Thursday, July 31, 2008

Cuil is not-so-cool on day #1

The launch of yet another search engine seemed pretty big as people all over the world went to Cuil.com (pronounced 'Cool') to try out a search. Although the home page looked cute and the results page got mixed opinions, the actual search results were quite irrelevant. I guess it is one of those things where the actual functionality matters more than appearance, eh?

The home page of cuil does have an environment friendly theme, apparently inspired by Blackle.

Prevent Thread Abort-ion with Critical-ity

If you've gone all the way to implement threading in your .NET application, you might be wondering what would happen to an atomic operation in the thread when Thread.Abort is called. Let's say you're performing an operation and storing the count of something in another variable - you've got to make sure that the values are consistent.

That's when you would use Thread.BeginCriticalRegion and Thread.EndCriticalRegion. While your thread is in a critical region, it will not abort till the critical code has executed.

As a side note, I'd like to mention that Microsoft also tells you to avoid the non-blocking Thread.Suspend() call because it only causes the thread to suspend at the next safe point for garbage collection. In other words, it means that the suspend is not immediate and can occur at some future time.

Computers: From Tube to Chip


From Tube to Chip: Early Computer History

From: macloo, 1 year ago





Professor Mindy McAdams's presentation about vacuum tubes, microprocessors, and connections between radio, World War II, and computer technology


SlideShare Link

Monday, July 28, 2008

Whitespaces and Display:None Tags

Normally, if you've got multiple occurrences of a whitespace in HTML, it gets converted to a single whitespace. However, if you add a couple of HTML tags with the CSS attribute display set to none, the spaces in the HTML document increase.

I find the behavior a bit odd, considering that the display: none isn't supposed to effect the layout of items, or so we would like to believe.

Saturday, July 26, 2008

Securing ASP.NET Applications


Hacking and Securing .NET Apps (Infosecworld)

From: shreeraj, 1 year ago








SlideShare Link

Scaling with Memcache


Scaling with memcached

From: acme, 10 months ago





memcached is a high-performance, distributed memory object caching system used by LiveJournal, Facebook, Bloglines and others. Find out how memcached works, how to it set up and how you can scale your website. Presented at YAPC::Europe 2007 by Leon Brocard.


SlideShare Link

Beyond REST with XMPP


Beyond REST? Building data services with XMPP

From: kellan, 2 days ago





Co-presented with Rabble.


SlideShare Link

XMPP for Cloud Services


Open Source XMPP for Cloud Services

From: mattjive, 1 day ago





Build next generation cloud services using XMPP and Open Source tools.


SlideShare Link

Memcache


Give Your Site A Boost With Memcache

From: benramsey, 1 day ago





Today\'s high-traffic websites must implement performance-boosting measures that reduce data processing and reduce load on the database, while increasing the speed of content delivery. One such method is the use of a cache to temporarily store whole pages, database recordsets, large objects, and sessions. While many caching mechanisms exist, memcached provides one of the fastest and easiest-to-use caching servers. This talk will cover memcached and the memcache extension for PHP from setting up a memcached server to using it to provide a variety of caching solutions, including the use of memcached as a session data store.


SlideShare Link

ASP.NET Server Controls vs HTML Controls

When I first started off with development in ASP.NET, I would always use plain ol' HTML tags instead of the ASP.NET server-side tags, hoping to save a bit on performance. However, as I picked up more concepts from ASP.NET, I gradually moved away from the HTML tags and now rely on them primarily for positioning of elements with DIVs. Now, all of you readers who are PHP fans and have never ventured into the ASP.NET camp would probably ask, "What do you have to gain from using server-side tags?".

The first thing that comes to mind is "globalization". You can pick up values from the resource file and whenever a change in language is needed, you can simply switch the strings in the resource file. The feature also makes building multi-lingual sites a breeze. To avoid the issue of re-compiling, there are satellite assemblies, which I hope to cover some other time.

Next comes the ability to re-base references. If you were to host your web application at a top-level directory served by the web server all the time and simply host additional websites on other ports or with different host names, all goes well, but what do you do when you want to host the application on a virtual directory? Back in the old days, that took a bit of re-writing of references but that isn't something for you to sweat about with ASP.NET. You can specify the "~" character for the base location of the application and the references would be automagically created for you on the server-side tags.

Finally comes the ability to let the IDE and the ASP.NET framework take care of rendering the HTML while you simply specify the properties on the control. Although there are times you would want to deal with 'raw' HTML directly, you wouldn't need to do this for the most part so why bother? With ASP.NET themes and skins, you'll also have an easy way to change the appearance of controls without having to visit each page.

Are you still using HTML tags within your ASP.NET application?

PS: I initially titled this post "Making things tougher for the ASP.NET server or easier for the developers" but then decided against it as the current title makes it easier to search via a search engine.

XP in a Vista skin

