Skip to content

Instantly share code, notes, and snippets.

@gadgetmies
gadgetmies / gist:6166f4664d34fd44984aa4598cc8ff04
Created June 24, 2024 11:28
Search on Vivino Chrome context menu action
Add a "Search on Vivino" context menu action to Google Chrome:
Create a folder with the following files and their contents:
event.js:
const menuItem = {
"id": "searchVivino",
"title": "Search on Vivino",
"contexts": ["selection"]
};
@gadgetmies
gadgetmies / check_row_count_in_postgres.sql
Created April 17, 2024 09:42
Check table row count in PostgreSQL
SELECT
nspname AS schemaname,relname,reltuples
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE
nspname NOT IN ('pg_catalog', 'information_schema') AND
relkind='r'
ORDER BY reltuples DESC;
@gadgetmies
gadgetmies / passport-openidconnect-redirect.md
Last active December 27, 2023 19:33
Redirect to original url with passport-openidconnect

The library stores the state property passed to it in the options for passport.authenticate. The state is available for the return handler in the req.authInfo.state property.

E.g. for:

http://localhost:3000/login/google?state=/foo

with

router.get('/login/google', (req, res, next) => {
@gadgetmies
gadgetmies / aliexpress_default_wish_list_items.md
Last active July 9, 2024 15:47
Resolving Aliexpress default wishlist full issue

When using a desktop browser and adding items to wish list on Aliexpress, those products get added to the default wish list. After a while your default wish list will get full and you cannot add items into any wish list as the wish list button only adds items to the default wish list, from where those can be moved to other wish lists. There is no simple way to see the contents of the default wish list, so cleaning it up is difficult. I got frustrated enough with this and created a solution that at least makes the job easier:

To get the titles of the items that are in your default wish list:

  1. Open the developer console in the browser and select the network tab
  2. Navigate to the wish list page on Aliexpress
@gadgetmies
gadgetmies / tm_apfs_manual_backup_instructions.md
Last active September 28, 2023 06:52
Prevent unmount issues with Time Machine backup disk that is "permanently" connected to a USB dock (APFS version)

NOTE: Use these steps for APFS backups. If you have an HFS backup, use: https://gist.github.com/gadgetmies/3e1336d6d8733ecc199a5123671efd33

I got frustrated with the "Disk Not Ejected Properly" warnings I often got when disconnecting my laptop from the USB dock because I had not unmounted the Time Machine backup disk first. Decided it's probably best to do something about the issue before the disk gets damaged.

The solution is rather simple and has three parts:

  • Store the disk encryption password in your keychain and always allow it's use for mounting the disk
  • Prevent automatic mounting of the backup disk to prevent it being mounted when disconnecting the laptop from the dock
  • Create an application that mounts the disk, runs the Time Machine backups and unmounts the disk when done

The application can be launched manually (e.g. from the MacOS dock) or be scheduled to run every now and then.

@gadgetmies
gadgetmies / convert_filenames_to_ascii.sh
Last active April 30, 2023 20:54
Scripts for syncing tracks to a CDJ-compatible drive on a Mac
#!/bin/sh
# Use this script to remove special characters from the names of your files to make it easier to sync them between filesystems (e.g. APFS, NTFS and FAT32)
DIR=
EXTENSION="*.mp3"
# DEBUG=true # Remove '#' from the beginning of the line to also print out files not being renamed
if [ -z $DIR ]; then
echo "DIR not set. Please set it to the folder containing your files to be renamed"
@gadgetmies
gadgetmies / tm_hfs_manual_backup_instructions.md
Last active September 28, 2023 06:53
Prevent unmount issues with Time Machine backup disk that is "permanently" connected to a USB dock (HFS version)

NOTE: Use these steps for HFS backups. If you have an APFS backup, use: https://gist.github.com/gadgetmies/d83382bc74aa5bc60dc24d04fd4d3605

I got frustrated with the "Disk Not Ejected Properly" warnings I often got when disconnecting my laptop from the USB dock because I had not unmounted the Time Machine backup disk first. Decided it's probably best to do something about the issue before the disk gets damaged.

The solution is rather simple and has three parts:

  • Store the disk encryption password in your keychain and always allow it's use for mounting the disk
  • Prevent automatic mounting of the backup disk to prevent it being mounted when disconnecting the laptop from the dock
  • Create an application that mounts the disk, runs the Time Machine backups and unmounts the disk when done

The application can be launched manually (e.g. from the MacOS dock) or be scheduled to run every now and then.

@gadgetmies
gadgetmies / helen.js
Last active November 18, 2022 22:47
Fetch energy consumption from Helen with Puppeteer and push results to InfluxDB
// Put this file under src folder in the path where you put the run.sh
const puppeteer = require("puppeteer");
const http = require("node:http");
const influxOrg = ''
const influxBucket = ''
const influxHost = ''
const influxPort = 8086
const influxToken = ''