Archive for the 'Guides' Category

HTTPS Generating Private Key and CSR For RapidSSL

December 3rd, 2007 by pyrat
  • Generate a private key

openssl genrsa -out domainname.key 1024

  • Generate a certificate signing request

openssl req -new -key domainname.key -out domainname.csr

When it asks for common name enter the fully qualified domain name. eg. www.racentries.com

Deploying with Capistrano VPS

July 4th, 2007 by pyrat

It has taken me a while to move from the custom checkout scripts that I use for rails deployment to move to the capistrano way of doing things. I am so excited about it that I have decided to write this blog post.

This is not a definitive guide to rails deployment with capistrano but is the way I do things when deploying to slicehost for an application which we will be releasing in the not too distant future. This should work out for other vps servers and can be modified for shared hosting where you dont have as many permissions such as sudo access. Also I am basically a capistrano beginner so take what I say with a pinch of salt.

Firstly, if you are not familiar with capistrano I recommend purchasing the peepcode episode titled Capistrano Concepts

Your using source control right?


The first step is to make sure that you are using source control. The source control system of choice in the rails world is subversion. Capistrano works with quite a few other scm applications but subversion is by far the most common.

So you need to have your application in a repository somewhere which your deployment box can access. You should also setup the repository to work with the rails app (ignore log files, ignore database.yml, ignore *.pid files etc.) There is a great rake task for setting up subversion on rails

You have installed and setup your vps?


Lets say you have setup your vps and plan to deploy with an nginx / mongrel_cluster rails stack. There is a good guide at usefuljaja for doing this.

You have also setup ssh key authentication to avoid typing in passwords all the time. You are also just deploying to a single server and only have one mongrel process to start with.

For installing and setting up nginx for your deployment its best just to install nginx from source and use the nginx config generator to configure nginx for your deployment. I am also loving the no_www option which redirects requests to www.example.org→example.org. Is it just me or do other people hate www.*

Setting up a deploy user on the VPS is also recommended for cleanliness.

You have setup a database and there is a domain you can run this off?


You need to setup the database in your production environment. A url to deploy to would also be nice, maybe you are still in development and you can use a static dyndns.org free domain to get started.

Install capistrano and railsmachine


sudo gem install railsmachine —include-dependencies

This is a great little collection of capistrano tasks to organise the deployment by convention over configuration.

Setup your rails app and deploy


cd {RAILS_ROOT}
cap—apply-to .

This creates a deploy.rb in your /config directory where you can setup the deployment. My deployment script can be found over at pastie

The tasks defined in the two bottom tasks are defined in a mycaptasks.rb file which I can move around projects. You could also set it up as an svn:external in your project if you want to be more DRY. It is also up on pastie

Now run:
cap setup

This sets up the folder structure that capistrano uses.

Now:
cap cold_deploy

To check everything is working ok.

Now:
cap deploy_with_migrations

This will build up your new database assuming you work withe database migrations.

From now on
cap deploy

To deploy your app.

Its in source control


Because the deploy scripts are contained within the source control it works great in a distributed work environment so other developers can work with your project and deploy in a common way. It brings deployment into a convention rather than custom built and often nasty deployment methods which exist out there.

Cheers for now


This has been a skim at deploying with capistrano and I urge you to check out the other and probably a lot better learning resources out there.

Everyday Scripting with Ruby - Book Review

June 24th, 2007 by pyrat

I recently finished Everyday Scripting with Ruby written by Brian Marick

Apart from using the pickaxe as a reference this is the first book on pure ruby that I have read. One big advantage that this book has is it uses ruby in a different context instead of the “rails way� that I am used to.

Over the last year I have been writing more and more scripts; mostly in Ruby and Bash. I have written everything from basic copy scripts to a more complicated website crawler called the harvester. I wont speak any more about the harvester as I am not proud of its application! It was great to read a book about the black art of scripting and get a strong grasp of how Ruby can be utilised in this context.

I thoroughly recommend getting this book and reading it cover to cover. The book starts easy then progresses in difficulty so is more of a cover to cover read than a reference. Apart from the chapter on regular expressions which is the most detailed description of ruby regular expressions I have seen to date.

TDD


Brian also mentions TDD very early on and manages to do well to enforce it throughout the book. I definitely go for the TDD approach when developing rails applications and plugins (wrote my first last week!) but have yet to use it for script development.

I am of the mind that TDD is great if you go as far as to start extracting methods to a class. If however, you are just writing a simple single stream script as I mostly do, it is not worthwhile writing tests for something simple and throw-away.

Driving the Browser


