martes, 19 de febrero de 2019

FP vs OO talk

Here's a quite balanced talk about FP and OO that fits my view of the two paradigms. Give it a shot if you have 40mins on your commute or something.
 
https://www.reddit.com/r/programming/comments/as6epa/fp_vs_oo_choose_two_by_brian_goetz/

jueves, 7 de febrero de 2019

TIL: paste -sd+

Following https://hacker-tools.github.io/ lectures, I found a neat trick I didn't know in the data wrangling chapter:

seq 100 | paste -sd+ | bc -l     # 5050


That's pretty nice.  I already had this usecase solved by an "addup" perl script that I stole years ago from Mark Jason Dominus' utils repo.

As a bonus, it reminds me the very similar trick to generate a regex that matches either of many words. That's part of my git pre-commit hook

# alternative to https://gist.github.com/SkyM/1641459
FORBIDDEN=$(echo 'declaim break ==== >>>> <<<< string.gmatch inspect' |
sed -e 's/ /\\\|/g')
git diff --cached | grep '^+' | sed -e 's/--.*//' |
grep -n $FORBIDDEN &&
echo "COMMIT REJECTED Found '$FORBIDDEN' references. Please remove them before commiting" &&
exit 1
view raw pre-commit.sh hosted with ❤ by GitHub

Not exactly the same, but it also belongs to "Higher Order Shell"