Skip to content

Instantly share code, notes, and snippets.

View chrisroos's full-sized avatar

Chris Roos chrisroos

View GitHub Profile
@chrisroos
chrisroos / 000_remove_index_from_mongo_collection.rb
Created February 9, 2011 13:46
Playing around with removing mongo indexes in standard active record migrations.
class RemoveIndexFromMongoCollection < ActiveRecord::Migration
def self.up
remove_mongo_index 'my_collection', 'my_index'
end
def self.down
# Intentionally blank
end
@chrisroos
chrisroos / redcloth-4.2.6-test.md
Created February 11, 2011 12:54
Steps to test/fix RedCloth 4.2.6 on Mac OS X

Intro

RedCloth 4.2.6 is broken on Mac OS X. It appears to be related to the case sensitive require fix. These steps expose and fix the problem on my machine.

Software versions

$ ruby -v
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.3.0], MBARI 0x6770, Ruby Enterprise Edition 2010.01

$ gem -v
@chrisroos
chrisroos / redcloth-4.2.6-test.md
Created February 11, 2011 15:19
Explanation of what I believe the problem to be with RedCloth 4.2.6 on Mac OS X

Create a temporary directory for us to work in

$ cd ~
$ mkdir tmp-redcloth
$ cd tmp-redcloth

Install RedCloth 4.2.6

Use bundler to install RedCloth 4.2.6 into our temporary directory.

@chrisroos
chrisroos / migration.rb
Created February 14, 2011 13:20
A test of whether the ActiveRecord ruby schema format supports bigints
# Create a table in a migration, testing both :integer with a limit of 8, and a :bigint
create_table :people, :force => true do |t|
t.column :col_1, :integer, :limit => 8
t.column :col_2, :bigint
t.column :col_3, :integer
end
@chrisroos
chrisroos / time_zone_test.rb
Created March 28, 2011 10:33
A test that attempts to ensure we don't run into problems with daylight savings
require 'test_helper'
class TimeZoneTest < ActiveSupport::TestCase
should "only use instances of TimeWithZone, not instances of Time" do
directories = Dir.glob(File.join(Rails.root, '**', '*.rb'))
matching_files = directories.select do |filename|
match = false
File.open(filename) do |file|
match = file.grep(%r{Time\.(now|utc)}).any?
@chrisroos
chrisroos / time_zone_test.rb
Created March 28, 2011 10:33
A test that attempts to ensure we don't run into problems with daylight savings. Credit for the test goes to James Mead.
require 'test_helper'
class TimeZoneTest < ActiveSupport::TestCase
should "only use instances of TimeWithZone, not instances of Time" do
directories = Dir.glob(File.join(Rails.root, '**', '*.rb'))
matching_files = directories.select do |filename|
match = false
File.open(filename) do |file|
match = file.grep(%r{Time\.(now|utc)}).any?
@chrisroos
chrisroos / asterisk-homebrew-install.txt
Created April 2, 2011 09:13
The output of using Homebrew to install Asterisk. This version of Asterisk fails to start when including any modules.
Chris-Rooss-MacBook-Pro-2:local chrisroos$ brew install -v asterisk
==> Downloading http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.1.6.tar.gz
File already downloaded and cached to /Users/chrisroos/Library/Caches/Homebrew
/usr/bin/tar xf /Users/chrisroos/Library/Caches/Homebrew/asterisk-1.6.1.6.tar.gz
==> Downloading patches
==> Patching
/usr/bin/patch -f -p1 -i 001-homebrew.diff
patching file sounds/Makefile
==> ./configure --prefix=/usr/local/Cellar/asterisk/1.6.1.6 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc --host=x86_64-darwin
./configure --prefix=/usr/local/Cellar/asterisk/1.6.1.6 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc --host=x86_64-darwin
@chrisroos
chrisroos / asterisk-homebrew-interactive-install.txt
Created April 2, 2011 09:14
The output of using Homebrew interactive mode to install Asterisk. This version of Asterisk starts correctly even when including modules.
Chris-Rooss-MacBook-Pro-2:~ chrisroos$ brew install --interactive asterisk
==> Downloading http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.1.6.tar.gz
File already downloaded and cached to /Users/chrisroos/Library/Caches/Homebrew
==> Downloading patches
==> Patching
patching file sounds/Makefile
==> Entering interactive mode
Type `exit' to return and finalize the installation
Install to this prefix: /usr/local/Cellar/asterisk/1.6.1.6
bash-3.2$ ./configure --prefix=/Users/chrisroos/wem-asterisk-homebrew --host=x86_64-darwin
@chrisroos
chrisroos / git-compare-upstream.rb
Created April 21, 2011 16:15
This attempts to show useful differences between two repos (probably your fork and the upstream original)
#!/usr/bin/env ruby
# This attempts to show useful differences between an upstream repo and your local copy.
# The motivation is that I want to be able to see differences between my forks of other github repos.
unless upstream_repo = ARGV.shift
puts "Usage: #{File.basename(__FILE__)} upstream-repo"
exit 1
end
@chrisroos
chrisroos / antisocial.js
Created May 25, 2011 13:35
Javascript snippet to unfollow all twitter followers
$('.unfollow-button').each(function() { $(this).trigger('click'); });