Skip to content

Instantly share code, notes, and snippets.

@the-solipsist
the-solipsist / watch-for-webpage-change-cron.sh
Created June 6, 2023 18:28 — forked from maxme/watch-for-webpage-change-cron.sh
Set this up in a crontab to check if a webpage changed since last check. It will email you the diff when it happens.
#!/bin/sh
checkIfPageChanged() {
URL="$1"
EMAIL_ADDRESS="$2"
CSS_SELECTOR="$3"
SILENT="$4"
tmpfile1=/tmp/$(echo $URL| sha1sum | cut -d" " -f1)
tmpfile2=$tmpfile1-1
curl -L --silent "$URL" -A "Maxme/1.0 (Watching for changes; https://gist.github.com/maxme/c31ffbb3cb21f3baa6e9c9e61bbe0a72)" \
@the-solipsist
the-solipsist / zotero-search-replace.js
Created September 10, 2023 20:41
Zotero search and replace javascript
// Adapted from
// https://forums.zotero.org/discussion/78501/possible-to-search-replace-a-character-in-all-titles
var s = new Zotero.Search();
s.libraryID = Zotero.Libraries.userLibraryID;
//s.addCondition('itemType', 'is', 'attachment');
// Add as many conditions as you like
s.addCondition('title', 'contains', 'Text to be replaced');
// get a list of valid fieldnames from https://api.zotero.org/itemFields?pprint=1
var ids = await s.search();
if (!ids.length) {
@the-solipsist
the-solipsist / notes_inline.lua
Created October 7, 2023 08:51
Convert Pandoc reference footnotes to inline footnotes
-- copied from https://groups.google.com/g/pandoc-discuss/c/_5-8TRJhhqo/m/xkbSBz2wAgAJ
-- pandoc --lua notes_inline.lua temp.md | sed -e 's/%%opening%%/ /g' | sed -e 's/%%closing%%//g'
function Note(note)
if #note.content == 1 then
table.insert(note.content[1].content, 1, pandoc.Str "%%opening%%")
table.insert(note.content[1].content, pandoc.Str "%%closing%%")
return note.content[1].content
@the-solipsist
the-solipsist / expense-accounts_coicop.journal
Created January 29, 2024 09:28
hledger account heirarchy based on COICOP 2018
; This chart of accounts is based on COICOP 2018.
; https://unstats.un.org/unsd/classifications/unsdclassifications/COICOP_2018_-_pre-edited_white_cover_version_-_2018-12-26.pdf
; While COICOP provides a "detailed" classification as well, going to 4-levels of depth,
; this is based on the "broad" classification, which goes to 2-levels of depth.
account Expenses:F&B
account Expenses:F&B:Food
account Expenses:F&B:Non-alcoholic-Beverages
account Expenses:F&B:Services
account Expenses:Alcohol&Narcotics
(01) Expenses:Food
(01.1) Expenses:Food:Food
(01.2) Expenses:Food:Beverages
(01.3) Expenses:Food:Processing
(02) Expenses:Alcohol
(02.1) Expenses:Alcohol:Beverages
(02.2) Expenses:Alcohol:Production
(02.3) Expenses:Alcohol:Tobacco
(02.4) Expenses:Alcohol:Narcotics
(03) Expenses:Clothing
@the-solipsist
the-solipsist / coicop_2018_detailed.csv
Last active February 26, 2025 08:30
Classification of individual consumption by purpose (COICOP) - Detailed in JSON, YAML, XML, JSONL, CSV, TSV
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 2.
"code","title","category","intro","includes","alsoIncludes","excludes"
"01","Food and non-alcoholic beverages",,"Division 01 covers food (01.1) purchased by households mainly for consumption or preparation at home and non-alcoholic beverages (01.2) purchased by households, regardless of where they are consumed. Division 01 excludes food and non-alcoholic beverages that are provided by facilities such as restaurants and school cafeterias through their food and beverage serving services (division 11).
Services purchased for the processing of primary goods provided by households to produce food and non-alcoholic beverages for their own consumption are also classified under this division (01.3).
Food comprises all edible goods that are purchased and consumed by households for the purpose of nourishment. Food includes: cereals and cereal products; meat; fish and other seafood; milk, other dairy products and eggs; oils and fats; fruit and nuts; vegetables, tubers, plantains, cooking bananas and pulses; sugar, con
@the-solipsist
the-solipsist / hledger-jj
Last active March 3, 2025 18:19
hledger-jj converted from ysh to bash by Gemini 2.0
#!/bin/bash
# -*- sh -*-
# Improved version of hledger-jj bash script, created by Gemini 2.0
# Original version of hledger-jj ysh script, created by Simon Michael
# --- Error Handling and Setup ---
if [[ -z "$LEDGER_FILE" ]]; then
echo "Error: LEDGER_FILE environment variable is not set." >&2
exit 1
fi
@the-solipsist
the-solipsist / usa-balance_of_trade-2024.csv
Last active April 14, 2025 20:38
USA's 2024 balance of trade against countries and areas (used in USTR's tariff formula)
year CTYNAME IYR EYR
2024 European Union 605760.393292 370189.230351
2024 World, Seasonally Adjusted 3267460.598735 2065131.061971
2024 Advanced Technology Products 763239.061303 464290.844933
2024 South and Central America 158813.069142 206144.200255
2024 North America 918546.31846 683401.298991
2024 Europe 770791.040045 503629.070492
2024 Africa 39514.999022 32125.813165
2024 Pacific Rim 1001672.349154 491850.736295
2024 World, Not Seasonally Adjusted 3267460.598737 2065131.061971
@the-solipsist
the-solipsist / blocked_accounts.txt
Last active May 10, 2025 08:48
Twitter/X accounts blocked in India due to legal demands by the Indian government
# These accounts were unavailable from an
# Indian IP address from 2025-05-03 onward
@Abdullah795895
@abeer_jahangir
@AdeelNonari
@afridi477
@Aftabhu98917565
@ahmedalisubhani
@akhtar4988
@AkhterNaqvi3