Skip to content

Instantly share code, notes, and snippets.

View tjvr's full-sized avatar

Tim Radvan tjvr

View GitHub Profile
@tjvr
tjvr / rheapq.py
Created December 29, 2016 15:23
heap-based priority queue from Python stdlib, modified to run on RPython
# -*- coding: latin-1 -*-
"""Heap queue algorithm (a.k.a. priority queue).
Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for
all k, counting elements from 0. For the sake of comparison,
non-existing elements are considered to be infinite. The interesting
property of a heap is that a[0] is always its smallest element.
Usage:
@tjvr
tjvr / wabt.rb
Last active January 31, 2017 23:12
Homebrew formula for WebAssembly Binary Toolkit
class Wabt < Formula
desc "The WebAssembly Binary Toolkit"
homepage "https://github.com/WebAssembly/wabt"
head "https://github.com/WebAssembly/wabt.git"
#url "https://github.com/WebAssembly/wabt/archive/binary_0xc.tar.gz"
sha256 "0ee56305b232d2a07aebd18afd0861ba39941d137ebf2ce2d57395a1bcd82940"
depends_on "cmake" => :build
def install
@tjvr
tjvr / binaryen.rb
Last active January 31, 2017 23:12
Homebrew formula for Binaryen
class Binaryen < Formula
desc "Compiler infrastructure and toolchain library for WebAssembly, in C++"
homepage "https://github.com/WebAssembly/binaryen"
url "https://github.com/WebAssembly/binaryen/archive/version_26.tar.gz"
head "https://github.com/WebAssembly/binaryen.git"
version "26"
sha256 "e78ff7ea4dbffa0d53084a0bc1ec8ed43445b674a02c17af798f3c0df13d418d"
depends_on "cmake" => :build
@tjvr
tjvr / tosh.ne
Last active February 16, 2017 15:38
tosh for nearley
line -> thing {% id %}
thing -> block {% id %}
| r_parens {% id %}
| b_parens {% id %}
n -> n4 {% id %}
@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;
@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 / 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 / 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 / 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 / nginx.conf
Last active September 10, 2019 08:31
nginx cors proxy
server {
listen 80;
server_name cors.tjvr.org;
root /usr/share/nginx/html;
index index.html;
client_max_body_size 1m;
client_body_buffer_size 64k;