Skip to content

Instantly share code, notes, and snippets.

Avatar
💀
I am the beast I worship

Fernando Camargo Del Buono fernandocamargo

💀
I am the beast I worship
View GitHub Profile
@fernandocamargo
fernandocamargo / README.md
Last active May 27, 2022
Report builder - request/response sample
View README.md

Request

{
  "columns": [
    {
      "type": "month",
      "values": ["01", "02", "03", "04", "05"]
    },
    "itemtype"
 ],
View run-tasks.js
export const fail = (reason) => Promise.resolve({ status: 'failed', reason });
export const skip = (unresolvedDependencies) =>
Promise.resolve({ status: 'skipped', unresolvedDependencies });
export const succeed = (value) =>
Promise.resolve({ status: 'resolved', value });
export const categorize = (stack, [id, { status, value }]) => {
const type = status === 'resolved' ? status : 'unresolved';
View basic.js
import { object, string } from 'yup';
import { useCallback, useMemo } from 'react';
import { Helmet as Metatags } from 'react-helmet';
import useForm from '../../../../macros/form/macro';
import { Text } from 'components/widgets/fields';
export const validationSchema = object().shape({
email: string().trim().min(3).max(255).email().required(),
password: string().trim().min(10).max(50).required(),
View async.js
import { useCallback, useEffect, useRef, useState } from 'react'
import { attempt, fail, getInitialState, succeed } from './reducers'
import { Validity } from './helpers'
export default ({ promise }) => {
const { current: controller } = useRef(new AbortController())
const [state, setState] = useState(getInitialState())
const resolve = useCallback(
View README.md

Usage:

import useAsync from './useAsync';

export const wait5Seconds = new Promise(
  resolve => window.setTimeout(resolve, 5000)
)

export default () => {
 const { resolve, loading } = useAsync({ promise: wait5Seconds })
View report-aggregated.json
{
"interview": {
"id": "9771aaf8-eafc-4658-b8ab-1b9eecf2f368",
"candidate": {
"id": "80959d1e-c507-49a2-b965-b3667c7eed48",
"firstName": "Fernando",
"lastName": "Camargo",
"headLine": "Senior Front End",
"photo": {}
},
View notifications-with-chupelson.js
const LOCAL = { email: "njr@gmail.com", expiredPassword: true };
const DB = {
preferences: { optIn: false },
notifications: { duplicated: true, something: true, fake: false },
bills: [1]
};
const response = (type, res, params) =>
console.log(JSON.stringify({ response: { type, res, params } }, null, 2));
View urlify.js
const URL = 'domain.com/x/y/z'
const PARAMS = {
firstname: 'firstName',
lastname: 'lastName',
phone: 'phone',
company: 'company',
}
const concat = ({
View recursive.js
export const content = [
{ label: 'Item 1' },
{
label: 'Item 2',
children: [
{ label: 'Item 2.1' },
{ label: 'Item 2.2' },
{
label: 'Item 2.3',
children: [
View app.js
import React from 'react';
import { useForm } from 'hooks';
import settings from './form-settings';
const App = () => {
const {
components: { Form, Submit },
elements: {