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
| """ | |
| Taken from here: | |
| https://github.com/thumbor/thumbor/issues/116 | |
| """ | |
| def crop_surrounding_whitespace(image): | |
| """Remove surrounding empty space around an image. | |
| This implemenation assumes that the surrounding space has the same colour | |
| as the top leftmost pixel. |
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
| """ | |
| Should follow: | |
| https://en.wikipedia.org/wiki/ISO_8601 | |
| See also: | |
| - https://stackoverflow.com/questions/2150739/iso-time-iso-8601-in-python | |
| """ | |
| import time | |
| timestamp = time.strftime('%Y-%m-%d-%Hh%M') # '2019-02-14-16h20' |
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
| # clone a repo | |
| git clone git@github.com:GitUserOrOrg/repo.git | |
| # create a new branch | |
| git checkout -b rreece/branch1 | |
| # set my branch to track the main when i do git pull | |
| git branch --set-upstream-to origin/main | |
| # show branches |
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
| import tensorflow as tf | |
| from google.protobuf import text_format | |
| ##______________________________________________________________________________ | |
| def model_fn(features, labels, mode, params, pbtxt): | |
| ... | |
| optimizer = tf.train.AdamOptimizer(learning_rate=params['lr']) | |
| train_op = optimizer.minimize(loss, global_step=tf.train.get_global_step()) |
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
| #!/usr/bin/env sh | |
| # This scripts downloads the mnist data and unzips it. | |
| DIR="$( cd "$(dirname "$0")" ; pwd -P )" | |
| cd "$DIR" | |
| echo "Downloading..." | |
| for fname in train-images-idx3-ubyte train-labels-idx1-ubyte t10k-images-idx3-ubyte t10k-labels-idx1-ubyte | |
| do |
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
| import argparse | |
| import psutil | |
| import tensorflow as tf | |
| from typing import Dict, Any, Callable, Tuple | |
| ## Data Input Function | |
| def data_input_fn(data_param, | |
| batch_size:int=None, | |
| shuffle=False) -> Callable[[], Tuple]: | |
| """Return the input function to get the test 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
| #!/usr/bin/env python3 | |
| """ | |
| Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
| BSD License | |
| """ | |
| import numpy as np | |
| # data I/O | |
| data = open('input.txt', 'r').read() # should be simple plain text file | |
| chars = list(set(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
| #!/usr/bin/env python2 | |
| """ | |
| FROM: http://code.activestate.com/recipes/251871/ | |
| latin1_to_ascii -- The UNICODE Hammer -- AKA "The Stupid American" | |
| This takes a UNICODE string and replaces Latin-1 characters with | |
| something equivalent in 7-bit ASCII. This returns a plain ASCII string. | |
| This function makes a best effort to convert Latin-1 characters into | |
| ASCII equivalents. It does not just strip out the Latin1 characters. |
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
| # Installing python3 on Mac OSX | |
| brew install python3 | |
| # Error: An unexpected error occurred during the `brew link` step | |
| # The formula built, but is not symlinked into /usr/local | |
| # Permission denied @ dir_s_mkdir - /usr/local/Frameworks | |
| # Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks | |
| # | |
| # See: https://github.com/Homebrew/homebrew-core/issues/19286 |
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
| # Use an official centos7 image | |
| FROM centos:7 | |
| RUN localedef -i fr_FR -c -f UTF-8 -A /usr/share/locale/locale.alias fr_FR.UTF-8 | |
| ENV LANG fr_FR.utf8 | |
| # gcc because we need regex and pyldap | |
| # openldap-devel because we need pyldap | |
| RUN yum update -y \ | |
| && yum install -y https://centos7.iuscommunity.org/ius-release.rpm \ |