Skip to content

Instantly share code, notes, and snippets.

@bluejack
bluejack / lsync
Created January 15, 2024 14:47
Sync local directory to S3 bucket
#!/bin/bash
## Conventions:
##
## Working directory has the same name as the s3 bucket.
## Script is executed from the parent of this directory.
##
BUCKET=$1
function authorize_api_usage(client_id, scope, user) {
return new Promise((res,rej) => {
const token_client = google.accounts.oauth2.initTokenClient({
client_id,
scope,
hint: user.email,
callback: (response) => {
if (!response.access_token) {
return rej('authorization-failed');
}
function onetap(cb) {
function _handle_prompt_events(event) {
if (event.isNotDisplayed()) {
if (event.getNotDisplayedReason() === 'suppressed_by_user') {
window.localStorage.removeItem('gothic-id');
cb('onetap-suppressed');
}
}
if (event.isSkippedMoment()) {
async function on_response(response) {
if (response && response.credential) {
const rawdata = jwt_decode(response.credential);
const user = (({ email, family_name, given_name, picture, name }) => ({ email, family_name, given_name, picture, name}))(rawdata);
window.localStorage.setItem('gothic-id', 'loaded');
}
// leverage user object or move on to next step.
}
function button(parent_id, params = {}) {
const container = document.getElementById(parent_id);
const options = {
type: 'standard',
theme: 'outline',
size: 'medium',
shape: 'pill',
...params,
function load_libaries(client_id, api_key, discovery) {
let goog_ready = false;
let gapi_ready = false;
let pass;
let fail;
let ready = new Promise((res, rej) => {
pass = res;
Rating Range Level
2800+ World Champion
2600+ Grandmaster
2400+ International Master
2200+ Master
2000+ Expert
1600+ Club player
1300+ Amateur
1000+ Casual
under 1000 Beginner
ELO USCF FIDE
2600 Grandmaster*
2400 and up Senior Master International Master*
2300 Fide Master
2200 National Master Candidate Master
2000 Expert
1800 Class A
1600 Class B
1400 Class C
1200 Class D
service free tier paid req paid duration/storage
API Gateway (12 Months) 1M free $1.00/1M N/A
Lambda (Always) first 1M free; 400k Gb/s $0.20/1M $0.000016667 Gb/s
DynamoDB (Always) first 25G free; 200M $1.25 1M write;$0.25 1M read $0.25/Gb
#!/bin/bash
## Conventions:
##
## Working directory has the same name as the s3 bucket.
## Script is executed from the parent of this directory.
##
BUCKET=$1