Category: Projects

  • Capture Card Viewer

    I recently came across an old, unopened Lenovo Chromebook 10e tablet from when I purchased two during a 99 dollar (each) fire sale maybe four years ago. Nowadays, they are arguably almost junk, sporting an old MediaTek processor running at 4C, 2.0 GHz, but still with a decent quality 10.1 inch screen at a 1920×1200 resolution and running Chrome OS 64-bit. (At some point in the last few years, they updated the OS to be 64-bit, it definitely used to be only 32-bit not that long ago.) This tablet undoubtedly has seen better days and is quite laggy when it comes to running applications. So, this got me thinking: What can this tablet be good for still in this day and age? — Ah, a portable, battery-powered monitor!

    Rewind a few months back, I had purchased a USB-C capture card in a similar effort of trying to accomplish a portable monitor, but with my iPad Pro. The capture card shows up as a webcam with an audio input as well and works decently well with the various iPadOS apps like HDMI Monitor from Orion. However, I have found that I don’t want to relegate my iPad to being just a portable monitor and it would be nice if I just had a semi-dedicated device for this portable monitor functionality — in comes this near-junk-status tablet.

    My first stop was of course to the Play Store, why build something when you can just buy it (or download it for free)? But, alas, the “premier” capture card app that I found (CapView), was incompatible with my ancient tablet. This led me down the natural rabbit hole of finding an alternative. One option was potentially using the built in Camera app, but without audio playback and a less than optimal screen-layout in the camera app, the experience was abysmal.

    So, I embarked on building my own — one that is low resource enough for an old tablet and one that is ideally relatively portable. Knowing that the USB capture card is exposed as a camera and microphone, a few choices came to mind: build a basic Android camera app, which would require me to restart my Android development days; or, I could just build it as a web app utilizing the latest in HTML5 technologies (navigator.mediaDevices.getUserMedia)!

    A few short hours of writing HTML and Javascript later, along with some additional polish like adding a basic CSS theme, drawing an SVG icon, and playing with the layout a bit, the resulting SPA artifact was pushed to Cloudflare Pages and Capture Card was born!

    Capture Card is hosted at https://capturecard.pages.dev/, an easy to remember URL that provides a basic page that supports accessing both the camera and microphone of a capture card. It exposes the devices as a basic video element, initially muted in-case you accidentally have an audio loop, and allows you to enable a fullscreen or picture-in-picture experience with the native video element. For added convenience, you can even use the query parameters video and audio to leverage name-based matching for the two devices. For example, https://capturecard.pages.dev/?video=usb&audio=usb will automatically use the devices that contains the word usb inside it, making it super easy to quickly open the right devices from a bookmark.

    The entire tool is hosted as a single HTML page, with zero external dependencies, requiring no long term maintenance as the tool doesn’t require updating unless the HTML/Javascript spec changes in some incompatible way. It is quick and easy to use on a Chromebook tablet like the one I have and does the job. Hopefully someone else comes across this tool and finds it useful to their flow. For now, I have found a new purpose for an old tablet.

    Got feedback? Leave a comment! I would appreciate any constructive feedback you have, or just let me know you’re using it. Enjoy!

  • Single Transferable Vote Election Tabulator

    Single Transferable Vote Election Tabulator

    For the 2016-17 school year election, the University of California, Santa Barbara’s Associated Students adopted single transferable voting¹ to elect their senate seats. Leading the software development, the tabulator is implemented in Python 3 with a wxPython-based front end. The software provides support for custom parsers to convert ballot data from different polling software to a universal JSON data format which is then processed by the tabulator. The software is divided into a backend thread that processes the election tabulation data and a modular front-end to allow for future alternative front-end implementations.

    As of December 2016, the election tabulator using STV has been open sourced and is available on GitHub. It is currently in use by the University of California, Santa Barbara, and North Dakota State University.

    ¹ Single transferable voting is a ranked voting system that redistributes an elector’s vote among unelected candidates based upon the individual’s ranked preference when either a candidate has been elected or eliminated from a race. This system provides a more proportional representation of parties during a multi-seat election.

  • CloudFlare Bulk IP Switcher

    A little while back, I had to move a bunch of web services that were hosted on a VPS to a new datacenter. As part of the move, I wasn’t able to transfer the IPs, so I was assigned a new IP. So, now I had to update all of my DNS records to reflect the change. Owning multiple domains, I realized that CloudFlare doesn’t provide an easy way to make this IP change across multiple zones (domains).

    If I wanted to change the records in each zone, I would need to export the DNS records in BIND format, make the changes, and then reupload the records. To fill this gap, I created a simple bulk IP changer that uses the CloudFlare API to iterate through all the zones and find all instances of the original IP address and replace the value with a new IP. I recently had the time to clean up this code, and I have now released it as open source.

    The source code is available on GitHub under an MIT license.

  • Tic-Tac-Toe Robot

    Tic-Tac-Toe Robot

    As part of ECE 92 (Projects in Electrical and Computer Engineering), I designed and built a robotic arm that plays a pencil-and-paper tic-tac-toe game with either 1 or 2 players. The system consists of an ARM based Arduino MCU board, a light weight 3 servo robot arm modified to hold a pen that floats vertically to handle variations on the board and arm angles, an LCD that displays the score, and two keypads for user input. The C++-based embedded software calibrates the arm servos which then draws the 9-square game grid, scans the keypads, updates the display, and draws the X and O game symbols based on the user input or its internal game algorithm.

    The display poster is available here and the related source code can be found on GitHub.