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
"""Token-cost comparison of serialisation formats for Pydantic models | |
generated with Polyfactory – single instance vs. list of ten. | |
pip install pydantic polyfactory pyyaml tiktoken pandas faker | |
""" | |
from __future__ import annotations | |
import json | |
import random | |
import sys |
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
# derived from https://github.com/mosquito/aiofile/issues/18#issuecomment-497983435 | |
# I do not vouch for correctness of this benchmark results | |
# pip install aiofile aiofiles tabulate uvloop | |
import asyncio | |
import os | |
import platform | |
import random | |
import tempfile | |
import time |
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 flatten_json(json_like): | |
""" | |
:param json_like: JSONable object | |
:return: flatten JSON-object, i.e. no inner dicts or lists | |
""" | |
from collections import deque | |
backlog = deque(("", json_like)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 time, json, subprocess | |
f = open("sensors.jsonl", "a") | |
while True: | |
sensors_data = json.loads(subprocess.check_output(["sensors", "-j"], text=True)) | |
data = {"time": time.time(), "sensors": sensors_data} | |
print(data) | |
json.dump(data, f) | |
f.write("\n") | |
time.sleep(60) |
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 test.py | |
========================================= test session starts ========================================== | |
platform linux -- Python 3.7.5, pytest-5.4.1, py-1.8.1, pluggy-0.13.1 | |
rootdir: CENSORED | |
collected 2 items | |
test.py FF [100%] | |
=============================================== FAILURES =============================================== | |
______________________________________ test_implementacja[pickle] ______________________________________ |
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
#!/bin/bash | |
# Test which DNS server is problematic (local dnsmasq, your SOHO router or is maybe whole Internet connection at fault if wellknown DNS fails as well | |
REMOTE_DNS=`nmcli dev show|perl -n -e '/IP4.DNS.*\s+([\d.]+)/ && print $1` | |
WELLKNOWN_DNS=1.1.1.1 | |
for server in localhost $REMOTE_DNS $WELLKNOWN_DNS; | |
do | |
dig gist.github.com @${server} &; | |
done |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 {browser, ExpectedConditions} from 'protractor'; | |
/** | |
* Check if web element is on top in visible area. | |
* To be called from `browser.executeScript` | |
* | |
* @param webElement | |
* @return true if it is | |
*/ | |
function elementIsVisibleOnTop(webElement): boolean { |
NewerOlder