Skip to content

Instantly share code, notes, and snippets.

@redraw
redraw / battery-monitor
Last active February 19, 2022 12:05
/usr/lib/systemd/system-sleep/battery-monitor
#!/bin/bash
# battery monitor systemd suspend/resume hook
LOGFILE=/var/log/battery.csv
KERNEL=$(uname -r)
BIOS=$(dmidecode -s bios-version)
log() {
cd /sys/class/power_supply
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/bin/bash
# brew install xbar jq
# pip install astro-cli
PATH=$PATH:/usr/local/bin
ASTRO=$(pyenv which astro)
$ASTRO --date "a week ago" -f json moon phases | jq -r "first | .emoji"
echo "---"
echo "phases | size=10"
let more = true
let data = []
let offset = 0
while (more) {
console.log(`Fetch offset: ${offset}`)
var req = new XMLHttpRequest();
req.open("GET", `https://www.pedidosya.com.ar/mobile/v2/users/myOrders?state=CONFIRMED&max=10&offset=${offset}&countryId=3`, false);
req.send(null)
let response = JSON.parse(req.responseText)
curl -sL whatthecommit.com | htmlq "#content p:first-child" -tw | sed '/^$/d'
@redraw
redraw / googlefit.ipynb
Last active April 19, 2021 01:53
my google fit records in covid time
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@redraw
redraw / dotfiles.sh
Last active March 17, 2021 00:48
restore dotfiles script
#!/bin/bash
# clone repo
git clone --bare git@github.com:redraw/dotfiles.git $HOME/.dotfiles
dotfiles () { git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"; }
# backup
for file in $(dotfiles ls-tree --name-only HEAD); do
mv -vf $file $file.bak 2>/dev/null
done
inotify(watch/wait) -- inotify tools to monitor file changes
wrk -- stress http server test
sendmidi/receivemidi -- midi tools
ipcalc -- calculate network hosts ranges
pup -- parse DOM
pyp -- pipe to python
qrcp -- transfer files scanning qr
gotty -- share tty
zerotier -- free tunnel / private LAN mesh network
castnow -- cast media to chromecast
@redraw
redraw / gist:f94756a2e2d9627d5af33731162b2d81
Last active March 5, 2021 23:02
el sr @ignaciovidal nos dejo manijas para repasar como funcionaba la herencia multiple en Python
>>> class A():
...: def uno(self):
...: print("A uno")
>>> class B():
...: def uno(self):
...: print("B uno")
...: def dos(self):
...: print("B dos")
...:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.