Skip to content

Instantly share code, notes, and snippets.

View wsanchez's full-sized avatar

Wilfredo Sánchez Vega wsanchez

View GitHub Profile
"""
To test, run:
python3.8 -m venv /tmp/e
/tmp/e/bin/pip install attrs twisted mypy
/tmp/e/bin/mypy test.py
Mypy output:
@wsanchez
wsanchez / okta.py
Last active February 26, 2021 18:42
Okta (Asyncio) + Twisted
##
# See the file COPYRIGHT for copyright information.
##
"""
Burning Man Profiles CLI
"""
from asyncio import ensure_future
from functools import partial, update_wrapper
_fetchJSON = async (url, json=null, headers={}) => {
if (headers["Content-Type"] === undefined) {
headers["Content-Type"] = "application/json";
}
else if (headers["Content-Type"] !== "application/json") {
throw new Error(`Not JSON content-type: ${headers["Content-Type"]}`);
}
const requestHeaders = new Headers(headers);
const requestOptions = { mode: "no-cors", headers: requestHeaders }
function check_all_on_page() {
for (const checkbox of document.getElementsByClassName("checkbox")) {
if (checkbox.checked == false) {
checkbox.click();
}
}
}
function open_approve_dialog() {
const approve = document.getElementById("utility_6f7351657f795bc1357a53142b1184cc");
from typing import Iterable, Optional
from alchimia.engine import TwistedEngine
from attr import Factory, attrib, attrs
from sqlalchemy import create_engine
from sqlalchemy.schema import Column, MetaData, Table
from sqlalchemy.types import String
@wsanchez
wsanchez / foo.py
Last active March 6, 2017 22:08
Private mutable state
@attrs(frozen=True)
class Foo(object):
"""
Something Foo-y
"""
@attrs(frozen=False)
class _State(object):
"""
Internal mutable state for Foo.
#!/bin/sh
set -e
set -u
# Too lazy for proper options parsing
PR_NUMBER="$1"; shift;
TICKET_NUMBER="$1"; shift;
@wsanchez
wsanchez / optional.py
Created July 15, 2016 17:08
Python Optional
"""
Optional.
"""
from __future__ import print_function
_novalue = object()
@wsanchez
wsanchez / keybase.md
Created October 26, 2015 21:00
Keybase proof

Keybase proof

I hereby claim:

  • I am wsanchez on github.
  • I am wsanchez (https://keybase.io/wsanchez) on keybase.
  • I have a public key whose fingerprint is 124D E808 15F7 0030 DEB0 5C9E EADE 6D48 EDA0 87B4

To claim this, I am signing this object: