Skip to content

Instantly share code, notes, and snippets.

View mjf's full-sized avatar

Matouš Jan Fialka mjf

View GitHub Profile
@mjf
mjf / npow2.c
Created February 4, 2014 01:18
Find next power of two in C
static size_t
npow2(size_t n)
{
n--;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
return n + 1;
@mjf
mjf / getfinfo
Last active August 29, 2015 13:56
getfinfo - Get file information formatted
#! /bin/sh
# getfinfo - Get file information formatted
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
# Variable GETFINFO_FORMAT can be used to c output
# formatting from generic to one of: XML, JSON or shell.
export LC_ALL=C
@mjf
mjf / shortfacl
Last active August 29, 2015 13:57
shortfacl - Reformat POSIX.1e ACL long form to short form
#! /bin/sed -f
# shortfacl - Reformat POSIX.1e ACL long form to short form
# Copyright (C) 2014 Matous J. Fialka
# Released under the terms of The MIT License
# Use as `getfacl /path/to/object | shortfacl`
# Remove comments
s/#.*$//
@mjf
mjf / procmemstat
Last active August 29, 2015 13:57
procmemstat - Show total and average memory usage of processes
#! /bin/sh
# procmemstat - Show total and average memory usage of processes
# Copyright (C) 2012 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
# Note: This is just a quick dirty hack...
#
# Check and parse arguments
@mjf
mjf / z
Last active August 29, 2015 13:58
DigDig - The handy dig(1) toolset
#! /bin/sh
# z - Dig wrapper
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
if ! DIG=`which dig`
then
echo Dig not found. 1>&2
exit 1
@mjf
mjf / .taskd_config
Last active August 29, 2015 13:58
TaskWarrior Settings
#
# <<>> EXTENSIONS <<>>
#
extensions = ~/.local/libexec/taskd
#
# <<>> FILES <<>>
#
log = /tmp/taskd.log
pid.file = /tmp/taskd.pid
@mjf
mjf / dec.sh
Last active August 29, 2015 13:59
encdec-tools - Ecrypt file and decript, typeset and search encrypted file
#! /bin/sh
# dec - Decrypt encrypted file
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
ENC_CIPHALG="${ENC_CIPHALG:-aes-256-cbc}"
ENC_FILEEXT="${ENC_FILEEXT:-enc}"
if [ $# -ne 1 ]
@mjf
mjf / dump_proc_mem
Created May 14, 2014 09:07
dump_proc_mem - Dump (running) process memory using GDB
#! /bin/sh
if [ $# -ne 1 ]
then
echo "Usage: ${0##*/} PID" 1>&2
exit 1
fi
cat /proc/$1/maps |
@mjf
mjf / bootime
Last active August 29, 2015 14:03
Record time until host is up
#! /bin/sh
# Record time until host is up
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
# Depends on the humantime script:
# https://gist.github.com/mjf/1079421#file-humantime
if [ $# -ne 1 ]
#cloud-config
# CoreOS Cloud Configuration YAML Developement File
# Copyright (C) 2014 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
hostname: <HOSTNAME>
users:
- name: core