Skip to content

Instantly share code, notes, and snippets.

View sahib's full-sized avatar
🤘

Chris Pahl sahib

🤘
View GitHub Profile
// Übungsbeispiel Stöhr
// man sollte erst versuchen es selbst zu lösen und dann das hier zu lösen.
// (Ich bin mir nicht sicher was schwerer ist :-))
// Sind vermutlich ein paar Fehler drin - einfach unten posten.
// (Anmerkung: Die Kommentare sind nicht von Prof. Stöhr)
#include <stdio.h>
/* Ein Array aus Strings */
char *c[] = {"ENTER", "NEW", "POINT", "FIRST"};
// Kurzes Beispiel wie man die Member einer Template Klasse
// doch noch auslagern kann - vor Gebrauch in Datein aufsplitten :-)
// Kompilieren mit: g++ template_main.cc template.cc template.hh -Wall -Wextra
//
// Das ganze ist etwas unschön. Was lernen wir daraus?
// Das gleiche wie bei 'new' templates nur benutzen wenn's
// wirklich begründet ist.
// ~c3
//===================================
#include <glib.h>
#include <stdlib.h>
#include <string.h>
static void foreach_file(const gchar * song_dir_path, const gchar * regex);
static gboolean path_go_up(char * song_dir_path);
static void find_in_musictree(const gchar * song_file_path, const gchar * regex, gint up_to);
//---------------------------------------------------
require 'find'
require 'tempfile'
$license = <<-eos
/* Cats insert there license here
* Hmm. Replace this.
*/
eos
# Insert license at beginning, using a crappy tmp file.
def randomize str
out = ""
pos = (0..str.length-1).to_a
pos.each do |num|
new_pos = rand(str.length-1)
# Swap
tmp = pos[num]
pos[num] = pos[new_pos]
import java.lang.Math;
import java.util.Arrays;
class A3 extends Thread {
private static final int N = 3;
private int myid = 0;
public volatile static Integer array[] = {0,0,0};
A3(int i)
#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/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):