You don't have to upgrade to Windows Vista to get the really cool U.I. effects. You can transform your old Windows XP with a couple of FREE tools.

Transparent Window Borders

To get transparent window borders, you can download TrueTransparency. It's got 4 different 'Aero'-styles and it works on Windows Vista Basic too!

Taskbar Thumbnails

You can get thumbnails of windows that you have open using Visual Task Tips and that's a free download too. However, the difference from Windows Vista is that this one doesn't work if your window is minimized but it works just fine with background windows but, hey it's free so that's good enough for most of us.

3D Window Switch

The coolest effect by far is the 3D window switch in Windows Vista when you press Windows+Tab. Now you can get it in Windows XP (or Vista Basic) too by downloading a little program called WinFlip. WinFlip also labels your windows in the 3D switch screen so it's actually easier to use than Windows Vista's flavor.

Friday, July 25, 2008

Wissy Wig

A co-worker recently asked me if I knew of any 'Wissy Wig' editors. I was wondering what he was talking about till he showed me a blog engine that TinyMCE editor... that's when I realised he was talking about "WYSIWYG" editors.

A couple of other times I was confused by people pronouncing abbreviations and acronyms was when a professor mentioned about Suzy (SuSe) Linux and the first time a storekeeper talked about Sartar (SATA) hard drives.

Script Exploit Via FCKEditor

At work, I use BugTracker.NET to post bug reports and do stuff. It's not my favorite bug tracking software, but since they already had it set up for us, we decided to just play along.

BugTracker.NET supports rich text via the FCKEditor control and while it is quite nifty, it lets you go into 'source code' mode by pressing Ctrl-Tab (which, by coincidence, is the same shortcut I use to switch between tabs in Firefox and most other browsers). I then typed in a JavaScript to redirect the browser to Microsoft.com (just a randomly selected website) and now that bug report is pretty much inaccessible to anyone with a browser that runs Javascript.

I know, I know, FCKEditor is just a control for WYSIWYG HTML editing so you can't really blame it for the fault of the system using it - BugTracker.NET should've removed the script while saving it.

Thursday, July 24, 2008

ASM: Assume Nothing

Assume nothing... except the location at which your code has been loaded and the boot drive in register dl. That's what Frank Kotler tells me when debugging one of my bootloaders when I tried to write a bootloader a whole decade after I stopped work with assembly language.

The problem I encountered was quite odd. I had my bootloader jumping to the right labels, writing characters just fine when I fed in the ASCII values to the registers via code, but when I tried to move something from a memory location it just gave me zeroes for data.

The fix was to set the ds register to the same location as the cs register and that got things working for me. Surprisingly, I didn't find any other examples on the 'net that mention about it - they have pretty much similar code to what I had in the beginning. Maybe I encountered the issue as I was using VMWare instead of a true PC.

groups.google.ae broken on Firefox, groups.google.com works fine

I've noticed the Google Groups page was broken today when I browsed it with Firefox. I remember seeing the overlapping sidebar previously and wondered why no one ever reported it and Google never did anything about it. I then noticed the URL in the address bar started with groups.google.ae and wondered if I'd get anything different on the international servers.

A few quick moments later, I was on groups.google.com and the page displayed just fine.

FeedJIT Down


FeedJIT, the web traffic tracker, was down today. They probably have SGOS acting as a reverse-proxy to serve Internet requests and their license renewal was pending.

Tuesday, July 22, 2008

Browser Design Mode

If you would like to try out a look with a web page in the browser, most browsers support a 'design mode', where you can type text, move items around or delete items from the page. It's all temporary client-side functionality but it's the easiest way to get a screenshot of what you're trying to achieve and would have as the end result.

To add a design mode button to your browser bookmark toolbar to enable you to turn on design mode for any page at the click of a button, add a bookmark with the URL specified as
javascript:void(document.designMode="on")

Response.Headers.Add causes Requires IIS integrated pipeline mode exception

I tried to send a file back to the browser through an HTTP handler in ASP.NET, but came up with a "This operation requires IIS integrated pipeline mode" on the line where I'm setting the content-disposition header. It seemed quite odd because I was doing something similar in a previous ASP.NET application. After a bit of Googling, I came across the solution...

Using "context.Response.Headers.Add" was the culprit. I replaced the "context.Response.Headers.Add" with a "context.Response.AddHeader" and voila! Works like a charm.

Rich Text Format

We've been thinking about document file formats that we need to support in an application and Microsoft's free Rich Text Format seemed like a good option. It's being updated frequently (MS Office 2007 incorporates the new RTF 1.9.1 standard) and is supported by pretty much every major word processor (MS Word, OpenOffice, AbiWord, ...).

Instead of having to build support for the MS Word 2007 & 2003 format and the OpenOffice formats, it's easier to just build in support for RTF and that's that.

