Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View aerickson's full-sized avatar

Andrew Erickson aerickson

View GitHub Profile
require 'rubygems'
require 'grit'
require 'active_support'
include Grit
#
# USAGE: dead_branches <path_to_repo>
#
<html>
<head>
<title>Image</title>
<script type="text/javascript">
function resizeImage()
{
var window_height = document.body.clientHeight
var window_width = document.body.clientWidth
@aerickson
aerickson / unix rename files
Created March 9, 2011 05:47
easier than dealing with sed (for me at least)
for f in *.MP3; do mv "$f" "`basename "$f" .MP3`.mp3"; done;
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
#!/bin/bash
FAIL=0
echo "starting"
./sleeper 2 0 &
./sleeper 2 1 &
./sleeper 3 0 &
./sleeper 2 0 &
@aerickson
aerickson / gist:1111135
Created July 28, 2011 07:10
making sudo work on lion
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
@aerickson
aerickson / rsync_with_progress.py
Created October 13, 2011 05:09
Get total rsync progress using Python
# 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,
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 / find_external_ip.rb
Created September 16, 2013 18:20
Get your IP address on unix-y system without a fork in Ruby. http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/
require 'socket'
def local_ip
orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
UDPSocket.open do |s|
s.connect '64.233.187.99', 1
s.addr.last
end
ensure
@aerickson
aerickson / PyCurlSSLFixOnUbuntu
Last active December 16, 2018 11:34
how to rebuild PyCurl against OpenSSL on Ubuntu (12-13+)
XBMC uses pycurl/libcurl to fetch stuff. YouTube requires the RC4
cipher that GnuTLS has removed for security reasons (or doesn't allow
it to be selected, or XBMC doesn't allow to specify the cipher...).
PyCurl linked against OpenSSL can take the RC4 argument and make the
Youtube plugin work (Ubuntu ships it linked against GnuTLS), so we
need to rebuild to make it work.
///
from: https://code.google.com/p/wfuzz/wiki/PyCurlSSLBug