Wednesday, November 30, 2011

Rolling Flat File Trace Listener

Here are the standard trace listeners supported by Enterprise Library 3.1 Logging Application Block.

Table 7 mentions the Rolling Flat File Trace Listener. The flat file rolls over based on either the size of the file or the time interval (such as daily). You could also do both.

Managing emails in Outlook

Most of what I knew about improving productivity managing emails in Outlook. But, sums it up nicely.

http://www.microsoft.com/atwork/productivity/emailtools.aspx

Monday, November 21, 2011

Evaluate websites

http://www.websiteoutlook.com/
Currently, Google is ranked #1 with more than a billion page views every day, and Facebook is at #2 with about half a billion page views every day.

In comparison, our retail client's online shopping website gets about a million page views every day.

Parkour

Parkour: method of movement focused on moving around obstacles with speed and efficiency
More at http://en.wikipedia.org/wiki/Parkour
Source: http://www.santabanta.com/jokes.asp?catid=10760

PDF Printer for Windows

Whenever I need to have a copy of something important, such as a travel ticket, I like to print to file instead of a regular printer. This way, I could always print it again without having to generate the material again. I used to use the Microsoft Office Document Image Writer for this. This is one of the non-default features that comes with Microsoft Office 2003 or 2007, but has been discontinued in Office 2010.
http://support.microsoft.com/kb/982760

So, when I have Office 2010 on my new PC, I install just this component from the Office 2007 installer, up until now. The MDI or TIF format works fine locally, but if I have to share it with someone else, it doesnt work as well.

For instance, when I booked a ticket for my father, I feel sending a PDF is a much better option. So, I googled for it, and the first paid ad brought this free PDF printer for Windows.
http://www.pdflite.com/printer?gclid=CPDAgNqyyawCFUwaQgodmHatrQ

Tried and tested, works fine.

Wednesday, November 16, 2011

Unread mails in Gmail

Once in while, I go to the Spam folder in my Gmailbox and retrieve the ones I do not consider spam. This pushes such emails to my inbox and then I see the nagging sign next to the Inbox that says 20 unread messages. Typically, I can find all of them on page 1. But since these are retrieved from the Spam folder, the dates would stretch to a few days earlier and so, I would have to navigate across pages to find each of these unread emails.

Gmail, fortunately, like Outlook and unlike most other web mail providers, gives a way to filter emails based on whether they are unread. To do this, simply search for label:unread while in Gmail, and you get this filtered list. Cool, huh?

Source: http://www.dailyblogtips.com/gmail-tip-how-to-browse-only-the-unread-messages/

Monday, November 14, 2011

Monday, November 7, 2011

Ways to work faster on slow connections

The science of Science

This is what the Google homepage looks like today:

And this is the first link from the ensuing search page at https://www.google.com/#q=Marie+Curie&ct=curie11-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=b5ba79dc84c9cc2c&biw=1280&bih=907

http://www.csmonitor.com/Innovation/Horizons/2011/1107/Marie-Curie-Why-her-papers-are-still-radioactive

From the ignorance of radioactive materials in those days, it makes one think... the things we take for granted today need not remain so once we later find a better reasoning. And that's why Science never dies, it never will.

SQL Server encryption issues with mirrored db

We wanted to store some encrypted data in some fields. So, went ahead with this approach.

DBA creates a MASTER KEY encrypted with a password known only to him.
DBA creates a SERVER CERTIFICATE encrypted with this MASTER KEY.
DBA creates a SYMMETRIC KEY encrypted with this SERVER CERTIFICATE.

And then, we just have to open the SYMMETRIC KEY and provide it the name of this SERVER CERTIFICATE before executing any

OPEN SYMMETRIC KEY KeyName DECRYPTION BY CERTIFICATE CertName
-- Include this in a SELECT command
-- CONVERT(varchar(128),DECRYPTBYKEY(@encrypted_value))
CLOSE SYMMETRIC KEY KeyName

This worked well in dev & test environments. But, in prod, we would have a mirrored server as failover to improve availability. And hence when we tried this out before we went live, in perf/staging environment, we got these errors when we attempted to manually failover the primary db server.

Please create a master key in the database or open the master key in the session before performing this operation.
The key 'KeyName' is not open. Please open the key before using it.

When the use the DBA's master key, the queries work fine. But, we wouldnt like our queries to use the master key, would we?

So, it seems the DBA had created a certificate on each server with the same name. But, that means having 2 different certificates, one on each server, with just the name being common.

To get this in place properly, the DBA has to create a certificate on one server, take a backup, copy it to the other server, and then restore it on the failover partner. This way, both the servers would actually use the same certificate.

Some of these best practices are also mentioned here.
http://technet.microsoft.com/en-us/library/cc917681.aspx

Friday, November 4, 2011

DateTime difference

In C#, if I have this
DateTime startedOn = DateTime.MinValue;
DateTime endedOn = DateTime.Now;
then
endedOn - startedOn is a valid expression that returns a TimeSpan with the difference between the 2 dates.

However, the same doesnt work in SQL Server. We need to use
DATEDIFF(s, startedOn, endedOn)
where s stands for seconds. So, if the 2 datetime values have a difference of 10 seconds and 1 minute, and if you expect 10, you are thinking Excel. The value returned here would be 70.

http://msdn.microsoft.com/en-us/library/ms174420.aspx

Dumb-me values

I wanted to perform some load testing of my app. And for which I had to insert some dummy data into a SQL table. Since we wanted to put in maximum data into the fields, it followed that each of the varchar fields should have data with its size limit. Instead of the usual dummy data, I put in some thought to come up with this instead. Am sharing this  since I thought this was nice. :)

First Name16 charactersMyFirstNameIsBig
Last Name16 charactersMyLastNameIsLong
Address1 30 charactersMy Address1 field is humongous
Address2 30 charactersMy Address2 field is huge too!
City 30 charactersI live in a pretty cloudy city
State30 charactersI'm in a const state of denial
Postal Code14 characterswhat zip code?
Email Address46 characterswritingCodeCanBeFunIfUKnowHow000000@iMGeek.com

I didnt come up with the size limits, just the values. The last one is a 6-digit 0-prefixed number that is used to store a million possible values.

StringBuilder

We all know that a StringBuilder object should be used when we are concatenating a sizeable number of strings.

It seems the default capacity is 16. The default maximum capacity is 2147483647 (Int32.MaxValue), which is around 2 gigs, since Int32 can store 4G different values, from -2G to 2G-1.

The value of 16 was surprising. I thought it would be much higher than that. So, in my app where I need to load about 300MB into a StringBuilder object, I guess it is better to use it with a sizeable initial capacity. The initial capacity is also used as a delta when it runs out of the initial capacity. So, choose it wisely. I like to use a value that is a tradeoff between asking for a memory allocation every 16 bytes, and asking for all (like 300MB) in 1 or 2 allocations. For my current app, I have used it as 10MB.

StringBuilder sb = new StringBuilder(10 * 1024 * 1024);

Reference: http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx