Skip to content

Instantly share code, notes, and snippets.

View RavuAlHemio's full-sized avatar

Ondřej Hošek RavuAlHemio

View GitHub Profile
@RavuAlHemio
RavuAlHemio / IntHashtable.java
Created December 15, 2013 00:37
Java-Dateien für PK (2013W) Blatt 7 Aufgabe 5
// Hashtabelle ist Beispiel für die Nutzung von Zufall und Wahrscheinlichkeit
// Hashtabelle ganzer Zahlen
// verwendet verkettete Liste zum Umgang mit Kollisionen
public class IntHashtable {
public static final int TABSIZE = 1024; // Größe der Hashtabelle
private IntListNode[] tab = new IntListNode[TABSIZE]; // die eigentliche Hashtabelle
// berechne den Hashwert von elem
@RavuAlHemio
RavuAlHemio / Charr.java
Last active December 31, 2015 03:48
Demonstration of reflective programming in Java.
// Released into the public domain.
// http://creativecommons.org/publicdomain/zero/1.0/
// Tipp:
// Integer.TYPE: Class<?>, die den primitiven Datentyp int beschreibt
// Integer.class: Class<?>, die die Integer-Klasse beschreibt
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@RavuAlHemio
RavuAlHemio / Cycle.java
Last active December 30, 2015 19:49
PK Cycle class
public class Cycle
{
private int elem;
private Cycle next;
public Cycle(int value, Cycle cycle) {
elem = value;
if (cycle == null) {
next = this;
} else {
@RavuAlHemio
RavuAlHemio / pabt-raindance.py
Created December 8, 2013 03:21
Powers on the bluetooth adapter, connects to the headset and sets it as the default PulseAudio sink.
#!/usr/bin/env python3
# Powers on the bluetooth adapter, connects to the headset and sets it as
# the default PulseAudio sink.
#
# Released into the public domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from sys import stderr
from gi.repository import GLib, Gio
from subprocess import Popen
@RavuAlHemio
RavuAlHemio / noper.py
Last active December 29, 2015 12:19
noper -- adds a "nope" overlay over a PNG, JPEG or (optionally animated) GIF
#!/usr/bin/env python3
import re
import os, os.path
import tempfile
from subprocess import Popen, PIPE
"""
RealPopen = Popen
def Popen(args, *posarg, **kwarg):
print(args)
@RavuAlHemio
RavuAlHemio / TheInvisible.java
Last active December 26, 2015 17:09
The Invisible: Checks for questionable visibility in a list of Java classes.
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/**
* The Invisible
*
* Checks for questionable visibility in a list of classes.
*
@RavuAlHemio
RavuAlHemio / dupeaddresses.py
Created September 4, 2013 20:57
OSM-XML duplicate address detector
#!/usr/bin/env python3
#
# Detects duplicate address specifications (addr:street, addr:housenumber
# and possibly addr:unit) in an OSM XML file.
#
# Released into the public domain.
from xml.dom.minidom import parseString as domParse
import xml.dom as dom
@RavuAlHemio
RavuAlHemio / fuelrod_config_diagrammer.py
Created July 29, 2013 01:30
Fuel rod configuration diagram creation script.
#!/usr/bin/env python3
# Creates fuel-rod diagrams.
import re
MARGIN_TOP = 4.5
MARGIN_LEFT = 4.5
MARGIN_RIGHT = 5.5
MARGIN_BOTTOM = 5.5
BOX_WIDTH = 50
@RavuAlHemio
RavuAlHemio / winfixres.c
Created July 27, 2013 19:39
Changes the resolution of a display on Windows. Useful for fixing the size of Wine's virtual desktop.
/**
* Changes the resolution of a display on Windows.
* Useful for fixing the size of Wine's virtual desktop.
*
* Released into the public domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
#include <stdio.h>
#include <wchar.h>
@RavuAlHemio
RavuAlHemio / pounceandwrite.c
Created July 27, 2013 19:38
Pounce-and-write. Waits until a file is accessible, then either writes a set of lines into it or executes a command.
/**
* Pounce-and-write. Waits until a file is accessible, then either writes a set
* of lines into it or executes a command.
*
* Released into the public domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
#include <errno.h>
#include <stdbool.h>