Skip to content

Instantly share code, notes, and snippets.

View scmx's full-sized avatar

Albert Arvidsson scmx

View GitHub Profile
@scmx
scmx / git-commit-title-first-word.md
Last active December 7, 2023 14:16
Example list of verbs / first word to use in git commit title #git #commit #title
View git-commit-title-first-word.md

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 / docker-prompt.md
Last active November 24, 2023 12:51
How to get a fancier bash prompt PS1 inside a docker container #docker #ps1 #emoji
View docker-prompt.md

How to get a fancier bash prompt PS1 inside a docker container

Today I wanted to make a recording of me running some commands inside a docker-container.

❯ docker-compose run app bash
root@e9bb2af4dc11:/usr/local/go/src/example.com/dev/project#

Needless to say it looked a bit bland with no colors and a long prompt that prevents me from recording a small terminal and show the full commands I'm

@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
View generate-qrcode-quick-action.md

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
View obfuscate-sentence.md

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 / using-details-summary-github.md
Last active August 28, 2023 19:21
Using <details> <summary> expandable content on GitHub with Markdown #details #summary #markdown #gfm #html
View using-details-summary-github.md

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 / capybara-selenium-webdriver-slow-speed.md
Created May 5, 2018 07:46
Capybara Selenium WebDriver running at a lower speed using sleep command #capybara #selenium #rails #
View capybara-selenium-webdriver-slow-speed.md

Capybara Selenium WebDriver running at a lower speed using sleep command

Ever wanted to run your integration/end-to-end test suite at a lower speed so that you better could observe what's happening and perhaps make a recording of it?

Here's a a technique I've been using when writing tests with Capybara Selenium WebDriver.

Put this in test/test_helper.rb or maybe something like spec/support/capybara.rb.

@scmx
scmx / maximum-words-validation.js
Created December 3, 2014 16:56
#angular #validation validate maximum word count textarea
View maximum-words-validation.js
angular.module('maximumWordsValidation', [])
// Counts number of words in field and sets validity if more than max
//
// Usage:
// <input maximum-words-validation="100"/>
// Example:
// <textarea ng-model="myModel.description" maximum-words-validation="100"></textarea>
// <span>{{myModel_description_words_count}} / 100 words</span>
//
// It will also set the {{fieldName}}_word_count variable on parent scope
@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
View locales-find-ruby-on-rails-script.md

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
View locales-compare-ruby-on-rails.md

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
View git-allcommits.md

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=()