Brad Rees | home

I recently upgraded my main PC, and as part of that I also had to transfer my music, photos and documents from the old machine to the new one. I used the trick here to rebuild my iTunes library on the new machine, as this allowed me to keep my ratings and playlists. This went off without a hitch. Great.

Then I plugged my iPhone in. Bad idea.

Without any warnings or confirmations it started to sync, which seemed fine as I now had a complete library of music, so I let it be. All my personal data, such as contacts and emails, lives in the cloud or on servers I have access to. Once the sync was finished I was shown a message that informed me that some of my apps were not authorised on the new machine. I fired up the iPhone, and to my dismay most of my apps had been deleted, with only a few exceptions.

The problem was that I had not yet signed into iTunes and authorised the new PC, which is quite an easy mistake to make. A warning before wiping everything would have been nice, thanks Apple. I had a look on the interwebs for a while, however this did not yield any great solutions for getting my precious apps back. The best solution was to manually go through my purchase history and re-purchase all the apps. Let me assure you this is boring, so I gave up after re-purchasing about 5 apps.

In the meantime, I decided to clean out my music folder. It was then I struck the goldmine of my old apps. iTunes saves all the downloaded apps in a directory with the extension .ipa. In my case this directory was D:\Users\Brad\Music\iTunes\Mobile Applications. For most people it will be in your My Music folder, then iTunes\Mobile Applications.

Simply click each .ipl and the app will be added back to iTunes. One sync and you should be golden.

, , Hide

Mar/10

15

Steve’s Wedding Chapel

Apparently our dev team gets angry if weddings are mentioned. Don’t believe me? Well let me explain.

In February and March 2008 I took some time off to visit Australia as I was going to attend a few weddings. On my return my desk had been covered in aluminium foil. Actually, to say my desk had been covered in al-foil is a massive understatement. Everything had been wrapped up – the Weetabix in my cereal box, all the loose change in my drawer, the drawer itself, the pens, pen lids and so on.

Desk covered in al-foil

My desk covered in al-foil March 2008

The pictures don’t fully do it justice, but you get the idea. It took me about a week to unwrap everything, and even now, over 2 years later, I still have my monitor stand and a bowl on my desk as a tribute to the 3 weeks of effort the dev team put in. It was truly epic. I was convinced that this would be the best office prank I would ever see…..

So recently one of our engineers, Steven, took 2 weeks of annual leave. When he was asked why the reply was “just for a holiday and a ski trip” or something similar. He forgot to mention it was for his wedding and honeymoon. Needless to say this riled up the dev team again, and a plan was formed. This one had to be be more epic than the al-foil prank and by a long way.

A group meeting was organised and the details fleshed out. This time construction would be required; we were going to build a wedding chapel on his desk.

Work got under way and even from the start this was going to be huge, so big in fact that wood, nails and tape would be required. We had the frame done by the end of the first week, which was a good start. I was then off to go snowboarding for a week, so that is where I left the project. I had no idea the result be be so grand.

The frame being built here by Jason and Greg

On my return I was greeted with the same sight as Steven when he arrived on Monday morning. A huge 10 foot tall chapel on his desk complete with:

  • bell tower
  • fresco ceiling with flying spagetti monster artwork
  • red carpet for his chair and keyboard
  • wedding music from a gift card that plays when his mouse is moved
  • illuminated signs for ‘Steve’s Wedding Chapel’
  • internal fairy lights
  • wedding car cans on his chair
  • blinkbox-themed stained glass windows
  • custom Slogfather artwork made from one of the wedding pictures (Steven’s last name is Sloggett)

and the list goes on. I’ll let the pictures to the rest of the talking, however Jodie has more info on the chapel construction here.

The view from my desk

Front view with stained glass window

Office gathers around to give Steve a wedding gift

The Slogfather poster

Chapel Sign - usually illuminated

The Spagetti Monster Fresco

Hide

I was at a loose end a few weekends ago and thought that I would build myself a little Roulette simulation and give one of the most well known betting strategies a go, the Martingale. The principle of the Martingale is that you double your bet if you lose, and then reset back to your starting bet if you win.

The theory is that you will always win back your losses once you have a win. For example; using a starting bet of 1 and having 3 losses before a win the bets would be: 1 (loss) + 2 (loss) + 4 (loss) results in a total loss of 7. The next bet should be 8 to recover the losses. As it turns out for every win you increase your pot by one, regardless of the number of losses. It sounds perfect on the surface, but can it really work?

