Skip to content

Instantly share code, notes, and snippets.

View MassimoSporchia's full-sized avatar

Massimo Sporchia MassimoSporchia

View GitHub Profile
@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 / 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 / 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 / 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