Skip to content

Instantly share code, notes, and snippets.

@icetan
icetan / try-lazy-trees-subflake.md
Last active June 27, 2022 13:11
Trying out subflakes and relative paths

Root flake file flake.nix:

{
  inputs = {
    utils.url = "github:numtide/flake-utils/bee6a7250dd1b01844a2de7e02e4df7d8a0a206c";
    sub1.url = "path:./sub1";
  };
  outputs = { nixpkgs, utils, sub1, ... }:
 utils.lib.eachDefaultSystem (system: {
@icetan
icetan / commit-msg
Created May 14, 2020 08:26
GIT commit message hook to add story ID from branch name, support for JIRA and ClubHouse
#!/bin/bash
file="$1"
branch=$(git rev-parse --abbrev-ref HEAD 2>&-)
check() {
local cmd=$1
local id=$($cmd <<<"$branch")
if [[ ! $(head -n1 "$file" | $cmd) ]]; then
echo $id
fi
@icetan
icetan / tap.sh
Last active April 23, 2020 06:58
Run TAP tests in Bash (depndencies: jq, curl, mktemp, sed, procps)
#!/bin/bash
# Copyright 2020 Christopher Fredén
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOF
@icetan
icetan / README.md
Last active July 4, 2019 09:56
Git commit message hook for JIRA issue ID's

Jira commit message hook

Automatically add Jira issue ID to commit messages based on the current Git branch name.

Install

Install in local repo:

Nix a Practical Introduction

Pros

  • builds the same independent of user environment (not on platform)
  • clean user env, no need to clutter your PATH with every persivable build tool
  • no clashing versions, becaus each build has it's own environment, multiple versions of the same dependency won't clash
  • coherent and declaritive way to define builds
  • cachable build outputs
@icetan
icetan / Makefile
Created November 8, 2017 10:48
Simple configure/Makefile
DOT = dot
MD = markdown
OUT = domain.svg README.html
prefix = /usr/local
-include ./config.make
%.svg: %.dot
$(DOT) -Tsvg -o $@ $<
### Keybase proof
I hereby claim:
* I am icetan on github.
* I am icetan (https://keybase.io/icetan) on keybase.
* I have a public key whose fingerprint is 1C67 8C00 4394 21C2 B5E9 2FFC 33F0 FF56 E55A 164A
To claim this, I am signing this object:
@icetan
icetan / rtrav.sh
Last active April 27, 2022 07:39
A bash to traverse a path upwards to find a certain file or directory
rtrav() { [ -e "$2/$1" ] && echo "$2" || { [ "$2" != / ] && rtrav "$1" "$(dirname "$2")"; }; }
# Find node_modules directory
rtrav node_modules $PWD
# clean output
hexdump -e '"%x"' -n8 /dev/urandom
# outputs a space before, F*CK
od -An -tx -N4 /dev/urandom
@icetan
icetan / curry.js
Last active February 29, 2016 15:52
Some quick curry patterns in ES6
// funcation tree(a, b, c) { return a + b + c; }
curry = f => x => f.length>1 ? curry(f.bind(f, x)) : f(x)
uncurry = f => function(){return [].reduce.call(arguments, (f,x) => f(x), f)}
// curry(tree)(1)(1)(1) === 3
// uncurry(curry(tree))(1, 1, 1) === 3
curry_ = f => f.apply.bind(f, f)
uncurry_ = f => function(){return f(arguments)}
// curry_(tree)([1, 1, 1]) === 3