Skip to content

Instantly share code, notes, and snippets.

View evanmiltenburg's full-sized avatar

Emiel van Miltenburg evanmiltenburg

View GitHub Profile
@evanmiltenburg
evanmiltenburg / json_argument_example.py
Last active April 18, 2016 20:00
Proposal for serialising arguments
import argparse
import json
def get_parser():
"Get an argument parser for this module."
parser = argparse.ArgumentParser(
description="Train an word embedding model using LSTM network")
parser.add_argument("--run_string", default="", type=str,
help="Optional string to help you identify the run")
@evanmiltenburg
evanmiltenburg / colorcombos.py
Created June 12, 2015 23:09
Script to easily obtain lists of RGB tuples from a .txt file containing URLs from colorcombos.com
from urlparse import urlparse
import colorsys, sys
def keyword_tuples(query):
"""Create (keyword,value) tuples for the query."""
return map(lambda x:tuple(x.split('=')), query.split('&'))
def get_colors(url):
"""Get colors from the URL, returns a list of hex color values (without #)"""
result = urlparse(url)
# modified from: https://gist.github.com/dellis23/6174914/
# - Added NLTK, which simplifies the chain and ngram logic.
# To use this script, you need to have downloaded the punkt
# data like this:
#
# import nltk
# nltk.download('punkt')
#
# - No more occasional KeyErrors.