Skip to content

Instantly share code, notes, and snippets.

Avatar
🔧
Trust me, I'm an engineer.

Nick Gashkov nickgashkov

🔧
Trust me, I'm an engineer.
View GitHub Profile
@nickgashkov
nickgashkov / main.py
Created Feb 19, 2019
Logging configuration with console and file handlers
View main.py
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):
View modify_number.py
# -*- coding: utf-8 -*-
def get_number():
return input('Введите число: ')
def to_int_or_none(number):
try:
return int(number)
except ValueError:
@nickgashkov
nickgashkov / gui.py
Last active Oct 16, 2017
Util to center PyQt5 window on a screen
View gui.py
# 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()