Skip to content

Instantly share code, notes, and snippets.

View b2whats's full-sized avatar
🎯
Focusing

Akimov Vladimir b2whats

🎯
Focusing
View GitHub Profile
@b2whats
b2whats / README.md
Created July 7, 2024 01:28 — forked from pcan/README.md
Node.js plain TLS Client & Server, 2-way Cert Auth

Node.js TLS plain TLS sockets

This guide shows how to set up a bidirectional client/server authentication for plain TLS sockets.

Newer versions of openssl are stricter about certificate purposes. Use extensions accordingly.

Prepare certificates

Generate a Certificate Authority:

@b2whats
b2whats / fluent_mapper_builder_gist.ts
Created May 4, 2022 02:54 — forked from JSuder-xx/fluent_mapper_builder_gist.ts
Explicitly declare modifications to an existing object type via a fluent interface which yields a mapping function to the derived type. Demonstration of TypeScript meta-programming through mapped and conditional types.
/**
* _Explicitly declare modifications_ to an existing object type via a fluent interface which yields a mapping function
* from the original data type to the type derived from the modification commands.
*
* The value over authoring a simple mapping function directly
* * harder to make a mistake due to the explicit nature
* * easier to read.
*
* This is _not_ production quality code but rather a _proof of concept_ gist for applying conditional/mapped
* types to mapper generation. A real-world usage might involve also generating the type-guard function
@b2whats
b2whats / constrained_fluent_builder.ts
Created May 4, 2022 02:54 — forked from JSuder-xx/constrained_fluent_builder.ts
Fluent Builder Type API which transforms any arbitrary fluent builder type into a fluent builder type enforcing call count dependencies between methods (where dependencies are represented as a type). Employs Mapped, Conditional, and Literal Types to demonstrate both TypeScript's proximity to dependent typing and the practical value.
/**
* Imagine a Fluent Builder where some subset of the fluent methods are valid to call
* * after one or more fluent methods have been called
* * before one or more fluent methods have been called
* * limited number of times.
*
* There is no way to enforce such constraints in statically typed languages such as C++, C# or Java when using a single builder
* class/interface. Developers would need to author many interfaces to represent the different shapes and would likely need to
* author many versions of the builder itself (proxies with a specific signature delegating to an underlying source builder).
*
@b2whats
b2whats / MutateRuntimePlugin.js
Created February 9, 2021 21:45 — forked from yordis/MutateRuntimePlugin.js
Remote PublicPath Modification
const PLUGIN_NAME = "MutateRuntimePlugin";
class MutateRuntimePlugin {
/**
*
* @param {FederationDashboardPluginOptions} options
*/
constructor(options) {}
/**
@b2whats
b2whats / types.md
Last active June 24, 2020 20:14
Types

Сравнения

type Require = {} extends { a: string } ? true : false // false
type OptionalProperty = {} extends { a?: string } ? true : false // true
type OptionalValue = {} extends { a: string | undefined } ? true : false
type Index = {} extends { [x: string]: any } ? true : false // true
@b2whats
b2whats / babel.config.js
Last active June 16, 2020 19:22
publish build componets
/* eslint-disable no-console */
const resolver = require('babel-plugin-module-resolver')
const resolve = require('enhanced-resolve')
const path = require('path')
const { DEBUG, BABEL_ENV, NODE_ENV, TARGET } = process.env
const isProduction = NODE_ENV === 'production'
const isServer = TARGET === 'server'
const resolverTs = resolve.create.sync({
extensions: ['.ts', '.tsx', '.js', '.json'],
@b2whats
b2whats / index.html
Last active April 15, 2020 17:16 — forked from JobLeonard/index.html
join vs concat when dealing with very long lists of single-character strings (http://jsbench.github.io/#c9813d523fd015e61472b9258703e6ef) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>join vs concat when dealing with very long lists of single-character strings</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@b2whats
b2whats / Infrastructure.js
Created March 12, 2019 12:54 — forked from sebmarkbage/Infrastructure.js
SynchronousAsync.js
let cache = new Map();
let pending = new Map();
function fetchTextSync(url) {
if (cache.has(url)) {
return cache.get(url);
}
if (pending.has(url)) {
throw pending.get(url);
}
@b2whats
b2whats / requirements.md
Last active February 27, 2019 09:40
requirements

Наименование компонента

Минимальное описание или графческое представление

Обсуждение

Тут бубут находится все обсуждения этого компонента в виде форализованных сообщений, ссылки на возможный дизайн и примеры

Когда использовать

Так мы пушим нотификации из любого места системы, статическое свойство класса.
NotificationManager.addMessage({
id?: number | string,
content: React.Node,
timeout?: number,
onClose?: (event: SyntheticEvent<HTMLElement>) => void
})