(http://www.openqa.org/selenium/)
There is an interesting section in browser control which I did not know about. There is Watir and Selenium which can be used to control browsers from within ruby.

There is also the mechanize ruby gem which can be used to build simple crawlers. This is interesting when you think about what is possible. I remember back in the day Alistair Burns and I wrote a bot for planetarion which would login every few hours and then send an email to your phone if you were under attack. We wrote it in PHP4 and it was a fairly dirty script. Nowadays you could do the same in ruby in an embarrassingly little amount of lines.

Modules, Classes and Monkey Patching


There is a great description of the above and when you should do each. Shoud what you are writing be a module or a class. Do you just monkey patch to solve the problem? All is explained here.

Top marks for this book. Buy it if you can.

Buachaille Etive Mor and Mountain Navigation

June 4th, 2007 by pyrat

Buachaille Etive Mor (The big herdsman of the glen) is an iconic scottish hill / ridge line in glencoe.

It makes a great point to point hill run as I found out yesterday with Robert Munro.

As you can see by the route it is a point to point run starting at Lagangarbh and finishing at Dalness. We achievied this using 2 cars but you could quite as easily drive to dalness with one car then hitch a lift to the start.

In terms of the details of the route, there is a fairly good path the whole way to keep you right.

However, the mist was down yesterday and a word of warning, a map and compass is required for this route and it was very handy yesterday in the thick mist.

You can see by the route that we made a couple of errors on the tops. After we arrived at the summits we did not check our direction the first few times and this caused us to run down the wrong ridge / corrie.

  • Always check your compass when you are about to descend.

The run took 3 hours 5 minutes; a good jaunt for a Sunday.

We stopped at the Real Food Cafe on the way back for some tasty food. I had a top class Lamb Burger.

I was thinking about getting a soup but then saw that it was £3.25!! so I went hungry and ate smart price bourbons in the car instead.

Freelancing…from a beginner’s perspective

April 18th, 2007 by pyrat

As I said in my last post, I have recently become self-employed, freelancing my design skills.

I thought I would cover some of the issues I have come across so far, and some of the resources I have found helpful.

First, the problems/issues:

It can be lonely. I am very happy in my own company. I always have been. But sometimes you just want people to bounce ideas off, or just banter with for 5 minutes when the particular task you are trying to achieve is driving you crazy. I find that this can be overcome by completely switching off from what you were doing, just like you would be if you wandered over to chat to a colleague for 5 minutes. For smaller problems, I find checking my personal email, looking at design inspiration websites, or looking at friends’ sites or flickr accounts is enough to get me back on track. For severe mental block, either a trip to the living room to watch half an hour of recorded TV shows, or a 30 min walk will do the trick. Which brings me to…

Motivating yourself could become a problem. It can be hard to define boundaries when you work from home. Your living space and work space become a little too close for comfort sometimes. It could (and I have to say that so far this has not happened to me) become very easy to get up late, finish early, watch a little too much daytime TV, let a friend stay a little too long when he stops by, etc. On occasion, these are perks of working for yourself, granted. But if they occur too often, you won’t get anything done. Working in the field that I do, I could feasibly work any hours I wanted to, but I dont think my girlfriend would be too impressed if I became nocturnal. And neither would my clients, I assume. They (generally) work ‘office’ hours, so they (quite rightly) expect me to be available at the same time. I have deliberately set out to start off on the right foot, keeping ‘office’ hours at least. I generally work longer than that though. Which leads nicely to…

It can be hard to switch off. With the work/home divide so blurred, it could be easy to go the other way, and never be able to switch off. There is always time to send one last email, make one last change to that document, etc. It is all to easy to answer the business phone at 11pm. But I really do agree with a lot of articles I have read that advise freelancers to beware of communication with clients outside normal working hours. The idea being that once the client gets one or two communications from you outside normal hours, they will think it is OK to contact you any time. There are always exceptions to this, where communications at 11pm need to take place, but try and keep them to a minimum. And the more you do little bits of work at night, the less you will be able to relax, and that will ultimately make you less productive during your proper working days. I also always keep a Sunday work free. I think this is very important. It is not good for anyone to work 7 days a week for any extended period of time. You need one day of relaxation and fun and not worrying about work at all.

These are just a few of the issues I have come across so far. I’m positive there are many more lurking around the corner, not least the anxiety about money and the problems of getting paid. I am learning all the time, not just about design now, but also about business. I hope to talk about these issues here as and when they arise.
I found these articles very helpful with regard to these issues:
Five Common Working At Home Problems Solved

Being Productively Unproductive

Five steps to get yourself in a mood to work

And now the upsides. Do I really need to discuss the upsides? Flexible hours, no boss, no potentially characterless dingy office, no irritation coworkers, your own music (this is a big thing for me), the list goes on.

And finally a couple of sites which I am finding particularly helpful while starting up on my own:

Web Worker Daily

Freelance Switch

and a giant resource worth checking out:

101 Essential Freelancing Resources

I hope this article has helped someone who is starting out, or thinking about it. Coming soon: more problems, solutions, resources and possibly an anecdote or two.

A life online: living decentralised still hot

February 12th, 2007 by pyrat

I wrote a white paper for Mercurytide, the company I used to work for almost a year ago titled A life online: living decentralised and it is still hot according to google blog search.

Essentially it discusses “how to use Web 2.0 applications to create an online platform”
http://www.mercurytide.com/whitepapers/life-online/

Simple Google Analytics Guide

January 10th, 2007 by pyrat

Welcome to the cheer factory blog as an initial post I am covering the bare essentials to getting your site setup with Google Analytics.

Google analytics is a free service to provide website statistics. To get started you need a google account, then create an analytics account using this username / password.

From here you can add a website profile as shown below.

add website profile
This takes you to a simple page which contains the following form.

create new profile

Tracking code is then generated. This should appear on every page on the site that you want to be tracked. Is the site has been well developed there should be only one or two layout templates and hopefully only one footer. Hopefully this should only need pasted in one location if you work by DRY href=> as much as possible.

example tracking code

After the site is setup and gathering stats you can go in a view the stats. Also, user accounts can be added to specific sites so you can give clients direct access to the statistics. An example overview page is shown below.

example overview

Thats all for now! Thanks for reading.