8th July 2022
Coding⚑
Python⚑
Python Snippets⚑
-
Interesting to test the accepted format of RSS dates.
>>> from email.utils import parsedate_to_datetime >>> datestr = 'Sun, 09 Mar 1997 13:45:00 -0500' >>> parsedate_to_datetime(datestr) datetime.datetime(1997, 3, 9, 13, 45, tzinfo=datetime.timezone(datetime.timedelta(-1, 68400)))
-
New: Convert a datetime to RFC2822.
Interesting as it's the accepted format of RSS dates.
>>> import datetime >>> from email import utils >>> nowdt = datetime.datetime.now() >>> utils.format_datetime(nowdt) 'Tue, 10 Feb 2020 10:06:53 -0000'
-
New: Encode url.
import urllib.parse from pydantic import AnyHttpUrl def _normalize_url(url: str) -> AnyHttpUrl: """Encode url to make it compatible with AnyHttpUrl.""" return typing.cast( AnyHttpUrl, urllib.parse.quote(url, ":/"), )
The
:/
is needed when you try to parse urls that have the protocol, otherwisehttps://www.
gets transformed intohttps%3A//www.
.
Javascript⚑
Javascript snippets⚑
-
New: Set variable if it's undefined.
var x = (x === undefined) ? your_default_value : x;
Science⚑
Data Analysis⚑
Recommender Systems⚑
-
Bookwyrm looks to be a promising source to build book recommender systems.