Skip to content

Instantly share code, notes, and snippets.

@qbikez
qbikez / TelemetryLogger.cs
Created Sep 2, 2020
Logging telemetry events via ILogger
View TelemetryLogger.cs
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.ApplicationInsights;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
namespace Telemetry
@qbikez
qbikez / perfcounters.ps1
Created Mar 3, 2017
a little Powershell Cmdle that makes performance measuring easier.
View perfcounters.ps1
$script:perfstack = @()
$fullperfnames = $false
function measure-function([string] $__name, [scriptblock] $__command) {
$__result = $null
$__cmd = {
$__result = Invoke-Command $__command
}
if ($script:perfstack -eq $null) {
View hg-repo-conversion
Some powershell scripts helpful in mercurial repository conversion
@qbikez
qbikez / example.tests.ps1
Last active Feb 27, 2016 — forked from nohwnd/example.tests.ps1
Pester problem matcher for VS Code
View example.tests.ps1
describe "DS"{
it "skipped" {} -skip
it "pending" {} -Pending
It "throw" { throw "sdfad" }
It "assertion fail" {1 | should be 10 }
It "string assertion fail" {"asdf" | should be "ffsad" }
it "success" {"adsf"}
}
@qbikez
qbikez / clone-hg.ps1
Last active Feb 22, 2016
a script to incrementally clone hg repo (for HUUGE repos)
View clone-hg.ps1
[cmdletbinding()]
param(
[Parameter(Mandatory=$true)]$repo,
[Parameter(Mandatory=$true)]$targetdir,
$offset = 0,
$batchsize = 50,
$total = 40000
)
@qbikez
qbikez / PSGet5.psm1
Created Feb 17, 2016
psget - powershell v5
View PSGet5.psm1
#########################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# PowerShellGet Module
#
#########################################################################################
Microsoft.PowerShell.Core\Set-StrictMode -Version Latest
@qbikez
qbikez / PSGet.psm1
Last active Feb 19, 2016
psget with fixes for unattended use
View PSGet.psm1
#########################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# PowerShellGet Module
#
#########################################################################################
Microsoft.PowerShell.Core\Set-StrictMode -Version Latest
@qbikez
qbikez / module.psm1
Created Feb 16, 2016
a template for creating powershell module
View module.psm1
$root = "."
if (![string]::IsNullOrEmpty($PSScriptRoot)) {
$root = $PSScriptRoot
}
#if ($MyInvocation.MyCommand.Definition -ne $null) {
# $root = $MyInvocation.MyCommand.Definition
#}
$helpersPath = $root
# grab functions from files
@qbikez
qbikez / bootstrap.ps1
Last active Aug 25, 2016
boostrap for installing other modules, etc
View bootstrap.ps1
[CmdletBinding()]
param ($path = ".", [switch][bool]$importonly)
function get-envinfo($checkcommands) {
$result = @{}
write-verbose "Powershell version:"
$result.PSVersion = $PSVersionTable.PSVersion
$result.PSVersion | format-table | out-string | write-verbose
@qbikez
qbikez / nuspec-tools.ps1
Created Feb 7, 2016
powershell helper functions for manipulating nuspec
View nuspec-tools.ps1
function Get-NuspecVersion($nuspec = $null) {
if ([string]::IsNullOrEmpty($nuspec)) {
$nuspec = Get-ChildItem . -Filter *.nuspec | select -First 1
}
$content = Get-Content $nuspec
$verRegex = "<version>(.*)</version>"
[string]$line = $content | where { $_ -match $verRegex } | select -First 1
$ver = $matches[1]
return $ver
}