journal (Sun May 17 2020)

Week of May

  • #ruby
  • #mac
  • #bash
  • #dance
  • #zouk
  • #wiliam

Realized Ruby has a neat way to generate random rand(1..10) rand(1...10)

  • https://blog.appsignal.com/2018/07/31/generating-random-numbers-in-ruby.html

Fixed my annoying problem of my mac reordering windows when I didnt want it to https://osxdaily.com/2011/11/12/stop-spaces-rearranging-mac-os-x/


Observed a really nice move by William at a demo. Will need to figure this one out. https://www.youtube.com/watch?v=xXl6JEiKO-I


Learnt ways to run a command inside a bash script my_variable=$(command-name-here) https://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-bash-assign-variable-command-output/

Prevent next command in shell script from running when previous fails

#!/bin/bash
set -e 
set -o pipefail

https://stackoverflow.com/a/4346420

Get the current branch name in GIT

git rev-parse --abbrev-ref HEAD

Replace a line in unix Uses streameditor sed -i 's/old-text/new-text/g' input.txt https://www.cyberciti.biz/faq/how-to-use-sed-to-find-and-replace-text-in-files-in-linux-unix-shell/

sed doesnt work correctly in mac, so I had to use a extra char

Error invalid command code . sed
https://stackoverflow.com/a/7573438

Replace a particular line in a file

sed -i '1 i README.md' .gitignore

https://unix.stackexchange.com/questions/518988/using-sed-to-insert-readme-md-in-gitignore/518991

How to delete a line in a file via bash https://www.youtube.com/watch?v=H4EMZKYLGa4