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 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))
@tirinox
tirinox / DemoMagic.ipynp
Created Jun 15, 2019
Demo of Jupyter's magic functions
View DemoMagic.ipynp
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# нажми здесь shift+enter, чтобы увидеть список магий\n",
"%lsmagic"
View priority_queue.py
import heapq
from collections import namedtuple
Task = namedtuple('Task', 'priority, id, content')
class TaskFlow:
def __init__(self):
self._queue = []
self._id = 0