Quotable Quotes from Lang.NET Symposium

Lang.NET was just over an hour or so ago, and there are many funny and interesting quotes I compiled over the last few days. Here are all I can remember and find on twitter.

Mads Torgersen on C# dynamic: “We owe it to IronPython and Ruby to make them first class languages.”

Mads Torgersen: “Static typers put the ‘anguish in languish’.”

Keith Robertson: “I’m here to sell you something. You can tell because I'm the one with the tie.”

Erik Meijer: “C# dynamic ‘is like the needle exchange program’.”

Tim Macfarlane: “We're planning on putting [Tycho] on the DLR pretty soon.”

Karl Prosser: “When I see squiggly brackets, it feels like a real language to me.”

Jeffrey Snover on Powershell: “No prayer based parsing.”

Lars Bak: “It’s good to have a slow compiler because that gives you job security.”

Joshua Goodman: “The way PMs fix things is by sending email.”

Erik Meijer: “I love the math - you don't need brain to do math. It’s all symbol pushing.”

Luke Hoban: “CodeDom is able to handle any language that is C#. Including VB.”

Erik Meijer: "LINQ is the solution to everything.”

Philip Wadler: “Monads aren't everything!”

Philip Wadler: “Nothing is so practical as a good theory.”

Erik Meijer: “Because of reflection, every language on the CLR is dynamic.”

I’ve enjoyed myself at Lang.NET and found the people and content are brilliant. I’ll definitely be back again next year. Kudos to the guys who helped set these up.

Random Insert/Select with T-SQL

Here’s something I found pretty useful. The situation is I need to insert entries into the database with one of the columns being some random data. If I did a Rand() directly in the statement:

Insert into NewStudy
select studyid,((29 + 1) - 27) * Rand() + 27,null from StudyTable

It will only generate Rand() once and fill in all rows with the same data, which is not what I want.

In order to generate a random number for each row, I have to create a view of the RAND() function:

SELECT RAND() as RandNumber
Insert into NewStudy
select studyid,((29 + 1) - 27) * (select RandNumber from vRandNumber) + 27,null 
from StudyTable

This works very well. Of course, 29 and 27 are my min and max respectively. I can create a separate function to do the same thing:

CREATE FUNCTION RandNumber(@Min int, @Max int)
 RETURN @Min + (select RandNumber from vRandNumber) * ((@Max+1)-@Min)

So instead, I can do RandNumber(27, 29) within the statement.

The problem why I didn’t use this randomization is because of permissions. Elevating a standard user to allow creation of a view is disallowed in my situation.

So this is what I did instead, to keep within the boundaries of the permissions, is to use row_number() instead. Take the mod of row_number by ((@Max + 1) - @Min) which is 3 for my case and add the @Min to it. It’s not random, but deterministic, but it works well enough for my case.

Insert into NewStudy
select studyid, (row_number() over (order by studyid)) % 3 + 27,null
from StudyTable

So that’s it. A deterministic pseudo “random” (not so random it seems) number based on row_number(). I wonder if there are other solutions to this.

Print-Ready Cheat Sheets for Web Developer

Here’s a great link I thought to share.


It contains 40 great cheat sheets pdf links so you can download them and print it right off.

MSIEXEC Failure on Windows 7

Some of you might be getting crashes from your installers. Here’s what the error looks like in your event logs:

Faulting application name: msiexec.exe, version: 5.0.7000.0, time stamp: 0x49432105
Faulting module name: ntdll.dll, version: 6.1.7000.0, time stamp: 0x49434898
Exception code: 0xc0000005
Fault offset: 0x00000000000ebbaa
Faulting process id: 0x12dc
Faulting application start time: 0x01c979f516ed5e4e
Faulting application path: C:\Windows\System32\msiexec.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll

This happens whenever you try to install anything that uses msiexec.exe on Windows 7. The workaround is to do a simple registry edit.


Remove all entries except default.

Don’t ask me why that works, but it works. I’m back to installing things. It seems people are having this problem just recently. Hope this helps anyone having this problem.

Slate Tablet PCs will be back

