Skip to content

Instantly share code, notes, and snippets.

View akx's full-sized avatar
👹
rer

Aarni Koskela akx

👹
rer
View GitHub Profile
akx@monolith:/tmp$ virtualenv django-venv
New python executable in django-venv/bin/python
Installing distribute..................................................................................................................................................................................done.
akx@monolith:/tmp$ . django-venv/bin/activate
(django-venv)akx@monolith:/tmp$ pip install django
Downloading/unpacking django
Downloading Django-1.4.3.tar.gz (7.7Mb): 7.7Mb downloaded
Running setup.py egg_info for package django
Installing collected packages: django
Running setup.py install for django
@akx
akx / Output.xml
Created January 9, 2013 12:01
Fun with DSLs, Coco style.
<foo>
<bar baz="quux"/>
<derp>and some content
<nested/>
<nested-too/>
</derp>
</foo>
class uWSGICacheBackedDict(object):
def __init__(self, prefix=""):
self.prefix = prefix
def __getitem__(self, key):
value = uwsgi.cache_get(self.prefix + str(key))
if value is None:
raise KeyError(key)
return value
@akx
akx / client.py
Created May 15, 2013 16:08
Simple uWSGI + XML-RPC
import xmlrpclib
s = xmlrpclib.ServerProxy('http://localhost:3040')
print s.pow(2,3)
print s.sum([2,3])
print s.system.listMethods()
@akx
akx / client.py
Last active December 17, 2015 09:09
Slightly less simple uWSGI + XML-RPC + uWSGI RPC (madness!)
import xmlrpclib
s = xmlrpclib.ServerProxy('http://localhost:58080')
print s.system.listMethods()
print s.pow(2,3)
print s.sum([2,3])
print s.hello("world")
@akx
akx / heta.sh
Last active December 18, 2015 17:58
#!/bin/bash
curl -s -o /tmp/heta.wav http://www.bitlips.fi/tts/`curl -s "-Finput=$1" -Fvox=1 -Ffx=5 -Fspeed=-2 http://www.bitlips.fi/tts/demo.cgi | grep -oE "tmp.+?wav"`
[ -f /usr/bin/afplay ] && /usr/bin/afplay /tmp/heta.wav || sox /tmp/heta.wav -d
import ctypes, win32con, functools
U = ctypes.windll.user32
EnumWindows = U.EnumWindows
EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
GetWindowText = U.GetWindowTextW
RealGetWindowClass = U.RealGetWindowClass
IsWindowVisible = U.IsWindowVisible
PostMessage = U.PostMessageW
WM_CLOSE = 16
@akx
akx / gifgif.py
Created October 29, 2013 16:21
Generate GIFs from random bits of videos.
# Inspired by http://rarlindseysmash.com/posts/stupid-programmer-tricks-and-star-wars-gifs
# via https://news.ycombinator.com/item?id=6633490
# Requires
# * a reasonably recent ffmpeg suite
# * Graphicsmagick or ImageMagick
# * optionally: Gifsicle
# * an input video file
# Usage:
# python gifgif.py a_video_file.avi
@akx
akx / cairocffi-22.py
Created November 4, 2013 18:56
Exploring cairocffi/#22
import cairocffi as cairo
import hashlib
from cStringIO import StringIO
from collections import Counter
import threading, sys, traceback, time
class ImageGenerator(object):
def __init__(self, text):
self.text = text
@akx
akx / gist:8528051
Created January 20, 2014 20:09
paramiko/paramiko #193/#230 test results
These were run on a Windows XP x32 virtual machine.
Python 2.5:
HEAD broken due to ctypes changes
#230 broken due to ctypes changes
Python 2.6:
HEAD broken re agent authentication
#230 works
Python 2.7
HEAD broken re agent authentication