Skip to content

Instantly share code, notes, and snippets.

View arthuralvim's full-sized avatar

Arthur Alvim arthuralvim

View GitHub Profile
@nivleshc
nivleshc / ansible-aws-inventory-main.yml
Created April 12, 2019 03:43
The main inventory file - declare variables here. This calls the worker file (which must be prese
---
# Name: ansible-aws-inventory-main.yml
# Description: this is the main file that calls the worker file (ansible-aws-inventory-worker.yml) to create an inventory of all the
# specific aws resources.
# Below are the resources that will be inventoried
# - vpc
# - subnet
# - igw
# - cgw
# - vgw
@GuillaumeDesforges
GuillaumeDesforges / changetheme.sh
Last active May 9, 2023 17:09
Bash one liner to set Zsh theme with oh-my-zsh default setup
# Just change the first THEME variable to whatever theme you want. The line will edit, reload and print you the changed line in the .zshrc file
THEME="ys"; sed -i s/^ZSH_THEME=".\+"$/ZSH_THEME=\"$THEME\"/g ~/.zshrc && source ~/.zshrc && echo "Edited line in ~/zshrc :" && cat ~/.zshrc | grep -m 1 ZSH_THEME
[server]
SERVER
[server:vars]
server_name=SERVER
email=noc@gopractice.io
docker_nginx_ssl=true
@steinwaywhw
steinwaywhw / AWS Lambda: Hello World.md
Last active March 8, 2022 10:40
An extremely simple AWS Lambda example in Python 3.

Preface

In general, AWS services can be accessed using

  1. AWS web interface,
  2. API libraries in a programming language, such as boto3 for Python 3,
  3. AWS command-line interface, i.e. awscli.

I opted for the API library since it is

@mapa17
mapa17 / pyexcelerate_to_excel.py
Created September 4, 2018 19:46
A helper function to write pandas.DataFrame to excel using pyexcelerate
import pandas as pd
import numpy as np
import timeit
import pyexcelerate
def pyexecelerate_to_excel(workbook_or_filename, df, sheet_name='Sheet1', origin=(1,1), columns=True, index=False):
"""
Write DataFrame to excel file using pyexelerate library
"""
@katzefudder
katzefudder / Dockerfile
Last active December 6, 2022 07:44
AWS CLI dockerized with Alpine Linux
FROM alpine:3.14
ENV AWSCLI_VERSION "1.20.7"
RUN apk add --update \
python3 \
python3-dev \
py-pip \
build-base \
&& pip install awscli==$AWSCLI_VERSION --upgrade --user \
@nqbao
nqbao / ssm_parameter_store.py
Last active March 21, 2024 00:15
Python class to provide a dictionary-like interface to access AWS SSM Parameter Store easily
# Copyright (c) 2018 Bao Nguyen <b@nqbao.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
@rjurney
rjurney / terminate_all_ec2.sh
Last active November 19, 2020 22:55
Bash script to disable termination protection and then terminate all instances in all regions :)
for region in `aws ec2 describe-regions | jq -r .Regions[].RegionName`
do
echo "Terminating region $region..."
aws ec2 describe-instances --region $region | \
jq -r .Reservations[].Instances[].InstanceId | \
xargs -L 1 -I {} aws ec2 modify-instance-attribute \
--region $region \
--no-disable-api-termination \
--instance-id {}
aws ec2 describe-instances --region $region | \
@doi-t
doi-t / getting-start-with-AWS-Batch.md
Last active January 2, 2023 09:50
A log of getting start with AWS Batch.
@luizbraga
luizbraga / collection_size.py
Created October 4, 2017 14:43
List collections, size and count of documents on MongoDB
from pymongo import MongoClient
MONGO_URI = ''
DATABASE_NAME = ''
client = MongoClient(MONGO_URI)
db = client[DATABASE_NAME]
collections = db.collection_names()
def readable_size(file_size):