Skip to content

Instantly share code, notes, and snippets.

View jcmartins's full-sized avatar

João Carlos Martins jcmartins

View GitHub Profile
@jcmartins
jcmartins / ec2node.rb
Last active January 14, 2016 14:15
Sensu EC2 remove client
require 'timeout'
require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-handler'
require 'fog'
class Ec2Node < Sensu::Handler
def filter; end
def handle
# #YELLOW
@jcmartins
jcmartins / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jcmartins
jcmartins / Docker utils
Last active August 1, 2017 15:27
Cleanup Docker
Delete all containers
docker rm -v $(docker ps -qa)
-v remove the volume
Delete all images
docker rmi $(docker images -q)
docker rmi $(docker images -q -f "dangling=true")
Removes all containers running under Docker, so use with caution.
docker ps -a | awk '{print $1}' | xargs docker kill
git reset --soft HEAD~1
git reset HEAD filexxx
@jcmartins
jcmartins / .vimrc
Last active January 14, 2016 14:10
.vimrc
filetype off " required
filetype plugin indent on
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@jcmartins
jcmartins / gist:ce8951db811086fc02f5
Last active October 31, 2019 15:11
Grafana with Google Auth
###GOOGLE Console DEV
Original JavaScript autorized
http://grafana.mydomain.com.br
URIs redirect autorized
http://grafana.mydomain.com.br:3000/login/google
### NGINX PROXY
server {
@jcmartins
jcmartins / sysctl.json
Last active September 22, 2015 17:48
sysctl parameters
{
"fs.file-max": "128000",
"net.core.netdev_max_backlog": "5000",
"net.core.somaxconn": "500",
"net.ipv4.ip_local_port_range": "10152 65500",
"net.ipv4.tcp_dsack": "0",
"net.ipv4.tcp_fack": "0",
"net.ipv4.tcp_fin_timeout": "30",
"net.ipv4.tcp_keepalive_intvl": "30",
"net.ipv4.tcp_keepalive_probes": "3",
@jcmartins
jcmartins / check_rds_disk.json
Last active September 24, 2015 16:46
sensu check json
{
"checks": {
"check_rds_disk": {
"type": "set",
"command": "/opt/sensu/embedded/bin/ruby ./check_rds.rb -i hostname_01 --disk-warning-over 70 --disk-critical-over 80 --period 1800",
"command": "/opt/sensu/embedded/bin/ruby ./check_rds.rb -i hostname_02 --disk-warning-over 40 --disk-critical-over 95 --period 1800",
"command": "/opt/sensu/e
@jcmartins
jcmartins / gem install nokogiri
Last active January 14, 2016 14:12
gem install nokogiri
Using system library
gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2/
@jcmartins
jcmartins / bash
Created January 5, 2016 19:41
List all running containers’ sizes and volumes:
for d in `docker ps | awk '{print $1}' | tail -n +2`; do
d_name=`docker inspect -f {{.Name}} $d`
echo "========================================================="
echo "$d_name ($d) container size:"
sudo du -d 2 -h /var/lib/docker/devicemapper | grep `docker inspect -f "{{.Id}}" $d`
echo "$d_name ($d) volumes:"
docker inspect -f "{{.Volumes}}" $d | sed 's/map\[//' | sed 's/]//' | tr ' ' '\n' | sed 's/.*://' | xargs sudo du -d 1 -h
done