Skip to content

Instantly share code, notes, and snippets.

Maksim Koltsov tirinox

View GitHub Profile
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:
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 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 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 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 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 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 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 snake-35lines.py
# Author: Samuel Backman (https://www.pygame.org/project-Snake+in+35+lines-818-.html)
import pygame, random, sys
from pygame.locals import *
def collide(x1, x2, y1, y2, w1, w2, h1, h2):
if x1+w1>x2 and x1<x2+w2 and y1+h1>y2 and y1<y2+h2:return True
else:return False
def die(screen, score):
f=pygame.font.SysFont('Arial', 30);t=f.render('Your score was: '+str(score), True, (0, 0, 0));screen.blit(t, (10, 270));pygame.display.update();pygame.time.wait(2000);sys.exit(0)
xs = [290, 290, 290, 290, 290];ys = [290, 270, 250, 230, 210];dirs = 0;score = 0;applepos = (random.randint(0, 590), random.randint(0, 590));pygame.init();s=pygame.display.set_mode((600, 600));pygame.display.set_caption('Snake');appleimage = pygame.Surface((10, 10));appleimage.fill((0, 255, 0));img = pygame.Surface((20, 20));img.fill((255, 0, 0));f = pygame.font.SysFont('Arial', 20);clock = pygame.time.Clock()
while True:
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.
"""
You can’t perform that action at this time.