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
#pragma mark - Original | |
- (NSURLSessionDataTask *)GET:(NSString *)URLString | |
parameters:(id)parameters | |
success:(void (^)(NSURLSessionDataTask *task, id responseObject))success | |
failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; | |
#pragma mark - Overrides | |
- (NSURLSessionDataTask *)GET:(NSString *)URLString |
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
require Rails.root.join('config/environments/production') | |
MyApp::Application.configure do | |
config.action_dispatch.tld_length = 2 # domain.com vs staging.domain.com | |
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
199.91.171.93 bb-m.rubygems.org | |
54.186.104.15 api.rubygems.org rubygems.org |
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 | |
BASE62_PRIMITIVES = { | |
"0" => 0, "1" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5, "6" => 6, "7" => 7, "8" => 8, "9" => 9, | |
"A" => 10, "B" => 11, "C" => 12, "D" => 13, "E" => 14, "F" => 15, "G" => 16, "H" => 17, "I" => 18, "J" => 19, | |
"K" => 20, "L" => 21, "M" => 22, "N" => 23, "O" => 24, "P" => 25, "Q" => 26, "R" => 27, "S" => 28, "T" => 29, | |
"U" => 30, "V" => 31, "W" => 32, "X" => 33, "Y" => 34, "Z" => 35, "a" => 36, "b" => 37, "c" => 38, "d" => 39, | |
"e" => 40, "f" => 41, "g" => 42, "h" => 43, "i" => 44, "j" => 45, "k" => 46, "l" => 47, "m" => 48, "n" => 49, | |
"o" => 50, "p" => 51, "q" => 52, "r" => 53, "s" => 54, "t" => 55, "u" => 56, "v" => 57, "w" => 58, "x" => 59, | |
"y" => 60, "z" => 61 | |
} |
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
require 'eventmachine' | |
require 'pp' | |
$stdout.sync = true | |
class KeyboardHandler < EM::Connection | |
include EM::Protocols::LineText2 | |
def post_init | |
print "> " |
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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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
require 'rubygems' | |
require 'eventmachine' | |
require 'evma_httpserver' | |
class HttpHandler < EM::Connection | |
include EM::HttpServer | |
@@listeners = [] | |
def process_http_request |
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
require 'rubygems' | |
require 'sinatra' | |
require 'em-http' | |
require 'json' | |
get '/tweets' do | |
content_type 'text/html', :charset => 'utf-8' | |
TWEETS.map {|tweet| "<p><b>#{tweet['user']['screen_name']}</b>: #{tweet['text']}</p>" }.join | |
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
class RingBuffer < Array | |
def initialize(size) | |
@max = size | |
super(0) | |
end | |
def push(object) | |
shift if size == @max | |
super | |
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
class RingBuffer < Array | |
def initialize(size) | |
@max = size | |
super(0) | |
end | |
def push(object) | |
shift if size == @max | |
super | |
end |