Skip to content

Instantly share code, notes, and snippets.

View mcintyre321's full-sized avatar

Harry McIntyre mcintyre321

View GitHub Profile
public class CsvFieldAttribute : Attribute
{
public CsvFieldAttribute()
{
Ignore = false;
}
public string Name { get; set; }
public int Index { get; set; }
public bool Ignore { get; set; }
}
@mcintyre321
mcintyre321 / boxstarter
Last active August 29, 2015 14:00
boxstarter
Set-ExplorerOptions -showHidenFilesFoldersDrives -showFileExtensions
Enable-RemoteDesktop
cinst IIS-WebServerRole -source windowsfeatures
Install-WindowsUpdate -acceptEula
cinst GoogleChrome
cinst notepadplusplus.install
cinst VisualStudio2013Professional
cinst resharper
cinst Console2
Array.prototype.liveMap = function (map, cleanUp) {
var destination = [];
this.map(function(item) {
destination[destination.length] = map(item);
});
this.subscribe(function (changes) {
changes.forEach(function(change) {
if (change.status === 'added') {
var t2 = map(change.value);
@mcintyre321
mcintyre321 / ExecutionQueue.cs
Created May 22, 2014 13:53
ExecutionQueue
public class ExecutionQueue
{
BlockingCollection<Action> bc = new BlockingCollection<Action>();
public ExecutionQueue(){
Task.Factory.StartNew(() =>
{
foreach (Action value in bc.GetConsumingEnumerable())
{
value();
}
public class ClassnameViewEngine : RazorViewEngine, IViewEngine
{
private readonly Assembly[] _searchAssemblies;
public ClassnameViewEngine(params Assembly[] searchAssemblies)
{
_searchAssemblies = searchAssemblies;
}
//This needs to be initialized to the root namespace of your MVC project.
@mcintyre321
mcintyre321 / gist:08b086153f17471b08ba
Last active September 24, 2020 15:03
Testing glossary

Test scopes

  • Unit test - an isolated test around a single 'unit' of code, although that can be anything from a method to a class to a series of (related) classes.
  • Component test - same as a unit test
  • Isolated test - a test that doesn't do any I/O, i.e. the Ports have been filled with in-memory Adapters
  • Integration test - a test that interacts with deployed instances of the code and related services, possiby with some Test Doubles (mocked/faked/stubbed etc).
  • End to End test - a test that entirely interacts with deployed instances using public interfaces
  • Test-per-class - a convention that there should be one unit test for each class

Uses of tests

var observify = function (obs, top) {
if (!top && !ko.isObservable(obs)) {
return;
}
var object = ko.unwrap(obs);
if (Object.prototype.toString.call(object) === "[object Array]") {
for (var i = 0; i < object.length; i++) {
var v = object[i];
if (!ko.isObservable(v)) {
if (Object.prototype.toString.call(v) === "[object Array]") {
(function() {
var __hasProp = {}.hasOwnProperty;
(function(factory) {
if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
return factory(require('knockout'), exports);
} else if (typeof define === 'function' && define['amd']) {
return define(['knockout', 'exports'], factory);
} else {
return factory(ko, ko.konva = {});
@mcintyre321
mcintyre321 / gist:1b9d8060acb39a4f39f0
Created June 24, 2015 09:21
JsonProperty for Entity Framework
[ComplexType]
public class JsonProperty<T> where T : class
{
[Required]
public string Json { get; private set; }
protected JsonProperty()
{
this.SerializerSettings = new PolymorphicJsonSerializerSettings();
}
@mcintyre321
mcintyre321 / gist:ff67ffa8e2f0c8ef86da
Created August 6, 2015 15:50
RazorHostFactory for debugging embedded resources
public class MyCustomRazorHostFactory : WebRazorHostFactory
{
public override System.Web.WebPages.Razor.WebPageRazorHost CreateHost(string virtualPath, string physicalPath)
{
// Implementation stolen from MvcRazorHostFactory :)
var host = base.CreateHost(virtualPath, physicalPath);
if (!host.IsSpecialPage)
{
return new MyCustomRazorHost(virtualPath, physicalPath);