This file contains hidden or 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 tmp_copy(source, destination): | |
| import shutil | |
| import os | |
| shutil.copy(source, destination) | |
| try: | |
| yield | |
| finally: | |
| os.remove(destination) |
This file contains hidden or 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
| # Get list of available packages on your operating system | |
| dpkg --get-selections | |
| # To check whether a package is installed or not: | |
| get --get-selections {prg_name} | |
| # Search for a filename comes from which package | |
| dpkg -S `which ifconfig` | |
| # List files installed to your system from package-name. |
This file contains hidden or 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
| from subprocess import STDOUT, CalledProcessError, check_output | |
| class SomethingYouWant: | |
| def __init__(self, working_dir): | |
| self.working_dir= working_dir | |
| def _build_cmd(self, cmd): | |
| return cmd.split(' ') | |
This file contains hidden or 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
| import itertools | |
| import sys | |
| import threading | |
| import time | |
| class Signal: | |
| stop = False | |
This file contains hidden or 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
| import sys | |
| from contextlib import contextmanager | |
| from functools import wraps | |
| def redirect_stdout_to(out_new): | |
| """Redirect stdout to out_new with context manager.""" | |
| out_old = sys.stdout | |
| sys.stdout = out_new | |
| yield |
This file contains hidden or 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
| import re | |
| POSITIVE_EMOJI_RE = re.compile(r"[;:=]-?[\)|D]+") | |
| NEGATIVE_EMOJI_RE = re.compile(r"[:=]-?[\(]+") |
This file contains hidden or 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 Person: | |
| def __init__(self, name, surname, age): | |
| self.name = name | |
| self.surname = surname | |
| self.age = age | |
| def __repr__(self): | |
| return f'{self.__class__.__name__}: <{self.name} {self.surname}>' | |
| def __eq__(self, other): |
This file contains hidden or 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
| # 0 is too far from ` ;) | |
| set -g base-index 1 | |
| # Automatically set window title | |
| set-window-option -g automatic-rename on | |
| set-option -g set-titles on | |
| #set -g default-terminal screen-256color | |
| set -g status-keys vi | |
| set -g history-limit 10000 |
NewerOlder