Skip to content

Instantly share code, notes, and snippets.

View GwynethLlewelyn's full-sized avatar
👩
Learning Go

Gwyneth Llewelyn GwynethLlewelyn

👩
Learning Go
View GitHub Profile

An attempt to get all command line configurations working to manually compile Homebrew's Node.js for macOS Big Sur

  ./configure --without-npm --with-intl=system-icu --shared-libuv --shared-nghttp2 --shared-openssl --shared-zlib --shared-brotli --shared-cares --prefix=/usr/local/Cellar/node/23.3.0 --use-prefix-to-find-headers --openssl-use-def-ca-store --enable-lto

Notes

  1. Use default XCode compiler & linker (reset appropriate variables!)
@GwynethLlewelyn
GwynethLlewelyn / extract-uuid.sh
Created August 20, 2024 17:52
Shell script that will grab all Second Life textures necessary for a specific LLSD XML backup
#!/bin/sh
# Grab all possible textures from LL's own CDN, referenced by UUID from LLSD backups.
# Usage: Go to where your LLSD XML files are stored; run script. Wait a few seconds. Done!
# (cc) 2024 by Gwyneth Llewelyn. Some rights reserved.
# Distributed under the MIT license: https://gwyneth-llewelyn.mit-license.org
# Second Life® is a registered trademark of Linden Lab. No copyright infringement is intended.
#
LLURL=http://asset-cdn.glb.agni.lindenlab.com/?texture_id=
for uuid in $( ug -U -P --format='%1%~' --regexp '<uuid>([a-f0-9\-]+)</uuid>' -- *.xml | sort | uniq ) ;
do
@GwynethLlewelyn
GwynethLlewelyn / convert.sh
Last active July 21, 2024 16:26
Batch conversion using ImageMagick
for file in *.png ; do
magick "$file" -define webp:lossless=true -define webp:auto-filter=true -define webp:filter-strength=50 -define webp:image-hint=picture -define webp:method=6 -define webp:thread-level=1 "${file%.*}.webp" ;
done
@GwynethLlewelyn
GwynethLlewelyn / imagemagick-convert-multiple-resolutions.md
Last active April 7, 2024 21:15
ImageMagick Simultaneously Convert To Multiple Resolutions
convert gw-original-1400.png -write mpr:img +delete \( mpr:img -resize 1280x +write gw-1280.png \) \( mpr:img -resize 1024x +write gw-1024.png \) \( mpr:img -resize 512x +write gw-512.png \) \( mpr:img -resize 500x +write gw-500.png \) \( mpr:img -resize 300x +write gw-300.png \) \( mpr:img -resize 256x +write gw-256.png \) \( mpr:img -resize 160x +write gw-160.png \) \( mpr:img -resize 128x +write gw-128.png \) \( mpr:img -resize 100x +write gw-100.png \) \( mpr:img -resize 90x +write gw-90.png \) \( mpr:img -resize 80x +write gw-80.png \) \( mpr:img -resize 64x +write gw-64.png \) \( mpr:img -resize 50x +write gw-50.png \) \( mpr:img -resize 40x +write gw-40.png \) \( mpr:img -resize 32x +write gw-32.png \) \( mpr:img -resize 16x +write gw-16.png \) null:
h
@GwynethLlewelyn
GwynethLlewelyn / generate-dane-tlsa-records.sh
Last active November 14, 2023 09:45
Viktor Dukhovni's shell script to generate all possible TLSA records for DANE from the full certificate chain
#! /usr/bin/env bash
# Bash needed for PIPESTATUS array
# Author: Viktor Dukhovni <[email protected]> (@ietf-dane)
# Date: 28 December 2015
# From https://community.letsencrypt.org/t/making-a-dane-tlsa-to-work-with-le/2129/8
# See also https://community.letsencrypt.org/t/please-avoid-3-0-1-and-3-0-2-dane-tlsa-records-with-le-certificates/7022
extract() {
case "$4" in
0) openssl x509 -in "$1" -outform DER;;
@GwynethLlewelyn
GwynethLlewelyn / convert-from-Latin-1-to-UTF-8.md
Created November 2, 2023 13:20
One-liner shell script to convert every file in a large directory tree from ISO-Latin-1 to UTF-8

Convert files from ISO-8859-1 (Latin-1) to UTF-8, recursively

This requires recode to be installed (brew install recode or apt install recode).

The example shows HTML files only. Adjust as required.

Process:

  1. (Recursively) find all files that end with *.htm or *.html.
  2. For each match, check its file type using file.
@GwynethLlewelyn
GwynethLlewelyn / get-flag.go
Created August 4, 2023 10:53
Go lang conversion from ISO-3166-1 two-letter codes to flag emoji
// To run this on the Go Playground: https://go.dev/play/p/9na7SU0ExdD
package main
import "fmt"
func main() {
country := "PT"
fmt.Printf("%s — Decimal: %d %d Hex: %#[1]x %#x\n", country, rune(country[0]), rune(country[1]))
@GwynethLlewelyn
GwynethLlewelyn / go-testing-fs-readdir.go
Created March 6, 2023 18:37
How to walk through a directory in Go (using the 'modern' post-1.16 functionality)
// See this in action: https://go.dev/play/p/mA3RRGhyZRe
// Read more about it: https://bitfieldconsulting.com/golang/filesystems#generalising-the-file-counter (scroll down a bit)
//
// The following code excerpt is placed in the Public Domain (CC0) by Gwyneth Llewelyn (2023)
package main
import (
"fmt"
"io/fs"
@GwynethLlewelyn
GwynethLlewelyn / direct-messages.js.md
Created December 15, 2022 14:01
Convert Twitter JSON direct messages to an easier format

Suppose you need to do a copy & paste of a conversation you had on Twitter to send it by email. Unfortunately, it's very hard to copy & paste it in toto from either the app or the web. Twitter makes it as hard as possible to do so, especially if you wish the whole conversation.

Conversations are conveniently stored as JSON files, but... you need to get access to them. One possible way to do so is the following:

  1. Ask Twitter for a link to an archive of all your data to be downloaded (they'll take up to 24 hours to provide you with it)
  2. Make sure jq is installed
  3. "862741-8538292" represents a conversation between two Twitter IDs (recipientId)
  4. You may have to massage the first line of direct-messages.js so that it reads