Skip to content

Instantly share code, notes, and snippets.

View jlindley's full-sized avatar

Jim Lindley jlindley

View GitHub Profile
@jlindley
jlindley / reserved_names.txt
Created January 8, 2011 06:06
Black list for account names or subdomains. Check for pluralized version of each, too, to be safe.
about
account
action
activity
add
admin
administration
affiliate
api
app
@jlindley
jlindley / pre-commit
Created November 11, 2010 22:50 — forked from jhsu/pre-commit
pre-commit hook for git, prevents console.log() statements
#!/bin/sh
# Don't allow console.log() statements to be committed.
#
# Add to .git/hooks/pre-commit
#
# Note: jquery.js seems to always include 1 reference
# in a debugging section, that one can be safely
# ignored. 1 reference to console.log is cool
# Easily inspect any list of objects in logger.
# Provided as a hack to the standard ruby (or Rails) logger:
#
# Example Code:
#
# # in some_file.rb
# chicken = :fred
# all_the_birds = [chicken, :roadrunner]
# my_logger.inspector(chicken, all_the_birds) # outputs to log:
#
Do you think it is a good idea to do downcase and a == or is there a better way?
def nbde_new_evaluation_result(nbde_evaluation)
letter = nbde_evaluation.part1_test_result.downcase
if letter == "p"
"Pass"
elsif letter == "f"
"Fail"
else
"Unknown"
jlindley@hypatia:~$ rvm -v
rvm 0.1.32 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
jlindley@hypatia:~$ rvm install rbx
Installing pre-requisites
Extracting rubinius-1.0.0-20100514.tar.gz ...
mv: rename /Users/jlindley/.rvm/src/rubinius-1.0.0 to /Users/jlindley/.rvm/src/rbx-1.0.0-20100514/rubinius-1.0.0: Directory not empty
Configuring rbx
Compiling rbx
# new branches appropriately merge from the starting point branch
git config --global branch.autosetupmerge true
# pull from origin and merge by default
git config --global branch.master.remote origin
git config --global branch.master.merge refs/heads/master
module Kernel
def other
o = []
ObjectSpace.each_object{|obj| o << obj unless (o==self)}
o
end
end
class Teapot
jlindley@hypatia:~/Projects/AMS/site_assign[master]$ st
# On branch master
nothing to commit (working directory clean)
jlindley@hypatia:~/Projects/AMS/site_assign[master]$ mate .
jlindley@hypatia:~/Projects/AMS/site_assign[master]$
jlindley@hypatia:~/Projects/AMS/site_assign[master*]$ st
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
named_scope :multiple_per_zip, lambda{
zip_counts = Site.count(
:all, :group => 'addresses.zip', :joins => :addresses
)
multi_site_zip_counts = zip_counts.reject{|k,v| v < 2}
just_zips = multi_site_zip_counts.map{|pair| pair[0]}.compact
{:conditions => ['addresses.zip in (?)', just_zips.join(",")]}
}
#!/bin/bash
cd /var/apps/buffarumble/current
export RAILS_ENV=production
/usr/bin/ruby -r'config/environment.rb' \
-e 'puts RAILS_ENV' \
-e 'puts "Events undelivered before: #{Event.undelivered.count}"' \
-e 'Event.undelivered.map(&:dispatch!)' \
-e 'puts "Events undelivered after: #{Event.undelivered.count}";0'