How to Get a JavaScript Stack Trace – Chrome Console

Hey everyone,

Just a quick post on something useful I came across today. In JavaScript you can access the stack trace via console using the following command (ctrl + shift + j):

console.trace()

In Chrome, this will let you navigate to each relevant call by clicking the line number in the console window. I’ve found it pretty useful for backtracking through jQuery exceptions.

For more info, check out this Stackoverflow post: http://stackoverflow.com/q/6715571/522859

Chrome Replacing Strings with Ellipses – Chrome Console

Hey everyone,

Ran into a bit of an issue today where a url was being shortened in Chrome’s console. It turns out that there’s a quick command you can use to copy the full value:

copy(myVariable)

Type copy into the console window and pass the variable you want to copy as a parameter. This will then be saved to your clipboard for pasting.

Check out this Stackoverflow post for more info: http://stackoverflow.com/a/19184513/522859

Simple Staging/Test Environment with Heroku – Ruby on Rails

Hey everyone,

This is just a quick guide on how to create a test/staging environment with Heroku.

-- Create staging environment
heroku create --remote staging

-- Push to staging app
heroku push staging master

-- Run rake db:migrate on staging app
heroku run rake db:migrate --remote staging

-- Add pgbackups add ons
heroku addons:add pgbackups --remote staging
heroku addons:add pgbackups --remote heroku

-- Create backup of production data
heroku pgbackups:capture --remote heroku

-- Copy to staging environemnt
heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote heroku` --remote staging

-- Create a new config file called staging.rb (/config/environments/staging.rb)

-- Add environment variables
heroku config:add RACK_EVN=staging RAILS_ENV=staging --remote staging

-- Ready to go !

For those of you using git branches etc, the following may come in handy as well:

-- Create local development branch
git branch development

-- Switch to dev branch
git checkout development

-- Make your changes and commit them
git init
git add .
git commit -m "My changes"

-- Push to staging environment (local development branch to staging environment master branch)
git push staging development:master

If you run into any trouble, I found the following links pretty helpful:

http://stackoverflow.com/a/6931462/522859
https://devcenter.heroku.com/articles/pgbackups#transfer
https://devcenter.heroku.com/articles/multiple-environments

Let me know if you’ve got anything to add.

Browse Folders as Root – Ubuntu

Just a quick post on how to browse folders as root in Ubuntu. Simply enter the following:

chris@chris-VirtualBox:/etc$ sudo nautilus

Once you’re in there you can view hidden files by pressing Ctrl+H.

If, like me, you’re coming from a Windows background – this may make things a little easier. Leave a comment below if you have any more useful tips!