Skip to content

Instantly share code, notes, and snippets.

var recursivelyOrderKeys = function(unordered) {
// If it's an array - recursively order any
// dictionary items within the array
if (Array.isArray(unordered)) {
unordered.forEach(function (item, index) {
unordered[index] = recursivelyOrderKeys(item);
});
return unordered;
}
@staxmanade
staxmanade / Get-Last-NuGet-Version
Created June 6, 2011 04:09
Powershell function that returns the last version of a NuGet package
function Get-Last-NuGet-Version($nuGetPackageId) {
$feeedUrl = "http://packages.nuget.org/v1/FeedService.svc/Packages()?`$filter=Id%20eq%20'$nuGetPackageId'"
$webClient = new-object System.Net.WebClient
$queryResults = [xml]($webClient.DownloadString($feeedUrl))
$version = $queryResults.feed.entry | %{ $_.properties.version } | sort-object | select -last 1
if(!$version){
$version = "0.0"
}
$version
}
@staxmanade
staxmanade / ConvertJavaScriptToTypeScript.md
Last active February 14, 2019 06:56
Some notes on converting JS to TypeScript with the help of PowerShell

Convert an existing project to TypeScript?

Rename files from javascript to typescript

ls *.js -Recurse | foreach{ move-item $_ ($_.FullName.TrimEnd("js") + "ts") }

install grunt-typescript (There are other TypeScript packages out there but I tried this one and it worked)

npm install grunt-typescript --save-dev

@staxmanade
staxmanade / merge-wrapper.js
Last active December 1, 2018 02:45
JS & SH merge wrappers
#!/usr/bin/env node
'use strict';
/*
#!/bin/bash
#
# Wrapper script for git mergetool
# This requires ~/.gitconfig file to have
# the following (adjusting for paths):
#
# [merge]
@staxmanade
staxmanade / Podcasts.opml
Last active January 2, 2016 21:48
OPML of the current podcasts I'm listening to. These are not in any particular order. I'm using the [Downcast](https://geo.itunes.apple.com/us/app/downcast/id393858566?mt=8&at=10lPYJ) iPhone app and set it to 2x speed for twice the listening throughput! (Unless an interviewee has a strong accent).
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Downcast Podcasts</title>
</head>
@staxmanade
staxmanade / gist:6362371
Created August 28, 2013 05:16
Goofing around with TypeScript, interfaces, inheritance, generics etc...
interface IAmSomeInterface {
getNumber(): number;
}
interface IAmAGenericInterface<T extends IAmSomeInterface> {
getInstanceOfSomeInterface(id: number): T;
}
class ClassExtendingSomeInterface implements IAmSomeInterface {
getNumber() {
@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