Skip to content

Instantly share code, notes, and snippets.

@vansha
vansha / MSpecToJUnit.xslt
Last active September 23, 2015 13:58
MSpec to JUnit transformation
<?xml version="1.0" encoding="utf-8"?>
<!--
Converts the MSpec (http://github.com/machine/machine.specifications) xml
output to JUnit output format.
The aim of this transformation is to integrate MSpec tests to Jenkins CI.
Jenkins understands test results presented in JUnit format.
-->
@vansha
vansha / MSpecToJUnitWithMSBuild.xml
Created September 4, 2010 20:50
Transform MSpect to JUnit using MSBuild
<Target Name="TransformMSpectToJUnit">
<XslTransformation
XmlInputPaths="$(SpecsResults)"
XslInputPath="$(MSpecToJUnitTransform)"
OutputPaths="$(SpecsAsJUnitOutput)"/>
</Target>
@vansha
vansha / get-packages.ps1
Created August 16, 2011 20:33
Download all packages for the solution via NuGet
$scriptDir = split-path $script:MyInvocation.MyCommand.Path
$nuget = "$scriptDir\tools\NuGet.exe"
$packagesDir = "$scriptDir\src\Packages"
$packagesConfigs = get-content "$packagesDir\repositories.config" `
| select-string -pattern "<repository path=" `
| foreach { $_ -replace "\s*<repository path=""", """$packagesDir\" } `
| foreach { $_ -replace "\s*/>" }
foreach ($pathToPackagesConfig in $packagesConfigs)
@vansha
vansha / Dtos.cs
Created August 26, 2012 19:00
Invoking services via REST endpoints
[RestService("/orders/{id}", "GET")]
[RestService("/orders/by-code/{code}", "GET")]
[RestService("/orders/search", "GET")]
public class GetOrders {
public int? Id { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public string Customer { get; set; }
}
@vansha
vansha / Dtos.cs
Created August 26, 2012 19:50
Simplified usage of ServiceStack REST services.
// Response types omitted.
// Note that request types now marked with IRequest<TResponse> interface.
// This allows Send method to determine response type at compile time.
[RestService("/orders/{id}", "GET")]
[RestService("/orders/by-code/{code}", "GET")]
[RestService("/orders/search", "GET")]
public class GetOrders : IRequest<GetOrdersResponse> {
public int? Id { get; set; }
public string Code { get; set; }
@vansha
vansha / RestServiceExtensions.cs
Created August 26, 2012 20:02
ServiceStack RestService extension allowing to call REST services in a generic way.
namespace ServiceStack.Service
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using ServiceStack.Service;
using ServiceStack.ServiceClient.Web;
using ServiceStack.ServiceHost;
@vansha
vansha / DapperQueryHierarchy.cs
Created February 24, 2013 21:25
Querying complex object hierarchies with dapper.
public class Order {
public int Id { get; set; }
public DateTime OrderedAt { get; set }
public IList<OrderLine> OrderLines { get; set }
public Person Customer { get; set }
}
public class OrderLine {
public int Id { get; set; }
public int Count { get; set; }
@vansha
vansha / mstest-to-junit.xsl
Last active December 16, 2015 06:49
Customized mstest-to-junit xsl we use to show MSTest results in Jenkins. Original xsl is taken from mstest plugin source - https://github.com/jenkinsci/mstest-plugin/blob/master/src/main/resources/hudson/plugins/mstest/mstest-to-junit.xsl Customizations: * Show tests with 'Timeout' outcome as failed one. * Tests with 'NotExecuted' and 'Aborted' …
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a ="http://microsoft.com/schemas/VisualStudio/TeamTest/2006" xmlns:b ="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" >
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<testsuites>
<!-- MSTest outcomes: -->
<!-- total="218" executed="53" passed="52" error="0" failed="0" timeout="0" aborted="0" inconclusive="1" passedButRunAborted="0" notRunnable="0" notExecuted="165" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" -->
<xsl:variable name="buildName" select="//a:TestRun/@name"/>
<xsl:variable name="numberOfTests" select="count(//a:UnitTestResult/@outcome) + count(//b:UnitTestResult/@outcome)"/>
<xsl:variable name="numberOfFailures" select="count(//a:UnitTestResult/@outcome[.!='Passed' and .!='Inconclusive' and .!='NotExecuted' and .!='Aborted']) + count(//b:UnitTestResult/@outcome[.!='Passed' and .!='Inconclusive' and
@vansha
vansha / RemoveDbConnections.sql
Last active December 16, 2015 16:49
Quickly Remove all connections to database (to be able to restore it). (tanks to @denisreznik)
ALTER DATABASE <dbname> SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE <dbname> SET MULTI_USER
GO
ALTER DATABASE <dbname> SET ONLINE
GO
@vansha
vansha / 0_reuse_code.js
Created June 25, 2014 11:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console