Friday, November 18, 2011

Logo

Logo do matter as it is the first impression created by your app

Couple of options:
Online logo generator: (Most claim to be freee, but they are not..pay $blah..)
1. Freelogoservices.com (have good collection of logos. but its paid service -  £29 for unlimited logos).

DIY:
Build an apple like logo using Gimp
http://wickedowl.blogspot.com/2006/07/creating-apples-shiny-table-effect.html
http://www.ehow.com/how_6896439_make-apple_like-3d-logo.html

Metallic text (using gimp):
http://penguinpetes.com/b2evo/index.php?p=351

Online image editor : www.sumopaint.com

Note:
Windows desktop icon should be 32x32 px.
Apple icons are 57x57px
Android icons are  96, 72, 48, or 36 pixels wide, depending on screen densit

Tuesday, October 25, 2011

Android apps

Some useful android apps:

1. Data on demand - shutsdown wifi/3g when screen goes off. Saving bandwith/power. Nice green app
2. 3g watchdog - watch and optionally disable 3g if quota limit is reached. Very useful to avoid surprise bills for 3g overuse.
3. Advanced task killer


The apps i have released on Android market are below(these are quite crappy but hope to improve them as i find time)
1. Radio hindi



2. Ship control game  - It still needs lot  of improvement. But hey its my first android game..so be easy on me :)


Friday, August 12, 2011

Online Code generators

A nice code generator for php:
http://www.phpscaffold.com/

Java Spring projects:
http://www.springfuse.com/

Planning to write my junit code generator using japa..


Thursday, July 7, 2011

Keyboard music

Coding for long time can leave you stressed.

So why not heal yourself as you code with some soothing music? This program plays random notes when you type a key. The idea is to create soothing music for coders or anyone who spends time typing in front of pc(instead of the boring keyboard noise).

Guitar and piano notes are included in the bundle, but user can add their own notes as mentioned in steps to run(wiki link below).

Also planning to include auto suggest with it sometime (so you dont have to type a long sentence or word again).

Its partly implemented, but disabled in code at the moment.

 

There is lot more work to be done, like better notes etc. (I am no music expert). The basic idea is built and can be improved easily.

If you wish to contribute for develoopment, please let me know. The project will always be open sourced.

 

For details please follow wiki notes here

The project is open sourced here

 

Disclaimer:1.  The code captures keystrokes provided by JNativeHook.jar and it should not be used for malicious intent. I will be in no way held responsible for any misuse.

               2. The code built so far is basic and not yet fully tested. There is a possibility of notes played loud,etc. Please beware of this.

 



Gods Debris By Scott Adams

For a change have been reading a novel called Gods Debris by Scott Adams(creator of Dilbert comics). 

It has no plot as such but an exchange of ideas/ a perspective about god/ belief system/universe/ etc. 

In short it expands your imagination .

Though some concepts are abstract and made up, I enjoyed Gods debris and have started with his next book The Religion war (futuristic novel about Christianity and Islam) .

 Update: read The religion war. Quite nice! I am a fan of Scott Adams (his blog)

Gods Debris ebook is free here

The Religion War ebook can be found here

 

 



Friday, July 1, 2011

When Windows+Eclipse+Firefox slow down

All big garbage collected programs have a problem on MS Windows where, if you iconify them, the OS drastically reduces the working set size, making its VM pages available to other processes. When you restore the program, then the first time it tries to do a garbage collect (which could be several times a second) it can suffer a long pause while it brings in almost its entire virtual memory footprint in order to chase references. I've seen it take as long as 200 seconds to do this, during which time the program is unusable.

Workaround : use windows key + D or show desktop buttton instead of minimize.
More details

For eclipse performance imporvement, update shortcut as below:
"C:\Program Files\eclipse\eclipse.exe" -vm c:\j2sdk1.4.2\jre\bin\javaw.exe -vmargs -Xms64m -Xmx384m -XX:CompileThreshold=5 -XX:+UseParallelGC
The flags are discussed on the following website: http://www.burnthacker.com/archives/000049.html.



Tuesday, June 28, 2011

SMTP email testing

 To run local integration test, install apache james mail server.
 1. Start the server by [james]\bin\run.bat
 2. Map the email host to you smtp server if required in hosts file
 3. Run the test and check [james]\apps\james\var\mail\outgoing for emails sent out

 To add a user in james :
  1. telnet localhost 4555
  2. login as root/root
  3. adduser [name] [pass]
