Patched Simple Facebook Like for WordPress

I am adding a Facebook Like button to the blog posts at work and so I looked for a WordPress plugin. The highest rated one I found is called Simple Facebook Like by a guy named Huseyin Berberoglu.

I had a bit of a problem getting the button to go where I wanted because the iframe that gets added to the page doesn’t have an ID or a class for me to address it by. I modified the source to stick in a class quickly and easily and dropped a comment on the guy’s blog to see if he would add it as an option for the plugin so future versions wouldn’t overwrite my change, and then I decided that I would just do it myself.

So I created a patch that can be applied to version 1.0.1 to let you specify a class for the iframe so you can use CSS to move it around more easily.

Browser frustrations

Earlier on I was writing some code that inserted some text into a textarea on a webpage. After the text has been inserted I needed the cursor to be at the end of the textarea so that the user could then type more text in afterwards without any messing around.

I thought it would be a simple matter, but it turned out to be quite frustrating.

Needed for all
var t = document.getElementById('add-comment');

Gecko (Firefox, Mozilla, etc.)

Webkit (Chrome, Safari, etc.)

Internet Explorer
t.setSelectionRange(t.value.length, t.value.length);

Is there some standard way of doing this that I’m unaware of? I think jQuery would be overkill for this one purpose.

jQuery Form failure

I’ve used the jQuery form plugin a few times before, but today I ran into an error I’d not seen before that took a few minutes to solve. I started out by searching Google, but couldn’t find the solution, so I’m writing it here in the hope of helping others in my unfortunate situation. πŸ™‚

The error was caused in jquery-1.3.2.min.js and went like this: (E || "").replace is not a function

I upgraded to jQuery 1.4.2 uncompressed and found that the same thing happened, but with a more helpful message: return (text || "").replace( rtrim, "" ); is not a function

I opened up jquery.form.js and did a quick search for ‘trim‘ and it only returned one result: var url = $.trim(this.attr('action'));

This is when I realised that my form had no action attribute, which is bad HTML even though fairly consistent browser behaviour is to submit to the current page.

Once I added the attribute to my form it all worked as expected. I’ve written a patch for the jquery.form.js file that I’ll submit to the developer in a couple of minutes. πŸ™‚

Remote Recorder, again

I’ve been spending quite a bit of time working on the next version of Remote Recorder (my Android app for recording TV programmes with Sky+). I’ve listened to a lot of feedback and the main thing requested by people was the availability of listings for TV channels, rather than just a search interface. When I originally made the app I just wanted to be able to search, so I made it just for myself. That’s no longer the case though, as there are quite a few users of the app, and that number is growing every day.

So I have spent quite a bit of time looking at how best to implement this feature and the video below is what I’ve come up with. Keep in mind that it’s incomplete, and excuse the elevator music πŸ™‚

So yeah, that’s the basics of how it will work. There will be some minor differences that I have in mind, like the ability to filter the channels/programmes by typing the name into the box at the top. This next version should go a long way towards making Remote Recorder a much more stable and usable Android app. πŸ™‚

Oh yeah, I also registered a domain name: Remote Recorder. πŸ˜€

Cash Gordon sucks

Just been looking at the Cash Gordon website and decided it’s not very good. Thought I’d share that with you all. πŸ™‚

More info
I just thought I’d take a second to explain this post… The Conservative Party put up a website that I’m not going to bother linking to that had a Twitter stream of all posts with a certain hashtag. They had no filtering of content, and no sanitising either. All HTML and Javascript got rendered directly on their page.

Cue carnage. People posted massive pictures, huge text, and a few people (myself included) posted Javascript redicrects to various other sites around the Internet.

The site appears to be down now. Whether that’s on purpose by the sysadmin team in the data centre, or because of a DDoS I don’t know. I guess it won’t be coming back up in its original form though. πŸ™‚

Google Analytics data:
Cash Gordon Google Analytics data

It was fun while it lasted.

Pulitzer prize for a Twitter user

I am predicting that in the next year or two there will be a winner of a Pulitzer prize based on their Twitter updates. After doing some real research I have decided that the award given will probably be in the journalism section, using the following criterion:

“For a distinguished example of local reporting of breaking news, with special emphasis on the speed and accuracy of initial coverage, presented in print or online or both” from the PDF linked to above.

It’s pretty much got to happen, right? That whole criterion sounds like it was written specifically for Twitter.

Sky Broadband ADSL username/password hardware lock-in

NOTE:Β This post is very outdated. I’m no longer sure that the instructions would be correct, and the sites I linked to seem to be down now. I have modified the link to point to an archived copy of the page.

β€”Stu, 2016-12-24

I’ve been a satisfied customer of Sky Broadband for the last couple of years now. The router/modem you get sent is usually either rebranded Netgear or Sagem hardware, which is good. The problem with this hardware is that Sky modify it in such a way that they hardcode the username and password for the actual ADSL connection, and never reveal it to the users.

