This file contains 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
// define a grammar called Hello | |
grammar Hello; | |
r : 'hello' ID; | |
ID : [a-z]+ ; | |
WS : [ \t\r\n]+ -> skip ; |
This file contains 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
grammar Expr; | |
// Need to call recursive rule expr from non-recursive rule | |
r : expr+ ; | |
// ANTLR4 : Left recursion! | |
// Operator precedence matches order of definition | |
expr : '-' expr // Unary minus | |
| expr ('*' | '/' ) expr | |
| expr ('+' | '-' ) expr |
This file contains 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
grammar CFunction; | |
function : retType name args ; | |
args : '(' arg (',' arg)* ')' ; | |
arg | |
: 'double' name # SCALAR_ARG | |
| 'double' '*' name # ARRAY_ARG |
This file contains 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 subprocess import run | |
import sympy as sp | |
def print_to_file(fname, expr): | |
# See https://tex.stackexchange.com/questions/34054/tex-to-image-over-command-line/34058#34058 | |
t_start = r"""\documentclass[border=2pt]{standalone} | |
\usepackage{amsmath} | |
\usepackage{varwidth} | |
\begin{document} |
This file contains 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
{ | |
"verbs" : ["aggregate", "architect", "benchmark", "brand", "cultivate", "deliver", "deploy", "disintermediate", | |
"disrupt", "drive", "e-enable", "embrace", "empower", "enable", "engage", "engineer", "enhance", | |
"envisioneer", "evolve", "expedite", "exploit", "extend", "facilitate", "generate", "grow", "harness", "implement", "incentivize", "incubate", "innovate", "integrate", | |
"iterate", "leverage", "matrix", "maximize", "mesh", "monetize", "morph", "optimize", "orchestrate", "productize", "recontextualize", "redefine", "reintermediate", | |
"reinvent", "repurpose", "revolutionize", "scale", "seize", "strategize", "streamline", "syndicate", "synergize", "synthesize", "target", | |
"transform", "transition", "unleash", "utilize", "visualize", "whiteboard"], | |
"adjectives": ["24/365", "24/7", "B2B", "B2C", "back-end", "best-of-breed", "bleeding-edge", "bricks-and-clicks", "clicks-and-mortar", | |
"collaborative", "compelling", "cross-p |
This file contains 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 sympy as sp | |
x = sp.symbols('x', real=True) | |
p, q = sp.symbols('p q', positive=True) | |
KL = sp.Integral(p*sp.log(p) - p*sp.log(q), (x, -sp.oo, sp.oo)) | |
mu, mu1, mu2 = sp.symbols('mu mu1 mu2', real=True) | |
sig, sig1, sig2 = sp.symbols('sig sig1 sig2', positive=True) | |
n = 1/sp.sqrt(2*sp.pi*sig**2)*sp.exp(-(x - mu)**2/(2*sig**2)) | |
KL_n = sp.simplify( | |
KL.subs({p: n.subs({mu: mu1, sig: sig1}), q: n.subs({mu: mu2, sig: sig2})}).doit() | |
) |
This file contains 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
# Amazon #Sagemaker instance | |
# open Jupyter | |
# new terminal | |
cd SageMaker | |
git clone https://github.com/matterport/Mask_RCNN.git | |
git clone https://github.com/waleedka/coco.git | |
cd coco/PythonAPI | |
source activate tensorflow_p36 | |
make | |
python setup.py install |
This file contains 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 boto3 | |
import os | |
import sys | |
import zipfile | |
HERE = os.path.dirname(os.path.realpath(__file__)) | |
def library_install(): | |
"""Dynamically add libraries to path, retrieving from S3 if necessary |
This file contains 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 amazonlinux:latest | |
MAINTAINER Matt McDonnell "matt@matt-mcdonnell.com" | |
RUN yum -y -q update | |
RUN yum -y -q install python27-pip zip | |
RUN pip install -q virtualenv |
This file contains 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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"s3:PutObject", | |
"s3:ListAllMyBuckets", | |
"s3:ListBucket", | |
"s3:CreateBucket" |
NewerOlder