Skip to content

Instantly share code, notes, and snippets.

Avatar

Christopher Arndt SpotlightKid

View GitHub Profile
@SpotlightKid
SpotlightKid / pyxrun.sh
Last active Aug 29, 2015
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.
View pyxrun.sh
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"
View fibonacci.py
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 Aug 29, 2015
Generate .AURINFO file, create Arch source package and add .AURINFO to it
View aurinfohelper.sh
#!/bin/bash
#
# aurinfohelper.sh
#
process() {
if [ ! -f PKGBUILD ]; then
echo "PKGBUILD not found!"
else
source PKGBUILD
@SpotlightKid
SpotlightKid / email_ankuendigung.py
Last active Aug 29, 2015
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.
View email_ankuendigung.py
#!/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 Aug 14, 2014
Pythonista UI file for AutomationTest.py
View AutomationTest.pyui
[{"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 Aug 29, 2015
Parse ISO-8601 formatted date/time strings with UTC offsets.
View parsedate.py
# -*- 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 Aug 25, 2014
Convert a string in ASCII hexadecimal notation into a list of integers.
View convert_hexstring.py
# -*- 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]
View soundmanager.py
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 / getcomments.py
Last active Aug 29, 2015
Parse Python source code from file and get/print source code comments.
View getcomments.py
# -*- coding: utf-8 -*-
"""Parse Python source code from file and get/print source code comments."""
__all__ = ('get_comments', 'get_comment_blocks')
import tokenize
from io import StringIO
@SpotlightKid
SpotlightKid / Next PyCologne Meeting.ipynb
Last active Aug 29, 2015
Print date and time of next PyCologne meeting in German
View Next PyCologne Meeting.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.