• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 02:10
CEST 08:10
KST 15:10
  • 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
Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN3The Memories We Share - Facing the Final(?) GSL30Code S RO12 Preview: Cure, Zoun, Solar, Creator4[ASL19] Finals Preview: Daunting Task30[ASL19] Ro4 Recap : The Peak15
Community News
Code S RO12 Results + RO8 Groups (2025 Season 2)3Weekly Cups (May 19-25): Hindsight is 20/20?0DreamHack Dallas 2025 - Official Replay Pack8[BSL20] RO20 Group Stage2EWC 2025 Regional Qualifiers (May 28-June 1)34
StarCraft 2
General
The Memories We Share - Facing the Final(?) GSL Code S RO12 Results + RO8 Groups (2025 Season 2) CN community: Firefly accused of suspicious activities Maru & Rogue GSL RO12 interviews: "I think the pressure really got to [trigger]" Karma, Domino Effect, and how it relates to SC2.
Tourneys
EWC 2025 Regional Qualifiers (May 28-June 1) RSL: Revival, a new crowdfunded tournament series DreamHack Dallas 2025 Last Chance Qualifiers for OlimoLeague 2024 Winter [GSL 2025] Code S:Season 2 - RO12 - Group B
Strategy
Simple Questions Simple Answers [G] PvT Cheese: 13 Gate Proxy Robo
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 475 Hard Target Mutation # 474 Futile Resistance Mutation # 473 Cold is the Void Mutation # 472 Dead Heat
Brood War
General
Will foreigners ever be able to challenge Koreans? BGH auto balance -> http://bghmmr.eu/ Battle.net is not working BW General Discussion Which player typ excels at which race or match up?
Tourneys
[ASL19] Grand Finals [BSL 2v2] ProLeague Season 3 - Friday 21:00 CET [BSL20] RO20 Group D - Sunday 20:00 CET [BSL20] RO20 Group B - Saturday 20:00 CET
Strategy
[G] How to get started on ladder as a new Z player I am doing this better than progamers do.
Other Games
General Games
Monster Hunter Wilds Path of Exile Nintendo Switch Thread Beyond All Reason Battle Aces/David Kim RTS Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
LiquidLegends to reintegrate into TL.net
Heroes of the Storm
Simple Questions, Simple Answers
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia TL Mafia Community Thread TL Mafia Plays: Diplomacy TL Mafia: Generative Agents Showdown Survivor II: The Amazon
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread All you football fans (soccer)! European Politico-economics QA Mega-thread
Fan Clubs
Serral Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion!
Sports
2024 - 2025 Football Thread Formula 1 Discussion NHL Playoffs 2024 NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Cleaning My Mechanical Keyboard How to clean a TTe Thermaltake keyboard?
TL Community
The Automated Ban List TL.net Ten Commandments
Blogs
I was completely wrong ab…
jameswatts
Need Your Help/Advice
Glider
Trip to the Zoo
micronesia
Yes Sir! How Commanding Impr…
TrAiDoS
Poker
Nebuchad
Info SLEgma_12
SLEgma_12
SECOND COMMING
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 12959 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
Turkey777 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
Online Event
04:00
May Mayhem: Playoffs
Clem vs ShoWTimE
herO vs MaxPax
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 282
StarCraft: Brood War
Sea 5860
actioN 657
PianO 377
Mind 48
soO 35
Icarus 23
Aegong 19
sSak 13
Noble 11
Bale 3
League of Legends
JimRising 804
Counter-Strike
tarik_tv9120
Stewie2K1517
Heroes of the Storm
Khaldor201
Other Games
summit1g8308
WinterStarcraft602
ViBE289
RuFF_SC293
Organizations
Other Games
gamesdonequick759
StarCraft: Brood War
CasterMuse 12
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• practicex 56
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 27
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Stunt656
• HappyZerGling86
Upcoming Events
Road to EWC
2h 51m
AllThingsProtoss
4h 51m
Road to EWC
9h 51m
BSL Season 20
11h 51m
Bonyth vs Doodle
Bonyth vs izu
Bonyth vs MadiNho
Bonyth vs TerrOr
MadiNho vs TerrOr
Doodle vs izu
Doodle vs MadiNho
Doodle vs TerrOr
Replay Cast
1d 17h
Replay Cast
2 days
Bellum Gens Elite
3 days
The PondCast
4 days
Bellum Gens Elite
4 days
Replay Cast
4 days
[ Show More ]
Bellum Gens Elite
5 days
Replay Cast
5 days
CranKy Ducklings
6 days
SC Evo League
6 days
Bellum Gens Elite
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2025-05-28
DreamHack Dallas 2025
Calamity Stars S2

Ongoing

JPL Season 2
BSL 2v2 Season 3
BSL Season 20
KCM Race Survival 2025 Season 2
NPSL S3
Rose Open S1
CSL Season 17: Qualifier 1
2025 GSL S2
Heroes 10 EU
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
ECL Season 49: Europe
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025
PGL Bucharest 2025
BLAST Open Spring 2025

Upcoming

CSL Season 17: Qualifier 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
CSLPRO Last Chance 2025
CSLAN 2025
K-Championship
SEL Season 2 Championship
Esports World Cup 2025
HSC XXVII
Championship of Russia 2025
Bellum Gens Elite Stara Zagora 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 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.