Skip to content

Instantly share code, notes, and snippets.

View gaustin's full-sized avatar

Grant Austin gaustin

  • Minneapolis, MN
View GitHub Profile
@gaustin
gaustin / myapp.rb
Created September 18, 2008 00:29 — forked from ivey/myapp.rb
require 'web'
urls = {
'/', 'index',
'/users', 'users',
'/user/(\d+)', 'user',
'/users/new', 'new_user',
'/user/(\d+)/edit', 'edit_user'
}
@gaustin
gaustin / httpdump
Created April 4, 2009 14:13 — forked from peterc/httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*""
# All the above tested only on OS X.
# Bash snippet to open new shells in most recently visited dir.
# Useful if you want to open a new terminal tab at the present
# tab's location.
#
# Put this in your .bashrc or whatever.
pathed_cd () {
if [ "$1" == "" ]; then
cd
else
from twisted.words.protocols.jabber import client, jid
from twisted.words.xish import domish, xmlstream
from twisted.application import internet, service
# Python bindings for Growl come with the SDK:
# http://growl.info/downloads_developers.php
from Growl import GrowlNotifier, Image
JID = 'test@example.com'
PASSWORD = 'secret'
require 'digest/sha1'
class String
def hash
Digest::SHA1.hexdigest self
end
def bit
"%0160b" % to_i(16)
end
@gaustin
gaustin / 0what.md
Created September 6, 2009 13:37 — forked from defunkt/0what.md

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

# Subject: Re: Newbie to Sinatra looking for example
# From: Ryan Tomayko <r@tomayko.com>
# To: sinatrarb@googlegroups.com
# Content-Type: text/plain; charset=UTF-8
#
# > Alright, so I'm pretty new to both Sinatra and web applications, and I
# > was wondering if someone could write up a quick example use of
# > Sinatra. Basically I want to see how Sinatra handles <form>s in one
# > view, and then shows the input on a different view.
# >
#!/usr/local/bin/macruby
framework 'Cocoa'
framework 'WebKit'
class VirtualBrowser
attr_reader :view, :file_name
def initialize
NSApplication.sharedApplication.delegate = self
@view = WebView.alloc.initWithFrame([0, 0, 1024, 768])
# for usage: ruby timecard.rb --help
require 'rubygems'
require 'optparse'
# This requires the 'cyberfox-gchart' gem (0.5.4), as the standard
# gchart gem is woefully broken for this kind of graph. Broken to the
# point that it's an inherent design choice that doesn't work well for
# this kind of chart. I'm sure that the cyberfox-gchart gem won't
# for usage: ruby timecard.rb --help
require 'rubygems'
require 'optparse'
# This requires the 'cyberfox-gchart' gem (0.5.4), as the standard
# gchart gem is woefully broken for this kind of graph. Broken to the
# point that it's an inherent design choice that doesn't work well for
# this kind of chart. I'm sure that the cyberfox-gchart gem won't