Skip to content

Instantly share code, notes, and snippets.

View nloadholtes's full-sized avatar
👍
here

Nick Loadholtes nloadholtes

👍
here
View GitHub Profile
@nloadholtes
nloadholtes / main.clj
Created December 14, 2018 00:38
IntrepidSubduedDatasets created by nloadholtes - https://repl.it/@nloadholtes/IntrepidSubduedDatasets
;; Enter your code here. Read input from STDIN. Print output to STDOUT
;;
;;
;; Sample data
;;
;;4
;;0 0
;;0 1
;;1 1
;;1 0
@nloadholtes
nloadholtes / data.txt
Created December 14, 2018 00:36
AliceblueMiniModularity created by nloadholtes - https://repl.it/@nloadholtes/AliceblueMiniModularity
Step G must be finished before step X can begin.
Step X must be finished before step B can begin.
Step A must be finished before step I can begin.
Step D must be finished before step H can begin.
Step O must be finished before step T can begin.
Step H must be finished before step C can begin.
Step S must be finished before step E can begin.
Step U must be finished before step M can begin.
Step M must be finished before step Z can begin.
Step R must be finished before step N can begin.
@nloadholtes
nloadholtes / stoic-inspiration-emails.py
Created February 25, 2018 20:35
The script I am using to generate daily emails for my Stoic Inspiration mailing list.
from mailchimp3 import MailChimp
import os
import sys
import datetime
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import random
from functools import partial
import json
@nloadholtes
nloadholtes / file_copy.py
Created December 31, 2017 22:01
Example of using argparse with dashes in the variable names
import argparse
def copyfiles(src, dest):
print("Copying from %s to %s" % (src, dest))
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("src_dir", metavar="src-dir", help="Where we are copying from")
@nloadholtes
nloadholtes / logging-handler.py
Created October 1, 2017 17:51
Using MagicURL in a logging handler
from logzio.handler import LogzioHandler
import logging
logger = logging.getLogger(__name__)
logz_handler = LogzioHandler(url=MagicURL("https://example.com/logging"))
logger.addHandler(logz_handler)
@nloadholtes
nloadholtes / magic_url.py
Created October 1, 2017 17:44
Create a URL based on today's date
from datetime import datetime
class MagicURL(object):
def __init__(self, base_url):
self.base_url = base_url
def __str__(self):
today = datetime.today()
return self.base_url + "/" + today.strftime("%Y-%m-%d")
@nloadholtes
nloadholtes / argparser-surprise.py
Created September 15, 2017 21:23
How to get argparse to use dashes in positional arguments
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("table_name", metavar="table-name", help="blah", default=None)
parser.add_argument("--start-ts", help="blah2", default=None)
settings = parser.parse_args()
import pdb; pdb.set_trace()
print("goodbye")
@nloadholtes
nloadholtes / setup.py
Created July 15, 2017 20:25
An example of using the git hash/tag as a version number
from setuptools import setup, find_packages
import subprocess
def _get_version_hash():
"""Talk to git and find out the tag/hash of our latest commit"""
try:
p = subprocess.Popen(["git", "describe",
"--tags", "--dirty", "--always"],
stdout=subprocess.PIPE)
except EnvironmentError:
def wat(my_input_list):
my_output_list = []
for x in my_input_list:
if isinstance(x, basestring):
#Why are we getting strings!?!?!
continue
output = process_stuff(x)
my_input_list.append(output)
return my_output_list
@app.route("/self-driving-car")
def self_drive_car_overview():
return render_template("sdc-why.template.html")