Skip to content

Instantly share code, notes, and snippets.

View jerodsanto's full-sized avatar
:shipit:
Always be shipping

Jerod Santo jerodsanto

:shipit:
Always be shipping
View GitHub Profile
- f.semantic_fields_for :contributions, obj, :child_index => i do |child_form|
= child_form.input :person_id, :collection => Person.all.collect { |p| [p.name, p.id]}, :include_blank => false, :label => 'Contributor Name'
= child_form.input :name, :label => 'Type'
@jerodsanto
jerodsanto / error.txt
Created December 10, 2010 18:27
this works in Rails 2, but not in Rails 3.
NoMethodError: undefined method `_run_before_destroy_callbacks'
Pledgee.where(:email_me => true).each do |pledgee|
if [1.week, 3.weeks, 6.weeks].include? pledgee.days_since_pledge
PledgeeMailer.reminder_email(pledgee).deliver
end
end
<?php
foreach ($images as $index => $image) {
if ($index % 3 == 0) {
echo "<div class='yox_row'>";
}
echo "<div class='yox_cell'>";
echo get_resource_link($image);
echo "</div>";
def online_users(since = 5)
sessions = ActiveRecord::SessionStore::Session.where("updated_at >= ?", since.minutes.ago)
user_ids = sessions.all.map { |session| session.data["user_id"] }
User.where(:id => user_ids)
end
@jerodsanto
jerodsanto / gist:1137337
Created August 10, 2011 16:31
Bookmarklet to uncripple Kindle Cloud Reader
(function() {
function uncrippleFrame() {
var body = this.contentWindow.document.getElementsByTagName('body')[0];
this.contentWindow.onclick = null;
body._frame = this;
body.onmousemove = function() {
this._frame.contentWindow.onclick = null;
this.setAttribute('style', '-webkit-user-select: auto;');
@jerodsanto
jerodsanto / set_wallpaper.rb
Created September 20, 2011 15:11
MacRuby script to set wallpaper on all connected monitors
#!/usr/bin/env macruby
abort "Usage: #{__FILE__} [image]" if ARGV.empty?
framework "Cocoa"
wallpaper_path = File.expand_path(ARGV.first)
wallpaper_url = NSURL.fileURLWithPath(wallpaper_path, isDirectory: false)
workspace = NSWorkspace.sharedWorkspace
@jerodsanto
jerodsanto / ios5_notify.sh
Created October 12, 2011 13:50
Siri, tell me when iOS 5 is available. Nothing? Fine. Bash, you do it.
#!/bin/bash
while :
do
echo "Checking for iOS 5: `date`"
result=`curl -s -L http://phobos.apple.com/version | grep Restore | grep iPhone | grep 5.0`
if [ -z "$result" ]; then
echo "Nothing yet..."
else
say "I O S 5 IS NOW AVAILABLE. GO GET YOUR DOWNLOAD ON, KID"
fi
module UniqueId
def self.included(base)
raise StandardError, "model must have 'uuid'" unless base.columns.any? { |c| c.name == 'uuid' }
base.before_create do
self.uuid = UUID.generate unless uuid.present?
end
end
end
@jerodsanto
jerodsanto / gist:1472671
Created December 13, 2011 16:00
Printing the $PATH with each entry on a separate line
# using ruby:
$ echo $PATH | ruby -e 'STDIN.read.split(":").each { |l| puts l }'
$ echo $PATH | ruby -e 'print STDIN.read.gsub(":", "\n")'
# Using sed: I would expect this to work, but it does not
$ echo $PATH | sed 's/:/\n/g'