Skip to content

Instantly share code, notes, and snippets.

View atl's full-sized avatar

Adam Lindsay atl

View GitHub Profile
# one-liner to be used with http://bitbucket.org/atl/remix-shell/
[aql([aq(a+b/40.,b*pow(c/40.0,2),source=segments.source) for a,b,c in zip([bars[d].start]*16,[bars[d].duration]*16,range(16))]) for d,e in enumerate(bars)]
package main
// Revised after seeing pkg/http/url.go
import (
"fmt";
"strings";
)
func shouldEscape(c int) bool {
# Code moved to http://github.com/atl/twitstream/
# Minimal python asynchronous http client that does non-authenticating
# proxies and http basic authorization. Intended as a proof of concept
# to access Twitter's streaming API:
# http://apiwiki.twitter.com/Streaming-API-Documentation
import asynchat, asyncore, socket, base64, urllib, sys
from urlparse import urlparse
try:
import json
@atl
atl / mps_parseargs.py
Created June 4, 2009 13:37
Stolen shamelessly from Michael Sparks' http://pastebin.com/fc0b32a3
# Stolen shamelessly from Michael Sparks' http://pastebin.com/fc0b32a3
def parseargs(argv, longopts, longflags):
args = {}
for k, key in longopts:
try:
i = argv.index("--"+key)
F = longopts[k,key].__class__(argv[i+1])
args[key] = F
del argv[i+1]
@atl
atl / shorten-bookmarklet.js
Created April 12, 2009 10:01 — forked from singpolyma/shorten-bookmarklet.js
Added rel="short_url" case
/* Expanded form of a bookmarklet for extracting rev=canonical OR tinyurling a page */
(function(){
var url=document.location;
var links=document.getElementsByTagName('link');
var found=0;
for(var i = 0, l; l = links[i]; i++) {
if (l.getAttribute('rev') == 'canonical' || (!(/icon/).exec(l.getAttribute('rel')) && (/short/).exec(l.getAttribute('rel')))) {
found=l.getAttribute('href');
break;
}