Book Review - CSharp for Sharp Kids

Using real-world analogies, Martin Dreyer does a great job of explaining the introductory concepts of C# & OOP to absolute beginners in the free E-Book C# for Sharp Kids. The 2.9 MB MSI file, containing the E-Book in MS Word format & code samples, can be downloaded from the Kid's Corner of MSDN's Beginner Developer Learning Center. The code samples are expected to run with Visual C# 2005 Express Edition but you can get it to work on a newer version of the Express Edition as well.

Although this text is targeted at young developers (aged between 12-16), it is equally good for folks of any age wanting to learn about programming with C#. Spread across 5 parts & about 165 pages, it is light-hearted & filled with meaningful cartoons. Here are a couple of samples -





Once readers finish the book, they will be able to build simple Console & Windows applications. It will also whet their appetite to know more about C#.

I highly recommend this book to those starting to learn programming with C#. What's more, it's free as well.
90
Read More

Internet Banking risks - Phishing, Vishing & now SIM-swap frauds

ICICI Bank has been running a Customer Education Series in Indian newspapers & they are one of the few Indian banks that bother to educate the public about banking facts that are not generally known. The columns in the series are available on the Web only as PDFs (AFAIK) & they do not seem to be easily reachable.

I've heard of Phishing & Vishing, but SIM-swap fraud was news to me. Excerpt from a today's column on SIM-swap fraud -

Your mobile phone is now also a convenient banking channel; but it can make you vulnerable to SIM-swap fraudsters if you do not take some simple precautions.

How do SIM-swap frauds occur?
• The fraudster obtains your mobile phone number and bank account details through a phishing e-mail.
• He asks your mobile-phone-service provider for a replacement SIM card under some pretext, like changeover to a new handset or loss of SIM/handset.
• The service provider deactivates your SIM card and gives him a replacement SIM.
• The fraudster introduces a payee into your bank account using the phished data, transfers funds from your account to his and withdraws the money through an ATM.
• All this while, your service provider's alerts don't reach you because your SIM card has been deactivated.

What are the safeguards that should be taken?
• Never respond to phishing e-mails.
• Do not disclose your mobile phone number on websites.
• Change your banking passwords frequently.

If you find your mobile number inactive for an unusually long period or abruptly barred from calls; or if it displays limited access or says the SIM is inactive; contact your service provider without delay and find out the reason.
Read More
"Export to Excel" without using components in a WinForms app

"Export to Excel" without using components in a WinForms app

Way back in 2004, I wrote a program to generate a Word file dynamically without using any components in a Web application. The technique I used makes use of the fact that documents can be converted from Word/Excel to HTML (File->Save As) and vice versa.  When you manually save an Office document as a Web page, you can see from its source that it renders some interesting HTML, CSS & Office XML. By understanding and emulating this conversion technique programmatically, we can generate Word or Excel documents through web pages.

This snippet shows how you can generate a report in Excel format in a web application after fetching data from a data source using the Office XML technique -

System.Data.DataTable workTable = new System.Data.DataTable();

//The tablename specified here will be set as the worksheet name of the generated Excel file.
workTable.TableName = "Customers";
workTable.Columns.Add("Id");
workTable.Columns.Add("Name");
System.Data.DataRow workRow;

for (int i = 0; i <= 9; i++)
{
workRow = workTable.NewRow();
workRow[0] = i;
workRow[1] = "CustName" + i.ToString();
workTable.Rows.Add(workRow);
}

string strBody = DataTable2ExcelString(workTable);

Response.AppendHeader("Content-Type", "application/vnd.ms-excel");
Response.AppendHeader("Content-disposition", "attachment; filename=my.xls");
Response.Write(strBody);


A complete working sample & a detailed explanation of the code are available.

A developer wanted to know how this method of converting a datatable to Excel can be adapted for a Windows Forms application.

The trick to generating the Excel file in a web application involves creating a HTML page containing some special CSS & Office XML and triggering a file download with the help of the following Response.AppendHeader statements -
Response.AppendHeader("Content-Type", "application/vnd.ms-excel");
Response.AppendHeader("Content-disposition", "attachment; filename=my.xls");


