Relove Netbeans

Almost a decade using NetBeans as my primary development IDE, I was always fell that NetBeans is lag behind IntelliJ especially their elegant Darcula theme which I like the most and some features offered is very responsive.

Anyway, I did not continue using it because the ultimate version is a bit pricy for me, and using the feature limited community edition make me feel like owning a jet aircraft but limited jet fuel.

So… download the latest NetBeans 8.1 and did some customization…
Da… Dang…. here is my new look and feel of NetBeans.

netbeans8.1

Anyway, the dark theme is not new, but I just realize using it with some other font and theme can be nice too 🙂

Besides that, the IDE now have better support for Html5/Javascript and AngularJS works much better than before (full release note here)

Here are my customization to share:

  1. Install “Dark Look and Feel Themes” from Netbeans plugin portal (Tools –> Plugins)
    dark-look-and-feel
  2. Dark Nimbus theme (Tools –> Options –> Appearance –> Preferred Look and Feel)
  3. Norway Today profile (Tools –> Options –> Fonts & Colors –> Profile)
  4. Gisha 14 as font display (Tools –> Options –> Fonts & Colors –> Syntax)
    (Note: OSX does not have this font, but default Monospaced looks good)
  5. 1.1 point line spacing (Need to add an entry as below in C:\Users\{YOU}\AppData\Roaming\NetBeans\{VERSION}\config\Editors\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml)
    (Note: OSX path @ /Users/{YOU}/Library/Application Support/NetBeans/{VERSION}/config/Editors/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml)

    <entry javaType="java.lang.Float" name="line-height-correction" xml:space="preserve">
        <value><![CDATA[1.1]]></value>
    </entry>
 

Microservices With 12factor

Stumble upon 12factor.net when I was reading some technical documentation @ heroku.

Noted there are couple of suggestions worth practicing even we are not toward micro services paradigm.

By adapting their recommendation such as, Create a code base per app; Set only implicit dependency to the app for eg: runtime library, dependency manager which contrary to explicit dependency like curl, system tools; Store configuration in enviroment variable; Treat backing service (database, email server, authentication server) as independent resource….. etc… etc.. allow us not only create highly scalable application, but also increase agility of application development and deployment.

 

Hibernate Envers With Existing Data

java.lang.RuntimeException: Cannot update previous revision for entity com.xxx.yyy.Users_audit 
and id 1
2015-11-12 16:22:19,168 ERROR [http-nio-8000-exec-3] EntitlementControllerAdvice: 
Unable to perform beforeTransactionCompletion callback
org.hibernate.AssertionFailure: Unable to perform beforeTransactionCompletion callback
...
...
...
Caused by: java.lang.RuntimeException: Cannot update previous revision for entity 
com.xxx.yyy.Users_audit and id 1
at org.hibernate.envers.strategy.ValidityAuditStrategy$1.doBeforeTransactionCompletion(ValidityAuditStrategy.java:223)

It’s because we configure ValidityAuditStrategy for audit strategy. Changing it to use DefaultAuditStrategy solve the problem, pheeeew…. (of course there are some trade off, which will not discuss here 🙂 )

From hibernate envers documentation:

ValidityAuditStrategy : Stores both the start revision and the end revision. Together these define when an audit row was valid.

DefaultAuditStrategy: Stores only the revision, at which an entity was modified.

 

 

3 minutes Docker Introduction

docker-whale

Many years ago, what we do when we want to deploy and run our application after development? Typically we will setup physical machine, this normally including but not limited to system tools, jdk, python, database, application server etc..etc.. then deploy and run.

If we have multiple environment to deploy and run, then we repeat the same step for all environment, eg: dev, qa, staging, production.

After few years, people tend to make their life easier by not setup, deploy and run the application directly on physical machine, but using virtual machine where they can easily clone it for other environment (figure 1 show architecture of virtual machine).

docker1figure 1
image from: www.docker.com

When more and more application run with different runtime environment, framework version, database vendor, server etc… Of cause deploying and running on top of virtual machine still works fine, but virtual machine is an operating system imitates dedicated hardware, meaning it shared host hardware system’s resources, which will then no longer available to the hosted applications.

Emerged of Docker container in perfect timing is good fit for this. It is a process that talks directly to the Linux kernel. And run as isolated process in host operating system. Meaning, we can now deploy our application in smaller container instead of virtual machine. (figure 2 show architecture of Docker).

docker2figure 2
image from: www.docker.com

If you still confuse Docker is just another type of virtual machine, figure 3 might clear your doubts.

vm-docker
figure 3

p/s: Docker looks promising and it is really a good match for microservices, nevertheless, it has some security concern as they are sharing same kernel with host.
Container and virtual machine have different strength, hence should not viewed as competitors, but complimentary.

Source:
Docker documentation
Self-pace video tutorial
Virtualization vs. Containers: What You Need to Know

 

 

Hadoop Distribution for Windows x64

Found it difficult to get hadoop distribution for my development use in Windows box. Decided to compile myself, and for those who face the same problem with me, you may click here to download (v2.5.2, v2.6.0, v2.7.1), or refer the complementary building guide (on top of BUILDING.txt from hadoop source) to compile yourself.

Happy hadooping 🙂

p/s : I re-archive some of the distribution to 7z instead tar.gz  due to my “free” online storage upload limit. And I personally tried with v2.7.1 only which working fine.

 

Beware when import cordova.js

If you would like to trigger the “deviceready” event fires when Cordova is fully loaded for some plugin usage,

document.addEventListener("deviceready", callbackFunction, false);

you need to include cordova.js in your application.

<script type="text/javascript" src="cordova.js"></script>

OK, you are done.

If you facing some unknown error in console as below even you have whitelist plugin added, cordova.js included,

Uncaught Error: Module cordova-plugin-whitelist.whitelist does not exist.
cordova.js:891 deviceready has not fired after 5 seconds.
cordova.js:884 Channel not fired: onPluginsReady
cordova.js:884 Channel not fired: onCordovaReady

then probably you include cordova.js wrongly as what I did (get from /platforms/android/assets/www/cordova.js)

<script src="asset/js/cordova.js"></script>

NOTE: You does not need to copy cordova.js from anywhere, just include as above mention will do, Cordova will figure out for u 🙂

 

Having pbcopy and pbpaste in Cygwin

Just add these 2 lines in your .bashrc

alias pbcopy="cat >/dev/clipboard"
alias pbpaste="cat /dev/clipboard"

We can now copy text into clipboard by piping it to pbcopy

# Copy current path
pwd | pbcopy

# Copy current datetime
date | pbcopy

And paste it from clipboard by pbpaste

# Paste it to new file
pbpaste > path.txt

# Paste it to terminal
pbpaste