Skip to content

Instantly share code, notes, and snippets.

View morenoh149's full-sized avatar
💭
Working from 🛰

Harry Moreno morenoh149

💭
Working from 🛰
View GitHub Profile
@morenoh149
morenoh149 / intro-blockchain-programming.md
Last active January 27, 2020 19:12
Intro to blockchain programming in js

Introduction to Blockchain Programming, Jan 2020

Explain blockchain

Chain of blocks

@morenoh149
morenoh149 / solidity-workshop.md
Last active October 26, 2019 01:12
Solidity workshop

Soldity Workshop

Prerequisites

Attendees should do the following before the event to get the most out of it. There will be a 20 minute lecture-overview at the beginning. You can do the prerequisites during the overview if you have not done so by then.

  1. install node.js (lts version is recommended)
  2. install git (use brew if on osx)
  3. install a code editor (vscode or atom.io)
@morenoh149
morenoh149 / dp01.js
Created February 26, 2019 20:31
Dynamic programming example
// The following was translated from python.
// See https://codility.com/media/train/15-DynamicProgramming.pdf
const dynamicCoinChanging = (coins, target) => {
let n = coins.length;
let dp = [0];
for (let i=0; i < target; i++) {
dp.push(Number.POSITIVE_INFINITY);
}
for (let i=0; i <= n; i++) {
@morenoh149
morenoh149 / save-model-to-sagemaker.py
Created February 12, 2019 10:35
Tensorflow serve on Sagemaker
def export_h5_to_pb(path_to_h5, export_path):
# Set the learning phase to Test since the model is already trained.
K.set_learning_phase(0)
# Load the Keras model
keras_model = load_model(path_to_h5)
# Build the Protocol Buffer SavedModel at 'export_path'
builder = saved_model_builder.SavedModelBuilder(export_path)
@morenoh149
morenoh149 / sol.py
Created December 5, 2018 20:51
Advent of Code 2018 Day 4 solution
import re
import pprint
pp = pprint.PrettyPrinter(indent=2)
def Input():
filename = './input.txt'
return open(filename)
lines = Input().read().split('\n')
@morenoh149
morenoh149 / postgis-geojson-liaison.js
Created November 9, 2018 02:34 — forked from DesignByOnyx/postgis-geojson-liaison.js
Helpful utility for converting postgis data into GeoJSON as it comes out of the db, and vice versa.
var wkx = require('wkx')
var pg = require('pg')
var pgUtil = require('pg/lib/utils')
const geoParser = {
init(knex){
// 1. Convert postgis data coming out of the db into geoJSON
// Every postgres installation will have different oids for postgis geo types.
knex
.raw('SELECT oid, typname AS name FROM pg_type WHERE typname IN (\'geography\', \'geometry\');')
const getInvite = fetch(
`${apiHost}/invite/?event=${event_id}&user=${userId}`
);
const getHost = fetch(`${apiHost}/user/${event.fields.host}/`);
Promise.all([getInvite, getHost, delayPromise(1000)()])
.then(values => {
values.pop(); // drop delayPromise's return value (undefined)
return values.map(v => v.json());
})
import tensorflow as tf
from keras import backend as K
from tensorflow.python.saved_model import builder as saved_model_builder
from tensorflow.python.saved_model import tag_constants, signature_constants
from tensorflow.python.saved_model.signature_def_utils_impl import predict_signature_def
builder = saved_model_builder.SavedModelBuilder('vgg16_no_augmentation_export')
signature = predict_signature_def(inputs={'input': parallel_model.inputs[0]},
outputs={'income': parallel_model.outputs[0]})
---------------------------------------------------------------------------
MemoryError Traceback (most recent call last)
<ipython-input-22-567222df1eb0> in <module>()
----> 1 x_train = vectorize_sequences(train_data)
2 x_test = vectorize_sequences(test_data)
<ipython-input-21-5d7c33381575> in vectorize_sequences(sequences, dimension)
2 # are a 1 in the tensor, 0 otherwise
3 def vectorize_sequences(sequences, dimension=10000):
----> 4 results = np.zeros((len(sequences), dimension))
@morenoh149
morenoh149 / Nbutton.js
Last active July 14, 2018 20:50
React Native Platform specific button
import React from "react";
import { Platform, TouchableNativeFeedback, TouchableOpacity, View } from "react-native";
const Colors = {
androidRippleDark: "#ccc"
};
const styles = {
style: {}
};