Skip to content

Instantly share code, notes, and snippets.

View Stradivario's full-sized avatar
🌊
Riding the wave

Kristiqn Tachev Stradivario

🌊
Riding the wave
View GitHub Profile
@Stradivario
Stradivario / flatten.ts
Created April 2, 2020 09:31
Flatten array typescript
export function flatten<T>(array: T[], depth?: number): Generator<T>;
export function flatten<T>(array: T[][], depth?: number): Generator<T>;
export function flatten<T>(array: T[][][], depth?: number): Generator<T>;
export function flatten<T>(array: T[][][][], depth?: number): Generator<T>;
export function flatten<T>(array: T[][][][][], depth?: number): Generator<T>;
export function flatten<T>(array: T[][][][][][][], depth?: number): Generator<T>;
export function flatten<T>(array: T[][][][][][][][], depth?: number): Generator<T>;
export function flatten<T>(array: T[][][][][][][][][], depth?: number): Generator<T>;
export function flatten<T>(array: T[][][][][][][][][][], depth?: number): Generator<T>;
export function flatten<T>(array: T[][][][][][][][][][][], depth?: number): Generator<T>;
// export function Reader<T>(...arg: ObjectType<T>[]): MethodDecorator {
// return (
// target: object,
// propertyKey: string | symbol,
// descriptor: TypedPropertyDescriptor<any>
// ) => {
// const method = descriptor.value;
// descriptor.value = function(args: unknown[]) {
// args = args || [];
@Stradivario
Stradivario / di.ts
Last active March 30, 2020 12:04
Dependency Injection in 24 lines of code using Typescript
type ObjectType<T> = new (...args: unknown[]) => T;
const C = new Map();
const ascii = (a: string) => a.charCodeAt(0);
const toHashKey = <T>(c: ObjectType<T>) =>
`${c}`
.split('')
.map(ascii)
import { CoreModule, Module, Controller, Query, Type, GraphQLObjectType, GraphQLString, GraphQLFloat, GraphQLInt } from "@gapi/core";
import { VoyagerModule } from "@gapi/voyager";
import { Neo4JModule, graphRequest } from "@rxdi/neo4j";
import { makeAugmentedSchema } from "neo4j-graphql-js";
import { mergeSchemas } from "graphql-tools";
const typeDefs = `
type Movie {
title: String
year: Int
@Stradivario
Stradivario / index.html
Last active December 24, 2019 11:44
Simplest Graphql client based on Web Components and https://github.com/rxdi/graphql-webcomponent
<script
type="text/javascript"
src="https://rawcdn.githack.com/rxdi/graphql-webcomponent/dd8686a81f88ba481d3b4d22d2459bfcbdcff9ed/dist/regular/0.0.15.js"
></script>
<setup-graphql
uri="https://countries.trevorblades.com/"
pubsub="wss://pubsub.youvolio.com/subscriptions"
></setup-graphql>
@Stradivario
Stradivario / decentralized-app.html
Last active November 14, 2019 01:52
Decentralized @rxdi website based on single WebComponent called <rx-graph></rx-graph> connecting with Graphql backend
<script src="./index.ts"></script>
<div id="app"></div>
<!-- State management -->
<script>
const APP_STATE = 'state';
const INITIAL_STATE = { clicked: true };
const getState = () => Container.get(APP_STATE).asObservable()
@Stradivario
Stradivario / app.html
Last active November 14, 2019 08:36
Decentralized @rxdi website based on single WebComponent called <rx-graph></rx-graph> connecting with Graphql backend
<script src="https://ipfs.io/ipfs/QmfXGKAeDwVZF9THVCKtYRjcNrhBG6iuBStXrNoBRGimFp/index.js"></script>
<div id="app"></div>
<!-- State management -->
<script>
const APP_STATE = 'state';
const INITIAL_STATE = { clicked: true };
const getState = () => Container.get(APP_STATE).asObservable()
import { html, Component, LitElement, css } from '@rxdi/lit-html';
import RedRock from '@client/assets/images/background/red-rock.png';
import BlueWater from '@client/assets/images/background/blue-water.png';
import Atmosphere from '@client/assets/images/background/plant-with-athmosphear.png';
interface PricingTemplate {
title: string;
subTitle: string;
slogan: string;
@Stradivario
Stradivario / gateway.ts
Created September 27, 2019 18:20
Graphql Gateway for @gapi applications
import {
Module,
CoreModule,
Bootstrap,
ON_REQUEST_HANDLER,
GRAPHQL_PLUGIN_CONFIG,
Container
} from '@gapi/core';
import {
MicroserviceModule,
@Stradivario
Stradivario / flex-grid.component.ts
Last active September 18, 2019 06:08
Reactive flex grid lit component
import { html, Component, LitElement, css, property, async, TemplateResult } from '@rxdi/lit-html';
import { Inject } from '@rxdi/core';
import { map, switchMap } from 'rxjs/operators';
import { combineLatest, of, Observable, isObservable, from } from 'rxjs';
import { ResponsiveService } from '@rxdi/ui-components/services';
/**
* @customElement flex-grid
*/
@Component({