Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View alastairs's full-sized avatar

Alastair Smith alastairs

View GitHub Profile
@alastairs
alastairs / ModelBindingExample.cs
Last active May 16, 2017 19:27
Example model binding
namespace Mvc.Examples
{
public class SomeController : Controller
{
public IActionResult Post([FromBody]MyModel model)
{
// Do something with `model` here
}
}
@alastairs
alastairs / GitHubSignIn.ts
Created May 6, 2017 14:26
Failing GitHub authorisation
import { ScreenCap } from "../../helpers/ScreenCap"
import { Casper } from "casperjs"
export class GitHubSignIn {
private readonly OAUTH_AUTHORISATION_FORM = '.oauth-review-permissions form[method=post]';
constructor(private casper: Casper, private screencap: ScreenCap) { }
login(username: string, password: string): void {
this.casper
@alastairs
alastairs / New-K8sClsuter.ps1
Created May 6, 2017 11:50
Deploy a new Kubernetes cluster to Azure Container Service using the Azure Command Line 2.0
param(
[Parameter(Mandatory=$true)]
[string]$SshKeyFile,
[Parameter(Mandatory=$true)]
[string]$Location = "westeurope",
[string]$ResourceGroup = "k8s-$Location",
[string]$ClusterName = "k8s-$Location",
[string]$DnsPrefix = "ch360",
[int]$MasterCount = 1,
[int]$AgentCount = 3,
@alastairs
alastairs / Declarative.cs
Created February 5, 2017 19:45
Express Yourself! Motivating Example
public int WhatDoIDo(int[] numbers)
{
return numbers.Count(i => i % 2 == 0)
}
@alastairs
alastairs / _init.ps1
Last active November 17, 2016 16:02
Code snippets for "How we do builds"
function global:build() {
 param(
  # The Tasks to execute. An empty list runs the 
  # default task, as defined in build.ps1
  [string[]] $Tasks = @(),
  [string] $Configuration = "Release",
  [string] $BuildNumber = '0'
  )
RestoreBuildLevelPackages
@alastairs
alastairs / top-left-accumulation.js
Last active May 13, 2016 20:11
Artificial Intelligence implementations for 2048
function Ai() {
this.UP = 0;
this.RIGHT = 1;
this.DOWN = 2;
this.LEFT = 3;
this.ORIGIN =
this.init = function() {
this.move = this.UP;
@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 / 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
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 / debug.log
Last active December 17, 2015 08:09
SaveAllTheTime debug.log
2013-05-13 21:44:23.1672 - WARN: *** Detected Unit Test Runner, setting MainThreadScheduler to Immediate ***
2013-05-13 21:44:23.1825 - WARN: If we are not actually in a test runner, please file a bug
2013-05-13 21:44:23.2136 - ERROR: Couldn't load settings, creating them from scratch
EXCEPTION: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\alastair\AppData\Roaming\SaveAllTheTime\settings.json'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamReader