Skip to content

Instantly share code, notes, and snippets.

@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 = ""; }
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
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"
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)
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>
:>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
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) {
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
function parse_git_branch {
xx=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)
/(\1)/")
echo "$xx"
}
function check_git_changes {
git diff --quiet 2>/dev/null
if [ $? -ne 0 ]; then
tput setaf 1 # red
else
scribot=# select * from (select count(distinct url) as c, date_trunc('hour', wh) as x from url group by x) as q order by c desc limit 20;
c | x
----+------------------------
35 | 2010-03-24 11:00:00+00
26 | 2009-10-28 10:00:00+00
25 | 2009-10-06 10:00:00+01
24 | 2009-10-07 12:00:00+01
24 | 2004-05-05 12:00:00+01
23 | 2004-01-29 12:00:00+00
22 | 2004-11-17 10:00:00+00