Skip to content

Instantly share code, notes, and snippets.

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

Aaron Powell aaronpowell

😶‍🌫️
View GitHub Profile
@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 / multi-reset.sh
Last active October 19, 2022 13:07
Resetting multiple files
#!/bin/sh
# Change the regex in `egrep` to match the pattern you want to reset
git status -s | grep "^A" | sed 's/A //' | while read i; do git reset HEAD $i; done
@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 / 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 / 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 / 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 / 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 / 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 / runner.js
Created January 11, 2014 07:58
A script for running generator functions
let runner = function (fn) {
if (typeof fn !== 'function') {
throw 'A generator function is expected';
}
var done = false;
var gen = fn();
var val;
while (!done) {
let obj = gen.next(val);
@aaronpowell
aaronpowell / List-RemoteGitBranches.ps1
Last active December 31, 2015 21:39
List remote git branches with a filter
function List-RemoteGitBranches {
param (
[Parameter(Mandatory=$true)]
[string]
$Filter
)
$branches = git branch -r | ?{ $_ -Match $filter }
$count = $branches.Length