Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jmcnevin on github.
  • I am jmcnevin (https://keybase.io/jmcnevin) on keybase.
  • I have a public key whose fingerprint is 2CD5 69CB 63AD E51C 3C3C F994 F0A7 AC2E 3E88 5C06

To claim this, I am signing this object:

use actors::Race::*;
pub enum Race {
Human,
Robot,
Dog,
Wolf,
Bear
}
@jmcnevin
jmcnevin / main.cf
Created March 13, 2010 08:43
Adds VERP support to NET::SMPT
# Add this line to your postfix main.cf file to add VERP support.
smtpd_authorized_verp_clients = $mynetworks
@jmcnevin
jmcnevin / s3_bucket_copy.rb
Created March 19, 2010 18:49
Will duplicate contents of one Amazon S3 bucket into another.
require 'rubygems'
require 'aws/s3'
require 'logger'
AWS::S3::S3Object.class_eval do
def self.copy_across_buckets(src_bucket, src_key, dest_bucket, dest_key, options = {})
src_bucket = bucket_name(src_bucket)
dest_bucket = bucket_name(dest_bucket)
source_key = path!(src_bucket, src_key)
@jmcnevin
jmcnevin / sort_movies.rb
Created January 30, 2011 22:14
Sorts a collection of files into folders based on the show name. I use this for TV episodes.
#!/usr/bin/env ruby -wKU
require 'fileutils'
TV_DIR = File.expand_path("~/Movies/TV")
EP_PATTERN = /^([a-z\.]+)\.((?:S[\d]+E[\d]+)|(?:[\dx\.]+))\..+\.(?:avi|mkv|mp4|mpg|mpeg)$/i
files = Dir[File.join(TV_DIR,'*')]
files.each do |f|
<html>
<head>
<style>
div {
border: 1px solid black;
margin-right: 10px;
padding: 10px;
}
#col1,#col2 {
float: left;
[default] [Thu, 15 Sep 2011 18:06:01 +0200] INFO: Processing execute[extract-jruby] action nothing (jruby::default line 16)
: stdout
[default] [Thu, 15 Sep 2011 18:06:01 +0200] INFO: Processing remote_file[/tmp/jruby-bin-1.6.4.tar.gz] action create (jruby::default line 24)
: stdout
[default] [Thu, 15 Sep 2011 18:06:57 +0200] INFO: Chef Run complete in 57.277101 seconds
: stdout
[default] [Thu, 15 Sep 2011 18:06:57 +0200] INFO: Running report handlers
: stdout
[default] [Thu, 15 Sep 2011 18:06:57 +0200] INFO: Report handlers complete
: stdout
@jmcnevin
jmcnevin / gist:2558928
Created April 30, 2012 14:48
Installing REE with RVM, Homebrew, XCode 4.3+ on OS X Lion
# Rather than going nuclear and downgrading Xcode or using some other big GCC installer,
# this worked for me...
# From https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
# Path may vary slightly...
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
# If you've attempted to install REE previously and it failed...
@jmcnevin
jmcnevin / gist:2781931
Created May 24, 2012 14:36
Worker class that will mark all methods as TorqueBox backgroundable
# In a worker class, all defined public methods will be marked to run in the
# background
class Worker
include TorqueBox::Messaging::Backgroundable
def self.method_added(method_name)
return if method_name.to_s =~ /^__a?sync/ # avoid infinite loop
return unless public_method_defined?(method_name)
always_background method_name
end
@jmcnevin
jmcnevin / gist:3018328
Created June 29, 2012 14:42
Bootstrap Ubuntu 12.04 LTS
knife bootstrap IP_ADDRESS -N NODE_NAME -d ubuntu12.04-gems