Skip to content

Instantly share code, notes, and snippets.

'''
VERY HACKY, DO NOT USE OR DO NOT COMPLAIN.
It was written to deal with forms.fields tests and those tests only.
'''
f = open('forms.py', 'r')
out = open('out.py', 'w')
res_words = ['def', 'from', 'try', 'import']
class PageParserAndThumbnailer(object):
def __init__(self, url, http_response):
self.url = url
self.headers, self.body = self.parse(http_response)
@property
def thumbnail(self):
"create expensive thumbnail"
def parse(self, http_response):
@honzakral
honzakral / run_django_tests.sh
Created December 29, 2009 05:32
Script for paralel execution of django's test suite.
#!/bin/bash
set -e
##
# Script for paralel execution of django's test suite.
#
# Usage: place it in the same directory as your django checkout (not inside)
# and run it
#
# Params: you can optionally supply number of processes to spawn
#!/bin/sh
### BEGIN INIT INFO
# Provides: hookbox
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 1
# Short-Description: hookbox server
### END INIT INFO
@honzakral
honzakral / bootstrap.sh
Created November 3, 2011 14:30
Testable python code...
#!/bin/bash
curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
python virtualenv.py testing_in_python
. testing_in_python/bin/activate
pip install django mock
python testable_templatetag.py

Stackoverflow to Elasticsearch

This script will load any stackoverflow site from the XML dump (retrievable at https://archive.org/details/stackexchange via torrent) into Elasticsearch.

To use just call:

python load_stack.py PATH
@honzakral
honzakral / -README.rst
Last active August 24, 2020 09:24
WebExpo demo
@honzakral
honzakral / README.rst
Last active December 25, 2015 22:08
Coding Dojo

WTF Game

Created at PyCon PL as a coding dojo challenge

"query": {
"bool": {
"must": [
{
"query_string": {
"query": "\"ruby\" OR \"rubi\" OR \"rubz\"",
"default_operator": "or"
}
}
],
# -*- coding: cp1250 -*-
class Halda():
"""halda - dokumentace
TYP 1A na vrcholu nejmenší hodnota, prosté položky
TYP 1B na vrcholu nejmenší hodnota, strukturované položky
TYP 2A na vrcholu největší hodnota, prosté položky
TYP 2B na vrcholu největší hodnota, strukturované položky
"""
### 0 Konstrukční procedury