Skip to main content

Posts

ArrayList vs LinkedList vs HashSet Performance Comparision

Conclusions Inserting & Reading sequentially from Collection prefer LinkedList/ArrayList Inserting & Reading/Deleting by Search/equals from Collection prefer HashSet Inserting, ArrayList & LinkedList performs best while HashSet takes double the time Reading, HashSet performs best while ArrayList & LinkedList are marginally less Deleting, HashSet performs 10 times better than ArrayList & ArrayList performs 4 times better than LinkedList. LinkedList is slow because of sequencial search Bottom line : unless you are not going to iterate using for(Integer i : list ) then prefer HashSet Inserting/Reading/Deleting integer's from zero till count JDK7 Collection action count time ms ArrayList Insert 100 0/1 LinkedList Insert 100 0/1 HashSet Insert 100 0/1 ArrayList Insert 10000 5 LinkedList Insert 10000 4 HashSet Insert 10000 7 ArrayList Insert 100000 11 LinkedList Insert 100000 11 HashSet Insert 100000 21 ArrayList Get/Read 100 0 LinkedLis...

Password Security Recommendations

User credential / Password Security. Recent security related embarrassment at Yahoo, LinkedIn and Sony has only proved that securing user information needs more considerations. Security is not a product rather a process. First identifying how username/password can be leaked and its price. Basically there are four ways an adversary can find out username/password for one or more accounts stored on the server.  1. Password guessing - Assuming adversary knows username for one or more accounts and they can       deploy dictionary attack to find correct password.  2. Adversary eavesdropping on user network ( Man in Middle Attack)  3. Adversary getting access to user computer through some virus/worm  4. Adversary getting access to username/password table or system on the server. Password Guessing : Fix :   Max invalid attempts strategy should be deployed, i.e. temporary lock the account after 4 or 5 invalid...

Use project specific license in Netbeans + Maven

Use this in pom.xml and Netbeans is intelligent enough to inject appropriate license in all newly created files. <licenses>         <license>             <name>The Apache Software License, Version 2.0</name>             <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>             <distribution>repo</distribution>             <comments>A business-friendly OSS license</comments>         </license>     </licenses> And this is what it produces /*  * Copyright 2012 intesar.  *  * Licensed under the Apache License, Version 2.0 (the "License");  * you may not use this file except in compliance with the License.  * You may obtain a copy of the License at  *  *      http://w...

Forum/Questions feature request to Github & Google

Hey Github/Google why don't you add a forum/questions feature just like other "wiki" and "issues" features. Today there is no way project adopters can ask direct questions to the project community without creating an issue and this will not scale, simply because many non-contributors do not read issues and answer's them. So eventually we are keeping big knowledge base out of helping others adopt or solve problems. Lack of this feature simply discourages people asking questions fearing they are spamming the project with issues, and eventually they will end-up not using the product. And on the other hand if you add this feature it will simply create more value, increase user engagement, and addition of new knowledge base to your system. You might also argue that why we need to duplicate this feature when there are other good sites like StackOverFlow for doing this, but adding or integrating this feature to your products is more natural as users will find...

Riak vs MongoDB vs MySQL Performance tests 1

Environment 1  Intel(R) Xeon(R) CPU           X3430  @ 2.40GHz Cores: 4 8 MB Cache Memory : 6GB ulimit : 1024 OS : CentOS 5.4 Riak : 1.1 MySQL 5.1 (Highly tuned system) Test data : Object : username, email, id Both test's were run from Java clients To make this test little meaningful I've send each read/write command to mysql in its own request. MySQL Single Node (time in ms)   inserts : 50, time : 871  inserts : 100, time : 324  inserts : 200, time : 835  inserts : 500, time : 1936  inserts : 1000, time : 3275  gets : 50, time : 55  gets : 100, time : 60  gets : 200, time : 119  gets : 500, time : 304  gets : 1000, time : 582 Riak Single Node (Recommended is 3 Nodes)   inserts : 50, time : 461  inserts : 100, time : 486  inserts : 200, time : 1473  inserts : 500, time : 3609  inserts : 1000, time : 6442  gets : 50, ti...

Simple Log4J Yahoo mail setup to recieve production errors as emails

Receive all server exceptions as email, never miss one, easy to share and discuss with the others Follow these simple steps to configure Log4j to use Yahoo mail. Step 1: Add dependencies         <dependency>             <groupId>javax.mail</groupId>             <artifactId>mail</artifactId>             <version>1.4</version>         </dependency>                <!-- Log4j -->         <dependency>             <groupId>log4j</groupId>             <artifactId>log4j</artifa...