Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python3
import wpilib
from robotpy_ext.control import xbox_controller
import magicbot
class MyRobot(magicbot.MagicRobot):
def createObjects(self):
self.driveStick = xbox_controller.XboxController(0)
@virtuald
virtuald / README.md
Last active March 24, 2016 04:38
FRC mjpg-streamer scripts

NOTE: These scripts are obsolete, you should use the mjpg-streamer.ipk file published at https://github.com/robotpy/roborio-packages instead.


mjpg-streamer scripts for RoboRIO

This was very quickly put together... so not quite as polished as I would normally like. :)

We used these scripts to run two camera servers on our roboRIO. Very little CPU usage as far as we can see. Only tested with the Microsoft LifeCam 3000 cameras.

@virtuald
virtuald / rawperf.py
Created June 3, 2016 20:22
NSQ performance tester
#!/usr/bin/env python
#
# Run this in three different terminal windows (presumes download of NSQD):
# - rm *.dat && ./nsqd
# - ./raw_perf.py read
# - ./raw_perf.py write
#
from __future__ import print_function
@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()
@virtuald
virtuald / exposure_control.py
Created March 31, 2016 14:36
Allows setting the exposure at runtime on a RoboRIO (auto means you can see, dark limits the exposure for camera tracking)
import os
import shutil
import threading
import hal
import wpilib
import logging
logger = logging.getLogger('exposure_control')
@virtuald
virtuald / treetest.py
Last active August 16, 2016 06:11
Buggy DnD behavior in PyGObject (fix at https://github.com/virtuald/pygi-treeview-dnd)
#!/usr/bin/env python
#
# Demonstrates potential buggy behavior in PyGObject+Treeview DnD
#
# Bug is that when do_drag_data_get is called, the selection_data argument
# appears to be discarded and never used, regardless of the return value
#
# This sample program should be executed like so:
#
# python treetest.py ~/some/path/*
@virtuald
virtuald / README.md
Last active October 1, 2016 19:46
Concept Map playlist visualization generated by Exaile 3.4 beta3

At work, I've been playing a little bit with visualization of data. After hours, I DJ at local Lindy Hop dance events, and it occurred to me recently that it could be interesting to visualize my playlists to understand more about what I actually played. Using Exaile, I'm able to easily add a lot of metadata to the tracks in my collection, and its plugin framework made it easy to take that data and do something interesting with it.

From that initial investigation, I've built in a playlist visualization templating engine plugin for Exaile that can do some very simple visualization stuff, and I'm planning on extending the types of things I can do with it. Here's an interesting one I created from a recent playlist. This visualization was inspired by The Concept Map, except the source code for this isn't minified. :)

The HTML/js was generated by Exaile 3.4-beta3.

@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 / 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 / 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