Archive

Author Archive

First forays into iPhone development

July 10th, 2009 edlong No comments

Hi,

I’ve just started looking into beginning development on the iPhone. Coming from C++, Objective-C seems a strange and foreign language and so I’ve been looking for useful tutorials online. The best I’ve found so far is a Stanford course that is available on iTunes U. Seems to be a very well put together course taught by Apple developers. I’ve looked at one lecture so far but was impressed.

Check it out

Stanford Lectures on Cocoa Programming

Other handy resources are:

iPhone dev blog
More tutorials

Let me know if anyone knows of other good tutorials.

Categories: Uncategorized Tags:

Using a single number to contain two other numbers

July 3rd, 2009 edlong No comments

Hi,

Due to a certain restrictive pattern being used at work, I’ve recently had the need to pass along two numbers but only had a single number to do so. It’s a bit of a nasty hack but is my first experience with using bit masking and is a useful technique. The integer being used in the pattern was an unsigned 32 bit integer and the two other integers I wanted to pass along were both unsigned 8 bit integers. The way we figured to send along the two numbers is to basically use half of the 32 bit integer to contain the two 8 bit integers using masking. The process is very simple there are two functions, Encode and Decode. Encode takes in two integers (I’ve made them unsigned 16 bits for the moment but you can easily cast the 8 bit unsigned integer to 16 bit) and returns a 32 bit unsigned int that contains the two. The encode function basically shifts the iFirstNumber into the lower 16 bits of the 32 bit integer. Then iSecondNumber is added to this to give a full 32 bit number.

uint32 Encode(const uint16 iFirstNumber, const uint16 iSecondNumber)
{
	uint32 iEncodedValue((iFirstNumber<< 16) + iSecondNumber);

	return iEncodedValue;
}

To explain it a little clearer suppose we have iFirstNumber set to 3 (0x00000011) and iSecondNumber set to 1 (0x00000001) we would end up with the encoded value being 0x0000001100000001

You can see that the first 16 bits contain iFirstNumber and the second 16 bits contain the second.

To get the two numbers back out again we have a similar Decode function:

void Decode(uint32 iValue, uint16& iFirstNumber, uint16& iSecondNumber)
{
	iFirstNumber = (uint16)((iValue & 0xFFFF0000) >> 16);
	iSecondNumber= (uint16)(iValue & 0x0000FFFF);
}

The first number is the overall value ANDed with 0xFFFF0000 and then shifted 16 bits to the right. ANDing the number with 0xFFFF0000 indicates that we are only interested in the first half of the bits in the overall value. It will turn all the rest of the bits in the value to be 0000000000. So after that we will be left with 0x0000001100000000. Now we need to narrow the number down to a 16 bit number. To do this we shift the bits 16 places to the right and cast to a uint16. Casting will remove the proceeding 16 bits(which are all now 0 anyway) and leave us with 0x00000011 which translates to 3.
For iSecondPosition we say that we want only the last half of the bits in the overall value. This leaves us with 0x0000000000000001. Casting this to a uint16 will leave us with 0x00000001 or 1.

In the end we actually didn't need to do it this way but got it working anyhow. Might be handy for someone maybe!

Categories: C/C++ Tags:

Champ Man preview

June 22nd, 2009 edlong No comments

Hi all,

Really sorry I haven’t blogged in a while, I’ve found it tough with work commitments and just not being motivated enough recently to do in my spare time! I’m going to try and get it all going again soon.

Edit: We’ve just announced the release date and a special new feature, CM Season Live:

http://www.championshipmanager.co.uk/server/show/ConWebDoc.918?PHPSESSID=a23581a233622d5e50d1dfbc20cabc14

http://www.championshipmanager.co.uk/server/show/ConWebDoc.917?PHPSESSID=a23581a233622d5e50d1dfbc20cabc14

In the meanwhile here a couple of previews of the game on GameReactor.

