Skip to content

Instantly share code, notes, and snippets.

@polynomialspace
polynomialspace / atou.go
Last active March 4, 2020 21:21
"ascii to fullwidth" convert plaintext standard chars to fullwidth
package main
import (
"fmt"
"os"
"bufio"
"strings"
)
func atofw(in string) (out string) {
@polynomialspace
polynomialspace / rot13.go
Last active March 4, 2020 11:35
rot13 / caesar implementation in go (bad/kinda silly)
package main
import (
"os"
"bufio"
"fmt"
)
// double curly brackets to provide arbitrary scoping for variable shadowing.
// this is rather disgusting, but cleaner than repeat casts or more vars.
@polynomialspace
polynomialspace / smb.conf
Last active January 20, 2023 21:33
Time Machine on Linux with Samba (4.11). Install avahi and this should 'just work'.
[global]
workgroup = Time Machine
netbios name = Time Machine
security = user
passdb backend = tdbsam
# Supposedly turning signing off may increase performance for TM.
# May require changes on client side, set to auto if issues occur.
# See: https://support.apple.com/en-us/HT205926
# Note that this is disabling a security feature. Only use on a
@polynomialspace
polynomialspace / badfizzbuzz.go
Last active October 8, 2019 20:20
Attempts to write the most inane but readable form of fizzbuzz in go
package main
import (
"fmt"
)
func main() {
fbarr := []string { "%[2]sFizzBuzz", "%[1]d", "%[1]d",
"%[2]sFizz" , "%[1]d", "%[2]sBuzz",
"%[2]sFizz" , "%[1]d", "%[1]d",
@polynomialspace
polynomialspace / ssh-keysign.sh
Last active September 23, 2019 20:29
Script to scp ssh pubkeys from a server and sign them with a local CA; still tweaking things.
#!/bin/sh
print_help() {
echo "A script to copy ssh host keys via SCP and sign them with a local SSH CA"
echo
echo "Simple usage: ${0} -h <host>"
echo "The following options are accepted:"
echo " -h: specify the host"
echo " -H: override the hostname for SCP (default: same as -h)"
echo " -s: override location of CA privkey (default: /etc/ssh/ca)"
@polynomialspace
polynomialspace / ovpn-gen.sh
Created September 23, 2019 16:39
script to generate .ovpn files, assumes several things, see https://polynomial.space/posts/openvpn/
#!/bin/sh
CLIENT="${1}"
IP="${2}"
if [ -z "${CLIENT}" ]; then
exit 1
fi
cd /etc/openvpn
@polynomialspace
polynomialspace / ssh-keygen-sign.sh
Last active September 23, 2019 20:18
Quick script to scrape ssh pubkeys from a server via ssh-keyscan and sign them with an SSH CA
#!/bin/sh
umask 77
TMPDIR=$(mktemp -d)
HOST="${1}"
cd ${TMPDIR}
for TYPE in dsa ecdsa ed25519 rsa; do
# ssh-key{gen,scan} are very smart and their outputs are not directly compatible, very cool
@polynomialspace
polynomialspace / gist:9ccfa7c922d4acba52e21016889c3ae2
Created February 17, 2019 07:43
Quick command list to create a debian container with systemd-nspawn
cd /var/lib/machines
debootstrap stable ./debian https://mirrors.kernel.org/debian
systemd-nspawn -M debian
echo 'deb https://deb.debian.org/debian-security stable/updates main' >> /etc/apt/sources.list
apt update && apt -y upgrade
apt install -y sudo
useradd -mUG sudo -s /bin/bash debian #kind of pointless.
passwd -d debian
@polynomialspace
polynomialspace / Dockerfile
Created December 10, 2018 10:03
Docker file for migen
FROM ubuntu
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV DEBIAN_FRONTEND=noninteractive
#^ Really, ubuntu? (tzdata hanging)
RUN apt-get update && apt-get -y install bison build-essential clang cmake flex gawk git graphviz gtkwave libboost-all-dev libffi-dev libftdi-dev libreadline-dev python3 python3-dev python3-setuptools qt5-default tcl-dev xdot
RUN git clone https://github.com/cliffordwolf/icestorm && cd icestorm && make -j $(nproc) && make install
RUN git clone https://github.com/YosysHQ/nextpnr && cd nextpnr && cmake -DARCH=ice40 . && make -j $(nproc) && make install
#!/bin/bash
sudo apt-get -y remove docker docker-engine docker.io
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" # No cosmic yet?
sudo apt update
sudo apt-get -y install docker-ce