Category Archives: General

Easy Python debugging

MATLAB has its weaknesses but one of the best things I like about MATLAB is the keyboard command. It allows you to halt the program at a given point and gives you an interactive session that has access to all the functions and variables that are available to your script.

There are a few ways to do this in python. Of course, you could use gdb, just like you would to debug a C program. I know there are extra “plugins” that allow you access to Python specific debugging commands but I haven’t tried it out yet.

My preferred method is to use the Python Debugger or pdb. The easiest way to do it is to launch your Python program as follows:

python -m pdb script.py

Then when your program hits an error, it will halt execution and give you an interactive console to debug the program right where the error was raised. It gives you access to all the variables and functions within the program at that particular point as well as a whole range of commands to help you with the debugging. Very useful especially when debugging useless error messages from third-party libraries.

There is another method that is a lot more similar to the MATLAB keyboard function. Just import the code module and the insert the command code.interact(local=locals()) wherever you want to do the debugging. It gives you an interactive console to debug your Python program. The local=locals() bit is required to give you access to all the local functions and variables.

Thank you…

Blogging every year on my birthday has become a bit of a tradition (last year being the exception). I think it’s just about the only time I actually blog – something I have to change this over the coming year. This past year has been a bit of a whirlwind but I think the theme of the past year has been the support from all the amazing people around me. So this time I am going to do something a little different. Instead of a list of things I achieved, I am going to pay tribute to all the people who have supported me during the past year.

There were many bumps in the road during my last few months at Bristol. My late-grandfather fell really ill sometime in early 2012 and his health deteriorated steadily until his passing on 3 June 2012. Bristol were very supportive throughout and were kind enough to allow me to defer 2 papers so I could attend the funeral. Once again, a big thank you to Dr. Walterio Mayol-Cuevas and everyone at the Department of Computer Science, University of Bristol.

As I mentioned, my late-grandfather passed away in June 2012. At times like these you tend to regret living 10,000 miles away from home. Thankfully I have amazing friends who dropped everything that they were doing and travelled back to Kajang to support me and my family through that rough patch. Even though we see each less and less as the years go by, I think we are probably closer now than we ever were. So cheers guys, for all the support over the years.

In the midst of all this I somehow managed to gain admission to the MSc Machine Learning at UCL. The admissions process got very messy as I wanted to start in October 2012 but didn’t get my final transcript until late September 2012. It was literally touch-and-go but I definitely would not have been able to start my masters this year if not for the amazing staff at UCL who went out of their way to help me enrol in time.

Then there’s the masters itself. The past 8 months have been the longest of my life! Or it would have been if not for the amazing people doing the MSc alongside me at UCL. We somehow pulled each other through the seemingly endless stream of coursework (and then exams) to get through two semesters at UCL. Here’s to more of the same during final semester…perhaps without the all-nighters this time!

And finally, my family. The past year has been tough for all of us but you have never failed to be there for me throughout with moral support and lots of prayers. I think the greatest sacrifice on your part was putting up with my absence over the past few months, all the missed family dinners and other events. I haven’t yet reached the finish line but I wouldn’t have got this far without you.

I know I am extremely blessed to be surrounded by such amazing people. At every bump in the road, there has been someone amazing who has stepped in to support me, to lift me back up and help me carry on. For that, I am truly grateful.

Tagged , , ,

Erna Mahyuni – Sabah: Mahatir’s failed attempt at social engineering

Erna Mahyuni – Sabah: Mahathir’s failed attempt at social engineering.

Farish Noor explains the complicated history of the various people of North Borneo and the Philippines in his column where he says:

“In the midst of the chest-thumping, saber-rattling jingoism and hyper-nationalism we see rising in both Philippines and Malaysia today, we ought to take a step back and look at ourselves honestly in the face.”

Historically the people of Sabah are a complex mix. With the formation of countries and borders, people who are connected by history and blood are now separated by that thing we call “citizenship.”

Tagged , , , , , ,

The Decay of Science or a mere statistical curiosity?

Nobel Prize Winners Age Statistics.

In 1965 Richard Feynman, prescient as always, prophesied that science would reach its impasse. “The age in which we live is the age in which we are discovering the fundamental laws of nature, and that day will never come again.” After the great truths are revealed, Feynman continued, “there will be a degeneration of ideas, just like the degeneration that great explorers feel is occurring when tourists begin moving in on a new territory.”

Indeed, by 1970s, the researchers have already mapped out the entire universe, from the microrealm of quarks and electrons to the macrorealm of galaxies and quasars. Physicists have shown that all matter is composed of a few elementary particles ruled by a few basic forces. Scientists have also woven their knowledge into an impressive, albeit incomplete, narrative of how we came to be. The universe exploded into existence 15 billion years ago, give or take five billion years, and is still expanding. Some 4.5 billion years ago, the detritus of a supernova condensed into our solar system. During the next few hundred million years, single-celled organisms bearing an ingenious molecule called DNA emerged on this planet. These primordial microbes gave rise, by means of natural selection, to an extraordinary array of more complex creatures, including Homo sapiens.

 

