Skip to content

Instantly share code, notes, and snippets.

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

Aaron Powell aaronpowell

😶‍🌫️
View GitHub Profile
@aaronpowell
aaronpowell / gist:8776893
Created February 2, 2014 23:51
Delete wifi profiles in Windows
function PromptForRemoval {
param (
[string]
[Parameter(Mandatory=$true)]
$Networkname
)
$title = "Delete network $NetworkName"
$message = "Do you want to delete the wifi network named $NetworkName"
@aaronpowell
aaronpowell / regex.md
Created February 12, 2014 03:41
Convert `Assert.IsTrue` to a useful assert statement

So I really hate when people use Assert.IsTrue(a == b) as an assertion in a unit test (I blogged my rant) so I decided to find a way to easily convert large test files to be more normal.

Search Regex

You'll want to search with this:

Assert\.IsTrue\((?<Actual>.*)\s*==\s*(?<Expected>.*)\)
//or if your language doesn't support named caprutes use:
Assert\.IsTrue\((.*)\s*==\s*(.*)\)
@aaronpowell
aaronpowell / grunt-tf-checkout.js
Created February 17, 2014 23:03
Grunt task for checking out files from TFVC
var tfPath = 'C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE\\TF.exe';
grunt.registerTask('tf-checkout', 'Checks out a location from TFS', function (path, recursive) {
var cb = this.async();
var recursiveFlag = recursive ? '/recursive' : '';
var child = grunt.util.spawn({
cmd: tfPath,
args: ['checkout', path, recursiveFlag]
}, function (err, result, code) {
if (err) {
grunt.fatal(err);
@aaronpowell
aaronpowell / grunt-tfpt-uu.js
Created February 18, 2014 00:08
TFS PowerTools undo unchanged files
var tfptPath = 'C:\\Program Files (x86)\\Microsoft Team Foundation Server 2013 Power Tools\\TFPT.EXE';
grunt.registerTask('tfpt-uu', 'Undo changes to unchanged files in the workspace (required TFs PowerTools 2013', function () {
var fs = require('fs');
var cb = this.async();
fs.exists(tfptPath, function (exists) {
if (!exists) {
grunt.warn('TFS Power Tools are not installed, aborting...');
cb();
@aaronpowell
aaronpowell / gist:9085724
Created February 19, 2014 03:47
AngularJS macros in Sweet.js
let module = macro {
case {_
$name
import $params (,) ...
} => {
letstx $name_str = [makeValue(unwrapSyntax(#{$name}), #{here})];
return #{
angular.module($name_str, [$params (,) ...])
};
}
@aaronpowell
aaronpowell / nth-child.md
Created March 11, 2014 23:34
TIL: how nth-child works

Today I learnt an interesting fact about how the nth-child CSS selector works and it was different to what I expected and what seems to make sense.

I had the following HTML snippet:

<div class="input-group">
        <div class="legacy">
                <div class="input-subgroup">
                    <input name="itemId" id="Type0" type="radio" checked="checked" value="1">
                    <label for="Type0">Single</label>
@aaronpowell
aaronpowell / multi-diff.sh
Created March 26, 2014 00:30
Diff multiple files in git
#!/bin/sh
git status -s | grep "^ M .*\.cs$" | sed 's/ M //' | while read i; do git diff --ignore-space-change $i; done
@aaronpowell
aaronpowell / null-guard.sjs
Last active August 29, 2015 13:58
Trying out the C# vNext `?.` operator in Sweet.js
macro null_helper {
rule { ($processed ...) ($rest) } => {
$processed (.) ... . $rest
}
rule { ($processed ...) ($rest_head $rest ...) } => {
$processed (.) ... . $rest_head
&& null_helper ($processed ... $rest_head) ($rest ...)
}
}
@aaronpowell
aaronpowell / gist:10609659
Created April 14, 2014 01:26
Umbraco document types grouped by the count of pages that use it (run via LINQPad)
(from dt in CmsDocumentTypes
join n in UmbracoNodes on dt.ContentTypeNodeId equals n.Id
select new {
n.Id,
n.Text,
Docs = CmsContents.Where(c => c.ContentType == n.Id).Where(c => !c.Node.Trashed).Count(),
IsNested = n.ParentID != -1
})
.Distinct()
.GroupBy(x => x.Docs)
@aaronpowell
aaronpowell / gist:10618558
Created April 14, 2014 05:29
Number of document type properties grouped by document type and ordered by the number of documents using them
CmsPropertyTypes
.GroupBy(pt => pt.ContentTypeId)
.Join(CmsDocumentTypes, x => x.Key, x => x.ContentTypeNodeId, (pts, dt) => new {
Property = pts,
DocumentType = dt
})
.Join(UmbracoNodes, x => x.DocumentType.ContentTypeNodeId, x => x.Id, (x, n) => new {
x,
n.Text
})