Skip to content

Instantly share code, notes, and snippets.

View ckdake's full-sized avatar

Chris Kelly ckdake

View GitHub Profile
# Unfortunately the Rails 2 version of DJ doesn't support before/after hooks. This hacks those in
# Stick this in an initalizer, and then any before(job) and after(job) methods in your Job classes will get called
module Delayed
module Backend
module ActiveRecord
class Job < ::ActiveRecord::Base
def invoke_job
payload_object.before(self) if payload_object.respond_to?('before')
payload_object.perform
@ckdake
ckdake / s3_size.rake
Created June 6, 2011 15:50
rake task to show size of all files in a s3 account
require 'fog'
desc "Tell us how much space is in use on S3"
namespace :s3 do
task usage: :environment do
size = 0
connection = Fog::Storage.new(
provider: 'AWS',
aws_access_key_id: ENV['aws_access_key_id'],
@ckdake
ckdake / Velocity 2011 Notes.textile
Created June 17, 2011 17:52
Velocity 2011 Notes

Velocity 2011

Tuesday

OpenStack workshop – Ron Pedde (Rackspace Hosting), Todd Willey (OpenStack), Matt Ray (Opscode)

@ckdake
ckdake / gist:1035814
Created June 20, 2011 15:22
make find_or_create_by methods work right with validations
# This and the next method are unfortunately 'magic'
# They set default paramaters for these two find_or_create_by_ method_missing methods
def self.find_or_create_by_email(params)
params = { email: params } unless params.is_a?(Hash)
super(params.reverse_merge(
password: Digest::MD5.hexdigest("#{rand(1024)}Time.now"),
username: Digest::MD5.hexdigest("#{rand(1024)}Time.now")
))
end
test "getters/setters for shipping methods should work" do
listing = Factory.create(:listing)
assert !listing.shipping_methods.include?('CATBUS')
assert !listing.ship_via_catbus
listing.ship_via_catbus = true
assert listing.ship_via_catbus
assert listing.shipping_methods.include?('CATBUS')
listing.ship_via_catbus = false
assert !listing.ship_via_catbus
end
@ckdake
ckdake / Procfile
Created October 14, 2011 19:47
Scaling Search
web: bundle exec rails server thin -p $PORT
worker: bundle exec rake jobs:work
memcached: bundle exec memcached -m 64
solr: bundle exec rake sunspot:solr:run
@ckdake
ckdake / Gemfile
Created November 3, 2011 18:38
Rails 3.1 Assets on S3 with HTTPS
gem 'fog' # Storage on S3 for carrierwave
gem 'rmagick' # Resizes images and makes thumbnails
gem 'carrierwave' # Image attachments, newer version doesn't work with local files preview hack
gem 'asset_sync' # Syncs assets to S3
@ckdake
ckdake / csv2map.py
Created April 24, 2012 13:53
Google Earth KML to a heathamp
import heatmap # http://jjguy.com/heatmap/
import random
import csv
if __name__ == "__main__":
pts = []
for point in csv.reader(open('coords.csv')):
pts.append((float(point[0]), float(point[1])))
print "Processing %d points..." % len(pts)
@ckdake
ckdake / nerdiestthingsofalltime.csv
Last active August 29, 2015 13:56
Top 10 Nerdiest Things Of All Time list from a handful of people at Big Nerd Ranch
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 10 columns, instead of 7 in line 6.
Dwarf Fortress,Dwarf Fortress,Dwarf Fortress,Dwarf Fortress,Dwarf Fortress,Dwarf Fortress,Tabletop RPGs,Dwarf Fortress,Dwarf Fortress,Dwarf Fortress
Pokemon,Star Wars,Ardiuno,Eclipse,Xcode,Android,Nerd Ranches,Bill Gates,Steve Balmer,Aaron Hillegass
Nethack,Dungeons and Dragons,MUDs,LARPing,Calculator watches,Comics,CCGs,MMORPGs,Lightning bolt! Lightning bolt!,There are only 10 types of people...
Nerdiest Things Of All Time Surverys,LARP,Dungeons and Dragons,Coding for Commodore 64,Programming your own TI-82 Games,Cosplay,John Carmack,Steve Wosniak,Misfired High Five,Short sleeved plaid shirts
Magic,Astronomy,Mathematics,Physics,Science Fiction,Electronics,Computers,Programming,Philosophy,Woodworking
Singh's Mac OS X Internals book,Fountain pens,Molecular gastronomy,Indo-European poetics,Derridean post-structuralism,New Hacker's Dictionary / The Jargon File,Hacker's Delight,Napier's bones,Proust,Medieval alchemical manuscripts
LARPing,Whirlyball Bachelor Parties,FaerieCon,Reenactments,Code Golf,Pale Skin,Coll
<?php
$config = array(
'db_host' => 'localhost',
'db_user' => 'root',
'db_pass' => '',
'system_name' => `hostname`,
'send_mail' => TRUE, // TRUE to send e-mails, FALSE to operate silently
'mail_to' => 'root@localhost', // comma-separated list of e-mail addresses