Skip to content

Instantly share code, notes, and snippets.

View testsubcommand.py
import sys
import argparse
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument('command', choices=['userpath'])
parser.add_argument('--verbose')
parser.add_argument('--flag', action='store_true', default=False)
@AlJohri
AlJohri / sample_sqlalchemy_reflection.py
Created Apr 9, 2019
sample usage of sqlalchemy reflection to load tables hooks to print queries as they happen
View sample_sqlalchemy_reflection.py
"""
http://docs.sqlalchemy.org/en/latest/core/tutorial.html
"""
import time
import logging
import logging.config
import warnings
import sqlparse
from functools import partial
View cache_structure.txt
cache
├── aylien.sqlite
├── clavis.sqlite
├── google.sqlite
├── google_search.sqlite
├── joblib
│   └── joblib
│   └── lib
│   └── utils
│   └── translate
View dvc-reset-checksum.py
#!/usr/bin/env python
import sys
from dvc.project import Project
from dvc.stage import Stage
stage_file = sys.argv[1]
dvc = Project()
with dvc.state:
View scrape_presidential_debates.py
import requests
from bs4 import BeautifulSoup
url = 'https://www.presidency.ucsb.edu/documents/presidential-documents-archive-guidebook/presidential-candidates-debates-1960-2016'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
for tr in soup.select('.field-body > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr'):
columns = tr.select('td')
if len(columns) == 1: continue
View clokta_1pass_totp_integration.md
  1. Install 1Password CLI and jq.

    brew install jq
    brew cask install 1password-cli
    
  2. Sign in to 1Password for the first time:

View gdrive.py
# pip install google-api-python-client
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
SCOPES = 'https://www.googleapis.com/auth/spreadsheets'
store = file.Storage('credentials.json')
creds = store.get()
if not creds or creds.invalid:
View downloader.py
import os
import time
import arrow
import requests
API = "https://projects.fivethirtyeight.com/election-night-api/tests/default/projected_winners.json"
NUM_TIMES = 4
TIME_TO_SLEEP = int(60/NUM_TIMES)
View dailykos.py
import io
import us
import csv
import itertools
import requests
import pandas as pd
import numpy as np
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."