Skip to content

Instantly share code, notes, and snippets.

View urbanspoon_reservations.rb
require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = 'EMAIL@provider.com'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
@aerickson
aerickson / rsync_with_progress.py
Created Oct 13, 2011
Get total rsync progress using Python
View rsync_with_progress.py
# from https://libbits.wordpress.com/2011/04/09/get-total-rsync-progress-using-python/
import subprocess
import re
import sys
print('Dry run:')
cmd = 'rsync -az --stats --dry-run ' + sys.argv[1] + ' ' + sys.argv[2]
proc = subprocess.Popen(cmd,
shell=True,
@aerickson
aerickson / gist:1111135
Created Jul 28, 2011
making sudo work on lion
View gist:1111135
from: http://forums.macrumors.com/showthread.php?t=447812
///////////////
Reboot into single user mode (hold Option S while booting until it switches to text mode)
At the single user prompt, type: /sbin/fsck -fy
This checks the filesystem integrity
View parallel_bash_runner
#!/bin/bash
FAIL=0
echo "starting"
./sleeper 2 0 &
./sleeper 2 1 &
./sleeper 3 0 &
./sleeper 2 0 &
View ruby seconds to human readable
def humanize secs
[[60, :seconds], [60, :minutes], [24, :hours], [1000, :days]].map{ |count, name|
if secs > 0
secs, n = secs.divmod(count)
"#{n.to_i} #{name}"
end
}.compact.reverse.join(' ')
end
@aerickson
aerickson / unix rename files
Created Mar 9, 2011
easier than dealing with sed (for me at least)
View unix rename files
for f in *.MP3; do mv "$f" "`basename "$f" .MP3`.mp3"; done;
View resize image while maintaining aspect ratio
<html>
<head>
<title>Image</title>
<script type="text/javascript">
function resizeImage()
{
var window_height = document.body.clientHeight
var window_width = document.body.clientWidth
View dead_branches.rb
require 'rubygems'
require 'grit'
require 'active_support'
include Grit
#
# USAGE: dead_branches <path_to_repo>
#