Some applications specifically need PDF documents for security but that's a whole different ballgame.

EDIT: There's a pretty good Wikipedia article on the Rich Text Format (RTF) and this Microsoft webpage is pretty detailed too.

Monday, July 21, 2008

MikeOS

If you're learning to build Operating Systems, you'll no doubt have searched and come across MikeOS. It's an open-source (BSD License) Operating System developed by Mike Saunders for assembly language developers to get started with writing their own Operating Systems.

MikeOS has been in development since 2006 and it has only become more active in recent days. The handbook accompanying the source code walks you through every bit of the code and also explains the reasoning behind the code structure.

MikeOS is quite capable is a starter's Operating System - it supports interaction with the serial port and the PC speaker, the FAT12 file system, and DOS-style interrupt handlers.

You can go to the MikeOS project website for more information at http://mikeos.berlios.de/

FCKEditor and RequiredFieldValidator: The Second Submit Issue

If you've noticed, the FCKEditor doesn't work too well with the RequiredFieldValidator. The RequiredFieldValidator reports invalid data indicating that no value has been provided for the FCKEditor. However, when you cause a postback again to submit the value, all is well.

This can be pretty annoying since you would have to write a custom validator, but for a quick fix you can just disable client-side validation on the RequiredFieldValidator by setting the EnableClientScript to false. Make sure the submit button or whatever control you are using has a handler that checks for Page.IsValid before you do anything... when you disable the client-side code, all the server-side code for the validators do is set the IsValid property of the page are let your event handlers execute normally.

Saturday, July 19, 2008

Oracle Dynamic Performance Views Architecture

The architecture of the Oracle Dynamic Performance Views is a stack of 3 levels of abstraction. At the lowest level, it consists of X$ views based upon C data structures. V_$ views are created over the X$ views and they are accessed through V$ synonyms.

Layers (lowest to highest):
X$ views from C data structures
V_$ views over X$ views
V$ synonyms to V_$ views

Multi-File Assemblies

Most people seem to think a .NET assembly is a file. However, assemblies can also span across multiple files or modules. An assembly essentially is a package of modules and resources with a manifest containing references to them (the manifest also stores the assembly name and version number). All of the type metadata and IL code resides within the module.

Visual Studio cannot create multi-module assemblies, but they are easy to create using the command-line compiler (csc.exe or vbc.exe) and the assembly linker (al.exe). All you need to do is compile the source code with the /target:module option and then pass, to the al.exe utility, the names of the modules as command line arguments with the /out:filename option and the /target option specifying the output type.

Example:
csc.exe /target:module /out:classlib1.netmodule classlib1.cs
csc.exe /target:module /out:program.netmodule program.cs
al.exe /target:winexe /out:program.exe classlib1.netmodule program.netmodule

System.Reflection: Get 'this' assembly

The Get*Assembly methods in the System.Reflection.Assembly namespace do add a bit of confusion as their description is usually quite brief. In this blog post, I'll add a bit more verbosity by going over some of the possible scenarios... here's the GetEntryAssembly vs GetExecutingAssembly vs GetCallingAssembly.

GetEntryAssembly

This method gets the assembly that started the process, pretty much what started the whole chain reaction and the reason why the CPU is looking at the bit of code you've written to make this call.

Suppose you've got a ConsoleApplication1.exe assembly that you double-click on to run, that's the entry assembly - it's as simple as that!

GetExecutingAssembly

In most large applications, you'll be writing your code as separate modules and would probably have a library of common structures and functions that you would need to access from each of the modules. The GetExecutingAssembly is like a 'Who Am I' for the code to tell which assembly is located in.

Let's say our ConsoleApplication1.exe makes a call to ClassLibrary1.dll. Now, if we were to call GetExecutingAssembly from within a method in ClassLibrary1.dll which in turn is called by a method in ConsoleApplication1.exe, we would get ClassLibrary1 as the executing assembly because that's where the exact code "Assembly.GetExecutingAssembly()" appears.

GetCallingAssembly

This gets a *little more* complicated here, but it's still simple enough for you to get with half a brain cell. If you were to look at the stack trace and take one step back from the current method, that's the calling method and wherever it is located is called the calling assembly.

Let's take 2 scenarios here as this takes a little more explaining.

Scenario 1 (GetCallingAssembly): Let's take the case of ConsoleApplication1 calling a method in ClassLibrary1. GetCallingAssembly would give you ConsoleApplication1.

Scenario 2 (GetCallingAssembly): Suppose ConsoleApplication1 calls a method in ClassLibrary1, which calls another method in ClassLibrary1. GetCallingAssembly now gives you ClassLibrary1.

Intel C4004

The Intel C4004 is the first commercial microprocessor. It is a 4-bit processor with 16 registers and it supports 46 instructions. Clocked at 740kHz, it can execute 92 instructions per second. It was sold from 1971 to 1981 and was originally built for use in Busicom calculators.

