Skip to content

Instantly share code, notes, and snippets.

"""
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
@brunobord
brunobord / bash_prompt.sh
Created October 14, 2012 14:07 — forked from bradsokol/bash_prompt.sh
Set color bash prompt according to active virtualenv, Git, Mercurial or Subversion branch and return status of last command.
#!/bin/bash
#
# DESCRIPTION:
#
# Set the bash prompt according to:
# * the active virtualenv
# * the branch/status of the current Git, Mercurial or Subversion repository
# * the return value of the previous command
# * the fact you just came from Windows and are used to having newlines in
# your prompts.
@brunobord
brunobord / *.sublime-keymap
Created May 24, 2012 08:40 — forked from n1k0/*.sublime-keymap
SublimeText2 macro and key binding for quickly wrapping text at 80 columns
/**
* Sample key binding (emacs users will hate it, but they're probably not using SublimeText2)
*
*/
[
{ "keys": ["ctrl+w"], "command": "run_macro_file", "args": {"file": "Packages/User/Quick Wrap.sublime-macro"}}
]
def _cmp(a, b):
# print a, b
if a == b:
return 0
if a.startswith(b) == 0:
return 1
else:
return -1
# my CMP... Comparing the first letter is not enough, IMHO.