Skip to content

Instantly share code, notes, and snippets.

[CmdletBinding(DefaultParameterSetName = 'FixedG')]
param(
[Parameter(ParameterSetName = 'FixedR', Mandatory)]
[ValidateRange(0, 255)]
$fixedR,
[Parameter(ParameterSetName = 'FixedG')]
[ValidateRange(0, 255)]
[int]$fixedG = 105,
using namespace System.Text.RegularExpressions
param([string[]]$extensions = 'ps1')
function Get-FileEncoding
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [string]$Path
)
@lzybkr
lzybkr / FormatHex.cs
Created March 15, 2017 22:11
Formatting hex objects
using System;
using System.Runtime.InteropServices;
using System.Reflection;
namespace App
{
enum E1 : byte
{
e1 = 5
}
<Configuration>
<ViewDefinitions>
<View>
<Name>Measure-Object-Output</Name>
<ViewSelectedBy>
<TypeName>Microsoft.PowerShell.Commands.GenericMeasureInfo</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
@lzybkr
lzybkr / Invoke-PerfviewPS.ps1
Created October 17, 2017 00:19
Run PowerShell via perfview with PowerShell EventSource sources
param(
$etlFile = '.\perfviewdata.etl',
$scenario = 'echo 1',
$logFile = '.\perfview.log')
$perfViewArgs = @(
'/AcceptEula'
'/ThreadTime'
"/LogFile=$logFile"
"/DataFile:$etlFile"
enum Color { Red; Green; Blue }
[System.Diagnostics.Tracing.EventSource(Name = "MyPSEventSource")]
class C : System.Diagnostics.Tracing.EventSource
{
[System.Diagnostics.Tracing.Event(1)]
[void] SomeRandomEvent([string]$Message, [Color]$Color)
{
$this.WriteEvent([int]1, [string]$Message, [int]$Color)
@lzybkr
lzybkr / GitHub_DownloadCounts.fsx
Created December 12, 2017 03:40
Get Download counts of all releases for a user/repo
#r "./FSharp.Data.2.4.3/lib/net45/FSharp.Data.dll"
open FSharp.Data
let (user,repo) =
match fsi.CommandLineArgs with
| [| _; arg1; arg2 |] -> (arg1, arg2)
| _ -> failwithf "usage: gh user repo"
@lzybkr
lzybkr / print_tree.ps1
Last active January 4, 2018 02:03
Print a tree with any Key and Parent properties.
# .SYNOPSIS
# Print a tree given a key property and parent property
#
# .PARAMETER InputObject
#
# The object to print.
#
# .PARAMETER KeyProperty
@lzybkr
lzybkr / Convert-ArgumentCompleterRegistrationScript.ps1
Created April 27, 2015 18:41
Script to convert TabExpansion++ completers to use Register-ArgmentCompleter
param(
[Parameter(ValueFromPipelineByPropertyName = $true, Mandatory, Position = 0)]
[Alias("PSPath")]
[string]$Path,
[string]$OutputPath
)
process
@lzybkr
lzybkr / format.xsd
Created September 12, 2018 00:42
Types/Format xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Configuration">
<xs:complexType>
<xs:all>
<xs:element name="DefaultSettings" type="DefaultSettings" minOccurs="0" maxOccurs="1"/>
<xs:element name="SelectionSets" type="SelectionSets" minOccurs="0" maxOccurs="1"/>
<xs:element name="Controls" type="Controls" minOccurs="0" maxOccurs="1"/>
<xs:element name="ViewDefinitions" type="ViewDefinitions" minOccurs="0" maxOccurs="1"/>