Skip to content

Instantly share code, notes, and snippets.

Kevin Ashcraft kevashcraft

Block or report user

Report or block kevashcraft

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kevashcraft
kevashcraft / TFDataset-Take.py
Created Feb 7, 2020
Iterating Through TF Dataset
View TFDataset-Take.py
# if dataset is not batched
# this will take 1 example
with (ambient, target), label in dataset.take(1):
print("ambient shape", ambient.shape)
print("target shape", target.shape)
print("label shape", label.shape)
ambient_array = ambient.numpy()
target_array = target.numpy()
label_array = label.numpy()
@kevashcraft
kevashcraft / Read-TFRecord.py
Created Feb 7, 2020
Read TFRecord File into TF Dataset
View Read-TFRecord.py
# Read a TFRecord file into a TF Dataset
def map_fn(serialized_example):
feature = {
'label': tf.io.FixedLenFeature([1], tf.int64),
'ambient': tf.io.FixedLenFeature([16000], tf.float32),
'target': tf.io.FixedLenFeature([4000], tf.float32)
}
example = tf.io.parse_single_example(serialized_example, feature)
ambient = tf.expand_dims(example['ambient'], 1)
target = tf.expand_dims(example['target'], 1)
@kevashcraft
kevashcraft / TFRecord-Writer.py
Last active Feb 7, 2020
Writing a TFRecord File
View TFRecord-Writer.py
# Write a ambient, target, and label data to a TFRecords file
with tf.io.TFRecordWriter('examples.tfrecord') as training_file:
for ambient, target, label in batch: # batch is a list of (ambient, target, label) tuples
features = {
'label': tf.train.Feature(int64_list=tf.train.Int64List(value=[label])),
'ambient': tf.train.Feature(float_list=tf.train.FloatList(value=ambient.tolist())), # ambient is a 1-D np array
'target': tf.train.Feature(float_list=tf.train.FloatList(value=target.tolist())) # target is a 1-D np array
}
example_proto = tf.train.Example(features=tf.train.Features(feature=features))
training_file.write(example_proto.SerializeToString())
@kevashcraft
kevashcraft / TFrecord-Reader.py
Created Feb 4, 2020
Reading a TFRecord File
View TFrecord-Reader.py
label_size = 1 # the length of the previously written label
feature_size = 256 # the length of the previously written feature lists
def map_fn(serialized_example):
feature = {
'label': tf.io.FixedLenFeature([label_)size], tf.int64),
'features': tf.io.FixedLenFeature([feature_size], tf.float32)
}
example = tf.io.parse_single_example(serialized_example, feature)
features = example['features']
label = tf.cast(example['label'], tf.int32)
@kevashcraft
kevashcraft / TFRecord-Writer.py
Last active Feb 4, 2020
Writing a TFRecord File
View TFRecord-Writer.py
with tf.io.TFRecordWriter('examples.tfrecord') as training_file:
for features, label in batch:
features = {
'label': tf.train.Feature(int64_list=tf.train.Int64List(value=[label])),
'features': tf.train.Feature(float_list=tf.train.FloatList(value=features)) # expects list, so if numpy use .tolist() and ensure it's 1-D
}
example_proto = tf.train.Example(features=tf.train.Features(feature=features))
training_file.write(example_proto.SerializeToString())
@kevashcraft
kevashcraft / favicon.sh
Created Jul 11, 2019
Create ico from png
View favicon.sh
convert logo.png -define icon:auto-resize=64,48,32,16 logo.ico
View ad-muter.js
clearInterval(aa)
function mv() {
var found_one = false
var primary = 0
let el = document.querySelectorAll('.mlbtv-media-player')[primary]
let has_ads = !!el.querySelector('.interruption-link')
if (!has_ads) {
el.querySelector('video').muted = false
@kevashcraft
kevashcraft / retrieve.py
Created Jun 18, 2018
Retrieve Stock Market Data from the AlphaVantage API
View retrieve.py
from urllib.request import urlopen
import yaml
def retrieve(symbol=None):
with open('config.yml') as f:
config = yaml.load(f)
params = {
'function': 'TIME_SERIES_DAILY',
'symbol': symbol,
@kevashcraft
kevashcraft / K8s-DigitalOcean-CoreOS.md
Last active Jan 28, 2020
How to Setup Kubernetes on DigitalOcean with CoreOS
View K8s-DigitalOcean-CoreOS.md

Kubernetes on DigitalOcean with CoreOS

Let's look at an example of how to launch a Kubernetes cluster from scratch on DigitalOcean, including kubeadm, an Nginx Ingress controller, and Letsencrypt certificates.

Overview

Environment

We'll be creating a four-node cluster (k8s-master, k8s-000...k8s-002), load balancer, and ssl certificates.

Table of Contents

  1. Install Kubernetes
@kevashcraft
kevashcraft / 00-WordPress-on-CoreOS.md
Last active Jan 19, 2018
Setup WordPress with Docker-Compose on CoreOS
View 00-WordPress-on-CoreOS.md

Setup WordPress with Docker-Compose on CoreOS

Setup Steps

  1. Create docker-compose.yml in /home/core/, replacing the $variables with your values
  2. Create nginx.tmpl in /var/lib/docker/volumes/wpserver_nginx_templates/_data/
  3. Create wp-server.service in /etc/systemd/system/
  4. Run sudo systemctl daemon-reload to load the new service file
  5. Run sudo systemctl start wp-server to start the WordPress Server
  6. Run sudo systemctl status wp-server to make sure everything is running
You can’t perform that action at this time.