Skip to content

Instantly share code, notes, and snippets.

@medwards
medwards / base.py
Created June 19, 2012 12:19
This produces an AssertionError. Why?
from sqlalchemy.ext.declarative import declarative_base, declared_attr
from sqlalchemy import Column, Integer, String, create_engine
Base = declarative_base()
class Thing(Base):
__tablename__ = 'things'
id = Column(Integer, primary_key=True)
name = Column(String)
discriminator = Column('type', String)
function reauthor_git()
{
git filter-branch -f --commit-filter '
GIT_AUTHOR_NAME=$1
GIT_AUTHOR_EMAIL=$2
git commit-tree "$@"
' $3
}
@medwards
medwards / commands.py
Created April 12, 2012 10:04
Adding custom commands to python setup.py
from setuptools import Command
class Compile(Command):
description = "run a custom compile command"
user_options = tuple()
def run(self):
print self.description
def initialize_options(self):
@medwards
medwards / create_cat_testdata.sh
Created April 2, 2012 12:42
An unprovable testsuite for cat
#!/bin/bash
i=0
while true
do
pass=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c $i`
echo $pass > ./testcases/length_$i.txt
i=$(($i + 1))
sleep 1
done
File "/home/medwards/.virtualenvs/pyramid/local/lib/python2.7/site-packages/chameleon/template.py", line 128, in __call__
return self.render(**kwargs)
File "/home/medwards/.virtualenvs/pyramid/local/lib/python2.7/site-packages/chameleon/zpt/template.py", line 258, in render
return super(PageTemplate, self).render(**vars)
File "/home/medwards/.virtualenvs/pyramid/local/lib/python2.7/site-packages/chameleon/template.py", line 188, in render
raise_with_traceback(exc, tb)
File "/home/medwards/.virtualenvs/pyramid/local/lib/python2.7/site-packages/chameleon/template.py", line 175, in render
self._render(stream, econtext, rcontext)
File "listing_ff766ad4b34fe2da3a424c3defebda82d297cfa5.py", line 223, in render
File "master_0f566c540119710058468ca546bb52d1cc73277f.py", line 289, in render_master
Traceback (most recent call last):
File "/home/medwards/.virtualenvs/pyramid/bin/pserve", line 9, in <module>
load_entry_point('pyramid==1.3', 'console_scripts', 'pserve')()
File "/home/medwards/.virtualenvs/pyramid/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 47, in main
return command.run()
File "/home/medwards/.virtualenvs/pyramid/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 290, in run
relative_to=base, global_conf=vars)
File "/home/medwards/.virtualenvs/pyramid/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 318, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "/home/medwards/.virtualenvs/pyramid/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
person = Person(name='Alice')
DBSession.add(person)
message = Message(person_id=person.id, content="a message to bob")
DBSession.add(message)
{% set row_blocks = [] %}
{% for item in items %}
{%- if row_width + item.width > 12 %}
{%- include "rowofstuff.html" %}
{%- for rowitem in row_blocks %}
{%- set something = row_blocks.remove(rowitem) %}
{%- endfor %}
{%- set row_width = 0 %}
{%- endif %}
{%- set something = row_blocks.append(item) %}
<html>
<head>
</head>
<body>
{% block thebody %}
{% include "something.html" %}
</body>
{% endblock %}
</html>
@medwards
medwards / gist:1381493
Created November 21, 2011 03:03
how to pass tests yick
Might be bad bc I removed some other junk in the diff
diff --git a/lib/play.rb b/lib/play.rb
index e8e7ceb..7ddc757 100644
--- a/lib/play.rb
+++ b/lib/play.rb
@@ -76,14 +76,16 @@ module Play
# Returns the Client subclass that matches the client requested
# in the config subclass.
def self.client