Posts

I love the Linq to REST capability

All without changes to your C# code at all. Awsome. Just watched Scott Hanselman's ADO.NET Data Services talk from NDC09. Rather good, so go watch. Given that it (ADO.NET Data Services) is agnostic of EntityFramework, Ling2Sql, NHibernate, or MyHomeGrownOrm, seems like a good basis for implementing simple CRUD style services. Looking at it I can see the appeal and its a good way to go. You could easily plug in a mock objects with test data pretending to be your database for NUnit testing your code with ease.

Windows Server 2008 as a Workstation

Image
Well, its well known that Windows Server 2008 is 11-19% faster than Vista, and its using the Vista kernel. There's a ton of articles and i'm not going to list them here. But what I am going to show you is how to do it. Quoting from Alex Zaharov-Reutt Although using server versions of Windows as desktop/workstation versions over the years certainly isn’t new, the source of the latest drive to turn Windows Server 2008 into Windows Workstation Vista 2008 seems to have come from Microsoft employee Vijayshinva Karnure, in his blog “The Way I See It”. Karnure works at Microsoft India, and in a blog entry called “Using Windows Server 2008 as a SUPER workstation OS”, and in a follow up “Cont’d” posting, he outlined what Server 2008 users need to do to enable all the Vista-esque workstation goodness. Another website called “Convert your Windows Server 2008 to a Workstation!” offers a “Windows Server 2008 to Workstation Manual”. Reasons why Server 2008 might be faster include the l...

Blackberry 8800 video encoding - How to

Image
Download this free encoder: http://www.erightsoft.com/SUPER.html The download link is very hard to find, so its here Use these settings: Output container: AVI Video Codec: DIVX Audio Codec: mp3 Encoder: MEncoder Video settings Size: 320:176 Aspect: 16:9 Frame/sec: 12.5 (pal) 14.985 (NTSC) Audio settings Sampling freq: 22050 Channels: 2 Bitrate: 64 Audio stream: default Enjoy!

A generic singleton - Part 2

Here is the critique and why there is a better solution to the article: A generic singleton Well, it isn't really singleton - since you can't control T , there can be as many T instances as you like. The code does check for non-public constructors, which is good. However, this is a check which is only performed at execution time - there's no compile-time check, which is a strike against it. It also relies on having enough access to call the non-public constructor, which adds some limitations. In addition, it doesn't prohibit internal constructors - so you can end up with non-singletons. There is an excellent article on singletons at http://www.yoda.arachsys.com/csharp/singleton.html Here are two proper implementations: public sealed class Singleton { static readonly Singleton instance = new Singleton(); // Explicit static constructor to tell C# compiler // not to mark type as beforefieldinit static Singleton() { } Si...

Surprising SQL speed increase - Part 2

Part 1 is availble below More generally speaking, you should never use a function on the LEFT side of a WHERE clause in a query. If you do, SQL won't use an index--it has to evaluate the function for every row of the table. The goal is to make sure that your where clause is " Sargable " Some other examples: Bad: Select ... WHERE isNull (FullName, '' ) = 'Ed Jones' Fixed: Select ... WHERE ((FullName = 'Ed Jones' ) OR (FullName IS NULL )) Bad: Select ... WHERE SUBSTRING (DealerName, 4 ) = 'Ford' Fixed: Select ... WHERE DealerName Like 'Ford%' Bad: Select ... WHERE DateDiff (mm,OrderDate, GetDate ()) >= 30 Fixed: Select ... WHERE OrderDate DateAdd (mm,- 30 , GetDate ()) Bad: Select ... WHERE Year (OrderDate) = 2003 Fixed: Select ... WHERE OrderDate >= '2003-1-1' AND OrderDate '2004-1-1'
The 3 Minute Management Course Lesson 1 A man is getting into the shower just as his wife is finishing up her shower, when the doorbell rings. The wife quickly wraps herself in a towel and runs downstairs. When she opens the door, there stands Bob, the next-door neighbour. Before she says a word, Bob says, "I'll give you £800 to drop that towel." After thinking for a moment, the woman drops her towel and stands naked in front of Bob. After a few seconds, Bob hands her £800 and leaves. The woman wraps back up in the towel and goes back upstairs. When she gets to the bathroom, her husband asks, "Who was that?" "It was Bob the next door neighbour," she replies. "Great!" the husband says, "did he say anything about the £800 he owes me?" Moral of the story: If you share critical information pertaining to credit and risk with your shareholders in time, you may be in a position to prevent avoidable exposure Lesson 2 A priest offered a Nun ...

Surprising SQL speed increase

I’ve just found out that the execution plan performance between the following two select statements are massively different: select * from your_large_table where LEFT(some_string_field, 4) = ' 2505 ' select * from your_large_table where some_string_field like ' 2505% ' The execution plans are 98% and 2% respectively. Bit of a difference in speed then. There are lots of places in our SQL where we use LEFT(something, x) = 'string' This should be replaced by the LIKE command for greater speed. I actually found this out by checking the LINQ generated SQL against my hand crafted SQL. I assumed the LIKE command would be slower, but is in fact much much faster.