Skip to content

Instantly share code, notes, and snippets.

@xaviershay
xaviershay / service_service.rb
Created September 16, 2012 04:36 — forked from tobias/service_service.rb
A TorqueBox service that consumes from a queue.
class ServiceService
def initialize(options)
@queue = TorqueBox::Messaging::Queue.new( '/queues/service_request' )
@running = true
end
def start()
Thread.new do
while @running

Moral questions for veganism

Hypothetically, you are a vegan with an iPhone.

Your choice to become a vegan was because you determined it to be morally correct.

Your moral evaluation is based primarily on two considerations

  • That factory farming is harming the environment
  • That treating animals inhumanely is, well, inhumane
module ActiveRecord
class Base
def atomic &block
transaction {
lock!
yield
}
end
end
end
@xaviershay
xaviershay / page.rb
Created February 16, 2009 00:17 — forked from chrislloyd/page.rb
Refactor this code: URL Matching Edition
--
So I have Pages, in a nested set so that each page has parent. That allows me to have urls like:
/foo/bar
where the Page with permalink 'foo' has a child with the permalink 'bar'. In my routes.rb I have a general catch-all route as my last route.
map.page '/*tree', :controller => 'pages', :action => 'show'
function parse_git_dirty {
git diff --quiet || echo " *"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
export PS1='\w $(parse_git_branch)\$ '
// Original
(function($) {
$.stuff = function(bitoftext) {
$.stuff.report = function() { console.log(bitoftext) };
}
$.stuff.report = function() {
throw("Constructor not called!");
}
#!/usr/bin/env ruby
require 'rubygems'
require 'midiator'
# Upped the tempo, reveals new curiosities
midi = MIDIator::Interface.new
midi.use("dls_synth")
#midi.autodetect_driver
# DRY temporary variables that require single use only, without assignment... seems
# useful for configuration files perhaps? urgh.
class Object
def with(object)
yield(object)
end
end
@reports = []