Skip to content

Instantly share code, notes, and snippets.

@kamiller
kamiller / draw_rounded.py
Created June 28, 2012 20:07
python rounded rectangle using cairo and arc
def draw_rounded(cr, area, radius):
""" draws rectangles with rounded (circular arc) corners """
from math import pi
a,b,c,d=area
cr.arc(a + radius, c + radius, radius, 2*(pi/2), 3*(pi/2))
cr.arc(b - radius, c + radius, radius, 3*(pi/2), 4*(pi/2))
cr.arc(b - radius, d - radius, radius, 0*(pi/2), 1*(pi/2)) # ;o)
cr.arc(a + radius, d - radius, radius, 1*(pi/2), 2*(pi/2))
cr.close_path()
cr.stroke()
@kamiller
kamiller / ubuntu-partner-repo
Created July 3, 2012 20:22
add ubuntu partner repo
sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
@kamiller
kamiller / lru.py
Created July 5, 2012 14:26
python LRU functools wrapper impl
import collections
import functools
def lru_cache(maxsize=100):
'''Least-recently-used cache decorator.
Arguments to the cached function must be hashable.
Cache performance statistics stored in f.hits and f.misses.
http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
@kamiller
kamiller / pandoc.sh
Created July 20, 2012 15:57
pandoc dependencies and usage
sudo apt-get install texlive-latex-base
sudo apt-get install texlive-latex-base
pandoc input.md --toc -o output.pdf
@kamiller
kamiller / validate_json.sh
Created July 25, 2012 19:09
validate json with python via bash script
echo '{"foo":"bar"}' | python -m json.tool >> /dev/null && exit 0 || echo "NOT valid JSON"; exit 1
@kamiller
kamiller / ubuntu_release.sh
Created August 28, 2012 12:35
determine ubuntu release
#!/bin/bash
lsb_release -sc
@kamiller
kamiller / debian_package_version.sh
Created August 28, 2012 18:18
compare debian package versions for equality
dpkg --compare-versions "1.0.11~rc1" gt "1.0-10" && echo "1.0-11 greater than RC"
@kamiller
kamiller / rsync.py
Created November 1, 2012 21:40
python rsync impl
## {{{ http://code.activestate.com/recipes/577518/ (r4)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This is a pure Python implementation of the [rsync algorithm](TM96).
[TM96] Andrew Tridgell and Paul Mackerras. The rsync algorithm.
Technical Report TR-CS-96-05, Canberra 0200 ACT, Australia, 1996.
http://samba.anu.edu.au/rsync/.
@kamiller
kamiller / signal_ex.py
Created January 8, 2013 20:02
send / receive USR1 signal
#!/usr/bin/env python
import os
import sys
import signal
if __name__ == "__main__":
print "sending signal, pid="+repr(sys.argv[1])
os.kill(int(sys.argv[1]), signal.SIGUSR1)
@kamiller
kamiller / belkin_n300_router_tomato_setup.md
Created February 21, 2013 23:44
Belkin n300 share router tomato USB flash instructions

TomatoUSB Setup Guide

So, about those instructions. An important thing to know is that the model number of this router is F7D7302, which is just a newer version of the F7D3302. So when you're searching for firmware that's the model you want to use. Now, I've spent some time doing research to get this working with TomatoUSB and finally came with a pretty simple solution. I've noticed a lot of guides want you to install DD-WRT first, which is completely unnecessary.

The best version for this unit right now is the TomatoUSB builds from Toastman. While this may appear to be a lot of steps, it's really not all that complicated.

You're going to want two files for this procedure. Google "tomato toastman 4shared" to find the repository (it's hosted on a download site called 4shared). You'll be looking for the latest version in the RT (MIPSR2) folder (each version will be split into VLAN and STD versions, you'll want the STD one). Inside of that folder will be a bunch of .bin and .trx files. You'll want the .