Skip to content

Instantly share code, notes, and snippets.

View eps1lon's full-sized avatar
:atom:
mt?!" “ .I.r '2 f

Sebastian Silbermann eps1lon

:atom:
mt?!" “ .I.r '2 f
View GitHub Profile
@eps1lon
eps1lon / framing_example.js
Last active January 17, 2017 19:16
example sql-like usage of jsonld frames with aboxes; put northwind.json in the same dir; tested with Chrome Version 55.0.2883.87 (64-bit); wont help u with other browser vendors;
(function (window) {
'use strict';
const $ = window.jQuery;
/**
* put these members where they fit best. they were just put into one obj
* for better overview
*
* @type {{context: {owl: string, dcam: string, rdf: string, dcmi: string, xml: string, xsd: string, ia: string, nw: string, nwa: string, rdfs: string, dc: string}, data: *, query: query, byUri: byUri, byUris: byUris, byType: byType}}
*/
(() => {
const items = {};
for (const row of document.querySelectorAll('tr td:nth-of-type(2)')) {
const full_name_element = row.querySelector('a.item_unique');
if (full_name_element !== undefined) {
const full_name = full_name_element.innerText;
let implicits = [];
import { Omit } from 'utility-types';
import { BaseItemTypeProps, EssenceProps, ModProps } from '../schema';
/**
* *_mod_key is keyof mods/essenceMods.json
*/
export interface NormalizedEssenceProps {
primary: number;
tier: number;
@eps1lon
eps1lon / tuple.ts
Last active June 19, 2018 15:51
Tuple type inference in TypeScript
// The problem, playground: https://bit.ly/2t9gDij
const getFirst = (arg: [number, number]) => arg[0];
const getSecond = (arg: [number, number]) => arg[1];
const foo = [1, 2];
const foo_tuple = foo as Tuple2b<typeof foo>;
const firstBad = getFirst(foo); // $ExpectError
// the "solution"
import React, { useContext } from "react";
//styles
import * as S from "./styles";
import * as A from "styles/shared-components";
//components
import Header from "components/Header";
import { AuthContext } from "components/Auth";
import SpinnerComponent from "components/Spinner";
@eps1lon
eps1lon / findDOMNode-deprecation-issues.md
Last active November 29, 2018 16:24
Issues observed when trying to migrate from findDOMNode to ref

issues migrating from findDOMNode

Timeline

  1. <= 16.3: findDOMNode is discouraged but accepted for certain use cases
  2. 16.3 (2018-03-28): forwardRef is introduced: It can be used in HOCs to avoid using findDOMNode on the enhanced component
  3. 16.6 (2018-10-23): findDOMNode is deprecated in React.StrictMode
  4. 16.7.alpha (2018-10-24): React.Concurrent mode is released: This mode extends React.StrictMode in a way that findDOMNode is deprecated in that mode too.
@eps1lon
eps1lon / useControlled.js
Created February 21, 2019 12:51
useControlled
function useIsControlled(value) {
const { current: isControlled } = React.useRef(value != null);
return isControlled;
}
function useControlled(config) {
const { value, defaultValue, setControlledValue } = config;
const isControlled = useIsControlled(value);
const [state, setState] = React.useState(defaultValue);
# exclude i10n md files searching in vscode "files to exclude"
*-de.md,*-es.md,*-fr.md,*-ja.md,*-pt.md,*-zh.md,*-ru.md
@eps1lon
eps1lon / lazyForwardRef.js
Created March 14, 2019 11:46
React lazy + forwardRef
const Component = React.lazy(() => {
return import("./Component").then(({ default: Component }) => {
return {
default: React.forwardRef((props, ref) => (
<Component ref={ref} {...props} />
))
};
});
});
@eps1lon
eps1lon / link.js
Created March 20, 2019 09:50
runs link for packages in Material-UI workspace