Skip to content

Instantly share code, notes, and snippets.

import throttle from 'lodash.throttle';
import React, { Dispatch, SetStateAction, useContext } from 'react';
import WasRenderedContext from '../contexts/WasRenderedContext';
type Key = 'darkMode' | 'tasks' | 'email' | 'version';
type DarkMode = boolean;
interface TaskText {
leaves: Array<{ text: string }>;
@steida
steida / nearest.js
Created October 8, 2018 17:41
Get nearest day week date defined by week in month
/* @flow */
import React from 'react';
import { DayOfWeek, LocalDate, TemporalAdjusters } from 'js-joda';
import { FormattedDate } from 'react-intl';
import { ValidationError } from '../../common/lib/validation';
import { connect } from 'react-redux';
import { fields } from '../../common/lib/redux-fields';
import { orderCourse } from '../../common/courses/actions';
import {
Block,
@steida
steida / textinput.js
Created June 7, 2018 22:21
Textarea auto height for server side rendering
<TextInput
multiline
// value={value}
defaultValue={value}
onChange={this.handleChange}
placeholderTextColor={placeholderTextColor}
placeholder={intl.formatMessage(messages.placeholder)}
ref={this.inputRef}
style={[
theme.styles.editorTextInput,
# https://github.com/este/este/wiki/GraphQL
# https://www.prisma.io/features/data-modeling/
# The order of types and consistent relations names is probably a pattern.
type User {
id: ID! @unique
createdAt: DateTime!
updatedAt: DateTime!
email: String! @unique
// @flow
import A from './A';
import ErrorPopup from './ErrorPopup';
import Box from './Box';
import Head from 'next/head';
import LoadingBar from './LoadingBar';
import MainNav from './MainNav';
import * as React from 'react';
import SwitchLocale from './SwitchLocale';
import Text from './Text';
// @flow
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import type { Error as ErrorType } from '../lib/error';
import Text, { type TextProps } from './Text';
export const errorToMessage = (error: ErrorType) => {
switch (error.type) {
case 'required':
return (
@steida
steida / getWeakKey.js
Created November 25, 2017 02:24
Get React key for immutable object without memory leaks.
export const getWeakKey = (() => {
const map = new WeakMap();
let idx = 0;
return element => {
if (map.has(element)) return map.get(element);
idx++;
map.set(element, idx.toString());
return idx;
};
})();
@steida
steida / keybase.md
Last active November 20, 2017 18:09

Keybase proof

I hereby claim:

  • I am steida on github.
  • I am steida (https://keybase.io/steida) on keybase.
  • I have a public key ASDDCI7ID7A8HN6Z6fJgGbnP3PFO0UKLOgSgZbpNcjzVgQo

To claim this, I am signing this object:

// Make complex type from primitive types
type Person = {
name: string,
age: number,
}
// Test it.
const joe: Person = {
name: 'Joe',
age: 60,
"babel-eslint": "^8.0.1",
"eslint": "^4.4.1",
"eslint-config-airbnb": "^16.0.0",
"eslint-config-prettier": "^2.6.0",
"eslint-loader": "^1.7.0",
"eslint-plugin-flowtype": "^2.35.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.0.1",