Skip to content

Instantly share code, notes, and snippets.

Karl Horky karlhorky

Block or report user

Report or block karlhorky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View App.Combobox.js
import React, { useState, useEffect } from "react";
import "./packages/combobox/styles.css";
import {
Combobox,
ComboboxInput,
ComboboxList,
ComboboxOption,
ComboboxPopup
} from "./packages/combobox/index";
View fetch-with-timeout.js
// Fetch with timeout
// Source: https://github.com/whatwg/fetch/issues/179#issuecomment-457698748
const networkTimeoutError = new Error('Network request timeout')
function getTimeout({ timeout }) {
if (timeout && timeout.constructor === Promise) {
return timeout
}
if (typeof timeout === 'number') {
@karlhorky
karlhorky / css-is-complex.md
Last active Jan 21, 2019
CSS is Complex. We can do better.
View css-is-complex.md

CSS is Complex. We can do better.

Posted on https://twitter.com/karlhorky/status/1082622697325166592

Ok, thread time.

CSS is unnecessarily complex. And we can do better.

There have been side conversations here and there, but I want to consolidate the information and opinions here. This will be a running thread, and I'll add to it as new things crop up.

@karlhorky
karlhorky / matebook-x-pro-pcie-x2-bandwidth-limitations.md
Last active Dec 15, 2018
Huawei Matebook x Pro PCI-Express 2 lane bandwidth limitations with eGPU
View matebook-x-pro-pcie-x2-bandwidth-limitations.md

Huawei Matebook x Pro PCI-Express 2 lane bandwidth limitations with eGPU

"In short, with current TB3 overheads, 2 lanes is enough to transfer data to the GPU. If you use a display connected to the external GPU, you'll see almost zero performance difference. If you want to use the internal display of your laptop, 2 lanes is not enough, and you'll need 4 lanes to shuffle the DisplayPort data back."

https://www.reddit.com/r/Huawei/comments/8niq84/matebook_x_pro_i7_3d_mark_scores_razer_core/dzx3n36/

Full Thread: https://www.reddit.com/r/Huawei/comments/8niq84/matebook_x_pro_i7_3d_mark_scores_razer_core/

Original Reference:

@karlhorky
karlhorky / flow-deepreadonly.js
Last active Aug 21, 2018
Flow: DeepReadOnly utility function
View flow-deepreadonly.js
// Source: https://github.com/facebook/flow/issues/5844
// $ReadOnly doesn't recursively apply invariance to nested object types, and there
// doesn't seem to be any way to do this besides making a separate copy of obj A
// that is invariant. I still want the variant A around in case I want to mutate it
// in certain contexts.
// It would be nice to have some way to use an object as if it's fully, deeply
// invariant without needing to declare a separate variant and invariant type for it.
@karlhorky
karlhorky / flow-Pick.js
Created Aug 21, 2018
Flow: Pick utility function to return a subset of keys of an object type
View flow-Pick.js
// Source: https://github.com/facebook/flow/issues/3367#issuecomment-414490844
// Flow Try: https://flow.org/try/#0C4TwDgpgBACglgYwNYB4DyAnOBzOA7ALijQCMArCBYAGigGkIQBnI0iqgPigF4oASNgFkAhmDgoAUFHqMm1KVBQMQHABRIiygJQ8ufAKIAbCAFsIeYABVwEdFlx5ayjhI4BuCRNCQolgAw8sIioAN5IfkQkAPZRxsJ4AL60YRFQ8SAJ7grSEghReEzAUAip-oEpRMAYAK4QCW5QAPSNUHhRUBAYGFEYnnkFRQgAjERlvBVQQ371TS2d3RhAA
// I've just came across with the need of defining an object type
// using a subset of another, or in other words, use some props
// definition of a certain object type and intersect this result
// (a reduced object type) with another set of props definitions
// to define a new type.
// I used to do this a lot with PropTypes using pick utility from
@karlhorky
karlhorky / flow-Omit.js
Last active Aug 21, 2018
Flow: Omit utility function to remove keys of an object type by using $Diff
View flow-Omit.js
// Source: https://github.com/facebook/flow/issues/3367#issuecomment-397933288
// We can replicate $Omit non dynamic functionality by doing the following:
type T0 = {
k0: string,
k1: number,
k2: boolean
};
@karlhorky
karlhorky / literalType.js
Created Aug 2, 2018
Flow Type: Literal Type Generic Type
View literalType.js
// @flow
// Originally from https://github.com/facebook/flow/issues/2639#issuecomment-409803679
const foo = 'FOO';
function literal(type) {
return { [type]: type };
}
@karlhorky
karlhorky / check-flow-types-without-pragma.md
Created Jul 31, 2018
Check Flow types without @flow pragma comment
View check-flow-types-without-pragma.md

Originally from: https://github.com/facebook/flow/issues/284#issuecomment-408675583

I use following solution which work great:

  1. .flowconfig file is placed to src folder.
  2. node_modules and flow-typed folders resides in root folder.
  3. Option all=true is enabled in .flowconfig file.
  4. flow-typed typings is included in .flowconfig file.
  5. Well-typed modules from node_modules folder that contain module own typings is included to .flowconfig file manually.
You can’t perform that action at this time.