Several Intel C4004 processors were sold by collectors as antiques for as much as $1,000.

Intel has made available the schematics and datasheets for this processor available for non-commercial use at it's website.

Friday, July 18, 2008

Making an operating system, by example

If you're learning to write an operating system, you've probably looked at some complex code and have tried to make sense of it. If you're still puzzled after your first attempt, you ought to take a look at MikeOS. It's simple code for a text-based Operating System and the goal is to keep the code readable enough for developers to learn. You can get the source code (the last release was on 15th July 2008) from the official website here: http://developer.berlios.de/projects/mikeos/

Javascript Libraries

If you're planning to revamp your site with some Javascript and AJAX, you might want to take a look at jQuery, ExtJS, Mochikit and Dojo libraries. They're the more popular of the lot.

jQuery is a really good place to start if you just want a little help with client side scripting for adding event handlers and using 'selectors' but don't want to go all the way with custom dialog boxes and other user interface elements.

ExtJs is often featured for its widgets. It can give you a cool Office 2007-like or Vista-like look and it's pretty comprehensive.

I haven't spent much time with Mochikit and Dojo, but I do find Mochikit's logging pane quite handy for client-side logging. It's for those times when you don't have access to a debugger (VS2008, in my case).

SourceForget.net - Now More Orangy

The world's most popular open-source project hosting site just got a makeover. They've now got a minimalist homepage!

Apparently, they've still got more work to do as the project statistics section of the site is down.

Thursday, July 17, 2008

Vector Desktops

I think the next step in the evolution of desktop wallpapers would be to have vector images that can be re-sized to fit any desktop. The elements of the wallpaper should have anchors/docking to the 4 directions or the center.

While in the spirit of vector graphics, I thought I'd post the Vin Diesel vector image that's been on my desktop lately:

I would've used a graffitti font for writing 'Vin Diesel', but I can't seem to find the perfect font for it :-(

Wednesday, July 16, 2008

Oracle Isolation Levels

Oracle supports 3 transaction isolation levels

1. Read committed (default)

A query will only be able access committed data. However, the transaction may be affected by changes made by other transactions.

This can be set by:
SET TRANSACTION ISOLATION LEVEL READ COMMITTED; (transaction level)
ALTER SESSION SET ISOLATION_LEVEL READ COMMITTED; (session level)

2. Serializable transactions

A query can only access data that was committed at the start of the transaction. Modification from DML operations performed from the same transaction will be visible.

The Serializable transaction isolation level is not supported with distributed transactions.

This can be set by:
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; (transaction level)
ALTER SESSION SET ISOLATION_LEVEL SERIALIZABLE; (session level)

3. Read only

A query can only access data that was committed at the start of the transaction. Modification to the data is not allowed.

This can be set by:
SET TRANSACTION ISOLATION LEVEL READONLY; (transaction level)
ALTER SESSION SET ISOLATION_LEVEL READONLY; (session level)

OpenSolaris 2008.05


Open Solaris 2008.05

From: angadsingh, 1 month ago





A tech talk on OpenSolaris 2008.05 delivered by me, the Sun Campus Ambassador of JIIT University at the Sun Corona Day of IGIT, GGSIPU.


SlideShare Link

Solaris 10 Features


Solaris 10 Technical Overview

From: danilop, 3 months ago





An overview of Solaris 10 new features.


SlideShare Link

Tuesday, July 15, 2008

Comparing the ArrayList and List (generic) collections in .NET

If you've started developing on .NET since version 1.0 or 1.1 of the framework, the ArrayList has probably been a favorite for you till .NET 2.0 when the fans switched flags to join the generic camp with the List class.

Looking at the implementation of the two classes, both internally use arrays. While the ArrayList uses an object array, the List uses a generic-typed array. The List therefore, supposedly (in theory... but probably due to issues in implementation of the compiler or framework, does not), gives you better performance as you get back the objects in the type that you inserted them thus saving you a type-cast operation. The performance benefits of generics over objects is a little disputed topic in the .NET framework - several others have demonstrated almost no performance benefit in the use of generics, but the key advantage we see here is compile-time validation of assignments based on data type as opposed to run-time validation of the variable assignments.

I still remember the software engineering course that I took up when I first used generics on an assignment. The instructor was visibly upset - they were using an old compiler for evaluation and when I asked them to get a brand new shiny compiler to support new language features, the argument from them is "That is such an archaic concept from the world of C++... Are you insane? We're teaching software engineering here, not computer programming 101". Sure, generics are opposed by some group of people but if they've got a better solution, they have yet to present it.

Monday, July 14, 2008

Auto Blog Posting on SlideShare.net


SlideShare.net now has a really cool interface for posting to Blogger.com - all you need to do is enter a title for the blog post and your authentication details... check your blog and voila! There it is!

Sunday, July 13, 2008

SlideShare: Introduction to OpenSocial


Opensocial Intro

From: cschalk, 3 weeks ago





Introduction to OpenSocial - Presented at Google Developer Day 08, Taipei, Taiwan


SlideShare Link

My 100th Post and My Modified Blogger.com Template

This is my 100th blog post!!!

After having been around this long on Blogger.com, I decided it was time to have a custom template applied - the stock templates aren't very appealing and so I just had to seriously consider getting some mods.

Modifying these templates is a bit of a challenge so I started off with one and modified it a bit to get this end result.

Instead of working with the template file directly, I download my blog page (complete) using Firefox and then use DreamWeaver to modify the CSS classes and see the results. When I like what I see, I copy across the CSS classes to the template and upload the template.

If I had to deal with the XML template directly, I'd have to chart everything out on a piece of paper to determine what goes where. That's sooo not what I'd like to do.

ASP.NET OutputCache on a user control

When using ASP.NET output caching on a user control, it is usually a good idea to set the Shared attribute to true and refer to the control with the same ID as this makes best use of the cache.

The default behavior of the output cache is with Shared set to false i.e. the cache isn't shared among multiple pages for the control.

Also, with output caching for user controls, the Location attribute is not supported because the controls have to be rendered on the ASP.NET web server.

EDIT: This is also called fragment caching.

Windows 3.11 not dead... yet



For those of you who thought Windows 3.11 was dead, well think again - it's been sold to OEMs all this while and Microsoft is finally killing it off this November. It makes you wonder why they didn't use Windows Mobile/Windows CE/Pocket PC.

If you're trying to build embedded devices, you may want to take the leap to Windows XP Embedded. There are a lot of public transportation buses powered by Windows XP for their route map system and HSBC uses it for their ATMs (when they do have downtime, it's fun to watch) so Windows XP will be around for embedded devices for quite a while.

