Skip to content

Instantly share code, notes, and snippets.

View danieljohnmorris's full-sized avatar
😀

Daniel Morris danieljohnmorris

😀
View GitHub Profile
@danieljohnmorris
danieljohnmorris / migrate_db.sh
Created December 2, 2013 11:03
migrate db heroku postgres
heroku pgbackups:capture -a gsa-live --expire
heroku pgbackups:restore HEROKU_POSTGRESQL_GREEN -a gsa-staging `heroku pgbackups:url -a gsa-live`
1) backup production database:
heroku pgbackups:capture --expire --remote production
2) obtain url string to backup from step 1:
heroku pgbackups:url --app production_app_name --remote production_app_branch_name
3) transfer backup from production to staging app:
heroku pgbackups:restore DATABASE 'production_app_backup_url_string_from_step_2' --app production_app_name --app staging_app_branch_name
@danieljohnmorris
danieljohnmorris / fetch_upstream.sh
Created January 15, 2014 09:04
git - fetch upstream
git fetch upstream
git merge upstream/master
git config alias.co checkout
git config alias.com commit
git config alias.pu !"git fetch origin -v; git fetch upstream -v; git merge upstream/master"
git config alias.mrg '!git commit -m "merge"'
@danieljohnmorris
danieljohnmorris / fix postgres key constraint error
Last active January 3, 2016 20:29
postgres - duplicate key violates unique constraint postgresql (i get this error when downloading production rails db to localhost through heroku)
# in psql prompt
# connect to db
\c databasename
# update counter
SELECT setval('tablename_columnname_seq', (SELECT MAX(columnname) FROM tablename)+1);
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@danieljohnmorris
danieljohnmorris / devise_token_auth.sh
Created March 28, 2014 17:08
android rails token auth testing
curl -v -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST http://beta.sofarsounds.com/api/v1/sessions -d "{\"user\":{\"email\":\"[email protected]\",\"password\":\"secret\"}}"
curl -v -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE http://beta.sofarsounds.com/api/v1/sessions/\?auth_token\=JRYodzXgrLsk157ioYHf
curl -v -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST http://beta.sofarsounds.com/api/v1/registrations -d "{\"user\":{\"email\":\"[email protected]\",\"password\":\"secret\",\"password_confirmation\":\"secret\"}}"
# create new project
phonegap create my-app
# requires...
# - android sdk
# - brew install ant
# - adding tools and platform-tools to path
#PATH=$PATH:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/tools # android command
#PATH=$PATH:$HOME/Development/adt-bundle-mac-x86_64-20140321/sdk/platform-tools # adb command
@danieljohnmorris
danieljohnmorris / .bash_profile
Created April 11, 2014 14:35
Rails deploy scripts
# This goes in user root dir, ie ~
# So you can just call
alias deploy=./deploy.sh
alias deploy_ci=./deploy_ci.sh
alias deploy_live=./deploy_live.sh
@danieljohnmorris
danieljohnmorris / email.html
Created September 16, 2014 18:55
desk replies - new theme
{% assign emails = case.emails %}
{% assign threadlength = emails.size|minus:1 %}
{% for email in emails reversed %}
{% if forloop.first %}
{{email.new_html}}
{% if email.agent %}
{% if email.agent.signature %}