Also refer : james-2.3.2\apps\james\SAR-INF\config.xml for default user/pass
Code to read email link

Simples



Friday, April 15, 2011

Drools - Java Rules engine

An implementation of JSR 94  spec.
More here



Sunday, April 10, 2011

Android - Getting skype to work

Installing skype on my android 2.2 powered M701(Haipad lol ) didnt work initially. It would crash after a login.

 

This post was quite useful to get it rocking: here

Wish skype gives support for video calls on android soon. Till then happy calling.

 

Quick Notes :

Adb - android debugging tool. This is found with android SDK under [android-sdk-mac_x86]/platform-tools

1. Connect your device using USB.

2. ./adb get-state   --> Get state of the device. If it has connected fine etc.

./adb remount

./adb pull /android/device/folder/file.txt /mac/folder  --> To copy a file

./adb push /mac/folder/file.xt /android/device/folder

./adb install - Example: adb install c:/apps/apps2sd.apk

./adb uninstall - Example: adb uninstall linda.apk

 

 

 



Tuesday, March 29, 2011

Gwt JSNI gotchas

1. Expression evaluation
http://code.google.com/p/google-web-toolkit/issues/detail?id=2912


Mock Mock Mock

Mocking is serious business for evolved coding monkeys these days. There are few good frameworks which help in mocking like easymock, jMockit, mockrunner etc

PowerMock
SmartGWT is a GWT widget library which has design issues as its classes doesnt mostly implement interfaces. But the problem is we have to use it as it has nice widgets.

Question: how do we unit test these classes which have native code and hard to mock?
 Powermock came to rescue us. It can re-engineer the class and supress static block and method.
Eg:
@RunWith(PowerMockRunner.class)
@PrepareForTest( {Appender.class})
@SuppressStaticInitializationFor({"com.google.gwt.user.client.ui.UIObject","com.smartgwt.client.widgets.BaseWidget"})
@MockPolicy({Slf4jMockPolicy.class, Log4jMockPolicy.class})
public class MyStaticTest{
}
The above supresses static blocks which have wierd native calls and helps us continue our junit as usual. But its a bit slow (worth it i believe).
More on usage here



jMock vs. EasyMock

Comparison of jmock & easy mock

Both have similar features. jMock has a DSL (domain specific language) while easy mock has record-replay style.

Apparently jMock seems to be better in terms of readability and usability. Would prefer the more intuitive framework like jMock than Easy mock.

Will post more when I actually try using jMock. Till than easy mock.

Useful links
1. EasyMock http://www.easymock.org
2. JMock  http://www.jmock.org
3. Mackinnon, T., et al. 2000. Endo-Testing: Unit Testing with Mock Objects. In Proceedings of XP 2000. http://www.mockobjects.com/files/endotesting.pdf
4. Freeman, S., et al. 2004. Mock Roles, not Objects. In Proceedings of OOPLSA 2004. http://www.mockobjects.com/files/mockrolesnotobjects.pdf
5. Walls, C. 2008. Spring in Action, 2nd Edition. Manning Publications Co., Greenwich, CT. §B.2.1.
6. Stewart, S. 2004. Approaches to Mocking. http://www.onjava.com/lpt/a/4526
7. Fowler, M. 2007. Mocks Aren't Stubs. http://martinfowler.com/articles/mocksArentStubs.html




Sunday, March 13, 2011

Batch script to load developer environment

Wrote a simple windows bat script to start my project work environment.
This would save me
4 + 2 + 3 + 2+2 = 14 mouse clicks
4+2 + 5 = 11 keystroke
3 + 3 = 6 copy paste
Saving me from making 14+ 3 + 6= 23 decisions.. lol
The effort involved to build this script is 1 hour though. On a long run saves my time and energy for making these 23 decisions.. Worth it i believe.
What this does is : start mysql server , tomcat, eclipse, mysql query browser and open command prompt into your current project
------------------
net start mysql5.1
f:
cd F:\apache-tomcat-6.0.29\bin\
start F:\apache-tomcat-6.0.29\bin\startup-debug.bat
start D:\tools\IDE\eclipse-jee-helios-SR2-win32\eclipse\eclipse_jee_helios.exe
"C:\Program Files\MySQL\MySQL Tools for 5.0\MySQLQueryBrowser.exe" -ulportal -pdontshow -hlocalhost
cd F:\project
-----------------

Wednesday, March 9, 2011

Smart GWT Gotchas


1. ListGrid - Change color of a row or individual cell
2. Dynamic Form
           StaticTextItem
