Skip to content

Instantly share code, notes, and snippets.

@vendettamit
vendettamit / InvokeRemoteProcess.cs
Created May 12, 2016 21:09
WMI Snippet to invoke a process on remote machine with privileges.
ConnectionOptions connection = new ConnectionOptions() {
EnablePrivileges = true
};
connection.Username = "achoudhary";
connection.Password = "ggn@1212";
connection.Authority = "ntlmdomain:health";
ManagementScope scope = new ManagementScope(
"\\\\7vmdev038\\root\\CIMV2", connection);
scope.Connect();
@vendettamit
vendettamit / MS-TestResult-XSL2.0.xsl
Created May 6, 2016 20:29
xml stylesheet to transform MS Coded UI test results to html with xslt 2.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xp="http://www.xmlprime.com/"
xmlns:ext="urn:extensions">
<xsl:output method="html" />
<xsl:param name="applicationPath" select="'.'" />
<xsl:template match="/">
<script language="javascript">
function toggle (name, spn)
@vendettamit
vendettamit / MS-TestResult-XSL1.0.xsl
Created May 6, 2016 20:28
xml stylesheet to transform MS Coded UI test results to html with xslt 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xp="http://www.xmlprime.com/"
xmlns:ext="urn:extensions">
<xsl:output method="html" />
<xsl:param name="applicationPath" select="'.'" />
<xsl:key name="groups" match="result" use="testCaseStatus"/>
<xsl:template match="/">
@vendettamit
vendettamit / UnitOfWorkFactory.tt
Created May 2, 2016 20:02
A T4Template to auto generate Unit of work factory over repository pattern (Entity framework)
<#@ template debug="true" hostSpecific="true" #>
<#@ output extension=".cs" #>
<#@ Assembly Name="System.Core.dll" #>
<#@ Assembly Name="System.Xml.dll" #>
<#@ Assembly Name="System.Xml.Linq.dll" #>
<#@ Assembly Name="System.Windows.Forms.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
@vendettamit
vendettamit / IdentitySeed.sql
Created April 5, 2016 14:19
Demo scripts replicating the scenario where Trunc would reset the Reseeded identity column in existing table
USE [YourDb]
GO
-- Create Table
CREATE TABLE [dbo].[TestTable](
[ID] [int] IDENTITY(11,1) NOT NULL,
[Var] [nchar](10) NULL,
[Dated] DateTime default CURRENT_TIMESTAMP
) ON [PRIMARY]
GO
@vendettamit
vendettamit / Trigger.js
Last active February 23, 2016 21:15
Change default onfocusout and trigger validation for individual form elements while user starts typing in input fields
$(document).ready(function () {
var $validatr = $('form').data('validator');
var settngs = $validatr.settings;
settngs.onkeyup = function (element, eventType) {
if (!$validatr.element(element))
{
$(this.currentForm).triggerHandler("invalid-form", [this]);
}
};
@vendettamit
vendettamit / DynamicLinqCSharp.cs
Created February 19, 2016 16:27
A dynamic linq class library source code. Download the original content from here - http://www.scottgu.com/blogposts/dynquery/dynamiclinqcsharp.zip
//Copyright (C) Microsoft Corporation. All rights reserved.
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
@vendettamit
vendettamit / TfvcTemplate.12.WithChaining.xaml
Created February 18, 2016 15:46 — forked from jstangroome/TfvcTemplate.12.WithChaining.xaml
The Team Build 2013 default process template for TFVC with support for queuing additional builds on success and passing parameters. http://blog.stangroome.com/2014/02/19/queue-a-team-build-from-another-and-pass-parameters/
<Activity x:Class="TfsBuild.Process" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mt="clr-namespace:Microsoft.TeamFoundation;assembly=Microsoft.TeamFoundation.Common" xmlns:mtbc="clr-namespace:Microsoft.TeamFoundation.Build.Client;assembly=Microsoft.TeamFoundation.Build.Client" xmlns:mtbco="clr-namespace:Microsoft.TeamFoundation.Build.Common;assembly=Microsoft.TeamFoundation.Build.Common" xmlns:mtbw="clr-namespace:Microsoft.TeamFoundation.Build.Workflow;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtbwa="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Activities;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:mtba="clr-namespace:Microsoft.TeamFoundation.Build.Activities;assembly=Microsoft.TeamFoundation.Build.Activities" xmlns:mtbac="clr-namespace:Microsoft.TeamFoundation.Build.Activities.Core;assembly=Microsoft.TeamFoundation.Build.Activities" xmlns:mtbag="clr-namespace:Microsoft.TeamFound
public class ExpensiveSqlLoggerInterceptor : DbCommandInterceptor
{
private readonly IQueryLogger _queryLogger;
private readonly int _executionMillisecondThreshold;
private readonly bool _includeStackTrace;
public ExpensiveSqlLoggerInterceptor(IQueryLogger logger, int executionMillisecondThreshold, bool enableStackTrace = true)
{
_queryLogger = logger;
_executionMillisecondThreshold = executionMillisecondThreshold;
public class Program
{
class TeamHistory
{
public DateTime Date { get; set; }
public string Event { get; set; }
public string TeamName { get; set; }