Skip to content

Instantly share code, notes, and snippets.

View jperl's full-sized avatar

Jon Perl jperl

View GitHub Profile
@jperl
jperl / sequence_fixed_len_numeric_column.py
Last active July 2, 2018 15:05
Sequence Fixed Length Numeric Column
def sequence_fixed_len_numeric_column(key,
shape=(1, ),
default_value=0.,
dtype=dtypes.float32,
normalizer_fn=None):
shape = fc._check_shape(shape=shape, key=key)
if not (dtype.is_integer or dtype.is_floating):
raise ValueError('dtype must be convertible to float. ' 'dtype: {}, key: {}'.format(dtype, key))
if normalizer_fn is not None and not callable(normalizer_fn):
raise TypeError('normalizer_fn must be a callable. Given: {}'.format(normalizer_fn))
@jperl
jperl / stack.py
Last active February 7, 2018 06:42
stack past tensor slices
import numpy as np
import tensorflow as tf
def _stack_past(x, steps):
"""Stack the past data for each step.
Ex. x = [0, ..., 60]. steps = [10, 20]
Result [x, x[:-10], x[:-20]] normalized to the same shape
"""
# Sort the steps in ascending order [10, 20]
@jperl
jperl / mnist_estimator.py
Created January 6, 2018 16:19 — forked from peterroelants/mnist_estimator.py
Example using TensorFlow Estimator, Experiment & Dataset on MNIST data.
"""Script to illustrate usage of tf.estimator.Estimator in TF v1.3"""
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data as mnist_data
from tensorflow.contrib import slim
from tensorflow.contrib.learn import ModeKeys
from tensorflow.contrib.learn import learn_runner
# Show debugging output
@jperl
jperl / import-rds-certs.sh
Created December 28, 2017 03:09 — forked from shareefhiasat/import-rds-certs.sh
import RDS certificates to java keystore on alpine / osx
#!/usr/bin/env sh
#i tried it and working like charm just have to note make the file .sh chmod +x and you may need sudo to run with permission but be carefull with sudo
#be sure the $JAVA_HOME is configure correctly or make it static as commentedline 7 below
OLDDIR="$PWD"
if [ -z "$CACERTS_FILE" ]; then
# you should have java home configure to point for example /usr/lib/jvm/default-java/jre/lib/security/cacerts
CACERTS_FILE=$JAVA_HOME/jre/lib/security/cacerts
fi
@jperl
jperl / import-rds-certs.sh
Created December 28, 2017 03:09 — forked from shareefhiasat/import-rds-certs.sh
import RDS certificates to java keystore on alpine / osx
#!/usr/bin/env sh
#i tried it and working like charm just have to note make the file .sh chmod +x and you may need sudo to run with permission but be carefull with sudo
#be sure the $JAVA_HOME is configure correctly or make it static as commentedline 7 below
OLDDIR="$PWD"
if [ -z "$CACERTS_FILE" ]; then
# you should have java home configure to point for example /usr/lib/jvm/default-java/jre/lib/security/cacerts
CACERTS_FILE=$JAVA_HOME/jre/lib/security/cacerts
fi
// non-blocking --- event loop
const resolveAsync = () =>
new Promise((resolve) => {
setTimeout(() => {
resolve('something');
}, 100);
});
const rejectAsync = () =>
@jperl
jperl / gist:60a3cc0cb42d442f46b5
Created November 11, 2015 02:54
ReactLayout ported to pure es6 module for use with webpack meteor https://github.com/jedwards1211/meteor-webpack-react
import React, {component} from 'react';
import ReactDOM from 'react-dom';
import { renderToString } from 'react-dom/server';
let ReactLayout = {};
ReactLayout._domLoaded = false;
ReactLayout._rootProps = {};
ReactLayout._readyCallbacks = [];
@jperl
jperl / gist:91f32a37dc1c12c48ad8
Created September 28, 2015 15:42 — forked from technoweenie/gist:1072829
.netrc file so you can push/pull to https git repos without entering your creds all the time
machine github.com
login technoweenie
password SECRET
machine api.github.com
login technoweenie
password SECRET
@jperl
jperl / gist:80ac150f733a1b84a803
Last active August 29, 2015 14:21
Meteor performance optimizations -- inspired by https://github.com/remcoder/computron
Tools.debouncedAutorun = function (f, timeout) {
var debounced = _.debounce(function (c) {
// Store current computation
var prev = Tracker.currentComputation;
// Set the new computation
Tracker.currentComputation = c;//thisComputation;
Tracker.active = !!Tracker.currentComputation;
// Call function
@jperl
jperl / gist:408119f2fbd190eabb7f
Created March 12, 2015 21:57
Impersonate meteor user for development
// Server
Meteor.methods({
/**
* Login as a userId. Must be an admin.
*/
impersonate: function (options) {
var self = this;
if (Settings.isProduction) {
var currentUser = Meteor.users.findOne(self.userId);