Skip to content

Instantly share code, notes, and snippets.

View pecigonzalo's full-sized avatar
🌊

Gonzalo Peci pecigonzalo

🌊
View GitHub Profile
@pecigonzalo
pecigonzalo / docker-dind-swarm-cluster.sh
Created June 9, 2017 17:32
Docker in Docker (dind) swarm creation script
#!/bin/bash
# set -x
MANAGER=${1:-3}
WORKER=${2:-0}
#=========================
# Creating cluster members
#=========================
@pecigonzalo
pecigonzalo / mbox2gg.py
Last active November 21, 2023 11:11 — forked from jacksonj04/mbox2gg.pl
mbox to Google Groups
#! /usr/bin/env python
# Import a mbox file to a Google Group using https://developers.google.com/admin-sdk/groups-migration/index
# You'll need to install https://developers.google.com/api-client-library/python/
# and enable Groups Migration API, read prerequisits of the API SDK
from __future__ import print_function
import mailbox
import StringIO
@pecigonzalo
pecigonzalo / delete_all_object_versions.sh
Last active July 25, 2022 21:12 — forked from weavenet/delete_all_object_versions.sh
Delete all versions (except latest) of all files in s3 versioned bucket using AWS CLI and jq.
#!/bin/bash
bucket=$1
set -e
echo "Removing all versions from $bucket"
versions=`aws s3api list-object-versions --bucket $bucket |jq '.Versions | .[] | select(.IsLatest | not)'`
markers=`aws s3api list-object-versions --bucket $bucket |jq '.DeleteMarkers'`
@pecigonzalo
pecigonzalo / rds-undo.sh
Last active July 14, 2022 14:07
Undo pending RDS changes
#!/usr/bin/env bash
set -euo pipefail
NAME="$1"
description=$(aws rds describe-db-instances --db-instance-identifier "$NAME")
instance_type=$(echo $description | jq -r '.DBInstances[0] | .DBInstanceClass')
allocated_storage=$(echo $description | jq -r '.DBInstances[0] | .AllocatedStorage')
@pecigonzalo
pecigonzalo / ofms.md
Created April 13, 2021 16:07 — forked from taion809/ofms.md
Observable F# Microservices

Observable FSharp Microservices (dotnetcore2.2+)

Let us define an observable microservice as one that exposes its internal state through events, metrics, and trace data. Ideally we can aggregate this data in some sort of centralized observability system for alerting and diagnostics. In my opinion there are tools that work much better than others and I will use those in this example but the most important part is that you have a starting point and your services can be observed and alerted on somehow. If your company does not have the means to setup all of this infrastructure you should consider buying one of the many SaaS options out today.

Disclaimer: I am not a native .net or F# developer, I think at this point in my career I've logged 2 weeks on an F# dev team so the implementations given below may not be idiomatic, however, my experience comes from being apart of both Devops and microservices dev teams in other teams and organizations.

That being said; let's start building an "observable" micro

@pecigonzalo
pecigonzalo / bootstrap.sh
Created January 9, 2022 16:38 — forked from pahud/bootstrap.sh
AWS SSO + Codespaces
#!/bin/bash
# video demo - https://www.youtube.com/watch?v=Y8TyE_DNds8
mkdir ~/.tmp && cd $_
# install aws-cli v2
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
sudo ./aws/install
@pecigonzalo
pecigonzalo / bootstrap.sh
Created January 9, 2022 16:37 — forked from pahud/bootstrap.sh
AWS SSO + Codespaces
#!/bin/bash
# video demo - https://www.youtube.com/watch?v=Y8TyE_DNds8
mkdir ~/.tmp && cd $_
# install aws-cli v2
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
sudo ./aws/install
@pecigonzalo
pecigonzalo / change.sh
Created December 20, 2021 08:22
Run command in folders
#!/usr/bin/env bash
set -euo pipefail
for repo in $(fd --type=directory -d 1); do
pushd $repo
${@:1:1} "${@:2}"
popd
done
@pecigonzalo
pecigonzalo / flake-direnv.md
Created December 7, 2021 14:49 — forked from inscapist/flake-direnv.md
Nix Flakes and Direnv on Mac OSX (Catalina)

Development environment with Nix Flakes and Direnv

This document is targeted at those who seek to build reproducible dev environment across machines, OS, and time.

It maybe easier for remote teams to work together and not spending hours each person setting up asdf/pyenv/rbenv, LSP servers, linters, runtime/libs. Nix is probably the closest thing to Docker in terms of development environment.

Flake is used here because it provides hermetic build, with absolutely no reliance on system environment (be it Arch/Catalina/Mojave). Also it freezes dependencies in flake.lock so builds are reproducible.

This gist provides the setup to develop Java/Clojure/Python applications on Nix. But it can be easily adapted to ruby, nodejs, haskell.

@pecigonzalo
pecigonzalo / tomcat.sh
Created December 14, 2015 03:42
Tomcat Init Script (Centos/RHEL/Fedora)
#!/bin/bash
#
# tomcatd Start Tomcat server
#
# chkconfig: - 80 20
# description: Tomcat Web Application Server
#
# processname: tomcat
# pidfile: /var/run/tomcat.pid