Skip to content

Instantly share code, notes, and snippets.

View trak3r's full-sized avatar

Thomas "Teflon Ted" Davis trak3r

View GitHub Profile
# 1) Point *.example.com in your DNS setup to your server.
#
# 2) Setup an Apache vhost to catch the star pointer:
#
# <VirtualHost *:80>
# ServerName *.example.com
# </VirtualHost>
#
# 3) Set the current account from the subdomain
class ApplicationController < ActionController::Base
# from: http://pivotallabs.com/users/alex/blog/articles/865-monkey-patch-du-jour
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
def log_info(sql, name, ms)
if @logger && @logger.debug?
@logger.debug("#{sql}, #{name}, #{ms}")
c = caller.detect{|line| line !~ /(activerecord|active_support|__DELEGATION__|\/lib\/|\/vendor\/plugins|\/vendor\/gems)/i}
c.gsub!("#{File.expand_path(File.dirname(RAILS_ROOT))}/", '') if defined?(RAILS_ROOT)
name = '%s (%.1fms) %s' % [name || 'SQL', ms, c]
=== Epic Snow Leopard Upgrayyyyd Guide ===
Son, you’re now living in the land of 64-bit systems.
That means that some of your 32-bit shit is now broken.
Not all is lost.
== Fixing MySQL weirdness
tell application "Terminal"
activate
do script with command "cd ~/my/development/directory"
do script with command "cd ~/my/development/directory; mate ."
do script with command "cd ~/my/development/directory; script/server"
do script with command "cd ~/my/development/directory; script/console"
do script with command "cd ~/my/development/directory; autotest"
end tell
namespace :prune do
desc "Delete all unnecessary files from vendored Rails"
task :rails do
require 'fileutils'
list = Dir.glob("vendor/rails/*/test")
FileUtils.rm_rf list, :verbose => true unless list.empty?
end
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Switch to 1.9.1 and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.1@rails3
@trak3r
trak3r / gist:647643
Created October 26, 2010 19:54 — forked from bryanl/gist:647174
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
@trak3r
trak3r / git-merge-into
Created May 16, 2011 15:31 — forked from anonymous/git-merge-into
Merge the current branch into another branch without (manually) switching
#!/usr/bin/env ruby
# Merges the current branch into the specified branch after checking out that branch.
# Usage:
# git merge-into [branch]
# [branch] defaults to "master" if not specified
# "sprint" is my convenience library for handling external processes.
@trak3r
trak3r / descriptive_sql_load_log.rb
Created July 19, 2011 20:53 — forked from JackDanger/descriptive_sql_load_log.rb
Let Rails display file names and line numbers for log activity.
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
protected
# Turn:
# User Load (6.3ms) SELECT * FROM "users"
# Into:
# User Load /app/views/_partial.erb:27 (6.3ms) in `_app_views_partial_erb` SELECT * FROM "users"
@trak3r
trak3r / filters_view.js.coffee
Created March 5, 2012 17:23 — forked from kwhitaker/filters_view.js.coffee
Trying to scope back to currentView
class window.PlacementFiltersView extends Backbone.View
el: "#placements form#filters"
initialize: ->
currentView = @
# Create a hash of labels for the filter type-aheads
@filterLabels = []
jQuery(@el).find('.filter-top-level option').each ->
if jQuery(@).val() isnt ''