8.31.2010

Speed Tracer (Chrome Extension)

I discovered this amazing tool a few months back created by Google called Speed Tracer. It is a Chrome Extension that allows, I suppose, just about anyone to diagnose performance issues in web applications. Take a look at the description below.


Using Speed Tracer you are able to get a better picture of where time is being spent in your application. This includes problems caused by:
  • Javascript parsing and execution
  • Layout
  • CSS style recalculation and selector matching
  • DOM Event handling
  • Network resource loading
  • Timer fires
  • XMLHttpRequest callbacks
  • Painting
  • and more ...

8.05.2010

32-bit and 64-bit software on Windows 7

Maintenance programming - yes, we all have to do it. Most of us experience it by way of coercion. The fortunate ones have the privilege of delegating this task to an eager intern willing to get their hands on any production code. I for one do not have such a privilege.

I have the responsibility of updating a VB6 application every year and in part of doing so is the need to set up an ODBC for each client machine. This year has been a little different in that these machines run Windows 7.

In Windows 7 there are two folders where dll, driver and executable files live...


%SystemRoot%\System32
     and
%SystemRoot%\sysWoW64

I was surprised to find out that on a 64-bit machine the System32 folder actually holds 64-bit files and not 32-bit files as the moniker suggests. Why? Backwards compatibility. That's right. That means the sysWoW64 folder contains 32-bit files. So let me give it to you again. System32 holds 64-bit files and sysWoW64 holds 32-bit files. That certainly is backwards.

And no, the WoW in sysWoW64 is not an acronym for World of Warcraft.  It actually means Windows 32-bit on Windows 64-bit, if that helps you remember at all.

6.18.2010

Microsoft Security Essentials

If you're looking for an anti-virus along with malware/spyware protection and you require all these things to be free on the Windows platform - take a look at Microsoft's Security Essentials. From the reviews I have read, it certainly seems like it will loosen the grips of the stranglehold that the two top AV software companies currently have on the market. I mean, how can you compete with free?

5.04.2010

A SQL Server Cursor example

Every now and then the need to write a SQL Server cursor comes up.  Since I find myself going back through a labyrinth of code when this happens, I thought it would be a good idea to post it here.  That's if I remember to look here the next time I need to create one - which just might be several seasons later.

*The humorous thing about this is that as I went to SQL Server Management Studio to copy the cursor example, it was gone.  Apparently, I closed the script window immediately after running it thinking I wouldn't need to use this in a long time.  No worries though, I wrote this up again in a short time.


declare @SOMEID int
declare appcursor cursor FAST_FORWARD
FOR SELECT Table1ID FROM tblTable1

open appcursor
fetch next from appcursor into @SOMEID
while @@fetch_status=0
begin

delete 
from tblWhatever
where WhateverID = (
select top 1 WhateverIDFK
from tblSomewhere
where SomeID = @SOMEID
order by DateOfEntry
)

fetch next from appcursor into @SOMEID

end
close appcursor
deallocate appcursor

One thing to note is the FAST_FORWARD hint.  You should always declare this when you need a forward-only, read-only result set.  FAST_FORWARD allows you to traverse the dataset with the least amount of overhead.  Cursors are generally slow because of the nature of their use.  Most times, you are forced to use a cursor because you have seemingly no other way to perform certain database actions, which frequently require small units of work like in the example above.  In the case where you need to update a result set, consider using FORWARD_ONLY (only use fetch next).  Please see this MSDN article for more information on cursor types.

3.10.2010

1024-bit RSA encryption cracked

A simple glance of this article's title (below) made my heart beat jump, literally. A quick google news search led to the legitimacy of this claim. Another title from gadgetsteria.com starts with "Good-bye earth: RSA encryption cracked when CPU put on digital diet…."

http://www.engadget.com/2010/03/09/1024-bit-rsa-encryption-cracked-by-carefully-starving-cpu-of-ele/

"By fluctuating the voltage to the CPU such that it generated a single hardware error per clock cycle, they found that they could cause the server to flip single bits of the private key at a time, allowing them to slowly piece together the password." 
It took 81 P4 chips and 104 hours of cpu time to achieve this feat.  This is a scary thought knowing that it will only be a matter of time when a single cpu with that computing power will be able to fit inside the confines of a netbook.  I'm about halfway done with this blog post and my heart is still beating at an accelerated rate.

RSA is an algorithm that Rivest, Shamir and Adleman first described in 1978. It is a public-key encryption method that is widely used for protecting all sorts of information, especially in the e-commerce space. It relies on the extreme difficulty of calculating the factors of very large numbers that only have two prime factors. The public key is exactly that, a product of two large primes. A 128-bit key (the product) can be a number from:

1 to 2^128
or
1 to 3.4028236692093846346337460743177e+38
or
1 to 340,282,366,920,938,000,000,000,000,000,000,000,000 

Now, the 1024-bit encryption that was just cracked has a public key that is MUCH larger.  It can be a number from:

1 to 2^1024
or 
1 to 1.797693134862315907729305190789e+308
or
(figure it out yourself)

Conventional wisdom told us that as long as we have keys long enough to withstand any brute force attack with the most powerful supercomputers of the time, cracking an encryption algorithm would simply be impossible.  But, this broke all the rules. They bypassed everything and went straight down to the cpu level. How did these guys at the University of Michigan have the prescience to do this? I don't know, but I am impressed and still very scared. 

3.01.2010

Subversion - an open source version control system

Subversion, you are simply awesome! You are as elegant and graceful in version control as Kim Yu-Na (김연아) is on the ice. Need I say more? I didn't think so.

Here is my version control setup on the Windows platform:

  • Subversion (creating a repository)
  • TortoiseSVN (windows shell program)
  • AnkhSVN (visual studio integration)
This is a typical setup for the Windows/Visual Studio user. Instructions (with pictures) can be found here. Thanks Matteo.

I've been recently tasked with moving an svn repository to another machine and I had no idea where to start.  So I did a quick search and found the "Relocate" option in the TortoiseSVN menu. Ok I'm done. That was easy. Now that I have all this free time, I'll go watch some more Queen Yu-Na videos...


Here's an interesting question/answer about SVN Relocate or Switch on Stackoverflow.

2.25.2010

The Tuple Type in the Microsoft .NET Framework 4.0

My first impression of the new System.Tuple type in the .NET 4.0 Framework was not a good one. Probably because at first look it seems like an implementation of the already existing System.Collections.Generic KeyValuePair. As you would expect, Microsoft had a few compelling reasons for this change.

Many of the MS language teams each created their own private version of the tuple. After some time, the teams within MS learned of this and wanted to use it in their code as well. After collaboration between the Base Class Libraries (BCL) and the Managed Extensibility Framwork (MEF) teams, they decided to include it in the upcoming Framework release.

So we know that MS uses tuples in their code. I can not even remember the last time I used KeyValuePair outside the use of a Dictionary collection. As I am writing this, I can think of a few ways I could have used KeyValuePair more in my code.

With the upcoming release of F# language, interoperability was paramount. Having different representations of a tuple in C# and F# would have led to coding woes. As it says in Microsoft's documentation, "any time you wanted to call a method from an F# assembly that took a tuple as an argument, you would be unable to use the normal C# syntax for a tuple or pass an existing C# tuple. Instead, you would be forced to convert your C# tuple to an F# tuple, and then call the method." Tuples are a core concept in functional languages, so it doesn't hurt to be exposed to it.

Some more interesting things about Tuples:
There is a maximum of 8 elements in a tuple. The eighth tuple must be of type tuple, making it limitless.
Tuples are reference types.