This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Arrays implicitly turn numbers to strings */ | |
var total = 4 | |
total += 5 | |
// total: 9 | |
total += [5] | |
// total: "95" | |
/* Arrays are numerically comparable */ | |
1 > 0 | |
// true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class C | |
attr_accessor :b | |
def foo | |
b ? b.foo : raise(NoMethodError.new) | |
end | |
alias gob foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## Taken from: http://snippets.dzone.com/posts/show/4935 | |
# | |
# Usage: | |
# a = AmazonS3Asset.new | |
# a.copy_over_bucket("myapp_production", "myapp_production") | |
require 'aws/s3' | |
require 'mechanize' | |
require 'logger' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var cloops = $(".rotating_cloop") | |
var shown = 0 | |
var length = cloops.length | |
setInterval(function(){ | |
shown++ | |
if(shown >= length) shown = 0 | |
$(cloops[shown-0]).hide(); | |
$(cloops[shown]).show() | |
}, 2000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
# Author: David Underhill | |
# Script to permanently delete files/folders from your git repository. To use | |
# it, cd to your repository's root and then run the script with a list of paths | |
# you want to delete, e.g., git-delete-history path1 path2 | |
# | |
# retrieved from: http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/ | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Forgetful.js is what I use on SSDs to prevent disk wear. | |
// Because each SSD sector can only be written a set # of times | |
// it's important not to write huge log files for no reason. | |
// So my test logs (and some others) are all outputted to this | |
// node.js instance which keeps track of the throughput | |
// in simply-named channels. | |
// | |
// To use this in, e.g., Rails, put this in environments/test.rb: | |
// | |
// class NamedChannelSocket < TCPSocket |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My record of provisioning a Solr server on EC2 (mostly mistakes): | |
# Take 2: | |
## AMI: ami-1515f67c (bare ubuntu) | |
sudo apt-get update | |
sudo apt-get install rubygems1.8 | |
sudo apt-get install git-core | |
git clone git://github.com/JackDanger/jackbash.git ./.bash | |
source ~/.bash/rc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
sudo apt-get update | |
sudo apt-get dist-upgrade | |
sudo apt-get install build-essential | |
sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.1 mysql-common mysql-server-5.1 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 libhtml-template-perl mysql-server-core-5.1 libmysqlclient16 libreadline5 psmisc | |
wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz | |
tar xvzf rubygems-1.3.5.tgz |