Skip to content

Instantly share code, notes, and snippets.

View edvaldoszy's full-sized avatar
🚀

Edvaldo Szymonek edvaldoszy

🚀
View GitHub Profile
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import axios from 'axios';
class App extends Component {
onInputChange = ({ target }) => {
const { files } = target;
@edvaldoszy
edvaldoszy / abreviar-nome.js
Created January 30, 2019 13:25
Função para abreviar nomes grandes
function abrevia(str) {
const nome = str.replace(/\s+/gi, ' ')
.trim();
return nome.split(' ')
.map((parte, index, nomes) => (index == (nomes.length - 1)) ? parte : `${parte[0]}.`)
.join(' ');
}
@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');
@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 / 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 / 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 / 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 / .bash_aliases
Last active March 31, 2020 14:56
Adicionado alias para o Docker
alias yi='yarn install'
alias ya='yarn add $@'
alias yad='yarn add -D $@'
alias cai='rm -rf node_modules && yarn install'
alias rnra='react-native run-android'
alias rnri='react-native run-ios'
alias docp='docker container prune -f'
alias dosp='docker system prune --all'
@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;