Quite easy, but without knowing how would you know… (the docs!)

The Collaborator Quick Start guide is the place to be.

[sudo] gem install heroku
# then
heroku keys:add
#your login details are taken and ssh key uploaded automatically
git clone git@heroku.com:APPNAME.git -o production
#using the proper git repo name.git

if git push heroku fails then do this:
git remote -v
Hopefully you will see an origin or heroku

If not, find out your git url:
heroku list
heroku info --app your-app-name

git remote add heroku git-url
(this bit from google groups)

The last week or so my Leopard iMac has been waking up in the middle of the night… it’s quite annoying.

Finally found the answer here:
macrumors – leopard imac waking from sleep issue.

It turns out the problem is caused by having Screen Sharing enabled, and the 5900 port (VNC) being exposed to the outside world through my router. While this allows me to remote connect from another Mac ….

The problem lies in the fact that the screen comes to life whenever ANYTHING connects to this port, be it another Mac, or a port scanner… before even authentication takes place. Tested this by trying to SSH to that port – bang, my monitors come to life.

Fixed it by removing the external port forward, and just using SSH into the Mac. Apple needs to stop waking up the screens until authentication has taken place.

Basically this means that the really awesome TouchPad app that got Fireballed a few weeks ago is only really useful if you turn off your computer (completely) at night or are willing to manually turn off port 5900 (the VNC port).

The weird thing is that this worked fine on Tiger.

So perhaps with Snow Leopard this won’t be a problem… ?

*** Please note – this will probably not work (at all) (for more than a day of light use) without Cron use. And isn’t at all authorised by Dreamhost!! ***

For a recent client project I’ve used a Dreamhost unlimited account, which for value compared with the resources available and the fact that you don’t have to do any building or setting up of the server environment makes it an easy win for a site that’s not going to have a huge amount of traffic or a large amount of processing.

Post-launch I got to work putting together a basic search engine and here’s a quick run through of the steps it took to get a very simple Sphinx instance working on Dreamhost, and a few hurdles thrown in the way by various googled articles.

Development Environment

Using the guide from FG install Sphinx locally:

curl -O http://sphinxsearch.com/downloads/sphinx-0.9.8-rc2.tar.gz
tar zxvf sphinx-0.9.8-rc2.tar.gz
cd sphinx-0.9.8-rc2
./configure
make
sudo make install

then install the TS plugin into your application

script/plugin install git://github.com/freelancing-god/thinking-sphinx.git

Any problems with that, check out the FG page linked.

Getting a basic search going

Following tutorials such as the Sphinx Railscast will get you there pretty quick.

In your searchable model you need to define an index


class Page < ActiveRecord::Base
  define_index do
    indexes :title
    indexes :long
    indexes :short
  end ...

Run the indexer and start the Sphinx instance:


rake thinking_sphinx:index
rake thinking_sphinx:start

After this you'll be able to search on your object. So using script/console

@searched_pages = Page.search("query")

will return what you're looking for!

Setting up Dreamhost

First things first you need to install Sphinx in your local area, as posted by Hugh Evans:

cd ~/
mkdir -p local
wget http://sphinxsearch.com/downloads/sphinx-0.9.8.1.tar.gz
tar -xzf sphinx-0.9.8.1.tar.gz
cd sphinx-0.9.8.1/
./configure --prefix=$HOME/local/ --exec-prefix=$HOME/local/
make
make install

then set up the PATHs

echo "export PATH="$PATH:~/local/bin"" >> ~/.bash_profile
source ~/.bash_profile

You can choose to set up a CRON task at this point too, but I'm not going into that.

Also at this point in the there's talk of using Sphinx being anti TOS in DH's eyes... but we'll see does the process get killed or not!

Configuring Sphinx for DH

Create a file called sphinx.yml in the RAILS_ROOT/config/ folder.

Because Dreamhost uses an externally referenced MySQL server instead of localhost you need to set up the sql_* parameters:


  sql_host: "mysql.YOURDOMAIN"
  sql_port: 3306
  sql_user: "USER"
  sql_password: "PASSWORD"
  sql_database: "DATABASE"

