Skip to content

Instantly share code, notes, and snippets.

@laroo
laroo / backup.sh
Created June 29, 2023 20:53
Borg backup script using Borgmatic and ntfy.sh
#!/usr/bin/env bash
function _trap_exit () {
ret=$?
if [ $ret -ne 0 ]; then
echo "Backup failed on '${BASH_COMMAND}'"
notify "max" "skull" "Borgmatic backup failed on '${BASH_COMMAND}'"
else
notify "default" "+1" "Borgmatic backup completed successfully"
@laroo
laroo / NMEA_NEO-6M.txt
Created March 15, 2023 23:56
NMEA commands for u-blox NEO-6M gps receiver
# Disabling all NMEA sentences
$PUBX,40,GGA,0,0,0,0*5A // Disable GGA
$PUBX,40,GLL,0,0,0,0*5C // Disable GLL
$PUBX,40,GSA,0,0,0,0*4E // Disable GSA
$PUBX,40,GSV,0,0,0,0*59 // Disable GSV
$PUBX,40,RMC,0,0,0,0*47 // Disable RMC
$PUBX,40,VTG,0,0,0,0*5E // Disable VTG
$PUBX,40,ZDA,0,0,0,0*44 // Disable ZDA
# Enabling all NMEA sentences
@laroo
laroo / PythonFlask_BulkModelSave_PaginatedQuery.py
Last active January 17, 2022 14:44
Python/Flask: BulkModelSave & PaginatedQuery: Context managers that will speedup insert/update & iterating a lot of rows
from __future__ import absolute_import, division, print_function, unicode_literals
from builtins import object # Python3 Compatibility
import logging
import math
from typing import Text, Dict, Optional
from datetime import datetime
from decimal import Decimal
import sqlalchemy
@laroo
laroo / postgresql_csv2table.sql
Created July 3, 2019 09:59
Quick CSV to table/CTE in PostgreSQL (RDS Aurora)
WITH csv_data AS (
SELECT string_to_array(regexp_split_to_table(
'2019-07-01,6001,49
2019-07-02,6001,91
2019-07-03,6001,23
2019-07-04,6001,79
2019-07-05,6001,16
2019-07-06,6001,
2019-07-07,6001,
2019-07-08,6001,54
@laroo
laroo / bash-blueprint-simple.sh
Last active June 29, 2023 09:58
Bash Blueprint - Simple
#!/usr/bin/env bash
function _trap_exit () {
echo "[exit]"
}
trap _trap_exit EXIT
function _trap_ctrl_c() {
echo "** Trapped CTRL-C"
exit -1
@laroo
laroo / .wacomcplrc.sh
Created December 3, 2015 09:53
Configuration for Wacom Graphire4 on Ubuntu 14.04
#!/bin/sh
# Configuration for Wacom Graphire4 on Ubuntu 14.04
#
# Add this script to your '~/.bashrc'
# (based on http://burner.com/autodesk-stuff/remapping-wacom-buttons-linux/)
# $ xsetwacom list dev
# Wacom Graphire4 4x5 stylus id: 12 type: STYLUS
# Wacom Graphire4 4x5 eraser id: 13 type: ERASER