Everything that could be discovered has been discovered; everything that needed to be explained has been explained; there is nothing left for science to do but to slowly decay or, as Feynman would put it, “degenerate.” Case closed.

Tagged , , , , , , ,

Kindle 3: Blank Page in PDF (fix)

Just a quick tip for anyone having issues viewing PDFs on a Kindle 3. I noticed that some pages just went missing (were shown as blank on the Kindle) even though I could view them fine on my Mac. If you are having this issue, one way to fix it is using Mac’s Preview application. I found that just making a change – such as inserting an extra page then removing it again – and re-saving the PDF fixed the issue. No problems with PDFs on the Kindle now.

No idea why it works, it just does. May have something to do with this but I don’t have Adobe Acrobat on my Mac and the process seemed quite tedious (although it may not be, I have no idea) so I didn’t try it. Worth a try if you are on Windows I guess.

Tagged , , , , , , , , , , , , , , , , , ,

22

Gonna keep it short and sweet this time (cos I have an exam tomorrow!). Here’s a list of things I’ve managed to do since my 21st birthday…

  1. Grown my hair out. I never realised how curly my hair is, probably cos it is usually always very short. I’ve got a mini-afro thing going on now and I kinda like it :-)
  2. Did a marketing internship at Fujitsu (Malaysia) last summer and I really enjoyed it. It was outside my comfort zone but I guess that’s part of the reason I took it in the first place.
  3. Applied for internships for this summer but wasn’t really successful at first. Got rejected by Bloomberg after the worst interview of my life (worst in the sense I’ve never done so badly in an interview) but I managed to get one at Parker Hannifin (UK) for this summer (yay!)
  4. Switched to a Mac. Got quite fed-up with my Compaq and I wanted something that is Unix-based but could still perform very well so it was a no-brainer really. Ubuntu was good but I probably spent less time working on it and more time getting it working!!!

No new theme this time cos I’ve been quite busy with the exams but if I find a new one that’s better than the current one I’ll update.

Tagged

21st trip around the sun

…and so another year of my life goes by on this little rock we call Earth. It’s been a tough year but I did achieve a lot of things.

  1. First, and probably most importantly, I made it into the University of Bristol to study Computer Science. Not that I had any doubts but still it’s kind of a relief to finally be here.
  2. I dumped Windows Vista!!! Not as important or hard to do as the previous one (especially given what a great job Microsoft did with it!) but Compaq (or HP rather) sure as hell didn’t make it easy to switch.
  3. I have gone Open Source. After years of putting it off I finally decided, with the help of Vista, to switch over to Ubuntu. Not the best Linux distro out there but hey, it’s a start.
  4. I grew a box beard. I’ve been wanting to do this for a while and finally did it last year. It didn’t last very long though. I had to get rid of it before I flew back for Christmas.
  5. I went to see Manchester United vs Everton in the English Premier League at Old Trafford with Shaun and GaPs.
  6. I took 6 whole months (Nov 2009 – April 2010) off all forms of sport to let my knee heal properly, something which I should have done 2 years ago although I still don’t know what the hell was wrong with it in the first place!
  7. I’m 21 years old! Not really an achievement but now I don’t have to worry about age limits for clubs and pubs any more and THAT is something :D

Not a very impressive list but all relatively important to me. So kudos to everyone who helped me through this year, both family and friends. I couldn’t have done it without you. Here’s to another 21 years of excitement…but hopefully with a lot less drama. I think I have had enough of that to last me a lifetime!!! Oh and of course, to mark another birthday, a new design for the site. Hope you like it!

Tagged ,

Mourinho are you listening?!

This is just one of a billion reasons why I love United. This song was sung during the 2006/2007 season. This version was sung after the 3-2 win over AC Milan in the Champions League semi-final at Old Trafford. United lost the semi-final 2nd leg but still managed to win the Premiership back from Chelsea later that month!

Mourinho are you listening?
You’d better keep the trophy glistening.
Coz we’ll be back in May
To take it away
Walking in a Fergie wonderland!

Tagged , , , , , ,

Joe Jacobs v20

Another year, another birthday…

To mark my turning another year older (and unfortunately another year bigger as well..literally) I’ve decided to give the blog a little redesign. The design was getting a bit too blue for my liking so I thought something a little brighter this time would be nice. I was going to call this post Joe Jacobs v2.0 but then I realised that I’ve probably redesigned this site about 20 times so version 20 is probably not that far off. So time to come out of your RSS readers guys! Here’s a little glimpse for those of you who are just too lazy ;)

Joe Jacobs 19 vs Joe Jacobs 20

Tagged ,