Skip to content

Instantly share code, notes, and snippets.

View carlessanagustin's full-sized avatar

carles san agustin carlessanagustin

View GitHub Profile
@carlessanagustin
carlessanagustin / dockerlog_setup.sh
Last active December 20, 2018 05:08
Docker log setup - apply: wget -O - https://goo.gl/x86FN9 | sudo bash
#!/usr/bin/env bash
# empty log file: echo "" > $(docker inspect --format='{{.LogPath}}' <container_name_or_id>)
# apply: wget -O - https://goo.gl/x86FN9 | sudo bash
FILEPATH=/etc/docker/daemon.json
cat << EOF > $FILEPATH
{
"log-driver": "json-file",
@carlessanagustin
carlessanagustin / install_gsutils.sh
Last active November 27, 2018 11:22
Install & setup Google SDK tools in Ubuntu
#!/usr/bin/env bash
export SOURCE_FOLDER=/tmp
export DESTINATION_FOLDER=tmp
export BUCKET=backup_bucket
#echo "lalalalalala" > /tmp/lala.txt
# Service Account role: roles/storage.objectAdmin = Storage Object Admin
export KEY=Service_Account.json
export NEWUSER=mybackup
@carlessanagustin
carlessanagustin / Dockerfile
Last active August 8, 2018 07:26
Netcat in a Docker container
FROM alpine:latest
RUN apk add --no-cache netcat-openbsd
ENTRYPOINT [ "nc" ]
# usage...
# build: docker build -t netcat:latest .
# server: docker run --rm -p <hostPort>:<containerPort> netcat:latest -l <port>
# client: docker run --rm netcat:latest <hostname> <remotePort>
@carlessanagustin
carlessanagustin / Dockerfile
Created July 18, 2018 10:07
Dockerfile for testing Ansible roles with https://kitchen.ci and https://serverspec.org
FROM ruby:2.4.4-jessie
LABEL maintainer="Carles San Agustin"
WORKDIR /
RUN echo 'source "https://rubygems.org"\n \
gem "test-kitchen"\n \
gem "kitchen-docker"\n \
gem "kitchen-ansible"\n \
gem "net-ssh"\n \
@carlessanagustin
carlessanagustin / Dockerfile
Created July 6, 2018 14:15
GCloud with Service Account in a Dockerfile
# place a copy of the service account key next to this file and rename <gcp_service_account_key>
# build: docker build -t gcloud .
FROM ubuntu:18.04
COPY ./<gcp_service_account_key>.json /saccount_key.json
ENV private_key=/saccount_key.json
# install required packages
RUN apt-get update && apt-get install -y lsb-core curl ssh jq && \
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
@carlessanagustin
carlessanagustin / debug_python.md
Created July 3, 2018 09:39
Debugging Python with ipdb
  • Install library:
pip install ipdb
  • Add line info .py before control step:
import ipdb; ipdb.set_trace()
@carlessanagustin
carlessanagustin / ansible.md
Last active July 17, 2019 09:37
Ansible best practices for startups to enterprises
@carlessanagustin
carlessanagustin / TICK_cheatsheet.md
Last active December 13, 2018 12:56
TICK Cheat Sheet (Telegraf, InfluxDB, Chronograf & Kapacitor)

InfluxDB

Login to Influx CLI

influx -ssl -unsafeSsl
    USE telegraf

Launch Influx commands

@carlessanagustin
carlessanagustin / my_cheatsheet.sql
Last active June 21, 2018 10:38
MySQL Cheat Sheet
# Show users
SELECT User, Host, Password FROM mysql.user;
# Create backup user
GRANT ALL PRIVILEGES ON *.* TO `backup`@`localhost` IDENTIFIED BY 'backup_password';
@carlessanagustin
carlessanagustin / statuscake_ips.php
Last active July 12, 2024 08:44
Generate a list of StatusCake IP addresses to allow in firewall
<?php
/**
* Generate a list of Status Cake Ip addresses
* To add allowed IPs to Nginx or Firewall
* from: https://www.statuscake.com/kb/knowledge-base/what-are-your-ips/
*/
$statuscake_locations_json = "https://app.statuscake.com/Workfloor/Locations.php?format=json";
$locations = json_decode(file_get_contents($statuscake_locations_json));
$output = "#STATUS CAKE IPs" . "\n";