You need to get out on your whale, into the big scary ocean, and start learning and creating again.
Thursday, March 15, 2012
Knockout.js
Friday, March 2, 2012
Find the bug - part two.
The most complicated thing in the world to understand is concurrency. Not even Einstein's General Theory of Relativity comes close. Here is an interesting gem that I got from a newsletter quite some time ago. I found the puzzle incredibly interesting and it convinced me to NEVER EVER EVER EVER:
- Assume I understand concurrency.
- Use the old core Threading stuff rather than the new modern concurrency frameworks (i.e. Threading pools, etc.).
- Assume I understand concurrency.
- Skip testing threaded applications - because I'm clever, it makes sense... and besides I understand concurrency.
- Assume I understand concurrency.
Look at the following Rorotika-inspired class and tell me what happens. Keep careful track of all the delays.
OSGi and your strong opinions
OSGi Feature Overview:
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.wasfposgi/wasfposgi/1.0.0.0/Overview/wasosgijpafep_OSGi_overview/player.html
Modular and dynamic OSGi Applications Part 1: Motivations and specifications:
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.was_v8/was/8.0/ProgramingModel/WASV8_OSGi_part1/player.html
Modular and dynamic OSGi Applications Part 2: OSGi applications support in WebSphere Application Server:
http://publib.boulder.ibm.com/infocenter/ieduasst/v1r1m0/index.jsp?topic=/com.ibm.iea.was_v8/was/8.0/ProgramingModel/WASV8_OSGi_part2/player.html
OSGi is the "Open Services Gateway initiative framework" which is a "module system and service platform for the Java programming language that implements a complete and dynamic component model". Thank you Wikipedia.
I am still working through these. So far I like the fact that OSGi is a way of enforcing modular architecture and deployment as well as the fact that it is a solution to the multiple versions of the same class on the CLASSPATH problem. What are your strong opinions on OSGi and/or alternatives?
Meta-post
![]() |
| Audience |
![]() |
| Traffic Sources |
Thursday, March 1, 2012
Can you find the bug? Part One
Anyway, if I'm honest, I'm sure there is code out there that I've written that could also potentially have leap year problems. You need to be wary when working with dates. For example, doing something like:
Date lastYear = new Date(today.getYear() - 1, today.getMonth(), today.getDay())for working out a date a year back could be potentially problematic. So we should just be always wary of date arithmetic when writing such code.
In any case, this post has got another point: I want to start a sort of "game" or "tradition" on the blog if you will. I want to call it: "Can you find the bug?". The idea being, that whenever we come across a piece of code with a subtle, or huge, or blaringly obvious bug in our daily lives, we share it, and "challenge" the others to see if they can find it. Not with the idea of mocking the code or the author, but with the point of learning. And also testing our bug-catching eyes. Because there's no better way to learn than to analyse code that is actually running in the wild. Kind of like our own DailyWTF - but a bit more focused, and perhaps relevant.
Now we shouldn't be shy, it could be code we wrote ourselves (I know I've had a couple epic ones!).
Now today, I've got a doozy for you guys. I'm not going to give you the full story just yet... but let's just say this code comes from a VERY prominent IT company, and this was code that actually shipped in a product that this company delivered and was used by millions of people all over the world. This piece of code also made the product in question completely and utterly useless on a certain day. I want you guys to find out what the bug, and that day is. Bonus points if you can tell me the company/product in question. This bug is not limited to a certain, specific, once off day - it will happen on any day that fits a certain pattern.
The original code was C, and for the purposes of this excercise I took the relevant part and transcribed it into python. Here it is:
I've verified that the general case of the bug exists by running it myself. You can run the script with "python
So, see if you can spot the bug. Additionally, what would you do to fix it?
Hope you guys enjoy! And if this works out to be a fun exercise we'll do it again!
The Good Saltmine Slave
1. You ignore job descriptions - Willing to go into the deepest shafts to get the salt even when assigned a nice surface patch in the shade
2. You're eccentric - You rile up your co-slaves with your humour and positive working attitude even at the risk of angering the slave drivers - happy slaves == more salt and happy masters
3. But you know when to dial it back - when the slave driver cracks his whip, you work shut your piehole and work as if your life depends on it
4. You praise openly - You pat your slave friends on the back if they've gathered acceptable amounts of salt and tell them that the masters appreciate their effort
5. You complain in private - If some slave pisses you off, go beat him up somewhere deep in the mine - you don't want to start a riot and stop the others from gathering the precious minerals
6. Speak up when others are intimidated - When you haven't had food for 3 days(not less), speak up - if you die of hunger your bosses will get less salt and have to get new slaves
7. Like proving others wrong - that nice pocket of salt in the dangerous underwater cavern CAN be mined. You do not just want the master satisfied - you want him to smile. Possibly, other motivations can also play a role, for example stupidity.
8. Always fiddling - You always try to find ways to gather more salt, unselfishly ignoring the fact that you'll spend the rest of your (short) life in the hole you're digging to get it
Of course the article was not referring to slaves hundreds of years ago, but I had fun thinking this up. Feel free to suggest improvements to my interpretations!
One last thing: Any parallels you might see to your own life or to people you know's lives is unintended.
Disqus is pissing me off
Bwhahahaha
For some reason, my personal account seems to be linked to the blog's disqus account. I just had a "whale" of a time (see what I did there) to try to sort out this confusion - and I've come to the conclusion that it's gonna be impossible.
I think what happened was that I was logged into the blog disqus admin interface when I logged into my google account, and now it seems my google account is forever linked to whaleventures disqus account.
Also, a comment from Dawid was logged as spam: http://whaleventures.blogspot.com/2012/02/managing-callback-spaghetti-in-nodejs.html#comment-452433000
I cannot see any reason why in the world that comment should be marked as spam.
So the point is, if any of you moderate using the whaleventures account, be sure to use an incognito window or even another browser or something. And, disqus just lost some major points in my eyes. Also, the fact that Wiehann had to find a work-around for notifications didn't make it start off on a lot of points either. Lets give it another week or so, but perhaps its prudent to start thinking of ways to migrate to another commenting system?

