Skip to content

Instantly share code, notes, and snippets.

View mario21ic's full-sized avatar
👋
Open to work

Mario IC mario21ic

👋
Open to work
View GitHub Profile
@mario21ic
mario21ic / function.js
Created April 5, 2017 22:16 — forked from vgeshel/function.js
AWS Lambda function for forwarding SNS notifications to Slack
console.log('Loading function');
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/...';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
@mario21ic
mario21ic / hashicorp.sh
Created April 12, 2017 16:24 — forked from afym/ hashicorp.sh
Install hashicorp tools in an easy way (terraform, packer, ...)
#!/bin/sh
TOOL_NAME=$1
ZIP_URL=$2
mkdir /tmp/$TOOL_NAME
cd /tmp/$TOOL_NAME
curl -sS $ZIP_URL > $TOOL_NAME.zip
unzip $TOOL_NAME.zip
sudo cp $TOOL_NAME /usr/local/bin/$TOOL_NAME
rm -rf /tmp/$TOOL_NAME
echo "$TOOL_NAME :: is installed successfully"
@mario21ic
mario21ic / install_terraform.sh
Created April 12, 2017 16:33
Script to install Terraform
#!/bin/sh
VERSION=$1
cd /tmp/
wget "https://releases.hashicorp.com/terraform/"$VERSION"/terraform_"$VERSION"_linux_amd64.zip"
unzip "terraform_"$VERSION"_linux_amd64.zip"
sudo cp terraform /usr/local/bin/terraform
rm -rf /tmp/terraform_$VERSION_linux_amd64.zip
echo "Terraform :: is installed successfully"
@mario21ic
mario21ic / terraform.sh
Last active May 15, 2017 20:56
Script to execute Terraform with environments and tfvars files
#!/bin/bash
# Usage: ./main.sh action [target] [params]
# ./main.sh plan
# ./main.sh plan -destroy
# ./main.sh plan vpc
# ./main.sh plan vpc -destroy
ACTION=$1
EXTRA=$*
TARGET=""
@mario21ic
mario21ic / github_orgy.py
Created May 19, 2017 14:58 — forked from kootenpv/github_orgy.py
As it is impossible to find out about new repos created by an org, this awkwardly named script exists.
""" github_orgy -- monitor github organizations for new repos.
Usage:
python3.5 github_orgy.py deepmind tensorflow facebookresearch google watson-developer-cloud
Or with cron:
@hourly /usr/bin/python github_orgy.py deepmind tensorflow facebookresearch google watson-developer-cloud
"""
import time
import os
@mario21ic
mario21ic / user.data.get.latest.sh
Created May 24, 2017 17:44
Script to use in user data to aws ec2
#!/bin/bash
BUCKET="mybucket.deploy"
ENVIRONMENT="dev"
LATEST="/tmp/latest.zip"
APP_DIR="/var/www/web"
latest=$(aws s3 ls s3://$BUCKET/$ENVIRONMENT/ --recursive | sort | tail -n 1 | awk '{print $4}')
aws s3 cp s3://$BUCKET/$latest $LATEST
sudo mkdir -p $APP_DIR && unzip -qo $LATEST -d $APP_DIR
rm -f $LATEST
@mario21ic
mario21ic / apache
Created June 4, 2017 19:07
Monit files to configuration: apache, httpd, nginx, mysql and sshd
check process apache with pidfile /run/apache2.pid
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program = "/etc/init.d/apache2 stop"
@mario21ic
mario21ic / socat_examples
Created June 23, 2017 17:42
Examples for using socat (and filan)
// Examples for using socat (and filan)
//"$" means normal user, "#" requires privileges, "//" starts a comment
///////////////////////////////////////////////////////////////////////////////
// similar to netcat
// connect to 10.1.1.1 on port 80 and relay to and from stdio
@mario21ic
mario21ic / subprocessdemote.py
Created June 26, 2017 23:39 — forked from sweenzor/subprocessdemote.py
Run python subprocess(es) as another user
#!/usr/bin/env python
import os
import subprocess
# > python subprocessdemote.py
# > sudo python subprocessdemote.py
def check_username():
export CLUSTER_DNS=[...]
export CLUSTER_IP=[...]
ssh -i workshop.pem docker@$CLUSTER_IP
docker container run -d --name jenkins -p 8080:8080 jenkins:alpine
docker container ls # Wait until it is up and running