February 2010 Entries
I write a lot of demo/test code that requires an ASP.Net provider stack and everytime I set up the sqlprovider I felt something akin to sticking a sharpened pencil in my ear. A 10mb database dependant on MSSQL just to write code/test that utilize a provider?!
Anyway, have a bit of time on my hands and contemplated writing an xml based provider stack but took a breath and said to myself; "self, someone else must have implemented this. let's see if the google knows anything about this"
ASP.NET XmlProviders - super light and open, supports all encryption types.
Clear text provider xml files...
After a minor bout of forgetfulness regarding legal regexp flags in Javascript, I knocked this one out that parses the comment block at the end of an YSOD.
var rxYSOD = /<!--\s*\[(.*?)]:(\s*.*\s(.*[\n\r]*)*?)\s*(at(.*[\n\r]*)*)-->/;
if (rxYSOD.test(text)) {
// looks like one..
var ysod = rxYSOD.exec(text);
errObj = { Message: ysod[2], StackTrace: ysod[4], ExceptionType: ysod[1] };
}
will find and parse the comment block shown. I am guessing that is why they put it there....
<html>
<!-- omitted -->
<body bgcolor="white">
<!-- omitted -->
</body>
</html>
<!--
[ArgumentException]: Unknown web method ValidateUser.
Parameter name: methodName
at...
I just thought I might keep an ongoing list of some of tools that I use daily.
This list is not inclusive and some of the obvious will be tacked on periodically.
http://compressorrater.thruhere.net/ - js compression
http://www.regextester.com/ - javascript regex tester
http://nregex.com - .net regex tester - needs some work but a reliable standby for years
http://jsbeautifier.org/
http://matthewjamestaylor.com/blog/ultimate-3-column-holy-grail-pixels.htm - xbrowser css layout cheatsheet
http://sourceforge.net/projects/ndoc3/
http://karlshifflett.wordpress.com/mole-for-visual-studio - search the page for 'Launch Mole Using WeakReference Hack' for the money shot.
...
I had the need to run a bunch of QUnit test pages and get a page level visual with the ability to drill down into a page to examine the tests without hacking them to fit in a runner or adding/changing script references in each and every one.
A need is like an itch and I like to code, not scratch, so here is a little QUnit addon that you can safely tack on to the tail of your deployed qunit.js to enable a runner and to unobtrusively hook the referenced pages. You do not have to touch the test pages and they will...
Mixing and matching security to get something like this locked down and providing the desired exposure might be challenging but I didn't offer to solve that in the title, did I?
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webScriptBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Salient.ScriptModel.Services.DualServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="Salient.ScriptModel.Services.DualServiceBehavior" name="Salient.ScriptModel.Services.DualService">
<endpoint...
Not only does System.Web.Extensions render client script enums incorrectly, The Ajax .toString and .parse are defective in either case. I haven't checked previous versions or 4.0 as delivered by vs10 but I suspect the code is the same.
Will update if I do decide to check other versions.
http://ajax.codeplex.com/WorkItem/View.aspx?WorkItemId=16450
test.enums.patched.js will be found while test..enums.patched.js will not.
I confirmed this in both IE8 and FF 3.6.
With native json support across all current versions of all major browsers it comes as some frustration that what is usually the standards bearer, Firefox 3.6, has dropped the ball.
using JSON.stringify(obj,replacer), the value returned from the replacer should be serialized and added to the json output.
FF 3.6 is ignoring the return value and serializing the object member.
Here is the test. If you see red, it is because the browser HAS native JSON but that it is failing.
Here are screenshots of all browsers/all platforms
bugzilla bug submitted
Until the bug is resolved I am overwriting JSON on firefox..
if (!this.JSON || /Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
...
// an empty object with xmldocs for assistance in creating ajax settings
var ajaxSettings = function() {
/// <summary>A set of key/value pairs that configure the Ajax request. All options are optional.
/// A default can be set for any option with $.ajaxSetup().</summary>
/// <field name="async" type="Boolean">Default: true
/// By default, all requests are sent asynchronous (i.e. this is set to true by default). If you
/// need synchronous requests, set this option to false. Note that synchronous requests may temporarily
/// lock...
Or: “What I hope is not just ‘Yet Another Visual Studio JavaScript Intellisense Walkthrough’”.
Author note: If this content seems dated, it is. When I started this blog last year I began by resurrecting a monster javascript documentation project that had been dormant for a year. Then I got busy and dropped it again. So here I am picking it back up again to provide some motivation for actually finishing a POJO documentation generator using xml doc comments and SCHB. While VS JScript Intellisense is nothing new I think that there are topics covered that I have not seen in other...
I have been playing with the MS Ajax minifier and knocked out a simple web harness. It seems to work as advertised. Compression is not as tight as some others but the integration via custom build step and the automation possibilities using the .dll version presents a very compelling case.
Get the minifier here.
Add this page and a reference to C:\Program Files\Microsoft\Microsoft Ajax Minifier 4\AjaxMin.dll.
<%@ Page Language="C#" ValidateRequest="false" %>
<%@ Import Namespace="Microsoft.Ajax.Utilities" %>
<script runat="server">
// Webform harness for Microsoft Ajax Minifier 4
// this source code placed in Public Domain by Sky Sanders
...
In response to a very interesting question by Jason Kealy on StackOverflow (Get an IDataReader from a typed List), I spiked out a fairly complete and tested implementation of IDataReader of IEnumerable and IEnumerable<T> that includes support for anonymous types making it possible to push Linq IQueryables containing anonymous types into an IDataReader.
The use case was performing a bulk insert from an in memory List. Apparently the implementation works well for this so I decided to fold it into my libs and post about it here as well.
You can find runnable source in the anwser on StackOverflow but due to the...
While writing a barebones js lib to provide intellisense enabled access to WCF JSON endpoints using the /js and /jsdebug mapped endpoints, I came across a bug in System.Web.Script.Services.ClientProxyGenerator.
I was wondering why all of the enums that were generated were marked as Flag when they clearly were not. The reason this is an issue is that if you want to .parse or .toString an enum and it is incorrectly marked Flag your results are going to be wrong.
The ramifications of this can vary from annoying to disasterous. Say you want to display people friendly value of an enum returned from a...
I have been struggling with the seemingly unbeatable UTCness of js Date.getTime in respect to dealing with dates going between javascript and wcf. I tried adding the offset/60/1000, munging local times, closing one eye and sticking out my tongue and nothing. nothing. The server was always getting a utc long and treating it as a local.
I have been following Rick's saga with wcf dates r.e. ajax and gave his solutions a go and got pleasant results with the .parseWithDate() tweak to json2.js but could not get results with the .stringifyWcf(). Got UTC with no offset no matter how much attention...
These classes build a non-denominational fixture that will Drop-Create-Drop a database in MS SqlServer. Following are sample implementations using NUnit and Fluent NHibernate.
To use the fixture, just supply a connection string that points to the database you want to create, override TestFixtureSetup and add some DDL script to the Scripts StringCollection.
NOTE: the fixture takes care of dropping and creating and declaring USING so to prepare a standard DB create script:
remove drop/create statements.
remove all USING statements.
The latest source and tests are at http://spikes.codeplex.com/SourceControl/changeset/view/41478
In use with NUnit
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using DeadSimpleDTO;
using...