Skip to content

Instantly share code, notes, and snippets.

View Aleksey-Danchin's full-sized avatar

Алексей Данчин Aleksey-Danchin

View GitHub Profile
@Aleksey-Danchin
Aleksey-Danchin / scene.py
Created January 27, 2024 14:37
Булевые операции
from manim import *
class Sample(Scene):
def construct(self):
ellipse1 = Ellipse(
width=4.0, height=5.0, fill_opacity=0.5, color=BLUE, stroke_width=10
).move_to(LEFT)
ellipse2 = ellipse1.copy().set_color(RED).move_to(RIGHT)
@Aleksey-Danchin
Aleksey-Danchin / scene.py
Created January 26, 2024 11:42
Hashtag cloud with clockwise transform
# Based on https://www.youtube.com/watch?v=u8zLAUroUq8&ab_channel=WildMathing
from manim import *
from numpy.random import uniform
# WORDS = (
# r"e^{i/pi}+1=0",
# r"3^2+4^2=5^2",
# r"V+F-E=2",
# r"\exists",
import TelegramBot from "node-telegram-bot-api";
export type UseHandler<ContextType> = (
message: TelegramBot.Message | undefined,
metadata: TelegramBot.Metadata | undefined,
query: TelegramBot.CallbackQuery | undefined,
context: ContextType,
next: () => void
) => void;
def merge_sort(array: list):
length = len(array)
buff = [0 for _ in range(length)]
def merge_sort_master(start_index, finish_index):
size = finish_index - start_index + 1
if size < 2:
return
def quick_sort(array: list):
def quick_sort_master(start_index, finish_index):
pivot = array[(start_index + finish_index) // 2]
left_index = start_index
right_index = finish_index
while left_index <= right_index:
while array[left_index] < pivot:
left_index += 1
while array[right_index] > pivot:
const getType = (x: any) => Object.prototype.toString.call(x).slice(8, -1);
// prettier-ignore
const primitiveTypes = ["Number", "String", "Boolean", "Null", "BigInt", 'Symbol', 'Undefined'];
const isPrimitiveType = (x: any) => primitiveTypes.includes(getType(x));
export const getCopy = (x: any) => {
if (isPrimitiveType(x)) {
return x;
}
@Aleksey-Danchin
Aleksey-Danchin / sudoku_solver.js
Created September 11, 2022 12:37
Sudoku solver (codewars)
// https://www.codewars.com/kata/5296bc77afba8baa690002d7
const puzzle = [
[5, 3, 0, 0, 7, 0, 0, 0, 0],
[6, 0, 0, 1, 9, 5, 0, 0, 0],
[0, 9, 8, 0, 0, 0, 0, 6, 0],
[8, 0, 0, 0, 6, 0, 0, 0, 3],
[4, 0, 0, 8, 0, 3, 0, 0, 1],
[7, 0, 0, 0, 2, 0, 0, 0, 6],
[0, 6, 0, 0, 0, 0, 2, 8, 0],
@Aleksey-Danchin
Aleksey-Danchin / byProgress.js
Created April 15, 2022 08:24
Декоратор для отслеживания прогресса загрузки ответа.
async function byProgress(response, progressHandler) {
const reader = response.body.getReader();
const chunks = [];
let length = 0;
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
@Aleksey-Danchin
Aleksey-Danchin / rename.js
Created April 12, 2022 15:10
Rename script for videos
const { readdir, rename } = require("fs/promises");
const { resolve } = require("path");
(async () => {
const __dirname = resolve();
const tracks = (await readdir(__dirname))
.map((name) => {
const match = name.match(/(\d{4})-(\d{2})-(\d{2}) (\d{2})-(\d{2})-(\d{2}).mp4/i);
@Aleksey-Danchin
Aleksey-Danchin / App.js
Created August 23, 2020 13:52
CustomTable usage example
import React from "react";
import CustomTable from "./Components/CustomTable";
function App() {
const users = [
{
id: 1,
name: "Алексей",
surname: "Данчин",