shiningthrough

A simple example of using Modules with Ruby On Rails

18 July 2011
A module provides a means of grouping together classes, methods and constants. This is advantageous for two reasons: It provides a namespace to avoid name clashes. It allows you to "mixin" the contents of the module into an existing class so that the module functions behave as if they were methods of the class. Lets see this in action with a simple example: We create a module called TextSta...

Gazetteer Of Great Britain Download with recognizable Counties and Latitude & Longitude

27 March 2011
The problem when developing a Gazetteer of Great Britain, is which of the counties should we be using? Perhaps the ones that are most familiar to residents in the UK would be postal counties, but these are no longer used by Royal Mail, and have been discontinued and are no longer maintained. They are currently provided as part of the "alias" file, to be used with the PAF database, but from 2013...

Summary of the different counties of Great Britain both Current and Historical

27 March 2011
If you require the Gazetteer data download, please go here. There are many definitions of a "county" with respect Great Britain, below I have compiled a summary of the different counties that exist, both current and historical. Counties of England Traditional Counties / Historical Counties / Ancient Counties ~445 - 1871 The boundaries of these counties were established over centuries, and in...

Speed up your Ruby on Rails application by only including the Scriptaculous libraries you need

30 December 2010
If your using javascript in your rails application, it's a good bet you have this line in your application layout file. <%= javascript_include_tag :defaults %> Problem is it pulls in a whole bunch of libraries, many of which you may not be using. So the best thing to do is specify only the scriptaculous libraries you need, for example, in nearly all my projects, effects.js is all I use....

Installing Git on PPC Mac OS X Leopard

20 December 2010
I had previously used the installer git-osx-installer to install Git 1.6.5.1 on my PPC Mac Mini Server, running Leopard 10.5.8. Unfortunately all installers since then are intel specific, so I thought I would install it from source. Download the source from here. Open the Terminal application, and enter the following commands. cd ~/Downloads tar -xjf git-1.7.3.4.tar.bz2 cd git-1.7.3.4 make ...

Setting up an SSL enabled Apache development server using Phusion Passenger on OS X Snow Leopard

05 December 2010
Want to have a secure https:// url for an application you are creating? I have compiled a list of concise steps to get you there as quickly as possible. If you want more details on each step, check out the references. Prerequisites OS X Snow Leopard install. Ruby and Ruby on Rails Apache 2 (comes with OS X leopard and Snow Leopard) Phusion Passenger with its associated preference pane ...

Mac OS X Git Clients Roundup

12 September 2010
I have been looking for a Mac OS X Git client, and these are the results of my initial search, I will try and pad out the descriptions of each as I become more familiar with them, and may even put together a feature matrix if I have the time. For now, here are my initial thoughts. Gitti Free download - Still in Beta Powerful, visually appealing, native OS X Git client. A few stability issues wh...

Change iTunes 10 buttons from vertical back to Horizontal

03 September 2010
I really don't like the new iTunes 10 vertical title bar buttons, fortunately they can be changed back to horizontal again quite easily. Open up terminal, and paste in the following command defaults write com.apple.iTunes full-window -boolean YES To make them vertical again, paste in this defaults write com.apple.iTunes full-window -boolean NO

Synchronize MarsEdit on multiple machines by sharing Local Drafts folder with Dropbox

12 August 2010
MarsEdit is my blogging client of choice, and I like to use it both on my MacPro and MacBook Pro. This can be achieved by using Dropbox. On the machine you currently use for MarsEdit, paste the following commands into a terminal window. Make sure you quit MarsEdit first if its running. mkdir ~/Dropbox/MarsEdit cd ~/Library/Application\ Support/MarsEdit/ mv LocalDrafts ~/Dropbox/MarsEdit/ ln -...

Using Dropbox to share Snippets between computers

25 July 2010
I think Snippets is the best code snippets application for Mac OS X, and I have it setup with Dropbox so my snippets can by synchronised between multiple machines. There are some instructions on the fuelcollective.com website, but they didn't work for me, the following steps show how I did it. If your running Snippets, first quit the application. Create a new Folder in Dropbox, I called min...

A comparison of Ruby pass by reference and C++ pass by reference

12 April 2010
Take the following Ruby and C++ applications: def do_something(text) text = "bar" end text = "foo" do_something(text) puts text The Ruby program above outputs "foo" Variable "text" holds address of String object containing "foo" Call do_something function passing in address of String object containing "foo" Address of String object containing "foo" gets copied to local variable "text" Lo...

