Skip to content

Instantly share code, notes, and snippets.

View nickydonna's full-sized avatar
🍩
donnuting

Nicky Donna nickydonna

🍩
donnuting
  • SunRun
  • Buenos Aires, Argentina
View GitHub Profile
### Keybase proof
I hereby claim:
* I am nickydonna on github.
* I am nickydonna (https://keybase.io/nickydonna) on keybase.
* I have a public key ASDVLuuLrKCEGq9uk1NHRsK1r9uSxdx_WNJuQmUBv5TFOAo
To claim this, I am signing this object:
const hasMark = window.performance && !!window.performance.mark;
const Performance = () => {
const defaultMark = {};
const getTiming = () => {
const timing = performance && performance.timing ? performance.timing.toJSON() : {};
const defaultTiming = {ipsyPageStart: __PAGE_START__, ipsyPageEnd: __PAGE_END__};
return {...timing, ...defaultTiming};
import React, {Component, Fragment} from 'react';
import { Modal, ModalBody, ModalHeader, ModalFooter, Button } from 'reactstrap';
/* eslint react/jsx-filename-extension: 0 */
const ErrorModal = ({error}) => (
<Modal isOpen={showError} toggle={toggleError}>
<ModalHeader toggle={toggleError}>Felicitaciones</ModalHeader>
<ModalBody>
<div className="col-md-6 offset-md-3">
{error}
// option one - using Promise.all - I like this the most
asyncAuth()
.then(user => {
return Promise.all([user, asyncFetch(user)])
})
.then(([user, data]) => {
// ...
});
// option two - nesting
@nickydonna
nickydonna / middleware.js
Last active February 19, 2018 19:59
express delay middleware
export const delayMiddleware = (delay) => (req, res, next) => {
setTimeout(next, delay)
});
// @flow
import React from 'react';
import styled from 'styled-components';
import { Segment } from 'semantic-ui-react';
import { parsePadding } from '../utils/styledHelpers';
import type { Component as ComponentType } from 'styled-components';
type FlexItemProps = {
flex?: string|number,
@nickydonna
nickydonna / README.md
Last active May 17, 2017 12:37
XStream distinct

xstream distinct

A function to use with xstream#compose to filter repeated events

Example

stream
  .compose(distinct((a, b) => a.id === b.id)
  .map(uniqueValue => { //... })
 
@nickydonna
nickydonna / channelMiddleware.js
Last active May 17, 2017 12:34
A Redux Middleware for Phoenix Channels
// flow
import type { MiddlewareAPI, Dispatch } from 'redux';
import { Socket } from 'phoenix';
const url = 'ws://localhost:4000/socket';
const usefullAction = [
'CHANNEL_PUSH',
'CHANNEL_DISCONNECT',
'EVENT_CONNECT',
'EVENT_DISCONNECT',
@nickydonna
nickydonna / flatten.js
Last active January 31, 2017 14:43
A simple implementation of flatten
const isArray = Array.isArray;
const reducer = (acc, ele) => {
const elements = isArray(ele) ? flatten(ele) : ele;
return acc.concat(elements);
};
const reduce = (arr) => arr.reduce(reducer, []);
const flatten = arr => isArray(arr) ? reduce(arr) : arr;
module.exports = flatten;
@nickydonna
nickydonna / ControllerRouter.js
Created September 22, 2016 19:53
A Contoller ReactRouter for v4
/* @flow */
import BrowserHistory from 'react-history/BrowserHistory'
import {Push, Replace} from 'react-history'
import React, {Component} from 'react'
import {StaticRouter} from 'react-router'
type RouterProps = {
onChange: (action: string, location: Object) => void,
pathname: string,
navigation?: 'PUSH' | 'REPLACE',