Skip to content

Instantly share code, notes, and snippets.

@nixternal
nixternal / wledrandom.sh
Last active December 11, 2022 22:51
Shell script you can add to a cron job to make WLED play random animations and color palettes.
#!/bin/sh
HOSTNAME='wled-dlamp1.local'
if nc -z "$HOSTNAME" 80 2>/dev/null; then
if curl -s "http://$HOSTNAME/json/state" | jq -r ".on"; then
PALETTE=$(shuf -i 0-70 -n 1)
FX=$(shuf -i 0-117 -n 1)
curl -s "http://$HOSTNAME/win&FP=$PALETTE&FX=$FX" >/dev/null
fi
fi
exit
@nixternal
nixternal / automations.yaml
Created February 2, 2019 17:05
Home Assistant (HassIO) Automated Backup & Push to Dropbox using dropbox-sync from danielwelch/hassio-addons
- id: '1548903378760'
alias: Daily Backup
trigger:
platform: time
at: '3:00:00'
action:
- service: hassio.snapshot_full
data_template:
name: DailyBackup_{{ now().strftime('%Y%m%d') }}
- id: '1548903378761'
@nixternal
nixternal / gist:356b685bbb659df30e1ed3031c1fd4c6
Created November 5, 2017 07:14
Raspbian Stretch - PiTFT
This is for the 2.8" 320x240 TFT from Adafruit. This is what I did to get it working on my Pi Zero W (also the Pi 3).
It isn't perfect, but it is working. Only issues I see are during the boot. I don't see the logo and it seems the refresh is
really slow.
/boot/cmdline.txt:
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=PARTUUID=59e04602-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fbcon=map:10
^^ changed that from serial ^^ added this
/boot/config.txt:
### Keybase proof
I hereby claim:
* I am nixternal on github.
* I am richjohnson (https://keybase.io/richjohnson) on keybase.
* I have a public key whose fingerprint is 3578 0981 A21D D662 2A96 7623 F4C1 838C D8C4 4738
To claim this, I am signing this object:
@nixternal
nixternal / gist:4970201
Created February 17, 2013 04:37
Get length of video, specifically MP4, using Python subprocess and mplayer. Any better idea/way to do this?
def get_mplayer_length(filename):
result = subprocess.Popen(['mplayer', '-vo', 'null', '-ao', 'null',
'-frames', '0', '-identify', filename], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
duration = [x for x in result.stdout.readlines() if "ID_LENGTH" in x]
return duration[0].split('=')[1].strip('\n')
#!/usr/bin/env python
import subprocess
from optparse import OptionParser
def get_mplayer_length(filename):
result = subprocess.Popen(['mplayer', '-vo', 'null', '-ao', 'null',
'-frames', '0', '-identify', filename], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
@nixternal
nixternal / gist:4962445
Created February 15, 2013 18:50
quick hack to get the total running time, or duration, of a video file.
#!/usr/bin/env python
import subprocess
from optparse import OptionParser
def get_length(filename):
result = subprocess.Popen(['ffprobe', filename], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
duration = [x for x in result.stdout.readlines() if "Duration" in x]