Skip to content

Instantly share code, notes, and snippets.

View mlabouardy's full-sized avatar
☁️
Subscribe to my newsletter ➡️ https://devopsbulletin.com

LABOUARDY Mohamed mlabouardy

☁️
Subscribe to my newsletter ➡️ https://devopsbulletin.com
View GitHub Profile
@mlabouardy
mlabouardy / response.json
Created October 24, 2017 11:57
9Gag response example
[
{
"Description": "Choose wisely! Comment why!",
"Image": "https://img-9gag-fun.9cache.com/photo/apQVjGb_460s.jpg"
},
{
"Description": "When you get to hot",
"Image": "https://img-9gag-fun.9cache.com/photo/aVMVE08_460s.jpg"
},
{
@mlabouardy
mlabouardy / app.go
Created October 24, 2017 12:27
simple http server in go
package main
import (
"fmt"
"log"
"net/http"
)
func HomeEndpoint(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello world :)")
@mlabouardy
mlabouardy / go-install.sh
Created October 24, 2017 12:27
Setup Go environment variables
# GOROOT is the location where Go package is installed on your system
export GOROOT=/usr/lib/golang
# GOPATH is the location of your work directory
export GOPATH=$HOME/projects
# PATH in order to access go binary system wide
export PATH=$PATH:$GOROOT/bin
@mlabouardy
mlabouardy / setup-httpd.sh
Created October 24, 2017 12:29
Install apache server on EC2
#!/bin/bash
yum install -y httpd
service httpd start
chkconfig httpd on
echo “<html><h2>Hello from mlabouardy</h2></html>” > /var/www/html/index.html
@mlabouardy
mlabouardy / write.js
Created October 26, 2017 13:17
Insert data to DynamoDB
'use strict';
var AWS = require('aws-sdk'),
uuid = require('uuid'),
documentClient = new AWS.DynamoDB.DocumentClient();
exports.writeMovie = function(event, context, callback){
var params = {
Item : {
"Id" : uuid.v1(),
@mlabouardy
mlabouardy / read.js
Created October 26, 2017 13:18
Read data from DynamoDB
'use strict';
var AWS = require('aws-sdk'),
documentClient = new AWS.DynamoDB.DocumentClient();
exports.readAllMovies = function(event, context, callback){
var params = {
TableName : process.env.TABLE_NAME
};
documentClient.scan(params, function(err, data){
@mlabouardy
mlabouardy / index.js
Created October 26, 2017 13:23
Send email with MailGun library
'use strict';
var mg = require('mailgun-js')({
apiKey: process.env.MAILGUN_API_KEY || 'YOUR_API_KEY',
domain: process.env.MAILGUN_DOMAIN || 'DOMAIN_NAME'
});
exports.sendEmail = function(event, context, callback){
mg.messages().send({
from: '[email protected]',
to: '[email protected]',
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "AWS" : "*" },
"Action": "sts:AssumeRole"
}]
}
@mlabouardy
mlabouardy / docker-compose.yml
Created October 27, 2017 09:41
Telegraf, InfluxDB, Grafana stack
version: "2"
services:
influxdb:
container_name: influxdb
image: influxdb:1.0.2
ports:
- "8083:8083"
- "8086:8086"
volumes:
- /home/core/volumes/influxdb:/var/lib/influxdb
@mlabouardy
mlabouardy / telegraf.conf
Created October 27, 2017 09:42
Telegraf + InfluxDB output
# Read metrics about CPU usage
[[inputs.cpu]]
percpu = false
totalcpu = true
fieldpass = [ "usage*" ]
name_suffix = "_vm"
# Read metrics about disk usagee
[[inputs.disk]]
fielddrop = [ "inodes*" ]