Category Archives: IT

Lazy Loading of Proxies

While working on a pureMVC project, I realised that there were N number of proxies registered with facade (yes, ApplicationFacade). The truth was, not all have been used during life cycle of a typical user functionality.

So what? It was merely difficult to categories the proxies for need of individual module/functionality.

The simple idea is to implement Lazy Loading / Lazy registration of proxy!

Instead of declaring statement at compile time like

facade.registerProxy(new MyProxy()); 

I overridden

retrieveProxy(...)

function in extended Facade class:

override public function retrieveProxy(proxyName:String):IProxy
{
 var proxyInstance:IProxy = super.retrieveProxy(proxyName);
 if(proxyInstance==null)
 {
 var myClass:Class = getDefinitionByName(proxyName) as Class;
 if(!myClass)
 return null;

 var proxyInstance:IProxy = new myClass();
 if(proxyInstance)
 registerProxy(proxyInstance);
 }
 return proxyInstance;
}

This also takes care of not registering duplicate proxy.
Uh oh! While doing this trick, I encountered on more problem.


ReferenceError: Error #1065: Variable myClass is not defined.

I banged my head and tried to figure out the reason. After digging for some time, I found that the (class) definition of proxy was somehow not been retrieved with

getDefinitionByName() 

.
It wasn’t possible to simply add import statements with those Proxy class names as Flex compiler ignores such unused (yes while compiling none of proxy was referenced) imports.

Simple trick worked:
in extended facade class constructer, I declared each proxy as variable, something like:

public class ApplicationFacade extends Facade
{
 public function ApplicationFacade(parameter:SingletonEnforcer)
 {
 super();

 var myProxy:MyProxy;
 }
}

and that’s all I wanted! The trick is this code doesn’t force an instance of proxy to be created, still at runtime when required, it finds definition of MyProxy class.

Infibeam Pi – a review

After using – playing with infibeam.com’s Pi, for almost about 4 months I thought to write about it. Many people have been asking me online and offline ‘How is it?’ And could simply respond with ‘Good’!

If you think this is smart device, can do much more like iPad, Galaxy Pad or so, its absolutely misconception. Its very very simple and dedicated eBook reader, and almost nothing beyond that. No wi-fi, no 3G, no browser, no touch-screen!
The device is meant for very specific purpose.

Battery:
The battery lasts long and the main reasons behind them is the way is designed – no backlight and E-ink  screen. This is indeed smart technique, absence of back light and flat simple screen provides very smooth, no eye itching experience. This definitely provides equally pleasant experience as if you were reading physical – paper book. Battery indeed lasts more than a week for me after a complete charging cycle.

Connectivity:
Connectivity is pretty simple way, charging and data transfer is possible with mini USB interface. It also has SD card  slot, so you every time do not need to connect reader via cable to transfer books.

Ebook reading / formatting:
Though it supports vast variety of formats including, TXT, EPUB, PDF, HTML, and more, the device converts – formats text on its own. For non technical reading, its indeed good. This may result into different placement of image, but is fine as long as you can link the reference!
However, for technical ebooks, this isn’t good. For instance, code snippet or some tips also gets converted and formatted with different font. This makes it little annoying to understand flow. Also, limited screen size may also split continuity. Reference to diagram involves multiple flips between few pages.
The best and i-like-most part is support for major Indian languages. Font support and formatting is really very nice when it comes to Indian regional text.

Audio:
It has very basic audio player which supports MP3 format. This player is indeed basic, don’t expect rocking sound experience! The ideal purpose, though not highlighted much anywhere, is audio ebook listening, and nothing beyond.

Screen / display:
It has simple 600 by 800 pixels of display which is sufficient for normal book reading. The landscape and full screen book reading experience is good for continuous reading.

  • Font families – changeable includes Georgia, Courier, MTX Bold
  • Size switches – increase / decrease actually changes font size and reformats text. For ebooks with scanned image type text, text recognition is not there, so can also use zoom in-out.
  • E-ink displays image in grayscale.
  • Refresh / response time is bit more, so requires patience after button press! 😀

Others:
No keyboard, very limited functional buttons, so no confusion for first time users.
Sudoku game, image viewer.

Minor bugs:

  • Landscape mode reading doesn’t show full title of ebook, even if it has sufficient space.
  • Header shows date, but not time – crazy!
  • For Indian scripts, specially with subscript characters and superscript characters, post formatting gives little annoying experience, for example a signle word is broken in such a way that first line terminates with consonant character and associated vowel goes to next line beginning! 🙂
  • About section – device says “GNU General Public License – this product contains software which applies to GPL. You may obtain and redistribute the GPL source code.” This is indeed crazy, GPL is license and not any type of source code. And the company – infibeam doesn’t mention which software (under GPL) is used, and from where! (consider it major, if you’re also open source promoter, like me.)