And because you installed Sphinx in your local area:


  bin_path: '/home/YOURUSERNAME/local/bin'

Finally, after setting whatever memory/fine tuning settings you wish/require set up the locations for the Sphinx files:


  config_file: "/home/YOURUSERNAME/DOMAIN.co.uk/shared/production.sphinx.conf"
  searchd_log_file: "/home/YOURUSERNAME/DOMAIN.co.uk/shared/log/searchd.log"
  query_log_file: "/home/YOURUSERNAME/DOMAIN.co.uk/shared/log/searchd.query.log"
  pid_file: "/home/YOURUSERNAME/DOMAIN.co.uk/shared/log/searchd.production.pid"
  searchd_file_path: "/home/YOURUSERNAME/DOMAIN.co.uk/shared/db/sphinx"

That should be you ready to start deploying.

Deploying

Using Git + Capistrano for deployment (and Passenger for the http server) my deploy.rb's namespace area looks like this:


namespace :deploy do
  task :restart do
    after_symlink
    restart_sphinx
    run "touch #{deploy_to}/current/tmp/restart.txt"
  end

  task :start do
    # nothing  (this avoids the 'spin' script issue)
  end

  desc "Re-establish symlinks"
  task :after_symlink do
    run <<-CMD
      rm -fr #{release_path}/db/sphinx &&
      ln -nfs #{shared_path}/db/sphinx #{release_path}/db/sphinx
    CMD
  end

  desc "Stop the sphinx server"
  task :stop_sphinx , :roles => :app do
    run "cd #{current_path} && rake thinking_sphinx:stop RAILS_ENV=production"
  end

  desc "Start the sphinx server"
  task :start_sphinx, :roles => :app do
    run "cd #{current_path} && rake thinking_sphinx:configure RAILS_ENV=production && rake thinking_sphinx:index RAILS_ENV=production && rake thinking_sphinx:start RAILS_ENV=production"
  end

  desc "Restart the sphinx server"
  task :restart_sphinx, :roles => :app do
    stop_sphinx
    start_sphinx
  end

end

There's probably a neater way to do this, but basically this makes sure Sphinx's indexes and conf files live in the shared deployment folder.

I recommend you try all this in a staging area first, obviously... and you can use Dreamhost's control panel to set up a staging subdomain with a new database in whatever fashion you prefer.

Any problems with this script flag them up, please! This is as much for my future reference as you googlies out there.

I’ve just signed up to Haystack which is a new web designer finder service from 37signals. They make some pretty useful apps for running a small team business.

