Skip to content

Instantly share code, notes, and snippets.

View mattetti's full-sized avatar

Matt Aimonetti mattetti

View GitHub Profile
$ thor merb:gem:redeploy
Installing abstract-1.0.0
Installing cgi_multipart_eof_fix-2.5.0
Installing couchrest-0.30
Installing daemons-1.0.10
Installing erubis-2.6.3
Installing extlib-0.9.10
Installing fail-fast-1.0.0
Installing fastthread-1.0.1
Building native extensions. This could take a while...
require 'rest_client'
require 'json'
###################
# CONF #
###################
# The smallest amount of changed documents before the views are updated
MIN_NUM_OF_CHANGED_DOCS = 10
@mattetti
mattetti / gist:259716
Created December 18, 2009 19:48 — forked from alloy/gist:225050
# Install kicker on osx: sudo gem install kicker --source http://gemcutter.org
#
# Place a `.kick' file with this code in the root of your project, which contains the file to watch.
# Then start running kicker from the project root: $ kicker
module Mockup
FILE_TO_WATCH = 'mockup-1.psd'
def self.last_exported_version
FileUtils.mkdir_p 'output'
xml.root do
xml.foo do
xml.bar
end
end
@mattetti
mattetti / install_homebrew.rb
Created May 18, 2010 02:09 — forked from mxcl/install_homebrew.markdown
Ruby 1.9 compatible version
#!/usr/bin/ruby
#
# Download and execute this script in one-line with no temporary files:
#
# ruby -e "$(curl http://gist.github.com/raw/323731/install_homebrew.rb)"
#
#
# I deliberately didn't DRY /usr/local references into a variable as this
# script will not "just work" if you change the destination directory. However
# please feel free to fork it and make that possible.
@mattetti
mattetti / connection_fix.rb
Created May 22, 2010 00:52 — forked from defunkt/connection_fix.rb
limit the amount of retries to 5
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
# expires_at '21:30', :public => true, :private => false
# will set max-age to the amount of seconds between now and tomorrow at 9:30PM
module ExpiresAt
def self.included(base)
base.send(:include, InstanceMethods)
end
module InstanceMethods
#!/usr/bin/env ruby
require 'benchmark'
require 'rubygems'
gem 'therubyracer'
gem 'haml'
gem 'tilt'
require 'v8'
require 'haml'
require 'pp'
require 'tweetstream'
require "hiredis"
require "redis/connection/hiredis"
require 'redis'
# Just so I can run without your rails stack
unless $redis
$redis = Redis.new(:host => "127.0.0.1", :port => 6379)
ruby-1.9.2-p290 :009 > r = Record.where(:e => "x")
Record Load (42.8ms) SELECT "records".* FROM "records" WHERE "records"."e" = 'x'
=> []
ruby-1.9.2-p290 :010 > r.class
=> ActiveRecord::Relation
ruby-1.9.2-p290 :011 > r.where(:c => "y")
Record Load (41.3ms) SELECT "records".* FROM "records" WHERE "records"."e" = 'x' AND "records"."c" = 'y'
=> []
ruby-1.9.2-p290 :012 >