• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:56
CEST 14:56
KST 21:56
  • 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
RSL Season 1 - Final Week6[ASL19] Finals Recap: Standing Tall12HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0
Community News
Firefly given lifetime ban by ESIC following match-fixing investigation17$25,000 Streamerzone StarCraft Pro Series announced7Weekly Cups (June 30 - July 6): Classic Doubles7[BSL20] Non-Korean Championship 4x BSL + 4x China10Flash Announces Hiatus From ASL81
StarCraft 2
General
The GOAT ranking of GOAT rankings RSL Revival patreon money discussion thread Weekly Cups (June 30 - July 6): Classic Doubles Server Blocker RSL Season 1 - Final Week
Tourneys
RSL: Revival, a new crowdfunded tournament series Sparkling Tuna Cup - Weekly Open Tournament FEL Cracov 2025 (July 27) - $8000 live event $5,100+ SEL Season 2 Championship (SC: Evo) $25,000 Streamerzone StarCraft Pro Series announced
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
External Content
Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome Mutation # 478 Instant Karma
Brood War
General
Flash Announces Hiatus From ASL [ASL19] Finals Recap: Standing Tall BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion A cwal.gg Extension - Easily keep track of anyone
Tourneys
[Megathread] Daily Proleagues 2025 ACS Season 2 Qualifier Small VOD Thread 2.0 Last Minute Live-Report Thread Resource!
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile CCLP - Command & Conquer League Project The PlayStation 5 Nintendo Switch Thread
Dota 2
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 Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine The Accidental Video Game Porn Archive Stop Killing Games - European Citizens Initiative
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023 NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Men Take Risks, Women Win Ga…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 751 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)17726 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 2h 5m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Hui .210
Rex 106
MindelVK 38
StarCraft: Brood War
Horang2 37845
BeSt 956
firebathero 673
Mini 506
EffOrt 401
Larva 363
Last 220
Leta 210
ToSsGirL 110
Dewaltoss 84
[ Show more ]
GoRush 40
Sharp 33
Barracks 31
Shinee 27
yabsab 23
Movie 18
Hm[arnc] 16
IntoTheRainbow 14
SilentControl 9
Noble 8
Hyuk 0
Dota 2
Gorgc7712
qojqva1285
XcaliburYe337
Counter-Strike
x6flipin543
edward56
Heroes of the Storm
Khaldor347
Other Games
tarik_tv33448
gofns18796
FrodaN5649
B2W.Neo2132
singsing2025
DeMusliM601
crisheroes480
shahzam464
Happy406
XaKoH 333
KnowMe187
SortOf158
Pyrionflax123
Organizations
StarCraft 2
CranKy Ducklings334
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• StrangeGG 40
• Legendk 11
• Adnapsc2 9
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• Ler81
League of Legends
• Nemesis3860
Upcoming Events
FEL
2h 5m
Elazer vs Spirit
Gerald vs MaNa
BSL20 Non-Korean Champi…
5h 5m
Bonyth vs Dewalt
QiaoGege vs Dewalt
Hawk vs Bonyth
Sziky vs Fengzi
Mihu vs Zhanhun
QiaoGege vs Zhanhun
Fengzi vs Mihu
Wardi Open
22h 5m
Replay Cast
1d 21h
WardiTV European League
2 days
PiGosaur Monday
2 days
uThermal 2v2 Circuit
3 days
Replay Cast
3 days
The PondCast
3 days
Replay Cast
4 days
[ Show More ]
Epic.LAN
4 days
CranKy Ducklings
5 days
Epic.LAN
5 days
BSL20 Non-Korean Champi…
6 days
Bonyth vs Sziky
Dewalt vs Hawk
Hawk vs QiaoGege
Sziky vs Dewalt
Mihu vs Bonyth
Zhanhun vs QiaoGege
QiaoGege vs Fengzi
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

KCM Race Survival 2025 Season 2
HSC XXVII
NC Random Cup

Ongoing

JPL Season 2
BSL 2v2 Season 3
Acropolis #3
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
2025 ACS Season 2: Qualifier
BSL20 Non-Korean Championship
CSLPRO Last Chance 2025
Championship of Russia 2025
RSL Revival: Season 1
Murky Cup #2
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters

Upcoming

CSL Xiamen Invitational
CSL Xiamen Invitational: ShowMatche
2025 ACS Season 2
CSLPRO Chat StarLAN 3
BSL Season 21
K-Championship
uThermal 2v2 Main Event
SEL Season 2 Championship
FEL Cracov 2025
Esports World Cup 2025
Underdog Cup #2
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
FISSURE Playground #1
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.