<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3143222736230165985</id><updated>2012-01-07T14:10:32.085-08:00</updated><category term='install'/><category term='show'/><category term='clustering'/><category term='attachment'/><category term='processing'/><category term='installation'/><category term='li'/><category term='html5'/><category term='default password'/><category term='max os x'/><category term='opendocument'/><category term='cookie'/><category term='validation'/><category term='hashmap'/><category term='css'/><category term='email'/><category term='gradient'/><category term='xml'/><category term='navigation bar'/><category term='snippets'/><category term='set java_home'/><category term='java'/><category term='attribute'/><category term='toggle'/><category term='jdk'/><category term='script-fu'/><category term='ical'/><category term='cd'/><category term='javax'/><category term='bufferedreader'/><category term='move'/><category term='inbox zero'/><category term='pdf'/><category term='doc'/><category term='batch'/><category term='isp'/><category term='read'/><category term='build'/><category term='javac'/><category term='html'/><category term='dsl'/><category term='file type'/><category term='parameter'/><category term='vba macro'/><category term='web browser'/><category term='screenshot processor'/><category term='examples'/><category term='mail'/><category term='url'/><category term='dom'/><category term='javascript'/><category term='admin'/><category term='link bar'/><category term='cluster'/><category term='documents'/><category term='object identity'/><category term='terracotta'/><category term='png'/><category term='_blank'/><category term='executable'/><category term='browser launch'/><category term='console'/><category term='mail.app'/><category term='snap backup'/><category term='browser'/><category term='openstream'/><category term='hide'/><category term='gimp'/><category term='bat'/><category term='windows'/><category term='background'/><category term='microsoft word'/><category term='dos'/><category term='image'/><category term='folders'/><category term='neooffice'/><category term='progressive enhancement'/><category term='cmd'/><category term='microsoft outlook'/><category term='email attachement'/><category term='router'/><category term='ant'/><category term='onclick'/><category term='tutorial'/><category term='files'/><category term='target'/><category term='safe'/><category term='safari bookmarks'/><category term='readline'/><category term='odf'/><category term='command script'/><category term='jquery'/><category term='example code'/><category term='servers'/><category term='administration'/><category term='nodes'/><category term='virus'/><category term='parser'/><category term='ul'/><category term='reuse'/><category term='done button'/><title type='text'>techdem</title><subtitle type='html'>Random Bits</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-3876210327698168520</id><published>2012-01-01T08:00:00.000-08:00</published><updated>2012-01-05T01:23:13.014-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='reuse'/><category scheme='http://www.blogger.com/atom/ns#' term='progressive enhancement'/><category scheme='http://www.blogger.com/atom/ns#' term='ul'/><category scheme='http://www.blogger.com/atom/ns#' term='link bar'/><category scheme='http://www.blogger.com/atom/ns#' term='li'/><category scheme='http://www.blogger.com/atom/ns#' term='navigation bar'/><category scheme='http://www.blogger.com/atom/ns#' term='html5'/><category scheme='http://www.blogger.com/atom/ns#' term='background'/><category scheme='http://www.blogger.com/atom/ns#' term='validation'/><category scheme='http://www.blogger.com/atom/ns#' term='gradient'/><category scheme='http://www.blogger.com/atom/ns#' term='css'/><title type='text'>Pure CSS Navigation Bar with No Image Files or JavaScript</title><content type='html'>A navigation bar styled purely with CSS is easier to modify and reuse than one dependent on image files or JavaScript.&lt;br&gt;&lt;br&gt;&lt;a href="http://www.centerkey.com/files/pure-css-nav-bar.html"   onclick="this.target='_blank';"&gt;&lt;img class=picture-box   src="http://2.bp.blogspot.com/-0J8KBE55eeQ/Tv-AuUJjFsI/AAAAAAAAAOE/k7OHslp1j6M/s1600/pure-css-menu-bar.png"&gt;&lt;/a&gt;&lt;div class=box-caption&gt;Pure CSS Navigation Bar&lt;/div&gt;&lt;br&gt;HTML for a navigation bar (a flat menu bar also called a nav bar or link bar) should contain just the list of buttons with their respective links.&lt;br&gt;&lt;br&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;&amp;lt;ul class=navigation-bar&amp;gt;&lt;br /&gt;   &amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;#a&amp;quot;&amp;gt;Alligator&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;   &amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;#b&amp;quot;&amp;gt;Bullfrog&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;   &amp;lt;li class=current&amp;gt;&amp;lt;a href=&amp;quot;#c&amp;quot;&amp;gt;Cheetah&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;   &amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;#d&amp;quot;&amp;gt;Dolphin&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;&amp;lt;/ul&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=box-caption&gt;Example Navigation Bar HTML&lt;/div&gt;&lt;br&gt;&lt;i&gt;Pure CSS Navigation Bar&lt;/i&gt; uses CSS to layout the buttons horizontally by disabling &lt;code&gt;list-style-type&lt;/code&gt; and displaying the list items as &lt;code&gt;table-cell&lt;/code&gt; elements.&lt;br&gt;&lt;br&gt;&lt;div class=code-box&gt;&lt;pre&gt;ul.navigation-bar {&lt;br /&gt;   list-style-type: none;&lt;br /&gt;   background-image: -webkit-linear-gradient(top, silver, midnightblue);&lt;br /&gt;   background-image:    -moz-linear-gradient(top, silver, midnightblue);&lt;br /&gt;   background-image:     -ms-linear-gradient(top, silver, midnightblue);&lt;br /&gt;   background-image:         linear-gradient(top, silver, midnightblue);&lt;br /&gt;   border: 2px solid dimgray;&lt;br /&gt;   padding: 0px;&lt;br /&gt;   margin: 0px;&lt;br /&gt;   background-color: midnightblue; /* IE6...IE9 */&lt;br /&gt;   *line-height: 3.2em; /* IE6,IE7 */&lt;br /&gt;   }&lt;br /&gt;ul.navigation-bar li {&lt;br /&gt;   display: table-cell;&lt;br /&gt;   *display: inline; /* IE6,IE7 */&lt;br /&gt;   }&lt;br /&gt;ul.navigation-bar li a {&lt;br /&gt;   display: table-cell;&lt;br /&gt;   text-decoration: none;&lt;br /&gt;   outline: none;&lt;br /&gt;   font-size: 120%;&lt;br /&gt;   color: white;&lt;br /&gt;   border-right: 2px solid dimgray;&lt;br /&gt;   padding: 15px 25px; /* sets button size */&lt;br /&gt;   }&lt;br /&gt;ul.navigation-bar li a:hover {&lt;br /&gt;   background-color: rgba(255, 255, 255, 0.2);&lt;br /&gt;   }&lt;br /&gt;ul.navigation-bar li.current a:hover {&lt;br /&gt;   background-color: rgba(255, 255, 255, 0.0);&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class=box-caption&gt;Pure CSS Navigation Bar&lt;/div&gt;&lt;br&gt;Try it out:&lt;div class=indent&gt;   &lt;a href="http://www.centerkey.com/files/pure-css-nav-bar.html"      onclick="this.target='_blank';"&gt;&lt;i&gt;Pure CSS Navigation Bar&lt;/i&gt; in Action&lt;/a&gt;&lt;/div&gt;&lt;br&gt;The &lt;a href="http://www.centerkey.com/colors/"&gt;color&lt;/a&gt; for the navigation bar in the example screenshot is &lt;code&gt;midnightblue&lt;/code&gt;.&amp;nbsp;  Other professional looking colors for the navigation bar include &lt;code&gt;firebrick&lt;/code&gt;, &lt;code&gt;seagreen&lt;/code&gt;, &lt;code&gt;sienna&lt;/code&gt;, &lt;code&gt;darkslategray&lt;/code&gt;, and &lt;code&gt;dimgray&lt;/code&gt;.&lt;br&gt;&lt;br&gt;&lt;i&gt;Pure CSS Navigation Bar&lt;/i&gt; will work on sites that &lt;a href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.centerkey.com%2Ffiles%2Fpure-css-nav-bar.html"&gt;validate to strict HTML or HTML5&lt;/a&gt;.&amp;nbsp;  And it follows a progressive enhancement strategy in that the navigation bar will display and function correctly for most all web browsers while providing improved visual effects for standards compliant web browsers.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-3876210327698168520?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/3876210327698168520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=3876210327698168520' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/3876210327698168520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/3876210327698168520'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2012/01/pure-css-navigation-bar-with-no-image.html' title='Pure CSS Navigation Bar with No Image Files or JavaScript'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-0J8KBE55eeQ/Tv-AuUJjFsI/AAAAAAAAAOE/k7OHslp1j6M/s72-c/pure-css-menu-bar.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-1638770904825712526</id><published>2011-12-20T21:50:00.000-08:00</published><updated>2012-01-01T13:23:37.357-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='_blank'/><category scheme='http://www.blogger.com/atom/ns#' term='onclick'/><category scheme='http://www.blogger.com/atom/ns#' term='jquery'/><category scheme='http://www.blogger.com/atom/ns#' term='html5'/><category scheme='http://www.blogger.com/atom/ns#' term='attribute'/><category scheme='http://www.blogger.com/atom/ns#' term='validation'/><category scheme='http://www.blogger.com/atom/ns#' term='html'/><category scheme='http://www.blogger.com/atom/ns#' term='target'/><category scheme='http://www.blogger.com/atom/ns#' term='browser'/><title type='text'>Simple Workaround for Strict HTML Validation of _blank Target</title><content type='html'>There are times when it's legitimate to automatically open up a link in a new tab or window of the user's web browser.&amp;nbsp;  Setting the link's "target" attribute to "_blank" used to be the correct way to realize this behavior.&lt;br /&gt;&lt;br /&gt;&lt;div class="code-box"&gt;   &lt;pre&gt;&amp;lt;a href="http://www.snapbackup.org/" target="_blank"&amp;gt;backup&amp;lt;/a&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Obsolete Usage&lt;/div&gt;&lt;br /&gt;Partly because the target expresses behavior instead of content, the "target" attribute has been depreciated and does not pass &lt;a href="http://validator.w3.org/"&gt;validation for strict HTML or HTML5&lt;/a&gt;.&amp;nbsp;  There's a cheap and dirty JavaScript trick that achieves the desired behavior and still validates.&lt;br /&gt;&lt;br /&gt;&lt;div class="code-box"&gt;   &lt;pre&gt;&amp;lt;a href="http://www.snapbackup.org/" onclick="this.target='_blank';"&amp;gt;backup&amp;lt;/a&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Compact (and valid HTML) Workaround&lt;/div&gt;&lt;br /&gt;Example link with "_blank" target:   &lt;div class=indent&gt;&lt;a href="http://www.snapbackup.org/" onclick="this.target='_blank';"&gt;backup&lt;/a&gt;&lt;/div&gt;&lt;br&gt;This workaround does pollute the semantics of the HTML with behavior instructions, but it's compact, easy to understand, and validates.&lt;br /&gt;&lt;br /&gt;For sites with jQuery, you can keep the HTML cleaner by using the &lt;a href="http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/"&gt;"rel" attribute to designate external links&lt;/a&gt; and then adding targets with a jQuery selector.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-1638770904825712526?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/1638770904825712526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=1638770904825712526' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/1638770904825712526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/1638770904825712526'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2011/12/workaround-for-strict-html-validation.html' title='Simple Workaround for Strict HTML Validation of _blank Target'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-5133040351208743067</id><published>2010-02-09T18:58:00.000-08:00</published><updated>2012-01-05T01:21:49.076-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='parser'/><category scheme='http://www.blogger.com/atom/ns#' term='dom'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='examples'/><category scheme='http://www.blogger.com/atom/ns#' term='processing'/><category scheme='http://www.blogger.com/atom/ns#' term='javax'/><title type='text'>Minimal Java for XML Processing</title><content type='html'>&lt;div class="push-right"&gt;&lt;a href="http://commons.wikimedia.org/wiki/File:Xml_logo.svg" title="Image by Jmh2o, GNU General Public License"&gt;&lt;img alt="XML Logo" src="http://3.bp.blogspot.com/_JkhT9b_CKsM/S3ImSpBENAI/AAAAAAAAALU/3JriKocdkCw/s400/xml-logo.png" /&gt;&lt;/a&gt;&lt;/div&gt;These Java examples show very simple ways to write, validate, and read XML files.&amp;nbsp;  Use the examples as tutorials to learn the basics of working with XML.&lt;br /&gt;&lt;br /&gt;Catalog of Java examples for XML processing:&lt;ul&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2010/02/minimal-java-for-xml-processing.html#xml-write"&gt;XML Writer&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2010/02/minimal-java-for-xml-processing.html#xml-validate"&gt;XML Validator&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2010/02/minimal-java-for-xml-processing.html#xml-read"&gt;XML Reader&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="push-left"&gt;&lt;a href="http://java.sun.com/" title="java.sun.com"&gt;&lt;img alt="Java Get Powered" src="http://java.com/im/get_powered_sm.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;The examples are presented as complete programs so you can quickly run and test them.&lt;br /&gt;&lt;br /&gt;For example, to try out the "XML Writer" program, you would download the &lt;code&gt;XmlWriter.java&lt;/code&gt; file and execute the following commands:&lt;pre&gt;&lt;br /&gt;     $ javac *.java&lt;br /&gt;     $ java XmlWriter.class&lt;/pre&gt;Code here is &lt;i&gt;Public Domain Software&lt;/i&gt; &amp;mdash; free to use as you like.&lt;br /&gt;&lt;br /&gt;&lt;hr id="xml-write" /&gt;&lt;b&gt;XML Writer&lt;/b&gt;&lt;br /&gt;This example program creates a very simple DOM (Document Object Model) containing a list of countries and then writes the DOM out to an XML file.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;XmlWriter.java&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;import java.io.File;&lt;br /&gt;import java.util.HashMap;&lt;br /&gt;import javax.xml.parsers.DocumentBuilder;&lt;br /&gt;import javax.xml.parsers.DocumentBuilderFactory;&lt;br /&gt;import javax.xml.transform.*;&lt;br /&gt;import javax.xml.transform.dom.DOMSource;&lt;br /&gt;import javax.xml.transform.stream.StreamResult;&lt;br /&gt;import org.w3c.dom.*;&lt;br /&gt;&lt;br /&gt;public class XmlWriter {&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;      try {&lt;br /&gt;         //Sample Data (countries and capitals)&lt;br /&gt;         HashMap&amp;lt;String, String&amp;gt; data = new HashMap&amp;lt;String, String&amp;gt;();&lt;br /&gt;         data.put("Egypt",   "Cairo");&lt;br /&gt;         data.put("Finland", "Helsinki");&lt;br /&gt;         data.put("Japan",   "Tokyo");&lt;br /&gt;&lt;br /&gt;         //Create DOM (with top-level node)&lt;br /&gt;         DocumentBuilder xmlBuilder =&lt;br /&gt;            DocumentBuilderFactory.newInstance().newDocumentBuilder();&lt;br /&gt;         Document xmlDoc = xmlBuilder.newDocument();&lt;br /&gt;         Node node = xmlDoc.createElement("countries");&lt;br /&gt;         xmlDoc.appendChild(node);  //top-level node&lt;br /&gt;&lt;br /&gt;         //Add Data to DOM&lt;br /&gt;         for (String key : data.keySet()) {&lt;br /&gt;            Element elem = xmlDoc.createElement("country");&lt;br /&gt;            elem.setAttribute("capital", data.get(key));   //attrib&lt;br /&gt;            elem.appendChild(xmlDoc.createTextNode(key));  //content&lt;br /&gt;            node.appendChild(elem);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;         //Write DOM to XML file&lt;br /&gt;         Source source = new DOMSource(xmlDoc);&lt;br /&gt;         Result result = new StreamResult(new File("countries.xml"));&lt;br /&gt;         Transformer xformer =&lt;br /&gt;            TransformerFactory.newInstance().newTransformer();&lt;br /&gt;         xformer.setOutputProperty(OutputKeys.INDENT, "yes");&lt;br /&gt;         xformer.transform(source, result);&lt;br /&gt;         }&lt;br /&gt;      catch (Exception e) {&lt;br /&gt;         System.out.println(e.getMessage());&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;View/Download: &lt;a href="http://www.centerkey.com/files/snippets/XmlWriter.java" title="Get Code"&gt;XmlWriter.java&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;countries.xml&lt;/div&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;countries&amp;gt;&lt;br /&gt;&amp;lt;country capital="Helsinki"&amp;gt;Finland&amp;lt;/country&amp;gt;&lt;br /&gt;&amp;lt;country capital="Cairo"&amp;gt;Egypt&amp;lt;/country&amp;gt;&lt;br /&gt;&amp;lt;country capital="Tokyo"&amp;gt;Japan&amp;lt;/country&amp;gt;&lt;br /&gt;&amp;lt;/countries&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;File Created by Program&lt;/div&gt;&lt;br /&gt;Note that using a DOM holds the entire XML tree structure in memory.  For large data sets it is often necessary to instead use SAX (Simple API for XML) which uses an event based approach to hold and process only the part of the document that is needed.&lt;br /&gt;&lt;br /&gt;&lt;hr id="xml-validate" /&gt;&lt;b&gt;XML Validator&lt;/b&gt;&lt;br /&gt;This example program validates an XML file against an XSD (XML Schema Definition).&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;XmlValidator.java&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;import java.io.File;&lt;br /&gt;import javax.xml.XMLConstants;&lt;br /&gt;import javax.xml.validation.Schema;&lt;br /&gt;import javax.xml.validation.SchemaFactory;&lt;br /&gt;import javax.xml.transform.stream.StreamSource;&lt;br /&gt;&lt;br /&gt;public class XmlValidator {&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;      try {&lt;br /&gt;         StreamSource xsdInput = new StreamSource(new&lt;br /&gt;            XmlValidator().getClass().getResourceAsStream("countries.xsd"));&lt;br /&gt;         Schema schema = SchemaFactory.newInstance(&lt;br /&gt;            XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(xsdInput);&lt;br /&gt;         schema.newValidator().validate(new StreamSource(&lt;br /&gt;            new File("countries.xml")));&lt;br /&gt;         System.out.println("XML file sucessfully validated against XSD.");&lt;br /&gt;         }&lt;br /&gt;      catch (Exception e) {&lt;br /&gt;         System.out.println(e.getMessage());&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;View/Download: &lt;a href="http://www.centerkey.com/files/snippets/XmlValidator.java" title="Get Code"&gt;XmlValidator.java&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;XML Schema Used to Validate XML&lt;/div&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;&amp;lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&amp;gt;&lt;br /&gt;   &amp;lt;xs:element name="countries"&amp;gt;&lt;br /&gt;      &amp;lt;xs:complexType&amp;gt;&lt;br /&gt;         &amp;lt;xs:sequence&amp;gt;&lt;br /&gt;            &amp;lt;xs:element name="country" maxOccurs="unbounded"/&amp;gt;&lt;br /&gt;            &amp;lt;/xs:sequence&amp;gt;&lt;br /&gt;         &amp;lt;/xs:complexType&amp;gt;&lt;br /&gt;      &amp;lt;/xs:element&amp;gt;&lt;br /&gt;   &amp;lt;xs:element name="country"&amp;gt;&lt;br /&gt;      &amp;lt;xs:complexType mixed="true"&amp;gt;&lt;br /&gt;         &amp;lt;xs:attribute name="capital" type="xs:string" use="required" /&amp;gt;&lt;br /&gt;         &amp;lt;/xs:complexType&amp;gt;&lt;br /&gt;      &amp;lt;/xs:element&amp;gt;&lt;br /&gt;   &amp;lt;/xs:schema&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;View/Download: &lt;a href="http://www.centerkey.com/files/snippets/countries.xsd" title="Get Schema"&gt;countries.xsd&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;cvc-complex-type.2.4.a: Invalid content was found starting&lt;br /&gt;with element 'region'. One of '{"":country}' is expected.&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Program Output&lt;/div&gt;&lt;br /&gt;The above error message was generated from an input file (&lt;code&gt;countries.xml&lt;/code&gt;) containing invalid XML.&amp;nbsp;  A &lt;code&gt;&amp;lt;region&amp;gt;&lt;/code&gt; tag was used where a &lt;code&gt;&amp;lt;country&amp;gt;&lt;/code&gt; tag was expected.&lt;br /&gt;&lt;br /&gt;&lt;hr id="xml-read" /&gt;&lt;b&gt;XML Reader&lt;/b&gt;&lt;br /&gt;This example program reads an XML file and prints out the name of each node along with its first attribute.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;XmlReader.java&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;import java.io.File;&lt;br /&gt;import javax.xml.parsers.DocumentBuilder;&lt;br /&gt;import javax.xml.parsers.DocumentBuilderFactory;&lt;br /&gt;import org.w3c.dom.*;&lt;br /&gt;&lt;br /&gt;public class XmlReader {&lt;br /&gt;&lt;br /&gt;   static void processNode(Node node) {&lt;br /&gt;      String msg = "node --&amp;gt; " + node.getNodeName();&lt;br /&gt;      String nodeContent = node.getFirstChild().getNodeValue();&lt;br /&gt;      if (!nodeContent.equals("\n"))  //check if has text content&lt;br /&gt;         msg = msg + " | value: " + nodeContent; //add text content&lt;br /&gt;      if (node.hasAttributes())  //add first attrib if exists&lt;br /&gt;          msg = msg + " | attrib: " +&lt;br /&gt;            node.getAttributes().item(0).getNodeName() + "=" +&lt;br /&gt;            node.getAttributes().item(0).getNodeValue();&lt;br /&gt;      System.out.println(msg);  //display node information&lt;br /&gt;      for (Node subNode = node.getFirstChild(); subNode != null;&lt;br /&gt;            subNode = subNode.getNextSibling())&lt;br /&gt;         if (subNode.getNodeType() == Node.ELEMENT_NODE)&lt;br /&gt;            processNode(subNode);&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;      try {&lt;br /&gt;         DocumentBuilder xmlBuilder =&lt;br /&gt;            DocumentBuilderFactory.newInstance().newDocumentBuilder();&lt;br /&gt;         Document xmlDoc = xmlBuilder.parse(new File("countries.xml"));&lt;br /&gt;         processNode(xmlDoc.getDocumentElement());&lt;br /&gt;         }&lt;br /&gt;      catch (Exception e) {&lt;br /&gt;         System.out.println(e.getMessage());&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;View/Download: &lt;a href="http://www.centerkey.com/files/snippets/XmlReader.java" title="Get Code"&gt;XmlReader.java&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;node --&amp;gt; countries&lt;br /&gt;node --&amp;gt; country | value: Finland | attrib: capital=Helsinki&lt;br /&gt;node --&amp;gt; country | value: Egypt | attrib: capital=Cairo&lt;br /&gt;node --&amp;gt; country | value: Japan | attrib: capital=Tokyo&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Program Output (input file: &lt;code&gt;countries.xml&lt;/code&gt;)&lt;/div&gt;&lt;br /&gt;&lt;hr /&gt;&lt;b&gt;Further Reading&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Elsewhere:&lt;ul&gt;&lt;li&gt;&lt;a href="http://techdem.blogspot.com/2009/06/java-snippets.html"&gt;Java Snippets&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.blogspot.com/2009/05/javahome-command-script.html"&gt;Set JAVA_HOME in a Command Script&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-5133040351208743067?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/5133040351208743067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=5133040351208743067' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/5133040351208743067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/5133040351208743067'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2010/02/minimal-java-for-xml-processing.html' title='Minimal Java for XML Processing'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_JkhT9b_CKsM/S3ImSpBENAI/AAAAAAAAALU/3JriKocdkCw/s72-c/xml-logo.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-2069466777220577012</id><published>2010-01-31T21:16:00.000-08:00</published><updated>2011-12-28T22:24:48.773-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='toggle'/><category scheme='http://www.blogger.com/atom/ns#' term='show'/><category scheme='http://www.blogger.com/atom/ns#' term='cookie'/><category scheme='http://www.blogger.com/atom/ns#' term='read'/><category scheme='http://www.blogger.com/atom/ns#' term='hide'/><category scheme='http://www.blogger.com/atom/ns#' term='parameter'/><title type='text'>JavaScript Snippets for Dynamic Web Pages</title><content type='html'>There are a ton of unnecessarily complicated JavaScript examples strewn about the Internet.&amp;nbsp;  In an attempt to counter that, here are a few simplified examples of using JavaScript to accomplish common tasks.&lt;br /&gt;&lt;br /&gt;Catalog of JavaScript Snippets:&lt;ul&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2010/01/javascript-snippets-dynamic-web-pages.html#show.hide.toggle"&gt;Show/Hide Toggle&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2010/01/javascript-snippets-dynamic-web-pages.html#read.url.parameters"&gt;Read URL Parameters&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2010/01/javascript-snippets-dynamic-web-pages.html#set.get.cookie"&gt;Set and Get Cookie Value&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;To try out a snippet, click the link for the example listed below the snippet.&lt;br /&gt;&lt;br /&gt;Code here is &lt;i&gt;Public Domain Software&lt;/i&gt; — free to use as you like.&lt;br /&gt;&lt;br /&gt;&lt;hr id="show.hide.toggle" /&gt;&lt;b&gt;Show/Hide Toggle&lt;/b&gt;&lt;br /&gt;JavaScript can be used to show and hide an object on a web page with each click by the user.&amp;nbsp;  This JavaScript snippet finds the display status of the element and flips the status from "none" (hidden) to "block" (visible) or from "block" to "none".&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;JavaScript&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;function toggle(elemName) {&lt;br /&gt;   var s = document.getElementById(elemName).style;&lt;br /&gt;   s.display = s.display == 'none' ? 'block' : 'none';&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Example: &lt;a href="http://www.centerkey.com/files/javascript/show-hide-toggle.html" title="Try it out"&gt;show-hide-toggle.html&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr id="read.url.parameters" /&gt;&lt;b&gt;Read URL Parameters&lt;/b&gt;&lt;br /&gt;JavaScript can be used to read URL parameters.&amp;nbsp;  This JavaScript snippet reads the name/value pairs appended to a URL and stores the values in an array named &lt;i&gt;params&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;JavaScript&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;var params = new Array();&lt;br /&gt;var keyvals = location.search.substring(1).split('&amp;amp;');&lt;br /&gt;for (count in keyvals) {&lt;br /&gt;   keyval = keyvals[count].split('=');&lt;br /&gt;   params[keyval[0]] = keyval[1];&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Example: &lt;a href="http://www.centerkey.com/files/javascript/read-parameters.html" title="Try it out"&gt;read-parameters.html&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr id="set.get.cookie" /&gt;&lt;b&gt;Set and Get Cookie Value&lt;/b&gt;&lt;br /&gt;JavaScript can be used to set and get browser cookies.&amp;nbsp;  This JavaScript snippet contains two functions — one to save the cookie value and the second to read the value back.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;JavaScript&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;function setCookie(key, value) {&lt;br /&gt;   var expires = new Date();&lt;br /&gt;   expires.setTime(expires.getTime() + 31536000000); //1 year&lt;br /&gt;   document.cookie = key + '=' + value + ';expires=' + expires.toUTCString();&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;function getCookie(key) {&lt;br /&gt;   var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');&lt;br /&gt;   return keyValue ? keyValue[2] : null;&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Example: &lt;a href="http://www.centerkey.com/files/javascript/set-get-cookie.html" title="Try it out"&gt;set-get-cookie.html&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;b&gt;Further Reading&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Elsewhere:&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.centerkey.com/style/switcher/"&gt;Two Line Style Switcher&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.centerkey.com/colors/"&gt;Sortable Color Name Chart&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-2069466777220577012?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/2069466777220577012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=2069466777220577012' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/2069466777220577012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/2069466777220577012'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2010/01/javascript-snippets-dynamic-web-pages.html' title='JavaScript Snippets for Dynamic Web Pages'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-9063128374619610240</id><published>2009-07-04T23:58:00.001-07:00</published><updated>2011-12-28T22:39:45.952-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='admin'/><category scheme='http://www.blogger.com/atom/ns#' term='install'/><category scheme='http://www.blogger.com/atom/ns#' term='router'/><category scheme='http://www.blogger.com/atom/ns#' term='installation'/><category scheme='http://www.blogger.com/atom/ns#' term='cd'/><category scheme='http://www.blogger.com/atom/ns#' term='isp'/><category scheme='http://www.blogger.com/atom/ns#' term='administration'/><category scheme='http://www.blogger.com/atom/ns#' term='web browser'/><category scheme='http://www.blogger.com/atom/ns#' term='dsl'/><category scheme='http://www.blogger.com/atom/ns#' term='default password'/><category scheme='http://www.blogger.com/atom/ns#' term='console'/><title type='text'>Don't Touch that DSL Installation CD</title><content type='html'>&lt;div class="push-right"&gt;&lt;a href="http://commons.wikimedia.org/wiki/File:Photo-RJ11.jpg"&gt;&lt;img alt="Phone Wiring" src="http://3.bp.blogspot.com/_JkhT9b_CKsM/SlEoOb9K_9I/AAAAAAAAAJA/ZPbs4Th6Cdg/s200/rj-11.png" title="Image by Shaddack, Public Domain" /&gt;&lt;/a&gt;&lt;div class=code-box-caption&gt;Phone Wiring&lt;/div&gt;&lt;/div&gt;When you purchase DSL (Digital Subscriber Line) broadband Internet service from an ISP (Internet Service Provider) such as your phone company, the ISP almost always provides you with an installation CD.&amp;nbsp;  Ever wonder what it installs?  It installs the ISP's branding all over your computer.&lt;br /&gt;&lt;br /&gt;&lt;div class="push-left"&gt;&lt;a href="http://commons.wikimedia.org/wiki/File:Crystal_128_yast_dsl.png"&gt;&lt;img alt="DSL Modem" src="http://4.bp.blogspot.com/_JkhT9b_CKsM/SlET5w1NCII/AAAAAAAAAIo/Hw7neTbqGtE/s200/dsl-modem.png" title="Image by Dake, GNU Free Documentation License" /&gt;&lt;/a&gt;&lt;div class=code-box-caption&gt;DSL Modem&lt;/div&gt;&lt;/div&gt;Besides electrical power and telephone wiring to the jack, all the DSL modem needs to access the DSL line is your DSL username and your DSL password.&amp;nbsp;  The DSL username and DSL password should be saved to your router not your computer, and that is why you do not need to install any DSL software on your computer.&amp;nbsp;  Additionally, the router provides critical network firewall protection and makes it easy to share your DSL connection with multiple computers.&amp;nbsp;  Contrary to what your ISP will tell you, there is no need to install any software on your computer.&amp;nbsp;  Doing so will just gunk up your computer.&amp;nbsp;  Don't do it.&lt;br /&gt;&lt;a name='more'&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="push-right"&gt;&lt;a href="http://commons.wikimedia.org/wiki/File:Ethernet_plug_grey.svg"&gt;&lt;img alt="Ethernet Cable" src="http://2.bp.blogspot.com/_JkhT9b_CKsM/SlEoOmpMziI/AAAAAAAAAJI/OrLjTKV2TL4/s200/ethernet-cable.png" title="Image by Elembis, GNU Free Documentation License" /&gt;&lt;/a&gt;&lt;div class=code-box-caption&gt;Ethernet Cable&lt;/div&gt;&lt;/div&gt;&lt;b&gt;Setup without Installing Software&lt;/b&gt;&lt;br /&gt;Instead, use your computer's web browser to access the router's configuration web page (administration console) to enter and save your DSL username and DSL password.&lt;br /&gt;&lt;br /&gt;&lt;div class="push-left"&gt;&lt;a href="http://commons.wikimedia.org/wiki/File:Wireless-Router.png"&gt;&lt;img alt="Router" src="http://1.bp.blogspot.com/_JkhT9b_CKsM/SlEYHK-JsNI/AAAAAAAAAIw/DJ3E0ahs1lo/s200/router.png" title="Image by Hroyer, GNU Free Documentation License" /&gt;&lt;/a&gt;&lt;div class=code-box-caption&gt;Router&lt;/div&gt;&lt;/div&gt;&lt;i&gt;1) Get Your DSL Login Information&lt;/i&gt;&lt;br /&gt;Using a computer with Internet access, go to your ISP's web site and create or register your DSL account.&amp;nbsp;  Take note of your DSL username and DSL password.&amp;nbsp;  (Note that some ISPs may have you create your DSL account via the DSL connection.)&lt;br /&gt;&lt;br /&gt;&lt;i&gt;2) Setup Equipment&lt;/i&gt;&lt;br /&gt;Connect up all your equipment.&amp;nbsp;  The &lt;i&gt;&lt;b&gt;DSL modem&lt;/b&gt;&lt;/i&gt; connects to the &lt;i&gt;&lt;b&gt;phone jack&lt;/b&gt;&lt;/i&gt; with a regular telephone wire (RJ-11).&amp;nbsp;  The &lt;i&gt;&lt;b&gt;router&lt;/b&gt;&lt;/i&gt; connects to the &lt;i&gt;&lt;b&gt;DSL modem&lt;/b&gt;&lt;/i&gt; and to the &lt;i&gt;&lt;b&gt;computer&lt;/b&gt;&lt;/i&gt; each with an Ethernet cable (&lt;a href="http://en.wikipedia.org/wiki/Category_5_cable"&gt;Cat5&lt;/a&gt;).&amp;nbsp;  Your equipment setup can be simplified by using a combination DSL modem device with a build-in router.&lt;br /&gt;&lt;br /&gt;&lt;div class="code-box code-box-output"&gt;&lt;i&gt;Phone Jack&lt;/i&gt; &amp;nbsp;&amp;harr;&amp;nbsp; &lt;i&gt;DSL Modem&lt;/i&gt; &amp;nbsp;&amp;harr;&amp;nbsp; &lt;i&gt;Router&lt;/i&gt; &amp;nbsp;&amp;harr;&amp;nbsp; &lt;i&gt;Computer(s)&lt;/i&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Equipment Connections&lt;/div&gt;&lt;br /&gt;&lt;i&gt;3) Configure Router to do DSL Login&lt;/i&gt;&lt;br /&gt;Use your web browser to log into the router configuration web page.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;Common Router Configuration Web Pages&lt;/div&gt;&lt;table class="data-box"&gt;&lt;tbody&gt;&lt;tr class="top"&gt;&lt;th&gt;Router Manufacture&lt;/th&gt;&lt;th&gt;Administration Console&lt;/th&gt;&lt;th&gt;Username&lt;/th&gt;&lt;th&gt;Password&lt;/th&gt;&lt;/tr&gt;&lt;tr class="odd"&gt;&lt;th&gt;2wire&lt;/th&gt;&lt;td&gt;&lt;a href="http://192.168.1.254/"&gt;192.168.1.254&lt;/a&gt;&lt;br /&gt;&lt;a href="http://homeportal/"&gt;homeportal&lt;/a&gt;&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;td&gt;&lt;i&gt;(blank)&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="even"&gt;&lt;th&gt;Apple&lt;/th&gt;&lt;td&gt;&lt;a href="http://10.0.1.1/"&gt;10.0.1.1&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;(blank)&lt;/i&gt;&lt;/td&gt;&lt;td&gt;public&lt;br /&gt;&lt;i&gt;(blank)&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="odd"&gt;&lt;th&gt;ASUS&lt;/th&gt;&lt;td&gt;&lt;a href="http://192.168.1.1/"&gt;192.168.1.1&lt;/a&gt;&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;/tr&gt;&lt;tr class="even"&gt;&lt;th&gt;Belkin&lt;/th&gt;&lt;td&gt;&lt;a href="http://192.168.2.1/"&gt;192.168.2.1&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;(blank)&lt;/i&gt;&lt;/td&gt;&lt;td&gt;&lt;i&gt;(blank)&lt;br /&gt;admin&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="odd"&gt;&lt;th&gt;D-Link&lt;/th&gt;&lt;td&gt;&lt;a href="http://192.168.0.1/"&gt;192.168.0.1&lt;/a&gt;&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;td&gt;admin&lt;br /&gt;&lt;i&gt;(blank)&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="even"&gt;&lt;th&gt;Linksys&lt;/th&gt;&lt;td&gt;&lt;a href="http://192.168.1.1/"&gt;192.168.1.1&lt;/a&gt;&lt;/td&gt;&lt;td&gt;admin&lt;br /&gt;&lt;i&gt;(blank)&lt;/i&gt;&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;/tr&gt;&lt;tr class="odd"&gt;&lt;th&gt;NETGEAR&lt;/th&gt;&lt;td&gt;&lt;a href="http://192.168.0.1/"&gt;192.168.0.1&lt;/a&gt;&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;td&gt;password&lt;/td&gt;&lt;/tr&gt;&lt;tr class="even"&gt;&lt;th&gt;TRENDnet&lt;/th&gt;&lt;td&gt;&lt;a href="http://192.168.1.1/"&gt;192.168.1.1&lt;/a&gt;&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;/tr&gt;&lt;tr class="odd"&gt;&lt;th&gt;Zoom&lt;/th&gt;&lt;td&gt;&lt;a href="http://10.0.0.2/"&gt;10.0.0.2&lt;/a&gt;&lt;/td&gt;&lt;td&gt;admin&lt;/td&gt;&lt;td&gt;zooomadsl&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;Note that manufactures sometimes change the default settings, so many older routers have different default settings.&amp;nbsp;  For an extensive list of router logins, visit: &lt;a href="http://www.routerpasswords.com/"&gt;routerpasswords.com&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Each manufacturer's router configuration web page is a little different, but the basic configuration steps are usually the same.&lt;br /&gt;&lt;br /&gt;Configuration Steps:&lt;ol&gt;&lt;li&gt;Find the DSL automatic settings detection option and run it&lt;/li&gt;&lt;li&gt;If you have your DSL username and DSL password, enter them into the DSL login fields.&lt;/li&gt;&lt;li&gt;Save your settings.&lt;/li&gt;&lt;li&gt;Look for a status message or status page and check that the DSL connection is active.&lt;/li&gt;&lt;li&gt;Browse to a news web site to verify you are connected to the Internet.&lt;/li&gt;&lt;li&gt;If you are presented with a web page to create your DSL account, do that and then go back to the router configuration web pages and save your DSL username and DSL password.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;Once you have tested your Internet connection, you should consider using the router configuration web page to change your router's administrator password and to setup your wireless network (Wi-FI).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Still Trying to Trick You&lt;/b&gt;&lt;br /&gt;Some ISPs are so desperate to force you to install their DSL software on your computer that they will block your Internet access with a software download web page.&amp;nbsp;  ISPs generally have software only for Mac OS X and Microsoft Windows.&amp;nbsp;  To support other operating systems, such as Ubuntu, the ISP will have an alternate activation or registration option that does not involve downloading and installing their software.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;Alternate Registration/Activation Web Pages&lt;/div&gt;&lt;table class="data-box"&gt;&lt;tbody&gt;&lt;tr class="top"&gt;&lt;th&gt;ISP&lt;/th&gt;&lt;th&gt;Backdoor&lt;/th&gt;&lt;/tr&gt;&lt;tr class="odd"&gt;&lt;th&gt;AT&amp;amp;T&lt;/th&gt;&lt;td&gt;&lt;a href="http://144.160.11.35/register"&gt;http://144.160.11.35/register&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;If you are running Mac OS X or Microsoft Windows, one option is to temporarily customize your browser so that it reports a different operating system.&lt;br /&gt;&lt;br /&gt;On Mac OS X:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;i&gt;Safari&lt;/i&gt; → &lt;i&gt;Preferences&lt;/i&gt; → &lt;i&gt;Advanced&lt;/i&gt; → Check option to &lt;i&gt;Show Develop menu in menu bar&lt;/i&gt; → close window → &lt;i&gt;Develop&lt;/i&gt; → &lt;i&gt;User Agent&lt;/i&gt; → &lt;i&gt;Other...&lt;/i&gt; → Replace all text with: &lt;i&gt;Ubuntu&lt;/i&gt; → &lt;i&gt;OK&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;For other systems:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;a href="http://chrispederick.com/work/user-agent-switcher/"&gt;User Agent Switcher&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Router Installation CD&lt;/b&gt;&lt;br /&gt;Your router probably also came with an install CD.&amp;nbsp;  As with the ISP install CD, don't touch it.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Fewer Moving Parts&lt;/b&gt;&lt;br /&gt;Avoiding your ISP's unnecessary DSL software will keep your machine cleaner and reduce the likelihood encountering problems in the future.&amp;nbsp;  Plus, having the router manage the DSL login information makes using multiple computers easier.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-9063128374619610240?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/9063128374619610240/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=9063128374619610240' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/9063128374619610240'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/9063128374619610240'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2009/07/dsl-install-cd.html' title='Don&apos;t Touch that DSL Installation CD'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_JkhT9b_CKsM/SlEoOb9K_9I/AAAAAAAAAJA/ZPbs4Th6Cdg/s72-c/rj-11.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-3659225797873293244</id><published>2009-06-10T21:14:00.000-07:00</published><updated>2012-01-01T13:28:40.073-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='openstream'/><category scheme='http://www.blogger.com/atom/ns#' term='url'/><category scheme='http://www.blogger.com/atom/ns#' term='hashmap'/><category scheme='http://www.blogger.com/atom/ns#' term='snippets'/><category scheme='http://www.blogger.com/atom/ns#' term='readline'/><category scheme='http://www.blogger.com/atom/ns#' term='bufferedreader'/><category scheme='http://www.blogger.com/atom/ns#' term='example code'/><category scheme='http://www.blogger.com/atom/ns#' term='browser launch'/><category scheme='http://www.blogger.com/atom/ns#' term='javac'/><title type='text'>Handy Java Snippets</title><content type='html'>&lt;div class="push-right"&gt;&lt;a href="http://commons.wikimedia.org/wiki/File:Text-x-java-source.svg" title="Image by Rocket000, GNU General Public License"&gt;&lt;img alt="Java Snippets" src="http://2.bp.blogspot.com/_JkhT9b_CKsM/SlO8w2X5TPI/AAAAAAAAAJo/H8Gxc2REeEM/s200/java-snippets.png" /&gt;&lt;/a&gt;&lt;/div&gt;Some people learn best through examples.&amp;nbsp;  With that in mind, here are some stripped-down simplified examples of Java code to perform various tasks.&amp;nbsp;  These snippets are not robust enterprise-ready patterns nor do they do not represent best practices.&amp;nbsp;  Rather, they are barebones examples to help you get up and running as quickly as possible.&lt;br /&gt;&lt;br /&gt;Catalog of Java Snippets:&lt;ul&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2009/06/java-snippets.html#hashmap.loop"&gt;HashMap Loop&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2009/06/java-snippets.html#top.map"&gt;TopMap Element Tracker&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2009/06/java-snippets.html#url.read"&gt;Web Page Reader&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2009/06/java-snippets.html#desktop.browser.launch"&gt;Desktop Browser Launch&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;div class="push-left"&gt;&lt;a href="http://java.sun.com/" title="java.sun.com"&gt;&lt;img alt="Java Get Powered" src="http://java.com/im/get_powered_sm.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;The snippets are presented as complete programs so you can quickly run and test them.&lt;br /&gt;&lt;br /&gt;For example, to try out the "HashMap Loop" program, you would download the &lt;code&gt;HashMapLoop.java&lt;/code&gt; file and execute the following commands:&lt;pre&gt;&lt;br /&gt;     $ javac *.java&lt;br /&gt;     $ java HashMapLoop.class&lt;/pre&gt;Code here is &lt;i&gt;Public Domain Software&lt;/i&gt; &amp;mdash; free to use as you like.&lt;br /&gt;&lt;br /&gt;&lt;hr id="hashmap.loop" /&gt;&lt;b&gt;HashMap Loop&lt;/b&gt;&lt;br /&gt;HashMaps are convenient for storing key-value pairs.&amp;nbsp;  This snippet iterates over a java.util.HashMap collection without explicitly creating an iterator.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;HashMapLoop.java&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;import java.util.HashMap;&lt;br /&gt;&lt;br /&gt;public class HashMapLoop {&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;      HashMap&amp;lt;String, String&amp;gt; data = new HashMap&amp;lt;String, String&amp;gt;();&lt;br /&gt;      data.put("Color", "Green");&lt;br /&gt;      data.put("Size",  "Medium");&lt;br /&gt;      data.put("Speed", "Fast");&lt;br /&gt;      for (String key : data.keySet())&lt;br /&gt;         System.out.println(key + " --&amp;gt; " + data.get(key));&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;View/Download: &lt;a href="http://www.centerkey.com/files/snippets/HashMapLoop.java" title="Get Code"&gt;HashMapLoop.java&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;Color --&amp;gt; Green&lt;br /&gt;Speed --&amp;gt; Fast&lt;br /&gt;Size --&amp;gt; Medium&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Program Output&lt;/div&gt;&lt;br /&gt;&lt;hr id="top.map" /&gt;&lt;b&gt;TopMap Element Tracker&lt;/b&gt;&lt;br /&gt;This snippet keeps track of the top (heaviest, furthest, oldest, longest, loudest, fastest, etc.) elements as your program processes the elements.&amp;nbsp;  Instead of holding onto all the elements, this snippet uses java.util.TreeMap to hold only the top elements.&lt;br /&gt;&lt;br /&gt;The code below demonstrates TopMap with a simple example of tracking the largest islands by land mass.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;TopMap.java&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;import java.util.*;&lt;br /&gt;&lt;br /&gt;public class TopMap&lt;k, v=""&gt; extends TreeMap&lt;integer, v=""&gt; {&lt;br /&gt;&lt;br /&gt;   private final int maxElems;&lt;br /&gt;&lt;br /&gt;   public TopMap(int maxNumberElements) {&lt;br /&gt;      super(Collections.reverseOrder());&lt;br /&gt;      maxElems = maxNumberElements;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   @Override&lt;br /&gt;   public V put(Integer key, V value) {&lt;br /&gt;      if (size() &amp;lt; maxElems || key &amp;gt; lastKey())&lt;br /&gt;         super.put(key, value);&lt;br /&gt;      if (size() &amp;gt; maxElems)&lt;br /&gt;         remove(lastKey());&lt;br /&gt;      return value;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;      TreeMap&lt;integer, string=""&gt; islands = new TopMap&lt;integer, string=""&gt;(3);&lt;br /&gt;      islands.put( 507000, "Baffin");&lt;br /&gt;      islands.put( 726000, "Borneo");&lt;br /&gt;      islands.put(2131000, "Greenland");&lt;br /&gt;      islands.put( 578000, "Madagascar");&lt;br /&gt;      islands.put( 800000, "New Guinea");&lt;br /&gt;      System.out.println("Three Largest Islands:");&lt;br /&gt;      for (Map.Entry&lt;integer, string=""&gt; island : islands.entrySet())&lt;br /&gt;         System.out.println(island.getKey() + " sq km - " + island.getValue());&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;/integer,&gt;&lt;/integer,&gt;&lt;/integer,&gt;&lt;/integer,&gt;&lt;/k,&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;View/Download: &lt;a href="http://www.centerkey.com/files/snippets/TopMap.java" title="Get Code"&gt;TopMap.java&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;Three Largest Islands:&lt;br /&gt;2131000 sq km - Greenland&lt;br /&gt;800000 sq km - New Guinea&lt;br /&gt;726000 sq km - Borneo&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Program Output&lt;/div&gt;&lt;br /&gt;Note that this solution does not support duplicates because TreeMap itself does not support duplicates.&amp;nbsp;  If your data contains ties (where two or more keys are equal), use &lt;a href="http://www.centerkey.com/files/snippets/TopMultiMap.java" title="Get Code"&gt;TopMultiMap&lt;/a&gt; (which incorporates a special comparator to hide duplicates) or use &lt;a href="http://www.centerkey.com/files/snippets/TopElements.java" title="Get Code"&gt;TopElements&lt;/a&gt; (which incorporates lists to keep track of possible ties).&lt;br /&gt;&lt;br /&gt;&lt;hr id="url.read" /&gt;&lt;b&gt;Web Page Reader&lt;/b&gt;&lt;br /&gt;This snippet reads the contents of a web page (example: &lt;a href="http://www.centerkey.com/files/snippets/WebPageReader.html"&gt;WebPageReader.html&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;WebPageReader.java&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;import java.io.*;&lt;br /&gt;import java.net.*;&lt;br /&gt;&lt;br /&gt;public class WebPageReader {&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;      String url = "http://www.centerkey.com/files/snippets/WebPageReader.html";&lt;br /&gt;      try {&lt;br /&gt;         BufferedReader reader = new BufferedReader(&lt;br /&gt;            new InputStreamReader(new URL(url).openStream()));&lt;br /&gt;         for (String s = reader.readLine(); s != null; s = reader.readLine())&lt;br /&gt;            System.out.println(s);&lt;br /&gt;         reader.close();&lt;br /&gt;         }&lt;br /&gt;      catch (Exception e) {&lt;br /&gt;         System.out.println(e.toString());&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;View/Download: &lt;a href="http://www.centerkey.com/files/snippets/WebPageReader.java" title="Get Code"&gt;WebPageReader.java&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Simple Web Page&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;bogy&amp;gt;&amp;lt;h1&amp;gt;WebPageReader Test&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;Program Output&lt;/div&gt;&lt;br /&gt;This approach can also be used to read text data, such as a &lt;a href="http://www.snapbackup.com/version/"&gt;product's current version number&lt;/a&gt;, from a web site.&lt;br /&gt;&lt;br /&gt;&lt;hr id="desktop.browser.launch" /&gt;&lt;b&gt;Desktop Browser Launch&lt;/b&gt;&lt;br /&gt;This snippet opens a web page in the user's default browser.&lt;br /&gt;&lt;br /&gt;&lt;div class="box-caption"&gt;DesktopBrowser.java&lt;/div&gt;&lt;div class="code-box"&gt;&lt;pre&gt;public class DesktopBrowser {&lt;br /&gt;&lt;br /&gt;   public static void main(String[] args) {&lt;br /&gt;      String url = "http://www.google.com";&lt;br /&gt;      try {&lt;br /&gt;         java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));&lt;br /&gt;         }&lt;br /&gt;      catch (java.io.IOException e) {&lt;br /&gt;         System.out.println(e.getMessage());&lt;br /&gt;         }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;   }&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;View/Download: &lt;a href="http://www.centerkey.com/files/snippets/DesktopBrowser.java" title="Get Code"&gt;WebPageReader.java&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This code requires Java 6 or later.&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;&lt;b&gt;Further Reading&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Elsewhere:&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.centerkey.com/mac/java/"&gt;Mac Java (create an installer)&lt;/a&gt;&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.blogspot.com/2009/05/javahome-command-script.html"&gt;Set JAVA_HOME in a Command Script&lt;/a&gt;&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;a href="http://www.centerkey.com/java/browser/"&gt;Bare Bones Browser Launch for Java&lt;/a&gt;&lt;br /&gt;   &lt;/li&gt;&lt;li&gt;&lt;a href="http://techdem.centerkey.com/2010/02/minimal-java-for-xml-processing.html"&gt;Minimal Java for XML Processing&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-3659225797873293244?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/3659225797873293244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=3659225797873293244' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/3659225797873293244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/3659225797873293244'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2009/06/java-snippets.html' title='Handy Java Snippets'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_JkhT9b_CKsM/SlO8w2X5TPI/AAAAAAAAAJo/H8Gxc2REeEM/s72-c/java-snippets.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-985827878986538291</id><published>2009-05-16T23:58:00.001-07:00</published><updated>2011-12-28T21:52:14.567-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='build'/><category scheme='http://www.blogger.com/atom/ns#' term='bat'/><category scheme='http://www.blogger.com/atom/ns#' term='batch'/><category scheme='http://www.blogger.com/atom/ns#' term='dos'/><category scheme='http://www.blogger.com/atom/ns#' term='cmd'/><category scheme='http://www.blogger.com/atom/ns#' term='ant'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='command script'/><category scheme='http://www.blogger.com/atom/ns#' term='jdk'/><category scheme='http://www.blogger.com/atom/ns#' term='set java_home'/><title type='text'>Set JAVA_HOME in a Windows Command Script</title><content type='html'>Apache &lt;a href="http://ant.apache.org/" onclick="this.target='_blank';" title="Apache Ant Project"&gt;Ant&lt;/a&gt; is a common tool for building Java applications, and most IDEs support building with Ant right from the IDE.&amp;nbsp;  However, when you need to build your Java application outside of the IDE, it can be handy to have a script kick off Ant.&lt;br /&gt;&lt;br /&gt;On Microsoft Windows the script needs to know the location of the JDK and Ant, which generally entails:&lt;ul&gt;   &lt;li&gt;Relying on environment variables to be set correctly or&lt;/li&gt;   &lt;li&gt;Hardcoding the path locations&lt;/li&gt;   &lt;/ul&gt;&lt;br /&gt;Both approaches are brittle and likely to result in maintenance and support headaches down the road.&amp;nbsp;  Additionally, hardcoding the paths assumes all the developers are running the same versions of the JDK and Ant.&amp;nbsp;  These limitations are insignificant for a centrally managed commercial software organization, but they can be problematic for a distributed open source project.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;DOS "for" Command&lt;/b&gt;&lt;br /&gt;Fortunately, it's easy to write a Command Script (.cmd) batch file using the DOS &lt;b&gt;&lt;code&gt;for&lt;/code&gt;&lt;/b&gt; command that automatically determines the path to the most current versions of the JDK and Ant.&amp;nbsp;  To test out the &lt;b&gt;&lt;code&gt;for&lt;/code&gt;&lt;/b&gt; command, try the following at the Windows Command Prompt.&lt;br /&gt;&lt;br /&gt;&lt;div class=box-caption&gt;Command Prompt Demonstration&lt;/div&gt;&lt;div class="code-box code-box-output"&gt;&lt;pre&gt;C:\&amp;gt;for /d %i in ("\Program Files\Java\jdk*") do set JAVA_HOME=%i&lt;br /&gt;C:\&amp;gt;set JAVA_HOME&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;You should see a result similar to:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;b&gt;&lt;code&gt;JAVA_HOME=\Program Files\Java\jdk1.7.0_02&lt;/code&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Command Script Solution&lt;/b&gt;&lt;br /&gt;To make it easy to launch Ant, put the following &lt;b&gt;&lt;code&gt;build.cmd&lt;/code&gt;&lt;/b&gt; file into the same folder as your &lt;b&gt;&lt;code&gt;build.xml&lt;/code&gt;&lt;/b&gt; Ant configuration file.&lt;br /&gt;&lt;br /&gt;&lt;div class=box-caption&gt;build.cmd File&lt;/div&gt;&lt;div class=code-box&gt;&lt;pre&gt;@echo off&lt;br /&gt;::::::::::::::::::::::::::::::::::::&lt;br /&gt;:: build.cmd (v1.0)               ::&lt;br /&gt;:: Microsoft Windows Build Script ::&lt;br /&gt;::::::::::::::::::::::::::::::::::::&lt;br /&gt;&lt;br /&gt;:: Set JAVA_HOME&lt;br /&gt;for /d %%i in ("\Program Files\Java\jdk*") do set JAVA_HOME=%%i&lt;br /&gt;&lt;br /&gt;:: set ANT_HOME&lt;br /&gt;for /d %%i in ("\Apps\Ant\apache-ant*") do set ANT_HOME=%%i&lt;br /&gt;&lt;br /&gt;:: Display Variables and Launch Ant&lt;br /&gt;set JAVA_HOME&lt;br /&gt;set ANT_HOME&lt;br /&gt;call %ANT_HOME%\bin\ant build&lt;br /&gt;pause&lt;/pre&gt;&lt;/div&gt;&lt;div class=box-caption&gt;View/Download: &lt;a href="http://www.centerkey.com/files/build-cmd.txt" title="Get File"&gt;&lt;code&gt;build.cmd&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Now to build your project, double-click the &lt;b&gt;&lt;code&gt;build.cmd&lt;/code&gt;&lt;/b&gt; file.&lt;br /&gt;&lt;br /&gt;While the script does not hardcode the JDK and Ant versions, it does require that the JDK is installed into the default location and that Ant in installed (copied) into the &lt;code&gt;\Apps\Ant&lt;/code&gt; folder.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Alternative Approach&lt;/b&gt;&lt;br /&gt;If you prefer to be more robust in your detection of the JDK home, you can use the DOS &lt;b&gt;&lt;code&gt;reg query&lt;/code&gt;&lt;/b&gt; command to read the Windows Registry information to locate the JDK.&amp;nbsp;  In the &lt;b&gt;&lt;code&gt;build.cmd&lt;/code&gt;&lt;/b&gt; file, replace the line that sets &lt;b&gt;&lt;code&gt;JAVA_HOME&lt;/code&gt;&lt;/b&gt; with the lines below.&lt;br /&gt;&lt;br /&gt;&lt;div class=box-caption&gt;Use Windows Registry to Set &lt;b&gt;&lt;code&gt;JAVA_HOME&lt;/code&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=code-box&gt;&lt;pre&gt;:: Set JAVA_HOME&lt;br /&gt;set KeyName=HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit&lt;br /&gt;set Cmd=reg query "%KeyName%" /s&lt;br /&gt;for /f "tokens=2*" %%i in ('%Cmd% ^| find "JavaHome"') do set JAVA_HOME=%%j&lt;/pre&gt;&lt;/div&gt;&lt;div class=box-caption&gt;View/Download: &lt;a href="http://www.centerkey.com/files/set-java-home-cmd.txt" title="Get File"&gt;&lt;code&gt;set-java-home.cmd&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The output of the &lt;b&gt;&lt;code&gt;reg query&lt;/code&gt;&lt;/b&gt; is piped through &lt;b&gt;&lt;code&gt;find&lt;/code&gt;&lt;/b&gt; to single out the desired key value.&amp;nbsp;  The third token (represented by &lt;b&gt;&lt;code&gt;%%j&lt;/code&gt;&lt;/b&gt;) on the line is the path.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Simplify&lt;/b&gt;&lt;br /&gt;By having &lt;b&gt;&lt;code&gt;build.cmd&lt;/code&gt;&lt;/b&gt; auto-detect the JDK and Ant, you can simplify the steps for new developers looking to contribute to your &lt;a href="http://code.google.com/p/snapbackup/source/browse/trunk/src/tools/build.cmd"&gt;open source project&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Apple Mac OS X Shell Script&lt;/b&gt;&lt;br /&gt;To kick off Ant on a Mac, you can use a short 2-line shell script.&lt;br /&gt;&lt;br /&gt;&lt;div class=box-caption&gt;build.sh.command File&lt;/div&gt;&lt;div class=code-box&gt;&lt;pre&gt;#!/bin/sh&lt;br /&gt;#############################&lt;br /&gt;##  Mac OS X Build Script  ##&lt;br /&gt;#############################&lt;br /&gt;&lt;br /&gt;cd `dirname $0`&lt;br /&gt;ant build&lt;/pre&gt;&lt;/div&gt;&lt;div class=box-caption&gt;View/Download: &lt;a href="http://www.centerkey.com/files/build-sh-command.txt"&gt;&lt;code&gt;build.sh.command&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This script is simple because Mac OS X ships with Ant and automatically downloads Java (including the JDK) the first time you use it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-985827878986538291?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/985827878986538291/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=985827878986538291' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/985827878986538291'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/985827878986538291'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2009/05/javahome-command-script.html' title='Set JAVA_HOME in a Windows Command Script'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-3342743659520856245</id><published>2009-04-26T18:09:00.000-07:00</published><updated>2011-12-28T22:41:09.743-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='max os x'/><category scheme='http://www.blogger.com/atom/ns#' term='files'/><category scheme='http://www.blogger.com/atom/ns#' term='documents'/><category scheme='http://www.blogger.com/atom/ns#' term='snap backup'/><category scheme='http://www.blogger.com/atom/ns#' term='ical'/><category scheme='http://www.blogger.com/atom/ns#' term='mail'/><category scheme='http://www.blogger.com/atom/ns#' term='folders'/><category scheme='http://www.blogger.com/atom/ns#' term='safari bookmarks'/><category scheme='http://www.blogger.com/atom/ns#' term='mail.app'/><title type='text'>Save Mac Data with Snap Backup</title><content type='html'>For most Mac users, Apple's &lt;a href="http://en.wikipedia.org/wiki/Time_Machine_(Mac_OS)" title="www.apple.com"&gt;Time Machine&lt;/a&gt; is the best solution for backing up their data.&amp;nbsp;  But for those who desire more control over exactly what data to backup, there's Snap Backup.&amp;nbsp;  If you backup only your personal data instead of your entire hard drive, your backup files can be relatively small and often even fit on a USB flash drive (memory stick).&lt;br /&gt;&lt;br /&gt;The trick is knowing exactly what folders and files to backup.&lt;br /&gt;&lt;br /&gt;Follow the steps below to setup Snap Backup on your Mac OS X system to backup your:&lt;ul style="margin-top: 1px;"&gt;   &lt;li&gt;&lt;i&gt;Documents&lt;/i&gt; Folder&lt;/li&gt;   &lt;li&gt;&lt;i&gt;Desktop&lt;/i&gt;&lt;/li&gt;   &lt;li&gt;&lt;i&gt;Safari&lt;/i&gt; Bookmarks&lt;/li&gt;   &lt;li&gt;&lt;i&gt;Address Book&lt;/i&gt; Data&lt;/li&gt;   &lt;li&gt;&lt;i&gt;iCal&lt;/i&gt; Data&lt;/li&gt;   &lt;li&gt;&lt;i&gt;Mail&lt;/i&gt; (Mail.app) Data&lt;/li&gt;   &lt;/ul&gt;&lt;br /&gt;&lt;div class=push-right&gt;&lt;a href="http://4.bp.blogspot.com/_JkhT9b_CKsM/SgiFCIr9UKI/AAAAAAAAAIA/9CpYJiHjRx0/s800/Snap+Backup+Installer.png" target="_blank"&gt;&lt;img class="link_r" src="http://4.bp.blogspot.com/_JkhT9b_CKsM/SgiFCIr9UKI/AAAAAAAAAIA/9CpYJiHjRx0/s200/Snap+Backup+Installer.png" title="Snap Backup Installer" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;1) Install Snap Backup&lt;/b&gt;Snap Backup is a free open source utility for archiving your data.&lt;br /&gt;&lt;br /&gt;Get it at:   &lt;div class=indent&gt;&lt;a href="http://www.snapbackup.org/download/" title="Download Snap Backup"&gt;www.snapbackup.org/download&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;2) Configure Snap Backup&lt;/b&gt;&lt;br /&gt;Go into the &lt;i&gt;Applications&lt;/i&gt; folder and launch &lt;i&gt;Snap Backup&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;Your &lt;i&gt;Documents&lt;/i&gt; folder and &lt;i&gt;Desktop&lt;/i&gt; will be listed in the "Source: Data to Backup" section by default.&amp;nbsp;  Now you need to add your &lt;i&gt;Safari&lt;/i&gt; bookmarks.&amp;nbsp;  Do this by clicking the &lt;b&gt;&lt;i&gt;Add File&lt;/i&gt;&lt;/b&gt; button and navigating to and opening the &lt;code&gt;Library/Safari/Bookmarks.plist&lt;/code&gt; file.&lt;br /&gt;&lt;br /&gt;Repeat the add process for each of following folders and files until they are all listed on the Snap Backup screen.&lt;br /&gt;&lt;br /&gt;&lt;table class="data-box"&gt;   &lt;tr&gt;&lt;th&gt;Source&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;td&gt;&lt;b&gt;Data Location&lt;/b&gt; (under &lt;i&gt;Home&lt;/i&gt; folder)&lt;/td&gt;&lt;th&gt;Type&lt;/th&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Documents Folder&lt;/th&gt;&lt;td&gt;Work files&lt;/td&gt;&lt;td&gt;&lt;code&gt;Documents&lt;/code&gt;&lt;/td&gt;&lt;td&gt;folder&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Desktop&lt;/th&gt;&lt;td&gt;Work files&lt;/td&gt;&lt;td&gt;&lt;code&gt;Desktop&lt;/code&gt;&lt;/td&gt;&lt;td&gt;folder&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Safari&lt;/th&gt;&lt;td&gt;Bookmarks&lt;/td&gt;&lt;td&gt;&lt;code&gt;Library/Safari/Bookmarks.plist&lt;/code&gt;&lt;/td&gt;&lt;td&gt;file&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Address Book&lt;/th&gt;&lt;td&gt;Contacts&lt;/td&gt;&lt;td&gt;&lt;code&gt;Library/Application Support/AddressBook&lt;/code&gt;&lt;/td&gt;&lt;td&gt;folder&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;iCal&lt;/th&gt;&lt;td&gt;Meetings&lt;/td&gt;&lt;td&gt;&lt;code&gt;Library/Calendars&lt;/code&gt;&lt;/td&gt;&lt;td&gt;folder&lt;/td&gt;&lt;/tr&gt;   &lt;tr&gt;&lt;th&gt;Mail&lt;/th&gt;&lt;td&gt;E-mail&lt;/td&gt;&lt;td&gt;&lt;code&gt;Library/Mail&lt;/code&gt;&lt;br&gt;&lt;code&gt;Library/Preferences/com.apple.mail.plist&lt;/code&gt;&lt;/td&gt;&lt;td&gt;folder&lt;br&gt;file&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;Data Location is relative to your &lt;i&gt;Home&lt;/i&gt; folder (&lt;code&gt;/Users/&lt;/code&gt;&lt;i&gt;[YourUserName]&lt;/i&gt;).&amp;nbsp;  For example, the full path for the &lt;code&gt;Documents&lt;/code&gt; folder on my system is: &lt;nobr&gt;&lt;code&gt;/Users/dem/Documents&lt;/code&gt;&lt;/nobr&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=push-right&gt;&lt;a href="http://4.bp.blogspot.com/_JkhT9b_CKsM/SgiPeSQwBgI/AAAAAAAAAII/lQ8L_140zvg/s800/Snap+Backup+Settings.png"&gt;&lt;img class="link_r" src="http://4.bp.blogspot.com/_JkhT9b_CKsM/SgiPeSQwBgI/AAAAAAAAAII/lQ8L_140zvg/s200/Snap+Backup+Settings.png" title="Snap Backup Settings" /&gt;&lt;/a&gt;&lt;/div&gt;Click the &lt;b&gt;&lt;i&gt;Save Settings&lt;/i&gt;&lt;/b&gt; button.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3) Prepare for Backup&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Optional:&lt;/i&gt; To make your e-mail more compact, you can empty your mail &lt;i&gt;Trash&lt;/i&gt; (&lt;b&gt;&lt;i&gt;Mailbox&lt;/i&gt;&lt;/b&gt; &amp;amp;rarr; &lt;b&gt;&lt;i&gt;Erase Deleted Message&lt;/i&gt;&lt;/b&gt;).&amp;nbsp;  Additionally, you should delete unneeded attachments (&lt;b&gt;&lt;i&gt;Message&lt;/i&gt;&lt;/b&gt; &amp;amp;rarr; &lt;b&gt;&lt;i&gt;Remove Attachments&lt;/i&gt;&lt;/b&gt;).&lt;br /&gt;&lt;br /&gt;Quit &lt;i&gt;Address Book&lt;/i&gt;, &lt;i&gt;iCal&lt;/i&gt;, and &lt;i&gt;Mail&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4) Perform Backup&lt;/b&gt;&lt;br /&gt;In &lt;i&gt;Snap Backup&lt;/i&gt;, click the &lt;b&gt;&lt;i&gt;Backup Now&lt;/i&gt;&lt;/b&gt; button to perform the backup.&lt;br /&gt;&lt;br /&gt;Be sure to perform backups on a regular basis, and periodically copy your backup files to a USB flash drive, external hard drive, or other remote storage device.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;hr /&gt;In the event you need to restore your data from a backup, follow the steps below.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Restore Steps:&lt;/b&gt;&lt;ol&gt;   &lt;li&gt;Quit &lt;i&gt;Address Book&lt;/i&gt;, &lt;i&gt;iCal&lt;/i&gt;, and &lt;i&gt;Mail&lt;/i&gt;&lt;/li&gt;   &lt;li&gt;Use &lt;i&gt;Finder&lt;/i&gt; to navigate to your &lt;code&gt;Backup&lt;/code&gt; folder&lt;/li&gt;   &lt;li&gt;Identify the backup file you wish to restore and double-click it (this will reveal the contents of the backup file)&lt;/li&gt;   &lt;li&gt;Drag the contents into your &lt;i&gt;Home&lt;/i&gt; folder&lt;/li&gt;   &lt;li&gt;Launch &lt;i&gt;Address Book&lt;/i&gt;, &lt;i&gt;iCal&lt;/i&gt;, and &lt;i&gt;Mail&lt;/i&gt; and check that your data has been restored.&lt;/li&gt;   &lt;/ol&gt;&lt;br /&gt;If you have a suggestion for an enhancement to Snap Backup, please let us know using the &lt;a href="http://www.snapbackup.org/feedback/" title="www.snapbackup.org"&gt;feedback form&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-3342743659520856245?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/3342743659520856245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=3342743659520856245' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/3342743659520856245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/3342743659520856245'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2009/04/save-mac-data-with-snap-backup.html' title='Save Mac Data with Snap Backup'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_JkhT9b_CKsM/SgiFCIr9UKI/AAAAAAAAAIA/9CpYJiHjRx0/s72-c/Snap+Backup+Installer.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-5375569359431647362</id><published>2008-03-02T21:39:00.000-08:00</published><updated>2011-12-27T22:48:27.362-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='microsoft outlook'/><category scheme='http://www.blogger.com/atom/ns#' term='inbox zero'/><category scheme='http://www.blogger.com/atom/ns#' term='email'/><category scheme='http://www.blogger.com/atom/ns#' term='done button'/><category scheme='http://www.blogger.com/atom/ns#' term='move'/><category scheme='http://www.blogger.com/atom/ns#' term='vba macro'/><title type='text'>Outlook Done Button</title><content type='html'>A strategy called &lt;a href="http://www.inboxzero.com/" title="Control your inbox"&gt;Inbox Zero&lt;/a&gt; centers around a "process to zero" approach to keeping your e-mail inbox empty.  You can use the Inbox Zero strategy to save yourself from e-mail overload and significantly reduce the amount time you waste rereading e-mails and sifting through an overflowing, stale inbox.&lt;br /&gt;&lt;div style="float: left; margin: 15px 15px 15px 0px; padding: 0px;"&gt;&lt;img src="http://3.bp.blogspot.com/_JkhT9b_CKsM/R8w-5qD2hTI/AAAAAAAAAC0/OYkefw_ZGag/s400/Done+Folder.png" /&gt;&lt;/div&gt;Many of your e-mail messages can simply be deleted after you have read them, and other messages should be moved into specific folders for future action or reference.  However, it is likely that the majority of your incoming messages simply need to be quickly read once and then moved out of the way into some kind of general "Done" folder.  These are the messages that require no action and are not worthy of filing into any specific folder, but it would be unwise to immediately delete them.&lt;br /&gt;&lt;br /&gt;Many e-mail applications make the process of moving read e-mail into a "Done" folder very easy with a single button click or keystroke -- not Microsoft Outlook.  &lt;a href="http://techdem.blogspot.com/2007/04/please-no-word-docs.html" title="Burden on the world"&gt;Microsoft&lt;/a&gt; has an amazing ability to make obvious and simple tasks become painfully convoluted and cumbersome.  Fortunately, there is a way to &lt;br /&gt;&lt;div style="float: right; margin: 15px 0px 15px 15px; padding: 0px;"&gt;&lt;img src="http://2.bp.blogspot.com/_JkhT9b_CKsM/R8w98aD2hSI/AAAAAAAAACs/CDDDqfd_cRg/s400/Done+Button.png" /&gt;&lt;/div&gt;configure Outlook to enable you to "process to zero" without being forced to use the mouse to drag each and every message into a "Done" folder.&lt;br /&gt;&lt;br /&gt;Follow the steps below to create an Outlook macro which implements a Done button.  The first step guides you though creating a certificate for you macro so the macro will be "trusted" on you computer.  Then you will create the macro itself and a corresponding &lt;b&gt;Done&lt;/b&gt; folder.  Lastly, customize the toolbar to add a button which runs the macro.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Steps:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;A) Create a Personal Digital Certificate&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Start  →  Programs  →  Microsoft Office  →  Microsoft Office Tools  →  Digital Certificate for VBA Projects  →  Your certificate's name: &lt;/i&gt;Personal Certificate&lt;i&gt;  →  OK  →  OK&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;img src="http://3.bp.blogspot.com/_JkhT9b_CKsM/R8w_-qD2hUI/AAAAAAAAAC8/9BY_uRdlYE8/s400/Done+Cert+Launch.png" style="padding: 0px;" /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;B) Create Macro from Microsoft Outlook&lt;/b&gt;&lt;br /&gt;1: &lt;i&gt;Tools  →  Macro  →  Macros...&lt;/i&gt;&lt;br /&gt;2: In  "Macro Name:" field, enter "MoveToDone" and click "Create"&lt;br /&gt;3: Enter the following code into the VBA editor:&lt;br /&gt;&lt;br /&gt;&lt;div class="code-box"&gt;&lt;pre&gt;Sub MoveToDone()&lt;br /&gt;  Set DoneFolder = Application.GetNamespace("MAPI"). _&lt;br /&gt;     GetDefaultFolder(olFolderInbox).Parent.Folders("Done")&lt;br /&gt;  For Each Msg In ActiveExplorer.Selection&lt;br /&gt;     Msg.Move DoneFolder&lt;br /&gt;     Next Msg&lt;br /&gt;  End Sub&lt;/pre&gt;&lt;/div&gt;&lt;div class="box-caption"&gt;&lt;a href="http://www.centerkey.com/files/MoveToDone.txt" title="Code for Outlook macro"&gt;View/Download&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;4: &lt;i&gt;Tools  →  Digital Signature...  →  Choose...  →  Select "Personal Certificate"  →  OK  →  OK&lt;/i&gt;&lt;br /&gt;5: &lt;i&gt;File  →  Save&lt;/i&gt;&lt;br /&gt;6: &lt;i&gt;File  →  Close and Return to Microsoft Outlook Office&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;C) Create a Done Folder&lt;/b&gt;&lt;br /&gt;&lt;i&gt;File  →  New  →  Folder...  →  Name: &lt;/i&gt;Done&lt;i&gt;  →  Select Mailbox (top of list)  →  OK&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;D) Add Done Button&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Tools  →  Customize...  →  Commands  →  Macros  →  Drag Project1.MoveToDone onto the toolbar  →  Context menu (right-click) for the new MoveToDone button  →  Set "Name:" to Done  →  Close&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;img src="http://3.bp.blogspot.com/_JkhT9b_CKsM/R8xCMqD2hVI/AAAAAAAAADE/-hm9ZyXdVWY/s400/Done+Add+Button.png" style="padding: 0px;" /&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;E) Enable Macros&lt;/b&gt;&lt;br /&gt;After restating Outlook and clicking your new "Done" button, you will be prompted to allow the button to run.&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;img src="http://1.bp.blogspot.com/_JkhT9b_CKsM/SLXgpJSBldI/AAAAAAAAADM/ixX-e6AN9-w/s400/outlook-done-security.png" style="padding: 0px;" /&gt;&lt;/center&gt;&lt;br /&gt;Check the "Always trust macros from this publisher" option and then click "Enable Macros".&lt;br /&gt;&lt;br /&gt;Now you can move a message from your Inbox into the Done folder with the "Done" button.&lt;br /&gt;&lt;br /&gt;You might also find it valuable to use the "Outbox" as your to do list.  If you need to take action on the e-mail, reply to the message even if you do not immediately send your reply.  That way, your "Outbox" becomes your to do list.&lt;br /&gt;&lt;br /&gt;Leveraging your Outbox as your to do list and using your new Done button, you can maintain an empty Inbox and focus on doing real work instead of suffering from e-mail overload.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-5375569359431647362?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/5375569359431647362/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=5375569359431647362' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/5375569359431647362'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/5375569359431647362'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2008/03/outlook-done-button.html' title='Outlook Done Button'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_JkhT9b_CKsM/R8w-5qD2hTI/AAAAAAAAAC0/OYkefw_ZGag/s72-c/Done+Folder.png' height='72' width='72'/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-7955447701895671786</id><published>2008-02-21T15:30:00.000-08:00</published><updated>2011-12-27T22:45:14.145-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='png'/><category scheme='http://www.blogger.com/atom/ns#' term='gimp'/><category scheme='http://www.blogger.com/atom/ns#' term='image'/><category scheme='http://www.blogger.com/atom/ns#' term='email'/><category scheme='http://www.blogger.com/atom/ns#' term='script-fu'/><category scheme='http://www.blogger.com/atom/ns#' term='screenshot processor'/><title type='text'>GIMP Screenshot Processor (Script-Fu)</title><content type='html'>They say a picture is worth a thousand words.  In that vain, rather than describe something on your computer display in words, it is often more effective to use a screenshot.  However, raw screenshots can be cumbersome.&lt;br /&gt;&lt;br /&gt;The image processing I use to make a raw screenshot easier to handle and view is straightforward:&lt;ol&gt;   &lt;li&gt;Scale down (shrink) the image by 80%&lt;/li&gt;   &lt;li&gt;Run the sharpen filter to make the text more readable&lt;/li&gt;   &lt;li&gt;Reduce the palette to 256 colors to take less space&lt;/li&gt;   &lt;li&gt;Add a border to make the image standout&lt;/li&gt;   &lt;li&gt;Save the image as a &lt;a href="http://en.wikipedia.org/wiki/Portable_Network_Graphics" title="Portable Network Graphics"&gt;PNG&lt;/a&gt; file for universal viewing&lt;/li&gt;   &lt;/ol&gt;&lt;br&gt;The image processing is easy in most graphics editors, but it is rather tedious if you are making lots of screenshots.  If you use the Open Source (free) graphics editor &lt;a href="http://www.gimp.org/" title="GNU Image Manipulation Program"&gt;GIMP&lt;/a&gt;, you can write a script to automatically perform the steps.&lt;br /&gt;&lt;br /&gt;&lt;div class=code-box&gt;&lt;pre&gt;; GIMP Screenshot Processor v1.2 (Script-Fu)&lt;br /&gt;(define (screenshot-processor img draw)&lt;br /&gt;   (gimp-image-scale img  ;Shrink image 80%&lt;br /&gt;      (* (car (gimp-image-width img)) 0.8)&lt;br /&gt;      (* (car (gimp-image-height img)) 0.8))&lt;br /&gt;   (plug-in-sharpen TRUE img draw 25)  ;Sharpen image&lt;br /&gt;   (gimp-image-convert-indexed img  ;Reduce colors to 256&lt;br /&gt;      1 0 256 FALSE TRUE "")&lt;br /&gt;   (script-fu-addborder img draw  ;Add 4px border&lt;br /&gt;       4 4 '(128 128 128) 0)&lt;br /&gt;   (gimp-image-flatten img)  ;Convert to single layer&lt;br /&gt;   )&lt;br /&gt;(script-fu-register&lt;br /&gt;   "screenshot-processor" "Screenshot Processor"&lt;br /&gt;   "Shrinks, sharpens, reduces color, and adds border to current image."&lt;br /&gt;   "Dem Pilafian, Center Key Software"&lt;br /&gt;   "Public Domain" "October 5, 2008" ""&lt;br /&gt;   SF-IMAGE "Image" 0 SF-DRAWABLE "Drawable" 0)&lt;br /&gt;(script-fu-menu-register "screenshot-processor" "&amp;lt;Image&amp;gt;/Tools")&lt;/pre&gt;&lt;/div&gt;&lt;div class=box-caption&gt;Download: &lt;a href="http://www.centerkey.com/files/screenshot-processor.scm.txt" title="Remove .txt from file name"&gt;&lt;code&gt;screenshot-processor.scm&lt;/code&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;b&gt;Steps to Install:&lt;/b&gt;&lt;ol&gt;   &lt;li&gt;Download script and save it as: &lt;b&gt;&lt;code&gt;screenshot-processor.scm&lt;/code&gt;&lt;/b&gt;&lt;/li&gt;   &lt;li&gt;Copy file to folder: &lt;b&gt;&lt;code&gt;&amp;lt;installfolder&amp;gt;/GIMP-2.0/share/gimp/2.0/scripts/&lt;/code&gt;&lt;/b&gt;&lt;/li&gt;   &lt;li&gt;&lt;b&gt;&lt;i&gt;Filters → Script-Fu → Refresh Scripts&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;   &lt;/ol&gt;&lt;br /&gt;&lt;img class=picture-box src="http://3.bp.blogspot.com/_JkhT9b_CKsM/R74NawGnqJI/AAAAAAAAACk/tFDZe2pbC-M/s400/screenshot-processor.png" /&gt;&lt;div class=box-caption&gt;Screenshot Processor&lt;/div&gt;&lt;/br&gt;Now you are ready to take your screenshot (in Microsoft Windows: &lt;b&gt;&lt;i&gt;&amp;lt;Ctrl-PrintScreen&amp;gt;&lt;/i&gt;&lt;/b&gt; or &lt;b&gt;&lt;i&gt;&amp;lt;Alt-PrintScreen&amp;gt;&lt;/i&gt;&lt;/b&gt;).&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Steps to Run:&lt;/b&gt;&lt;ol&gt;   &lt;li&gt;Create new image by pasting screenshot into GIMP&lt;/li&gt;   &lt;li&gt;&lt;b&gt;&lt;i&gt;Tools → Screenshot Processor&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;   &lt;li&gt;&lt;b&gt;&lt;i&gt;File → Save → Name:&lt;/i&gt; screenshot.png &lt;i&gt;→ Save → Save&lt;/i&gt;&lt;/b&gt;&lt;/li&gt;   &lt;/ol&gt;&lt;br /&gt;The result is a convenient screenshot image file that is appropriate for sending in an e-mail.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-7955447701895671786?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/7955447701895671786/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=7955447701895671786' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/7955447701895671786'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/7955447701895671786'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2008/02/gimp-screenshot-processor-script-fu.html' title='GIMP Screenshot Processor (Script-Fu)'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_JkhT9b_CKsM/R74NawGnqJI/AAAAAAAAACk/tFDZe2pbC-M/s72-c/screenshot-processor.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-6012056051121534064</id><published>2007-04-30T01:17:00.000-07:00</published><updated>2011-12-27T22:35:56.156-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='opendocument'/><category scheme='http://www.blogger.com/atom/ns#' term='odf'/><category scheme='http://www.blogger.com/atom/ns#' term='neooffice'/><category scheme='http://www.blogger.com/atom/ns#' term='email attachement'/><category scheme='http://www.blogger.com/atom/ns#' term='pdf'/><category scheme='http://www.blogger.com/atom/ns#' term='microsoft word'/><category scheme='http://www.blogger.com/atom/ns#' term='doc'/><title type='text'>Please, No Word Docs</title><content type='html'>It used to be that when someone would e-mail me a Microsoft Word document I would cringe but basically accept that that just reflected the sad state of the computer world.&amp;nbsp;  If I needed to open the Word document, I feared Microsoft ActiveX components and malicious macro viruses taking over my computer and deleting files or stealing passwords.&lt;br /&gt;&lt;br /&gt;Nowadays there is almost never a good reason to e-mail a Word document.&amp;nbsp;  If you intend for the recipients to only view and print the document, &lt;i&gt;send the document as a PDF file&lt;/i&gt;.&amp;nbsp;  If, on the other hand, you intend for the recipients to make edits to the document, &lt;i&gt;send the document as an ODF (Open Document Format) file&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Generating PDF Files&lt;/b&gt;&lt;br /&gt;Wikipedia describes &lt;a href="http://en.wikipedia.org/wiki/Portable_Document_Format"&gt;PDF&lt;/a&gt; as "the de facto standard for printable documents."  PDFs are easily opened on most all computers today and tend to be very compact, so they are practical and convenient as e-mail attachments.&lt;br /&gt;&lt;br /&gt;On Mac OS X it couldn't be easier to generate PDF files.&amp;nbsp;  Apple built PDF support right into the operating system.&amp;nbsp;  From any word processor, like iWork Pages or MS Office, just bring up the print window (press &lt;i&gt;&amp;lt;Command-P&amp;gt;&lt;/i&gt;), click the "PDF" button, and select "Save as PDF...".&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img class=picture-box src="http://3.bp.blogspot.com/_JkhT9b_CKsM/RjZ4egwYMWI/AAAAAAAAABc/xP2cGrb1OIw/s400/save-pdf-mac.png"&gt;&lt;div class=box-caption&gt;Generating a PDF on Mac OS X&lt;/div&gt;&lt;br /&gt;After you have saved your document as a PDF file, send it as an e-mail attachment.&lt;br /&gt;&lt;br /&gt;On Windows it's almost as easy, but you first need to install a &lt;i&gt;print-to-PDF&lt;/i&gt; utility such as the popular and free &lt;a href="http://sourceforge.net/projects/pdfcreator/"&gt;PDFCreator&lt;/a&gt;.&amp;nbsp;  After installing PDFCreator, just print from any word processor, such as LibreOffice, OpenOffice.org, or MS Office, and select the printer named "PDFCreator".&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img class=picture-box src="http://1.bp.blogspot.com/_JkhT9b_CKsM/RjZ4oAwYMXI/AAAAAAAAABk/rOBD4I2dhTk/s400/save-pdf-windows.png"&gt;&lt;div class=box-caption&gt;Generating a PDF on Windows&lt;/div&gt;&lt;br /&gt;Save the PDF file to your Desktop and then send it as an e-mail attachment.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;OpenDocument&lt;/b&gt;&lt;br /&gt;If you intend for the recipients of your e-mail message to be able to edit the document you are sending, you will want to be sure the recipients have access to a word processor that understands the format of your attached document.&lt;br /&gt;&lt;br /&gt;Unfortunately, if you send a Word Perfect file, you are discourteously assuming the recipients have purchased Word Perfect.&amp;nbsp;  Likewise, if you send an MS Word file, you are discourteously assuming the recipients have purchased MS Word.&amp;nbsp;  And, if you send an iWork Pages, you are discourteously assuming the recipients have purchased iWork Pages.&amp;nbsp;  There is a better way.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://en.wikipedia.org/wiki/OpenDocument"&gt;OpenDocument (ODF)&lt;/a&gt; is an international standard document format which does not dictate a restriction of using a particular word processor.&amp;nbsp;  If you or any of your e-mail recipients do not already have an ODF capable office suite, there are full featured Open Source office suites that can be downloaded for free.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table class=data&gt;&lt;tr style="background-color: white;"&gt;&lt;th&gt;&lt;a href="http://www.libreoffice.org/" title="Mac, Windows, and Linux"&gt;&lt;img style="width: 50px;" src="http://3.bp.blogspot.com/--WOtf1aXxvc/Tvq1RWAVB7I/AAAAAAAAANg/dWWgTZ2kdiE/s400/LibreOffice.png"&gt;&lt;/a&gt;&lt;br&gt;&lt;i&gt;LibreOffice&lt;/i&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="http://www.openoffice.org/" title="Mac, Windows, and Linux"&gt;&lt;img src="http://2.bp.blogspot.com/_JkhT9b_CKsM/Rjaz5QwYMaI/AAAAAAAAAB8/oM14j4Xe4lg/s400/icon-openoffice.png"&gt;&lt;/a&gt;&lt;br&gt;&lt;i&gt;OpenOffice.org&lt;/i&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="http://www.koffice.org/" title="Linux"&gt;&lt;img style="width: 50px;" src="http://3.bp.blogspot.com/-OZT-UBB9TeU/Tvq1br_IoWI/AAAAAAAAANs/XuO4eDwC6es/s200/KOffice.png"&gt;&lt;/a&gt;&lt;br&gt;&lt;i&gt;KOffice&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;For Mac OS X, Microsoft Windows, and Linux, download &lt;a href="http://www.openoffice.org/"&gt;OpenOffice.org&lt;/a&gt;.&amp;nbsp;  For Linux, you can also download &lt;a href="http://www.koffice.org/"&gt;KOffice&lt;/a&gt;.&amp;nbsp;  These are complete office suites with word processors, presentation programs, and spreadsheets.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Please&lt;/b&gt;&lt;br /&gt;Next time you need to send out a document, think of the recipients.&amp;nbsp;  Please, no Word docs.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Elsewhere&lt;/b&gt;&lt;small&gt;&lt;br /&gt;&lt;a href="http://en.nothingisreal.com/wiki/Please_don't_send_me_Microsoft_Word_documents"&gt;Please don't send me Microsoft Word documents&lt;/a&gt; (nothingisreal.com)&lt;br /&gt;&lt;a href="http://sify.com/finance/fullstory.php?id=14764211"&gt;ODF likely standard for e-governance&lt;/a&gt; (Sify.com)&lt;br /&gt;&lt;a href="http://www.openmediaboston.org/node/323"&gt;Why Are You Still Wasting Money on MS Office?&lt;/a&gt; (Open Media Boston)&lt;br /&gt;&lt;a href="http://arstechnica.com/news.ars/post/20080925-judge-microsoft-documentation-unfit-for-us-consumption.html"&gt;Judge: Microsoft documentation unfit for US consumption&lt;/a&gt; (Ars Technica)&lt;br /&gt;&lt;a href="http://www.computerweekly.com/Articles/2008/01/04/228747/governments-adopt-opendocument-format.htm"&gt;Governments adopt OpenDocument Format&lt;/a&gt; (ComputerWeekly.com)&lt;br /&gt;&lt;a href="http://www.cbronline.com/article_news.asp?guid=5CCA84A7-F291-40CC-B2DA-6CF637195FE5"&gt;US libraries back Massachusetts ODF plan&lt;/a&gt; (Computer Business Review)&lt;br /&gt;&lt;a href="http://www.desktoplinux.com/news/NS4797716899.html"&gt;Massachusetts verdict: MS Office formats out&lt;/a&gt; (DesktopLinux.com)&lt;br /&gt;&lt;a href="http://news.zdnet.co.uk/software/0,1000000121,39276978,00.htm"&gt;Belgian government chooses OpenDocument&lt;/a&gt; (ZDNet)&lt;br /&gt;&lt;a href="http://www.infoworld.com/article/07/05/15/norway-mandates-open-documents_1.html"&gt;Norway likely to mandate open document formats&lt;/a&gt; (InfoWorld)&lt;br /&gt;&lt;a href="http://www.desktoplinux.com/news/NS3446288416.html"&gt;California may mandate ODF for all state offices&lt;/a&gt; (DesktopLinux.com)&lt;br /&gt;&lt;a href="http://www.infoworld.com/article/07/02/06/HNtexasminnodf_1.html"&gt;Texas, Minnesota eye move to ODF&lt;/a&gt; (InfoWorld)&lt;br /&gt;&lt;a href="http://news.com.com/8301-10784_3-6122939-7.html"&gt;French government report lauds ODF&lt;/a&gt; (CNET News)&lt;br /&gt;&lt;a href="http://weblog.infoworld.com/openresource/archives/2007/04/microsoft_tries.html"&gt;Microsoft tries to maintain its monopoly...are you surprised?&lt;/a&gt; (InfoWorld)&lt;/small&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-6012056051121534064?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/6012056051121534064/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=6012056051121534064' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/6012056051121534064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/6012056051121534064'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2007/04/please-no-word-docs.html' title='Please, No Word Docs'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_JkhT9b_CKsM/RjZ4egwYMWI/AAAAAAAAABc/xP2cGrb1OIw/s72-c/save-pdf-mac.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-5514724333262470133</id><published>2007-01-17T16:04:00.000-08:00</published><updated>2011-12-26T00:03:31.613-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='nodes'/><category scheme='http://www.blogger.com/atom/ns#' term='cluster'/><category scheme='http://www.blogger.com/atom/ns#' term='terracotta'/><category scheme='http://www.blogger.com/atom/ns#' term='clustering'/><category scheme='http://www.blogger.com/atom/ns#' term='object identity'/><category scheme='http://www.blogger.com/atom/ns#' term='servers'/><title type='text'>Don't Sacrifice Object Identity to Cluster Your Java Application</title><content type='html'>Two objects may have the same value yet not be the same objects.&amp;nbsp;  In Java you test if objects have the same value using &lt;code&gt;equals()&lt;/code&gt; and test if they are actually the same object using the &lt;code&gt;==&lt;/code&gt; operator.&amp;nbsp;  The &lt;code&gt;==&lt;/code&gt; operator compares object IDs to test if the two objects are truly the same.&amp;nbsp;  &lt;a href="http://www.onjava.com/pub/a/onjava/2006/09/13/dont-let-hibernate-steal-your-identity.html"&gt;James Brundege&lt;/a&gt; explains, "In the VM you do not get an ID for an object; you simply hold direct references to the object.&amp;nbsp;  Behind the scenes, the VM does assign an eight-byte ID, which is what a reference to an object really is."  This notion of object identity is fundamental to Java programming semantics and is part of everything from passing objects into methods to referencing objects from other objects.&lt;br /&gt;&lt;br /&gt;For example, a shopping cart might have a shipping method set which in turn has a rate used for calculating the shipping charge.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;img src="http://1.bp.blogspot.com/_JkhT9b_CKsM/Ra7GF4nxKiI/AAAAAAAAAAM/Bch-Z26mNa8/s400/java-obj-id-classes.png" /&gt;&lt;br /&gt;&lt;b&gt;Java Classes for a Simple Cart&lt;/b&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;You could access the rate object using simple getters with code such as: &lt;code&gt;cart.getShippingMethod().getRate()&lt;/code&gt;.&amp;nbsp;  This is straightforward for Java developers to code and is very efficient within the JVM.&amp;nbsp;  Compare this approach to the database paradigm which has a radically different set of constraints than Java programming.&lt;br /&gt;&lt;br /&gt;Relational databases have tables with rows and columns where information is tied together with keys.&amp;nbsp;  This structure is appropriate when storing data to disk, but it results in an &lt;a href="http://en.wikipedia.org/wiki/Object-Relational_impedance_mismatch"&gt;object-relational impedance mismatch&lt;/a&gt; when moving between the database world and the Java world.&amp;nbsp;  Keys work well in relational databases to hook up the bits of data, but they create undesirable overhead and complexity when introduced into your application code.&amp;nbsp;  In our example of the shopping cart, you would end up writing special methods for passing around keys and performing lookups in tables for shipping methods and rates instead of using simple getters leveraging the natural semantics of Java.&amp;nbsp;  Or put more simply, Java is well suited for business logic working on transient data and the database is well suited to handling persistent data.&lt;br /&gt;&lt;br /&gt;This leads us to a fundamental guideline of building real world applications: &lt;i&gt;Resist with all your ability treating transient application data as persistent data to solve some architectural need&lt;/i&gt;.&amp;nbsp;  Only make data persistent when it is truly ready to be stored in the database.&amp;nbsp;  This guideline can even be applied to clustering.&lt;br /&gt;&lt;br /&gt;Traditional clustering solutions with APIs to access a clustered HashMap require serialization (implement &lt;code&gt;java.io.Serializable&lt;/code&gt;) and cause Java objects to lose their identity which essentially forces the overhead of the database paradigm into the coding for your transient application data.&amp;nbsp;  The API is the interface between the application and the cluster.&amp;nbsp;  Think of the API as the impedance resulting from the object to clustered HashMap mismatch.&lt;br /&gt;&lt;br /&gt;The objects in the clustered HashMap are isolated such that re-materializing them on a different node puts the burden of managing the object relationships on the application developer.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;img src="http://1.bp.blogspot.com/_JkhT9b_CKsM/Ra7Ig4nxKlI/AAAAAAAAAAk/yzPUwslJiOE/s400/java-obj-id-objects.png" /&gt;&lt;br /&gt;&lt;b&gt;Relationships for Cart Objects&lt;/b&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;If you put a cart object into a clustered HashMap or database and later retrieve the shipping method and the rate, your application has to know how to reconstruct those object relationships.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;img src="http://4.bp.blogspot.com/_JkhT9b_CKsM/Ra7IgonxKkI/AAAAAAAAAAc/Woe20b0ZLjI/s400/java-obj-id-hashmap.png" /&gt;&lt;br /&gt;&lt;b&gt;Distributed HashMaps Wreak Havoc on Object Identity&lt;/b&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.terracotta.org/"&gt;Open Terracotta&lt;/a&gt; is an open source clustering solution that takes a very different approach to clustering — one that enables it to preserve object identity across the cluster.&amp;nbsp;  A shared object is logically the same object across the cluster.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;img src="http://1.bp.blogspot.com/_JkhT9b_CKsM/Ra7Ig4nxKmI/AAAAAAAAAAs/HPbaWVnAf9E/s400/java-obj-id-tc.png" /&gt;&lt;br /&gt;&lt;b&gt;Preserving Object Identity Across the Cluster&lt;/b&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;The core of Open Terracotta is a technology called DSO (Distributed Shared Objects) which clusters Java objects across servers, coordinates threads among the different JVMs, and performs distributed method invocation.&amp;nbsp;  DSO clusters at the JVM level using &lt;a href="http://unserializableone.blogspot.com/2006/12/using-java-bytecode-in-clustering.html"&gt;bytecode instrumentation&lt;/a&gt; enabling it to monitor when your application reads or modifies any shared objects and then only transmit the fields of the object that actually changed when they are needed.&amp;nbsp;  You use an XML configuration file to tell DSO which objects to share.&lt;br /&gt;&lt;br /&gt;&lt;div class=code-box&gt;&lt;pre&gt;&amp;lt;dso&amp;gt;&lt;br /&gt;   &amp;lt;instrumented-classes&amp;gt;&lt;br /&gt;      &amp;lt;include&amp;gt;&lt;br /&gt;         &amp;lt;class-expression&amp;gt;com.townsend-camera.cart.*&amp;lt;/class-expression&amp;gt;&lt;br /&gt;      &amp;lt;/include&amp;gt;&lt;br /&gt;   &amp;lt;/instrumented-classes&amp;gt;&lt;br /&gt;   &amp;lt;web-applications&amp;gt;&lt;br /&gt;     &amp;lt;web-application&amp;gt;Cart&amp;lt;/web-application&amp;gt;&lt;br /&gt;   &amp;lt;/web-applications&amp;gt;&lt;br /&gt;&amp;lt;/dso&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=box-caption&gt;Sample Configuration for Clustering Cart Application&lt;/div&gt;&lt;br /&gt;Object sharing effectively takes place below the application, so the application is not specifically aware of or directly involved in the clustering.&amp;nbsp;  DSO materializes the shared objects in the JVMs and keeps the objects coherent, including object identity, across the JVMs.&lt;br /&gt;&lt;br /&gt;Preserving object identity makes clustering more transparent for application developers but has a potentially greater impact on clustering of frameworks and tools, such as &lt;a href="http://jboner.github.com/2006/08/17/webex-how-to-cluster-your-spring-application-in-less-than-30-min.html"&gt;Spring&lt;/a&gt;, Lucene, and &lt;a href="http://javamuse.blogspot.com/2006/12/clustering-glassbox.html"&gt;Glassbox&lt;/a&gt;.&amp;nbsp;  Just like the Java applications that use them, frameworks and tools written in Java are built on objects.&amp;nbsp;  One key difference is that it is often impractical to access and modify the source code of frameworks and tools used by your application.&amp;nbsp;  By weaving the clustering code into classes as they are loaded into the JVM, Open Terracotta does not rely on the source code.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;center&gt;&lt;img src="http://3.bp.blogspot.com/_JkhT9b_CKsM/Ra7IgYnxKjI/AAAAAAAAAAU/6ADfP8_uDBk/s400/java-obj-id-framework.png" /&gt;&lt;br /&gt;&lt;b&gt;Clustering at the JVM Level&lt;/b&gt;&lt;/center&gt;&lt;br /&gt;&lt;br /&gt;Of course, some classes are inherently unclusterable, like classes with threads and disk I/O.&amp;nbsp;  Writing a sales transaction to disk from one application node should not automatically cause every other application node in the cluster to attempt to do the same.&amp;nbsp;  This brings us back to the contrast of transient application data verses persistent data, and our earlier guideline: &lt;i&gt;Resist with all your ability treating transient application data as persistent data to solve some architectural need&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;In our shopping cart example, a cart generally is transient application data until the user performs a checkout and makes a purchase.&amp;nbsp;  Clustering the cart enables scaling-out the application across a server farm and ensures that if an application node fails, the user's cart is preserved and made available on another application node.&amp;nbsp;  Pushing out when data is specifically persisted by the application makes it easier to cluster your application while still preserving object identity across the cluster to simplify your application code.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-5514724333262470133?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/5514724333262470133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=5514724333262470133' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/5514724333262470133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/5514724333262470133'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2007/01/dont-sacrifice-object-identity-to.html' title='Don&apos;t Sacrifice Object Identity to Cluster Your Java Application'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_JkhT9b_CKsM/Ra7GF4nxKiI/AAAAAAAAAAM/Bch-Z26mNa8/s72-c/java-obj-id-classes.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3143222736230165985.post-2465569002746682811</id><published>2006-12-22T13:38:00.000-08:00</published><updated>2011-12-25T23:50:55.604-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='virus'/><category scheme='http://www.blogger.com/atom/ns#' term='file type'/><category scheme='http://www.blogger.com/atom/ns#' term='executable'/><category scheme='http://www.blogger.com/atom/ns#' term='email'/><category scheme='http://www.blogger.com/atom/ns#' term='attachment'/><category scheme='http://www.blogger.com/atom/ns#' term='safe'/><title type='text'>But the e-mail came from someone I trust...</title><content type='html'>The single most harmful advice perpetrated on computer users is to only open &lt;nobr&gt;e-mail&lt;/nobr&gt; attachments from people they know.&lt;br /&gt;&lt;br /&gt;The implication is that you have no control over getting a computer virus — you must rely on trust.&amp;nbsp;  The problem is most viruses come from people you know.&lt;br /&gt;&lt;br /&gt;IT departments around the world have given out this dangerous advise for years.&amp;nbsp;  It's failed us miserably and resulted in a give up and surrender mentality of relying on virus scanning software to save our pathetic, helpless selves.&lt;br /&gt;&lt;br /&gt;Instead, IT departments should educate computer users to only open (click on) &lt;nobr&gt;e-mail&lt;/nobr&gt; attachments if they know the file type of the attachment is safe and does not run a program or script.&amp;nbsp;  It's ok to open a picture or a movie but only if you know the attachment actually is a picture or a movie.&amp;nbsp;  &lt;b&gt;If you are not sure, don't open it.&lt;/b&gt;&amp;nbsp;  Simple.&amp;nbsp;  Any file extension you are not familiar with should be considered dangerous regardless of who sent it.&amp;nbsp;  In particular, never open &lt;nobr&gt;e-mail&lt;/nobr&gt; attachments with extensions of "&lt;code&gt;.exe&lt;/code&gt;", "&lt;code&gt;.bat&lt;/code&gt;", or "&lt;code&gt;.cmd&lt;/code&gt;".&lt;br /&gt;&lt;br /&gt;An &lt;nobr&gt;e-mail&lt;/nobr&gt; attachment is not ok just because it is from a trusted friend.&amp;nbsp;  However, an &lt;nobr&gt;e-mail&lt;/nobr&gt; attachment is almost certainly safe if the file extension (characters after the LAST dot in the file name) is known to be safe.&lt;br /&gt;&lt;br /&gt;Sample Files with &lt;b&gt;Safe&lt;/b&gt; Extensions:&lt;div class=indent&gt;&lt;code&gt;fun.mpg&lt;/code&gt; &amp;nbsp; &lt;i&gt;(movie)&lt;/i&gt;&lt;br /&gt;&lt;code&gt;fun.jpg&lt;/code&gt; &amp;nbsp; &lt;i&gt;(photo)&lt;/i&gt;&lt;br /&gt;&lt;code&gt;fun.png&lt;/code&gt; &amp;nbsp; &lt;i&gt;(image)&lt;/i&gt;&lt;br /&gt;&lt;code&gt;fun.txt&lt;/code&gt; &amp;nbsp; &lt;i&gt;(plain text)&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;Sample Files with &lt;b&gt;Dangerous&lt;/b&gt; Extensions:&lt;div class=indent&gt;&lt;code&gt;fun.exe&lt;/code&gt; &amp;nbsp; &lt;i&gt;(runnable program — very dangerous on Windows)&lt;/i&gt;&lt;br /&gt;&lt;code&gt;fun.bat&lt;/code&gt; &amp;nbsp; &lt;i&gt;(runnable script — very dangerous on Windows)&lt;/i&gt;&lt;br /&gt;&lt;code&gt;fun.cmd&lt;/code&gt; &amp;nbsp; &lt;i&gt;(runnable script — very dangerous on Windows)&lt;/i&gt;&lt;br /&gt;&lt;code&gt;fun.doc&lt;/code&gt; &amp;nbsp; &lt;i&gt;(Word file with VBScript/VBA can contain viruses)&lt;/i&gt;&lt;br /&gt;&lt;code&gt;fun.xlsx&lt;/code&gt; &amp;nbsp; &lt;i&gt;(Excel file with VBScript/VBA can contain viruses)&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;Be careful of masquerading file types.&amp;nbsp;  For example, the file "&lt;code&gt;fun.txt.exe&lt;/code&gt;" is &lt;b&gt;not&lt;/b&gt; a text file; it is a potentially very dangerous executable file.&lt;br /&gt;&lt;br /&gt;And when curiosity is getting the best of you, ask yourself, "&lt;i&gt;If this content is so great, why isn't it on a web site somewhere so I don't have to mess around with opening an &lt;nobr&gt;e-mail&lt;/nobr&gt; attachment?&lt;/i&gt;"&lt;br /&gt;&lt;br /&gt;In general, viewing a web page is safe as long as you don't download and open files from the web site.&amp;nbsp;  However, the web browser Microsoft Internet Explorer (a.k.a. IE) is special &amp;mdash; it automatically runs special Microsoft ActiveX controls from the web site.&amp;nbsp;  And ActiveX can contain viruses.&amp;nbsp;  IE has definitely gotten safer recently, but it has a long history of automatically running dangerous stuff.&amp;nbsp;  You are much, much better off with Firefox, Safari, or Opera.&lt;br /&gt;&lt;br /&gt;Likewise, Microsoft Outlook has long history of automatically running scripts in &lt;nobr&gt;e-mail&lt;/nobr&gt; messages even before the user has opened the message.&amp;nbsp;  Use safer &lt;nobr&gt;e-mail&lt;/nobr&gt; clients, like &lt;a href="http://mozilla.org/thunderbird/"&gt;Thunderbird&lt;/a&gt; or &lt;a href="http://www.apple.com/macosx/whats-new/mail.html"&gt;Apple Mail (mail.app)&lt;/a&gt;.&amp;nbsp;  Or use a web-based &lt;nobr&gt;e-mail&lt;/nobr&gt; system, like &lt;a href="http://mail.google.com/"&gt;Gmail&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;While computer viruses are primarily a problem for Microsoft Windows users, Apple Mac OS X and Linux users should also adopt a policy of only opening &lt;nobr&gt;e-mail&lt;/nobr&gt; attachments if the file type is known to be safe.&lt;br /&gt;&lt;br /&gt;You have more control over your Internet fate than you think.&amp;nbsp;  Take control &amp;mdash; don't just rely on antivirus software.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3143222736230165985-2465569002746682811?l=techdem.centerkey.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techdem.centerkey.com/feeds/2465569002746682811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3143222736230165985&amp;postID=2465569002746682811' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/2465569002746682811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3143222736230165985/posts/default/2465569002746682811'/><link rel='alternate' type='text/html' href='http://techdem.centerkey.com/2006/12/but-e-mail-came-from-someone-i-trust.html' title='But the e-mail came from someone I trust...'/><author><name>Dem Pilafian</name><uri>http://www.blogger.com/profile/16877729223914159583</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://www.pilafian.com/dem/photos3/main.jpg'/></author><thr:total>0</thr:total></entry></feed>
