Skip to content

Instantly share code, notes, and snippets.

View fabidick22's full-sized avatar
🦖
Working from home

Dickson A. fabidick22

🦖
Working from home
View GitHub Profile
@fabidick22
fabidick22 / round.py
Last active December 17, 2018 15:36
entero, flotante mas cercano python, redondear a un numero primo.
"""
EJEMPLOS:
get_round(2.25)
Out[3]: 2.5
get_round(2.30)
Out[4]: 2.5
get_round(2.55)
Out[5]: 3.0
"""
@fabidick22
fabidick22 / migrate-ecr.py
Last active March 12, 2024 21:25
Migrate AWS ECR images from one account to another in different regions
"""
MIT License
Copyright (c) 2021 fabidick22
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@fabidick22
fabidick22 / get-stacks.py
Last active November 6, 2019 20:53
Get all stack (CloudFormation) from Boto3 (Python)
import boto3 as b3
cf_b3 = b3.client("cloudformation", region_name="us-east-1")
def get_all_stacks():
"""
Function to get all stacks.
:return: (dict) Dict object
"""
@fabidick22
fabidick22 / server.js
Last active April 21, 2020 19:11
Express server file to integrate a static application with the Azure App-Services service. (Error: Cannot GET /path)
const express = require('express');
const server = express();
const options = {
index: ['index.html','hostingstart.html']
};
server.use('/', express.static(__dirname, options));
server.get('/*', (req, res) => {
res.sendFile(__dirname + "/" + options.index[1]);
@fabidick22
fabidick22 / send_notification_slack.py
Last active August 25, 2021 20:19
Send notification to Slack from a AWS Lambda function with Webhook (no python dependencies).
from datetime import datetime
from urllib.error import URLError, HTTPError
from urllib.parse import urlencode
from urllib.request import Request, urlopen
import json
import os
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# More details: https://github.com/maverick9000/zsh2000
CURRENT_BG='NONE'
SEGMENT_SEPARATOR_RIGHT='\ue0b2'
SEGMENT_SEPARATOR_LEFT='\ue0b0'
ZSH_THEME_GIT_PROMPT_UNTRACKED=" ✭"
ZSH_THEME_GIT_PROMPT_DIRTY=''
ZSH_THEME_GIT_PROMPT_STASHED=' ⚑'
ZSH_THEME_GIT_PROMPT_DIVERGED=' ⚡'
@fabidick22
fabidick22 / environments.env
Created August 19, 2021 16:01
environment variables defined in task definition by aws (ECS EC2)
AWS_EXECUTION_ENV=AWS_ECS_EC2
# more details about this endpoints: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-metadata-endpoint-v4.html
ECS_CONTAINER_METADATA_URI_V4=http://1.2.3.4/v4/291b4307-more-token
ECS_CONTAINER_METADATA_URI=http://1.2.3.4/v3/291b4307-more-token
@fabidick22
fabidick22 / .env
Created December 10, 2021 04:20
Configure minIO with s3 as gateway (IAM role)
MINIO_PORT=9000
MINIO_BUCKET_NAME=aws-bucket-name
MINIO_REGION=us-east-1
#Custom user and password
MINIO_ROOT_USER=mySuperUser
MINIO_ROOT_PASSWORD=mySuperPasswd123!
FILESYSTEM_DEFAULT=minio
mkdir /home/ubuntu/sobreplanos
aws s3 cp s3://sobreplanos-boilerplate/artifacts/sobreplanos.zip /home/ubuntu/sobreplanos.zip
cd /home/ubuntu/
unzip sobreplanos.zip -d sobreplanos
rm -rf sobreplanos.zip
cd sobreplanos
chown -R ubuntu:ubuntu /home/ubuntu
export PATH="/usr/share/rvm/rubies/ruby-2.6.8/lib/ruby/gems/2.6.0:/usr/share/rvm/gems/ruby-2.6.8@sobreplanos:/usr/share/rvm/gems/ruby-2.6.8@global/bin:/usr/share/rvm/rubies/ruby-2.6.8/bin:/usr/share/rvm/bin:/home/ubuntu/.nvm/versions/node/v14.15.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ubuntu/sobreplanos/bin:$PATH"
echo "##### INSTALL"
RAILS_ENV=production bundle install
@fabidick22
fabidick22 / gh-runner-token.py
Last active May 27, 2022 18:49
Script to get a github actions runner token (no dependencies)
#!/usr/bin/env python3
import urllib.request
import urllib.parse as req_parse
import os
import json
GITHUB_API = os.getenv("GITHUB_API", "https://api.github.com/{}")
RUNNER_SCOPE = os.getenv("GITHUB_API", "repo")
GITHUB_OWNER = os.getenv("GITHUB_OWNER")