Skip to content

Instantly share code, notes, and snippets.

@vansha
vansha / vs-build-performance.linq.cs
Last active August 29, 2015 14:14
Measure and profile Visual Studio solution build performance
// Struggling with slow VS solution build?
// This script should help in analyzing slow parts, by higlighting slowest projects and msbuild targets.
//
// Use following steps:
// 1. Setup proper Visual studio build settings. Use TOOLS -> Options -> Projects and Solutions -> Build and Run dialog.
// * maximum number of parallel project builds - 1
// * MSBuild project output verbosity - Diagnostic. In Diagnostic mode MSBuild outputs targets performance summary for each project.
// 2. Clean solution
// 3. Build solution
// 4. Copy build output from Output window to some file, for example c:\tmp\build-output.txt
@vansha
vansha / pullups.md
Last active August 29, 2015 14:11
Armstrong pull-up program results

My goal is to do 30 consecutive pull-ups before March 1, 2015.

I'm going to try Armstrong pull-up program and will track progress here, so you will know whether it works or not :) To keep me motivated and to give @raol an instrument for friendly trolling this gist will remain public.

Week 1 (December 8-12)

Day Push-ups Pull-ups Total Notes
Mon 60, 50, null 14 (missed other) 14
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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)