Skip to content

Instantly share code, notes, and snippets.

@npatmaja
npatmaja / git_alias_sort_remote_branches
Created March 22, 2018 02:36
Git alias to sort remote branches based on last updated time desc
blremotesorted = "!for branch in `git branch -r | grep -v HEAD`;do echo `git show --format=\"%ci %cr %an\" $branch | head -n 1` \t$branch; done | sort -r"
blremotesortedcsv = "!for branch in `git branch -r | grep -v HEAD`;do echo `git show --format=\"%ci,%cr,%an\" $branch | head -n 1`,$branch; done | sort -r"

Category: The Essence of Composition

Roughly, category theory is a general mathematical theory of structures and of systems of structures [[1]]. Generally, is best represented with Objects and Arrows that go between them.

A -> B -> C
A -> C

If there is an arrow from object A to object B, and another arrow from B

@npatmaja
npatmaja / vim-cheat-sheet.md
Last active February 15, 2017 04:22
My Vim Cheat Sheet

Vim Cheat Sheet Collection

Mode Command Description
NORMAL * Select all occurrences of word under cursor. Put the cursor to the desired word and pres * to search for the next occurrences of the word. Press n to go to the next occurrence
NORMAL n Go to the next occurrence of the searched term
NORMAL N Go to the previous occurrence of the searched term
@npatmaja
npatmaja / new_gist_file
Last active September 15, 2016 06:58
Upgrading packages in Ubuntu 16.04
# Show upgradable package
sudo apt list --upgradable
# Upgrade a package
sudo apt install --only-upgrade <package-name>
# Autoremove unused packages
sudo apt autoremove
@npatmaja
npatmaja / functional.js
Last active August 21, 2016 16:26
Functional JS
// Partial application
const sum = (a, b, c) => a + b + c;
const papply = (fn, ...rest) => (...last) => fn.apply(null, [...rest, ...last]);
const a = papply(sum, 5);
console.log(a(2, 3));
// currying
const curry = (fn, ...rest) => {
@npatmaja
npatmaja / async-propagate-callback.js
Created May 5, 2015 07:25
propagate async callback usefull when using async.waterfall with mongoose
// to propagate async callback
// usefull when using async.waterfall
// with mongoose
async.waterfall([
task1(),
task2(),
task3()
], callFinalCallback());
@npatmaja
npatmaja / deploy
Last active December 26, 2015 14:56
Setup Hugo deployment to Github pages without using subtree
#!/usr/bin/env bash
# change into the script's directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR > /dev/null
# configuration
OUT=out
TMP=tmp
@npatmaja
npatmaja / git-aliases.md
Last active August 29, 2015 14:18
Gist aliases in `~/.gitconfig`
[alias]
	bl = branch -l
	co = checkout
	ec = config --global -e
	up = !git pull --rebase --prune $@ && git submodule update --init --recursive
	pushm = push origin master
	pullm = pull origin master
	pusho = !git push origin "$(git rev-parse --abbrev-ref HEAD)"
	pullo = !git pull origin "$(git rev-parse --abbrev-ref HEAD)"
@npatmaja
npatmaja / readme.md
Last active August 29, 2015 14:07
Use underscore js inside Jade, unescape attribute content

To be able to use underscore variable inside the Jade's attribute (make it unescaped) use != instead of only =. example

img(src!="<%= coverImage %>", height="100px")

taken from pugjs/pug#198