Monday, 26 October 2009

NextIT Strategies

Its been quite a time, programming in C++,VB, ASP.Net, Java and most of contemporaries. So it was time to call off coding and to go further in design of systems. While pursuing Masters in LSE-London, the only “sub-subject” I loved was IT strategy. This was something quite close to my interests after couple of years of coding. So now after few months of graduating, I had a look at what are future technologies IT-execs are looking at. So I came across this page, showing important strategic technologies.


1. Virtualization
2. Cloud Computing
3. Servers – Beyond Blades
4. Web Oriented Architectures
5. Enterprise Mashups
6. Specialised Systems
7. Social Software and Systems
8. Unified Communication
9. Business Intelligence
10. Green IT


Well, all certainly look futuristic. From Virtualization to Green IT, strategies are in direction of minimal usages(power, space, resources) and maximum output. I thought to have a look on few. Many organizations, one like IBM has started quickly gearing up towards BI and forming different knowledge grids which can be used for developing better e-governing systems. Green IT among all these seems to be the need of hour as well as good branding strategy. As you watch news indicating dangers of consumption of large amount of energies, it becomes inevitable for IT execs to consider this strategy and start mulling over it. Data centers are quite the first point to start with. Though I am all ears to hear Cloud Computing(SaaS, PaaS, IaaS) noise, but it seems that large organizations will watch its acceptance by SME’s first and will not enter during its infancy. Though few like Sungard has already adopted and delivered systems on these models, it’s still some time to scale on it. Cloud Computing is though, bound to be pervasive in near future. Enterprise Mashups, are already in market since the inception of social networking sites. The road ahead certainly looks, and seems to be good playground for Strategic players as it was for developers in last couple of decades.

Thursday, 13 August 2009

Bhuvan Launched


Well, Bhuvan is getting launched again. No not from Lagaan-II but from ISRO. Bhuvan(Earth in Sanskrit),is a satellite mapping tool similar to Google Earth and Wikimapia. It was developed by Indian Space Research Organisation (ISRO). It offers resolution up to 5 metres and is considered as a rival to Google Earth and Wikimapia.

A beta version of this application http://bhuvan.nrsc.gov.in/ has been launched on 12th August 2009.Bhuvan will be able to take more closer pictures of the Indian Subcontinent as compared to the Google Earth. Bhuvan will feature a zoom level of upto 10 meters while the Google Earth features a zoom level of up to 200 meters. The new ISRO Bhuvan will also feature a multi layer information mapping while the present Google Earth features a single layer information mapping system. Apart from that, Bhuvan will also update map information every year contrary to the Google Earth which updates its map information every 4 years.

“With Bhuvan we will be able to produce very local information which will be specific to only to our own country. This information available from this mapping system will be useful in addressing very local problems like floods, famines, infrastructure development, education and much more,” said ISRO chairman Dr G Madhavan Nair.

Also I found this information of Bhuvan plug-in available from one of the sites. You can download plug-in from the Bhuvan website after registration and you will also need DirectX8 or higher version (www.microsoft.com/windows/directx/) for installing the plug-in. Mac OS and Linux users will have to wait till next launch as at the moment Bhuvan can run only on windows system and is optimised for IE6 or higher.

Though I haven't tried yet as Bhuvan got a heavy load, it seems. However, Its a proud moment for Indians and ya, for Aamir Khan too!!!!

Saturday, 8 August 2009

Religion of Reasons - Please research