3. JSON parsing :
                JavaScriptObject jsObject = JSON.decode(responseData);
                JSONArray accountNames = XMLTools.selectObjects(jsObject, "accounts");
                final JSONValue jsonAccount = accountObjs.get(0);
                final String accountNumber = jsonAccount.isObject().get("AccountNumber").isString().stringValue();
4. Mock Presenter gotcha :
   Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client 
     Fix : GWTMockUtilities.disarm();   More here

5. Speed up gwt compile time : here

6. Error processing request: The response could not be deserialized
             Annonying issue in dev mode from eclipse. See that the default compile target is set to ../web-inf/classes in eclipse. Restart eclipse. clean up target classes folder. Got it working...after a redeploy of war again...strange..cant point to one specific thing (as i did clear browser cache/eclipse classes output/restart eclipse)
Apparently workaround seems to be try redeploying app whenever this issue occurs..

7. Wrap text in list grid:
listGrid
.setFixedRecordHeights(false);
listGrid
.setWrapCells(true);

8. Listgrid pagination related issues(issues with page scroll based pagination):
Serendipity might have already solved the pagination and csv export : http://code.google.com/p/crmdipity/downloads/list
think best if we have traditional pagination approach. and have as PaginatedListGrid which will solve all list grid related issues:
  - sorting
  - export to excel
  - print
  - slow page load
  - less browser load (as only one page of data is available at any point of time)




Thursday, February 17, 2011

GWT + Smart GWT

Technology stack:

            Client side: GWT Sdk 2.1 / Smart GWT 2.4          

            Server side:  Spring 3 mvc application which returns response in JSON data format. / Tomcat 6

            Development tools  : Eclipse Helios 3.6 /  GWT plug-in / GWT designer plug-in (this has useful features to design the UI, but consumes lot of memory and quite buggy and annoying) / To show debug console: javascript: isc.showConsole()

 POC Implementation Approach:

            A simple application to use Smart GWT components was designed. The key areas to investigate were – how well the UI components fit together and client server interaction options.

            *.gwt.xml defines the GWT module with core classes to be inherited and also the entry point class. The entry point class onModuleLoad() method is the first to be called in the GWT application to load the rest of the UI components.

            Used Smart GWT components for layout - VLayout, HLayout and SectionStack for collapsible sections.

            Smart GWT ListGrid widget, can easily render the search result data by setting a specific Datasource.

 (Note: This notion of datasource is not the same a database datasource; it is just a terminology for abstracting client server communication by Smart GWT).

 Various datasource can be used to handle JSON, XML, RPC, etc server responses. These can be found in package : com.smartgwt.client.data.*DataSource

             The prototype uses RestDataSource to consume JSON response generated by a Spring MVC 3 application.                     

            Once these components are organized in the Entry point class, using the gwt compiler generate all the JavaScript and HTML code required by the app. This can be deployed to a server.

Initial impression

Pros:

  • Less JavaScript and HTML to write and maintain.
  • Open source Smart GWT code allows viewing code and identifying bugs easily: code source link . Also an active smart GWT development forum is helpful.
  • Choice of Smart GWT datasource allows you to mock data for static prototypes and then switch to real web application for data. Also this decouples client UI development from server side build.
  • Swing style UI development:  Using smart GWT, you get a swing development feel, with components added into container classes and event handlers defined for

Components                       

  • Ready  to use components:

                Using Smart GWT you get widgets out of the box, but best practise around usage and modification needs to be identified. . Smart GWT has a rich set of ready to use widgets, a showcase is available here  

Cons:

  • Modular design for building large scale apps is yet to be identified. Initial impression shows SmartGWT is not written with MVP pattern in mind as suggested by Google.
  • Unit testing :

            How best to make SmartGWT components unit testable needs to be identified. There is not much mention of how the Smart GWT components can be unit tested. If we consider using only GWT, this can be achieved using junit GWTTest case.            

TODO:

  • Smart GWT or just GWT:  Building a GWT application from scratch without using any frameworks will need considerable amount of effort to follow the standard MVP pattern. But this is more flexible and unit testable, though time consuming. GWT best practise suggests using MVP design pattern for building larger applications.
  • SmartGWT has its own approach, where you use a widget, introduce a  
  • datasource into it and you are done. Yet to identify the best practise around building
  • such smart GWT components in a modularised (or MVP) fashion.
  • Using framework GWT-platform and SmartGWT could be an option to try MVP architecture as mentioned here. This would need more investigation.
  • Validation/message/exceptions display and other generic feature support of smart GWT is yet to be investigated.
  • Client server architecture:  Having Spring MVC + Spring core on the server side and GWT + Smart GWT on the client side could be a good stack of open source technologies, but given that GWT by default uses RPC for client server interaction, usage of these needs to be better evaluated. (esp. authentication/session handling/security etc).
