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 / watchdog.py
Last active June 26, 2017 11:49
Restarts the target process when it exits
"""
Simple watchdog which just restarts the command.
You can specify the limit for restarts by env-variable LIMIT
Example:
LIMIT=10 python watchdog.py this_may_fall.exe
"""
import logging
import os
@inesusvet
inesusvet / proto.js
Last active February 19, 2025 17:37
module.exports = {
package: null,
syntax: "proto2",
messages: [{
name: "Msg",
syntax: "proto2",
fields: [{
rule: "optional",
type: "Commands",
name: "command_number",
@inesusvet
inesusvet / 10-flake8.py
Created August 1, 2017 06:36
Git pre-commit hook to check code style of changed files right at commit time
from __future__ import print_function
"""
Pre-commit hook for PEP8 styling
Works well with flake8==3.0.4
"""
__author__ = 'Ivan Styazhkin <[email protected]>'
import subprocess
import sys
@inesusvet
inesusvet / shena-parser.py
Created August 17, 2017 20:12
Преобразование выгрузки транзакций из "нативного" php формата в csv
from __future__ import print_function
INPUT_FILENAME = 'export_dmr.txt'
OUTPUT_FILENAME = 'export_dmr.csv'
FIELDS = [
'dmr_transaction_id',
'paid_at',
'purchase_price',
'purchase_currency',
'order_price',
@inesusvet
inesusvet / time-keeper.py
Created September 4, 2017 19:09
Kill child by timeout
"""
Simple watchdog which kills the command affter timeout.
You can specify the timeout in seconds for kill by env-variable TIMEOUT
Example:
TIMEOUT=300 python time-keeper.py this-will-hang-up-but-gonna-be-killed-in-5-mins.exe
"""
import logging
import os
import subprocess
@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,
@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 / 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 / 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
"""
Sends system's pulse to a watchdog device
Usage:
python pulse.py <serial device>
Example:
SLEEP=25 python pulse.py /dev/ttyUSB0
"""