Skip to content

Instantly share code, notes, and snippets.

View braveulysses's full-sized avatar

Jacob Childress braveulysses

View GitHub Profile
@braveulysses
braveulysses / gist:3114134
Created July 15, 2012 00:43
Temporarily advertise AT&T U-verse 2WIRE gateway over Bonjour
dns-sd -P "U-verse Gateway" _http._tcp local 80 gateway.2wire.net 172.16.0.1
@braveulysses
braveulysses / json-tidy.py
Created January 4, 2012 20:03
JSON pretty print
#!/usr/bin/env python
import sys
try:
import json
except ImportError:
print "Can't import JSON module. Make sure you're using Python 2.6 or above."
sys.exit(1)
try:
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#
@braveulysses
braveulysses / gist:870019
Created March 14, 2011 22:33
iTerm: launch multiple sessions
-- An iTerm 2 launch script. Opens three terminal windows,
-- logs them in to three different hosts,
-- and cd's to a common directory.
--
-- Place in ~/Library/Application Support/iTerm/Scripts
--
global remoteDirectory
set remoteDirectory to "/my/project"
@braveulysses
braveulysses / kaprekar.rb
Created November 11, 2010 19:54
Kaprekar's routine. Undoubtedly not the best way to do it.
#!/usr/bin/env ruby
# See: http://en.wikipedia.org/wiki/Kaprekar_constant
$MAX_DIGITS = 4
$KAPREKARS_CONSTANT = 6174
class Fixnum
def sort(padding=0)
ordered = Array.new
@braveulysses
braveulysses / venv.sh
Created June 13, 2010 03:28
Simple wrapper script for Python virtualenv
#!/bin/sh
###############################################################################
#
# venv: A simple wrapper for Python virtualenv
#
###############################################################################
VIRTUALENV_ROOT_DIR=~/Projects/Virtualenv
@braveulysses
braveulysses / py-git-bash.sh
Created February 2, 2010 05:27 — forked from flashingpumpkin/py-git-bash.sh
show git status at bash prompt
function _bash_git_status() {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function _bash_git() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/±\1$(_bash_git_status)/'
}
function prompt() {
local BLACK="\[\033[0;30m\]"
@braveulysses
braveulysses / cheat_on_ruby-1.9.1.diff
Created June 1, 2009 15:18
Patch to run cheat with Ruby 1.9.1
--- /opt/local/lib/ruby1.9/gems/1.9.1/gems/cheat-1.2.1/lib/cheat.rb 2009-06-01 10:30:32.000000000 -0500
+++ cheat.rb 2009-06-01 10:30:19.000000000 -0500
@@ -1,5 +1,10 @@
$:.unshift File.dirname(__FILE__)
%w[rubygems tempfile fileutils net/http yaml open-uri wrap].each { |f| require f }
+begin
+ PLATFORM = RUBY_PLATFORM
+rescue NameError
+ # ... then we're probably using Ruby < 1.9
+end
@braveulysses
braveulysses / github.sh
Created May 31, 2009 04:06
A helper script for working with GitHub Git repositories.
#!/bin/bash
# A helper script for working with GitHub Git repositories.
function git_dir_check() {
if [ ! -d ".git" ]; then
echo "Not a git repository!"
exit
fi
}
@braveulysses
braveulysses / get_lcd_panel.sh
Created May 29, 2009 20:30
Gets the model number of your MacBook's display panel.
#!/usr/bin/env bash
# Get the model number of your MacBook's LCD panel.
# Thanks, Ars Technica!
ioreg -lw0 | grep IODisplayEDID | sed "/[^<]*</s///" | xxd -p -r | strings -6