Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# example converts an html table to json using pup & jq
# unfortunately, it appears pup does not natively decode characters within the
# html transform? tried using the --plain flag but no dice.
curl -s https://news.ycombinator.com/ \
| pup 'table table tr:nth-last-of-type(n+2) td.title a json{}' \
| jq '.[]|{href,text}|select(.text!=null)' \
| jq -s '.'
@lidopaglia
lidopaglia / tfdl.ps1
Created May 13, 2023 15:51
Example using PowerHTML module to parse html table content
#!/usr/bin/env pwsh
# Requires -Module PowerHTML
# Most downloaded movies via torrent sites by TorrentFreak.com
param(
[parameter()]
[switch]$full=$false
)
@lidopaglia
lidopaglia / duration.sh
Created December 10, 2021 18:08
Print duration of all movies with 'Christmas' in the title
#!/usr/bin/env bash
# use mediainfo to get total playtime of one or more video files
# and then calculate total playtime.
# e.g. mediainfo --Inform="Video;%Duration%" [inputfile]
err() {
echo "Error: $1"
exit 1
}
@lidopaglia
lidopaglia / clip2md
Last active March 12, 2022 19:22
browser bookmarklets
javascript:(
function() {
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
/*IE specific code path to prevent textarea being shown while dialog is visible.*/
return clipboardData.setData("Text", text);
}
else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
@lidopaglia
lidopaglia / mindlamp_cache.log
Created September 10, 2021 21:09
logs collected for mindlamp troubleshooting
1:C 10 Sep 2021 18:25:50.276 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 10 Sep 2021 18:25:50.276 # Redis version=6.0.8, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 10 Sep 2021 18:25:50.276 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 10 Sep 2021 18:25:50.285 * Running mode=standalone, port=6379.
1:M 10 Sep 2021 18:25:50.285 # Server initialized
1:M 10 Sep 2021 18:25:50.285 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
1:M 10 Sep 2021 18:25:50.285 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled' as root,
@lidopaglia
lidopaglia / seqcurl.sh
Created August 30, 2021 13:30
example that creates a string of curl commands to sequentially check for wan ip.
#!/bin/bash
prog=${0##*/}
errlog(){
logger -i -s -t $prog -p error "$2"
[ $1 -gt 0 ] && exit $1
}
infolog(){
@lidopaglia
lidopaglia / jsonval.sh
Created August 30, 2021 13:26
returns the value of a json property
#!/bin/bash
function jsonval() {
# extract the value of a json property.
# if avoiding jq as dependency makes sense.
# https://gist.github.com/cjus/1047794
prop="$1";json="$2"
temp=`echo $json \
| sed 's/\\\\\//\//g' | sed 's/[{}]//g' \
| awk -v k="text" '{n=split($0,a,",");

NVMe

Recently purchased two NVMe SSD disks. The [Corsair Force MP600][3] and the [Inland Premium 2TB][4]. Installed in a desktop running Ubuntu 20.04.2 LTS.

First, installed nvme-cli tools. Userspace tooling to control NVMe drives:

sudo apt install nvme-cli
@lidopaglia
lidopaglia / 01.bash_shortcuts_v2.md
Created August 7, 2021 16:00 — forked from tuxfight3r/01.bash_shortcuts_v2.md
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@lidopaglia
lidopaglia / nginx-ip-api.md
Created August 7, 2021 15:56
NGINX script for making your own public IP API

NGINX script for making your own public IP API

location /ip {
    default_type text/plain;
    return 200 $remote_addr;
}
location /ip_json {
    default_type application/json;
 return 200 "{\"ip\":\"$remote_addr\"}";