Skip to content

Instantly share code, notes, and snippets.

import os
import time
import math
import psutil
def convert_size(size_bytes):
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
import os
import time
import math
import psutil
def convert_size(size_bytes):
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
import os
import time
import math
import psutil
def convert_size(size_bytes):
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
import os
import time
import math
import psutil
def convert_size(size_bytes):
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
@ephes
ephes / subprocess_read_write_example.py
Created March 20, 2020 12:11
Example of communication between two processes with subprocess
import subprocess
from queue import Queue
from threading import Thread
from tempfile import NamedTemporaryFile
class ClosableQueue(Queue):
SENTINEL = object()
import pytest
from django.conf import settings
from python_podcast.users.tests.factories import UserFactory
@pytest.fixture
def user() -> settings.AUTH_USER_MODEL:
password = "password"
user = UserFactory(password=password)
from django import template
from django.conf import settings
from wagtail.images.templatetags.wagtailimages_tags import image
register = template.Library()
@register.tag(name="srcset_image")
from django import template
from django.conf import settings
from wagtail.images.templatetags.wagtailimages_tags import image
register = template.Library()
@register.tag(name="srcset_image")
import sys
from PyPDF2 import PdfFileReader
pages = []
doc = PdfFileReader(sys.argv[1])
for num in range(doc.numPages):
page = doc.getPage(num)
pages.append(page.extractText())
print("\n".join(pages))