Skip to content

Instantly share code, notes, and snippets.

@usmansaleem
Last active October 31, 2019 02:51
Show Gist options
  • Save usmansaleem/9bb0e98d05caa0afcc649b6593733edf to your computer and use it in GitHub Desktop.
Save usmansaleem/9bb0e98d05caa0afcc649b6593733edf to your computer and use it in GitHub Desktop.
The data for blog at usmans.info
[ {
"id" : 186,
"urlFriendlyId" : "tcp_client_using_vertx_kotlin_gradle",
"title" : "TCP Client using Vertx, Kotlin and Gradle build",
"description" : "Step by Step guide to create simple TCP client using Vertx, Kotlin and Gradle",
"body" : "<p>As part of my hobby project to control RaspberryPi using Google Home Mini and/or Alexa, I wanted to write a very simple TCP client that keeps a connection open to one of my custom written server in cloud (I will write another blog post to cover the server side on a later date). The requirement of the client is to send a shared secret upon connecting and then keep waiting for message from server. Vert.x, Kotlin and Gradle allow rapid development of such project. The generated jar can be executed on Raspberry Pi. These steps outline the project setup and related source code to showcase a Vert.x and Kotlin project with Gradle.</p>\n<h2>Project Directory Structure</h2>\n<p>From command line (or via Windows Explorer, whatever you prefer to use) create a directory for project,for instance <code>vertx-net-client</code>. Since we are using Kotlin, we will place all Kotlin files in <code>src/main/kotlin</code> folder. The <code>src/main/resources</code> folder will contain our logging configuration related files.</p>\n<pre class=\"editor-colors lang-\"><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>cd&nbsp;vertx-net-client</span></span></div><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>mkdir&nbsp;-p&nbsp;src/main/kotlin</span></span></div><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>mkdir&nbsp;-p&nbsp;src/main/resources</span></span></div></pre><h3 id=\"project-files\">Project Files</h3>\n<p>We need to add following files in the project</p>\n<ul>\n<li><code>.gitignore</code>\nIf you want to check your project into git, you may consider adding following <code>.gitignore</code> file at root of your project\n</li>\n</ul>\n<script src=\"https://gist.github.com/usmansaleem/b5838484a20cb8b08f236f2265ad7a8e.js\"></script>\n\n<ul>\n<li><code>logback.xml</code>\nThis example is using slf4j and logback for logging. If you decide to use it in your project, you may also add following logback.xml file in <code>src/main/resources</code>. Modify it as per your requirements. This example will\nlog on console.\n</li>\n</ul>\n<script src=\"https://gist.github.com/usmansaleem/750c6d1cad0721b52be2ff00f758fb9f.js\"></script>\n\n<h2>Gradle Setup</h2>\n<p>We will use Gradle build system for this project. If you don’t already have Gradle available on your system, download and unzip gradle in a directory of your choice (<code>$GRADLE_HOME</code> is used here to represent this directory). This gradle distribution will be used as a starting point to create Gradle wrapper scripts for our project. These scripts will allow our project to download and use correct version of gradle distribution automatically without messing up system. Really useful when building your project on CI tool or on any other developer's machine.</p>\n<p>Run following command in project's directory</p>\n<pre class=\"editor-colors lang-\"><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>$GRADLE_HOME/bin/gradle&nbsp;wrapper</span></span></div></pre><p>The above commands will generate following files and directories.</p>\n<pre class=\"editor-colors lang-\"><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>gradle/&nbsp;&nbsp;gradlew&nbsp;&nbsp;gradlew.bat</span></span></div></pre><h3 id=\"gradle-build-file-build-gradle-\">Gradle build file <code>build.gradle</code></h3>\n<p>Create (and/or copy and modify) following <code>build.gradle</code> in your project's root directory. Our example gradle build file is using <a href=\"https://github.com/jponge/vertx-gradle-plugin/\">vertx-gradle-plugin</a>.\n</p>\n<script src=\"https://gist.github.com/usmansaleem/e723f25b827e0a925eaef2957a80132d.js\"></script>\n<p>In the project directory, run following command to download local gradle distribution:</p>\n<pre class=\"editor-colors lang-\"><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>./gradlew</span></span></div></pre><p>(or <code>.\\gradlew.bat</code> if in Windows)</p>\n<p>At this stage we should have following file structure. This is also a good time to commit changes if you are working with git.</p>\n<ul>\n<li><code>.gitignore</code> </li>\n<li><code>build.gradle</code> </li>\n<li><code>gradle/wrapper/gradle-wrapper.jar</code> </li>\n<li><code>gradle/wrapper/gradle-wrapper.properties</code></li>\n<li><code>gradlew</code> </li>\n<li><code>gradlew.bat</code></li>\n<li><code>src/main/resources/logback.xml</code></li>\n</ul>\n<p>Now that our project structure is ready, time to add the meat of the project. You may use any IDE of your choice. My preference is IntelliJ IDEA.</p>\n<p>Create a new package under <code>src/main/kotlin</code>. The package name should be adapted from the following section of <code>build.gradle</code></p>\n<pre class=\"editor-colors lang-\"><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>vertx&nbsp;{</span></span></div><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>&nbsp;&nbsp;&nbsp;&nbsp;mainVerticle&nbsp;=&nbsp;\"info.usmans.blog.vertx.NetClientVerticle\"</span></span></div><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>}</span></span></div></pre><p>From the above example, the package name is <code>info.usmans.blog.vertx</code></p>\n<p>Add a new Kotlin Class/file in <code>src/main/kotlin/info/usmans/blog/vertx</code> as <code>NetClientVerticle.kt</code></p>\n<p>The contents of this class is as follows</p>\n<script src=\"https://gist.github.com/usmansaleem/2a176a7b752fcb72f7f31964809696fe.js\"></script>\n\n<h2>Explaining the Code</h2>\n<p>The <code>fun main(args: Array&lt;String&gt;)</code> is not strictly required, it quickly allows running the Vert.x verticle from within IDE. You will also notice a small hack in the method for setting system property <code>vertx.disableDnsResolver</code> which is to avoid a Netty bug that I observed when running on Windows machine and remote server is down. Of course, since we are using vertx-gradle-plugin, we can also use <code>gradle vertxRun</code> to run our verticle. In this case the <code>main</code> method will not get called.</p>\n<p>The <code>override fun start()</code> method calls <code>fireReconnectTimer</code> which in turn calls <code>reconnect</code> method. <code>reconnect</code> method contains the connection logic to server as well as it calls <code>fireReconnectTimer</code> if it is unable to connect to server or disconnects from server. In <code>reconnect</code> method the <code>socket.handler</code> gets called when server send message to client.</p>\n<pre class=\"editor-colors lang-\"><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>socket.handler({&nbsp;data&nbsp;-&gt;</span></span></div><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logger.info(\"Data&nbsp;received:&nbsp;${data}\")</span></span></div><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//</span><span class=\"syntax--storage syntax--type syntax--class syntax--todo\"><span>TODO</span></span><span>:&nbsp;Do&nbsp;the&nbsp;work&nbsp;here&nbsp;...</span></span></div><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})</span></span></div></pre>\n\n<h2 id=\"distributing-the-project\">Distributing the project</h2>\n<p>To create redistributable jar, use <code>./gradlew shadowJar</code> command. Or if using IntelliJ: from Gradle projects, Tasks, shadow, shadowJar (right click run). This command will generate <code>./build/libs/vertx-net-client-fat.jar</code>.</p>\n<h3 id=\"executing-the-client\">Executing the client</h3>\n<p>The client jar can be executed using following command:</p>\n<pre class=\"editor-colors lang-\"><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>&nbsp;java&nbsp;-DserverHost=127.0.0.1&nbsp;-DserverPort=8888&nbsp;-DconnectMessage=\"hello\"&nbsp;-jar&nbsp;vertx-net-client-full.jar</span></span></div></pre><p>If you wish to use SLF4J for Vert.x internal logging, you need to pass system property <code>vertx.logger-delegate-factory-class-name</code> with value of <code>io.vertx.core.logging.SLF4JLogDelegateFactory</code>. The final command would look like:</p>\n<pre class=\"editor-colors lang-\"><div class=\"line\"><span class=\"syntax--text syntax--plain syntax--null-grammar\"><span>java&nbsp;-DserverHost=127.0.0.1&nbsp;-DserverPort=8888&nbsp;-DconnectMessage=\"hello\"&nbsp;-Dvertx.logger-delegate-factory-class-name=\"io.vertx.core.logging.SLF4JLogDelegateFactory\"&nbsp;-jar&nbsp;vertx-net-client-full.jar</span></span></div></pre><p>You can configure Vert.x logging levels in logback.xml file if required.</p>\n<h2 id=\"conclusion\">Conclusion</h2>\n<p>This post describes how easy it is to create a simple TCP client using Vert.x, Kotlin and Gradle build system. Hopefully the techniques shown here will serve as a starting point for your next DIY project.</p>",
"blogSection" : "Main",
"createdOn" : "2017-12-08",
"modifiedOn" : "2017-12-14",
"createDay" : "08",
"createMonth" : "Dec",
"createYear" : "2017",
"categories" : [ {
"id" : 0,
"name" : "Vertx"
}, {
"id" : 1,
"name" : "Kotlin"
}, {
"id" : 2,
"name" : "Gradle"
} ]
}, {
"id" : 185,
"urlFriendlyId" : "sri_hash_generator",
"title" : "SRI Hash Generator",
"description" : "Using SRI Hash when loading javascript resources in webpage",
"body" : "<p><b>SRI</b> or Sub Resource Integrity allows to specify computed hash to externally loaded javascript (and other contents) to ensure that they have not been tempered mid-flight. It is a common technique to use when loading jQuery javascript, for instance.</p><p>Check out this <a href=\"https://www.srihash.org/\" target=\"_blank\">handy website</a> to generate the required code easily.&nbsp;</p><p><br></p>",
"blogSection" : "Main",
"createdOn" : "2017-11-26",
"modifiedOn" : "2017-11-26",
"createDay" : "26",
"createMonth" : "Nov",
"createYear" : "2017",
"categories" : [ {
"id" : 0,
"name" : "Web"
}, {
"id" : 1,
"name" : "JavaScript"
} ]
}, {
"id" : 184,
"urlFriendlyId" : "jgit_checkout_modify_gist_kotlin",
"title" : "Using jgit to checkout and modify gist from Kotlin",
"description" : "Code snippet showing JGit usage",
"body" : "<p>As I have discussed previously that <a href=\"https://gist.github.com/\" target=\"_blank\">gist </a>can be an alternative way to store data online at GitHub and use in your application. However, in order to make changes to data, the gist is required to be cloned, make changes and push back. <a href=\"https://www.eclipse.org/jgit/\" target=\"_blank\">JGit </a>is a lightweight Java library that can be used to checkout gist and commit and push changes to it. Following code snippet shows how to achieve it in Kotlin.</p>\n<script src=\"https://gist.github.com/usmansaleem/3ccad1e8c1066827aa5e4c332e7daece.js\"></script>\n",
"blogSection" : "Main",
"createdOn" : "2017-11-23",
"modifiedOn" : "2017-11-24",
"createDay" : "23",
"createMonth" : "Nov",
"createYear" : "2017",
"categories" : [ {
"id" : 0,
"name" : "Kotlin"
}, {
"id" : 1,
"name" : "JGit"
}, {
"id" : 2,
"name" : "gist"
}, {
"id" : 3,
"name" : "Git"
} ]
}, {
"id" : 183,
"urlFriendlyId" : "embedding_gist_with_angularjs",
"title" : "Embedding gist with AngularJS",
"description" : "Code snippet showing how to embed gist with AngularJS",
"body" : "<b>Github gists</b> is a neat way of sharing code snippets. However, embedding it with AngularJS may be a bit of challenge. <a target=\"_blank\" href=\"https://github.com/blairvanderhoof/gist-embed\">Gist-embed</a> and little bit of Angular directive code to the rescue. <code data-gist-id=\"6926ad2ddc952b9d34050efa91e83048\" data-gist-show-spinner=\"true\"></code>",
"blogSection" : "Main",
"createdOn" : "2017-11-16",
"modifiedOn" : "2017-11-23",
"createDay" : "16",
"createMonth" : "Nov",
"createYear" : "2017",
"categories" : [ {
"id" : 0,
"name" : "Java"
}, {
"id" : 1,
"name" : "GitHub"
}, {
"id" : 2,
"name" : "AngularJS"
} ]
}, {
"id" : 182,
"urlFriendlyId" : "reading_json_and_other_data_from_gist",
"title" : "Reading json and other data from gist",
"description" : "Discussing reading data from gist via rawgit",
"body" : "The GitHub gists acts as a git repository allows to put versioned controlled data which can be read and refreshed from server side program such as this blogger. However, github has placed restrictions which doesn't allow browsers (via javascript) to read data directly. The alternative is to use <a href=\"https://rawgit.com\" target=\"_blank\">rawgit.com</a> which sets correct headers as well.",
"blogSection" : "Main",
"createdOn" : "2017-10-31",
"modifiedOn" : "2017-11-23",
"createDay" : "31",
"createMonth" : "Oct",
"createYear" : "2017",
"categories" : [ {
"id" : 0,
"name" : "Git"
}, {
"id" : 1,
"name" : "Github"
} ]
}, {
"id" : 181,
"urlFriendlyId" : "migrating_blogging_software_to_vertx3_kotlin_gradle_circleci_and_docker",
"title" : "Migrating blogging software to vertx3, kotlin, gradle, circleci and docker",
"description" : "Read about migrating my blogging software to vertx3, kotlin, gradle, circleci and docker",
"body" : "Finished migrating the blogging software to vertx3 using kotlin. Gradle is used as build tool while <a href=\"https://circleci.com\" target=\"_blank\">circleci</a> is used as cloud based CI environment. The hosting is moved from Openshift to <a href=\"https://hyper.sh\" target=\"_blank\">hyper.sh</a>. The code is as usual available on <a href=\"https://github.com/usmansaleem/kt-vertx\" target=\"_blank\">Github</a>",
"blogSection" : "Main",
"createdOn" : "2017-10-20",
"modifiedOn" : "2017-10-20",
"createDay" : "20",
"createMonth" : "Oct",
"createYear" : "2017",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 180,
"urlFriendlyId" : "working_with_multiple_git_repo_from_parent_directory",
"title" : "Working with multiple git repo from parent directory",
"description" : "Read about how to work with multiple git repo from parent directory",
"body" : "The following git configuration can be used to work with multiple git repositories from same parent directory. Really useful for a project with multiple git repos. Usage would be <code>git all pull</code> or <code>git all status</code>.<br> <code data-gist-id=\"b72aebc3c07428d96cdb3f5d49f0290d\"></code>\r\n",
"blogSection" : "Main",
"createdOn" : "2017-05-31",
"modifiedOn" : "2017-05-31",
"createDay" : "31",
"createMonth" : "May",
"createYear" : "2017",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 179,
"urlFriendlyId" : "lets_encrypt_free_ssl_certificates",
"title" : "Let's encrypt - Free SSL certificates",
"description" : "Read about Let's encrypt free SSL certificates",
"body" : "<a href=\"https://letsencrypt.org/\" target=\"_blank\">Let's encrypt</a> is free, automated and open certificate authority. I am using it on my site to get my site served on https. The other good part is same certificate both for <a href=\"https://usmans.info/\" target=\"_blank\">usmans.info</a> and <a href=\"https://usman.id.au/\" target=\"_blank\">usman.id.au</a>. The only downside is that they are valid for 90 days, after which you need to renew and install them again. Its manual step to install certificate in Openshift.",
"blogSection" : "Main",
"createdOn" : "2017-03-24",
"modifiedOn" : "2017-03-24",
"createDay" : "24",
"createMonth" : "Mar",
"createYear" : "2017",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 178,
"urlFriendlyId" : "migrated_blog_software_using_vert_x_on_openshift",
"title" : "Migrated blog software using Vert.x on Openshift",
"description" : "Read about my migration of blog software using Vert.x on Openshift",
"body" : "Decided to re-wrote my blog server in Vert.x and deploy it on Openshift. The code is available on my <a href=\"https://github.com/usmansaleem/vert.x.blog\" target=\"_blank\">github account</a> as usual.",
"blogSection" : "Main",
"createdOn" : "2017-03-24",
"modifiedOn" : "2017-03-24",
"createDay" : "24",
"createMonth" : "Mar",
"createYear" : "2017",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 177,
"urlFriendlyId" : "bootstrap_3_and_h2",
"title" : "Bootstrap 3 and H2",
"description" : "Read about moving to Bootstrap 3 and H2",
"body" : "Time to move to Bootstrap 3 and H2",
"blogSection" : "Main",
"createdOn" : "2016-04-10",
"modifiedOn" : "2016-04-10",
"createDay" : "10",
"createMonth" : "Apr",
"createYear" : "2016",
"categories" : [ ]
}, {
"id" : 176,
"urlFriendlyId" : "msysgit_and_conemu",
"title" : "msysgit and ConEmu ",
"description" : "Experiences with msysgit and ConEmu ",
"body" : "If you are using <a href=\"https://git-for-windows.github.io/\" target=\"_blank\">MSysGit</a> on Windows and love to use git from command line, try it together with this excellent console emulator <a href=\"http://conemu.github.io/\" target=\"_blank\">ConEmu-Maximus5</a>.",
"blogSection" : "Main",
"createdOn" : "2015-12-15",
"modifiedOn" : "2015-12-15",
"createDay" : "15",
"createMonth" : "Dec",
"createYear" : "2015",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 175,
"urlFriendlyId" : "wildfly_skeleton_project_using_maven",
"title" : "Wildfly skeleton project using maven",
"description" : "Read about how to use Wildfly skeleton project using maven",
"body" : "<pre><code data-language=\"bash\">mvn archetype:generate -DarchetypeArtifactId=wildfly-javaee7-webapp-archetype -DgroupId=mypackage.myapp -DartifactId=MyWebApp -DarchetypeGroupId=org.wildfly.archetype -DarchetypeVersion=8.2.0.Final</code></pre>",
"blogSection" : "Main",
"createdOn" : "2015-12-09",
"modifiedOn" : "2015-12-09",
"createDay" : "09",
"createMonth" : "Dec",
"createYear" : "2015",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 174,
"urlFriendlyId" : "using_java_preference_api_with_jfilechooser",
"title" : "Using Java Preference API with JFileChooser",
"description" : "Read about how to use Java Preference API with JFileChooser",
"body" : "Following code snippet shows how to use Java Preference API with JFilechooser to make it remember last used directory location.\n\n<pre><code data-language=\"java\">\n...\nFile file = new File(\"default.xml\");\nfile = selectOutputFile(file);\n...\n\nprivate static File selectOutputFile(File outputFile) throws IOException {\n //load last selected location from preference\n Preferences prefs = Preferences.userRoot().node(MyClass.class.getName()); //or some other alias we wish to use\n\n JFileChooser fileChooser = new JFileChooser(prefs.get(\"LAST_USED_FOLDER\", new File(\".\").getAbsolutePath()));\n\n //we want to filter xml files by default\n fileChooser.setFileFilter(new FileFilter() {\n @Override\n public boolean accept(File f) {\n if (f.isDirectory()) {\n return true;\n }\n String s = f.getName();\n return s.endsWith(\".xml\");\n }\n\n @Override\n public String getDescription() {\n return \"*.xml\";\n }\n });\n\n fileChooser.setSelectedFile(outputFile); //can be omitted if required.\n\n int status = fileChooser.showSaveDialog(null); //or pass JFrame reference\n\n if (status == JFileChooser.APPROVE_OPTION) {\n outputFile = fileChooser.getSelectedFile();\n\n if (!outputFile.exists()) {\n outputFile.createNewFile(); //if we are going to write contents, otherwise, raise error or something\n }\n\n //finally save the folder of selected file in preference\n prefs.put(\"LAST_USED_FOLDER\", outputFile.getParent());\n } else if (status == JFileChooser.CANCEL_OPTION) {\n return null;\n }\n\n return outputFile;\n }\n </code></pre>",
"blogSection" : "Main",
"createdOn" : "2015-06-25",
"modifiedOn" : "2015-06-25",
"createDay" : "25",
"createMonth" : "Jun",
"createYear" : "2015",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 173,
"urlFriendlyId" : "some_useful_git_setup_commands",
"title" : "Some useful git setup commands",
"description" : "Read about some useful git setup commands",
"body" : "Following are some useful git setup commands.\n<p>\nSet up a global username to be used for all commits.\n<pre><code data-language=\"bash\">git config --global user.name [your username]</code></pre>\n\nSet up a global email to be used for all commits. Note that GitHub can associate multiple emails to your account. GitHub can aggregate statistics regarding your commits if you verify your email(s).\n<pre><code data-language=\"bash\">git config --global user.email [your email]</code> </pre>\n\nSet all branches to automatically rebase instead of merge. This produces a cleaner commit tree.\nThis doesn't mean you must always rebase; it's just the way to go unless you have a good reason not to.\n<pre><code data-language=\"bash\">git config --global branch.autosetuprebase always</code>\t</pre>\n\nEnsure that all new branches are set up to track its upstream branch.\n<pre><code data-language=\"bash\">git config --global branch.autosetupmerge true</code></pre>\n\nPrevents Git from pushing changes in all matching local branches. It will only push changes in the branch you are currently in.\n<pre><code data-language=\"bash\">git config --global push.default current</code></pre>\n\nTell Git to not treat a file as having been modified if the only change is file mode executable bit. Useful for working on FAT/Windows systems.\n<pre><code data-language=\"bash\">git config --global core.filemode false</code></pre>\n\nImproves git status performance considerably on Windows 7 x64\n<pre><code data-language=\"bash\">git config --global core.preloadindex true</code></pre>\n\n</p>",
"blogSection" : "Main",
"createdOn" : "2015-06-15",
"modifiedOn" : "2015-06-15",
"createDay" : "15",
"createMonth" : "Jun",
"createYear" : "2015",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 172,
"urlFriendlyId" : "using_redirect_port_for_ssl_in_wildfly_8_1",
"title" : "Using redirect port (for SSL) in Wildfly 8.1",
"description" : "Read about how to redirect port (for SSL) in Wildfly 8.1",
"body" : "<p>If JBoss is running as a normal user on port 8080 and 8443 while iptables are set up to forward requests from 80 and 443 to 8080 and 8443 respectively, we may need to provide port redirection in wildfly/undertow configuration so that access to any restricted area automatically forwards to 443 instead of 8443. </p>\nFrom jboss-cli:\n<pre><code data-language=\"bash\">\n/socket-binding-group=standard-sockets/socket-binding=https-redirection:add(port=443)\n/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=redirect-socket,value=\"https-redirection\")\n </code></pre>\nYou can name socket-binding as per your needs, it doesn't has to be <code>https-redirection</code>.",
"blogSection" : "Main",
"createdOn" : "2015-06-10",
"modifiedOn" : "2015-06-15",
"createDay" : "10",
"createMonth" : "Jun",
"createYear" : "2015",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 3,
"name" : "Linux"
}, {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 171,
"urlFriendlyId" : "moving_blog_to_amazon_ec2",
"title" : "Moving blog to Amazon EC2",
"description" : "Read about moving blog to Amazon EC2",
"body" : "Just finished moving my blog to Amazon EC2. At the moment, Amazon RDS is hosting the database (in PostgreSQL), while configured Wildfly 8.2 on a EC2 micro instance. This allows a more detailed control of deployment such as ability to serve domain on SSL.",
"blogSection" : "Main",
"createdOn" : "2015-06-02",
"modifiedOn" : "2015-06-02",
"createDay" : "02",
"createMonth" : "Jun",
"createYear" : "2015",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 2,
"name" : "PostgreSQL"
}, {
"id" : 3,
"name" : "Linux"
}, {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 170,
"urlFriendlyId" : "ikm_java_6_test",
"title" : "IKM Java 6 Test",
"description" : "Read about my IKM Java 6 Test",
"body" : "<p>A client recently requested that I get screened for IKM Java 6 test. A quick Google search revealed that their tests are \"adaptive\" in nature and as you proceed the questions become more and more difficult. Also adding to difficulty that there are more than 1 correct/possible answers and there is negative marking for answering a totally irrelevant option. Following is the snapshot of my result (forwarded by the client).</p>\n\n<img src=https://scontent-lax.xx.fbcdn.net/hphotos-xat1/v/t1.0-9/1510644_10153102591318241_7885363000443162545_n.jpg?oh=cbb890e729cb3dcd03289f74c2b4a71a&oe=55FCBEEA alt=\"IKM Java Test\"/>",
"blogSection" : "Main",
"createdOn" : "2015-05-18",
"modifiedOn" : "2015-05-18",
"createDay" : "18",
"createMonth" : "May",
"createYear" : "2015",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 169,
"urlFriendlyId" : "using_intellij_idea_as_git_merge_tool_via_cygwin",
"title" : "Using IntelliJ IDEA as git merge tool (via cygwin)",
"description" : "Read about how to use IntelliJ IDEA as git merge tool (via cygwin)",
"body" : "<p>IntelliJ IDEA can be used as a git mergetool. If you have merge conflicts, launching <code>git mergetool</code> will launch IntelliJ IDEA. Following configurations are required in <code>~/.gitconfig</code> . Update the path to idea.exe accordingly.</p>\n<h3>Cygwin</h3>\n<p>\n<pre><code data-language=\"bash\">\n[mergetool \"ideamerge\"]\n cmd = C:/Program\\\\ Files\\\\ \\\\(x86\\\\)/JetBrains/IntelliJ\\\\ IDEA\\\\ 13.1.3/bin/idea.exe merge `cygpath -wa $LOCAL` `cygpath -wa $REMOTE` `cygpath -wa $BASE` `cygpath -wa $MERGED`\n[merge]\n tool = ideamerge\n</code></pre>\n</p>\n<h3>MSysGit</h3>\n<p>\nFor MSysGit, we need to convert paths using our own script. Create ~/winpath.sh as\n<pre><code data-language=\"bash\">\n#! /bin/sh\n\nfunction wpath {\n if [ -z \"$1\" ]; then\n echo \"$@\"\n else\n if [ -f \"$1\" ]; then\n local dir=$(dirname \"$1\")\n local fn=$(basename \"$1\")\n echo \"$(cd \"$dir\"; echo \"$(pwd -W)/$fn\")\" | sed 's|/|\\\\|g';\n else\n if [ -d \"$1\" ]; then\n echo \"$(cd \"$1\"; pwd -W)\" | sed 's|/|\\\\|g';\n else\n echo \"$1\" | sed 's|^/\\(.\\)/|\\1:\\\\|g; s|/|\\\\|g';\n fi\n fi\n fi\n}\n\nwpath \"$@\"\n</code></pre>\nThen in your ~/.gitconfig\n<pre><code data-language=\"bash\">\n[mergetool \"ideamerge\"]\ncmd = \"/c/Program\\\\ Files\\\\ \\\\(x86\\\\)/JetBrains/IntelliJ\\\\ IDEA\\\\ Community\\\\ Edition\\\\ 15.0.2/bin/idea.exe\" merge `~/winpath.sh $LOCAL` `~/winpath.sh $REMOTE` `~/winpath.sh $BASE` `~/winpath.sh $MERGED`\n[merge]\n tool = ideamerge\n</code></pre>\n</p>",
"blogSection" : "Main",
"createdOn" : "2015-05-17",
"modifiedOn" : "2015-12-15",
"createDay" : "17",
"createMonth" : "May",
"createYear" : "2015",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 168,
"urlFriendlyId" : "getting_gruveo_work_on_ubuntu_13_10",
"title" : "Getting GruVeo (anonymous video/voice flash based chat) work on Ubuntu 13.10",
"description" : "Read about how to fix GruVeo (anonymous video/voice flash based chat) work on Ubuntu 13.10",
"body" : "<p><a href=\"https://www.gruveo.com/\" target=\"_blank\">Gruveo</a> is an excellent anonymous Flash/browser based very simple video\\audio chat website). Due to some weird bug in Ubuntu 13.10 which doesn't allow to change camera settings on individual website (such as Gruveo) through Flash settings popup, following workaround can be used through Flash's global settings.</p>\n\n<p>Visit <a href=\"http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager06.html\" target=\"_blank\">http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager06.html</a> Select monitor with the eye tab (5th from the left), scroll down and select required site, http://www.gruveo.com, and then click radio button \"Always Allow\" (see following screenshot). Restart the browser and refresh gruveo again. The video chat is now working.</p>\n",
"blogSection" : "Main",
"createdOn" : "2014-01-06",
"modifiedOn" : "2014-01-06",
"createDay" : "06",
"createMonth" : "Jan",
"createYear" : "2014",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 167,
"urlFriendlyId" : "acer_aspire_v5_linux_skype_dark_video_issue_fn_brightness_issue",
"title" : "Acer Aspire V5 (V5-571PG), Linux (Fedora Core 16+, Ubuntu 13+) Skype Dark Video issue, Fn Brightness issue",
"description" : "Read about how to fix Acer Aspire V5 (V5-571PG), Linux (Fedora Core 16+, Ubuntu 13+) Skype Dark Video issue, Fn Brightness issue",
"body" : "<p>Recently I switched from <strong>Fedora 18</strong> to <strong>Ubuntu 13.10</strong> on my personal Acer Aspire V5 laptop (a wrong decision when I bought it - anyways...). There are two annoying issues when using both Fedora and Ubuntu on this laptop</p>\n\n<h2>Skype Dark Video Screen issue</h2>\n<p>Skype works on both Fedora and Ubuntu, however, there is this darn issue of dark video screen. This can be fixed by using <code>guvcview</code> and/or from command line tool uvcdynctrl as discussed by this <a href=\"http://phoxis.org/2012/02/24/fix-dark-video-in-skype-for-linux/\" target=\"_blank\">guy</a> in detail.</p>\n\n<p>\nTo ease up calling <code>uvcdynctrl</code>, you can create a launcher and add it to the dash. Follow <a href=\"https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles\" target=\"_blank\">this</a> link to create desktop launcher in Ubuntu.\n</p>\n\n<h2>Fn keys Screen Brightness issue</h2>\n<p>The second issue is that screen brightness doesn't work, neither Fn Brightness (blue Fn - left right keys) nor from System Settings ... Brightness & Lock.</p>\n\n<p>To fix the issue for System Settings, we need to add <code>acpi_backlight=vendor</code> to kernel command line parameter as part of grub config. For Fedora follow similar approach for grub2, following approach works in Ubuntu. Update <code>GRUB_CMDLINE_LINUX</code> in <code>/etc/default/grub</code> then run <code>update-grub</code> and restart.</p>\n\n<p>To make the Fn key work again, try fixing <code>/etc/acpi/asus-keyboard-backlight.sh</code> and update <code>KEYS_DIR</code> to <code>KEYS_DIR=/sys/class/backlight/intel_backlight</code>. This will allow Fn scripts to call the correct scripts instead of default values (which doesn't work anymore after using <code>acpi_backlight=vendor</code>). Restart to test it.</p>\n\n<p>P.S. Ubuntu seems to have become more user friendly than Fedora (shh...don't tell my former colleagues back at Red Hat ;-))</p>\n ",
"blogSection" : "Main",
"createdOn" : "2014-01-06",
"modifiedOn" : "2014-01-06",
"createDay" : "06",
"createMonth" : "Jan",
"createYear" : "2014",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 166,
"urlFriendlyId" : "java_decompiler",
"title" : "Java Decompiler",
"description" : "Read about my experience with Java Decompiler",
"body" : "<p>My favorite Java Decompiler tool. <a href=\"http://java.decompiler.free.fr/\" target=\"_blank\">JD-GUI</a>. The only free tool to reverse engineer and understand Java 5 and above code. A must have tool under your belt as a Java coder. </p> ",
"blogSection" : "Main",
"createdOn" : "2013-06-24",
"modifiedOn" : "2013-06-24",
"createDay" : "24",
"createMonth" : "Jun",
"createYear" : "2013",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 165,
"urlFriendlyId" : "an_additional_australianized_domain",
"title" : "An additional \"Australianized\" domain",
"description" : "Read about my additional \"Australianized\" domain",
"body" : "<p>Added <a href=\"http://usman.id.au\">http://usman.id.au</a> which also points to (via CNAME) this application hosted on OpenShift, similar to my existing domain, http://www.usmans.info.\n</p>",
"blogSection" : "Main",
"createdOn" : "2013-06-12",
"modifiedOn" : "2013-06-12",
"createDay" : "12",
"createMonth" : "Jun",
"createYear" : "2013",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 163,
"urlFriendlyId" : "quick_catch_up_of_changes_in_java_7",
"title" : "Quick catch up of changes in Java 7",
"description" : "Read about some quick catch up of changes in Java 7",
"body" : "Java 7 introduced two major changes:\n<ul>\n<li> Project Coin</li>\n<li> NIO-2</li>\n</ul>\nMajor changes introduced by Project Coin are as follows:\n<ul>\n<li> try-with-resources construct to automatically close resources (such as IO resources etc.)</li>\n<li> Enhanced switch statement to handle String </li>\n<li> Enhanced numeric literals (for improved readability)</li>\n<li> Handling multiple exceptions in single catch block</li>\n<li> Diamond syntax for generics to avoid excessive code.</li>\n<li> Fixes for varargs warnings</li>\n</ul>\n\nNIO-2 changes include:\n<ul>\n<li> Path construct for dealing with files and files like entities. </li>\n<li> Files utility class (similar to what Arrays does for arrays)</li>\n<li> Future and call-back based asynchronous IO</li>\n</ul>\n\nLets see above features with help of some java code.\n\n<h2>switch for Strings</h2>\n\n<pre><code data-language=\"java\">\npublic class TestSwitch {\n\n public static void testSwitch(String day_of_week) {\n\tswitch(day_of_week.toLowerCase()) {\n\t\tcase \"monday\": System.out.println(\"Monday\"); break;\n\t\tcase \"tuesday\": System.out.println(\"Tuesday\"); break;\n\t\tcase \"wednesday\": System.out.println(\"Wednesday\"); break;\n\t\tcase \"thursday\": System.out.println(\"Thursday\"); break;\n\t\tcase \"friday\": System.out.println(\"Friday\"); break;\n\t\tcase \"saturday\": System.out.println(\"Saturday\"); break;\n\t\tcase \"sunday\": System.out.println(\"Sunday\"); break;\n\t\tdefault: System.out.println(\"Unknown day:\" + day_of_week);\n\n\t}\n }\n\n public static void main(String a[]) {\n\ttestSwitch(\"monday\");\n\ttestSwitch(\"Thursday\");\n\ttestSwitch(\"somwar\");\n }\n\n}\n</code></pre>\n\n<h2>Enhanced Numeric Literals</h2>\n\nIn java7, binary literals can be specified by using 0b prefix. In previous versions, we would have to use parseInt with base 2 to get such behavior (which means calling a method, no ability to use in switch statement, possiblity of RuntimeException due to misrepresentation of binary literal etc.) Consider:\n\n<pre><code data-language=\"java\">\nint x1 = Integer.parseInt(\"1000101100001111\", 2);\n</code></pre>\ncan now be replaced with:\n<pre><code data-language=\"java\">\nint x1 = 0b1000101100001111;\n</code></pre>\n\nIn addition, as you may notice above may be difficult to read, Java7 introduces _ to improve readibility:\n\n<pre><code data-language=\"java\">\nint x1 = 0b1000_1011_0000_1111;\n</code></pre>\n\n<h2>Enhanced Exception handling</h2>\nJava7 introduces enhanced exception handling. It now allows you to specify alternate exceptions in single catch block aka multi-catch and final rethrow.\n\nThe syntax is:\n\n<pre><code data-language=\"java\">\ntry {\n\n} catch(Exception1 | Exception2 e) {\n\n}\n</code></pre>\n\nThe 'e' will represent super class of Exception1 and Exception2, which is generally Exception or Throwable. The alternate exception i.e. Exception2 must not be superclass of\nException1. For example, following will produce compile time error:\n\n<pre><code data-language=\"java\">\n public static void testNewException(){\n FileReader fr = null;\n try {\n char[] buf = new char[100];\n fr = new FileReader(\"somefile.txt\");\n fr.read(buf);\n } catch(FileNotFoundException | IOException e) {\n e.printStackTrace();\n }\n }\n</code></pre>\n\nwill result:\n<pre><code data-language=\"general\">\n error: Alternatives in a multi-catch statement cannot be related by subclassing\n } catch(final FileNotFoundException | IOException e) {\n ^\n Alternative FileNotFoundException is a subclass of alternative IOException\n1 error\n</code></pre>\n\n\n\nFollowing is a more better approach:\n\n\n<pre><code data-language=\"java\">\npublic static void testNewException(){\n FileReader fr = null;\n try {\n fr = new FileReader(\"somefile.prop\");\n java.util.Properties prop = new java.util.Properties();\n prop.load(fr);\n } catch(FileNotFoundException fne) {\n System.err.println(\"File Not found\");\n } catch(IOException | IllegalArgumentException e) {\n System.err.println(\"Error handling properties file:\" + e.getMessage());\n }\n}\n</code></pre>\n\nThe final rethrow allows you to write a single catch block, yet only throw related exception. For instance, in earlier version, we may write this code to signal that calling\ncode should handle the exception:\n\n<pre><code data-language=\"java\">\n public static void testOldGeneralException() throws Exception{\n FileReader fr = null;\n try {\n fr = new FileReader(\"somefile.prop\");\n java.util.Properties prop = new java.util.Properties();\n prop.load(fr);\n } catch(Exception e) {\n System.err.println(\"Problem dealing with file, rethrowing...\");\n throw e;\n }\n }\n</code></pre>\n\nThis allows to consume all exceptions and then throw general exception. However, the calling side also has to handle the general exception .... a bad idea.\n\nIn Java7, the above can be rewritten as:\n\n\n<pre><code data-language=\"java\">\n public static void testNewFinalException() throws\n FileNotFoundException, IOException, IllegalArgumentException{\n FileReader fr = null;\n try {\n fr = new FileReader(\"somefile.prop\");\n java.util.Properties prop = new java.util.Properties();\n prop.load(fr);\n } catch(final Exception e) {\n System.err.println(\"Problem dealing with file, rethrowing...\");\n throw e;\n }\n }\n\npublic static void main(String a[]) {\n try {\n testNewFinalException();\n }catch(FileNotFoundException fne) {\n System.err.println(\"File Not found\");\n }catch(IOException e) {\n System.err.println(\"Error handling properties file:\" + e.getMessage());\n }\n\n}\n</code></pre>\n\nYou don't have to specify \"final\" in catch block, but it helps in understanding the semantics.\n\n<h2>Try-With-Resource (TWR)</h2>\n\nConsider the above example of Filehandling, it misses the close operation. Usually in pre-Java7, we would have to write it as:\n\n<pre><code data-language=\"java\">\npublic static void testNewException(){\n FileReader fr = null;\n try {\n fr = new FileReader(\"somefile.prop\");\n java.util.Properties prop = new java.util.Properties();\n prop.load(fr);\n } catch(FileNotFoundException fne) {\n System.err.println(\"File Not found\");\n } catch(IOException | IllegalArgumentException e) {\n System.err.println(\"Error handling properties file:\" + e.getMessage());\n } finally {\n if(fr != null) {\n try {\n fr.close();\n }catch(IOException e) {\n System.err.println(\"Error closing file, nothing to do\");\n }\n }\n }\n }\n</code></pre>\n\nI have to write similar code for handling JDBC artifacts as well (ResultSet, Statement, Connection etc.)\n\nIn Java7, the try syntax has been changed, consider this:\n<pre><code data-language=\"java\">\npublic static void testNewTry() throws FileNotFoundException, IOException{\n try(FileReader fr = new FileReader(\"somefile.prop\")) {\n java.util.Properties prop = new java.util.Properties();\n prop.load(fr);\n }\n }\n</code></pre>\n\nHowever, note that try-with-resources block might still cause unclosed resources if you are not careful, consider:\n\n<pre><code data-language=\"java\">\npublic static void testNewTry2() throws\n FileNotFoundException, IOException{\n try(ObjectInputStream os = new ObjectInputStream(\n new FileInputStream(\"somefile.bin\"))) {\n }\n }\n</code></pre>\n\nIn above example, FileInputStream may open an invalid file, which will cause ObjectInputStream to not be created, however, FileInputStream will not be closed. The correct approach would be:\n\n<pre><code data-language=\"java\">\npublic static void testNewTryr3() throws\n FileNotFoundException, IOException{\n try(FileInputStream fis = new FileInputStream(\"somefile.bin\");\nObjectInputStream os = new ObjectInputStream(fis)) {\n //...\n }\n}\n</code></pre>\n\nThe above code will make sure to close both FileInputStream and ObjectInputStream.\n\n<h3>Diamond syntax for generics</h3>\nThis one is easy and beautiful. Consider following code:\n\n<pre data-language=\"java\">\n Map&lt;Integer, Map&lt;String, String>> map = new HashMap&lt;Integer, Map&lt;String,String>>();\n</pre>\n\nThe above is declaring a map, identifiable by an integer id which contains another map containing further lookup values. This could be rewritten as:\n\n<pre data-language=\"java\">\n Map&lt;Integer, Map&lt;String, String>> map = new HashMap&lt;>();\n</pre>\n\nJava7 will work out the details on right-hand side. It is backward compatible i.e. you can replace the above syntax for your old code.\n\nStay tuned for NIO2 related changes.",
"blogSection" : "Main",
"createdOn" : "2012-12-30",
"modifiedOn" : "2012-12-30",
"createDay" : "30",
"createMonth" : "Dec",
"createYear" : "2012",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 162,
"urlFriendlyId" : "custom_module_in_domain_mode_in_jboss_7_not_found_error",
"title" : "Custom module in domain mode in JBoss 7.1/EAP 6 not found error?",
"description" : "Read about how to Custom module in domain mode in JBoss 7.1/EAP 6 not found error?",
"body" : "<p>\nSo you decided to use a custom module in JBoss EAP6/AS 7 and your setup is domain mode where your host and domain are on separate machines, and you add a module in your domain controller ... and still getting errors in logs that JBoss is unable to find required module?\n</p>\n<p>\nMake sure to add the module to your host instance as well since domain mode only pushes deployable contents onto hosts, and module is not a deployable content.\n</p>\n<p>\nKeep Jbossing....\n</p>",
"blogSection" : "Main",
"createdOn" : "2012-12-05",
"modifiedOn" : "2012-12-05",
"createDay" : "05",
"createMonth" : "Dec",
"createYear" : "2012",
"categories" : [ {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 159,
"urlFriendlyId" : "jee_web_filter_to_fix_jsf_root_context_handling",
"title" : "JEE Web Filter to fix JSF root context handling",
"description" : "Read about how to JEE Web Filter to fix JSF root context handling",
"body" : "<p>The JSF implementation in JBoss AS 7/EAP 6 has a small annoyance when it comes to handling of default page in default (root) context and outcome attribute, such as in h:link. </p>\n\n<p>For instance, consider my domain, www.usmans.info. In my blog software, the JSF servlet handles *.xhtml extensions. The default welcome page is set to index.xhtml.</p>\n\n<p>The problem is, if someone hits just the domain, the JSF components which contains 'outcome' attribute does not generate proper URL. For instance, rather then generating http://www.usmans.info/notes.xhtml, it will generate /notes.xhtml only.<p>\n\n<p>To fix this annoyance, I had to set default welcome page as index.jsp, which did a redirect to index.xhtml. However, this workaround caused an unnecessary browser redirect.</p>\n\n<p>To avoid the browser redirect, I introduced a web filter which detects this particular use-case and internally forwards to index.xhtml. This fix the issue and JSF engine renders all targets/outcome correctly. Here is the code:</p>\n\n<pre><code data-language=\"java\">\nimport java.io.*;\nimport javax.servlet.*;\nimport javax.servlet.http.*;\nimport javax.servlet.annotation.*;\n\n/**\n* This filter is to fix an invonvinence where\n* JSF link tag's 'outcome' is not calculated correctly\n* if application is accessed with just the domain name\n* i.e http://www.usmans.info .\n*\n* We forward the request to index.xhtml if the request URI is just /.\n* This is probably just JBoss/Mojarra issue, but we needed this fix\n* to avoid having index.jsp which redirect to index.xhtml\n*\n* @author Usman Saleem\n* @version 1.0\n*/\n@WebFilter(urlPatterns={\"/*\"})\npublic class FixRootURIFilter implements Filter {\n\n private FilterConfig filterConfig = null;\n\n public void init(FilterConfig filterConfig) throws ServletException {\n this.filterConfig = filterConfig;\n }\n\n @Override\n public void doFilter(ServletRequest request, ServletResponse response,\n FilterChain chain) throws IOException, ServletException {\n\tif(request instanceof HttpServletRequest) {\n\t\tHttpServletRequest httpReq = (HttpServletRequest) request;\n\t\tString uri = httpReq.getRequestURI();\n\t\tif(uri != null && uri.equals(\"/\")) {\n\t\t\tRequestDispatcher rd = filterConfig.\n getServletContext().\n getRequestDispatcher(\"/index.xhtml\");\n\t\t\tif(rd != null) {\n\t\t\t\trd.forward(request, response);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\n\t//default handling - do nothing and forward reqeust to filter chain\n chain.doFilter(request, response);\n\n }\n @Override\n public void destroy() { }\n}\n\n\n</code></pre>\n\n",
"blogSection" : "Main",
"createdOn" : "2012-12-02",
"modifiedOn" : "2012-12-02",
"createDay" : "02",
"createMonth" : "Dec",
"createYear" : "2012",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 141,
"urlFriendlyId" : "introduced_blog_sections",
"title" : "Introduced Blog Sections",
"description" : "Read about Blog Sections implementation",
"body" : "Updated my blog software to provide blog sections. Ideally these are suppose to be \"blog categories\" while categories are suppose to be \"tags\", since I already had used \"categories\", I named then as \"Blog Section\". For now, there is <a href=\"http://www.usmans.info/index.xhtml?blogSection=Experiments\">Experiments </a> section. In future I am planning to add Urdu only sections etc.",
"blogSection" : "Main",
"createdOn" : "2012-11-21",
"modifiedOn" : "2012-11-21",
"createDay" : "21",
"createMonth" : "Nov",
"createYear" : "2012",
"categories" : [ {
"id" : 4,
"name" : "IT"
}, {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 139,
"urlFriendlyId" : "embedding_custom_fonts_with_font_face",
"title" : "Embedding custom fonts with @font-face",
"description" : "Read about how to Embedding custom fonts with @font-face",
"body" : "<p>New browsers are capable of showing custom embedded fonts which can be specified by using @font-face css tag. This allows web designers to use custom fonts which users don't need to install on their machine.</p>\n<p>With custom font (Hussaini Nastaleeq): <div id=\"hnfont\">پروگرامنگ Ú©ÛŒ دنیا میں خوش آمدید . یہ ایک اردوفونٹ ٹیسٹ ہÛ’</div></p>\n<p>Without custom font (System default): <div style=\"font-size: x-large;\">پروگرامنگ Ú©ÛŒ دنیا میں خوش آمدید . یہ ایک اردوفونٹ ٹیسٹ ہÛ’</div></p>\n\n<p>If font style is same in all above samples, you are probably not using most recent browser capable of using font-face css style.</p>\n\n<p>The custom font `Hussaini Nastaleeq` is a fork of Nafees Nastaleeq and is available <a href=\"https://github.com/khaledhosny/hussaini-nastaleeq\" target=\"_blank\">here</a>. The font is quite small in size (~ 300K) and browser should only download them if they are used by the page. </p>\n\n<p> Tested on Linux (Fedora 17) on Chrome Version 22.0.1229.94 and Firefox Version 16.0.1, Opera (Windows) and Chrome (Windows). The best rendering is on Firefox though.</p>\n\n<p>Numerous efforts are made to make this font work on IE 8 (which uses eot), however, still not able to make it work on IE8 unfortunately. The font is converted from ttf to eot on Linux using <s><a href=\"http://code.google.com/p/ttf2eot/\" target=\"_blank\">ttf2eot</a></s> <a href=\"http://www.w3.org/Tools/eot-utils/\" target=\"_blank\">eot-utilities</a>.</p>\n\n<p>On JBoss side (if using JSF), you probably need to specify correct mime types for the font types. Here are the implementation details:</p>\n<p>\n- web.xml:\n<pre><code data-language=\"html\">\n<mime-mapping>\n <extension>ttf</extension>\n <mime-type>application/octet-stream</mime-type>\n </mime-mapping>\n <mime-mapping>\n <extension>eot</extension>\n <mime-type>application/vnd.ms-fontobject</mime-type>\n </mime-mapping>\n</code></pre>\n\n- css file:\n<pre><code data-language=\"css\">\n/* Required first for IE, no format */\n@font-face\n{\n font-family: u;\n src: url(\"#{resource['fonts:nafees_riqa.eot']}\");\n}\n\n@font-face\n{\n font-family: u;\n src: url(\"#{resource['fonts:nafees_riqa.ttf']}\") format('opentype');\n}\n\n#nrfont {\n font-family: u;\n font-size: x-large;\n}\n</code></pre>\n\n- JSF template:\n<pre><code data-language=\"html\">\n &lt;h:outputStylesheet name=\"uzi.css\" library=\"css\" /&gt;\n</code></pre>\n\n- Applying font:\n<pre><code data-language=\"html\">\n&lt;div id=\"nrfont\"&gt; ...\n</code></pre>\n</p>",
"blogSection" : "Main",
"createdOn" : "2012-11-06",
"modifiedOn" : "2012-11-06",
"createDay" : "06",
"createMonth" : "Nov",
"createYear" : "2012",
"categories" : [ {
"id" : 4,
"name" : "IT"
}, {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 138,
"urlFriendlyId" : "testing_xa_datasource.",
"title" : "Testing xa datasource.",
"description" : "Read about how to Testing xa datasource.",
"body" : "Just moved the datasource to use jta. Last time it was not working, looks like it started working now ... strange!",
"blogSection" : "Main",
"createdOn" : "2012-09-12",
"modifiedOn" : "2012-09-12",
"createDay" : "12",
"createMonth" : "Sep",
"createYear" : "2012",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 137,
"urlFriendlyId" : "moving_project_to_maven_build_system",
"title" : "Moving project to maven build system",
"description" : "Read about how to Moving project to maven build system",
"body" : "My blog project is now moved to maven build system from old Eclipse project. It is also now directly merged/synchronized with openshift git repository. In addition, I ended up writing my own RSS feed generator. Good stuff. Check out my github profile for the source code of this blog.",
"blogSection" : "Main",
"createdOn" : "2012-09-12",
"modifiedOn" : "2012-09-12",
"createDay" : "12",
"createMonth" : "Sep",
"createYear" : "2012",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 4,
"name" : "IT"
}, {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 136,
"urlFriendlyId" : "exploring_openshift",
"title" : "Exploring Openshift",
"description" : "Read about how to Exploring Openshift",
"body" : "<p>Time to jump openshift bandwagon, start using PaaS (platform as a service) and join Cloud. Why do I need it and what is Openshift?</p><p>My expertise area is JEE development, and I try to keep myself updated with the latest technologies by \"getting my hands dirty\" in coding. Some time ago, I implemented my own JEE based blogging implementation and decided to host it on resin and then followed by JBoss AS 7. The next step was to get a good, reliable and cheap JBoss hosting. I manage to get a cheap \"VPS\" host (around 10$/month), however, I wasn't happy with it. Too unreliable, too slow, much lesser resources. And I have to manage everything by hand, monitor JBoss, monitor my HSQLDB etc. Even though its raw power to control things as you please, but it gets too time consuming pretty soon.</p><p><a href=\"http://www.openshift.com\">Openshift</a> comes to the rescue.</p><p>From offering perspective, at the moment, they provide free of cost developer preview (and I hope this will remain as it is). For a low volume site like mine, this was perfect. It provides me a ground to test with the latest and greatest technologies at no fraction of cost.</p><p>From technology perspective, I was able to setup one instance of JBoss AS 7 and PostgreSQL 8.4 within minutes, ready to push my changes via git. The main time spent was converting my blog data from hsqldb to PostgreSQL. Openshift provide hooks and access to manage all it with ease - a developer's dream. Pretty neat.</p><p>Now the scalability, assuming that my site becomes very popular, I can add another JBoss instance to scale my load (same goes for PostgreSQL instance), this is the true beauty of \"PaaS\".</p>\n<p>So there you go, get yourself an Openshift account and start experimenting. Stay tuned for my further Openshift experiments :) </p>",
"blogSection" : "Main",
"createdOn" : "2012-09-06",
"modifiedOn" : "2012-09-06",
"createDay" : "06",
"createMonth" : "Sep",
"createYear" : "2012",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 2,
"name" : "PostgreSQL"
}, {
"id" : 4,
"name" : "IT"
}, {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 135,
"urlFriendlyId" : "deploying_site_on_jboss_as_7",
"title" : "Deploying site on JBoss AS 7.0.2",
"description" : "Read about how to Deploying site on JBoss AS 7.0.2",
"body" : "So I finally decided to give JBoss AS 7 as try. It required some minor modifications in data source JNDI names to migrate from Resin to JBoss. Specifically, I modified the JDBC JNDI to java:/uziblogds from jdbc/uziblog. Another change was to modify the DataSource injection. Instead of @Inject @Named(\"jdbc/uziblog\"), JBoss was happier to use @Resource(mappedName=\"java:/uziblogds\")",
"blogSection" : "Main",
"createdOn" : "2011-11-18",
"modifiedOn" : "2011-11-18",
"createDay" : "18",
"createMonth" : "Nov",
"createYear" : "2011",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 6,
"name" : "JBoss"
} ]
}, {
"id" : 134,
"urlFriendlyId" : "locating_the_jar_containing_particular_class",
"title" : "Locating the jar containing particular class",
"description" : "Read about how to Locating the jar containing particular class",
"body" : "<p>Often while developing a Java web app, you found yourself in a situation where different version of same class is available on classpath and the one picked by classloader is not the one that your code is using (you are using a newer version while classloader is loading an older version). The following code snippet can be used to find which jar contains the offending class</p>\n\n<pre data-language=\"java\">\nMyClass.class.getProtectionDomain().getCodeSource().getLocation());\n</pre>",
"blogSection" : "Main",
"createdOn" : "2011-10-12",
"modifiedOn" : "2011-10-12",
"createDay" : "12",
"createMonth" : "Oct",
"createYear" : "2011",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 132,
"urlFriendlyId" : "new_site_changes",
"title" : "New Site Changes",
"description" : "Read about how to New Site Changes",
"body" : "\t\t\t<div>After my last hosting provider crash, I think its time to redesign the site from scratch. And it is going to be based on all\n\t\t\t\tJava now. Time to brush up my web development skills.</div><br />\n\t\t\t<div>Stay Tuned for my blog and tutorial/lectures. Drop me an email\n\t\t\t\tat usman (at) usmans.info for any suggestions, comments and queries.</div>",
"blogSection" : "Main",
"createdOn" : "2011-06-28",
"modifiedOn" : "2011-06-28",
"createDay" : "28",
"createMonth" : "Jun",
"createYear" : "2011",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 131,
"urlFriendlyId" : "advanced_java_tips_tricks_and_techniques",
"title" : "Really advanced Java tips, tricks and techniques",
"description" : "Read about advanced Java tips, tricks and techniques",
"body" : "Are you looking for some really advanced Java discussions? then subscribe to <a href=\"http://www.javaspecialists.eu/archive/archive.jsp\">The Java Specialists News letter</a> manage by Java Champion Dr. Heinz Kabutz.<br />\n\n<br />\n\nOf course, my all time favorite topic (which I always refer to my new class of Java students :-)) is <a href=\"http://www.javaspecialists.eu/archive/Issue100.html\">Java programmers aren't born</a>.",
"blogSection" : "Main",
"createdOn" : "2011-03-17",
"modifiedOn" : "2011-03-17",
"createDay" : "17",
"createMonth" : "Mar",
"createYear" : "2011",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 130,
"urlFriendlyId" : "java_speech_api_freetts",
"title" : "Java Speech API (freetts)",
"description" : "Read about how to Java Speech API (freetts)",
"body" : "The following instructions were provided by me on a forum some years back on how to run helloworld for Java Speech API (on Windows platform). I am copying it here again (for my own reference, as well as any other aspirants out there)<br />\n\n<br />\n\n<a href=\"http://sourceforge.net/projects/freetts/files/\">Download</a> the <a href=\"http://freetts.sourceforge.net/docs/index.php\">freetts</a> library. Extract and follow following instructions to run a HelloWorld program successfully:<br />\n\n<br />\n\n1. Unzipped: freetts-1.2.1-bin.zip to a folder, say [freetts]<br />\n\n<br />\n\n2. Execute [freetts]/lib/jsapi.exe to obtain jsapi.jar<br />\n\n<br />\n\n3. Created a sample 'demo' folder.<br />\n\n<br />\n\n4. Copied contents (sound files and HelloWorld.java) of [freetts]\\demo\\JSAPI\\HelloWorld to my 'demo' folder.<br />\n\n<br />\n\n5. Copied following files from [freetts]\\lib to my 'demo' folder:<br />\n\nfreetts.jar<br />\n\njsapi.jar<br />\n\ncmu_us_kal.jar<br />\n\ncmulex.jar<br />\n\nen_us.jar<br />\n\n<br />\n\n6. Copied [freetts]/speech.properties file to my home folder i.e. C:\\Documents and Settings\\[my_user_name] OR /home/[my_user_name]<br />\n\n<br />\n\n7. Compiled HelloWorld program as:<br />\n\njavac -classpath .;./jsapi.jar HelloWorld.java<br />\n\n<br />\n\n8 Run it as follows:<br />\n\njava -classpath .;./jsapi.jar;./freetts.jar;./cmu_us_kal.jar HelloWorld<br />\n\n<br />\n\n9. Following output came:<br />\n\nAll general Mode JSAPI Synthesizers and Voices:<br />\n\nFreeTTS en_US general synthesizer (mode=general, locale=en_US):<br />\n\nkevin<br />\n\nkevin16<br />\n\n<br />\n\nUsing voice: kevin16<br />\n\n<br />\n\nand I hear the voice as well.<br />\n\n<br />\n\nand my own test code:<br />\n\n<pre data-language=\"java\">\n\nimport javax.speech.*;\nimport javax.speech.synthesis.*;\nimport java.util.Locale;\n\npublic class HelloWorld2 {\n\npublic static void main(String args[]) {\n\ntry {\n\n// Create a synthesizer for English\n\nSynthesizer synth = Central.createSynthesizer(\n\nnew SynthesizerModeDesc(Locale.ENGLISH));\n\n\n\n// Get it ready to speak\n\nsynth.allocate();\n\nsynth.resume();\n\n// Speak the \"Hello world\" string\n\nsynth.speakPlainText(\"I love Java programming.\", null);\n\n// Wait till speaking is done\n\nsynth.waitEngineState(Synthesizer.QUEUE_EMPTY);\n\n// Clean up\n\nsynth.deallocate();\n\n} catch (Exception e) {\n\ne.printStackTrace();\n\n}\n\n}\n\n}\n\n</pre>",
"blogSection" : "Main",
"createdOn" : "2011-02-28",
"modifiedOn" : "2011-02-28",
"createDay" : "28",
"createMonth" : "Feb",
"createYear" : "2011",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 129,
"urlFriendlyId" : "postgresql_9_cross_platform_binaries_rpm_deb",
"title" : "PostgreSQL 9.0 cross-platform binaries RPM/DEB",
"description" : "Read about how to PostgreSQL 9.0 cross-platform binaries RPM/DEB",
"body" : "<a href=\"http://openscg.org\">OpenSCG</a> has released <a href=\"http://openscg.org/se/postgresql/packages.jsp\">RPM/DEB packages</a> for PostgreSQL 9.0. This allows an easy installation of PostgreSQL 9.0 which is friendly with the native package manager. ",
"blogSection" : "Main",
"createdOn" : "2011-02-14",
"modifiedOn" : "2011-02-14",
"createDay" : "14",
"createMonth" : "Feb",
"createYear" : "2011",
"categories" : [ {
"id" : 2,
"name" : "PostgreSQL"
} ]
}, {
"id" : 127,
"urlFriendlyId" : "creating_sha256_password_hashes",
"title" : "Creating sha256 password hashes",
"description" : "Read about how to Creating sha256 password hashes",
"body" : "<p>The following code snippet is an example on how to generate SHA 256 hash of\na String in Java</p>\n<pre data-language=\"java\">\npublic String generateHash(String value) {\n String password=null;\n try {\n\tbyte[] valueBytes = value.getBytes(\"UTF-8\");\n\tMessageDigest md = MessageDigest.getInstance(\"SHA-256\");\n\tbyte[] encodedBytes = md.digest(valueBytes);\n\tString hexEncodedValue = toHexString(encodedBytes);\n\tpassword = hexEncodedValue;\n\t} catch (UnsupportedEncodingException e) {\n\t\t\t//should not happen, just log.\n\t\t\tlog.error(e.getMessage(), e);\n\t} catch (NoSuchAlgorithmException e) {\n\t\t\t//should not happen, just log.\n\t\t\tlog.error(e.getMessage(), e);\n\t}\n\treturn password;\n}\n/**\n * Fast convert a byte array to a hex string\n * with possible leading zero.\n * @param b array of bytes to convert to string\n * @return hex representation, two chars per byte.\n */\n\npublic static String toHexString (byte[] b)\t{\n StringBuffer sb = new StringBuffer(b.length * 2);\n\t for (int i=0; i &lt; b.length; i++) {\n\t\t// look up high nibble char\n\t\tsb.append(hexChar[( b[i] &amp; 0xf0) &gt;&gt;&gt; 4]);\n\t // look up low nibble char\n\t sb.append(hexChar[b[i] &amp; 0x0f]);\n }\n\t return sb.toString();\n}\n\n\t/**\n\t * table to convert a nibble to a hex char.\n\t */\n\n\tstatic char[] hexChar = {\n\t '0' , '1' , '2' , '3' ,\n\t '4' , '5' , '6' , '7' ,\n\t '8' , '9' , 'a' , 'b' ,\n\t 'c' , 'd' , 'e' , 'f'};\n</pre>",
"blogSection" : "Main",
"createdOn" : "2010-11-20",
"modifiedOn" : "2010-11-20",
"createDay" : "20",
"createMonth" : "Nov",
"createYear" : "2010",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 126,
"urlFriendlyId" : "password_encryption_in_subetha",
"title" : "Password encryption in Subetha",
"description" : "Read about how to Password encryption in Subetha",
"body" : "The other day I submitted patch to encrypt passwords in <a href=\"http://code.google.com/p/subetha/\">Subetha</a>, a Java based open source mailing list manager. The patch can be tracked <a href=\"http://code.google.com/p/subetha/issues/detail?id=43\">here</a>.",
"blogSection" : "Main",
"createdOn" : "2010-11-20",
"modifiedOn" : "2010-11-20",
"createDay" : "20",
"createMonth" : "Nov",
"createYear" : "2010",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 125,
"urlFriendlyId" : "custom_layout_manager_in_java_xylayout",
"title" : "Custom Layout Manager in Java (XYLayout)",
"description" : "Read about how to Custom Layout Manager in Java (XYLayout)",
"body" : "This year in my Advanced Java Programming class, I put an additional 'Ludo' game as semester project (it is suppose to use RMI).<br />\n\n<br />\n\nMy students who took the project wanted an easier layout manager to place the components (as I was quite against using null layout manager). So, they ask me whether there exists any XYLayout. It turns out there are some implementations out there, but I was not happy with their licenses. So, I ended up writing my own XYLayoutManager. It will be a good showcase for my students as well. Here goes the code:<br />\n\n<br />\n\n<pre data-language=\"java\">\n/*\n * The code is licensed under Create Commons Attribution 3.0 License\n * http://creativecommons.org/licenses/by/3.0/\n *\n * Copyright (c) 2010 Usman Saleem.\n * http://usmans.info\n *\n */\n\npackage info.usmans;\n\nimport java.awt.Component;\nimport java.awt.Container;\nimport java.awt.Dimension;\nimport java.awt.Insets;\nimport java.awt.LayoutManager;\nimport java.util.LinkedHashMap;\nimport java.util.Map;\n\n/**\n * The XYLayout places components on x,y location\n *\n * @author usman\n */\n\npublic class XYLayout implements LayoutManager {\n\n\t/*\n\t * This hash table will contain our components and their x,y location as\n\t * constraints\n\t */\n\n\tprivate Map components = new LinkedHashMap();\n\n\t// Register a component into a map\n\t// The name is the x,y location of the component. i.e. 10,20\n\n\tpublic void addLayoutComponent(String name, Component comp) {\n\t\t// parse name, which should be in int,int format\n\t\tif (name == null || name.trim().length() <= 0) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid constraint: \" + name);\n\t\t}\n\n\t\tString[] location = name.split(\",\");\n\n\t\tif (location == null || location.length != 2) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid constraint: \" + name);\n\t\t}\n\n\t\tint x = 0;\n\t\tint y = 0;\n\n\t\ttry {\n\t\t\tx = Integer.parseInt(location[0]);\n\t\t\ty = Integer.parseInt(location[1]);\n\t\t} catch (NumberFormatException nfe) {\n\t\t\tthrow new IllegalArgumentException(\"Invalid constraint: \" + name);\n\t\t}\n\n\t\tcomponents.put(comp, new XYLocation(x, y));\n\t}\n\n\t// Remove components from our map\n\tpublic void removeLayoutComponent(Component comp) {\n\t\tcomponents.remove(comp);\n\t}\n\n\tpublic Dimension preferredLayoutSize(Container target) {\n\t\treturn target.getPreferredSize();\n\t}\n\n\t// for now return preferredlayoutsize\n\tpublic Dimension minimumLayoutSize(Container parent) {\n\t\treturn preferredLayoutSize(parent);\n\t}\n\n\t// place all components at its desired location\n\tpublic void layoutContainer(Container parent) {\n\t\tInsets insets = parent.getInsets();\n\t\tfor (Component c : components.keySet()) {\n\t\t\tXYLocation location = components.get(c);\n\t\t\tDimension dimension = c.getPreferredSize();\n\t\t\tc.setBounds(location.x + insets.left, location.y + insets.top,\n\t\t\tdimension.width, dimension.height);\n\t\t}\n\t}\n\n\t/*\n\t * This class is a simple value object class to hold x and y location\n\t */\n\n\tprivate class XYLocation {\n\t\tprivate int x;\n\t\tprivate int y;\n\t\tpublic XYLocation(int x, int y) {\n\t\t\tthis.x = x;\n\t\t\tthis.y = y;\n\t\t}\n\t}\n}\n\n</pre><br />\n\n<br />\n\nHere is the test class.<br />\n\n<br />\n\n<pre data-language=\"java\">\n\n/*\n * The code is licensed under Create Commons Attribution 3.0 License\n * http://creativecommons.org/licenses/by/3.0/\n *\n * Copyright 2010 Usman Saleem.\n * http://usmans.info\n *\n */\n\npackage info.usmans;\n\nimport java.awt.BorderLayout;\nimport java.awt.event.*;\nimport java.util.Random;\nimport javax.swing.*;\n\n/**\n* A Test application to test XY Layout.\n* @author usman\n*/\n\npublic class TestXYLayout extends JFrame implements ActionListener {\n\n private JLabel board = new JLabel(new ImageIcon(getClass().getResource(\"ludo1.gif\")));\n\n private JLabel stimpy = new JLabel(new ImageIcon(getClass().getResource(\"stimpy.gif\")));\n\n private JPanel panel = new JPanel();\n\n private JPanel bottom = new JPanel();\n\n private JButton moveButton = new JButton(\"Move\");\n\n\n\n public void init() {\n\n setSize(560, 620);\n\n //add our panels in JFrame\n\n add(panel, BorderLayout.CENTER);\n\n add(bottom, BorderLayout.SOUTH );\n\n\n //add our button in bottom frame\n bottom.add(moveButton);\n moveButton.addActionListener(this);\n\n //set panel layout to XYLayout\n panel.setLayout(new XYLayout());\n panel.add(\"0,0\",stimpy);\n panel.add(\"0,0\",board);\n\n //draw our components on center panel\n drawComponents();\n\n }\n\n private void drawComponents() {\n panel.remove(board);\n panel.remove(stimpy);\n //calculate random x,y position\n int x = new Random().nextInt(this.getX()+this.getWidth());\n int y = new Random().nextInt(this.getY()+this.getHeight());\n\n panel.add(String.valueOf(x)+\",\"+String.valueOf(y), stimpy);\n panel.add(\"0,0\", board);\n\n panel.validate();\n\n }\n\n public void actionPerformed(ActionEvent e) {\n drawComponents();\n }\n\n public static void main(String[] args) {\n SwingUtilities.invokeLater(new Runnable() {\n public void run() {\n TestXYLayout test = new TestXYLayout();\n test.init();\n test.setDefaultCloseOperation(TestXYLayout.EXIT_ON_CLOSE);\n test.setResizable(false);\n test.setVisible(true);\n }\n\n });\n\n }\n}\n</pre>",
"blogSection" : "Main",
"createdOn" : "2010-06-25",
"modifiedOn" : "2010-06-25",
"createDay" : "25",
"createMonth" : "Jun",
"createYear" : "2010",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 121,
"urlFriendlyId" : "c_search_and_replace_string_program",
"title" : "C search and replace string program",
"description" : "Read about how to C search and replace string program",
"body" : "The other day I needed to write a C function which search and replace all tokens in a char * aka C strings. Searching on google doesn't returned too many promising results, hence I ended up writing my own function. Here it goes:\n\n\n\n<pre data-language=\"c\">\n/*\n* casr --- C based search and replace program in a char *\n*\n* Author: Usman Saleem - usman.saleem@gmail.com\n*\n* This code is released under The MIT License.\n* http://www.opensource.org/licenses/mit-license.php\n*\n* Copyrights (c) 2010, Usman Saleem.\n*\n*/\n#include &lt;stdio.h&gt;\n#include &lt;string.h&gt;\n#include &lt;stdlib.h&gt;\n/*\n* The search and replace function attempts to replace\n* 'token' with 'replacement' on a copy of 'line'.\n* Returns:\n* - NULL for invalid arguments or out of memory\n* - 'line' reference if nothing to replace\n* - char * with all tokens replaced.\n*\n* The caller should call free if the reference to 'line' and\n* returned value is different\n*/\nchar * csar(char *line, char *token, char *replacement)\n{\n char *result, *finalresult; /* the return string */\n int token_length; /* length of token */\n int replacement_length; /* length of replacement */\n int count; /* number of replacements */\n char *tmp;\n char *curr;\n int diff;\n /* Basic sanity of arguments */\n if (!line)\n return NULL;\n if (!token || !(token_length = strlen (token)))\n return NULL;\n if (!replacement || !(replacement_length = strlen (replacement)))\n return NULL;\n /*return same line if there is nothing to replace */\n if (!(strstr (line, token)))\n return line;\n curr = line;\n /*determine count of tokens */\n for(count = 0; tmp = strstr(curr,token); count++)\n {\n curr = tmp+token_length;\n }\n /*allocate memory*/\n finalresult = result = malloc(strlen(line) + (replacement_length*count) + 1 - (token_length*count));\n if(!result)\n {\n return NULL; /*out of memory?*/\n }\n /*move to beginning of line*/\n curr = line;\n for(;;)\n {\n /*determine next location of token */\n tmp = strstr(curr, token);\n if(!tmp) break;\n diff = tmp - curr;\n strncpy(result, curr, diff); /*copy the pre-token part*/\n strcpy(result+diff, replacement); /*copy replacement*/\n strcpy(result+diff+replacement_length, tmp+token_length); /*copy rest of stuff*/\n /*move to next token position*/\n curr = curr+diff+token_length;\n /*update result position to next replace position*/\n result = result+diff+replacement_length;\n }\n return finalresult;\n}\nint main(void)\n{\n char *line1=\"\";\n char *line2=\"abcdef\";\n char *line3=\"abc@abc.txt@@def@\";\n char *line4=\"@middle@\";\n char *line5=\"@\";\n char *line6=\"@@@\";\n printf(\"line1: %s replaced with %s\\n\",line1, csar(line1, \"@\", \"xxATxx\"));\n printf(\"line2: %s replaced with %s\\n\",line2, csar(line2, \"@\", \"xxATxx\"));\n printf(\"line4: %s replaced with %s\\n\",line4, csar(line4, \"@\", \"xxATxx\"));\n printf(\"line5: %s replaced with %s\\n\",line5, csar(line5, \"@\", \"xxATxx\"));\n printf(\"line6: %s replaced with %s\\n\",line6, csar(line6, \"@\", \"xxATxx\"));\n char *temp = csar(line3, \"@\", \"xxATxx\");\n char *temp1 = csar(temp, \".\", \"xxDOTxx\");\n printf(\"line3: %s replaced with %s\\n\",line3,temp1 );\n}\n</pre>",
"blogSection" : "Main",
"createdOn" : "2010-05-07",
"modifiedOn" : "2010-05-07",
"createDay" : "07",
"createMonth" : "May",
"createYear" : "2010",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 120,
"urlFriendlyId" : "linux_skype_webcam_and_ubunto_9",
"title" : "Linux skype webcam and Ubunto 9.10",
"description" : "Read about how to Linux skype webcam and Ubunto 9.10",
"body" : "<pre class=\"brush: bash\">bash -c 'LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so skype'</pre><br />\n\n<br />\n\nAnd you have a working webcam in skype on Ubuntu 9.10",
"blogSection" : "Main",
"createdOn" : "2010-04-15",
"modifiedOn" : "2010-04-15",
"createDay" : "15",
"createMonth" : "Apr",
"createYear" : "2010",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 119,
"urlFriendlyId" : "bash_bulk_renaming",
"title" : "Bash bulk renaming",
"description" : "Read about how to Bash bulk renaming",
"body" : "<pre class=\"brush: bash\">find . -name en.lng -exec sh -c 'exec mv \"$1\" \"${1%/*}/zh_cn.lng\"' {} {} \\; -print</pre><br />\n\n<br />\n\nRename en.lng to zh_cn.lng in subdirectories.",
"blogSection" : "Main",
"createdOn" : "2010-03-30",
"modifiedOn" : "2010-03-30",
"createDay" : "30",
"createMonth" : "Mar",
"createYear" : "2010",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 118,
"urlFriendlyId" : "launching_bash_as_sub_process_from_java_program",
"title" : "Launching bash as sub process from Java program",
"description" : "Read about how to Launching bash as sub process from Java program",
"body" : "Recently one of my colleague who was attempting to mimic the 'host' command found in Oracle's 'sql*plus' (written in C) to EnterpriseDB's 'edb*plus' which is written in Java. <br />\n\n<br />\n\nBoth sql*plus and edb*plus are non-gui, shell based programs.<br />\n\n<br />\n\nThe 'host' command launches a new bash shell over top of current running sql*plus process. User use this new bash shell and when they type 'exit', the prompt again returns to to sql*plus.<br />\n\n<br />\n\nThis become quite a challenge to implement in Java. The typical approach that both my colleague and I come up with initially was to launch bash as <pre class=\"brush: java\">Runtime.exec(\"bash\")</pre> or <pre class=\"brush: java\">Runtime.exec(\"bash -i\")</pre> and use the process' inputstream and outputstream to communicate with bash. These approaches, however, didn't get us the bash prompt, that is we were not able to detach current running java program and introduce a new bash prompt.<br />\n\n<br />\n\nSo, i finally come up with following solution which seem to do the trick.\n\nThe trick is to go native. In our native code, we need to fork bash as a separate process and then wait for it. This is technically different from what Runtime.exec does. Runtime.exec technically calls bash in same process space and pass the arguments of exec to bash itself. Going native actually spawns a new process from JVM process itself. Here is the code:<br />\n\n<br />\n\nTestBash.java:<br />\n\n<code class=\"java\"><br />\n\nimport java.io.*;<br />\n\n<br />\n\npublic class TestBash {<br />\n\n public static native void gonative();<br />\n\n<br />\n\n public static void main(String args[]) throws IOException {<br />\n\n System.loadLibrary(\"gonativelib\");<br />\n\n <br />\n\n BufferedReader br = new BufferedReader(new InputStreamReader(System.in));<br />\n\n while(true) {<br />\n\n System.out.print(\"edb*plus:\");<br />\n\n String line = br.readLine();<br />\n\n if(line == null) line=\"\";<br />\n\n if(line.equalsIgnoreCase(\"host\")) {<br />\n\n gonative();<br />\n\n }else if(line.equalsIgnoreCase(\"quit\")) {<br />\n\n break;<br />\n\n }else {<br />\n\n\tSystem.err.println(\"valid commands: host, quit\");<br />\n\n }<br />\n\n }<br />\n\n System.exit(0);<br />\n\n }<br />\n\n<br />\n\n}<br />\n\n</code><br />\n\n<br />\n\ngonative.h:<br />\n\n<code class=\"C\"><br />\n\n/* DO NOT EDIT THIS FILE - it is machine generated */<br />\n\n#include <jni.h><br />\n\n/* Header for class TestBash */<br />\n\n<br />\n\n#ifndef _Included_TestBash<br />\n\n#define _Included_TestBash<br />\n\n#ifdef __cplusplus<br />\n\nextern \"C\" {<br />\n\n#endif<br />\n\n/*<br />\n\n * Class: TestBash<br />\n\n * Method: gonative<br />\n\n * Signature: ()V<br />\n\n */<br />\n\nJNIEXPORT void JNICALL Java_TestBash_gonative<br />\n\n (JNIEnv *, jclass);<br />\n\n<br />\n\n#ifdef __cplusplus<br />\n\n}<br />\n\n#endif<br />\n\n#endif<br />\n\n</code><br />\n\n<br />\n\ngonativelib.c:<br />\n\n<code class=\"C\"><br />\n\n#include <stdio.h><br />\n\n#include <stdlib.h><br />\n\n#include <sys/types.h><br />\n\n#include <sys/wait.h><br />\n\n#include <unistd.h><br />\n\n#include \"gonative.h\"<br />\n\n/* Spawn a child process running a new program. PROGRAM is the name<br />\n\n * of the program to run; the path will be searched for this program.<br />\n\n * ARG_LIST is a NULL-terminated list of character strings to be<br />\n\n * passed as the programu00eds argument list. Returns the process ID of<br />\n\n * the spawned process. */<br />\n\nint spawn (char* program, char** arg_list)<br />\n\n{<br />\n\n pid_t child_pid;<br />\n\n /* Duplicate this process. */<br />\n\n child_pid = fork ();<br />\n\n if (child_pid != 0)<br />\n\n /* This is the parent process. */<br />\n\n return child_pid;<br />\n\n else {<br />\n\n /* Now execute PROGRAM, searching for it in the path. */<br />\n\n execvp (program, arg_list);<br />\n\n /* The execvp function returns only if an error occurs. */<br />\n\n fprintf (stderr, \"an error occurred in execvp\\n\");<br />\n\n abort ();<br />\n\n }<br />\n\n}<br />\n\n/*<br />\n\n * Native Method which will be called from Java class<br />\n\n */ <br />\n\nJNIEXPORT void JNICALL Java_TestBash_gonative (JNIEnv *env, jclass classname)<br />\n\n{<br />\n\n int child_status;<br />\n\n /* The argument list to pass to the \"ls\" command. */<br />\n\n char* arg_list[] = {<br />\n\n \"bash\", /* argv[0], the name of the program. */<br />\n\n NULL /* The argument list must end with a NULL. */<br />\n\n };<br />\n\n /* Spawn a child process running the \"ls\" command. Ignore the<br />\n\n * returned child process ID. */<br />\n\n spawn (\"bash\", arg_list);<br />\n\n /* Wait for the child process to complete. */<br />\n\n wait (&child_status);<br />\n\n /*<br />\n\n if (WIFEXITED (child_status))<br />\n\n printf (\"the child process exited normally, with exit code %d\\n\",<br />\n\n WEXITSTATUS (child_status));<br />\n\n else<br />\n\n printf (\"the child process exited abnormally\\n\");<br />\n\n<br />\n\n printf (\"done with main program\\n\");<br />\n\n */<br />\n\n}<br />\n\n</code><br />\n\n<br />\n\nCompiling:<br />\n\n<code class=\"BASH\"><br />\n\ngcc -o libgonativelib.so -shared -Wl,-soname,libgonative.so -I/opt/jdk1.6.0_18/include -I/opt/jdk1.6.0_18/include/linux gonativelib.c -static -lc<br />\n\n</code><br />\n\n<br />\n\nExecution:<br />\n\n<code class=\"BASH\"><br />\n\njava -Djava.library.path=. TestBash<br />\n\n</code>",
"blogSection" : "Main",
"createdOn" : "2010-03-18",
"modifiedOn" : "2010-03-18",
"createDay" : "18",
"createMonth" : "Mar",
"createYear" : "2010",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 117,
"urlFriendlyId" : "zekr_open_source_quran_software",
"title" : "Zekr - Open source Quran software",
"description" : "Read about how to Zekr - Open source Quran software",
"body" : "<a href=\"http://zekr.org/quran/\">Zekr - Quran</a><br />\n\n<br />\n\nExcellent and accurate Quran software based on <a href=\"http://tanzil.info\">tanzil.info</a>. Available for Windows, Linux and Mac. <br />\n\n<br />\n\nIn order to run on Ubuntu (without using .deb), I made some modifications in the .sh file. I simply comment out check for MOZILLA_FIVE_HOME.<br />\n\n<br />\n\nSecondly, make sure you have downloaded Nafees Web Naksh font available from crulp.org, this will make urdu translation very readable.<br />\n\n<br />\n\nLastly, make sure that you have flashplugin-nonfree module installed, otherwise sound may not work.<br />\n\n<br />\n\nJazak Allah.",
"blogSection" : "Main",
"createdOn" : "2009-12-25",
"modifiedOn" : "2009-12-25",
"createDay" : "25",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 116,
"urlFriendlyId" : "changing_file_prefix_in_bulk_in_linux",
"title" : "Changing file prefix in bulk in Linux",
"description" : "Read about how to Changing file prefix in bulk in Linux",
"body" : "<pre class=\"brush: bash\">\nfind . -name pg-\\*|awk '{a=$1;sub(/\\pg-/,\"ppas-\",a);printf \"mv %-100s %s\\n\",$1,a}'&gt;xyz\n</pre><br />\n\n<br />\n\nThis command will change the file names prefix from one to another. For example, I have files in current (and sub) directory as pg-aaa.x pg-bbb.x and I want to change these to ppas-aaa.x ppas-bbb.x. The commands will be directed to file xyz. Source it to run the actual commands. i.e. <pre>. xyz</pre>",
"blogSection" : "Main",
"createdOn" : "2009-12-09",
"modifiedOn" : "2009-12-09",
"createDay" : "09",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 114,
"urlFriendlyId" : "invalid_or_expired_ticket_at_nucleus_cms_while_adding_item",
"title" : "Invalid or expired ticket at Nucleus CMS while adding item",
"description" : "Read about how to Invalid or expired ticket at Nucleus CMS while adding item",
"body" : "This should be solved by optimizing/repair nucleus_tickets table (if it is being reported as overhead)",
"blogSection" : "Main",
"createdOn" : "2009-12-09",
"modifiedOn" : "2009-12-09",
"createDay" : "09",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 112,
"urlFriendlyId" : "ubuntu_8_9_dual_head_monitors_and_multiple_keyboard_modes",
"title" : "Ubuntu 8.10/9.04 Dual Head Monitors and multiple keyboard modes",
"description" : "Read about how to Ubuntu 8.10/9.04 Dual Head Monitors and multiple keyboard modes",
"body" : "<b>Dual Head Modes:</b><br />\n\nSwitching to VGA and turning off laptop screen<br />\n\n<pre class=\"brush: bash\">xrandr --output LVDS --off --output VGA --auto</pre><br />\n\n<br />\n\nYou can switch back the outputs at the end of the presentation simply with a:<br />\n\n<pre class=\"brush: bash\">xrandr --output LVDS --auto --output VGA --off</pre><br />\n\n<br />\n\nKeyboard layouts:<br />\n\n(External keyboard)<br />\n\n<pre class=\"brush: bash\">setxkbmap us</pre><br />\n\n(Laptop)<br />\n\n<pre class=\"brush: bash\">setxkb gb</pre>",
"blogSection" : "Main",
"createdOn" : "2009-12-09",
"modifiedOn" : "2009-12-09",
"createDay" : "09",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 111,
"urlFriendlyId" : "finding_out_directory_of_a_user_in_linux",
"title" : "Finding out directory of a user in Linux",
"description" : "Read about how to Finding out directory of a user in Linux",
"body" : "<code class=\"bash\">echo ~username</code> <br />\n\nor <br />\n\n<code class=\"bash\"><br />\n\ndir = ~username<br />\n\necho $dir <br />\n\n</code> should do the trick from terminal window.",
"blogSection" : "Main",
"createdOn" : "2009-12-09",
"modifiedOn" : "2009-12-09",
"createDay" : "09",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ ]
}, {
"id" : 108,
"urlFriendlyId" : "vi_keyboard_shortcuts",
"title" : "VI Keyboard Shortcuts",
"description" : "Read about how to VI Keyboard Shortcuts",
"body" : "<a href=\"http://www.keyxl.com/aaab462/105/VIM-Text-Editor-keyboard-shortcuts.htm\">VI Keyboard Shortcuts</a><br />\n\n<br />\n\nTo open a new tab (if supported)<br />\n\n<br />\n\n:tabnew filename<br />\n\ngt (Move to other tab in normal mode)",
"blogSection" : "Main",
"createdOn" : "2009-12-08",
"modifiedOn" : "2009-12-08",
"createDay" : "08",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ ]
}, {
"id" : 107,
"urlFriendlyId" : "list_of_my_firefox_add_ons.",
"title" : "List of my firefox Add-ons.",
"description" : "Read about how to List of my firefox Add-ons.",
"body" : "Following is the list of my firefox Add-ons.<br />\n\n<br />\n\nAdblock Plus<br />\n\nBookmarks Menu<br />\n\nDownloadHelper<br />\n\nDownThemAll!<br />\n\nFoxClocks<br />\n\nGoogle Bookmarks Button Reloaded<br />\n\nHide Caption Titlebar<br />\n\nLastPass<br />\n\nOmnibar<br />\n\nSlimbar<br />\n\nToggleMenubar<br />\n\n<br />\n\nSome of the above add-ons works best with Chromifox Basic theme.",
"blogSection" : "Main",
"createdOn" : "2009-12-04",
"modifiedOn" : "2009-12-04",
"createDay" : "04",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ ]
}, {
"id" : 104,
"urlFriendlyId" : "syntax_highlighting_test_using_geshi_plugin",
"title" : "Syntax highlighting test using Geshi plugin",
"description" : "Read about how to Syntax highlighting test using Geshi plugin",
"body" : "This post is to test syntax highlighting.\n\n<code class=\"java\"><br />\n\npublic class Test {<br />\n\nstatic{<br />\n\n System.out.println(\"static initializer\");<br />\n\n}<br />\n\n<br />\n\npublic Test() {<br />\n\n System.out.println(\"constructor\");<br />\n\n //annon inner clas<br />\n\n new java.awt.event.ActionListener() {<br />\n\n {<br />\n\n //instance initializer<br />\n\n System.out.println(\"inner class instance initializer\");<br />\n\n }<br />\n\n public void actionPerformed(java.awt.event.ActionEvent e){}<br />\n\n }; //inner class<br />\n\n}<br />\n\n<br />\n\n{<br />\n\nSystem.out.println(\"instance initializer\");<br />\n\n}<br />\n\n<br />\n\npublic static void main(String a[]) throws ClassNotFoundException {<br />\n\n Class.forName(a[0]);<br />\n\n Test t = new Test();<br />\n\n t = new Test();<br />\n\n //Class c = Test.class;<br />\n\n}<br />\n\n}<br />\n\n</code>",
"blogSection" : "Main",
"createdOn" : "2009-12-04",
"modifiedOn" : "2009-12-04",
"createDay" : "04",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ ]
}, {
"id" : 101,
"urlFriendlyId" : "welcome_to_new_site",
"title" : "Welcome to new site",
"description" : "Read about how to Welcome to new site",
"body" : "Finally made the move to shift my blogging from blogger.com to personal hosting. I decided to use Nucleus CMS. Its quite extensive and customizable. I was able to port my old blog posts from blogger to this CMS. Technically, this becomes the first post.",
"blogSection" : "Main",
"createdOn" : "2009-12-02",
"modifiedOn" : "2009-12-02",
"createDay" : "02",
"createMonth" : "Dec",
"createYear" : "2009",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 74,
"urlFriendlyId" : "fix_for_sound_issue_in_ubuntu_9_04_hp_pavilion_dv4000",
"title" : "Fix for sound issue in Ubuntu 9.04 HP Pavilion dv4000",
"description" : "Read about how to Fix for sound issue in Ubuntu 9.04 HP Pavilion dv4000",
"body" : "<div style=\"clear:both;\"></div>The sound was giving error on my HP dv4000 running Ubuntu 9.04.<br /><br />Here is the listing of my hardware modules:<br /><code><br />00:1e.2 Multimedia audio controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Audio Controller (rev 04)<br /> Subsystem: Hewlett-Packard Company Device 309d<br /> Flags: bus master, medium devsel, latency 0, IRQ 17<br /> I/O ports at 1c00 [size=256]<br /> I/O ports at 18c0 [size=64]<br /> Memory at b0040800 (32-bit, non-prefetchable) [size=512]<br /> Memory at b0040400 (32-bit, non-prefetchable) [size=256]<br /> Capabilities: <access denied=\"\"><br /> Kernel driver in use: Intel ICH<br /> Kernel modules: snd-intel8x0<br /></access></code><br />Adding following at the end of /etc/modprobe.d/alsa-base.conf<br /><code><br />options snd-intel8x0 ac97_quirk=1 buggy_irq=1 buggy_semaphore=1<br /></code><br /><br />if <code>ac97_quirk=1</code> doesn't work, try 0,2,3 or 4 as value.<br /><br />Reboot.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2009-09-22",
"modifiedOn" : "2009-09-22",
"createDay" : "22",
"createMonth" : "Sep",
"createYear" : "2009",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 73,
"urlFriendlyId" : "a_very_simple_java_based_ident_server",
"title" : "A very simple java based Ident server",
"description" : "Read about how to A very simple java based Ident server",
"body" : "<div style=\"clear:both;\"></div><span style=\"font-size:85%;\">Every now and then I need to connect to IRC servers and I don't run a full blown identd daemon on my Ubuntu machine. Hence I come up with a very simple java based Ident server. Simply run it before connecting to an IRC server, it will terminate once the response is served. Its a quick and dirty code, not production quality at all. Feel free to use it at your own risk.<br /></span><br /><code><br />import java.net.*;<br />import java.io.*;<br /><br />/*<br />* This class acts as a simple Ident server<br />* usage: sudo java jident [&lt;fakeid&gt;]<br />* fakeid is optional, if not passed, nobody is used.<br />* It simply terminates once ident response is served.<br />* Best use is to run before connecting to an irc server.<br />* If on Linux, it should be called using 'sudo' since it<br />* runs on port 113.<br />* Use at your own risk.<br />* @author Usman Saleem<br />* @version 1.0<br />*/<br />public class jident {<br /><br />public static void main(String args[]){<br />//create a server socket on port 113<br />try {<br /> int port = 113;<br /> System.out.println(\"Simple java based identd server by Uzi\");<br /> ServerSocket srv = new ServerSocket(port);<br /><br /> // Wait for connection from client.<br /> Socket socket = srv.accept();<br /><br /> BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));<br /> String msg = br.readLine();<br /> //should be in format &lt;port-on-server&gt; , &lt;port-on-client&gt;<br /> System.out.println(\"Request: \"+msg);<br /> if(msg != null) {<br /> //send response back to server<br /> msg+= \" : USERID : UNIX : \" + (args.length>=1?args[0]:\"nobody\");<br /> System.out.println(\"Response: \"+msg);<br /> BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));<br /> wr.write(msg);<br /> wr.newLine();<br /> wr.flush();<br /> System.out.println(\"Response sent, waiting from server\");<br /> System.out.println(\"server:\"+br.readLine());<br /><br /> }<br /> socket.close();<br /> srv.close();<br /> System.out.println(\"Done.\");<br /><br />} catch (IOException e) {<br /> e.printStackTrace();<br /> System.exit(-1);<br />}<br /><br /><br /><br />}<br /><br />}<br /></code><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2008-07-12",
"modifiedOn" : "2008-07-12",
"createDay" : "12",
"createMonth" : "Jul",
"createYear" : "2008",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 72,
"urlFriendlyId" : "removing_c_compilation_error:_stdio_h:_no_such_file_or_directory_on_ubuntu",
"title" : "Removing c compilation error: stdio.h: No such file or directory on Ubuntu",
"description" : "Read about how to Removing c compilation error: stdio.h: No such file or directory on Ubuntu",
"body" : "If you are compiling a simple c program on Ubuntu and you get following stupid error(s):<code>error: stdio.h: No such file or directory</code> then you need to install 'build-essential' package. This can be install using Synaptic Package Manager or apt-get.",
"blogSection" : "Main",
"createdOn" : "2008-06-12",
"modifiedOn" : "2008-06-12",
"createDay" : "12",
"createMonth" : "Jun",
"createYear" : "2008",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 71,
"urlFriendlyId" : "wii_wasabi_and_wii_clip",
"title" : "Wii, Wasabi and Wii-Clip",
"description" : "Read about how to Wii, Wasabi and Wii-Clip",
"body" : "<div style=\"clear:both;\"></div>The other day I luckily manage to purchase a Nintendo Wii while I was here in Florida at a client site for a month. Since I had to take that back to home, I wasn't sure if the games available there would be playable on this Wii or not. So, I did some research ... order wasabi modchip alongside Wii-Clip ... installed it in Wii with the help of a friend and hopefully I will be now able to play region free games on it :-).<a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http://bp3.blogger.com/_9v1q9LEnHIA/SFFZh0_lKyI/AAAAAAAAAKY/loKuVISPO_4/s1600-h/wasabi-wiiclip.jpg\"><img style=\"margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;\" src=\"http://bp3.blogger.com/_9v1q9LEnHIA/SFFZh0_lKyI/AAAAAAAAAKY/loKuVISPO_4/s320/wasabi-wiiclip.jpg\" alt=\"\" id=\"BLOGGER_PHOTO_ID_5211044681540250402\" border=\"0\" /></a>",
"blogSection" : "Main",
"createdOn" : "2008-05-02",
"modifiedOn" : "2008-05-02",
"createDay" : "02",
"createMonth" : "May",
"createYear" : "2008",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 70,
"urlFriendlyId" : "nj_album",
"title" : "NJ Album",
"description" : "Read about how to NJ Album",
"body" : "<div style=\"clear:both;\"></div><div style=\"text-align:center;width:194px;font-family:arial,sans-serif;font-size:83%\"><div style=\"height:194px;background:url(http://picasaweb.google.com/f/img/transparent_album_background.gif) no-repeat left\"><a href=\"http://picasaweb.google.com/usman.saleem/USVisit\"><img src=\"http://lh4.google.com/image/usman.saleem/Re7cIMAewPE/AAAAAAAAAHM/z4rb4ICQxxg/s160-c/USVisit.jpg\" width=\"160\" height=\"160\" style=\"border:none;padding:0px;margin-top:16px;\"></a></div><a href=\"http://picasaweb.google.com/usman.saleem/USVisit\"><div style=\"color:#4D4D4D;font-weight:bold;text-decoration:none;\">US Visit</div></a><div style=\"color:#808080\"></div></div><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2007-03-07",
"modifiedOn" : "2007-03-07",
"createDay" : "07",
"createMonth" : "Mar",
"createYear" : "2007",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 69,
"urlFriendlyId" : "my_visit_to_enterprisedb_edison_office",
"title" : "My visit to EnterpriseDB Edison office",
"description" : "Read about how to My visit to EnterpriseDB Edison office",
"body" : "<div style=\"clear:both;\"></div>I am at EnterpriseDB Iselin (New Jersey) office for a business trip of 6 weeks.<br /><br />Enjoying the warm welcome by everyone in the office. It will be a memorable trip of my life.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2007-03-06",
"modifiedOn" : "2007-03-06",
"createDay" : "06",
"createMonth" : "Mar",
"createYear" : "2007",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 68,
"urlFriendlyId" : "i_became_sun_certified_web_component_developer",
"title" : "I became Sun Certified Web Component Developer",
"description" : "Read about how to I became Sun Certified Web Component Developer",
"body" : "<div style=\"clear:both;\"></div>Cleared SCWCD today on October 16, 2006 around 11:15 PST with passing score of 82%. Not very happy with the score, it should have been higher :-). But, as they say 'a pass is a pass'.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-10-16",
"modifiedOn" : "2006-10-16",
"createDay" : "16",
"createMonth" : "Oct",
"createYear" : "2006",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 67,
"urlFriendlyId" : "setting_custom_icon_for_individual_nodes_in_jtree",
"title" : "Setting Custom icon for individual nodes in JTree",
"description" : "Read about how to Setting Custom icon for individual nodes in JTree",
"body" : "<div style=\"clear:both;\"></div>For changing and removing the Default Icons in a JTree Component see following link:<br />http://javaalmanac.com/egs/javax.swing.tree/DefIcons.html<br /><br />However, above approach does not take care of individual icons. Here is the solution that I used in one of my projects:<br /><br />1. Let your nodes extend from a generic super class, say MyNode, where MyNode is extended from DefaultMutableTreeNode. Define public abstract Icon getIcon(); in MyNode.<br /><br /><code><br />/**<br />* My Node<br />* @author usman<br />*/<br />public abstract class MyNode extends DefaultMutableTreeNode{<br /><br />&nbsp;public MyNode () {<br />&nbsp;&nbsp;super(\"Title Of Node);<br />&nbsp;}<br /><br />&nbsp;public abstract javax.swing.Icon getIcon();<br />}<br /></code><br /><br />2. Create sub classes of MyNode which are supposed to be inserted into the tree, implementing getIcon method, for instance:<br /><code><br />/**<br />* Custom Node<br />* @author usman<br />*/<br />public class CustomNode extends MyNode{<br /><br />&nbsp;public CustomNode() {<br />&nbsp;&nbsp;super(\"Title Of Node);<br />&nbsp;}<br /><br />&nbsp;public </code><code>javax.swing.Icon </code><code>getIcon() {<br />&nbsp;&nbsp;return new javax.swing.ImageIcon(getClass().getResource(\"/icons/myicon16.png\"));<br />&nbsp;}<br />}<br /></code><br />Now create a custom tree cell renderer, in which you set the default icon based on the sub class type:<br /><code><br />import java.awt.Component;<br />import javax.swing.JTree;<br />import javax.swing.tree.DefaultTreeCellRenderer;<br /><br />public class CustomTreeCellRenderer extends DefaultTreeCellRenderer{<br />&nbsp;public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {<br />&nbsp;if((value instanceof MyNode) &&amp; (value != null)) {<br /> &nbsp;&nbsp;setIcon(((MyNode)value).getIcon());<br />&nbsp; }<br /><br />//we can not call super.getTreeCellRendererComponent method, since it overrides our setIcon call and cause rendering of labels to '...' when node expansion is done<br /><br />//so, we copy (and modify logic little bit) from super class method:<br /><br />&nbsp;String stringValue = tree.convertValueToText(value, sel,<br /> expanded, leaf, row, hasFocus);<br /><br />&nbsp;this.hasFocus = hasFocus;<br />&nbsp;setText(stringValue);<br />&nbsp;if(sel)<br />&nbsp;&nbsp; setForeground(getTextSelectionColor());<br />&nbsp;else<br />&nbsp;&nbsp; setForeground(getTextNonSelectionColor());<br /><br />&nbsp;if (!tree.isEnabled()) {<br />&nbsp;&nbsp; setEnabled(false);<br />&nbsp;}<br />&nbsp;else {<br />&nbsp;&nbsp; setEnabled(true);<br />&nbsp;}<br />&nbsp; setComponentOrientation(tree.getComponentOrientation());<br />&nbsp;selected = sel;<br />&nbsp;return this;<br /><br />}<br />}<br /><br /></code><br />The method of interest is <code>getTreeCellRendererComponent</code> in which we call getIcon method of our sub classes and sets the icon of current node. We don't call super class method directly because it somehow mess up with default width calculation of our nodes and cause '...' in rendering the labels. The '...' is specially visible if we programmatically expand children of a node.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-08-28",
"modifiedOn" : "2006-08-28",
"createDay" : "28",
"createMonth" : "Aug",
"createYear" : "2006",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 66,
"urlFriendlyId" : "enterprisedb_replication_server",
"title" : "EnterpriseDB Replication Server",
"description" : "Read about how to EnterpriseDB Replication Server",
"body" : "<div style=\"clear:both;\"></div>EnterpriseDB adds replication server under its belt. For official details see <a href=\"http://www.enterprisedb.com/news_events/press_releases/15_08_06b.do\">http://www.enterprisedb.com/news_events/press_releases/15_08_06b.do </a><br /><br />This is the project I am currently working on. I am responsible for refactoring the user interface and building it from grounds up using NetBeans IDE. NetBeans GUI builder a.k.a Mattise is perhaps the best Java UI designer I have ever worked with. Well, it is good enough to make me switch from Eclipse IDE to NetBeans IDE as my primary development platform :-)<br /><br />Under the hood, project Replication Server UI (internally we call it Replication Console) is built upon best coding practices as well as utilizes MVC and several GOF design patterns. Build as pure swing based thin client, it uses RMI to communicate with backend Replication Servers and web services to communicate with EnterpriseDB DBA Management Server.<br /><br />Here is the screenshot of the upcoming Replication Server Beta 2 UI.<br /><br /><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http://photos1.blogger.com/blogger/2294/965/1600/rrep-ui-beta2.png\"><img style=\"margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;\" src=\"http://photos1.blogger.com/blogger/2294/965/320/rrep-ui-beta2.png\" alt=\"\" border=\"0\" /></a><br /><br />Other cool things that I am \"responsible\" for integrating in this project are: .1. Integrating AXIS based web services engine to control replication servers life cycles, .2. extending JBoss Microcontroller (JBoss MBean Services) to hook up replication servers with DBA Management Server and last but not least, several backend code refactoring back in the days of Beta 0 and Beta 1 :-)<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-08-23",
"modifiedOn" : "2006-08-23",
"createDay" : "23",
"createMonth" : "Aug",
"createYear" : "2006",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 2,
"name" : "PostgreSQL"
}, {
"id" : 4,
"name" : "IT"
}, {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 65,
"urlFriendlyId" : "enterprisedb_wins_best_database_award_at_linuxworld",
"title" : "EnterpriseDB Wins Best Database Award at LinuxWorld",
"description" : "Read about how to EnterpriseDB Wins Best Database Award at LinuxWorld",
"body" : "<div style=\"clear:both;\"></div><span style=\"font-size:85%;\"> EnterpriseDB Wins Best Database Award at LinuxWorld for Second Consecutive Year; Enterprise Open Source Database Takes Top Honor, Besting Oracle, Others...</span><br /><br /><a href=\"http://www.enterprisedb.com/news_events/press_releases/18_08_06.do\">http://www.enterprisedb.com/news_events/press_releases/18_08_06.do</a><br /><br />Well, since it is my company, I won't say much :-), just that I am so proud.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-08-23",
"modifiedOn" : "2006-08-23",
"createDay" : "23",
"createMonth" : "Aug",
"createYear" : "2006",
"categories" : [ {
"id" : 4,
"name" : "IT"
}, {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 64,
"urlFriendlyId" : "sun_certified_business_component_developer_for_j2ee_1_3",
"title" : "Sun Certified Business Component Developer for J2EE 1.3",
"description" : "Read about how to Sun Certified Business Component Developer for J2EE 1.3",
"body" : "<div style=\"clear:both;\"></div>Today on Friday, March 10, 2006 around 3'o clock I have attempted and cleared Sun Certified Business Component Developer for J2EE 1.3 with flying colors ... an excellent score of 95% .... 67 correct questions out of a total of 70 questions .... hip hip hurray :-)<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-03-10",
"modifiedOn" : "2006-03-10",
"createDay" : "10",
"createMonth" : "Mar",
"createYear" : "2006",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 4,
"name" : "IT"
}, {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 63,
"urlFriendlyId" : "neural_network_using_java",
"title" : "Neural Network using Java",
"description" : "Read about how to Neural Network using Java",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://diwww.epfl.ch/mantra/tutorial/english/\">Neural Java Index</a>: \"Neural Networks Tutorial with Java Applets\"<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-03-02",
"modifiedOn" : "2006-03-02",
"createDay" : "02",
"createMonth" : "Mar",
"createYear" : "2006",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 62,
"urlFriendlyId" : "flazx_ebooks",
"title" : "FlazX - EBooks",
"description" : "Read about how to FlazX - EBooks",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.flazx.com/index.php\">FlazX - Welcome to your Computer &amp; IT learning center</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-02-15",
"modifiedOn" : "2006-02-15",
"createDay" : "15",
"createMonth" : "Feb",
"createYear" : "2006",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 61,
"urlFriendlyId" : "autopackage_easy_linux_software_installation",
"title" : "Autopackage : Easy Linux Software Installation",
"description" : "Read about how to Autopackage : Easy Linux Software Installation",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://autopackage.org/index.html\">Autopackage : Easy Linux Software Installation</a>: \"Autopackage makes software installation on Linux easy. Software distributed using Autopackage can be installed on multiple Linux distributions and integrate well into the desktop environment.\"<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-01-31",
"modifiedOn" : "2006-01-31",
"createDay" : "31",
"createMonth" : "Jan",
"createYear" : "2006",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 60,
"urlFriendlyId" : "windows_xp_changing_ip_address_gateway_and_dns_from_command_line_or_batch_script",
"title" : "Windows XP: Changing IP Address, Gateway and DNS from command line (or batch script)",
"description" : "Read about how to Windows XP: Changing IP Address, Gateway and DNS from command line (or batch script)",
"body" : "<div style=\"clear:both;\"></div>netsh interface ip set address [connection] static [ip] [mask] [gateway] 1<br /><br />netsh interface ip set dns [connection] static [first]<br /><br />netsh interface ip add dns [connection] [second] index=2<br /><br />For example, Following entries will change network connection \"Local Area Connection\" with IP address 10.10.1.15, Mask 255.255.255.0, Gateway 10.0.0.10 and Primary DNS 10.90.1.1 and Seconday DNS 10.90.1.2 (All values are hypothetical)<br /><blockquote><br />netsh interface ip set address \"Local Area Connection\" static 10.10.1.15 255.255.255.0 10.0.0.10 1<br /><br />netsh interface ip set dns \"Local Area Connection\" static 10.90.1.1<br /><br />netsh interface ip add dns \"Local Area Connection\" 10.90.1.2 index=2<br /></blockquote><br /><br />Using above entries/commands one can update network settings/configuration of Laptop in different LAN environments.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-01-26",
"modifiedOn" : "2006-01-26",
"createDay" : "26",
"createMonth" : "Jan",
"createYear" : "2006",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 59,
"urlFriendlyId" : "universal_console_redirector_the_code_project_threads_processes_ipc",
"title" : "Universal Console Redirector - The Code Project - Threads, Processes , IPC",
"description" : "Read about how to Universal Console Redirector - The Code Project - Threads, Processes , IPC",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.codeproject.com/threads/consolepipe.asp\">Universal Console Redirector - The Code Project - Threads, Processes &amp; IPC</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2006-01-05",
"modifiedOn" : "2006-01-05",
"createDay" : "05",
"createMonth" : "Jan",
"createYear" : "2006",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 58,
"urlFriendlyId" : "jsf_tutorial_from_marty_hall_and_coreservlets_com",
"title" : "JSF Tutorial from Marty Hall and coreservlets.com",
"description" : "Read about how to JSF Tutorial from Marty Hall and coreservlets.com",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.coreservlets.com/JSF-Tutorial/\">JSF Tutorial from Marty Hall and coreservlets.com</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-12-28",
"modifiedOn" : "2005-12-28",
"createDay" : "28",
"createMonth" : "Dec",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 57,
"urlFriendlyId" : "cewolf_hart_enabling_web_object_framework",
"title" : "Cewolf - Chart Enabling Web Object Framework",
"description" : "Read about how to Cewolf - Chart Enabling Web Object Framework",
"body" : "<div style=\"clear:both;\"></div>Cewolf can be used inside a Servlet/JSP based web application to embed complex graphical charts of all kinds (e.g. line, pie, bar chart, plots, etc.) into a web page. Therefore it provides a full featured tag library to define all properties of the chart (colors, strokes, legend, etc.). Thus the JSP which embedds the chart is not polluted with any java code. Everything is described with XML conform tags.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-12-28",
"modifiedOn" : "2005-12-28",
"createDay" : "28",
"createMonth" : "Dec",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 56,
"urlFriendlyId" : "drawing_eyes",
"title" : "Drawing eyes...",
"description" : "Read about how to Drawing eyes...",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://startart.artlair.com/tut_eyes1.html\">Drawing Eyes...</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-12-08",
"modifiedOn" : "2005-12-08",
"createDay" : "08",
"createMonth" : "Dec",
"createYear" : "2005",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 55,
"urlFriendlyId" : "sed_one_liner_examples",
"title" : "Sed one liner examples",
"description" : "Read about how to Sed one liner examples",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.student.northpark.edu/pemente/sed/sed1line.txt\">Sed one liner</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-11-30",
"modifiedOn" : "2005-11-30",
"createDay" : "30",
"createMonth" : "Nov",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 54,
"urlFriendlyId" : "automatic_form_submission_after_specified_time_using_javascript",
"title" : "Automatic form submission after specified time using javascript",
"description" : "Read about how to Automatic form submission after specified time using javascript",
"body" : "<div style=\"clear:both;\"></div>Put following code after your form tag:<br /><code><br />&lt;script language=\"Javascript\"&gt;<br />function doSubmit() {<br /><br />//asubmit is the name of the SUBMIT button in the form<br />document.yourForm.asubmit.click();<br />}<br />//auto submit after 5 second<br />setTimeout(\"doSubmit()\",5000);<br />&lt;/script&gt;<br /></code><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-11-23",
"modifiedOn" : "2005-11-23",
"createDay" : "23",
"createMonth" : "Nov",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 53,
"urlFriendlyId" : "eid_greetings",
"title" : "Eid Greetings",
"description" : "Read about how to Eid Greetings",
"body" : "<div style=\"clear:both;\"></div>Eid Greetings .... today would be the last day of holy month Ramadan and tomorrow would be Eid InshaAllah.\n<br /><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-11-03",
"modifiedOn" : "2005-11-03",
"createDay" : "03",
"createMonth" : "Nov",
"createYear" : "2005",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 52,
"urlFriendlyId" : "reading_windows_environment_variable_in_java",
"title" : "Reading windows environment variable in java",
"description" : "Read about how to Reading windows environment variable in java",
"body" : "<div style=\"clear:both;\"></div>import java.io.*;\n<br />public class Test{\n<br />public static void main(String args[]) throws IOException{\n<br />//JDK1.5\n<br />System.out.println(System.getenv(\"USERDOMAIN\"));\n<br />\n<br />//Pre-JDK1.5\n<br />Process p = Runtime.getRuntime().exec(\"cmd.exe /c echo %USERDOMAIN%\");\n<br />BufferedReader br = new BufferedReader\n<br /> ( new InputStreamReader( p.getInputStream() ) );\n<br />String myvar = br.readLine();\n<br />System.out.println(myvar);\n<br />\n<br />}\n<br />}<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-10-20",
"modifiedOn" : "2005-10-20",
"createDay" : "20",
"createMonth" : "Oct",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 51,
"urlFriendlyId" : "nist_internet_time_service",
"title" : "NIST Internet Time Service",
"description" : "Read about how to NIST Internet Time Service",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://tf.nist.gov/timefreq/service/its.htm\">NIST Internet Time Service</a>: \"Set Your Computer Clock Via the Internet\n<br />NIST Internet Time Service (ITS)\"<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-10-20",
"modifiedOn" : "2005-10-20",
"createDay" : "20",
"createMonth" : "Oct",
"createYear" : "2005",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 50,
"urlFriendlyId" : "free_java_jsp_servlet_web_hosting_and_webservices_hosting",
"title" : "Free Java JSP Servlet Web Hosting and WebServices Hosting",
"description" : "Read about how to Free Java JSP Servlet Web Hosting and WebServices Hosting",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://s43.eatj.com/index.jsp\">Free Java JSP Servlet Web Hosting and WebServices Hosting</a>: \"Java servlet/JSP/MySQL web hosting, web service hosting, J2SE 5.0(1.5), Apache 2.0, Tomcat 5.5 (Private JVM), MySQL 4.1(Your own db), SMTP, POP accounts, 99% uptime, 24x7 monitoring.\"<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-10-20",
"modifiedOn" : "2005-10-20",
"createDay" : "20",
"createMonth" : "Oct",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 49,
"urlFriendlyId" : "linuxquestions_org_how_to_configure_the_kde_3_3_menu_manually_without_kmenuedit_linuxanswers",
"title" : "LinuxQuestions.org- How To Configure the KDE 3.3 Menu manually (without KMenuEdit) - LinuxAnswers",
"description" : "Read about how to LinuxQuestions.org- How To Configure the KDE 3.3 Menu manually (without KMenuEdit) - LinuxAnswers",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.linuxquestions.org/questions/answers.php?action=viewarticle&amp;artid=319\">LinuxQuestions.org- How To Configure the KDE 3.3 Menu manually (without KMenuEdit) - LinuxAnswers</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-10-14",
"modifiedOn" : "2005-10-14",
"createDay" : "14",
"createMonth" : "Oct",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 48,
"urlFriendlyId" : "rob_van_der_woude_scripting_pages_batch_files_rexx_kixtart_perl_vbscript",
"title" : "Rob van der Woude's Scripting Pages: Batch Files, Rexx, KiXtart, Perl, VBScript",
"description" : "Read about how to Rob van der Woude's Scripting Pages: Batch Files, Rexx, KiXtart, Perl, VBScript",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.robvanderwoude.com/\">Rob van der Woude's Scripting Pages: Batch Files, Rexx, KiXtart, Perl, VBScript</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-26",
"modifiedOn" : "2005-09-26",
"createDay" : "26",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 47,
"urlFriendlyId" : "javassist",
"title" : "Javassist",
"description" : "Read about how to Javassist",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.csg.is.titech.ac.jp/~chiba/javassist/\">Javassist</a>:\n<br />\n<br />\"Javassist (Java Programming Assistant) makes Java bytecode manipulation simple. It is a class library for editing bytecodes in Java; it enables Java programs to define a new class at runtime and to modify a class file when the JVM loads it. Unlike other similar bytecode editors, Javassist provides two levels of API: source level and bytecode level. If the users use the source-level API, they can edit a class file without knowledge of the specifications of the Java bytecode. The whole API is designed with only the vocabulary of the Java language. You can even specify inserted bytecode in the form of source text; Javassist compiles it on the fly. On the other hand, the bytecode-level API allows the users to directly edit a class file as other editors.\"<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-21",
"modifiedOn" : "2005-09-21",
"createDay" : "21",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 46,
"urlFriendlyId" : "java_examples_jexamples_com",
"title" : "Java Examples - JExamples.com",
"description" : "Read about how to Java Examples - JExamples.com",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.jexamples.com/\">Java Examples - JExamples.com</a> We analyze the source code of production Java open source projects such as Ant, Tomcat and Batik and load that analysis into a java examples database designed for easy searching. You enter the name of a Java API Class you want to see example invocations of and click Search.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-20",
"modifiedOn" : "2005-09-20",
"createDay" : "20",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 45,
"urlFriendlyId" : "pastebin_collaborative_debugging_tool",
"title" : "pastebin - collaborative debugging tool",
"description" : "Read about how to pastebin - collaborative debugging tool",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://pastebin.com/\">pastebin - collaborative debugging tool</a><br /><br />You have some code that you want to share on some forum or with a group of people on internet, use the above site, it does exactly that.<br /><br />You will get a URL like <a href=\"http://pastebin.com/365340\">http://pastebin.com/365340</a><br /><br />Simply excellent.<br /><br />--Uzi<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-16",
"modifiedOn" : "2005-09-16",
"createDay" : "16",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 44,
"urlFriendlyId" : "how_to_create_and_use_a_patch_in_linux",
"title" : "How to create and use a patch in Linux",
"description" : "Read about how to How to create and use a patch in Linux",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.cpqlinux.com/patch.html\">How to create and use a patch in Linux</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-16",
"modifiedOn" : "2005-09-16",
"createDay" : "16",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 43,
"urlFriendlyId" : "snmp4j_free_open_source_snmp_api_for_java",
"title" : "SNMP4J - Free Open Source SNMP API for Java",
"description" : "Read about how to SNMP4J - Free Open Source SNMP API for Java",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.snmp4j.org/\">SNMP4J - Free Open Source SNMP API for Java</a>\n<br />The SNMP4J Java SNMP API provides the following features:\n<br />\n<br /> * SNMPv3 with MD5 and SHA authentication and DES and AES 128, AES 192, and AES 256 privacy.\n<br /> * Pluggable Message Processing Models with implementations for MPv1, MPv2c, and MPv3\n<br /> * All PDU types.\n<br /> * Pluggable transport mappings. UDP and TCP are supported out-of-the-box.\n<br /> * Pluggable timeout model.\n<br /> * Synchronous and asynchronous requests.\n<br /> * Command generator as well as command responder support.\n<br /> * Free open source with the Apache license model\n<br /> * Javau201au00d1u00a2 1.4.1 or later\n<br /> * Logging based on Log4J\n<br /> * Row-based efficient asynchronous table retrieval with GETBULK.\n<br /> * Multi-threading support.\n<br /> * JUnit tests (will be available soon)\n<br />\n<br />The SNMP4J-Agent pure Java SNMP agent API adds command responder support to the SNMP4J core API and comes with:\n<br />\n<br /> * Implementations for SNMP-TARGET-MIB, SNMP-NOTIFICATION-MIB, SNMP-FRAMEWORK-MIB, SNMPv2-MIB, SNMP-COMMUNITY-MIB, SNMP-USER-BASED-SM-MIB, SNMP-VIEW-BASED-ACM-MIB, and SNMP-MPD-MIB.\n<br /> * SNMPv1,v2c,v3 multi-lingual agent support, including MD5 and SHA authentication as well as DES and AES(128, 196, 256) privacy.\n<br /> * IPv4/IPv6 UDP and TCP support.\n<br /> * Code generation from MIB specifications is provided through AgenPro 2 which is a language and API independent template based code generator with round-trip generation facilities. <div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-13",
"modifiedOn" : "2005-09-13",
"createDay" : "13",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 42,
"urlFriendlyId" : "clocklink_com",
"title" : "ClockLink.com",
"description" : "Read about how to ClockLink.com",
"body" : "<div style=\"clear:both;\"></div><blockquote><br /><a href=\"http://www.clocklink.com\">Clock Link</a> provides fashionable clocks that you can easily embed in your web page. All you need to do is simply paste the tag on your web page. Our clock will display the city name of your choice if you choose. You can also choose a time zone for your clock so it will show the correct time. Decorate your website with our clocks.<br /></blockquote><br /><br />I have used this clock in my blogger as well. Take a look at the right side, Pakistan Standard Time. Neat.....<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-09",
"modifiedOn" : "2005-09-09",
"createDay" : "09",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 41,
"urlFriendlyId" : "changing_network_configuration_on_windows_from_java",
"title" : "Changing network configuration on Windows from Java",
"description" : "Read about how to Changing network configuration on Windows from Java",
"body" : "<div style=\"clear:both;\"></div>Use freely available jRegistryKey API (http://www.bayequities.com/tech/Products/jreg_key.shtml ) or any other API to manipulate windows registry as follows:<br /><br />1. Open registry on the HKEY_LOCAL_MACHINE<br /><br />2. Find the subKey = SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards\\\"netcard# \"<br /><br />\"netcard# \" usually is \"1\" but you can control any subkey and find specific netwrok Adapters<br /><br />Refer to \"MSDN Registry Entries for Network Adapter Cards\"<br /><br />3. Get data for the value \"ServiceName\"<br /><br />4. Find the subKey = SYSTEM\\CurrentControlSet\\Services\\\"ServiceName\"\\Parameters\\TcpIp\"<br /><br />5. Set data for the value \"IpAddress\" to change IP address<br /><br />6. Set data for the value \"SubnetMask\" to change subnet mask<br /><br />7. Set data for the value \"DefaultGateway\" to change default gateway<br /><br />8. Reboot your PC.<br /><br />Disclaimer: I haven't yet tested changing the network configuration, change above reigstry keys at your own risk!<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-08",
"modifiedOn" : "2005-09-08",
"createDay" : "08",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 40,
"urlFriendlyId" : "using_urdu_fonts_in_java",
"title" : "Using urdu fonts in Java",
"description" : "Read about how to Using urdu fonts in Java",
"body" : "<div style=\"clear:both;\"></div>Other day someone asked me how to use Urdu fonts in Java. So for a sample java program that uses urdu font, you need to do following:<br /><br />1. Download Nafees Nastaleeq Urdu font from <a href=\"http://http://www.crulp.org/Downloads/Nafees%20Nastaleeq(Updated).ttf\">CRULP</a>.<br /><br />2. Copy the font in C:\\WINDOWS\\Fonts folder<br /><br />3. Create following java program. It should display \"Usman\" in Urdu.<br /><br /><code><br /> import java.awt.*;<br /> import javax.swing.*;<br /> <br /> public class BasicDraw {<br /> public static void main(String[] args) {<br /> new BasicDraw();<br /> }<br /> BasicDraw() {<br /> // Create a frame<br /> JFrame frame = new JFrame();<br /> <br /> // Add a component with a custom paint method<br /> frame.getContentPane().add(new MyComponent());<br /> <br /> // Display the frame<br /> int frameWidth = 200;<br /> int frameHeight = 200;<br /> frame.setSize(frameWidth, frameHeight);<br /> frame.setVisible(true);<br /> }<br /> <br /> class MyComponent extends JComponent {<br /> // This method is called whenever the contents needs to be painted<br /> public void paint(Graphics g) {<br /> int style = Font.PLAIN;<br /> int size = 24;<br /> Font font = null;<br /> font = new Font(\"Nafees Nastaleeq\", style, size);<br /> String text = \"\\u005cu0639\\u005cu062b\\u005cu0645\\u005cu0627\\u005cu0646\";<br /> g.setFont(font);<br /> <br /> // Draw a string such that its base line is at x, y<br /> int x = 80;<br /> int y = 40;<br /> g.drawString(text, x, y);<br /> }<br /> }<br /> }<br /></code><br /><br />4. The resulting image should look like:<br /><a onblur=\"try {parent.deselectBloggerImageGracefully();} catch(e) {}\" href=\"http://photos1.blogger.com/blogger/2294/965/1600/usman_urdu_java.jpg\"><img style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;\" src=\"http://photos1.blogger.com/blogger/2294/965/320/usman_urdu_java.jpg\" border=\"0\" alt=\"\" /></a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-08",
"modifiedOn" : "2005-09-08",
"createDay" : "08",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 39,
"urlFriendlyId" : "visiting_lectures_at_quaid_e_azam_university",
"title" : "Visiting lectures at Quaid-e-Azam University",
"description" : "Read about how to Visiting lectures at Quaid-e-Azam University",
"body" : "<div style=\"clear:both;\"></div>Started September 2nd, 2005, I am delievering visiting lectures at <a href=\"http://www.qau.edu.pk\">Quaid-e-Azam University, Islamabad, Pakistan</a> for the subject of Object Oriented Programming to the students of M.Sc.<br /><br />I have delievered visiting lectures for the same subject (graduate level) at Punjab College of Information Technology (aff. with Mohammad Ali Jinnah University) and at College of Information Technology (aff. with Allama Iqbal Open University) before joining my current job (2003-2004).<br /><br />Other subjects at my credentials are Intro. to Database Management Systems and E-Commerce.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-09-05",
"modifiedOn" : "2005-09-05",
"createDay" : "05",
"createMonth" : "Sep",
"createYear" : "2005",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 38,
"urlFriendlyId" : "experience_with_open_source_office_productivity_softwares",
"title" : "Experience with open source office productivity softwares",
"description" : "Read about how to Experience with open source office productivity softwares",
"body" : "<div style=\"clear:both;\"></div>I have recently switched over to following two greate open source tools:<br /><br />Sun OpenOffice 1.9.122 (open source replacement for MS Office)<br />Mozilla Thunderbird (email client)<br /><br />So far my experience with both of these softwares is quite good. <br /><br />Besides the above two, following are other open source softwares I am using on my MS Windows platform:<br /><br />Gaim 1.4.0 (Instant Messaging Tool for Yahoo, MSN and many more)<br />ASpell (Spell checker)<br />Mozilla Firefox (Internet browser)<br />7-Zip (Compression tool handles zip, rar and many more compression algorithms)<br /><br />Following great softwares are also on my PC (not open source but free):<br /><br />FlashGet (Download manager)<br />SmartCVS (although I have purchased professioanl license, but its available for free as foundation version)<br />Acrobat Reader 7.0<br />K-Lite Codec Pack (useful collection of mostly used codecs)<br /><br />Enjoy,<br /><br />Uzi<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-08-19",
"modifiedOn" : "2005-08-19",
"createDay" : "19",
"createMonth" : "Aug",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 37,
"urlFriendlyId" : "enterprisedb_at_linuxworld",
"title" : "EnterpriseDB at LinuxWorld",
"description" : "Read about how to EnterpriseDB at LinuxWorld",
"body" : "<div style=\"clear:both;\"></div>Following photos are of EnterpriseDB desk at LinuxWorld .... what does the thrid one implies? :-)<br /><br /><a href=\"http://photos1.blogger.com/blogger/2294/965/1600/LinuxWorld-Day1_1.jpg\"><img style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;\" src=\"http://photos1.blogger.com/blogger/2294/965/320/LinuxWorld-Day1_1.jpg\" border=\"0\" alt=\"\" /></a><br /><div style=\"text-align: center;\">Shahzad</div><br /><a href=\"http://photos1.blogger.com/blogger/2294/965/1600/LinuxWorld-Day1_2.jpg\"><img style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;\" src=\"http://photos1.blogger.com/blogger/2294/965/320/LinuxWorld-Day1_2.jpg\" border=\"0\" alt=\"\" /></a><br /><div style=\"text-align: center;\">Scott</div><br /><a href=\"http://photos1.blogger.com/blogger/2294/965/1600/LinuxWorld-Day1_3.jpg\"><img style=\"display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;\" src=\"http://photos1.blogger.com/blogger/2294/965/320/LinuxWorld-Day1_3.jpg\" border=\"0\" alt=\"\" /></a><br /><div style=\"text-align: center;\">The Award...</div><br /><hr /><br />Kewl......<br /><br />--Uzi<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-08-10",
"modifiedOn" : "2005-08-10",
"createDay" : "10",
"createMonth" : "Aug",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 36,
"urlFriendlyId" : "whitespace_programming_language",
"title" : "Whitespace programming language",
"description" : "Read about how to Whitespace programming language",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://compsoc.dur.ac.uk/whitespace/index.php\">Whitespace Programming language</a>, a new language out there with only three tokens: space, tab and line feed.<br /><blockquote><br />The language itself is an imperative, stack based language. Each command consists of a series of tokens, beginning with the Instruction Modification Parameter (IMP). These are listed in the table below.<br /><br />IMP Meaning<br />[Space] Stack Manipulation<br />[Tab][Space] Arithmetic<br />[Tab][Tab] Heap access<br />[LF] Flow Control<br />[Tab][LF] I/O<br /><br /></blockquote><br /><br />Here is a sample ws program from their tutorial:<br /><blockquote><br /><h3>Annotated Example</h3><br />Here is an annotated example of a program which counts from 1 to 10, outputting<br />the current value as it goes.<br /><br />[Space][Space][Space][Tab][LF] Put a 1 on the stack<br /><br />[LF][Space][Space][Space][Tab][Space][Space]<br />[Space][Space][Tab][Tab][LF]<br />Set a Label at this point<br /><br /><br />[Space][LF][Space]Duplicate the top stack item<br /><br />[Tab][LF][Space][Tab]Output the current value<br /><br />[Space][Space][Space][Tab][Space][Tab][Space][LF]<br />Put 10 (newline) on the stack...<br /><br />[Tab][LF][Space][Space]...and output the newline<br /><br /><br />[Space][Space][Space][Tab][LF]Put a 1 on the stack<br /><br />[Tab][Space][Space][Space]Addition. This increments our current value.<br /><br />[Space][LF][Space]Duplicate that value so we can test it<br /><br />[Space][Space][Space][Tab][Space][Tab][Tab][LF]<br />Push 11 onto the stack<br /><br /><br />[Tab][Space][Space][Tab]Subtraction. So if we've reached the end, we have a zero on the stack.<br /><br />[LF][Tab][Space][Space][Tab][Space][Space]<br />[Space][Tab][Space][Tab][LF]If we have a zero, jump to the end<br /><br /><br />[LF][Space][LF][Space][Tab][Space]<br />[Space][Space][Space][Tab][Tab][LF]<br />Jump to the start<br /><br /><br />[LF][Space][Space][Space][Tab][Space]<br />[Space][Space][Tab][Space][Tab][LF]<br />Set the end label<br /><br /><br />[Space][LF][LF]Discard our accumulator, to be tidy<br /><br />[LF][LF][LF]Finish<br /><p><br />What could be simpler? The source code for this program is available<br /><a href=\"http://compsoc.dur.ac.uk/whitespace/count.ws\">here</a>. Have fun!<br /></p><br /></blockquote><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-08-04",
"modifiedOn" : "2005-08-04",
"createDay" : "04",
"createMonth" : "Aug",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 35,
"urlFriendlyId" : "enterprisedb_selected_as_best_database_solution_at_linuxworld_san_francisco_2005_finalists",
"title" : "EnterpriseDB selected as Best Database Solution at LinuxWorld San Francisco 2005 Finalists",
"description" : "Read about how to EnterpriseDB selected as Best Database Solution at LinuxWorld San Francisco 2005 Finalists",
"body" : "<div style=\"clear:both;\"></div>EnterpriseDB is selected as one of the \"Best Database Solution\" at LinuxWorld San Francisco 2005 Finalists.<br /><br />This is really an honor for me as an employee of EnterpriseDB and Lead on EDB-Installer to see our product listed in Linux World's Best Database Solution finalists.<br /><br />Cool.... :-)<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-08-02",
"modifiedOn" : "2005-08-02",
"createDay" : "02",
"createMonth" : "Aug",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 34,
"urlFriendlyId" : "faster_ms_office_outlook",
"title" : "Faster MS Office Outlook",
"description" : "Read about how to Faster MS Office Outlook",
"body" : "<div style=\"clear:both;\"></div>Here is the recipe for a faster outlook.<br /><br /><blockquote>Turn off MS Word as editor from Tools->Options->Mail Format->Uncheck Use Microsoft Office Word ....<br /><br />\"Compose in this Message format\" should be Plain Text.<br /></blockquote><br /><br /><span style=\"font-weight:bold;\">Consequences</span><br />MS Word is off loaded from memory, making outlook much faster. Good thing....<br /><br />No spelling check .... very very bad!<br /><br />Here is the (free) solution for spell check not only in \"MS-Word free Outlook\" but in any other windows application.<br /><br />Download and install <a href=\"http://hcidesign.com/freespell/\">FreeSpell</a> which is based on <a href=\"http://aspell.net/win32/\">ASpell</a>.<br /><br />Freespell does the trick, select any text in any application, hit the Freespell key combination (by default WindowsKey+Z), Aspell comes into play and you have your mistake free text replaced.<br /><br />The only drawback of FreeSpell is that it can not be minimize to system tray. So, download another (free) utility that can make any windows application iconify to System Tray, its called <a href=\"http://www.teamcti.com/TrayIt\">TrayIt!</a>. No installation required, just run the downloaded executable, press CTRL, minimize your desired application and there it goes into system tray ... Neat isn't it :-).<br /><br />Now I have cleaner, faster Outlook, and usable spell checker .....<br /><br />Enjoy!<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-08-02",
"modifiedOn" : "2005-08-02",
"createDay" : "02",
"createMonth" : "Aug",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 33,
"urlFriendlyId" : "java_examples_from_the_java_developers_almanac_1_4",
"title" : "Java Examples from The Java Developers Almanac 1.4",
"description" : "Read about how to Java Examples from The Java Developers Almanac 1.4",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://javaalmanac.com/\">Java Examples from The Java Developers Almanac 1.4</a>\n<br />The best resource to obtain quick, short, useful java code snippets. I simply adore this site.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-26",
"modifiedOn" : "2005-07-26",
"createDay" : "26",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 32,
"urlFriendlyId" : "linux_determine_your_distro",
"title" : "Linux: Determine your distro",
"description" : "Read about how to Linux: Determine your distro",
"body" : "<div style=\"clear:both;\"></div>Using <span style=\"font-style:italic;\">cat /etc/issue</span> command should let you know your linux distribution.<br /><br />Here is output of this command on my system:<br /><blockquote><br />[usman@isb-usman ~]$ cat /etc/issue<br />Fedora Core release 4 (Stentz)<br />Kernel \\r on an \\m<br /></blockquote><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-26",
"modifiedOn" : "2005-07-26",
"createDay" : "26",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 31,
"urlFriendlyId" : "redhat_gnome_2_menu_categories",
"title" : "Redhat Gnome 2 Menu categories",
"description" : "Read about how to Redhat Gnome 2 Menu categories",
"body" : "<div style=\"clear:both;\"></div><a href=\"https://www.redhat.com/archives/fedora-list/2004-April/msg02572.html\">Redhat Gnome 2 Menu categories</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-20",
"modifiedOn" : "2005-07-20",
"createDay" : "20",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 30,
"urlFriendlyId" : "what_is_faster_linkedlist_of_arraylist",
"title" : "What is faster - LinkedList of ArrayList? (Author: Dr. Heinz M. Kabutz)",
"description" : "Read about how to What is faster - LinkedList of ArrayList? (Author: Dr. Heinz M. Kabutz)",
"body" : "<div style=\"clear:both;\"></div>What is faster - LinkedList of ArrayList?\n<br />\n<br />As programmers, we often try to eke the last ounce of performance out of our collections. An interesting statement is this: \"ArrayList is faster than LinkedList, except when you remove an element from the middle of the list.\" I have heard this on more than one occasion, and a few months ago, decided to try out how true that statement really was. Here is some code that I wrote during last week's Java 5 Tiger course:\n<br />\n<br />import java.util.*;\n<br />\n<br />public class ListTest {\n<br /> private static final int NUM_ELEMENTS = 100 * 1000;\n<br /> public static void main(String[] args) {\n<br /> List ar = new ArrayList();\n<br /> for (int i = 0; i &lt; NUM_ELEMENTS; i++) {\n<br /> ar.add(i);\n<br /> }\n<br /> testListBeginning(ar);\n<br /> testListBeginning(new LinkedList(ar));\n<br /> testListMiddle(ar);\n<br /> testListMiddle(new LinkedList(ar));\n<br /> testListEnd(ar);\n<br /> testListEnd(new LinkedList(ar));\n<br /> }\n<br /> public static void testListBeginning(List list) {\n<br /> long time = System.currentTimeMillis();\n<br /> for (int i = 0; i &lt; 10000; i++) {\n<br /> list.add(0, new Object());\n<br /> list.remove(0);\n<br /> }\n<br /> time = System.currentTimeMillis() - time;\n<br /> System.out.println(\"beginning \" +\n<br /> list.getClass().getSimpleName() + \" took \" + time);\n<br /> }\n<br /> public static void testListMiddle(List list) {\n<br /> long time = System.currentTimeMillis();\n<br /> for (int i = 0; i &lt; 10000; i++) {\n<br /> list.add(NUM_ELEMENTS / 2, new Object());\n<br /> list.remove(NUM_ELEMENTS / 2);\n<br /> }\n<br /> time = System.currentTimeMillis() - time;\n<br /> System.out.println(\"middle \" +\n<br /> list.getClass().getSimpleName() + \" took \" + time);\n<br /> }\n<br /> public static void testListEnd(List list) {\n<br /> long time = System.currentTimeMillis();\n<br /> for (int i = 0; i < 10000000; i++) {\n<br /> list.add(new Object());\n<br /> list.remove(NUM_ELEMENTS);\n<br /> }\n<br /> time = System.currentTimeMillis() - time;\n<br /> System.out.println(\"end \" +\n<br /> list.getClass().getSimpleName() + \" took \" + time);\n<br /> }\n<br />}\n<br />\n<br />\n<br />One small little addition in Java 5 is the method getSimpleName() defined inside Class. I do not know how many times I have needed such a method and have had to write it.\n<br />\n<br />The output is obvious, but surprising nevertheless in the extent of the differences:\n<br />\n<br />beginning ArrayList took 4346\n<br />beginning LinkedList took 0\n<br />middle ArrayList took 2104\n<br />middle LinkedList took 26728\n<br />end ArrayList took 731\n<br />end LinkedList took 1242\n<br />\n<br />\n<br />Finding the element in the middle of the LinkedList takes so much longer that the benefits of just changing the pointer are lost. So, LinkedList is worse than ArrayList for removing elements in the middle, except perhaps if you are already there (although I have not tested that).\n<br />\n<br />So, when should you use LinkedList? For a long list that works as a FIFO queue, the LinkedList should be faster than the ArrayList. However, even faster is the ArrayBlockingQueue or the CircularArrayList that I wrote a few years ago. The answer is probably \"never\".\n<br />\n<br />Kind regards\n<br />\n<br />Heinz\n<br />\n<br /><a href=\"http://www.javaspecialists.co.za/archive/Issue111.html\">Read it all here...</a>\n<br /><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-13",
"modifiedOn" : "2005-07-13",
"createDay" : "13",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 29,
"urlFriendlyId" : "c_jdbc_clustered_jdbc",
"title" : "C-JDBC - Clustered JDBC",
"description" : "Read about how to C-JDBC - Clustered JDBC",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://c-jdbc.objectweb.org/\">C-JDBC - Clustered JDBC</a>: \"C-JDBC is a free open source database cluster middleware that allows any Java application (standalone application, servlet or EJB container, ...) to transparently access a cluster of databases through JDBC(tm). The database is distributed and replicated among several nodes and C-JDBC balances the queries among these nodes. C-JDBC handles node failures and provides support for checkpointing and hot recovery.\"<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-11",
"modifiedOn" : "2005-07-11",
"createDay" : "11",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 28,
"urlFriendlyId" : "jboss_ejb_3_0_beta_1",
"title" : "JBoss EJB 3.0 Beta 1",
"description" : "Read about how to JBoss EJB 3.0 Beta 1",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://jboss.org/jbossBlog/blog/bburke/2005/06/24/JBoss_EJB_3_0_Beta_1_Released.txt\">JBoss EJB 3.0 Beta 1</a>\n<br />\n<br />The JBoss Group has announced the availability of EJB 3.0 Beta 1. 'This release models as closely as possible to the upcoming Public Draft of the EJB 3.0 specification. The spec was a fast moving target the past few weeks, so we still need to cross the T's and dot the i's as far as spec compliance goes. We plan on doing another release sometime in July to complete some of the minor stuff we are missing. Special thanks goes especially to Emmanuel Bernard, Bill DeCoste, and of course Gavin 'guys! guys!' King.'\n<br />\n<br /><a href=\"http://jboss.org/jbossBlog/blog/bburke/2005/06/24/JBoss_EJB_3_0_Beta_1_Released.txt\">Full Story:</a>\n<br />\n<br />(Source: java.net)<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-11",
"modifiedOn" : "2005-07-11",
"createDay" : "11",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 27,
"urlFriendlyId" : "alphaworks_remote_system_management_tool_overview",
"title" : "alphaWorks : Remote System Management Tool : Overview",
"description" : "Read about how to alphaWorks : Remote System Management Tool : Overview",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.alphaworks.ibm.com/tech/rsmt?open&amp;S_TACT=105AGX59&amp;S_CMP=GR&amp;ca=dgr-jw06awrsmt\">alphaWorks : Remote System Management Tool : Overview</a>: \"Remote System Management Tool\n<br />\n<br /><strong>An integrated environment for remote system management, including file systems, users, and processes on any UNIX or Windows server.</stong>\n<br /><blockquote>\n<br /><em>What is Remote System Management Tool?</em>\n<br />\n<br />Remote Server Management Tool is an Eclipse plug-in that provides an integrated graphical user interface (GUI) environment and enables testers to manage multiple remote servers simultaneously. The tool is designed as a management tool for those who would otherwise telnet to more than one server to manage the servers and who must look at different docs and man pages to find commands for different platforms in order to create or manage users and groups and to initiate and monitor processes. This tool handles these operations on remote servers by using a user-friendly GUI; in addition, it displays configuration of the test server (number of processors, RAM, etc.). The activities that can be managed by this tool on the remote and local server are divided as follows:\n<br />\n<br /> * Process Management: This utility lists the process running on UNIX and Windowsu00acu00c6 servers. One can start and stop processes. Along with process listing, the utility also provides details of the resources used by the process.\n<br />\n<br /> * User Management: This utility facilitates creation of users and groups on UNIX servers; it also provides options for listing, creating, deleting, and modifying the attributes of users and groups.\n<br />\n<br /> * File Management: This utility acts as a windows explorer for any selected server, irrespective of its operating system. One can create, edit, delete, and copy files and directories on local or remote servers. Testers can tail the remote files.\n<br />\n<br /><em>How does it work?</em>\n<br />This Eclipse plug-in was written with the Standard Widget Toolkit (SWT). The tool has a perspective named Remote System Management; the perspective consists of test servers and a console view. The remote test servers are mounted in the Test Servers view for management of their resources (process, file system, and users or groups).\n<br />\n<br />At the back end, this Eclipse plug-in uses the Software Test Automation Framework (STAF). STAF is an open-source framework that masks the operating system-specific details and provides common services and APIs in order to manage system resources. The APIs are provided for a majority of the languages. Along with the built-in services, STAF also supports external services. The Remote Server Management Tool comes with two STAF external services: one for user management and another for proving system details.\n<br /></blockquote><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-09",
"modifiedOn" : "2005-07-09",
"createDay" : "09",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 26,
"urlFriendlyId" : "software_testing_automation_framework_staf",
"title" : "Software Testing Automation Framework (STAF)",
"description" : "Read about how to Software Testing Automation Framework (STAF)",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://staf.sourceforge.net/index.php\">Software Testing Automation Framework (STAF)</a>:\n<br /><blockquote>The Software Testing Automation Framework (STAF) is an open source, multi-platform, multi-language framework designed around the idea of reusable components, called services (such as process invocation, resource management, logging, and monitoring). STAF removes the tedium of building an automation infrastructure, thus enabling you to focus on building your automation solution.\n<br />\n<br />STAX is an execution engine which can help you thoroughly automate the distribution, execution, and results analysis of your testcases. STAX builds on top of three existing technologies, STAF, XML, and Python, to place great automation power in the hands of testers. STAX also provides a powerful GUI monitoring application which allows you to interact with and monitor the progress of your jobs.\n<br />\n<br />Other STAF services are also provided to help you to create an end-to-end automation solution. Other STAF services include: Event, EventManager, Cron, Email, HTTP, NamedCounter, FSExt (File System EXTension), and Timer.</blockquote><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-09",
"modifiedOn" : "2005-07-09",
"createDay" : "09",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 25,
"urlFriendlyId" : "open_source_release_for_sun_app_server",
"title" : "Open Source Release For Sun's App Server",
"description" : "Read about how to Open Source Release For Sun's App Server",
"body" : "<div style=\"clear:both;\"></div>Open Source Release For Sun's App Server\n<br />By Jim Wagner\n<br /><blockquote>\n<br />Sun Microsystems (Quote, Chart) is quietly releasing the source code to the upcoming Java System Application Server, Platform Edition 9, under the GlassFish project, named after a semi-transparent aquarium fish.\n<br />\n<br />The company is expected to release the source code for its Java-based application server under a new open source license as it kicks off its JavaOne conference in San Francisco today.\n<br /></blockquote>\n<br /><a href=\"http://www.internetnews.com/dev-news/article.php/3515651\">Read more here...</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-09",
"modifiedOn" : "2005-07-09",
"createDay" : "09",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 24,
"urlFriendlyId" : "software_engineer",
"title" : "Software Engineer",
"description" : "Read about how to Software Engineer",
"body" : "<div style=\"clear:both;\"></div>The following quote is taken from <span style=\"font-weight:bold;\">Rapid J2EE Development: An Adaptive Foundation for Enterprise Applications</span> <span style=\"font-style:italic;\">By Alan Monnox</span> which I am studying nowadays.<br /><br /><blockquote>The title software engineer is worthy of further elaboration. IT professionals have a propensity for putting all manner of titles on business cards, from systems analyst and enterprise architect to quality specialist and IT consultant. The true software professional, however, is an extremely versatile individual who is fully capable of fulfilling many, but not necessarily all, of the predefined roles on a project. It is to this type of individual that I apply the term software engineer. Putting aside for a moment the technical description of the role and the associated computer scientist tag, a software engineer is someone who not only knows his or her profession but knows it well. He or she can effectively contribute in all project phases, whether analysis, design, implementation, or testing. Moreover, a software engineer continually looks for new ideas to improve what he or she does and how it is done. In short, a software engineer understands that self-improvement and continuous learning are fundamental activities for an IT professional.</blockquote><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-09",
"modifiedOn" : "2005-07-09",
"createDay" : "09",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 23,
"urlFriendlyId" : "fedora_core_4_tips_and_tricks",
"title" : "Fedora Core 4 Tips and Tricks",
"description" : "Read about how to Fedora Core 4 Tips and Tricks",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://home.gagme.com/greg/linux/fc4-tips.php\">Fedora Core 4 Tips & Tricks</a>. Wish to take your Fedora Core 4 experience to next level, try the tips presented in this link. They offer all those things which by default are not part of official Fedora Core 4 but they should be!<br /><br />I setup successfully XMMS MP3 plugin, Xine DVD player, NTFS Module and Flash plugin (which I require most).<br /><br />I am enjoying it since Fedora Core 2.<br /><br />Great stuff ...<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-08",
"modifiedOn" : "2005-07-08",
"createDay" : "08",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
} ]
}, {
"id" : 22,
"urlFriendlyId" : "major_internet_disruption_in_pakistan_continues_for_4th_consecutive_day",
"title" : "Pakistan Times | Top Story: Major Internet disruption in Pakistan continues for 4th consecutive day",
"description" : "Read about how to Pakistan Times | Top Story: Major Internet disruption in Pakistan continues for 4th consecutive day",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.pakistantimes.net/2005/07/01/top1.htm\">Pakistan Times | Top Story: Major Internet disruption in Pakistan continues for 4th consecutive day</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-07-08",
"modifiedOn" : "2005-07-08",
"createDay" : "08",
"createMonth" : "Jul",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
}, {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 21,
"urlFriendlyId" : "beyond_the_obvious",
"title" : "Beyond the obvious",
"description" : "Read about how to Beyond the obvious",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://shahzadkhokhar.blogspot.com/\">Beyond the obvious</a> ..... <strong>respect!</strong> ..... the man that groom me professionaly, give me chance to prove myself ....... I have utmost respect for him ..... <div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-27",
"modifiedOn" : "2005-06-27",
"createDay" : "27",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 20,
"urlFriendlyId" : "gaim",
"title" : "Gaim 1.3.1",
"description" : "Read about how to Gaim 1.3.1",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://gaim.sourceforge.net/about.php\">Gaim</a>\n<br />\n<br />Gaim is a multi-protocol instant messaging (IM) client for Linux, BSD, MacOS X, and Windows. It is compatible with AIM and ICQ (Oscar protocol), MSN Messenger, Yahoo!, IRC, Jabber, Gadu-Gadu, SILC, GroupWise Messenger, and Zephyr networks.\n<br />\n<br />Gaim users can log in to multiple accounts on multiple IM networks simultaneously. This means that you can be chatting with friends on AOL Instant Messenger, talking to a friend on Yahoo Messenger, and sitting in an IRC channel all at the same time.\n<br />\n<br />Gaim supports many features of the various networks, such as file transfer, away messages, typing notification, and MSN window closing notification. It also goes beyond that and provides many unique features. A few popular features are Buddy Pounces, which give the ability to notify you, send a message, play a sound, or run a program when a specific buddy goes away, signs online, or returns from idle; and plugins, consisting of text replacement, a buddy ticker, extended message notification, iconify on away, spell checking, tabbed conversations, and more.\n<br />\n<br />Gaim runs on a number of platforms, including Windows, Linux, and Qtopia (Sharp Zaurus and iPaq).\n<br />\n<br />Gaim integrates well with GNOME 2 and KDE 3.1's system tray, as well as Windows's own system tray. This allows you to work with Gaim without requiring the buddy list window to be up at all times. <div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-26",
"modifiedOn" : "2005-06-26",
"createDay" : "26",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 19,
"urlFriendlyId" : "google_suggest_beta",
"title" : "Google Suggest - Beta",
"description" : "Read about how to Google Suggest - Beta",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.google.com/webhp?complete=1&amp;hl=en\">Google Suggest - Beta</a> As you type, Google will offer suggestions. Use the arrow keys to navigate the results. <a href=\"http://labs.google.com//suggestfaq.html\">Learn more</a><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-26",
"modifiedOn" : "2005-06-26",
"createDay" : "26",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 18,
"urlFriendlyId" : "7zip",
"title" : "7-Zip (Opensource file archiver)",
"description" : "Read about how to 7-Zip (Opensource file archiver)",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.7-zip.org/\">7-Zip</a>\n<br />7-Zip is a file archiver with high compression ratio.\n<br />\n<br />7-Zip is free software distributed under the GNU LGPL.\n<br />\n<br />The main features of 7-Zip:\n<br />\n<br /> * High compression ratio in new 7z format with LZMA compression\n<br /> * 7-Zip is free software distributed under the GNU LGPL\n<br /> * Supported formats: 7z, ZIP, CAB, RAR, ARJ, GZIP, BZIP2, Z, TAR, CPIO, RPM and DEB\n<br /> * For ZIP and GZIP formats 7-Zip provides compression ratio that is 2-10 % better than ratio provided by PKZip and WinZip\n<br /> * Self-extracting capability for 7z format\n<br /> * Integration with Windows Shell\n<br /> * Powerful File Manager\n<br /> * Powerful command line version\n<br /> * Plugin for FAR Manager\n<br /> * Localizations for 55 languages\n<br /><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-26",
"modifiedOn" : "2005-06-26",
"createDay" : "26",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 17,
"urlFriendlyId" : "anonymizer_free_web_proxy_cgi_proxy_list_free_anonymizers_and_the_list_of_web_anonymizers_list",
"title" : "Anonymizer: free web proxy, CGI proxy list, free anonymizers and the list of web anonymizers list",
"description" : "Read about how to Anonymizer: free web proxy, CGI proxy list, free anonymizers and the list of web anonymizers list",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.freeproxy.ru/en/free_proxy/cgi-proxy.htm\">Anonymizer: free web proxy, CGI proxy list, free anonymizers and the list of web anonymizers list</a> ..... the description says it all!<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-26",
"modifiedOn" : "2005-06-26",
"createDay" : "26",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 16,
"urlFriendlyId" : "myjavaserver_free_java_hosting_service",
"title" : "MyJavaServer - Free Java hosting service",
"description" : "Read about how to MyJavaServer - Free Java hosting service",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.myjavaserver.com/\">MyJavaServer</a>. The free java hosting service. I have utilized this when it used to be known as mycgiserver.com. I must say, you ought to try it, it will only take your time and skill, no money whatsoever. I my early days of testing java online, I created following site <a href=\"http://www.myjavaserver.com/~jmaster\">jMaster</a> ... those golden old university days......<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-26",
"modifiedOn" : "2005-06-26",
"createDay" : "26",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 15,
"urlFriendlyId" : "smartcvs",
"title" : "[SmartCVS]",
"description" : "Read about how to [SmartCVS]",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.smartcvs.com/\">[SmartCVS]</a> Perhaps the best CVS tool that I have used ever. Worth every penny I spend on it! ($70)<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-24",
"modifiedOn" : "2005-06-24",
"createDay" : "24",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ ]
}, {
"id" : 14,
"urlFriendlyId" : "avoiding_java_runtime_exec_method_space_problem",
"title" : "Avoiding Java Runtime exec method space problem",
"description" : "Read about how to Avoiding Java Runtime exec method space problem",
"body" : "<p>Typical way of executing an external process in java is using java.lang.Runtime class' exec method.\n\nIts most comman usage is\n<code>\ngetRuntime().exec(\"c:\\\\somefolder\\\\somecommand.exe\");\n</code>\n</p>\n<p>\nAssume there is a space in the folder, amazingly the above form will work, for instance\n<code>\ngetRuntime().exec(\"c:\\\\some folder\\\\somecommand.exe\");\n</code>\nBut this form will fail if we have two or more consective spaces, for instance\n<code>\ngetRuntime().exec(\"c:\\\\some folder\\\\somecommand.exe\");\n</code>\nIt will raise java.io.IOException.\n<code>\nException in thread \"main\" java.io.IOException: CreateProcess: C:\\some folder\\somecommand.exe error=2\nat java.lang.ProcessImpl.create(Native Method)\nat java.lang.ProcessImpl.(Unknown Source)\nat java.lang.ProcessImpl.start(Unknown Source)\nat java.lang.ProcessBuilder.start(Unknown Source)\nat java.lang.Runtime.exec(Unknown Source)\nat java.lang.Runtime.exec(Unknown Source)\nat java.lang.Runtime.exec(Unknown Source)\n...\n</code>\nIt seems that StringTokenizer used by exec(String) method is minimizing more that one white space to single space.\n</p>\nThe workaround is to create single element array of String holding command and pass it to exec method.\n<code>\nString[] command = new String[1]; //for providing arguments, create multiple elements\ncommand[0] = \"c:\\\\some folder\\\\somecommand.exe\";\ngetRuntime().exec(command);\n</code>\nand this time it works like a charm.\n\nKeep coding in java .... :-)",
"blogSection" : "Main",
"createdOn" : "2005-06-23",
"modifiedOn" : "2005-06-23",
"createDay" : "23",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 13,
"urlFriendlyId" : "affan_blog",
"title" : "Affan's Blog: Sharks ... what about 'em? (Part 1)",
"description" : "Read about how to Affan's Blog: Sharks ... what about 'em? (Part 1)",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://affans.blogspot.com/2005/06/sharks-what-about-em-part-1.html\">Affan's Blog: Sharks ... what about 'em? (Part 1)</a> Here is an interesting article about \"sharks\" ....\n<br />\n<br />Fact 1: Shark is our company's official logo\n<br />Fact 2: Affan is a very good n old friend of mine. He was also my university fellow.\n<br />Fact 3: He happens to be VP in our company :-)\n<br />\n<br />Enjoy,<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-23",
"modifiedOn" : "2005-06-23",
"createDay" : "23",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 12,
"urlFriendlyId" : "fedora_core_4_experience",
"title" : "Fedora Core 4 experience",
"description" : "Read about how to Fedora Core 4 experience",
"body" : "<div style=\"clear:both;\"></div>Today I finally managed to install Fedore Core 4 on my office laptop. When I first logged in, every thing seems same as it was in Fedore Core 3 (except the new default theme Clearlooks), the top panel, the bottom panel and the default background. However, upon closer inspection I have found out that they have introduce two new menus besides Applications; Places and Desktop.<br /><br />Desktop now contains Preferences and System settings sub-menus and it allows you to lock the screen and logout as well.<br /><br />Places contains shortcuts to Home, Desktop, Computer, Connect to Server..., and Search for Files. Out of these the \"Connect to Server...\" is preety useful. It allows you to connect to SSH, FTP, Windows Share, Web Dev etc. from one single dialog box.<br /><br />They have also bundled several useful tools in Fedora Core 4, the one I like best is Native Eclipse 3.1.<br /><br />They are getting better day by day ... and convincing me more and more to minimize the usage of Windoze and increase the usage of Linux in daily course of business.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-23",
"modifiedOn" : "2005-06-23",
"createDay" : "23",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 3,
"name" : "Linux"
}, {
"id" : 5,
"name" : "General"
} ]
}, {
"id" : 11,
"urlFriendlyId" : "divx_6",
"title" : "DivX 6",
"description" : "Read about how to DivX 6",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://download.divx.com/divx/DivXPlay.exe\">DivX 6 Play Bundle</a>\n<br />\n<br />It is now considered to be rival of DVD since it now has capability of menus etc.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-20",
"modifiedOn" : "2005-06-20",
"createDay" : "20",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 4,
"name" : "IT"
} ]
}, {
"id" : 10,
"urlFriendlyId" : "articles_published_on_developer_com",
"title" : "Articles published on developer.com",
"description" : "Read about how to Articles published on developer.com",
"body" : "<div style=\"clear:both;\"></div>Following are the articles of mine that are published on <a href=\"http://www.developer.com\">Developer.com</a><br /><br />\n<br />\n<br /><a href=\"http://www.developer.com/xml/article.php/1380861\">Using XML as an Application-Level Protocol</a><br />\n<br />\n<br /><a href=\"http://www.developer.com/java/ent/article.php/1356891\">A Pattern/Framework for Client/Server Programming in Java</a><br />\n<br />\n<br /><a href=\"http://www.developer.com/java/other/article.php/3109251\">Stopping Your Class from Being Inherited in Java, the Official Way and the Unofficial Way</a> <br />\n<br />\n<br /><a href=\"http://www.developer.com/services/article.php/3443951\">Developing Java Web Services with AXIS</a> <br /><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-18",
"modifiedOn" : "2005-06-18",
"createDay" : "18",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 9,
"urlFriendlyId" : "free_computer_books",
"title" : "Ju Rao's Homepage: Free Computer Books",
"description" : "Read about how to Ju Rao's Homepage: Free Computer Books",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.maththinking.com/boat/booksIndex.html\">Ju Rao's Homepage: Free Computer Books</a>\n<br />\n<br />The best resource of publicly, freely and legally available ebooks on net. I learned a lot from the ebooks refered from this resource.\n<br />\n<br />It does not hosts the books, it provides the links to the original books where they are hosted.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-17",
"modifiedOn" : "2005-06-17",
"createDay" : "17",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ ]
}, {
"id" : 8,
"urlFriendlyId" : "firetune_faster_connection_for_mozilla_firefox",
"title" : "FireTune: Speedup, tweak, optimize and tune Firefox easily - faster browsing, faster surfing - faster connection for Mozilla Firefox",
"description" : "Read about how to FireTune: Speedup, tweak, optimize and tune Firefox easily - faster browsing, faster surfing - faster connection for Mozilla Firefox",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.totalidea.com/freestuff4.htm\">FireTune: Speedup, tweak, optimize and tune Firefox easily - faster browsing, faster surfing - faster connection for Mozilla Firefox</a>\n<br />\n<br />Yes, it works ..... pages are opening up much faster than before. I pick settings Faster Computer/Faster Connection.\n<br />\n<br />Best of all, its free!<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-17",
"modifiedOn" : "2005-06-17",
"createDay" : "17",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ ]
}, {
"id" : 7,
"urlFriendlyId" : "xtra_google_the_best_of_google_on_one_searchable_page",
"title" : "Xtra-Google - The Best of Google on one searchable page",
"description" : "Read about how to Xtra-Google - The Best of Google on one searchable page",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://www.xtragoogle.com/\">Xtra-Google - The Best of Google on one searchable page</a>\n<br />\n<br />Find this page while searching, a definite for googlers :). This page is not associated with Google Inc.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-17",
"modifiedOn" : "2005-06-17",
"createDay" : "17",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ ]
}, {
"id" : 6,
"urlFriendlyId" : "fedora_project_sponsored_by_red_hat",
"title" : "Fedora Project, sponsored by Red Hat",
"description" : "Read about how to Fedora Project, sponsored by Red Hat",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://fedora.redhat.com/\">Fedora Project, sponsored by Red Hat</a> Fedora Core 4 is now available. Once downloaded and installed I'll post my user experience with this new version of Fedora Core.<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-14",
"modifiedOn" : "2005-06-14",
"createDay" : "14",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ ]
}, {
"id" : 5,
"urlFriendlyId" : "dont_hate_the_hacker_hate_the_code",
"title" : "Don't hate the hacker, hate the code",
"description" : "Read about how to Don't hate the hacker, hate the code",
"body" : "<div style=\"clear:both;\"></div>Whoever said that, I totally agree with it. Writing code that doesn't break is an ethical responsiblity of every coder.\n<br />\n<br />I think to achive this, a coder has to think like a code breaker .... and how to think like a code breaker .... well you should be able to break code of others .... and ultimately yours own!<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-13",
"modifiedOn" : "2005-06-13",
"createDay" : "13",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ ]
}, {
"id" : 4,
"urlFriendlyId" : "orkut_more_annoyance_than_comfort",
"title" : "Orkut..More annoyance than comfort",
"description" : "Read about how to Orkut..More annoyance than comfort",
"body" : "<div style=\"clear:both;\"></div><a href=\"http://orkut.com/\">Orkut</a> .... Orkut proves that .NET is crashing when it is being loaded .... enormously ....<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-13",
"modifiedOn" : "2005-06-13",
"createDay" : "13",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ ]
}, {
"id" : 3,
"urlFriendlyId" : "interesting_java_program",
"title" : "Interesting Java program",
"description" : "Read about how to Interesting Java program",
"body" : "<div style=\"clear:both;\"></div><span style=\"font-size:100%;\"><br />This is perhaps the most interesting java behavior that I have encountered. Try to guess the output before actually compiling it and running it.<br /></span><br /><span style=\"font-size:85%;\">public class Guess {<br />public static void main(String args[]) {<br />for(int i=0;i<=args.length;i++){<br />System.out.println(args[i]);<br />}<br />}</span><br /><span style=\"font-size:100%;\">Run this program as follows:</span><br /><span style=\"font-size:85%;\">>java Guess *</span><br /><span style=\"font-size:100%;\"><br />If you think that program will produce * as output, then you are wrong my brother, you need to try it out yourself :)<br /><br />--Uzi<br /></span><div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-09",
"modifiedOn" : "2005-06-09",
"createDay" : "09",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 1,
"name" : "Java"
} ]
}, {
"id" : 2,
"urlFriendlyId" : "wrapper_over_runas_utility",
"title" : "Wrapper over runas utility",
"description" : "Read about how to Wrapper over runas utility",
"body" : "<div style=\"clear:both;\"></div>Runas is a useful Windows utility that allows to run programs as different users. But this utility can not be executed from batch files (password cannot be piped). Hence I comeup with my own program which is a wrapper over runas and it is scriptable.<br /><br />This is achived by utilizing another C++ class SendKeys, which I downloaded from <a href=\"http://www.codeproject.com/cpp/sendkeys_cpp_Article.asp\">http://www.codeproject.com/cpp/sendkeys_cpp_Article.asp</a> . This is a useful piece of code that allows to \"send keys\" to another active application.<br /><br />Here is the code sample how I achieve this:<br /><br /><span style=\"font-size:78%;\">CSendKeys sk; </span><br /><span style=\"font-size:78%;\">//create runas process </span><br /><span style=\"font-size:78%;\">STARTUPINFO si; </span><br /><span style=\"font-size:78%;\">PROCESS_INFORMATION pi;<br />ZeroMemory( &si, sizeof(si) ); </span><br /><span style=\"font-size:78%;\">si.cb = sizeof(si); </span><br /><span style=\"font-size:78%;\">ZeroMemory( &pi, sizeof(pi) );</span><br /><br /><span style=\"font-size:78%;\">if( !CreateProcess( NULL, // No module name (use command line). </span><br /><span style=\"font-size:78%;\">(LPTSTR)(LPCTSTR)runas , // Command line. runas is like \"c:\\\\windows\\\\system32\\\\runas.exe /env /user:user command\"</span><br /><span style=\"font-size:78%;\">NULL, // Process handle not inheritable. </span><br /><span style=\"font-size:78%;\">NULL, // Thread handle not inheritable. </span><br /><span style=\"font-size:78%;\">FALSE, // Set handle inheritance to FALSE. </span><br /><span style=\"font-size:78%;\">CREATE_NEW_CONSOLE,// Openup process in a new console </span><br /><span style=\"font-size:78%;\">NULL, // Use parent's environment block. </span><br /><span style=\"font-size:78%;\">NULL, // Use parent's starting directory. </span><br /><span style=\"font-size:78%;\">&si, // Pointer to STARTUPINFO structure. </span><br /><span style=\"font-size:78%;\"> &pi ) // Pointer to PROCESS_INFORMATION structure. ) { </span><br /><span style=\"font-size:78%;\"> cerr << \"CreateProcess failed:\" <<><br /><span style=\"font-size:78%;\"> return -1; </span><br /><span style=\"font-size:78%;\"> } </span><br /><span style=\"font-size:78%;\">WaitForInputIdle(pi.hProcess,INFINITE);<br />//activate it using sk </span><br /><span style=\"font-size:78%;\">sk.AppActivate((LPCTSTR)runasPath); </span><br /><span style=\"font-size:78%;\"></span><br /><span style=\"font-size:78%;\">//pass password (I pick it up from command line)</span><br /><span style=\"font-size:78%;\">pass = pass + \"{ENTER}\"; </span><br /><span style=\"font-size:78%;\">sk.SendKeys(pass);<br /></span><br /><span style=\"font-size:78%;\">// Wait until child process exits. (make it an argument?) </span><br /><span style=\"font-size:78%;\">WaitForSingleObject( pi.hProcess, INFINITE );<br /></span><br /><span style=\"font-size:78%;\">// Close process and thread handles. </span><br /><span style=\"font-size:78%;\">CloseHandle( pi.hProcess ); </span><br /><span style=\"font-size:78%;\">CloseHandle( pi.hThread );</span><br /><span style=\"font-size:78%;\"></span><br />This program can be called (from a .bat file, for example) RunAsAnotherUser username password command.<br /><br />Cheerz,<br /><br />--Uzi<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-09",
"modifiedOn" : "2005-06-09",
"createDay" : "09",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ ]
}, {
"id" : 1,
"urlFriendlyId" : "first_post_finally",
"title" : "First Post, finally",
"description" : "Read about how to First Post, finally",
"body" : "<div style=\"clear:both;\"></div>This is the first post I am making on blogger....I hope this will grow as time passes...<div style=\"clear:both; padding-bottom:0.25em\"></div>",
"blogSection" : "Main",
"createdOn" : "2005-06-09",
"modifiedOn" : "2005-06-09",
"createDay" : "09",
"createMonth" : "Jun",
"createYear" : "2005",
"categories" : [ {
"id" : 5,
"name" : "General"
} ]
} ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment