Skip to content

Instantly share code, notes, and snippets.

View ShadowMitia's full-sized avatar
💭
Coding my problems

Dimitri Belopopsky ShadowMitia

💭
Coding my problems
View GitHub Profile
@ShadowMitia
ShadowMitia / main.py
Created December 3, 2024 22:03
Frieze Pattern Generator in Python from Friezes, Triangulations, and Trees by YIJIA ZENG (Bachelor Thesis) http://lup.lub.lu.se/student-papers/record/9111047
# From: http://lup.lub.lu.se/student-papers/record/9111047
import matplotlib . pyplot as plt
import networkx as nx
def unimodular ( arr0 , arr1 , arr2 , j , order , edges ) : # use unimodular rules to calculate a new row and connecting vertices of the corresponding polygon triangulation for every 1 in this row
arr2 =[]
k = 0
for i in range ( order ) : # To calculate the left - most and right - most ones , we need to take care of the index
#!/bin/bash
# Requires https://github.com/sharkdp/fd
fdfind Cargo.toml --exec bash -c "pushd {//}; cargo clean"
@ShadowMitia
ShadowMitia / script.sh
Created February 16, 2022 20:00
Get duration of a video/playlist
function displaytime {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
(( $D > 0 )) && printf '%d days ' $D
(( $H > 0 )) && printf '%d hours ' $H
(( $M > 0 )) && printf '%d minutes ' $M
(( $D > 0 || $H > 0 || $M > 0 )) && printf 'and '
@ShadowMitia
ShadowMitia / script.sh
Last active January 24, 2022 12:32
Get video filesize on youtube (works with playlists too) (doesn't always include audio size if separated)
yt-dlp -F url > file.txt; cat file.txt | grep "1920x1080" | grep "webm" | sed "s/ \+/ /g" | cut -d ' ' -f6 | rev | cut -c4- | rev | awk '{s+=$1} END {printf "%.0f\n", s}'
use rand::prelude::*;
#[derive(Clone, Copy)]
struct Point2 {
x: f64,
y: f64,
}
#[derive(Clone, Copy)]
struct Point3 {
@ShadowMitia
ShadowMitia / kdtree.cpp
Last active May 29, 2021 15:32
KDTree implementation, based on wikipedia example (C++11 version)
#include <algorithm>
#include <cmath>
#include <iostream>
#include <memory>
#include <optional>
#include <string>
#include <type_traits>
#include <vector>
@ShadowMitia
ShadowMitia / bubble_sort_ocaml.ml
Created October 3, 2020 21:19
Recursive bubble in ocaml
let rec print_list = function
[] -> ()
| e::l -> print_int e ; print_string " " ; print_list l
let bubble_sort l =
let n = (List.length l) - 1 in
let rec bubble_sort_rec arr res n =
match arr with
| [] -> if n > 0 then bubble_sort_rec res [] (n - 1) else res
| x :: [] -> if n > 0 then bubble_sort_rec (res @ [x]) [] (n - 1) else (res @ [x])
/*
From : https://dev.to/thepracticaldev/daily-challenge-117-minminmax-2kmn
Given an unsorted array of integers, find the smallest number in the array,
the largest number in the array, and the smallest number between the two array
bounds that are not in the array.
Examples
minMinMax({-1, 4, 5, -23, 24}); //[-23, -22, 24]
@ShadowMitia
ShadowMitia / output.log
Created September 24, 2019 13:27
Conan tox output
GLOB sdist-make: /home/dimitri/gits/conan/setup.py
full inst-nodeps: /home/dimitri/gits/conan/.tox/.tmp/package/1/conan-1.19.0.dev0.zip
full installed: astroid==2.2.5,beautifulsoup4==4.8.0,bottle==0.12.17,certifi==2019.9.11,chardet==3.0.4,codecov==2.0.15,colorama==0.4.1,conan==1.19.0.dev0,coverage==4.2,deprecation==2.0.7,distro==1.1.0,fasteners==0.15,future==0.17.1,idna==2.8,isort==4.3.21,Jinja2==2.10.1,lazy-object-proxy==1.4.2,MarkupSafe==1.1.1,mccabe==0.6.1,mock==1.3.0,monotonic==1.5,node-semver==0.6.1,nose==1.3.7,packaging==19.2,parameterized==0.7.0,patch==1.16,pbr==5.4.3,pluginbase==0.7,Pygments==2.4.2,PyJWT==1.7.1,pylint==2.3.1,pyparsing==2.4.2,python-dateutil==2.8.0,PyYAML==5.1.2,requests==2.22.0,six==1.12.0,soupsieve==1.9.3,tqdm==4.36.1,typed-ast==1.4.0,urllib3==1.25.5,waitress==1.3.1,WebOb==1.8.5,WebTest==2.0.33,wrapt==1.11.2
full run-test-pre: PYTHONHASHSEED='477153901'
full run-test: commands[0] | nosetests
EE.....................SS..SSSS..............................................................
@ShadowMitia
ShadowMitia / main.cpp
Created September 1, 2019 20:53
Converting array to texture
#include <filesystem>
#include <fstream>
#include <bitset>
#include <cstdint>
#include <vector>
#include <cstddef>
#include <fmt/format.h>
#include <fmt/color.h>