Skip to content

Instantly share code, notes, and snippets.

View GraemeF's full-sized avatar

Graeme Foster GraemeF

View GitHub Profile
@GraemeF
GraemeF / BrokenKnockout.html
Created December 21, 2011 18:45 — forked from garyshort/BrokenKnockout.html
Broken Knockout
<html>
<body>
<form data-bind="submit: onSubmit">
<button type="submit">Submit</button>
</form>
<script type="text/javascript" src="knockout-2.0.0.js"></script>
<script type="text/javascript">
window.onload = function () {
Feature("Character management", module)
.scenario("Create a new character")
.given(Events.Named_AreSubscribedTo "characterCreated")
.when(Character._IsCreatedWithName_ 1, 'bob')
.then(Events.ShouldDescribeTheCreationOfCharacter_Named_ 1, 'bob')
.complete()
@GraemeF
GraemeF / gist:1401254
Created November 28, 2011 17:43
vows-bdd
{Feature} = require "vows-bdd"
vows = require 'vows'
assert = require 'assert'
Feature("Share stuff between steps", module)
.scenario("Set properties on given and when")
.given "A is set", ->
@A = "A"
@callback()
@GraemeF
GraemeF / gist:1381916
Created November 21, 2011 07:24
PowerShell script to keep running builds when stuff changes
Import-Module pswatch
Function Rebuild($message)
{
cls
Write-Host $message
Invoke-psake .\build.ps1
}
Rebuild "Starting up."
@GraemeF
GraemeF / TypedFactoryTests.cs
Created November 11, 2011 11:51
Test to show that the DefaultTypedFactoryComponentSelector doesn't match parameters on dependencies of the returned type.
namespace TypedFactoryTests
{
#region Using Directives
using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using Should.Fluent;
@GraemeF
GraemeF / Continuous-CoffeeScript.ps1
Created October 8, 2011 22:19 — forked from jfromaniello/continous-qunit.ps1
Continuously watches for .coffee file changes in a folder (and subfolders), and runs the CoffeeScript compiler against them
# watch a file changes in the current directory,
# compile when a .coffee file is changed or renamed
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = get-location
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $false
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName
while($TRUE){
@GraemeF
GraemeF / Player.coffee
Created September 3, 2011 21:04
Jasmine example converted to CoffeeScript
class Player
play: (song) ->
@currentlyPlayingSong = song
@isPlaying = true
pause: ->
@isPlaying = false
resume: ->
throw new Error "song is already playing" if this.isPlaying
@GraemeF
GraemeF / RestorePackages.ps1
Created July 31, 2011 11:47 — forked from damianh/RestorePackages.ps1
PowerShell script to restore a projects packages and tools. Requires nuget.exe to be in the project root and commited to source control.
# Tools
.\NuGet.exe i DotCover -s \\myserver\Dev\NuGetPackages -o Tools
.\NuGet.exe i StyleCopCmd -s \\myserver\Dev\NuGetPackages -o Tools
# Dependecies
$packageConfigs = Get-ChildItem . -Recurse | where{$_.Name -eq "packages.config"}
foreach($packageConfig in $packageConfigs){
Write-Host "Restoring" $packageConfig.FullName
nuget i $packageConfig.FullName -o Packages
}
@GraemeF
GraemeF / RequestExtensions.cs
Created July 30, 2011 20:02
Request/Response extensions
public static class RequestExtensions
{
public static string AsString(this RequestStream requestStream)
{
return new StreamReader(requestStream).ReadToEnd();
}
public static XDocument AsXml(this RequestStream requestStream)
{
return XDocument.Load(requestStream);
Comma and semicolon
Use the comma (,) and semi-colon (;) characters to indicate nonhierarchical portions
of the URI. The semicolon convention is used to identify matrix parameters:
http://www.example.org/co-ordinates;w=39.001409,z=-84.578201
http://www.example.org/axis;x=0,y=9
These characters are valid in the path and query portions of URIs, but not all code
libraries recognize the comma and semicolon as separators and may require custom