Skip to content

Instantly share code, notes, and snippets.

View stigok's full-sized avatar
🚢
ship it!

Stig Otnes Kolstad stigok

🚢
ship it!
View GitHub Profile
@stigok
stigok / decryption-keys
Last active June 19, 2022 09:36
mkinitcpio install hook to embed LUKS decryption keys to initramfs
#!/bin.bash
# stigok 22-02-2018
KEYDIR=/etc/initcpio/keys
function help {
cat <<EOF
This hook will embed decryption keys for the encrypted root device into
initramfs to automatically mount the root partition after a successful
decryption of the boot partition.
import queue
import threading
import sys
class ThreadedQueue:
def __init__(self, task, timeout=10):
self.threads = dict()
self.queues = dict()
self.task = task
self.timeout = timeout
@stigok
stigok / setbrightness
Created January 30, 2018 15:08
Script to set brightness in steps. Never to 0.
# Set screen brightness
# Usage: setbrightness more|less|<int>
DIR="/sys/class/backlight/intel_backlight"
MAX_VALUE=$( < $DIR/max_brightness )
MAX_STEP=${MAX_STEP:-8}
STEP_AMOUNT=$(( $MAX_VALUE / $MAX_STEP ))
CURRENT_VALUE=$( < $DIR/brightness )
CURRENT_STEP=$(( $CURRENT_VALUE / $STEP_AMOUNT ))
const int SECOND = 1000;
const int MINUTE = 60 * SECOND;
const int RESOLUTION = 1 * SECOND;
//const int EXTRA_TURN_TIME = SECOND;
const int GREEN = 0;
const int RED = 1;
const int DRY_RUN = 1; // Comment this whole line to enable gpio pins
@stigok
stigok / file1.py
Last active February 6, 2018 21:25
Python 3: how to import methods from a different file in same folder
def test():
print("Test method")
if __name__ == "__main__":
print("Main method")
@stigok
stigok / config.txt
Created September 9, 2017 23:59
Sample Pi boot config
# See /boot/overlays/README for all available options
gpu_mem=128
start_file=start_x.elf
fixup_file=fixup_x.dat
initramfs initramfs-linux.img followkernel
# Enable ALSA interface
audio=on
uart0=off
#import dialogs, ugfx, network, badge, deepsleep
#import dialogs from micropython/unix/modules/dialogs.py
import ugfx, network, badge, time
mocked_messages = [
'sshow: hei, verden!',
'krav: hello, world!',
'sshow: funker dette?',
'krav: ja :):):):)',
'sshow: hei, verden!',
@stigok
stigok / after-rsync
Created July 30, 2017 17:22
File system watcher that executes a command when MOVED_TO event occurs, i.e. when rsync file transfer is complete
#!/bin/bash
# Do something after rsync completes
#
# Usage: after-rsync <srcdir> <command> [...args]
set -x
srcdir=$1
shift
@stigok
stigok / vid2html5
Created July 30, 2017 17:18
Convert a video file to a cross-browser HTML5 video compatible file format
#!/bin/bash
# Convert a video file to a cross-browser HTML5 video compatible file format
#
# Usage: vid2html5 <infile> [<outdir>]
#
# stigok jul 2017
infile="$1"
timestamp=`date +'%Y-%m-%d-%H%M%S'`
outdir=${2:-.}
outfile=$outdir/$timestamp.mp4
@stigok
stigok / openvpn-reconnect.sh
Created July 13, 2017 11:41
Make openvpn reconnect when a network interface goes up
#!/bin/bash
# Initiates reconnect of the openvpn process
#
# Made for /etc/NetworkManager/dispatcher.d/, but should be working
# for /etc/network/if-up.d/ as well.
#
IFACE=$1
ACTION=$2