Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
FILE=$1
MESSAGE=$(cat $FILE)
TICKET=[$(git rev-parse --abbrev-ref HEAD | grep -Eo '^(\w+/)?(\w+[-_])?\d+' | grep -Eo '(\w+[-])?\d+' | tr "[:lower:]" "[:upper:]")]
if [[ $TICKET == "[]" || "$MESSAGE" == "$TICKET"* ]];then
exit 0;
fi
echo "$TICKET $MESSAGE" > $FILE
@abuduba
abuduba / prepare-commit-msg
Created December 16, 2019 21:42
Prepend ticket number in the commit message
#!/bin/bash
FILE=$1
MESSAGE=$(cat $FILE)
TICKET=$(git rev-parse --abbrev-ref HEAD | sed -E 's/([a-z]+\/)?([a-z]+-[0-9]+).*/[\2]/' | tr "[:lower:]" "[:upper:]" | grep -Eo '^\[([A-Z]+-)?\d+/]$')
if [[ "$MESSAGE" == "$TICKET"* ]];then
exit 0;
fi
echo "$TICKET $MESSAGE" > $FILE
!(a != b || c != d) == (a == b && c == d)
!(a >= b && c <= d) == (a < b || c > d)
!(!a || !b) == (!!a && !!b) == (a && b);
!(!a && !b) == (!!a || !!b) == (a || b);
/* Double negation returns the variable itself */
import { createContext } from './hotkeys';
const c = createContext();
// Alerts when "no way" is typed in.
c.register('n o space w a y', () => {
alert('Yes way!');
});
/*
@abuduba
abuduba / hotkeys.js
Last active October 12, 2022 03:39
Hotkey library
const isEqual = (a, b) => {
const aKeys = Object.keys(a);
if (aKeys.length !== Object.keys(b).length) {
return false;
}
return aKeys.every(
(k) => Object.prototype.hasOwnProperty.call(b, k)
&& a[k] === b[k],
'use strict';
const isEqual = (buff, hotkey) => {
const buffKeys = Object.keys(buff);
if (buffKeys.length !== Object.keys(hotkey).length) {
return false;
}
return buffKeys.every(
(k) => hotkey.hasOwnProperty(k) && buff[k] === hotkey[k]
);