Skip to content

Instantly share code, notes, and snippets.

View tshemsedinov's full-sized avatar
🌍
World ICT Revolution Leader

Timur Shemsedinov tshemsedinov

🌍
World ICT Revolution Leader
View GitHub Profile
@tshemsedinov
tshemsedinov / srp.mjs
Last active May 21, 2024 04:38
Refactor this code using SRP
// Refactor this code using SRP (Single Responsibility Principle)
// To do this you need to decompose getRate into at least
// 2 functions: first will implement `retry` functionality,
// second will work with domain model (prepare call, get results)
// You may decompose to 3 functions or classes but please don't
// make over-engineering in Java style.
// Task from «Patterns for Async and Node.js»
// (Rethinking GRASP, SOLID, GoF for Frontend & Backend)
// 👉 https://t.me/asyncify
@tshemsedinov
tshemsedinov / example.rs
Created August 7, 2023 20:12
Rust compiled by wasm-pack
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern {
pub fn callback(res: i32);
}
#[wasm_bindgen]
pub fn add(a: i32, b: i32) -> i32 {
return a + b;
40
58
23
16
74
31
69 x 2
32 x 2
68
35
@tshemsedinov
tshemsedinov / EXAMPLE.md
Created February 15, 2022 23:59
Nobr example

Here is a code example (using tag <code>) I want to render without breaking line at the middle: const instance = new Polygon([10, 10], [30, 10], [30, -10]); so I'd expect to see whole line at the second line.

To render this I must add line breaks manually, like this:

Here is a code example (using tag <code>) I want to render without breaking line at the middle: const instance = new Polygon([10, 10], [30, 10], [30, -10]); so I'd expect to see whole line at the second line.

@tshemsedinov
tshemsedinov / notOptimal.js
Last active December 8, 2021 08:59
Bad code example for students
'use strict';
let movePoints = (offset, points) => {
points.forEach((point) => {
const type = typeof point;
if (type === 'object') {
point.x += offset.x;
point.y += offset.y;
} else {
let i = points.indexOf(point);
@tshemsedinov
tshemsedinov / master.js
Last active July 22, 2020 20:23
code 1 on assert
'use strict';
// node 12.14.0
// node 14.3.0, 14.4.0, 14.5.0
// node v15.0.0-pre
const assert = require('assert');
const { Worker } = require('worker_threads');
const worker = new Worker('./worker.js');
CREATE TABLE Country (
Id integer NOT NULL,
Name character varying(25) NOT NULL
);
ALTER TABLE Country
ADD CONSTRAINT pkCountryId PRIMARY KEY (id);
CREATE TABLE City (
Id serial NOT NULL,