Category Archives: CodeMinder

Posting an AJAX JSON request with jQuery

After trying to Google this for the fifth time, and writing it from scratch for the seventh time, I’m sticking this snippet here. In AJAX apps, it’s always made sense to me to do JSON both ways, even though the … Continue reading

Posted in CodeMinder, JavaScript, JSON, Programming, REST | 1 Comment

SQL Snapshot Notes

Sometimes when testing you need to repetitively restore a database back to a certain point in time. For very large databases the regular SQL restore can take quite a while. It seemed to me that using snapshots instead of regular … Continue reading

Posted in CodeMinder, SQL | Leave a comment

From .NET, Calling REST and getting "dynamic" results

It seems like every time I want to call a RESTful service from my .NET app I have to re-lookup the documentation for either Hammock or RestSharp. Mainly for my own future reference, here’s the code using Hammock to get … Continue reading

Posted in CodeMinder, JSON, Programming, REST | Leave a comment

Force a SQL Restore

Really tired of having to google this and piece it together every time I want it, so I’m posting it here. <span class="kwrd">alter</span> <span class="kwrd">database</span> DbName <span class="kwrd">set</span> single_user <span class="kwrd">with</span> <span class="kwrd">rollback</span> <span class="kwrd">immediate</span> <span class="kwrd">go</span> <span class="kwrd">restore</span> <span … Continue reading

Posted in CodeMinder, SQL | Leave a comment

Write MSMQ Messages from PowerShell

This PowerShell script sends a message to an MSMQ. I did it this particular way because NServiceBus can consume messages sent like this. [Reflection.Assembly]::LoadWithPartialName("System.Messaging"); $queueName = '.\Private$\'; $queue = new-object System.Messaging.MessageQueue $queueName; $utf8 = new-object System.Text.UTF8Encoding; $tran = new-object System.Messaging.MessageQueueTransaction; … Continue reading

Posted in CodeMinder, MSMQ, PowerShell, Programming | 9 Comments

Read MSMQ Messages from PowerShell

This script dumps the contents of an MSMQ to the console. This one dumps the Journal contents of a private queue; of course you’ll have to adjust that line for your queue. [Reflection.Assembly]::LoadWithPartialName(<span class="str">"System.Messaging"</span>) $queueName = <span class="str">'.\Private$\\Journal$'</span>; $queue = … Continue reading

Posted in CodeMinder, MSMQ, PowerShell, Programming | Leave a comment

Update a SQL table’s XML value to insert a node

Sometimes a snippet of example code is all that’s needed: <span class="kwrd">update</span> MyTable <span class="kwrd">set</span> XmlColumn.<span class="kwrd">modify</span>(<span class="str">' insert &lt;Description&gt;This is a description&lt;/Description&gt; as last into (/xpath/to/parent)[1] '</span>) <span class="kwrd">where</span> SomeValue = <span class="str">'whatever'</span>

Posted in CodeMinder, Programming, SQL, XML | Leave a comment

Running Multiple AJAX Requests in Parallel

Update: Being about three years old, this post is pretty much obsolete. You can get this behavior, and many more convenient asynchronous compositions, with a JavaScript “Promise” library. See, for example, jQuery.when() or Q.js. — In some JavaScript I needed … Continue reading

Posted in CodeMinder, Programming | 2 Comments

log4net Template for CodeRush

If you use log4net for logging in the traditional way you end up having a lot of classes with the following line: <span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> mLog </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> log4net.ILog </span><span … Continue reading

Posted in CodeMinder, CodeRush | Leave a comment

Drop a SQL column default constraint that has been implicitly named

CodeMinder: to remind myself of stuff that I usually have to look up each time I do it. Notice the unnamed default in the following line: alter table test add col1 int not null default 1 This creates a default … Continue reading

Posted in CodeMinder, Programming, SQL | Leave a comment