Skip to content

Instantly share code, notes, and snippets.

View ubuntu-docker.sh
#!/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
@polynomialspace
polynomialspace / Makefile
Last active Dec 10, 2018
Quick and dirty makefile to build migen or yosys and dependencies on fedora (Why isnt this just a shell script?)
View Makefile
all: migen
deps:
sudo yum install git make gcc gcc-c++
icestorm: deps
sudo yum install -y python3 libftdi-devel \
&& git clone https://github.com/cliffordwolf/icestorm \
&& cd icestorm \
&& make -j $(nproc) \
@polynomialspace
polynomialspace / Dockerfile
Created Dec 10, 2018
Docker file for migen
View Dockerfile
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
@polynomialspace
polynomialspace / gist:9ccfa7c922d4acba52e21016889c3ae2
Created Feb 17, 2019
Quick command list to create a debian container with systemd-nspawn
View gist:9ccfa7c922d4acba52e21016889c3ae2
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 / ovpn-gen.sh
Created Sep 23, 2019
script to generate .ovpn files, assumes several things, see https://polynomial.space/posts/openvpn/
View ovpn-gen.sh
#!/bin/sh
CLIENT="${1}"
IP="${2}"
if [ -z "${CLIENT}" ]; then
exit 1
fi
cd /etc/openvpn
@polynomialspace
polynomialspace / ssh-keygen-sign.sh
Last active Sep 23, 2019
Quick script to scrape ssh pubkeys from a server via ssh-keyscan and sign them with an SSH CA
View ssh-keygen-sign.sh
#!/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 / ssh-keysign.sh
Last active Sep 23, 2019
Script to scp ssh pubkeys from a server and sign them with a local CA; still tweaking things.
View ssh-keysign.sh
#!/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 / badfizzbuzz.go
Last active Oct 8, 2019
Attempts to write the most inane but readable form of fizzbuzz in go
View badfizzbuzz.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 / smb.conf
Last active Feb 20, 2020
Time Machine on Linux with Samba (4.11). Install avahi and this should 'just work'.
View smb.conf
[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 / rot13.go
Last active Mar 4, 2020
rot13 / caesar implementation in go (bad/kinda silly)
View rot13.go
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.