Reflections of a scattered Mind!!

"Not all scattered pieces are of broken glass"

Doing Things the HTML Way

Hi,

Some points that come into handy while developing in HTML:

  • Always use XHTML tags. meaning that, your HTML should be well-formed XML (closing  & ending tags should be present). Like, for example, use <br/> instead of <br>
  • Try to use XHTML 1.0 strict as much as possible. But, this mode doesn’t support target attribute on anchor (<a>) links. If you need to specify ‘target’ on links, they you should be using XHTML 1.0 transitional doctype.
  • Always specify the doctype of your HTML page. Also just run the validator test available at w3c.org to know where are deviating from the standards specified. And fix as much as possible to make it closer to standards.
  • IE doesn’t support *.ico [Icons] files as images in <img> tags. So, make sure that your images are NOT ico types.
  • Are you developing site in non-English language? Then, knowing about Dynamic Fonts is a must before implementation. Try to find more about it from Google ( I have no experience with them to tell you :-( )
  • A common bad practice among beginners: Uploading a large image to the server (like, 1024 * 768) & then set required image & height(200 * 150)  in HTML. This would cause unnecessary bandwidth waste which can be easily avoided by uploading the resized image of the desired dimensions.
  • You should learn about ‘Alternate Style-sheets’ if you wanna provide multiple themes to the webuser. Basic usage of this can be found at: http://javascript.about.com/library/blswitch.htm
  • One important, yet highly ignored practise, is providing a Print specific stylesheet for the page. This is possible by specifying media=”print” on the stylesheet link, like <link type=”text/css” rel=”stylesheet” href=”/css/print.css” media=”print” />. And, let all the unneccesary data be hidden in this css file (like, ads, navigational menu, header, search bar etc.). Keep the print to minimum.
  • It would also look good if we provide the end-user a ‘Print Preview’ from inside our page itself. This isn’t any magic, its similar to multi theming concept as said above.

Yes, I understand these are very basics, but don’t we know that Basics are the building blocks of any application?

Update: The Print Preview concept is borrowed from
http://www.alistapart.com/d/printtopreview/example.html.
Click on ‘Print this Page’ on the LHS of the page & see that page layout changes, giving the user the Print Preview Experience

GTalk: Display Images Cache

In my last article, I talked about the way of obtaining a user’s display image in Yahoo! Messenger & Google Talk, over the internet through http protocol (the browser way). In this case, it is the browser’s decision about the cache to be used for those images. But, the IM client Applications(googletalk.exe, YahooMessenger.exe) are stand-alone applications. And we do not expect them to fetch the display image on the fly over the wire from the internet, whenever the image is to be displayed. The most simple, obvious but yet powerful solution is  to maintain the cache of images on the disk.

Now, my point of this article is, what is this cache location of images, so that I can easily navigate over to there and pick a friend’s avatar from there..  :–) Well on Windows Systems, the display images cache directory for GTalk is:

1
C:\Documents and Settings\<windows username>\Local Settings\Application Data\Google\Google Talk\avatars

The images saved in there are PNG files with transparent background, so you can open them with basic image application [maybe, you need to change the application extension to .png]. Do you observe there are two images for each id  there ? One image is 32 x32 [ends with .online.avatar] and the other is 96 x 96 px image [ends with .original.avatar].

You can find much more information about GTalk at http://www.customizetalk.com. This site has some useful information all about the GTalk Themes Development, GTalk Bots Development and many other interesting [and not complicated at the same time] stuff.

Its fun as well as  interesting to find how simple a powerful application can be. Sticking to development basics :)

Update: Find some interesting Google Talk emoticons & their string equivalents here : http://tkhere.blogspot.com/2007/12/brand-new-google-chat-emoticons-no-one.html

Display Images in Instant Messengers

Have you ever felt while chatting that your friend’s display image is awesome ? If you ever felt so, the most obvious thing you’d try to do next is save the image [so that you can use it later on some purpose]. But, in general, the messengers do not support saving the display images [No, you can’t just right-click on the menu & select Save]. Well, I just explored & experimented a bit with Google Talk & Yahoo! Messenger to check how to access the display images through an http url? So, here are my results:

  • Yahoo! Messenger: The display image of all the users are publicly available on the web. To access the avatar / display image of a user whose Y! Id is yid, then just navigate to: http://img.msg.yahoo.com/avatar.php?yids=yid
    Here comes a shock now !! All images are publicly available, meaning that everyone has permissions to save your image onto their disk.
  • Google Talk: I’m not really sure where the images get loaded from on GTalk, but on the GTalk plugin available on GMail, the images are loaded from: https://mail.google.com/mail/photos/username@gmail.com, where the username is the user’s Google username. On contrary to the Yahoo! Security Settings, these images are NOT publicly available. You cannot access the images of users who are not in your friends list. Also, this URL checks for your valid session, meaning that you need to be logged into GMail to access these images.

