Skip to content

Instantly share code, notes, and snippets.

View julianobarbosa's full-sized avatar
💭
I may be slow to respond.

Juliano Barbosa julianobarbosa

💭
I may be slow to respond.
View GitHub Profile
@julianobarbosa
julianobarbosa / clean_code.md
Created April 1, 2025 15:25 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

- After making changes, ALWAYS make sure to start up a new server so I can test it.
- Always look for existing code to iterate on instead of creating new code.
- Do not drastically change the patterns before trying to iterate on existing patterns.
- Always kill all existing related servers that may have been created in previous testing before trying to start a new server.
- Always prefer simple solutions
- Avoid duplication of code whenever possible, which means checking for other areas of the codebase that might already have similar code and functionality
- Write code that takes into account the different environments: dev, test, and prod
- You are careful to only make changes that are requested or you are confident are well understood and related to the change being requested
- When fixing an issue or bug, do not introduce a new pattern or technology without first exhausting all options for the existing implementation. And if you finally do this, make sure to remove the old implementation afterwards so we d
"Code Gen Instruction": {
"prefix": "instruction-codegen",
"body": [
"\t\"github.copilot.chat.codeGeneration.instructions\": [",
"\t\t{",
"\t\t\t\"text\": \"use JavaScript for all code. use camelCase for variable names, PascalCase for class names. Use spaces for indentation. Use single quotes for strings. Use 2 spaces for indentation.\"",
"\t\t}",
"\t],"
]
@julianobarbosa
julianobarbosa / login-via-pim.sh
Created February 25, 2025 16:45 — forked from paolosalvatori/login-via-pim.sh
This Bash script allows to login to a given Azure Subscription using Microsoft Entra Privileged Identity Management (PIM)
#!/bin/bash
# Variables
SUBSCRIPTION_ID=$(az account show --query id --output tsv) # Subscription ID
ROLE_NAME="8e3af657-a8ff-443c-a75c-2fe8c4bcb635" # Owner role
ROLE_DEFINITION_ID="/subscriptions/${SUBSCRIPTION_ID}/providers/Microsoft.Authorization/roleDefinitions/${ROLE_NAME}" # Role definition resource ID
PRINCIPAL_ID=$(az ad user show --id $(az account show --query user.name -o tsv) --query id -o tsv) # Your account object ID
ROLE_ASSIGNMENT_ID=$(uuidgen) # Generate a unique GUID for the role assignment
JUSTIFICATION="I need access to [$(az account show --query name --output tsv)] Azure subscription" # Justification for the role assignment
API_VERSION="2020-10-01" # API version
@julianobarbosa
julianobarbosa / devbox.sh
Last active January 8, 2025 12:37 — forked from vfarcic/devbox.sh
###############################################################
# Nix for Everyone: Unleash Devbox for Simplified Development #
###############################################################
# Additional Info:
# - Devbox: https://www.jetpack.io/devbox
# - Say Goodbye to Containers - Ephemeral Environments with Nix Shell: https://youtu.be/0ulldVwZiKA
# - Say Goodbye to Makefile - Use Taskfile to Manage Tasks in CI/CD Pipelines and Locally: https://youtu.be/Z7EnwBaJzCk
#########
@julianobarbosa
julianobarbosa / .tmux.conf
Created January 1, 2023 16:00 — forked from kawaz/.tmux.conf
tpm auto install
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm'"
@julianobarbosa
julianobarbosa / lambda_function.py
Created January 18, 2022 00:30 — forked from gregarious-repo/lambda_function.py
AWS Lambda to stop or start EC2 instances based on the instance tags.
import boto3
import time
##
# First function will try to filter for EC2 instances that contain a tag named `Scheduled` which is set to `True`
# If that condition is meet function will compare current time (H:M) to a value of the additional tags which defines the trigger `ScheduleStop` or `ScheduleStart`.
# Value of the `ScheduleStop` or `ScheduleStart` must be in the following format `H:M` - example `09:00`
#
# In order to trigger this function make sure to setup CloudWatch event which will be executed every minute.
# Following Lambda Function needs a role with permission to start and stop EC2 instances and writhe to CloudWatch logs.
@julianobarbosa
julianobarbosa / stress.sh
Created September 12, 2021 15:51 — forked from mikepfeiffer/stress.sh
Install Stress Utility on Amazon Linux 2
sudo amazon-linux-extras install epel -y
sudo yum install stress -y

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r
@julianobarbosa
julianobarbosa / run-ansible-with-any-host-without-inventory
Created November 17, 2019 22:15 — forked from lilongen/run-ansible-with-any-host-without-inventory
How to run Ansible without specifying the inventory but the host directly?
Question:
. How to run Ansible without specifying the inventory but the host directly?
. Run a playbook or command with arbitrary host not in the inventory hosts list?
. run ansible with arbitrary host/ip without inventory?
Answer:
Surprisingly, the trick is to append a ,
The host parameter preceding the , can be either a hostname or an IPv4/v6 address.
ansible all -i example.com,