Bits


Today-I-learned liked micro-posts. (may move to Posts)

On this page:


Debug ZSH Config

List ZSH config files for debugging purposes:

zsh -o SOURCE_TRACE

Source:



Brew Reinstall PostgreSQL

Unfortunately, in order to reinstall a local macOS instance of PostgreSQL from scratch brew uninstall by itself won’t be enough. Instead,

check if there’s an instance:

$ launchctl list | grep -i sql

Stop it with:

$ brew services stop postgres

Remove PostgreSQL, and all related files:

$ brew uninstall --force postgres
$ rm -rf /usr/local/var/postgres
$ rm -rf .psql_history .psqlrc .psql.local .pgpass .psqlrc.local
$ brew cleanup

Confirm through:

$ brew list | grep sql

Re-install PostgreSQL

$ brew install postgresql

This won’t restore the postgres superuser if it’s been dropped before.


Local Ruby Server

Browsers avoid executing anything originating directly from the file system. Rather than gem installing anything to serve a few files locally spin a WEBrick instance from the terminal using Ruby’s Un library.

$ cd dir/with/files
$ ruby -run -e httpd . -p 8080

Visit localhost:8080 to play with the served files.

Learn more about Un, reading it’s, pretty much, hidden documentation.


Running processes

If we need to see which processes are currently running on our mac box we can run from the terminal:

$ lsof -i -P

On linux:

$ sudo netstat -tunapl

Clone folder

We can clone a folder with all it’s contents, including hidden files, as well as preserving all file attributes with:

$ cp -a /path/original/folder/. /cloned/folder/

Better Git diff algorithm

According to Git documentation the diff uses one of four algorithms. According to this SO explanation the histogram algorithm has all of patience’s goodness, and it’s slightly faster than the default algorithm.

Add to your ~/.gitconfig

[diff]
  algorithm = histogram