It is commonly cited that the casino would have a limit on the table, resulting in a hypothetical punter eventually not being able to bet the required amount to get back all the losses after a large losing streak, even if they had the funds available. With a large number of gambling sites online I thought that there is a possibility that you may be able to find a venue willing to take even a large bet, hence I excluded this constraint from the testing. As it turns out it is very hard to make the system work even with some basic real world constraints, such as credit limits.

In fact if we were to change the multiplication from a factor of 2 to a factor of 3 (1,3,9,27, 81 etc), or a factor of 10 (1, 10, 100, 1000) the theory would still work and possibly the wins would be greater. A win after 3 losses would net 14 from a cost of 13 using a factor of 3, and 889 from a cost of 111 for a factor of 10. As such I though these higher factors should also be investigated as I had not read about people trying to use them.

Firstly, lets start with the ideal case. I have used a simulation of European Roulette, where the table only has one house spot (a single zero), as opposed to American Roulette, which has two house spots (zero and double zero). This would help tip it even further in favour of the punter. Each one of the graphs below represents a typical run, however, each simulation would vary quite a bit.

Simulation of 1000 Roulette games - Martingale Strategy

1000 Games of Roulette - Martingale strategy with no external rules.

After playing 1000 games using no real world constraints we can see that in fact the punter has come out on top. The final amount won was in fact 471, which is quite close to what a statistical model would predict (one unit for each win, with an overall probability of around 0.47). The big issue is that in order to get to that level there were 3 occasions where very large losses had been incurred, putting the punter well in the red. In this specific simulation over 8000 was risked on one losing streak, while already 8000 in the red. This is only for an end payout of 471 – not a good risk in my books.

Martingale when only small bets are allowed once in debt

Martingale - only small bets are allowed once in debt shows a loss overall

If we make it so the punter can only make single unit bets once they are in the red then we see how the picture changes – after only a few games the punter has blown their reserve cash trying to win it all back. From there it is a constant downhill spiral. This is not quite realistic, generally a player would go in with a larger reserve.

Martingale simulation - no debt allowed with 100 starting cash

No debt allowed and 100 starting cash.

Updating the simulation to allow for a starting kitty of 100 we see that for a while the punter is doing well, however, as soon as there is a run of 6 losses the game is over. In fact, compared to no starting cash the player is actually worse off by about 90 units for this simulation.

At this point I thought it might be worth looking into using higher multiplication factors to see if the situation could be improved. My initial suspicions were that while the wins would be greater, so would the losses. I couldn’t quite get my head around the idea that perhaps if the multiplication was larger than Euler’s number (2.71828) then perhaps something magical would happen regarding exponential growth. It didn’t, so at least I proved something to myself with this experiment.

Triple up each time - Martingale

Triple up each losing bet - no limits

Tripling up showed some interesting results – in this case we have had to bet over 28000 for a final payout of around 19000. The numbers are larger, however, so is the risk. Some simulations have very large losing streaks resulting in any real player being long since wiped out. The situation is much the same when multiplying each loss by 10.

Martingale multiply by ten

Multiply by 10 each loss - no limits

Wow, almost one billion made after only 500 games! Unfortunately, the bet was over one billion so the chances of any normal person getting a loan to cover a bet like that are, well, small.

I did not stop simulating there, trying all sorts of combinations using different numbers and different strategies. Nothing would work in the long run while some reasonable real life constraints were placed on the simulation. This is not a surprise result, as Einstein apparently once said: “No one can possibly win at roulette unless he steals money from the table while the croupier isn’t looking”. Nonetheless, it was still an interesting exercise.

Hide

Recently blinkbox pushed a new release of the site onto the live environment which adds a number of quite cool features that we have been working on over the last few months. As the UI lead engineer I’m quite excited by these so I thought I would share.

Perhaps my favourite change is that now any of the free movies or TV icons have a ‘Free’ overlay applied to them automatically. This is great at calling out how much free content we have, which is actually quite a lot now (loving the snowboarding titles we have)! We also are using the same system for showing off trailers, in case you notice the similarity. Additionally for trailer titles we also show the date they are to be released in the cinemas, or if they are currently showing, underneath the player (for example Avatar).

Free titles shown with a blue overlay

Free titles shown with a blue overlay

