Skip to content

Instantly share code, notes, and snippets.

@davidalpert
davidalpert / OwinMiddlewareFluentExtensions.tt
Created April 8, 2014 20:14
T4 template to generate convention-based names for Owin/Katana middleware
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".cs" #>
<#
var namespace_name = "YOUR_NAMESPACE_HERE";
var extension_class_name = "EXTENSION_CLASS_NAME_GOES_HERE";
C:\Users\dalpert>powercfg -devicequery wake_armed
Intel(R) Centrino(R) Ultimate-N 6300 AGN
Intel(R) 82579LM Gigabit Network Connection
C:\Users\dalpert>powercfg -devicedisablewake "Intel(R) Centrino(R) Ultimate-N 6300 AGN"
C:\Users\dalpert>powercfg -devicequery wake_armed
Intel(R) 82579LM Gigabit Network Connection
C:\Users\dalpert>powercfg -devicedisablewake "Intel(R) 82579LM Gigabit Network Connection"
@davidalpert
davidalpert / build.xml
Last active August 29, 2015 13:56
A simpler MSBuild script to download all packages in a solution.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir>$(MSBuildThisFileDirectory)</SolutionDir>
<NugetExe>$(MSBuildThisFileDirectory)tools\NuGet\NuGet.exe</NugetExe>
</PropertyGroup>
<ItemGroup>
<Solutions Include="$(SolutionDir)**\*.sln" />
@davidalpert
davidalpert / RestoreAllPackages.msbuild.xml
Created February 6, 2014 02:32
An MSBuild script to download all packages referenced from a set of .NET solution's packages.config files.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir>.</SolutionDir>
</PropertyGroup>
<!-- This targets file sets a handful of nuget-related properties. -->
<Import Project=".nuget/NuGet.targets"/>
@davidalpert
davidalpert / GreaseMonkey-PrettyWebtime.js
Created January 13, 2014 16:26
A GreaseMonkey script to prettify the WebTime timesheet view.
// ==UserScript==
// @name PrettyWebtime
// @namespace http://spinthemoose.com/
// @version 0.6
// @description tries to make webtime more usable
// @match https://*.replicon.com/*
// @copyright 2013+, David Alpert
// ==/UserScript==
function PrettyWebtime() {
@davidalpert
davidalpert / gist:8244886
Created January 3, 2014 19:33
cpack succeeds
PS C:\users\davida\dev\marv.git\src\Marv> cpack
Calling 'C:\Chocolatey\chocolateyInstall\nuget.exe pack -NoPackageAnalysis'.
Attempting to build package from 'Marv.csproj'.
Packing files from 'C:\users\davida\dev\marv.git\src\Marv\bin\Debug'.
Using 'Marv.nuspec' for metadata.
Found packages.config. Using packages listed as dependencies
Successfully created package 'C:\users\davida\dev\marv.git\src\Marv\marv.0.2.1.0.nupkg'.
Reading environment variables from registry. Please wait... Done.
@davidalpert
davidalpert / gist:8244875
Created January 3, 2014 19:32
updating chocolatey's nuget client
PS C:\users\davida\dev\marv.git\src\Marv> C:\Chocolatey\chocolateyInstall\NuGet.exe update -self
Checking for updates from https://nuget.org/api/v2/.
Currently running NuGet.exe 2.1.0.
Updating NuGet.exe to 2.7.3.
Update successful.
@davidalpert
davidalpert / gist:8244859
Last active January 2, 2016 03:39
cpack fails
PS C:\dev\marv.git\src\Marv> cpack
Calling 'C:\Chocolatey\chocolateyInstall\nuget.exe pack -NoPackageAnalysis'.
Attempting to build package from 'Marv.csproj'.
Packing files from 'C:\dev\marv.git\src\Marv\bin\Debug'.
Using 'Marv.nuspec' for metadata.
The 'minClientVersion' attribute is not declared.
Reading environment variables from registry. Please wait... Done.
@davidalpert
davidalpert / StringExtensions.cs
Last active December 30, 2015 07:09
StringExtensions.ToWords() converts "EnteringAirTemperature" to "Entering Air Temperature"; useful as a default convention for converting type names to human readable labels for display purposes.
public static class StringExtensions
{
/// <summary>
/// Converts the string representation of <paramref name="src"/> to a human-readable format.
/// </summary>
/// <example>"SomeEnumValue" becomes "Some Enum Value"</example>
/// <example>"Some_Class_Name" becomes "Some Class Name"</example>
/// <param name="src">the raw input to humanize</param>
/// <param name="casingStyle">
/// An optional <see cref="CasingStyle"/> lets you control how the string is rewritten.
@davidalpert
davidalpert / BrowserFixture.cs
Created November 12, 2013 08:41
Enhance the browser object to function like a webdriver.
//Given
public class EchoModule : NancyModule
{
public EchoModule()
{
Get["/form"] = ctx =>
{
return @"
<html>
<head><title>form</title></head>