http://gamereactor.co.uk/grtv/?id=4194

http://gamereactor.co.uk/grtv/?id=4210

Categories: General Tags:

Convert UIF to ISO

April 23rd, 2009 edlong No comments

Hi,

I recently had a UIF image that I didn’t really know how to mount. After some digging I found that it seems to mount only with MagicISO, a Windows only application.

However there is a nifty little converter that converts from UIF to ISO which can then be mounted, burned etc.

Check it out at http://vafer.org/projects/uif2iso4mac/.

Categories: Mac Tags:

Turning off Macbook screen when displaying through TV using a DVI adapter

March 28th, 2009 edlong 2 comments

Hi,

I’ve recently picked up a nice big TV and doing quite a bit of streaming from my laptop through the TV. However one this that has annoyed me is that the display on my Macbook Pro stays on all the time even when the primary display is the TV. After searching around for a little bit I found this work-around. It only really works well however if you have a remote.

Basically you hook up the TV using a DVI adapter and go into display preferences. Go into the ‘Arrangement’ tab and you’ll see two blue boxes. One of those boxes will have a narrow white rectangle on the top of it. Drag this rectangle over to the TV(i.e. the opposite to the one it is on already) and close the preferences pane. Start up FrontRow and it will automatically turn off the secondary display (now the MBP screen) and you can watch TV without having the secondary display annoying you.

Link to detailed explanation.

Categories: Mac Tags:

Adding favicons to your site

March 28th, 2009 edlong No comments

Hi,

After moving my site over to my new host I did a couple of little jobs on it. The first thing I did was to sort out some of the 404s that I’ve been getting. One of those is that my site is missing a favicon. A favicon is the little icon that is displayed on Firefox tabs or next to the URL in Firefox. IE also supports it. It is a 16×16 image that needs to be saved as a ‘.ico’ file. Photoshop doesn’t export to this format natively but there is a free plugin available for it at the Telegraphics site. Once I created a simple image I exported it and FTP’ed it into the webroot of my site. I then edited my skin header and within the head tags I added the following lines of html:




The extra couple of lines are to satisfy IE’s oddities.
You can also use png or even gifs for this but if you don’t use the ico format IE doesn’t play nice.

Once thats been done you should be ready to go. Most browsers won’t show the icon unless you clear your cache and restart your browser, IE6 won’t display it unless you actually add the site to your favourites.

Safari also has some problems. Emptying the cache in the regular fashion won’t clear the favicons. You need to go to the ‘Edit’ menu and select Reset Safari. Check Remove all website icons. If this doesn’t work, quit safari and you’ll have to manually clear them by going to User/Library/Safari/Icons and in Windows C:\Documents and Settings\YourUserName\Local Settings\Application Data\Apple Computer\Safari\WebpageIcons.db.

You may see the little grey ‘EL’ icon that II now have on my site, that’s it!

Categories: HTML Tags:

Lots of new posts

March 24th, 2009 edlong No comments

Hi,

For anyone following a feed of the site, sorry about all the new posts!

I’ve had to repost a lot of older archived posts as I completely lost my wordpress database and have been trawling through the Google cache and entering them again.

Categories: General Tags:

Google Apps, HFSExplorer, Ajax modal window

March 24th, 2009 edlong No comments

Hi,

I’ve recently upgraded to Google Apps for my site. It allows me to use Google Mail for my own personal site and I can use all the Google Documents, Spreadsheets and the rest of their free applications. I just had to modify my MX records for my site to point at Googles MX server(which takes a while to go through). Check it out if you’re a webmaster, I was previously using SquirrelMail so using Gmail is a massive improvement!

http://www.google.com/a/help/intl/en/admins/editions.html

Recently when I booted up into the Windows XP partition using bootcamp of the Intel Mac I’m using I needed to access the files on the Leopard OSX partition of the hard-drive. After looking around for a bit I found HFSExplorer which can read from a HFS partition(i.e. Mac OS filesystem) and copy from it if needed. It is read-only though which is a bit of a bummer but is open-source and worked pretty well when I used it.

