Skip to content

Instantly share code, notes, and snippets.

View jonathanhle's full-sized avatar

Jonathan Le jonathanhle

View GitHub Profile
@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 / 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 / prepare_ubuntu_template.sh
Created May 9, 2023 06:32 — forked from reluce/prepare_ubuntu_template.sh
Prepare Ubuntu 22.04 Cloud Image and Template for Proxmox
# All commands will be executed on a Proxmox host
sudo apt update -y && sudo apt install libguestfs-tools -y
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
# Install qemu-guest-agent on the image. Additional packages can be specified by separating with a comma.
sudo virt-customize -a jammy-server-cloudimg-amd64.img --install qemu-guest-agent
# Read and set root user password from file.
sudo virt-customize -a jammy-server-cloudimg-amd64.img --root-password file:password_root.txt
# Create an additional user.
sudo virt-customize -a jammy-server-cloudimg-amd64.img --run-command "useradd -m -s /bin/bash myuser"
# Set password for that user.
@jonathanhle
jonathanhle / umbrellactl
Created May 4, 2023 23:29 — forked from jasmas/umbrellactl
umbrellactl: Bash script to check status, enable or disable Cisco Umbrella Roaming Security Module for AnyConnect on MacOS
#!/usr/bin/env bash
PLUGIN_BASE='/opt/cisco/secureclient/bin/plugins'
read -r -d '' USAGE << EGASU
Usage: `basename $0` [-s|-e|-d|-h]
-s, --status Print Umbrella Roaming Security module status
-e, --enable Enable Umbrella Roaming Security module
-d, --disable Disable Umbrella Roaming Security module
@jonathanhle
jonathanhle / Using paginated APIs (4 ways!).ipynb
Created April 26, 2023 08:14 — forked from jsoma/Using paginated APIs (4 ways!).ipynb
Paginated APIs with Python: Four ways!
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jonathanhle
jonathanhle / GoogleAuthenticationCurl.sh
Created March 16, 2023 13:54 — forked from LindaLawton/GoogleAuthenticationCurl.sh
Curl bash script for getting a Google Oauth2 Access token
# Tutorial https://www.daimto.com/how-to-get-a-google-access-token-with-curl/
# YouTube video https://youtu.be/hBC_tVJIx5w
# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.
# Authorization link. Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=http://127.0.0.1&scope=[Scopes]&response_type=code
# Exchange Authorization code for an access token and a refresh token.
# sh -c "$(curl -fsSL https://gist.githubusercontent.com/gjgd/5a08da85a98bf147294f331461e44d1f/raw/a63bf0f4169a8ab651adfa0a56e676e6bc465876/setup-github-action-runner.sh)"
# Update instance
sudo apt update -y
sudo apt upgrade -y
# Install latest version of git
sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
import asyncio
from typing import Coroutine, List, Sequence
def _limit_concurrency(
coroutines: Sequence[Coroutine], concurrency: int
) -> List[Coroutine]:
"""Decorate coroutines to limit concurrency.
Enforces a limit on the number of coroutines that can run concurrently in higher