Friday, October 31

Codenameone Flow Order

This is the flow order of functions that is loaded when an application created using codenameone framework starts

 1. ImmuntiyMeterApp.init(Object context)

 2. ImmuntiyMeterApp.start()

 3. StateMachine.initVars(Resources res)

 4. StateMachine.beforeMain(Form f)

 5. StateMachine.postMain(Form f)

 6. StateMachine.StateMachine(String resFile)

Saturday, October 25

The Web Developer's must have Tool - Firebug



Without Firebug i wouldn't have learned the HTML, CSS, Javascript or the working of Web very quickly.

Firebug is a add-on that is available with  firefox browser and a firefox-lite with chrome.

So what is so great about the Firebug? 

1.  Firebug lets you inspect each HTML elements (like <a>, <div>, <table> ...) and when you inspect the element then the element, its margin, padding, border gets highlighted.

2. On inspecting a element, you can also the view the CSS used to style that part. You can also manipulate and tweak the css to view the result on the fly.

3. To see what all resources are loaded when a page is requested.To find out the time taken and the order in which the resource is loaded. To find out the status, url, domain, ip, size and Header info.

4. To debug JavaScript, to trace the stack flow of the script, to break the script and inspect the DOM and other elements at that time.

Tuesday, July 29

Irony of Science in Eid al-Fitr

In today’s world, the science has grown incredibly that we have Hubble Space Telescope  launched into space watching the universe in different spectrums. We have satellites for weather predictions; we have Terrestrial Space observatory Telescope's watching for flares in sun and climate in Jupiter. We have even accurately and safely landed man on the moon. 

We can even accurately predicate solar and lunar eclipse, the exact points in earth where it would be visible. We have even predicated the next arrival of Halley's Comet  and also the distance away from the earth. The next arrival of Halley's Comet is on 28th July 2061, and then on 7th May, 2134  and it will pass within 13.9 million km from earth.

Halley's Comet May 29 1910


In spite of all these feats, we still haven’t been able to predicate accurately the Eid al-Fitr. In India, all banks and govt office calendars marked 28th July as Eid al-Fitr holiday but it was predicted a day earlier.

The date of Eid al-Fitr for a region is confirmed by the sighting of the new moon.in that particular region. In countries like India, where even the whole nation has same time-zone can't still predicate when the new moon will occur.

Saturday, July 26

How much is the Advertisment Revenues in Media


Advertisment is the primary revenue for most media.


Industries that are spending  in online medium.
  • Electronics
  • Fashion - Men
  • Fashion - Woman
  • Baby Care
  • Video Games
  • Fitness
  • Health Care
  • Car
  • Bike
  • Jewellery
  • Dating

Sunday, July 13

To insert debug code in all functions using regular expression


Lets illustrate with a Javascript  Source Code and Notepad++ IDE

Regular Expression to Find functions

((\w*)\s*[:|=]\s*function\(\w*\)\s*\{)

Debug Code to insert inside each functions

console.log("functionName");

Regular Expression to Insert Debug Code inside Functions

$1 \n\tconsole\.log\("$2"\)\;

Note: Please enable "Regular expression" and ". matches newline" in Search Mode in Replace box in Notepad++ for inserting inside more than 1 function using regular expression.


A sample Javascript before inserting Debug code

var SyntaxHighlighter = function() {
    var sh = {
        all: function(params)
        {
            attachEvent(
                window,'description'
            );
        }
    };
}();

Javascript code after inserting Debug code using Regular Expression

var SyntaxHighlighter = function() {
      console.log("SyntaxHighlighter");
    var sh = {
        all: function(params)
        {
            console.log("all");
            attachEvent(
                window,'description'
            );
        }
    };
}();


To know more about How this Regular Expression Works and Customisation


Saturday, June 21

Eclipse IDE Shortcuts

1.   System.out.println();


syso + Ctrl + Space

2.  Toggle Comment

Ctrl + Shift + C

3.  Run Application

Ctrl + F11

4.  Import all packages

Ctrl + Shift + O

5.  Auto Complete

Ctrl + Space

6. Generate Getter and Setter

Ctrl + Shift + G

But this shortcut is not default one, so you have to set it in eclipse.

Steps to map a command to desired key combination:
  1. Goto 'Windows' menu -> 'Preferences' ->'General' -> 'Keys'
  2. In 'type filter text', type 'getter'
  3. Select command 'Generate Getters and Setters'
  4. Below in 'Binding' field, press CTRL + SHIFT + G
  5. In 'When' selection below, select 'In Windows'
  6. Click 'Apply'.
  7. If in any case there shows Conflicts then either unbind the old one or change your key combo.
  8. Click 'OK'


Saturday, May 31

Protect your Privacy in Internet from Google and other Service Providers


DNS Servers
Usually there are two DNS Servers

Prefered  DNS server : 5.135.165.179
Alternate DNS server : 8.8.8.8

Here 8.8.8.8 is the Public DNS service provided by Google.


So best way to protect yourself is by using DNS servers of your ISP or OpenDNS

BSNL DNS Server 1 :  218. 248.240.208
BSNL DNS Server 2 :  218. 248.240.23

or

OpenDNS Server1    :  208.67.222.222

OpenDNS Server2    :  208.67.220.220



More detailed reasoning at How you have no privacy from Google and other service providers



Sunday, May 25

Install LAMP (Linux Apache Mysql PHP) in ubuntu

 

Step 1 : Install Apache2

sudo apt-get update
sudo apt-get install apache2
To check the installation,try the following address in the browser
http://localhost:80/ 

Step 2 : Install Mysql

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
Enter the mysql root password,when promted during installation To do simple auto configuration of mysql follow these commands

sudo mysql_install_db
sudo /usr/bin/mysql_secure_installation
Then enter the mysql root password entered earlier
press 'n' to not change the current password

Remove anonymous users? [Y/n] y 
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n] y
For Production machines, press 'y' for option 'Remove test database and access to it?'

