This file contains 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
import sqlite3 | |
import sqlalchemy | |
def print_formatted_table(table: list[list]): | |
column_lengths = [ | |
max(len(table[i][column_num]) for i in range(len(table))) | |
for column_num in range(len(table[0])) | |
] | |
for row in table: | |
print("|", end=" ") |
This file contains 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
import sqlite3 | |
import typing | |
def create_docs_table( | |
connection: sqlite3.Connection, | |
ids: list[int] | |
): | |
cursor = connection.cursor() | |
cursor.execute("DROP TABLE IF EXISTS docs") |
This file contains 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
import argparse | |
import inspect | |
import typing | |
from updaters import UpdaterA, UpdaterB, UpdaterC, UpdaterD | |
params_type = dict[str, typing.Any] | |
This file contains 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
import os | |
import shutil | |
from charset_normalizer import from_bytes | |
import xmltodict | |
def get_xml_dict(path: str): | |
with open(path, "rb+") as f: | |
content = f.read() |
This file contains 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
import argparse | |
from dataclasses import dataclass | |
import re | |
@dataclass | |
class ParseResult: | |
request_time: float = 0 | |
insert_time: float = 0 |
This file contains 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
import numpy as np | |
from sklearn.base import BaseEstimator, TransformerMixin | |
class CollinearFilter(BaseEstimator, TransformerMixin): | |
def __init__(self, thresh: float = 0.95, choose_corr="random", random_state=None): | |
self.thresh = thresh | |
self.choose_corr = choose_corr | |
self.state = np.random.RandomState(random_state) |
This file contains 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 very_slow_function(n: int) -> int: | |
return n ** 1000 |
This file contains 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
# весь бот состоит из модулей | |
module: | |
# у модуля есть название | |
name: "Perimetry" | |
# входная точка | |
entry_point: | |
type: "text" | |
pattern: "Perimetry" | |
# какие-то действия, которые выполняются | |
# после прохождения входной точки |
This file contains 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
function listAllFiles() { | |
var sheets = SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet = sheets.getActiveSheet(); | |
var cell = sheet.getActiveCell(); | |
var to_visit = [DriveApp.getFolderById("<id>")]; | |
var info = [], f; | |
var q = '"'; | |
while (to_visit.length > 0) { | |
var cur_folder = to_visit.pop(); | |
var files = cur_folder.getFiles(); |
This file contains 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
public class Sum { | |
public static void main(String[] args) { | |
int[][] intsArray = new int[args.length][]; | |
for(int i = 0; i < args.length; i++) { | |
intsArray[i] = parseInts(args[i]); | |
} | |
int result = 0; | |
for(int i = 0; i < intsArray.length; i++) { | |
for(int j = 0; j < intsArray[i].length; j++) { |
NewerOlder