Skip to content

Instantly share code, notes, and snippets.

View josheinstein's full-sized avatar

Josh Einstein josheinstein

  • Einstein Technologies
  • USA
View GitHub Profile
@josheinstein
josheinstein / DataSize.cs
Created May 18, 2012 16:15
DataSize Class (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
@josheinstein
josheinstein / Enable-AppearOffline.ps1
Created May 3, 2012 15:09
Enable "Appear Offline" in Microsoft Lync
$ErrorActionPreference = 'Stop'
try {
$LyncPolicyKey = 'HKLM:\Software\Policies\Microsoft\Communicator'
if (!(Test-Path $LyncPolicyKey)) {
New-Item $LyncPolicyKey
}
@josheinstein
josheinstein / PSObjectComparer.cs
Created May 1, 2012 21:17
IComparer for PSObjects in PowerShell
namespace Einstein.PowerShell
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Linq;
@josheinstein
josheinstein / CollectionHelper.cs
Created May 1, 2012 21:16
Testing sets for equality (IEnumerable and IDictionary)
using System;
using System.Collections;
public static class CollectionHelper {
public static bool SetsEqual(IEnumerable set1, IEnumerable set2) {
var h1 = new Hashtable();
foreach ( var item in set1 ) {
h1[item] = true;
@josheinstein
josheinstein / LINQ.psd1
Created April 30, 2012 16:29
LINQ-ish Cmdlets for PowerShell
@{
# MODULE
Description = 'LINQ for PowerShell'
ModuleVersion = '3.0'
GUID = '03BDA80F-0831-406E-B6AE-59E32D73F190'
# AUTHOR
Author = 'Josh Einstein'
CompanyName = 'Einstein Technologies'
@josheinstein
josheinstein / Args.cs
Created April 30, 2012 16:21
Argument Validation Helper (C#)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
/// <summary>
/// Provides methods for checking method arguments for validity and throwing localizable exceptions for invalid
/// arguments or argument combinations.
@josheinstein
josheinstein / Test-Requirement.psm1
Created April 30, 2012 16:10
Test-Requirement - Would love to see something like this in PowerShell.
##############################################################################
#.SYNOPSIS
# Ensures that certain dependencies are available in the current environment.
#
#.DESCRIPTION
# Test-Requirement will throw an exception if the requirement is not met, or
# it will write a verbose message if the requirement succeeds. It is not
# intended to be used in a conditional statement, rather it is intended to be
# used at the top of your function as a declarative statement in a scope that
# will be aborted if an exception is thrown.