The bottom line:
This is dedicated ebook reader for India, but not as per ‘Indian Price’ – bit more expensive considering set of features. However the available options are good enough for non technical or semi technical reading.

Couple of one liners from my friends when they played with my reader.
“Please remove paper placed on screen and switch it on, I want to see!” (though actually it was on with some book opened)

“If this is offered around Rs.5000, I shall get one.”

“This is a book only, and is thinner than our technical books.” (when I handed over with leather case)
Bonus for readers of this post –

Get your favorite newspaper delivered to your e-mailbox, daily and read using this reader

  • Grab copy of Calibre Ebook Management software. It’s free and open source, supports multiple operating systems.
  • Install and open
  • Click on Fetch newsSchedule news download and you will see a window like below:Schedule news download
  • search for your favorite newspaper / magazine and click on the name. Of course, you can also add your own way – own news feed. But this requires little technical knowledge.
  • When you select – highlight the item, Schedule option on right side will be enabled, just select preferred time and frequency and save.
  • Now click on Connect / Share icon and setup your email account, make sure you enabled auto send option.
  • That’s it!

Note, this trick requires software to be open and internet to be connected, for the time you have scheduled. You can use scheduled activity to start / wake up your computer before the schedule and hibernate / shutdown post schedule.

I also recommend Calibre Ebook Management software as it has vast options to convert ebook to multiple formats.

Update:

infibeam Pi is just a wrapper and Indian branding of netronix ebook device! I was bit surprised to find this. Also, firmware upgrade is also not smooth. Post upgrade, you may expect some bugs as new gifts! 😀

Auto fare Calculator for Indian cities

Many people either carry copy of auto fare card with them or do remember formula. However, it becomes difficult when you are roaming in multiple cities frequently.

A lot many similar apps available, however they are either platform specific, outdated or requires GPRS or other network connection. Few others are city specific.

This is a very simple attempt to overcome a couple of situations.

The application:

  • Works on almost any mobile with basic browser (internet browsing software)
  • Does not require any GPRS or other connection to run the app
  • Has support for multiple cities of India
  • Support for night fare calculation – based on device time
  • No installation required, just copy to mobile and run
  • No advertisement, no license fee – free and open source
  • Can be very easily updated
  • Has very basic and simple interface, executes and works simply

Grab it : Download http://harit.kotharee.com/app/fareCalc.htm . (Right click to the link and select ‘Save As…’ and save to your computer / or save the copy on your mobile.)

Use it : Open the saved copy of fareCalc.htm from your mobile or equivalent device, in most cases, it should open with default available browser. That’s it. No need to explain further. 🙂

Why HTMLand JavaScript?

  • Most mobile browser supports
  • No formatting / styling required
  • Widest compatibility across mobile platforms
  • No rebuild, easy to update
  • No installation required
  • Easy to share

Flash Player Cache and loading issues

By programming its not possible to clear out flash player and browser cache at a point of time, that too without user’s knowledge.
This, at times creates problem when a third party component, say SWF is loaded. Generally the URL from where SWF is to be loaded remains constant. So Flash Player often caches for browser’s easy experience.

However, if the third party – remote component if again in turn does some activity over network, it gives randomly wrong results  Generally this happens because the loaded component actually resides in cache, at times.

To overcome this, there is a way, not to clear cache, but to make browser and flash player feel as if you are always loading some new component (say SWF) from new location.
This simple trick is achieved by doing something like….
http://haritkothari.wordpress.com/myNewComp.swf?[firstparam=123&secondparam=456]&randomcount=Math.random()*Math.random()

The randomcount query param has no more significance other than make FP feel its another URL request, which is not cached! The stronger you implement dummy param, the less is probable for FP to cache.

This can be easily be used with loader to load remote component, however only care need to take is the dummy parameter should not be such that is interpreted by remote component, otherwise result may go to any extent!!!

This is also not Flash Player or actionscript specific trick, even banking and few other sites implement this in stronger ways to avoid caching, apart from session id!

Flex Formatter

Flex Builder 3, an eclipse~ IDE for flex and actionscript based project development lacks few primary code indentation and refactoring functionalities by itself.

Searching for some other technical requirement drove me to Flex Formatter, a third party project on source! Cheers, its BSD license! 🙂

This tool is really small but very essential and useful plugin

Flex Formatter tools

Flex Formatter tools

Many times it happens that code is written in hurry to achieve some short term goal. Either some efforts need to invest to refactor and indent the code, or else go for Flex Formatter.

Built in capability to generate ASDoc is also impressive! However, I suppose, all these features, of flex formatter have been covered with Flash Builder 4.

A Deewar dialogue between IT guys

Today evening I was chatting with my colleagues in break time.
Suddenly one of them said something and I created an IT version of famous Hindi movie – Deewar. This makes more sense during present scenario of recession.

