Skip to content

Instantly share code, notes, and snippets.

View hernantz's full-sized avatar
🏠
Working from home

hernantz

🏠
Working from home
View GitHub Profile
@hernantz
hernantz / tictactoe.py
Last active August 29, 2015 14:14
Simple tic tac toe game
# -*- coding: utf-8 -*-
GRID = {
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
@hernantz
hernantz / grooveshark_api.py
Last active August 29, 2015 14:07
Grooveshark Python API
#!/usr/bin/env python
import httplib
import StringIO
import hashlib
import uuid
import random
import string
import sys
import os
import subprocess
@hernantz
hernantz / common_fabfile.py
Last active July 14, 2017 06:00
Fabfile with common fabric tasks, featuring virtualenvwrapper, nginx, supervisord, git deployment and some other goodies.
from fabric.api import task, local, sudo, run, prefix, env, cd
from fabric.contrib.files import exists, first
from contextlib import contextmanager, nested
def once(s):
"""Command_prefixes is a list of prefixes"""
if s not in env.command_prefixes:
return s
return 'true'
@hernantz
hernantz / test_union_find.py
Created August 19, 2012 22:20
These files are the python implementation of the union find algoritm and it's unit tests.
#!/usr/bin/env python
import unittest
from union_find import UnionFind
class TestUnionFind(unittest.TestCase):
def test_init(self):
u = UnionFind(5)
self.assertEquals([0, 1, 2, 3, 4], u.id)