Skip to content

Instantly share code, notes, and snippets.

@alexamy
alexamy / postgresql_intro.py
Last active June 6, 2020 18:39
Решение задания № 6 по теме "Знакомство с СУБД PostgreSQL" по предмету "Базы данных"
import psycopg2
# 6. Сколько маршрутов обслуживают самолёты каждого типа?
query = """select ad.aircraft_code, count(distinct f.flight_no)
from aircrafts_data ad
left join flights f
using (aircraft_code)
group by ad.aircraft_code;"""
connection = psycopg2.connect(
@alexamy
alexamy / mock.test.ts
Created January 4, 2023 23:38
Jest mocking
import { nanoid } from 'nanoid/non-secure';
import { Autolog } from '../autolog';
jest.mock('nanoid/non-secure');
jest.mock('../autolog', () => {
const actual = jest.requireActual('../autolog');
return {
__esModule: true,
...actual,
@alexamy
alexamy / extract-emojis.js
Last active March 30, 2024 22:29
Extract emojis list as JSON & CSV from https://*.slack.com/customize/emoji
// extract all emojis from https://*.slack.com/customize/emoji
// open devtools console and paste this code
// tested in google chrome
await getEmojis();
async function getEmojis() {
const result = {};
const allCount = parseInt(document.querySelector('.p-customize_emoji_wrapper__count').textContent);
const log = (s) => console.log('[sep] %c%s', 'background: #2f3640; color: #00a8ff; font-weight: bold; font-size: 14px; padding: 1px', s);
@alexamy
alexamy / gist:091e3f1444bb6185a349c61e6f96e819
Last active July 7, 2023 09:38
Remove all videos from Youtube Watch Later playlist (run in console on https://www.youtube.com/playlist?list=WL)
setInterval(function deleteOne() {
const actions = document.querySelector("ytd-playlist-video-renderer button[aria-label='Меню действий']");
actions.click();
setTimeout(() => {
const icon = document.querySelector("path[d='M11 17H9V8h2v9zm4-9h-2v9h2V8zm4-4v1h-1v16H6V5H5V4h4V3h6v1h4zm-2 1H7v15h10V5z']");
const remove = icon.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
remove.click();
}, 10);
}, 20);
@alexamy
alexamy / store.tsx
Last active May 23, 2024 09:53
SolidJS store example
import { createContext, createEffect, on, useContext, type JSXElement } from 'solid-js';
import { createStore } from 'solid-js/store';
import { render } from 'solid-js/web';
// **** This is a complete, operational example of a store that includes custom methods.
// **** Copy-paste to https://playground.solidjs.com/
// Store type (with custom methods)
export type State = ReturnType<typeof createAppStore>;