Posts

Showing posts from 2012

Coloring individual columns of a column chart (Google Visualization)

Now before i get into the nuts and bolts of my problem. I must confess that i was quite skeptical about the google charts API, mainly because of using the mostly awesome Jfreecharts  in the past. However having used it for a bit now, i am warming up to the idea of it, because quite frankly it is much simpler to use. You are likely to have a "cool" looking chart with tooltips etc in a much shorter time when compared to JFreeCharts. Anyway so about my problem, recently i was asked to create a column chart such that each column is colored differently.  My data looked something like this    var  data  =  google . visualization . arrayToDataTable ( [      [ 'Year' ,  'Games Finished' ] ,      [ '2003' ,   12 ] ,      [ '2004' ,   6 ] ,      [ '2005' ,   15 ] ,    ] ) ; The problem with this was that each column in the column chart is the same...

Consuming a RESTFul web service with Java Part 1 (java.net way)

Its incredible how common RESTFul web services have become now, i mean i have only started hearing about them in the last couple of years and the usage surge is a little interesting, especially since the style was originally proposed by Roy Fielding back in 2000. I guess one of the reasons could be all the big players getting onboard the REST bandwagon, but anyway this post is not about an analysis of the "RISE Of The REST", its really about how to consume them. If you want to know more about how REST works have a read of this post by Stefan Tilkov.   Ok so now there have been two projects where i have had to write REST clients, projects such as: Data capture automation tool: This was a java client i wrote for the School of Chemistry at UNSW, which basically helps them upload their experiments data to a server via a web service. I loved this project, i mean i had a chance to do commercial Swing programming, how often does that happen? ohh and i also had a chance to flex...

Java and referencing

Given that the last post was all about pointers and references in C++, it is only fair that i do justice to my first love (Java) and talk about parameter passing and referencing in it. Now b eing a managed language, there is no memory management as such in Java, so no pointers no keeping track of what memory is being used where. So how does that work? well there is the Java garbage collector, which periodically (to my knowledge, there really is no telling exactly when) does the rounds and deletes any objects that are no longer being referenced. To go into the details of the garbage collector (GC) and reference counting and related concepts deserves a post on its own, so i will just skip it here. Anyway so yeah.... GC  woohhuuuu, we can focus solely on the business logic and not worry about dangling pointers and other memory related grief. Now this is awesome, i mean it really is, however it does have its cons, Java programs run slower because of  the  GC  compared to...

Of pointers and references........

About two and a half years ago, i would have never imagined myself writing anything about pointers or let alone be at a stage where i am no longer intimidated by them, but here i am blogging about using them. This is after almost 2 years of disliking it......well 2 years to actually get the hang of it and use them properly and honestly it now makes so much sense and i get an idea of the power of unmanaged code (of course when done properly). Coming from the managed world (Java, Python and to some extent C#), it was quite a task for me to get grips with managing memory, even now i won't say i have mastered the art of memory management in C++, but i am reasonably comfortable with it. The point i am trying to make is, watching out for memory isn't second nature to my programming style....I still need to be on absolute alert when i am writing any C++ code, especially when i am passing pointers around the code. However having said all of that, writing some C++ code in vim,...

Async (Non-blocking) programming with Java

Following on from my last post, where i explore doing Async with C++0x, in this one i try to accomplish the exact same thing with Java. So first of all, before i say anything else, to me Java is first love and to some extent I still love the idea of writing anything in Java. However there are things that i have come to appreciate in other languages such as C++. So in case you are wondering, why the disclaimer? well when trying to do some Async stuff with Java, i found it to be a bit more complicated then what it was in C++. I honestly never ever imagined myself saying this, but yes it is true, i tried really hard to blame it on the tutorials that i found or my own thinking, but i must accept it for what it is. Problem Given how boring my problem definition was in the last post, i will try to make this more exciting in this one. So say, we have a shop and we are counting the cash at the end of the day to know how much we earned. A colleague will provide some help, by counting t...

Async (non-blocking) programming with C++11

  Asynchronous  programming is a wonderfull thing is it not? However that only applies if it is used in a controlled manner. Given the advantages that it offers it can potentially be very easy to get into the swing of it all and make an entire application async and ending up in debugging hell in the event of unexpected application behaviour. So why am i talking about aync? ok so let me get one thing clear, when i say async i strictly mean non-blocking, because you can make an async call and have your program wait on the function to finish doing its task, however in that case  you are no longer doing what you set out to do.  Ok i guess  am just dragging this out, well i get the point , enough foreplay, now on to business! Since my research work is mostly all C++, i reached a stage in my research where i had to adopt an asynchronous (non-blocking) approach at solving one of my research problems. Which had me to go on the hunt for the best possible ...

Calling Java methods from C++

  In one of my projects, I had the need to call a Java function from a C++ class and somewhat surprisingly it was more complicated than I initially expected it to be. Arguably there are more resources on how to call C++ functions from a Java class then the other way around. Also one needs to ensure that the documentation refers to calling Java from C++ instead of C , as there differences in the function calls. Hence based on my experience here's the solution that I came up with. Requirements I wanted a Java class to perform a certain task and return an array of double  (primitive type). I would then invoke this Java method from my C++ class and use the values of that double array. A sample of my Java class public class Test{ public[] double array; public int size; public double[] getArray() { array = new double[]{1.2,3.2,1.2}; return array; } } Hurdles and initial mistakes Initially what I was trying was to...

ASP.NET MVC2 and IIS 7.5 deployment issue

After spending hours and pulling my hair out over the deployment error , i finally found a solution, but before i talk about the actual solution, i will provide some context to the underlying problem. I have recently developed an ASP.NET application using the MVC2 framework and when i tried to deploy the application on IIS i encountered a deployment error. The link between .NET framework (any version) and IIS This is the least visible problem of them all, because you are most likely to assume that this has already been taken care of. This is not an issue if IIS is installed before the .NET framework, however  if IIS is uninstalled or installed after the .NET framework has been installed than it does not automatically establish the link between the two . In case of the latter the issue can be resolved by manually establishing the link between IIS by the following steps start the command prompt and navigate to the directory where you have installed the ASP.NET framework e.g....