Skip to content

Instantly share code, notes, and snippets.

class foo {
private _bar:boolean = false;
get bar():boolean {
return this._bar;
}
set bar(theBar:boolean) {
this._bar = theBar;
}
}
@romero126
romero126 / Powershell Function to C# Function
Last active February 14, 2021 01:38
Convert-ToCSharp
function Convert-ToCSharp
{
param(
[Parameter(Mandatory)]
[System.String]$Path,
[Parameter(Mandatory)]
[System.String]$OutFile
@romero126
romero126 / WinTerm Image
Created June 12, 2020 17:15
Windows Terminal
function Get-WTSettingsPath {
# Determine if we are in WT
$Profile = $env:WT_PROFILE_ID
if (!$Profile)
{
throw "WT Not available"
}
$SettingsPath = Get-Item "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal*\LocalState\" | Select-Object -ExpandProperty FullName
$SettingsPath
class ConstrainedVariableInterpolation : System.Management.Automation.Language.AstVisitor {
hidden [Hashtable] $Property
[System.Collections.Generic.List[PSCustomObject]] $Result
hidden [System.Management.Automation.Language.Ast] $Ast
[System.Management.Automation.Language.AstVisitAction] CheckForPostAction([System.Management.Automation.Language.Ast] $ast, [System.Management.Automation.Language.AstVisitAction] $action)
{
throw 'CheckForPostAction not supported'
}
@romero126
romero126 / ConstrainedVariableInterpolation
Last active May 9, 2021 22:44
ExpandStringVisitor: Context locked String Interpolation using AstVisitor
class ConstrainedVariableInterpolation : System.Management.Automation.Language.AstVisitor {
hidden [Hashtable] $Property
[System.Collections.Generic.List[PSCustomObject]] $Result
hidden [System.Management.Automation.Language.Ast] $Ast
[System.Management.Automation.Language.AstVisitAction] CheckForPostAction([System.Management.Automation.Language.Ast] $ast, [System.Management.Automation.Language.AstVisitAction] $action)
{
throw 'CheckForPostAction not supported'
}
#Import-Module "$PSScriptRoot\..\Module\WindowsPresentationFramework" -Force
. "$PSScriptRoot\WindowsPresentationFramework.ps1"
#Region ThreadSafe
# Bind Variables
[WindowsPresentationFrameworkThreadSafe()]
[PSObject] $Variable = "Herro World from Proxy Scope"
[WindowsPresentationFrameworkThreadSafe()]
$Sync = [hashtable]::Synchronized(@{})
@romero126
romero126 / Connect-DeviceAuthorization.ps1
Created May 9, 2021 21:39
Connect-DeviceAuthorization
function Connect-DeviceAuthorization {
[CmdletBinding()]
param(
[Parameter(
HelpMessage = "Specify an Application ClientID defaults to the ClientID for 'AzureAD'"
)]
[string] $ClientID = '1b730954-1685-4b74-9bfd-dac224a7b894',
[Parameter(
@romero126
romero126 / text.md
Created August 6, 2022 09:46
Scratch
[
{
"S": [
{
"N": "G0",
"T": 1,
"DN": "D0"
},
{
"N": "G1",
@romero126
romero126 / Code.ps1
Created September 30, 2022 01:28
NamedPipelines
function New-NamedPipeServer {
param(
[Parameter(Mandatory)]
[string] $PipeName,
[Parameter(Mandatory)]
[scriptblock] $ScriptBlock
)
Start-Job -Name $PipeName -ScriptBlock {
function Invoke-ForEachObjectWithProgress {
[CmdletBinding()]
[Alias("ForEachWP")]
param(
[Parameter(Mandatory, ValueFromPipeline)]
[object] $InputObject,
[Parameter()]
[string] $Activity = "Processing items",