Skip to content

Instantly share code, notes, and snippets.

https://photos.app.goo.gl/ARpfMtqQVf0ySFyf2
"""AWS Lambda Handler for making loan grade predictions"""
import os
import boto3
import botocore
import json
import numpy as np
from keras.models import load_model
from keras import backend as K
Loan Amount Debt to Income A B C D E F G
10000 20.43 0 1 0 0 0 0 0
16000 29.13 0 0 0 1 0 0 0
23975 14.47 1 0 0 0 0 0 0
@jamesandersen
jamesandersen / model_definition.py
Created August 28, 2017 13:56
Keras Neural Network Model for Lending Club Data
"""Create Keras model"""
from keras.models import Sequential
from keras.layers import Dense, Dropout
from keras.constraints import maxnorm
def create_model(input_dim, output_dim):
# create model
model = Sequential()
@jamesandersen
jamesandersen / Dockerfile
Created July 1, 2017 05:33
Multi-stage Dockerfile
# BUILD the app in first stage
FROM jamesandersen/alpine-golang-opencv3:edge
RUN apk --no-cache add git
WORKDIR /go/src/github.com/jamesandersen/gosudoku
COPY . .
RUN go get github.com/nytimes/gziphandler
RUN go-wrapper download # "go get -d -v ./..."
RUN go-wrapper install # "go install -v ./..."
# Start from a *NEW* image in the second stage
@jamesandersen
jamesandersen / parsed-sudoku.txt
Created July 1, 2017 03:22
Parsed Sudoku Image
7....3..2..4...1.9..52.9....2..15.7...........9.47..8....7.48..3.2...5..9..3....1
@jamesandersen
jamesandersen / cgo_memory_alloc.go
Created June 30, 2017 23:05
Allocating C memory when invoking C code via CGO
// allocate 81 char string in C memory
parsed := C.CString(strings.Repeat("0", 81))
defer C.free(unsafe.Pointer(parsed)) // free it when we're done here
// allocate byte array for our image data in C memory
p := C.CBytes(data)
defer C.free(unsafe.Pointer(p)) // free it when we're done
// float32 is standardized type compatible with C
gridCoords := []float32{-1, -1, -1, -1, -1, -1, -1, -1}
@jamesandersen
jamesandersen / cgo_preamble.go
Last active June 30, 2017 23:06
Cross-platform CGO Preamble
/*
#cgo darwin CPPFLAGS: -I/usr/local/Cellar/opencv3/3.2.0/include -I/usr/local/Cellar/opencv3/3.2.0/include/opencv2
#cgo darwin CXXFLAGS: --std=c++1z -stdlib=libc++
#cgo darwin LDFLAGS: -L/usr/local/Cellar/opencv3/3.2.0/lib -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo
#cgo linux CPPFLAGS: -I/usr/include -I/usr/include/opencv2 -I/usr/local/include -I/usr/local/include/opencv2
#cgo linux CXXFLAGS: --std=c++1z
#cgo linux LDFLAGS: -L/usr/lib -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo
#include <stdlib.h>
#include "sudoku_parser.h"
*/
../samples/800wi.png 7....3..2..4...1.9..52.9....2..15.7...........9.47..8....7.48..3.2...5..9..3....1
../samples/article.jpg 8..........36......7..9.2...5...7.......457.....1...3...1....68..85...1..9....4..
../samples/squiggly.png 319.5.2784..68...5.......927.2..51.............17..6.364.......2...68..9875.1.436
../samples/sudoku_9x9_250.png .3.5...29215.4.......1...7...3.....2.4..9.8....7.....6...9...8.972.8.....5.4...61
../samples/sudoku-loesung.png ....1.75.7486..3.13...94...1.4..65.759..7..3.....48...43.1....29.2...64.8.7.5.91.
../samples/Sudoku-Solving.png .....4.9.8.297....9.12..3......49157.13.5.92.57912......7..26.3....382.5.2.5.....
../samples/sudoku.png ..53.....8......2..7..1.5..4....53...1..7...6..32...8..6.5....9..4....3......97..
../samples/sudoku1.png ..3.92...4...3..1.27........1.3....8.5.167.3.3....8.6........53.3..8...9...62.1..
../samples/sudoku2.jpg 58.3...6..9..68.7.2.....8.3.3..1...77.58461.98...9..2.3.1.....6.5.63..4..4...5.12
../samples/Sudoku3334.jpg 4.......9...5.8...79.3.2.81.5.6.9.
@jamesandersen
jamesandersen / gist:0ed3a6c4841f184831b47ce4398a42af
Created January 12, 2017 04:52
AWS Cloud Formation Template for ECS Stack with Elastic IP Associated to Auto-Scaling Group
AWSTemplateFormatVersion: '2010-09-09'
Description: >
AWS CloudFormation template to create a new VPC
or use an existing VPC for ECS deployment
in Create Cluster Wizard
Parameters:
EcsClusterName:
Type: String
Description: >
Specifies the ECS Cluster Name with which the resources would be