This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -ti -v $(pwd):/tmp DOCKER_IMAGE /bin/bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$user = "USERNAME" | |
$pass = "PASSWORD" | |
$pair = "${user}:${pass}" | |
#Encode the string to the RFC2045-MIME variant of Base64, except not limited to 76 char/line. | |
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair) | |
$base64 = [System.Convert]::ToBase64String($bytes) | |
#Create the Auth value as the method, a space, and then the encoded pair Method Base64String | |
$basicAuthValue = "Basic $base64" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Load assembly | |
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.SqlParser") | Out-Null | |
$ParseOptions = New-Object Microsoft.SqlServer.Management.SqlParser.Parser.ParseOptions | |
$ParseOptions.BatchSeparator = 'GO' | |
## No Errors | |
$Sql = "Select * from sys.sysdatabases" | |
$Script = [Microsoft.SqlServer.Management.SqlParser.Parser.Parser]::Parse($SQL, $ParseOptions) | |
$Script.Errors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// serviceUri - the fabric address of the service you want to query for partitions | |
// this gist assumes your service has an Int64 partitioning scheme. | |
var fabricClient = new FabricClient(); | |
var servicePartitionList = await fabricClient.QueryManager.GetPartitionListAsync(serviceUri); | |
IList<Int64RangePartitionInformation> partitionKeys = new List<Int64RangePartitionInformation>(servicePartitionList.Count); | |
foreach (var partition in servicePartitionList) | |
{ | |
var int64PartitionInfo = partition.PartitionInformation as Int64RangePartitionInformation; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prerequisites: | |
You have a piece of old software you need to run but it requires .net 2.0 to install. | |
Steps to install .net framework 2.0: | |
1. Download .net framework from microsoft.com. | |
2. Realize it is x64 and not x86 as needed. | |
3. Download .net framework 2.0 sp2 from microsoft.com | |
4. Realize it is only the service pack and does not include the installer. | |
5. Find a USB cd rom drive. | |
6. Copy the exe off of the cd. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<T> TraverseTree<T>(this T parent, Func<T, IEnumerable<T>> getChildren) | |
{ | |
yield return parent; | |
foreach (var child in getChildren(parent)) | |
{ | |
foreach (var item in child.TraverseTree(getChildren)) | |
{ | |
yield return item; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Guid ToGuid(this int value) | |
{ | |
byte[] bytes = new byte[16]; | |
BitConverter.GetBytes(value).CopyTo(bytes, 0); | |
return new Guid(bytes); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ask the user for a gist name | |
param ( | |
[string]$gistname = "$(Read-Host 'Enter a name for the gist')" | |
) | |
# constant | |
$gistapi = "https://api.github.com/gists" | |
$filename = $gistname + '.diff' | |
$teststring = "`{`"description`": `"the description for this gist`",`"public`": true,`"files`": `{`"file1.txt`": `{`"content`": `"String file contents`"`}`}`}" | |
# get the diff from the current session |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#requires -version 2.0 | |
[CmdletBinding()] | |
param ( | |
[parameter(Mandatory=$true)] | |
[ValidatePattern('\.rptproj$')] | |
[ValidateScript({ Test-Path -PathType Leaf -Path $_ })] | |
[string] | |
$Path, | |
[parameter( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Powershell script for adding/removing/showing entries to the hosts file. | |
# | |
# Known limitations: | |
# - does not handle entries with comments afterwards ("<ip> <host> # comment") | |
# | |
$file = "C:\Windows\System32\drivers\etc\hosts" | |
function add-host([string]$filename, [string]$ip, [string]$hostname) { |
NewerOlder