Skip to content

Instantly share code, notes, and snippets.

View dexterous's full-sized avatar

Saager Mhatre dexterous

View GitHub Profile
require 'fileutils'
require 'active_support'
require 'commands/servers/base'
puts "=> Ctrl-C to shutdown listener"
tail_thread = tail(Pathname.new("#{File.expand_path(RAILS_ROOT)}/log/#{RAILS_ENV}.log").cleanpath)
trap(:INT) { exit }
require 'rubygems'
require 'rspec'
describe 'Int with scope' do
class Ooga
def initialize
@bar = 'woot'
end
@kaiwren
kaiwren / quote.txt
Created October 30, 2010 19:16
Managers, management, churches and religion.
The first myth of management is that it exists. Managers are to management as churches are to religion.
@kaiwren
kaiwren / js_route.js
Created January 31, 2011 15:50
js routes from ruby routes
FooNamespace.Routes = {
myResourcePath: function(){ return '<%= my_resource_path(:format => 'json') %>' }
}
@nutrun
nutrun / earl.rb
Created March 3, 2011 02:49
Ruby strings that do web things
# Earl: Strings that do web things
#
#
# Examples:
#
# text = "Blah blah http://tinyurl.com/4bnjzbu blah http://tinyurl.com/4tefu9f"
#
# text.urls # => ["http://tinyurl.com/4bnjzbu", "http://tinyurl.com/4tefu9f"]
#
# text.locations # => ["http://nutrun.com/weblog/2010/11/17/supercharged-ruby-console-output.html", "http://nutrun.com"]
@kaiwren
kaiwren / gist:957742
Created May 5, 2011 19:41
Quote from the Buddha

From http://everything2.com/title/nontheist

The Buddha is the first historically known nontheist. Most Buddhists are nontheist.

The Buddha was often asked whether God existed. Usually, he replied with a complete silence. Once, however, he told the story of the man shot by a poisoned arrow.

When the doctor came and wanted to pull the arrow out of the wound, the man grabbed the doctor's hand and asked:

"Before you start treating me, Doctor, tell me, who was it that shot me? Was he of warrior class or some other class? Was he tall or was he short? Was he young or was he old? Was he dark skinned or light skinned?"

@dexterous
dexterous / shit_error.js
Created July 29, 2011 11:16
The (ho|e)rror!
// if you're going to send back...
{
'status' : 'Failure',
'message' : 'Resource creation failed',
'errors' : ['Problems creating resource in the system']
}
// ... you might as well just save everyone the trouble and send back...
{ 'shit happened': true }
@Dierk
Dierk / KanbanDemo.groovy
Created September 13, 2011 19:32
Classic concurrent producer-consumer problem with using a kanban system to avoid buffer overflows when consumers are slow
import groovyx.gpars.dataflow.DataFlowQueue
import groovyx.gpars.dataflow.operator.DataFlowPoisson
import static groovyx.gpars.dataflow.DataFlow.operator
import java.util.concurrent.atomic.AtomicInteger
def upstream = new DataFlowQueue() // empty trays travel back upstream to the producer
def downstream = new DataFlowQueue() // trays with products travel to the consumer downstream
def prodWiring = [inputs: [upstream], outputs: [downstream], maxForks: 3 ] // maxForks is optional
def consWiring = [inputs: [downstream], outputs: [upstream], maxForks: 3 ] // maxForks is optional
@timyates
timyates / match.groovy
Created June 27, 2012 09:17
match/when implemented with Groovy's GEP-3
// No commas
def a = 'tim'
def nocom = match( a ) {
when 'dave' 'Hi Dave'
when 'tim' 'Hi Tim'
otherwise 'none of the above'
}
assert nocom == 'Hi Tim'
// Commas
dog.legs.walk! if dog.normal?
dog.hover_craft.hover! if dog.robot?