Skip to content

Instantly share code, notes, and snippets.

View wwiechorek's full-sized avatar

William Wiechorek wwiechorek

View GitHub Profile
@wwiechorek
wwiechorek / bin-cc.md
Created February 19, 2016 12:44 — forked from erikhenrique/bin-cc.md
Bin de cartões de crédito para validação

Validação para cartão de crédito.

Bin e padrões para validação de cartão de crédito.

Bandeira Começa com Máximo de número Máximo de número cvc
Visa 4 13,16 3
Mastercard 5 16 3
@wwiechorek
wwiechorek / gitche.sh
Created September 14, 2016 19:59
Git add + commit + pull + push AUTO
#!/bin/bash
git add -A
git commit -m "$0"
git pull
git push
@wwiechorek
wwiechorek / index.js
Last active January 4, 2019 15:04
SSR - React com create-react-app
import bodyParser from 'body-parser';
import compression from 'compression';
import express from 'express';
import cookieParser from 'cookie-parser';
import Loadable from 'react-loadable';
import render from './render';
const app = express();
const PORT = process.env.PORT || 3000;
@wwiechorek
wwiechorek / app.js
Last active February 25, 2019 22:50
Estrutura de botão em react
import Button from './Button'
<Button>Default</Button>
<Button inline>Inline</Button>
<Button inline primary>Primary</Button>
<Button
inline
@wwiechorek
wwiechorek / js
Created August 8, 2019 20:58
HooksError
import React, { useState } from 'react'
function AppHooks() {
const [list, setList] = useState([])
function run() {
setInterval(() => {
list.push(Math.random())
@wwiechorek
wwiechorek / gist:944f886d316114d80742a42308fa5e2c
Created November 27, 2019 12:58
Mudar fonte padrão de um projeto React-native
import { Text } from 'react-native'
let oldText = Text.render;
Text.render = function (...args) {
let origin = oldText.call(this, ...args);
return React.cloneElement(origin, {
style: [{fontFamily: 'Open Sans'}, origin.props.style]
});
};
import Document, { Head, Main, NextScript } from 'next/document';
// Import styled components ServerStyleSheet
import { ServerStyleSheet } from 'styled-components';
export default class MyDocument extends Document {
static getInitialProps({ renderPage, req }) {
// Step 1: Create an instance of ServerStyleSheet
const sheet = new ServerStyleSheet();
@wwiechorek
wwiechorek / App.js
Created June 11, 2020 02:34
Erro React
import React, { useEffect, useState, useCallback } from 'react'
function App() {
const [user, setUser] = useState(false)
const [count, setCount] = useState(0)
const valid = useCallback(() => {
console.log(count)
if(count === 12) {
alert("12")
@wwiechorek
wwiechorek / index.js
Last active July 19, 2022 21:17
Simple worker pool in javascript/nodejs
function createWorkerPool(max) {
let current = 0
let queue = []
async function run() {
if(current >= max || queue.length === 0) return
current++
let action = queue.shift()