Skip to content

Instantly share code, notes, and snippets.

View kino6052's full-sized avatar
🏠
Working from home

Kirill Novik kino6052

🏠
Working from home
View GitHub Profile
expect(reduce(['change', 'input-01', 'ball'], initialState)).toEqual({
input: "ball",
isInStockOnly: false,
products: [
{
id: "0",
category: "Sporting Goods",
price: "$49.99",
stocked: true,
name: "Football",
const initialState: IState = {
input: "",
isInStockOnly: false,
products: [
{
id: "0",
category: "Sporting Goods",
price: "$49.99",
stocked: true,
name: "Football"
import React from "react";
import { Subject } from "rxjs";
export type EventType = "click" | "change" | "focus";
export type Id = string;
export type IEvent = [EventType, Id, string | undefined];
export const EventSubject = new Subject<IEvent>();
export const EventWrapper: React.FC<{ id: string }> = (props) => {
@kino6052
kino6052 / existence.ts
Last active December 8, 2020 16:34
Existence
const is = (it, n = Symbol()) => (it ?? n) !== n;
const is = it => (it ?? null) !== null;
@kino6052
kino6052 / remove-all-branches.sh
Created November 30, 2020 17:37
Remove All Local Branches
git branch | grep -v "master" | xargs git branch -D
@kino6052
kino6052 / formik-is-pristine.ts
Created November 20, 2020 19:19
Formik isPristine
const isPristine = (
fieldName: string | string[],
touched: FormikTouched<FormikValues>
) =>
[fieldName]
.flatMap((fieldName) => fieldName)
.every((fieldName) => !touched[fieldName]);
import { Subject } from "rxjs";
import { RTCMessagingAgent } from "./rtc-messaging-agent";
const configuration = {
iceServers: [
{
urls: [
"stun:stun.l.google.com:19302",
"stun:stun1.l.google.com:19302",
"stun:stun2.l.google.com:19302",
export class RTCMessagingAgent {
// Subjects
public OnAddParticipantSubject = new Subject<string>();
public OnRemoveParticipantSubject = new Subject<string>();
public OnSetLocalDescription = new Subject<
[string, RTCSessionDescriptionInit]
>();
public OnSetRemoteDescription = new Subject<
[string, RTCSessionDescriptionInit]
export class BroadcastingAgent {
// Participants
public participants: string[] = [];
// Subjects
public addParticipantSubject = new Subject<string>();
public removeParticipantSubject = new Subject<string>();
private commSubject: Subject<IMessage<unknown>>;
constructor(
export class Client {
private id = generateId(4, 4);
// Channels
private dataChannels: { [id: string]: RTCDataChannel } = {};
private streams: { [id: string]: MediaStream[] } = {};
// Agents
private BroadcastingAgent = new BroadcastingAgent(
this.id,