Friday, December 6, 2013

LDAP Failover configuration


Using referral attribute it is possible to implement  LDAP - Failover, though it still needs to be tested.

http://docs.oracle.com/javase/jndi/tutorial/ldap/misc/url.html#MULTI

Improving Website Performance without fixing code!

Google's pagespeed is a component that can be deployed on an nginix or an apache server that compresses and caches web static resources such as css / js files and modifies header instructions on the fly to enable browser caching.

https://developers.google.com/speed/pagespeed/


Friday, May 3, 2013

Unix Commands



  • How to find out the unix system / server architecture type?
  • uname -a






Tuesday, September 18, 2012

How to Avoid Getter and Setter Methods in JAVA, JSF and any POJO's

The lombok java utility helps to avoid getter and setter methods in java, especially in JSF and any POJO's 

After Installing it (very simple 2 click process) and add the same jar to your project's classpath.

Here is an example of how to avoid getters and setters in java using lombak.jar , scala does that but just to avoid getters and setters this utility is more than enough.

Example:
public class Person{
public String name;
public int age;
public int getAge(){
   return this.age;
}
public void setAge(int argAge){
 this.age = argAge;
}
//[...] Other Getters and Setters HERE.
}

To convert the POJO use the "@Data" annotation as follows. 

@Data public class Person{
   public String name;
   public int age;
}
That's it deploy / code / refactor / life is short - Enjoy!


  • There are more handy and specific annotations head over to the website.
  • Reduces all the noisy clutter methods in the class, no need for the lombak jar to be present during runtime.
  • Works like magic with IBatis & JRebel also!
  • Your IDE still sees the getter and setter methods as though they exist. (Atleast in eclipse it does for me! )
  • Reduces the code size of the project by at least 30%. 


Many Thanks to the lombak team!

Thursday, April 19, 2012

JMS Jboss behind NAT firewall



JMS clients like swing or remote clients were unable to connect to the JBOSS server because of random ports and the ip address of the machine which was not the same as the internal ip address of the machine from the cloud provider. When JBOSS starts it has to bind with the ip address of 0.0.0.0


  1. Open inbound port 443, the JMS client was unable to connect to the server.
  2. The following ports were opened on inbound.
    • 8083, and 8093
    • 8080,
    • 1098-1099,
    • 8009,
    • 4444-4445 & 4457
  3. Once the above ports were opened, the JMS client is able to connect to that IP address.
  4. At this point the server basically returns the host name (name of the box devjmsserver) , since that was not a FQDN like devserverjms.domain.com it failed. 
    1. For this reason a host name was created and a subdomain under the main domain was created to point to this public ip address.
  5. The FQDN now created was devserverjms.maindomain.com
    • Still the JMS client is not able to connect to the server.
  6. On the server listing all the ports that the jboss server was listening to, it picked random ports greater than the >1024 < 65000
    1. netstat -tulnp will list all the ports
  7. The jboss server on startup assigns random ports, we have to “fix” the ports that the server is listening to. 
    1. For this we have to edit the /home/jboss/jboss-5.1.0.GA/server/default/deploy/messaging/remoting-bisocket-service.xml and edit the serverBindProperty and serverConnectorProperty to a fixed non clashing port, for this test environment we gave it as 7914.
  8. Now running the client it is able to resolve and connect to it and send messages to that server.

Wednesday, March 14, 2012

Cassandra super column

An excellent article on Cassandra super column

http://arin.me/blog/wtf-is-a-supercolumn-cassandra-data-model

From cassandra learning resources at this link.

http://programmers.stackexchange.com/questions/28992/best-cassandra-learning-resources

Monday, March 12, 2012

MySQL Group_concat (transposing rows into columns)

To find out the columns in a table in mysql where you might need it programatically. You can use the information schema.

 SELECT group_concat(column_name) as columnNames

 FROM information_schema.columns

 WHERE 

     `TABLE_NAME` = 'EMPLOYEE_TABLE'

 

This would produce the  output as a single row instead of columns.

> EMP_ID,EMP_NAME,EMP_AGE

The group_concat transposes a result set from rows into columns, which is very ideal and can save some compute logic on the application side.

http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat

Wednesday, December 28, 2011

Hadoop Tutorial

Yahoo! Hadoop Tutorial This tutorial includes the following materials designed to teach you how to use the Hadoop distributed data processing environment: Hadoop 0.18.0 distribution (includes full source code) A virtual machine image running Ubuntu Linux and preconfigured with Hadoop VMware Player software to run the virtual machine image A tutorial which will guide you through many aspects of Hadoop's installation and operation.

Tuesday, December 27, 2011

Web Usability - Accessible Data Tables

Making your JSF datatable and html tables more accessible and 508 compliant.

