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 / exmp3.py
Created May 9, 2014 09:02
find and extract MP3 files from a binary file
#!/usr/bin/env python3
from math import floor
import struct
mp3_bit_rates = {
0b0001: 32000,
0b0010: 40000,
0b0011: 48000,
0b0100: 56000,
0b0101: 64000,
@RavuAlHemio
RavuAlHemio / deriff.py
Created May 9, 2014 07:46
dissect a RIFF file and extract all WAVE components into .wav files
import io
import struct
container_chunks = {b"RIFF", b"LIST"}
class RiffChunk:
def __init__(self, tag, data):
self.tag = tag
self.data = data
@RavuAlHemio
RavuAlHemio / gdbcheatsheet.md
Created February 2, 2014 12:20
gdb cheat sheet (in German)

Programm starten

Programmargumente können entweder auf der Kommandozeile übergeben werden:

gdb --args ./prog arg1 arg2 arg3

oder als Teil des gdb-Befehls run:

gdb ./prog

@RavuAlHemio
RavuAlHemio / runas-stdio.cpp
Created January 27, 2014 09:13
runas-stdio: A variant of runas which takes all its parameters as UTF-8 strings via stdio.
// Released into the public domain.
// http://creativecommons.org/publicdomain/zero/1.0/
#include <string>
#include <cstdio>
#include <fcntl.h>
#include <io.h>
#include <windows.h>
@RavuAlHemio
RavuAlHemio / secvault.c
Created January 19, 2014 23:55
secvault kernel module
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/cdev.h>
#include <linux/semaphore.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/thread_info.h>
#include <linux/sched.h>
@RavuAlHemio
RavuAlHemio / apples.py
Created January 19, 2014 15:24
given a set of wanted apple types, find combinations of apple types that ensure every apple tree is well-pollinated
import logging
__author__ = 'ondra'
logger = logging.getLogger("apples")
class Apple:
def __init__(self, number, name, bloom_time, good_donors=None, other_donors=None,
triploid=False):
"""
@RavuAlHemio
RavuAlHemio / clusters.cpp
Created January 7, 2014 19:44
finding the connected components of a graph
#include <QQueue>
#include <QSet>
#include <iostream>
#include <cstdint>
class Pixel
{
@RavuAlHemio
RavuAlHemio / Main.java
Created December 16, 2013 18:16
Lösung von Tutorium 05-ods-gleichheit, Beispiel 01-copy
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int N = 10;
Wohnung[] wohnungen = new Wohnung[N];
Wohnung klein = new Wohnung(3, 28);
@RavuAlHemio
RavuAlHemio / Haus.java
Created December 16, 2013 18:16
Lösung von Tutorium 05-ods-gleichheit, Beispiel 03-deep
import java.util.Arrays;
public class Haus {
private Wohnung[] wohnungen;
public Haus() {
wohnungen = new Wohnung[0];
}
@RavuAlHemio
RavuAlHemio / Main.java
Last active December 31, 2015 13:09
Lösung von Tutorium 05-ods-gleichheit, Beispiel 02-compare
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int N = 10;
Wohnung[] wohnungen = new Wohnung[N];
Wohnung klein = new Wohnung(3, 28);