This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def smart_rename(file): | |
# renames a file by adding a numeric index to it | |
# increments the index if the directory already has files with the index | |
regex = r'(.+)_\((\d+)\)\.(.+)' # filename_(0).ext | |
make_filename = lambda p: p[0] + f"_({p[1]})." + p[2] | |
filename, path = os.path.basename(file), os.path.dirname(file) | |
match = match_regex(regex, filename) | |
parts = list(match.groups())[::2] if match else filename.split('.') | |
parts.insert(1, int(match.group(2)) if match else 0) | |
new_path = os.path.join(path, make_filename(parts)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int is_prime(int n) { | |
if (n < 3) return (n == 2); | |
if (~n & 1) return 0; | |
for (int i = 3; i*i <= n; i += 2) | |
if (n % i == 0) return 0; | |
return 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define _USE_MATH_DEFINES | |
#include <math.h> | |
#include <windows.h> | |
// width and height of screen | |
#define ww 100 | |
#define wh 50 | |
void clr(CHAR_INFO* d) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# вычисляет хэш нескольких файлов | |
from hashlib import md5 | |
def files_hash(files): | |
temp = md5() | |
for file in tqdm(files, desc="calculating files hash"): | |
with open(file, "rb") as f: | |
for chunk in iter(lambda: f.read(4096), b""): | |
temp.update(chunk) | |
return temp.hexdigest() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Masonry - stagger option, vanilla JS</h1> | |
<p>Resize window or click to toggle item size</p> | |
<div class="grid"> | |
<div class="grid-item"></div> | |
<div class="grid-item grid-item--width2 grid-item--height2"></div> | |
<div class="grid-item grid-item--height3"></div> | |
<div class="grid-item grid-item--height2"></div> | |
<div class="grid-item grid-item--width3"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- The button to open modal --> | |
<label for="my-modal" class="btn modal-button">open modal</label> | |
<input type="checkbox" id="my-modal" class="modal-toggle" /> | |
<label for="my-modal" class="modal modal-bottom sm:modal-middle"> | |
<label class="modal-box"> | |
<h3 class="font-bold text-lg">Congratulations random Internet user!</h3> | |
<p class="py-4">You've been selected for a chance to get one year of subscription to use Wikipedia for free!</p> | |
<div class="modal-action"> | |
<label for="my-modal" class="btn">Yay!</label> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def commentify(text, start, end, width=32, fill="="): | |
content = f' {text} '.center(width - len(start) - len(end) - 2, fill) | |
return f'{start} {content} {end}' | |
while True: | |
text = input('Enter text: ') | |
if not text: | |
break | |
print(commentify(text.upper(), '//', '//', width=42)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <cstdlib> | |
namespace 🔵 = std; | |
using 🔢 = int; | |
using 💯 = unsigned; | |
using 💀 = void; | |
using 🕖 = time_t; | |
using 👌 = bool; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "build file", | |
"type": "cppdbg", | |
"request": "launch", | |
"program": "${workspaceFolder}/compile/${fileBasenameNoExtension}", | |
"args": [], | |
"stopAtEntry": false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// template function to print table | |
template <typename T> | |
void ptable(vector<vector<T>> table, int axis_offset = 0, int split = 10, | |
int tab_size = 8, int index_width = 3, bool round_val = false) { | |
int rows = table.size(); | |
int splitted_parts = rows / split + (rows % split != 0); | |
for (int table_n = 0; table_n < splitted_parts; table_n++) { | |
int columns = min(split, (int)rows - table_n * split); | |
cout << setw(index_width + 3) << " | "; | |
for (int i = 0; i < columns; i++) { |
OlderNewer