Skip to content

Instantly share code, notes, and snippets.

View wldcordeiro's full-sized avatar

Wellington Cordeiro wldcordeiro

View GitHub Profile
@wldcordeiro
wldcordeiro / jest-eslint.config.js
Created May 25, 2018 02:44
Jest Multi Project Example
const { resolve } = require('path')
const root = resolve(__dirname, '..')
module.exports = {
rootDir: root,
displayName: 'eslint',
runner: 'jest-runner-eslint',
testMatch: ['<rootDir>/src/**/*.js', '<rootDir>/config/*.js'],
}
@wldcordeiro
wldcordeiro / h.js
Created April 26, 2016 18:25
React h() Function
/* eslint no-param-reassign:0 */
import React from 'react';
import _ from 'lodash';
const classIdSplit = /([\.#]?[a-zA-Z0-9_:-]+)/;
const notClassId = /^\.|#/;
export function h(tagName, properties, children = []) {
/**
const eventMap = {
onClick: 'click',
onChange: 'change',
onKeyDown: 'keydown',
onKeyUp: 'keyup'
}
const ROOT_KEY = '__rektroot_';
const instancesByRootID = {};
let ROOT_ID = 1;
@wldcordeiro
wldcordeiro / egg.js
Last active November 12, 2019 12:52
The Egg programming language from Eloquent JS Chapter 11
function parseExpression(program) {
program = skipSpace(program);
var match, expr;
if (match = /^"([^"]*)"/.exec(program)) {
expr = {type: "value", value: match[1]};
} else if (match = /^\d+\b/.exec(program)) {
expr = {type: "value", value: Number(match[0])};
} else if (match = /^[^\s(),"]+/.exec(program)) {
expr = {type: "word", name: match[0]};
Reading manifest: Error processing permissions.1: Value "background" must either: must either [must either [be one of ["clipboardRead", "clipboardWrite", "geolocation", "idle", "notifications"], be one of ["bookmarks"], be one of ["history"], be one of ["find"], be one of ["menus.overrideContext"], be one of ["search"], be one of ["activeTab", "tabs", "tabHide"], be one of ["browserSettings"], be one of ["cookies"], be one of ["downloads", "downloads.open"], be one of ["topSites"], be one of ["webNavigation"], or be one of ["webRequest", "webRequestBlocking"]], be one of ["alarms", "mozillaAddons", "storage", "unlimitedStorage"], be one of ["browsingData"], be one of ["devtools"], be one of ["identity"], be one of ["menus", "contextMenus"], be one of ["pkcs11"], be one of ["geckoProfiler"], be one of ["sessions"], be one of ["contextualIdentities"], be one of ["dns"], be one of ["management"], be one of ["privacy"], be one of ["proxy"], be one of ["nativeMessaging"], be one of ["telemetry"], be one of ["theme
@wldcordeiro
wldcordeiro / thunk.js
Created April 4, 2019 01:33
Polling in Redux Thunk
function polling(tries) {
return async (dispatch, getState) => {
const result = await Promise.all([
loadIntegrations(), // calling fetch()
getAllEnabledCalendarEvents(), // calling fetch()
]);
if (Array.isArray(result)) {
if (
result[0].every((calendar) => calendar.name && calendar.id) &&
areDifferentBy(getState().time.integratedCalendars, result[0])
@wldcordeiro
wldcordeiro / with-slide.js
Created August 8, 2018 00:10
Transitions and Stuffz
import React, { Component } from 'react'
import { bool, func, number, oneOf, oneOfType, shape, string } from 'prop-types'
import { Transition } from 'react-transition-group'
import stringify from 'json-stable-stringify'
function parseAmount(amount) {
if (typeof amount === 'object') {
return {
in: amount.in != null ? amount.in : 100,
out: amount.out != null ? amount.out : 0,
@wldcordeiro
wldcordeiro / sliding-container.js
Created August 8, 2018 00:05
Using react-transition-group
import React from 'react'
import { bool, element, oneOf } from 'prop-types'
import { css } from 'glamor'
import { Transition } from 'react-transition-group'
import { wrapperStyle } from './styles'
const transInfo = '250ms cubic-bezier(0.07, 0.95, 0, 1)'
const baseSlideStyle = {
transition: `opacity ${transInfo}, transform ${transInfo}`,

Component Description

Write a high level overview of what it's for.

Usage Example

<MyComponent onClick={doSomething}/>
const merge = require('webpack-merge')
const common = require('./webpack.common.js')
const config = require('./env.config')
const { AUTHM_GATEWAY_URL, DAM_ROOT_PATH } = config
const rewriteRegex = new RegExp(`^${DAM_ROOT_PATH}/.`)
module.exports = merge(common, {