I see that bots have cracked both Gmail and Hotmail Live’s captcha methods. Not only that but did it in 60 seconds, very impressive. Read about it here and more in depth here.

I’ve also been playing around with some Ajax stuff recently. I had to make a modal window that contains a form, the form set a session variable that is set just once for a user’s session. I looked around for a bit, tried a few samples and found Control Modal which is a pretty lightweight, easy to use Modal window Ajax API built on top of Prototype. Check out the demos and grab a version at the Control Modal site. Below is some code I wrote to place the form in the Modal window.


Select an option


Note: Took us ages to figure that onclick was the right Prototype JS event to fire the click event, we were previously using click() but it wasn’t working. So now when the page loads a dom loaded event is triggered which then goes and creates a click event on the modal_link_one id which creates the Ajax modal window.

Categories: Archive Post, Mac, Prototype Tags:

No SVN icons with Aptana Studio/Eclipse

March 24th, 2009 edlong No comments

I had a strange problem with Aptana Studio for the last week. I have Subclipse installed as a plugin and previously all my icons appeared fine, all the repository information showed up. I was able to perform Update and all the other typical SVN commands. However in the last week all the icons disappeared and were replaced by question marks. Nothing had appeared to have changed so I was confused with it! Aptana had previously performed an update so I decided to uninstall it and re-installed Aptana, same problem. I uninstalled it again and put in Eclipse but same problem. Finally after fishing around a bit I saw that my workspace directory i.e. ~/Sites/ had an .svn directory in it. I had no idea why it was there so I deleted it and the subdirectories, restarted Aptana and all the icons showed up agan! I’ve no idea how it got in to begin with but I’ve seen it again since on a Ubuntu machine so its not just me!

I needed a command to see what packages were installed in Ubuntu, found this after a little searching:

    dpkg –get-selections

Does the job nicely.

Categories: Archive Post, Linux, Mac Tags:

Ajax forays

March 24th, 2009 edlong No comments

I’ve began playing with Ajax for the first time in the last week. I wanted to load up a page and display it within the current page. So I decided to use an Ajax request to get the page but I also needed to pass in some parameters to this page from a form on the current page. After spending a bit of time messing around trying to convert the parameters and pass them in through the url of the request, Michael Sharman who I work with showed me a nice Prototype function serialize(). This takes in a form element and converts it to a string of parameters e.g. id=4&class=five&test=yes. It can also convert to form to key value pairs but I didn’t need that at the time. I then just called the page like so:

var ajax = Ajax.Update('myDiv','test.cfm',{method:'get',params:$('myFormID').serialize(true)});

This places the content from the ajax request into the div of id ‘myDiv’.
The funny thing is that I had used the request to place the div within a form which was then submitted but the content obtained from the Ajax request doesn’t seem to register with the DOM and didn’t appear when the form was submitted.

So I had

So the div within the form would be filled from the Ajax request but when the form was submitted and the form variable dumped, the div elements wouldn’t show up even though they are inputs, selects etc.
I wonder is there a way to register content got from an Ajax call with the DOM?

Turns out what I was doing was quite stupid idea anyway and was better suited to a CF custom tag so I did that instead but would be interested in the solution.

I was getting a lot of spam on certain WordPress posts in the last couple of weeks. You may remember the problem I was having the stylesheet a few weeks back and my solution was to let unregistered users to post. An unregistered user only needed to enter their username and comment and that was it. Obviously this meant it was vulnerable to spamming and indeed I was moderating about 10 posts a day and marking them as spam. Getting annoyed with having to do this I looked around for free captchas for WordPress and found this site - http://www.protectwebform.com/plugin_wordpress. You need to register which is a bummer but after following the steps it seems to be working nicely after one day, no more spam :)

Categories: Archive Post, Javascript Tags: