This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculate the weekday of any given date | |
# Author: djwatt5 | |
# We use the floor method from the math module | |
# to calculate the year offset. | |
import math | |
# Format: day: 1-31, month: 1-12, year: 1- | |
# String option: if not specified, the result | |
# will be an integer (Sunday: 0, Monday: 1, ..., |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
### This is an example on how to use blobs with the webapp_enhanced project | |
### Author: djwatt5 | |
### | |
### Most of the content here can be automatically generated | |
### using the console tool from webapp_enhanced. The only | |
### piece of code below that is custom can be found in the | |
### `self.create()` method (see line 43). | |
### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lib import db, utils | |
from lib.db import validators | |
BOOK_EXTENSIONS = ['azw', 'azw1', 'azw4', 'epub', 'kf8', 'mobi', 'pdb', 'pdf', 'prc', 'tpz'] | |
class BookModel(db.BlobModel): | |
### Data: | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Code for passing through edit pages | |
# Handle a PUT request. | |
def put(self, *args): | |
BaseController.put(self, *args) | |
# Form is a dictionary with elements like | |
# property_name: list_of_validators. | |
form = self.model.form | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Biology IA Simulations | |
# By Daniel Watson | |
import numpy | |
import matplotlib.pyplot as plt | |
# Controlled variables | |
h = .1 # days (step size) | |
population = 3.9e6 # remains constant | |
mosquitoes = 1e8 # remains constant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy paste this into the JS console of any window that has loaded | |
// https://coinmarketcap.com/ | |
var CURRENCY = 'bitcoin'; | |
var w = window.open('https://coinmarketcap.com/currencies/' + CURRENCY + '/historical-data/?start=20000101&end=20170806'); | |
w.addEventListener('load', function () { | |
var rows = $(w.document.getElementById('historical-data')).find('tr'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Automatically build a vanilla or Cudnn RNN.""" | |
import numpy as np | |
import tensorflow as tf | |
def gru(inputs, | |
num_layers, | |
num_units, | |
direction='unidirectional', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def split_by_delimiter(ts, delimiter): | |
"""Split a numeric tensor similarly to python's `str.split` method.""" | |
ts_str = tf.reshape(tf.reduce_join(tf.as_string(ts), separator=' '), [-1]) | |
ts_slices = tf.string_split( | |
tf.string_split(ts_str, delimiter=str(delimiter)).values) | |
result = tf.SparseTensor( | |
ts_slices.indices, | |
tf.string_to_number(ts_slices.values, out_type=ts.dtype), | |
ts_slices.dense_shape) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Optimizer to find the closest sigmoidal function to the identity.""" | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import tensorflow as tf | |
LEARNING_RATE = 1e-3 # make this small to make optimization converge. | |
BATCH_SIZE = 10000 # make this big to make optimization more accurate. | |
STEPS = 1000 # increase this if the learning rate is too small. |