Skip to content

Instantly share code, notes, and snippets.

Avatar

Wil Koch wil3

View GitHub Profile
View checkpoint_to_pb.py
import os, argparse
import tensorflow as tf
"""
This script converts a checkpoint to a pb file without needing to know
the names of the input and output nodes. This then allows you to use the
Tensorflow tool summarize_graph to identify potential input/output nodes.
Usage:
@wil3
wil3 / run_gymfc.py
Created Oct 16, 2018
Test of GymFC working with latest OpenAI baselines master branch
View run_gymfc.py
#!/usr/bin/env python3
import os
from baselines.common import tf_util as U
from baselines import logger
import gymfc
import argparse
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
View hash-tput.py
"""
Purpose:
This python script is meant to introduce you to parellel processing with
threads and processes. The example uses a simple worker than randomly selects
a letter and continually hashes this value. This demonstrates two methods for
creating a thread, (1) by specifying a target function or (2) inheriting
threading.Thread.
This lesson also shows that the Thread and Process API are (for the most part)
interchangable allowing us to simply replace threading.Thread with multiprocessing.Process
View http-server-events.py
""" Demo creating a simple webserver and using a pub/sub design pattern
to have handlers for the request url to do work off the critcal path. This could
for example be used to process data analytics.
The publisher uses the callback to signal to the subscriber data has changed.
Conditions are used to ensure subscribers are not reading data while it is being
written. This allows the sublisher to wait (sleep) until the publisher wakes
them up to process an event. See docs for more information on Conditions,
https://docs.python.org/2/library/threading.html#condition-objects
@wil3
wil3 / produce-consume.py
Created Nov 10, 2017
Python 2 Producer/Consumer demonstration
View produce-consume.py
"""
Introduce producer/consumer model with thread safe queues
This demo can be first illustrated as an M/M/K queue in which we have incoming
messages at some rate added to a single queue, each consumer thread will
continually get and process items from the queue.
This is to demonstrate tradeoffs with the queue size, and number
View s3b_reg.py
import requests, time, sys, random, string
from urlparse import urlparse
from time import sleep
import argparse
#import subprocess
class MeasureBoot:
def __init__(self):
self.current_token = None
View entropy.py
import gzip, os, shutil
import cStringIO
from optparse import OptionParser
"""
Calculate the average entropy of files in the given directories
"""
def entropy(f):
@wil3
wil3 / ga_string.py
Created Apr 12, 2015
Genetic algorithm to evolve strings
View ga_string.py
#!/usr/bin/env python
__author__ = "William Koch"
import re
import sys
import random
import numpy
from deap import algorithms
from deap import base
from deap import creator
from deap import tools
View keybase.md

Keybase proof

I hereby claim:

  • I am wil3 on github.
  • I am wilkoch (https://keybase.io/wilkoch) on keybase.
  • I have a public key whose fingerprint is A13D 0086 FCEF 07F0 2B68 92EF 6AE1 45AF FEC0 1E3C

To claim this, I am signing this object:

@wil3
wil3 / sendgmail.py
Last active Aug 29, 2015
Send an email from your Gmail account using Python
View sendgmail.py
#!/usr/bin/env python
"""Send an email with your Gmail account
"""
import smtplib
__author__ = "William Koch"
class SendGmail: