Skip to content

Instantly share code, notes, and snippets.

Alastair Smith alastairs

Block or report user

Report or block alastairs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View npm-debug.log
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 Apr 10, 2015
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".
View Json.cs
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 Aug 29, 2015
Topshelf with ASP.NET vNext
View ConsoleOutput.txt
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 Dec 20, 2010
PowerShell one-liner to extract all archives in a directory (requires the PSCX).
View Expand-AllArchives
ls |% { pushd $_; ls *.zip |%{ Expand-Archive $_; rm $_} popd }
View MethodMultipleResponsibilities.cs
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 Aug 14, 2011
Leap Year Calculator First Attempt
View acceptance_tests.cs
[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 Aug 14, 2011
Leap Year Calculator Second Attempt
View FirstImpl.cs
public static bool IsLeapYear(int year)
{
return true;
}
@alastairs
alastairs / gist:1152445
Created Aug 17, 2011
Pretty-print JSON
View gist:1152445
public string GetPrettyPrintedJson(string json)
{
dynamic parsedJson = JsonConvert.DeserializeObject(json);
return JsonConvert.SerializeObject(parsedJson, Formatting.Indented);
}
@alastairs
alastairs / get-scriptdirectory.ps1
Created Sep 13, 2011
Function to get the directory in which this script resides.
View get-scriptdirectory.ps1
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 Sep 15, 2011
Initialise a collection to an extension of another collection
View gist:1219663
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)
You can’t perform that action at this time.