For those wanting more than free content we have a number of improvements for purchasing our premium content. Firstly the browse catalogue now supports price filters, which is quite handy for finding cheap flicks. Secondly we now have box sets and bundles – so you can buy a whole TV season or a movie bundle (Godfather Trilogy perhaps?). And lastly we are now securely storing credit card details for repeat purchases, much like Amazon. Using this I think you can go from browsing to watching in under a minute if the title is available for streaming – which is much quicker than trekking to the local rental store.

We have also updated the Games area and added a new video jigsaw. This is good fun on the easy a medium skills, although the hard setting can take a little while – you’ve been warned. All the current competitions are now listed on a dedicated competition page for all the competition junkies.

Last but by no means least is the member referral system – pass on your invite code after a purchase and you’ll get £1, while your mates will get £5 credit each! That is more than enough for even the latest rentals. I think this is a great deal for everyone so get it while it’s hot.

, , Hide

Recently I have been investigating the web capabilities of the Playstation 3 NetFront browser, and for the most part it works as expected. There are a few caveats however, and in my case this was enough to prevent the Prototype JavaScript library from loading. So far I have discovered the following issues:

  • Ajax works, however it will only do a GET request – POST returns immediately with no data supplied.
  • General browser model most closely follows Internet Explorer, however the accessors for the CSS opacity is like other browsers (Mozilla).
  • Currently can’t read the opacity, gives a value of 1.0 always.
  • Can’t fire custom events as the method for creating an event does not work (document.createEventObject).
  • Since there are no custom events some functions do not work, such as Prototype’s document.observe('dom:loaded').

The event firing issue is a bit of a nasty one if you rely on custom event for updating page elements. To work around Prototype’s dom:loaded issue I have added a new method: Event.domLoaded(), that takes a function and stores it in an array. Once the DOM is ready the array is iterated through and each function is called. I have also enhanced the method to call the function parameter if the DOM has already been marked as ready, thereby preventing race conditions caused by a delayed function call. In other words it makes it safe to register a function to be called as soon as possible, regardless of the present state of the page.

I have uploaded an updated version of Prototype with the fixes applied – download here. Let me know if there are any issues.

, Hide

I received a call from my uncle Bruce 2 days ago – after saying hello I was greeted a friendly yet frantic “I’m in big trouble Brad, my computer has been hacked!”. After getting most of the details of what happened and realising that it was quite unlikely any bank details or other highly confidential details were compromised I arranged to leave work early and see what we could do.

While I spend a considerably amount of my time at work making sure our website is secure I had yet to personally have experienced the wrath of an online scammer. I was intrigued to say the least. Once I arrived we scoped out the problem – one of my uncle’s email accounts had been compromised when he inadvertently tricked into giving away his password. After reviewing the situation it was quite a simple mistake to make, as they had impersonated his email provider in a similar nature to previous contact he had regarding setting his BlackBerry.

It was quite interesting to see how the scammers work. They seemed to have a limited interest in trying to get money out of my uncle directly; they were more interested in trying to impersonate him. By using a line similar to: “I’m stuck in Africa at an art fair with no money, please can you send me £500 so I can get back” they actually managed to get about 3-4 responses from friends offering to help. I’m fairly sure they will also sell entire contact list to spammers for a reasonable fee.

After trying some common techniques for re-enabling access to his account we hit a wall. The scammers had changed all the details required to change an account, such as the alternate email address and secret question. Lucky for Bruce he had his email account linked to his BlackBerry. This they key we needed: by sending a password reset email back to the same address we were able to forward the email to another temporary email address and then follow the usual password reset steps. I say we used a temporary email as there was a chance that this wasn’t going to work, hence we didn’t want the scammer to be aware of another email address, should he check the sent items.

During the password reset process we were asked to provide country information. The scammer would have been asked the same question and it would appear that this is checked against a geo-ip database, hence they were forced to put in a reasonable location of Senegal. They may have been in a surrounding country and were exploiting the errors in the geo-ip database, however the general region seems correct based on the information provided when they were asking for money.

So this makes me ask the question – why can’t we lock our email accounts, such that it is only accessible from certain regions. Banks have this feature for credit cards, and even if they do get a bit over zealous sometimes and block my card while I’m on holiday, it is still a good system. It is my opinion that the leading webmail providers should include an option so that any access from unauthorised regions should be blocked – or at least prevented from making system changes.

For example in my case I would like to restrict access to Europe, North America, Australasia and possibly the Middle East (Another trip to Dubai would be nice!). Additionally I could state that changes to my account may only be done from the UK and Australia. Should I urgently need to make a change there are family and friends that I could call to make the change on my behalf, or simply use a VPN to gain access via a local ISP.

