Skip to content

Instantly share code, notes, and snippets.

View scmx's full-sized avatar

Albert Arvidsson scmx

View GitHub Profile
@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 April 14, 2024 08:39
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 February 17, 2023 11:28
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 December 17, 2022 05:27 — 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 April 1, 2024 02:07
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

@scmx
scmx / asdf-node-yarn.md
Created July 10, 2018 10:03
#asdf #nodejs #yarn
@scmx
scmx / toggle-dark-mode.md
Last active January 21, 2022 00:54
Script Toggle Dark Mode On/Off for Mac OS, Hyper term, Tmux and Vim #macos #hyper #tmux #vim #darkmode #applescript

Script to Toggle Dark Mode On/Off for Mac OS, Hyper term, Tmux and Vim

I had some fun pimping my development setup during my summer vacation 🏖 🏝 and here's what I came up with. A script toggle-dark-mode that toggles dark mode for not only Mac OS, but also Hyper, tmux and vim at once. I'm gonna be so productive now.. 😁

toggle-dark-mode

*(I've customized Hyper term to remove dead space on top for maximized windows,