Skip to content

Instantly share code, notes, and snippets.

View sylvaindethier's full-sized avatar

Sylvain Dethier sylvaindethier

View GitHub Profile
@sindresorhus
sindresorhus / post-merge
Last active July 25, 2024 06:53
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@coderofsalvation
coderofsalvation / is_array.bash
Created January 11, 2014 21:44
check if variable is array, returns 0 on success, 1 otherwise
# check if variable is array, returns 0 on success, 1 otherwise
# @param mixed
is_array()
{ #detect if arg is an array, returns 0 on sucess, 1 otherwise
[ -z "$1" ] && return 1
if [ -n "$BASH" ]; then
declare -p ${1} 2> /dev/null | grep 'declare \-a' >/dev/null && return 0
fi
return 1
@chanmix51
chanmix51 / arrays_in_bash.md
Last active April 2, 2020 18:26
Using arrays in Bash

Using arrays in bash

creating an array

$> my_array=(one two three)

accessing/setting elements

$> echo ${my_array}

one

@developit
developit / *state-machine-component.md
Last active February 6, 2021 00:44
265b lib for building pure functional state machine components. https://github.com/developit/state-machine-component

state-machine-component

A tiny (265 byte) utility to create state machine components using two pure functions.

🔥 JSFiddle Demo

Usage

The API is a single function that accepts 2 pure functions as arguments: