Skip to content

Instantly share code, notes, and snippets.

View sahib's full-sized avatar
🤘

Chris Pahl sahib

🤘
View GitHub Profile
#!/usr/bin/python
def find_next_free_x_display():
for i in range(10):
try_path = "/tmp/.X" + str(i) + "-lock"
try:
with open(try_path,"r"):
print("-- " + str(i) + " is there")
except:
return i
#!/usr/bin/env python
import os, sys, time
def find_next_free_x_display(max_tries = 10):
"""
Find the next free X Display by
investigating the Xlocks in /tmp
"""
for i in range(max_tries):
#!/usr/bin/env python
import os, sys
def find_next_free_x_display(max_tries = 10):
"""
Find the next free X Display by
investigating the Xlocks in /tmp
"""
for i in range(max_tries):
#!/usr/bin/env python
import sqlite3, unittest
class KittehDB:
def __init__(self,path):
"""
Creates database at specified path
"""
print("Creating Database")
#!/usr/bin/env python
import re, urllib.request, sys
from html.parser import HTMLParser
from urllib.error import HTTPError,URLError
class TableHTMLParser(HTMLParser):
def __init__(self):
super(TableHTMLParser,self).__init__()
self.__interest = False
self.__lastday = "Montag"
@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
@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 / 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.
'''
  • Fix libglyr, implement echonest
  • Things to look at:
    • weechat + bitlbee
    • mutt (finally?) or evolution looks good too.
    • taskwarrior extended
    • tmux
    • i3
    • IPython
  • Coding:
    • Clutter
>>> def co():
... try:
... while True:
... item = yield
... print('Received:', item)
... except GeneratorExit:
... print('Exit.')
...
...
...