Skip to content

Instantly share code, notes, and snippets.

View inesusvet's full-sized avatar
🇬🇧
You know: fish, chips, cup 'o tea, bad food, worse weather, Mary flippin Poppins

Ivan Styazhkin inesusvet

🇬🇧
You know: fish, chips, cup 'o tea, bad food, worse weather, Mary flippin Poppins
View GitHub Profile
@inesusvet
inesusvet / min_max_avg.py
Last active August 27, 2018 07:05
File system read vs CSV iteration vs Redis cache read vs Memcached read
import sys
import numpy as np
def get_reads_and_writes(lines, wanted):
result = []
for line in lines:
_, name, value = line.split(':')
if name == wanted:
@inesusvet
inesusvet / commit-msg
Created December 16, 2018 14:20
Literacy for everyone! Put a link to random wiki-page to your commit messages
#!/bin/bash
message_file=$1
echo "" >> $message_file
random_wiki=`curl -s --head https://en.wikipedia.org/wiki/Special:Random | grep 'location: ' | cut -d ' ' -f 2`
echo "In case you are interested, you may read about $random_wiki" >> $message_file
@inesusvet
inesusvet / open_and_close.py
Created January 19, 2019 14:38
Coding dojo in Minsk session result for 2019-01-19
"""
See https://www.codewars.com/kata/all-that-is-open-must-be-closed-dot-dot-dot
## Background
We all know about "balancing parentheses" (plus brackets, braces and chevrons)
and even balancing characters that are identical.
Read that last sentence again, I balanced different characters and identical
characters twice and you didn't even notice... :)
@inesusvet
inesusvet / chemistry.py
Created January 26, 2019 20:39
Coding dojo in Minsk session result for 2019-01-26
"""
See the full table at http://www.hemi.nsu.ru/mends.htm
"""
MENDELEEV_TABLE = {
'H': 1,
'He': 4,
'Li': 7,
'Be': 9,
'B': 11,
@inesusvet
inesusvet / digital.py
Created February 3, 2019 16:43
Coding dojo in Minsk session result for 2019-02-03
"""
See https://www.codewars.com/kata/digital-cypher
"""
import itertools
import string
ABC = string.ascii_lowercase
@inesusvet
inesusvet / leo.py
Created February 3, 2019 17:01
Simple performance test of a VigenereCipher class on text of a famous book by Leo Tolstoy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Можно скачать Войну и Мир здесь
http://vojnaimir.ru/files/book1.txt
http://vojnaimir.ru/files/book2.txt
"""
import codecs
@inesusvet
inesusvet / love_vs_friendship.py
Created February 9, 2019 13:04
Coding dojo in Minsk session result for 2019-02-09
"""
See https://www.codewars.com/kata/love-vs-friendship/train/python
If a = 1, b = 2, c = 3 ... z = 26
Then l + o + v + e = 54
and f + r + i + e + n + d + s + h + i + p = 108
So friendship is twice stronger than love :-)
@inesusvet
inesusvet / randomize.py
Created February 9, 2019 18:19
Simple script for a PR Tsar duties - I want to distribute incoming PRs evenly in the team. Cats are the power here
#!/usr/bin/env python
import random
NAME_TO_GITHUB = {
'Adam': 'ajbeairsto',
'Ihor': 'ikalnytskyi',
'Ivan': 'inesusvet',
'Maddie': 'madmott',
'Roman P': 'malor',
'Roman K': 'romankolpak',
@inesusvet
inesusvet / space.py
Created February 23, 2019 13:54
Introduction to Python 2019-02-23
a = 'space'
print(a)
a = 100500
print(a)
a = -6.5
print(a)
@inesusvet
inesusvet / reverse_polish.py
Created February 24, 2019 14:49
Coding dojo in Minsk session result for 2019-02-24
"""
See https://www.codewars.com/kata/reverse-polish-notation-calculator
Your job is to create a calculator which evaluates expressions in Reverse Polish notation.
For example expression 5 1 2 + 4 * + 3 - (which is equivalent to 5 + ((1 + 2) * 4) - 3 in normal notation)
should evaluate to 14.
For your convenience, the input is formatted such that a space is provided between every token.
Empty expression should evaluate to 0.
Valid operations are +, -, *, /.
You may assume that there won't be exceptional situations (like stack underflow or division by zero).