Amitabh Bachchan : “Mere paas…
4 GB RAM hai,
3MB L2, 2.53 GHz, 1066 MHz ka Intel Core2 Duo processor hai,
21″ LCD Monitor hai,
300GH ki Hard Disk hai,
Logitech ka Optical mouse hai,
LightScribe aur BlueRay waalaa DVD writer hai,

Flex Builder 3 ka license hai,
Windows Vista ka license hai,
4MBPS ka Internet connection hai,

Tumhare paas kya hai?

Shashi Kapoor : “Mere paas nayaa project hai!

IT Managers

I have come across a few managers, in IT industry. Although I do not like theories of management much, but still I believe there is some scientific and psychological truth is there.

Here I am not writing these theories, but expressing how an action can give positive or negative reaction. Of course, this post had been saved as draft quiet a long time ago, now draft is in the form of new post.

Few managers tend to act being a superior authority. They often forget basic fundamentals of successful management – punctualness, responsiveness and co-operativeness, etc.

Few lac attitude of encouragement. I have observed at many places that lac of encouragement decreases the throughput of a single person at major level. This can be even more in mass. Managers are meant to get the work done, smartly.

Torturing behavior also affects output. Often, these situation arises when managers fail (of course, themselves) to understand what the subordinates thinks like. They fail to catch opportunities to have co-workers’ and subordinates’ views. These situations often end in harsh behavior or chaotic situations at worse.

‘Psycho’ manager often forgets that subordinate is after all a human being, a social animal, a creature! (This statement reminds me of someone, I interacted with during my last phase of Post Grad study!!! :p)

Managers should not be damagers!

Also, I have seen few managers who are really down to Earth, although being at management cum technical level.

Simple encouragement pours enthusiasm to juniors, subordinates and co-workers too!

Regular feedback and interation between IT managers and colleagues often reduces some pressure about achieving targets.

Also, more the freedom given to the employees (of course, with control),  better the output is  Any how, employees also need to manage their tasks!

A golden line that I believe – a true manager is a person with whom no subordinate feels aftraid of to interact, anytime. This makes sense when interaction increases to solve problems, with less efforts.

Masking with customized / polygon shape

A typical requirement to create custom closed shape was a big pain till now at my workplace. Many were working to create some run time changeable shape and through that, mask an image. I achieved this; finally, after visiting a blog and a forum for Flash programming. Also, my colleague Mayur helped to organize once I was ready and I explained like Proof of Concept.

For custom shape, you will require a reference to public property of any DisplayObject / UIComponent – that is graphics (flash.display.Graphics)

Now is the real crux.

The next steps work just like you draw something on paper (or Canvas)

// Create and initialize Sprite object
var spriteObj:Sprite = new Sprite();

// Clear graphics
spriteObj.graphics.clear();

// Define style of line (border of the shape)
spriteObj.graphics.lineStyle(1, 0xff00ff);

// Start filling with a selected color
spriteObj.graphics.beginFill(0x00ff00);

// Move to a position to start from (without actually drawing)
spriteObj.graphics.moveTo(x, y);

// Draw a line / curve or anything that is supported by graphics
// This may be used in a loop or recursive manner to draw lines / curves passing through n points
for(...;...;...)
{
	spriteObj.graphics.curveTo(handlerX, handlerY, x, y);
}

// End filling process, just like you put pen aside!
spriteObj.graphics.endFill();

// Define a new canvas and initialize it
var canObj:Canvas = new Canvas();

// Add the just created Sprite object as a raw (not direct UIComponent child) child
canObj.rawChildren.addChild(spriteObj);

// Use over image as a mask, if required
imgComp.mask =  canObj;

Dumb Spammer

Receiving spam messages via email is old way. Receiving unsolicited calls and SMS is present tense! And that makes us tensed at times!!!!

Here are two samples of idiot spammers:

1.

An email

From hrd.hcl.com@gmail.com

Dear Candidate,

Ref: Selection and initial response of your Resume online.
It is our good pleasure to inform you that your Resume has been
selected for our plants in NOIDA ” HCL Technologies Ltd Unit – 4″.
The Company is the collaboration concern of “HCL Groups India Ltd”.
Dealing in IT and Electronics manufacturing business in India.

You are selected according to your resume in which Project you have
worked on according to that you have been selected in Company.

Your interview will held on 14th to 20th of OCT. 2008 in Delhi.

You will be pleased to know that Company has advise you in the
selection panel that yourApplication can be progress to final stage.
You will come to Company corporate office in NOIDA. Your offer latter
with Air Ticket will be send to you by courier before date of
interview.. You have to come with photo-copies of all required
documents. First you have to deposit the (Cash) as an initial amount
in favor of Company HRD. Department. for Rs 4,250/- through any
[CANARA BANK] Branch from your Home City to Company Senior HRD.
Account NO- 2886101000289- Name of Mr.RAKESH GUPTA. This is
refundable interview security. Your offer latter with Air tickets
will be send to your Home Address by courier after receiving the
confirmation of interview security deposited in CANARA BANK . All the
expenditure will be paid by Company to you at the time of face to face
meeting with you in Company.. The Company can be offer you as salary
with benefits for this post Rs. 35,000/- to Rs.70,000/- P.M + (HRA +
D.A + Conveyance and other Company benefits. The designation and Job
Location will be fix by Company HRD. At time of final process.

REQUIRED DOCUMENTS BY THE COMPANY HRD.
photo-copies of Qualification Documents (Must)
photo-copies of Experience Certificates (If any)
photo-copies of Address Proof (Must)
Two Passport Size Photo-graph (Must)

The Job profile, salary offer, and date -time of interview will be
mention in your offer latter. Your offer latter will dispatch very
shortly after receiving your confirmation of cash deposited in CANARA
Bank. The last date of interview security deposit in bank 6/10/2008
TO 7/10/2008. We wish you the best of luck for the subsequent and
remaining stage. You have to give the information after deposited the
security money in bank to same Email ID Your offer latter will be
dispatch same time after recd. the information of security deposited
by email..

Thanks

Mr.. RAKESH GUPTA ( HRD)
HCL Groups India Ltd.
H.O. B -125, HCL House,
Surajpur Industrial Area,
GREATER NOIDA
Cont No :-09837772058

2.

An SMS received from No. 919116655433 (yes, I don’t know whether it’s international SMS of prefix is short for +91)

“IIM CALCUTTA invites graduates from 2006-08 with min 50% for a course with a guaranteed job for the post of Sales Manager with 4.5 p.a. Cal:9903456704/9433248198”

I can never imagine that IIM contacts some advertisement agency, or perhaps I might have received the SMS from some frustrated – failed student of IIM!!!!

Please donate some brainstorming food to those dumb! :p

Setting up Subversion under windows

Prerequisites:

  1. Subversion Binary (http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91)
  2. TortoiseSVN (http://tortoisesvn.net/downloads)
  3. SVN Service Wrapper for Windows (http://www.lw-works.com/files/svnservice/svnservice-1.0.0.msi) – svnservice

Alternate to 1 & 2 – download 1 Click Setup (http://svn1clicksetup.tigris.org/)

Step 1

  1. Install Subversion binary.
  2. Make sure that the bin directory of Subversion is under PATH environment variable.
  3. Set any text Editor’s path as SVN_EDITOR environment variable. (e.g. c:\windows\notepad.exe)

Step 2

  1. Create code / document repository (the main destination or data centre!!)
svnadmin create "d:\codeRepo"
               Alternatively, you may also use explorer’s context menu to add selected folder as repository using TortoiseSVN.
  1. Go to the repository folder (e.g. codeRepo)
    1. Edit /conf/svnserve.conf file

Uncomment following:

                               [general]
                               anon-access = read
                               auth-access = write
                               password-db = passwd
    1. Edit /conf/passwd file

Uncomment following / specify allowed username & passwords:

                               [users]
                               harry = harryssecret
                               sally = sallyssecret
                               harit = harit’s password

Step 3

  1. Start svnservice
               svnserve --daemon --root "d:\codeRepo"
  1. Add new Project directory by
               svn mkdir svn://localhost/myproject
  1. Provide correct username & password (that is configured earlier)

Otherwise, use SVN repository browser to browse SVN repos. Right click provides rich set of options like adding new files/folders, delete, etc. etc. Use svn://localhost/myproject or similar as URL to browse.

Optional options!

  1. Setup svn-service to start at startup
               svnservice -install --daemon --root "d:\codeRepo"
               sc config svnservice start= auto
               net start svnservice
  1. Bind windows user for authentication (see source link 1 – http://www.stanford.edu/~bsuter/subversion-setup-guide/#svnserve-windows-user)

Please make sure that the svnservice is running correctly. Use Control Panel > Administrator Options > Services > Subversion (or whatever you named it) to verify. If the service is not running, it is the root of many problems.

This setup also works on network. You can access this repo through other machines connected through network. Each time you modify the files and commit, subversion will do authentication based on username and commit new version.

Major advantage of subversion – old (and deleted) files remain there in repository and can be retrieved back, so is perfect backup solution for code!

Sources for more advanced setup:

  1. http://www.stanford.edu/~bsuter/subversion-setup-guide/
  2. http://blogs.vertigosoftware.com/teamsystem/archive/2006/01/16/Setting_up_a_Subversion_Server_under_Windows.aspx
  3. http://blog.excastle.com/2005/05/31/mere-moments-guide-to-installing-a-subversion-server-on-windows/
%d bloggers like this: