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 distutils import dir_util | |
import pytest | |
import os.path | |
from pathlib import Path | |
@pytest.fixture | |
def data_path(tmpdir, request) -> Path: | |
""" | |
If in the same folder as the test module exists a sub folder with the 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
class UniversalDecorator: | |
""" Good for standalone functions as well as for object methods """ | |
def __init__(self, orig_func): | |
self.orig_func = orig_func | |
def __call__(self, *args): | |
""" For standalone function decoration """ | |
return self.orig_func(*args) | |
def __get__(self, wrapped_instance, owner): |
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
function gitcred () { | |
rep_uri=$(git config --get remote.origin.url) | |
rep_proto=${rep_uri:0:8} | |
rep_url=${rep_uri:8} | |
user_name=$1 | |
user_name=${user_name:-andgineer} | |
user_psw=$2 | |
user_psw=${user_psw:-???} | |
uri=$rep_proto$user_name:$user_psw@${rep_url#*@} |
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
find ./ -iname "*.mp3" -type f -exec sh -c 'cp $0 "$(basename -- $(dirname -- $0))_$(basename -- $0)"' {} \; |
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
#!/usr/bin/env bash | |
# | |
# "Set-ups or/and activates development environment" | |
# | |
VENV_FOLDER="venv" | |
PYTHON="python3.7" | |
RED='\033[1;31m' | |
GREEN='\033[1;32m' |
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
timeout -k 1s --preserve-status 0.5s \ | |
perl -e '$|++; print "bla-bla\n"; sleep(2); print "The end."' \ # placeholder for you process | |
| perl -pe 'END { exit $status } $status=1; if (/end/) {$status=0; exit;}' | |
# see explanation in andrey.engineer/posts/en/bash_wait_with_timeout_for_string.html |
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
@pytest.hookimpl(tryfirst=True, hookwrapper=True) | |
def pytest_runtest_makereport(item, call): | |
outcome = yield | |
rep = outcome.get_result() | |
if rep.when == 'call' and rep.failed: | |
mode = 'a' if os.path.exists('failures') else 'w' | |
try: | |
with open('failures', mode) as f: | |
if 'browser' in item.fixturenames: | |
web_driver = item.funcargs['browser'] |
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
#include <ESP8266WiFi.h> | |
void setup() { | |
Serial.begin(115200); | |
delay(1000); | |
Serial.printf("\nTry connecting to WiFi with SSID '%s'\n", WiFi.SSID().c_str()); | |
WiFi.mode(WIFI_STA); | |
WiFi.begin(WiFi.SSID().c_str(),WiFi.psk().c_str()); // reading data from EPROM, last saved credentials | |
while (WiFi.status() == WL_DISCONNECTED) { |
NewerOlder