View getMillis.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMillis { | |
param ( | |
$unixTimeStamp | |
) | |
$epochStart = Get-Date 01.01.1970 | |
$millisStamp = ($epochStart + ([System.TimeSpan]::frommilliseconds($unixTimeStamp))).ToLocalTime() | |
$millisStampOutput = $millisStamp.ToString("yyyy-MM-dd HH:mm:ss.ffffff") | |
$millisStampClipboard = $millisStamp.ToString("HH:mm:ss.ffffff") | |
Write-Host "~~~~~~~~~~~~~~~~~~~~~~~~~~~~" | |
Write-Host "Datetime: $millisStampOutput" -ForegroundColor Cyan |
View create-codeFiles.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function create-codeFiles($name, $testName, $extension, $linkText) { | |
$codeFile = ("$name" -replace "\s", "_") -replace ".+", "$&.$extension" | |
$testFile = ("$name" -replace "\s", "_") -replace ".+", "$&$testName.$extension" | |
New-Item $codeFile -ErrorAction Ignore | |
New-Item $testFile -ErrorAction Ignore | |
Add-Content $testFile -Value $linkText | |
code . | |
Invoke-Item $codeFile | |
Invoke-Item $testFile | |
} |
View refactoredNomad.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get-nomadLogs ([string]$jobId, [string]$featureFlag) { | |
function get-stderr ($jobId) { | |
$nomadLogs = nomad alloc logs -stderr -job $jobId | |
if (nomad status $jobID | Select-String status.*dead) { | |
Out-Host -InputObject $nomadLogs | |
} | |
} | |
function get-logs($jobId) { |
View spagettiNomad.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get-nomadLogs ($jobId, $featureFlag) { | |
$nomadLogs = ($featureFlag -ne "e") ? | |
(nomad alloc logs -job $jobId) : | |
(nomad alloc logs -stderr -job $jobId) | |
if ($featureFlag -eq "l") { oh -InputObject $nomadLogs } | |
if (nomad status $jobID | sls -Pattern "(?=.*\d)failed") { | |
write-host "Job Failed - see webUI - stderr below" -ForegroundColor DarkRed |
View downloadCert.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function test-certificate($domain, $contextLength = 10, [switch]$download) { | |
$cacertPath = "c:\cacert.pem" | |
$connectDomain = $domain + ":443" | |
#<feature> download certificate into a download folder | |
if($download) { | |
echo "q" | openssl s_client -servername $domain -connect $connectDomain -CAfile $cacertPath | | |
openssl x509 -text | | |
out-file "C:\Users\$env:USERNAME\downloads\$domain.txt" -force | |
Write-Host "~~~" -ForegroundColor darkcyan |
View match-branches.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function match-branch ([switch]$local_only, [switch]$remote_only, [switch]$both) { | |
$localBranches = ((git branch -l) -replace "\*", "") -replace " ", "" | |
$remoteBranches = (((git branch -r) -replace "\*", "") -replace " ", "") -replace "origin/", "" | |
$branch_comparison = Compare-Object -ReferenceObject $localBranches -DifferenceObject $remoteBranches -IncludeEqual | |
| Select-Object @{Label = "branch"; Expression = { $_.InputObject } }, | |
@{Label = ”both”; Expression = { $_.SideIndicator -eq "==" } }, | |
@{Label = ”remote_only”; Expression = { $_.SideIndicator -eq "=>" } }, | |
@{Label = ”local_only”; Expression = { $_.SideIndicator -eq "<=" } } | |
if ($local_only) { $branch_comparison | Where-Object -Property "local_only" -EQ "true" | Select-Object branch } | |
elseif ($remote_only) {$branch_comparison | Where-Object -Property "remote_only" -EQ "true" | Select-Object branch} |
View filecount-per-folder.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -Recurse -Directory | | |
Select-Object Name, @{ | |
Name="FileCount"; | |
Expression={(Get-ChildItem $_ -File | Measure-Object).Count } | |
} |
View get_files_with_parent_folder.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir *.mp4 -rec -file | | |
select-object @{ | |
Name="folder"; | |
Expression = {Split-Path (Split-Path $_.Fullname -parent) -leaf} | |
},name |
View Force-OutlookAddinLoad.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function disableResiliency { | |
param( | |
[Parameter(Mandatory = $true)] | |
[string]$AddinName, | |
[Parameter(Mandatory = $false)] | |
[switch]$Force, | |
[Parameter(Mandatory = $false)] | |
[switch]$AllowUserControl | |
) | |
$AddinList = $null |
View argparse_boilerplate.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#file: foobar.py | |
import argparse | |
def function_proper(param1, param2) -> None: | |
#CODE... | |
def init_argparse() -> argparse.ArgumentParser: | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--param1") | |
parser.add_argument("--param2") |
OlderNewer