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 / 256color.pl
Created May 4, 2016 03:10 — forked from hSATAC/256color.pl
256color.pl
#!/usr/bin/perl
# Author: Todd Larason <[email protected]>
# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $
# use the resources for colors 0-15 - usually more-or-less a
# reproduction of the standard ANSI colors, but possibly more
# pleasing shades
# colors 16-231 are a 6x6x6 color cube
for ($red = 0; $red < 6; $red++) {
@Jaykul
Jaykul / ScriptPropertyRecalculatesVariable.ps1
Last active April 8, 2018 01:35 — forked from pinecones-sx/fcobject.ps1
How to capture a variable value in a closure
function global:Get-CompFolder{
param($iFolderLoc)
$objCompFolder = [Ordered]@{
'Location' = $iFolderLoc
'Folder' = Get-Item $iFolderLoc
'SortedTree' = @()
}
New-Object -TypeName PSObject -Property $objCompFolder |
Add-Member -Passthru -Type ScriptProperty -Name Tree -Value {
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);
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)
@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.
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 / 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
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"
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) {}
@Jaykul
Jaykul / New-Hyperlink.ps1
Last active August 21, 2024 11:02 — forked from JustinGrote/Write-ANSIHyperlink.ps1
Powershell Function to create Terminal HyperLinks using ANSI Escape Sequences (Supported in Windows Terminal PREVIEW)