Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View techthoughts2's full-sized avatar
🕵️‍♂️
Investigating a better artifact workflow

Jake Morrison techthoughts2

🕵️‍♂️
Investigating a better artifact workflow
View GitHub Profile
@techthoughts2
techthoughts2 / python.json
Last active April 18, 2024 21:42
Collection of Python Snippets for VSCode
{
"if": {
"prefix": "if",
"body": ["if ${1:expression}:", "\t${2:pass}"],
"description": "Code snippet for an if statement"
},
"if/else": {
"prefix": "if/else",
"body": ["if ${1:condition}:", "\t${2:pass}", "else:", "\t${3:pass}"],
"description": "Code snippet for an if statement with else"
@techthoughts2
techthoughts2 / python_notes.py
Last active March 6, 2024 06:05
python_learning
"""
Ctrl+K Ctrl+0 Fold (collapse) all regions editor.foldAll
Ctrl+K Ctrl+J Unfold (uncollapse) all regions
Ctrl+Shift+[ Fold (collapse) region editor.fold
Ctrl+Shift+] Unfold (uncollapse) region editor.unfold
Ctrl+K Ctrl+[ Fold (collapse) all subregions editor.foldRecursively
Ctrl+K Ctrl+] Unfold (uncollapse) all subregions editor.unfoldRecursively
"""
# region links
@techthoughts2
techthoughts2 / ws_setup.ps1
Last active December 3, 2023 17:42
This PowerShell script will setup a fresh workstation with everything needed to sucessfully work and be a DevOps Master day-to-day.
#region installs
# core tech choco installs
$script:chocoCoreTech = @(
# 'vscode' # visual studio code
# 'python' # python
# '7zip' # file archiver with good compression ratio
# 'git' # git for windows
# 'firefox' # firefox browser
)
@techthoughts2
techthoughts2 / CustomPSObject
Last active October 11, 2023 15:47
Several examples of creating and working with custom PowerShell objects and hash tables. Examples include creating customer Powershell objects that contain multiple values.
#Jake Morrison - @jakemorrison - http://techthoughts.info
$results = [PSCustomObject]@{
HypTotal = $hyptotal
MgmtVMTotal = $mgmtVMTotal
UniqueCustomerCount = $customerTotal
TotalComputerObjects = $allCompsTotal
TotalUserObjects = $userTotal
}
@techthoughts2
techthoughts2 / schedule_cron
Last active October 6, 2023 03:24
Scheduled cron expressions and examples of using cron to scheudle things in AWS
cron(Minutes | Hours | Day-of-month | Month | Day-of-week | Year)
cron(0 0/4 * * ? *) Every 4 hours
cron(0 10 * * ? *) 10:00AM UTC everyday
cron(15 12 * * ? *) 12:15PM UTC everyday
cron(0 18 ? * MON-FRI *) 6:00PM UTC every Mon-Fri
cron(0 8 1 * ? *) 8:00AM UTC every first day of the month
cron(0/10 * ? * MON-FRI *) Every 10 min Mon-Fri
cron(0/5 8-17 ? * MON-FRI *)Every 5 minutes Mon-Fri between 8:00AM - 5:55PM UTC
cron(0 9 ? * 2#1 *) 9:00AM UTC first Monday of each month
@techthoughts2
techthoughts2 / git_commands
Last active September 25, 2023 03:13
A set of useful git commands I often use
git config --global -e
git config --list --show-origin
git config --global user.name
git config --global user.email
git config --global core.editor "code --wait"
Windows creds
git config --global credential.helper wincred
git clone
$NumberOfLogicalProcessors = Get-CimInstance win32_processor | Select-Object -ExpandProperty NumberOfLogicalProcessors
ForEach ($core in 1..$NumberOfLogicalProcessors) {
start-job -ScriptBlock {
$result = 1;
foreach ($loopnumber in 1..2147483647) {
$result = 1;
foreach ($loopnumber1 in 1..2147483647) {
$result = 1;
@techthoughts2
techthoughts2 / ps_Errors.ps1
Last active August 3, 2023 18:56
Working with PowerShell Errors
function Reset-Errors {
$Global:Error.Clear()
$psISE.Options.ErrorForegroundColor = '#FFFF0000'
$Global:ErrorView = 'NormalView'
}
Reset-Errors
#generate an error
function Show-Error {
Get-Item c:\doesnotexist.txt
@techthoughts2
techthoughts2 / ps_lambda
Last active June 27, 2023 16:11
Some basic code snips for PowerShell Lambda Stuff
#Download the .NET Core 2.1 SDK from https://www.microsoft.com/net/download
Install-Module AWSPowerShell.NetCore
Install-Module AWSLambdaPSCore
Import-Module AWSPowerShell.NetCore
Import-Module AWSLambdaPSCore
Get-Command -Module AWSLambdaPSCore
New-Item PSLambda -ItemType Directory
@techthoughts2
techthoughts2 / Send-TelegramTextMessage
Last active June 9, 2023 14:37
This PowerShell function will send a Telegram message via the Telegram Bot API. Specify your Bot token and chat ID and send text messages to the specified Telegram chat via PowerShell.
<#
.Synopsis
Sends Telegram text message via Bot API
.DESCRIPTION
Uses Telegram Bot API to send text message to specified Telegram chat. Several options can be specified to adjust message parameters.
.EXAMPLE
$bot = "#########:xxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxx"
$chat = "-#########"
Send-TelegramTextMessage -BotToken $bot -ChatID $chat -Message "Hello"
.EXAMPLE