Skip to content

Instantly share code, notes, and snippets.

View jmileham's full-sized avatar

John Mileham jmileham

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jmileham on github.
  • I am jmileham (https://keybase.io/jmileham) on keybase.
  • I have a public key ASCRcZUF4rFbb0eb18iYtveFXV7ivmA3xqEJIojw2u3eYwo

To claim this, I am signing this object:

@jmileham
jmileham / gist:1647599
Created January 20, 2012 14:31
Backbone + Google Analytics for hash urls
// Inspired by Kendall Buchanan, (https://github.com/kendagriff)
// Rewritten for hash URLs by John Mileham
// MIT licence
// Version 0.0.1
(function() {
var originalLoadUrl = Backbone.History.prototype.loadUrl;
@jmileham
jmileham / gist:1590088
Created January 10, 2012 17:18
Paperclip :hash example
class MyModel < ActiveRecord::Base
has_attached_file :foo, hash_secret: "SomeSufficientlyRandomSecret", :path => ":hash.:extension"
end
@jmileham
jmileham / gist:1217668
Created September 14, 2011 20:21
Minimal GPG Paperclip processor
# You'll need to pregenerate a keyring with your pubkey in it and add to your repo.
# GPG does this automatically when you import keys to a non-existant keyring file.
module Paperclip
class Encrypt < Processor
def make
raise ArgumentError.new("no :encrypt_to address provided. (#{@options.inspect})") unless @options[:encrypt_to]
Tempfile.new(['attachment','.pgp']).tap do |outfile|
Paperclip.run('gpg', '--batch --always-trust --keyring :keyring --no-default-keyring -o :out -r :recipient -e :in', :in => @file.path, :out => outfile.path, :recipient => @options[:encrypt_to], :keyring => PATH_TO_MY_KEYRING)