Skip to content

Instantly share code, notes, and snippets.

@DimChtz
DimChtz / ytdl.pyw
Last active January 29, 2020 00:00
Python script (GUI) to download YouTube videos (as video or audio).
# You need to install pafy, pillow and youtube-dl otherwise it won't work
# pip install pafy
# pip install pillow
# pip install youtube-dl
from importlib.util import find_spec as find_lib
from os.path import expandvars as os_vars
from urllib.request import urlopen
from PIL import Image, ImageTk
import tkinter.filedialog
@DimChtz
DimChtz / range2.cpp
Last active November 8, 2017 10:58
Range function for 2d loop in C++.
#include <iostream>
#include <vector>
#include <utility>
template<typename T>
std::vector<std::pair<T, T>> range2(T start1, T end1, T start2, T end2) {
std::vector<std::pair<T, T>> loopValues{};
for (T i = start1; i < end1; ++i) {
for (T j = start2; j < end2; ++j) {
@DimChtz
DimChtz / calcAUC.m
Last active November 8, 2017 10:59
A function that calculates AUC using sensitivity and specificity in Matlab.
function[auc] = calcAUC(sens, spec)
tpr = sens;
fpr = 1 - spec;
[~, indices] = sort(sqrt(fpr.^2 + tpr.^2));
tpr = tpr(indices);
fpr = fpr(indices);
@DimChtz
DimChtz / imgsimfilter.py
Last active November 8, 2017 11:00
A little something to remove similar concurrent (only concurrent) images in a folder(s) in Python.
import math, operator
from functools import reduce
from PIL import Image
from os import listdir, remove
from os.path import isfile, join
import sys
def update(currImage, totalImages, suffix=''):
filledSize = int(round(20 * currImage / float(totalImages)))
perc = round(100.0 * currImage / float(totalImages), 1)