confucius

A curl service for "Confucius say" quotes. Don't know why I made this. Curl confucius.alex.balgavy.eu at your own risk.
git clone git://git.alex.balgavy.eu/confucius.git
Log | Files | Refs | LICENSE

server.rb (3608B)


      1 require 'socket'
      2 require 'time'
      3 
      4 confucius = [
      5   "America Good Place to Put Chinese restaurant.",
      6   "Woman who puts detergent on top shelf, Jump for Joy.",
      7   "a girl's best asset is her 'lie'ability.",
      8   "american beer like sex on boat. Both fucking close to water.",
      9   "baby conceived on back seat of car with automatic transmission grow up to be shiftless bastard.",
     10   "baseball very funny game - man with 4 balls no can walk!",
     11   "boy who play with himself pulls boner.",
     12   "crowded elevator smells different to midget.",
     13   "even the greatest of whales is helpless in middle of desert.",
     14   "he who eats to many prunes, sits on toilet many moons.",
     15   "he who outruns the cheetah is fucking fast on his feet!",
     16   "he who pull out to fast leave rubber behind.",
     17   "he who refuses to listen is lying.",
     18   "he who sitteth on an upturned tack shall surely rise.",
     19   "he who sniffs Coke, drowns.",
     20   "he who stands in corner with hands in pocket doesn't feel crazy, feels nuts.",
     21   "it take square ass to shit a brick.",
     22   "lady who live in glass house, dress in basement!",
     23   "man who argue with wife all day get no peace at night.",
     24   "man who drop watch in toilet bound to have shitty time.",
     25   "man who eat jellybean fart in technicolor.",
     26   "man who fart in church sit in own pew.",
     27   "man who fishes in other man's well often catch crabs.",
     28   "man who fly plane upside down have crackup.",
     29   "man who go to bed with itchy butt wake with smelly finger.",
     30   "man who go to bed with sex on mind, wakes with solution in hand.",
     31   "man who have woman on ground have piece on earth.",
     32   "man who lay girl on hill not on level.",
     33   "man who lose key to apartment not get new key.",
     34   "man who marry girl with no bust has right to feel low down.",
     35   "man who put head on railroad track get splitting headache.",
     36   "man who run behind car get exhausted, man who run in front of car get tired.",
     37   "man who sneezes without hanky takes matters into his own hands.",
     38   "man who speaks with forked tongue should not kiss baloons.",
     39   "man who stand on toilet get high on pot.",
     40   "man who walk with head held high will not see dog poop on sidewalk.",
     41   "man who run through airport turnstile is going to Bangkok.",
     42   "man who wears tight pants is like cheap hotel, no ballroom.",
     43   "man with both feet firmly planted on ground has difficulty putting on pants.",
     44   "man with hole in pocket feel cocky all day.",
     45   "many nails to build a crib, one screw to fill it.",
     46   "secretary not permanent till screwed on desk.",
     47   "squirrel who runs up woman's leg not find nuts.",
     48   "support bacteria -- it's the only culture some people have!",
     49   "the hand that turneth the knob, opens the door.",
     50   "to make egg roll, push it.",
     51   "wash your face in the morning, neck at night.",
     52   "when lady say no, she mean maybe; when lady say maybe, she mean yes; when lady say yes, she no lady.",
     53   "woman who cooks carrots and pees in same pot very unsanitary.",
     54   "woman who dance while wearing jock strap have make believe ballroom.",
     55   "woman who not practise sex before marriage is sentenced to an indeterminate length.",
     56   "woman who ride bicycle in city pedal ass all over town."
     57 ]
     58 
     59 server = TCPServer.new('0.0.0.0', ENV["PORT"])
     60 
     61 loop do
     62   Thread.start (server.accept) do |socket|
     63     request = socket.gets
     64     STDERR.puts request
     65 
     66     response = "Confucius say, #{confucius.sample}\n"
     67     socket.print "HTTP/1.1 200 OK\r\n" +
     68       "Content-Type: text/plain\r\n" +
     69       "Content-Length: #{response.bytesize}\r\n" +
     70       "Connection: close\r\n"
     71       socket.print "\r\n"
     72 
     73       socket.print response
     74       socket.close
     75   end
     76 end