Saturday, April 21, 2012

First steps with Heroku

After bashing together a little web-site using Sinatra a while back, it sat on my machine for several months sobbing gently to itself.  All that changed today when I set out to upload the site to Heroku.

I already had a Heroku account and knew my way around Ruby and Sinatra (in which the site was written).  Uploading involved using git though, and that's where most of my learning was to be done.  I followed a mash-up of the instructions here and here.  What follows is a reminder for myself of what I actually ended up doing; maybe I'll look back and laugh at my naivete later.

First up, I needed to get the files on my local machine ready for git.  I already had git installed so I did

cd /my/app/dir
git init
git add .
git status

Whoops, I'd added far too many intermediate files.  I created a .gitignore file in my app's root directory

touch .gitignore

Then I did some Googling to find out how to remove things I'd accidentally added to my git staging area. I hit gold on stackoverflow) and ran

git rm --cached -r "*mini*"

which worked a treat.  It took longer than I'd like (15 mins or so) to work out the proper syntax to match the filenames I wanted (they all had the word 'mini' in them and it wasn't obvious from the git man pages that git rm would accept a wildcarded filename).  So then I wrote

git commit -m "Initial app commit"

So good so far.  I pretty well understood what I'd been doing git-wise, even if it wasn't second nature and I knew I'd probably forget the precise commands.  With my push pending I needed somewhere to push it to.  Logging on to my account at heroku.com I selected an empty Heroku app I must have created a while ago.  This empty app had a git repo ready created and associated with it, so that was my target location.  Here's what I did

gem install heroku
heroku login
<provided authentication gubbins - username and password - I'd created a git key some time before>
git remote add my_app_name git@heroku.com:my_garbled_heroku_app_name.git
git push my_app_name master

Then I hit the URL listed in my Heroku account and bingo!, there was my app.  And there was much rejoicing!

All I need to do now is figure out the inevitably subtly different workflow I'll use to make and upload changes to my site. :)

Thursday, December 29, 2011

Nice Rake overview

Just spotted a nice post here.

Thursday, December 8, 2011

Janki Method - spaced repetition

Interesting idea about how to learn technical subjects quickly is covered here using spaced repetition and a free fact-deck app called Anki.

Sunday, November 13, 2011

Name generators in Ruby

Found this. Feel the need to read up on Markov Chains now.

Saturday, November 12, 2011

It would be great if I could break into a Ruby app like I can break into a Visual Studio app

Eventually not knowing how to do this (or even if it was possible) annoyed me enough that I did a bit of Googling. I came up with this on StackOverflow. There are a few options there. I need to try them out to see which one(s) provide a behaviour I'm happy with.

Friday, January 18, 2008

What's your Mac/Ruby setup?

I've been having a nightmare getting Ruby and RubyGems playing nicely on my Mac. I wanted to get the latest (stable) version of Ruby so the one that comes pre-installed with OS X was no good. Somehow, when I first tried to install Ruby and RubyGems using DarwinPorts I ended up with ruby in /usr/local and gem in /opt/local. This caused issues from my terminal since I didn't have both these in my path - so this was the first thing I had to fix (by adding some paths to my .profile file).

One annoyance while I was doing all this was I was having to run the port and gem commands as an administrator. The login I use for my development work isn't an administrator so I have to keeping switching to an admin account in my shell and invoking the commands that way. However, the way I understand it, that means any environment variables ($PATH and $GEM_HOME are the two that seem to have reared their heads for me here) are now the admin users'. I don't really want to have to have my dev user's environment set to the same as the admin one. I'm thinking that I've got into a mess here and I need to do one of two things:
1. Do a private install of Ruby and RubyGems just for my dev user, or
2. Make my dev user an administrator.

I'm leaning towards 1 at the moment.

Recently I installed NetBeans, hoping to use it to debug my Ruby apps but I got a problem with RubyGems again. The issue was that it couldn't find the gem command, presumably because the modified path in my .profile file isn't picked up my OS X.

Thursday, January 17, 2008

Removing rubygems on OS X

rm -rf /usr/local/lib/ruby/site_ruby/1.8/rubygems*
rm -rf /usr/local/lib/ruby/gems/
rm /usr/local/bin/gem* # be careful on this one