Skip to content

Instantly share code, notes, and snippets.

View mattyoho's full-sized avatar

Matt Yoho mattyoho

  • San Francisco, CA, USA
View GitHub Profile
class Proc #:nodoc:
def bind(object)
block, time = self, Time.now
(class << object; self end).class_eval do
methodname = "bind#{time.to_i}_#{time.usec}"
definemethod(methodname, &block)
method = instancemethod(methodname)
removemethod(methodname)
method
end.bind(object)
# let's pretend we are not dealing with Rails, AR or even a DB
# controller
def index
@kids = Kid.fetch
end
# view
<ul>
<%- @kids.each do |kid| -%>
# solution provided by Eloy Duran
class API
def self.get(id)
new(with_response_data)
end
end
class APIWithIdentityMap < API
def self.map
# http://lbi.lostboys.nl/prikbord/ruby-on-rails-ldap-integration
class UserSession < Authlogic::Session::Base
verify_password_method :valid_ldap_credentials?
end
class User < ActiveRecord::Base
@mattyoho
mattyoho / .gitconfig
Created December 4, 2009 19:56 — forked from kneath/._what.md
[alias]
up = !sh -c 'git pull && git log --pretty=format:"%Cred%ae %Creset- %C(yellow)%s %Creset(%ar)" HEAD@{1}..'
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
#!/usr/bin/env ruby
puts "looking for the gems to upgrade..."
gem_info = Struct.new(:name, :version)
to_reinstall = []
Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path|
path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/
name, version = $1, $2
bundle_info = `file path`
to_reinstall << gem_info.new(name, version) unless bundle_info =~ /bundle x86_64/
end
# 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/
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production: