Skip to content

Instantly share code, notes, and snippets.

View robsonalves's full-sized avatar
🏠
Working from home

Robson Alves robsonalves

🏠
Working from home
View GitHub Profile
@robsonalves
robsonalves / list.txt
Created June 27, 2023 11:33 — forked from shortjared/list.txt
List of AWS Service Principals
a4b.amazonaws.com
access-analyzer.amazonaws.com
account.amazonaws.com
acm-pca.amazonaws.com
acm.amazonaws.com
airflow-env.amazonaws.com
airflow.amazonaws.com
alexa-appkit.amazon.com
alexa-connectedhome.amazon.com
amazonmq.amazonaws.com
@robsonalves
robsonalves / bash_aws_jq_cheatsheet.sh
Created June 15, 2022 14:48 — forked from lukeplausin/bash_aws_jq_cheatsheet.sh
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
@robsonalves
robsonalves / ecs-task-export-import.sh
Created October 19, 2021 02:49 — forked from pahud/ecs-task-export-import.sh
ECS Task export/import
# export the task def
family='TaskDefName'
$ aws ecs describe-task-definition --task-definition $family \
--query "taskDefinition.{family:family, taskRoleArn:taskRoleArn, executionRoleArn:executionRoleArn, networkMode:networkMode, containerDefinitions:containerDefinitions, volumes:volumes, placementConstraints:placementConstraints, requiresCompatibilities:requiresCompatibilities, cpu:cpu, memory:memory, tags:tags, pidMode:pidMode, ipcMode:ipcMode, proxyConfiguration:proxyConfiguration}" | jq 'del(.[] | nulls)' > taskDef.json
# import the task def into newFamily task family
$ aws ecs register-task-definition --cli-input-json file://taskDef.json --family newFamily
# one-liner
aws ecs describe-task-definition --task-definition $family \
@robsonalves
robsonalves / generate-ssh-key.sh
Created August 11, 2020 00:02 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@robsonalves
robsonalves / install-docker.md
Created May 30, 2020 02:32 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@robsonalves
robsonalves / buckets.tf
Created May 29, 2020 14:38 — forked from nagelflorian/buckets.tf
Terraform config for static website hosting on AWS
# AWS S3 bucket for static hosting
resource "aws_s3_bucket" "website" {
bucket = "${var.website_bucket_name}"
acl = "public-read"
tags {
Name = "Website"
Environment = "production"
}
@robsonalves
robsonalves / main.tf
Created May 29, 2020 14:38 — forked from danihodovic/main.tf
Terraform - static site using S3, Cloudfront and Route53
variable "aws_region" {
default = "eu-west-1"
}
variable "domain" {
default = "my_domain"
}
provider "aws" {
region = "${var.aws_region}"
@robsonalves
robsonalves / main.cs
Last active May 1, 2020 06:12
Infix to Postfix
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
//Console.Write("Infix Formule: ");
//string infix = Console.ReadLine();
string infix = "4.5+a5+.1215 + 1";
@robsonalves
robsonalves / gist:d5828239ab83f6849c1fb77c99e091af
Created April 13, 2020 17:33
CURL to Mensure ResponseTime
curl 'https://{{YOUR_WEB_SITE}}/' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: en-US,en;q=0.8,ja;q=0.6' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.86 Safari/537.36' -H 'Connection: keep-alive' --compressed -s -o /dev/null -w "%{time_starttransfer}\n"
@robsonalves
robsonalves / triangulo2.cs
Last active June 25, 2019 21:06 — forked from celiosouza2013/triangulo2.cs
Execício área triangulo utilizando classes, atributos e métodos
//Criando Classe
using System;
namespace Course
{
class Triangulo
{
private double A { get; set; }
private double B { get; set; }
private double C { get; set; }