Skip to content

Instantly share code, notes, and snippets.

@thiamsantos
thiamsantos / .editorconfig
Last active March 1, 2018 12:50
editorconfig
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@thiamsantos
thiamsantos / shadow.css
Last active August 12, 2017 12:15
Material Shadows
.z-depth-focus {
box-shadow: 0 0 8px rgba(0, 0, 0, .18), 0 8px 16px rgba(0, 0, 0, .36);
}
.z-depth-2dp {
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14),
0 1px 5px 0 rgba(0, 0, 0, .12),
0 3px 1px -2px rgba(0, 0, 0, .2);
}
@thiamsantos
thiamsantos / db-conventions.md
Last active April 25, 2025 13:43
Convenções de nomenclatura para banco de dados

Convenções de nomenclatura para banco de dados

Geral

Os nomes das tabelas e colunas devem estar minúsculas e as palavras devem ser separadas por underscore, seguindo o padrão snake case. E todos os termos devem estar em inglês, exceto alguns termos que não há tradução apropriada para o inglês. Sempre prefira nomes descritivos, evitando ao máximo contrações.

Tabelas

Os nomes das tabelas devem estar no plural.

@thiamsantos
thiamsantos / Password.php
Created November 15, 2017 23:07
password hashing bcrypt + sha384
<?php
class Password
{
public static function hash(string $password): string
{
return password_hash(base64_encode(hash('sha384', $password, true)), PASSWORD_BCRYPT);
}
public static function verify(string $password, string $hash): bool
@thiamsantos
thiamsantos / index.js
Created April 26, 2018 14:29
eloquent js squirrel journal
function hasEvent(event, entry) {
return entry.events.indexOf(event) !== -1
}
function tableFor(event, journal) {
return journal.reduce(
(table, entry) => {
const hasTheEvent = hasEvent(event, entry)
const isSquirrel = entry.squirrel
@thiamsantos
thiamsantos / shuffle.js
Created June 15, 2018 17:43
array shuffle in js
function shuffle(arr) {
const {acc} = arr.reduce(
({acc, current}) => {
const index = Math.round(Math.random() * (current.length - 1))
const item = current[index]
current.splice(index, 1)
return {acc: [...acc, item], current}
},
{acc: [], current: [...arr]}
#!/bin/bash
ORIGIN="${1}"
DEST="${2}"
function move_files {
ORIGIN="${1}"
if test -f "${ORIGIN}"
then
valid_branchs = [
"master"
]
"git"
|> System.cmd(["branch"])
|> elem(0)
|> String.split("\n")
|> Enum.map(&String.trim/1)
|> Enum.reject(&match?("", &1))
defmodule Crypto do
def encrypt(data, key) when is_binary(data) and is_binary(key) do
iv = :crypto.strong_rand_bytes(16)
cipher = :crypto.block_encrypt(:aes_cbc256, hash_key(key), iv, pad(data))
Base.encode64("#{iv}#{cipher}")
end
def decrypt(digest, key) when is_binary(digest) and is_binary(key) do
text = Base.decode64!(digest)