Skip to content

Instantly share code, notes, and snippets.

View scmx's full-sized avatar

Albert Arvidsson scmx

View GitHub Profile
@scmx
scmx / nodejs-detect-inconsistent-filepaths-in-smallburg-character-asset-pack.md
Last active October 4, 2022 12:20
Node.js script for detecting inconsistent character images in small-burg-towns-pack Smallburg base pack

Node.js script for detecting inconsistent character images in small-burg-towns-pack Smallburg base pack

is a really cool pixel art pack by almostApixel that you can find on itch.io.

I was playing around with the folder of images and started building a little demo that generates a random character in a random state, with random skin, random hair etc.

But then I noticed that some images didn't load. The file paths I were relying on weren't consistent. If I for example randomized an adult character with a dark brown ponytail, then the image wouldn't work

@scmx
scmx / jxa-ts-applescript-typescript.md
Last active May 18, 2025 22:38
How to write AppleScript JXA JavaScript in Vim or VS Code with TypeScript types #applescript #jxa #javascript #typescript #types #vim #coc

How to write AppleScript JXA JavaScript in Vim or VS Code with TypeScript types

jxa-ts-applescript-typescript

If you have written an AppleScript before, you might have felt the same way as I did, that it was a poor experience to use the Script Editor app, it's barely better than writing the script in any text editor or in a heredoc to run using osascript.

Luckily you could try the JXA variant instead, AppleScript using Javascript. But writing such a file in the Script Editor app is not a better experience sadly.

@scmx
scmx / iterm-dynamic-profile-dark-mode.md
Created April 9, 2021 18:44
How to switch between dark mode and light mode in iTerm using dynamic profiles #iterm #dark-mode #light-mode #node
@scmx
scmx / git-commit-title-first-word.md
Last active June 11, 2025 04:49
Example list of verbs / first word to use in git commit title #git #commit #title

Example list of first words to use in a git commit title

I like writing well-formed git commits that explain the intention behind why a code change was made.

Check out Chris Beams excellent How to Write a Git Commit Message if you haven't read it.

Anyway, for a project I've been working on I've gathered up 900+ commits that hold up a pretty high quality (except for one 😁). Let's look at some trends about these commits!

Most common first words in commit titles of a project

@scmx
scmx / extract-objects-from-rails-models-and-controllers.md
Last active May 19, 2025 14:17
7 Patterns to Refactor Rails Models 7 years later #rails #model #refactor #valueobject #serviceobject #formobject #queryobject #viewobject #policyobject #decorator

7 Patterns to Refactor Rails Models 7 years later

You may have read the following excellent blogpost by Brian Helmkamp of CodeClimate. It nicely describes 7 types of objects that can be extracted from models and controllers in a Rails-app.

7 Patterns to Refactor Fat ActiveRecord Models https://codeclimate.com/blog/7-ways-to-decompose-fat-activerecord-models/ Brian Helmkamp on Oct 17, 2012.

Here are my thoughts on it, reading it as an experienced rails developer, 7 years later 😅 👴

@scmx
scmx / hide-idle-cursor.md
Last active May 17, 2025 20:20 — forked from josephwegner/jquery-hideIdleCursor.js
Hide your cursor on a web page when it is idle. Great if you're using a web page for some sort of TV Display and don't want the cursor messing things up. #javascript #cursor #css #idle #hide

Hide your cursor on a web page when it is idle

Great if you're using a web page for some sort of TV Display and don't want the cursor messing things up

document.addEventListener("DOMContentLoaded", () => {
  let idleMouseTimer;
  let forceMouseHide = false;

 document.body.style.cursor = "none";
@scmx
scmx / git-vim-mac-os-bash.md
Last active April 24, 2022 11:47
Simple git + vim setup on Mac OS with bash #git #vim #macos #bash

Simple git + vim setup on Mac OS with bash

Nice defaults

git config --global commit.verbose true
git config --global push.default current

Load up ~/.bashrc on Mac OS bash ~/.bash_profile

@scmx
scmx / marbles.ex
Last active December 9, 2018 22:34
Elixir circular data structure marbles for solving Advent of Code 2018 day 9
defmodule Marbles do
def new do
%{size: 0, current: 0, counter: 0}
end
def to_list(state) do
[]
|> do_to_list(state, state.current, state.current)
|> Enum.reverse
end
@scmx
scmx / how-to-abbrev-long-tech-words.md
Created October 1, 2018 10:13
How to abbreviate long tech words nicely #abbreviate #tech #i18n #l10n #k8s

How to abbreviate long tech words nicely :trollface:

Just for fun, I do not recommend using this

Ever heard of I18n? Probably. But do you know what it stands for? Internationalization. There's a few other common ones as well

  • l10n localization
  • k8s kubernetes
@scmx
scmx / using-details-summary-github.md
Last active May 26, 2025 18:43
Using <details> <summary> expandable content on GitHub with Markdown #details #summary #markdown #gfm #html

How to use <details> <summary> expandable content on GitHub with Markdown

Firstly, what is <details> <summary>?

The HTML Details Element (<details>) creates a disclosure widget in which information is visible only when the widget is toggled into an "open" state. A summary or label can be provided using the <summary> element. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details.

Example