Skip to content

Instantly share code, notes, and snippets.

View sahib's full-sized avatar
🤘

Chris Pahl sahib

🤘
View GitHub Profile
@sahib
sahib / cairo_play.py
Created April 6, 2013 19:26
Two Cairo Widgets usable for Gtk. Ported from FreyaMPD.
import cairo
from math import pi
from gi.repository import Gtk, Gdk
class CairoGtkWidget(Gtk.DrawingArea):
def __init__(self):
Gtk.DrawingArea.__init__(self)
# Theming Information (so cairo widgets look natural)
#!/bin/bash
# Description:
# Script to query mpd's status and download a cover of the currently playing
# song on song-change and execute a user-defined command to show the cover.
# (e.g. with notify-send, by default with a image viewer for testing)
# Feel free to make your customizations here.
MPD_SERVER="--port 6600 --host localhost" # For default case.
#!/usr/bin/env python
# encoding: utf-8
import sys
import os
def finish(data_set):
base_names = {}
for dup in data_set:
>>> def co():
... try:
... while True:
... item = yield
... print('Received:', item)
... except GeneratorExit:
... print('Exit.')
...
...
...
@sahib
sahib / pipeline.py
Created December 17, 2012 13:58
Pipeline Example with Python Coroutines
'''
Python coroutine Example for a Pipeline model.
--------- ------- -------
| Source | => send() => | Pipe | => send() => | Sink |
--------- ------- -------
close() shutdown the *whole* Pipeline.
'''
  • Fix libglyr, implement echonest
  • Things to look at:
    • weechat + bitlbee
    • mutt (finally?) or evolution looks good too.
    • taskwarrior extended
    • tmux
    • i3
    • IPython
  • Coding:
    • Clutter
@sahib
sahib / app.py
Created November 11, 2012 14:05
Musterlösung für die Flask Aufgabe
#!/usr/bin/env python
# encoding: utf-8
'''
Das ist die eigentliche Anwendung die ihr schreiben sollt.
Unten findet ihr bereits eine minimale Flask Anwendung.
Jetzt müsst ihr sie nur noch erweitern.
'''
@sahib
sahib / levenshtein_utf8.c
Created May 6, 2012 12:24
Better implementation to get the lv-distance of two utf8-strings
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <locale.h>
///////////////////////////////
// Old version
gsize levenshtein_plain_strcmp(const gchar * s, const gchar * t)
@sahib
sahib / utf8_levenshtein.c
Created May 6, 2012 10:46
Silly implementation for utf8 levenshtein (works by converting utf-8 to ucs4)
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
///////////////////////////////
gsize gunicode_strlen(const gunichar * s)
{
gsize cnt = 0;
@sahib
sahib / matrix.cc
Created April 17, 2012 19:17
Just playing with templates
#include <stdexcept> // std::invalid_argument
#include <cstdio> // printf()
#include <cstdlib> // EXIT_SUCCESS
#include <cstring> // memset()
namespace NV
{
template<typename FloatType, unsigned w, unsigned h> class matrix