Skip to content

Instantly share code, notes, and snippets.

View atl's full-sized avatar

Adam Lindsay atl

View GitHub Profile
@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;
}
@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]
# 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
package main
// Revised after seeing pkg/http/url.go
import (
"fmt";
"strings";
)
func shouldEscape(c int) bool {
# 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)]
#!/usr/bin/env python
"""worker.py: An implementation of an event-based asynchronous pattern.
Uses generators to allow asynchronous tasks to be coded in-line. Allows the
implementer to define what technique is used to execute asynchronously and
which generator iterations are executed asynchronously.
References:
http://code.activestate.com/recipes/576952/ [inline asynchronous code]
@atl
atl / filtered_jTweetsAnywhere.html
Created June 3, 2010 11:29
example jTweetsAnywhere usage that filters out replies and old-style retweets, hides selected hashtags, preserves carriage returns, and hides repetitions of a userpic
<html>
<!-- I'm a beginnner with JS/jQuery, so I welcome suggestions
on how to make it more idiomatic. -->
<head>
<link rel="stylesheet" type="text/css" href="jquery.jtweetsanywhere-1.0.0.css" />
<style type="text/css">
/* Since we're showing one user's stream, show the profile image the first time: */
.jta-tweet-profile-image {visibility: hidden}
.jta-tweet-list-item:first-child .jta-tweet-profile-image {visibility: visible}
</style>
@atl
atl / instructions
Created March 24, 2011 12:49
HOWTO: compile and install redis on a no.de machine as of 2011-03-24
# First, we need a little extra effort to install GCC
pfexec pkg_add gcc44
export PATH="$PATH:/opt/local/gcc44/bin"
pkgin in binutils
# make and install
mkdir ~/sw
cd ~/sw
wget http://redis.googlecode.com/files/redis-2.2.2.tar.gz
gtar xvf redis-2.2.2.tar.gz
@atl
atl / diff
Created June 16, 2011 12:53
pyechonest.artist.extract
--- a/pyechonest/artist.py Thu Jun 16 13:40:52 2011 +0100
+++ b/pyechonest/artist.py Thu Jun 16 13:51:16 2011 +0100
@@ -876,3 +876,28 @@
result = util.callm("%s/%s" % ('artist', 'similar'), kwargs)
return [Artist(**util.fix(a_dict)) for a_dict in result['response']['artists']]
+def extract(text='', start=0, results=15, buckets=None, limit=False, max_familiarity=None, min_familiarity=None,
+ max_hotttnesss=None, min_hotttnesss=None):
+ buckets = buckets or []
+ kwargs = {}
@atl
atl / google_twunter_lol.json
Created July 28, 2011 21:15 — forked from jamiew/google_twunter_lol
All the dirty words from Google's "what do you love" project: http://www.wdyl.com/
easterEgg.BadWorder.list={
"4r5e":1,
"5h1t":1,
"5hit":1,
a55:1,
anal:1,
anus:1,
ar5e:1,
arrse:1,
arse:1,