Skip to content

Instantly share code, notes, and snippets.

View made2591's full-sized avatar
🎯
Focusing

Matteo Madeddu made2591

🎯
Focusing
View GitHub Profile
@made2591
made2591 / main.go
Created January 16, 2018 17:33 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@made2591
made2591 / TMDB.go
Created March 11, 2018 10:29
A TheMovieDB wrapper in Go ready to be build over AWS Lambda.
package main
import (
"os"
"fmt"
"errors"
"strings"
"net/http"
"encoding/json"
"github.com/aws/aws-lambda-go/lambda"
@made2591
made2591 / index.js
Last active June 27, 2020 18:54
AWS Lambda Node.js as slack command handler (with specified grammar)
const AWS = require('aws-sdk');
const Slack = require("slack-node");
AWS.config.region = process.env.REGION;
const lambda = new AWS.Lambda();
// ####################################################
// ################# SECURITY CHECK ###################
// ####################################################
// check if slack token is equal to env var
@made2591
made2591 / index.js
Created March 24, 2018 14:41
AWS Lambda Node.js to get change of status in EC2 instances.
const Slack = require("slack-node");
// Load the AWS SDK for Node.js
const AWS = require("aws-sdk");
// Set the region
AWS.config.update({region: process.env.REGION});
// Create EC2 service object
var ec2 = new AWS.EC2();
function capitalizeFirstLetter(string) {
@made2591
made2591 / main.py
Created March 24, 2018 14:53
AWS Lambda Python to handle actions defined in a configuration file over S3
import boto3
import os
import json
##############################################################
###################### Check context #########################
##############################################################
def check_context(event):
if event["context"] in contexts.keys():
@made2591
made2591 / body-template
Created March 24, 2018 14:55
Body Mapping template to get JSON from Slack Command post request
## convert HTML POST data or HTTP GET query string to JSON
## get the raw post data from the AWS built-in variable and give it a nicer name
#if ($context.httpMethod == "POST")
#set($rawAPIData = $input.path('$'))
#elseif ($context.httpMethod == "GET")
#set($rawAPIData = $input.params().querystring)
#set($rawAPIData = $rawAPIData.toString())
#set($rawAPIDataLength = $rawAPIData.length() - 1)
#set($rawAPIData = $rawAPIData.substring(1, $rawAPIDataLength))
#!/bin/bash
set -o errtrace -o nounset -o pipefail -o errexit
echo "hello world"
@made2591
made2591 / colors.json
Created January 13, 2019 17:24
A tuya bulb colour mapping with the one exposed by Google Home application
[
{
"1":true,
"2":"white",
"3":255,
"4":255,
"5":"fffafa000005ff",
"6":"00ff0000000000",
"7":"ffff500100ff00",
"8":"ffff8003ff000000ff000000ff000000000000000000",
@made2591
made2591 / docker-compose.yaml
Last active March 5, 2019 23:44
A docker compose to start up a proxy and a simple web server for illustrative purposes
version: "3"
services:
proxy:
container_name: proxy
restart: always
image: debian:jessie
privileged: true
ports:
- "80:80"
networks:
@made2591
made2591 / README.md
Created July 19, 2019 14:25
Flattener

Flattener

Flattener is a utility to flatten an array of arbitrarily nested arrays of integers into a flat array of integers.

Getting Started

To run the project, just create a folder and put the file flattener.js, test.js and package.json inside.

Prerequisites