Skip to content

Instantly share code, notes, and snippets.

@staxmanade
staxmanade / Powershell_Create_Change_Package.ps1
Created December 4, 2012 17:58
Create a zip package of the changes between two hashes within a git dir
param(
$beginSha = $(throw '-beginSha is required'),
$endSha = $(throw '-endSha is required'),
$projectName = $( (get-item .).name )
)
# Get a list of all the files that have been added/modified/deleted
$filesWithMods = git diff --name-status $beginSha $endSha | Select @{Name="ChangeType";Expression={$_.Substring(0,1)}}, @{Name="File"; Expression={$_.Substring(2)}}
@staxmanade
staxmanade / gist:4063952
Created November 13, 2012 04:37
Hack p4merge into approval tests
[SetUpFixture]
public class HackToSetupApprovalTestsToFindP4Merge
{
[SetUp]
public void SetUpFixture()
{
var field = typeof(FirstWorkingReporter).GetField("reporters", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
var currentItems = (IEnumerable<IEnvironmentAwareReporter>)field.GetValue(DiffReporter.INSTANCE);
var newitems = new[] { P4MergeDiffReporter.INSTANCE }.Concat(currentItems).ToArray();
@staxmanade
staxmanade / WanIPValidator.ps1
Created September 26, 2012 04:14
IP Validator script
<#
# Little utility to display a toast msg when your external WAN IP address changes
#
# sample command to throw into a scheduled task
# -> powershell.exe -noprofile -file {PathToThisScript}.ps1 {YOUR_EXPECTED_EXTERNAL_WAN_IP}
#
#>
$expectedIpAddress = $args[0]
$ipaddressFound = 'NOT FOUND'
@staxmanade
staxmanade / gist:3782651
Created September 25, 2012 15:40
TFS checkin by person count
$history = tf history ./* /recursive /noprompt;
$h = @{}; $history | where { $_ } | select -skip 2 | %{ $val = $_.Substring(10, 13).Trim(); if([string]::IsNullOrEmpty($h[$val])){ $h[$val] = 0; "add $val"; } else{ $val; $h[$val] = $h[$val] + 1} }; $h
@staxmanade
staxmanade / gist:2562639
Created April 30, 2012 20:58
FizzBuzz - Javascript
var msg;
// FizzBuzz 1
for(var i = 1; i <=100; i++, msg = ''){
if(i % 5 === 0)
msg = 'Buzz';
if(i % 3 === 0)
msg += 'Fizz';
@staxmanade
staxmanade / Where.ps1
Created April 5, 2012 03:23 — forked from ferventcoder/Where.ps1
Somebody's where.exe implementation as powershell ;)
function where-is($command) {
(ls env:\path).Value.split(';') | `
where { $_ } | `
%{ [System.Environment]::ExpandEnvironmentVariables($_) } | `
where { test-path $_ } |`
%{ ls "$_\*" -include *.bat,*.exe,*cmd } | `
%{ $file = $_.Name; `
if($file -and ($file -eq $command -or `
$file -eq ($command + '.exe') -or `
$file -eq ($command + '.bat') -or `
@staxmanade
staxmanade / StaticCLassItemMetadata.cs
Created January 13, 2012 06:39
Sort of like an Enum with more data or behavior possibilities.
public class Sample
{
[Test]
public void MetadataSample()
{
Items.ItemA.ShouldEqual(Items.ItemA);
Items.ItemA.Description.ShouldEndWith("Description for A");
}
}
@staxmanade
staxmanade / EnumerableEx.cs
Created October 5, 2011 18:02
Concating enumerables (just a thought)
public static class EnumerableEx
{
public static IEnumerable<T> Concat<T>(params IEnumerable<T>[] enumerables)
{
if (enumerables == null) throw new ArgumentNullException("enumerables");
return enumerables.SelectMany(i => i);
}
}
@staxmanade
staxmanade / gist:1180060
Created August 30, 2011 02:57
Fun(for a 4yr old) - little powershell speak what you type (
function Start-The-Fun()
{
$voice = new-object -com SAPI.SpVoice;
while($true)
{
write-host "->" -NoNewLine;
$msg = read-host;
$Voice.Speak( $msg, 1 ) | out-null;
}
@staxmanade
staxmanade / gist:1059430
Created July 1, 2011 21:26
Pseudo code I think could be used to leverage StatLight.Core
using System;
using System.Collections.ObjectModel;
using StatLight.Client.Harness.Events;
using StatLight.Core.Common;
using StatLight.Core.Configuration;
using StatLight.Core.Events;
using StatLight.Core.Events.Aggregation;
using StatLight.Core.Reporting;
using StatLight.Core.Runners;
using StatLight.Core.WebBrowser;