Skip to content

Instantly share code, notes, and snippets.

View Box.tsx
import React from 'react'
type ResponsiveType<T> =
| T
| [T]
| [T, T]
| [T, T, T]
| [T, T, T, T]
| [T, T, T, T, T]
type SpacingType = 0 | 5 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50
type MarginSpacingType = SpacingType | 'auto'
@smashercosmo
smashercosmo / generate.js
Created May 22, 2019
Generate fake data out of TypeScript types
View generate.js
const execa = require('execa')
const jsf = require('json-schema-faker')
;(async () => {
const { stdout } = await execa(
'./node_modules/.bin/ts-json-schema-generator',
[
'--path',
'./organizations.ts',
'--type',
View ssr.js
const { StaticRouter } = require('react-router-dom')
const https = require('https')
const http = require('http')
const express = require('express')
const bodyParser = require('body-parser')
const React = require('react')
const { renderToString } = require('react-dom/server')
const path = require('path')
const fs = require('fs')
View proxy.js
const api = route.all('/api/(.*)', async (ctx, next) => {
ctx.respond = false
const { res, req, url, method, headers } = ctx
const proxyUrl = new URL(
BASE_URL + url.replace(/^\/api/, '/api/v2'),
)
const proxyReq = makeProxyRequest({
url: proxyUrl,
View proxy.js
const route = require('koa-route')
const http = require('http')
const https = require('https')
const got = require('got')
const {
UMBRA_APS_CLIENT_SECRET,
UMBRA_API_EXTERNALURL,
UMBRA_AUTH_URI,
} = process.env
View ScrollTracker.js
const set = new Set()
if (typeof window !== 'undefined') {
window.addEventListener('scroll', () => {
Array.from(set).forEach(fn => fn())
})
}
class ItemsListCursorTracker extends Component {
constructor(props) {
View proxy.js
const route = require('koa-route')
const request = require('request')
const got = require('got')
const {
UMBRA_APS_CLIENT_SECRET,
UMBRA_API_EXTERNALURL,
UMBRA_AUTH_URI,
} = process.env
View Table.tsx
import React from 'react'
import cx from 'classnames'
import { useTableScrollObserver } from './useTableScrollObserver'
import styles from './Table.css'
type TableProps = {
children: React.ReactNode
}
@smashercosmo
smashercosmo / rule.js
Created Dec 10, 2018
redux action eslint rule
View rule.js
function hasNotOnlyTypePayloadAndMetaProps(node) {
return node.properties.some(
prop =>
prop.key.name !== 'type' &&
prop.key.name !== 'payload' &&
prop.key.name !== 'meta',
)
}
function isReduxActionTypePropertyValue(value) {
View Dashboard.tsx
import * as React from 'react'
import { Heading } from '../Heading/Heading'
import { TasksStatus } from '../TasksStatus/TasksStatus'
import { Section } from '../Section/Section'
import { VerticalStack } from '../VerticalStack/VerticalStack'
import { TasksGroupsList } from '../TasksGroupsList/TasksGroupsList'
import { TaskNodesList } from '../TaskNodesList/TaskNodesList'
import {