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 / KeysToKeystore.java
Last active August 29, 2015 14:05
Converts a private key (generated by OpenSSL's "genpkey") and a corresponding certificate chain (X.509 PEM) to a Java keystore.
// Released into the public domain.
// http://creativecommons.org/publicdomain/zero/1.0/
// converts a PKCS#8 PEM private key (as generated by OpenSSL's "genpkey")
// and a corresponding certificate chain (X.509 PEM) to a Java keystore.
// why can't keytool do this natively?
// warning: requires JRE 8 because it uses java.util.Base64
import java.io.BufferedInputStream;
@RavuAlHemio
RavuAlHemio / mbdbpy3.py
Created June 22, 2014 21:49
mbdb file decoder, ported to Python 3, no mbdx file needed
#!/usr/bin/env python3
import sys
import hashlib
def getint(data, offset, intsize):
"""Retrieve an integer (big-endian) and new offset from the current offset"""
value = 0
while intsize > 0:
value = (value << 8) | data[offset]
offset += 1
@RavuAlHemio
RavuAlHemio / cbencode.cpp
Last active August 29, 2015 14:02
HTML and URL encoding outgoing messages for the vBulletin chatbox, for Qt.
#include <iomanip>
#include <iostream>
#include <QByteArray>
#include <QSet>
#include <QString>
#include <QTextCodec>
static const QSet<QChar> urlSafeCharacters {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
@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
{