Skip to content

Instantly share code, notes, and snippets.

View faried's full-sized avatar

Faried Nawaz faried

View GitHub Profile
#!/usr/bin/env python
"""DCPU-16 disassembler.
Run as parse.py /path/to/dcpufile.
http://0x10c.com/doc/dcpu-16.txt
"""
import sys
@faried
faried / dumpredditlinks.py
Created October 24, 2011 17:10
dump reddit links
@faried
faried / echo.go
Created October 7, 2011 12:46
echo server
// listen for a connection
// read what they type, and echo it back
// when they type "quit", close the connection.
package main
import (
"bufio"
"fmt"
"net"
"os"
@faried
faried / Makefile
Created September 1, 2011 23:09
makefile for inform6 project
CFLAGS= -I.
PROG= inform6
SRCS= arrays.c asm.c bpatch.c chars.c directs.c errors.c expressc.c expressp.c \
files.c inform.c lexer.c linker.c memory.c objects.c states.c symbols.c \
syntax.c tables.c text.c veneer.c verbs.c
OBJS= ${SRCS:.c=.o}
all: $(PROG)
clean:
@faried
faried / subredditauthors.py
Created June 24, 2011 07:37
Print out list of authors common in two subreddits.
#!/usr/bin/env python
"""Print out list of authors common in two subreddits."""
from json import loads
# from hashlib import sha1
import sys
from time import sleep
from urllib2 import urlopen
URLBASE = 'http://www.reddit.com/r/%s/.json'
@faried
faried / maildirtocouch.py
Created February 9, 2011 21:37
Parse out a few headers, store doc in db and then attach email attachments.
#!/usr/bin/env python
"""Store messages in a Maildir into a couchdb database."""
import couchdb
from email.header import decode_header
from email.utils import parseaddr, getaddresses
import logging
from mailbox import Maildir
from optparse import OptionParser
import os
;; example function to call
(defun underline-char (char-point)
(add-text-properties char-point (1+ char-point)
'(face underline)))
(defun do-high-ascii (fn)
(interactive "aFunction: ")
(save-excursion
(goto-char (point-min))
(while (< (point) (point-max))
@faried
faried / gist:813583
Created February 6, 2011 18:28
try harder to parse headers
def utf8decode(thing):
"""Try to convert from ASCII to UTF-8."""
try:
return thing.decode('utf-8')
except UnicodeDecodeError, _exc:
# many badly created messages will be like this
try:
return thing.decode('iso-8859-15')
except UnicodeDecodeError, exc:
@faried
faried / maildirtocouch.py
Created February 1, 2011 22:02
Store messages in a Maildir into a couchdb database.
#!/usr/bin/env python
"""Store messages in a Maildir into a couchdb database."""
import couchdb
from mailbox import Maildir
from optparse import OptionParser
import os
from pprint import pprint
import sys
from uuid import uuid4
@faried
faried / booklist.py
Created December 11, 2010 19:22
read a list of isbn numbers from a google docs spreadsheet, update related title/author cells.
#!/usr/bin/env python
"""Get title/author for ISBNs in a Google Docs spreadsheet."""
from getpass import getpass
import os
import os.path
import sys
from gdata.spreadsheet import service, SpreadsheetsList
from gdata.books import service as bservice