Skip to content

Instantly share code, notes, and snippets.

View aviafelix's full-sized avatar

Alexander Okrugin aviafelix

View GitHub Profile
@aviafelix
aviafelix / another_patcher.py
Last active February 26, 2024 02:32
Patching binary files with Python
#/usr/bin/env python3
"""
Yet another simple binary patcher
"""
patches = [
{
# 1 Windows x64, version 3, build 1234
'file': 'file_1.bin',
'offset': 0x0BA950,
'original': b'\x00',
@aviafelix
aviafelix / amazonlinux_changed.md
Created April 14, 2015 10:42
Setup tsung for AmazonLinux
@aviafelix
aviafelix / configure-load-testing-stand.md
Created April 14, 2015 08:33
Example: Setting up load testing stand with Yandex-Tank, JMeter and Tsung on CentOS 7+
@aviafelix
aviafelix / python-parsing-dates.py
Created April 27, 2015 16:24
Python datetime / dateutil parsing dates example
import datetime
import dateutil.parser
timestring1 = '2007-03-04T21:08:12.127'
timestring2 = '2012-03-04 12:08:12.354'
dt1 = datetime.datetime.strptime(timestring1, '%Y-%m-%dT%H:%M:%S.%f')
dt2 = datetime.datetime.strptime(timestring2, '%Y-%m-%d %H:%M:%S.%f')
dup1 = dateutil.parser.parse(timestring1)
dup2 = dateutil.parser.parse(timestring2)
@aviafelix
aviafelix / puzzle.py
Created October 31, 2018 19:22
mail.ru: birthday quest '18
#!/usr/bin/env python3
from pprint import pprint
REPLACERS = {
'А' : 'О',
'а' : 'о',
'Б' : 'П',
'б' : 'п',
'В' : 'Р',
'в' : 'р',
@aviafelix
aviafelix / rkn_business.py
Created May 5, 2018 12:32
RKN: Nothing personal
#!/usr/bin/env python3
STRING_RKNZ = "Роскомнадзор запретил букву"
def gen_rualphabet_uppercase():
"""
"""
l = list(chr(l) for l in range(ord('А'), ord('Я')+1))
l.insert(ord('Е') - ord('А') + 1, 'Ё')
return "".join(l)
@aviafelix
aviafelix / compare_json_msgpack_python.md
Last active May 6, 2018 09:23
Compare json, simplejson, ujson, msgpack, umsgpack, cbor, cbor2, flunn on CPython 3.5.2, Ubuntu, VMware Player

Compare json, simplejson, ujson, msgpack, umsgpack, cbor, cbor2, flunn performance on CPython 3.5.2

Tests were performed on Ubuntu 16.04 guest OS running on VMware Player

import timeit
timeit.timeit(
    'qwerty.dumps(data)',
    setup='import {lib} as qwerty\nfrom test_json import data\n',
    number=1000)
sudo -i
su root
sudo -i
sudo shutdown -s
sudo shutdown -t 0
ip addr show
sudo yum install kbd
loadkeys sk
sudo loadkeys sk
localectl list=kezmaps