Skip to content

Instantly share code, notes, and snippets.

View tjvr's full-sized avatar

Tim Radvan tjvr

View GitHub Profile
@tjvr
tjvr / 99-pico.rules
Created April 6, 2021 19:08
Raspberry Pi Pico/RP2040 udev rules
# /etc/udev/rules.d/99-pico.rules
# Make an RP2040 in BOOTSEL mode writable by all users, so you can `picotool`
# without `sudo`.
SUBSYSTEM=="usb", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0003", MODE="0666"
# Symlink an RP2040 running MicroPython from /dev/pico.
#
# Then you can `mpr connect $(realpath /dev/pico)`.
SUBSYSTEM=="tty", ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0005", SYMLINK+="pico"
@tjvr
tjvr / compile.js
Last active September 27, 2019 16:10
compile a moo lexer
const moo = require('moo')
function compileClass(constructor, indent) {
let s = ''
s += indent + 'var ' + constructor.name + ' = ' + constructor
for (let key in constructor.prototype) {
s += '\n\n'
const value = constructor.prototype[key]
if (typeof value === 'function') {
s += indent + constructor.name + '.prototype.' + key + ' = ' + value
@tjvr
tjvr / switch.py
Created August 3, 2019 11:13
Kramer Protocol 2000 for VS-66HN (and probably other HDMI switchers too)
#!/usr/bin/env python
import socket
import struct
import sys
HOST = "192.168.1.39"
PORT = 5000
def switch(input_port):
@tjvr
tjvr / flirc-mpris.service
Last active March 25, 2023 20:35
Flirc DBUS MPRIS Daemon
[Unit]
Description=Control MPRIS media players with your Flirc
[Service]
ExecStart=/usr/bin/flirc_mpris.py
Restart=always
[Install]
WantedBy=default.target
@tjvr
tjvr / crypttab
Last active March 13, 2024 17:06
Hibernate on Ubuntu 18.04 with LVM full-disk encryption
sda5_crypt UUID=c66880c1-c2f1-40fc-9580-f25d493876ef none luks,discard
@tjvr
tjvr / switch_once.py
Last active July 2, 2018 21:28
Energenie ENER314 Raspberry Pi board
#!/usr/bin/python2
import sys
import time
import RPi.GPIO as GPIO
# set the pins numbering mode
GPIO.setmode(GPIO.BOARD)
@tjvr
tjvr / README.md
Last active August 23, 2017 22:18
metalsmith-pdf-chrome

Don't use this, use wkhtmltopdf. Don't waste your life like I did.


Render PDFs using Chrome.

const m = Metalsmith(__dirname)
  .use(markdown({
 smartypants: true,
@tjvr
tjvr / moo 🐄 benchmarks
Last active March 17, 2017 15:33
$ npm run benchmark
JSON
✔ 🐮 x 830 ops/sec ±0.74% (90 runs sampled)
✔ syntax-cli x 385 ops/sec ±1.06% (85 runs sampled)
tosh
✔ 🐮 x 1,403 ops/sec ±0.80% (93 runs sampled)
✔ tosh x 428 ops/sec ±1.26% (87 runs sampled)
Python
@tjvr
tjvr / json.js
Last active March 3, 2017 17:08
// 71 functions generated
// 37747 bytes
(function(ctx) {
return (function(lex) {
function error(id) {
throw new Error(id);
}
function g0() {
@tjvr
tjvr / tosh.html
Created February 16, 2017 17:36
tosh grammar railroad
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style type="text/css">
svg.railroad-diagram {
background-color: hsl(30,20%,95%);
}
svg.railroad-diagram path {
stroke-width: 3;