Skip to content

Instantly share code, notes, and snippets.

@errkk
errkk / dl.py
Last active July 10, 2023 09:37
Generate Driving licence number
#! /usr/bin/python3
# Thing for making up a valid (ish) driving licence number
# https://www.drivercheck.co.uk/find-out-more/photocard-driving-licence-explained/
# Note checksum is just dumped on there, not generated cos IDK how it's calculated
import argparse
from datetime import date
from typing import Tuple
@errkk
errkk / garage.rb
Last active December 26, 2016 19:09
#!/usr/bin/env ruby
#
require 'rmodbus'
status_labels = [
['Drive not ready', 'Ready for operation (READY)'],
['Stop', 'Running operation message (RUN)'],
['Clockwise rotating field (FWD)', 'Anticlockwise rotating field (REV)'],
['No fault', 'Fault detected (FAULT)'],
['No warning', 'Warning active (ALARM)'],
@errkk
errkk / Stepper.ino
Last active April 19, 2016 21:53
Controls a 4 phase 28BYJ-48 stepper motor, via some digital pins an an LM2003 driver
// Control a 4 phase stepper motor with an Arduino
// Controls a 28BYJ-48 stepper motor, via some digital pins an an LM2003 driver
// Uses direct port manipulation for fast concurrent pin state changes
// https://en.wikipedia.org/wiki/Stepper_motor#/media/File:Drive.png
int motorSpeed = 1000;
int count = 0;
int countsperrev = 32*16;
// can do > 1100 uS
#include <TinyWireS.h>
// MAX INT 32767
#ifndef TWI_RX_BUFFER_SIZE
#define TWI_RX_BUFFER_SIZE (16)
#endif
#define ADDR 0x11
#include <Manchester.h>
#define RX_PIN 0
#define RELAY_PIN 1
uint8_t data;
uint8_t id;
void setup() {
@errkk
errkk / findpis.sh
Last active May 18, 2016 17:07
Find Raspberry Pis on network
#!/bin/sh
RANGE=$1
echo "Looking for Pis in 10.193.${RANGE:-9}.0/24"
sudo nmap -sP "10.193.${RANGE:-9}.0/24" | grep "B8:27" -B 2
@errkk
errkk / gist:981b51761e7ac8f1541e
Created April 20, 2015 16:07
Print just the temperature from a DS18B20
# Print the number in degrees
awk -F'=' '/ t=/ { print $NF/1000 }' /sys/bus/w1/devices/$DEVICE_ID/w1_slave
# For Curling
curl $URL --data "value=$(awk -F'=' '/ t=/ { print $NF/1000 }' /sys/bus/w1/devices/$DEVICE_ID/w1_slave)" --compressed;
@errkk
errkk / fadecandy.json
Created December 16, 2014 22:18
fadecandy.json
{
"listen": ["0.0.0.0", 7890],
"verbose": true,
"color": {
"gamma": 2.5,
"whitepoint": [0.4, 0.4, 0.4]
},
"devices": [
@errkk
errkk / gist:5b7a2ad83f4701407292
Created December 16, 2014 11:22
Salt Bootstrap Fail 2014.7

When Vagrant Upping, and you get this error:

ImportError: No module named requests


Stderr from the command:

stdin: is not a tty

SSH onto the box

@errkk
errkk / gist:5a19dcb0f4ab71757a99
Created December 16, 2014 11:08
Vagrant looses suspended VM

Run VBoxManage list vms you can see your VMs and the ID

Paste that into .vagrant/machines/default/virtualbox/id