PAC code O2
by Mex on Aug.06, 2009, under Technology
Just had to get my PAC code from O2 and it turns out was easy as pie. Just had to ring 4445 (25p a call though) answer some easy(ish) questions. “How much credit do you have?” Not so easy to find out when your on the phone in question. Once done though was given the code over the phone, no waiting like you used to have to do.
Referencing Springerlink with BibTex
by Mex on Mar.31, 2009, under Technology
I have been writing a couple of reports recently and took the time to start learning LaTeX and BibTex (through Lyx and JabRef admittedly). When dealing with references some resources like the ACM provide BibTex citations which you can copy and paste into your database, other’s like SpringerLink unfortunatly don’t. This led to me descovering a tool from University of Sydney which automaticly generates BibTex records for SpringerLink for you. They even provide a bookmarklet to make things even easier.
Window 7 on the NC10
by Mex on Mar.18, 2009, under Technology
I recently did a review of my new NC10 netbook, and though it’s a lovely device I would prefer to run something a bit more up to date on it than XP. With the 1 Gig or ram it comes with and the modest CPU Vista was out of the question, but I have geared good things about people getting the Windows 7 beta running on this class of device, so I thought it would be worth giving it a go.
Preparation
The NC10 comes set up with three partitions, the first is a hidden area where the recovery software is installed, followed by a NTFS partition which Windows XP is installed on and a second NTFS partition which is used to store backups with Samsung’s backup software. To make room for Windows 7 I resized the backup partition with a live USB Linux distro called GParted. Because I was installing Windows 7 onto a new device I wasn’t worried about taking a backup, but you should take a backup before doing this normally.
One thing of note is that I made the partition almost the same size and the data on it, and now I am continually getting popups in Windows saying the drive is very full, so it’s prob worth leaving about 25% extra free space in the backup partition when you shrink it.
Installation
The NC10 like other devices in it’s class does not have a CD drive and I don’t own a USB CD drive, so I had to go with installing it off of a USB stick. This was much easier than I expected thanks to a great walk through I found over at dotnetwizard.net. I have heard people saying how much quicker Windows 7 installs that Vista, but it didn’t feel that fast to me.
Problems
I could not get Windows7 on the NC10 to connect to my wifi connection, but this seems to be a problem with our wifi as aposed to the NC10 as it works everywhere else. The Ethernet on the other hand did not work as there are no Windows 7 drivers for this device on Windows Update. The Windows Vista driver from Marvell’s worked fine however.
The other main issue is the reduced battery life, under Windows XP doing casual web browsing etc. I can get almost 6 hours before I need to charge, under Windows 7 it is closer to 4.
The good bits.
The new Areo effects work well, and only stutter under very high load. In-fact other than slightly higher memory usage running Windows 7 doesn’t feel any worse than running Windows XP, and this can easily be remedied by upgrading the memory from 1Gb to 2Gb.
Finally
I think I am going to continue using Windows 7 on the NC10, unless I know I am goign to have a very long day away from the charger. I would like to thank Ade Miller for his excelent blog post which really helped me in setting up Windows 7 on my NC10.
Unit testing private methods in Java.
by Mex on Mar.15, 2009, under Technology
Unit tests are both the saviour and ultimate bane of modern java programmers. Very few people would argue that they are a bad idea, and that they improve the quality of code but for those new to writing unit tests are often lost on where to start. In this post I am going to talk about unit testing private methods, and what is good and bad about doing so.
Some Theory.
In the example below ClassWithPrivateMethod contains the private method someMethod which we want to test. To get access to this method for testing we could make it public/protected; but that would make the classes interface ugly, and give people access to functions that could break the working of the class. We could put the test case inside the class being tested, but this quickly becomes messy. Ideally we want the method to remain private but be accessed from another class. It turns out that private methods are not private, as much as books on Java will tell you they are. Using reflection it is possible to execute private methods as if they were public.
public class ClassWithPrivateMethod { private void someMethod(String param) { System.out.println(param + " World"); } }
To call a method with reflection we first need a reference to the method. This is normaly done with Reflection.getMethod, however because the method we want to access is not public we have to use Reflection.getDeclaredMethod. This gives us a handle on the method, but it is unusable because the method is still private. Calling setAccessible(true) on this method object lets us invoke it. The method can now be called via reflection the same way a public method would be. Bellow is a clearer example of a test that simply invokes the private method.
public class Test { @Test public void test() { Method methodToTest = classWithPrivateMethod.getClass(). getDeclaredMethod("someMethod", String.class); methodToTest.setAccessible(true); methodToTest.invoke(IntancetoInvokeOn, "hello"); } }
This technique can be further extrapolated to testing methods which rely one some state of the object which is difficult to achieve in a normal unit test.
public class ClassWithPrivateMethodandFields { private int x,y; private boolean isPair() { return x==y; } }
public class Test { @Test public void test() { Method methodToTest = classWithPrivateMethod.getClass(). getDeclaredMethod("someMethod", String.class); methodToTest.setAccessible(true); Field x = classWithPrivateMethod.getClass() .getDeclaredField("x"); x.setAccessible(true); Field y = classWithPrivateMethod.getClass() .getDeclaredField("y"); y.setAccessible(true); methodToTest.invoke(IntancetoInvokeOn, "hello"); } }
Finally
This is a powerful tool for testing, but over use can highlight the fact that your interface is not as clean as it could be. I hope this is helpful to people and if you have any ideas or comments please leave them below.
Pipex / Tiscali Update
by Mex on Mar.14, 2009, under Technology
I returned home this weekend to find more letters from Pipex, asking me for payment. The current Outstanding balance is now £56.61, and a bar on our outgoing call facility.
This would be all very good but we have never had a phone line with Pipex, and so our outgoing calls work just fine. It has become clear that calling Pipex will not achieve any thing on this matter so I am going to try snail mail and see if we get any further. I will post with any updates we have.
On another note, when logging into Pipex today i got a nice message saying their security cetificate is invalid, smooth Pipex, smooth.
Samsung NC10
by Mex on Feb.18, 2009, under Technology
Specifications
1.6 GHz Intel Atom N270 10.2″ 1024×600 Screen 1GB DDR2 802.11b/g Wifi 100/10 Ethernet Bluetooth 160GB hard drive 5,200mAh 6 cell battery
First impressions
The NC10 is a very striking looking netbook. I have the black model but it is also available in white and blue. The lid follows the classic Samsung styling of gloss black with chrome style lettering, and the faux chrome of the letting is also present on the hinges and as a stripe which goes around the sides and front of the chassis. Internally everything is made of matt plastic which won’t pick up finger prints, the lid however picks up grease and fingerprint no matter how hard you try and look after it. The status lights are placed along the front edge in such a way that its possible to see them and their descriptions with the lid either open or closed. Also along the front edge is a 3/1 memory card reader. The power button which took me a few seconds to locate, is placed on the side of the NC10 in line with the hinge and is nicely styled to match the faux chrome highlight. (continue reading…)
Updated theme
by Mex on Jan.30, 2009, under Technology
EclEmma
by Mex on Jan.27, 2009, under Technology
HackTags
by Mex on Jan.24, 2009, under Technology
One of my friends has pointed me at his latest project over at www.hacktags.org www.ptrtovoid.net called HackTags. If you remember Geek Codes, this is something like that, a badge to show off your geekyness and promote your favourite open source projects. The project is still only in early “pre beta” stage, only 48hours of coding upon writing this, so some things are likely to change but the auther Didi is happy to hear any ideas or suggestions about the site.
Google Analytics
by Mex on Jan.20, 2009, under Technology
Nearly all webmasters have now heard Google Analytics, Google’s website statistics package, so having set this blog up I took the opportunity to try it out. Setting Analytics up was easy, if you already have an Google account registering for Analytics takes seconds, agree to the usual EULA and enter your website address and your almost ready to go. Google Analytics uses Javascript to track usage and the next step of setting up the service is adding their script snippet to every page on your site. Because all I have at the moment is a blog on here, all I had to do was edit one template file and everything was set up. Note however the analytics page does show data in real time, processing is done in batches once every two hours, which isn’t exactly clear so you have to weight a little while before data starts getting shown.
One thing I have found out is that it’s probably worth setting up filters strait away, else you may get all excited only to find out all your traffic is coming from yourself. If you have a static IP this is easy just go setting page (link is found just under the google analytics logo on the home page) click edit next to your domain and find the button for “add filter”. Name your rule, and choose to “exclude all traffic from an ip address”. You will then need to enter your internet IP address bellow, in the form “192.168.1.1 ” the back slashes are needed because anything entered in a filter is treated as a regex. If you are using WordPress you might want to add the following rule as well, to block post previews from the stats too, as these are likely to be all from yourself.
Name: preview
Filter type: Custom - Exclude
Filter Field: Request URI
Filter Pattern: preview=true
Case Senstive: true
I have encluded an example output from the Analytics dashboard to give an idea of some of the information the tool gives you, though with a few more visitores I am sure it would be more interesting. The report is only an overview of the information avaliable and it is possible to drill down further to find out for example which of your blogs posts people have spend the most time on, as well as being able to view the path people traverse your site with, and the details that people used if they searched for you.
So now with all this information, I can work on getting more viewers to this blog; anything greater than 1 has goto be a win.







