Skip to content

Instantly share code, notes, and snippets.

DaneGardner /
Created Mar 26, 2021
"Red alert" for locally run script
def main():
raise NotImplementedError()
if __name__ == "__main__":
except Exception:
import vlc
from time import sleep
DaneGardner / gist:9eb09cb0a31db2324e22075f27f06f9c
Created Dec 12, 2020
Scaling TastyWorks for Ubuntu 20.04 w/ 4k laptop monitor
View gist:9eb09cb0a31db2324e22075f27f06f9c
# Tastyworks is created using JavaFX, as discovered by glancing through
# their java library directory. JavaFX does scale for hi-dpi displays,
# but only does this automatically on Mac. To force this behavior on
# Ubuntu, manually set the legacy gnome scaling factor that is being
# used by JavaFX to detect this state, but I believe is being ignored
# by Gnome itself. []
gsettings set org.gnome.desktop.interface scaling-factor 2
DaneGardner /
Last active Nov 26, 2018
Setting Celestron hand controller location via IP geolocation
readonly serial=/dev/ttyS0
latlon="$(curl -s | jq -r '.loc')"
lat=$(cut -d, -f1 <<< ${latlon})
lon=$(cut -d, -f2 <<< ${latlon})
location=$(./ "${lat}" "${lon}")
DaneGardner /
Last active Dec 8, 2018
Setting Celestron hand controller time via NTP or RTC module
readonly serial=/dev/ttyS0
function getTime() {
# temporarily disable the ntp client
service ntp stop
# force an immediate time update; with timeout at 30s
timeout 30 ntpd -gq
DaneGardner /
Last active Jul 18, 2021
Installing CUDA 9.1 on Ubuntu 18.04 (circ. 5/18)

Install CUDA 9.1 on Ubuntu 18.04

Prep system

sudo apt install build-essential gcc-6 g++-6

sudo update-alternatives --remove-all gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 20
sudo update-alternatives --set gcc /usr/bin/gcc-6
DaneGardner /
Created May 27, 2017
Automatic connecting to Bluetooth joystick for Raspberry Pi
### NOTE: add cron job that runs every minute using `crontab -e`:
### * * * * * ~/
# using a device ID is more secure, but using \t uses first available device
DaneGardner / # macvim - 2016-06-01_15-47-46.txt
Created Jun 1, 2016
macvim on Mac OS X 10.11.5 - Homebrew build logs
View # macvim - 2016-06-01_15-47-46.txt
Homebrew build logs for macvim on Mac OS X 10.11.5
Build date: 2016-06-01 15:47:46
DaneGardner /
Last active Oct 22, 2015
Dropwizard healthchecks based on logged errors
public void doRun(SwitchboardConfiguration configuration, Environment environment) throws Exception {
Optional<Meter> allLogs = Optional.fromNullable( environment.metrics().getMeters().get("ch.qos.logback.core.Appender.all") );
Optional<Meter> warnLogs = Optional.fromNullable( environment.metrics().getMeters().get("ch.qos.logback.core.Appender.warn") );
Optional<Meter> errorLogs = Optional.fromNullable( environment.metrics().getMeters().get("ch.qos.logback.core.Appender.error") );
if(allLogs.isPresent()) {
if(errorLogs.isPresent()) registerLogMeterAsHealthCheck(environment, allLogs.get(), errorLogs.get(), "logged_errors", 0.05D);
if(warnLogs.isPresent()) registerLogMeterAsHealthCheck(environment, allLogs.get(), warnLogs.get(), "logged_warns", 0.25D);