Skip to content

Instantly share code, notes, and snippets.

View willianantunes's full-sized avatar
🎯
Focusing

Willian Antunes willianantunes

🎯
Focusing
View GitHub Profile
@willianantunes
willianantunes / azure_devops_project_stats.py
Created October 27, 2021 20:52
Azure DevOps: Collect metrics given a project from an organization
import base64
import json
import sys
import urllib.parse
from urllib.request import Request
from urllib.request import urlopen
print("Collecting parameters...")
organization_name, project_id, user_with_token = sys.argv[1], sys.argv[2], sys.argv[3]
#!/bin/bash
# https://askubuntu.com/a/1178685
# Args
INTERFACE=$1
ACTION=$2
# Check if the OpenVPN interface will be indeed tun0!
if [ "$INTERFACE" = "tun0" ]; then
@willianantunes
willianantunes / honest-bash-situation.sh
Created June 16, 2021 21:50
Import environment variables from a file (GitHub Actions
while read line; do
if [[ $line =~ ^([a-z]|[A-Z]).+ ]]; then
echo "Settings the following ==> $line"
echo "$line" >> $GITHUB_ENV
fi
done < .env.development
@willianantunes
willianantunes / lag_ruby_server.rb
Created September 27, 2020 14:28
It's like my project runner-said-no-one-ever, but far more simple
require 'cgi'
require 'socket'
require 'logger'
require 'json'
require 'faker'
logger = Logger.new(STDERR)
server = TCPServer.new(ENV.fetch('PORT', 8000).to_i)
time_to_be_delayed = ENV.fetch('DELAY_ANSWER_IN_SECONDS', 1).to_i
@willianantunes
willianantunes / project_version_pypi.py
Created November 19, 2019 17:14
You can use it in your Azure DevOps pipeline to create new flows
import sys
from json import load
from urllib.request import urlopen
# $(Build.Repository.Name) is expected as parameter
organization, app_name = sys.argv[1].split("/")
env_should_publish = "ENV_SHOULD_PUBLISH"
def return_line_which_has_value(file_name: str, value_to_be_found: str) -> str:
@willianantunes
willianantunes / check-image-build-it-if-needed.sh
Last active July 27, 2019 22:07
Check if an image exists and built it if not
function docker_tag_exists() {
if [[ $# -lt 2 ]]; then
echo "Usage: $( basename $0 ) <repository-name> <image-tag>"
exit 1
fi
IMAGE_META="$( aws ecr describe-images --repository-name=$1 --image-ids=imageTag=$2 2> /dev/null )"
if [[ $? == 0 ]]; then
echo $IMAGE_META
@willianantunes
willianantunes / set_env_variable.py
Created July 7, 2019 16:14
Sample logic about how to set variable on Azure DevOps
import os
import sys
branch_name: str = sys.argv[1]
print(f"Received argument: {branch_name}")
env_image_type = "ENV_IMAGE_TYPE"
def set_value(key, value):
print(f"Set key {key} as {value}")
@willianantunes
willianantunes / version_strategy.py
Last active July 25, 2019 14:02
Python Script following SemVer (Semantic Versioning) integrated with GitHub to use in Azure DevOps
import json
import sys
import urllib.request
def set_value(key, value):
print(f"Set key {key} as {value}")
print(f"##vso[task.setvariable variable={key};]{value}")
@willianantunes
willianantunes / django_console.py
Created March 2, 2019 16:21
Starting script to enable Django Console in IntelliJ IDEA Ultimate
import os
import sys
from runpy import run_module
import django
from django.core import management
print(f"Python {sys.version} on {sys.platform}")
print(f"Django {django.get_version()}")
print(f"Current dir: {os.getcwd()}")
package br.com.globo.aop;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class PointCuts {