Skip to content

Instantly share code, notes, and snippets.

@jamesrcounts
jamesrcounts / WriteOnlyProperty.patch
Created May 2, 2012 17:16
A patch to handle Write-Only properties in WritePropertiesToString<T>. Are write only properties a good idea? I don't know. Did I find one in legacy code? Yes. Did I write that legacy code? Yes.
Index: ApprovalUtilities.Tests/Utilities/StringUtilitiesTest.cs
===================================================================
--- ApprovalUtilities.Tests/Utilities/StringUtilitiesTest.cs (revision 408)
+++ ApprovalUtilities.Tests/Utilities/StringUtilitiesTest.cs (working copy)
@@ -26,12 +26,34 @@
[TestMethod]
public void WritePropertiesToStringTest()
{
- var anonymous = new
+ var anonymous = new
@jamesrcounts
jamesrcounts / turing.coffee
Created April 23, 2012 22:42
A turing machine in coffeescript
alert = (s) -> console.log s
createResult = (state, symbol, direction) ->
nextState: state
writeSymbol: symbol
moveTo: direction
toString: () -> [this.nextState, this.writeSymbol, this.moveTo].join ", "
createRule = (state, symbol, result) ->
inState: state
@jamesrcounts
jamesrcounts / pda.coffee
Created April 21, 2012 16:10
A pushdown automata in coffeescript
createResult = (state, symbols) -> {
resultState: state
pushSymbols: symbols.reverse()
}
createRule = (state, input, symbol, result) -> {
currentState: state
inputChar: input
stackSymbol: symbol
ruleResult: result
@jamesrcounts
jamesrcounts / README.md
Created April 20, 2012 17:09
A coffeescript finite state machine, just for fun. This machine implements a string.Contains() function.

Finite State Machine Revisited

This machine determines if a specified substring exists within a string. The initial machine is the first machine I wrote in CoffeeScript, so there should be plenty of room for improvement.

Also interesting, I think there is an opportunity for some meaningful use of CoffeeScript classes.

First we'll add a shim for alert.

alert = (value) -&gt; console.log value
@jamesrcounts
jamesrcounts / CodeCompareReporter.patch
Created March 27, 2012 16:25
A DevArt CodeCompare DiffReporter for ApprovalTests
Index: ApprovalTests.sln
===================================================================
--- ApprovalTests.sln (revision 392)
+++ ApprovalTests.sln (working copy)
@@ -4,7 +4,7 @@
ProjectSection(SolutionItems) = preProject
ApprovalTests.build = ApprovalTests.build
ApprovalTests.vsmdi = ApprovalTests.vsmdi
- ApprovalTests3.vsmdi = ApprovalTests3.vsmdi
+ ApprovalTests1.vsmdi = ApprovalTests1.vsmdi
@jamesrcounts
jamesrcounts / BeyondCompareReporter.cs.patch
Created March 19, 2012 15:15
A patch that corrects GetPathInProgramFilesX86 behavior in a process compiled for x86
Index: BeyondCompareReporter.cs
===================================================================
--- BeyondCompareReporter.cs (revision 378)
+++ BeyondCompareReporter.cs (working copy)
@@ -20,7 +20,7 @@
public static string GetPathInProgramFilesX86(string path)
{
var x86Path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\" + path;
- return File.Exists(x86Path) ? x86Path : Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"\" + path;
+ return File.Exists(x86Path) ? x86Path : Environment.GetEnvironmentVariable("ProgramW6432") + @"\" + path;
@jamesrcounts
jamesrcounts / DevEnvDiffReporter.cs
Created March 16, 2012 02:36
A VS 11 DiffReporter for ApprovalTests
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ApprovalTests.Reporters
{
public class DevEnvDiffReporter : GenericDiffReporter
{