just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo.
| import * as React from 'react'; | |
| /** | |
| * React.Ref uses the readonly type `React.RefObject` instead of | |
| * `React.MutableRefObject`, We pretty much always assume ref objects are | |
| * mutable (at least when we create them), so this type is a workaround so some | |
| * of the weird mechanics of using refs with TS. | |
| */ | |
| export type AssignableRef<ValueType> = | |
| | { |
| // create context with no upfront defaultValue | |
| // without having to do undefined check all the time | |
| function createCtx<A>() { | |
| const ctx = React.createContext<A | undefined>(undefined) | |
| function useCtx() { | |
| const c = React.useContext(ctx) | |
| if (!c) throw new Error("useCtx must be inside a Provider with a value") | |
| return c | |
| } | |
| return [useCtx, ctx.Provider] as const |
just the bare necessities of state management.
Hotlink it from https://unpkg.com/valoo.
| import { makeExecutableSchema, addMockFunctionsToSchema } from 'graphql-tools'; | |
| import { graphql } from 'graphql'; | |
| import GraphQLMock from 'graphql-mock'; | |
| import typeDefs from 'imports/startup/both/typeDefs'; | |
| // Make a GraphQL schema with no resolvers | |
| const schema = makeExecutableSchema({ typeDefs }); | |
| // Creates random id | |
| const revisedRandId = () => |
| pragma solidity ^0.4.19; | |
| contract HelloWorld { | |
| string defaultResponse = "Hello to a decentralized world!"; | |
| function getResponse(string here) public returns (string) { | |
| return here; | |
| } | |
| } |
Philosophy is a way of life and not just a theoretical discipline.
Epictetus (55 — 135 AD) was a Greek slave of Rome. He became a great Stoic philosopher and teacher, and was eventually freed.
Although he was a fatalist, he believed that individuals are responsible for their own actions, which they can examine and control through rigorous self-discipline.
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.
elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent| .vagrant |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)