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

 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!

 How to Remove Box Shadow from Elements

A lot of developers and designers work with bootstrap nowadays and sometimes you need to override rules created by default by the framework. Here’s something I needed to remove a while back.

.progress {
    -webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
}

Progress bars have a default box-shadow. To remove it, simply add a rule to change the value to none

// from bootstrap
.progress {
    -webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.15);
}

//custom
.no-shadow {
    -webkit-box-shadow: none;
    box-shadow:none;
}

Apply this to your own elements

<div class="progress no-shadow">
  <div class="progress-bar no-shadow"></div>
</div>

Done!

.

 PG::DuplicateTable: ERROR: relation "table_name" already exists

StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR:  relation "table_names" already exists
: CREATE TABLE "table_names" ("id" serial primary key, "name" character varying, "owner_id" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 

This error show when you try to migrate a while the table is already existing.

This error is a result of deleting migration files instead of using the the rails rollback.

Solution

Delete the table using your console

your_app_development=# drop table table_name;
DROP TABLE