Equality of Python classes using slots
import operator
class CommonEqualityMixin(object):
__slots__ = ()
def __eq__(self, other):
if isinstance(other, self.__class__):
# alternative to elasticsearch_loader | |
# not optimized, as http connections are not reused | |
# but simple enough to work for files that are not prohibitively large | |
pv foo.log | split --line-bytes=10000000 --filter="cat | sed 's/^/{\"create\":{\"_index\":\"logs-foo-default\"}}\n/' | curl -u admin:changeme -XPOST -H 'Content-Type: application/x-ndjson' 'http://localhost:9200/_bulk' --data-binary @-" |
import cv2 | |
import matplotlib.pyplot as plt | |
import pandas as pd | |
VIDEO_NAME = 'led960_3.mp4' | |
cap = cv2.VideoCapture(VIDEO_NAME) | |
assert cap.isOpened() | |
FPS = 960 |
Equality of Python classes using slots
import operator
class CommonEqualityMixin(object):
__slots__ = ()
def __eq__(self, other):
if isinstance(other, self.__class__):
#!/bin/bash | |
# https://gist.github.com/egonbraun/7176976fe05ece092410462facf0adb6 | |
# OpenVPN configuration Directory | |
OPENVPN_CFG_DIR=/etc/openvpn | |
# Where this script should create the OpenVPN client config files | |
OUTPUT_DIR=~/ovpn-mfa/ |
geoname_id,locale_code,continent_code,continent_name,country_iso_code,country_name,subdivision_1_iso_code,subdivision_1_name,subdivision_2_iso_code,subdivision_2_name,city_name,metro_code,time_zone,is_in_european_union | |
49518,en,AF,Africa,RW,Rwanda,,,,,,,Africa/Kigali,0 | |
49747,en,AF,Africa,SO,Somalia,BK,Bakool,,,Oddur,,Africa/Mogadishu,0 | |
51537,en,AF,Africa,SO,Somalia,,,,,,,Africa/Mogadishu,0 | |
53654,en,AF,Africa,SO,Somalia,BN,Banaadir,,,Mogadishu,,Africa/Mogadishu,0 | |
54225,en,AF,Africa,SO,Somalia,SH,"Lower Shabeelle",,,Merca,,Africa/Mogadishu,0 | |
56335,en,AF,Africa,SO,Somalia,SD,"Middle Shabele",,,Giohar,,Africa/Mogadishu,0 | |
57289,en,AF,Africa,SO,Somalia,WO,"Woqooyi Galbeed",,,Hargeisa,,Africa/Mogadishu,0 | |
58994,en,AF,Africa,SO,Somalia,GE,Gedo,,,Garbahaarrey,,Africa/Mogadishu,0 | |
59611,en,AF,Africa,SO,Somalia,MU,Mudug,,,Gaalkacyo,,Africa/Mogadishu,0 |
# https://dba.stackexchange.com/questions/240459/mysql-5-6-too-much-write-after-enabling-compression | |
mysql> show variables; | |
+--------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |
| Var |
"""time.process_time() and time.perf_counter() for Python 2 on Ubuntu.""" | |
import ctypes | |
import errno | |
from ctypes.util import find_library | |
from functools import partial | |
CLOCK_PROCESS_CPUTIME_ID = 2 # time.h | |
CLOCK_MONOTONIC_RAW = 4 | |
clockid_t = ctypes.c_int |
Using a slightly modified version of https://github.com/popravich/python-redis-benchmark to disable async tests and support Python 2. | |
*** CPython 2.7 | |
------------------------------------------------------------------------------------------------------------- benchmark 'bulk-string': 36 tests ------------------------------------------------------------------------------------------------------------- | |
Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations | |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
benchmark_parser_bulk_string[---10-hiredis-bytes] 425.7475 (1.0) 1,924.3785 (1.03) |
2019-03-14 08:30:31 MySQL_Thread.cpp:2874:run(): [ERROR] 0x7fb2a4e0d000: epoll got event, unreg, move to resume 0x7fb2974d1c80 | |
2019-03-14 08:30:31 MySQL_Thread.cpp:3045:run(): [ERROR] 0x7fb2a4e0d000: add to thr exchange resume 0x7fb2974d1c80 | |
2019-03-14 08:30:31 MySQL_Thread.cpp:2732:run(): [ERROR] 0x7fb2a480d000: poll get from myexchange resume, reg 0x7fb2974d1c80 | |
2019-03-14 08:30:31 MySQL_Thread.cpp:2855:run(): [ERROR] 0x7fb2a480d000: set sess to_process=0 0x7fb2974d1c80 | |
2019-03-14 08:30:31 MySQL_Thread.cpp:2951:run(): [ERROR] 0x7fb2a480d000: checking mypoll DS 0x7fb29bdffc00 fd 2367 events 1 revents 1 0x7fb2974d1c80 | |
2019-03-14 08:30:31 MySQL_Thread.cpp:3146:process_data_on_data_stream(): [ERROR] 0x7fb2a480d000: handling revent 0x7fb2974d1c80 | |
2019-03-14 08:30:31 MySQL_Thread.cpp:3167:process_data_on_data_stream(): [ERROR] 0x7fb2a480d000: finish handling revent 0x7fb2974d1c80 | |
2019-03-14 08:30:31 MySQL_Thread.cpp:3225:process_all_sessions(): [ERROR] 0x7fb2a480d000: processing 0x7fb2974d1c80 | |
2019-03-14 08:30:3 |
Argument
echo $1 $2 # argument by position
echo $@ # all arguments
Default
echo ${x:-default value} # equiv to python: "x or 'default value'"