Skip to content

Instantly share code, notes, and snippets.

import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state
@sublee
sublee / README.rst
Created September 28, 2010 08:03
Finger Binary ASCII art generator for Python

Finger Binary

What's Finger Binary?

Here is a description of Finger Binary in Wikipedia.

Finger binary is a system for counting and displaying binary numbers on the

@paulirish
paulirish / utmstrip.user.js
Last active April 11, 2024 07:53
userscript: Drop the UTM params from a URL when the page loads
// ==UserScript==
// @name UTM param stripper
// @author Paul Irish
// @namespace http://github.com/paulirish
// @version 1.2
// @description Drop the UTM params from a URL when the page loads.
// @extra Cuz you know they're all ugly n shit.
// @include http*://*
// ==/UserScript==
@parse
parse / shell.c
Created May 11, 2011 07:31
Simple shell in C
/* Compile with: g++ -Wall –Werror -o shell shell.c */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
@rjp
rjp / robohash.js
Created July 8, 2011 15:04
Replace twitter avatars with robohash robots
// ==UserScript==
// @name RoboHash Your Twitters
// @namespace rjp
// @description Replace twitter avatars with RoboHash avatars
// @include http://twitter.com/
// ==/UserScript==
// linkifyContainer idea gratefully and wholly stolen from
// http://arantius.com/misc/greasemonkey/linkify-plus.user.js#
// with minor reformatting by me to make a nicer gist
@sbz
sbz / hexdump.py
Created July 13, 2011 13:04
hexdump implementation in Python
def hexdump(src, length=16):
FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or '.' for x in range(256)])
lines = []
for c in xrange(0, len(src), length):
chars = src[c:c+length]
hex = ' '.join(["%02x" % ord(x) for x in chars])
printable = ''.join(["%s" % ((ord(x) <= 127 and FILTER[ord(x)]) or '.') for x in chars])
lines.append("%04x %-*s %s\n" % (c, length*3, hex, printable))
return ''.join(lines)
@whit
whit / .Xresources
Created October 23, 2011 17:19
Personal ~/.Xresources settings. With some rxvt-unicode tweaks, Solarized color theme etc...
##############
# Xft settings
##############
Xft.dpi: 96
Xft.antialias: true
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight
@ties
ties / gist:1424374
Created December 2, 2011 18:51
pcap/dpkt example that dumps (some) http request headers
#!/usr/bin/env python
import dpkt, pcap, socket
from ipaddr import IPv4Address, IPv6Address
import syslog
class HTTPRequest():
def __init__(self, host, uri, ip = None, user_agent = None):
self.uri = uri
self.user_agent = user_agent
self.host = host
@jasonrdsouza
jasonrdsouza / gmail.py
Created January 25, 2012 04:52
Python script to access a gmail account and download particular emails
import email, getpass, imaplib, os
detach_dir = '.' # directory where to save attachments (default: current)
user = raw_input("Enter your GMail username:")
pwd = getpass.getpass("Enter your password: ")
# connecting to the gmail imap server
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user,pwd)
m.select("cs2043") # here you a can choose a mail box like INBOX instead
@vgoklani
vgoklani / expand_url.py
Created February 13, 2012 00:08
Expand shortened URLs in Python
# http://stackoverflow.com/questions/748324/python-convert-those-tinyurl-bit-ly-tinyurl-ow-ly-to-full-urls
#############
# urllib2
import urllib2
fp = urllib2.urlopen('http://bit.ly/rgCbf')
fp.geturl()
# ==> 'http://webdesignledger.com/freebies/the-best-social-media-icons-all-in-one-place'