Skip to content

Instantly share code, notes, and snippets.

@krivaten
Last active April 6, 2016 14:59
Show Gist options
  • Save krivaten/7891c4870537fb12d684 to your computer and use it in GitHub Desktop.
Save krivaten/7891c4870537fb12d684 to your computer and use it in GitHub Desktop.

Rake Commands

To reset the database, run:

rake db:reset db:drop db:create db:structure:load db:migrate db:seed

Factory Girl Snippets

FactoryGirl.create_list(:kase_with_deceased, 10)

FactoryGirl.create_list(:case, 10)

FactoryGirl.create_list(:inquiry, 10)

To generate a whole bunch of data after a reset, use:

rails c

FactoryGirl.create_list(:kase_with_deceased, 10) && FactoryGirl.create_list(:inquiry, 10) && FactoryGirl.create_list(:product, 10) && FactoryGirl.create_list(:package, 10)

New Ember Data Store Methods

Name Async from serve/store Sync from store Query server
Single Record findRecord(type, id) peekRecord(type, id) queryRecord(type, {query})
All Records findAll(type) peekAll(type) query(type, {query})

Helper Uses

{{full-name "Daniel" model.lastName}}

{{my-component name=(full-name model.firstName "Smith")}}

{{! The following usage would set the model.name to the new full name when my-component calls the submit action. }}

{{my-component submit=(action (mut model.name) (full-name model.firstName "Smith"))}}

GIT Snippets

Rename Local Branch

git branch -m old_branch new_branch         # Rename branch locally    
git push origin :old_branch                 # Delete the old branch    
git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote
  • text(?!\.) - String not followed by a period

Convert Bootstrap to Flex

Find ([\s, \"])row(?=[\s, \"]) Replace $1flex

Find col--(\D\D)--(\d?\d) Replace c--$1--$2

Characters Description
abc… Letters
123… Digits
\d Any Digit
\D Any Non-digit character
. Any Character
\. Period
[abc] Only a, b, or c
[^abc] Not a, b, nor c
[a-z] Characters a to z
[0-9] Numbers 0 to 9
\w Any Alphanumeric character
\W Any Non-alphanumeric character
{m} m Repetitions
{m,n} m to n Repetitions
* Zero or more repetitions
+ One or more repetitions
? Optional character
\s Any Whitespace
\S Any Non-whitespace character
^…$ Starts and ends
(…) Capture Group
(a(bc)) Capture Sub-group
(.*) Capture all
(abc|def) Matches abc or def
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment