Thursday, 22 March 2012

Rackspace cloud Ubuntu install LAMP

Everything up to date with package manager:
apt-get update
apt-get upgrade --show-upgraded

Install everything:
apt-get install apache2 php5 libapache2-mod-php5
apt-get install mysql-server mysql-client php5-mysql
apt-get install phpmyadmin

Restart Apache:
/etc/init.d/apache2 restart

Check ImageMagick configuration

$ convert -list configure

Wednesday, 21 March 2012

Specifying the endpoint when accessing Amazon AWS S3 bucket

"The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint."

I got this error today when using the aws-s3 Gem. Perhaps it works out-of-the-box for those in America, but I chose Ireland to store my images, and the solution to the above was this line:
AWS::S3::DEFAULT_HOST.replace "" 

Friday, 9 March 2012

Setting up Sendgrid mail for Spree on Heroku

The free mailing functionality for Heroku is provided by, and allows your site to send up to 200 emails a day for no charge. Just perfect for my new low-traffic Spree e-commerce site that I've just built, but I did have some trouble working out to set it up. Here's how I got it working.

Firstly, enable Sendgrid on your Heroku app:
$ heroku addons:add sendgrid:starter
Then, run:
$ heroku config
this will reveal the SENDGRID_PASSWORD and SENDGRID_USERNAME values which you need for the next step:
Now go to the Configuration pages in your Spree admin interfaces and add a new mail method. Take a look at this screenshot to see what settings I used:

Tuesday, 6 March 2012

Datetime field presentation in ASP.NET MVC and Rails views

There are plenty of similarities between ASP.NET MVC and Rails, but I do keep stumbling across things that set them apart.

I used MVC's scaffolding today to build me the standard CRUD-y interfaces. Some of my fields were datetime fields, and to my disappointment the interfaces I was given provided simple text input fields which clearly I'll have to modify to restrict entry to a date format.

This is in stark contrast to Rails, with which only last week I was doing the same thing - and the date fields were dd/mm/yyyy drop-downs. Nice.

Friday, 2 March 2012

Using the @ symbol in content with ASP.NET MVC3's Razor

Razor’s language parser is clever enough in most cases to infer whether a @ character within a template is being used for code or static content.  For example, below we're using a @ character as part of an email address:
An email was sent to at: @DateTime.Now 

When parsing a file, Razor examines the content on the right-hand side of any @ character and attempts to determine whether it is C# code (if it is a CSHTML file) or VB code (if it is a VBHTML file) or whether it is just static content.  The above code will output the following HTML (where the email address is output as static content and the @DateTime.Now is evaluated as code:
An email was sent to at: 3/2/2012 1:23:24 PM

In cases where the content is valid as code as well (and you want to treat it as content), you can explicitly escape out @ characters by typing @@.

Thursday, 1 March 2012

Spree performance in development mode - precompiling assets

Important note, borrowed directly form the Spree help docs. Rails 3.1 introduced the concept of the asset pipeline. Unfortunately this causes some significant performance issues when running Spree in development mode. The good news is you can improve performance significantly by using a special precompile task.

$ bundle exec rake assets:precompile:nondigest

Using the precompile rake task in development will prevent any changes to asset files from being automatically included in when you reload the page. You must re-run the precompile task for changes to become available.

Rails also provides the following rake task that will delete the entire public/assets directory, this can be helpful to clear out development assets before committing.
$ rake assets