Skip to content

Instantly share code, notes, and snippets.

View johnatandias's full-sized avatar
👨‍👩‍👧‍👦
No success compensates for your family's failure.

Johnatan Dias johnatandias

👨‍👩‍👧‍👦
No success compensates for your family's failure.
View GitHub Profile
@johnatandias
johnatandias / x1.cfg
Created July 1, 2019 20:26
CS:GO - X1
bot_kick
mp_freezetime 0
mp_free_armor 1
mp_startmoney 50000
mp_buy_anywhere 1
mp_buytime 99999
mp_maxmoney 50000
mp_round_restart_delay 2
mp_maxrounds 50
mp_warmup_end
@johnatandias
johnatandias / Input.js
Last active July 5, 2019 00:47
KaiOS navigation with React Hooks
import React from 'react';
import css from './Input.module.css'
export const Input = ({ label, type }) => {
return (
<div className={css.content}>
<input className={css.input} type={type} nav-selectable="true" />
<label className={css.label}>{label}</label>
</div>
)
@johnatandias
johnatandias / DatabaseService.js
Created July 11, 2019 22:32
A simple example of indexedDB for KaiOS devices
class DatabaseProvider {
constructor() {
this.db = {};
this.dbName = 'todos';
this.dbVersion = 1;
this.stores = { TODOS: 'todos' };
this.init();
}
init() {
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import { scss } from '@kazzkiq/svelte-preprocess-scss';
const production = !process.env.ROLLUP_WATCH;
export default {
@johnatandias
johnatandias / listenToAllEvents.js
Last active June 25, 2020 23:25
Listen to all events
(() => {
Object.keys(window).map(property => {
if (property.startsWith('on')) {
window[property] = event => console.log('=>', event.type, { event })
}
})
})()
@johnatandias
johnatandias / input.scss
Created December 27, 2019 20:48
BLiP Design System - Input
@mixin size($size) {
width: $size;
height: $size;
}
.bds-icon {
display: inline-flex;
align-items: center;
svg {
@johnatandias
johnatandias / clean_code.md
Last active February 21, 2020 21:59 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

O código é limpo se puder ser entendido facilmente por todos da equipe. O código limpo pode ser lido e aprimorado por um desenvolvedor que não seja o autor original. Com capacidade de compreensão, vem a legibilidade, a capacidade de mudança, a extensibilidade e a manutenção.


Regras gerais

  1. Siga as convenções padrão.
  2. Mantenha isso simples, estúpido.
    • Mais simples é sempre melhor.
  • Reduza a complexidade o máximo possível.
@johnatandias
johnatandias / minify.js
Created April 26, 2020 14:19
Minify HTML files with Javascript
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Document</title>
</head>
@johnatandias
johnatandias / index.ts
Last active April 22, 2021 17:10
Fill string with
export const pad = ({
value,
size,
fillWith,
}: {
value: string | number
size: number
fillWith: string
}): string => {
const filled: Array<string | number> = Array.from(
@johnatandias
johnatandias / format.js
Created July 17, 2020 16:06
Format CPF and CPNJ
const formatCPF = cpf => {
const invalidCPF = !cpf || cpf.length !== 11;
if (invalidCPF) return cpf;
return cpf
.replace(/[^\d]/g, '')
.replace(/(\d{3})(\d{3})(\d{3})(\d{2})/, '$1.$2.$3-$4');
};
const formatCNPJ = cnpj => {