Skip to content

Instantly share code, notes, and snippets.

@arbitrary-dev
arbitrary-dev / es6-flatten.js
Last active Jan 10, 2017
Some code, that will flatten an array of arbitrarily nested arrays
View es6-flatten.js
// ECMAScript 6
const flatten = (arr) =>
// Reducer concat array items to accumulated result
// or recursively calls flatten again if the item is an array.
arr.reduce((acc, item) =>
acc.concat(Array.isArray(item) ? flatten(item) // recursively flatten nested array
: item), // concat ordinary item
[]); // init empty accumulator
@arbitrary-dev
arbitrary-dev / x
Created Dec 29, 2016
Xtract lines from file or input
View x
# x 2,4 <file>
# printf <text> | x 4,$
sed -n $1p $2
@arbitrary-dev
arbitrary-dev / find-inodes
Last active Dec 29, 2016
Where my inodes at?
View find-inodes
# find-inodes <path>
find $1 -xdev -printf '%h\n' | sort | uniq -c | sort -k1 -n | less
@arbitrary-dev
arbitrary-dev / ls-xargs-cnv
Last active Dec 29, 2016
Convert films in a batch
View ls-xargs-cnv
ls **/*.avi | xargs -d '\n' -n1 -I {} cnv film -b 500k -dn --log error {}
@arbitrary-dev
arbitrary-dev / cyrillic-chars.txt
Last active Dec 18, 2016
For use inside ~/.XCompose
View cyrillic-chars.txt
Cyrillic_A = U+0410
Cyrillic_a = U+0430
Cyrillic_BE = U+0411
Cyrillic_be = U+0431
Cyrillic_CHE_descender = U+04B6
Cyrillic_che_descender = U+04B7
Cyrillic_CHE = U+0427
Cyrillic_che = U+0447
Cyrillic_CHE_vertstroke = U+04B8
Cyrillic_che_vertstroke = U+04B9