Skip to content

Instantly share code, notes, and snippets.

View fnavalca's full-sized avatar

Fran Navarro Alcaraz fnavalca

View GitHub Profile
@fnavalca
fnavalca / aws_resources_finder.sh
Last active October 16, 2020 09:03
AWS resources finder by subnet IDs
#!/usr/bin/env bash
# Add all the subnet ID you want to find resources
declare -a subnets=("subnet-id")
echo "Removing all previous data"
rm -rf rds_*.txt ec2_*.txt redshift_*.txt elasticache_*.txt codebuild_*.txt lambda_*.txt
find_rds () {
echo "Finding RDS for $1"
@fnavalca
fnavalca / list_enabled_services_systemctl.md
Created March 12, 2020 12:13
List all enabled services from systemctl

Command to list all services in systemctl:

systemctl list-unit-files

If you want to filter by enabled:

systemctl list-unit-files --state=enabled
@fnavalca
fnavalca / delete_commit_local_and_remote.md
Last active January 20, 2020 14:14
Delete a commit in Git: local and remote

Deleting commit

Delete a local commit

If it is the last commit you do you can do it with:

git reset --hard HEAD~
@fnavalca
fnavalca / remove_all_branches_merged_to_master_from_local.md
Created December 8, 2019 20:10
Remove all branches merged to master from local

First of all, you must to be updated with your remote.

After that, the command is:

 git branch --merged | grep -v "\*" | grep -v master | grep -v dev | xargs -n 1 -I {} git branch -d {}

Explanation:

  • git branch --merged: list only branches merged into HEAD of current branch
@fnavalca
fnavalca / existing_project_to_github_repository.md
Last active December 8, 2019 19:49
Add an existing project to GitHub repository

The first thing you must to do is create a new repo on GitHub. Do not create it with any file (README, license or gitignore). We can add these files after.

So go ahead:

% echo "# Test project" > README.md
% git init
Initialized empty Git repository in /Users/example/Projects/example/.git/
% git add .