Skip to content

Instantly share code, notes, and snippets.

View maiconbaumx's full-sized avatar

Maicon Baum maiconbaumx

  • Sicredi
  • Porto Alegre
View GitHub Profile
@fnichol
fnichol / README.md
Last active August 17, 2020 14:41
A Windows/Linux/macOS PowerShell Rustup Install Script

A Windows/Linux/macOS PowerShell Rustup Install Script

On Windows, run

& ([scriptblock]::Create((New-Object System.Net.WebClient).DownloadString('https://gist.github.com/fnichol/699d3c2930649a9932f71bab8a315b31/raw/rustup-init.ps1')))

in a PowerShell session. This downloads and runs rustup-init.ps1, which in turn downloads and runs the correct version of the rustup-init executable on

@wknapik
wknapik / empty_bucket.sh
Last active March 5, 2024 09:53
Empty an s3 bucket of all object versions and delete markers in batches of 400
#!/usr/bin/env bash
set -eEo pipefail
shopt -s inherit_errexit >/dev/null 2>&1 || true
if [[ ! "$#" -eq 2 || "$1" != --bucket ]]; then
echo -e "USAGE: $(basename "$0") --bucket <bucket>"
exit 2
fi
@andreas-wilm
andreas-wilm / nvmraid.sh
Last active June 5, 2023 22:11
Combine all NVMs on AWS instance (e.g. i3) as raid0 and mount as data
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/raid-config.html
nvmes=$(sudo lsblk | awk '/^nvme/ {printf "/dev/%s ", $1}')
sudo mdadm --create --verbose /dev/md0 --level=0 --name=my_raid --raid-devices=$(echo $nvmes | wc -w) $nvmes
sleep 10# crutch
sudo mkfs.ext4 -L my_raid /dev/md0
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.conf
sudo dracut -H -f /boot/initramfs-$(uname -r).img $(uname -r)
sudo mkdir /data
sudo mount LABEL=my_raid /data
sudo chown ec2-user:ec2-user /data/
@lestephane
lestephane / Dockerfile
Created September 10, 2017 19:35
Dockerized terraform bundler
FROM golang:alpine
RUN apk update && apk upgrade && \
apk add --no-cache git zip
ARG TERRAFORM_VERSION
RUN git clone --single-branch --branch v${TERRAFORM_VERSION} https://github.com/hashicorp/terraform.git /go/src/github.com/hashicorp/terraform
RUN cd $GOPATH/src/github.com/hashicorp/terraform && echo $GOPATH && go install ./tools/terraform-bundle
@bojand
bojand / index.md
Last active March 1, 2024 19:32
gRPC and Load Balancing

Just documenting docs, articles, and discussion related to gRPC and load balancing.

https://github.com/grpc/grpc/blob/master/doc/load-balancing.md

Seems gRPC prefers thin client-side load balancing where a client gets a list of connected clients and a load balancing policy from a "load balancer" and then performs client-side load balancing based on the information. However, this could be useful for traditional load banaling approaches in clound deployments.

https://groups.google.com/forum/#!topic/grpc-io/8s7UHY_Q1po

gRPC "works" in AWS. That is, you can run gRPC services on EC2 nodes and have them connect to other nodes, and everything is fine. If you are using AWS for easy access to hardware then all is fine. What doesn't work is ELB (aka CLB), and ALBs. Neither of these support HTTP/2 (h2c) in a way that gRPC needs.

@lukeplausin
lukeplausin / bash_aws_jq_cheatsheet.sh
Last active January 29, 2024 10:00
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
@yegorg
yegorg / sysctl.conf
Created September 20, 2016 09:28
ubuntu sysctl performance tuning
# Kernel sysctl configuration file for Linux
#
# Version 1.12 - 2015-09-30
# Michiel Klaver - IT Professional
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant
#
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details.
@hermes-pimentel
hermes-pimentel / tag-ebs.py
Last active October 14, 2022 07:52
Copy tags from EC2 to EBS
# set variable AWS_PROFILE= to credentials
import boto3
# CHANGE REGION HERE-
ec2 = boto3.resource('ec2', 'sa-east-1')
#check your own tags before run this script
#loop for tag Name
def tag_name():
print "Loop for TAG Name"
for volume in ec2.volumes.all():
@hermes-pimentel
hermes-pimentel / NAT-HA.sh
Last active August 3, 2016 16:01
NAT HA with only one machine. (ASG)
#!/bin/sh
#1) Create your private subnet, SGs, and etc... and get the route table ID from privates subnets that need a NAT instance / allocate a new Elastic IP and get the ID.
#2) create a launch configuration with the script bellow (dont use user-data text, upload a file with '.sh' extension)
# use the this policy in AMI role:
#ec2-role-policy
# {
# "Version": "2012-10-17",
# "Statement": [
# {
@hermes-pimentel
hermes-pimentel / elb-cf-logs-parser.sh
Last active December 27, 2017 12:59
ELB/CF Parser
#download files from bucket
#group logs
cat *.log >> single.txt && mv single.txt single.log
#IPS GET
cat single.log| grep -v POST | awk '{print $3}' | cut -d : -f 1 | sort | uniq -c | sort -nr
#IPS POST
cat single.log| grep -v GET | awk '{print $3}' | cut -d : -f 1 | sort | uniq -c | sort -nr