Skip to content

Instantly share code, notes, and snippets.

View alastairs's full-sized avatar

Alastair Smith alastairs

View GitHub Profile
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install' ]
2 info using npm@1.4.3
3 info using node@v0.10.26
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 warn package.json WebAssets@0.1.0 No README data
6 verbose readDependencies using package.json deps
7 verbose install where, deps [ 'D:\\Code\\SoC\\Source\\WebAssets',
@alastairs
alastairs / Json.cs
Created April 10, 2015 15:15
A simple type to wrap up a JSON string into an object that represents the concept of "a JSON string". Use this anywhere you want have to say "string" but really want to say "JSON".
using System;
namespace RedGate.Cef.WebUI.Impl
{
/// <summary>
/// A simple type to wrap up a JSON string into an object that represents the concept of a JSON string.
/// Use this anywhere you have to say "string" but really want to say "JSON".
/// </summary>
[Serializable]
public class Json
@alastairs
alastairs / ConsoleOutput.txt
Last active August 29, 2015 14:25
Topshelf with ASP.NET vNext
Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshel
f.HostConfigurationException: The service was not properly configured:
[Failure] Command Line An unknown command-line option was found: SWITCH: appbase
(True)
[Failure] Command Line An unknown command-line option was found: ARGUMENT: "C:\t
emp\TopShelfVNextIssue"
[Failure] Command Line An unknown command-line option was found: ARGUMENT: "Micr
osoft.Framework.ApplicationHost"
[Failure] Command Line An unknown command-line option was found: SWITCH: configu
ration (True)
@alastairs
alastairs / Expand-AllArchives
Created December 20, 2010 10:56
PowerShell one-liner to extract all archives in a directory (requires the PSCX).
ls |% { pushd $_; ls *.zip |%{ Expand-Archive $_; rm $_} popd }
public ActionResult Record(int id)
{
Record record = repository.Load(id);
var viewModel = new { record.Id, record.Name, record.Description, record.Url /* etc. */ };
return View(viewModel);
}
@alastairs
alastairs / acceptance_tests.cs
Created August 14, 2011 17:31
Leap Year Calculator First Attempt
[TestFixture]
public class LeapYearCalculatorAcceptanceTests
{
[Test]
public void TestThat_IsLeapYear_ShouldReturnTrue_WhenTheGivenYearIsATypicalLeapYear()
{
const int typicalLeapYear = 1996;
var isLeapYear = LeapYearCalculator.IsLeapYear(typicalLeapYear);
@alastairs
alastairs / FirstImpl.cs
Created August 14, 2011 17:35
Leap Year Calculator Second Attempt
public static bool IsLeapYear(int year)
{
return true;
}
@alastairs
alastairs / gist:1152445
Created August 17, 2011 19:57
Pretty-print JSON
public string GetPrettyPrintedJson(string json)
{
dynamic parsedJson = JsonConvert.DeserializeObject(json);
return JsonConvert.SerializeObject(parsedJson, Formatting.Indented);
}
@alastairs
alastairs / get-scriptdirectory.ps1
Created September 13, 2011 21:55
Function to get the directory in which this script resides.
function Get-ScriptDirectory {
$invocation = (Get-Variable MyInvocation -Scope 1).Value
$script = [IO.FileInfo] $invocation.MyCommand.Path
if ([IO.File]::Exists($script)) {
return (Split-Path $script.Fullname)
} else {
return $null
}
}
@alastairs
alastairs / gist:1219663
Created September 15, 2011 16:04
Initialise a collection to an extension of another collection
private static readonly IEnumerable<Foo> BaseCollectionOfFoo = new List<Foo>
{
new Foo(1),
new Foo(2),
new Foo(3)
};
private static readonly IEnumerable<Foo> AllFoo = new List<Foo>(BaseCollectionOfFoo)
{
new Foo(4)