I would also like to be clear that this would be on a per account basis. I would not like to suggest that we block key internet services from developing countries, as that would surely result in even more hardship for the honest citizens of these regions. The system would not be perfect due to the limitations of GeoIP, however it would have most likely protected my uncle seeing as the hack seems to have originated from a place he has not visited.

Hide

Since I now catch the train to work instead of riding my Ducati or bicycle I have a bit of extra time in the mornings and nights. I had thought about reading on the trip but so far I have a better toy – iPhone gaming. Maybe a Kindle for Christmas will peak my enthusiasm for reading, so I’ll wait for that.

In the meantime I’ve become addicted to the Doom port for the iPhone. This has only happened in the last couple of days after a recommendation from a colleague. My previous addictive game was GeoDefence Swarm, which I would highly recommend, although that will have to take a back seat to Doom for the time being.

I’ve played quite a lot of Doom in my time, although almost all of it was either single player with God mode on, or Deathmatches with guys from school over our 14.4kbps modems (the good old days of init strings). The iPhone port has actually got me playing the single player game properly for the first time ever – 16 years after it’s initial release.

Doom iPhone - Enhanced controls while screen is on

Doom iPhone - Enhanced controls while screen is on

Doom iPhone - Markers highlighted with flash

Doom iPhone - Markers highlighted with flash

Perhaps the biggest issue with the game is the control system, the touch screen is quite hard to use at first. After playing most of episode 1 (8 levels) I have added something that is quite useful. The biggest problem with the control system is not the responsiveness, it is the lack of any markings on the screen that help your fingers back to the centre points of each control area. I experimented with Blu-Tack, and while it worked ok my fingers would get caught up if I applied to much pressure. It would also obstruct the screen when not playing Doom.

I went to my local phone mobile phone store and picked up a cheap iPhone screen protector for £3. These generally come with cut out sections for the ear piece and the home button. These two parts are actually almost the perfect shape for each of the control areas when using the “Ultimate” control scheme – the left area requires a rectangular shape, while the right requires a circular disk. Placing these in the correct area results in subtle raised ridges that enhance the controls considerably.

The great thing about this solution is there is no chance of damaging the phone, and then when your bored of Doom simply peel off the stickers. If you are worried about the stickers coming off prematurely simply place the full screen protector over the top, which will firmly hold them in place without effecting much else. For such a cheap price so far this is working well, hopefully it will help me get through the Shores of Hell :)

, Hide

While updating the visual design of blinkbox.com a few months back we noticed something wasn’t right in IE7 – the performance was terrible. IE 7 has been around a lot longer than many of the other browsers we currently support in our level 1 tier, and is starting to show its signs of age.

The problem manifested itself mainly as a one second or more delay when hovering over images. Typically this would be a trivial operation for a browser, as it was simply applying the :hover classes for the element.

A bug was raised and I started the investigation by checking the usual culprits, such as incorrect binding of javascript events, HTML issues, CSS selectors that had run wild, and so on. A search on Google yielded no usable results that helped, either. Since none of these had improved the performance of the page, I started to get a bit more aggressive with my bug hunting.

I removed all the images from the page and this worked, although that wasn’t a solution that we could use. After carefully working through it, it turned out to be an issue with only the background images that we were using.

Now there was nothing really special about the background images, just simple PNGs, 1 pixel wide with repeat-x on them, which are then used to form a gradient. Standard stuff for a web page.

Notice the hover state on the Fast and Furious icon - that was were it was most noticable.

Notice the hover state on the Fast and Furious icon - that was where it was most noticable.

Technically, all of our gradients are bundled together into one image and then positioned using CSS, so I checked to see if that was the cause of the problem. One of the options of our image bundling system is the ability to have the images split up and served as separate files. After giving that a go it was apparent that it had no effect.

My next thought was that perhaps the number of repeating images were to blame. I made a quick check by disabling the repeat-x, and the site started running like normal. Realising that this was the issue I used the gradient generator to output wider images (20px), and voilà, the performance issues were sorted for good. So, if you are going to use a lot of gradients, and would like to keep your site running smoothly, then make sure they are more than 1px wide, as IE7 just can’t handle it.

*Of note blinkbox.com uses over 4ooo pixels of vertical gradients site wide, so this might be an extreme case :)

, , Hide