To use this technique in a Winforms application, the string content representing the HTML page (containing the special CSS & Office XML) needs to be saved as a text file and the file should be given an extension of ".xls". The last 3 lines in the snippet above which are irrelevant in a WinForms app  can be replaced with this line -
System.IO.File.WriteAllText(@"C:\Report.xls", strBody);

Also see:
HOW TO send an email with a Word or Excel file attachment built on the fly
60
Read More

Google Script Converter transliterates between Indian languages

If you can speak & understand one of 11 Indian languages (Bengali, Gujarati, Hindi, Kannada, Malayalam, Marathi, Punjabi, Sanskrit, Tamil, Telugu and Urdu) but cannot read in that language, Google Script Converter can help you out by transliterating it into a language among them that you can read or to English. So let's say you are a Hindi speaker living in Hyderabad who can understand Telugu but cannot read local news in an online Telugu newspaper like Eenadu. To start reading Telugu in Hindi, English or whichever of the other  Indian languages supported by the tool, you have to copy a site's content & paste it within the text-area in Script Converter.
Telugu text in Hindi (click on the image to see a larger one)

This is a great tool for those trying to learn new Indian languages. To take this a step further, I wish there is a text to speech tool that can work well for Indian languages. I found that regular text to speech tools can speak out English words properly but not words in Indian languages transliterated to English.

Try it out: Eenadu in English

Also see:
Read Telugu news sites in transliterated English
Voice of Opera
36
Read More

"Open With Google Docs Viewer" IE8 Accelerator

Accelerators in IE8 work on text within a web page & let you access popular web services from the context menu. For instance, to translate a word you can highlight text from any webpage, and then click on the blue Accelerator icon that appears above your selection & choose the Translate with Live Search Accelerator.

I recently built a "Open With Google Docs Viewer" IE8 Accelerator that lets you view a PDF, Powerpoint or TIFF document on the Web without downloading it to your local computer. Once installed (click on the button on this page), you can use this Accelerator to view any files of those formats within the browser with Google Docs Viewer. It is also helpful when you don't have the supporting application to open the file with. Once the file is opened within Google Docs Viewer, you can choose to download or print or edit it online in case it is a .PDF or .PPT file.

It's easy to build Accelerators and you can find plenty of independently developed IE8 Accelerators (and Web Slices and Search Providers) like my favorite "Find on LinkedIn" Accelerator in the IE 8 Add-ons Gallery.

I submitted one a while back & wish the site's interface to contribute was more explicit & intuitive. To start contributing you have to click on the "Join" link on the top right corner of the Add-ons Gallery home page to create an account. Once you are signed-in, its not immediately obvious where you have to upload your Accelerator XML file. You have to click on your user name after signing-in to reach the Upload page where you have to provide details about your Accelerator. It is published on the Gallery after a Review. It would have been better if names of the contributors were shown once they are listed on the Gallery.

Also see:
HOW TO open a PDF or Word .DOC file within the browser
 48
Read More

Screen scrape with jQuery, AJAX, JSONP & YQL

Since reading this excellent article about scraping content from a Wikipedia page using Yahoo! Query Language (YQL) as a proxy for cross-domain Ajax, I'm hooked to YQL. YQL helps in circumventing the same-origin policy that prevents a script loaded from one domain from getting or manipulating properties of a document from another domain.  YQL has been around for about 2 years now & last year Yahoo introduced the capability to execute the tables of data built through YQL using JavaScript.

Ajax, jQuery, JSONP (JSON with Padding) & YQL make a heady combination - check Christian Heilmann's code samples.

