Posts

spark - sbt build tool

The spark documentation doesn't says (or maybe i missed it) about getting sbt tool if you're trying to build it on Windows. You need this to build, package and run scala code in spark. This tool can be obtained here . Once you have this installed, you can fire up your command / cygwin command prompt and continue building, packing and running your code by following this guide . basically it is just running sbt assembly .

MsBuild CS: 1668 invalid search path lib

There is an easy fix for this issue. (hopefully you didn't try to install VS2008 or Windows SDK),  All you have to do is create the missing directory as stated by blogger here :- http://frazzleddad.blogspot.com/2010/04/fixing-invalid-search-path-for-lib.html

Hibernate - specifying multiple packageToScan in configuration

After placing my hibernate entity in a different jar file, i notice that some of my tables are not created. Finally i figureout that it has to do with my hibernate configuration, specifically packageToScan attribute. With this i can specify multiple jar files that host my hibernate entities (table).

Dynamic Jasper Report Maven

If you want to find out maven repository for Dynamic Jasper and the home page info sounds confusing, try here . In short, what you need to define on your pom.xml is as follows Copied from Dynamic Jasper link for easy reference only. fdvsolution.public http://archiva.fdvs.com.ar/repository/public1/ And the dependency is shown below :

Compiling Plaid for Window

I don't know why am i even compiling Plaid for, maybe it can be a cool language to try out. Anyway, the site documentation works, just that there are a few glitches that i need to handle when compiling for Windows. As stated in the documentation, go 1. Grab TortoiseSVN 2. Check out the source https://code.google.com/p/plaid-lang/ , into a directory of your likings, let's say c:\java\plaid 3. Include the followings in your path : C:\java\plaid\fastbuilder;C:\java\plaid; 4. Goto C:\java\plaid\tests and run ant build . You should be able to compile successfully. 

Building spark is easy

I was amazed how easy it is to build S park on Windows. Just have to 1. Download and install Scala 2.9.2. Ensure your SCALA_HOME is accurately setup. 2. Also make sure you have javac available in your environment path. 3. Download spark (0.7.0). Spark uses sbt (simple build tool and it is shipped together with the code. After you extracted spark source code, goto the root folder and run sbt/sbt package And you're done! Awesome.

Jquery UI Tab causes Ajax Options null exception

When you are loading your jquery UI tab in your browser and at the same time you enable your firebug, you might run into this problem - ajax options is null. No immediate fixes, just gotta turn off your firebug during jquery ui tab loading process. :(

Spring MVC ExceptionHandler gets easier.

Spring MVC exception handling gets easier with @ControllerAdvice with the release of Spring 3.2.1. You can annotate your class as shown below and add a method to handle exception @ControllerAdvice public class AppCoreController { @ExceptionHandler(Exception.class) public @ResponseBody RequestStatus handleException(Exception exception) { RequestStatus errorStatus = new RequestStatus(); errorStatus.setMessageCode(-999); errorStatus.setMessageDescription(exception.getMessage()); return errorStatus; } } Please note that RequestStatus is a custom controller and yeap we are returning an class / object type as oppose to just String data type.  These add exception handling capabilities to all your existing controller. 

Error FAKEROOTKEY set to 818929733

When i was trying to compile linux kernel, i bump into the following issue,  fakeroot: FAKEROOTKEY set to 818929733  fakeroot: nested operation not yet supported Turn out that i was actually running root on top of my username. :D  To fix this, just type "exit" to get out of the root mode and execute fakeroot command again. 

Knockoutjs markup evaluation is javascript like

Lets say you have an observable called "totalRecordCount" and using the following code to evaluate if a markup should be visible. data-bind="visible : $index < $root.totalRecordCount" All these will be evaluated to false, until ......... data-bind="visible : $index() < $root.totalRecordCount()" Seems like evaluation falls back pretty much to traditional javascript evaluation.

Navigating around jstree

Here are some methods that you probably need to know to work with jstree. 1. Get the currently selected node var treeDivControlName = "myJsTree"; var selectedNode = $('#'+ treeDivControlName).jstree('get_selected'); 2. Get the path from root to the currently selected node  var parents = $("#" + treeDivControlName).jstree("get_path", selectedNode); 3. Creating a  new node in your tree  $("#" + treeDivControlName).jstree("create", selectedNode, "inside", newNode.node); 4. Removing the currently selected node  $("#" + treeDivControlName).jstree("remove", null);  // null will remove the currently selected node

Working with JsTree : Create a tree

jstree is one of the most popular javascript tree user control around.  However, using it is not so straight forward. Let's go ahead and create your first jsTree. There are several ways to create a jstree either through HTML or via JSON. This is really just a matter of loading the proper plugin. Think of plugin as feature for your jstree. Please include jquery and jquery.jstree.js in your page. The code sample below show how to create a simple jsTree, JSON way. $("#" + treeDivControlName).jstree({ "json_data" : { "data" : [ c1.node, c2.node, companyNode.node ] }, "plugins" : [ "themes", "json_data", "ui", "checkbox", "crrm", "contextmenu" ] }).bind("select_node.jstree", function (e, data) {  alert(data.rslt.obj.data("id") +  ":" + data.rslt.obj.data("nodeType")); }); ` Check out the plugin section - yo...

Popular project in Github

If you're trying to find out what are the interesting projects in Github, you can try clicking on the url here  ( https://github.com/popular/starred )

Excluding Javascript validation in Eclipse

I've been bumping into this issue so often until i had to write it down, somehow :) http://stackoverflow.com/questions/4867885/how-to-exclude-a-javascript-file-from-javascript-validation-in-eclipse

Symfony 2 Doctrine configuration for MySql database

This post provides a quick and dirty way to setup your doctrine configuration using Symfony v.20.  I assume that you're using MySql database. Step 1 First you need to enable your "pdo_mysql" driver in php.ini file. Just uncomment the following configuration in your php.ini. Restart your IIS and you're pretty much done. extension=php_pdo_mysql.dll Step 2 You need to have the following configuration in your symfony\app\config\parameters.ini file.      [parameters]     database_driver="pdo_mysql"     database_host="127.0.0.1"     database_port="3306"     database_name="testproject"     database_user="root"     database_password="root"     mailer_transport="smtp"     mailer_host="localhost"     mailer_user=""     mailer_password=""     locale="en"     secret="ThisTokenIsNotSoSecretChangeIt" You might have noticed that ...

Dictionary vs HashTable performance

This is rather old but some developers still questions the performance cost of Dictionary vs Hashtable. Link below provides a performance comparison between both data structure. http://blog.bodurov.com/Performance-SortedList-SortedDictionary-Dictionary-Hashtable/

Android : Properties for SHAPE xml

What are the properties you can use when you're creating a SHAPE xml for styling your layout such as gridview or button? Please check this link out :- http://developer.android.com/guide/topics/resources/drawable-resource.html#Shape

Android Programmatically apply style to your view

Applying style to your view (button in this case) dynamically is pretty easy. All you have to do is place the following in your layout folder (res/layout) Let's call this file : buttonstyle.xml <?xml version="1.0" encoding="utf-8"?> < selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" > <shape> <solid android:color="#449def" /> <stroke android:width="1dp" android:color="#2f6699" /> <corners android:radius="3dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> </item> <item> <shape> <gradient android:startColor="#449def...

RhinoMock to return different value based on method parameter

How do you return different values based on different parameter in a mocked object using RhinoMock? Maybe there are other ways of doing the same thing. These are the two methods that i know. Lets say i have the following interface that i wanna mock. public interface ITest { int Test(string data); } [TestMethod] // Method #1 public void ExpectConditionalMethodInputParameter() { var mock = new MockRepository(); var subject = mock.DynamicMock (); int result; With.Mocks(mock).Expecting ( delegate { Expect.Call(subject.Test(Arg .Is.Equal("1"))).Return(100).Repeat.Any(); // Set expectation input parameter1 Expect.Call(subject.Test(Arg .Is.Equal("2"))).Return(200).Repeat.Any(); // Set expectation input parameter2 } ).Verify( delegate { result = subject.Test("2"); // Returns 200 if parameter is 2, return 100 if parameter is 1 } ); } [Tes...

Efficient way of representing Date

What is an efficient way of representing date? Try the following code (Taken from Art of Computer Programming Vol 4) var y = 2012; // Year 2012 var m = 6 // June var d = 30 // 30th day on the calendar month // Efficient representation (packing) var result = (((y Breaking this down further, we have (y Binary representation for 2012 is : 11111011100 Left shift by 4 : 111110111000000 Next we have, ((y 111110111000000 + 110 (m = 6) = 111110111000110 Left shift 5, becomes 11111011100011000000 Next we add the days to it which bring us to the following equation 11111011100011000000 + 11110 = 11111011100011011110 ( Decimal : 1030366) So our final result is : 1030366 // Unpacking var day = result%32; 1030366 % 32 = 30 (once you have this, the rest is pretty straight forward) var month = (result >> 5) %16; var year = result >> 9; Is there any other alternative for doing this? Maybe for other data types such as telephone.