Skip to content

Instantly share code, notes, and snippets.

View sahib's full-sized avatar
🤘

Chris Pahl sahib

🤘
View GitHub Profile
@sahib
sahib / semaphor.c
Last active September 4, 2019 10:22
A rather primitive Semaphore implementation in C using pthreads
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
/* Stupid implementation of C semaphores with pthreads.
* Used as mutex for counting a variable below.
*
* compile with:
*
* cc semaphor.c -o sam -lpthread -Wall -Wextra -std=c99 -Os
#include <glyr/glyr.h>
#include <glyr/cache.h>
#include <glib.h>
#include <stdlib.h>
void do_insert(GlyrQuery * q, GlyrDatabase * db, char * artist, char * album, char * title)
{
glyr_query_init(q);
glyr_opt_artist(q,artist);
glyr_opt_album(q,album);
@sahib
sahib / trav.c
Created March 18, 2012 18:27
corrected trav.c
#include <stdio.h>
#include <fts.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
typedef struct
{
char * path;
@sahib
sahib / MemPool.cc
Created March 27, 2012 13:19
(Silly) Per-Type-based Mempool
// g++ MemPool.cc $(pkg-config --libs --cflags glib-2.0) -Wall -Wextra -pedantic
#include <glib.h>
#include <algorithm>
template<class StorageClass>
class UseMemPool
{
public:
void * operator new(size_t size)
#!/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
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, 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, 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 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"