Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Maksim Koltsov tirinox

🎯
Focusing
View GitHub Profile
View perspective_terminal.py
# Prints pseudo 3D image in ASCII
import shutil
c, r = shutil.get_terminal_size()
print(''.join(('*' if (j-c/2) % (i+1) == 1 else '-' if 4*r/(i+1)%2==0 else ' ') for i in range(r) for j in range(c)), end='')
View example_defaultdict.py
text = """
We develop a methodology for automatically analyzing text to aid in discriminating firms that encounter catastrophic
financial events. The dictionaries we create from Management Discussion and Analysis Sections (MD&A) of 10-Ks
discriminate fraudulent from non-fraudulent firms 75% of the time and bankrupt from nonbankrupt firms 80% of the
time. Our results compare favorably with quantitative prediction methods. We further test for complementarities by
merging quantitative data with text data. We achieve our best prediction results for both bankruptcy (83.87%) and
fraud (81.97%) with the combined data, showing that that the text of the MD&A complements the quantitative financial
information.
"""
View xo_naive_ai.py
import random
from flask import Flask, request
class Game:
X = 'X'
O = 'O'
N = ' '
def __init__(self, size=3, to_win=3):
View xo_flask_comments.py
import random
from flask import Flask, request
class Game:
X = 'X'
O = 'O'
N = ' '
def __init__(self, size=3, to_win=3):
View christmas_tree.py
import random
class ASCIICanvas:
def __init__(self, w=50, h=100):
assert 0 < w < 1000 and 0 < h < 1000
self.w = w
self.h = h
self.buffer = []
self.clear()
View radix_on.py
# this is Radix sort prove of O(n) time complexity
import random
import matplotlib.pyplot as plt
import time
def radix_sort(a_list, radix=10):
max_length_achieved = False
tmp, placement = -1, 1
View matmul_demo.py
# это пример показывает применение __matmul__ и __imatmul__ для пользовательских классов
class MyMatrix:
def __init__(self, data):
self.data = data
# для получения элементов матрицы как A[строка, столбец]
def __getitem__(self, pos):
i, j = pos
return self.data[i][j]
View sort_operator.py
import operator
class Item:
def __init__(self, name, price, qty):
self.name = name
self.price = price
self.qty = qty
def total_cost(self):
View brutal_download.py
import socket
import select
from urllib.parse import urlsplit
def brutal_download(url, save_to):
url_components = urlsplit(url)
host = url_components.netloc
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, 80))
View btc_generate_address.py
import hashlib
import ecdsa
import os
from binascii import hexlify
from base58 import b58encode
# Installation:
# pip install base58 ecdsa
# Use that service to make sure that this generator works well: