Skip to content

Instantly share code, notes, and snippets.

View WebMaestroFr's full-sized avatar

Etienne Baudry WebMaestroFr

View GitHub Profile
@WebMaestroFr
WebMaestroFr / url.js
Last active February 23, 2018 09:40
URL Parser and Media Promise
export function encodeURLParams(params) {
return Object
.entries(params)
.sort((a, b) => a[0] - b[0])
.reduce((search, entry) => [
...search,
entry
.map(encodeURIComponent)
.join('=')
], [])
@WebMaestroFr
WebMaestroFr / TimeAgo.js
Last active August 6, 2019 09:18
A React component to display timestamps as "time ago" strings.
import React, {Component} from 'react';
const SECOND = 1000,
MINUTE = SECOND * 60,
HOUR = MINUTE * 60,
DAY = HOUR * 24,
MONTH = DAY * 30,
YEAR = DAY * 365;
export const getTimeAgoString = (timestamp) => {
@WebMaestroFr
WebMaestroFr / CandlesticksChart.tsx
Last active May 2, 2022 14:47
Candlesticks Chart for Recharts v2
import React, { ReactNode, useMemo } from "react";
import { Bar, RectangleProps, ComposedChart } from "recharts";
import { CategoricalChartProps } from "recharts/types/chart/generateCategoricalChart";
export interface CandlestickData {
open?: number;
high?: number;
low?: number;
close?: number;
}