View load_dotenv.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
View pre-push
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 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: |
View port_pid.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Map LISTENing TCP ports to their PIDs using lsof | |
LSOF=/usr/sbin/lsof | |
# e.g. netstat -an | |
# 127.0.0.1.25 *.* 0 0 49152 0 LISTEN | |
# *.22 *.* 0 0 49152 0 LISTEN |
View TestConnect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
View accounts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- References: | |
-- https://stackoverflow.com/a/55223096/4constraint 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) |
View s3_edit.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
bucket_path=$1 | |
bucket_bk_path="$1_$(date +%s)" | |
tmp_file=$(mktemp) | |
# Donwload a temporary file | |
aws s3 cp "${bucket_path}" "${tmp_file}" |
View address_capture.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
View init.fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function av-exec | |
aws-vault exec $argv[1] -- $argv[2..-1] | |
end | |
function av-shell | |
av-exec $argv[1] fish | |
end | |
alias kexec-dev="kubectl-exec firma-dev" | |
alias kexec-stage="kubectl-exec firma-stage" |
View auth_context.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adaptação de http://www.east5th.co/blog/2017/05/08/graphql-authentication-with-elixir-and-absinthe/ | |
defmodule DemoWeb.AuthContext do | |
@moduledoc false | |
@behaviour Plug | |
import Plug.Conn | |
alias Guardian.Plug.Pipeline |
View JSON.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: https://github.com/michalmuskala/jason | |
""" | |
use Absinthe.Schema.Notation | |
scalar :json_text, name: "Json" do | |
description(""" | |
The `Json` scalar type represents arbitrary json string data, represented as UTF-8 |
NewerOlder