(Source: Geek.com)

Saturday, July 12, 2008

Do we even need those non-generic interfaces?

Ever since generics was introduced in .NET 2.0, developers have been switching from the ArrayList to the List generic collection class. It makes life easier for the developers because they don't have to cast into the datatype that they need while retrieving. (Sure, there is the StringCollection class but what about when you don't have strings to deal with?)

Taking the use of generics to the next level, we then get developers into the idea of using the Generic interfaces - take IComparable as an example...

Normally, you would implement IComparable with a CompareTo(object) where you would cast the object into the type you are comparing with. With IComparable, you can compare against something you do not have to cast such as CompareTo(int) or CompareTo(CompensationPackage).

Theoretically, the idea seems to work pretty well but you would notice that a couple of the .NET framework classes just won't play along. Take the Array.Sort method, for instance - it will just complain about not finding an implementation of the non-generic IComparable. The same applies to the Array.Sort method which deceptively seems to indicate that it is a generic variant or Array.Sort.

...so yet again, we're stuck with having to implement non-generic interfaces till a 'truly generic' version of Array.Sort comes along.

(Coming up soon: Extension methods to get around this issue)

Friday, July 11, 2008

BitComet 1.02 bug: Incomplete or Unfinished download at 100%

BitComet 1.02 is a buggy - it won't download all the files completely although it claims to have downloaded 100% and stops the download process. You can find other reports of the bug here:
http://www.tocomet.com/post/40798/

You can perform a manual hash check after stopping the torrent (sometimes the stop button does not work - you have to close and open BitComet to stop the torrent).

Till a fix is available, you can use a previous version available at:
http://www.bitcomet.com/doc/download-achive.htm

Thursday, July 10, 2008

Software Development Satire


In software development, communication is key. Here's a popular email forward describing the reality of software development and the miscommunication prevalent.

Wednesday, July 9, 2008

FCKEditor and RoundedPanelExtender

The FCKEditor doesn't seem to be compatible with the RoundedPanelExtender of the AJAX Control Toolkit in MS Internet Explorer. Whenever I place the FCKEditor as a control within a panel that has the RoundedPanelExtender, the FCKEditor is visible for a second or two after page load and then disappears. It works perfectly well on Firefox though.

The browser versions that I'm using are MS Internet Explorer 7 and Firefox 3.

More Downtime on GWB


We had a bit of downtime on GWB (GeeksWithBlogs.com) today. I only noticed it for a couple of minutes so you can bet Agent 008 Jeff Julian was on the case and had everything up and running again :-)

FCKEditor 2.6.2


I've tried using FCKEditor 2.6.2 for an ASP.NET web application I was working on and it's really cool. You can check out a demo of the editor here:
http://www.fckeditor.net/demo

Unlike the version of FCKEditor on GWB (GeeksWithBlogs.com), we don't have a separate popup browser window. A common problem on GWB's FCKEditor is when you're done using the popup browser window, it doesn't automatically close.