I was actually wondering if there is any tool which can list me all the data-transfers happening b/w my IMs & the host sites? Wouldn’t it be wonderful if we know all the endpoints of an IM server, the message formats etc. [We can probably develop our custom messenger for that IM service, if we get to  know those details :)]

Well, now girls [especially Indians, who are conservative] should give a thought before uploading their display image, if they do not want their pictures to fall into wrong / unwanted hands.

Now, its time to have fun by tricking your pals by their own display images as yours.. :D :D

New Domain

Hi!!

A post from me after a long time, and this time I’ve news to share. I bought a domain name for myself [not a great domain name, though :(]. I found a place to host my site temporarily for a few months.. :)

As can obviously be seen, this is powered by wordpress. I’ve taken a bit time to import all my previous entries into this blog [from Blogger, Y! Blog]. In case, u need any help regarding the first step to migrate from blogger to wordpress, I’m happy to help you…

The main purpose to get a domain is: I do not want to lose touch with web development & i wouldn’t be laxy if its my OWN domain / site. Now that I’ve got a domain for myself, I’m planning to host a few small services on my site. Keep looking this blog once in a while. [I suggest to go for the RSS feed].

Looking forward to develop for my site.. :)

Is Mozilla Firefox More Secure Than Internet Explorer?

Have you ever asked someone why does he/she prefer Mozilla Firefox over Microsoft Internet Explorer? If not, you ask yourself that question. And as I guess (or atleast the surveys say) that the most common answer is:

“Mozilla Firefox is secure, while Internet Explorer is not”

Even that was my opinion also. But well, things aren’t the same as thought about. I was just going through some vulnerability statistics in these browsers and the results laughed at me saying – “Welcome to the real world of security dude!!”
Let me give you some overall statistics on vulnerabilities in these applications.

Secunia Vulnerabilities:

Mozilla Firefox 3.x : 68 (11 highly, 1 less, 2 not critical, others unknown) – 0 unpatched

Microsoft Internet Explorer 8.x : 1 (1 less critical) – 1 unpatched

(Secunia is a leading Security Analyzing organization)

Even though the turnaround time for patches is comparatively much better in case of Firefox, the Internet Explorer has very few bugs (which are even not very critical).

Being a fan of Firefox myself, it was hard to believe the statistics. So I also checked the CVE (Common Vulnerabilities & Exposures) identifiers registered for both Firefox & IE. But even those showed me that Internet Explorer is safe, even safer than Firefox…

Well folks, the next time you ask someone to use Firefox instead of Internet Explorer, please find some other reason (instead of telling it is secure).

Things to Remember for Android !!!

  • android:layout_width and android:layout_height are compulsory for all nodes.
  • The outermost container should contain the attribute: xmlns:android=”http://schemas.android.com/apk/res/android”

Installing Android !!!

Few steps for setting up things before developing applications for Android….

  • Download & Install JRE from http://www.java.com/en/download/manual.jsp
  • Download & Extract Eclipse IDE for Java Developers from http://www.eclipse.org/downloads/
  • Download the latest version of Android SDK from http://developer.android.com/sdk/
  • Download ADT (Android Development Tools) from http://developer.android.com/sdk/adt_download.html
  • Start Eclipse, then select Help > Software Updates > Find and Install….
  • Select Archive and then browse to the downloaded ADT Zip file.
  • You should see the plugin listed by the URL, with “Developer Tools” nested within it. Select the checkbox next to Developer Tools and click Install…
  • On the subsequent Install window, “Android DDMS” and “Android Developer Tools” should both be checked. Click Next, then Finish. Restart Eclipse.
  • Select Window > Preferences… to open the Preferences panel (Mac: Eclipse > Preferences).
  • Select Android from the left panel.
  • For the SDK Location in the main panel, click Browse… and locate your downloaded SDK directory. Click Apply, then OK.
  • Now, lets install an AVD (Android Virtual Device). Navigate to /tools in a command line and execute:
    android create avd --name  #your_avd_name# --target #targetid#
  • Just press Enter when asked to create an hardware profile.