Step 3 : Install PHP

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
Then after installation, open below file and edit with sudo privelege.
etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>

          DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm

</IfModule>
To install other php modules or extension, first find it
apt-cache search php5-
Then install that required module
sudo apt-get install <module_name>
The default server public folder is in the below path
/var/www/

Step 4 : Restart Apache Web Server

sudo service apache2 restart 

Friday, April 11

String is immutable in java


Yes, it true that string is immutable in java which means that the String object doesn't change.
But that can't be true because we have seen many occasions in the program where the String variable is changed.

Yes its true, but we have our understanding of String a bit wrong here. Actually unlike C program, in Java, String is not a primitive variable but a special Class. So in our code  actually we are creating a String object for new character sequence.

For more understanding go to this link String can't be immutable in java

Friday, April 4

Neo4j Community Build Error


To build the neo4j community,  I am following  the steps as done in Travis CI link here.

But i am getting the error below
[ERROR] Failed to execute goal org.neo4j.build.plugins:license-maven-plugin:3:check (check-licenses) on project neo4j-kernel: Some files do not have the expected license header -> [Help 1] 
To solve this "Build the community/license-check submodule first." as suggested in SO link here.

But still i am getting the same error.

Please check whether my steps taken are correct or not.


/$ mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.6.0_30, vendor: Sun Microsystems Inc.
Java home: /usr/lib/jvm/java-6-openjdk-amd64/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-60-generic", arch: "amd64", family: "unix"



/$ cd ~/Workspace/neo4jdev/community-experiments/licensecheck-config/
~/Workspace/neo4jdev/community-experiments/licensecheck-config$ mvn install

