Skip to content

Instantly share code, notes, and snippets.

@sirosen
sirosen / click_decorator.py
Last active January 2, 2023 15:29
click annotation validation
import typing as t
import click
def deco(f):
f = click.option("--foo")(f)
f = click.option("--bar", type=int)(f)
return f
@sirosen
sirosen / trigger-globus-search-rate-limit.py
Last active April 2, 2021 16:31
Trigger the Globus Search Rate Limit
#!/usr/bin/env python3
"""
Intentionally trigger rate limiting within Globus Search.
This script runs a request loop, up to a maximum of N, until a rate limiting
error is reached. If given an access token, it will make authenticated calls.
Without an access token, it makes unauthenticated calls.
"""
import argparse
import json
@sirosen
sirosen / get-subscription-ids.py
Created August 13, 2020 15:11
get-subscription-ids from Globus Transfer
#!/usr/bin/env python3
import sys
import globus_sdk
CLIENT_ID = "5f50cf96-04f9-4223-97f7-7d288d132b34"
UUIDLEN = len(CLIENT_ID)
@sirosen
sirosen / copy-globus-acls.py
Last active July 27, 2020 13:53
Copy Globus Endpoint ACL Script
#!/usr/bin/env python3
"""
Copy all of the Access Control Lists from one Globus Endpoint to another, by
means of the globus-cli
This will not remove any ACLs from either endpoints and it will not stop to
check for duplicates
"""
import argparse
import json
@sirosen
sirosen / scrape-acls.sh
Created July 17, 2020 15:59
globus-cli acl scraping example
#!/bin/bash
# substitute your own Endpoint ID here
EP_ID="SET ME"
# use text output, and scrape the header off with tail
# grep -v "^NULL" removes rules with no ID -- these are cases where a
# permission is granted via a role (e.g. administrator), not an ACL rule we
# could recreate
@sirosen
sirosen / ClientCredentialsExample.java
Created July 16, 2020 18:22
Java Client Credentials Grant Example
/*
* A simple example of a Client Credentials Grant against Globus Auth
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import javax.net.ssl.HttpsURLConnection;
import java.net.URL;
@sirosen
sirosen / ascii_server_timing.py
Created July 8, 2020 14:41
ASCII art server timing bar graph from response object
"""
Parse and display Server-Timing header info
"""
import shutil
def timing_string_to_dict(server_timing_string):
"""
Given a Server Timing value as a string, parse it into a dict of the format
@sirosen
sirosen / gruvbox.js
Last active April 10, 2019 14:39
hterm color profiles
[
"#cc241d",
"#98971a",
"#d79921",
"#458588",
"#b16286",
"#689d6a",
"#7c6f64",
"#928374",
"#9d0006",
@sirosen
sirosen / vimrc
Created April 8, 2019 21:17
vimrc autodetect py_autoformat
" ALE conf
let g:ale_fixers = {
\ '*': [],
\ 'python': ['isort', 'black'],
\}
let g:airline#extensions#ale#enabled = 1
" if a '.__py_autoformat' file is in the cwd or a parent of the cwd, enable ALE fix_on_save and tune for black
augroup py_ft
au!
@sirosen
sirosen / output.txt
Last active November 6, 2018 16:20
reproduce click #1134
$ python test.py
in dummy_transaction pre-yield
going critical
in dummy_transaction except clause