Skip to content

Instantly share code, notes, and snippets.

@alicantorun
alicantorun / group-objects-by-property.md
Created June 10, 2019 10:29 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@alicantorun
alicantorun / Authorization.jsx
Created March 6, 2020 08:46 — forked from GiladShoham/Authorization.jsx
React Authorizaion component
import React, { PropTypes } from 'react';
import apConnect from 'apollo-passportjs-react/lib/connect';
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
}
const Authorization = (allowedRoles) =>
(WrappedComponent, options = {}) => {
import React from "react";
import {
LayoutChangeEvent,
PanResponder,
PanResponderGestureState
} from "react-native";
import styled from "styled-components";
type StateType = {
barHeight: number | null,
@alicantorun
alicantorun / chart-with-d3.jsx
Created June 7, 2022 22:30 — forked from samselikoff/chart-with-d3.jsx
Diff from "Building an Animated Line Chart with d3, React and Framer Motion" https://www.youtube.com/watch?v=kPbRDn5Fg0Y
import * as d3 from "d3";
import {
eachMonthOfInterval,
endOfMonth,
format,
isSameMonth,
parseISO,
startOfMonth,
} from "date-fns";
import useMeasure from "react-use-measure";