Skip to content

Instantly share code, notes, and snippets.

View lxchurbakov's full-sized avatar

Aleksandr Churbakov lxchurbakov

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.6.0/rxjs.umd.js"></script>
</head>
<body>
<input id="name" />
<div id="gender">Gender: null</div>
@lxchurbakov
lxchurbakov / slackbot.js
Last active October 28, 2022 07:28
chatbots
const app = new App({
socketMode: true,
token: String(process.env.SLACK_BOT_TOKEN),
appToken: String(process.env.SLACK_APP_TOKEN),
signingSecret: String(process.env.SLACK_SIGNING_SECRET),
});
;(async () => {
// Start your app
app.start().catch((error) => {
@lxchurbakov
lxchurbakov / display.rs
Last active November 1, 2022 11:16
rust-basics
use std::fmt;
struct Position {
longitude: f32,
latitude: f32,
}
impl fmt::Display for Position {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.longitude, self.latitude)
@lxchurbakov
lxchurbakov / node-chrome.json
Created October 28, 2022 15:46
launch.json
{
"configurations": [
{
"name": "Launch Frontend",
"request": "launch",
"runtimeArgs": [
"run-script",
"dev"
],
"runtimeExecutable": "npm",
@lxchurbakov
lxchurbakov / fe-build-nginx
Last active May 22, 2023 06:57
deployment-stuff
// nginx.conf
events { }
http {
include mime.types;
include /etc/nginx/conf.d/*;
}
// default.conf
// See $PORT is taken from container run envs
@lxchurbakov
lxchurbakov / index.ts
Created November 8, 2022 08:46
moment-like-string-format-parser
const extractParams = (after: string) => {
if (!after.startsWith('(')) {
return [after, {}];
}
const paramsEnd = after.indexOf(')');
return [
after.slice(paramsEnd + 1),
Object.fromEntries(
@lxchurbakov
lxchurbakov / atoms.tsx
Last active June 3, 2023 04:25
minimal-ui
import React from 'react';
import styled, { css } from 'styled-components';
type PropsOf<T> = T extends React.FC<infer P> ? P : never;
export type BaseProps = {
p?: string;
pt?: string;
pl?: string;
pr?: string;
// tsconfig
{
"compilerOptions": {
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./src",
"outDir": "./dist",
"sourceMap": true,
"declaration": false,
@lxchurbakov
lxchurbakov / rxjs.ts
Created December 6, 2022 08:21
libraries
const observable = (predicate) => (listener) => predicate(listener);
const pipe = (obs) => (...operators) => operators.reduce((acc, op) => op(acc), obs);
const map = (mapper) => (obs) => observable((resolve) => obs((data) => resolve(mapper(data))));
const mergeMap = (mapper) => (obs) => observable((resolve) => obs((data) => mapper(data)(resolve)))
const filter = (predicate) => (obs) => observable((resolve) => obs((data) => predicate(data) && resolve(data)));
// {
@lxchurbakov
lxchurbakov / assets.ts
Last active January 25, 2023 09:38
plugins
export type Image = HTMLImageElement;
const loadImage = async (url: string) => new Promise<Image>((resolve, reject) => {
const img = new Image();
img.onload = () => resolve(img);
img.onerror = (e) => reject(e);
img.src = url;
});