Thursday, December 22, 2011

Firefox Share (alpha) :: Add-ons for Firefox

Cool add on to post from the firefox address bar.

Thursday, December 15, 2011

CSS best practices


CSS Notes

I have compiled few CSS best practices and notes from various sources. I have attempted to give the original authors the credit, but if I am missing anything please leave a comment to correct. 

What are the benefits of using CSS over normal HTML element?

a. Re-usability with CSS we can reuse styles that can be applied across different html elements.

b. Maintenance:- Easier to maintain few or more well structured css files.


What is the difference between DIV and SPAN tags, how does it affect layouts and CSS usage?
A DIV tag makes a paragraph break for the content within the DIV tag.  In other words when the browser encounters a div tag it does a paragraph break and renders the content and followed by a paragraph break.

A span tag does no do that. The latter inlines contents and the former block content.

Both the tags apply it's CSS style to its child elements.



The following are block tags:-
div, h1...h6, p, ul, li, table, blockquote, pre, form 

The following are inline tags:-span, a, strong, em, img, br, input, abbr, acronym 

What are CSS selectors?


Every HTML element can be identified by the following forms by it's class attribute, id attribute and the HTML element in itself can be targeted as identifier (TABLE, TR, TD).

However in the final option that style would be applied to all the elements in the document tree regardless of its occurrence.

1. Example Class Based Selector :-
/** Targets all elements whose class attributes match **/.sampleCssClass {
  color: #ddd;
}

content


2. Example ID Based Selector :-
/** Targets all h1 tags where attribute id is equal to headerText **/h1#headerText {
 color: red;
}

content goes here




3. Example Targeted Element Based Selector :-
/** Targets all specific table elements **/table.SampleCssClass{
 background-image: url('/images/fenil.png');
}

How can more than one CSS style class be applied to the same element ? Space separated list of css styles on the class attribute of the html content. In the case of icefaces put it in the style class attribute, then it will automatically be rendered as the class attribute when the dom tree is built.

What kind of CSS selector should we use?

Class based selector for maximum re-use.
Things to keep in mind before writing CSS  CLASS based selectors?

a. Avoid element specific style attributes.
b. element specific style attributes can be in a different css class.

What is CSS Reset?



A CSS reset, is resets the style that may be the default in a browser, so the margin and padding can be set as 0px for a default list of elements.


What is CSS Alphabetizing, and why should we alphabetize it?Ordering the style elements within a CSS class by alphabetical order.

For example
:-



.classUnorderedElements {


BORDER-RIGHT: #a52a2a 3px solid;
PADDING-RIGHT: 3px;
BORDER-TOP: #a52a2a 3px solid;
PADDING-LEFT: 3px;
Z-INDEX: 1;
LEFT: 50%;
FLOAT: none;
VISIBILITY: visible;
PADDING-BOTTOM: 3px;
MARGIN: 2px;
BORDER-LEFT: #a52a2a 3px solid;
PADDING-TOP: 3px;
BORDER-BOTTOM: #a52a2a 3px solid;
POSITION: absolute;
TOP: 21%;
BACKGROUND-COLOR: #ffb6c1
}


The above is an example where the elements within the class are un ordered alphabetically.






Why should we alphabetically order the elements within a css class?
    It is easier to scroll through and debug specific elements in a css class when we come across  it.
    It is more time consuming to read element by element.




What is a CSS shortcut?


Example .longclass{
 margin-top: 11px; margin-right: 11px; margin-bottom: 11px; margin-left: 11px;
}


Example .shortCutClass{
 margin:11px;
}


The same can be said for padding and certain other attributes.




Should I group elements in one line when I write code or should I write each element in a separate line?


Write each style element in a new line, alphabetized in a new line.


.classOrderedElements {
BORDER-RIGHT: #a52a2a 3px solid; BORDER-LEFT: #a52a2a 3px solid;

BORDER-TOP: #a52a2a 3px solid; BORDER-BOTTOM: #a52a2a 3px solid;
BACKGROUND-COLOR: #ffb6c1
FLOAT: none;LEFT: 50%;
MARGIN: 2px;
PADDING-RIGHT: 3px;
PADDING-LEFT: 3px; PADDING-BOTTOM: 3px;
PADDING-TOP: 3px;
POSITION: absolute;
TOP: 21%;
VISIBILITY: visible;
Z-INDEX: 1;
}
Do Not Write as below, because certain editors may scroll all the way to the right. And it would be difficult to debug.



.classUnorderedElements {

BORDER-RIGHT: #a52a2a 3px solid; BORDER-LEFT: #a52a2a 3px solid; BORDER-TOP: #a52a2a 3px solid; BORDER-BOTTOM: #a52a2a 3px solid; BACKGROUND-COLOR: #ffb6c1

FLOAT: none; LEFT: 50%; MARGIN: 2px; PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px;PADDING-TOP: 3px; POSITION: absolute; TOP: 21%; VISIBILITY: visible;Z-INDEX: 1;
}



