Skip to content

Instantly share code, notes, and snippets.

View Pierozi's full-sized avatar

Pierre Tomasina Pierozi

View GitHub Profile
@Pierozi
Pierozi / https-redirect-nginx.conf
Created March 12, 2018 10:05
Nginx configuration for HTTPS redirection
user www-data;
worker_processes 2;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
http {
@Pierozi
Pierozi / stopinator.sh
Created January 22, 2018 13:31
Automatic Stop AWS EC2 Bastion Instance each hour if no SSH connection established
#!/bin/bash
# Copyright (c) 2018, Pierre Tomasina
INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
EC2_REGION=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | rev | cut -c 2- | rev`
SSH_RUNNING=`netstat -nap | grep ESTABLISHED | grep sshd`
uptimeMore60min=`cat /proc/uptime | awk '{print $1/60" > 60"}' | bc -l`
if [ 0 -eq $uptimeMore60min ];then
{
"variables": {
"profile" : "{{env `AWS_PROFILE`}}",
"region" : "{{env `AWS_REGION`}}",
"build_vpc" : "{{env `VPC_ID`}}",
"build_subnet" : "{{env `SUBNET_ID`}}",
"build_instance_type" : "{{env `AWS_INSTANCE_TYPE`}}",
"source_ami" : "{{env `AWS_SOURCE_AMI`}}",
"distribution" : "Amazon Linux",
"distribution_user" : "{{env `AWS_AMI_USER`}}",
@Pierozi
Pierozi / cloudformation.sh
Created January 15, 2018 12:36
AWS Cloudformation check and upload to S3
#!/bin/bash -
#title :cloudformation
#description :handle cloudformation command
#author :© 2016 Continuous SA - Tomasina Pierre
#date :20170202
#version :0.1
#usage :bash cloudformation [OPTIONS] action
#notes :Requirement : aws-cli
#==============================================================================
@Pierozi
Pierozi / generic_trait_type_hint.rs
Created December 27, 2017 08:47
Genric trait implementation type hint issue in RUST Lang
trait Provide {
fn credentials(&self) -> bool;
}
struct StaticProvider {
foo: String
}
impl StaticProvider {
pub fn new(value: String) -> StaticProvider {
return StaticProvider {
@Pierozi
Pierozi / SemverObject.php
Created December 19, 2017 13:33
ValueObject of Sementic Versioning
<?php
namespace My\Vendor;
/**
* Class SemverObject
*/
final class SemverObject
{
protected $major;
@Pierozi
Pierozi / .tmux.conf
Created May 29, 2017 09:15
Tmux config
set -g default-terminal "xterm"
set -g default-terminal "screen-256color"
set-option -g default-shell /usr/bin/zsh
set -g prefix C-a
unbind C-b
bind C-a send-prefix
set -s escape-time 1
set -g base-index 1
@Pierozi
Pierozi / rxjs.multiplyBy.js
Created April 6, 2017 08:02
RxJs Operator multiplyBy
// Credit andre-staltz
// from : https://egghead.io/instructors/andre-staltz
const data = [1,2,3,4,5];
var foo = Rx.Observable.of(...data);
// foo.map
// foo.filter
// foo.merge
// foo.combineLatest
@Pierozi
Pierozi / HoaOptionSnippet.php
Created February 17, 2017 10:21
HoaOption
<?php
namespace Hoa\Option;
interface Option
{
public function isSome() : bool;
public function isNone() : bool;
}
#!/bin/bash
RATE=5
CEIL=1
echo -e "Clean rules"
/sbin/tc qdisc del dev eth0 root
echo -e "Turn on queueing discipline"
/sbin/tc qdisc add dev eth0 root handle 1: htb default 15