Ignoring Ruby On Rails files with Git, on OS X, and using TextMate

03 April 2010
I thought I would share which files I ignore with Git, while developing Ruby On Rails applications using TextMate on Mac OS X. There are 2 ways to ignore files using Git: Specify the files to ignore in a .gitignore file that can be created in any Git directory, but is most commonly created just once in your root Git directory. This file gets included in your git repository, it's for ignoring...

Apple with Alan Partridge, ah ha!

23 March 2010
How did Alan Partridge get into a 1970's Apple Advert?

Dynamic multiple image uploads with Ruby on Rails

23 February 2010
This tutorial explains how to create a simple web application that allows a user to upload one, or multiple images. It makes use of the paperclip plugin, Ajax using RJS and new multi-model form functionality that has arrived with Rails 2.3.3 in the form of accepts_nested_attributes_for. Make sure your up to date with Rails, you will need at least 2.3.3 Lets start by making a new rails applica...

Install RMagick and ImageMagick on Leopard OS X, quickly and simply

15 February 2009
RMagick is a Ruby interface that allows access to the ImageMagick image processing library. When I started out developing in Ruby on Rails, installing RMagick was quite an endeavour, which was one of the reasons I used ImageSciene in preference. The installation has now become very simple indeed. Go to the RMagick download page, and download the rmagick-osx-installer (at the time of writing, t...

Install ImageScience on OS X Leopard

15 February 2009
I couldn’t find a tutorial that took me through this process successfully, in the end I combined information from several other articles to provide these simple steps. Prerequisites I used a clean fresh Install of Leopard to begin with. Make sure you have installed Xcode from the Leopard disk. Install ruby_inline Open a terminal, and enter: sudo gem install RubyInline Install FreeIm...

Use Photoshop to remove Mac OS X Leopard window shadows from screenshots

02 December 2008
Whilst i was writing a recent article it was necessary for me to take some dialog screenshots from OS X Leopard. There are several ways of doing this: Using the grab utility that comes with OS X. Holding Apple, ctrl, shift and 4, release, then press space. Entering "screencapture -ic" on the command line, then press space. (This appears to be the same capture as above) Use one of the man...

Reindex spotlight in OS X Leopard

15 December 2007
I recently upgraded to OS x Leopard, and afterwards noticed that spotlight was failing to find certain applications. It was necessary to delete the index database in order to force reindexing. This is done using the mdutil application. You can find out what it does by opening a terminal window, and typing: man mdutil But, if you just want to straight ahead and remove the index database, open a ...

Safari 3 bugs

22 June 2007
Like over a million others (at time of writing) i have upgraded to Safari 3. There are some great new features which are covered in other blog posts, but i am also encountering a few problems... Apple's new browser crashes on me at least once today, but it is still only a beta, but one problem i found was its lack of support for the pseudo-class, :last-child. First Child Second Child The above ...

GET and POST in Ruby on Rails

24 May 2007
Lets start with the basics..... What are GET and POST? GET and POST specify the two main ways by which the browser sends a form's data to the server for processing. The Get method contacts the server, and sends the forms data in a single transmission step. The browser appends the data to the forms action URL, separated by the question mark character. With the POST method, the browser sends ...

Select helper methods in Ruby on Rails

01 May 2007
It can get quite confusing when it comes to using the different select helpers, select, select_tag and collection_select and in my opinion there is a lack of adequate documentation. For my own use if nothing more, i have done my best to compare the different form helper methods available, and when and how to use them. First we will look at the html for a basic selection box: <select name="...

Simple debugging in ruby on rails

24 April 2007
I often find while writing a ruby on rails applications that i need to display the contents of a variable quickly and easily, this is straight forward in a view, but not so easy in a controller or model. There are a couple of ways to do this: logger.debug "variable" will write to the development.log file, or if your using webrick as your development server, you can use: STDERR.puts "variable...

My first post!

18 April 2007
My first blog post! and i am quite pleased with myself. I wrote this blog application from scratch using Ruby on Rails, its kind of an experiment, i get to try out new features, and generally use this site to mess around with. In addition the XHTML and CSS that are used to make the layout are also a first for me. You'll notice that the grass always sticks to the bottom of the site, and the pag...