Skip to content

Instantly share code, notes, and snippets.

View narfdotpl's full-sized avatar

Maciej Konieczny aka narf narfdotpl

View GitHub Profile
@narfdotpl
narfdotpl / gist:1835101
Created February 15, 2012 11:09
running tests with Johnny Cache on

Oh, the joys of running tests with Johnny Cache on...

ipdb> Currency.objects.all()
[]
ipdb> Currency.objects.get(symbol='EUR')
<Currency: EUR/PLN>
ipdb> Currency.objects.count()

0

@narfdotpl
narfdotpl / mini.md
Created January 6, 2012 22:06
Mini based cars
@narfdotpl
narfdotpl / README.md
Created October 10, 2011 19:36
PyWaw troll
@narfdotpl
narfdotpl / magic.py
Created September 23, 2011 23:04
JS game engines by number of watchers
#!/usr/bin/env python
# encoding: utf-8
"""
Get list of JavaScript game engines ordered by number of watchers at GitHub.
"""
import json
from BeautifulSoup import BeautifulSoup
import requests
@narfdotpl
narfdotpl / gist:1180921
Created August 30, 2011 13:47
memory leak in a Django app
# source of a massive memory leak in a Django app (if obj is QuerySet):
if not obj:
return None
@narfdotpl
narfdotpl / jc.py
Created August 15, 2011 09:58
invalidate Johnny Cache
#!/usr/bin/env python
# encoding: utf-8
"""
Invalidate Johnny Cache's cache for given models outside "normal Django"
(e.g. in a management command).
"""
from johnny.cache import invalidate
from johnny.middleware import QueryCacheMiddleware
@narfdotpl
narfdotpl / fix-it-fix-it
Created June 18, 2011 13:01
fix iTunes icon
#!/usr/bin/env sh
sudo curl -L http://3.narf.pl/iTunes.icns > /Applications/iTunes.app/Contents/Resources/iTunes.icns
echo 'relog, remove itunes from dock, go to /Applications and drag it back'
@narfdotpl
narfdotpl / gist:995048
Created May 27, 2011 11:10
mysql unicode ffs
-- mysql unicode ffs
DROP DATABASE foo;
CREATE DATABASE foo CHARACTER SET utf8 COLLATE utf8_general_ci;
@narfdotpl
narfdotpl / gist:860606
Created March 8, 2011 17:26
fix plotting in Octave.app

To fix plotting in Octave.app in latest Snow Leopard (10.6.6 at the moment of writing) change /Applications/Gnuplot.app/Contents/Resources/bin/gnuplot as follows:

@@ -31,7 +31,7 @@ ROOT=`(cd "${BASE}" 2>/dev/null && pwd)`
 # startup the Gnuplot program.
 GNUPLOT_HOME="${ROOT}"
 PATH="${ROOT}/bin:${PATH}"
-DYLD_LIBRARY_PATH="${ROOT}/lib:${DYLD_LIBRARY_PATH}"

+DYLD_LIBRARY_PATH="${ROOT}/lib"

@narfdotpl
narfdotpl / mysqldb.markdown
Created December 4, 2010 16:01
MySQLdb, Python 2.5 and OS X 10.6

MySQLdb, Python 2.5 and OS X 10.6

I wasted too much time trying to make MySQLdb work with Python 2.5 (mysteriously it worked fine with 2.7). I thought I'll share my experience.

I installed MySQLdb normally with pip install MySQL-python (yeah, ingenious name) and there were no problems. But every time I imported it, I got following error: