Home > Blogs
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.
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:
CREATE VIEW vRandNumber
AS
SELECT RAND() as RandNumber
go
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)
RETURNS float
AS
BEGIN
RETURN @Min + (select RandNumber from vRandNumber) * ((@Max+1)-@Min)
END
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.
Here’s a great link I thought to share.
http://www.backtoessentials.com/tools/40-useful-print-ready-cheat-sheet-for-web-developers/
It contains 40 great cheat sheets pdf links so you can download them and print it right off.
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.
HKLM\Software\Microsoft\SQMClient\Windows\DisabledSessions
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.
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!
Here’s a good tip for elevating privileges in SharePoint.
http://blogs.devhorizon.com/blogs/reza_on_blogging/archive/2007/07/12/484.aspx
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;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
// 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
web.Dispose();
}
});
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. :)
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.
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.
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.
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.
Note to self – Before developing on SharePoint, always enable debugging on the development machine to see a “little” more verbose error messages. Edit the web.config and change the following:
<SafeMode MaxControls="200" CallStack="false" ...> <!-- Becomes -->
<SafeMode MaxControls="200" CallStack="true" ...>
<customErrors mode="On" /> <!-- Becomes -->
<customErrors mode="Off" />
<compilation batch="false" debug="false"> <!-- Becomes -->
<compilation batch="true" debug="true">
Note to self - If using any external assemblies that try to access Microsoft.Sharepoint assemblies, remember to change the trust level to full in the web.config.
<trust level="Full" originUrl="" />
This is only used during development.
When it comes to production, install assembly into the GAC with gacutil /i to allow external assemblies access to Microsoft.Sharepoint assemblies.
Visual Studio Lab (VSLab) exploits the power of F# and its interactive top level to provide an interactive environment similar to MatLab and Mathematica, in which you can easily create Add-ins and interact dynamically with them inside Visual Studio. Moreover, since F# is a compiled language, the final code can be compiled as a standalone application.
Goal of the project is to provide the basic infrastructure to turn Visual Studio in VSLab, and a number of addins (called viewlets) used to show data and support development of scientific based applications.
Take a look. :) I assure you that you'll be impressed.
Flash content is finally searchable by two of the biggest online search engines on the internet, Google and Yahoo.
One of the biggest disadvantage of using Flash content for your dynamic content is simply because it is not searchable, and now with Adobe's new optimized Adobe Flash Player helping both Google and Yahoo to search and index Flash content, this means that there is no excuse left NOT TO USE FLASH on your web sites.
Note that Microsoft Live Search was not included in this partnership.
Now, for those enthusiastic about writing Silverlight content on the web, might I ask, what is Microsoft going to do about this? Both in its Live Search, making it competitive with Google and Yahoo to search Flash content, and also making Silverlight content searchable too. This is the biggest advantage Adobe Flash has over Silverlight now, and if Microsoft doesn't do anything about it, the web will not be convinced about Silverlight, regardless of the amount of bribing promoting they can and will do.
Adobe, we love you and thank you.
To those Silverlight enthusiasts, please get your facts right about Adobe Flash before even bashing Adobe Flash technology. You know who you are.
Is it better to have a user implicitly learning how an application work easily by discovery, rather than explicitly learning how an application works through training and books?
If something goes wrong with an application, is it really a "problem between the keyboard and the chair"? Or is it because the "User Experience" isn't sufficient or consistent to assist with implicit learning?
Sometimes people in the "Computer Industry" need to think more about the user and how to ease their pain, instead of blaming them and create more pain for them.
I'm always amazed when a user tells me "It just works! Amazing!" instead of "How do you do this?". That's "User Experience" for you.
Think about it.
This is my rant today.
Well, it seems this month I'm up for being interviewed. Here's the link to my interview.
Rob Burke is teaching a WPF training course through Toronto-based consultancy ObjectSharp. The course is called “Windows Presentation Foundation for Developers and Lead Designers,” and, as the title suggests, it offers a hands-on experience designed to give developers and lead designers the knowledge, background, tips and references they’ll need to build smart client applications using the Windows Presentation Foundation.
After enjoying the process of training a team of developers and designers to use WPF, this course is the result of turning that material into a course that we could offer here.
The inaugural course offering is currently scheduled for August 13th-15th. If you’re interested in taking part, please find more information about the course on ObjectSharp’s site. Also, if August 13th is too long for you to wait, or you’re interested in an on-site course, please contact Julie James, ObjectSharp’s Training Manager.
More on Rob Burke.
What is Pex?
Pex generates test inputs that cover all, or at least many of the corner cases in your .NET code. These test inputs are plugged into parameterized unit test that you write. The result is a small unit test suite, where each unit test calls the parameterized unit test with particular test inputs. There is a great picture on the main Pex page that illustrates this process.
Pex supports other unit test frameworks since the unit tests that Pex generates can be executed by other unit test frameworks without Pex. Pex comes with support for MSTest, the unit test framework of Visual Studio, out of the box. For support for other unit test frameworks, please look at the Pex Extensions project.
Parameterized unit tests have been around for quite some time already, under several names -- row tests, data-driven tests, theories, etc.
What is really unique about Pex is that it analyzes your .NET code, instruction by instruction, to understand what your code is doing. Then, in a fully automatic way, Pex computes relevant test inputs that trigger the corner cases of the code. When you write assertions, Pex will try to come up with test inputs that cause an assertion to fail.
Feedback
To ask questions, get help, or just give feedback, please take a look at our mailing lists.
Links
Homepage: http://research.microsoft.com/pex
Download: http://research.microsoft.com/pex/downloads.aspx
Nikolai Tillmann's Blog: http://blogs.msdn.com/nikolait
Peli de Halleux's Blog: http://blog.dotnetwiki.org/
Source Analysis, also known as StyleCop, analyzes C# source code to enforce a set of best practice style and consistency rules.
Source Analysis for C# can be downloaded here: https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sourceanalysis.
Source Analysis Blog: http://blogs.msdn.com/sourceanalysis
Here's a very simple QuickSort algorithm from Wikipedia written in a very Functional way of C#. Notice that it looks very close to the pseudo-code algorithm shown in Wikipedia. The pivot used is just sequence.First(). You can replace the pivot by some random position if you wish.
1: public static IEnumerable<T> QuickSort<T>(this IEnumerable<T> sequence) where T : IComparable<T>
2: { 3: return !sequence.Any()
4: ? sequence
5: : ((from x in sequence.Skip(1)
6: where x.CompareTo(sequence.First()) < 0
7: select x)
8: .QuickSort()
9: ).Concat(new[] { sequence.First() }).Concat((from x in sequence.Skip(1) 10: where x.CompareTo(sequence.First()) >= 0
11: select x).QuickSort());
12: }
I tried making this more fun by using the Fix Point Generator which I mentioned previously, and converted that code into a Func<IEnumerable<T>> instead. Here's the code.
1: public static Func<T, T> Fix<T>(Func<Func<T, T>, Func<T, T>> F)
2: { 3: return x => F(Fix(F))(x);
4: }
5:
6: static void Main()
7: { 8: var quicksort = Fix<IEnumerable<int>>(
9: qsort =>
10: sequence =>
11: !sequence.Any()
12: ? sequence
13: : qsort(from x in sequence.Skip(1)
14: where x.CompareTo(sequence.First()) < 0
15: select x)
16: .Concat(new[] { sequence.First() }) 17: .Concat(qsort(from x in sequence.Skip(1)
18: where x.CompareTo(sequence.First()) >= 0
19: select x)));
20: }
This is a perfect example of how you can use the Fix Point Generator to create your recursive functions on the fly. If you want to make it reusable with an extension method, you can easily convert it to the extension method, or a normal method. Personally I feel that using the Fix Point Generator is more intuitive and slightly more readable as oppose to the extension method way of doing things.
One point to note is that the "Concat" extension only accepts an IEnumerable<T> and not a single item. You can solve this by the above, "new[] { sequence.First() }" which is a cleaner way if you don't want to write your own extension method (which you could too).
Crazy stuff eh?
If your bluetooth adapter is a Broadcom Bluetooth 2.0 EDR, like the "ThinkPad Bluetooth with Enhanced Data Rate" or any Broadcom Bluetooth 2.0 EDR type adapter, you can follow the steps below to get bluetooth working on Windows Server 2008.
Required for install:
Vista or WS2008 x86: http://www.toshiba-tro.de/tools/bluetooth/BT-stack.zip
Vista or WS2008 x64: http://www.toshiba-tro.de/tools/bluetooth/BT-stack-64bit.zip
Hex Editor, e.g. WinHex or CodePad
1. If you down it, you will install this software. When Toshiba Setup say Plug your BT device, you'll click to cancel. Install is succesfull.
2. Open Device Manager (Start | Control Panel | Device Manager) or Start | Run... | devmgmt.msc
You find in Other devices - Bluetooth dongle. Get Properties of it. On fold Details you see Property, It scroll to Hardware Ids. In Value Box u see two line, e.g.:
USB\VID_0A5C&PID_2101&REV_0100
USB\VID_0A5C&PID_2101
You copy second line with short Ids ('USB\VID_0A5C&PID_2101')
3. Now you going to folder:
Vista or WS2008 x86: %PROGRAMFILES%\Toshiba\Bluetooth Toshiba Stack\Drivers\tosrfusb
Vista or WS2008 x64: %PROGRAMFILES(x86)%\Toshiba\Bluetooth Toshiba Stack\Drivers\tosrfusb
Here are files: tosrfusb.cat, tosrfusb.inf, tosrfusb.sys
You need edited *.cat, and *.inf file.
4. Open tosrfusb.inf in Notepad.exe (e.g. Start | Run... | Notepad.exe)
Here you must edited line 161:
%TosrfUsb.DeviceDesc97%=TosrfUsb_Device, USB\VID_0C24&PID_000F
and line 288:
%TosrfUsb.DeviceDesc97%=TosrfUsb_Device, USB\VID_0C24&PID_000F
You edit this lines to:
%TosrfUsb.DeviceDesc97%=TosrfUsb_Device, USB\VID_0A5C&PID_2101
And save as tosrfusb.inf (replace original file).
5. Open tosrfusb.cat in Hex Editor (e.g. WinHex, CodePad).
Ctrl+F.. You need line of characters (but not find this data as text value!):
4800570049004400390037020410010001042C7500730062005C007600690064005F00300063003200340026007000690064005F0030003000300035
or
H.W.I.D.9.7.......,u.s.b.\.v.i.d._.0.c.2.4.&.p.i.d._.0.0.0.5
or
HWID97 ,usb\vid_0c24&pid_0005
There you must change value help by ASCI table, e.g.:
4800570049004400390037020410010001042C7500730062005C007600690064005F00300041003500430026007000690064005F0032003100300031
or
H.W.I.D.9.7.......,u.s.b.\.v.i.d._.0.A.5.C.&.p.i.d._.2.1.0.1
or
HWID97 ,usb\vid_0A5C&pid_2101
And save as tosrfusb.cat (replace original file).
6. Now you can install your BT.
Vista or WS2008 x86: %PROGRAMFILES%\Toshiba\Bluetooth Toshiba Stack\ECCenter.exe
Vista or WS2008 x64: %PROGRAMFILES(x86)%\Toshiba\Bluetooth Toshiba Stack\ECCenter.exe
You must Ignore install not sign drivers and all is Okay.
[Source: MSDN Forums]
If anyone tried to install WMP plugin for Firefox on Windows Server 2008 (or any server os), they will get an error stating that server os are not supported. In order to get it working, you need to do the following steps.
- Rename wmpfirefoxplugin.exe to wmpfirefoxplugin.zip.
- Extract it into a directory.
- Type the following command in a console:
msiexec /a ffplugin.msi - It will install it probably in C:\
- Copy this file, np-mswmp.dll, into your plugins directory of Firefox (usually C:\Program Files\Mozilla Firefox\plugins)
Restart Firefox and it should work.
I copied this blog post from Chris Dufour's blog. Chris copied it from Rob Windsor's blog. Rob copied it from Julie Lerman's blog. Julie copied it from Guy Barrette's blog. I'm sure someone will copy it from me and add their own little flair.
If you live in Toronto and don't attend DevTeach, Guy Barrette is going to make you code in Clipper for the remainder of your career (BTW - that's Clipper development with no Multi Edit and no Norton Guides. Ah, there, now you're shaking). Seriously, DevTeach has a great lineup of speakers from Toronto and across the globe. Where else can you hear, see, touch, feel, talk to, describe your problems (IT/Dev related or not) and have a beer with these guys/gals?
And that's only half of them!!!
Need more reasons?
Keynote by Scott Hanselman
Scott is one of the most prolific, renowned and respected bloggers (http://www.hanselman.com) and podcasters (http://www.hanselminutes.com) in the .NET world. Scott is a hands-on thinker, a renowned speaker and writer. He has written a few books, most recently with Bill Evjen and Devin Rader on Professional ASP.NET. In July 2007, he joined Microsoft as a Senior Program Manager in the Developer Division. In his new role he'll continue to explore and explain a broad portfolio of technologies, both inside and outside Microsoft. He aims to spread the good word about developing software, most often on the Microsoft stack. Before this he was the Chief Architect at Corillian Corporation, now a part of Checkfree, for 6+ years and before that he was a Principal Consultant at STEP Technology for nearly 7 years.
http://www.devteach.com/keynote.aspx
Silverlight 2.0 Workshop
For the first time an independent conference is having a workshop on Building Business Applications with Silverlight 2.0. Join Rod Paddock and Jim Duffy as they give you a head start down the road to developing business-oriented Rich Internet Applications (RIA) with Microsoft Silverlight 2.0. Microsoft Silverlight 2.0 is a cross-browser, cross-platform, and cross-device plug-in positioned to revolutionize the way next generation Rich Internet Applications are developed. Microsoft’s commitment to providing an extensive platform for developers and designers to collaborate on creating the next generation of RIAs is very clear and its name is Silverlight 2.0. In this intensive, full-day workshop, Rod and Jim will share their insight and experience building business applications with Silverlight 2.0 including a review of some of the Internet’s more visible Silverlight web applications. This workshop is happening on Friday May 16 at the Hilton Toronto.
http://www.devteach.com/PostConference.aspx#PreSP
Bonus session: .NET Rocks hosts a panel May 14th at 18:00
This year the bonus session (Wednesday May 14 at 18:00) will be a panel of speakers debating the Future of .NET. Where is .NET going? How will new development influence .NET and be influenced by .NET? Join Carl Franklin and Richard Campbell from .NET Rocks as they moderate a discussion on the future directions of .NET. The panellists include individuals who have strong visions of the future of software development and the role that .NET can play in that future. Attend this session and bring your questions to get some insight into the potential future of .NET! This bonus session is free for everyone. Panelists are: Ted Neward,Oren Eini ,Scott Bellware
http://www.devteach.com/BonusSession.aspx
Party with Palermo, DevTeach Toronto Edition
Jeffrey Palermo (MVP) is hosting Monday May 12th in Toronto is acclaimed "Party with Palermo". This is the official social event kicking off DevTeach Toronto. The event is not just for the attendees of Toronto it’s a free event for everyone. It’s a unique chance for the attendees, speakers and locals to meet and talk with a free beer. The event will be held at the Menage club location and you need to RSVP to attend. Get all the details at this link:
http://www.partywithpalermo.com/
DevTeach Toronto is going to be a lot of fun and a great chance to learn from the best minds in the industry. Register now - you don't want to miss out.
Well, 45 minutes before my surprise presentation I had to do, without me even knowing I had to do it. Here it is.
Video: Toronto Code Camp 2008 - Speakers Room Part 2
From OSNews:
Microsoft has released source code from the Singularity research project onto Codeplex under an academic, non-commercial license. "The Singularity Research Development Kit is based on the Microsoft Research Singularity project. It includes source code, build tools, test suites, design notes, and other background materials. The Singularity RDK is for academic non-commercial use only and is governed by this license."
How cool is that? I'm going to download it and play with it! For those who don't already know, here's a description of what Singularity is.
Singularity is a research project focused on the construction of dependable systems through innovation in the areas of systems, languages, and tools. We are building a research operating system prototype (called Singularity), extending programming languages, and developing new techniques and tools for specifying and verifying program behavior.
Advances in languages, compilers, and tools open the possibility of significantly improving software. For example, Singularity uses type-safe languages and an abstract instruction set to enable what we call Software Isolated Processes (SIPs). SIPs provide the strong isolation guarantees of OS processes (isolated object space, separate GCs, separate runtimes) without the overhead of hardware-enforced protection domains. In the current Singularity prototype SIPs are extremely cheap; they run in ring 0 in the kernel’s address space.
Singularity uses these advances to build more reliable systems and applications. For example, because SIPs are so cheap to create and enforce, Singularity runs each program, device driver, or system extension in its own SIP. SIPs are not allowed to share memory or modify their own code. As a result, we can make strong reliability guarantees about the code running in a SIP. We can verify much broader properties about a SIP at compile or install time than can be done for code running in traditional OS processes. Broader application of static verification is critical to predicting system behaviour and providing users with strong guarantees about reliability.
For those who has been getting the ultimate crashes from SharePoint Designer, and many weird oddities with it, this is something that you should know while working with Data View Web Parts. Occasionally, SharePoint Designer will NOT allow you to add a Data View Web Part no matter what you do, as shown below, and the main reason is... *drum roll*... your file is not saved.

The first screen shot shows a "changed but not saved file" and "Insert Selected Fields As..." not working and the second screen shot shows the "Insert Selected Fields as..." working after saving.
Here's a tip for those people getting & instead of & (and all those other fancy html encodes) from your XSLT variables. You just need to add disable-output-escaping and set that to "yes" when you do a value-of.
<xsl:value-of select="$Site" disable-output-escaping="yes"/>
While working with SharePoint, I found that I sometimes need to replace strings with some characters or strings, for example, replacing "&" with "&", or replacing "_x0020_" with " ". This is a useful template to do so. I got this template from here.
1: <!-- here is the template that does the replacement -->
2: <xsl:template name="replaceCharsInString">
3: <xsl:param name="stringIn"/>
4: <xsl:param name="charsIn"/>
5: <xsl:param name="charsOut"/>
6: <xsl:choose>
7: <xsl:when test="contains($stringIn,$charsIn)">
8: <xsl:value-of select="concat(substring-before($stringIn,$charsIn),$charsOut)"/>
9: <xsl:call-template name="replaceCharsInString">
10: <xsl:with-param name="stringIn" select="substring-after($stringIn,$charsIn)"/>
11: <xsl:with-param name="charsIn" select="$charsIn"/>
12: <xsl:with-param name="charsOut" select="$charsOut"/>
13: </xsl:call-template>
14: </xsl:when>
15: <xsl:otherwise>
16: <xsl:value-of select="$stringIn"/>
17: </xsl:otherwise>
18: </xsl:choose>
19: </xsl:template>
And here's how you'll call it.
1: <!-- pretend this is in a template -->
2: <xsl:variable name="myString" select="'This%20is%20Test'"/>
3: <xsl:variable name="myNewString">
4: <xsl:call-template name="replaceCharsInString">
5: <xsl:with-param name="stringIn" select="string($myString)"/>
6: <xsl:with-param name="charsIn" select="'%20'"/>
7: <xsl:with-param name="charsOut" select="' '"/>
8: </xsl:call-template>
9: </xsl:variable>
10: <!-- $myNewString is a result tree fragment, which should be OK. -->
11: <!-- If you really need a string object, do this: -->
12: <xsl:variable name="myNewRealString" select="string($myNewString)"/>
And there you have it. Very useful indeed.
After the Toronto Code Camp event on Saturday, the gang went out for a drink at the Spotted ***. Your host, Rob Windsor was interviewing each of us. There're lots of weird things going on, especially badgers running around. :) Here it is. It's hilarious. Enjoy.
Video: Toronto Code Camp 2008: Interviews at the Pub
I've just installed this to try it out. Here's a description of what it is from jkOnTheRun.
Anyone who has been using mobile devices for very long knows too well the hit and miss scenario caused by multi-tasking. You have too much running in the background and the CPU grinds up to 100% and it's hard to do much of anything. Today's Freeware of the Moment is a utility that aims to end that problem once and for all. Process Lasso sets some rules and runs (with very little resources) in the background and prevents bad things from happening when too much gets going at once. It watches your CPU resources and when they get tapped out it steps the priority down for processes until the system is running at an even keel. I have heard many people praise this program but none so well as Steven Hughes of BostonPocket PC who has published a very thorough review of Process Lasso. Check out the review and then give Process Lasso a try and see how well your older system runs with today's programs. Note that Process Lasso runs under Windows 2000, XP and Vista and there are both 32 bit and 64 bit versions available. Be sure and get the right one and you'll be hauling buns in short order. Don't be intimidated, while Process Lasso has all sorts of technical settings to give you total control over your running environment the defaults will pretty much sort your system out with ease.
Well, the next version of XNA Game Studio is released. Download it here.
What’s New with XNA Game Studio?
- XNA Game Studio 2.0 works in all versions of Visual Studio 2005. This includes Standard and Professional, as well as many other specific editions.
- The new and improved interface makes it easier for you to manage your Xbox 360 console.
- You’ll find that managing and building content is easier and more consistent in XNA Game Studio.
- We’ve included project templates for content importers and processors.
- You can configure how content is processed with the new ability to set parameters on Content Processors.
What’s new in the XNA Framework? Now you can:
- Create rich multiplayer games over Xbox LIVE using the new networking APIs.
- Create Audio more effectively with the new XACT editor!
- Host XNA Framework games easily inside a Windows Form.
- Use the virtualized GraphicsDevice: no more special code to handle device reset and recreate!
- Take advantage of render targets that are more flexible, consistent, and easier to use. Xbox 360 and Windows now support multiple render targets (MRTs) as well.
- Easily nest one component inside another thanks to improvements in GameComponent.
- Enjoy many more enhancements and tweaks!
Reading Mads Torgersen old blog post on Recursive Lambda Expressions, I decided it was time for me to seriously play with his code and try out the fixed point generator to create recursive lambda expressions (together with the fact that I was sick and felt bored).
Taking lessons from that blog post, I created a reusable fixed point generator which we can use for anything that uses recursion. Here's the code, simply.
1: public static Func<T, T> Fix<T>(Func<Func<T, T>, Func<T, T>> F)
2: { 3: return x => F(Fix<T>(F))(x);
4: }
5:
6: public static Func<T, T, T> Fix<T>(Func<Func<T, T, T>, Func<T, T, T>> F)
7: { 8: return (x, n) => F(Fix<T>(F))(x, n);
9: }
10:
11: public static Func<T1, T2, T1> Fix<T1, T2>(Func<Func<T1, T2, T1>, Func<T1, T2, T1>> F)
12: { 13: return (x, n) => F(Fix<T1, T2>(F))(x, n);
14: }
15:
16: public static Func<T, T, T, T> Fix<T>(Func<Func<T, T, T, T>, Func<T, T, T, T>> F)
17: { 18: return (x, n, k) => F(Fix<T>(F))(x, n, k);
19: }
Static Fix methods are the actual Fixed Point Generator as described in Mads' blog. This simplifies the code and makes it reusable. The method at lines 11-14 shows how 2 different input can be used. I will be using this method for the sine and cosine lambda expressions I've written.
1: Func<double, double> factorial = Fix<double>(fac => x => x == 0 ? 1 : x * fac(x - 1));
2: Func<double, int, double> sine = Fix<double, int>(sin => (x, n) => n == 0 ? x :
3: sin(x, n - 1) + Math.Pow(-1, n) * Math.Pow(x, 2 * n + 1) / factorial(2 * n + 1));
4: Func<double, int, double> cosine = Fix<double, int>(cos => (x, n) => n == 0 ? 1 :
5: cos(x, n - 1) + Math.Pow(-1, n) * Math.Pow(x, 2 * n) / factorial(2 * n));
The factorial lambda expression is the same as in Mads' blog. I've created both sine and cosine lambda expressions learning from how the fixed point generator works. I have to keep factorial as double instead of int because it'll make the precision wrong.
I used the Taylor Series in order to generate the sine and cosine function. x is the angle in radians, and n is the number of recursion to do (i.e. the more recursion, the more precision).
The basic recursion is as follows:

So that's that! Plug in your lambda expression into the Fix static method and you're done, you've got recursion.
Further testing out whether if it actually works, here's a simple testing code:
1: for (int i = 0; i < 20; i++)
3: Console.WriteLine(factorial(i));
6: Console.WriteLine(sine(Math.PI / 4, 10));
7: Console.WriteLine(Math.Sin(Math.PI / 4));
9: Console.WriteLine(cosine(Math.PI / 3, 10));
10: Console.WriteLine(Math.Cos(Math.PI / 3));
Here, what I do is I check my sine and cosine output with the actual Math.Sin and Math.Cos methods from the framework. It looks like it works well with n = 10 or higher, achieving the same precision as the framework.
That's that. I will play around with more of this, and create more methods out of this.
I tried generalizing the method itself to make it look better and easier to read, but the limits of Generics in C# stopped me from doing anything further. Here's what I tried to do, but failed of course.
1: // I need a constraint operator- to make this work, but Generics does not support this
2: public static Func<T, T> Factorial<T>() where T : struct, IEquatable<T>, operator-
3: { 4: return Fix<T>(fac => x => x.Equals(0) ? 1 : x * fac(x - 1));
5: }
If that was successful, then the code would have been reduced to simply like this.
Doesn't that look better? If only, but there must be come other way to do this.
If Google can do it, so can Microsoft. Volta is the GWT of .NET. Enough said. Here's a description of what it is.
The Volta technology preview is a developer toolset that enables you to build multi-tier web applications by applying familiar techniques and patterns. First, design and build your application as a .NET client application, then assign the portions of the application to run on the server and the client tiers late in the development process. The compiler creates cross-browser JavaScript for the client tier, web services for the server tier, and communication, serialization, synchronization, security, and other boilerplate code to tie the tiers together.
Developers can target either web browsers or the CLR as clients and Volta handles the complexities of tier-splitting for you. Volta comprises tools such as end-to-end profiling to make architectural refactoring and optimization simple and quick. In effect, Volta offers a best-effort experience in multiple environments without any changes to the application.
Download it here.
You need Visual Studio 2008 and .NET Framework 3.5.
InfoQ has a very good article for those who need to override the equality operator. Quote from InfoQ:
In this deep dive article on equal operator overloading Jonathan Allen clears the air on overriding the equality operator. In the article Jonathan provides code samples in both VB and C# to demonstrate the nuances of each .NET language. He also covers usage in both structures and classes.
Areas covered include:
- The initial Class signature
- Fields and Properties
- Type-Safe Equality
- Hash Codes
- Overriding the base class Equals method
- Performance and Testing
Enjoy this well-thought through tutorial on Equality Operator overloading.
There is a new Microsoft Downloads page created entirely with Silverlight. Click on the link to see more. It's just a preview site now.
Microsoft IT and Microsoft Research released a Line Of Code (LOC) counter that counts the number of lines of code in your software development project to determine the size and status of your project, predicting system defects, providing measurements of productivity and quality, accessing code stability, and using these metrics to measure the success of your project.
LOC Counter can be used as a stand-alone client or as a Visual Studio 2005 add-in. The tool has the following features:
- It handles many different programming languages.
- It performs many different kinds of code counts.
- It handles comments, system-generated code, blank lines, and code churn.
- It connects to many different repositories.
- It provides an estimated defect density that is based on code churn.
- It is customizable. A user can change the kinds of objects that are counted during a counting task.
- It generates detailed reports. In addition, a user can export the report information to a Microsoft Office Excel® worksheet or to a Portable Document Format (PDF) file.
- It is fast. The tool can parse 10 million lines of code in less than one hour.
It uses a Defect Density Algorithm developed from Microsoft Research that uses the following version control history of a file to estimate the software defect density with an accuracy of 89 percent:
- The number of times that the selected files has been modified
- The time period in which the modifications have occurred
- The number of files that were actually modified
"Use of Relative Code Churn Measures to Predict System Defect Density" is a PDF document from Microsoft Research that describes this.
An IT Showcase web cast called How Microsoft IT Uses Visual Studio Team System 2005 to Measure Software Code Stability includes a discussion on how code changes, also known as code churn, may affect the code stability of a programming project.
Parallel Extensions to the .NET Framework is a managed programming model for data parallelism, task parallelism, and coordination on parallel hardware unified by a common work scheduler. Parallel Extensions makes it easier for developers to write programs that scale to take advantage of parallel hardware by providing improved performance as the numbers of cores and processors increase without having to deal with many of the complexities of today’s concurrent programming models.
Parallel Extensions provides library based support for introducing concurrency into applications written with any .NET language, including but not limited to C# and Visual Basic.
ParallelFX runs on .NET FX 3.5, and relies on features available in C# 3.0 and VB 9.0 and includes:
- Imperative data and task parallelism APIs, including parallel for and foreach loops, to make the transition from sequential to parallel programs simpler.
- Declarative data parallelism in the form of a data parallel implementation of LINQ-to-Objects. This allows you to run LINQ queries on multiple processors. (PLINQ)
- First class tasks that can be used to schedule, wait on, and cancel parallel work.
- New concurrency runtime used across the library to enable lightweight tasks and effectively map and balance the concurrency expressed in code to available concurrent resources on the execution platform.
- Several great examples of how to use parallelism in real world problems to obtain impressive speedups, including a raytracer, Sudoku puzzle generator, and other simple puzzle solvers and smaller samples.
Resources:
Download Here
Parallel Extensions Team Blog
MSDN Parallel Computing Developer Center
MSDN Magazine Article: Parallel Performance: Optimize Managed Code for Multi-Core Machines
MSDN Magazine Article: Parallel LINQ: Running Queries on Multi-Core Processors
The Manycore Shift whitepaper
MSDN Forums: Parallel Extensions to the .NET Framework
MSDN Forums: Parallel Computing General forum
Parallel Extensions to the .NET Framework Connect Site
Channel9 Parallel Extension Videos
The Farseer Physics Engine is an easy to use 2D physics engine designed for Microsoft’s XNA and Silverlight platforms. The Farseer Physics Engine focuses on simplicity, useful features, and enabling the creation of fun, dynamic games.
Features
- General
- Easy To Use!
- Support for XNA (XBOX 360 and Windows)
- Support for Silverlight (1.1 and above)
- Support for Managed .Net Languages In General
- Collison
- Concave and Convex Polygons Supported
- Multiple Collision Geometries Per Body
- Collision Categories For Complex Interaction Between Physics Objects
- Collision Callback Mechanism
- Dynamics
- Joints
- Revolute Joint (body to body or fixed to world)
- Angle Joint (body to body or fixed to world)
- Slider (Prismatic) Joint
- Pin (Distance) Joint
- Force Controllers
- Linear Spring
- Angular Spring
- Easy To Build Custom Force Controllers (Explosions, Steering Behaviors, etc.)
- Support and Debugging
- Samples Framework With Samples Covering Most Major Engine Features. (XNA and Silverlight versions)
- Debug Viewer To View All Major Physics Objects (part of samples framework)
- User Manual (in progress)
Interview from InfoQ
Although intended for games, a physics engine can be used for UI effects too. This would generally be very useful to create cool effects, especially on Silverlight applications.
As the title says, it is released on MSDN Subscriptions. Go get it everyone!
Visual Studio Team System 2008 Team Foundation Server Trial (x86 and x64 WoW) - DVD (English)
Visual Studio Team System 2008 Team Suite Trial (x86 and x64 WoW) - DVD (English)
Visual Studio Team System 2008 Test Load Agent Trial (x86 and x64 WoW) - CD (English)
Visual Studio 2008 Standard Edition (x86 and x64 WoW) - DVD (English)
Visual Studio 2008 Express Editions (x86 and x64 WoW) - DVD (English)
Visual Studio 2008 Professional Edition (x86 and x64 WoW) - DVD (English)
MSDN Library for Visual Studio 2008 (x86 and x64 WoW) - DVD (English)
Here is the link to all the presentations from the Microsoft SOA and Business Process Conference 2007 that was held in Redmond from October 29th to November 2nd.
Steve Sfartz, architect evangelist at Microsoft France, mentions that access is available until 11/21/2007.



Click on the issues for the direct download link.
Here are some nice keybinding posters from Microsoft Downloads.
Visual Basic 2008 Keybinding Poster
Printable wall poster containing list of useful keyboard shortcuts for Visual Basic 2008 developers
Visual C++ 2008 Keybinding Poster List of keybidings for Visual C++ language within Visual Studio and Visual C++ Express 2008
Visual C# 2008 Poster
Wall chart showing useful keyboard shortcuts for Visual C# programming language
NET Namespaces Poster
The .NET Framework 3.5 Common Namespaces and Types Poster
(IN)SECURE Magazine is a freely available digital security magazine discussing some of the hottest information security topics. Issue 14, has just been released.
The covered topics are:
- Attacking consumer embedded devices
- Review: QualysGuard
- CCTV: technology in transition - analog or IP?
- Interview with Robert "RSnake" Hansen, CEO of SecTheory
- The future of encryption
- Endpoint threats
- Review: Kaspersky Internet Security 7.0
- Interview with Amol Sarwate, Manager, Vulnerability Research Lab, Qualys Inc.
- Network access control: bridging the network security gap
- Change and configuration solutions aid PCI auditors
- Data protection and identity management
- Information security governance: the nuts and bolts
- Securing moving targets
- 6 CTOs, 10 Burning Questions: AirDefense, AirMagnet, Aruba Networks, AirTight Networks, Fortress Technologies and Trapeze Networks
- The need for a new security approach
- Data insecurity: lessons learned?
- Wi-Fi safety and security