Skip to content

Instantly share code, notes, and snippets.

View mbiemann's full-sized avatar

Marcell Biemann mbiemann

View GitHub Profile
@mbiemann
mbiemann / file_base_path.py
Created September 5, 2020 17:57
Python Get Script File Base Path (Directory)
import os
print(
os.path.dirname(os.path.abspath(__file__))+os.sep
)
@mbiemann
mbiemann / aws-cli.sh
Last active September 6, 2020 15:16
AWS CLI Commands
# S3 - Sync Local Directory (deleting cloud files if local files were deleted)
aws s3 sync ./ s3://bucket_name/ --delete
@mbiemann
mbiemann / hdfs.sh
Last active September 6, 2020 16:08
HDFS Commands
# List
hdfs dfs -ls /
# Delete Directory
hdfs dfs -rm -r /DIRECTORY
@mbiemann
mbiemann / aws-redshift.sql
Created September 8, 2020 15:09
AWS Redshift SQL Commands
-- CREATE EXTENAL SCHEMA
-- https://docs.aws.amazon.com/pt_br/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
CREATE EXTERNAL SCHEMA 'yourDatabase'
FROM DATA CATALOG DATABASE 'yourDatabase'
REGION 'us-east-1'
IAM_ROLE 'arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME';
@mbiemann
mbiemann / aws-hudi-add-partitions.py
Created September 9, 2020 04:13
Python script to run on AWS looking for all Apache Hudi Glue Table and Add Partition via Athena according to S3 files
import json,time
import boto3
athena_output = 's3://aws-athena-query-results-ACCOUNTID-REGION'
athena = boto3.client('athena')
glue = boto3.client('glue')
s3 = boto3.client('s3')
@mbiemann
mbiemann / candidates.json
Last active November 12, 2021 22:23
Game Of Thrones - Election Candidates
[
"Alice Stark",
"Bruno Arryn",
"Casie Tully",
"Desmond Greyjoy",
"Eliane Tarly",
"Fran Lannister"
]
@mbiemann
mbiemann / single-random-voting.py
Last active November 12, 2021 22:32
Game Of Thrones - Election Single Random Voting
import json, random
# load candidates file
candidates = json.load(open('candidates.json','r'))
# numbers of candidates
total_of_candidates = len(candidates)
# generate a random number
voting = random.randint(1,total_of_candidates)
# get the name of chosen candidate (array starts with zero)
chosen = candidates[voting-1]
@mbiemann
mbiemann / parallel-sequence-voting.py
Last active November 14, 2021 04:12
Game Of Thrones - Election Parallel Sequence Voting
import json, random, time
from multiprocessing import Process
candidates = json.load(open('candidates.json','r'))
total_of_candidates = len(candidates)
# people in sequence X district in parallel = total of voting
people_in_sequence = 3
district_in_parallel = 3
@mbiemann
mbiemann / colima-docker-apple-silicon.md
Last active February 28, 2024 22:13
Using colima and Docker Engine on Apple Silicon (M1 Chip)

Using colima and Docker Engine on Apple Silicon (M1 Chip)

This tutorial uses Homebrew to install colima and Docker.

It was tested on Apple MacBook Pro (13-inch, M1, 2020) 8G and macOS Monterey version 12.1 (21C52).

Uninstall any Docker version

Make sure you have fully uninstall any versions of Docker. You can check using:

@mbiemann
mbiemann / python-dev-env.md
Last active February 22, 2022 14:35
Python Development Environment

Python Development Environment

This tutorial will install:

  1. Homebrew
  2. pyenv
  3. venv

Pre-requirements