Skip to content

Instantly share code, notes, and snippets.

View benzittlau's full-sized avatar

Ben Zittlau benzittlau

View GitHub Profile
@benzittlau
benzittlau / gist:1230582
Created September 20, 2011 22:15
Various Delayed Job snippets
# List delayed jobs
ruby-1.9.2-p180 :002 > Delayed::Job.all.to_a
# Generate delayed job mongoid indexes
rails runner 'Delayed::Backend::Mongoid::Job.create_indexes'
# Work off the delayed job queue
Delayed::Worker.new.work_off
# Disabled delayed jobs during test
@benzittlau
benzittlau / blur.html
Created September 23, 2011 17:39
Ben's amazing bluring script
<html>
<head>
<title> Ben's amazing bluring script </title>
</head>
<h1> Ben's amazing bluring script </h1>
<button id="reset">Reset</button>
<button id="blur">Blur</button>
<span id="paint_white" class="selected">Paint White</span>
<span id="paint_black">Paint Black</span>
<span id="paint_toggle">Paint Toggle</span>
@benzittlau
benzittlau / reset_hard_origin_master
Created October 13, 2011 01:48
Reset a local branch to exactly match a remote branch
macbook:al Ben$ git reset --hard origin/master
@benzittlau
benzittlau / gist:1364764
Created November 14, 2011 18:56
Push a specific git commit to a remote repo
Push the commit with the given SHA to origin:develop
git push origin 3733b4360f280f084c1d719e7cf4d277c7934621:develop
@benzittlau
benzittlau / gist:3130243
Created July 17, 2012 15:55
Combine Find with Tar
sudo find . -mtime -30 ! -type d -print | xargs tar -cvf ~/archive.tar
@benzittlau
benzittlau / game_of_life.rb
Created September 24, 2012 16:06
Game of life implementation in ruby
class World
attr_accessor :cells
NEXT_STATE = [:dead, :alive, :alive, :dead, :dead, :dead, :dead, :dead]
def initialize(cells)
@cells = cells
end
def add_newly_born_cells
@benzittlau
benzittlau / send-template
Created October 13, 2012 19:16
Working send template call for mandrill
m.messages 'send-template', {:template_name => "Folder Shared", :template_content => [{:name => "sharelink", :content => "<a href='www.google.com'>test link</a>"},{:name => "monkeyrewards", :content => "<a href='www.google.com'>test link</a>"}], :message => {:subject => "Folder Shared!", :from_email => "[email protected]", :to => [{:email => "[email protected]", :name => "Ben Zittlau"}]}}
@benzittlau
benzittlau / tmux.conf
Created November 9, 2012 03:30
Template tmux.conf file
# Act like Vim
set-window-option -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
# Look good
set-option -g default-terminal "screen-256color"
@benzittlau
benzittlau / basename_locale.php
Created November 24, 2012 22:31
Test demonstrating the danger of not explicitly setting your locale in PHP
<?php
// Set the locale to 'C'
setlocale(LC_CTYPE, 'C');
// Set the string to 'Test Folder' in hebrew
$path = '/Hebrew Test Folder/מחרוזת בדיקה';
// Echo out just the base string
echo $path . "\n"; // /Hebrew Test Target/מחרוזת בדיקה
<?php
'modifiedDate' => date(DateTime::RFC3339, $timestamp)