Skip to content

Instantly share code, notes, and snippets.

View Jaykul's full-sized avatar
😀
Learning

Joel Bennett Jaykul

😀
Learning
View GitHub Profile
@Jaykul
Jaykul / AudioPlaybackEngine.cs
Last active October 8, 2022 05:41 — forked from markheath/AudioPlaybackEngine.cs
FireAndForget NAudio Sample
using System;
using NAudio.Wave;
using NAudio.Wave.SampleProviders;
namespace FireAndForgetAudioSample
{
class AudioPlaybackEngine : IDisposable
{
private readonly IWavePlayer outputDevice;
private readonly MixingSampleProvider mixer;
function Expand-AstVariables {
param (
[Parameter(Mandatory, ValueFromPipeline)]
[System.Management.Automation.Language.Ast] $Statement,
[Parameter(Mandatory)]
[ref] $result,
[Parameter(Mandatory)]
[PSObject] $Properties
)
@Jaykul
Jaykul / New-Hyperlink.ps1
Last active May 2, 2024 21:58 — forked from JustinGrote/Write-ANSIHyperlink.ps1
Powershell Function to create Terminal HyperLinks using ANSI Escape Sequences (Supported in Windows Terminal PREVIEW)
using namespace System.Management.Automation
using namespace System.Collections.Generic
class ArgumentCompleterBase : IArgumentCompleter {
hidden [List[CompletionResult]] $Results = [List[CompletionResult]]::new()
[string] $WordToComplete
[Language.CommandAst] $commandAst
# override in child class
[void] AddCompletionsFor([string] $commandName, [string] $parameterName, [Collections.IDictionary] $fakeBoundParameters) {}
function Get-Data {
Param (
[Parameter()][int]$MajorVersion = $(([environment]::OSVersion.Version).Major),
[Parameter()][int]$MinorVersion = $(([environment]::OSVersion.Version).Minor),
[Parameter()][string]$Find = "wcPatchUri"
)
Process{
Try{
$cdnBaseURI = "https://example.com"
@Jaykul
Jaykul / SelfCleaningJob.ps1
Last active April 8, 2018 01:35 — forked from anonymous/SelfCleaningJobs.ps1
Self-cleaning jobs make more jobs to clean themselves up!
function New-SelfCleaningJob {
param(
$Name=$([Guid]::NewGuid().Guid)
)
$job = Start-Job -Name $Name { 1..10 | % { Write-Output $_ } }
$jobCleanup = Register-ObjectEvent $job -EventName StateChanged -Action {
if($EventArgs.JobStateInfo.State -eq "Completed") {
# Note this prints to host no matter what's going on right now ....
Receive-Job $Sender | out-host
Show-UI -Title 'FTP Log Search' {
Grid -Columns Auto,* -Rows 5 -Margin 5 -MinHeight 200 -MinWidth 250 {
Label "Date (MM/DD/YY)"
New-DatePicker -Name First -Column 1 -Margin "5"
Label "Clip Name" -Row 1
New-TextBox -Name Last -Row 1 -Column 1 -Margin "5"
Label "E-mail Address" -Row 2
@Jaykul
Jaykul / RemoveOldFiles.ps1
Last active April 8, 2018 01:35 — forked from anonymous/gist:93c9fa41bef0253096bc08bf9518e301
Gists can have multiple files, and if you set the extension, they get syntax highlighting
Import-Module "D:\Coding\PowerShell\Modules\remove-OldFiles.psm1"
remove-OldFiles -Path 'D:\Coding' -ExcludeFolders "Bootstrap Learning","PowerShell","Waaah!"
#the folder Waaah! dont exists in the Folder mentioned above. so in the PSM there is a write-Host line to display this error. but i dont see it when i call the function from the ps1 script.
param(
$Source = "c:\users\USER1\desktop\test\folder1",
$Destination = "c:\users\USER1\desktop\test\folder2"
)
$Sources = Get-ChildItem $Source -recurse -depth 4 | Where-Object {$_.name -like "*``, *`` *``(*2016)"} | Select-Object -ExpandProperty FullName
Push-Location $Source
foreach($SourcePath in $Sources) {
$DestPath = Join-Path $Destination (Resolve-Path $SourcePath -Relative)
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class NativeConsoleMethods
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr GetStdHandle(int handleId);