Skip to content

Instantly share code, notes, and snippets.

View mjf's full-sized avatar

Matouš Jan Fialka mjf

View GitHub Profile
@mjf
mjf / mac.sh
Last active January 18, 2017 14:31
MAC - L2 address formatter
#! /bin/sh
# MAC - L2 address formatter
# Copyright (C) 2011, 2014 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
FORMAT=Collon
LETTER_CASE=Keep
while [ $# -gt 0 ]
@mjf
mjf / experimental-aggressively-compressed-patricia-trie.c
Created January 10, 2012 00:24
Aggressively compressed radix tree (patricia trie)
struct Edge; /* forward declaration */
#define VERTEX_MAX_EDGES 3 /* instead of real memory allocation */
struct Vertex {
unsigned long int width;
struct Edge *edges[VERTEX_MAX_EDGES];
void *datum;
};
@mjf
mjf / dusum.awk
Created January 13, 2012 08:36
DUSUM - Summarize Output of Program du(1) with human-readable mode auto-detection
#! /usr/bin/awk -f
# DUSUM - Summarize Output of Program du(1)
# Copyright (C) 2012 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
#
# Note: Human-readable mode of du(1) is auto-detected.
BEGIN {
B = 1
@mjf
mjf / frate.sh
Created February 13, 2012 09:08
FRATE - Print file grow rate in Kbps
#! /bin/sh
# FRATE - Print file grow rate in Kbps
# Copyright (C) 2012 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
if [ $# -ne 1 ]
then
printf 'usage: frate [file]\n' 1>&2
exit 1
@mjf
mjf / markdown2dokuwiki.sed
Created February 20, 2012 12:36
Markdown2Dokuwiki - Reformat Markdown to Dokuwiki
#! /bin/sed -f
## Markdown2Dokuwiki - reformat Markdown to Dokuwiki
## Copyright (C) 2012 Matous J. Fialka, <http://mjf.cz/>
## Released under the terms of The MIT License
## TODO: many things yet...
# reformatovani nadpisu
s/^#####/==/
@mjf
mjf / ask.sh
Created March 2, 2012 11:07
ASK - asks Yes/no question (with signal handling)
#! /bin/sh
# ASK - asks Yes/no question (with signal handling)
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the Terms of The MIT License
signal_handler()
{
printf -- 'Interrupted.'
@mjf
mjf / pt
Created March 9, 2012 10:43
PT - Trace process ID up in the process tree
#! /bin/sh
# PT - Trace process ID up in the process tree
# Copyright (C) 2012 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
if [ $# -ne 1 ]
then
echo usage: pt pid
exit
@mjf
mjf / recurrent.sh
Created March 16, 2012 10:22
Example of recurrent shell scrip call over it's arguments
#! /bin/sh
# PUT SOME CODE WORKING ON $1 HERE
if [ $# -gt 1 ]
then
shift
exec $0 $*
fi
@mjf
mjf / lockscript
Last active December 11, 2023 16:53
lockscript - Shell script locking template
#! /bin/sh
# lockscript - Shell script locking template
# Copyright (C) 2012-2014 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
# USAGE
# =====
#
# Rename, link or source this file to your desired script.
@mjf
mjf / lastworkday.sh
Created April 23, 2012 11:40
Show Next/Last Work Day
#! /bin/sh
date -d "`[ $(date +%u) -eq 1 ] && echo 3 days ago || echo yesterday`" $*