Skip to content

Instantly share code, notes, and snippets.

@virtuald
virtuald / route+custom.js
Last active October 12, 2018 23:58
Rewrite of riot.js tag router
(function (riot, route) {
'use strict';
//
// Modified version of the riot-router tags
//
// - Intended to be used recursively. You can even use multiple routers in a tag and they'll work
// - Each 'route' event receives the parent container, and any arguments that it would normally get
// - Child tags receive an attribute 'route_path' which contains the current routing
// - Adding a '/@@' to the end of a route allows the route to have subordinate routers
@virtuald
virtuald / anyerr.go
Created September 13, 2018 00:38
Similar to golang.org/x/sync/errgroup
package anyerr
// portions derived from golang context package, BSD license
import (
"github.com/hashicorp/go-multierror"
"sync"
)
// closedchan is a reusable closed channel.
@virtuald
virtuald / Vagrantfile
Created August 11, 2018 22:03
Vagrant NFS4 client+server automated setup
$serverScript = <<-SCRIPT
sudo apt-get update
sudo apt-get -y install nfs-kernel-server
sudo mkdir -p /exports/share
sudo chown -R vagrant:vagrant /exports
echo "/exports 192.168.50.0/24(rw,fsid=0,no_subtree_check,sync,sec=sys)" > /etc/exports
@virtuald
virtuald / data.json
Created May 1, 2018 18:15
Simulated drivetrain characterization data
{
"slow-forward": [
[21.084223, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[21.104242, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[21.124327, 12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[21.144219, 12.0, 0.001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
[21.164237, 12.0, 0.001, 0.012, 0.012, 0.0, 0.0, 0.0, 0.0],
[21.184224, 12.0, 0.001, 0.012, 0.012, 0.0, 0.0, 0.0, 0.0],
[21.204217, 12.0, 0.002, 0.012, 0.012, 0.0, 0.0, 0.0, 0.0],
[21.224186, 12.0, 0.002, 0.024, 0.024, 0.0, 0.0, 0.0, 0.0],
@virtuald
virtuald / patch_pathlib2.py
Created December 8, 2017 19:27
monkeypatch 'globmatch' function onto pathlib2
#
# monkeypatch to add 'globmatch' function to PurePath, which implements
# the same style of matching that glob supports (which is different
# from what match supports)
#
# Same license as pathlib2 (MIT license)
#
from __future__ import print_function
from pathlib2 import PurePath,PurePosixPath
@virtuald
virtuald / test.cfg
Last active September 6, 2017 21:44
ns2html netscreen config file (GPL, from http://ns2html.sourceforge.net/download.html)
set clock timezone 0
set vrouter trust-vr sharable
set vrouter "untrust-vr"
exit
set vrouter "trust-vr"
unset auto-route-export
exit
set service "TCP_123" protocol tcp src-port 0-65535 dst-port 123-123
set auth-server "Local" id 0
set auth-server "Local" server-name "Local"
@virtuald
virtuald / treeview.py
Created May 28, 2017 21:44
GTK3 breeze theme treeview separator bug
#
# This example treeview reproduces the treeview glitching with the gtk-breeze theme
# under GTK 3.22 (Fedora 25)
#
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
@virtuald
virtuald / prio_hack.py
Last active May 5, 2017 06:00
GStreamer Windows Audio Thread Priority hack
#
# Proof of concept to hack around lack of thread priority in GStreamer on
# Windows. See https://bugzilla.gnome.org/show_bug.cgi?id=781998
#
from __future__ import print_function
from ctypes.wintypes import BOOL, DWORD, HANDLE, LPCWSTR
import ctypes as C
@virtuald
virtuald / wayland_bug.py
Created April 29, 2017 14:43
Segfault on Wayland
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
win.connect("delete-event", Gtk.main_quit)
win.show_all()
win2 = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
@virtuald
virtuald / uitest.py
Created July 6, 2016 04:52
Working StatusIcon code
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GdkPixbuf, GLib
win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
theme = Gtk.IconTheme.get_default()