Skip to content

Instantly share code, notes, and snippets.

View emptyset's full-sized avatar
🦑
hello

Alan Fay emptyset

🦑
hello
  • Nowhere
View GitHub Profile
@emptyset
emptyset / production-traffic.gv
Created May 30, 2020 17:01
Just for fun, a dotfile to help plan a train-based Factorio base
digraph {
rankdir=LR;
{ iron_ore copper_ore stone coal uranium_ore } -> ore_line
// smelter: specific to iron/copper plate production (1:1 ratio)
// quarry: any stone or pure stone-based production
// steel mill: specific for steel plate production
// due to 5:1 ratio, iron ore fed separate from general smelter
#!/usr/bin/awk -f
# ip2dec
BEGIN {
ip = ARGV[1]
split(ip, octets, ".")
for (i = 1; i <= 4; i++) {
dec += octets[i] * 256 ** (4 - i)
}
printf("%i\n", dec)
}
@emptyset
emptyset / jam.ino
Last active August 29, 2015 14:16
Code for the JAM!
int motorPin = 3;
int lightsPin = 5;
int limitPin = 7;
int buttonPin = 8;
int buttonLightPin = 4;
boolean active = false;
boolean motorRunning = false;
int dispenseSeconds = 300;
int motorRunMaxSeconds = 20;
@emptyset
emptyset / .zshrc
Created December 14, 2014 18:53
sample code for git branch on prompt (zsh) - copied from some source elsewhere; sorry unable to remember to give credit
# git branch display
git_prompt()
{
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2> /dev/null | sed -n '/^\*/s/^\* //p')
if git diff --quiet 2> /dev/null >&2; then
@emptyset
emptyset / split.sh
Created November 20, 2014 15:01
Short (very rough) sketch of parsing out subtitles and applying them to a different SRT file. Not verified to work (for whatever [shell programming] reason(s), I couldn't run this all as one script, and instead had to echo out the grep commands and run the apply portion in a separate script. That could have been due to haste and not really payin…
#!/bin/sh
# separate times and words (grep and -v)
grep '^[0-9]+:[0-9]+:' $1 &> $1.times
grep '^[0-9]+:[0-9]+:' -v $2 &> $2.words
# apply the times to the text
awk 'NR==FNR{a[i++]=$0;next;}{ if ($0 ~ /[0-9]+/) printf"%s\n%s\n", $0,a[j++];else print;}' i=1 j=1 $1.times $2.words &> $1_vs_$2.srt
# add the counter
#awk '/[0-9]+\:/{printf("%d\n%s",++counter,$0);}{print $0;}' $1_vs_$2.srt &> $1_vs_$2-final.srt
@emptyset
emptyset / extract.sh
Created July 12, 2013 03:53
This is probably an over-engineered shell script that can be used to modify .ovpn files from vpngate.net so that they can be easily imported into the openvpn GUI that is included with stock Ubuntu installations.
FILE=$1
FILENAME=${FILE%%.*}
# extract the keys and certificates
sed -n "/<ca>/,/<\/ca>/p" $FILE > $FILENAME.ca.crt-tmp
sed -n "/<cert>/,/<\/cert>/p" $FILE > $FILENAME.crt-tmp
sed -n "/<key>/,/<\/key>/p" $FILE > $FILENAME.key-tmp
# modify the keys and certificates
sed '/ca>/d' $FILENAME.ca.crt-tmp > $FILENAME.ca.crt
@emptyset
emptyset / update.sh
Created February 27, 2012 19:51
Trying out github's gist feature by sharing the small update script I use to maintain my dotfiles across different systems using Dropbox.
#!/usr/bin/env zsh
# This configuration file script will create links to the various
# dotfiles and directories in the user's home directory. This allows
# for the .configuration directory to be "dropped" in and immediately
# setup the shell, keys, editor settings, environment variables, etc.
# Instructions
#
# 1. Setup a link called ".configuration" that points to the dotfiles