Skip to content

Instantly share code, notes, and snippets.

View barbagrigia's full-sized avatar

Vlad Trukhin barbagrigia

View GitHub Profile
// in reusable feature instance
import createActions from '../reusable-feature/actions';
import selectors from './selectors';
import { createAction } from 'redux-actions';
const actions = createActions('INSTANCE_1', selectors);
actions['additionalAction'] = createAction(...);
#!/bin/bash
docker run --rm --name test-container -v $(pwd):/home/circleci/codesandbox-client -w /home/circleci/codesandbox-client -d -t codesandbox/node-puppeteer yarn start:test && \
sleep 6 && docker exec -it test-container yarn test:integrations && \
docker stop test-container
@ivosh
ivosh / index.js
Created February 12, 2018 09:11
evolving-react-patterns-async-await
componentDidMount() {
this.setState({ content: this.props.loading() })
try {
const res = await fetch(this.props.url);
this.setState({ content: this.props.done(res.json()) });
} catch (err) {
this.setState({ content: this.props.error() });
}
}
@markerikson
markerikson / reduxRandomExample.js
Created January 23, 2018 02:07
Redux random number middleware with resumable state
import {createStore, applyMiddleware} from"redux";
import {randomMiddleware, higherOrderRandomReducer} from "./reduxRandomMiddleware";
function randomInt(prng, lowest, highest) {
return lowest + Math.floor(prng() * (highest - lowest + 1));
}
function counterReducer(state = 0, action) {
switch(action.type) {
case "INCREMENT" : {
@markerikson
markerikson / NotificationManager.jsx
Created January 21, 2018 15:43
React / Redux / Semantic-UI toast notifications implementation
import React, {Component} from "react";
import {connect} from "react-redux";
import _ from "lodash";
import { Message } from "semantic-ui-react";
import {Portal} from 'react-portal';
import {selectNotifications} from "./notificationSelectors";
import {dismissNotification} from "./notificationActions";
@markerikson
markerikson / reselect-selectors-memoization.md
Last active April 14, 2018 21:02
Reselect selectors and memoization explanation

[9:39 PM] suark: A selector is a function that takes only 1 param which is state and it returns data.
[9:40 PM] maladr0it: in my case it can't function with only that information
[9:40 PM] maladr0it: so i should perhaps rethink
[9:40 PM] maladr0it: it needs to know what chat to get messages for
[9:40 PM] acemarke: @suark: a selector can take any number of arguments
[9:40 PM] acemarke: both in general, and with Reselect specifically
[9:41 PM] suark: I thought createselect returns a function that only takes state
[9:41 PM] acemarke: nope
[9:41 PM] acemarke: in fact, it calls all "input selectors" with all the arguments you pass in
[9:41 PM] maladr0it: only taking state sounds very limiting.. perhaps i should read about what selectors actually are used for

const puppeteer = require('puppeteer');
let browser = puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
async function test(url) {
browser = await browser;
const page = await browser.newPage();
const a = Date.now();
await page.goto(url, {
@busypeoples
busypeoples / IntroductionToFlow.md
Last active June 29, 2020 08:22
Introduction To Flow

Introduction To Flow

Intended for developers interested in getting started with Flow. At the end of this introduction, you should have a solid understanding of Flow and how to apply it when building an application.

Covers all the basics needed to get started with Flow.

Covers all the basic needed to get started with Flow and ReactJS.

@busypeoples
busypeoples / FlowReactTutorial.js
Last active July 17, 2023 10:12
Flow Fundamentals For ReactJS Developers
//
// MIT License
//
// Copyright (c) 2018 Ali Sharif
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@busypeoples
busypeoples / FlowTutorial.js
Last active July 17, 2023 10:12
Flow Fundamentals For JavaScript Developers
//
// MIT License
//
// Copyright (c) 2018 Ali Sharif
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is