Skip to content

Instantly share code, notes, and snippets.

@perryism
perryism / Dockerfile
Last active April 7, 2023 00:55
Convert Xgboost model to PMML 4.3 version
FROM python
RUN apt-get update
RUN apt-get install -y openjdk-11-jdk
RUN python -m pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org sklearn xgboost==1.0.0 sklearn2pmml ipython
RUN wget https://github.com/jpmml/jpmml-xgboost/releases/download/1.4.0/jpmml-xgboost-executable-1.4.0.jar
RUN python train.py
RUN java -jar jpmml-xgboost-executable-1.3.16.jar --model-input iris.model --fmap-input Audit.fmap --target-name Adjusted --pmml-output XGBoostAudit.pmml
@perryism
perryism / all_subclass_of.py
Last active April 6, 2023 15:56
Get subclass of a superclass from a module
import inspect
def is_subclass_of(superclass):
def curry(cls):
return inspect.isclass(cls) and cls is not superclass and issubclass(cls, superclass)
return curry
def all_attributes_from_module(module):
return [ getattr(module, i) for i in dir(module) ]
@perryism
perryism / vertex_ai_client.yaml
Last active April 26, 2023 22:24
Vertex AI endpoint openapi 3.0.0 spec
openapi: 3.0.0
info:
title: Vertex AI endpoint spec
version: "1.0.0"
servers:
- url: vertex ai endpoint
description: localhost
components:
@perryism
perryism / myscript.py
Created January 11, 2023 06:08
Make python package executable
def run():
print('Hello world')
@perryism
perryism / math_num_to_words.py
Created September 1, 2022 01:58
Generate numbers to words for my 4th grader
from num2words import num2words
import random
def gen():
num1 = random.randint(1, 99)
num2 = random.randint(1, 99)
if num2 >= 10:
u = "hundredths"
else:
from random import randrange
from datetime import datetime, timedelta
def random_date_between(start_date, end_date):
time_between_dates = end_date - start_date
days_between_dates = time_between_dates.days
random_number_of_days = randrange(days_between_dates)
return start_date + timedelta(days=random_number_of_days)
def random_date_from(start_date, time_between_dates):
@perryism
perryism / build_and_deploy.yaml
Created March 16, 2022 16:47
Github actions to deploy react app as a static site to google cloud
name: Deployment
on: [push]
jobs:
  Build-App:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
@perryism
perryism / prometheus-endpoint.yaml
Last active October 22, 2021 17:54
prometheus_metrics_outside_of_cluster.yaml
apiVersion: v1
kind: Endpoints
metadata:
name: gpu-metrics
namespace: monitoring
labels:
app: gpu-metrics
release: prometheus
subsets:
- addresses:
@perryism
perryism / codebuild_creds.sh
Created December 17, 2020 01:47
Update codebuild github token to access private repos
# Ref: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-access-tokens.html
cat <<EOT >> creds.json
{
"username": "perryism",
"token": "my_access_token",
"serverType": "GITHUB",
"authType": "OAUTH",
"shouldOverwrite": true
}EOT
@perryism
perryism / Dockerfile
Created August 5, 2020 20:50
Rails 6 alpine
FROM ruby:2.7.1-alpine3.12
RUN apk add --no-cache build-base nodejs nodejs-npm yarn sqlite-dev tzdata && \
gem install nokogiri && \
gem install rails
WORKDIR /app
COPY Gemfile /app