Skip to content

Instantly share code, notes, and snippets.

View mjf's full-sized avatar

Matouš Jan Fialka mjf

View GitHub Profile
@mjf
mjf / humandate
Created July 12, 2011 23:31
Posix shell script to convert between time in human form and seconds
#! /bin/sh
# Posix shell script to convert between time in human form and date
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
if humantime=`humantime -f $@`
then
date -d "$humantime seconds" '+%F %T'
fi
@mjf
mjf / bup
Created July 21, 2011 11:50
Posix shell script to connect two shell commands by bi-directional pipe
#! /bin/sh
# Posix shell script to connect two shell commands by bi-directional pipe
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
if [ $# -ne 2 ]
then
printf -- 'Usage: bip COMMAND COMMAND\n'
exit 0
@mjf
mjf / ascii2xterm
Created July 22, 2011 13:52
Transform ASCII-art tables into XTerm-art tables
#! /bin/sed -f
# Transform ASCII-art tables into XTerm-art tables
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
# Horizontal and vertical line crossing
s/-|-/-^[(0^On^[(B-/g
# Top side and vertical line crossing
@mjf
mjf / junos_strip_comments.c
Created September 2, 2011 00:25
Simple FSM to strip Juniper configuration comments
/**
* Strip Juniper Comments
* Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
* Released under the terms of The MIT License
*/
#include <stdio.h>
enum {
ASCII_NUL = '\000',
@mjf
mjf / year.c
Created September 9, 2011 17:48
Year - normal, leap or calendar change 1752 year?
/**
* Year - normal, leap or calendar change 1752 year?
* Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
* Released under the terms of The MIT License
*
* Install as follows:
*
* $ cc -pedantic -ansi -pedantic-errors -Wall -Werror year.c -o year
* $ su -c 'cp year /usr/local/bin'
*/
@mjf
mjf / easter.c
Created September 9, 2011 22:38
Easter - calculate Easter Sunday (Gregorian calender)
/**
* Easter - calculate Easter Sunday (Gregorian calender)
* Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
* Released under the terms of The MIT License
*
* $ cc -pedantic -ansi -pedantic-errors -Wall -Werror easter.c -o easter
* $ su -c 'cp easter /usr/local/bin'
*/
#include <stdlib.h>
@mjf
mjf / look_mjf.lua
Created October 5, 2011 07:34
Shiny look for Ion3plus window manager by MJF
--------------------------------------------------------------------------------
-- look.lua - Ion3 or Ion3plus look called "Shiny"
-- Copyright (C) 2008,2009 Matous J. Fialka, <http://mjf.cz/>
-- Relesed under the terms of The MIT License
--
-- Remarks: Drop into ~/.ion3/ or install in the system-wide directory
-- Authors: Matous Jan Fialka
-- Created: Tue Apr 1 00:12:52 CEST 2008
-- Updated: Mon Feb 9 01:09:41 CET 2009
--
@mjf
mjf / etab.c
Created October 19, 2011 23:17
Possibly the shortest program to expand tabelators to spaces
/**
* Possibly the shortest program to expand tabelators to spaces
* Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
* Released under the terms of The MIT License.
*/
#include <stdio.h>
int
main(void)
@mjf
mjf / record.sh
Last active May 3, 2018 13:03
Record and replay shell sessions using script(1) and scriptreplay(1)
#! /bin/sh
# Record - record shell session using script(1)
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
RECORD_PATH="$HOME/.typescripts/%Y/%m/%d"
RECORD_FILE='%H%M%S'
RECORD_TIMING_FILE="$RECORD_FILE.timing"
@mjf
mjf / pulsingdate.sh
Created November 14, 2011 22:52
XTerm (256-colours) "pulsing" date in the top right corner of the terminal
#! /bin/sh
# Pulsing date XTerm mastery
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
# Prerequisities: flock tput TERM=xterm-256color
lock()
{