Skip to content

Instantly share code, notes, and snippets.

View The-Running-Dev's full-sized avatar

Ben Richards The-Running-Dev

View GitHub Profile
@The-Running-Dev
The-Running-Dev / Response.json
Created May 6, 2018 22:18 — forked from SvenAelterman/Response.json
VS2017 Response.json for silent install
{
"installChannelUri": ".\\ChannelManifest.json",
"channelUri": "https://aka.ms/vs/15/release/channel",
"installCatalogUri": ".\\Catalog.json",
"channelId": "VisualStudio.15.Release",
"productId": "Microsoft.VisualStudio.Product.Enterprise",
"includeRecommended": true,
"includeOptional": true,
"productKey": "AAAAABBBBBCCCCCDDDDDEEEEE",
@The-Running-Dev
The-Running-Dev / transcode-video.sh
Created March 31, 2018 21:05 — forked from lisamelton/transcode-video.sh
Transcode video file (works best with Blu-ray or DVD rip) into MP4 (or optionally Matroska) format, with configuration and at bitrate similar to popular online downloads.
#!/bin/bash
#
# transcode-video.sh
#
# Copyright (c) 2013-2015 Don Melton
#
about() {
cat <<EOF
$program 5.13 of April 8, 2015
@The-Running-Dev
The-Running-Dev / Reset-BuildOutput.ps1
Created June 30, 2017 17:49
Resets the build output directory for MSBuild project files back to the defaults
function Reset-BuildOutput {
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[Parameter(Position = 0, Mandatory, ValueFromPipeline)][ValidateScript( {Test-Path $_ -PathType Leaf})][string] $projectFile
)
$xml = [xml](Get-Content (Resolve-Path $projectFile))
$debugProperties = $xml.DocumentElement.PropertyGroup | Where-Object { $_.Condition -match 'Debug' } | Where-Object { $_.OutputPath -notmatch 'bin' }
$releaseProperties = $xml.DocumentElement.PropertyGroup | Where-Object { $_.Condition -match 'Release' } | Where-Object { $_.OutputPath -notmatch 'bin' }
@The-Running-Dev
The-Running-Dev / Map.cs
Last active June 27, 2017 17:05
Map Values from Dictionary to .NET Object
/// <summary>
/// Maps a Dictionary of key<string>, value<object> to
/// an object of type T where T has to be a class,
/// with the assumption that all mappings are done
/// to T's public properties
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="targetObject"></param>
public void Map<T>(Dictionary<string, object> source, ref T targetObject) where T : new()
@The-Running-Dev
The-Running-Dev / SlackClient.cs
Created June 19, 2017 13:57 — forked from jogleasonjr/SlackClient.cs
A simple C# class to post messages to a Slack channel. You must have the Incoming WebHooks Integration enabled. This class uses the Newtonsoft Json.NET serializer available via NuGet. Scroll down for an example test method and a LinqPad snippet. Enjoy!
using Newtonsoft.Json;
using System;
using System.Collections.Specialized;
using System.Net;
using System.Text;
//A simple C# class to post messages to a Slack channel
//Note: This class uses the Newtonsoft Json.NET serializer available via NuGet
public class SlackClient
{
@The-Running-Dev
The-Running-Dev / Update-StartMenu.ps1
Created June 14, 2017 17:01
Organizes your start menu into your defined categories. Support -WhatIf.
[CmdletBinding(SupportsShouldProcess = $true)]
Param(
)
$commonStarMenuDir = 'C:\ProgramData\Microsoft\Windows\Start Menu\Programs'
$userStartMenDir = Join-Path $env:AppData 'Microsoft\Windows\Start Menu\Programs'
$tempStartMenuDir = Join-Path $env:Temp 'TempStartMenu'
if (Test-Path $tempStartMenuDir) {
Get-ChildItem $tempStartMenuDir -Recurse | Remove-Item -Recurse -Force
function Compress-Packages {
param(
[string] $sourcePath,
[string] $destinationPath,
[string] $zipFile
)
if (Test-Path $destinationPath) {
Remove-Item $destinationPath -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
}
$excludeFiles = $('update.ps1', 'chocolateyInstall.ps1', '*.nupkg')
# packageDir is defined in the individual update script
Push-Location $packageDir
function global:au_BeforeUpdate {
if ([System.IO.Directory]::Exists($settingsDir) -and $settingsZip) {
Compress-Archive -Path $settingsDir -DestinationPath $settingsZip -Force
}
}
@The-Running-Dev
The-Running-Dev / New-CertificateRequest.ps1
Last active May 30, 2017 17:09
Create a IIS certificate request for a given host name or list of host names.
# Usage
# New-CertificateRequest subdomain.domain.com
# New-CertificateRequest subdomain1.domain.com, subdomain2.domain.com, subdomain3.domain.com
# New-CertificateRequest subdomain1.domain.com, subdomain2.domain.com, subdomain3.domain.com 'C:\Requests'
function New-CertificateRequest {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory)][string[]] $hostHeaders,
[Parameter(Position = 1)][string] $outputDir = 'C:\Requests'
)
@The-Running-Dev
The-Running-Dev / Get-ProcessOnPort.ps1
Last active May 10, 2017 18:37
Gets the name and the path of the process on the specified local port number
function Get-ProcessOnPort {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory = $true)][int32] $portNumber
)
Get-NetTCPConnection -State Listen -LocalPort $portNumber -ErrorAction SilentlyContinue | `
Select-Object -First 1 -ExpandProperty OwningProcess | `
Select-Object @{Name = "Id"; Expression = {$_} } | `
Get-Process | `