Top Posts in Python
Linux Rename Multiple Files Extension
In unix environment, mv is the command to move files and we can use it to change file extension also. But it works with a single file only and it doesn’t take wild characters also.
Here I am providing a simple script that you can use to change extension of multiple files in a directory.
Queue Implementation in Java using Array
Queue is a special type of collection designed to hold elements before processing and order elements in a FIFO (first-in-first-out) manner.
Here I am trying to implement Queue with Object Array and provides basic functionalities like enqueue(obj), dequeue() and isEmpty().
How to implement ArrayList with Array in Java
ArrayList is similar to Object Array but provides the feature of dynamic space allocation when the number of objects in the list grows. In Object Array we need to provide the size at the time of initialization but that is not required for ArrayList. Actually when you initialize ArrayList, it automatically assigns its capacity to 10.
Here I am trying to implement ArrayList with Object Array and provide basic functions i.e get(index), add(object) and remove(index).
JiBX is a very powerful framework for converting XML data to java object and vice versa. It is very useful in applications integration where XML is the format for data transfer, for example, Web Services and Legacy Systems Integration based on Message Oriented Model (MOM).
Converting Java Object in to XML is called Marshalling and creating java object from XML is called un-marshalling. There are many frameworks available for XML transformation such as JAXB and XMLBeans but JiBX differs in the approach for XML binding and transformation process. JiBX performs these tasks via utility classes generated at compile time via ant scripts. This approach reduces the processing time by moving away from the traditional two-step process with other parsers to a single step.
Benchmarks done on various XML binding tools have shown JiBX as the fastest and the most memory efficient parsing framework till date.
Here I am providing a sample application for XML transformation using JiBX parser.
Java XML Formatter
eXtensive Markup Language (XML) is one of the popular medium for messaging and communication between different applications. Since XML is open source and provides control over data format via DTD and XSDs, it’s widely used across technologies.
Few days back, I came across a situation where the third party API was returning Document object and XML message as String. So I wrote this simple XmlFormatter class to format the XML with proper indentation and convert Document object to XML String.
Java Object clone() Method – Cloning in Java
Java Object class comes with native clone() method that returns the copy of the existing instance. To use java cloning, all you need is to implement the marker interface java.lang.Cloneable so that it won’t throw CloneNotSupportedException at runtime.
So if clone() function returns the object copy, why do we need to over-write it and in which cases?
How to Change App icon in Mac
In Mac OS, all the applications have .app extension but it ships in the form of a zip file. So you can easily check the contents of any application.
The application icon is actually an icon file with .icns extension stored in the application. To change the icon of application, you need to find out the existing icon file and then replace it with the desired one. For example, here I am changing Firefox icon to some other icon.
How to Install Memcached Server on Windows as Service
In my earlier posts, I explained how to install memcached server on *nix and Mac OS systems. Today I will explain how to install memcached server on Windows operating system.
To install Memcached Server on Windows, we need to have its exe or batch process but memcached server was written for *nix operating system and you can’t get a Windows version from memcached server official website.
The problem is solved by Jellycan Code and they provide the Win32 version in binary format that can be used to install memcached server on Windows.
Memcached Java Client Example
In my previous post, I listed down most common telnet commands for memcached with sample execution terminal logs. Today I want to discuss about the Memcached Client program available in Java language.
There are three most widely used memcached client programs in java
3. gwhalin memcached client
I have used Greg Whalin memcached client and found it easy to understand and use. It provides all the basic functionalities with thread pooling. Its available under BSD license and you can download it from below URL:
Memcached Telnet Commands Example
In earlier posts, we saw how to install memcached server on Mac OS and Unix systems. After that we worked on it to start at boot time as a daemon process in Mac OS. Today, we will go through some of the basic memcached telnet commands that we can use to check the health of memcached server. These commands are very helpful in debugging purpose and can be used from any operating system with telnet installed.
If you are on unix system, then using “ps -eaf | grep memcached” command you can check the port on which its running.