Skip to content

Instantly share code, notes, and snippets.

Avatar

CJ chernjie

View GitHub Profile
@chernjie
chernjie / set.sh
Last active Sep 12, 2020
CLI implementation of Set, using file for storage
View set.sh
#!/usr/bin/env bash
STATEFILE=${STATEFILE:-retry.log}
# dependencies
for i in sort gsed grep echo
do command -v $i > /dev/null || (echo $i not found >&2 && exit 1)
done
prime() {
View npmr
#!/usr/bin/env bash
# Like `npm`, but executes the command in nested sub-directories within
# your current git repository
#
# @author CJ <lim@chernjie.com>
# Example:
#
# $ npmr ls lodash # List installed packages in nested node packages
View parallelLimit
#!/bin/sh
rundir=/var/run/parallelLimit
pause_file="$rundir/paused"
harakiri_file="$rundir/good-day-to-die"
is-paused() {
[ -f "$pause_file" ]
}
View mkpasswd
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from optparse import OptionParser
from passlib.hash import sha512_crypt;
import getpass;
parser = OptionParser(usage="%prog --method=sha-512")
parser.add_option(
'--method',
View jsonFilterByKeys.sh
#!/usr/bin/env bash
json2markdowntable () {
local headers=$@
echo $headers | sed "s, , | ,g"
seq $# | while read i; do echo " --- "; done | xargs | sed "s, , | ,g"
json -a $headers -d" | "
}
View order-interval.js
#!/usr/bin/env node
// time csvtojson data/order-interval-20180102.csv | node mockup/order-interval.js
var stdin = require('../../ppdg/ppdg-elk/src/stdinjson.js');
var lodash = require('lodash');
stdin(_process);
function _process (err, data) {
return lodash(data)
View gitmoji-cheatsheet.js
var table = $$('.emoji-card').map((el, i) => {
return {
emoji: el.firstChild.firstChild.innerHTML,
code: el.lastChild.firstChild.innerHTML,
description: el.lastChild.lastChild.innerHTML
};
}).reduce((table, el, i) => {
var tr = document.createElement('tr');
tr.innerHTML = '<td>' + el.emoji + '</td><td>' + el.code + '</td><td>' + el.description + '</td>';
table.appendChild(tr);
View .editorconfig
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
@chernjie
chernjie / branch-cleanup.sh
Last active Mar 19, 2020
Find redundant branches and print commands to delete them
View branch-cleanup.sh
#!/usr/bin/env bash
COLOR_YELLOW(){ echo -en "\033[33m"; }
COLOR_RESET() { echo -en "\033[0m"; }
MAIN_BRANCH=${1:-master}
MAIN_REMOTE=${2:-origin}
label() {
echo -e "\033[33m$@\033[0m" >&2
View whack-a-mole
#!/usr/bin/env bash
_whack_a_mole_log=~/dotfiles/log/whack-a-mole.log
_whack_a_mole () {
printf $@:
while true
do
i=$(ps aux | grep $@ | grep -ve grep -ve whack-a-mole | awk '{print $2}')