The new version certainly ranks higher on user-friendliness.

Wishlist: ASP.NET control to detect change

What we need in ASP.NET is a change-tracking control. Whenever we modify elements on a form, it would be a good idea to display a popup for user confirmation before navigating away from the page. Right now, I've got some pretty ugly Javascript doing this.

The next version of the AJAX Control Toolkit would really kick a** if it had this control. It could also include bug fixes for the 'focus' issue with the RoundedControlExtender and TextBoxWatermarkExtender.

Tuesday, July 8, 2008

StringCollection Internals


A search comparing the StringCollection to the ArrayList may give you articles that say "the ArrayList works better than the StringCollection" but what you need to know is that a StringCollection is simply extra methods over an ArrayList - there is an actual ArrayList included as a private member within the StringCollection class and it caters to storage needs of StringCollection. In other words, the StringCollection is just a disguised ArrayList!

You don't really have to decide between using an ArrayList or the StringCollection wrapper - both are essentially the same! You use a StringCollection wrapper when you are dealing with strings... the cast to a string is performed by a method in the wrapper so you don't have to do it each time you access it. If you aren't dealing with strings, the StringCollection isn't an option anyway.

More Speculations on Google PageRank: Favors Wikipedia

If you count the number of pages linking to a Wikipedia page, there may be none but it still appears on the first page of the search results.

Google seems to rank pages from Wikipedia higher up in the results. One possibility is that it doesn't seem to be using the regular PageRank algorithm for some websites. Either that or the PageRank algorithm uses a list of 'favorite domains' when ranking pages. I considered the possibility of 'favorite domains' a little more and Googled it a bit when I came across an article that mentions about Google having access to the domain registration information so I'm guessing that there is a possibility Google checks the age of the wikipedia.org domain registration and factors that in too.

Monday, July 7, 2008

.NET 3.5: StringCollection vs ArrayList

I've been running a couple of tests on the ArrayList and the StringCollection in .NET 3.5 to determine if the ArrayList still performs better than the StringCollection for insertions. There are a couple of articles on it, this one from 2004 being the one that also presents source code for a simple test that they've performed:
http://weblogs.asp.net/justin_rogers/archive/2004/02/29/81680.aspx

Initially, I went with a normal-looking test but without creating the string table and that skewed the results. I initially wrote the code with the test on the StringCollection first and then the ArrayList and, according to the results, the ArrayList was a better performed. I then switched the positions of the ArrayList code and the StringCollection code and the results were reversed. Whichever executed first took longer. It was pretty normal for it to do that so...

I added the initial loading of strings into an array and then adding the array elements into the ArrayList and the StringCollection. Running another series of tests showed that the order still does matter - whichever executed first took less time.

The only way to prevent one test from affecting the other was to run the tests independently so I ran only the code for the ArrayList followed by the next run with only the code for the StringCollection. This time, I was able to get better results - the ArrayList consistently outperforms the StringCollection but the performance difference does seem quite marginal. Unless you're dealing with over 15 million strings, you're not going to take much of a performance hit so you can use whatever seems more convenient.

Here are the results that I came up with (time measured in ticks):


5 million string, independent executions

SC - 3047, 3063, 3047, 3078
AL - 3000, 3016, 3000, 3016


5 million string, populating from string array (skewed results)

AL - 219, 203, 219, 219
SC - 422, 422, 422, 438

SC - 203, 219, 234, 218
AL - 469, 484, 438, 485


5 million strings, ignoring string table (skewed results)

SC - 3219, 3063, 3110, 3031
AL - 2937, 2828, 2828, 2828

AL - 3000, 3016, 2985, 2984
SC - 2844, 2844, 2859, 2844


EDIT: I took a closer look at the StringCollection class and discovered that it is just a wrapper over the ArrayList. For more, read:
http://knitinr.blogspot.com/2008/07/stringcollection-internals.html

Sunday, July 6, 2008

The Infinite Monkey Theorem

Just a little while ago, I was reading about the Infinite Monkey Theorem, as a means of providing input to software tests, on Wikipedia that states: "a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type a particular chosen text, such as the complete works of william Shakespeare."

The explanation of the theorem clarifies that the behavior of the "monkey" is assumed to be something that can generate characters randomly. Stating that particular assumption does tend to pacify critics trying to discredit the theorem.

If you've observed child behavior, they initially repeat whatever seems to interest them. If they pressed the space bar and found the sound made by the keyboard interesting, they would continue to press the space bar to boredom. They will then try out some other keys at the center of the keyboard, or perhaps some toward the left and right edges too but they wouldn't usually get to the upper edge since those are farther away and less likely to be pressed... unless they push the keys in sequence (1, 2, 3, 4, 5, 6, 7, 8, 9, 0...) but that isn't random.

