Postagens

Understanding Visitor Pattern

Imagem
In Object Oriented Design, the visitor patter is one of the obscure pattern yet powerful enough to solve many complex OO scenarios. Visitor Pattern is also not really easy to understand at the first glance but you need to dig it around with practical examples. (I guess it’s not just for Visitor pattern but also for all the other patterns) I would like to give a clean and simple introduction to visitor pattern with this post. So let’s start with a simple example ofthe usage of Visitor pattern. Visitor Pattern is often useful when there are fair numbers of related classes. One of the common examples of such a scenario is ‘drawing different shapes’. In this case we have a set of related classes; Circle, Trangle, Rectangle etc. Now, if we are going to implement a draw() function for all these classes i.e. circle::draw(), trangle::draw().. etc we may be drawing different shapes but we are replicating a fair amount of code in all the classes. (Because the underlying methods, that we use to d...

Image transferring on Ubuntu 9.10 - gPhoto2 as Nikon Transfer

Imagem
When dealing with multimedia devices Ubuntu becomes a nightmare as most of the devices does not offer you the Ubuntu compatibility. The story was the same for my Nikon Digital Camera transfer tools. I badly wanted to transfer images from my camera to my computer and found out that Ubuntu doesn't allow me to transfer the images. Finally gPhoto2 came to save me and it is a nice tool that allows you to transfer all your images from your cam to pc. This is what I did. Install gphoto2. (simply use the package manager) Unmount the device(camera) if mounted automatically. Open a terminal and go to the location that you want to store the images. Then do : gphoto2 --get-all-files For more information do : gphoto2 --usage That's all. By the way.. I know this is not a very user friendly way but after all as an Ubuntu user.. this is not an alien thing to use command line to transfer images :).

iTunes on Ubuntu - Songbird 1.4.3

Imagem
Missing iTunes on Ubuntu ? I have completely moved from Windows to Ubuntu 9.10 during last 3-4 months, and now I have alternatives for almost all the application I used to run on Windows. However, I'm missing iTunes so badly and couldn't find an attractive media player for Ubuntu till I came across Songbird . A few days back I downloaded their latest release( Songbird 1.4.3, Build 1438) and really feel happy about the user interface and the features. I feel like I'm using iTunes on Ubuntu.(apparently the Songbird plugin for iPod support seems broken so I have to user gtkpod for manage iPod on Ubuntu ) For those who are new to Songbird, it is a free and open source software audio player (and web browser too) which was founded by Rob Lord. Songbird utilizes the cross-platform frameworks, Mozilla's XULRunner and GStreamer media framework, and capable of running on Microsoft Windows, Mac OS X, and various Linux flavors(Ubuntu, Fedora). When we compare Songbird 1.4.3 with...

Real-time XML Syntax Highlighter in Javascript - EditArea

If you are looking for a Real-time XML Syntax Highlighter and in the same time you want it as a web based lightweight tool then EditArea is the perfect solution for that. In WSO2 ESB 3.0.0(up coming release) , I've integrated all the source(xml) fields with EditArea highlighter to give the use a real-time rich xml editing experience. However, the original highlighter comes with some dull colors for XML Syntax as well as for controllers. So, I modified the EditArea source and came up something like this. (It takes few seconds to load..;)) EditArea support syntax highlighting not only in XML but many other programming languages including Java,PHP, C/C++, CSS, Perl, Ruby, Python and many more. I have hosted a modified version of EditArea which supports Real-time XML Syntax Highlighting here . So, EditArea is one of the rear opensource tool that is specifically designed to support Real-time syntax highlighting for most of the popular programming languages and yet it runs with its ext...

Preserving CDATA sections - AXIOM StAX parsing

In XML CDATA sections provide a way to tell the parser that there is no markup in the characters contained by the CDATA section. And that makes it much easier to create documents containing sections where markup characters might appear, but where no markup is intended. CDATA is commonly used for scripting language content and sample XML/HTML content. So in context of Web Services with Apache Axis, the default settings of the AXIOM StAX parser would ignore the CDATA sections and won't preserve them after the parsing is done. In coalescing mode, the parser will not only coalescing adjacent text nodes, but also CDATA sections. However there are cases that you need to preserve CDATA section after parsing and creating OMElement. So, in such a scenario you need to switch off the coalescing mode by setting a property in XMLInputFactory. (i.e.: "javax.xml.stream.isCoalescing" = false). The following code will create an AXIOM OMElement with preserving CDATA. For detailed overview...

Modularity in Software Engineering

Imagem
What is Modularity 'Modularity' - a frequently used term in Software Engineering. Its often tends to feel that our Software System is modular owing to that of the physical and logical structure of the system. We often distinguish interfaces and their implementations, abstracting the functionality behind the interfaces, grouping classes and interfaces under packages based on their functionality etc. Those techniques are really cool and they are the real drivers of modular software, but unfortunately modularity could not be achieved just by applying such techniques. Modularity is software engineering is based on few fundamental concepts. Self-Contained : "Agile & Autonomous" A module is a self-contained component of a larger software system. This doesn't mean that it is an atomic component. In fact a module consists a several smaller pieces which are collectively contributed to the functionality/performance of the module. We cannot remove or modify at least any ...

Restoring Grub2 on Ubuntu 9.10

It's often required to have a dual boot on any machine owing to the compatibility of the application software. I recently came across a real messy scenario where had to install Windows several times on my Ubuntu/XP dual-boot system. This is a bit risky case for two reasons. Ubuntu 9.10 comes with Grub2 and conventional Grub restoring methods would not be applicable and also Windows 2008-sp1 is know to be a very restricted OS with huge amount of security features. However, I managed to restore everything after installing Win 2008. Here are the steps that I followed. Following procedure will be valid on Ubuntu 9.10/Win XP, Vista, 2008, 7 You need the Ubuntu 9.10 live CD Boot from live CD Go to 'System->Administration -> Disk Utility' Find out the partition that you install Ubuntu (root). eg. 'sda4' Then open a terminal and mount the partition that you found above. ' sudo mount /dev/sdXY /mn t ' where X - Device Descriptor and Y-Partition Id ' sudo g...