Skip to content

Instantly share code, notes, and snippets.

View ecin's full-sized avatar
🐶
Woof!

ecin ecin

🐶
Woof!
View GitHub Profile
class Address
# :street, String
# :city, String
# :state, String
# :country, String
scope :local, lambda { |query| search_by_street_or_city(query, query) }
scope :national, lambda {|query| search_by_state_or_country(query, query) }
end
Running 683 tests...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................OK!
bin/mspec ci --background --agent
rubinius 2.0.0dev (1.8.7 68a5acb5 yyyy-mm-dd JI) [x86_64-apple-darwin10.8.0]
................................................................................................................................................................................................................
@ecin
ecin / lobster.rb
Created September 4, 2011 06:13
Using Rack apps in Goliath.
require 'goliath'
require 'rack/lobster'
class Lobster < Goliath::API
map '/' do
run Rack::Lobster.new
end
end
@ecin
ecin / github-pinboard-include.html
Created January 24, 2012 08:23
github-pinboard-include
<script src="http://copypastel.github.com/github-pinboard/lib/githubPinboard.js"></script>
@ecin
ecin / phantomjs_facebook.js
Created April 23, 2012 21:06
Log into Facebook with phantomJS
console.log("got here");
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.open("http://facebook.com", function(status) {
if ( status === "success" ) {
@ecin
ecin / timelog.txt
Created June 27, 2012 21:01
Organize by tasks taking most time
http://cl.ly/1L1H1s1T1b2Y2x3v2G41
@ecin
ecin / goarena.go
Created August 31, 2012 17:34
Dtrace probes in your Golang code
package main
/*
Ping vs Pong: A Gladiatorial Match
Two goroutines enter, only one leaves...
*/
/*
#cgo LDFLAGS: -lprobes -L/usr/local/lib
#include "probes.h"
@ecin
ecin / mapper.rb
Last active December 20, 2015 08:19
How to add a Rails routes helper (tightly-coupled version).
# config/initializers/extensions/action_dispatch/routing/mapper.rb
module ActionDispatch
module Routing
class Mapper
module Resources
alias_method :old_add_route, :add_route
def add_route(action, options)
if @scope[:throttle]
throttlers = @scope.delete(:throttle)
@ecin
ecin / ohash.rb
Created October 16, 2013 16:43
OStruct-like that raises raises error on non-existent keys.
class OHash < Hash
def initialize(key_values)
key_values.each { |key, value| self[key] = value }
end
def method_missing(key)
if self.has_key?(key)
return self[key]
else
raise NoMethodError
@ecin
ecin / post-commit
Created October 28, 2013 14:54
git post-commit signature
#!/bin/sh
#
# Sign the just-made commit with a globally configured GPG key.
git commit --amend --allow-empty --gpg-sign=`git config user.signingkey` --reuse-message=HEAD