Skip to content

Instantly share code, notes, and snippets.

View hilbix's full-sized avatar
🐢
I may be slow to respond.

Valentin Hilbig hilbix

🐢
I may be slow to respond.
View GitHub Profile
@hilbix
hilbix / avcheck.sh
Created February 1, 2015 04:11
Print runtime length of a video (and number of estimated frames)
#!/bin/bash
avcheck()
{
avprobe "$1" -show_packets 2>/dev/null |
awk -F'=' -vN="$1" '
/^\[/ { if (arm && k["codec_type"]=="video") { last=k["dts_time"]; # printf "%s", k["flags"];
}; delete k; arm=1; next; }
arm { k[$1]=$2; }
$0=="codec_type=video" { frames++; }
@hilbix
hilbix / wtfpl
Created October 27, 2015 11:42 — forked from nielsvanderbeke/wtfpl
Do What The Fuck You Want To Public License
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@hilbix
hilbix / COPYRIGHT.CLL
Created October 27, 2015 11:38
COPYRIGHT.CLL copied from http://permalink.de/tino/cll
@hilbix
hilbix / kswapd-check.sh
Created March 28, 2013 15:27
Bash/AWK script to detect 100% CPU on kswapd processes, caused by a known Linux kernel issue on RHEL 5.5 (and CentOS) kernel 2.6.18-194.el5. Returns 0 if no problem, and usually 2 when the problem hits. (Note: It will return 1 on first invocation. Better safe than sorry.)
#!/bin/bash
PIDFILE=/tmp/kswapd-check.pids
scanpids()
{
cat -s /proc/[1-9]*/stat 2>/dev/null |
awk 'BEGIN {
want["(kswapd0)"]=1;
want["(kswapd1)"]=1;
@hilbix
hilbix / CopySelectedMessagesHeadersToClipboard.outlook2003.vba
Last active December 17, 2015 10:49
Outlook 2003 Macro to copy selected Mails with full Mail headers into Clipboard Needs "Microsoft Forms 2.0 Object Library" (WIN/system32/FM20.dll) und "Microsoft CDO 1.21 Library" (SHARED/system/msmapi/1031/cdo.dll)
' Source https://gist.github.com/hilbix/5597981
Public Sub CopySelectedMessagesHeadersToClipboard()
Dim sel As Outlook.Selection
Dim msg As Outlook.MailItem
Dim n As Integer
Dim all As String
Dim errcnt As Integer
Dim omsg As Object
Dim mmsg As MAPI.Message
Dim spid As String, seid As String
@hilbix
hilbix / gist:5830049
Created June 21, 2013 09:28
X11 keyboard settings
Section "InputDevice"
Identifier "Keyboard"
Driver "kbd"
# Option "XkbModel" "pc105"
Option "XkbLayout" "us,de"
Option "XKbOptions" "grp:alt_shift_toggle"
EndSection
@hilbix
hilbix / curl.php
Created July 11, 2013 15:49
Dangerous PHP curl test script - mainly to test SSL reachability (60 means trouble with the SSL cert)
<?
# Warning, do not keep this publicly reachable, it is dangerous.
header("Content-type: text/plain");
$ch = curl_init($_SERVER["QUERY_STRING"]);
curl_exec($ch);
echo "-- errno: ";
echo curl_errno($ch);
curl_close($ch);
@hilbix
hilbix / ca.config
Created July 11, 2013 15:26
Root CA certificate which can be imported into Firefox
# see http://www.identityblog.com/?p=645
dir = .
[ ca ]
default_ca = CA_default
[ CA_default ]
serial = $dir/serial
database = $dir/certindex.txt
@hilbix
hilbix / GIT branch relation aliases
Last active December 29, 2015 17:19
GIT "relate" ALIAS to quickly show how all branches relate to HEAD (or given branch). GIT "graph" ALIAS to show the graph between two commits (from HEAD to it origin, or given branch, by default). `graph` Improved to highlight starting point (which is not always obvious).
git config --global --replace-all alias.relate '!f(){ git for-each-ref --format="%(refname:short) %(upstream:short)" refs | while read -r l r; do printf "%24s %s\\n" "$(git rev-list --cherry-mark --dense --left-right --boundary --oneline "${r:-${1:-HEAD}}...$l" -- | sed "s/^\\(.\\).*/\\1/" | sort | uniq -c | tr -d " " | tr "\\n" " ")" "$l"; done; }; f'
git config --global --replace-all alias.graph '!f(){ case "$#:$1" in 0:) r="HEAD...HEAD@{u}";; 1:*...*) r="$1";; 1:*) r="HEAD...$1";; *) r="$1...$2";; esac; git rev-list --cherry-mark --dense --left-right --boundary --pretty --graph "$r" -- | less -XFp "$(git rev-parse "${r%...*}")"; }; f'
git config --global --replace-all alias.graph1 '!f(){ case "$#:$1" in 0:) r="HEAD...HEAD@{u}";; 1:*...*) r="$1";; 1:*) r="HEAD...$1";; *) r="$1...$2";; esac; git rev-list --cherry-mark --dense --left-right --boundary --oneline --graph "$r" -- | less -XFp "$(git rev-parse "${r%...*}")"; }; f'
# THIS IS PUBLIC DOMAIN.
# Thanks to the makers of GIT for the extremely impressiv
@hilbix
hilbix / FIX-pipeline-import-problem.sh
Created September 2, 2016 14:41
Fix problem with GitLab not importing exported projects due to error "Failed to replace pipelines because one or more of the new records could not be saved."
#!/bin/bash
OOPS() { { printf 'OOPS:'; printf ' %q' "$@"; printf '\n'; } >&2; exit 23; }
x() { "$@"; }
o() { x "$@" || OOPS failed "$?:" "$@"; }
case "$#:$1" in
0:'') cat <<EOF
Usage: $0 ...tar.gz
Fixes following problem when an Import onto GitLab fails with following error: