Skip to content

Instantly share code, notes, and snippets.

View presidentbeef's full-sized avatar

Justin Collins presidentbeef

View GitHub Profile
@presidentbeef
presidentbeef / rubychat.rb
Created January 6, 2011 08:02
Simple Ruby chat with GServer
require 'gserver'
class ChatServer < GServer
def initialize *args
super
#Keep a list for broadcasting messages
@chatters = []
#We'll need this for thread safety
#Have a site that is compromised somehow.
#Someone is able to upload malicious .htaccess files that
#redirect based on User Agent being Windows and a whole list
#of possible referers, including Google.com.
#
#This script periodically checks the site and then emails if it gets
#anything other than a 200
require 'net/smtp'
site = "example.com"
def dameraulevenshtein(seq1, seq2)
len1 = seq1.length
len2 = seq2.length
oneago = nil
row = (1..len2).to_a << 0
len1.times do |i|
twoago, oneago, row = oneago, row, Array.new(len2) {0} << (i + 1)
len2.times do |j|
cost = seq1[i] == seq2[j] ? 0 : 1
delcost = oneago[j] + 1
#A little Twitter thing to post random quotes from Edsger Dijkstra
require 'yaml'
require 'open-uri'
require 'twitter' #twitter4r gem
require 'hpricot'
class DijkstraQuote
class << self