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 / 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 / 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 / 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 / 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 / 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:
"""
Sends system's pulse to a watchdog device
Usage:
python pulse.py <serial device>
Example:
SLEEP=25 python pulse.py /dev/ttyUSB0
"""
@inesusvet
inesusvet / 20-complexity.py
Last active October 9, 2020 08:59
Pre-commit hook for Cyclomatic Complexity check
from __future__ import print_function
"""
Pre-commit hook for Cyclomatic Complexity check
Works well with radon==2.2.0
"""
__author__ = 'Ivan Styazhkin <[email protected]>'
import subprocess
@inesusvet
inesusvet / amqp-producer.go
Created February 23, 2018 15:27
Simple amqp producer script which is tolerant to connection errors
package main
import (
"encoding/json"
"flag"
"fmt"
linuxproc "github.com/c9s/goprocinfo/linux"
"github.com/streadway/amqp"
"log"
"os"
@inesusvet
inesusvet / gist:200b27c95ad6e6dee19ec339439b14e9
Created January 21, 2018 17:57
PoC for comparison of dict.items() as check that sub-dict is contained
In [39]: a = {}
In [40]: for i in xrange(4):
...: key = ''.join(random.sample(string.ascii_lowercase, 10))
...: a[key] = key
...:
In [41]: a
Out[41]:
{'beuvqlcnyp': 'beuvqlcnyp',
@inesusvet
inesusvet / check-reports.py
Last active November 26, 2017 18:49
Проверить суммы положительных и отрицательных числе в двух столбцах во всех csv-файлах отчетов
#!/usr/bin/env python
from __future__ import print_function
import csv
import glob
import logging
import os
logging.basicConfig(
level=logging.WARNING,