Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am zefer on github.
  • I am zefer (https://keybase.io/zefer) on keybase.
  • I have a public key whose fingerprint is F567 C5FD F4C4 6609 D9C6 D3D8 69F5 6243 1352 83C0

To claim this, I am signing this object:

@zefer
zefer / ie8_spoofer.js
Created September 18, 2013 16:10
A bit of a bodge way to test JS fallback behaviour on old browsers like IE8, using PhantomJS.
navigator.geolocation = undefined;
window.FormData = undefined;
window.getComputedStyle = undefined;
window.matchMedia = undefined;
window.FileReader = undefined;
window.Worker = undefined;
window.WebSocket = undefined;
window.requestAnimationFrame = undefined;
window.performance = undefined;
window.EventSource = undefined;
@zefer
zefer / vim_cheatsheet.md
Created April 10, 2012 09:26
My newbie Vim cheatsheet

Enter insert mode

i    insert before character under cursor
a    insert after cursor
I    insert at beginning of current line
A    insert at end of the line
o    starts insert mode in a new line below current one
O    insert in a new line above current one

Enter insert mode & replace

ciw ("change inner word") change word under cursor

@zefer
zefer / Skeleton Grid
Created November 2, 2011 10:03 — forked from dhg/Skeleton Grid
This is the Skeleton.gs grid example
<!-- The container is a centered 960px -->
<div class="container">
<!-- Give column value in word form (one, two..., twelve) -->
<div class="sixteen columns">
<h1>Full Width Column</h1>
</div>
<!-- Sweet nested columns cleared with a clearfix class -->
<div class="six columns clearfix">
require 'spec_helper'
describe OrdersController do
describe "GET express (/order/new/express)" do
context "with an empty basket" do
let(:current_basket) do
basket = mock(Basket, sub_total: 0.to_money)
controller.stub(:current_basket).and_return(basket)
@zefer
zefer / heroku_cedar_hirefire_patch.rb
Created July 14, 2011 15:28
Patch HireFire so worker auto-scaling works on the Beta Heroku Cedar stack
# hopefully a temporary patch so HireFire will run on the Heroku Cedar stack
# NB: the worker type is hard-coded as "worker" below, this must correlate to the type in Procfile
# NB: ENV['APP_NAME'] must be defined (e.g. 'heroku config:add APP_NAME=myherokuappname')
# using ps & ps_scale instead of info & set_workers
class HireFire::Environment::Heroku
private
def workers(amount = nil)
c = 'ffffff'
canvas_image = Magick::Image.new(w, h) {
self.background_color = c
}
@zefer
zefer / copy-s3-bucket.rb
Created April 4, 2011 11:24
Copy contents of an S3 bucket to a another bucket using an EC2 instance and a simple Ruby script. Useful for transferring large amounts of data and will work across geographic regions.
require 'rubygems'
require 'right_aws'
aws_access_key_id = 'your-access-key'
aws_secret_access_key = 'your-secret-key'
target_bucket = 'your-source-bucket'
destination_bucket = 'your-destination-bucket'
s3 = RightAws::S3Interface.new(aws_access_key_id, aws_secret_access_key)
@zefer
zefer / full_nginx_s3_proxy.conf
Created March 9, 2011 10:33
my full conf for allowing S3 CORS file uploads
# DO NOT RESPOND TO REQUESTS OTHER THAN upload.xxx.ly AND upload.xxx.com
server {
listen 80 default;
server_name _;
return 444;
}
# FILE UPLOADS
server {
listen 80;
@zefer
zefer / mongoid_money_usage.rb
Created February 23, 2011 14:46
Money represented with the Money gem, persistence using Mongoid
class Product
include Mongoid::Document
include Mongoid::Timestamps
field :description, :type => String
field :price_pence, :type => Integer, :default => 0
field :currency_iso, :type => String, :default => Money.default_currency.iso_code
validates_presence_of :description