Archive for hard
Limits? …. What limits?
“You can quit, and no one will care if you do. But you will know.”
John Collins (Ironman founder)
Bouldering
So I thought I was good at climbing and generally being able to lift myself up a wall that I was paying someone else for. This was generally my experience after six months of climbing at hardrock and cliffhanger. So one day my friend John mentioned this bouldering joint, and like a lamb to slaughter, I went.
OK, first thing, I was probably the least talented person there, and second, bouldering is much much harder than climbing. The cost of falling from one is much much higher and you pull off more skin of your hands which makes the subsequent climbs much harder.
And the grades are so very different. At cliffhanger, the grades are generally V scale but at lacticfactory they are based on complexity of effort. So there is no way of telling if I do a V3 at Altona, how well do I do at lactic.
Insert prolongated sigh.
Going this wednesday again
to lactic factory … WILL BE AWESOME
Enjoy the video below as well.
Dynamic Classes in Java
Recently discovered how to create dynamic classes in Java.
Thread.currentThread().getContextClassLoader().loadClass("DynamicClassPath")
And then if you want to invoke a method on it ![]()
Object obj = clazz.newInstance();
Method m = clazz.getMethod("methodName", null);
And then to call it:
m.invoke(obj, null);
Google Maps and Suburbs
This thursday and friday my company , held its quarterly innovation day event. This is similar to Google’s own Innovation Time Off or Atlassian’s FedEx days . In short, we as employees got to propose ideas beforehand and then work on them for two whole days. Towards the end of friday, we got to present our efforts in front of the company and the best ideas got a business impetus to be developed as a company feature. The result of the last innovation day was the open sourcing of the page model developed in house called Gizmo by Luke Cunningham.
So last thursday, I decided to join forces with Geoffrey Giesemann on his idea of visualising suburbs and their corresponding information onto google maps. In this, I hoped my recent knowledge of their V3 API would come in handy. So we started at about lunch time on thursday and we split the task on basis of front and back end. The back end became Geoff’s task and he decided to write a rails application to load the monstrously verbose and complicated suburbs’ file and parse to JSON in a neat form. (Neat here being defined by the lack of extraneous data). My task became the front end. That is, to mock the JSON data that Geoff would provide and set up the map to display it. And thankfully, my knowledge from the recent devfest did come in handy
.
I started with a simple map and ensured that I could load the defaults and set up a single marker. This was fairly easy as the new API is very intuitive to work with. Then came adding additional controls to the top left of the map, which we decided would be the capital cities of the states. This would allow us to go directly to the geographical centers of the states, or centre of Australia, if we wanted. The mock data simply comprised of suburb name, its geocodes (latitude and longitude) and the name state it belonged to. I started out with a hundred suburbs and loaded them, using default markers in firefox and the whole thing was working neatly. I set up the info windows and was disappointed when I found out that the content was simple HTML(I was hoping for more controls, they are fun). The fun started when I loaded all the suburbs from Australia that I could find (in this case 15,000).
The fun was that with 15000 suburbs, all my browsers crashed; Firefox, Safari, Chrome. Someone suggested lynx but we had to decline, even though ASCII representation was tempting
. So we decided to use clustering. Now V2 API used to have a MarkerClusterer, but for V3 Fluster2 was recommended. And rightly so. It was very easy to use and even easier to understand; even for someone like me who has not done much Javascript. But even after we clustered the suburbs, only Chrome could manage the load, probably due to its V8 engine. Once we dropped it in, the result was as follows:

Then we added custom markers for suburbs based on their state.

These markers were obtained from google’s map icon repository.
and some information on the InfoWindow

and our front end was complete. Geoffrey soon provided the the actual JSON data and after optimising our JS code to handle such a large load, we had a very nice application.
P.s Particular thanks to Daniel Hall who made me understand why the ‘A’ in AJAX stands for asynchronous.
Unit tests!
In the morning, I had a very interesting discussion with a colleague of mine. He was writing a simple handler which passed an annotation to a calling class about which we knew nothing. All we knew that by passing the annotation, the class did stuff properly. For those fortunate enough to have dealt with objects in python and ruby, behold the Java annotation example:
@Test
public void testSomethingWorks() {
assertTrue("Eve knows ", alice.secret(), bob.secret());
}
More can be found at Java 1.5 Annotations
The @Test is the annotation, telling the whatever is reading the code that what follows is a JUnit test. Similarly we had an annotation, above a class method and the discussion started. My friend’s argument was something that only did one thing, and that thing was just an annotation passing to a black box, did not need a equally trivial unit test. Now this test is made harder by absence of any decent mocking frameworks. That is, we could have mocked out the external utility that was a black box and done a fast and simple JUnit test, but not to be.
I asked my friend if he cared when/if the code was changed. On being answered in the affirmative, I asked him whether in that situation, he would like to know by our build light breaking, or by one of our system administrators coming to us and informing us?
Thankfully, that seemed to convince him that a test, whether trivial or not, is needed to cover a piece of code which does something. Any thing. I say thankfully because I really did not have any more arguments up my sleeve, other than my sanctimonious anger
Running is hard!
So I try and run and it is a personal battle. You can run as fast as you can and be as dedicated about it, but there comes a point when your body simply goes, naah, slow down lad (for me that is after 3 minutes
).
So what is the best thing I have landed on ? It’s apparently called ‘Interval Training’. The idea being you run really fast for a set amount of time, slow down for half that time and then fast again. Repeat the cycle as long as you can. I have been doing that and it hurts
.
But I would highly recommend it. It is a great way to learn to improve your stamina and learn to improve your will power.
But if you extend it past an hour, make sure no one watches you cry.