Journal

34 entries under "code"

Friday, May 24, 2024

I was wondering if it’s possible to load a local JavaScript file via bookmarklet (to get around Firefox’s character limit) but it seems file:// URLs will return an error. I can either load an https:// URL or embed my file inside an extension.

Monday, May 20, 2024

How can we reduce the size of homebrew-cask and homebrew-core folders?

[As of Homebrew 4, you can save space by removing certain packages only used for developing formulae or casks:]

brew untap homebrew/core
brew untap homebrew/cask

Thursday, April 4, 2024

Cheap non-ugly ULID combining time and a random number using radix 36.

Date.now().toString(36) + Math.random().toString(36).replace('0.', '') // something like lulgjvgkc5mk5sbmfaf

Monday, March 18, 2024

Finally managed to install a custom app via Cloudron by following the tutorial documentation, and without installing Docker.

1. Install the Cloudron CLI locally

sudo npm install -g cloudron
cloudron login my.example.com

2. Setup build tools

One-click install the Docker Registry App (replace alfa.bravo below with this app domain) and Build Service App (replace charlie.delta below with this app domain) via your Cloudron App Store. Configure the latter’s credentials in /app/data/docker.json via the File Manager

{
  "alfa.bravo": {
    "username": "CLOUDRON_USERNAME",
    "password": "CLOUDRON_PASSWORD"
  }
}

and restart the app.

3. Install the pre-packaged custom app

Replace the simple tutorial app with yours:

git clone https://git.cloudron.io/cloudron/tutorial-nodejs-app
cd tutorial-nodejs-app
cloudron build --set-build-service https://charlie.delta --set-repository alfa.bravo/echo/foxtrot --tag golf
cloudron install --image alfa.bravo/echo/foxtrot:golf

If you want to update, run cloudron build again, then call cloudron update like so:

cloudron build --set-build-service https://charlie.delta --set-repository alfa.bravo/echo/foxtrot --tag golf
cloudron update --image alfa.bravo/echo/foxtrot:golf

Resources

Aside from the tutorial documentation, I found some hints in these forum topics:

Wednesday, March 6, 2024

Whisper or ‘Whisper-Faster’ can run as a standalone terminal program on macOS 10.14 with whisper-standalone-win by simply downloading the binary from ‘releases’ and running a single command from the resulting folder:

./whisper-faster "~/alfa/bravo.mp3" --pp --model base.en --language=en --output_format all --output_dir .

This will fetch the model if there isn’t a local copy, and transcribe into about half a dozen formats, including plaintext, JSON, and subtitle files.

The openai/whisper documentation says:

The .en models for English-only applications tend to perform better, especially for the tiny.en and base.en models. We observed that the difference becomes less significant for the small.en and medium.en models.

To run it without printing text into the console, use -pp or send to NUL

Saturday, March 2, 2024

macOS Time Machine exclusions can be managed via the terminal, as documented in Exclude folders by regex (?) from time machine backup, Control Time Machine from the command line, and Scripting Timemachine exclusion lists:

find `pwd` -maxdepth 3 -type d -name 'node_modules' | xargs -n 1 tmutil addexclusion

But this doesn’t make it show up in the System Preferences GUI. Writing to defaults seems to do that:

sudo defaults write /Library/Preferences/com.apple.TimeMachine.plist SkipPaths -array-add "~/.cache"

but I’m too paranoid about doing it wrong to see what happens.

Asimov is another option (installed via homebrew) to “Automatically exclude development dependencies from Apple Time Machine backups”.

Friday, March 1, 2024

How Bear does analytics with CSS

when a person hovers their cursor over the page (or scrolls on mobile) it triggers body:hover which calls the URL for the post hit. I don’t think any bots hover and instead just use JS to interact with the page, so I can, with reasonable certainty, assume that this is a human reader.

Friday, February 23, 2024

How many HTTP requests does it take to read a blog post versus a thread? What does it mean when it matters? What does it mean when it doesn’t?

Saturday, February 17, 2024

Forked cors-anywhere to replace cors-proxy.fringe.zone with cors.rosano.ca in Joybox, OSFeedbox, and home.

YunoHost has an ‘Edit’ button on their homepage which lets you directly modify the content and send them a ‘patch’.

I wasn’t able to submit my change because of a ‘File not found’ error, but still find it fascinating to not require people to use GitHub or Git in order to contribute.

The logic is in the seemingly random ‘gertrude’ repository (which has not much of a README or description for what it is, and it looks like the ‘patch’ is just the full HTML page content; perhaps someone can manually integrate it later. They claim to require email verification to catch spam before actually sending the change.

If it was possible to put a mailto on the internet without spam, it could remove friction from this kind of collaboration and create steps for people to do larger things.

Monday, February 12, 2024

[DRAFT] FAST Accessibility Checklist

[Look for these cues to ensure accessibility: visual content (like images, video); changeable color; input controls; interaction features; audio content; time limits; text-only input.]

Spec review i18n checklist

[Look for these cues to handle underlying localization: natural language text for humans (in error messages, UI text, JSON strings, etc…); interactions with text through a keyboard or cursor; searching, matching, sorting text; capturing user input; represents time; deals with names, addresses, time formats, etc…; references any cultural norms.]

How to be a -10x Engineer

Mock function calls until no original code runs.

Wow, do I need to change my approach!

Sunday, February 11, 2024

People don’t like build systems but they love static-site generators.

Friday, February 9, 2024

Hugo Testing

Each branch of Joe’s hugo-testing git repository is a scratchpad where he has over 750 attempted ‘solutions’ to help different people on the Hugo forum. Seems like discovery requires starting at a specific topic (as opposed to searching for the problem or solution), but it’s quite organized the way it is. How might being this prolific in helping others impact one’s own skills?

Wednesday, February 7, 2024

Is there a better way to run a command N times in bash?

alfa=10
for bravo in $(seq $alfa); do
   echo "$bravo"
done

How do I get the Git commit count?

git rev-list --count master

How do you jump to the first commit in git?

git checkout `git rev-list --max-parents=0 HEAD | tail -n 1`

Monday, February 5, 2024

Building a self-updating profile README for GitHub

GitHub Actions can run on a recurring schedule and manually by pushing a button.

Saturday, February 3, 2024

[1. Distribute a self-hostable package; 2. Releases are free to distribute and use, source not available; 3. Offer free community support channels via a forum or chat; 4. Provide source and extended community access for a monthly fee; 5. Automatically make the source available on a rolling basis delayed by one year.]