This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://lukasrieder.com/2009/07/14/extend-your-bash-ps1.html | |
function parse_git_dirty_and_branch() { | |
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'` | |
[[ $branch != '' ]] && echo "($(parse_git_dirty)$branch)" | |
} | |
# set a fancy prompt (non-color, unless we know we "want" color) | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import re | |
import os | |
import sys | |
import lxml.html | |
import twitter | |
api = twitter.Api( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import lxml.html | |
from collections import Counter | |
doc = lxml.html.parse(open("cache.html")) | |
users = [x.text.upper() for x in doc.xpath("//div[@class='side_sec_box side_article_area']/div/p[@class='user']/a")[:400]] | |
print "".join(map(lambda x: x[0], Counter("".join(users)).most_common(5))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
# This program works with both 1.8.7 and 1.9.3 | |
# | |
# usage: | |
# ruby cal.rb [month] [year] | |
# month and year are optional | |
require "date" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! -*- coding: utf-8 -*- | |
from multiprocessing import Pool | |
class Worker(object): | |
def __init__(self, func, *args): | |
self.func = func | |
self.args = args | |
def __call__(self, *args, **kw): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import cmd | |
class MyShell(cmd.Cmd): | |
def precmd(self, line): | |
lines = line.split(';') | |
self.cmdqueue.extend(lines[1:]) | |
return lines[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"errors" | |
"flag" | |
"fmt" | |
"log" | |
"net" | |
"net/http" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
var workerSize = 4 | |
type Fetcher interface { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
def product(v, coins=[500, 100, 50, 10, 5, 1], used=[]): | |
if len(coins) == 1: | |
yield 1 | |
else: | |
for i, coin in enumerate(coins): | |
diff = v - coin | |
if diff == 0: | |
yield 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .conkyrc | |
alignment bottom_left | |
gap_x 0 | |
gap_y 0 | |
background no | |
use_xft yes | |
xftfont Bitstream Vera Sans Mono:size=10:Bold |