This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xrandr --newmode "1920x1080" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync | |
xrandr --addmode Virtual1 1920x1080 | |
xrandr --output Virtual1 --mode 1920x1080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Use IntelliSense to learn about possible attributes. | |
// Hover to view descriptions of existing attributes. | |
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Run Python current file", | |
"type": "python", | |
"request": "launch", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am nenetto on github. | |
* I am nenetto (https://keybase.io/nenetto) on keybase. | |
* I have a public key whose fingerprint is 47B4 35B3 E57D FD46 77FE 4DE9 F885 7F5D C440 4967 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def to_str(bytes_or_str): | |
"""Transform to string UTF-8""" | |
if isinstance(bytes_or_str, bytes): | |
value = bytes_or_str.decode(‘utf-8’) | |
else: | |
value = bytes_or_str | |
return value # Instance of str | |
def to_bytes(bytes_or_str): | |
"""Transform to bytestring""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python only supports a single constructor per class, the __init__ method. | |
# Use @classmethod to define alternative constructors for your classes. | |
# Use class method polymorphism to provide generic ways to build and connect concrete subclasses. | |
class GenericInputData(object): | |
def read(self): | |
raise NotImplementedError | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyBaseClass: | |
def __init__(self, value): | |
self._value = value | |
class Explicit(MyBaseClass): | |
def __init__(self, value): | |
super(__class__, self).__init__(value * 2) | |
class Implicit(MyBaseClass): | |
def __init__(self, value): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Avoid using multiple inheritance if mix-in classes can achieve the same outcome. | |
# Use pluggable behaviors at the instance level to provide per-class customization when mix-in classes may require it. | |
# Compose mix-ins to create complex functionality from simple behaviors. | |
class ToDictMixin(object): | |
"""This class add the ability to serialize an object to a dictionary | |
Takes each element of self.__dict__ and saves it | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FixedResistance(Resistor): | |
@property | |
def ohms(self): | |
return self._ohms | |
@ohms.setter | |
def ohms(self, ohms): | |
if hasattr(self, ‘_ohms’): | |
raise AttributeError(“Can’t set attribute”) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Descriptor protocol | |
# Special objects with that show magic functionality when they are the type of | |
# other's class attribute. | |
## Methods | |
def __get__(self, obj, type = None) -> object: | |
""" | |
self: descriptor itself | |
obj: object the descriptor is attached (as attribute) to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rarely used, metaclasses can be used for validation of other classes | |
class ValidatePolygon(type): | |
def __new__(meta, name, bases, class_dict): | |
# Don’t validate the abstract Polygon class | |
if bases != (object,): | |
if class_dict[‘sides’] < 3: | |
raise ValueError(‘Polygons need 3+ sides’) | |
return type.__new__(meta, name, bases, class_dict) |
OlderNewer