Skip to content

Instantly share code, notes, and snippets.

@adamchester
adamchester / blog_welcome.blog.md
Created June 3, 2012 02:37
Welcome to my blog, it may be updated rarely
@adamchester
adamchester / blog_purpose.blog.md
Created June 17, 2012 13:26
This blog is purely a learning experience
@adamchester
adamchester / blog_test_assertion.testing.node.md
Created July 18, 2012 04:47
A simple test assertion DSL

Why?

I am not good at writing bug-free code in JavaScript or CoffeeScript. I am equally not good at writing bug-free tests. It would be nice to have a way to quickly build a basic 'safety net' for my code, and be able to describe the tests in a format less verbose than 'describe->it-should->etc'.

It should also be a good learning experience.

Goals

@adamchester
adamchester / blog_class_apply.coffeescript.md
Created July 25, 2012 03:27
How do you create a CoffeeScript class instance using 'apply'?

How do you create a CoffeeScript class instance using 'apply'?

The answer is, like this:

util = require('util')
assert = require('assert')

class MyClass
	constructor: (@splatArgs...) -> @first = splatArgs[0]; @second = splatArgs[1]
@adamchester
adamchester / blog_computer.setup.md
Last active October 8, 2015 23:28
My 2011/2012 computer setup

I do all my work on a laptop.

Hardware

  • Apple MacBook Pro 15" Early 2011, 8GB RAM, Core i7 2.3GHz (MacBookPro8,2)
  • Storage: 750GB hdd, plus 240GB OCZ Vertex 3 MI (note: removed optical media drive)
  • Apple magic mouse <- I hate this thing
  • External monitors/keyboards available depending on client site(s)
@adamchester
adamchester / blog_debug_model_binding.aspnetmvc.debug.md
Last active March 28, 2023 15:03
Debugging ASP.NET MVC 4 model binding

The Scenario

Recently we had a tricky defect raised where, under certain circumstances, the user-entered values were not being persisted. The page was a somewhat complex data entry form, with many fields, lots of validation, and a complex hierarchy of view model objects and controls/helpers.

The process

After reproducing the issue (which itself was difficult), the first thing we did was to attach the debugger and set a break point on the first line of the controller action.

@adamchester
adamchester / gist:8065483
Created December 21, 2013 04:39
AutoFixture specimen creation performance test
private class SpecimenWithEverything
{
public enum MyEnum
{
MyFirstValue,
MySecondValue,
MyThridValue,
}
public string String1 { get; set; }
@adamchester
adamchester / gist:9560154
Created March 15, 2014 00:52
git diff after win store target change
diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj
index 351d930..00bf659 100644
--- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj
+++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj
@@ -1,5 +1,5 @@
?<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuild
<PropertyGroup>
let whereNotExistsIn itemsToExclude itemToTest =
itemsToExclude |> Seq.exists (fun j -> itemToTest = j) |> not
let except itemsToExclude allItems =
allItems |> Seq.filter (whereNotExistsIn itemsToExclude)
[| "one"; "two"; "three"; |]
|> except [|"two"|]
|> Dump
@adamchester
adamchester / gist:cdabfc76d76c3a641698
Last active August 29, 2015 14:02
Except (faster; set-based)
let except ex all = all |> Seq.filter (not << Set.ofSeq(ex).Contains)
let filtered = [| 1..1000000 |] |> except [| 20..29 |]