Skip to content

Instantly share code, notes, and snippets.

View danieljohnmorris's full-sized avatar
😀

Daniel Morris danieljohnmorris

😀
View GitHub Profile
@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\":\"user@example.com\",\"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\":\"user1@example.com\",\"password\":\"secret\",\"password_confirmation\":\"secret\"}}"
=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 / 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);
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 / fetch_upstream.sh
Created January 15, 2014 09:04
git - fetch upstream
git fetch upstream
git merge upstream/master
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 / 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`
@danieljohnmorris
danieljohnmorris / fix_postgres_constraints.sh
Created October 10, 2013 17:33
Postgres.app dev db fix bugged table id constraints
psql -h localhost
\c gsa_development;
REINDEX DATABASE gsa_development;
SELECT MAX(id) FROM taggings;
SELECT nextval('taggings_id_seq');
SELECT setval('taggings_id_seq', (SELECT MAX(id) FROM taggings)+1);
class hey
def hi
if true
end
end
end
@danieljohnmorris
danieljohnmorris / command line
Last active December 18, 2015 01:39
work mode
mate /etc/hosts
*add lines to hosts file / comment out to use sites*
dscacheutil -flushcache