Skip to content

Instantly share code, notes, and snippets.

View jlindley's full-sized avatar

Jim Lindley jlindley

View GitHub Profile
if rails_env = ENV['RAILS_ENV']
rails_root = File.basename(Dir.pwd)
rails_env_string = case rails_env
when 'development'
'dev'
when 'production'
'prod'
else
rails_env
<html>
<head>
<script type="text/javascript">
function is_it_private(){
var is_private_element = document.getElementsByName("is_private")[0];
alert("Value is " + is_private_element.checked );
}
# has_many polymorphic, delays saving association until student is saved
june:dev> t = Tag.create
Tag Create (0.6ms) INSERT INTO "tags" ("updated_at", "created_at") VALUES('2009-06-12 18:45:29', '2009-06-12 18:45:29')
=> #<Tag id: 3, created_at: "2009-06-12 18:45:29", updated_at: "2009-06-12 18:45:29">
june:dev> s = Student.new
=> #<Student id: nil, created_at: nil, updated_at: nil>
june:dev> s.tags << t
june:dev> t = Tag.new
=> #<Tag id: nil, created_at: nil, updated_at: nil>
june:dev> s = Student.new
=> #<Student id: nil, created_at: nil, updated_at: nil>
june:dev> s.tags << t
=> [#<Tag id: nil, created_at: nil, updated_at: nil>]
june:dev> s.save
# needed to get spork/rspec running under snow leopard
# edit line 12 of rspec-1.2.8/lib/spec/runner/drb_command_line.rb
# was
# DRb.start_service("druby://localhost:0")
# should be
DRb.start_service("druby://127.0.0.1:0")
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA53HXZDjHthh1CGh6uk7ymy0C0AFTSUYu1QviKvolZF0UAGlmjiljuQMXIqXI9IR/kAFbO2Dl8vsbB1NLmD1YAsRb7WcSh4RaADpo20UStyS3vURFnozMB/1NX/7Lf7pFXve/dD5pLXzlGIjSfI+PeEyqB9Hrv89CKkHILCDKQNc7kljhzw4y8yJWtaTUUPYxGuNVz3LLY77IepiubJEfofae2djg71nl1khglUF0V60z/CwnWS8M/0DD9oMEHX+UosQzVX21UYKs4Ur7OQn+ebwS/zvl/ETARpl8EHWeevtd9/Qi1kJygrJb2HWd8jtHrfdqUw73T1fFVQqepBglMQ== jlindley@Monkey.local
Knock knock.
Who's there?
.
.
.
.
.
.
.
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA53HXZDjHthh1CGh6uk7ymy0C0AFTSUYu1QviKvolZF0UAGlmjiljuQMXIqXI9IR/kAFbO2Dl8vsbB1NLmD1YAsRb7WcSh4RaADpo20UStyS3vURFnozMB/1NX/7Lf7pFXve/dD5pLXzlGIjSfI+PeEyqB9Hrv89CKkHILCDKQNc7kljhzw4y8yJWtaTUUPYxGuNVz3LLY77IepiubJEfofae2djg71nl1khglUF0V60z/CwnWS8M/0DD9oMEHX+UosQzVX21UYKs4Ur7OQn+ebwS/zvl/ETARpl8EHWeevtd9/Qi1kJygrJb2HWd8jtHrfdqUw73T1fFVQqepBglMQ== jlindley@Monkey.local
#!/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'
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(",")]}
}