Skip to content

Instantly share code, notes, and snippets.

View adammck's full-sized avatar

Adam Mckaig adammck

View GitHub Profile
@adammck
adammck / gist:1314693
Created October 25, 2011 23:08
Temporarily patch the Rails configuration for the duration of a block
# Temporarily patch the Rails configuration for the duration of a block.
# For example:
#
# test "should create a resque job when background_jobs is true" do
# with_config :background_jobs=>true do
# repo = Repo.create :url=>TEST_CLONE_URL
# assert_queued(CloneJob, [repo.pk])
# end
# end
#
@adammck
adammck / rvm [un]export
Created January 8, 2011 08:37
a quick example session using my rvm fork, demonstrating 'rvm export' in rvmrc.
# see:
# https://github.com/adammck/rvm
# no env vars are defined:
$ echo $TWITTER_API_KEY
# rvm isn't enabled as default:
$ which ruby
/usr/bin/ruby
@adammck
adammck / gist:645896
Created October 25, 2010 22:10
Call with do-what-I-mean args
def call_with_dwim_args(callable_, args):
"""
Call and return ``callable_`` with *do-what-I-mean* ``args``. More
precisely:
| if ``args`` is a dict, call ``callable_(**args)``
| if ``args`` is a list, call ``callable_(*args)``
| otherwise, call ``callable_(args)``
The usual Pythonic solution of testing ``iter(args)`` and catching
# Contributor: Adam Mckaig <[email protected]>
# vim: et ts=4 sw=4
pkgname=python-mox
pkgver=0.5.3
pkgrel=1
pkgdesc="Object-mocking framework for Python."
arch=("any")
url="http://code.google.com/p/pymox/"
license=("APACHE")
/*
* run this in firebug to extract a list of the
* album/artist/track names from any browse page
* at lala.com, then acquire them from a less
* obnoxious source. outputs csv.
*/
(function() {
var extract = function() {
#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4
import os, sys
from django.conf.urls.defaults import *
# this list will be populated with the
# urls from the urls.urlpatterns of each
# running rapidsms app, then imported by
# django as if we'd declared them all here
# in sites-available/example.com
<VirtualHost *:80>
ServerName example.com
ProxyPass /path http://localhost:4000/
ProxyPassReverse /path http://localhost:4000/
ProxyPreserveHost on
ProxyRequests on
</VirtualHost>
# in mods-available/ports.conf
#!/usr/bin/env ruby
# vim: noet
capitals = {
"England" => "london",
"France" => "paris",
"Germany" => "berlin",
"Spain" => "madrid",
"Italy" => "rome",
#!/usr/bin/env python
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HTTPServer(('', 8000), SimpleHTTPRequestHandler).serve_forever()
[rubygsm]$ ./gsm-band usa
Found modem on port:
/dev/ttyUSB0
GSM bands supported:
850, 900, 1800, 1900, 850/1900, 900E/1800, 900E/1900
Currently selected:
900E/1800