Skip to content

Instantly share code, notes, and snippets.

View TryTryAgain's full-sized avatar
🎯
Focusing

Michael Lawler TryTryAgain

🎯
Focusing
View GitHub Profile
@TryTryAgain
TryTryAgain / gotp.py
Created January 20, 2023 17:44
A simple "get OTP" python script utilizing pyotp: Supply an MFA seed and get the current and following/next OTP token readout, useful for getting a quick MFA OTP token provided a seed.
#!/usr/bin/env python
import pyotp
import argparse
# Variables grabbed from CLI arguments
parser = argparse.ArgumentParser(
    description='Supply MFA seed and get current and next OTP readout')
parser.add_argument(
    '-s', '--seed',
    required=True
@bassmanitram
bassmanitram / hack-selections.js
Created November 11, 2022 12:56
How to make Terraform 0.13 properly update a Terraform 0.12 state
/*
* Put this in a place where node can find it (referenced by $SCRIPT_HOME in the driver script)
* or figure out how to do this with JQ :)
*
* Basically, for every key that starts with "registry.terraform.io/hashicorp/" duplicate its value to
* that same key with "hashicorp" translated to "-" (keep the original property too)
*/
const fs = require("fs")
const output ={};
Object.entries(JSON.parse(fs.readFileSync( "/dev/stdin" ))).forEach(([key,value]) => {
@sarimarton
sarimarton / fix_github_copilot.sh
Last active April 24, 2024 06:59
Fix Github Copilot in dealing with self-signed certificates
# [2023-05-25] Added Copilot Chat, and VSCode Insiders
# [2023-05-20] Add VSCode Insiders variant
# [2023-02-22] Added Copilot Labs
# Fix Github Co-pilot self-signed cert problem
# See: https://github.com/orgs/community/discussions/8866#discussioncomment-3517831
# Note
#
# To make Github Copilot/Nightly/Labs/Chat work, you might need additional
@slimsag
slimsag / ramblings.md
Last active December 13, 2023 08:02
Because cross-compiling binaries for Windows is easier than building natively

Because cross-compiling binaries for Windows is easier than building natively

I want Microsoft to do better, want Windows to be a decent development platform-and yet, I constantly see Microsoft playing the open source game: advertising how open-source and developer friendly they are - only to crush developers under the heel of the corporate behemoth's boot.

The people who work at Microsoft are amazing, kind, talented individuals. This is aimed at the company's leadership, who I feel has on many occassions crushed myself and other developers under. It's a plea for help.

The source of truth for the 'open source' C#, C++, Rust, and other Windows SDKs is proprietary

You probably haven't heard of it before, but if you've ever used win32 API bindings in C#, C++, Rust, or other languages, odds are they were generated from a repository called microsoft/win32metadata.

@TryTryAgain
TryTryAgain / fix_copilot_proxy.sh
Created February 19, 2022 04:35
Fix GitHub Copilot behind Netskope or Zscalar or other Proxy
#!/bin/bash
_VSCODEDIR="$HOME/.vscode/extensions"
_COPILOTDIR=$(ls "${_VSCODEDIR}" | grep -E "github.copilot-[1-9].*") # For copilot
_COPILOTDEVDIR=$(ls "${_VSCODEDIR}" | grep "github.copilot-nightly-") # For copilot-nightly
_EXTENSIONFILEPATH="${_VSCODEDIR}/${_COPILOTDIR}/dist/extension.js"
_DEVEXTENSIONFILEPATH="${_VSCODEDIR}/${_COPILOTDEVDIR}/dist/extension.js"
if [[ -f "$_EXTENSIONFILEPATH" ]]; then
echo "Found Copilot Extension, applying 'rejectUnauthorized' patches to '$_EXTENSIONFILEPATH'..."
perl -pi -e 's/,rejectUnauthorized:[a-z]}(?!})/,rejectUnauthorized:false}/g' ${_EXTENSIONFILEPATH}
@z0ph
z0ph / find_loggroups_size.sh
Last active December 16, 2021 21:09
Find AWS CloudWatch LogGroups size + retention | sorted
aws logs describe-log-groups \
--query "logGroups[*].{LogGroup:logGroupName,VolumeSize:storedBytes,RetentionInDays:retentionInDays} | reverse(sort_by(@, &VolumeSize))" \
--output table
# Source: https://gist.github.com/d2f36b05bf959e5fc91497ea3f0dceb3
#######################################################
# Free Docker Desktop Alternative For Mac And Windows #
# https://youtu.be/LGNEG-t96eE #
#######################################################
# Referenced videos:
# - How to run local multi-node Kubernetes clusters using kind: https://youtu.be/C0v5gJSWuSo
# - K3d - How to run Kubernetes cluster locally using Rancher k3s: https://youtu.be/mCesuGk-Fks
@system123
system123 / google_auth.py
Created March 2, 2021 17:09
Google Auth TOTP code generator, just seed it with your MFA secret key and it'll generate codes exactly as Google Auth does.
def get_totp_token(secret, refresh_time=int(time.time())//30):
secret = secret.strip().replace(' ', '')
secret = secret.ljust((len(secret) + 7) & (-8) ,'=')
key = base64.b32decode(secret, True)
msg = struct.pack(">Q", refresh_time)
h = bytearray(hmac.new(key, msg, hashlib.sha1).digest())
o = h[19] & 15
h = str((struct.unpack(">I", h[o:o+4])[0] & 0x7fffffff) % 1000000)
return h.zfill(6)
@noamsdahan
noamsdahan / passrole_actions_and_parameters.csv
Last active April 19, 2024 05:54
A list of IAM actions which require iam:PassRole as of December 2020. Nested parameters are written with dot ('.') notation. Where there are multiple relevant parameters, they are separated by the pipe character ('|'). consult the AWS documentation on special cases - noted with an asterisk (most of them are "array of documents" type parameters).…
IAM Permission Params
amplify:CreateApp iamServiceRoleArn
amplify:UpdateApp iamServiceRoleArn
appconfig:CreateConfigurationProfile RetrievalRoleArn
appconfig:UpdateConfigurationProfile RetrievalRoleArn
appflow:CreateConnectorProfile connectorProfileConfig.connectorProfileProperties.Redshift.roleArn
appflow:UpdateConnectorProfile connectorProfileConfig.connectorProfileProperties.Redshift.roleArn
application-autoscaling:RegisterScalableTarget RoleARN
apprunner:CreateService SourceConfiguration.AuthenticationConfiguration.AccessRoleArn|InstanceConfiguration.InstanceRoleArn
apprunner:UpdateService SourceConfiguration.AuthenticationConfiguration.AccessRoleArn|InstanceConfiguration.InstanceRoleArn
@mblythe86
mblythe86 / plex_cleanup.rb
Created September 25, 2020 16:09
Clean unused posters/art/banners from Plex
#!/usr/bin/env ruby
# At least for movies, it looks like it copies the 'selected' stuff into the
# _stored/ folder. It also seems to use the _combined/ folder for access.
# so, I shoud be able to delete anything that's not those two.
# And after that, in the _combined folder, I can/should delete any broken links
# and remove them from <art> and <posters> in Info.xml.
# remove <reviews> from Info.xml too, since it seems to be unused.
# As far as I can tell, extras.xml can just be deleted?
# Same for Artists