Skip to content

Instantly share code, notes, and snippets.

View scmx's full-sized avatar

Albert Arvidsson scmx

View GitHub Profile
@scmx
scmx / vanilla-jsdoc-typescript-jsconfig-setup.md
Last active May 12, 2025 07:08
Vanilla JavaScript setup with JSDoc TypeScript Compiler Linting using jsconfig.json + Node.js builtin Test Runner

Vanilla JavaScript setup with JSDoc TypeScript Compiler Linting + Node.js builtin Test Runner

Here's how I usually set up vanilla javascript projects these days to enable typescript compiler jsdoc linting via jsconfig.json with checkJs: true.

JSDoc TypeScript Reference

First you need a jsconfig.json with at least "checkJs": true. TypeScript as a dev dependency npm i -D typescript. Not needed for build since it's vanilla javascript.

@scmx
scmx / node-repl-start-with-esm-already-imported.md
Created May 10, 2025 11:04
How to start Node.js repl with some ESM already imported #node #repl

How to start Node.js repl with some ESM already imported

repl.js

import { foo, bar } from './foobar.js'
import { baz } from './baz.js'
Object.assign(globalThis, { foo, bar, baz })

node -r ./repl.js

@scmx
scmx / proj-fzf-project-opener-with-tmuxinator.md
Last active December 14, 2023 15:16
proj shell script project opener using fzf with tmux and tmuxinator

proj shell script project opener using fzf with tmux and tmuxinator

proj-fzf-project-opener-tmux-nvim

First you need a script like this in your terminal. It will detect all your projects, format them with a date when last used, sort them and pass through fzf. When a project has been selected it will cd to that directory and by default run tn which is another script for creating a new tmux session from the current directory. If you run proj something it will run that instead inside that directory.

$HOME/.zshrc or similar

proj() {
  local project_cmd=("$@")
@scmx
scmx / generate-qrcode-quick-action.md
Last active November 21, 2023 15:09
Generate QR code macOS quick action open in Preview.app #qrencode #automator

Generate QR code macOS quick action open in Preview.app

#qrencode #automator

A little automator script for adding a right click menu Services -> "Generate QR Code and open in Preview"

brew install qrencode cli for creating QR code. (brew info qrencode)

Open Automator.app -> Add a new Quick Action (service) -> Add "Run Shell Script"

@scmx
scmx / obfuscate-sentence.md
Created October 2, 2023 11:53
Obfuscate sentence by scrambling letters except first and last #ruby #shell

Obfuscate sentence by scrambling letters except first and last

#ruby #shell

obfuscate-sentence

#!/usr/bin/env ruby

ARGF.read.split("\n").each do |line|
  puts line
    .split(' ')
@scmx
scmx / locales-find-ruby-on-rails-script.md
Created March 15, 2023 13:44
Ruby on Rails locales-find script for fuzzy searching through locales yaml files using full dot notation part #rails #locales #fzf #fuzzy #compare

Ruby on Rails locales-find script for fuzzy searching through locales yaml files using full dot notation part

Hacked together a quick ruby script for fuzzy searching for locale keys with their full dot notation part. It loads all yaml files in config/locales, flattenes all the key paths like sv.foo.bar.baz and prints the value and filename after. The result is passed through fzf for fuzzy filtering.

bin/locales-find | fzf --ansi -e

or maybe: docker-compose run --rm web bin/locales-find 2>/dev/null | fzf --ansi -e

@scmx
scmx / locales-compare-ruby-on-rails.md
Created March 15, 2023 13:29
Ruby on Rails compare yaml locales by key for each language #rails #locales #yml #compare #ruby #script

Ruby on Rails compare yaml locales by key for each language

Comparison tool for rails locales.

Pass in dotation paths for interesting yaml parts and this tool will travsere through all locales looking for matches, printing the found value for each locale if a match is found.

Example usage

@scmx
scmx / git-allcommits.md
Last active February 23, 2023 20:58
git-allcommits List all commits made by you in all repositories in the last month #git #commits #multirepo

git-allcommits List all commits made by you in all repositories in the last month

#!/usr/bin/env bash

# List all commits made by you in all repositories in the last month

set -euo pipefail

commits=()
@scmx
scmx / vscode-settings-typescript-tsdk-double-backslash-windows-workaround-nextjs.md
Last active February 22, 2023 16:08
VSCode settings.json typescript.tsdk double backslash windows workaround Next.js

VSCode settings.json typescript.tsdk double backslash windows workaround Next.js

VSCode does not provide a way to have OS specific .vscode/settings.json for a project. microsoft/vscode#5595

Next.js adds property to it with a value that needs to be different for windows:

  • macOS/Linux "typescript.tsdk": "node_modules/typescript/lib"
  • Windows "typescript.tsdk": "node_modules\\typescript\\lib"

This is problematic when you want the file to be shared and tracked by version control.

@scmx
scmx / equential-paste-recording.md
Created January 23, 2023 10:48
macOS Sequential Copy Paste pbcopy pbpaste shell script. Start it and copy some things. Press Ctrl+c and you get the list all things you copied. #macos #clipboard #sequential #paste #pbpaste #pbcopy #bash #shell

macOS Sequential Copy Paste pbcopy pbpaste shell script

Start it and copy some things, then press Ctrl+c and you get a list of all things you copied.

~/.bin/sequential-paste-recording

#!/usr/bin/env bash

list=()
last=""