The other week my router decided not to work any more. Luckily I had a spare that my dad bought on eBay for Β£1 once. I plugged it in and that’s when I realised I didn’t have to enter any details to connect. Very strange. I contacted Sky to get a replacement router and I never got it. It was delivered to me, but I never went to fetch it from the Post Office because I thought I’d be fine with the spare. I regretted that decision last week when the spare died on me too. I now suspect a faulty power cable, for both to die in such a short time.

I contacted Sky and asked them to resend another one so I could connect again. I still hadn’t heard anything back from them by today, and I was getting bored, and fed up of using 3G on my phone for everything, so I went to Argos and bought myself a nice new Linksys router.

After I’d plugged it in I was prompted for a username and password for the ADSL. I typed in my user details as they were the only details I thought would be even close to correct, even though I doubted that. When it didn’t work I did a little bit of a search from my phone and found lots of people with the same problem.

I decided to call Sky Broadband technical support to see if they could give me the information I needed to connect. I spoke to a very nice man on the other end of the phone who didn’t really have a clue what I was talking about. He kept saying that Sky can’t offer support for other routers, and I kept saying that I understand how a router works and I just needed my ADSL username and password. Eventually he said there was absolutely no way of him finding out any details that I could use to connect, and that by not using a Sky router I’d be breaking the terms and services. I told him that was ridiculous.

I then complained about ordering a router last week and not having heard anything back. He put me on hold and got one dispatched for me right away. Why had I been waiting so long if it only takes a couple of seconds?

After hanging up I did a bit more searching online and discovered that there way to find your login details is actually very basic. As long as you still have a Sky router/modem around somewhere you can use the details on the label printed on the bottom to generate the same details on this extremely useful website.

I entered the details for one of my Sky routers on the site, then entered the generated details on my Linksys configuration page and everything worked perfectly! πŸ™‚ I now have a working Sky Broadband Internet connection with a non-crippled router.

The only reason I can think of for this whole setup is to prevent Sky from getting support calls for problems that are nothing to do with their hardware from people who don’t know what they’re doing. This is fine for most people, but they shouldn’t be forcing people to use only their equipment. Sky should have a way of generating a username and password for users of non-Sky-branded routers, and they should provide them to customers who call and request them. It wouldn’t be that hard, and the people who would buy another router and configure it themselves are the people who are intelligent enough not to call Sky when something goes wrong with their Belkin router.

Sky Remote Recorder update for Android

I made some changes to my Sky remote record app for Android available on the market today. The changes are fairly basic, and are mostly there to make the user experience a bit better.

For example, if your recording fails then you receive a screen where you can choose to test your login details on Sky’s website to make sure you’ve got them correct, you can also view the help on my site, or open the preferences to change your username and/or password.

The update will make it much easier for people to be sure their details are correct and solve any problems they may encounter when setting up remote record requests with Sky.

Bring It! – Getting started

To begin developing my game I downloaded the latest Android SDK and set up Eclipse as explained in great (and hopefully up-to-date) detail on Google’s instructions page.

Once this was working I got the latest version of the Rokon game engine and extracted it into my workspace folder. I imported the existing project into Eclipse and added my own class to the list. I copied one of the examples into my own class and then removed the com.rokon.examples class and files. I changed all references of the com.rokon.examples class to my own class in files like the AndroidManifest.xml file. I missed a few places at first, but Eclipse is pretty good at telling you what’s wrong. I found it helpful to clean the project using the Project->Clean menu item to make sure no errors were left over from before certain changes.

Once I had eradicated all errors from Eclipse I ran the source in an Android Virtual Device. To my immense surprise it was working!

I went into the code and started to strip out all the bits I didn’t want. I kept one sprite around, but changed the sprite texture to my own arrow, and made it considerably smaller.

That was all pretty easy, and I thought things were going to well until I realised that I now needed to get down to the harder stuff. The user would need to aim in different directions from one point, so I needed a way for the person to change the angle. My first thought was to use the scroll ball that appears on most HTC devices these days. I thought that might be a bit of a problem though, because I was planning on using the scroll ball press as the trigger, and that might lead to people accidentally pressing it when they didn’t want to.

I decided that it would be cool to have the character point towards where the user pressed on the screen. The problem with that is that code is required to work out what angle to rotate the character by depending on where the character is, and where the player has pressed on the screen. I managed to find various little bits and pieces online that helped me come up with a decent solution.

That looks very complicated, but it’s not that bad, really. The angle is worked out using the position of the centre of the sprite and the position of the press on the screen. I’d explain it in more detail, but that might take a while. You may notice the +90 near the end of the rotation line. Unfortunately that’s a bit of a hack to add 90 degrees of rotation to whatever angle is given to me. It works, so I’m fine with that for now.

Now when I run the “game” I see an arrow on the screen. If I press on the screen then the arrow points at where I pressed. If I move my finger while it’s pressed then the arrow follows my finger around. A good start to coding the actual character.

Now to climb the rest of the mountain!