Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en-US' xml:lang='en-US' xmlns='http://www.w3.org/1999/xhtml'>
<head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
<title>Urban Dictionary, March 9: SMTA</title>
<script type='text/javascript'>
//<![CDATA[
var MobileDetector={redirect:function(b,a){if(b&&b.match(/(iPhone|iPod|Android|webOS|Opera Mini|PlayStation Portable)/)){this.go(a)}},go:function(a){window.location=a}};
MobileDetector.redirect(navigator.userAgent, "http://m.urbandictionary.com/");
//]]>
</script>
@apeckham
apeckham / gist:2484155
Created April 24, 2012 21:54
heroku console; puts `cat /home/heroku_rack/lib/static_assets.rb`
module Heroku
class StaticAssetsMiddleware
def initialize(app)
@app = app
end
def call(env)
# call returns an array containing [response code, header, Rack::Response]
reply = @app.call(env)
@apeckham
apeckham / groupme.rb
Created May 29, 2012 21:56
groupme fetch image urls
require 'httparty'
require 'ap'
$url = ARGV.shift
$cookie = ARGV.shift
raise unless $url && $cookie
class Client
include HTTParty
@apeckham
apeckham / gist:2844037
Created May 31, 2012 15:10
hash the contents of the public directory, inspired by http://grosser.it/2010/01/12/checksum-for-a-whole-folder-in-ruby/
def self.commit_hash
@commit_hash ||= begin
files = Dir["public/**/*"].select { |f| File.file?(f) }.sort
contents = files.map { |f| File.read(f) }.join
hash = Digest::MD5.hexdigest(contents)[0..6]
"rel-#{hash}"
end
end
@apeckham
apeckham / gist:2886678
Created June 7, 2012 04:57
run Handbrake on a batch of files, listed as arguments
#!/bin/sh -e
for i in "$@"; do
HandBrakeCLI -i "$i" -o "${i%.*}-ipad.mp4" --preset="iPad"
done
require 'spork'
Spork.prefork do
ENV['RAILS_ENV'] = ENV['RACK_ENV'] = 'test'
ENV['SPHINX_ON'] = 'true'
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'spec/autorun'
require 'spec/rails'
require 'webrat/integrations/rspec-rails'
@apeckham
apeckham / gist:2913906
Created June 12, 2012 01:49
use rbenv to install 1.9.3 from mirrorservice when ruby-lang is down
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz"
install_package "ruby-1.9.3-p194" "http://www.mirrorservice.org/sites/ftp.ruby-lang.org/pub/ruby/ruby-1.9.3-p194.tar.gz"
require 'queue_classic'
module CloudApp
Queue = QC::Queue
FailedQueue = QC::Queue.new 'queue_classic_failed_jobs'
class Worker < QC::Worker
def handle_failure(job, exception)
FailedQueue.enqueue job
@apeckham
apeckham / gist:2917943
Created June 12, 2012 14:43
block all contacts in Adium
tell application "Adium"
repeat with c in every contact
set blocked of c to true
end repeat
end tell
@apeckham
apeckham / gist:2918620
Last active October 6, 2015 02:18
list all addons for all heroku apps
for app in `heroku apps | awk '{ print $1 }'`; do heroku addons --app $app; done