Skip to content

Instantly share code, notes, and snippets.

BrandonLMorris / Dockerfile
Created March 15, 2016 18:57
Dockerized Flask Example
FROM ubuntu:14.04
# Install Python Setuptools
RUN apt-get install -y python-setuptools
# Install pip
RUN easy_install pip
# Add and install Python Modules
ADD requirements.txt /src/requirements.txt
BrandonLMorris /
Created October 12, 2018 14:48
A no-frills working implementation of a convolutional neural network in pure PyTorch
from absl import app, flags
import torch
from torch import nn
import torch.nn.functional as F
from torchvision.datasets import FashionMNIST
from torchvision.transforms import Compose, ToTensor
from import DataLoader
dev = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
BrandonLMorris /
Created October 9, 2018 23:26
Deep Q-learning example to play Doom with PyTorch
#!/usr/bin/env python3
Brandon L Morris
Adapted from work by E. Culurciello
from absl import app, flags
import itertools
from random import sample, randint, random
BrandonLMorris /
Created September 9, 2017 16:38
TensorFlow MNIST classifier example, adopted from
from tensorflow.examples.tutorials.mnist import input_data
import tensorflow as tf
import argparse
import os
import matplotlib.pyplot as pyplot
EPOCHS = 5000
SAVE_PATH = 'mnist-cnn-model.cpkt'
pid name appeared
1 Alchemy 2014 Southeast
2 Balloons 2010 Southeast
3 Bit Counting 2010 Southeast
4 Black Vienna 2009 Mid-Central
5 Block Game 2009 Southeast
6 Bounce 2012 Mid-Central
7 Bulletin Board 2008 Mid-Central
8 Burnout 2011 Southeast
9 Underground Cables 2010 Southeast
import sys
from time import time
from app import database
from app.modules.user_manager import models as user
# Query once, filter each time
t = time()
q = database.session.query(user.User)
"""A simple example of using unittest.mock to patch a function in a test"""
import unittest
from unittest.mock import patch
def f(x):
return 2**x
def g(y):
retrun f(y % 15)


auacm-cli is a command line tool that can be used to interact with the api through the terminal. The general command is auacm will subcommands for interacting with particular facets of the site.


  • [none] for general information
  • login/logout
  • problem
  • submit
  • comp[etition[s]]
Simple example of currying and creating higher-order functions
in Python.
Taken from
def curry2(f):
BrandonLMorris /
Created February 12, 2016 14:54
Demonstrating a gotcha of Python mutable types
Simple demonstration of the gotcha that can occur in Python with mutable
types being shared across instances of a class
Taken with slight modification from the Python Guide
(The same thing applies to default arguments)