• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 06:55
CEST 12:55
KST 19:55
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
TL.net Map Contest #21: Voting3[ASL20] Ro4 Preview: Descent6Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Weekly Cups (Oct 6-12): Four star herO65.0.15 Patch Balance Hotfix (2025-10-8)68Weekly Cups (Sept 29-Oct 5): MaxPax triples up3PartinG joins SteamerZone, returns to SC2 competition325.0.15 Balance Patch Notes (Live version)119
StarCraft 2
General
The New Patch Killed Mech! 5.0.15 Patch Balance Hotfix (2025-10-8) TL.net Map Contest #21: Voting Weekly Cups (Oct 6-12): Four star herO PartinG joins SteamerZone, returns to SC2 competition
Tourneys
Tenacious Turtle Tussle WardiTV Mondays SC2's Safe House 2 - October 18 & 19 Sparkling Tuna Cup - Weekly Open Tournament RSL Offline Finals Dates + Ticket Sales!
Strategy
Custom Maps
External Content
Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers Mutation # 492 Get Out More
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Brood War web app to calculate unit interactions BSL Season 21 Whose hotkey signature is this? Any rep analyzer that shows resources situation?
Tourneys
[ASL20] Semifinal B [ASL20] Semifinal A [Megathread] Daily Proleagues [ASL20] Ro8 Day 4
Strategy
Current Meta BW - ajfirecracker Strategy & Training Siegecraft - a new perspective TvZ Theorycraft - Improving on State of the Art
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread ZeroSpace Megathread Dawn of War IV Path of Exile
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
SPIRED by.ASL Mafia {211640} TL Mafia Community Thread
Community
General
Russo-Ukrainian War Thread Men's Fashion Thread Things Aren’t Peaceful in Palestine Sex and weight loss US Politics Mega-thread
Fan Clubs
The herO Fan Club! The Happy Fan Club!
Media & Entertainment
Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023 NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
Inbreeding: Why Do We Do It…
Peanutsc
From Tilt to Ragequit:The Ps…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1330 users

#TODO: Find suitable ransom to nego new end points

Blogs > Chef
Post a Reply
1 2 Next All
Chef
Profile Blog Joined August 2005
10810 Posts
Last Edited: 2015-11-24 01:33:55
November 22 2015 23:04 GMT
#1

## blogjwa.rb

require_relative '../secrets.rb'
require 'shitpost'
require 'net/https'
require 'uri'
require 'json'

USER = 'Chef'
PASS = TL_PASS
TL_POST_URL = 'https://www.teamliquid.net'
TL_POST_PATH = '/post'

def deliver_garbage(content)

uri = URI.parse(TL_POST_URL)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
data = "content=#{content}&user=#{USER}&pass=#{PASS}"
headers = {'Content-Type'=> 'application/x-www-form-urlencoded'}
JSON.parse http.post(TL_POST_PATH, data, headers)
end

content = ShitPost.generate('poop')

puts deliver_garbage(content).inspect

## blogjudge.rb

require 'nokogiri'
require_relative '../list_of_users_i_like.rb'

XML_DOC_URL = 'http://www.teamliquid.net/GetLatestUserBlogReplies?User=Chef'

def silently_judge_replies(replies)

def judgement(name)
ARRAY_OF_USERS_I_LIKE.include?(name) ? 5 : (1 + rand(5))
end

judgements = {}

replies.each_with_index do |r, i|
judgements[r['name']] ||= []
judgements[r['name']] << { i => judgement(r['name']) }
end

judgements
end

def return_replies_hash
doc = Nokogiri::XML(open(XML_DOC_URL))
Hash.from_xml(doc.xpath('//replies').to_s)
end

replies = return_replies_hash
judgements = silently_judge_replies(replies)

puts judgements.inspect

## crontab

0 0 * * 0 /usr/local/rvm/gems/ruby-2.0.0-p353@tl/wrappers/ruby /home/dev/tl/scripts/blogjwa.rb > /home/dev/cron-debug.txt 2>&1
0 * * * * /usr/local/rvm/gems/ruby-2.0.0-p353@tl/wrappers/ruby /home/dev/tl/scripts/blogjudge.rb > /home/dev/cron-debug.txt 2>&1


***
LEGEND!! LEGEND!!
Zealously
Profile Blog Joined October 2011
East Gorteau22261 Posts
Last Edited: 2015-11-22 23:56:11
November 22 2015 23:55 GMT
#2
I don't know what this is so I will do the very internet thing, assume it's clever/funny and 5/5
AdministratorBreak the chains
LightTemplar
Profile Blog Joined August 2011
Ireland481 Posts
November 23 2015 00:13 GMT
#3
Consider your assumption silently judged then.
"Thoughts are always there, the mind can't stop" - Grubby
Zealously
Profile Blog Joined October 2011
East Gorteau22261 Posts
November 23 2015 00:22 GMT
#4
On November 23 2015 09:13 LightTemplar wrote:
Consider your assumption silently judged then.


