Skip to content

Instantly share code, notes, and snippets.

View sakramentas's full-sized avatar

Lucas Sacramento sakramentas

View GitHub Profile
{
"version": "0.0.1",
"type": "project",
"variant": "monorepo",
"structure": [
[
"Tiles",
{
"type": "react-component",
"name": "Tiles",
{
"version": "0.0.1",
"type": "project",
"variant": "monorepo",
"structure": [
[
"test-folder/components/Counter2",
{
"type": "react-component",
"name": "Counter",
@sakramentas
sakramentas / after.js
Created November 16, 2019 18:01 — forked from moimikey/after.js
object literals for redux reducers
// O(1)
const todo = (state, action) => {
const actions = {
ADD_TODO: () => {
return {
id: action.id,
text: action.text,
completed: false
}
},
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { accessor } from 'react-big-calendar/lib/utils/accessors';
import { accessor as accessorPropType } from 'react-big-calendar/lib/utils/propTypes';
import { noop } from 'lodash';
import { zonedToLocal, localToZoned } from '/client/utils/timezones';
import { hasTime, shiftDate, shiftHour } from '/client/utils/date';
/**
* withTimeZone - HOC to add time zone support to react-big-calendar
@sakramentas
sakramentas / event_loop_blockers.js
Last active August 18, 2019 11:04
Simple timer to identify processes blocking the NodeJS Event Loop
const chalk = require('chalk');
const getHrDiffTime = time => {
// ts = [seconds, nanoseconds]
const ts = process.hrtime(time);
// convert seconds to miliseconds and nanoseconds to miliseconds as well
return ts[0] * 1000 + ts[1] / 1000000;
};
const outputDelay = (interval, maxDelay) => {
/*
what it does:
Wraps objects to respond to data path strings separated by '/'
ex: vpFoo['path/to/0/property'] <= same as => foo.path.to[0].property
usage:
const foo = {
bar: 12,
something: [
{ baz: 14 }
]
@sakramentas
sakramentas / cssSelectorRegex.js
Last active August 18, 2019 11:05
Regex to match every Possible CSS selector
const cssRegex = /([*="'.#():[*^$~\\|>+,\w\]\s\-]*?(?![^{]*\}))[\s\n]?[{,]/gm;
const isPromise = obj => Boolean(obj) && typeof obj.then === 'function';
const next = (iter, callbacks, prev = undefined) => {
const { onNext, onCompleted } = callbacks;
const item = iter.next(prev);
const value = item.value;
if (item.done) {
return onCompleted();
}