Some facts about YQL from around the Web (work in progress) -
* YQL is a hosted web service that can scrape HTML for you. It also runs the HTML through HTML Tidy and caches it for you.
* It only returns the body content of the HTML - so no styling (other than inline styles) will get through.
* ...it treats the info on the web as a virtual table that developers can manipulate in a standardized way, regardless of the API that data came from.
* YQL understands and supports data sources like RSS, Atom, JSON, XML, CSV, HTML, Flickr, Yahoo! Finance, Weather, and so on.
* ...makes client-side mashups possible without using server-side proxies.
* Usage Limits:
Per application limit (identified by your Access Key): 100,000 calls per day
Per IP limits: /v1/public/*: 1,000 calls per hour; /v1/yql/*: 10,000 calls per hour


Also see:
HOW TO prevent screen scraping 
Google Spreadsheets functions for scraping external data
77
Read More

Deleting cookies doesn't clear Hotmail's "Remember me" in IE8

An anxious Hotmail/Passport user was bothered that in IE 8 his Accounts showed up even after deleting cookies. He posted this concern on the MSDN IE Web Development Forum.

I verified this in IE 8 (on Windows XP SP2 & Vista) by clicking the Delete button in the Browsing History section in the General Tab of Internet Options. I believed this "Remember me" feature depended on cookies & should go away on deleting cookies. I even closed the browser & re-opened the browser after 10 minutes to see the user name still there. On deleting cookies in Chrome though, the user name does go away.

I found that in the Hotmail/Windows Live Sign In page, only on clicking the X mark that you get on hovering near the user name (which represents "Don't remember this Windows Live Id") can you make the credentials go away.

I checked with my Indian MVP colleagues what the reason could be for this intriguing behavior in IE 8. I got to know from Windows Client MVP Ramesh Kumar that this is because of the Windows Live Sign-in Helper, an IE 8 Add-on that is enabled by default.

The purpose of this Windows Live Sign-in Assistant is to provide sign-in support for multiple IDs. It has been provided to make the sign-in experience faster and more convenient for users that have more than one Windows Live ID account.


So this explains the mystery of the credential persistence for those who are not aware of this IE 8 Add-on. The Windows Live Sign-in Assistant article explains what you can do if you don't need this feature -
If you decide that the Sign-in Assistant is not for you, you can disable it by going to the Tools menu in IE, selecting “Manage Add-ons”, highlighting “Windows Live Sign-in Helper”, and then choosing “Disable” in the settings box.  Alternatively, you can remove it permanently by using the “Add/Remove Programs” dialogue in the Control Panel (it shows up as “Windows Live Sign-in Assistant”).

Also see:
HOW TO create your own IE8 Accelerator
50
Read More

View Selection Source in IE

One of the features I like in Firefox as a developer is the "View Selection Source" option that you can choose  from the context menu to view dynamically rendered source of a desired portion of the web page. This feature helps you focus on a specific portion of a web page that you want to investigate instead of getting the entire HTML source.
IE 8's Developer Tools lets you view the HTML source for selected content as well but using it is cumbersome. After invoking Developer Tools (Tools > Developer Tools or F12 key) with the HTML tab open, you have to select an element in the DOM Explorer & then choose View > Source > Element Source with Style. That's about 5 steps compared to just a single step in Firefox.

Patrick Clancey has shared a bookmarklet that will let you view the HTML source of a selected portion of a web page within an alert window, in just a single step. Follow these steps to install the bookmarklet in IE 8:
  • Scroll down to the bottom of this page.
  • Right click on the link View Selection Source
  • Select "Add to Favorites..."
  • In the "Add a Favorite" dialog box that opens, select Favorites Bar from the dropdown opposite to label "Create in"
  • Click on the Add button
From the menu, select View > Toolbars & select the Favorites Bar to see the bookmarklet appear below the address bar.

To use the bookmarklet, select the content you want to view the HTML source of and click on the View Selection Source bookmarklet. The source will show up in an alert window

Also see -
IE8 Developer Tools Tips & Tricks:
#6: Count links in a page
#5: Find Link Paths
#4: Edit CSS Visually
#3: Customize HTML Source Viewer
#2: Script Console
#1: Color Picker
Read More

HOW TO get files cached by Safari & Firefox

Unlike in IE 8 where you can view temporary files easily (Tools > Internet Options | General | Browsing History | Settings | View files), fetching temporary files that are cached is not straight-forward in Safari on Windows & Firefox.

I learnt from this WebmasterWorld forum posting that on Windows XP, the file-path for the Safari cache is something like this:
C:\Document and Settings\[username]\Local Settings\Application Data\Apple Computer\Safari

The cache file is named Cache.db - it's a .db file in the SQLite format.


In Windows Vista, the path of the Cache.db is C:\Users\\AppData\Local\Apple Computer\Safari (assuming you have installed the OS on the C Drive)

As explained in that thread, files like images are stored in Blob format within Cache.db file. These can be viewed with a tool like SQLite Maestro which includes a BLOB Viewer.

To retrieve files from the cache in Firefox type about:cache in the Firefox address bar.


In the page that opens up, click on the “List Cache Entries” link of Disk cache device section. This is where large files like Flash files are cached.

On a related note, I got to know from a recent experience that Google may not store images of the pages that it caches nor does the Wayback Machine archive every website.
Read More

Read this if you are installing VS 2010 Web Developer Express on Windows XP

Be aware that the installation of Visual Web Developer 2010 Express on Windows XP will work only if it has SP3. I guess this holds true for other Express products as well. I didn't find an explicit page describing the minimum system requirements and I learnt about this by trial & error or rather after reading this thread on the IIS.NET Forums after encountering the error. The post also provides a link to an ISO image of Windows SP3 (544.9 MB) in case you need it. You can use an open source tool like 7-Zip (that also does compression) to extract files from the ISO file.


The setup for Visual Web Developer 2010 Express requires Web Platform Installer (WebPI) to be installed. In my case, after I executed the Installer, I expected it to drive me through the steps but it suddenly fell quiet. I had to go to Windows Start > Programs to see Web Platform Installer there, activate it & proceed further.

If you run into any other issues with the Web Platform Installer,  the WebPI section on the IIS.NET Forums is probably the best place to look for answers.


Unlike the VS 2008 comparison of editions, the VS 2010 comparison of features among editions does not include the Express edition (yet)

Read More

Free Photos & Images

Images & illustrations make content lively & sticky. Commercial websites can affoard to pay for slick images but thankfully for the rest of us, there are a good many sites that offer free photos & images.

I spotted a list of over a dozen such sites with liberal licensing policies on the morgueFile website (at the bottom of the home page). morgueFile allows usage without attribution.

Smashing Magazine also has a nice compilation of free stock photography sites.

Here are a few more obvious & popular ones that both the lists missed (sites are linked to their pages on licensing terms):

Read More

TechEd India 2010 starts with a Bang

The 3-day TechEd India event started in Bangalore with a keynote by Somasegar, Senior Vice President, Developer Division, Microsoft. He announced the availability of the much awaited Visual Studio 2010 & and .NET Framework 4.

(Photo by @msigeek)

If you are missing the event (like me), catch the action on the slick TechEd India website. While you are at that site, there's a neat Silverlight-based Win-a-Min Quiz contest that you should try out. The contest is going to run between 9:30AM to 7:00PM during the event days & its open to everyone in India. They are giving away movie tickets every couple of minutes during that time.



Many Indian MVPs are tweeting about the event & you can tune in to that as well for live updates.

Also see:
Developer Contests
Read More

My favorite jQuery plugins

jQuery, John Resig's brain-child, has an irresistible charm that attracts legions of followers. Many of these followers selflessly share plugins they create for free. So if you have seen a clever, dazzling, intriguing, laborsaving, mind-blowing, {add your favorite adjectives} client-side feature on some site, the odds are high that there is already a jQuery plugin for it.

For long I have smirked at folks who post their compilation of favorite jQuery plugins with attention grabbing titles like  "37 More Shocking jQuery Plugins", "37 Phenomenal jQuery Plugins..", "75+ Top jQuery Plugins.." but now I know how hard it is know to about some amazing plugin & keep it to yourself. I wouldn't want to forget the beautiful ones that I've benefited from, so here goes my list of favorites (work in progress) -
  1. JCrop - to crop images programmatically
  2. SearchHighlight - Highlights matched words on a search results page
  3. jQuery-gestures - adds mouse gestures to a webpage
  4. imgAreaSelect - select a rectangular area of an image to crop or annotate
  5. Image Annotation plugin - to add an annotation at a desired position on an image
  6. AutoComplete - "autocomplete" an input field to enable to users quickly find and select some value
  7. Multiple File Upload - upload multiple files at once
  8. quickSearch - for searching through tables, lists, etc quickly
  9. jGrowl - to show fading & sticky message boxes
  10. Pagination - ~5KB plugin to add paging to result-sets

The official jQuery Plugins site accepts plugins from contributors & publishes details in a standard format. The good thing is they come with a demo that you can try out.

I feel the best way in which developers making use of the plugins can help this effort is by rating submissions & reporting issues for the common good.
Read More
Comparison of free Web Analytics tools

Comparison of free Web Analytics tools

There are a bunch of free Web Analytics tools -
  • Google Analytics 
  • StatCounter 
  • Piwik 
  • Woopra 
  • Clicky
  • SiteMeter
Each of them has something unique. The Clicky website compares all the above across some 40 odd parameters.

Except for Google Analytics & Piwik, the rest have limitations on features with their free editions. They restrict the data retention size & period.

Piwik is a downloadable, open source (GPL licensed) real time web analytics software program that uses PHP & MySQL. It needs to be installed on your server, so you own your data.

The number of hits captured by each of the tools for the same site could vary. This could be because some tools like Google Analytics use JavaScript & a user may disable it in their browser. Some of these may not count bots and some register hits based on user's visit length.

Also see:
HOW TO generate a Heat Map with Google Chart API
Read More

Book Review: Head First PMP

I purchased Head First PMP after a PM friend recommended me that book as a good starter guide to taking the PMP certification. As he mentioned & others have vouched, no one book including this one can help you pass the exam. What this book does is that it makes learning Project Management concepts enjoyable. This was my first book in the Head First series. I liked the book's unusual, non-linear style (with things like notes in the margins) of presentation although the excessive use of goofy pictures put me off a bit. The tone throughout is very informal, friendly & conversational which makes the guide engaging.

The 42 processes which form the core of the PMBOK (Project Management Body of Knowledge) Guide, 4th Edition and cross-cut 9 Knowledge Areas & 6 Process Groups are explained well. Processes grouped by Knowledge Area make up a chapter. Besides the 9 chapters focusing on the Knowledge Areas, there are 6 more which cover the preliminaries & practice tests with answers. Important points in them are reiterated & highlighted. 2 complete chapters including a Practice test are available for free download. You could check these out & see if the book suits you before you buy it.

On the negative side, there are some typos & errors that you would have to look out for. I found some of the examples in the book to be too unrealistic & contrived to be of practical benefit.

Summary: Whether or not you are taking the exam, I feel this is a good guide on Project Management to start with if you are an aspiring PM or one by circumstance.
Read More

Tried these Hotmail, GMail features?

Email service providers have now gone way beyond just fetching & sending emails. Did you know, Hotmail has a SMS alerts feature that notifies you whenever an important e-mail (you can define what's important) arrives in your Hotmail inbox? (Ofcourse, if you are always connected to the Internet from your mobile, this may not sound like a novelty)

I was impressed with GMail's Auto-unsubscribe feature after noticing it today. Let's say you spotted in your GMail inbox, a newsletter that you are no longer interested in or a message from a list group that you don't remember subscribing to. When you mark such a message as spam by clicking on the "Report Spam" button, you may see a dialog box that asks if you want to report spam as well as Unsubscribe from that list.


Once you click on it, GMail will send a request to the sender on your behalf that your email address be removed from the list. The Unsubscribe option is not available though for all mailing lists and this option won't  be shown for lists that are known to be owned by spammers.

You can try a bunch of other similar tricks by going to the Gmail Labs feature from the Settings link that's at the top right corner after you are logged in.

Also see:
A Spooky (but fun) incident with GMail
HOW TO fetch unread emails from a mail server
HOW TO send an email programmatically using C# with GMail

..
Read More