It's ok I'm a writer all I do is have my thoughts judged anyway
AdministratorBreak the chains
Ilikestarcraft
Profile Blog Joined November 2004
Korea (South)17731 Posts
November 23 2015 00:41 GMT
#5
This is what happens to an English major who becomes a programmer
"Nana is a goddess. Or at very least, Nana is my goddess." - KazeHydra
Chef
Profile Blog Joined August 2005
10810 Posts
November 23 2015 01:04 GMT
#6
The real horror is that I've edited this 3 times realising there are bugs in my fake code.

2.1.3 :005 > ary = ['Zealously', 'LightTemplar', 'Zealously', 'Ilikestarcraft']
=> ["Zealously", "LightTemplar", "Zealously", "Ilikestarcraft"]
2.1.3 :006 > def judgement(ary); ary.each {|n| puts "#{n} #{(1 + rand(5))}" } end
=> :judgement
2.1.3 :007 > judgement ary
Zealously 4
LightTemplar 4
Zealously 3
Ilikestarcraft 2

Harsh. Luckily the real program accounts for ils and makes him a 5
LEGEND!! LEGEND!!
iSometric
Profile Blog Joined February 2011
2221 Posts
November 23 2015 02:23 GMT
#7
System.out.println("5/5")
strava.com/athletes/zhaodynasty
patrick321
Profile Joined August 2004
United States185 Posts
November 23 2015 03:04 GMT
#8
stars ||= 5

This made me stop for a couple minutes and see if i could break it.
c3rberUs
Profile Blog Joined December 2010
Japan11286 Posts
November 23 2015 05:56 GMT
#9
comments = [ 'This is Ruby right? First time seeing Ruby code', 'The syntax looks close to Python', 'Anyway 5/5 until I can actually read Ruby']

for comment in comments:
printf comment
WriterMovie, 진영화 : "StarCraft will never die".
mantequilla
Profile Blog Joined June 2012
Turkey779 Posts
November 23 2015 09:11 GMT
#10
Sure it will throw a nullpointerexception.
Age of Mythology forever!
boxerfred
Profile Blog Joined December 2012
Germany8360 Posts
November 23 2015 12:20 GMT
#11
public void learnRuby(){
// todo
}
YourGoodFriend
Profile Blog Joined June 2010
United States2197 Posts
November 23 2015 14:46 GMT
#12
Is your handle in reference to Chef?

Also obligatory ewww ruby {{My language}} is so much better.
anonymous is the most famous author that anyone can be
amazingxkcd
Profile Blog Joined September 2010
GRAND OLD AMERICA16375 Posts
November 23 2015 15:23 GMT
#13
why are you requiring nokogiri ? should only need the "passion" directive
The world is burning and you rather be on this terrible website discussing video games and your shallow feelings
Danglars
Profile Blog Joined August 2010
United States12133 Posts
November 23 2015 21:57 GMT
#14
Haha the silent judge and people I like bits. haha
Great armies come from happy zealots, and happy zealots come from California!
TL+ Member
Fecalfeast
Profile Joined January 2010
Canada11355 Posts
November 23 2015 23:33 GMT
#15
##Feast.rb

require 'shitpost'

def chew()
# Find something to eat
food = ShitPost.generate('poop')
# Break food down into an array of separate words spitting out any punctuation or spaces
food.split(/\W+/).map(&:to_s)
swallow(food)
end

