Skip to content

Instantly share code, notes, and snippets.

View SpotlightKid's full-sized avatar

Christopher Arndt SpotlightKid

View GitHub Profile
@SpotlightKid
SpotlightKid / pyxrun.sh
Last active August 29, 2015 13:56
Here is a useful little shell function I came up with while experimenting with Cython (http://cython.org/). Put it in your ~/.bashrc and then use it to compile a Cython source code file (*.pyx extension) into a standalone executable and run it directly.
pyxrun() {
PYTHON="${PYTHON:-python}"
if [ "x$1" = "x-t" ]; then
local timeit="time"
shift
fi
if [ -z "$1" ]; then
echo "usage: pyxrun [-t] <file>.pyx"
cpdef int fib(int n):
if n == 2:
return 2
elif n < 0:
raise NotImplementedError
elif n <= 1:
return 1
else:
return fib(n-1) + fib(n-2)
@SpotlightKid
SpotlightKid / aurinfohelper.sh
Last active August 29, 2015 14:00
Generate .AURINFO file, create Arch source package and add .AURINFO to it
#!/bin/bash
#
# aurinfohelper.sh
#
process() {
if [ ! -f PKGBUILD ]; then
echo "PKGBUILD not found!"
else
source PKGBUILD
@SpotlightKid
SpotlightKid / email_ankuendigung.py
Last active August 29, 2015 14:05
Format announcement of next user group meeting given a template and a data file and open an email client with recipient, subject and body pre-filled.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""Format announcement of next user group meeting given a template and a data
file and open an email client with recipient, subject and body pre-filled.
Usage:
ankuendigung.py ankuedigung.tmpl meeting.data
where ``ankuendigung.tmpl`` is a Jinja2 template and ``meeting.data`` is an
@SpotlightKid
SpotlightKid / AutomationTest.pyui
Created August 14, 2014 00:22
Pythonista UI file for AutomationTest.py
[{"class":"View","attributes":{"name":"Automation Test","background_color":"RGBA(1.000000,1.000000,1.000000,1.000000)","tint_color":"RGBA(0.000000,0.478000,1.000000,1.000000)","enabled":true,"border_color":"RGBA(0.000000,0.000000,0.000000,1.000000)","flex":""},"frame":"{{0, 0}, {540, 575}}","nodes":[{"class":"View","attributes":{"enabled":true,"flex":"W","name":"view1","corner_radius":5,"border_width":1,"border_color":"RGBA(0.000000,0.000000,0.000000,1.000000)","background_color":"RGBA(0.928571,0.937143,1.000000,1.000000)","uuid":"320B1558-A4C5-4FD7-8DCE-208BAA15B0DC"},"frame":"{{9, 18}, {515, 107}}","nodes":[]},{"class":"Switch","attributes":{"enabled":true,"flex":"","name":"sw_light","value":false,"action":"","border_color":"RGBA(0.000000,0.000000,0.000000,1.000000)","uuid":"AEB0BAA8-F834-46B4-9825-E4D652511996"},"frame":"{{152, 58}, {51, 31}}","nodes":[]},{"class":"Label","attributes":{"font_size":17,"enabled":true,"text":"Licht an\/aus","flex":"","name":"label1","border_color":"RGBA(0.000000,0.000000,0.00
@SpotlightKid
SpotlightKid / parsedate.py
Last active August 29, 2015 14:05
Parse ISO-8601 formatted date/time strings with UTC offsets.
# -*- coding:utf-8 -*-
"""Parse ISO-8601 formatted date/time strings.
Uses only standard library modules and supports UTC offsets.
"""
__all__ = ("parse_isodate", "UTCOffset")
import re
@SpotlightKid
SpotlightKid / convert_hexstring.py
Created August 25, 2014 08:30
Convert a string in ASCII hexadecimal notation into a list of integers.
# -*- coding:utf-8 -*-
"""Convert a string in ASCII hexadecimal notation into a list of integers.
Example::
>>> convert_hexstring('F0 7E 7F 06 01 F7')
[240, 126, 127, 6, 1, 247]
>>> convert_hexstring('f07E7F 6 1 F7')
[240, 126, 127, 6, 1, 247]
import sound
class SoundManager(object):
def __init__(self, name = ''):
self._playing = dict()
def load_effect(self, name):
sound.load_effect(name)
def play_effect(self, name, volume=0.5, pitch=1.0):
@SpotlightKid
SpotlightKid / Next PyCologne Meeting.ipynb
Last active August 29, 2015 14:06
Print date and time of next PyCologne meeting in German
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SpotlightKid
SpotlightKid / graphicsstate.lua
Last active August 29, 2015 14:09
Functions to wrap love.graphics calls to preserve settings
--- Functions to wrap love.graphics calls to preserve settings like color,
-- line style, filters etc.
-- getLineJoin() throws an error if no line join mode is set in love 0.9.1
if not pcall(love.graphics.getLineJoin) then
love.graphics.setLineJoin('miter')
end
-- these are for love 0.9.1
local ALL_SETTINGS = {