This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A nice template for SQL TRY-CATCH with transactions | |
Taken from this SO discussion thread: https://stackoverflow.com/questions/7488149/sql-transaction-error-the-current-transaction-cannot-be-committed-and-cannot-su | |
*/ | |
create procedure [usp_my_procedure_name] | |
as | |
begin | |
set nocount on; | |
declare @trancount int; | |
set @trancount = @@trancount; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$modelXmlPath = Read-Host "model.xml file path" | |
$hasher = [System.Security.Cryptography.HashAlgorithm]::Create("System.Security.Cryptography.SHA256CryptoServiceProvider") | |
$fileStream = new-object System.IO.FileStream ` -ArgumentList @($modelXmlPath, [System.IO.FileMode]::Open) | |
$hash = $hasher.ComputeHash($fileStream) | |
$hashString = "" | |
Foreach ($b in $hash) { $hashString += $b.ToString("X2") } | |
$fileStream.Close() | |
$hashString |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check whether we are running in elevated mode | |
function Test-IsInElevatedMode { | |
<# | |
.DESCRIPTION | |
Checks to see whether the current Powershell prompt is running in elevated mode | |
.EXAMPLE | |
Test-IsInElevatedMode | |
.OUTPUTS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class UriInterpolator | |
{ | |
/// <summary> | |
/// Dynamically produces a parameterized path using the provided dynamic <paramref name="parameters"/> object | |
/// </summary> | |
/// <param name="path">The path with placeholders in the format of {paramName}</param> | |
/// <param name="parameters">A dynamic object representing parameter values to be interpolated into the <paramref name="path"/></param> | |
public static string BuildQueryPath(string path, dynamic parameters) | |
{ | |
if (parameters == null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// A simple representation of time | |
/// </summary> | |
public sealed class Time : IEquatable<Time> | |
{ | |
/// <summary> | |
/// Gets the hour | |
/// </summary> | |
public int Hour { get; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal static class FileInspector | |
{ | |
[DllImport("kernel32.dll")] | |
private static extern Microsoft.Win32.SafeHandles.SafeFileHandle CreateFile(string lpFileName, System.UInt32 dwDesiredAccess, System.UInt32 dwShareMode, IntPtr pSecurityAttributes, System.UInt32 dwCreationDisposition, System.UInt32 dwFlagsAndAttributes, IntPtr hTemplateFile); | |
private static readonly uint GENERIC_WRITE = 0x40000000; | |
private static readonly uint OPEN_EXISTING = 3; | |
[DllImport("kernel32.dll")] | |
[return: MarshalAs(UnmanagedType.Bool)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ServiceModel.Activation; | |
using System.Web.Routing; | |
namespace ACME.Services | |
{ | |
public class Global : System.Web.HttpApplication | |
{ | |
protected void Application_Start(object sender, EventArgs e) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko.bindingHandlers.drag = { | |
_dragging: false, | |
init: function (element, valueAccessor, allBindingsAccessor, data, context) { | |
$(element).attr('draggable', 'true'); | |
$(element).on('dragstart', function(e) { | |
// Payload (assumed to be a viewmodel) is converted to a plain JSON object | |
var d = ko.unwrap(valueAccessor()); | |
e.originalEvent.dataTransfer.setData("application/json", ko.toJSON(d)); | |
this._dragging = true; |