This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'gserver' | |
| class ChatServer < GServer | |
| def initialize *args | |
| super | |
| #Keep a list for broadcasting messages | |
| @chatters = [] | |
| #We'll need this for thread safety |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
NewerOlder