Saturday, July 18, 2009

Thumbnail generation algorithm with out losing image aspect ratio

Referred many thumbnail generation algorithms, but many were about to crop most of the available screen area, if the image to be thumbnail'ed is not aligned with the image's aspect ratio.

Algorithm that I figured out to save more area of the original image is:
Assume the thumbnail dimension should be x':y'.
1. Load the image and get original width(w) and hieght(h).
2. Scale the image to X:Y, such that:
a. if h > w, Y = h * aspect_ratio, X=w
b. if h < w, X = w * aspect_ratio, Y=h
3. Crop the scaled image to x':y' calculating the area from center of the picture.

GdkPixbuf functions used for implementing this algorithms are:
gdk_pixbuf_new_from_file(),
gdk_pixbuf_get_width(),
gdk_pixbuf_get_height(),
gdk_pixbuf_scale_simple(),
gdk_pixbuf_new(),
gdk_pixbuf_copy_area()

strcasestr()

The strcasestr() function is defined in libc on '2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686 GNU/Linux' machine is defined as:
$nm -AC /usr/lib/libc.*|grep strcasestr
/usr/lib/libc.a:strcasestr.o:00000000 W strcasestr
flag 'W' means weakly defined. If it is linked with normal code without defining the function(), compiler error is observed saying 'strcasestr() undefined'. The function's declaration could be found in . To avoid compilation error, I have written my own strcasestr() function, but altered the expected functionality of the function to suit my requirement.

I need to compare whether a given string is a sub-string(case-insensitive) of the given string. But the string could be found only at the word begining. The code fragment for the strcasestr() is pasted below.

static gchar* my_strcasestr(gchar *source, gchar *target) {
gushort i = 0, len = 0; /* assuming search string length won't be greater than sizeof(gushort) */
guchar after_space = 1;

len = strlen(target);
for (; source[i] != '\0'; i++) {

if(!after_space && source[i] != ' ')
continue;
if(source[i] == ' ') {
after_space = 1;
continue;
}
after_space = 0;
if(!strncasecmp((source+i), target, len))
return (source+i);
}
return NULL;
}
If there is any better way of doing this, pls let me know.

Thursday, November 08, 2007

ntde1ect.com, a big headache

Recently, my system was threaten by one more virus, ntde1ect.com, which spreads through the usb drives(pendrive).

It seems this virus is very intelligent one and it corrupts even the system files 'ntdetect.com' and 'ntldr'.

the associated files coming with this virus are:
ntde1ect.com,
autorun.inf,
avpo.exe,
avp0.exe,
avp0.dll, and
a directory with name hashxxx, containing scripts to block orkut and youtube sites, usually located only on 'drive with label C'.
Indication to find out this virus is, when open a drive, its opening in a new window instead of in the same window. This might be because of autorun.inf.

We may find the instances of ntde1ect.com and autorun.inf in all the root directories of the partitions.

Another indication is we are not able to change the option of show hidden files option.

To remove this virus, no other way except booting the system in recover mode.

After booting the system in recover mode, switch on to respective partitions and try remove all the said files in partition's root directory and in /windows/system32 directory.

One important thing is to change the attributes of these files to readable format using 'attrib'.
ex:
c:/>attrib -r ntde1ect.com
will take out the 'no read' restriction on the files, so that we can delete.

Then have to remove the traces of this virus(avp0.exe, ntde1ect.com, ...) in regedit.

Tuesday, July 17, 2007

XML Talk@twincling


On Last saturday(14th of july), i gave a talk on XML and technologies in Twincling society whose motive is to develop and promote open source software products. You can find the slides here. The session went very good as the response from audience and i covered xml, dtd, schema and namcespaces. But the other technologies like xpath, xlink, xslt, etc are not able to covered due to time limitation. My special thanks to Saifi, Sumit, Namita Iyer and other active members of twincling society to give me an opportunity to share my knowledge.

You can find more information on twincling society here.

Tuesday, July 03, 2007

guruji.com

I heard about this search engine company many days back. Yesterday they have started a contest " search and win". I played the contest my referral link is here.

But i didn't get the idea behind this contest. Do they want to show off their product to the outer world? I still feel that Its relatively impossible to find accurate data particularly for indian(or any country) content. They may have taken assumptions based on geographic, IP based, or content related, or what ever it may be... there is no proper way to categorize the data that its belonging to particular place. A person working in Canada( born and bought up in India) may want to write his daily musings/happenings may be in canada or india or what ever he wants. I am still wondering how many of users would be interested in to search for India related content (especially in this globalized world).

Update:
I won a T-Shirt playing on this contest. Thanks to guruji.com team.

Monday, February 26, 2007

This is how i get free access to ACM Portal, A Security Hole

Yes, its true! I got free access to ACM Portal from a network which is not subscribed. This Portal will allow us to view the abstract of desired paper. But if we want to download the paper we must either have membership account with ACM or our network must be subscribed as most of the educational organizations do. Failing the 2 options we cant get access to download the paper(through the acm portal).

Till now, me and my friends have an illusion that the requests are tracked based on the IP address and if the IP address is not in the subscription list, it would be treated as normal request. But it may not be true. When I type a paper title in google search and selects a result link which is targeted to acm portal, i can get access to the acm portal page as a genuine user from Google, Inc, and can download the desired paper. It gives us full access as a subscribed user. I tested with Firefox and Konqueror browsers and friends working in other companies are tested on windows IE as well. Its only possible with google search, but not with other search engines like Yahoo Search, ASk.

Observe some of the screenshots I got through while experimenting. Sometimes its showing Google,Inc; sometimes CILEA Consortium; and sometimes FUJITSU Ltd. I guess its a security hole. And one more thing is that the search result must contain CFID and CFTOKEN. May be these two attributes are the driving factors for me to get access. Try the Sample search. Select the result which is pointing to acm portal (It would be in the first 10 entries). When i search for those two variables, i came to know that CFID and CFTOKEN are the ColdFusion session variables. They are used to track the user's browser session. By default, all ColdFusion versions write CFID and CFTOKEN as persistent cookies in the client browser. An important security note is: Coding sensitive data such asCFID and CFTOKEN in the URL string is a security risk. Even though they are designed as per-session cookies, its still possible for us to access with Google search.

I am still wondering why its only possible with Google Search and not with any other search engines. May be I need to dig into ColdFusion programming.

Update:
Seems Google Search is not providing such results. But this link would directly allow you to access acm portal under the 'Google Inc' network. The reason is, as i said earlier, the query result should include the CFID and CFTOKEN arguments.

Monday, February 05, 2007

Am i a Dreamer????

Am i a dreamer???, as the title of this post asks, i came across this questions many times, but i eventually supressed that thought upon doing the things and converting my self into a do-er, rather than dreamer.
Few days back, i been to read an article in Times of India, a survey that dwells about the qualities of planner / do-er/ dreamer. According to the survey, a Planner is one who like to have everything in order and spend hours before making decision. A Doer is one who takes the things as they come into and go ahead. But a Dreamer is one who do more planning than doing. The dreamer is one who spent much of his time planning, rather to fail (or lag) at implementation, and a bit idealist and want things to be done perfectly.

But my conception of Dreamer is one who can think of an idea, and plan it for implementation (i mean, a perfect plan), and go ahead with it. A dreamer can only lead the world!. A goal is a dream with a deadline, according to the author, An idea without at least some element of absurdity is not worth further consideration. Small businesses don't grow bigger without a dreamer, planner, risk taker, and doer. Enterprenuer is one who is more a dreamer in addition who can plan, take risks and implement. Today world is renovating more with dreamers, so the start-up boom. Without Dreams, you can not set a goal, without goal, you cannot plan, without plan, you cannot control, and without control you cannot manage either yourself or others. So i continue dreaming...!

Sunday, February 04, 2007

temp2.exe (irc.momma worm) - How i got to remove it successfully

temp2.exe and/or temp1.exe, both these two viruses irritated me for some time yesterday. While i was copying some files using flash drive, my machine got to threaten of this virus. Some anti viruses treated it as worm, though it harms seriously. Mainly it deteriorates the data flow. So its related to network security. I clearly came to evidence that temp2.exe and temp1.exe are running on my system and until i ended them, i cant be able to detach the removable devices. In addition, when i tried to open other windows partitions, they are opened as new window, even though i havnt used that option. I addition it adds autorun option in the context menu explorer.

When i digg into the details, i came to know much about the virus, how its working, and all. If we are copying from infected machine, this virus puts three files along with the data into the disk.
They are: copy.exe, host.exe and autorun.inf
autorun.inf file contains only two lines.
[autorun]
open=copy.exe
when we open the infected disk, autorun will invokes and virus starts acting by running the copy.exe file. It creates a dump of above three files in root directory of each partition and make a copy of copy.exe in system32 directory. Also a copy of temp1.exe and temp2.exe wlould be kept in system32. Along with it corrupts the xcopy.exe and svchost.exe files in system32.exe. It also kept registry entry.

Steps to remove the virus:

So to remove the virus one has to be careful. First off the system restore monitoring. Then delete the three-files from root directory of each partition. Also remove copy.exe, xcopy.exe, temp1.exe, temp2.exe and svchost.exe from system32 directory. And the remaining is deleting the entries in registry. So to do that search in the registry for each of the file entries and manually delete them. After that restart your machine. So u will be out of that little dragon. a old copy of svchost.exe and xcopy.exe will be written back into your machine.

To check whether the virus got cleared or not, by observing the file properties of these two files. They must indicate the company info as 'Microsoft Corporation...'. If they are not from microsoft corporation, and anything which are residing in system32 directory must be from microsoft, else u can suspect of a malicious entry. After successful removal of the virus, u can continue by checking the system restore monitoring.

Monday, December 18, 2006

Another humorous cartoon from Sridhar

నిన్ను మెడిసిన్ చదివించాను, నా ఆస్తిపాస్తులన్నీ ఇచ్చాను, చక్కటి పిల్లను తెచ్చి పెళ్లి చేశాను, రాజకీయంగా కూడా నిలబెట్టాను.
నన్నెందుకురా బద్నాం చేస్తావు.......

Friday, November 24, 2006

Dynamic Memory Allocation in C, C++ - my strange experiences with gcc and g++

Yesterday i learnt few strange things about malloc() in C and new, delete operators in C++.
Compiler referred is gcc for C, and g++ for C++ programs.

First one:
int *a=malloc(sizeof(int) *0); //i am trying to allocate 0 bytes of memory and pointing that location with pointer a.
==> What should happen, Segmentation fault( run time error) , since allocating 0 bytes of memory is absurd and then referencing it through a pointer a is too wrong. It went through compilation and run perfectly on 'dereferencing' as a[0]=5, a[1]=2,... .
==> But i get segfault when i am trying to allocate -ve bytes of memory.

Second one:
int *a= new int[0];
==> the same effect with 0 size memory allocation and runtime error when trying to allocate (-ve)size of memory.

Third one:
This one, i strongly beleive that it sould raise runtime error, as it is mentioned in C++ standards.
int* a=new int[10];
......
delete a; //Here it should be delete[] a;
==> When an array of objects are created with new operator, while deleting all objects, we should use delete[], instead of delete; since delete will only delete that object.

Fourth one:
Do you think that on freeing or deleting the dynamic memory, the contents/memory locations will be deleted permanantly? No, it shouldn't be. The compiler will just cut of those associated links and the memory locations still with the content that we have assigned. If u want to try, assign the locations to other pointer before freeing/deleting.
My experience is:
int *a=malloc(sizeof(int)*4);
a[0]=1;a[1]=2;a[2]=3;a[3]=4;
int *t;
t=a;
free(a);
printf("%d , %d , %d , %d ",t[0],t[1],t[2],t[3]);
//Answer is "0 , 2 , 3 , 4"

int *a=new int[4];
a[0]=1;a[1]=2;a[2]=3;a[3]=4;
int *t;
t=a;
delete(a);
printf("%d , %d , %d , %d ",t[0],t[1],t[2],t[3]);

//Answer is "0 , 2 , 3 , 4"

==> I am not able to figure out the logic behind making the value of base address to 0 upon deleting. If it is to make value of deleted location as '0', then it should be with all the locations that are dynamically created. But it isn't. And also one more thing is 'write' operation is more costly than delinking.

Your comments are appreciated, if you have proper reasons.

Tuesday, November 21, 2006

Thy Self in Johari Window - an update

This post is a follow-up to my previous post, and i thought that i could update it. Thanks to those for putting their effors on letting me know better.
If you want to know more about johari window (Jeo-Harry window), please visit the following links.

http://en.wikipedia.org/wiki/Johari_window
http://kevan.org/johari
http://www.noogenesis.com/game_theory/johari/johari_window.html
http://business.nmsu.edu/~dboje/503/johari_window.htm

Saturday, November 18, 2006

BhimaShankar - One of the 12 Jyotirlingas


Last Saturday i went to BhimaShankar, which is located in the Western Ghats mountain range near to Pune. The distance is 110 km from Pune, and we (me, my friend Sridhar and two of his roommates) went by a cab. The journey is thrilling and the place is located in the far end of the Sahyadri Mountain range. Our trip is just a Half Day only, as we just want to dharshan the Swayambhu Linga. Bhimashankar is also the origin of Bhima River which merges up with Krishna river at Raichur.

This jyothirlinga is one of the famous and ancient ones, which was associated with lord 'Shiva', and has formed upon destroying the demon 'Tripurasara'. If you want to know more about the story and, its formation, refer to this page.

It is believed that the ancient shrine was erected over a Swayambhu Linga or a Self Emanated Shiva Linga. Thus the Linga is exactly in the centre of the floor of the Garbagriha or the Sanctum.

This place gives a wonderful view of Mumbai (ofcourse, which we hav been able to view due to fog), and the hill stations around. Its not more than a pilgrim’s paradise, also a trekker’s delight and traveller’s sojourn. But the ghat road is not so good, and if you opted to go by bus, you will definitely face inconvenience.

This place is good for trekkers as one of the hill is almost 90-deg slope, in the Mumbai side, and i came to know that many trekkers love to climb it. And it is also an extremely dangerous place, if slipped, 100% chances of no survival.

In the near bottom the main hill, there is one point which is said that as origin of the Bhima River. But the disappointing thing is that the Linga was covered up by a silver coating. We came to know that the cover will be released daily twice, once in the early morning 4.30 , and midday 12.00-12.30 pm. The darshan time starts early from 5.30AM and Maha Puja went at 12.00-12.30pm.
Some of the pics that we have taken in the journey.









Thursday, November 09, 2006

I am delighted (and a bit busy..)

ఈ రోజు నాకు చాల సంతోషంగా ఉంది. కావలసినంత తెలుగును చదివాను. కొన్ని రోజుల నుంచి నేను అనుకుంటున్నా నాకేమీ పని లేదు, లైఫ్ బోర్ కొడుతుందని. కాని నిన్నటి నుంచి నేను చాల బిజి. కారణం ఏంటో తెలుసా? చాల మంది తెలుగు బ్లగర్స్ వున్నారని తెలుసుకుని, వాళ్ళ బ్లాగులు చదవటం మొదలుపెట్టా. ఇంకా చదువుతూనే వున్నా.

అసలు నాకు తెలుగు ఎందుకు చదవాలని అనిపించింది అంటే, చాలా రోజుల తర్వాత నేను తెలుగులో ఉత్తరం వ్రాయల్సి వచ్చింది, మా మామయ్యకు. ఉత్తరమే ఎందుకు, ఫోన్ చెయ్యోచ్చుగా అనుకుంటున్నరా? ఒక చెక్కు పంపాల్సివచ్చింది. ఉత్త చెక్కును కవర్ లొ పెట్టి పంపలేముగా, దాంతో ఏవో కొన్ని మాటలు రాద్దామని పేపర్ తీసుకున్నా. అంతే! నాకు తెలుగు రాయటం రావట్లేదు. ఎంత ట్రై చేసినా ఇంగ్లీషులోనే పదాలు వస్తున్నాయి. చివరికి నాలుగు ముక్కలు రాసి పోస్ట్ చేసా. ఇంక అప్పుడు నిర్ణయింఛుకున్నా నేను నా తెలుగు ప్రతిభను తిరిగి తెచ్చుకోవాలని. (నా తెలుగు రైటింగ్ చాలా బాగుండేది, కాని ఈ ఇంజనీరింగ్ చదువులు చదివి అంతా మర్చిపోయా.)

వర్తమానంలోకి వస్తే, ఇప్పటి వరకు నేను కొన్ని తెలుగు బ్లాగులు మాత్రమే చదివాను. వాటిలో శోధన, చదువరి, గడ్డిపూలు, స్వాతి కుమారి, క్రిష్ణదేవరాయలు, స్నేహమా, మరి ముఖ్యంగా వీవెన్. ఇంకా నేను చదవ వలసిన బ్లాగులు చాలా వున్నై. వాటిని రేపటికి వాయిదా వేస్తూ....

- ఉమా..

Wednesday, November 01, 2006

మా తెలుగు తల్లికి మల్లెపూదండ (Maa Telugu Talli ki Mallepoodanda)


On the Occuaction of Andhra Rastra Avatarana Dinostavam!

Tuesday, October 31, 2006

**Casino Royale** - A Prequel , Reboot and Retcon


"Casino Royale" the name reflects the gambling game where gamblers earn more money fooling the players. Casino Royale is the latest Bond movie to be released on 17'Nov. Its being directed by Martin Campbell, who had directed the movies like "Golden Eye", "Vertical Limit", and "Mask of Zorro". Being a big fan of James Bond i am awaiting for this adventurous venture's release. This new venture is coming with lots of changes from the previous bond movies, and first of all new bond is introducing, Daniel Criag'. Looking at the posters im not able to digest Daniel Criag as James Bond. I still prefer to watch Peirce Brosnon as Bond even he is older.

My curiosity towards Bond movies thrown me to search for new information regarding the Casino Royale. I came to know many interesting points about this venture and may be it is the reason that Brosnon asked for more remuneration. The Casino Royale is the First ever novel of James Bond series written by Ian Flemming. Its going to show James bond differently from the previous sequel. Its a bit serious and non-comedic adaptation of Ian Flemings Story.
Title of this post reflects that its a prequel, reboot, and retcon of the Bond movies. Why it is a prequel is that the story will tell us the necissity of born of James Bond which was narrated by Ian Flemming. Its a Retcon (Retroactive Continuity), coz its going to show something different in JamesBond from the older sequel. And its a Reboot, since Pierce Brosnon was retired from Bond Character and New Bond, Daniel Criag, was adopted.
This movie is against terrorism and Criag is about to stop winning a bank in the Casino Royale game which supports the terrorist groups. Lets wait till Nov'17th to watch the new Bond and his (new)Bond girls.
Note: Eon Productions decided to take another Jame Bond venture with Daniel Criag. Could it be expected that Craig fits well into Bond character?

Sunday, October 15, 2006

State of Mind, an experience!

