Skip to content

Instantly share code, notes, and snippets.

View wjuniorw's full-sized avatar
🏠
Working from home

Wilson junior wjuniorw

🏠
Working from home
View GitHub Profile
@wjuniorw
wjuniorw / cpf_validator_fp.js
Created November 20, 2024 23:36
validate CPF with functional programing paradigm in javascript
const clearCPF = cpf => cpf.replace(/\D/g, '')
const validLength = cpf => cpf.length === 11
const redundant = cpf => cpf.split('').every(x => x === cpf[0])
const restOrZero = amount => (amount === 10 || amount === 11) ? 0 : amount
const calculateDigits = cpf => {
const numsStr = cpf.split('')
const arrNums = Array.from(numsStr, n => +n)
const nineDigits = arrNums.slice(0,9)
const tenDigits = arrNums.slice(0,10)
@wjuniorw
wjuniorw / Gitflow.md
Last active September 28, 2023 18:43

Gitflow

O que é o gitflow?

  • Primeiramente oque não é o Gitflow

    • Não é um software
    • Não é uma biblioteca ou framewok

O git flow pode ser adotado como:

  • Modelo
@wjuniorw
wjuniorw / findMostRecurrentNumber.js
Created August 14, 2022 07:01
find most recurrent number...
const arr = [1, 2, 3, 4, 1, 5, 1, 6, 1, 7, 7, 42, 42, 42, 42, 42]
const findMostRecurrent = param => {
return param.reduce((acc, curr, index, base) => {
const currSum = base.filter( it => it === curr).length
const newAcc = { ...acc, [curr]: currSum }
if (++index == base.length) {
const arrObj = Object.keys(newAcc)
.map(it => ({ [it]: acc[it] }))
@wjuniorw
wjuniorw / a_good_git_flow.md
Last active March 8, 2021 01:11
a good git flow implementation

A good git flow implementations:

  • Three principal branches : main,dev,qa

  • these three are locked to push

flows:

  • feature, improvement or fix:

    • checkout and pull on main branch

      • git checkout main

  • git pull origin main

import { useState } from 'react'
// custom hook .................useFile..........................
const useInputFile = () => {
const [file, setValue] = useState('')
function getBase64({target}) {
const fileToLoad = target.files[0]
const FR = new FileReader()
FR.onload = (event) => {
return setValue(event.target.result)
}
@wjuniorw
wjuniorw / Login.js
Last active November 30, 2016 19:12
Login/logot usando localStorage com reactjs
var React = require('react')
var loginPage = React.createClass({
getInitialState: function () {
return {
token: null,
user: null,
badLogin: null
}
<!DOCTYPE html>
<html ng-app="app">
<head>
<title>skill</title>
<meta charset="utf-8" />
</head>
<body>
<section ng-view></section>
<script type="text/javascript" src="lib/angular.min.js"></script>
<script type="text/javascript" src="lib/angular-route.min.js"></script>
(function () {
'use strict';
angular
.module('app')
.directive('imgUpload', Upload)
function Upload () {
var directive = {
restrict: 'AE',
scope: {