Skip to content

Instantly share code, notes, and snippets.

View tuxpower's full-sized avatar

José Gaspar tuxpower

  • Porto, Portugal
View GitHub Profile
This document contains all the web links for the book
Effective MySQL: Backup and Recovery by Ronald Bradford
http://effectivemysql.com/book/backup-recovery
Introduction
------------
http://www.mysql.com/about/legal/licensing/index.html
http://mysql.com
@tuxpower
tuxpower / docker_network_101
Last active August 22, 2016 13:53
Docker - Manipulating networks, names and aliases
$ docker network create blue
368305ab14a4b276905948806bc31f72df9e28bea6798336abe272f8fd1c0811
$ docker network create green
8b74c5d61262bc22bbcb8a045caba38e05b46116706ea26719e8be1061083336
$ docker run -d --name sky --net blue --net-alias things redis
d7c7b09fafe0823d2f428bce882b850e45fb5ea23b569e65b9d7ea7cb3c4b17f
$ docker run -d --name navy --net blue --net-alias things redis
eeb78a572ca66f208443fb19a2cc1d44a4c761da10727f322942860de87fa713
@tuxpower
tuxpower / docker_vault_wr_101
Created August 22, 2016 14:39
Docker - store secrets using Hashicorp Vault
$ cat vault.hcl
backend "consul" {
address = "consul:8500"
advertise_addr = "consul:8300"
scheme = "http"
}
listener "tcp" {
address = "0.0.0.0:8200"
tls_disable = 1
}
@tuxpower
tuxpower / docker_logs_101
Created August 22, 2016 15:07
Docker - Managing Log files
$ docker run -d --name redis-server redis
e1da6218780ad8243dfcaf83bd2f712ae981089510a1ba4b67f689f11db54f4a
$ docker logs --tail 10 redis-server
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
1:M 22 Aug 15:02:57.686 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
@tuxpower
tuxpower / docker_swam_101
Created August 22, 2016 18:56
Docker - Getting started with swam
$ docker-machine create -d virtualbox node1
$ docker-machine create -d virtualbox node2
$ docker swarm init --advertise-addr 192.168.99.100
Swarm initialized: current node (3e9deoyqmm4q95xmxegtlusi0) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join \
--token SWMTKN-1-05ii9ckfw8evswg3spzgtef8pvy9l2e1izzp16k0gxtwchr96u-b7q7ksfqdum2jrybdsb9qobrx \
$ docker-machine create --driver virtualbox swarm-1
$ docker-machine create --driver virtualbox swarm-2
$ docker-machine create --driver virtualbox swarm-3
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
swarm-1 - virtualbox Running tcp://192.168.99.100:2376 v1.12.1
swarm-2 * virtualbox Running tcp://192.168.99.101:2376 v1.12.1
@tuxpower
tuxpower / centos_oracle_java8_install.sh
Last active August 24, 2016 15:06
Oracle Java 8 unattended linux installation
#!/usr/bin/env bash
# Dear Oracle: I know you employ more lawyers than engineers, but FFS please just make it possible to download that package with a simple curl or wget.
# Oh, and the fact that the certificate is invalid means that if this did come to a lawsuit, people would just claim that a MITM attack forged their agreement to the licence.
wget -q --no-cookies --no-check-certificate --header \
"Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u102-b14/jdk-8u102-linux-x64.rpm"
sudo yum localinstall -y jdk-8u102-linux-x64.rpm

MongoDB Practice

MongoDB Exercise in mongo shell

Connect to a running mongo instance, use a database named mongo_practice.

Document all your queries in a javascript file to use as a reference.

Insert Documents

When using --filters option always check which ones are supported e.g. 'aws ec2 describe-vpcs help' (dhcp-options-id, isDefault, state, vpc-id).

Otherwise use tag-key and tag-value for key/value combination of a tag assigned to the resource:

$ aws ec2 describe-vpcs --profile xxx-sandbox --filters Name=tag-key,Values=Name Name=tag-value,Values=myVPC

{
    "Vpcs": [
        {
            "VpcId": "vpc-55de7c32",

List AWS regions and parsing using jq:

$ aws ec2 describe-regions | jq '.Regions[].RegionName'

"ap-south-1"
"eu-west-1"
"ap-southeast-1"
"ap-southeast-2"
"eu-central-1"
"ap-northeast-2"