Skip to content

Instantly share code, notes, and snippets.

Xavier Shay xaviershay

Block or report user

Report or block xaviershay

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
xaviershay / service_service.rb
Created Sep 16, 2012 — forked from tobias/service_service.rb
A TorqueBox service that consumes from a queue.
View service_service.rb
class ServiceService
def initialize(options)
@queue = '/queues/service_request' )
@running = true
def start() 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
View atomic.rb
module ActiveRecord
class Base
def atomic &block
transaction {
View 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:
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. '/*tree', :controller => 'pages', :action => 'show'
View gist:49265
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)\$ '
View gist:41148
// Original
(function($) {
$.stuff = function(bitoftext) {
$ = function() { console.log(bitoftext) };
$ = function() {
throw("Constructor not called!");
View fizzbuzz_midi.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'midiator'
# Upped the tempo, reveals new curiosities
midi =
View with.rb
# DRY temporary variables that require single use only, without assignment... seems
# useful for configuration files perhaps? urgh.
class Object
def with(object)
@reports = []
You can’t perform that action at this time.