Skip to content

Instantly share code, notes, and snippets.

View jonathanhle's full-sized avatar

Jonathan Le jonathanhle

View GitHub Profile
@jonathanhle
jonathanhle / create_access_request.py
Created April 16, 2024 21:56
Discord Access Spike - adding auto approval with tags and populated request reason
import random
import string
from datetime import datetime
from typing import Optional
from flask import current_app, has_request_context, request
from sqlalchemy.orm import joinedload, selectin_polymorphic, selectinload
from api.extensions import db
from api.models import (
@jonathanhle
jonathanhle / ssh-airplane-wifi.md
Created March 8, 2024 23:56 — forked from guillochon/ssh-airplane-wifi.md
Instructions on how to SSH on airplane WiFi that blocks port 22

Using SSH through airplane WiFi that blocks port 22

Many aircraft that offer wifi only permit access to machines on port 80/443, the standard http(s) ports. If you want to SSH, you have to set up an intermediate machine that hosts the SSH service on either port 80 or 443. An easy (and free) way to do this is via a Google free-tier micro instance. These instances have a 1 GB transfer ceiling per month, but so long are you are only transmitting textual data a few days per month, this limit should not be easily exceeded. Set up one of these VMs via the Google Cloud console, and select CentOS 7 as the disk image. Make sure that you allow http/https traffic on the instance, the two checkboxes in the Firewalls section of the VM settings. Optionally, set a static external IP address for your server in the VM config, in case you don't want to look up the IP each time. Then, ssh into the new VM (the IP address will be listed as the "external IP" in the list of instances) and edi

@jonathanhle
jonathanhle / Filter-NGPVAN-Political-Emails.md
Created October 23, 2023 16:36 — forked from canadaduane/Filter-NGPVAN-Political-Emails.md
Move Incoming NGPVAN Political Emails in Gmail to Spam (Google Apps Script)
  1. Go to https://script.google.com
  2. Create a New Project
  3. Replace the Code.gs file it creates for you with the javascript below (copy/paste)
  4. Save the script
  5. Go to Triggers (looks like an alarm clock on left-hand side)
  6. Create a Trigger that acts every 10 minutes and calls filterNGPVANSpam
  7. You'll need to authorize this script to act on your behalf, which may require that you use the scary "Advanced" section to allow the script to read/write to your email inbox.
@jonathanhle
jonathanhle / command line apple script osascript
Created October 13, 2023 15:31
command line apple script osascript
osascript <<END
tell application "System Events"
delay 0.5
keystroke space using command down
delay 0.5
set textBuffer to "TextEdit"
repeat with i from 1 to count characters of textBuffer
keystroke (character i of textBuffer)
delay 0.05
@jonathanhle
jonathanhle / Okta Group Rule Expression for Contains
Created October 11, 2023 19:46
Okta Group Rule Expression for Contains
user.userType=="EMPLOYEE" and (String.stringContains(user.title,"Software Engineer") or String.stringContains(user.title,"Software Developer") or String.stringContains(user.title,"Frontend Engineer") or String.stringContains(user.title,"Mobile Engineer") or String.stringContains(user.title,"Distinguished Engineer"))
@jonathanhle
jonathanhle / PokeAPI-based Coding Test Practice.md
Last active October 13, 2023 04:05
PokeAPI-based Coding Test Practice

PokeAPI-based Coding Test Practice

Environment:

  • Programming Language: Python (or your preferred language)
  • Libraries allowed: requests, json

Problem 1: Basic API Request (Easy)

Problem Statement:

@jonathanhle
jonathanhle / gist:a7fa989d5dedbcde4729e405c5754de3
Last active September 13, 2023 00:05
Quick loop through SGs to update them with a new CIDR, if there's an existing one. Only dealing with untagged SGs that are probably ClickOps
import boto3
# Initialize boto3 client
ec2 = boto3.client('ec2')
# CIDRs to check
EXISTING_CIDRS = ["1.2.3.4/32", "5.6.7.8/32"]
NEW_CIDR = '10.11.12.13/22'
# Create a paginator for the describe_security_groups method
@jonathanhle
jonathanhle / clear-google-drive-trash.py
Last active June 6, 2023 23:52
Google "Desktop" App Python Script to Delete Specific Files from Google Drive Trash
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
import os
import pickle
# If modifying these SCOPES, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/drive']
@jonathanhle
jonathanhle / delete_all_object_versions.sh
Created June 1, 2023 22:30 — forked from weavenet/delete_all_object_versions.sh
Delete all versions of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
bucket=$1
set -e
echo "Removing all versions from $bucket"
versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions'`
markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'`
@jonathanhle
jonathanhle / nextdns spec code
Created May 16, 2023 18:27
nextdns spec code
# This is some horrible stuff, but just quickly jotting stuff down to show it's possible to automate the nextdns API with LinkedIP setup, including profile creation
import requests
from nextdnsapi.api import account, settings
from shell import shell
from ifconfigparser import IfconfigParser
header = account.login("account.name@company.com", "some-pass-word")