Back

Useful snippets

Bash

Continually check if a website is up

$ while ! curl http://download.redis.io/ -m 5 ; do sleep 1 ; done

Check if a command runs successfully

$ while docker info ; ret=$? ; [ $ret -ne 0 ]; do echo "waiting for docker to start" && sleep 5; done

Output to HTML

$ apt-get install aha
$ git diff master remotes/b/master --colour-words | aha --black > output_file.htm

ROR

Add Postgres unix date default

change_column :jobs, :status_updated_at, :integer, default: -> { 'extract(epoch from now())' }, null: false

Emacs

Search and replace in a directory

Using Dired.

Running SQLi