My nephew eventually got tired of pushing keys on the keyboard so the "infinite amount of time" part may be hard to test. He pushes the power button now because it gets the hard disk LED flashing and then eventually turns all the LEDs off :-(

Napkin Specification

When building systems, we've always got to watch out for the infamous 'Napkin specification'. This kind of spec looks good and simple, but when you start to build you would notice some detail missing.

For instance, consider a case where you're building the user interface for an application using a user interface wireframe and the business components have already been provided to you. At first glance, you might think, "How hard can it be? We've already got the screen design and have the business components built." As development begins, you start to build the user interface by disabling buttons that the user should not have access to (for whatever reason) and when you're demo-ing the system to the customer, the customer asks why the buttons are even on the screen when the user shouldn't be able to use them.

I wouldn't say there was no design here - there was a design specifying which screen element should go where, but there was no specification for the behavior of the elements. How much data should be allowed in a particular field before displaying an error to the user? What kind of data is considered invalid? For some people, "cooldude@localhost" is a perfectly valid email address but others would want a check for a dot in the domain name.

__designer:wfdid from Visual Studio's ASPX designer

__designer:wfid in visual studio

Visual Studio 2005 SP1 added in a couple of __designer:wfdid attributes into some of my ASP.NET tags and they prevent the project from compiling. Apparently, there's a bug somewhere that didn't get fixed with the service pack.

Removing the attribute fixed the compilation error.

Saturday, July 5, 2008

ASP.NET: Preventing overrides to settings

The ASP.NET web.config file has a location element with the attribute allowOverride. You can use it to prevent child directories from overriding the settings specific in the web.config file.

Although, it's a handy feature to have when you're testing/debugging, you should avoid using it because it can lead to less maintainable applications - somebody would scratch their heads over why their settings aren't taking effect.

Model View Controller (MVC) Design Pattern

I came across a slideshow by Alan Dean on the Model View Controller (MVC) pattern here:



He also mentions about the ASP.NET MVC framework and the REST web interface in the presentation.

Friday, July 4, 2008

Identi.ca launched yesteday

Identica, a Twitter-clone, was launched by the Canadian firm, Control Yourself Inc., yesterday. The software powering Identica is available with an open source license and it supports the OpenMicroBlogging spec.

Error Pages: ReddIt and Acromedia





...and we have yet another look at error pages. Today, we look at the page from ReddIt and another error page from Acromedia. I must say it is apparent that Twitter really does spend a lot on the graphic design of their error pages compared to any other site we've seen.

Designing Enumerations

Every software architect or technical lead has to consider the possibility of a change in the requirements and thus the software and has to build a system resilient to such change. He/she would also have to design a system that is easy to implement and easy to modify. One such area is dealing with the enumerations when defining the detailed design of the application.

When a method accepts input that is from a small set of values, it is generally a good idea to accept that input as an enumeration to minimize the possibility of receiving invalid arguments.

For example, if your method accepts gender as a character, you would be accepting either an 'F' or an 'M'. If you receive any other character, that would be an invalid parameter. If a user passed in an 'f' or an 'm', you would need to add extra logic to the method to convert the lower case characters to upper case characters.

Assuming we have just defined a new enumeration to pass as a parameter to our function, we can then forsee another problem. Suppose the calling method does not have a value to pass in, such as for passing an Unknown or N/A, it would have no way to pass in such a parameter.

There are two different approaches we can follow to accept these values. The first approach, which can also work with .NET 1.1 is to always reserve the first value in an enumeration to use as a null, such as with the DateTimeKind enumeration present in the .NET framework. The other approach involves using the Nullable generic in .NET 2.0 as the argument type for the function.

Ugly Messages on Thinkpad Recovery


I have an IBM Thinkpad T60 that I got about 2 years ago and I just used the Recovery CD to get a clean environment. It reminded me of the errors that I got the last time I used the Recovery CD:

C:\temp\{36948~1 - The process cannot access the file because it is being used by another process.
Memory size: 526757888
Return code: 502
Winxp pro 512
The system cannot find the file specified.

Now, if a normal user sees those messages and the system waits on the screen, he or she would think the recovery did not work. I wonder why they don't just give me a regular Windows disk. If they do want to get stingy, they might as well give me Linux instead of Windows. The "No warranty on software" policy is just another reason why people resort to piracy - if they've paid for it, they might as well use it one way or another.

Thursday, July 3, 2008

Rounded Corners: Comparing jQuery Corner with the AJAX Control Toolkit

If you're developing an ASP.NET application, adding a rounded corners extender to your panel is the most common way to get rid of the pointy ends. You can add borders to the rounded panel as well as assign a different color to the top and bottom edges of the panel. You'll probably run into the issue of not being able to add padding to the panel as that makes it go haywire. A work-around is to create another panel or div within your rounded panel and add padding or margins to it.

For a cleaner solution, you can give jQuery Corner a try. It's a plug-in available for jQuery to apply rounded corners (in a large variety of styles) and all you have to do is apply a CSS class to the panel or div and include a tiny JavaScript into your page. It works well as you can apply padding to the panel/div itself, without having to create any additional ones. However, you can't have a border to the rounded panel/div (jQuery Corner automatically removes the borders). jQuery Corner also gives you the benefit of being able to apply the rounded corners to non-ASP.NET pages so you can run a part of your website on another technology too.

Here are some samples with both that I came up with:


The Rounded Corners Extender can have borders and edge colors applied to it.



Adding padding to the Rounded Corners Extender keeps it from resizing with the window and makes it protrude from the right.

GeeksWithBlogs Down



GeeksWithBlogs.com has been experiencing downtime for most of yesterday and today. Since I have my blog mirrored on both GeeksWithBlogs and Blogger, it did keep me from blogging much. I guess I should just keep writing and post to Blogger.com for now. More from me real soon.

I Plurked Today



I just Plurked a little while ago. No, I'm not ill - Plurking is the act of posting a message on Plurk (weird name, I know!). It seems to be like Twittering, except that it doesn't have the mobile (maybe they do and I just haven't found it yet?) or IM elements to it - you have to be at a web browser to use it.

Their timeline interface is quite nice and is their unique selling point. I wonder how long it'll keep them ahead though - there are so many browser add-ons, desktop applications and web front-ends for Twitter that somebody could just come up with a Plurk-like interface for Twitter.

Other non-core functionality on Plurk is the Karma that you accumulate for activities (Eg. when someone 'follows' you, you earn karma. When someone 'leaves' you, you lose karma.).

I wonder why we need another social networking site though - we've got so many already. I just join the ones that I know where most of my friends are - FaceBook and Orkut!

Wednesday, July 2, 2008

iStockPhoto Error Page

iStockphoto has a cute error page (though not as cute as Twitter's!). Check it out:

Tuesday, July 1, 2008

Beating the TextBoxWatermarkExtender in the Focus game

You've probably read my earlier post about setting focus on a form element. All went well. Then, things went to the U.I. guy who went crazy with the TextBoxWatermarkExtender control and now none of your forms have focus on a form element any more :-(

I guess the developers of the TextBoxWatermarkExtender didn't think of all the possible ways in which people would use the control - some people actually do want to keep the focus on a control to help their keyboard-loving users.

Anyway, I set out to try different ways to get focus on the control. I created a master page and content pages, just to simulate a real scenario (You do use Master pages in all your apps, right?). I then started with the simple TextBox1.Focus(); and, umm... that didn't work.

I then thought I'd go the way of JavaScript because I did encounter some scenarios in which the ASP.NET means of obtaining focus didn't work, but the JavaScript version did work (although I didn't take the time to diagnose the problem as we needed a quick-fix). I then proceeded to go with the Page.ClientScript.RegisterStartupScript, but the string turned out to be a little too icky and unread so I went to the end of the page code in the ASPX file and created a SCRIPT block. Okay, now let's get a reference to the textbox the quick-and-dirty way since I'm not expecting to change the IDs or anything. I ended up with this code:

window.onload = function() {
var txtbox = document.getElementById("ctl00_ContentPlaceHolder1_TextBox1");
txtbox.focus();
}

It didn't work :-( I also had the TextBox1.Focus() in the Page_Load event to make sure that I get focus, but neither of the two worked.

I then decided to try a Google search. A quick search later, I landed on a page which I think was on the ASP.NET forums that was totally unrelated to getting focus - it was about using JavaScript to set a value in a textbox that had a TextBoxWatermarkExtender on it. The solution was to change the className property of the textbox via JavaScript and I decided to give it a shot. I changed my code to:

window.onload = function() {
var txtbox = document.getElementById("ctl00_ContentPlaceHolder1_TextBox1");
txtbox.className = '';
txtbox.focus();
}
...and still nothing :-(

Now, although the post on the forum wasn't marked as the answer, I thought it might have worked for the original poster since it sounded a bit weird and weird things have a way of working but in the end, what matters is that it didn't work for me.

I then thought - what if my JavaScript was getting the focus on the textbox, but the ASP.NET code for obtaining focus was triggering some insane maniac function within the TextBoxWatermarkExtender and taking focus away? I commented out the TextBox1.Focus(); statement with a quick double front-slash and voila! My page loaded with the focus on the text box!!!

The code didn't make it into today's build of the code, but you can bet the first thing I'll do tomorrow will be slapping that code onto every page in the project containing an eligible form element (which in our case is a textbox).

PS: Just in case you lost me somewhere in the article, the code that worked is:

window.onload = function() {
var txtbox = document.getElementById("ctl00_ContentPlaceHolder1_TextBox1");
txtbox.className = '';
txtbox.focus();
}