Skip to content

Instantly share code, notes, and snippets.

sm = Selmaho()
sm.selmaho = smt
sm.multi = 1
session.save(sm)
print session.query(Selmaho).count()
def query(self, query=None, type=None, valsi=[], gloss=None,
rafsi=[], selmaho=None, definition=None, notes=None,
regexp=False, like=None):
results = []
if query:
args = {"gloss": gloss, "valsi": valsi, "rafsi": rafsi,
"selmaho": selmaho, "definition": definition, "notes": notes,
"regexp": regexp, "type": type}
listargs = ["valsi", "rafsi"]
@timo
timo / Dancer.rb
Created June 12, 2009 10:30 — forked from tene/Dancer.rb
class Dancer
def description()
"is like a beautiful swan, gracefully flying over a lake"
end
def steps()
"⚡→→→→↓↓↓↓←↓→↓←↑↑↑↑→↓←↑Ϟ"
end
def dance()
puts self.WHAT
puts "My dance " + self.description
import threading
import time
import subprocess
# make the system preload the sound
subprocess.Popen(["mplayer", "/home/timo/.drama/drama.ogg", "-ao", "null"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
def prebuffer_image(image):
open("/home/timo/Pictures/wallpapers/" + image, "r").read()
threading.Thread(target=prebuffer_image, args=("kittenface.jpg",)).start()
class City(Base):
__tablename__ = "city"
name = Column(Unicode(6), primary_key=True)
rooms = relationship("Room", backref="city")
def __repr__(self):
return u'<City "%s" with %d rooms>' % (self.name, len(self.rooms))
class Room(Base):
__tablename__ = "room"
@timo
timo / flymake.vim
Created April 5, 2011 22:08
python flymake ftplugin
if !exists('b:did_flymake')
let b:did_flymake = 1
autocmd BufWritePost <buffer>
\ call FlyMake('cd %s; export FN="%s"; pylint "$FN"; pep8 "$FN"; pyflakes "$FN"',
\ '[^:]*:\([0-9]*\):\%\(.*:\)? \(.*\)',
\ '.*:\([0-9]*\):\%\(.*:\)? \(.*\)')
autocmd BufWinLeave <buffer> call FlyMakeCloseWindows()
endif
@timo
timo / flymake_part.vim
Created April 5, 2011 22:35
a part of flymake-vim (or rather: my version of it)
function! s:FlyMakeDisplay(buf, type, msg, regexp)
let source_file = expand("%")
let dic = s:FlyMakeParseDictionary(a:msg, a:regexp)
if len(keys(dic)) == 0
return 0
endif
let sorted_keys = sort(keys(dic), function('s:FlyMakeNumberSort'))
execute 'match' a:type "'\\%" . sorted_keys[0] . "l'"
call cursor(sorted_keys[0], 1)
#!/usr/bin/env python
# -*- coding:utf8 -*-
import urllib
import lxml.etree
from subprocess import Popen
rohdaten = urllib.urlopen("http://events.ccc.de/camp/2011/Fahrplan/schedule.en.xml").read()
#daten = unicode(rohdaten, "latin1")
daten = rohdaten
@timo
timo / notebook_launcher.py
Created December 19, 2011 16:26
branded ipython notebook launcher
"""==============================
Branded IPython Notebook Launcher
=================================
Executing this module will create an overlay over ipython notebooks own static
files and templates and overrides static files and templates and copies over all
example notebooks into a temporary folder and launches the ipython notebook server.
You can use this to offer an interactive tutorial for your library/framework/...
@timo
timo / gist:1627867
Created January 17, 2012 18:03
implement ravel method for numpypy
diff -r 07bd76d923fd pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py Wed Jan 18 09:32:00 2012 +1000
+++ b/pypy/module/micronumpy/interp_numarray.py Sat Jan 21 21:33:07 2012 +0100
@@ -558,6 +558,12 @@
arr.setshape(space, new_shape)
return arr
+ def descr_ravel(self, space, w_order="C"):
+ if space.str_w(w_order) != "C":
+ raise OperationError(space.w_NotImplementedError, space.wrap(