If it is an effective shortcut, which as follows, then that can be combined in a single line, as long as it does not exceed the default view port of an editor (80 columns)


.originalLongClass{


    margin-left:    5px;  
    margin-right:   7px;  
    margin-top8px;  
}
.newShortCutClass
    margin8px 7px 0px 5px;
}


What about performance, since new lines take up space and more time to download the CSS files each time?


That is the job of the compressor to do at build time when a product build is done. For development it should be a new line.




What is the difference between em's , pt , px and percent?

I wish I knew where I found this to give proper credit, please leave a comment and I will link to the appropriate post.

Meet the Units

  1. “Ems” (em): The “em” is a scalable unit that is used in web document media. An em is equal to the current font-size, for instance, if the font-size of the document is 12pt, 1em is equal to 12pt. Ems are scalable in nature, so 2em would equal 24pt, .5em would equal 6pt, etc. Ems are becoming increasingly popular in web documents due to scalability and their mobile-device-friendly nature.
  2. Pixels (px): Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one dot on the computer screen (the smallest division of your screen’s resolution). Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser. One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices.
  3. Points (pt): Points are traditionally used in print media (anything that is to be printed on paper, etc.). One point is equal to 1/72 of an inch. Points are much like pixels, in that they are fixed-size units and cannot scale in size.
  4. Percent (%): The percent unit is much like the “em” unit, save for a few fundamental differences. First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully scalable for mobile devices and for accessibility.




__________________________________________________


a) How can I increase the font size of my entire site?

b) Accessibility?

c) Performance.

Yahoo has a CSS compressor that can be configured as an ant task.


d) Separate skins based on user preferences.






e) Separate CSS styles for structure and skin?


Do not combine colors or intermix colors in between structure and skin, also handle transparency.


Identify the structural CSS.


Identify the skin CSS that you want to apply for that stucture.


Further identify the background and foreground elements of that skin.




f) Separate container and content.Identify the container tags or style that will hold your content.


Identify the content tags or style that will hold your content.


g) DOCTYPE declaration and CSS compatibilities.

h) CSS Organization


The CSS classess within the document can match the typical layout of the website.


For example the bottom of the page is the footer and the top of the css file contains the classes for the header elements.


It can be grouped based on relationship and context.


It can be grouped based on page element based or section based.


In other words given an element we should identify where the matching css could be found quickly.


__________________________________________________


Credits and Useful Links

http://www.toxel.com/design/2009/01/11/top-50-best-css-articles-and-resources/

http://www.w3.org/TR/CSS2/selector.html

http://www.digital-web.com/articles/architecting_css/

http://net.tutsplus.com/tutorials/html-css-techniques/5-tips-to-writing-better-css/

http://www.w3schools.com/css/css_pseudo_classes.asp





How to find the current logged in windows user from java?


The class NTSystem will help to retrieve the logged in user name and other credentials.

Example:

NTSystem obj = new NTSystem();
System.out.println("Logged In User Name "+obj.getName());


From the java docs :-


This class implementation retrieves and makes available NT security information for the current user.

http://docs.oracle.com/javase/6/docs/jre/api/security/jaas/spec/index.html?com/sun/security/auth/module/package-summary.html

Wednesday, November 30, 2011

Inputs and Conditional Processing in Batch File

To get input from the console in a batch file and assign it to a variable  the following syntax works very well.

set /p name=Debug Y/N?

Then you can Echo %name% to print the contents of that variable.

To conditionally check for the content of that variable

IF "%name%" == "y" (other dos commands go here...) Without the enclosing braces :-)


I found it particularly usefull to start my jboss with some agents disabled conditionally based on what options I choose, that way I can still play around with multiple agents and debugging options without having to maintain multiple copied of the run.bat files, which is messy !!!

Tuesday, November 29, 2011

Split String on every UpperCase Letter, String Modify Array and String Join the array as a single word.


For example we have a string like “thisIsTheDay”

http://stackoverflow.com/questions/3752636/java-split-string-when-an-uppercase-letter-is-found

1.String sample = “thisIsTheDay”;
2.String[] sampleArray = sample.getChartType().split("(?=\\p{Lu})");
3.sampleArray = (String[])ArrayUtils.removeElement(sampleArray, "this");
4. String newStringName  = StringUtils.join(sampleArray," ");

Line 1: Declares a sample string.

Line 2: Splits the string for every unicode character that it encounters.

Line 3: Removes any unwanted words from the new array.

Line 4: Joins the elements of the array as a new word.