Skip to content

Instantly share code, notes, and snippets.

🔥
Light My Fire!

Mikhail Kashkin xen

🔥
Light My Fire!
Block or report user

Report or block xen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View tos.md
title
Курс "Magic Python для начинающих"

Добро пожаловать на курс "Магия Python для начинающих"

Содержание лекций:

Вводная часть:

View 1-provider.py
from web3 import Web3, HTTPProvider, IPCProvider
web3 = Web3(IPCProvider('/Users/xen/Library/Ethereum/rinkeby/geth.ipc'))
# web3 = Web3(IPCProvider('/Users/xen/Library/Ethereum/geth.ipc'))
print(web3.eth.blockNumber)
print(web3.eth.accounts)
@xen
xen / check_hash.py
Last active Jul 21, 2019
telegram site auth
View check_hash.py
# implementation of Telegram site authorization checking algorithm
# for more information https://core.telegram.org/widgets/login#checking-authorization
import collections
import hmac
import hashlib
def check_string(d, token):
secret = hashlib.sha256()
secret.update(token.encode('utf-8'))
@xen
xen / jinja.json
Last active Jul 5, 2018
VS Code Jinja2 snippets
View jinja.json
{
"i18n": {
"prefix": "_",
"body": [
"{{ _('${TM_SELECTED_TEXT:${1:text}}') }}"
],
"description": "i18n"
},
"gt": {
"prefix": "gt",
@xen
xen / check_erdpou.py
Last active Aug 23, 2016
Алгоритм проверки ЕГРПОУ / Алгоритм перевіркі ЄДРПОУ
View check_erdpou.py
import operator
def check_erdpou(code):
""" Алгоритм проверки кода ЕРДПОУ """
code = int(code)
def check(sec, shift=False, step=0):
""" Генерация контрольного числа """
nums = list(range(1 + step, 8 + step))
if shift:
nums.insert(0, nums.pop(6))
@xen
xen / isretina.py
Last active Jun 22, 2016
isretina.py
View isretina.py
from objc_util import *
us = ObjCClass('UIScreen')
if us.mainScreen().scale() == 2.0:
print('Retina')
elif us.mainScreen().scale() == 3.0:
print('iPhone 6 Plus')
else:
print('Non retina')
View pip.conf
# cat ~/.pip/pip.conf
[global]
default-timeout = 60
respect-virtualenv = true
#download-cache = /home/xen/.pip/cache
log-file = /home/xen/.pip/pip.log
use-wheel = yes
find-links = /home/xen/.pip/wheels
[wheel]
@xen
xen / 1-usage.txt
Last active Sep 12, 2018
i18njson translate using Google Translate
View 1-usage.txt
$ python i18njson-translate.py --help
Usage: i18njson-translate.py [OPTIONS] INPUTFILE OUTPUT
Process and translate .po or JSON files and generate translated .po file
in result. Can work with exist .po files and if in initial file msgid
dissapear then mark translaed string as obsolete. Try to play nice with
version control systems and follow initial file order format, you will get
predicteable diffs.
Options:
@xen
xen / .gitconfig
Last active Aug 29, 2015
Git config
View .gitconfig
[user]
name = XX
email = X@X.X
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
@xen
xen / example.py
Last active Jun 12, 2019
HTTP cache headers decorator for Flask
View example.py
# example
from flask import json
from .utils import docache
@api.route('/jsonmethod', defaults={'count': 10})
@docache(hours=48, content_type='application/json')
def get_count(count):
# can be useable with JSON APIs
You can’t perform that action at this time.