Skip to content

Instantly share code, notes, and snippets.

// Two files (the helper function and its associated tests) have been
// concatenated here for the sake of fitting into one Gist.
// File: flatten-array.ts
// ----------------------
// Type definitions
type Nested<T> = Array<T | Nested<T>>
// Flattens an array by recursively iterating through items of the
// (nested) array, returning the values at the leaf nodes.
@chaucerbao
chaucerbao / cVimrc
Last active June 8, 2017 23:44
Configuration for cVim
map ; openCommandBar
" Page navigation
map <C-f> scrollFullPageDown
map <C-b> scrollFullPageUp
map <C-d> scrollPageDown
map <C-u> scrollPageUp
map <C-e> scrollDown
map <C-y> scrollUp
@chaucerbao
chaucerbao / lock
Created September 27, 2013 20:06
(Mac OSX) Locks the computer. Put it in `/usr/local/bin/`.
#!/bin/sh
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
@chaucerbao
chaucerbao / .bash_profile
Created July 31, 2013 06:17
(Mac OSX) Common Bash behavior settings
# Command prompt
export PS1='[\u@\h \W]\$ '
# Color LS
alias ls='ls -hFG'
# Color GREP
alias grep='grep --color=auto'
# Tab completion
@chaucerbao
chaucerbao / .inputrc
Created July 17, 2013 17:49
Personal Bash readline init file for more intuitive behavior
set completion-ignore-case on
set show-all-if-ambiguous on
# tab: menu-complete
# Use Unicode & do NOT use the "8bit hack" to input/output non-ASCII characters
# See http://code.google.com/p/iterm2/wiki/Keybindings
set input-meta on
set output-meta on
set convert-meta off
@chaucerbao
chaucerbao / ramdisk
Last active December 14, 2015 04:29
(Mac OSX) Create a ram disk under /Volumes/RamDisk. Put it in `/usr/local/bin/`. Usage: ./ramdisk.sh [size(MB)]
#!/bin/sh
SIZE_MB=${1:-1024}
SECTORS=$((${SIZE_MB}*1024*1024/512))
diskutil erasevolume HFS+ "RamDisk" `hdiutil attach -nomount ram://${SECTORS}`