Skip to content

Instantly share code, notes, and snippets.

View AndBondStyle's full-sized avatar

Andrew AndBondStyle

View GitHub Profile
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import numpy as np
def plot_grad_flow(model):
ave_grads = []
max_grads = []
layers = []
for name, param in model.named_parameters():
@AndBondStyle
AndBondStyle / environ.py
Created January 3, 2020 12:22
[Python] Read environment variables from .env file
import urllib.parse as urlparse
from envparse import Env
import json as pyjson
import warnings
import os
def shortcut(cast):
# Fix: `default` kwarg is always second argument
# So you can do `env.whatever('KEY', 'DEFAULT')`
@AndBondStyle
AndBondStyle / Dockerfile
Last active November 5, 2019 18:57
Docker build from local git repository
# Bootstrap image
FROM alpine:latest as bootstrap
LABEL stage=bootstrap
WORKDIR /tmp
COPY . .
RUN apk update && apk add --update git
RUN git archive HEAD -v -o files.tar
RUN mkdir files && tar xf files.tar -C files
@AndBondStyle
AndBondStyle / server.py
Last active March 8, 2018 21:43
Single-file Django server
from django.template.backends.django import DjangoTemplates
from django.core.wsgi import get_wsgi_application
from django.core.management import call_command
from os.path import basename, dirname
from django.shortcuts import render
from django.conf import settings
from django.urls import path
@AndBondStyle
AndBondStyle / config-highlight.cfg
Last active May 31, 2021 01:00
PyCharm's Darcula theme for Python's IDLE IDE
[Darcula]
normal-foreground = #A9B7C6
normal-background = #2B2B2B
definition-foreground = #A9B7C6
definition-background = #2B2B2B
keyword-foreground = #CC7832
keyword-background = #2B2B2B
builtin-foreground = #8888C6
builtin-background = #2B2B2B
string-foreground = #008080