Skip to content

Instantly share code, notes, and snippets.

View abombss's full-sized avatar

Adam Tybor abombss

  • Accenture
  • Chicago, IL
View GitHub Profile
@abombss
abombss / toggle-list-sep.ps1
Created August 6, 2011 19:18
Powershell script to toggle and change the windows regional settings for the list separator to make outputting CSV files from excel using different delimiters much easier
function toggle-list-sep
{
$path = "hkcu:\Control Panel\International"
$key = "sList"
$cur_sep = (Get-ItemProperty -path $path -name $key).$key
if ($args.Length -gt 0) { $value = $args[0] }
elseif ($cur_sep -eq ",") { $value = "|" }
else { $value = "," }
@abombss
abombss / getTypeName.js
Created November 8, 2011 07:34
Javascript Type / Class Name
function getTypeName(value) {
if (value === null) {
return "null";
}
var t = typeof value;
switch (t) {
case "function":
case "object":
if (value.constructor && value.constructor.name) {
@abombss
abombss / git-submodule-reload.ps1
Created November 20, 2011 21:06
Powershell to re-clone all git submodules
$hash = @{}; $list = cat .gitmodules | where { $_ -like "*=*" } | foreach { $_.Split("=")[1].Trim() }; while ($list) { $key, $value, $list = $list; $hash[$key]=$value }; $hash.GetEnumerator() | foreach { & git submodule add $_.Value $_.Name }
@abombss
abombss / WebRequestExtensions.cs
Created May 17, 2012 18:25
Cloning Web/HttpRequests in .Net
public static class WebRequestExtensions
{
public static HttpWebRequest CloneRequest(this HttpWebRequest originalRequest, Uri newUri)
{
return CloneHttpWebRequest(originalRequest, newUri);
}
public static WebRequest CloneRequest(this WebRequest originalRequest, Uri newUri)
{
var httpWebRequest = originalRequest as HttpWebRequest;
@abombss
abombss / FixNuget.ps1
Created July 18, 2012 19:47
Fix All Nuget Packages in Solution
Get-Project -All | %{ $proj = $_; Get-Package -Project $_.Name | %{ $pkg = $_; Uninstall-Package -Id $pkg.Id -ProjectName $proj.Name -Force; Install-Package -Id $pkg.Id -ProjectName $proj.Name -Version $pkg.Version } }
@abombss
abombss / PSAddMember.psm1
Created August 8, 2012 19:02
PSAddMember -- Extend all objects with an easier to use PSAddMember function
Function PSAddMember() {
$this = $args[0]
switch($args.Count) {
2 {
($args[1] -as [HashTable]) | %{ $_.GetEnumerator() } | %{ Add-Member -InputObject $this -Name $_.Name -value $_.Value -MemberType Noteproperty -Force -PassThru }
break;
}
3 {
@abombss
abombss / Util.ps1
Created August 30, 2012 21:24
Handy Powershell Cmdlets
Function Where-ObjectMatches() {
[CmdletBinding(DefaultParameterSetName="MatchLike")]
Param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Alias("Value", "Input", "Object", "io")]
[psobject[]]$InputObject,
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true,Position=1)]
[Alias("Selector")]
[psobject]$Property,
@abombss
abombss / Get-ArchiveItems.ps1
Created November 14, 2012 03:54
Powershell List Zip Archive File Contents
function Get-ArchiveItems {
param([Parameter(Mandatory)][string]$Archive)
function recurse-items {
param([object]$items)
foreach($item in $items) {
$item
$folder = $item.GetFolder
if ($folder) {
recurse-items $folder.Items()
@abombss
abombss / Install-AppFabricCache.ps1
Last active December 10, 2015 20:38
Automatically Install AppFabric Cache Cluster and Nodes
function Uninstall-AppFabricCacheNode {
#TODO: Should try and remove the configuration stuff
gwmi win32_product -filter "Name LIKE 'AppFabric%'" |% {
$key="IdentifyingNumber=`"$($_.IdentifyingNumber)`",Name=`"$($_.Name)`",version=`"$($_.Version)`"";
([wmi]"Win32_Product.$key").uninstall()
}
}
function Reset-AppFabricCacheDatabase {
param(
@abombss
abombss / PsLocalDb.psm1
Created March 6, 2013 21:22
Powershell LocalDb Wrapper
function Start-LocalDb {
[CmdletBinding()]
param(
[Parameter(Mandatory,ValueFromPipeLine,Position=1)]
[psobject[]]$Instance,
[string]$ToolPath = (Find-LocalDbExe)
)
begin {
}