Skip to content

Instantly share code, notes, and snippets.

@virtuald
virtuald / route+custom.js
Last active Oct 12, 2018
Rewrite of riot.js tag router
View route+custom.js
(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 Sep 13, 2018
Similar to golang.org/x/sync/errgroup
View anyerr.go
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 Aug 11, 2018
Vagrant NFS4 client+server automated setup
View Vagrantfile
$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
Simulated drivetrain characterization data
View data.json
{
"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 Dec 8, 2017
monkeypatch 'globmatch' function onto pathlib2
View patch_pathlib2.py
#
# 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 Sep 6, 2017
ns2html netscreen config file (GPL, from http://ns2html.sourceforge.net/download.html)
View test.cfg
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
GTK3 breeze theme treeview separator bug
View treeview.py
#
# 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
GStreamer Windows Audio Thread Priority hack
View prio_hack.py
#
# 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 Apr 29, 2017
Segfault on Wayland
View wayland_bug.py
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 Jul 6, 2016
Working StatusIcon code
View uitest.py
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()
You can’t perform that action at this time.