After a long gap of more than two months, i am back to blogging. This post is abt my experience of Soft skills session in our training schedule. I enjoyed this session more and particularly the games which we played individually and as a team learnt us many things which we were not aware of. This is what is terms in behavioural science 'hiding due to blindedness'. Many of us feel that a typical puzzle or game can not be solved by myself, without any others help. But we did came to experience physically as its only our perception of being tough. We played games like 'BrainLock', 'Gammat-Jammat', 'Ring Toss', etc.. But all these games are not only involving analytical thinking, but also requires technical fundas which we might have learnt in school days. Particularly when it comes to the BrainLock game, its too difficult to crack it, without the technical clue, the centrifugal force.
While playing these games, my state of mind is sometimes puzzy and sometimes i forcedly kept it to peaceful to solve the puzzle. But its founded that to solve any kind of problem, our state of mind must be peaceful, for getting the better and productive results.
I want to dwell more into this behavioral science to deal with large number of people. Shd anyone help me out there any kind of books or practices u came across?

Thursday, July 27, 2006

Destination@home

I am presently at my home, enjoying home food. I completely switched on to home food within one day, after 7 months long gap, thank god. My stay will be for 2 weeks and 'll left to Pune to join in Amdocs. I need to get police clearance, get ICNR stamp on my passport, and have to meet all my old friends.

Friday, July 21, 2006

I am Graduated

Yeah!
I am graduated, at last!. I successfully finished my Masters in Software Engineering. Now i can sleep more than 6hrs a day. Its time to get out of all the tensions.
Thank god, and to my thesis supervisor, Prof. B. D. Chaudhary, without his help, i may not get degree with better satisfaction.
I have a strange feeling, but i dont know why it is so? Everyone have feel that they are leaving MNNIT, spending 2 yrs here, and when its time to leave, they are getting little bit senti. But i dont have such feelings, and that too im feeling very happy as a prisioner gets released (may be my comparision is not so effective).
My overall satisfaction is good. But only having a little bit angry on MNNIT, that no one recognize a graduate's worth, and even every one try to degrade their confidence level, only a few professors know how to extract the good output, upto their expectation, and my supervisor is one in that list.
But overall MNNIT is a good place, i learnt how to live, the infrastructure is good, need to be amended.

Friday, June 30, 2006

An excerpt from A Film by Aravind

కలయో మాయో నువు కలసిన ఈ పూట
వలపో గెలుపో ఇరు మనసుల ఈ ఆట
నీ చెలిమి నాకు కొత్త భాష నేర్పగ, ఊసులన్ని పెదవి చాటు చేరగ పాడిన ఈ పాట
తొలిప్రేమకే సరిలేదని, తొలిస్పర్శక ఎదురేదని చెబుతున్న ఈ మాట

On request from vikram i am editing the above master piece, i like it very much, in english:

kalayo mayo nuvu kalasina ee poota,
valapo gelupo iru manasula ee aata,
nee chelimi naku kotta bhasha naerpaga, oosulanni pedavi chatu cheraga paadina ee paata,
tholi premake sariledani, tholi sparsake eduraedani chebutunna ee maata!

vikram, hope u understand it.

Wednesday, June 28, 2006

Browse by name

Its not rather a new concept to the techies, but i havnt find it till i had an exiting experience with my flock browser yesterday. I used to type the website full address along with the http://, but yesterday, while browsing, i forgotten to press "Ctrl+Enter" after typing google, just pressed "Enter" button. I thought that it may raise DNS error. Its a surprise for me and it wents to display the google home page. Then later i tried to type "ICDE 2007", which goes to the page http://www.srdc.metu.edu.tr/webpage/icde/ . Later i think of why this is happening , even our DNS sometimes not able to resolve some new site names and it will take some time to refresh its DNS entries. I keep on tried some more key words and came to know that it is only being done for some of the keywords. Later i came to know that this is what people call "Browse by Name". Its a feature being added in Google toolbar for IE. As if any new feature is added in IE, it'll definitely done in Firefox. When it is being done in IE with Google toolbar, its being directed me either directly to a corresponding site or google search page. But with the Flock broser, which i use often, it tries to redirect to the first site based on a combination of keywords. I forgotten to mention, Flock is a Web browser based on the Mozilla code base. It has most of the Firefox features with extra features.