Skip to content

Instantly share code, notes, and snippets.

View PauloMigAlmeida's full-sized avatar
🏄‍♂️

Paulo Miguel Almeida PauloMigAlmeida

🏄‍♂️
View GitHub Profile
@PauloMigAlmeida
PauloMigAlmeida / user-mode-linux-alpine-steps.sh
Last active October 25, 2024 22:45 — forked from hughpearse/user-mode-linux-alpine-steps.txt
User Mode Linux (UML) Kernel With Alpine Linux OS
How to compile the linux kernel, launch it as a process and boot into Alpine linux
#Command + Shift + 5
#Host -> Docker GCC -> UML w/ Alpine
# create and mount the filesystem
sudo rm -rf ~/workspace/root_fs_um
mkdir -p ~/workspace/root_fs_um
cd ~/workspace/root_fs_um
dd if=/dev/zero of=root_fs bs=1M count=1024
@PauloMigAlmeida
PauloMigAlmeida / main.tf
Created March 25, 2024 03:26
EMR Serverless Terraform provisioning
# Assuming that you have AWS cli installed and configured.
# To run:
# terraform init
# terraform plan -out terraform.tfplan
# terraform apply terraform.tfplan
provider "aws" {
region = "ap-southeast-2"
}
@PauloMigAlmeida
PauloMigAlmeida / paging.asm
Last active May 13, 2021 10:10
10MB identity-mapped paging x86-64
; Mem definition
PML4.Addr equ 0x00010000 ; PML4
PDPE.Addr equ 0x00011000 ; 0x10000 + PML4 (512 entries of 64 bits)
PDE.Addr equ 0x00012000 ; 0x11000 + PDPE (512 entries of 64 bits)
PTE.Addr equ 0x00013000 ; 0x12000 + PDE (512 entries of 64 bits)
; Setup pages structure and flag bits
; Present (bit 1) and ReadWrite(bit 2) bits are set
.StdBits equ 0x03
@PauloMigAlmeida
PauloMigAlmeida / glacier_basic_calculator.py
Created July 17, 2018 20:16
glacier_basic_calculator.py
# ap-souteast-2 prices only for now
import math
import sys
upload_requests_price_per_thousand = 0.06
storage_price_per_gb = 0.005
standard_retrieval_price_per_gb = 0.012
standard_retrieval_price_per_1000_requests = 0.06
free_tier_retrieve_per_month = 10
@PauloMigAlmeida
PauloMigAlmeida / list_amazonlinux_amis.sh
Created October 17, 2017 08:56
List latest Amazon Linux AMIs in every AWS region
for region in $(aws ec2 describe-regions --query "Regions[].RegionName" --output json | jq -r '.[]'); do
echo "$region = $(aws ec2 describe-images --owners amazon --filters 'Name=name,Values=amzn-ami-hvm-????.??.?.x86_64-gp2' --query 'sort_by(Images, &CreationDate) | [-1].ImageId' --region $region)"
done

Keybase proof

I hereby claim:

  • I am PauloMigAlmeida on github.
  • I am paulomigalmeida (https://keybase.io/paulomigalmeida) on keybase.
  • I have a public key whose fingerprint is 72C3 8C20 51A2 0BED 8CFF D7C4 AD41 6024 41C7 75EC

To claim this, I am signing this object:

@PauloMigAlmeida
PauloMigAlmeida / find_ami_in_multiple_regions.sh
Last active March 4, 2021 17:11
Utility script that allows you to find the same ami(name) across multiple regions
#!/bin/bash
# Author: Paulo Miguel Almeida <[email protected]>
#
# Desc: Utility script that allows you to find the same ami(name) across multiple regions.
# For instance, let's suppose that you want to find the Ubuntu Server 16.04 LTS HVM SSD
# to build a nice cloudformation template. Note that you can play around with the filters
# that AWSCLI provides. Have fun ;)
# Usage:
# find_ami_in_multiple_regions.sh ami-e93da085 (Obs.: This ami must be at same region your AWS is set)
@PauloMigAlmeida
PauloMigAlmeida / find_class_directory.sh
Created August 12, 2015 19:52
Search Java class within a directory. It's particularly useful when dealing with Maven conflicts.
#!/bin/bash
# Usage ./find_class_directory.sh <folder> <class>
# Example: ./find_class_directory.sh WEB-INF/lib SignatureReader
TARGET_DIR=$1
TARGET_CLASS=$2
LIST_FILES=$(ls -1 $TARGET_DIR | grep -i -e ".*\.jar")
while read -r line; do
@PauloMigAlmeida
PauloMigAlmeida / download.sh
Created July 28, 2015 20:57
Downlads today's files from a AWS S3 bucket
#/bin/bash
# Usage ./download.sh <bucket_name> <target_folder>
# Example: ./download.sh test ./files_today
# Note: you must configure your awscli before use this. Execute aws configure
BUCKET_NAME=$1
TARGET_DIR=$2
FILES_LIST=$TARGET_DIR/files.txt
@PauloMigAlmeida
PauloMigAlmeida / Makefile
Created February 18, 2015 21:31
OpenCV CascadeClassifier example for face detection
# Makefile
ifeq ($(shell pkg-config --modversion opencv),)
$(error Package gtkmm-2.4 needed to compile)
endif
CXXFLAGS += `pkg-config --cflags opencv`
LDLIBS += `pkg-config --libs opencv`
BINS = program
program_OBJS = main.o