Wow what a morning its been!! As I read SundayTimes article "Religion of Reason"(http://lite.epaper.timesofindia.com/getpage.aspx?edlabel=TOIA&pubLabel=TOI&pageid=14&mydateHid=09-08-2009) , I get to know that Atheist community catching up in London. Over 200 buses with hoardings of "there's probably no God, So enjoy Life"....It just quirked a smile from my face as I thought "Oh Ya and when you cannot enjoy, come to God running again!!!"

Article at various instances point out that a person may pray but they could be Atheist. It states that certain religions encourage atheism. Now thats quite amusing. As per Prakash Shesh, whole of Jain or Buddhist or Hindu philosophers community are atheists because they have denied the belief of existence of God. I would ask Prakash Shesh to go over Jainism or Hindu philosophy first, it states that we are actually manifestations of cosmic energy and we do have energy stored within us, in chakras of body and in soul matter, but we don't deny existence of souls who have already attained it. Prakash has misinterpreted indian religions in their philosophical sense. Religions preach us to attain supreme self-realisation through penance, through rituals and through devotion to God(who are supreme souls if not creator of universe), which are actually the processes of attaining, exploring or activating or searching(as per Prakash) our energy and taking it to peak. Its like a chicken and egg story, though we have energy within us, in order to attain self-realisation or be free from birth-death cycle we should be devoted to souls who have traversed the path. We are same as those souls but not as self-realised as them. Hoardings on the bus say "Atheism can be the rejection of theism or the absence of belief in existence of deities"...Now how can you reject theism if you believe in existence of deities??

Atheism in real sense is complete denial of existence of God. But the word 'God' here, is misconstrued as only being creator of universe. God in real sense is a supreme soul who guides us to attain Moksha through various paths. Atheists are people who only believe in rationalism. They only believe in logical life, though life doesn't manifest in logical way every time. Cosmos is real, souls are real, karma associated with them is real and energy within is also real,but explanation for the same is not logical. But Blog space is small to explain that. Finally, I strongly object various references pointed towards certain religions without researching and tagging Atheist to actually who are not.

Friday, 7 August 2009

Future Directions of Computing - II

Next set of technologies are related to life sciences and would be taking paramount importance in future.

Here comes Chemical Computing
Chemical computing is an unconventional approach to computation that uses a "soup" where data is represented by different concentrations of chemicals. Chemical computers can exploit several different kinds of reaction to carry out the computation. For example, so-called conformation computers use polymer molecules that change shape in response to a particular input. Metabolic computing exploits the kinds of reactions typically found inside a living cell.
Dr Andrew Adamatzky of the University of West England works on another type. "I am dealing only with reaction-diffusion computing," he explains. This type of computation exploits waves travelling through a beaker of chemicals to carry out useful calculations.
These waves are the information carriers in the computer. They are created by triggering chemical reactions in the soup at specific points. As waves propagate from different areas they collide and interact - effectively processing the information they hold. At the site of their interaction a point with a new chemical concentration is created, which is in effect an answer.
With a beaker full of thousands of waves travelling and interacting with each other, complex computational problems can be solved. Quite Interesting, ain't it? Now I know its quite difficult to assimilate those things, but its real and IBM is already into it. Lets not be amazed when it shows up in future.

Next is my favourite, DNA Computing
DNA computing, commonly called biomolecular computing, is an emerging field that uses DNA and biochemistry instead of silicon-based electronics. The first proof-of-concept use of DNA to perform computation was carried out by Professor Leonard Adleman at the University of Southern California in 1994. The original goal of the field was to use biomolecules to beat electronic computers at solving large complex problems. But most of scientists refuse to believe that so the goal has been changed to do unconventional things that silicon cannot. In particular Shapiro is trying to develop smart drugs that are capable of computation. "You want a drug that can sense the biochemical environment, analyse it and, in response, release a molecule which is the appropriate drug for that particular situation," he said. Very useful indeed, I thought it could apply somewhere in complex computations and then get in touch with financial and scientific systems. There's where my curiousity for it emerged.

The final future front is Plastics Computing
Silicon is expensive and complex to produce, requiring clean rooms and precise manufacturing techniques in plants that can cost billions of dollars. This means they are currently out of reach for low-cost products. But organic polymers, a class of substances that are used to make everything from bin bags to solar panels, could offer a solution. "It really opens up a whole new set of options for what you do with electronics," said Professor Art Ramirez of Bell Labs. Highly conductive polymers were first discovered in the early 1960s and are already used in some electronic devices. In 2004, electronics giant Philips announced a concept flexible display, while other companies such as Cambridge Display Technology use them to manufacture organic light-emitting diodes (LEDs). Earlier this year, UK firm Plastic Logic said that it would build the world's first factory to produce plastic electronic circuits. Although, circuits made of polymers are much slower than silicon devices, they have one significant advantage: they can be printed using techniques similar to those used to mass produce magazines and wallpaper. This means they are cheap and easy to produce. And as the polymers can be printed onto flexible substrates they can also be used in totally new types of device, such as large-scale billboards or electronic newspapers.
Wow, Imagining picking up electronic newspapers is like having papers from Hogwartz.

So, this was a brief about six upcoming future computing to keep an eye on...lets see what catches up faster!!!

Future Directions of Computing - I

What and how many could be it ?
Well, Here's the first one - Quantum Computing
A quantum computer is a theoretical device that would make use of the properties of quantum mechanics, the realm of physics that deals with energy and matter at atomic scales. In a quantum computer data is not processed by electrons passing through transistors, as is the case in today's computers, but by caged atoms known as quantum bits or Qubits. A bit is a simple unit of information that is represented by a "1" or a "0" in a conventional electronic computer. A qubit can also represent a "1" or a "0" but crucially can be both at the same time - known as a superposition. This allows a quantum computer to work through many problems and arrive at their solutions simultaneously. "It is like massively parallel processing but in one piece of hardware," said Professor Artur Ekert of the University of Oxford. Further he said,
"They will not be used in run-of-the-mill desktop applications but specialist uses such as searching vast databases, creating uncrackable ciphers or simulating the atomic structures of substances. "

Now how about Light Computing -
"We are dissipating huge amounts of power in chips right now," said Professor Stan Williams of computer firm Hewlett Packard. And the problem will get worse as the components become smaller, making chips even more inefficient, he said. "If we could find new ways of moving information around a chip, we could significantly reduce the amount of power that is dissipated."
A potential solution would be to use particles of light - photons - instead of electrons to move information around and between chips. "Electrons will still be doing the computing but photons will be doing the communicating," he said. It is similar to the technology that is used to move data around the internet today but at a much smaller scale. The technology could be key for transferring data between massively multiple core chips - devices with several linked computing engines.

Next comes Spin Computing
Spintronics, also known as magnetoelectronics, is a technology that harnesses the spin of particles, a property ignored by conventional electronics. By using the spin of particles - detected as a weak magnetic force - scientists believe they can unlock almost infinite computing power.
"An electron always has spin and it can be spinning one of two different ways: up or down."said Mr Roche. These two different states can be used to represent a "1" or a "0" - the bits of information used by all computers. Basic spintronic devices are already used in today's computers. For example, most hard drives today use a "spin valve", a device that reads information off the individual disks or platters that make up a hard drive. But researchers at firms such as Intel and IBM are hoping to take this one stage further. "We are hoping to use it to store data, to transmit data; to do all the things we do now with charge but to use the spin property of the electron instead," said Mr Roche. Chips exploiting spintronics would in theory be able to transmit data with spin using a lot less charge.

Well its enough for one post...there are other three remaining >>>

Wednesday, 5 August 2009

Next Generation Trading Systems

At the turn of century, when technological innovation in financial domain is touching its peak I was wondering about the next generation innovation. When I watch movies like Minority Report, I understand there is ample window of innovation left in our day-to-day lives . But when I think about financial domain especially trading systems in various markets across number of asset classes, it points me towards thin window left. There are couple of reasons for reckoning like this. Firstly, financial technological innovation was among first software services that picked up in 70s. Secondly, companies in India have already started moving more towards life-sciences projects. TCS CEO Ramadorai said in an Interview that financial systems innovation is now more about sustenance rather than innovation. Also while going through this thoughts I came across a article from product manager of Sungard, Erricson Potus, on Next Generation Trading Systems.

He observed that, the current focus for vendors is the development of cross-asset trading systems. The demand for these systems was simply not there in the early 1990s when firms operated in strict, self-contained silos. The equities team traded equities from its equities desk and the same for the fixed income team. Consequently each desk used different trading systems. But at around the turn of the millennium, as the derivatives market continued to grow, financial institutions’ customers began to form crossasset derivatives platforms where traders were no longer restricted to single asset classes and
were dealing with all types of instruments. In addition, a sharp increase in the number of hedge funds operating as proprietary trading desks acted as another catalyst in the demand for cross-asset trading systems.

He outlined number of building blocks that would be necessary for development of next generation trading systems.

· Robust system infrastructure and the ability to store a vast array of financial and market data that can be used for risk management purposes.
· A complete lifecycle management capability
· A consistent and flexible pricing framework that can cater for today’s heterogeneous, cross-asset trading environment and the constant innovation in financial products, especially in the credit, interest rate derivatives and structured products area.
· An open architecture with good integration capabilities to other in-house systems, execution venues, broker-dealers, documentation systems and data providers to name a few examples.
· A strong platform to cater for the use of a wide range of individual asset classes, OTC, electronic trading and high-volume FX/MM trading, plain vanilla contracts mixed with complex derivatives, all incorporated into a greater cross-asset solution.
· A desktop that displays full risk management and P&L information.
· Full integration with key market players in the trading space such as Bloomberg, Reuters and Markit.

While above are the thoughts of pointing towards a system that involves integrating the systems on various parameters and projecting a seamless performance, the other thoughts can be on to moving on mobile systems or systems developed through DNA computing. The market players have already sent out the products on mobile but haven’t heard much on DNA computing contribution towards it. But this would be worth watching on how it evolves if DNA computing picks up and systems migration towards it.

Thursday, 30 July 2009

Imagining India

I am writing about the book which I am currently reading. As it is quite a long book, one post wouldn’t suffice. It’s book about India, past present and future. The title goes “Imagining India”. Nilekani has done a detailed research on how past demographics, freedom struggle and politics have shaped the present of india and pointing towards incredible future. How everything suddenly have started to point in right direction. Human Capital, Politics, Mindset and Demographics all pointing towards shaping India into Super power. But he cautiously maintains that if this dimensions(more so with Human Capital) are not managed, the same will back fire into us.

On Human capital book mentions, it’s interesting to note how the current population which was supposedly called overpopulated during emergency days is going to serve as a major factor in our role as super power in world. China and India have been most populous states from early 19th century and remained so during post independence years. China foreseeing the population problem, started to cure it by levying heavy taxes on populous family and by advertising contraceptive measures in 60s. China being authoritarian country was easily able to get through its point to people. While India being a democratic country was taking its time. The time taken became too heavy to curb the problem. It went on to extent that Emergency was declared in 1975 and people were ruthlessly given contraceptive treatment. Instances of Sanjay Gandhi's wielding of powers and his influence on his mother are also stated in book. During those days, major countries feared that India would gobble up ¼ th of food of the world. It was also decided that Pakistan be given food but not India. Such was the condition that we were neck deep in the debt from World Bank and India was on brink of bankruptcy. But somehow the condition remained floating and we were able to come out of that black time. Today this same population has become the driving force in economy and Indians are favoured all over the world in IT industry. The reasons for this human capital lay in the past and book depicts that in a very analytical manner.

Nandan mentions how he and his father were influenced by Nehruvian ideas of making India educated and put it in same cup as British. Though early leaders hated idea of capitalism but Nehru all the way favored it, though not openly. Nehru was first to bring English in India as official language. Indian demographics being divided majorly in two kinds of scripts, Aryan(North-Indian) and Dravidian(South- Indian), It was becoming impossible to decide which language to adopt as national language. Confronting this situation with introduction of English language was one of first achievements of Nehru. This early adoption of English language has helped India in modern world leaving China behind in competition.

There are similar detailed and analytical description on how our past shaped present and how we will have to take the road ahead. Though I am just in between reading first part of the book, I am quite interested and hooked on to know what lies ahead.

Thursday, 25 June 2009

मी शिवाजीराव भोसले बोलतो आहे


The last Marathi movie I watched was Dombivali Express and the next was “Mi Shivaji Rao Bhosle bolto aahe” Dombivali Express was good but this was…good effort man!!! This is must watch for most part of Maharashtri people. The limitations in mindset of Marathi people are neatly drawn and portrayed. Most of them being of non-Business background and of quite simple public life, Marathi people feel helpless at not getting their point at places of importance. Business life makes a person to bend or break rules in order to get his/her way which most of Marathis don’t favour. Most of them tend to live in oblivion mode that if they are good, they will be treated good resulting in content nature. While other communities like Gujarati and Punjabi are quite dynamic and of flexible nature which enables them to expand and prosper. Though things have changed in modern times and Indian youth(be Marathi or Gujarati or any other community) are experimenting non-conventional careers and professional life, still the parents of today’s Marathi youth are bit reluctant to try non-conventional fields.

The movie is story about Marathi person who is unable to resist government and corporate forces trying to bring down his ancestral home in Mumbai and giving him a flat in far suburb in Mumbai. Also his son and daughter are not able to move forward in their career as they don’t have strong backing like a Khanna or Patel family. Intially, he gets frustrated at not able to do anything and drowns himself in liquor. Mahesh Manjrekar who plays Shivaji Rao, then comes to his rescue his downfall and recoup the energy. Rebuking him and then inspiring him to raise his self-esteem, Shivaji instructs him to take some big steps forward that can serve as profound example to other Marathi people.

Movie shows how diversity in our country can be useful and every community has something to give. I enjoyed the movie especially the dialogue delivery by Mahesh Manjrekar.

Thursday, 4 June 2009

Continuous Trade Matching Algorithm

If someone wants to go through various OMA(Order Matching Algorithm), one can start with the basic one below from BSE. This is what I worked with during my previous job tenure.
Continuous Trade Matching Algorithm
Intro
If an order arrives in the order book of a security, it may immediately match with a counter-order should the principle of price and time priority allow matching. If the order cannot match, it remains in the order book.
The incoming bid (sequence no.8) matches orders no.6 and 4 as shown below:



Market order in MMTS I (Cash market)
An incoming market order (with no price specified) will match against opposite orders at the best price level only.
The incoming offer (sequence no.9) matches against order no.8 as shown below:
Price - 5645
Traded Volume - 25

The unmatched, residual quantity (15) of order no.9 is withdrawn from the order book.


Market order in MMTS II (Derivative and Commodities markets):

An incoming market order (with no price specified) will match against opposite orders not only at the best price level but at subsequent price levels as well.


The incoming market sell order (sequence no.9) matches against orders at three different price levels as shown below:
Price Traded volume
5645 25
5630 10
5625 5

The incoming market order matches buy orders no.8, 2 and 1 at the limit prices of the orders. In case of order no.1 the unmatched, residual quantity (10) remains in the order book.
The difference between two markets should be noted. That should be it for now.

Saturday, 30 May 2009

Wise and Otherwise

Today I am writing about a book which is worth reading for people from all age-groups. A book, simply with human touch from our daily life. A book with 51 small stories from one of leading icons from India. Its “Wise and Otherwise”. I came across this book when I was about to travel from Pune to Bangalore which is about 17 hours journey by bus. I thought to buy a book(not too heavy not too light) for my travel, so that I could ward off my boring time. On one of the roadside shops in Pune, I saw this book(not too heavy not too light) and the author name underneath, it was by Sudha Murthy.

The name itself gave me the interest shoot-ups to buy the book. I have always been impressed by iconic figures like Narayan Murthy who started from modest conditions to lead one of indigenious software companies of India. More so, I have been impressed by equally potent lady who stood by him during all this time. They are kind of ideal couple to me. A socialist-bright-bespectacled man wanting to help people either through politics or business backed by equally intelligent wife who invests her first savings into his fledgling business and gives up her career allowing him to chase the dreams. Quite amazing!!!

Anyways returning to the book, I picked it up and ruffled through pages to check whether they are in good condition. And I readily decided to buy it. On the date of journey, I boarded the bus in evening which was about to reach Bangalore next day at around noon. I opened the book as soon as bus started. After few mins, Bhool bhulaiya started playing in coach. But the book was too interesting to see the movie.

The book is coveted with 51 experiences throughout her life. Each of the stories have taken place in small moments and teachings they portray, add big meaning to life. There are many heart touching stories as well some funny instances.

Below are few highlights:
A story about a poor and intelligent boy financially helped by Mrs.Murthy during her school years, pays her back the extra money that are left at the end of his education shows the degree of honesty in boy. Or a story of man who dumps his father with Infosys charitable organization lying to Sudha that he picked up this man on roadside and wants to put him with her organization for further care showing the cruelty that exists in today’s world. There are also funny instances when a marketing person enters Sudha’s Office and starts bluffing(unaware of the fact that he standing in front of Sudha Murthy) that he knows Narayan and Sudha murthy from childhood. He goes on to further length stating that it was he who helped tie a knot between couple. At the end Sudha gives him sound chiding and asks him to get out. Many more like this….

I just loved reading the book as if I am eating an icecream. No heavy words, no heavy doses just light moments that matters lot in life.

Saturday, 25 April 2009

Getting mp3 files from directories

Quite useful if you want to find mp3 files from directory recursively. I used while developing CMS for my company. Getting Podcast libraries is important.

#!/usr/bin/perl -w
use strict;
use MP3::PodcastFetch::TagManager;
use File::Basename;
sub recurse($)
{
my($path) = @_;
my $duration=0;
my $ftype= "";
my $manager = MP3::PodcastFetch::TagManager->new();
my $filename="";
$path .= '/' if($path !~ /\/$/);
print $path,"\n";
## loop through the files contained in the directory
for my $eachFile (glob($path.'*')) {
## if the file is a directory
if( -d $eachFile)
{
recurse($eachFile);
}
else
{
($filename, undef, $ftype) = fileparse($eachFile,qr"\..*");
$filename =~ s/_+/ /g;
print "$ftype
\n";
if ($ftype eq ".mp3")
{
if($eachFile =~ m/GUID/)
{ ## print the file ... tabbed for readability
my $filesize = -s $eachFile;
$duration = $manager->get_duration($eachFile);
open (MYFILE, '>>datafulltracks.csv');
print MYFILE $filename,", Duration - ",$duration,", Size- ",$filesize,"\n";
}
}
}
}
close (MYFILE);
}
## initial call ... $ARGV[0] is the first command line argument

recurse($ARGV[0]);

Recursive Directory Listing in Perl

#!/usr/bin/perl -w
use strict;
sub recurse($)
{
my($path) = @_;
$path .= '/' if($path !~ /\/$/);
print $path,"\n";
for my $eachFile (glob($path.'*'))
{
## if the file is a directory
if( -d $eachFile) {
## pass the directory to the routine ( recursion )
recurse($eachFile);
}
else
{
## print the file ... tabbed for readability
open (MYFILE, '>>data.csv');
print MYFILE "\t",$eachFile,"\n";
}
}
close (MYFILE);
}
## initial call ... $ARGV[0] is the first command line argument

recurse($ARGV[0]);

Wednesday, 1 April 2009

Getting Transaction details from Paypal in PHP

Below is code for getting transaction details if you are using Paypal for payment purposes. Auto-return and PDT has to be enabled in paypal system for below code to work.
}
else
{
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp))
{
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0)
{
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}
 