[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.239s
[INFO] Finished at: Fri Apr 04 15:06:07 IST 2014
[INFO] Final Memory: 14M/148M



~/Workspace/neo4jdev/community-experiments/licensecheck-config$ cd ..
~/Workspace/neo4jdev/community-experiments$ MAVEN_OPTS="-Xss2m -Xmx1G"
~/Workspace/neo4jdev/community-experiments$ mvn install -DskipTests

[INFO] --- license-maven-plugin:3:check (check-licenses) @ neo4j-kernel ---
[INFO] Checking licenses...

[INFO] [INFO] Missing header in: /~/Workspace/neo4jdev/community-experiments/kernel/src/test/java/org/neo4j/unsafe/batchinsert/BatchInserterImplTest.java
[INFO] Missing header in: /~/Workspace/neo4jdev/community-experiments/kernel/src/test/java/org/neo4j/kernel/RaceBetweenCommitAndGetMoreRelationshipsIT.java
[INFO] Missing header in: /~/Workspace/neo4jdev/community-experiments/kernel/src/main/java/org/neo4j/tooling/GlobalGraphOperations.java

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Neo4j - Graph Database Kernel ..................... FAILURE [1.719s]
[INFO] Neo4j - JMX support ............................... SKIPPED
[INFO] Neo4j - Usage Data Collection ..................... SKIPPED
[INFO] Neo4j - Graphviz generation ....................... SKIPPED
[INFO] Neo4j - Lucene Index .............................. SKIPPED
[INFO] Neo4j - Graph Algorithms .......................... SKIPPED
[INFO] Neo4j - Graph Matching ............................ SKIPPED
[INFO] Neo4j - Cypher .................................... SKIPPED
[INFO] Neo4j Community ................................... SKIPPED
[INFO] Neo4j Community ................................... SKIPPED
[INFO] Neo4j - Generic shell ............................. SKIPPED
[INFO] Neo4j Examples .................................... SKIPPED
[INFO] Neo4j Server API .................................. SKIPPED
[INFO] Neo4j Server ...................................... SKIPPED
[INFO] Neo4j Server Examples ............................. SKIPPED
[INFO] Licensing configuration ........................... SKIPPED
[INFO] Neo4j Community Build ............................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.427s
[INFO] Finished at: Fri Apr 04 15:08:26 IST 2014
[INFO] Final Memory: 14M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.neo4j.build.plugins:license-maven-plugin:3:check (check-licenses) on project neo4j-kernel: Some files do not have the expected license header -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


Resolved

The license check is failing may because of some repository url may have changed,  which we have no control of so its better to skip the license check.

The following command will help to skip license check and build sucessfully.
$ mvn install -DskipTests -Dlicensing.skip

In linux os, it build successfully but in windows there were some issues in project "neo4j-browser" so i skipped that project to successfully  build in windows too.

Below is the error in windows in project neo4j-browser
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Licensing configuration ........................... SUCCESS [  2.796 s]
[INFO] Neo4j - Primitive Collections ..................... SUCCESS [  0.794 s]
[INFO] Neo4j - Graph Database Kernel ..................... SUCCESS [01:34 min]
[INFO] Neo4j - JMX support ............................... SUCCESS [  1.362 s]
[INFO] Neo4j - Usage Data Collection ..................... SUCCESS [  3.880 s]
[INFO] Neo4j - Monitor Logging ........................... SUCCESS [  1.120 s]
[INFO] Neo4j - Graphviz generation ....................... SUCCESS [  1.592 s]
[INFO] Neo4j - Lucene Index .............................. SUCCESS [  4.390 s]
[INFO] Neo4j - Graph Algorithms .......................... SUCCESS [  2.070 s]
[INFO] Neo4j - Graph Matching ............................ SUCCESS [  1.230 s]
[INFO] Neo4j Community Cypher Build ...................... SUCCESS [ 11.080 s]
[INFO] Neo4j - Cypher Commons ............................ SUCCESS [ 50.804 s]
[INFO] Neo4j - Cypher Compiler 2.1 ....................... SUCCESS [03:45 min]
[INFO] Neo4j - Cypher .................................... SUCCESS [ 37.636 s]
[INFO] Neo4j Community ................................... SUCCESS [  1.420 s]
[INFO] Neo4j GraphGist ................................... SUCCESS [  6.780 s]
[INFO] Neo4j - Cypher Documentation ...................... SUCCESS [ 36.070 s]
[INFO] Neo4j Community ................................... SUCCESS [  0.750 s]
[INFO] Neo4j - Generic shell ............................. SUCCESS [  3.550 s]
[INFO] Neo4j Examples .................................... SUCCESS [  1.790 s]
[INFO] Neo4j Server API .................................. SUCCESS [  1.920 s]
[INFO] Neo4j Browser ..................................... FAILURE [  0.430 s]
[INFO] Neo4j Server ...................................... SKIPPED
[INFO] Neo4j - Server Plugin Tests ....................... SKIPPED
[INFO] Neo4j Server Examples ............................. SKIPPED
[INFO] Neo4j Community Build ............................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:15 min
[INFO] Finished at: 2014-04-11T17:08:08+05:30
[INFO] Final Memory: 54M/302M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (default) on project neo4j-browser: An An
t BuildException has occured: unless=cmdsuccess -> [Help 1]

Now if you want to continue by skipping the project "Neo4j Browser", follow the below command
$ mvn install -DskipTests -Dlicensing.skip -e -rf :neo4j-server


Atlas, successfully build
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Neo4j Server ...................................... SUCCESS [01:55 min]
[INFO] Neo4j - Server Plugin Tests ....................... SUCCESS [  3.482 s]
[INFO] Neo4j Server Examples ............................. SUCCESS [  1.880 s]
[INFO] Neo4j Community Build ............................. SUCCESS [  0.440 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:05 min
[INFO] Finished at: 2014-04-11T17:20:07+05:30
[INFO] Final Memory: 46M/227M
[INFO] ------------------------------------------------------------------------