Skip to content

Instantly share code, notes, and snippets.

View edvaldoszy's full-sized avatar
🚀

Edvaldo Szymonek edvaldoszy

🚀
View GitHub Profile
@edvaldoszy
edvaldoszy / default.conf
Created December 20, 2021 14:16
Configuração padrão do NGINX
# /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
...
location / {
root /usr/share/nginx/html;
function getPathWithKey(path, key) {
return typeof path === 'string' ? `${path}[${key}]` : key;
}
/**
* Esta função converte um objeto plano com chaves aninhadas para
* o formato esperado pelo URLSearchParams, que é utilizado nas requisições
* que exige o "Content-Type": "application/x-www-form-urlencoded".
*
* Um objeto com estrutura
#!/bin/sh
CONFIG_FILE=/etc/docker/daemon.json
cat << CONFIG > $CONFIG_FILE
{
"log-driver": "json-file",
"log-opts": {
"max-size": "50m",
"max-file": "1"
@edvaldoszy
edvaldoszy / cors.conf
Created August 3, 2020 01:17
CORS on NGINX
# https://enable-cors.org/server_nginx.html
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
root /usr/share/nginx/html;
@edvaldoszy
edvaldoszy / convert-time-to-human-readable.js
Created January 23, 2020 13:24
convert-time-to-human-readable
function convertTimeToHumanReadable(time) {
const units = [
['days', 480], // 8 horas (8 * 60)
['hours', 60],
['minutes', 1],
];
function reducer({ duration, ...others }, [unit, amount]) {
const result = Math.floor(duration / amount);
@edvaldoszy
edvaldoszy / ReactNative.dockerfile
Last active December 10, 2019 19:20
Docker React Native Android
FROM openjdk:8-jdk
ENV ANDROID_COMPILE_SDK="28"
ENV ANDROID_BUILD_TOOLS="28.0.3"
ENV ANDROID_SDK_TOOLS="4333796"
ENV ANDROID_HOME="${PWD}/android-sdk-linux"
ENV PATH="${PATH}:${PWD}/android-sdk-linux/platform-tools/"
RUN apt update -qy; \
apt install -qy curl unzip; \
@edvaldoszy
edvaldoszy / object-get-path.js
Last active January 23, 2020 13:23
Get path from JavaScript Object
/**
* Get object path value or return defaultValue
* @param {object} object Object to get path value
* @param {string[]} keys Object path in an array
* @param {any} defaultValue Default value if the path does not exists
*/
function getPath(object, keys, defaultValue) {
if (keys.length === 1) {
const [curr] = keys;
return object[curr];
@edvaldoszy
edvaldoszy / csv-import.js
Created November 21, 2019 04:30
Faz a importação de um CSV para o banco de dados
const { Writable } = require('stream');
const { createReadStream } = require('fs');
const Split = require('stream-split');
const input = createReadStream('./votacao_candidato_munzona_2018_PR.csv', { encoding: 'latin1' });
// const [nl] = Buffer.from('\n');
// const buffer = Buffer.from('Edvaldo\nSzymonek');
// console.log(buffer[7] === nl);
@edvaldoszy
edvaldoszy / prepare-commit-msg.sh
Last active October 31, 2019 14:42
Modificando mensagem de commit
#!/bin/bash
MSG="$(cat $1)"
if [[ "$MSG" =~ ^\#[0-9]+ ]]; then
echo "gam-backlog${MSG}" > $1
fi
@edvaldoszy
edvaldoszy / d2-max-block
Last active September 7, 2019 04:12
Calcula a porcentagem de bloqueio de um personagem em Diablo II
#!/usr/bin/env node
require('./diablo2-calc-max-block');