Skip to content

Instantly share code, notes, and snippets.

@DaneGardner
DaneGardner / main.py
Created Mar 26, 2021
"Red alert" for locally run script
View main.py
def main():
raise NotImplementedError()
if __name__ == "__main__":
try:
main()
except Exception:
import vlc
from time import sleep
@DaneGardner
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. [https://stackoverflow.com/a/26184471]
gsettings set org.gnome.desktop.interface scaling-factor 2
@DaneGardner
DaneGardner / hc-location.sh
Last active Nov 26, 2018
Setting Celestron hand controller location via IP geolocation
View hc-location.sh
#!/bin/bash
readonly serial=/dev/ttyS0
latlon="$(curl -s ipinfo.io | jq -r '.loc')"
lat=$(cut -d, -f1 <<< ${latlon})
lon=$(cut -d, -f2 <<< ${latlon})
location=$(./latlon2celestron.py "${lat}" "${lon}")
@DaneGardner
DaneGardner / hc-time.sh
Last active Dec 8, 2018
Setting Celestron hand controller time via NTP or RTC module
View hc-time.sh
#!/bin/bash
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
DaneGardner / ubuntu_18.04_cuda.md
Last active Jul 18, 2021
Installing CUDA 9.1 on Ubuntu 18.04 (circ. 5/18)
View ubuntu_18.04_cuda.md

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
DaneGardner / joystick-connect.sh
Created May 27, 2017
Automatic connecting to Bluetooth joystick for Raspberry Pi
View joystick-connect.sh
#!/bin/bash
###
### NOTE: add cron job that runs every minute using `crontab -e`:
### * * * * * ~/joystick-connect.sh
###
# using a device ID is more secure, but using \t uses first available device
DEVICE='\t'
#DEVICE='XX:XX:XX:XX:XX:XX'
@DaneGardner
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
DaneGardner / Service.java
Last active Oct 22, 2015
Dropwizard healthchecks based on logged errors
View Service.java
@Override
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);
}