Skip to content

Instantly share code, notes, and snippets.

View vangberg's full-sized avatar

Harry Vangberg vangberg

View GitHub Profile
@vangberg
vangberg / README
Created February 18, 2009 10:32
lambda v proc v Proc.new
In 1.8 proc == lambda && proc != Proc.new
In 1.9 proc == Proc.new && proc != lambda
# This is our base controller, much like ApplicationController in Rails
class App < Sinatra::Base
# Default settings that should be shared by all controllers
set :foo, :bar
def shared_helper
# this will be available for everything
end
end
@vangberg
vangberg / DWM-ON-OS-X.md
Created February 22, 2010 19:24
dwm on os x [work in progress!]

Installing and configuring dwm on OS X

  1. Install XQuartz (http://xquartz.macosforge.org) which is the development version of the X11.app that ships with OS X, which means it is way more up to date. I have had some weird issues with X11.app v. 2.3-something. XQuartz 2.5.0 fixed that.

  2. Install dwm from Homebrew, brew install dwm. This makes a bunch of necessary tweaks to the DWM configuration.

  3. Add the following script to $PATH, name it dwm-launch and chmod 755:

    cd ~
    

while true

@cloudvoxcode
cloudvoxcode / ami_listener.rb
Created May 6, 2010 15:54
Asterisk AMI event listener - connect, read, & output
#!/usr/bin/ruby
# connect to Asterisk AMI port, authenticate, and print all AMI event messages
# as they're received.
# more or for Asterisk hosting: http://help.cloudvox.com/
# version: 2010-05-04
require 'socket'
unless ARGV.length == 4
puts 'usage: ruby ./ami_listener.rb hostname port username password'
#! /usr/bin/env ruby
# this program (on osx and probably others) will give you a 'named screen'
# (ns) command that will create named screens that will also name Terminal.app
# tabs, even on re-attach. save it in ~/bin/ns and use as in
#
# to create a named screen
#
# ns ~/src/foobar
#
module VSRG
class Period
class << Period
def for(*args, &block)
options = args.options
first = args.first
last = args.last
case first
// Handles JavaScript history management and callbacks. To use, register a
// regexp that matches the history hash with its corresponding callback.
window.HashHistory = {
// The interval at which the window location is polled.
URL_CHECK_INTERVAL : 500,
// We need to use an iFrame to save history if we're in an old version of IE.
USE_IFRAME : jQuery.browser.msie && jQuery.browser.version < 8,
@sifu
sifu / USAGE.txt
Created November 3, 2010 14:27
jsoneval
eg. to print the ids of all documents within a couchdb database:
curl "http://127.0.0.1:5984/somedb/_all_docs" | jsoneval.js "body.rows.forEach( function( r ){ console.info( r.id ) } );"
@sr
sr / cloudkick-resque
Created November 21, 2010 14:15
cloudkick plugin for resque
#!/usr/bin/env ruby
$:.unshift "lib"
require "init"
workers = Resque.workers
total = workers.size.to_f
idling = workers.select { |w| w.idle? }.size
working = Resque.working.reject { |w| w.idle? }.size.to_f
busyness = (working / total) * 100