Skip to content

Instantly share code, notes, and snippets.

View aaronpowell's full-sized avatar
😶‍🌫️

Aaron Powell aaronpowell

😶‍🌫️
View GitHub Profile
@aaronpowell
aaronpowell / gist:7231110
Created October 30, 2013 11:27
DDD Brisbane

Title

JavaScript, aww yeah!

Abstract

Anything that can be written in JavaScript will be written in JavaScript.

So let's take that and go with two really out there ideas and get them working in JavaScript, first let's look at LINQ and by extensions PLINQ, and how you can create proper lazy collections in JavaScript.

@aaronpowell
aaronpowell / gist:6695293
Created September 25, 2013 04:55
Copy Umbraco files on build
<Target Name="BeforeBuild">
<ItemGroup>
<UmbracoFiles Include="..\packages\UmbracoCms.6.1.5\UmbracoFiles\umbraco\**\*;" />
<UmbracoClientFiles Include="..\packages\UmbracoCms.6.1.5\UmbracoFiles\umbraco_client\**\*;" />
</ItemGroup>
<Copy SourceFiles="@(UmbracoFiles)" DestinationFiles="@(UmbracoFiles->'umbraco\%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(UmbracoClientFiles)" DestinationFiles="@(UmbracoClientFiles->'umbraco_client\%(RecursiveDir)%(Filename)%(Extension)')" />
</Target>
@aaronpowell
aaronpowell / StorageFolderExtensions.cs
Created September 24, 2012 01:33
Extension methods for WinRT StorageFolder
public static class StorageFolderExtensions
{
public static async Task<bool> FileExistsAsync(this StorageFolder folder, string fileName)
{
try
{
await folder.GetFileAsync(fileName);
return true;
}
catch (FileNotFoundException)
@aaronpowell
aaronpowell / .gitignore
Created May 31, 2013 05:02
ScriptCS libgit2 sample. You need to manually copy the NativeBinaries folder from the LibGit2Sharp folder into the bin folder if you're using 0.5.* of ScriptCS
bin
packages
@aaronpowell
aaronpowell / PreExecutingResult.cs
Created April 18, 2013 04:45
Execute a Razor view server side in a MVC project. I'm returning the HTML in a JSON blob for this example
public class PreExecutingResult : JsonResult {
private ViewResult viewResult;
private object model;
public PreExecutingResult(string viewName, object model) {
viewResult = new ViewResult {
ViewName = viewName
};
viewResult.ViewData.Model = model;
glimpse.render.engine = (function($, pubsub) {
var providers = {},
addition = function (scope, data, metadata, insertType, filterType) {
var html = $('<div>' + build(data, metadata) + '</div>').find('.glimpse-row-holder:first > .glimpse-row'),
rowHolder = scope.find('.glimpse-row-holder:first'),
scopeTarget = rowHolder.find('> .glimpse-row:' + filterType);
if (scopeTarget.length == 0) {
scopeTarget = rowHolder;
insertType = 'appendTo';
@aaronpowell
aaronpowell / dal.cs
Created January 22, 2013 00:10
Umbraco unit test mocking
public class DataLayer {
private readonly INeedAnAbstraction abs;
public DataLayer() : this(new UmbracoAbstraction()) {}
public DataLayer(INeedAnAbstraction abs) {
this.abs = abs;
}
public IEnumerable<Node> FilterSomeNodes(string docTypeAlias) {
@aaronpowell
aaronpowell / output.js
Created May 12, 2014 23:14
Sweet.js classes combined with type-safe properties via ES6 Proxies
function Person(name) {
this.name = name;
return new Proxy(this, {
set: function (target, property, val) {
var currentType = typeof target[property];
var newType = typeof val;
if (property in target && currentType !== newType) {
throw new Error('Property ' + property + ' must be a ' + currentType);
}
target[property] = val;
// assuming http://www.html5rocks.com/en/tutorials/es6/promises/
var arr = [1, 2, 3, 4, 5];
var promises = arr.map(x => $.getJSON('/foo/bar?baz=' + x));
Promise.all(promises)
.then((result1, result2, result3, result4, result5) => {
//merge results
});
@aaronpowell
aaronpowell / gist:4255436
Created December 11, 2012 02:34
Invalid typescript
var foo = 'baz';
var bar: any;
bar = foo === 'true' ? true : foo === 'false' ? false : foo;