Archive for category Uncategorized

MongoMapper callbacks/hooks

It took me a while to find these, so I thought I would post them here. In the end I had to search the source code to find them.

:before_save,                        :after_save,
:before_create,                      :after_create,
:before_update,                      :after_update,
:before_validation,                  :after_validation,
:before_validation_on_create,        :after_validation_on_create,
:before_validation_on_update,        :after_validation_on_update,
:before_destroy,                     :after_destroy,
:validate_on_create,                 :validate_on_update,
:validate

I was searching for these amongst MongoMapper doucmentation and blog posts when really they are an ActiveSupport concept as the following comment suggests:

Almost all of this callback stuff is pulled directly from ActiveSupport . . .

Being new to rails I wasn’t very familiar with the ActiveSupport stuff and so I didn’t know to look there. Anyway this is how I use them in my posts model:

class Post
  include MongoMapper::Document

  many :comments

  key :title, String, :required => true
  key :slug, String
  key :body, String, :required => true
  key :published, Boolean
  key :published_on, Date, :default => Date.today

  after_save :update_comment_titles

  private

    def update_comment_titles
      comments.each do |comment|
        comment.post_title = self.title
        comment.save
      end
    end

end

My comments live in a separate document collection and each Comment document contains the title of the Post that it belongs to. This allows me to list all comments (on the admin page for example) without having to query any of the Post documents.

This above after_save call back ensures that the post_title on each Comment is updated if I ever update the title of the post.

Tags: , , , ,

Wickes 1 – 0 Maplin

I was in a Maplin store yesterday returning a set of precision screw drivers that were of such poor quality that I asked to see the manager to complain. I showed the manager where it said “Quality Tools” on the box then I showed him how the tiny shafts just rotated in the handles and came off. I showed how the ones that didn’t fall apart weren’t even straight (so crooked that they couldn’t be used).

They were so bad that I was expecting a “wow, I’ll have to take them off the shelves straight away”. But what I got was:

Yeah, they’re pretty bad but we didn’t make them.

I was told that any complaints should be addressed at the manufacturer!

On a positive note I stopped in Wickes (recommended by a friend) on my way home and picked up a set of precision screw drivers for around the same price.

They were Wickes own brand so I wasn’t expecting much but the quality was far superior to what I got from Maplin. Even the plastic case they came in was sturdy and practical. So if you’re in the Limerick area and looking for good value tools I can recommend Wickes.

Have too much money?

Just give it to me!


You will be paying securely via PayPal.

Tags: , ,

Currys …lots of worries

I don’t want my blog to become somewhere that I complain about everything but I have to get this of my chest. Here is a currently ongoing story of me trying to get vouchers for a replacement camera that I am owed from Currys in Limerick.

Remember it’s a blog, so read form the bottom to get the full story.

Blogger has let me down

I was on holiday last week, in the north of the country. I was a way from internet access for most of the week but I decided to send some MMS pictures of the places I was at to this blog. I had sent about 6 or 7 photos, which is not free, and towards the end of the week I was looking forward to seen how my travels looked. I found an internet cafe but when I checked my blog I was very disappointed to see that it hadn’t changed.

I have posted MMS messages to my blog before and found it to be an excellent service, the best use of MMS I’ve seen to date.

I could of course add my entries now by sending the photo via bluetooth and trying to recall the date, time and place but it just isn’t the same.

Currency conversion in Google

When I first found out about using the google search as a calculator I was very impressed. I experimented with different units such as “one and a half parallax seconds a year in angstroms per second“. I was, however, immediately disappointed when I tried to use currencies in my calculations and they wouldn’t work.

But now Google have added a currency converter to their search so you can do things like “50 pounds a mile in €/km“.

Now you can price some flooring you’re looking at in the north like this “12 british pounds per square foot * nine square meters in euros“.

amazon.co.uk scam Euro shoppers

I have just discovered a scam used by amazon.co.uk to trick Euro shoppers into buying products from them.

I am an Irish user of the amazon website and as such I pay attention to the ‘approx’ Euro price of products when shopping around for the best price. This Euro price I thought was an ‘approx’ because of the varying exchange rates, but I always assumed it was close enough to use. This is not the case!

The sterling price given for items contains VAT for the UK. The Euro price for items contains no VAT at all. It doesn’t say ‘ex. vat.’ or any other indication that the price you see in Euros can be a lot less than the price you will pay. Even when I am logged in an they know what country I am from they still leave out VAT on the Euro price.

When I asked amazon about this they said, “When VAT applies to an order, the relevant VAT charges for the country of destination will be clearly reflected on your e-mail confirmations and invoices.”

But it is too late! You have shopped around and decided to buy the item from amazon and only then do they say anything about VAT.

AuctionSniper.com

I’ve started using AuctionSniper.com to do my ebay bidding. It didn’t work the first time I’ve tried it but I have since won auctions at bargain prices.

A nice feature is bidding groups. Here you can bid on a group of items until you have won enough. For example if you want a hard-drive, you would look on ebay for any hard-drives you would like, give a max bid for each and auctionsniper will keep last-minute bidding on each of the items until you have won one.

Phone wallpapers

I have uploaded some pictures that I use as wallpapers on my phone. You are free to download them from my website and use them on your own phone.

Wikipedia on my phone

From time to time I would be browsing stuff on Wikipedia and come across an interesting article that I would like to read, but at a later time. Specifically I would like to be able to read it while away from the computer. I used to print off pages, but this proved to be a waste of paper (particularly when I end up not reading many printouts) and very messy (with lots of sheets of paper lying around).
I was thinking about buying an ebook reader but these are very expensive, so before spending a lot of money on a new device, I decided to try reading on my phone.
I had sent short notes to my phone before to read, so I tried this with a few wikipedia entries. I just cut & pasted the text from the web page to to a txt file and sent it to my phone. Later when I went to read them I realized that a note could only be 3000 characters long. This was way to short.

My next step was to download ReadManiac. This is a very good reader that you can change font size and uses the screen to the maximum. Plus, it can read large files.

ReadManiac has a feature that lets you download eBooks by providing a url. I am now using this feature to download wikipedia entries as plain text via a script on my website.