• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 01:16
CEST 07:16
KST 14:16
  • 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
Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12[ASL20] Ro24 Preview Pt2: Take-Off7[ASL20] Ro24 Preview Pt1: Runway13
Community News
SC4ALL $6,000 Open LAN in Philadelphia7Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues25LiuLi Cup - September 2025 Tournaments3Weekly Cups (August 25-31): Clem's Last Straw?39Weekly Cups (Aug 18-24): herO dethrones MaxPax6
StarCraft 2
General
Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues #1: Maru - Greatest Players of All Time Team Liquid Map Contest #21 - Presented by Monster Energy Classic Games #3: Rogue vs Serral at BlizzCon What happened to Singapore/Brazil servers?
Tourneys
Maestros of The Game—$20k event w/ live finals in Paris RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament SC4ALL $6,000 Open LAN in Philadelphia LANified! 37: Groundswell, BYOC LAN, Nov 28-30 2025
Strategy
Custom Maps
External Content
Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around Mutation # 487 Think Fast
Brood War
General
Pros React To: SoulKey's 5-Peat Challenge ASL20 General Discussion BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ BSL Team Wars - Bonyth, Dewalt, Hawk & Sziky teams
Tourneys
[ASL20] Ro16 Group A [ASL20] Ro16 Group B [Megathread] Daily Proleagues SC4ALL $1,500 Open Bracket LAN
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Borderlands 3 Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile General RTS Discussion Thread
Dota 2
LiquidDota to reintegrate into TL.net Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine The Games Industry And ATVI UK Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
The Personality of a Spender…
TrAiDoS
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1253 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)17727 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
Next event in 4h 45m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
NeuroSwarm 156
StarCraft: Brood War
sSak 45
Noble 23
Icarus 9
League of Legends
JimRising 617
Counter-Strike
Stewie2K293
Super Smash Bros
hungrybox905
Other Games
summit1g7704
WinterStarcraft472
ViBE235
XaKoH 148
Nina77
Organizations
Other Games
BasetradeTV34
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• Berry_CruncH317
• practicex 37
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• Scarra1851
Upcoming Events
RSL Revival
4h 45m
Maestros of the Game
11h 45m
BSL Team Wars
13h 45m
Afreeca Starleague
1d 4h
Snow vs Sharp
Jaedong vs Mini
Wardi Open
1d 5h
Sparkling Tuna Cup
2 days
Afreeca Starleague
2 days
Light vs Speed
Larva vs Soma
LiuLi Cup
3 days
The PondCast
4 days
Korean StarCraft League
5 days
[ Show More ]
[BSL 2025] Weekly
6 days
BSL Team Wars
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
SEL Season 2 Championship
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
RSL Revival: Season 2
Maestros of the Game
Chzzk MurlocKing SC1 vs SC2 Cup #2
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
FISSURE Playground #1

Upcoming

2025 Chongqing Offline CUP
BSL Polish World Championship 2025
IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
SC4ALL: StarCraft II
EC S1
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
MESA Nomadic Masters Fall
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
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.