Skip to content

Instantly share code, notes, and snippets.

View DeoLeung's full-sized avatar

Zhanzhao (Deo) Liang DeoLeung

View GitHub Profile
@akheron
akheron / smtpd_fixture.py
Last active June 30, 2021 10:26
SMTP server pytest fixture
# The SMTP server runs in a separate thread and stores sent messages in a list
#
# Usage:
#
# def test_fn(smtpd):
# host = smtpd.host
# port = smtpd.port
#
# # Run code that send email using an smtp server at host:port
#
@ThomasG77
ThomasG77 / shapely2D_to_3D.py
Last active January 9, 2020 08:58
Just one method to convert 2D to 3D geometry with shapely
# -*- coding: utf-8 -*-
from shapely.geometry import LineString
from shapely import wkt
line = LineString([(0, 0, 5), (1, 1, 5)])
# memo for 3D
wkt3D = line.wkt
# 2D
@hideaki-t
hideaki-t / unzip.py
Created May 18, 2014 07:34
unzipping a zip file with non-utf8 encoding by Python3
import zipfile
import sys
from pathlib import Path
def unzip(f, encoding, v):
with zipfile.ZipFile(f) as z:
for i in z.namelist():
n = Path(i.encode('cp437').decode(encoding))
if v: