Skip to content

Instantly share code, notes, and snippets.

View RHDZMOTA's full-sized avatar
👨‍💻
More info at: rhdzmota.com

Rodrigo H. Mota RHDZMOTA

👨‍💻
More info at: rhdzmota.com
View GitHub Profile
@RHDZMOTA
RHDZMOTA / es-scala-config.md
Created June 1, 2019 03:33
Using elastic4s

Elasticsearch Scala Config

This is a simple elasticsearch scala config.

SBT Config

Add the following dependency:

"com.sksamuel.elastic4s" %% "elastic4s-http" % "6.5.1"
@RHDZMOTA
RHDZMOTA / create-pemfile.md
Created October 15, 2019 04:21
Create pemfile

Create the pemfile using aws-cli:

$ aws ec2 create-key-pair --key-name rodrigo-hernandez-mota-ds-dev --query 'KeyMaterial' --output text --region us-west-2 --profile ds-dev > rodrigo-hernandez-mota-ds-dev.pem
$ chmod 400 rodrigo-hernandez-mota-ds-dev.pem
@RHDZMOTA
RHDZMOTA / create-pemfile.md
Created October 15, 2019 04:21
Create pemfile

Create the pemfile using aws-cli:

$ aws ec2 create-key-pair --key-name rodrigo-hernandez-mota-ds-dev --query 'KeyMaterial' --output text --region us-west-2 --profile ds-dev > rodrigo-hernandez-mota-ds-dev.pem
$ chmod 400 rodrigo-hernandez-mota-ds-dev.pem
@RHDZMOTA
RHDZMOTA / README.md
Created October 18, 2019 22:54
Tree Traversal Exercise

Tree Traversal Exercise

Given a tree-like structure like:

          3  
        / | \
       1  5 10   
      /  / \  \
     6  1   4  5  

The enrollment-database contains data resembling the following:

  • student
id first_name last_name gender gpa age
1 Amelia O'Sullivan female 3.7 20
2 Rachel Stevens female 3.5 25
3 Sarah Dunn female 3.2 23
4 Liam Baker male 3.3 24
@RHDZMOTA
RHDZMOTA / Dockerfile
Created January 2, 2020 17:49
Alpine python with postgresql and mysql deps
FROM python:3.7-alpine3.9
ENV PYTHONBUFFERED 1
RUN apk add --update --no-cache --virtual .build-deps \
ca-certificates gcc postgresql-dev python3-dev linux-headers musl-dev \
libffi-dev jpeg-dev zlib-dev g++ mariadb-dev
RUN mkdir /code
WORKDIR /code
@RHDZMOTA
RHDZMOTA / snippet.md
Last active May 6, 2020 00:14
Some utility commands for git & github!

Update your repo!

One-time setup

Run the following commands on the first setup:

  1. Create an empty repository on github.
    • Name: credit-risk-lecture
    • Description: [team-name]
  2. Create the repo and add rhdzmota as a collaborator.
@RHDZMOTA
RHDZMOTA / irr-jax.py
Created April 27, 2020 06:13
Internal rate of return using JAX.
import jax.numpy as np
def irr(cashflows):
res = np.roots(cashflows[::-1])
mask = (res.imag == 0) & (res.real > 0)
# Filter out imaginary component.
if not mask.any():
return np.nan
res = res[mask].real
@RHDZMOTA
RHDZMOTA / example-output.json
Last active May 4, 2020 00:21
Multiprocessing when having a blocking process (matplotlib and disk writes) - a quick hack
{
"ASYNC-PROCESS": 2.6283581256866455,
"ASYNC-THREAD": 11.003680944442749,
"SYNC": 10.771448135375977
}
import numpy as np
def irr(cashflows):
# Get polynomial roots
res = np.roots(cashflows[::-1])
# Filter out imaginary component.
mask = (res.imag == 0) & (res.real > 0)
if not mask.any:
return np.nan