Skip to content

Instantly share code, notes, and snippets.

@qbikez
qbikez / TelemetryLogger.cs
Created September 2, 2020 13:50
Logging telemetry events via ILogger
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 March 3, 2017 04:20
a little Powershell Cmdle that makes performance measuring easier.
$script:perfstack = @()
$fullperfnames = $false
function measure-function([string] $__name, [scriptblock] $__command) {
$__result = $null
$__cmd = {
$__result = Invoke-Command $__command
}
if ($script:perfstack -eq $null) {
Some powershell scripts helpful in mercurial repository conversion
@qbikez
qbikez / example.tests.ps1
Last active February 27, 2016 05:43 — forked from nohwnd/example.tests.ps1
Pester problem matcher for VS Code
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 February 22, 2016 11:03
a script to incrementally clone hg repo (for HUUGE repos)
[cmdletbinding()]
param(
[Parameter(Mandatory=$true)]$repo,
[Parameter(Mandatory=$true)]$targetdir,
$offset = 0,
$batchsize = 50,
$total = 40000
)
@qbikez
qbikez / PSGet5.psm1
Created February 17, 2016 07:53
psget - powershell v5
#########################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# PowerShellGet Module
#
#########################################################################################
Microsoft.PowerShell.Core\Set-StrictMode -Version Latest
@qbikez
qbikez / PSGet.psm1
Last active February 19, 2016 09:26
psget with fixes for unattended use
#########################################################################################
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# PowerShellGet Module
#
#########################################################################################
Microsoft.PowerShell.Core\Set-StrictMode -Version Latest
@qbikez
qbikez / module.psm1
Created February 16, 2016 06:25
a template for creating powershell module
$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 August 25, 2016 04:17
boostrap for installing other modules, etc
[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 February 7, 2016 19:00
powershell helper functions for manipulating nuspec
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
}