My [single item, cos i'm not paying!] portfolio is located here. Check it out!

The last few days I’ve been putting the finishing touches to the CMS behind Harry Ferguson Memorial.com. Initially completely in hand-coded HTML (to get it looking right without distracting myself hacking around in a CMS template styling system), it was time to choose a CMS to allow a certain amount of user updating to be done on the site.

I first experienced the Textpattern CMS through my participation in the TextDrive Joyent Mixed Grill “Venture Capitalist” life-time subscription. I was initially baffled by it’s usage of ‘forms’ ‘pages’ and ‘sections’ to categorise different design and structural hierarchy. Mostly using WordPress over the last few years on various sites and most recently developing a custom Rails CMS for the upcoming Bible Society of Northern Ireland website (note: current site is *not* of my creation) (launching in the next few weeks) I decided I needed to hunt around a bit. A quick play with Drupal left me unimpressed, I wasn’t going to touch Joomla (is it just me or does every site that uses it scream “look, it’s a site built using Joomla!”) and so I thought I’d take Textpattern out for another try.

Impressed by the fact it’s finally had an update (version 4.2.0 was released just a week ago (28th August) — after, I believe, a long hiatus — time to give it a spin once more.

Installation is pretty simple, quite lightweight; doesn’t require much in the way of configuration if you have a bog standard *AMP setup, just create or associate the database you wish to use (you can use a ‘_txp’ style suffix to append onto your existing DB) and create the .htaccess requested – it’s all explained on the linked instruction page.

I’m not going to do any sort of tutorial on the installation process, that’s been covered so many times, by so many people, I’d only do it a disservice. However, I have been using the YAB_Shop plugin, which is seriously lacking in documentation, with a 27 page forum post over at Textpattern.org. I’ll be putting together a few thoughts and instructions (which I found difficult to find) on the e-commerce plugin in the next few days and hopefully that’ll help someone out (and help me process and learn further!).

—-

Edit: I realise I didn’t really ‘review’ the experience, which I intend to do more so when I write about the plugin, most of my gripes are with the plugin workflow!

It’s happened to me twice in the last couple of weeks, and this time I knew exactly what I’d done, so here’s the solution if you make the same bad and non-”Rails Way” mistake I did.

dave@infinity:~/$ rake RAILS_ENV=production db:schema:load
(in /apps/special)
rake aborted!

Mysql::Error: Table 'special_production.pages' doesn't exist: SHOW FIELDS FROM `pages`

(See full trace by running task with --trace)

In my routes.rb file I had specified a route as such:
# map.connect 'special-day', :controller => 'pages', :action=>'show',
:id=>Page.find_by_title("Special Day").id

DON’T DO THIS. Not sure in what way it struck me as an overly good idea, but just don’t.
Strip that route out of your code and if necessary replace it as such:

# map.connect 'special-day', :controller => 'pages', :action=>'special-day'

What threw me about this problem is that I thought there was an issue in my schema.rb or migrations, this isn’t the case: ‘rake’ is trying to load the environment and falls over because ‘Pages’ hasn’t got going yet.

Don’t forget when you’re finished you may need to re-setup and migrate (cap deploy:setup / cap deploy:migrations) before your site will go.

P.S. This (silliness) never went into production!

I’ve had huge amounts of pain getting WordPress set up locally over the last few weeks on my old machine and when it struck again with my new development environment it definitely time to write down the required steps to get a great LAMP/Rails setup prepared (for me)!

Leopard has PHP and Apache fairly up to date, and probably MySQL as well, but I decided to get MySQL up to scratch using the Universal Binary along with a few command line instructions available here (guide and links to downloads).

I didn’t use this script myself, and at a year old it may have a few imperfections, but HiveLogic have a fairly well rounded Ruby/Rails install going on.

Finally, WordPress to go on your LAMP stack will be a lot less painful using this guide for Tech Recipes.

Any suggestions additions or replacements for this list? Drop a comment!

The Geeky Irish Rockstars I have six draft posts in the wings waiting to be pushed out, works in progress related to technologies I’ve been working with lately for Contrast.ie

Working on a still-hush-hush project with the lads best known for their rock star company photo and probably this week for their choice of marketing for Exceptional, the bug tracking tool for Rails (and more) at Railsconf in Las Vegas.

Part of the reason there’s been so little going on here is that I’ve been… well… rather busy. Trying to get client work done as well as freelancing with Contrast has been a bit of a struggle and I’ve just spent three days getting my brand new 24″ iMac set up and running… a pain worth the endurance, though I’m fairly certain I now need a bigger desk!

So, some posts about Rails, HAML, Cucumber, and possibly a very very late review of FOWA Dublin which never quite got finished coming up in the next few weeks.

Read the peculiar story of a BBC journalist who unknowingly betrayed the confidence of an island secret 25 years ago.

Things which piqued my interested: the islands use words like “ganzeys” for jumpers/jerseys/pullovers which my mother uses but not many others I’ve ever met; and the fact that during the War the island was officially classified as a ship called “HMS Atlantic Isle.” Which is pretty cool!

Good news.

As of 1st March 2009 the Student Loans Company released some beautiful information:

The new rate for income based student loans is 1.5% from 6 March until further notice. Interest is applied to loans from the date they are paid to you until they are repaid in full.

Dear Mister Government sponsored money lending money company: I apologise for venting that you were a big hypocrite.