Skip to content

Instantly share code, notes, and snippets.

View mjf's full-sized avatar

Matouš Jan Fialka mjf

View GitHub Profile
@mjf
mjf / ar2rom.c
Last active December 24, 2015 06:29
ar2rom - Convert Arabic numerals to Roman numerals
/**
* ar2rom - Convert Arabic numerals to Roman numerals
* Copyright (C) 2013 Matous J. Fialka, <http://mjf.cz/>
* Released under the terms of The MIT License
*
* Compile: cc -pedantic -ansi -Wall -Werror -o ar2rom ar2rom.c
*/
#include <stdlib.h>
#include <stdio.h>
@mjf
mjf / getpos.sh
Last active December 24, 2015 15:19
GETPOS - Get screen position (column, line)
#! /bin/sh
exec < /dev/tty
ostty=`stty -g`
stty raw -echo min 0
printf -- '\033[6n' > /dev/tty
IFS=\; read -d R -r line col
stty $ostty
printf -- '%d,%d\n' `expr ${col%R} - 1` `expr ${line:2} - 1`
@mjf
mjf / gist:6990442
Created October 15, 2013 11:56
Shell alias to log work
# log work
alias log='history -p !! >> ${LOGFILE:-~/log}'
@mjf
mjf / bitset.c
Created October 15, 2013 23:26
Handle bitsets in ANSI C
/**
* cc -pedantic -ansi -pedantic-errors -Wall -Werror bitset.c -o bitset
*/
#include <stdint.h>
#include <stdlib.h>
typedef enum { /* no use for stdbool.h with ANSI C */
false = 0,
true
@mjf
mjf / partcomp.sh
Last active December 28, 2015 17:49
partcomp - Partition Computing for Kickstart
#! /bin/sh
# partcomp - Partition Computing for Kickstart
# Copyright (C) 2013 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
RAM=${1:-4096}
HDD=${2:-512000}
SWAPFS_MAX=32768
@mjf
mjf / .htaccess
Last active December 28, 2015 20:18
Banners
<Directory "/var/www/html">
AuthType Basic
AuthName "WARNING: THIS IS A PRIVATE COMPUTER SYSTEM. ONLY AUTHORIZED USERS ARE PERMITTED ACCESS TO THIS WEB SITE. ALL ACCESS ATTEMPTS ONTO THIS SYSTEM ARE CLOSELY MONITORED AND LOGGED. ANY ATTEMPT TO CIRCUMVENT SECURITY OF THIS SYSTEMS MAY RESULT IN LEGAL ACTION(S)."
AuthUserFile "/etc/httpd/conf/.htpasswd"
AuthGroupFile "/etc/httpd/conf/.htgroup"
Require valid-user
Require group webmasters
@mjf
mjf / sysctlgen
Last active December 29, 2015 13:39
sysctlgen - Generate useful /etc/sysctl.conf options
#! /bin/sh
#
# sysctlgen - Generate useful /etc/sysctl.conf options
# Copyright (C) 2013 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
#
#
# Get PAGE_SIZE value from system compile-time variables
@mjf
mjf / CSIRT-IRF.txt
Last active July 7, 2016 11:54
CSIRT Incident Reporting Form (IRF)
#!CSIRT-IRF-1.0
# Computer Security Incident Response Team (CSIRT)
# Incident Reporting Form (IRF)
----- BEGIN IRF -----
# Fill in any preliminary information below this line
@mjf
mjf / editfacl
Last active December 31, 2015 16:39
editfacl - Edit POSIX.1e ACL information
#! /bin/sh
# editfacl - Edit POSIX.1e ACL information
# Copyright (C) 2013 Matous J. Fialka, <http://mjf.cz/>
# Released under the terms of The MIT License
EDITOR="${EDITOR:-vi}"
TMPDIR="${TMPDIR:-/tmp}"
GETFACLOPT="$GETFACLOPT"
@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;