Little Red Riding Hood – In C#

Tonight, I was bored. Seriously, it was either this or watching the Eurovision song contest. Sadly, with BBC iPlayer, I was able to do both.

I’ve decided that when I have kids, they’re going to know how to use computers and learn how to program (I can wish).

So, I’ve rewritten the story of Little Red Riding Hood. This time it’s in C#. I have no idea why I decided I would do this – by the time I’d realised, it was too late

So if you want to tell your kids a bedtime story whilst edging them into becoming programmers, read on.

Read More

Getting a list of numbers between two values

This is yet another extension.

I don’t like Enumerable.Range() for the sole reason you have to give a start index and a count. So I made up my own. This is an extension for an integer type and will allow you to specify two values that you want a range for

public static IEnumerable<int> RangeTo(this int startValue, int endValue, int step)
{
	return (endValue < startValue) ?
		Enumerable.Range(endValue, startValue - endValue + 1).Reverse() :
		Enumerable.Range(startValue, endValue - startValue + 1);
}

This will also allow for reverse lists – see how to use it below:

1.RangeTo(10);  // {1,2,3,4,5,6,7,8,9,10}
5.RangeTo(10);  // {5,6,7,8,9,10}
10.RangeTo(5);  // {10,9,8,7,6,5}
3.RangeTo(3);   // {3}

int x = 15;
int y = 17;
x.RangeTo(10);  // {15,14,13,12,11,10}
y.RangeTo(x);  // {17,16,15}
x.RangeTo(y);  // {15,16,17}
13.RangeTo(x); // {13,14,15}

Random sort on IEnumerable object

Quick extension on an IEnumerable object to return the collection in a random order:

public static IEnumerable<T> Random<T>(this IEnumerable<T> source)
{
	return source.OrderBy(x => Guid.NewGuid());
}

For example, to return a random set of 5 items from the collection:

var randomSet = myEnumerable.Random().Take(5);

If anyone knows of a better way, let me know :)

Howdy 2010

It’s been nearly a year since I posted anything and, since then, I’ve grown sick of my current Word Press theme so I’ve installed this nice little theme for the mean time. I might design my own (a nice one) but for the moment this one will do.

Since last time:

  • I graduated
  • I got a job here in York
  • I’m still here

So yup – that’s my exciting life. I’ve been playing with .NET 3.5 (and poking my nose into .NET 4 recently) so I’ll probably have a thing or two to say about that.

Well that’s annoying – O2 and tethering

Like the rest of the world, I now know about the iPhone 3GS. My housemate held off getting an iPhone 3G because he expected something new and better would be released. Everyone expected something.

I wasn’t too bothered because I knew that MMS and tethering would be enabled in the iPhone 3.0 update – so I went ahead and got myself a 24 month iPhone contract with O2 back in April.

I still doesn’t bother me about the upgrade. My iPhone does what I want and that’s fine enough for me. Battery life is suitable for my needs and, although the digital compass is a cool idea, I don’t really mind not having it.

What does bother me is this: Internet Tethering on O2. O2 are charging an absolute fortune to allow me to tether to my iPhone. Stupid, seeing as my current contract allows unlimited data and wifi via The Cloud and Openzone (which, through this I can only see The Cloud).

I probably should know, but I dont, and I’m not sure how they would differentiate against tethering and using my iPhone. Granted, if I started downloading gigabytes of data, some questions could be asked. But for general use – would they be monitoring it? How about if everything was just tunnelled via SSH?

So yes, it will be interesting to see what I can do when I upgrade without needing O2’s permission.

As for MMS messages (yeay! they’re available now), I’m happy to hear that it will come from the text allowance. All that’s needed is to text to a special number on O2 and it get’s set up.

Thankfully, it doesn’t require a rip-off bolt-on to work…

New design – hurrah!

Hurrah! I’ve been reading a bit about HTML5 and creating a wordpress template, so here’s a new design.

I’ve moved from Blogger to using WordPress on my own server. Gives me a little bit more flexibility, but I think it might sacrifice a little on the Google search. Ahh well. One annoying thing in the import/export is that it imported the tags as categories. I’ll sort that out – I was probably just using it wrong.

Hopefully the design works alright – though it might be broken in one or two parts. If anything seems horribly broken, then please let me know. I also plan on playing with a CSS style to make it work nicely on the iPhone too.

