Tuesday, 22 July 2014
Friday, 18 July 2014
Html.ActionLink is fraught with the possibility that either the controller or action or parameter name(s) have been changed. As a way of making sure that these are always valid, we can use a strongly typed lambda expression.
We first define an ActionLink method which takes in the linkText (a string) and a lambda expression representing the controller, action and parameter(s):
Given a test action TestAction defined in the HomeController class:
We can add to our view:
Wednesday, 2 July 2014
Within stored procedures, PRINT statements appear at the very end when the stored procedure has fully executed. This makes it an unlikely candidate for printing out messages of far the stored procedure has progressed - what we'd rather want is immediate printing of the message.
To this end, I wrote a little stored procedure LogMessage that takes a 'string' as an argument and then prints this together with the time:To use it: which prints:
Thursday, 19 June 2014
Wednesday, 18 June 2014
Adding CSS dynamically onto a page can be useful if you are making a simple GreaseMonkey script which changes the css styles to make the text more readable. First define a simple function addCss:If you do not have JQuery on the page, you can always use vanilla js: Finally we can add any css we want to:
Wednesday, 11 June 2014
Following on from Doug Finke's ‘Embedding’ F# in PowerShell article, I wanted to load F# scripts within PowerShell.
Later, after a bit of Google-ing, I worked out that you don't need to use the fsc.exe compiler, because we can instead use Add-Type. However we need a "CodeDom" for the F#. I ended up installing The Old F# "PowerPack", which includes one in its FSharp.Compiler.CodeDom.dll DLL file.Here is the definition of my Add-FSharpType CmdLet:
Give either of these two parameters:
- Path - the path to the F# script file.
- TypeDefinition - a string containing the F# code.