Skip to content

Instantly share code, notes, and snippets.

@brianwigfield
brianwigfield / Example.cs
Last active December 20, 2015 09:28
Expression property extension that works even with implicit castings
public T MakeNewTest<T>(Expression<Func<T, string>> details) where T : class, new()
{
var obj = new T();
details.UnwrapPropertyExpression().SetValue(obj, "initial", null);
return obj;
}
public void Main()
{
var it = MakeNewTest<Test>(_ => _.MyValue);
@brianwigfield
brianwigfield / index.html
Last active December 18, 2015 12:59
Drawing
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Moving a Segment</title>
<script type="text/javascript" src="http://paperjs.org/static/js/paper.js"></script>
<script type="text/paperscript" canvas="canvas">
var center = new Point(200, 200);
var house = null;
@brianwigfield
brianwigfield / app.coffee
Created December 18, 2012 22:01
Express routes
routes = require('./routes').addRoutes(app, storage)
public class DocumentStoreRegistry : Registry
{
public DocumentStoreRegistry()
{
For<IDocumentStore>().Singleton()
.AddInstances(_ =>
_.ConstructedBy(ctor =>
{
var store = new DocumentStore { Url = ConfigurationManager.AppSettings["RAVENHQ_CONNECTION_STRING"] };
store.Initialize();