Skip to content

Instantly share code, notes, and snippets.

View jnalley's full-sized avatar

Jon Nalley jnalley

View GitHub Profile
@jnalley
jnalley / cdp.py
Last active September 30, 2020 16:52
Use client.py from cdpcli to make direct API calls
import platform
from cdpcli.client import ClientCreator, Context
from cdpcli.endpoint import EndpointCreator, EndpointResolver
from cdpcli.loader import Loader
from cdpcli.parser import ResponseParserFactory
from cdpcli.retryhandler import create_retry_handler
from cdpcli.translate import build_retry_config
import gspread
from gspread_dataframe import get_as_dataframe
from oauth2client.service_account import ServiceAccountCredentials
class GoogleSheets:
def __init__(self, credentials):
scope = ["https://www.googleapis.com/auth/drive"]
self.gc = gspread.authorize(
@jnalley
jnalley / singleton.py
Created February 1, 2020 01:10
A singleton "like" Python snippet using lru_cache
#!/usr/bin/env python3
from functools import lru_cache
class Singleton:
@lru_cache
def __new__(cls, *args, **kwargs):
return super().__new__(cls)
@jnalley
jnalley / entrypoint.sh
Created December 13, 2019 19:54
Airflow docker entrypoint.sh
#!/usr/bin/env bash
readonly AIRFLOW_SETUP_DIR='/usr/local/airflow'
readonly HOST_PORT_REGEX='(@|//)([^:]+):([0-9]+)'
die() { echo -e "$*" ; exit 1 ; }
wait_for_port() {
local i
local name=${1}
#!/usr/bin/env python3
from __future__ import print_function
import os
import sys
from airflow import settings
from airflow.models import Connection
from sqlalchemy.orm import exc
@jnalley
jnalley / setup.sh
Created October 4, 2017 16:16
Debian Setup Script
#!/usr/bin/env bash
DOTFILES='https://github.com/jnalley/dotfiles.git'
export DEBIAN_FRONTEND=noninteractive
rm -vf /etc/apt/sources.list \
/etc/apt/sources.list.d/*.list
cat > /etc/apt/preferences.d/security.pref <<EOF