This file contains hidden or 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
# lib/my_project/task.ex | |
defmodule MyProject.Task do | |
@moduledoc """ | |
TODO: run async task on tests will not work, with unpredictable side effects | |
""" | |
@adapter Keyword.get( | |
Application.compile_env(:my_project, __MODULE__, []), | |
:adapter, | |
Task |
This file contains hidden or 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 |
This file contains hidden or 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: |
This file contains hidden or 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 |
This file contains hidden or 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"); |
This file contains hidden or 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) |
This file contains hidden or 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}" |
This file contains hidden or 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", |
This file contains hidden or 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" |
This file contains hidden or 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 |
NewerOlder