GWT performance tuning
Server side tracing link
Client side Speed tracer link
Appstats for java link

Debug setting:

Run GWT Development Mode

  • Go into the Run Configuration menu and create a new Web Application configuration (this little Google g).
  • Select the slf4gwt-samples-client-app project and set com.google.gwt.dev.DevMode as the Main Class. On the Server tab uncheck Run built-in server and on the GWT tab set the URL as http://localhost:8080/slf4gwt-samples-server-app.
  • Save and run!
  • Select the src/main/webapp directory from the project and you are done. Now the GWT development mode runs.
  • There will be an Eclipse view called Development Mode, that shows you the URL for development mode. Copy it into your browser.
Run GWT debug on tomcat:
 1. Get google plugin for eclipse
2. Then in eclipse, right click on your project and choose Debug as -> Web Application (running on external server)
3. Enter URL of your web app on tomcat (like http://localhost:8080/YourApp/YourApp.html and eclipse will give you new one - it will add stuff like ?gwt.codesvr=127.0.0.1:9997
And you can hot replace the code as the code will be served from eclipse and not from application deployed in tomcat. So cool. Thanks google

GWT compiler performance tip:
   Add 4 in gwt-maven-plugin setting ..more
  Gwt plugin




Useful links
GWT:
Smart GWT : has rich set of gwt components.
Smart GWT+ GWT +MVP example
GWT debug mode on tomcat link2
Modular GWT

JSON GWT integration :

GWT gui designer

GWT EventBus sample





Tuesday, January 25, 2011

jquery IE AJAX issues

The list of issues when working with jquery IE AJAX issues are so huge and painful that I plan to maintain a log here :

1. trim() javascript function is not implemented in IE.
 Solution: Use $.trim('str ') instead of javascript trim()

2. Use javascript stacktrace jquery plugin. This is a life savior for identifying IE issues..
http://eriwen.com/javascript/js-stack-trace/
Open source in git here



Friday, January 21, 2011

Spring mvc 3 junit test

Below is a code snippet to easily test a spring annotated web controller


public abstract class BaseWebControllerTest {
    @Autowired
    protected ApplicationContext context;
    protected MockHttpServletRequest request;
    protected MockHttpServletResponse response;
    protected HandlerAdapter handlerAdapter;

    public void before() {
        handlerAdapter = context.getBean(HandlerAdapter.class);
    }
   
    void handle(HttpServletRequest request, HttpServletResponse response) throws Exception {
        final HandlerMapping handlerMapping = context.getBean(HandlerMapping.class);
        final HandlerExecutionChain handler = handlerMapping.getHandler(request);
        assertNotNull("No handler found for request, check you request mapping", handler);

        final Object controller = handler.getHandler();

        final HandlerInterceptor[] interceptors = handlerMapping.getHandler(request).getInterceptors();
        for (HandlerInterceptor interceptor : interceptors) {
            final boolean carryOn = interceptor.preHandle(request, response, controller);
            if (!carryOn) {
                return;
            }
        }

        handlerAdapter.handle(request, response, controller);
    }

}


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("/spring/test-app-config.xml")

public class MyControllerTest extends BaseWebControllerTest{
    MyController controller;

    @Before
    public void before() {
        super.before();
        controller = context.getBean(MyController.class);
    }

    @Test
    public void testGetRestRequest() throws Exception {
        request = new MockHttpServletRequest();
        response = new MockHttpServletResponse();
       
        request.setContentType("application/json");
        request.setMethod("GET");
        request.setRequestURI("/rule/"+id);

        handle(request, response);
       
        String result =response.getContentAsString();
        logger.info("RESULT : "+result);
        //assert json response is right.
    }
}

Reference:
http://efreedom.com/Question/1-2314377/Testing-Spring-MVC-Annotations

Thursday, January 13, 2011

Batch scripts

Context : If you are a java programmer? and you use tomcat  on windows? and you do not want repeated stress injury?
If yes then below are the scripts:

#1# Script to shutdown tomcat, deploy app, and startup ##
set tomcat_home=C:\..\apache-tomcat-6.0.20
set CATALINA_HOME = %tomcat_home%
cmd /c %tomcat_home%\bin\shutdown.bat

cmd /c mvn clean package -Dmaven.test.skip
rmdir /s /q %tomcat_home%\webapps\coacs

copy target\myhotapp.war %tomcat_home%\webapps
cmd /c %tomcat_home%\bin\startup.bat

#2# Run tomcat in debug mode  - store this under tomcat/bin as tomcat-debug.bat ##
set CATALINA_HOME=C:\Apps\apache-tomcat-6.0.20
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
%CATALINA_HOME%\bin\catalina.bat jpda start




Friday, January 7, 2011

Oracle fix for schema table prefix and running scripts from sql developer

In oracle it appears like a NON_OWNER user though granted access(select, insert, delete, update) to tables created by OWNER of the table cannot directly view them without the schema prefix.

This would mean all the queries in the java application will have to have this table owner user name prefix.

The possible options to drop this prefix :

1. ALTER SESSION SET CURRENT_SCHEMA= OWNER_SCHEMA ; (AFTER LOGON trigger as mentioned here )
But this works only for the current session unless we have a logon trigger. This seems like a preferred approach as per various forum threads.

2. Create views/synonyms from the NON_OWNER current user per table. So the tables can be accessed without prefix.

3. It could be something simpler as well (I am no DB expert) like setting the default current schema for the NON_OWNER user in some other way.


Running scripts from SQL developer:


To run this from sqldeveloper :
1. Set a default Path: Tools menu > Preferences > Database > Worksheet > Select default path to look for scripts
2. open run.sql from sqldeveloper File > Open
3. Run script.

Tuesday, January 4, 2011

iPhone apps - App-le a day

iPhone apps seems like the new trend and what else should a developer be doing in his spare time?



My motivation:

1. Millions of users. You can share apps with the world and make a small earning till iphone user base exists. Isn't that cool

2. Its market place is excellent

3. One of the best integration of technology man possesses - all in the palms of your hand.

4. Good way to know more about Apple & their products.





Few iPhone apps that I have been churning are now live on itunes:




1. AutoSignIn(free) - formerly called LogMeIn.




An auto login app to help you login to most of the popular sites -like gmail, admob, ebay, yahoo, gdocs, etc.. As iphone has no provision to store your password/email this should be handy. I use most of the time.
The idea is that you dont need an app for every popular website on the internet. Just an autologin app should do as most websites are mobile friendly these days.
Was formerly called
LogMeIn. Due to copyright issues had to rename to AutoSignIn with a better icon. Hope we enjoy.

2. gDox (free)



An auto login app for gDocs. Live now.




3. Radio players (free)



Has a very intuitive interface for couple of iphone radio apps i have been spamming itunes store with (until they said no more). Some are regional. Below is the list.
  • Radio kannada
  • Tamil Hits
  • Telugu hits
  • Radio Eye - English radio stations organized based on top stations and genre
  • Hindi hits




4. aMaze!! (free)



An attempt to use Chipmunk physics engine and sparrow framework to build a maze game with balls moved into target square through iphone movement. Its a free app with some nice music and interface (except that the physics engine is not that great).
Learnings:
Chipmunk C library is free but hard to code(its objective C library costs 200 bucks and i didn't wanted to shell out a $). Though this was a good experience with physics engine, i found it to be unstable and not so easy to work around memory and timer issues of chipmunk C library. Would not recommend anyone to use chipmunk c library (don't know if the paid objective C bundle is better). Better go for cocos 2d. Its more popular.



5. Java JEE IQ (Was $1. Now free)



Java/j2ee quick notes for revision etc esp. during interview. It consists of notes from an industry perspective- has spring/hibernate/struts/JSR's/core java/ etc and some useful pdfs. This was my first app and i spent a lot of time learning objective c/buying macbook & ipod touch/installing snow leopard/xml parsing library/xcode/interface builder/ and understanding how to make a release to itunes. I am charging a $ for all that effort of mine. Hope it is acceptable.




All the above apps can be found by searching 'bri8' on itunes store or following this link:
http://itunes.apple.com/us/artist/bri8-ltd/id396468155



OpenID

It is so convenient to pull out information from account which user already has instead of making the user key in the boring registration form. In a way it follows DRY(do no repeat yourself) principle.

Here comes OpenID. You can also auto register the user with this php script. Cool stuff for my community site..

Open ID +PHP : http://devzone.zend.com/article/3581