Linux: See the available disk space

The df command is a useful command that reports the total usage in all mounted filesystems in table format.

The first column shows the name of disk partition, ie, /devdisk1@ and devfs. Other columns normally show the Used Space, Available Space, and Capacity which is the percentage of available space against the used space.

Screen shot 2017 10 23 at 5.18.57 pm

 Global Regex Replace

Regular expression replacement will always have a place. The fastest way to replace substrings on a string is to split and join like to following:

let ourString = "My name is Leon. Your name is not Leon";
ourString.split("Leon").join("Buddy"); // My name is Buddy. Your name is not Buddy"

Regular expressions will let you replace string with conditions easily

let partialString = ":pensive: will only be replaced if :p is not followed by ensive"
let stringToFind = new RegExp(/:p(?!ensive)/, 'g');
partialString = partialString.replace(stringToFind, ":stuck_out_tongue:"); // :pensive: will only be replaced if :stuck_out_tongue: is not followed by ensive

Another example:

let partialString = 'party party party p';
let stringToFind = new RegExp(/p(?!arty)/, 'g');
partialString = partialString.replace(stringToFind, "party"); // party party party party

 Basic Linux Commands

There is never a shortage of good cheatsheets specially for Linux

Directory Listing

ls
Gemfile				app				dump.rdb			spec
Gemfile.lock

Directory Listing with hidden files

$ ls -al
total 1376
drwxr-xr-x   49 thorpeobazee  staff    1666 Sep 17 22:33 .
drwxr-xr-x   13 thorpeobazee  staff     442 Sep 17 21:06 ..
-rw-r--r--    1 thorpeobazee  staff     633 Sep  7 08:28 .babelrc
-rw-r--r--    1 thorpeobazee  staff     163 Sep 12 18:19 .eslintrc
drwxr-xr-x   16 thorpeobazee  staff     544 Sep 18 09:44 .git
-rw-r--r--    1 thorpeobazee  staff     736 Sep  7 08:28 .gitignore
drwxr-xr-x    9 thorpeobazee  staff     306 Jun  7 12:05 .idea
-rw-r--r--    1 thorpeobazee  staff      20 Sep  7 08:28 .jshintrc
-rw-r--r--    1 thorpeobazee  staff      30 Jun  5 19:35 .rspec
-rw-r--r--    1 thorpeobazee  staff     898 Jun 16 13:42 .rubocop.yml
-rw-r--r--    1 thorpeobazee  staff      14 Jun  5 19:35 .ruby-gemset
-rw-r--r--    1 thorpeobazee  staff       6 Jun  5 19:35 .ruby-version
drwxr-xr-x    5 thorpeobazee  staff     170 Sep  7 08:28 .storybook
-rw-r--r--    1 thorpeobazee  staff    2515 Sep 12 18:19 Gemfile
-rw-r--r--    1 thorpeobazee  staff   19934 Sep 12 18:19 Gemfile.lock

Change Directory

Changes directory to other_dir

cd other_dir

Show the name of the current working directory

$ pwd
/Users/mememe/projects/my_project

 How to Backup a Heroku Database

Backup databases are one of the most important things you can do for your applications. It allows you to restore your database in case of problems in updating your database or simply due to some hacking.

Back up a Heroku database

$ heroku pg:backups:capture
Starting backup of postgresql-diagonal-12345... done

Use Ctrl-C at any time to stop monitoring progress; the backup will continue running.
Use heroku pg:backups:info to check progress.
Stop a running backup with heroku pg:backups:cancel.

Backing up EMBER to b001... done

Download a Heroku database dump

heroku pg:backups:download
Getting backup from  your-app... done, #1
Downloading latest.dump.. 100% 00:00 6.84MB

Backup database of a particular app

$ heroku pg:backups capture --app grow360-eu
Starting backup of postgresql-diagonal-12345... done

Use Ctrl-C at any time to stop monitoring progress; the backup will continue running.
Use heroku pg:backups:info to check progress.
Stop a running backup with heroku pg:backups:cancel.

Backing up EMBER to b001... done

To get the link of your dump

This will return the a url for your to download

heroku pg:backups public-url b001 -a your-app
https://feratu.s3.amazonaws.com/76784543jkjskdjfsdjdkljklgjsdlfjgsdfgsdf/gsdfgjsdjgksdfgsd/gsdjfgklsdjgfslkfgjsdg/gsjdfgkjsdlfgjsdfgjsdfgjkAmz=fjaklsfjalksfjklj

Done!