Now you are done with setup……. Happy developing with Android !!!
Start with Hello, World program in the documentation.


Sai Prasad

Quotes I Like :: Vol. II

  • Footprints on the sands of time aren’t made by sitting down. - Proverb
  • Know how to listen & you’ll profit even from those who talk badly. - Plutarch
  • Accept the challenges, so you may feel the exhilaration of victory. - GS Patton
  • If you want to succeed, you must make your own opportunities as you go. - John B. Gough
  • If a man wants his dreams to come true, he must wake up! - Anonymous
  • Blame yourself if you have no branches or leaves; don’t accuse the sun for partiality - Chinese proverb
  • They conquer who believe they can. - John Dryden

Subdomains on Localhost

Intro Developing websites on localhost may sometimes need making of sub domains. Installing and running another server for this purpose is useless, consumes more resources etc. So here is the technique to make sub domains on localhost.

You can also use this to host more than one site on localhost. i.e, you can host multiple sites situated on different folders.

PS: This is for Apache configuration.

Steps

First decide on the subdomain names… for eg: sub.localhost, sub2.localhost, alt.localhost , images.localhost etc.. You can also name www.name.com. (Please note that if there is a site with that name on the net, you wont be able to access that site on the internet.)

Second making these sites to point to 127.0.0.1, for this you can edit the HOSTS file on windows. The HOSTS file found on Windows (and linux too) is like a local DNS (domain name server). When you type a url on the browsers address bar, the domain name is converted to the IP of the server by a DNS lookup by the browser. Now here is the catch … Windows first looks at the HOSTS file before doing any DNS lookup. So we can block certain sites by editing the HOSTS file.

HOSTS file is found typically here …

Windows XP : C:\WINDOWS\SYSTEM32\DRIVERS\ETC
Windows 2K : C:\WINNT\SYSTEM32\DRIVERS\ETC
Windows 98/ME : C:\WINDOWS
Linux : /etc/

The Lines followed by a # are comments and explains how to use the HOSTS file.127.0.0.1 is the IP address that is used to loopback to your computer itself.

Now add to HOSTS line 127.0.0.1 <hostname> Egs:

1
2
3
4
5
6
127.0.0.1 sub.localhost
127.0.0.1 sub1.localhost
127.0.0.1 sub2.localhost
127.0.0.1 images.localhost
127.0.0.1 mysiteonmycomp.com
127.0.0.1 images.mysiteonmycomp.com

Next we have to assign each of these different URL’s to different folders. This is done on the apache conf file. (httpd.conf file situated in apache\conf\ directory). Note that if you are using XAMPP, the virtual hosts file is at apache\conf\extra\httpd-vhosts.conf.

Scroll all the way down the httpd.conf file until you reach about Virtual Hosts. Add for each domain (or subdomain)

1
2
3
4
5
6
7
NameVirtualHost <sitename>:80

<virtualhost <sitename>:80>
    ServerName <sitename>
    DocumentRoot DocumentRoot-see example
    DirectoryIndex index.php index.html index.html index.htm index.shtml
</VirtualHost>

You can also any valid extra parameters also (like ServerAdmin, ServerAlias etc.)

eg:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
NameVirtualHost saiprasad.com:80
<virtualhost saiprasad.com:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "C:/xampp/htdocs/www"
    ServerName saiprasad.com
    ServerAlias www.saiprasad.com
</virtualhost>

NameVirtualHost test.saiprasad.com:80
<virtualhost test.saiprasad.com:80>
    ServerAdmin webmaster@myjoomlasite.com
    DocumentRoot "C:/xampp/htdocs/test"
    ServerName test.saiprasad.com
</virtualhost>

NOTE : All the DocumentRoots must be under the DocumentRoot (i.e; must be a sub-directory) specified in httpd.conf. For example, in XAMPP, the default DocumentRoot is C:/xampp/htdocs. Therefore, the DocumentRoot of any virtual host cannot be given as : C:/xampp/test. The folder must be under C:/xampp/htdocs.

Parallel Programming Minor Test - I

Date : 29.08.2008
Duration : 40 Minutes
Max. Marks : 10

1. Give a CREW PRAM algorithm to merge two sorted lists.

2. Define shuffle and exchange connections in a shuffle-exchange network. Prove that if a shuffle link connects nodes i and j, then j is single-bit left cyclic rotation of i.

3. What is the average number of communication links in the use during Johnsson and Ho’s one-to-all broadcast algorithm on the hypercube?