With the advent of multi-touch capabilities, and the iPhone popularizing this capability, together with Windows 7 having multi-touch capabilities in-built to the operating system itself, I will expect slate tablets (i.e. no keyboards, just screen) to be back, better than before. For those who have forgotten, slate tablets died out long ago in preference for the convertible tablets (i.e. keyboard and screen).

To get into the market, it first has to be light enough, and a screen wide enough to be comfortable. Together with a “Slate Stand” for desktop usage, this will enhance multi-touch on the desktop itself. We now are seeing laptops so slim (1 inch thick) and so light (2 lbs) with screen sizes of 13.1” or larger, I predict that this will be the critical factors in bringing back the slate tablets.

If somehow, someone is able to integrate a “Slate Stand” as part of the tablet design, that will be awesome.

Imagine a “Slate Stand” being a supporting stand to tilt the tablet in a 20 to 40 degrees angle (adjustable of course) for easy touch screen experience. I’m thinking just a fold under the laptop which can increase and decrease the degree angle as the fold gets closer together. Imagine this: /\ :underneath your laptop, and flattening out: —— :when you don’t need it.

Together with full size keyboard which will “slide in and out” virtually on the screen with a flick of a button (or gesture, or on some text input) and each key is big enough for our fingers, I think we’ve got something pretty good going on here.

Re-engineering applications’ user interactions to make full use of multi-touch, and we have endless possibilities. Hey, that’s what WPF is for. *wink*

Let’s hope to see it out there soon!

Elevating Privileges in SharePoint

Here’s a good tip for elevating privileges in SharePoint.


For those who doesn’t want to click on that link (like myself when I searching for this post again), here’s the code.

//Don't dispose the following two objects. Sharepoint will take care of their disposal when page is completely rendered.
SPWeb  webInUserContext = SPContext.Current.Web;
SPSite SiteInUserContext = SPContext.Current.Site;
Guid webGuid = webInUserContext.ID;
Guid siteGuid = SiteInUserContext.ID;

                    // get the site in impersonated context
                    using (SPSite site = new SPSite(siteGuid))

                        // get the web in the impersonated context
                        SPWeb web = site.OpenWeb(webGuid);
                       // Do your work here  



There we go. I used this piece of code to access the SPFile of a document within SharePoint. SPFile requires elevated privileges, and can’t be access with just your normal privileges.

My code works now, and I’m happy. :)

Where is my Check-In in SharePoint Designer?


If you notice, the master page file in SharePoint Designer is checked out (from the check symbol at the side). It’s supposed to show me “Check In” and “Undo Check Out” and all that. Where is it?

It is under your “Edit” toolbar, “Check In”.


So when it doesn’t display, you know where to go.

Hiding Sign In Link For Anonymous Access Users in SharePoint

To customize SharePoint “Sign In” link, we need to modify or duplicate Welcome.ascx in your Control Templates directory.

Here’s a good post specifying how to hide your sign in link.

Hide the Sign In link for the anonymous access user in anonymous access enabled site - Bend the Welcome.ascx - SharePoint MOSS

You can play around with Welcome.ascx and come up with your custom style sign in.

Free UX Tools and Extensions for Websites

Here’s a great blog post with the compilation of great tools if you’re a web developer.

Top 29 Free UX Tools and Extensions

I ran a few of the test on our website, and boy are there a few optimizations we could have done, especially for the JavaScript within the pages to improve performance. And also some quirks xhtml and css errors which will just make things nice and more standardised.

SharePoint: Bug or Feature? @Created not on Variation Site

As mentioned in the title, the @Created date field (or site column, depending on your terminology), the date of document creation, which is by default available to all pages and documents, is not replicated when you create a site variation. It is however *linked* to the original document from the original site itself. So if you ever decide to turn off site variation, you’ll lose the @Created date field on your site variation, and there’s absolutely no way to get it back, or at least I haven’t found a way to get it back without hacking it through code.

So be careful when you decide to create a site variation. This “feature” caught us all by surprise, especially when variation was turned off and still wanted the persisted site.

One suggestion to get around it is to create another field and set the computed value to today’s date. I’ll blog more on how we solve this problem when we actually do.