Category Archives: Uncategorized

Ruby on Rails autoloading causing “uninitialized constant” error

Whilst working on a personal project using the excellent betfair-ng gem that I converted to a ruby on rails project I came across a strange issue Once When running the code I was getting the following error.

1
 uninitialized constant Betfair::Client

It took a while to realise that this was caused by the autoloading feature of rails. However working out what to do to fix it turned out to be a little tricky but actually very simple. All I needed to do was to to move the `require` into the class initializer:

1
2
3
4
5
6
class BetfairCommands
def initialize
require 'betfair'
@client = Betfair::Client('X-Application', app_key)
end
end

I’m still quite new to ruby so don’t really know the full impact of this change, but it seems to work fine so far.

EDIT:

So it turns out that I didn’t need to do that way. I just needed to change the line in the Gemfile from

1
gem 'betfair-ng'

to

1
gem 'betfair-ng', require: 'betfair'

This then meant that I could remove the require from the class completely and rails now hooks it up.

How to un-install a buggy msi that you created with wix

Today I had an issue with a wix based msi that I was developing. The msi was installing and starting up a TopShelf based service. However I forgot to add a condition to stop it trying to start the service when it was being removed and this was failing as the exe had been removed by the time it tried to start the service, doh!

This was a big problem as by default I do major upgrades that un-installs the old version before installing the new one.

With a little digging on the wix forums I managed to work it out. Basically you have to replace the msi that is cached in the C:\Windows\Installer folder with the new one that fixes the issue. To do this you need to make sure that the ProductId is the same and run the following msiexec command:

1
msiexec /fv [PathToYourInstaller]

This replaces the cached one with your fixed one which you will be able to uninstall.

If you don’t know the ProductId as you get wix to auto-generate it using ProductId=’*’ like I do, you will have to find the cached installer in the C:\Windows\Installer directory (I ordered by size and then found it by comparing the size). Then use InstaEdIt! or Orca to open up the msi and find the ProductId in the Properties table. Temporarily use this in the wix code create a new msi.

Setting up your environment to build the Wix3.6 sources

