Skip to content

Instantly share code, notes, and snippets.

@DaneGardner
DaneGardner / rebuild.sh
Created December 29, 2022 23:23
Install RTL8761B drivers in LibreElec OS
#!/bin/bash -ex
image=SYSTEM
sdcard=/media/${USER}/LIBREELEC
path=squashfs-root
rm -rf ${image} ${path}
cp ${sdcard}/${image} ${image}
unsquashfs ${image}
@DaneGardner
DaneGardner / main.py
Created March 26, 2021 21:22
"Red alert" for locally run script
def main():
raise NotImplementedError()
if __name__ == "__main__":
try:
main()
except Exception:
import vlc
from time import sleep
@DaneGardner
DaneGardner / gist:9eb09cb0a31db2324e22075f27f06f9c
Created December 12, 2020 17:06
Scaling TastyWorks for Ubuntu 20.04 w/ 4k laptop monitor
# 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 November 26, 2018 00:34
Setting Celestron hand controller location via IP geolocation
#!/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 December 8, 2018 17:12
Setting Celestron hand controller time via NTP or RTC module
#!/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 October 28, 2024 17:36
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
DaneGardner / joystick-connect.sh
Created May 27, 2017 23:56
Automatic connecting to Bluetooth joystick for Raspberry Pi
#!/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 June 1, 2016 22:48
macvim on Mac OS X 10.11.5 - Homebrew build logs
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 October 22, 2015 17:39
Dropwizard healthchecks based on logged errors
@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);
}