[Update: In WordPress, there's a Categories to Tags tool. Woo!]

Dell Mini 9 – Updating the BIOS without Windows or a USB DOS

Recently I bought myself a Dell Mini 9, with Ubuntu installed. It seemed to be great, except the battery didn’t charge (although this fixed itself), from what I read elsewhere, it’s necessary to leave it plugged into the AC for a certain amount of time. There was other tweaking and pressing of buttons but I think that was what did it.

Whilst looking around, I found another problem. There was information about newer versions of the BIOS fixing some battery issues. I had version A00 of the BIOS but, currently, the most recent is version A05 – and Dell only do Windows versions of the flasher.

I don’t have a copy of Windows. I have a Mac Mini, which runs Leopard, and now Ubuntu on this laptop. My previous laptop had a Windows partition, but that had been wiped completely ready for sale and I’m not willing to spend the time reinstalling to create a USB version of DOS.

The options seemed to be:

  • find someone with a Windows machine
  • install a Windows partition on my laptop
  • install Freedos, and do some tweaking so that it runs from USB key.

I found another option though:

  • flash the BIOS, without having to install anything extra or use a USB key.

I’d spotted that there’s a Fat16 partition at the beginning of the hard drive. I mounted this and found that it’s Dell’s diagnostics partition – which runs under DOS. It seemed promising. So I renamed the AUTOEXEC.BAT file, so it would just load to a command line, and changed the grub menu on my Ubuntu filesystem to boot up the Dell partition.

Please note: I take no liability for anything you do to your computer whilst trying this. It worked for me (yeay), and hopefully it will work for you. So please know what your doing.

Firstly, mount the Dell utility partition – this needs to be done as a root user (i.e. sudo)
$ sudo mkdir dellpart
$ sudo mount /dev/sda9 dellpart

Then rename the autoexec.bat and autoexec.up to something else (I just named them autoexecOLD.bat and autoexecOLD.up). Not too sure if the *.up file does anything but it doesn’t hurt to rename. You want to rename these files so they don’t automatically run.
$ sudo mv ./dellpart/autoexec.bat ./dellpart/autoexecOLD.bat
$ sudo mv ./dellpart/autoexec.up ./dellpart/autoexecOLD.up

Then download the DOS version of the BIOS you want – in my case, this was A05 (filename: QHA05DOS.EXE).
$ sudo cp QHA05DOS.EXE ./dellpart/
That’s pretty much all that’s needed in the Dell partition, you just need access to it. Originally I updated the grub menu, but then I found that it wasn’t necessary to do so. When you restart your Mini, pick ‘Boot Options’ to choose a boot device and then select ‘Dell Diagnostics’

That loads the DOS command line – then just do:
c:>QHA05DOS.EXE
And that’s it! The BIOS flasher will begin to run – soon you’ll be updated with the new BIOS. Be sure to run it with AC plugged in, etc.

For me, this completed and then turned the screen black for a few seconds. I found that the program restarted the machine for me – so don’t interrupt it when it’s doing that 10 or so seconds of black screen.

I also had a slight problem with it not going back to Ubuntu. The grub menu didn’t show up, so I assume that the boot device was changed somehow. I played about for a bit and when I ran seal.exe it brought up the initial ‘This is your service tag’ screen and then that worked. One of the files on the Dell parition says that the seal program ‘hacks the disk’ – so I assume it sets the boot partition back to the Ubuntu partition.

And that’s it! All should be updated :) Please note, that renaming the autoexec.bat files means they wont automatically run. So if you need to run the diagnostics, then it wont automatically execute. You might want to rename them back (you’ll need to remount, etc).Otherwise, if you want a handy DOS command line without the diagnostics automatically showing, the program you need to run is: c:diagsdelldiag.com

This all worked for me – but I can’t guarantee it will work for everyone. Good luck :)

Photo Rotator – Day 2

Wow!

Still getting lots of emails about the Photo Rotator app so I have a few features that I’d like to implement for the next update, which won’t be for a few weeks since I’m currently finishing off my university degree and need to focus on that. Keep sending your feature requests/comments/questions to ipod@bolsterweb.com and, if I can, I’ll stick them on the to-do list.

So just a thanks to all the kind emails I’ve been sent already :) And a whopping great big thanks to the massive support for Photo Rotator. 1,865 of you downloaded it yesterday!

I will keep you all up to date. Who knows? It might even make it to 5,000 downloads in it’s first weekend!

Thanks again,
Jonathon

Photo Rotator – Great first day!

Hello everyone in internet land!

I just wanted to say a great big thanks to all the people that downloaded Photo Rotator in it’s first day. Yesterday 442 of you downloaded it!

Thank you to everyone! Especially all of you that have emailed with thanks and suggestions for updates. If anyone else has any suggestions or anything then please email ipod@bolsterweb.com .

I’ve added a donation button to my page. I will keep Photo Rotator as a free application but anyone is more than welcome to make a donation so I’m able to eat :) If you really like the application and would like to donate then please just press the ‘Donate’ button on my pages.

If you really like the application but don’t want to donate then that’s fine too. You can even just send me an email with suggestions and I’d be happy with that too :)

Thanks again to everyone! Please tell your friends and family :)
Jonathon Bolster

Photo Rotator 0.5 now in the App Store

Hurrah!
My very first App Store application has been released today. That is the Photo Rotator.

It’s a very small program with one purpose only, and that’s to rotate photos! Open the application, choose a picture, press a few buttons and the new photo is rotated.

Why do it? Well, I received a message containing a photo I wanted to set as my background. Problem was that the photo had the wrong orientation, so it would only show up sideways. I looked on the app store for similar programs and found some – but they charged for it!

It’s an incredibly simple program with a feature that should have been built in which is why I made one and it’s free. No charge, ever. Although, if you really like it then please feel free to donate by pressing the button at the side of this page (thank you).

Download Photo Rotator from the App Store

If you have any questions, bugs, comments then please email ipod@bolsterweb.com