Skip to content

Instantly share code, notes, and snippets.


John Andersen pdxjohnny

View GitHub Profile
View plot.awk
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device.
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average
katef / life-utf8.c
Last active Jan 2, 2021
XBM to UTF-8 braille image things
View life-utf8.c
* John Conway's Game of Life.
* This is written for POSIX, using Curses. Resizing of the terminal is not
* supported.
* By convention in this program, x is the horizontal coordinate and y is
* vertical. There correspond to the width and height respectively.
* The current generation number is illustrated when show_generation is set.
0xdade /
Created Jan 23, 2020
Simple code snippet for a python file to delete itself, whether it's a standalone .py file or compiled into an executable using pyinstaller
#!/usr/bin/env python3
Determine if this python is part of an executable or a standalone script and then delete the file accordingly.
If the script has been bundled into an executable using pyinstaller (such as pyinstaller --onefile <fname>.py) then the realpath of __file__ will be incorrect, thus the use of sys.executable.
Example of just relying on __file__:
$ pyinstaller --onefile
$ ls dist/
dnoliver /
Created Jan 13, 2020
Disk encryption with Clevis example
GNU nano 4.3
set -euxo pipefail
rpm -qa clevis* cryptsetup* luks* tpm2* e*fspr* | sort
# Creation
# dd if=/dev/zero of=/dev/sda1 bs=1M status=progress
simpsoka /
Last active Jan 7, 2021
This is a list of questions to check our decision making.

Do I want to die on this hill?

  • Pass: This is morally good and if not handled has long term consequences
  • Fail: This if self serving

Am I including everyone?

  • Pass: My ego is not driving this conversation
  • Fail: The people in this conversation will only tell me I'm right and not push back
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active Jan 17, 2021
Build and run minimal Linux / Busybox systems in Qemu
View gist:02e165a0004be33734ac2334f215380e


export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

drmalex07 /
Last active Jan 7, 2021
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward


Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

Description=Setup a secure tunnel to %I
julz / main.go
Created Nov 20, 2015
containersched minicontainer
View main.go
package main
import (
func main() {
jpillora / sshd.go
Last active Jan 5, 2021
Go SSH server complete example - Read more here
View sshd.go
// A small SSH daemon providing bash sessions
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
// Client:
cee-dub / sse.go
Created May 30, 2014
Simple Golang SSE example using CloseNotifier
View sse.go
package main
import (
// SSE writes Server-Sent Events to an HTTP client.
You can’t perform that action at this time.