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
POST /sms/a8d9808243301811b94f4df3f911026d.sms HTTP/1.0 | |
Host: localhost:8765 | |
Connection: close | |
User-Agent: Java/1.5.0_22 | |
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2 | |
Content-type: application/x-www-form-urlencoded | |
Content-Length: 217 | |
CustomerNickname=CAST&ResponseType=NORMAL&Keyword=&Option=&Data=ping&Message=Cast%20ping&OriginatorAddress=17783212541&ServerAddress=32075&AcceptedTime=29Aug,10%2017:41:38&DeliveryType=SMS&Carrier=fido&NetworkType=gsm |
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
# What would you call it? | |
module Enumerable | |
# Do a map and select at the same time. Chuck Norris! | |
def chuck_norris(&block) | |
self.inject([]) do |collection, *args| | |
if result = block.call(*args) | |
collection.push result | |
end | |
collection | |
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
// How does it work? Hit it with /?username=bradgessler&size=reasonably_small | |
// and you get your URL (and redirect). Need more documentation? RTFSC. | |
var http = require('http'); | |
http.createServer(function(request, response){ | |
var query = require('url').parse(request.url, true).query; | |
if(!query || !query.username){ | |
response.writeHead(412, {'Content-Type': 'text/plain'}); |
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
def configuration_class(*keys) | |
Class.new do | |
attr_accessor *keys | |
def self.keys=(keys) | |
@keys = keys | |
end | |
def self.keys | |
@keys |
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 bash | |
# Bare minimum Gems that are needed to keep a Ruby development environment in sync. This assumes | |
# that you use bundler in your workflow to control the installation of all other gems. If you need | |
# to bump the bundler or rubygem version across your team, change that here, then run bundler and | |
# and keep going. | |
RVMRC=1.9.2@my_gem_set | |
RUBYGEM_VERSION="1.6.2" | |
BUNDLER_VERSION="1.0.15" |
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 'thin' | |
# curl "http://localhost:10001/?wait=5&status=500" | |
# --- | |
# wait - How many seconds should I wait before returning the status? | |
# status - HTTP return code | |
Thin::Server.start('127.0.0.1', 10001, Proc.new{|env| | |
req = Rack::Request.new(env) |
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 'fiber' | |
EM.run{ Fiber.new{}.resume } | |
__END__ | |
/Users/bgessler/Desktop/crash.rb:6: [BUG] Segmentation fault | |
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.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
curl -s http://en.wikipedia.org/wiki/Rocket | sed -n -e 's/.*<p>\(.*\)<\/p>.*/\1/p' | sed -e "s/<[^>]*>//g" | say |
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
A [common criticism](http://news.ycombinator.com/item?id=3737272) of building applications outside of Rails is the loss of a great, integrated tool chain. | |
> You don't pick Rails as the engine for powering your API simply for the asset pipeline, you pick it for all the other stuff @macaw pointed out! If you hook up Sinatra and Sprockets, you are without Rails' ORM, migrations, generators, routing, test infrastructure, plugin ecosystem, and arguably most importantly, the conventions and agility. | |
There is some truth to that, but it doesn't have to be that way. | |
I'm going to pick on ActiveRecord. The internet is [littered](http://community.active.com/blogs/productdev/2011/02/28/using-activerecord-3-without-rails) [with](http://exposinggotchas.blogspot.com/2011/02/activerecord-migrations-without-rails.html) [posts](https://github.com/thuss/standalone-migrations) about using ActiveRecord outside of Rails. Most solutions involve hacking together a Rake file that deals with this stuff. Its a pain. | |
Rails has alread |
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 'sprockets' | |
module Sprockets | |
module Forkin | |
class Manifest < ::Sprockets::Manifest | |
attr_reader :workers | |
# The last argument should be the number of workers | |
def initialize(environment, path, workers=1) | |
@workers = workers |