Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Radvan tjvr

View GitHub Profile
@tjvr
tjvr / compile.js
Last active Sep 27, 2019
compile a moo lexer
View compile.js
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 Aug 3, 2019
Kramer Protocol 2000 for VS-66HN (and probably other HDMI switchers too)
View switch.py
#!/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 Apr 13, 2019
Flirc DBUS MPRIS Daemon
View flirc-mpris.service
[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 Sep 24, 2020
Hibernate on Ubuntu 18.04 with LVM full-disk encryption
View crypttab
sda5_crypt UUID=c66880c1-c2f1-40fc-9580-f25d493876ef none luks,discard
@tjvr
tjvr / switch_once.py
Last active Jul 2, 2018
Energenie ENER314 Raspberry Pi board
View switch_once.py
#!/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 Aug 23, 2017
metalsmith-pdf-chrome
View README.md

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 Mar 17, 2017
$ npm run benchmark
View moo 🐄 benchmarks
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
View json.js
// 71 functions generated
// 37747 bytes
(function(ctx) {
return (function(lex) {
function error(id) {
throw new Error(id);
}
function g0() {
@tjvr
tjvr / tosh.html
Created Feb 16, 2017
tosh grammar railroad
View tosh.html
<!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;
@tjvr
tjvr / tosh.ne
Last active Feb 16, 2017
tosh for nearley
View tosh.ne
line -> thing {% id %}
thing -> block {% id %}
| r_parens {% id %}
| b_parens {% id %}
n -> n4 {% id %}
You can’t perform that action at this time.