Skip to content

Instantly share code, notes, and snippets.

@erratir
erratir / MVP_example.js
Last active April 27, 2024 03:18
MVP (Model-View-Presenter) pattern example https://codepen.io/erratir/pen/xxKYevd
// https://codepen.io/erratir/pen/xxKYevd
// MVP — Presenter — создает модель и отображение, после чего отвечает за связывание их между собой:
// слушает изменения в каждом из них и вызывает обновления
// user-view.js
const render = (html) => {
const element = document.createElement(`div`);
element.innerHTML = html;
return element;
};
@erratir
erratir / index.html
Last active April 27, 2024 03:18
Event Emitter - паттерн: https://codepen.io/erratir/pen/dybEVPO
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<input type="text">
@weibeld
weibeld / telegram-api.pdf
Last active April 27, 2024 03:18
Telegram CLI Commands
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@patshaughnessy
patshaughnessy / gist:70519495343412504686
Last active April 27, 2024 03:11
How to Debug Postgres using LLDB on a Mac
This note explains how to build Postgres from source and setup to debug it using LLDB on a Mac. I used this technique to research this article:
http://patshaughnessy.net/2014/10/13/following-a-select-statement-through-postgres-internals
1. Shut down existing postgres if necessary - you don’t want to mess up your existing DB or work :)
$ ps aux | grep postgres
pat 456 0.0 0.0 2503812 828 ?? Ss Sun10AM 0:11.59 postgres: stats collector process
pat 455 0.0 0.0 2649692 2536 ?? Ss Sun10AM 0:05.00 postgres: autovacuum launcher process
pat 454 0.0 0.0 2640476 304 ?? Ss Sun10AM 0:00.74 postgres: wal writer process
pat 453 0.0 0.0 2640476 336 ?? Ss Sun10AM 0:00.76 postgres: writer process
@angelblasco
angelblasco / Estructura PL_SQL
Last active April 27, 2024 03:11
Plantillas PL/SQL
DECLARE
/* aqui van las variables */
BEGIN
/* estructura del programa, sentencias SQL */
EXCEPTION
/* manejo de excepciones */
END;
/* final del bloque */
@nafiesl
nafiesl / how_to_get_telegram_chat_id.md
Created December 20, 2023 11:49
How to get Telegram Bot Chat ID

How to get Telegram Bot Chat ID

Create a Telegram Bot and get a Bot Token

  1. Open Telegram application then search for @BotFather
  2. Click Start
  3. Click Menu -> /newbot or type /newbot and hit Send
  4. Follow the instruction until we get message like so
    Done! Congratulations on your new bot. You will find it at t.me/new_bot.
    
@erratir
erratir / groupBy.js
Last active April 27, 2024 03:08
Group array of objects by object key
/**
* Group array of objects by object key
* Example:
const pets = [
{ type:"Dog", name:"Bobik", skills: { canBite: true } },
{ type:"Cat", name:"Tiger", skills: { canBite: true } },
{ type:"Dog", name:"Tuzik", skills: { canBite: true } },
{ type:"Cat", name:"Leopold", skills: { canBite: false } }
];
@erratir
erratir / utils.js
Last active April 27, 2024 03:07
Функция обертка для кеширования результатов вызова функции
// Функция обертка для кеширования результатов вызова функции
const cache = new Map()
const cached = (fn, fnName = '') => {
if (fnName) console.info(`Результат выполнения функции '${fnName}' будет закэширован`);
return async (...params) => {
const key = params.toString()
if (!cache.has(key) ) {
console.log('функция будет выполнена')
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@aamiaa
aamiaa / CompleteDiscordQuest.md
Last active April 27, 2024 03:02
Complete Recent Discord Quest

Complete Recent Discord Quest

Note

This no longer works in browser!

Note

This no longer works if you're alone in vc! Somebody else has to join you!

How to use this script:

  1. Accept the quest under User Settings -> Gift Inventory