Skip to content

Instantly share code, notes, and snippets.

@SeeminglyScience
SeeminglyScience / Get-ActiveTranscriptPath.ps1
Created November 22, 2017 22:21
Gets the path of active transcripts for the current runspace. Utilizes unsupported code, use at your own risk.
function Get-ActiveTranscriptPath {
[CmdletBinding()]
param()
end {
$flags = [System.Reflection.BindingFlags]'Instance, NonPublic'
$transcriptionData = $Host.Runspace.GetType().
GetProperty('TranscriptionData', $flags).
GetValue($Host.Runspace)
$transcripts = $transcriptionData.GetType().
@SeeminglyScience
SeeminglyScience / PlatformUnix.cs
Last active January 31, 2018 23:52
Unsuccessful proof of concept for fixing Unix Console.ReadKey without native binaries.
using System;
using System.Runtime.InteropServices;
namespace Microsoft.PowerShell.Internal
{
internal class PlatformUnix
{
// termios
private const int STDIN_FILENO = 0; // File descriptor for Standard Input.
private const int NCCS = 64; // Size of the array c_cc for control characters.
@SeeminglyScience
SeeminglyScience / gist:e8b0e1ef0673a288b7b67916e8303d99
Last active February 21, 2018 01:46
Working list of issues that can be closed after PSReadLine changes
PSReadLine
https://github.com/PowerShell/vscode-powershell/issues/535
https://github.com/PowerShell/vscode-powershell/issues/569
https://github.com/PowerShell/vscode-powershell/issues/1027
https://github.com/PowerShell/vscode-powershell/issues/815
https://github.com/PowerShell/vscode-powershell/issues/785
https://github.com/PowerShell/vscode-powershell/issues/550
https://github.com/PowerShell/vscode-powershell/issues/873
https://github.com/PowerShell/vscode-powershell/issues/998
@SeeminglyScience
SeeminglyScience / Enter-PSSessionWithEdit.ps1
Last active May 4, 2023 03:27
Proof of concept for "psedit" working outside of PSES.
function Enter-PSSessionWithEdit {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[ValidateNotNullOrEmpty()]
[string] $ComputerName
)
end {
$enterEventName = 'RemoteSessionEditor.Enter'
if (-not $Host.Runspace.Events.GetEventSubscribers($enterEventName)) {
# Syntax:
# ?? -If $true -Then { 'yep' } -Else { 'nah' }
# ?? -If $true { 'yep' } : { 'nah' }
# ?? -If $true { 'yep' } else { 'nah' }
# ?? -If $true { 'yep' } { 'nah' }
#
# $true | ?? -Then { 'yep' } -Else { 'nah' }
# $true | ?? { 'yep' } : { 'nah' }
# $true | ?? { 'yep' } else { 'nah' }
# $true | ?? { 'yep' } { 'nah' }
using namespace System.Collections.Generic
using namespace System.Management.Automation
using namespace System.Security.AccessControl
using namespace Microsoft.Win32
function Get-InstalledSoftware {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline)]
[ValidateNotNullOrEmpty()]
function Expand-MemberInfo {
[Alias('emi')]
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline, Mandatory)]
[Alias('Member')]
[psobject] $InputObject,
[Parameter()]
[ValidateSet('IL', 'CSharp', 'VisualBasic')]
@SeeminglyScience
SeeminglyScience / console-settings.reg
Last active August 17, 2020 17:53
My registry values for conhost configuration. Note that "FaceName" is "__DefaultTTFont__" because I set the font within my PowerShell profile. Make sure to remove application specific subkeys under "Console" as they will override these settings.
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console]
"ColorTable00"=dword:00000000
"ColorTable01"=dword:00800000
"ColorTable02"=dword:00005000
"ColorTable03"=dword:00808000
"ColorTable04"=dword:0000003c
"ColorTable05"=dword:00562401
"ColorTable06"=dword:00f0edee
@SeeminglyScience
SeeminglyScience / emca-335-i.11.md
Last active May 15, 2024 20:25
Rules for CLS-compliance

[I.11 Collected Common Language Specification rules][§I.11]

The complete set of CLS rules are collected here for reference. Recall that these rules apply only to "externally visible" items—types that are visible outside of their own assembly and members of those types that have public, family, or family-or-assembly accessibility. Furthermore, items can be explicitly marked as CLS-compliant or not using the System.CLSCompliantAttribute. The CLS rules apply only to items that are marked as CLS-compliant.

  1. CLS rules apply only to those parts of a type that are accessible or visible outside of the defining assembly. ([§I.7.3])

  2. Members of non-CLS compliant types shall not be marked CLS-compliant. ([§I.7.3.1])

  3. Boxed value types are not CLS-compliant. ([§I.8.2.4].)

$CppHeaderFilePath = 'path/to/something.h'
$interfaceDefinition = Get-Content $CppHeaderFilePath -Raw
$flags = [Reflection.BindingFlags]::NonPublic -bor [Reflection.BindingFlags]::Instance
$fields = @{
_a = [guid].GetField('_a', $flags)
_b = [guid].GetField('_b', $flags)
_c = [guid].GetField('_c', $flags)
_d = [guid].GetField('_d', $flags)
_e = [guid].GetField('_e', $flags)
_f = [guid].GetField('_f', $flags)