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

Tuesday, December 31, 2013

Code Test

Code Snippets

I’m testing out StackEdit as a blog writing tool. Hopefully this shows some code snippets.

Example Octopress

rake new_page["Hello World"]
rake preview
rake generate

Code block

Hello world
How are you?


  Object obj = new Object();

Objective C

  NSString *string = @"Hello World";
  NSDictionary *dictionary = @{ @"title": string };

Written with StackEdit.

Monday, July 15, 2013

Command failed with status (65): [xcodebuild -project ios-sim.xcodeproj]

I'm writing a Sencha/PhoneGap app which has been a story by itself, but here's a problem that I ran into today and solved relatively quickly. I was in the process of install PhoneGap's ios-sim package with Homebrew. I ran into the following error after running brew install ios-sim:

The following build commands failed:
    Ld build/ normal i386
    Ld build/ normal x86_64
(2 failures)
rake aborted!
Command failed with status (65): [xcodebuild -project ios-sim.xcodeproj -con...]


Turns out that xcodebuild was pointing to XCode Developer Preview 2, which is not supported by ios-sim. Makes sense. So the solution is to change the path that xcodebuild points to. So I looked for where xcodebuild was pointing.

Jims-MacBook-Air:ios-sim jamesslien$ xcode-select -print-path

And changed the path using the switch command

sudo xcode-select -switch /Applications/

After that brew installed ios-sim and I'm on my way to packaging up the app for release on iPhone and Android.

Written with StackEdit.