Skip to content

Instantly share code, notes, and snippets.

View lkostrowski's full-sized avatar
🇺🇦

Lukasz Ostrowski lkostrowski

🇺🇦
View GitHub Profile
export declare namespace SystemID {
/**
* System short public ID, e.g A10005, B00040
*/
export type Short = string & {
__brand: 'system-short-id';
};
/**
* UUID V4
new Promise(resolve => {
throw new Error(0) return 1
})
.then(console.log)
.catch(e => {
console.log(e) return 2;
})
.then(console.log)
const a = [1, 2, 3, 4, 5];
// Implement this
a.multiply()
console.log(a) // [1, 2, 3, 4, 5, 1, 4, 9, 16, 25]
@lkostrowski
lkostrowski / lib.tsx
Created May 29, 2020 09:42
Component resolver
import React, {ComponentType} from 'react';
// Lib
declare function withDataResolving<TAppState, TReturnState, R1 = any>(injectSelectors: [(appState: TAppState) => R1], strategy: (data: R1) => TReturnState): <TProps extends {}>(Component: ComponentType<TProps>) => (props: TProps & TReturnState) => ComponentType<Exclude<TProps, TReturnState>>;
declare function withDataResolving<TAppState, TReturnState, R1 = any, R2 = any>(injectSelectors: [(appState: TAppState) => R1, (appState: TAppState) => R2], strategy: (data: R1, data2: R2) => TReturnState): <TProps extends {}>(Component: ComponentType<TProps>) => (props: TProps & TReturnState) => ComponentType<Exclude<TProps, TReturnState>>;
declare function withDataResolving<TAppState, TReturnState, R1 = any, R2 = any, R3 = any>(injectSelectors: [(appState: TAppState) => R1, (appState: TAppState) => R2, (appState: TAppState) => R3], strategy: (data: R1, data2: R2, data3: R3) => TReturnState): <TProps extends {}>(Component: ComponentType<TProps>) => (props: TProps & TRe
export const SystemSelectorV2: SystemsSelectorV2 = {
getSystemsForTableView: createSelector(getSystemsDomain, (domain) =>
Object.values(domain.systemsByID).map((normalizedSystem) => {
const baseData: SystemModel.SystemsTableRowData = {
id: normalizedSystem.id,
systemID: normalizedSystem.systemIdentifier,
address: normalizedSystem.address,
systemType: normalizedSystem.type,
customer: null,
installer: null,
@lkostrowski
lkostrowski / Settings.route.ts
Created May 5, 2020 18:22
Route Object Pattern
/**
* Create a class/service, possibly don't export it so it's not confused with it's instance
*/
class SettingsRoute {
/**
* Expose public routes
* Can be also as getter functions - possible even better!
*/
public MAIN = `${this.baseUrl}settings`;
public SECURITY = `${this.baseUrl}settings/security`;
@lkostrowski
lkostrowski / app.tsx
Last active January 29, 2019 22:05
React DI Poc
import React from 'react';
import { DependencyContainer, ProvidersMap } from 'some-react-di';
const providers = new ProvidersMap([SomeService, {token: AnotherService, provide: new MockService()}]);
providers.bind('string-token').to('some-value');
export const App = () =>
(
<DependencyContainer providersMap={providers}>
<SomeContainerComponentA />
{
"name": "my-razzle-app",
"version": "0.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/code-frame": {
"version": "7.0.0-beta.44",
"resolved": "http://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz",
"integrity": "sha512-cuAuTTIQ9RqcFRJ/Y8PvTh+paepNcaGxwQwjIDRWPXmzzyAeCO4KqS9ikMvq0MCbRk6GlYKwfzStrcP3/jSL8g==",
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/code-frame@7.0.0-beta.44":
version "7.0.0-beta.44"
resolved "http://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9"
dependencies:
"@babel/highlight" "7.0.0-beta.44"
@lkostrowski
lkostrowski / input.vue
Last active April 14, 2017 15:57
Input in vue.js
import createRandomId from 'utilities/helpers/createRandomId';
<template>
<div class="input">
<div class="input__field-container" >
<label
:for="thisId" class="input__label"
:class="required ? 'input__label--required' : '' ">{{label}}</label>
<input