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 / docker_tags_delete.sh
Created December 20, 2017 21:48
Script to delete a list of docker image tags
#!/bin/bash
for i in $(seq $2 $3)
do
AMI="$1":"$i"
echo "Delete iamge: "$AMI
docker rmi -f $AMI
done
# Setup Cluster
for i in 1 2 3; do
docker-machine create -d virtualbox swarm-$i
done
eval $(docker-machine env swarm-1)
docker swarm init --advertise-addr $(docker-machine ip swarm-1)
@mario21ic
mario21ic / postgres
Created December 6, 2017 16:54 — forked from mmrwoods/postgres
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"'
@mario21ic
mario21ic / terraform.sh
Last active January 16, 2018 22:33
Script to work with terraform and workspaces inside of a docker container
#!/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=$*

HOWTO: Installing Vault On AWS Linux

This is quick howto for installing vault on AWS Linux, mostly to remind myself. At the end of this tutorial, you'll have a working vault server, using s3 for the backend, self signed certificates for tls, and supervisord to ensure that the vault server is always running, and starts on reboot.

Setting up S3

First things first, let's set up an s3 bucket to use as the storage backend for our s3 instance.

  1. From the AWS Mangement Console, go to the S3 console.

  2. Click on the Create Bucket button

@mario21ic
mario21ic / BaseDao.kt
Created October 28, 2017 20:50 — forked from florina-muntenescu/BaseDao.kt
Use Dao inheritance to reduce the amount of boilerplate code
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@mario21ic
mario21ic / installr331loki.sh
Created October 27, 2017 00:32 — forked from ccortezb/installr331loki.sh
install R 3.3.1 on Elementary OS loki with R studio RGTK 2.2 and Rattle for Data mining
# Get R (base) and a few dependencies for packages
sudo apt-get -y install r-base libapparmor1 libcurl4-gnutls-dev libxml2-dev libssl-dev
sudo su - -c "R -e \"install.packages('tidyverse', repos = 'http://cran.rstudio.com/')\""
sudo su - -c "R -e \"install.packages('devtools', repos='http://cran.rstudio.com/')\""
sudo su - -c "R -e \"devtools::install_github('daattali/shinyjs')\""
sudo su - -c "R -e \"install.packages('rmarkdown', repos='http://cran.rstudio.com/')\""
# install java8
sudo apt install openjdk-8-jdk
@mario21ic
mario21ic / main.py
Last active October 25, 2017 19:02
Python script to filter names and documents
#!/usr/bin/env python
import csv
import re
def extract_document(names_document):
return [int(s) for s in names_document.split() if s.isdigit()]
def extract_letters(names_document):
return " ".join(re.findall(r"(?i)\b[a-z]+\b", names_document))
@mario21ic
mario21ic / docker-compose.yml
Created October 24, 2017 21:23 — forked from franckweb/docker-compose.yml
Selenium Grid docker compose file with firefox and chrome
version: '2'
services:
seleniumhub:
container_name: seleniumhub
image: selenium/hub
ports:
- "4444:4444"
@mario21ic
mario21ic / postgres_queries_and_commands.sql
Created October 12, 2017 19:55 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'