Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
ORIGIN="${1}"
DEST="${2}"
function move_files {
ORIGIN="${1}"
if test -f "${ORIGIN}"
then
@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]}
@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 / 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 / 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 / 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 / .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 / support-input-date.js
Created July 25, 2017 20:27
check if browser support input type date
function supportInputDate() {
const type = 'date'
const smile = '1)'
const inputElement = document.createElement('input')
inputElement.setAttribute('type', type)
inputElement.value = smile
inputElement.value !== smile
return inputElement.type === 'date' && inputElement.value !== smile
@thiamsantos
thiamsantos / will-appear.js
Created July 19, 2017 21:27
Check if a element will appear in the screen
const throttle = (limit, fn) => {
let wait = false
return (...args) => {
if (!wait) {
fn(...args)
wait = true
setTimeout(() => {
wait = false
}, limit)