Posts

Showing posts from June, 2011

Javascript A simple grayed out overlay

Overlay One of the most adopted feature of web2.0 is the use of a grayed out overlay panel. Overlay is useful to insert a new page inside the current page.. Almost all the javascript libraries available today comes with the overlay feature inbuilt. Below is the code snippet for overlay using plain js and html without any libraries. Code <HTML> <BODY> The javascript code to display and hide the overlay. <script type="text/javascript"> function disable1() { var blurDiv = document.createElement("div"); blurDiv.id = "blurDiv"; blurDiv.style.cssText = "position:absolute; top:0; right:0; width:" + screen.width + "px; height:" + screen.height + "px;background-color: #000000; opacity:0.5; filter:alpha(opacity=50)"; var aDiv = document.createElement("div"); aDiv.appendChild(document.createTextNode("Overlay panel")); aDiv.id = "aDiv"

Debugging minified/obfuscated javascript on production

What is minified or packed JS  Minification is the practice of removing unnecessary characters from code to reduce its size thereby improving load times. When code is minified all comments are removed, as well as unneeded white space characters (space, newline, and tab). In the case of JavaScript, this improves response time performance because the size of the downloaded file is reduced. Two popular tools for minifying JavaScript code are JSMin and YUI Compressor.  YUI compressor to minify a js  java -jar yuicompressor*.jar inputFile.js -o inputFile-min.js   Obfuscation  Obfuscation is an alternative optimization that can be applied to source code. Like minification, it removes comments and white space, but it also munges the code. As part of munging, function and variable names are converted into smaller strings making the code more compact as well as harder to read.   Debugging minified js  Following the best practices, the javascript files in production are minified/

Jconsole configuration - Tomcat

JMX local/remote monitoring configuration for tomcat using JConsole. Start tomcat with the following self-explanatory params. 1. -Dcom.sun.management.jmxremote=true 2. -Dcom.sun.management.jmxremote.port=8181 3. -Dcom.sun.management.jmxremote.authenticate=false 4. -Dcom.sun.management.jmxremote.ssl=false These two params are to solve RMI transport issues of java 1.6 5. -Djava.rmi.server.hostname=localhost 6. -Djava.net.preferIPv4Stack=true Unix/Linux export CATALINA_OPTS="-Dcon.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=8181 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false" Windows On windows set each parameter separately, otherwise you must use line separator (\). set CATALINA_OPTS=-Dcom.sun.management.jmxremote=true set CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote.port=8181 set CATALINA_OPTS=%CATALINA_OPTS% -Dcom.sun.management.jmxremote.authenticate=false