Skip to content

Instantly share code, notes, and snippets.

View nikitagashkov's full-sized avatar
🔧
Trust me, I'm an engineer.

Nikita Gashkov nikitagashkov

🔧
Trust me, I'm an engineer.
View GitHub Profile
@nikitagashkov
nikitagashkov / gui.py
Last active October 16, 2017 18:02
Util to center PyQt5 window on a screen
# Copyright (c) 2017 Nick Gashkov
#
# Distributed under MIT License. See LICENSE file for details.
from PyQt5.QtWidgets import QDesktopWidget
def center_window_on_screen(window):
desktop_widget = QDesktopWidget()
screen_size = desktop_widget.screenGeometry()
@nikitagashkov
nikitagashkov / modify_number.py
Created August 11, 2018 09:36
Number modifier
# -*- coding: utf-8 -*-
def get_number():
return input('Введите число: ')
def to_int_or_none(number):
try:
return int(number)
except ValueError:
@nikitagashkov
nikitagashkov / main.py
Created February 19, 2019 12:13
Logging configuration with console and file handlers
import logging
import logging.config
import settings
def setup_logging():
logging.config.dictConfig(settings.LOGGING_CONFIG)
log = logging.getLogger("sys.excepthook")
def excepthook(exc_type, exc_value, exc_traceback):