Skip to content

Instantly share code, notes, and snippets.

@Cykooz
Cykooz / gist:5a5a7d1c3d78017fcefb6769fde811b1
Created September 8, 2017 06:18
psutil - RecursionError
cykooz@cykooz-nb:~/Work/backend$ ./bin/python
Python 3.6.2 (default, Jul 20 2017, 08:43:29)
[GCC 5.4.1 20170519] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from raven.base import DummyClient
>>> import psutil
>>>
>>> client = DummyClient()
>>> client.is_enabled = lambda: True
cykooz@cykooz-nb:~/Work/backend$ ./bin/python
Python 3.6.2 (default, Jul 20 2017, 08:43:29)
[GCC 5.4.1 20170519] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from raven.base import DummyClient
>>> import psutil
>>>
>>> psutil.Popen._Popen__subproc = None
>>>
@Cykooz
Cykooz / testing.py
Created March 21, 2018 18:25
Helpers for fuzzy comparison of different types of objects.
# -*- coding: utf-8 -*-
"""
:Authors: cykooz
:Date: 19.11.2015
"""
import re
import six
from six.moves.urllib.parse import urlparse, parse_qsl, unquote_plus
async def get_pdf_first_page(executors_manager: ExecutorsManager, src_path, dst_path, *, dpi=72, png=False):
"""Try to get a first page of the given pdf-file with GS, ignoring all errors."""
command = [
'gs',
'-q',
f'-r{dpi}',
'-dTextAlphaBits=4',
'-dGraphicsAlphaBits=4',
]
if png:
@Cykooz
Cykooz / bootstrap.py
Last active July 3, 2024 21:33
zc.buildout bootstrap script v1.3.1
"""
:Version: 1.3.1
Look for the latest version of the script in the GIST:
https://gist.github.com/Cykooz/118fba100c9ceb76ee822f7541d480c4
"""
import argparse
import logging
import os
@Cykooz
Cykooz / pre_reading.rs
Created December 10, 2022 22:04
Process data from iterator with pre-readming.
/// Pre-reading data from memory increases speed slightly for some operations
#[inline(always)]
fn foreach_with_pre_reading<D, I>(
mut iter: impl Iterator<Item = I>,
mut read_data: impl FnMut(I) -> D,
mut process_data: impl FnMut(D),
) {
let mut next_data: D;
if let Some(src) = iter.next() {
next_data = read_data(src);