def swallow(food)
stomach = []
churn = false
#digest words into letters
for chunks in food
if churn == false
churn = true
else
churn = false
chunks.split(//)
# jumble letters into stomach array
for mush in chunks
if churn == true
stomach.unshift(mush)
else
stomach << mush
end
end
vomit(stomach)
end

def vomit(stomach)
#regurgitate contents of stomach until empty
for bile in stomach
puts bile
end
puts "I feel much better now"
end

chew()


I only really know python so I googled a lot of things for this but unless I misunderstand what the module shitpost does I think this would work
ModeratorINFLATE YOUR POST COUNT; PLAY TL MAFIA
Chef
Profile Blog Joined August 2005
10810 Posts
Last Edited: 2015-11-24 01:34:52
November 24 2015 01:28 GMT
#16
I think the chew method can be improved by not including the swallow call. What happens when you want to write code where the shit post is immediately regurgitated to feed your young? Also the swallow method is not in scope, so it won't work. Chew should really take the argument food, not generate the food.

As a personal preference, I dislike comments which are not explaining an unusual piece of code that would make another programmer wonder why you did it a specific way. The method containing the code should generally be enough to tell you what it does.
LEGEND!! LEGEND!!
Fecalfeast
Profile Joined January 2010
Canada11355 Posts
November 24 2015 02:15 GMT
#17
I was writing the comments to explain to me what I wanted to program to do. I lack organization and writing things down before I can articulate them in code keeps me on track.

What does 'in scope' mean? I'm fairly green at programming and just make tools that I can't find with a simple google search.

Are you saying it would be better to have a separate method for finding food, then feed that variable through chew's parameter brackets?
ModeratorINFLATE YOUR POST COUNT; PLAY TL MAFIA
patrick321
Profile Joined August 2004
United States185 Posts
November 24 2015 02:36 GMT
#18
The OP's post was clever but fecalfeast's was art. The form perfectly embellished the content. And his topical name was the cherry on top of the cow pie.

Critiquing his code here is like stopping a singer to correct his lyrics.
Chef
Profile Blog Joined August 2005
10810 Posts
November 24 2015 14:31 GMT
#19
On November 24 2015 11:15 Fecalfeast wrote:
I was writing the comments to explain to me what I wanted to program to do. I lack organization and writing things down before I can articulate them in code keeps me on track.

What does 'in scope' mean? I'm fairly green at programming and just make tools that I can't find with a simple google search.

Are you saying it would be better to have a separate method for finding food, then feed that variable through chew's parameter brackets?

Sure, it's not problem. I like to write methods I wish existed when thinking about the top level logic of my code, and then write the methods.

My bad about the scope, your methods are all in the global scope so they are accessible to one another.

ex

2.1.3 :001 > def bear; puts 'bear'; end
=> :bear
2.1.3 :002 > def kuma; puts bear; end
=> :kuma
2.1.3 :003 > kuma
bear

In larger applications, you have to throw things into classes and modules, so that you can avoid naming collisions by polluting the global scope (you can google javascript global scope for a typical explanation).

If for example you had defined method A within method B, you wouldn't be able to access method A outside method B. Similarly, if you define methods within a class, you can access them anywhere within the class, but outside the class you have to call Class.method (or if you have an instance of the class, instance.method).

I'm just saying your method chew does not describe accurately enough what it does, which is find food and digest it and vomit it out. So when someone calls chew they will get the unexpected result of vomit. Really your method would be accurately called find_food_eat_it_and_vomit_it_out which is a method that seems to have a lot of responsibilities. If I wrote such a method, it would have calls to three other methods, find_food eat_food (which has chew_food and swallow_food methods) vomit_food. This way the code is more reusable, the stack trace will be easier to read, and if you need to update one of them, all your methods that use them will be updates simultaneously, instead of you having to update the same code in multiple places.

Even if all you use code for is one off scripts for yourself, it might help you to build a library of methods you often need to use (which you could do a very simple require to have accessible in all your scripts, saving you some copy / pasting). Naming those methods logically will help you to remember without referencing them.
LEGEND!! LEGEND!!
endy
Profile Blog Joined May 2009
Switzerland8970 Posts
November 24 2015 23:20 GMT
#20
After a hard day at work, coding, I open at TL, then "yes a Chef blog"... meh
...

Chef, how about an "Allow me to analyze your code writing" ;-)



ॐ
1 2 Next All
Please log in or register to reply.
Live Events Refresh
Afreeca Starleague
10:00
Ro4 Match 2
Soma vs Bisu
Afreeca ASL 15903
sctven
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 201
SortOf 140
ProTech80
Rex 40
StarCraft: Brood War
Calm 8440
Sea 6022
Rain 4200
Flash 4155
Jaedong 2896
BeSt 1741
Horang2 817
Mini 797
Pusan 537
EffOrt 521
[ Show more ]
actioN 396
Larva 356
Stork 325
ZerO 296
Hyun 250
firebathero 218
Barracks 190
Light 157
PianO 104
hero 76
ToSsGirL 69
JYJ41
Backho 38
Rush 36
Aegong 35
Sharp 31
NotJumperer 28
yabsab 25
Bale 24
JulyZerg 14
Terrorterran 13
Hm[arnc] 12
Sacsri 12
ajuk12(nOOB) 11
HiyA 9
soO 9
Noble 7
SilentControl 7
Dota 2
XaKoH 305
XcaliburYe248
League of Legends
JimRising 650
Counter-Strike
olofmeister1766
shoxiejesuss685
x6flipin295
Other Games
summit1g7056
ceh9500
Pyrionflax300
crisheroes251
DeMusliM122
B2W.Neo117
Fuzer 40
Organizations
Counter-Strike
PGL4225
Other Games
gamesdonequick933
StarCraft: Brood War
UltimateBattle 293
StarCraft 2
WardiTV27
StarCraft: Brood War
lovetv 8
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 14 non-featured ]
StarCraft 2
• LUISG 30
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift2453
• Jankos2185
• Lourlo703
Upcoming Events
OSC
3h 5m
OSC
7h 5m
MaxPax vs Gerald
Solar vs Krystianer
PAPI vs Lemon
Ryung vs Moja
Nice vs NightPhoenix
Cham vs TBD
MaNa vs TriGGeR
PiGosaur Monday
13h 5m
OSC
1d 12h
The PondCast
1d 23h
OSC
2 days
Wardi Open
3 days
CranKy Ducklings
3 days
Safe House 2
4 days
Sparkling Tuna Cup
4 days
[ Show More ]
Safe House 2
5 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.