Skip to content

Instantly share code, notes, and snippets.

View velnias75's full-sized avatar
🏠
Working from home

Heiko Schäfer velnias75

🏠
Working from home
View GitHub Profile
@velnias75
velnias75 / qgithubreleaseapi-9999.ebuild
Last active February 14, 2016 06:41
Gentoo ebuild for QGitHubReleaseAPI with GitHub fetch
# Copyright 2015 Heiko Schaefer <heiko@rangun.de>
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
inherit cmake-utils eutils git-r3
DESCRIPTION="Qt library to receive release information from the GitHub API"
HOMEPAGE="https://github.com/velnias75/QGitHubReleaseAPI"
@velnias75
velnias75 / rnd_expr.py
Last active February 18, 2016 05:03
Python script to create random (huge) expressions
#!/usr/bin/env python
#
# Copyright (C) 2016 Heiko Schaefer <heiko@rangun.de>
#
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
#
import ast
@velnias75
velnias75 / timeleft.sh
Created October 31, 2016 15:22
Simple time estimator for avconv, without any error checking
#!/bin/sh
#
# Simple time estimator for avconv, without any error checking
#
# Usage: timeleft.sh HH:MM:SS.nn SOURCE_FPS ENCODE_FPS TIME
#
# Notice: for fractional SOURCE_FPS multiply SOURCE_FPS to an integer
# and ENCODE_FPS by the same factor,
# i.e. ENCODE_FPS=24.92 and SOURCE_FPS=5 => 2492 500
#
@velnias75
velnias75 / aplan.xslt
Last active April 15, 2017 07:21
XSLT-template to output a VLC playlist suitable to convert to MP4 files
<stylesheet version="1.0"
xmlns="http://www.w3.org/1999/XSL/Transform"
xmlns:strings="http://exslt.org/strings"
xmlns:xspf="http://xspf.org/ns/0/">
<output method="text" encoding="utf-8"/>
<variable name="apos">'</variable>
<param name="outdir" select="'/data1/var/tmp'"/>
@velnias75
velnias75 / karatsuba.php
Last active July 16, 2017 04:16
PHP implementation of the Karatsuba algorithm (base 10)
<?php
function karatsuba($num1, $num2) {
if(($num1 < 10) || ($num2 < 10)) {
return $num1 * $num2;
}
$m = ceil((max(ceil(log10($num1)), ceil(log10($num2))))/2);
@velnias75
velnias75 / log2.py
Last active October 14, 2017 02:08
Recursive/iterative/native integer log2 algorithm comparison in Python
#
# Recursive/iterative/native integer log2 algorithm comparison in Python
#
# (c) 2017 Heiko Schaefer <heiko@rangun.de>
#
import sys, time, math
# recursive
def log2r(a, b = 0):
@velnias75
velnias75 / bicot.cpp
Created November 5, 2017 09:09
Binominal coefficient constant template
/*
* binominal coefficient constant template
*
* g++ --std=c++11 -g0 -O3 -s bicot.cpp -o bicot
*
* (c) 2017 by Heiko Schaefer <heiko@rangun.de>
*
*/
#include <iostream>
@velnias75
velnias75 / bico.c
Last active November 5, 2017 09:10
Calculate binominal coefficient
/*
* calculate binominal coefficient
*
* gcc -std=c99 -g0 -O3 -s bico.c -o bico -lm
*
* (c) 2017 by Heiko Schaefer <heiko@rangun.de>
*
*/
#include <math.h>
@velnias75
velnias75 / ilog.S
Created April 18, 2018 11:09
Assembler integer logarithm
# unsigned int ilog(unsigned int value, unsigned int base);
# (c) 2018 by Heiko Schaefer
.section .text
.globl ilog
.type ilog, @function
ilog:
pushl %ebp
movl %esp, %ebp
@velnias75
velnias75 / dynv6.sh
Created July 27, 2018 05:47 — forked from corny/dynv6.sh
Update script for dynv6.com to set your IPv4 address and IPv6 prefix
#!/bin/sh -e
hostname=$1
device=$2
file=$HOME/.dynv6.addr6
[ -e $file ] && old=`cat $file`
if [ -z "$hostname" -o -z "$token" ]; then
echo "Usage: token=<your-authentication-token> [netmask=64] $0 your-name.dynv6.net [device]"
exit 1
fi