Skip to content

Instantly share code, notes, and snippets.


Everton Ribeiro nuxlli

View GitHub Profile
nuxlli /
Last active Feb 7, 2022
Loading dotenv files with exports and interpolations without override the current vars
#!/usr/bin/env bash
# This function loads variables from a .env (dotenv format) files without
# override the current variables. It will fix the relative paths.
# Example:
# $ export ENV=developer
# $ cat dotenvs/.env
# ENV=staging
nuxlli / pre-push
Created Dec 1, 2020
A protection to not push code for main by accident
View pre-push
# Warn before pushing to protected branches
# - Make script executable with
# chmod +x pre-push
# - Bypass with:
# git push --no-verify
# - To add hooks on global configuration
# git config --global core.hooksPath [path for folder with hooks]
# References:
nuxlli /
Created Nov 19, 2020
List port by process on macOS
# Map LISTENing TCP ports to their PIDs using lsof
# e.g. netstat -an
# *.* 0 0 49152 0 LISTEN
# *.22 *.* 0 0 49152 0 LISTEN
import java.sql.SQLException;
import java.sql.DriverManager;
import java.sql.Connection;
public class TestConnect {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
System.out.println("Connection test...");
//you need create database with this name 'github-example-jdbc'
String url = System.getenv("RUNDECK_DATABASE_URL");
String user = System.getenv("RUNDECK_DATABASE_USERNAME");
nuxlli / accounts.sql
Last active Oct 21, 2020
Constraint uniq external reference for two rows
View accounts.sql
-- References:
-- 69463
-- Table Definition ----------------------------------------------
CREATE TABLE accounts (
id bigint DEFAULT nextval('id_seq'::regclass) PRIMARY KEY,
natural_person_id bigint,
legal_entity_id bigint,
CONSTRAINT chk_only_one_is_not_null CHECK (num_nonnulls(natural_person_id, legal_entity_id) = 1)
#!/usr/bin/env bash
set -e
bucket_bk_path="$1_$(date +%s)"
# Donwload a temporary file
aws s3 cp "${bucket_path}" "${tmp_file}"
View address_capture.exs
regex = ~r/^(?:(?<number1>\d{1,}|sn|s\/n)\s*[-,]?\s*)?(?<street>.*?)(?:\s*[-,]?\s*(?<number2>\d{1,}|sn|s\/n))?$/
streets = [
"201 Rua Almirante Calheiros",
"201, Rua Almirante Calheiros",
"201 - Rua Almirante Calheiros",
"sn Rua Almirante Calheiros",
"s/n, Rua Almirante Calheiros",
"Rua Almirante Calheiros 201",
"Rua Almirante Calheiros, s/n",
nuxlli /
Created Jul 6, 2020
Fish k8s alias and scripts
function av-exec
aws-vault exec $argv[1] -- $argv[2..-1]
function av-shell
av-exec $argv[1] fish
alias kexec-dev="kubectl-exec firma-dev"
alias kexec-stage="kubectl-exec firma-stage"
nuxlli / auth_context.ex
Created Dec 3, 2019
Absinthe middleware for auth with Guardian
View auth_context.ex
# Adaptação de
defmodule DemoWeb.AuthContext do
@moduledoc false
@behaviour Plug
import Plug.Conn
alias Guardian.Plug.Pipeline
View JSON.ex
defmodule Web.Graphql.Types.Scalars.JSON do
@moduledoc """
The Json scalar type allows arbitrary JSON values to be passed in and out.
Requires `{ :jason, "~> 1.1" }` package:
use Absinthe.Schema.Notation
scalar :json_text, name: "Json" do
The `Json` scalar type represents arbitrary json string data, represented as UTF-8