This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REQUIRED := python3.11 curl | |
$(foreach bin,$(REQUIRED),\ | |
$(if $(shell command -v $(bin) 2> /dev/null),,$(error Please install `$(bin)`))) | |
REPOSITORY_ROOT := $(PWD) | |
.poetry/bin/poetry: ## install poetry | |
@curl -sSL https://install.python-poetry.org | POETRY_HOME=$(REPOSITORY_ROOT)/$(shell basename $(dir $(abspath $(dir $(@))))) python3.11 - --version=1.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
All environment variable access should be performed via this module. | |
- allows tracing of where variables are used | |
- provide sensible defaults | |
- reduce string typos | |
Declare env vars below with default values. | |
""" | |
import os | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Logging for the project.""" | |
import json | |
import logging | |
class JsonFormatter(logging.Formatter): | |
"""Formatter that outputs JSON strings after parsing the LogRecord. | |
Notes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: help | |
help: | |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | |
help: ## Print this help message | |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' | |
help: ## Show this help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://tunzor.github.io/posts/docker-list-images-by-size/ | |
docker image ls --format "{{.Repository}}:{{.Tag}} {{.Size}}" | \ | |
awk '{if ($2~/GB/) print substr($2, 1, length($2)-2) * 1000 "MB - " $1 ; else print $2 " - " $1 }' | \ | |
sed '/^0/d' | \ | |
sort -n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UNAME_S := $(shell uname -s) | |
UNAME_M := $(shell uname -m) | |
ifeq ($(UNAME_S),Darwin) | |
OS := darwin | |
else | |
OS := linux | |
endif | |
ifeq ($(UNAME_M),x86_64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin/cue: | |
$(eval TMP := $(shell mktemp -d)) | |
$(eval TARFILE := cue.tar.gz) | |
if [[ $$OSTYPE == 'darwin'* ]]; then wget 'https://github.com/cue-lang/cue/releases/download/v0.5.0-alpha.1/cue_v0.5.0-alpha.1_darwin_amd64.tar.gz' -O $(TMP)/$(TARFILE); fi | |
@tar -xf $(TMP)/$(TARFILE) -C $(@D) cue* | |
rm -rf "$(TMP)" | |
@echo "Installed $@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import math, random, copy | |
CASEID = 'respid' | |
PATH = '/Users/bridgetlittleton/Box Sync/WWB/Survey Data - CONFIDENTIAL/WWB_Main_Survey_Data_20210629.xls' | |
profpos_mapping = {'Research scientist or similar [INDIA/UK/USA]': 'j', | |
'Masters / Ph.D. student [ITALY]': 'g', | |
'Masters / Ph.D. student [INDIA/UK/USA]': 'g', | |
'Assistant Professor / Lecturer [INDIA/UK/USA]': 'j', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
import re | |
regex = 'assert_true[(]((.|\s)*)[)]' | |
class MultiAssert: | |
def __init__(self): | |
self.checks = [] | |
@staticmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
import json | |
import oauth2 # https://raw.github.com/brosner/python-oauth2/master/oauth2/__init__.py | |
from pprint import pprint | |
import urllib2 | |
stream_url = "https://stream.twitter.com/1/statuses/filter.json" |