Skip to content

Instantly share code, notes, and snippets.

View jonathanhle's full-sized avatar

Jonathan Le jonathanhle

View GitHub Profile
@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("[email protected]", "some-pass-word")
@jonathanhle
jonathanhle / umbrella_dns_changer for osx
Last active May 12, 2023 03:10
umbrella_dns_changer for osx
#!/bin/bash
# -----------------------------------------------------------
# Get installed OSX Network Devices and then list the ones with Active Internet Connections
# -----------------------------------------------------------
InstalledHardware=$(networksetup -listallhardwareports | grep Device | awk '{print $2}')
ActiveInterfaces=$(ifconfig | pcregrep -M -o '^[^\t:]+(?=:([^\n]|\n\t)*status: active)')
# -----------------------------------------------------------
# Get list of active network devices
@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 / _Library_LaunchAgents_com.twingate.macos.plist
Created April 28, 2023 13:55
Keep Twingate Client running on OSX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>network</key>
<string>some-kind-of-twingate-network</string>
@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 / Pokemon API Paginator
Last active April 26, 2023 08:56
Quick paginator using requests_paginator for the Pokemon API
###### Method 1
from requests_paginator import RequestsPaginator
BASE = 'https://pokeapi.co/api/v2/pokemon'
def get_next_page(page):
body = page.json()
if body['next']:
return body['next']
return None
@jonathanhle
jonathanhle / Internal Policy on ChatGPT Usage Example.md
Last active June 6, 2023 04:00
Internal Policy on ChatGPT Usage Example

Internal Policy on ChatGPT Usage

1. Introduction

This document outlines the internal policy for using ChatGPT, an AI language model developed by OpenAI. The purpose of this policy is to provide guidance on the responsible and secure use of ChatGPT within our organization while mitigating the risk of exposing sensitive information.

2. Scope

This policy applies to all employees who access and use ChatGPT for work-related purposes, including but not limited to communication, data analysis, document generation, and research.