Skip to content

Instantly share code, notes, and snippets.

View filipenevola's full-sized avatar

Filipe Névola filipenevola

View GitHub Profile

Sharing State

Manage the state in the parent and provide to children templates is very often something that needs to be handled in frontend applications.

In React there is a standard called “Lift up the state” and this approach is also adopted in other frontend libraries/frameworks.

To make the code easier we can use some utilities:

// utility code
@filipenevola
filipenevola / produtos.js
Last active February 15, 2022 18:37
Dúvidas sobre Arrays e Formatação
// Para rodar instale Node.js na sua máquina
// E rode pelo terminal com:
// node produtos.js
const produtos = [
{
nome: "caneta",
preco: 2.229,
},
{
nome: "feijão",
@filipenevola
filipenevola / slackText.txt
Created January 27, 2022 13:27
how to avoid errors coming from a dependent module in typedefs
Filipe Névola Jan 25th at 1:40 PM
@channel does anyone know how to avoid errors coming from a dependent module in typedefs?
I would like to ignore mongodb typedefs checks: https://github.com/DefinitelyTyped/DefinitelyTyped/commit/e978da68b45cd896df143160d910218c5ef89306/checks?check_suite_id=5038300272
This is the PR https://github.com/DefinitelyTyped/DefinitelyTyped/pull/58433
tomche 1 day ago
skipLibCheck: true maybe?
Stephan Meijer 1 day ago
Or override them in a .d.ts, extending the namespace
/Users/filipe/Documents/meteor/ws/meteor/meteor --exclude-archs web.browser.legacy,web.cordova --settings private/env/dev/settings.json
=> Running Meteor from a checkout -- overrides project version (Meteor 2.5-rc.0)
| (#1) Profiling: ProjectContext resolveConstraints
|
| ProjectContext resolveConstraints...............................481 ms (1)
| ├─ _initializeCatalog............................................89 ms (1)
| │ └─ LocalCatalog#initialize....................................89 ms (1)
| │ ├─ addPatternsToList 2 ms (2)
| │ ├─ LocalCatalog#_computeEffectiveLocalPackages.............16 ms (1)
| │ │ ├─ optimistic hashOrNull................................12 ms (110)
@filipenevola
filipenevola / meteor-windows-dev-bundle-logs-fail-14.13.0.0.txt
Created October 3, 2020 09:52
Meteor Windows Dev Bundle Log - fail to build 14.13.0.0
Started by upstream project "meteor-dev-bundle-windows" build number 317
originally caused by:
Started by upstream project "meteor-dev-bundle" build number 1128
originally caused by:
Started by user Filipe Névola
Running as Filipe Névola
[EnvInject] - Loading node environment variables.
[EnvInject] - Preparing an environment for the build.
[EnvInject] - Keeping Jenkins system variables.
[EnvInject] - Keeping Jenkins build variables.
@filipenevola
filipenevola / migrate_repo.sh
Last active May 3, 2020 14:58 — forked from mariozig/migrate_repo.sh
Migrate repo from GitLab to GitHub Full blog post @ http://ruby.zigzo.com/2015/03/23/moving-from-gitlab-to-github/
REPO_NAME=website
FROM=git@gitlab.com:quave/$REPO_NAME.git
TO=git@github.com:quavedev/$REPO_NAME.git
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
git clone --mirror $FROM
@filipenevola
filipenevola / Image.js
Last active April 14, 2020 14:23
Image fallback component
import React, { useState } from 'react';
export const Image = ({ src, srcOnError, ...rest }) => {
const [srcImg, setSrcImg] = useState(null);
const onError = () => {
setSrcImg(srcOnError);
};
const cachedSrc = transformUrlForCaching(src);
@filipenevola
filipenevola / client.js
Last active January 23, 2020 20:57
Meteor Apollo snippets
/**
Snippets showing how to configure Apollo with Meteor in two different ways:
1 - Using DDP (websocket connection)
2 - Using HTTP (post requests)
I'm using a regular HTTP post approach when isAPIModule() returns true
and DDP approach when returns false. I control isAPIModule changing
a setting in the deployment settings.json
That is not necessary for almost every application but in my case I have
%% Failed to install 'cordova-plugin-meteor-webapp': Using "requireCordovaModule" to load non-cordova module "fs" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
at Context.requireCordovaModule (/Users/filipenevola/Documents/meteor/ws/meteor/dev_bundle/lib/node_modules/cordova-lib/src/hooks/Context.js:57:15)
at module.exports (/Users/filipenevola/Documents/quave/ws/bemarke/.meteor/local/cordova-build/plugins/cordova-plugin-meteor-webapp/scripts/iosAddBridgingHeader.js:2:20)
at runScriptViaModuleLoader (/Users/filipenevola/Documents/meteor/ws/meteor/dev_bundle/lib/node_modules/cordova-lib/src/hooks/HooksRunner.js:181:32)
at runScript (/Users/filipenevola/Documents/meteor/ws/meteor/dev_bundle/lib/node_modules/cordova-lib/src/hooks/HooksRunner.js:157:16)
at /Users/filipenevola/Documents/meteor/ws/meteor/dev_bundle/lib/node_modules/cordova-lib/src/hooks/HooksRunner.js:125:20
at /Users/filipenevola/Documents/meteor/ws/meteor/dev_bundle/l
@filipenevola
filipenevola / target-process-copy-id-title.js
Created October 16, 2019 08:59
Tampermonkey script to copy id and title of an entity on Target Process
// ==UserScript==
// @name Pathable - Copy TP US title/id
// @namespace com.pathable
// @include https://pathable.tpondemand.com/*
// @version 1.0.5
// @grant GM_setClipboard
// ==/UserScript==
function formatInfo(usId, usTitle) {
return '[' + usId + '] ' + usTitle;