Skip to content

Instantly share code, notes, and snippets.

View apg's full-sized avatar
🐢
Turtle

Andrew Gwozdziewycz apg

🐢
Turtle
View GitHub Profile
#lisp.py
#
#An interpreter for a simple scheme like lexically
#scoped language implemented as single python expression.
#
#The interpreter is limited to the lambda special form and a
#sum function. The data types supported are positive integers
#and symbols.
#

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@apg
apg / star.md
Last active August 29, 2015 14:25

rendered star

@apg
apg / output
Last active August 29, 2015 14:26
$ go run score.go
Test: [1 2 3]
score=0
Test: [2 1 3]
score=1
Test: [3 2 1]
score=2
Test: [1 2 4 3 5]
score=1
Test: [1 2 4 3 5 6 8 9 7]
# instead of:
match = someregex.match(line)
if match:
print match.groups()
else:
print 'boo'
# why not make use of the 'as' keyword and do something like:
if someregex.match(line) as match:
# quick and dirty inverted index
import re, os
class InvertedIndex(object):
def __init__(self):
self._data = {}
def add(self, words, document):
for word in words:
# broken, hacked up version of
# http://bret.appspot.com/entry/how-friendfeed-uses-mysql for sqlite
# database = bequas.Database('something.db')
# database.initialize(); database.create_index('hello', unique=True);
# database.insert({'hello': 'world'})
import sqlite3
import uuid
import datetime
import zmq, time
def main(addr):
print addr
context = zmq.Context(1, 1)
socket = context.socket(zmq.SUB)
socket.setsockopt(zmq.SUBSCRIBE, "")
socket.connect(addr)
#!/bin/bash
# run in cron every 15 minutes to capture your tweets while on vacation
DATE=`date +"%Y-%m-%d-%H-%M"`
curl -u username:password http://twitter.com/statuses/friends_timeline.rss >
/home/apgwoz/vacation-dumps/twitter/$DATE.rss
"""ARGF from Ruby in Python.
"""
import sys, os
class _ARGF(object):
def __init__(self):
self.lineno = 1