Skip to content

Instantly share code, notes, and snippets.

View stoffeastrom's full-sized avatar

Christoffer Åström stoffeastrom

View GitHub Profile
ʕ◔ϖ◔ʔ
U+0295, U+25D4, U+03D6, U+25D4, U+0294
@stoffeastrom
stoffeastrom / zsh_history.sh
Created December 8, 2022 08:11 — forked from danydev/zsh_history.sh
Store commands in history only if successful
# README: This allows you to store in your history file only commands
# with a successful status (or forced exited by you with signal 2).
# Put this content in your .zhsrc
# CREDITS: inspired by https://scarff.id.au/blog/2019/zsh-history-conditional-on-command-success/
# This function will be hooked to zshaddhistory.
# zshaddhistory is called before a history line is saved. See zshmisc(1).
function my_zshaddhistory() {
# Prevent the command from being written to history before it's
# executed; save it to LASTHIST instead. Write it to history
@stoffeastrom
stoffeastrom / EBNF-cheatsheet.md
Created May 21, 2022 12:22 — forked from refs/EBNF-cheatsheet.md
Extended Backus-Naur Form Cheatsheet

Symbols

Usage Notation
definition =
concatenation ,
termination ;
alternation |
optional [ ... ]
repetition { ... }
@stoffeastrom
stoffeastrom / hoge.rb
Created June 21, 2021 18:08 — forked from minamijoyo/hoge.rb
Using GitHubPrivateRepositoryReleaseDownloadStrategy removed in brew v2
require "formula"
require_relative "lib/private_strategy"
class Hoge < Formula
homepage "https://github.com/yourcompany/hoge"
url "https://github.com/yourcompany/hoge/releases/download/v0.1.0/hoge_v0.1.0_darwin_amd64.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
sha256 "6de411ff3e4b1658a413dd6181fcXXXXXXXXXXXXXXXXXXXX"
head "https://github.com/yourcompany/hoge.git"
version "0.1.0"
@stoffeastrom
stoffeastrom / git-stash-untracked-show.md
Created December 22, 2020 22:02 — forked from imghasemi/git-stash-untracked-show.md
How to show git stash untracked files

REF: https://stackoverflow.com/a/12681856

Untracked files are stored in the third parent of a stash commit. (This isn't actually documented, but is pretty obvious from The commit which introduced the -u feature, 787513..., and the way the rest of the documentation for git-stash phrases things... or just by doing git log --graph stash@{0})

You can view just the "untracked" portion of the stash via:

git show stash@{0}^3
@stoffeastrom
stoffeastrom / bash_strict_mode.md
Created March 31, 2020 07:03 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o pipefail explanation

set -e, -u, -o pipefail

The "set" lines These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing. With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.

set -euo pipefail is short for:

set -e
set -u
@stoffeastrom
stoffeastrom / README.md
Created May 30, 2018 12:53 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
@stoffeastrom
stoffeastrom / migrate-to-lerna.sh
Created April 30, 2018 16:30 — forked from JamieMason/migrate-to-lerna.sh
Bash script to migrate multiple projects into one Lerna monorepo (https://lernajs.io)
#!/usr/bin/env bash
set -x
shopt -s extglob dotglob
cd "$HOME"
rm -rf "$HOME/TEMP_DIR"
mkdir "$HOME/TEMP_DIR"
cd "$HOME/TEMP_DIR"
git init
@stoffeastrom
stoffeastrom / iterm2-solarized.md
Created March 17, 2018 19:58 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Meslo powerline font + [Powerlevel9k] - (macOS)

Default

Default

Powerlevel9k

Powerlevel9k

@stoffeastrom
stoffeastrom / docker_images.sh
Created June 28, 2017 07:09 — forked from hydra1983/docker_images.sh
Save and load docker images in batch
#!/bin/bash
readonly DB_FILE="$(pwd)/images.db"
readonly IMG_DIR="$(pwd)/images"
save-images() {
echo "Create ${DB_FILE}"
echo "$(docker images|grep -v 'IMAGE ID'|awk '{printf("%s %s %s\n", $1, $2, $3)}'|column -t)" > "${DB_FILE}"
echo "Read ${DB_FILE}"