Recently I have been back creating Wix installers and unfortunately I came across a a bug in the RC0 that was causing issues with my Burn bootstrapper. This had already been fixed in the latest sources so I went ahead and built the latest sources. This wasn’t as easy as I though it would be so here are the steps I needed to take:

  1. Install the Windows SDK 7.1 (http://www.microsoft.com/en-us/download/details.aspx?id=8279) (I just did a full install)
  2. Install Mercurial (http://mercurial.selenic.com/)
  3. Clone the latest Wix sources into a local folderย (hg cloneย https://hg.codeplex.com/wix)
  4. Change directory to the new wix folder.
  5. Switch to the Wix36 branch (hg update wix36).
  6. Setup an environment variable called WIX_ROOT pointing to your newly downloaded sources (In my case C:\source\codeplex\wix).
  7. Open up a VS2010 command prompt in administrator mode and navigate to the WIX_ROOT path.
  8. Run make.bat.

Now once that is completed, hopefully you should only have non-fatal errors and warnings an if that is the case the latest wix installer will be located under %WIX_ROOT%\build\debug\x86\release\%WIX_VERSION%\.

VS2010 Caching MSBuild properties

This really bit me in the arse today and wasted about 2 hours of my time so I thought I’d better blog about it!

I was splitting out the Properties required for a WixProject today and could not work out why the changes to my imported proj file were not being imported.

It turns out that VS2010 is really helpful when it comes to this and will cache the properties the first time they are loaded. Unfortunately it looks like the only way to get around this “feature” is to restart visual studio or use the msbuild commandline to build your project.

Joyness!

Sponsor me and get a “free” plug to your website on my blog!

Thanks to SharpCrafters (the makers of PostSharp THE AOP framework for .Net ๐Ÿ™‚ ) sponsoring me on my Princes Trust charity challenge I have had the great idea of giving away free plugs to your site and/or product if you sponsor me.

Any amount will get a thank-you blog post but if you sponsor me ยฃ100 or more you will be able guide the content of the blog-post (within reason! ๐Ÿ˜‰ ). If you have donated over ยฃ100 DM me (@caveman_dick) and I will send you details of how to contact me!

As SharpCrafters were the first they even get a banner!

SharpCrafters banner

Please sponosor me on my charity challenge!

This year at the end of September I am embarking on a charity challenge for the Princes Trust. This has been partially organised through my new employers (Advanced Health and Care Ltd part of the Advanced Computer Software Group) and they will be kindly sponsoring me to the tune of £100 but I need to raise the rest.

The challenge I’m entering is the Wild UK challenge which involves racing from the north coast to the south coast of Devon by cycling, hiking and kayaking a total of 100 miles!

So far I have managed to raise a bit at work by doing selling some cakes I have baked and will be doing a lottery next payday. I did plan to sort out a load of my junk to sell at a boot fair however this has been quite difficult to find the time (I moved out of London in Jan as my mum health was deteriorating and she has recently been diagnosed with Alzheimer’s :().

Unfortunately I’m still majorly short of the £800 target (£600 of which I need to raise by the end of August!), so hopefully this is where you will be able to help! ๐Ÿ˜‰

My sponsorship page can be found here. Anything that you can spare would be very much appreciated. Just think if you don’t have that extra drink down the pub on Friday, you can easily spare a fiver! ๐Ÿ˜‰

Thanks everyone! ๐Ÿ™‚

Shop with Wiggle sports shop and raise money for charity!!!

If you haven’t heard on the 3rd-5th Sept I will be cycling from London to Amsterdam in aid of the charities “Hope and Play” and “Action for Children”.

To aid with my fundraising, I recent just negotiated with my favourite online Cycle store Wiggle to get 10% cashback of anything you buy on the site for 3 months after you create a new account!!

To setup an account and make your purchases use click on the banner below.

Please Note: This offer will only work if you setup a new account. If you have an existing account with wiggle you will need to setup another account for the money to go to the charity.

If you are not very sporty but still want to donate, you can use my fundraising page here: http://www.virginmoneygiving.com/team/haysL2A

[ad#WiggleBanner]

Headphone volume issue on HTC desire after upgrading to froyo

So I went ahead and upgraded my mobile with the OTA update that has showing on my mobile. I wanted to upgrade ASAP due to the fact that I have run out of space for apps on the internal memory and this upgrade will resolve it (apps can be moved to the SD card).

However I think I may have jumped the gun as now whenever I use headphones the volume is stuck at max and even when the phone software says the volume is silent it’s still blasting out! ๐Ÿ™ Unfortunately spotify doesn’t have an internal volume control at all so it’s a no go there too.

I’ve had a search on Google and it looks like people are not experiencing the exact same issue, however there are a lot with issues with the volume in some way or another.

Hopefully this will be fixed pretty quickly as it now makes the phone unusable as a media player and I have to go back to using my iPod.

In the meantime if anyone finds a solution to this please let me know!

UPDATE: After searching for a resolution to this and not coming across anything much I managed to find someone saying recessed headphone jacks are quite problematic. The Desire doesn’t actually have a recessed jack but I do use a silicon case that makes the jack a bit recessed. This has not been a problem before, but I thought I’d give it a go without the case. Low and behold the volume buttons seemed to be working fine. I thought this was a bit strange so out the case back on and what’s even stranger is that is still worked fine. Now I have no idea why this happened and to me it seems a bit strange that this would even cause it in the first place (I would assume that it would be lower in volume or only one channel). Unless of course I came across a bug that has a 1 in 1,000,000 chance of hitting. Anyway I’m glad it’s working now!! ๐Ÿ™‚

London To Amsterdam bike ride 2010

Basically I’m on the scrounge for sponsorship. On Friday September the 3rd, along with 100 other riders I will be participating in a bike ride to raise money for the charities “Hope and Play” and “Action for Children”. Over 3 days we will be cycling just over 182 miles, from Stanstead in London, to the centre of Amsterdam in Holland.

To put the distance of how far we will be riding into perspective, it will be the equivalent to doing the London to Brighton bike ride, every day for just over three days.

Here is how we will do it

Day 1:
Stansted Mountfitchet to Harwich โ€“ about 110km (68 miles) though undulating Essex countryside. At 9.30am we will leave Stansted Mountfitchet where we will make our way to Harwich.

Day 2:
Hook of Holland to Heemskerk โ€“ about 135km (83 miles) up the F1 cycle path on the Dutch coast. We will disembark the ferry at around 7.30 and straight onto the cycle path up the cost. Heading through the Kennemerduinen Nature Reserve we will make our way to Heemskerk.

Day 3:
Heemskerk to central Amsterdam โ€“ about 50km (31miles) This will be the final stage of the ride and will take us nicely in to the centre of Amsterdam

You can sponsor me at virgin money giving, http://www.virginmoneygiving.com/team/haysL2A . Any donations, no matter how small will hopefully help me reach my target of ยฃ500 of which all of it will be going directly to the charities as I am covering the ยฃ290 trip costs myself.

Last but not least, no we will not be cycling home!!

Thanks in advance for your generosity.

Not sure if anyone actually reads my blog, but anyway it’s worth a go and any extra pennies will be worth it!!! ๐Ÿ™‚

UPDATE: If you use the below banner, setup a new account and make any purchases within the next 3 months, I will donate the proceeds to the charity page.

[ad#WiggleBanner]