// parse the data
$lines = explode("\n", $res);
$keyarray = array();
//print_r($lines);
if (strcmp ($lines[0], "SUCCESS") == 0)
{
for ($i=1; $i

Java Archive Header in PHP

Header for Java-archive.

Sunday, 22 March 2009

Text Editor in Java Script

I used it in WAP site generator code. Quite useful and straight forward.

var area;
var showDiv;
var formattedStr = "";
startPosition = 0;
var endPosition = 0;
window.onload = function()
{
area = document.getElementById("area");
showDiv = document.getElementById("showDiv");
};
function publish()
{
formattedStr = "+document.getElementById("area").value+"";
showDiv.innerHTML = formattedStr;
}
function insertsBoldTag()
{
findPositions();
var text = area.value;
if (startPosition!=endPosition) {
var sbStr = text.substring(startPosition,endPosition);
sbStr = ""+sbStr+"";
fillsFormattedString(text,sbStr);
}
}
function insertsItalicTag()
{
findPositions();
var text = area.value;
if (startPosition!=endPosition) {
var sbStr = text.substring(startPosition,endPosition);
sbStr = ""+sbStr+"";
fillsFormattedString(text,sbStr);
}
}
function insertsUnderlineTag()
{
findPositions();
var text = area.value;
if (startPosition!=endPosition) {
var sbStr = text.substring(startPosition,endPosition);
sbStr = ""+sbStr+"";
fillsFormattedString(text,sbStr);
}
}
function insertsDeleteTag()
{
findPositions();
var text = area.value;
if (startPosition!=endPosition) {
var sbStr = text.substring(startPosition,endPosition);
sbStr = ""+sbStr+"";
fillsFormattedString(text,sbStr);
}
}
function findPositions()
{
var text = area.value;
if (document.selection) {
// Internet Explorer
var range = document.selection.createRange();
var dpl = range.duplicate();
if (range.text.length > 0) {
dpl.moveToElementText(area);
dpl.setEndPoint("EndToEnd", range);
startPosition = dpl.text.length-range.text.length;
endPosition = startPosition + range.text.length;
}
}
else {
// Mozilla Firefox
startPosition = area.selectionStart;
endPosition = area.selectionEnd;
}
}
function fillsFormattedString(text, selectedText)
{
// split textarea value into three pieces: before startPosition,
// startPosition until endPosition, and after endPosition
var str1 = text.substring(0,startPosition);
var str2 = text.substring(startPosition,endPosition);
var str3 = text.substring(endPosition,text.length);
// replace str2 with formatted substring (selectedText)
str2 = selectedText;
// form the new string
formattedStr = str1+str2+str3;
area.value = formattedStr;
}

Friday, 20 March 2009

Reading URL in PHP

This was the most used code for me in my mobile apps/services application. As I work with a number of sms gateway providers and affiliates, which required often to use their services from my application(web apps), I used a service-url(developed on any technology) in PHP application in following way. This is simple aint it?

function curl_get_file_contents($URL)
{
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
?>

Friday, 20 February 2009

Creating Zip file using PHP

A useful code to create a zip file from the PHP. I used it in WAP site generator and it worked on first take.
< ?php class zipfile { var $datasec = array(); var $ctrl_dir = array(); var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; var $old_offset = 0; function add_dir($name) { $name = str_replace("", "/", $name); $fr = "\x50\x4b\x03\x04"; $fr .= "\x0a\x00"; $fr .= "\x00\x00"; $fr .= "\x00\x00"; $fr .= "\x00\x00\x00\x00"; $fr .= pack("V",0); $fr .= pack("V",0); $fr .= pack("V",0); $fr .= pack("v", strlen($name) ); $fr .= pack("v", 0 ); $fr .= $name; $fr .= pack("V", 0); $fr .= pack("V", 0); $fr .= pack("V", 0); $this -> datasec[] = $fr;
$new_offset = strlen(implode(”", $this->datasec));
$cdrec = “\x50\x4b\x01\x02″;
$cdrec .=”\x00\x00″;
$cdrec .=”\x0a\x00″;
$cdrec .=”\x00\x00″;
$cdrec .=”\x00\x00″;
$cdrec .=”\x00\x00\x00\x00″;
$cdrec .= pack(”V”,0);
$cdrec .= pack(”V”,0);
$cdrec .= pack(”V”,0);
$cdrec .= pack(”v”, strlen($name) );
$cdrec .= pack(”v”, 0 );
$cdrec .= pack(”v”, 0 );
$cdrec .= pack(”v”, 0 );
$cdrec .= pack(”v”, 0 );
$ext = “\x00\x00\x10\x00″;
$ext = “\xff\xff\xff\xff”;
$cdrec .= pack(”V”, 16 );
$cdrec .= pack(”V”, $this -> old_offset );
$cdrec .= $name;
$this -> ctrl_dir[] = $cdrec;
$this -> old_offset = $new_offset;
return;
}

function add_file($data, $name)
{
$fp = fopen($data,”r”);
$data = fread($fp,filesize($data));
fclose($fp);
$name = str_replace(”", “/”, $name);
$unc_len = strlen($data);
$crc = crc32($data);
$zdata = gzcompress($data);
$zdata = substr ($zdata, 2, -4);
$c_len = strlen($zdata);
$fr = “\x50\x4b\x03\x04″;
$fr .= “\x14\x00″;
$fr .= “\x00\x00″;
$fr .= “\x08\x00″;
$fr .= “\x00\x00\x00\x00″;
$fr .= pack(”V”,$crc);
$fr .= pack(”V”,$c_len);
$fr .= pack(”V”,$unc_len);
$fr .= pack(”v”, strlen($name) );
$fr .= pack(”v”, 0 );
$fr .= $name;
$fr .= $zdata;
$fr .= pack(”V”,$crc);
$fr .= pack(”V”,$c_len);
$fr .= pack(”V”,$unc_len);
$this -> datasec[] = $fr;
$new_offset = strlen(implode(”", $this->datasec));
$cdrec = “\x50\x4b\x01\x02″;
$cdrec .=”\x00\x00″;
$cdrec .=”\x14\x00″;
$cdrec .=”\x00\x00″;
$cdrec .=”\x08\x00″;
$cdrec .=”\x00\x00\x00\x00″;
$cdrec .= pack(”V”,$crc);
$cdrec .= pack(”V”,$c_len);
$cdrec .= pack(”V”,$unc_len);
$cdrec .= pack(”v”, strlen($name) );
$cdrec .= pack(”v”, 0 );
$cdrec .= pack(”v”, 0 );
$cdrec .= pack(”v”, 0 );
$cdrec .= pack(”v”, 0 );
$cdrec .= pack(”V”, 32 );
$cdrec .= pack(”V”, $this -> old_offset );
$this -> old_offset = $new_offset;
$cdrec .= $name;
$this -> ctrl_dir[] = $cdrec;
}
function file() {
$data = implode(”", $this -> datasec);
$ctrldir = implode(”", $this -> ctrl_dir);
return $data . $ctrldir . $this -> eof_ctrl_dir . pack(”v”, sizeof($this -> ctrl_dir)) .
pack(”v”, sizeof($this -> ctrl_dir)) . pack(”V”, strlen($ctrldir)) .
pack(”V”, strlen ( $data)) . “\x00\x00″;
}
}
// Test this class
$zipTest = new zipfile();
$zipTest->add_dir(”images/”);
$zipTest->add_file(”images/box1.jpg”, “images/box1.jpg”);
$zipTest->add_file(”images/box2.jpg”, “images/box2.jpg”);
// Return Zip File to Browser
Header(”Content-type: application/octet-stream”);
Header (”Content-disposition: attachment; filename=zipTest.zip”);
echo $zipTest->file();
// Alternatively, you can write the file to the file system and provide a link:
/*
$filename = “output.zip”;
$fd = fopen ($filename, “wb”);
$out = fwrite ($fd, $zipTest -> file());
fclose ($fd);
echo “Click here to download the new zip file.“;
*/
?>

Sunday, 15 February 2009

File Uploading in PHP

0)
{
echo "Error: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
?>


By using the global PHP $_FILES array you can upload files from a client computer to the remote server.
The first parameter is the form's input name and the second index can be either "name", "type", "size", "tmp_name" or "error".

Like this:
$_FILES["file"]["name"] - the name of the uploaded file
$_FILES["file"]["type"] - the type of the uploaded file
$_FILES["file"]["size"] - the size in bytes of the uploaded file
$_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server
$_FILES["file"]["error"] - the error code resulting from the file upload


This is a very simple way of uploading files. For security reasons, you should add restrictions on what the user is allowed to upload.
Restrictions on Upload
In this script we add some restrictions to the file upload. The user may only upload .gif or .jpeg files and the file size must be under 20 kb:


0)
{
echo "Error: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
}
}
else
{
echo "Invalid file";
}
?>


Note: For IE to recognize jpg files the type must be pjpeg, for FireFox it must be jpeg.
Saving the Uploaded File
The examples above create a temporary copy of the uploaded files in the PHP temp folder on the server.

The temporary copied files disappears when the script ends. To store the uploaded file we need to copy it to a different location:

0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "
";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "
";
echo "Type: " . $_FILES["file"]["type"] . "
";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>

Friday, 30 January 2009

FPML

Financial Innovation being one of my favourite topics, I decided to pick on some popular technology standards in the Industry. FPML(Financial Products Markup Language), FIX(Financial Information Exchange), SWIFT(Society for Worldwide Interbank Financial Telecommunication) and MDDL(Market Data Definition Language) are major ones. FPML and MDDL are XML based while SWIFT and FIX being older are non-XML. Well I concentrate on FPML here to leave other implementations in later post.

The need for the standards arrived due to communication hassles between the exchanges and different format of messages. To streamline the whole process of trading activities, an e-business language was established based on industry standards for derivatives industry. It is based on XML which is standard meta-language for sharing data between the applications. FPML provides basis for information sharing which is independent of hardware or software underlying.

Though there were already a couple of globally accepted standards previously, they were not able to cater to rising needs of financial products which were innovated constantly since 1980s. OTC(Over-the-Counter) derivatives were constantly evolving on basis of needs of trading partners. Technology at those times were used in price and risk calculations. A typical illustration of how OTC trading operated in those days would help to see the need of such evolution.

"When two partners traded each quoting the suitable price to other, the price would go to price/risk management department of each for confirmation. Once the pricing and risk deparment would confirm the order, the confirmation receipt would go on each sides settlement and collateral management departments to execute the order. The confirmation receipts being different caused non-seamless communication and delay in execution of trades."

Also with growing number of attributes the current systems were doomed to be obselete due to non-provision for such requirements. However, with evolution of Internet and development of global standard as XML, it is now possible to develop systems which can work on flexible messaging format. It has now become cost-effective to build such systems which are less error-prone, manual and lot more flexible to the need of ever-growing financial products.

Advantages
The advantages are quite obvious.
Seamless communication between systems and business processes.
Support for diverse set of applications including turn-key applications and core technology ones.
Reduced processing costs, communication costs and labour costs.
Less operational risks and business opportunities.

Efficient and Reliable UI automation without Selenium

I have been experiencing satisfaction over UI automation efforts after a half-decade of my work in automation. The reason is new age tools ...