Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Luis Felipe Zaguini zaguiini

🎯
Focusing
  • Brazil
Block or report user

Report or block zaguiini

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zaguiini
zaguiini / getAge.js
Last active May 27, 2019
Return the age given the parameters
View getAge.js
function getAge(month, day, year) {
const birthDate = new Date(year, month - 1, day)
const fromNow = new Date() - birthDate
const absoluteAge = new Date(fromNow).getFullYear()
// that's because timestamps starts from 1970, so
// we're getting relatively to that year
return Math.abs(absoluteAge - 1970)
}
@zaguiini
zaguiini / use-mutual-number-field.js
Last active Mar 8, 2019
Useful hook for when updating multiple values that must fit 100%
View use-mutual-number-field.js
function useMutualNumberField({
values,
index,
setCurrentValue,
setAllValues,
}) {
return function handlePercentageChange(rawInputtedValue) {
const inputtedValue = parseInt((rawInputtedValue || 0).toString(), 10)
const prevValue = values[index].percentage
@zaguiini
zaguiini / usage.tsx
Created Mar 6, 2019 — forked from sibelius/usage.tsx
useSelectRows is a hook that manage a list of selected items, so you don't have to
View usage.tsx
const MyUserSelectableList = ({ users ) => {
const { onRowCheck, isRowSelected } = useSelectedRows();
return (
<>
{users.map(user => (
<>
<Checkbox value={isRowSelected(user)} onChange={(value) => onRowCheck(user, value)} />
<span>{user.name}</span>
</>
@zaguiini
zaguiini / Router.js
Last active Jan 9, 2019 — forked from nurycaroline/Router.js
Treta do Bundle
View Router.js
import React, { Component } from 'react';
import { Switch, Route } from 'react-router-dom';
const PAGES = [
{
name: 'Home',
path: '/',
loader: './pages/Home',
},
];
View classe.jsx
function login() {
// login logic here
}
class LoginForm extends React.PureComponent {
render() {
return (
<form onSubmit={login}>
<input type="email" /><br />
<input type="password" /><br />
@zaguiini
zaguiini / codigo-menos-feio.swift
Created Aug 28, 2018
An example of less ugly code
View codigo-menos-feio.swift
let tags: [String] = ["vNome", "vLocal", "vData", "vEquipe", "vAmigos", "vReferencia"]
for tag in tags {
form.rowByTag(tag)?.disabled = true
form.rowByTag(tag)?.evaluateDisabled()
}
@zaguiini
zaguiini / codigo-feio.swift
Created Aug 28, 2018
An example of Ugly code
View codigo-feio.swift
form.rowByTag("vNome")?.disabled = true
form.rowByTag("vNome")?.evaluateDisabled()
form.rowByTag("vLocal")?.disabled = true
form.rowByTag("vLocal")?.evaluateDisabled()
form.rowByTag("vData")?.disabled = true
form.rowByTag("vData")?.evaluateDisabled()
form.rowByTag("vEquipe")?.disabled = true
form.rowByTag("vEquipe")?.evaluateDisabled()
form.rowByTag("vAmigos")?.disabled = true
form.rowByTag("vAmigos")?.evaluateDisabled()
View sample-compo.js
import React from 'react'
import classNames from 'classnames'
import styles from './styles.module.scss'
export default ({ negative = false, name, surname }) => (
<div
className={classNames(
styles['name-container'],
negative && styles['name-negative'],
View sass-module-webpack-config.js
{
test: /(?<!\.module)\.scss$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
},
},
View src.js
import React from 'react'
import store from './store'
import { Provider } from 'react-redux'
import Main from '@/views'
export default () => (
<Provider
store={store}
You can’t perform that action at this time.