Skip to content

Instantly share code, notes, and snippets.

@jimkang
jimkang / make-link-index.js
Last active March 28, 2024 23:19
Make links to files with specific extensions
@jimkang
jimkang / download-soundcloud-playlist.js
Last active January 1, 2024 22:44
Download everything from a SoundCloud playlist
// Paste this into the console and get ready to click "Save" in response to the save dialog a bunch of times. Or better yet, disable asking where to save in your browser.
var buttons = document.querySelectorAll('.sc-button-more')
var index = 0;
function moreNext() { var more = buttons[index]; more.click(); ++index; setTimeout(dl, 500); }
function dl() { var dlButton = document.querySelector('.sc-button-download'); dlButton.click(); if (index < buttons.length) { setTimeout(moreNext, 100);}}
moreNext();
@jimkang
jimkang / make-indexes.js
Last active August 16, 2023 03:20
Create html indexes for images in a folder. Classic! Puts the index files in a directory named `indexes`; you may want to change that.
#!/usr/bin/env node
/* global process */
var fs = require('fs');
var imgFileExts = ['png', 'jpg'];
if (process.argv.length < 3) {
console.error(
'Usage: node make-index.js <directory with images>'
@jimkang
jimkang / obsidian.desktop
Created May 23, 2023 23:14
Obsidian AppImage desktop shortcut that goes in /usr/share/applications/obsidian.desktop.
[Desktop Entry]
Name=Obsidian
GenericName=Notes organizer
Comment=Organize notes
Exec=/home/jimkang/apps/Obsidian-1.0.3.AppImage
Terminal=false
Type=Application
Keywords=notes;organizer;
Keywords[fr]=Texte;éditeur;
Keywords[ru]=текст;текстовый редактор;
@jimkang
jimkang / roll-until-you-get-it.js
Last active February 16, 2023 02:38
Console automation for roll-a-guy
function getYourClass(targetClass) { document.getElementById('roll-button').click(); setTimeout(() => { if (document.getElementById('class').textContent !== targetClass) { window.requestAnimationFrame(() => getYourClass(targetClass)); }}, 0) }
getYourClass('Ranger')
// Edit selector to check things other than strength.
function getYourScore(minScore) { document.getElementById('roll-button').click(); setTimeout(() => { if (+document.querySelector('.row:first-child .ability-score-column').textContent < minScore) { window.requestAnimationFrame(() => getYourScore(minScore)); }}, 0) }
getYourScore(16)
@jimkang
jimkang / Contract Killer 3.md
Last active September 19, 2024 18:10
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@jimkang
jimkang / unzip-bandcamp.sh
Created February 19, 2021 03:03
When you download from Bandcamp, the zip file comes with no directory structure, so this gives it one. Explanation: https://jimkang.com/weblog/articles/bandcamp-unzip/
#!/bin/bash
for file in *.zip
do
filename="${file%.*}"
# Filenames can't contain /. So, I wonder
# what Bandcamp would do if they had AC/DC?
unzippath=$(echo "$filename" |sed -e 's/ - /\//')
mkdir -p "$unzippath"
unzip "$filename" -d "$unzippath"
@jimkang
jimkang / get-entries-in-date-range.sh
Last active April 5, 2020 19:26
Simple script for getting markdown files in a certain date range (assuming the files use a common Zettelkasten naming convention in which every file starts with YYYY-MM-DD).
#!/bin/bash
src=.
start=$1
end=$2
if [[ ! $start ]] && [[ ! $end ]]; then
printf "Usage: ./tools/get-entries-in-date-range.sh [start string] [end string]\nEnd string is optional.\n\nExample: To get filenames that come after 2020-03 (anywhere in March) but before 2020-03-29 (assuming files follow this naming convention):\n./tools/get-entries-in-date-range.sh 2020-03 2020-03-29\n";
exit 1;
fi
@jimkang
jimkang / pickle-to-json.py
Created December 2, 2019 14:53
Because I always forget
import pickle
import json
data = pickle.load(open('file.pkl', 'rb'))
out_file = open("out.json", "w")
out_file.write(json.dumps(data))
@jimkang
jimkang / static-ease-values.js
Created November 13, 2019 23:16
Get static cubic easing values. I just ran these in the Node REPL to get the numbers.
var { easeCubic } = require('d3-ease')
var { range } = require('d3-array')
range(0, 1, 0.05).map(easeCubic).map(n => n.toFixed(2)).join(';')