Skip to content

Instantly share code, notes, and snippets.

And if you survive till two thousand and five
I hope you're exceedingly thin
For if you are stout you will have to breathe out
While the people around you breathe in
var sys = require('sys');
var connect = require('connect');
var redisFactory = require('redis-node');
var redis = redisFactory.createClient();
var server = connect.createServer();
// test with: ab -n 5000 -c 40 http://127.0.0.1:3000/folders
function buffer_to_strings(x) {
for(var i in x) {
:>test.html; lynx -dump http://redis.io/commands | awk '/commands/{print $2}' | while read i; do j=${i##*/}; (echo "<h1>$j</h1>"; curl $i | sed -n -e '/<aside>/,/<\/aside>/d' -e '/<article>/,/<\/article>/p'; echo "<hr>") >> test.html; sleep 1; done
use Template;
use Template::Parser;
my $p = Template::Parser->new();
my $tt = join('', <DATA>);
print $p->parse($tt) ? "OK" : "NOT OK";
__DATA__
[% INCLUDE monkeys %]
<ul>
if ! git status >/dev/null 2>/dev/null ; then
echo "not a git repository"
exit 128
fi
B=/tmp/.lnt.branches
T=/tmp/.lnt.tracking
# first we find our local branches
git branch --no-abbrev --no-color | cut -b3- | sort > $B
# do we have any remotes?
rc=$(git remote | wc -l)
del folder:mince
del folder:opensource
del user:rjp:read
zadd folder:mince 12345 23
zadd folder:mince 12346 24
zadd folder:opensource 12345 25
zadd folder:mince 12349 26
zadd user:rjp:read 12345 23
zadd user:rjp:read 12345 25
echo "should be 2"
require 'rubygems'
require 'redis'
$redis = Redis.new()
$redis.select(3)
# do a zdiffstore only on scores that match
# ie [23:12345] will only be removed by [23:12345], not [23:12350]
def zdiffstore(x, y)
$redis.zunionstore "tmp.zu", [x, y], :weights=>[1,-1], :aggregate=>:sum
@rjp
rjp / gist:814271
Created February 7, 2011 11:26
Fear my metaprogramming sk1llz
var sys = require('sys');
var l = [
{ unread: 4, sub: 1 },
{ unread: 0, sub: 1 },
{ unread: 4, sub: 0 }
];
filters = process.env.filter; if (filters == undefined) { filters = ""; }
@rjp
rjp / gist:833546
Created February 18, 2011 11:11
Turn clover-C of a bunch of iTunes tunes into a nice HTML table
awk -F\\t 'BEGIN{print"%html\n %body\n %table\n %tr\n %th Track\n %th Artist\n %th Album"}{printf(" %%tr\n %%td %s\n %%td %s\n %%td %s\n",$1,$3,$4)}' | recode utf8..html | haml
@rjp
rjp / jshow.rb
Created February 22, 2011 23:44
require 'rubygems'
require 'json'
require 'open-uri'
$base = ENV['UA_BASE'] || 'http://localhost:3000'
$user = ENV['UA_USER'] || 'user'
$pass = ENV['UA_PASS'] || 'pass'
# {"folder":"test2","to":"rjp","id":2035015,"body":"FLANGES","inReplyTo":2034051,"subject":"Ainsley","epoch":1298383425,"read":false,"annotations":[{"body":"*mutter*","epoch":1298384919,"from":"rjp"}],"from":"rjp","inReplyToHierarchy":[{"folder":"test1","id":2034051,"from":"rjp"}],"replyToBy":[{"folder":"test1","id":2035371,"from":"rjp"}]}