Skip to content

Instantly share code, notes, and snippets.

View MassimoSporchia's full-sized avatar

Massimo Sporchia MassimoSporchia

View GitHub Profile
1. pip install jupyterlab
pip install tensorflow boto3 sagemaker
2. Then type “jupyter Lab”, the notebook should open in the browser
1. import tensorflow as tf
msg = tf.constant('Ciao mondo')
tf.print(msg)
3. Check that everything works
4. Now create a new Jupyter Notebook
1. Download this: LINK (https://raw.githubusercontent.com/aws/amazon-sagemaker-examples/master/introduction_to_applying_machine_learning/breast_cancer_prediction/Breast%20Cancer%20Prediction.ipynb)
2. Modify the Setup terminal
@MassimoSporchia
MassimoSporchia / neptune-cdk.ts
Created May 21, 2020 07:52
Neptune Hello-World CDK
import * as cdk from '@aws-cdk/core';
import * as neptune from '@aws-cdk/aws-neptune';
export class NeptuneTestStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const dbClusterParameterGroup = new neptune.CfnDBClusterParameterGroup(this, 'neptune-ClusterParameterGroup', {
description: 'test-description',
@MassimoSporchia
MassimoSporchia / glueworkflow.ts
Created May 18, 2020 13:54
Sample Glue Workflow with CDK
import * as cdk from "@aws-cdk/core";
import * as glue from "@aws-cdk/aws-glue";
export class GlueStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
var workflow = new glue.CfnWorkflow(this, "glueWorkflow", {
name: "testWorkflow",
});
@MassimoSporchia
MassimoSporchia / aws-iot-with-alpn.js
Created May 4, 2020 15:05 — forked from HQarroum/aws-iot-with-alpn.js
Using the AWS IoT SDK with ALPN extensions to connect over MQTTS on port 443
const client = require('aws-iot-device-sdk');
// The options object to provision the MQTT client with.
// Update values between chevrons with the appropriate values.
const opts = {
host: "<aws-iot-endpoint>",
keyPath: "<path-to-private-key>",
certPath: "<path-to-device-certificate>",
caPath: "<path-to-root-ca>",
// We are specifying that we want to connect on the
@MassimoSporchia
MassimoSporchia / main.js
Created May 1, 2020 08:15 — forked from h0ru5/main.js
connecting to AWS IoT through a HTTP CONNECT
const {toProxyOpts, proxyConnect } = require("./proxy-connect")
// using it to connect to AWS IoT through a HTTP CONNECT proxy
const aws = require("aws-iot-device-sdk");
const proxyUrl = process.env.http_proxy || "http://localhost:3128/";
const opts = {
keyPath: "assets/device.private.key",
certPath: "assets/device.cert.pem",
@MassimoSporchia
MassimoSporchia / failover_asg_lambda_to_slack.py
Created March 16, 2020 09:48 — forked from freedomofkeima/failover_asg_lambda_to_slack.py
Failover Script between Spot and On-demand ASG Instances (ECS Cluster Checking + Slack Notification)
#!/usr/bin/env python
# Lambda Script for spot instances failover
# NOTE 1: Re-failover from on-demand to spot will be done if all desired ECS tasks are currently running
# NOTE 2: The maximum number of spot instances is taken from its DesiredCapacity
# WARNING: You cannot increase DesiredCapacity of on-demand from the console without changing this script,
# however, you can increase DesiredCapacity of spot instances from the console and if it fails,
# this script will start on-demand instead of spot instances
#
import boto3
import json
@MassimoSporchia
MassimoSporchia / Create-Administrator.ps1
Created May 23, 2018 10:23 — forked from ducas/Create-Administrator.ps1
Create a local administrator account using PowerShell
$Username = "su"
$Password = "password"
$group = "Administrators"
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
$existing = $adsi.Children | where {$_.SchemaClassName -eq 'user' -and $_.Name -eq $Username }
if ($existing -eq $null) {
@MassimoSporchia
MassimoSporchia / AggregateExcel.R
Last active April 4, 2018 07:13
Macro to aggregate Excel from a directory, into a Master, using a template (with existing sheets with Pivot Tables, Graphs, and the likes)
library(openxlsx)
library(plyr)
template <- "template.xlsx"
masterfile <-
"master.xlsx"
dirpath <-
"data/"
@MassimoSporchia
MassimoSporchia / generateJsonNames.js
Created January 11, 2018 15:50
Snippet that creates random people from a list of names and surname (json arrays in files) and writes it to a file (json array)
var fs = require('fs');
var namesIn = "names.json"
var surnamesIn = "surnames.json"
var peopleOut = "peopleOut.json"
var namesFile = fs.readFileSync(namesIn, 'utf8');
var surnamesFile = fs.readFileSync(surnamesIn, 'utf8');
namesJson = JSON.parse(namesFile);
surnamesJson = JSON.parse(surnamesFile);