Skip to content

Instantly share code, notes, and snippets.

joshkunz / repro.log
Last active Feb 3, 2020
Repro instructions for QEMU SIGRTMIN patch
View repro.log
$ go version
go version go1.13.7 linux/amd64
$ env GOOS=linux GOARCH=arm64 go build test.go
$ aarch64-linux-user/qemu-aarch64 ./test
fatal error: sigaction failed
runtime stack:
runtime.throw(0xd60c0, 0x10)
~/code/go/src/runtime/panic.go:774 +0x54
cd /sys/kernel/config/usb_gadget/
mkdir -p pi4
cd pi4
echo 0x1d6b > idVendor # Linux Foundation
echo 0x0104 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB # USB2
echo 0xEF > bDeviceClass
echo 0x02 > bDeviceSubClass
joshkunz /
Created Jun 18, 2019
Keybase proof for

Keybase proof

I hereby claim:

  • I am joshkunz on github.
  • I am joshkunz ( on keybase.
  • I have a public key ASAFydC3Pw9tk4JPBdLBDlzVDiZ-l5_hFsBD2xOaGI-cxAo
joshkunz /
Created Nov 16, 2018
Example homebrew flag parser in rust.
use std::collections::HashMap;
use std::convert::From;
use std::env;
use std::error;
use std::boxed::Box;
use std::iter::FromIterator;
type Error = Box<error::Error>;
fn parse_arg(s: &str) -> Result<(&str, &str), Error> {
joshkunz / mpd_fileaccess-v0.20.5.patch
Created Feb 22, 2017
This patch allows you to play any file on your local filesystem (that the MPD server can read) using the `file://` URI syntax.
View mpd_fileaccess-v0.20.5.patch
diff --git a/src/client/ClientFile.cxx b/src/client/ClientFile.cxx
index 0382789..9c41d2c 100644
--- a/src/client/ClientFile.cxx
+++ b/src/client/ClientFile.cxx
@@ -33,19 +33,17 @@ Client::AllowFile(Path path_fs) const
throw ProtocolError(ACK_ERROR_PERMISSION, "Access denied");
- if (uid >= 0 && (uid_t)uid == geteuid())
- /* always allow access if user runs his own MPD
joshkunz / scrape.js
Last active Nov 15, 2015
Script to scrape netflix ranking history found at . Sorry about the formatting, I just typed it in the dev-tools box. Outputs as csv in the form "Netflix movie id,date,title,rating". Ratings are 1-5, -3 means "not interested".
View scrape.js
var elems = document.querySelectorAll("li.retableRow"); for (i = 0; i < elems.length; i++) { var item = elems[i]; var mid = item.getAttribute("data-movieid"); var date = item.querySelector("").textContent; var title = item.querySelector(".col.title a").textContent; var rating = item.querySelector(".col.rating div").getAttribute("data-your-rating"); console.log(mid + "," + date + "," + "\"" + title + "\"" + "," + rating); }
joshkunz /
Last active Nov 6, 2015
A simple protocol for sending synchronous binary messages between two hosts.


A simple channel implementation for python for prototyping and debugging. It is thread-safe.


Channel.listen(<host>, <port>, reuse=True, echo=True) -> iterator over client channel objects


  • <host>: The IP address to listen on.
joshkunz /
Created Oct 2, 2015
A python implementation of the sealer/unsealer pattern from "E in a Walnut"
# Returns two classes, a "Sealer", and an "Unsealer".
# Lets call the Sealer "s" and the Unsealer "u".
# For any pair of s and u returned from makeBrandPair, s.seal(value)
# (where "value" can be any python object) returns a boxed version of
# value that cannot be extracted unless you have a reference to the
# unsealer u (not 100% sure on this, but it seems to be true).
# When you call u.unseal(box), the value originally sealed into the
# box is returned. A separate call to makeBrandPair will return
# a different sealer/unsealer pair that only work with eachother.
def makeBrandPair():
joshkunz / t.go
Created Sep 4, 2015
Go routines with manual yielding.
View t.go
package main;
import "fmt"
import "runtime"
func main() {
a := make(chan bool)
b := make(chan bool)
joshkunz / example.go
Last active Aug 27, 2015
Newlines in go.
View example.go
type thing struct {
a, b int
c string
d uint
// this is valid go (in a function context)
v := thing{ a: 0,
b: 0,
You can’t perform that action at this time.