This file contains 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
library(RJSONIO) | |
cStdin <- file('stdin') | |
open(cStdin) | |
readMessage <- function() { | |
message <- c() | |
while(length(line <- readLines(cStdin, n = 1)) > 0) { | |
if(line == "end") { break } | |
message <- c(message, line) |
This file contains 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
<!doctype html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
</head> |
This file contains 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
class String | |
def method_missing(*args) | |
if args.first.to_s.match(/omnom/) | |
noms = args.first.to_s.scan(/nom/).length | |
self[0..-(noms+1)] | |
else | |
super | |
end | |
end | |
end |
This file contains 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
mov esi, 1000 | |
mov eax, 0 | |
loop: | |
cmp eax, esi | |
je end | |
mov ebx, eax | |
mod ebx, 3 | |
rem ebx | |
cmp ebx, 0 |
This file contains 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
mysql = MysqlStore.new | |
person_mapper = mysql.generate_table_mapping("person") do | |
map :first_name | |
map :last_name | |
map :dob, :dob_to_s_db | |
end | |
a = Person.new | |
a.first_name = "Ryan" | |
a.last_name = "Briones" |
This file contains 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
class ConvertsNumberAlphaID | |
ALPHAS = %w( a b c d e f | |
g h i j k l | |
m n o p q r | |
s t u v w x | |
y z 0 1 2 3 | |
4 5 6 7 8 9 | |
A B C D E F | |
G H I J K L | |
M N O P Q R |
This file contains 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
class Tower | |
attr_reader :name | |
def initialize(name) | |
@name = name | |
@disks = [] | |
end | |
def stack(disk_number) | |
raise "Disk too big" unless can_stack?(disk_number) |
This file contains 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
class Foo | |
def deadline_string=(deadline_string) | |
self.deadline = (parse_string(deadline_string, Chronic) || parse_string(deadline_string, Time)) | |
@deadline_invalid = true unless self.deadline | |
end | |
private | |
def parse_string(string, parser) | |
begin | |
parser.parse(string) |
This file contains 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
#!/usr/bin/env ruby | |
# From: https://github.com/ryanbriones/cgiup/blob/master/bin/cgiup | |
require 'webrick' | |
unless ARGV[0] | |
STDERR.puts "usage: cgiup [PATH TO CGI SCRIPT]" | |
exit 1 | |
end | |
cgi_script = File.expand_path(ARGV[0]) |
This file contains 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
#!/usr/bin/env ruby | |
require "rubygems" | |
require "eventmachine" | |
class PubSubServer < EM::Connection | |
attr_accessor :channels | |
SubscriberChannel = EM::Channel.new | |