Skip to content

Instantly share code, notes, and snippets.

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

Aaron Powell aaronpowell

😶‍🌫️
View GitHub Profile
@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;
@aaronpowell
aaronpowell / WinJS-to-CommonJS.js
Created December 4, 2012 12:16
Convert WinJS APIs into CommonJS modules
(function (global) {
var walker = function (k, t, o) {
if(!t) {
t = k;
} else {
t = t + k + '/';
}
if(typeof o !== 'object') {
if(t) {
require.define(t.substring(0, t.length - 1), function (r, m, e) {
@aaronpowell
aaronpowell / make.sublime-build
Created November 29, 2012 01:02
Sublime make build command including Windows support
{
"cmd": ["make"],
"working_dir":"${project_path}",
"windows": {
"cmd": ["C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/bin/nmake"]
}
}
@aaronpowell
aaronpowell / gist:4159243
Created November 28, 2012 05:37
Get changeset from workspace
var localPath = "Some Path";
if (!Workstation.Current.IsMapped(localPath)) {
Log.LogError(string.Format("The local path '{0}' is not mapped to a TFS workspace.", LocalPath));
return false;
}
var info = Workstation.Current.GetLocalWorkspaceInfo(localPath);
var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(info.ServerUri);
var workspace = info.GetWorkspace(collection);
var localVersions = workspace.GetLocalVersions(new [] {new ItemSpec(localPath, RecursionType.Full)}, false);
@aaronpowell
aaronpowell / selectMany.js
Created November 19, 2012 03:22
LINQ SelectMany in JavaScript
Array.prototype.selectMany = function (fn) {
return this.map(fn).reduce(function (x, y) { return x.concat(y); }, []);
};
// usage
console.log([[1,2,3], [4,5,6]].selectMany(function (x) { return x; })); //[1,2,3,4,5,6]
console.log([{ a: [1,2,3] }, { a: [4,5,6] }].selectMany(function (x) { return x.a; }));
[TestClass]
class Tests {
[TestMethod]
public void DataSet_A() {
RunTestWithData("A", "Z");
}
[TestMethod]
public void DataSet_B() {
RunTestWithData("B", "Y");
$(document).on('click', '#showInvestigated', function () {
window.location = '@Html.Raw(Url.Action("StoreErrors"))';
});
module PubSub {
interface ISubscription {
(...args: any[]): void;
}
interface IDictionary {
[name: string] : ISubscription[];
}
var registry : IDictionary = {
@aaronpowell
aaronpowell / StorageFolderExtensions.js
Created September 24, 2012 01:46
WinJS StorageFolder file exists
Windows.Storage.StorageFolder.prototype.fileExistsAsync = function(fileName) {
var folder = this;
return WinJS.Promise(function (complete, error) {
folder.getFileAsync(fileName).then(function() {
complete();
}, function() {
error();
});
});
};
@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)