Skip to content

Instantly share code, notes, and snippets.

@bascht
Created December 24, 2014 15:35
Show Gist options
  • Select an option

  • Save bascht/e182d12b77cc34a2a0d9 to your computer and use it in GitHub Desktop.

Select an option

Save bascht/e182d12b77cc34a2a0d9 to your computer and use it in GitHub Desktop.
Xmas Song
require 'socket'
begin
PAYLOAD=open("xmas.txt").read
SONG=open('silent.txt').read
rescue Exception => e
puts "Burp: #{e}"
exit(-1)
end
server = TCPServer.open(2300)
loop do
Thread.start(server.accept) do |client|
client.puts(PAYLOAD)
SONG.each_line do |line|
client.puts line
sleep 3
end
client.puts "This christmas message was brought to you by Ruby #{RUBY_VERSION}. Bye!"
client.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment