Friday, August 8, 2014

Start Nginx on Rackspace

Nginx's docs say you can typically start nginx in /usr/bin/nginx. Rackspace is slightly different.
sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart

Monday, February 3, 2014

Git Auto Completion

You need git-autocompletion!  Especially if you are using something like git-flow.

Make sure you have brew.

brew install git bash-completion

Edit your bash_profile...

vim ~/.bash_profile

...and add this:

  if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion


Save and restart your terminal or run source to make sure it works.

source ~/.bash_profile

Experience the bliss that is git autocompletion.

ActiveRecord::StatementInvalid: SQLite3::BusyException: database is locked:

Pesky rails debugger.  I leave the computer for half an hour to clear out some snow.  while in debug mode an my sqlite test database gets locked.  No fear.

If your dev server is affected you try opening up the console 

rails c
and running
ActiveRecord::Base.connection.execute("BEGIN TRANSACTION; END;")

...or if your test db is affected, just run

rake db:test:prepare
in the terminal.

Friday, January 31, 2014

Rails Destroy Table, Create Table, Migrate

Ever messed up your db by not using the rails destroy migration?

Instead of running the rake commands separately like so:

rake db:drop 
rake db:create
rake db:migrate

... you can stack them into one command.

rake db:drop db:create db:migrate

This way you don't have to wait for the environment to reload for each rake command.

Wednesday, January 29, 2014

Rails: A server is already running. Check /vagrant/tmp/pids/

I'm using vagrant as my virtual machine for a project and kept running into my port not shutting down completely after exiting the rails server.

vagrant@precise32:/vagrant$ rails s
=> Booting Thin
=> Rails 3.2.16 application starting in development on
=> Call with -d to detach
=> Ctrl-C to shutdown server
A server is already running. Check /vagrant/tmp/pids/

Solution was to check the port and to kill the process with the pid:

$ lsof -wni tcp:3000
ruby    12365 vagrant    9u  IPv4 114859      0t0  TCP *:3000 (LISTEN)
kill -9 12365