Skip to content

Instantly share code, notes, and snippets.

View zain's full-sized avatar
💭
Livin' the dream.

Zain Memon zain

💭
Livin' the dream.
View GitHub Profile
"""
I've been thinking lately about how perfect Redis would be for storing a
simple social graph. I posited that it would be relatively few lines of code,
and that it'd be clean code too. So here it is: a basic social graph built on Redis.
"""
class FriendGraph(object):
def __init__(self, ring):
self.ring = ring
@zain
zain / ps1.bash
Created May 19, 2011 01:07
PS1 that looks smexy
#### PS1 customization ####
NONE="\[\033[0m\]" # unsets color to term fg color
# regular colors
K="\[\033[0;30m\]" # black
R="\[\033[0;31m\]" # red
G="\[\033[0;32m\]" # green
Y="\[\033[0;33m\]" # yellow
B="\[\033[0;34m\]" # blue
M="\[\033[0;35m\]" # magenta
@zain
zain / gist:1026036
Created June 14, 2011 22:02
Word counter
import operator, string
f = open('input.txt', 'r+')
s = f.read()
f.close()
just_words = s.lower().translate(string.maketrans("",""), string.punctuation)
counts = {}
for word in just_words.split():
if word in counts:
==> Downloading http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/v9.0.4/postgresql-9.0.4.tar.bz2
File already downloaded in /Users/zain/Library/Caches/Homebrew
/usr/bin/tar xf /Users/zain/Library/Caches/Homebrew/postgresql-9.0.4.tar.bz2
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.0.4 --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-python --with-perl --with-ossp-uuid --datadir=/usr/local/Cellar/postgresql/9.0.4/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.0.4/share/doc/postgresql ARCHFLAGS='-arch x86_64'
./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.0.4 --enable-thread-safety --with-bonjour --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxslt --with-python --with-perl --with-ossp-uuid --datadir=/usr/local/Cellar/postgresql/9.0.4/share/postgresql --docdir=/usr/local/Cellar/postgresql/9.0.4/share/doc/postgresql ARCHFLAGS='-arch x86_64'
checking build system
==> Downloading http://download.berlios.de/mapnik/mapnik-0.7.1.tar.gz
File already downloaded in /Users/zain/Library/Caches/Homebrew
/usr/bin/tar xf /Users/zain/Library/Caches/Homebrew/mapnik-0.7.1.tar.gz
==> scons PREFIX=/usr/local/Cellar/mapnik/0.7.1 ICU_INCLUDES=/usr/local/Cellar/icu4c/4.4.1/include ICU_LIBS=/usr/local/Cellar/icu4c/4.4.1/lib install
scons PREFIX=/usr/local/Cellar/mapnik/0.7.1 ICU_INCLUDES=/usr/local/Cellar/icu4c/4.4.1/include ICU_LIBS=/usr/local/Cellar/icu4c/4.4.1/lib install
scons: Reading SConscript files ...

Welcome to Mapnik...

==> Checking out http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/
/usr/bin/svn up --force http://svn.openstreetmap.org/applications/utils/export/osm2pgsql/ /Users/zain/Library/Caches/Homebrew/osm2pgsql--svn
Skipped 'http://svn.openstreetmap.org/applications/utils/export/osm2pgsql'
At revision 26305.
Summary of conflicts:
Skipped paths: 1
/usr/bin/svn export --force /Users/zain/Library/Caches/Homebrew/osm2pgsql--svn /private/tmp/homebrew-osm2pgsql-HEAD-BTuw
Export complete.
==> ./autogen.sh
./autogen.sh
“Turning Geo-Data into Geo-Visualizations”
When tasked with displaying geo-data, most developers decide to put some big red markers on an embeddable Google Map and call it a day. If want to create maps that are more beautiful, more interactive, and more usable, this session is for you.
Abstract:
This session is an introduction to the tools available for creating beautiful, interactive geo-visualizations for the web.
New tools and libraries have lowered the barrier of entry for creating useful maps. What was once exclusively the realm of traditional geographers is now accessible by almost any web developer.
def heaviest_incr_subseq(seq, weights):
dp = {}
dp[0] = weights[0]
for i in xrange(1, len(seq)):
dp[i] = weights[i]
for j in reversed(xrange(0, i - 1)):
if (dp[j] + weights[i] > dp[i]):
dp[i] = dp[j] + weights[i]
return max(dp.values())
from mock import Mock, patch
import requests
class VSSecureMailWS:
def encrypt_and_send(self, url, data):
r = requests.post(url)
if r.status_code == 200:
return "{0} {1}".format(data, r.text)
else:
return "Error"
import httplib, base64
host = "server.com"
path = "/foo/bar"
username = "jess"
password = "hunter2"
http = httplib.HTTP(host)
http.putrequest("GET", path)