Skip to content

Instantly share code, notes, and snippets.

public class MailSender
{
// Call this from Application_Start in Global.asax.cs
public static void Init()
{
var viewRenderer = new EmailViewRenderer(ViewEngines.Engines) {EmailViewDirectoryName = "Emails"};
var emailParser = new EmailParser(viewRenderer);
Email.CreateEmailService = ()=>new EmailService(viewRenderer, new PremailerEmailParser(emailParser), ()=>new SmtpClient());
}
@andrewdavey
andrewdavey / index.html
Created October 20, 2013 17:39
HTML for AngularJS and TypeScript example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>TypeScript AngularJS Controller Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.min.js"></script>
<script src="app.js"></script>
@andrewdavey
andrewdavey / app.ts
Created October 20, 2013 17:38
Example AngularJS application using TypeScript
/// <reference path="angular.d.ts"/>
class KittenController {
constructor(
private $scope: ng.IScope,
private debounce: IDebounce
) {
this.watchForSizeChanges();
}
@andrewdavey
andrewdavey / Object.inherit.js
Created July 3, 2012 14:15
Simple object inheritance in JavaScript
(function () {
"use strict";
var copyOwnProperties = function (from, to) {
for (var propertyName in from) {
if (from.hasOwnProperty(propertyName)) {
to[propertyName] = from[propertyName];
}
}
};
// General resource format:
{
metadata: [ // array of metadata objects
{ "<any-string1>": <any-json> },
{ "<any-string2>": <any-json> },
"<any-string3>" // short hand for { "<any-string3>": null },
...
],
data: <any-javascript-value> // e.g. string, number, boolean, object, array
@andrewdavey
andrewdavey / example.cshtml
Created February 24, 2012 13:26
Nancy razor helper problem
<!DOCTYPE html>
<html>
<head>
<title>Resource</title>
</head>
<body>
@TestHelper()
</body>
</html>
@andrewdavey
andrewdavey / semvercompare-output.txt
Created January 21, 2012 16:58
Sample output from SemVerCompare
> SemVerCompare.exe old\Cassette.dll new\Cassette.dll
Type added: Cassette.CassetteApplicationContainer
Type added: Cassette.ICassetteApplicationContainer`1
Type changed: Cassette.IO.IsolatedStorageDirectory
Member added: Void .ctor(System.Func`1[System.IO.IsolatedStorage.IsolatedStorageFile])
Type changed: Cassette.ICassetteApplication
Member added: System.Collections.Generic.IEnumerable`1[Cassette.Bundle] get_Bundles()
Member added: System.Collections.Generic.IEnumerable`1[Cassette.Bundle] Bundles
Type changed: Cassette.IO.IsolatedStorageFile
public class Global : System.Web.HttpApplication {
protected void Application_Start(object sender, EventArgs e) {
var store = new SmartMessageStore();
DependencyResolver.Register(typeof(IMessageStore), () => store);
}
}
@andrewdavey
andrewdavey / gwt-cs.cs
Created May 25, 2011 09:53
Different approach to C# unit testing
// Sorry to stir things up, but I really don't get on with the current *Unit test frameworks
// in C#. I hate creating_long_semi_english method names. I hate then repeating myself
// in code e.g. public void It_sould_equal_10() { Assert.That(it == 10); }
// I think the problem stems from making a method the atom of a test.
// This leads to crap method names and hard to understand tests.
// What follows is a different approach. (Not real code yet, just ideas!)
// One Test class per class under test.
// Inherits framework `Tests` class to provide test-DSL methods.
@andrewdavey
andrewdavey / gist:964993
Created May 10, 2011 17:55
Witness coffeescript syntax idea
Given loadPage('/login'), [
Given userIsRemembered('johnsmith'), [
When [
'enter correct password': input(password: 'test')
click 'login'
]
Then [
dashboardScreenLoaded()
]
]