Skip to content

Instantly share code, notes, and snippets.

@iffy
iffy / hexagons.rst
Created September 12, 2011 15:22
Spec

Hexagon Dots

depth

4

Challenge

Your challenge is to write a bot to play the Hexagon dots game. Your bot will

@iffy
iffy / sample output
Created September 21, 2011 00:00
skool example
$ python
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from storm.locals import Store, create_database
>>> from skmodel import Student, Class, Grade
>>>
>>> # use test db
... db = create_database('sqlite:test.db')
>>> store = Store(db)
def getRecords(kw=None):
"""
@param kw: A dictionary of narrowing criteria for the records. For example,
if you wanted to only show records for student's named "Bill" you would
pass::
{'first': 'Bill'}
"""
if not kw:
@iffy
iffy / doc.py
Created September 23, 2011 16:58
minmal doctest example
import doctest
import work
suite = DocTestSuite(work)
# What goes here?
@iffy
iffy / bar.py
Created October 4, 2011 15:25
import error
from datetime import datetime, timedelta
from foo.datetime import something
@iffy
iffy / output
Created October 14, 2011 16:19
sql patcher
$ python patcher.py
-- UPDATE customer to version 1
create table customer (
id integer primary key,
);
update _schema_version set version='1' where what='customer';
-- UPDATE customer to version 2
alter table customer add column (email text);
create unique index foo on customer(email);
update _schema_version set version='2' where what='customer';
@iffy
iffy / output
Created November 1, 2011 22:31
coverage bug?
$ coverage run --branch ./thefile.py ; coverage report
Name Stmts Miss Branch BrPart Cover
-------------------------------------------
thefile 8 0 4 1 92%
@iffy
iffy / console
Created November 16, 2011 20:11
broken pipe
[matt] /tmp $ python
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from subprocess import Popen, PIPE
>>>
>>> f = open('dafile', 'w')
>>> f.write('import sys\n'
... 'raise Exception("hey")')
>>> f.close()
@iffy
iffy / client
Created November 30, 2011 16:14
sftp
[matt] ~ $ sftp -oPort=8022 foo@10.1.15.5:/somefile /tmp/somefile
Connecting to 10.1.15.5...
foo@10.1.15.5's password:
Fetching /somefile to /tmp/somefile
Cannot download non-regular file: /somefile
@iffy
iffy / gentoo py2.6 pg8.4.4 (production server)
Created December 21, 2011 22:50
psycopg unicodedecodeerror
Python 2.6.2 (r262:71600, Sep 14 2009, 13:43:10)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from psycopg2 import connect
>>> from psycopg2.extras import DictCursor
>>> from psycopg2 import extensions
>>>
>>> # do what you need to get these:
... from sm.db import connstr
>>>