Skip to content

Instantly share code, notes, and snippets.

@jmtsantos
jmtsantos / lockscreen-mining.sh
Created May 22, 2021 15:08
script to start your miner or whatever while the screen is locked
#!/bin/bash
# lockscreen-mining.sh script to start your miner or whatever while the screen is locked
XMRIG_BINARY=xmrig
XMRIG_CONFIG=/home/jsantos/opt/xmrig.json
start_miner () {
if pgrep -x $XMRIG_BINARY > /dev/null
then
# Small guide to create a LUKS disk on top of a bcache device using an SSD and HDD
# Setup
# /dev/sda cache device (SSD)
# /dev/sdb backing device (HDD)
# Create the bcache
# --block should match the sector size of the backing device
# --bucket should match the cache size of the cache device
# You can ommit these two arguments and just use the default values
@jmtsantos
jmtsantos / migrate_yb.sh
Last active May 22, 2021 15:10
migrate all you password-store passwords and secrets to another GPG key
#!/bin/bash
KEYID=<KEY ID FOR YOUR NEW ENCRYPTING KEY>
cd ~/.password-store
for f in $(find . -name '*.gpg'); do
oldpass=$(gpg -d $f)
echo $oldpass | gpg -r $KEYID -e > $f
chmod 600 $f
@jmtsantos
jmtsantos / uptime.sh
Created January 5, 2020 12:44
Register battery life to file
#!/bin/bash
start_time="$(date -u +%s.%N)"
while true
do
elapsed_time="$(date -u +%s.%N)"
echo "battery:$(cat /sys/class/power_supply/BAT1/capacity) seconds:$(bc <<<"($elapsed_time - $start_time)/60") uptime:$(uptime)"
echo "battery:$(cat /sys/class/power_supply/BAT1/capacity) seconds:$(bc <<<"($elapsed_time - $start_time)/60") uptime:$(uptime)" > uptime.txt
sleep 30
@jmtsantos
jmtsantos / cockpit.conf
Created November 21, 2017 17:41
Cockpit reverse proxy with nginx 1.13
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server cockpithost:9090;
}
server {
package cgd
import (
"errors"
"os"
"strconv"
"strings"
"sync"
"time"