Skip to content

Instantly share code, notes, and snippets.

View vittorio-nardone's full-sized avatar

Vittorio Nardone vittorio-nardone

View GitHub Profile
@vittorio-nardone
vittorio-nardone / docker-compose.yml
Created February 16, 2021 16:10
Compose sample of sidecar container
version: "3.9"
services:
web:
build: ./App
ports:
- "5000:5000"
volumes:
- sidecar:/sidecar
command: sh -c "git clone https://github.com/vittorio-nardone/sidecar.git ; flask run"
redis:
@vittorio-nardone
vittorio-nardone / Dockerfile
Created November 27, 2020 14:02
Docker image to run Selenium and Firefox on Raspberry PI (python web scraping)
FROM arm32v7/python:3.8
RUN apt-get -y update
RUN apt-get -y upgrade
# Install Firefox and Selenium
RUN apt-get install -y firefox-esr
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-arm7hf.tar.gz
RUN tar -xf geckodriver-v0.23.0-arm7hf.tar.gz
@vittorio-nardone
vittorio-nardone / login.py
Last active November 27, 2020 14:06
Paradox IP150 - UI scraping with Python/Selenium on Raspberry PI
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
from selenium import webdriver
import os
from time import sleep
from pyvirtualdisplay import Display
def paradox_login():
# Set screen resolution to 1366 x 768 like most 15" laptops
display = Display(visible=0, size=(1366, 768))
@vittorio-nardone
vittorio-nardone / Dockerfile
Created November 18, 2020 09:55
Simple Prophet dockerfile
FROM python:3.6.10-slim
RUN apt-get -y update && apt-get install -y \
python3-dev \
apt-utils \
python-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --upgrade setuptools
@vittorio-nardone
vittorio-nardone / HyperTuning.py
Created November 18, 2020 09:15
Metaflow steps to perform hyperparameters tuning in Prophet
@step
def hyper_tuning(self):
"""
Hyperparameters tuning
"""
# Tune hyperparameters of the model
param_grid = {
'changepoint_prior_scale': [0.001, 0.01, 0.1, 0.5],
'seasonality_prior_scale': [0.01, 0.1, 1.0, 10.0],
}
@vittorio-nardone
vittorio-nardone / ProphetSimpleFlow.py
Created November 17, 2020 17:42
A simple Metaflow flow to train a Prophet model using defaults
import pandas as pd
import numpy as np
from io import StringIO
from metaflow import FlowSpec, step, Parameter, IncludeFile
from fbprophet import Prophet
class ProphetFlow(FlowSpec):
"""
@vittorio-nardone
vittorio-nardone / LambdaLayers.yaml
Created October 7, 2020 11:52
A sample of AWS Lambda Layer
SeleniumChromiumLayer:
Type: AWS::Lambda::LayerVersion
Properties:
CompatibleRuntimes:
- python3.7
- python3.6
Content:
S3Bucket:
Ref: BucketName
S3Key:
@vittorio-nardone
vittorio-nardone / amplify.yaml
Created September 8, 2020 13:55
AWS Amplify CI/CD pipeline with code linter (JS / Python) and Cypress end-to-end test
version: 1
backend:
phases:
build:
commands:
- '# Evaluate backend Python code quality'
- find amplify/backend/function -name index.py -type f | xargs pylint --fail-under=5 --rcfile=pylint.rc
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple
frontend:
@vittorio-nardone
vittorio-nardone / amplify_auth.js
Created September 8, 2020 13:14
Test AWS Amplify login / logout (Cognito) using Cypress
export const labels = {
// Auth
signInLabel: 'Sign In',
signOutLabel: 'Sign Out',
signInHeader: 'Sign in to your account',
signInResetPassword: 'Reset password',
signInCreateAccount: 'Create account',
}
@vittorio-nardone
vittorio-nardone / Dockerfile
Last active September 8, 2020 11:46
Amplify CI docker image
FROM amazonlinux:latest
RUN yum update -y
RUN yum -y install \
git \
curl \
openssl \
gcc-c++ \
gcc \
openssl-devel \