Skip to content

Instantly share code, notes, and snippets.

@Titiaiev
Titiaiev / init-node-ts.sh
Created April 14, 2023 00:08
генерация проекта нода плюс тс
#!/bin/bash
# создаёт новый nodejs typescript
# настраивает eslint, prettier, nodemon, устанавливает рабочие зависимости
# инициализирует гит репозиторий и делает инит комит
echo "(Будет использовано для name в package.json и создания директории проекта)"
echo -n "Введите название проекта: "
read PROJECT_NAME
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid",
#! /bin/bash
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add - \
&& touch /etc/apt/sources.list.d/mongodb-org-4.4.list \
&& echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list \
&& sudo apt-get update \
&& sudo apt-get install -y mongodb-org \
&& sudo mkdir /var/lib/mongodb /var/log/mongodb /var/run/mongodb \
&& sudo chown -R mongodb:mongodb /var/lib/mongodb /var/log/mongodb /var/run/mongodb \
&& sudo touch /etc/mongod.conf \
&& sudo wget https://gist.githubusercontent.com/Titiaiev/5af58cf194f5412665f201e40f6668b9/raw/98dd724c349e46cab521a5e626fa8247019b6a87/mongod.conf > /etc/mongod.conf \
@Titiaiev
Titiaiev / latency.txt
Created August 21, 2020 20:33 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

#!/bin/bash
DIVIDER="====================================="
USER_CHROM_PROFILE_DIRNAME=".chrome_user_profile"
IGNORE=".gitignore"
echo "Хотите запустить инициализацию нового проект? (yes/no)"
read AGREE
echo "$DIVIDER"
@Titiaiev
Titiaiev / launch_vscode_chrome.js
Last active December 5, 2019 17:18
work automation
#!/usr/bin/env node
const {exec} = require('child_process');
const process = require('process');
const USER_CHROM_PROFILE_DIRNAME = "./chrome_user_profile";
const URLs_FOR_OPEN = ['google.com', 'nodejs.org'];
var gfg;
// # запуск хрома без гуи для удаленного дебага
// #chrome --headless --remote-debugging-port=9222 https://chromium.org
// список интересных флагов для хрома
@Titiaiev
Titiaiev / react.html
Created April 29, 2019 19:40
React { простой стартовый шаблон-песочница }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React app</title>
</head>
<body>
@Titiaiev
Titiaiev / Caesar-cipher.js
Last active January 5, 2019 23:01
Шифр Цезаря. Перебирает варианты сдвига в строке и возвращает массив вариантов строк.
// для теста
// const str = 'ПГПГ ПЮОГ УГПЦ';
// расшифровывается в "мама мыла раму"
const caesarCipher = function caesarCipher(string) {
const codesMap = {
а: 1,
б: 2,
в: 3,
г: 4,
д: 5,
@Titiaiev
Titiaiev / .eslintrc
Last active November 10, 2019 16:52
eslint config
{
"extends": [ "airbnb-base" ],
"parser": "babel-eslint",
"plugins": [],
"env": {
"amd": true,
"browser": true,
"jquery": true,
"node": true,
"es6": true,