Cheatsheet: Write Multiple Lines Content in YAML
date: 2022-05-31 · Tags: #dev, #tilIt's crazy that there are NINE different ways to write multi-line strings in YAML.
Here is a simple cheatsheet:
- Use
>
most of the time: interior line breaks are stripped out, although you get one at the end. - Use
|
if you want those linebreaks to be preserved as\n
(for instance, embedded markdown with paragraphs). - Use
>-
or|-
instead if you don't want a linebreak appended at the end. - Use
"blahblah..."
if you need to split lines in the middle of words or want to literally type linebreaks as\n
And this is difference betweetn "
and '
in YAML:
How to create a literal: | blank without quotes | " | ' |
---|---|---|---|
Single quote | ' | ' | '' |
Double quote | " | \" | " |
Backslash | \ | \\ | \ |
- Whenever applicable use the unquoted style since it is the most readable.
- Use the single-quoted style (
'
) if characters such as"
and\
are being used inside the string to avoid escpaing them and therefore improve readability. - Use the double-quoted style (
"
) when the first two options aren't sufficient, i.e. in scenarios where more complex line breaks are required or non-printable characters are needed.
Check references for more detailed examples :(
References:
What’s in which Python
date: 2022-05-31 · Tags: #python, #good-readingYou're able to look up the major key feature changes from Python 2.1 to Python 3.11 in one page!
This is a summary of what features appeared in which versions of Python. Items with a star were introduced with a
__future__
import.
Lesser Known PostgreSQL Features
date: 2022-05-30 · Tags: #sql, #tilYeah, the first I know I could do linear regression in PostreSQL.😅 At least, SQL rules all in BIG data. For the third article, It's may another way to implement workable distributed locks.
Refs:
Customizable Python UI-Library based on Tkinter
date: 2022-05-28 · Tags: #python, #uiWow, what a pretty and simple UI library for Python!
Python has a builtin UI toolkit named as Tkinter
which do not look well
actually, but it's embeded as std lib while included in many OS distributions.
CustomTkinter
is a small enough library to beautify your applications!
TomSchimansky/CustomTkinter: A modern and customizable python UI-library based on Tkinter
When Python can’t thread: a deep-dive into the GIL’s impact
date: 2022-05-27 · Tags: #python, #good-reading"When Python can’t thread: a deep-dive into the GIL’s impact"
You Should Compile Your Python And Here’s Why
date: 2022-05-25 · Tags: #pythonWhat? 通过预编译 string template 来达到性能的提升 ???
Tracking Side Effects in Scala
date: 2022-05-23 · Tags: #scalaThis article1 is about how to use new features 234 from Scala 3 to distinguish side effects safely via type signatures in compile time.
Quite interesting to learn new syntax if you could implement them by yourself.
References:
Footnotes
The balance has shifted away from SPAs
date: 2022-05-22 · Tags: #dev, #react, #good-readingWhat is next trend in Javascript UI framework (maybe should limit to SSG)? I think "0kB JavaScript by default." must have a name. People has been bored with heavy runtime bring by framework in order to achieve the most extreme lightweight and speed. Here are serveral featured libraries:
SPAs are no longer the cool kids they once were 10 years ago. --- The balance has shifted away from SPAs
Update 2022-07-03:
New player is comming. denoland/fresh: The next-gen web framework.
Initial JSON Type Support in Python
date: 2022-05-21 · Tags: #python, #tilBecause typing system in Python lacks of recursive type, we can not annotate
JSON-like data for type hints. Recently, There is a progress that an
experimental JSON
type has been implemented under _typeshed
lib.
Try it like:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from _typeshed import JSON
Of course, we still need to wait offical JSON
type support.
Update 2022-06-22: The PR in typeshed
still can not be merged.
Happy Birthday to designer Dieter Rams, who's turning 90 today!
date: 2022-05-21 · Tags: #design, #newsHappy Birthday to Dieter Rams!
I just know that from tweet of Gary Hustwit1, who's the director of the documentary film Rams2.
Dieter Rams (May 20, 1932) is a great designer ever who belief in "Less, but better" design. I also post his famous ten principles of "Good design"
To celebrate the day, Director Gary Hustwit is streaming his documentary film about Dieter free worldwide a few days.
Besides, I also strongly recommend Gary Hustwit's other films on industrial design!
Footnotes
Google Cloud Released AlloyDB for PostgreSQL
date: 2022-05-15 · Tags: #cloud, #newsAt Google I/O 2022, Google Cloud team announced AlloyDB for PostgreSQL, a fully-managed, PostgreSQL-compatible database for demanding, enterprise-grade transactional and analytical workloads.
Features:
- Fully compatible with PostgreSQL, providing flexibility and true portability for your workloads
- Superior performance, 4X faster than standard PostgreSQL for transactional workloads
- Transparent and predictable pricing, with no expensive licensing and no opaque I/O charges
- Simplified management with machine learning-enabled autopilot systems
All in cloud native! All in PostgreSQL! :)
Introduce storage engine of AlloyDB: AlloyDB for PostgreSQL under the hood: Intelligent, database-aware storage
Product: AlloyDB for PostgreSQL
EnterpriseDB's solution for cloud-native PostgreSQL:
A lock-free, concurrent, generic queue in 32 bits
date: 2022-05-15 · Tags: #data-structure, #good-readingPEP 690 – Lazy Imports
date: 2022-05-14 · Tags: #pythonIMHO, I like lazy imports as a fancy and powerful opt-in feature, but it's quite doubtful to set this feature enabled by default in current proposal (PEP 690).
Implicit behaviors are terrible and will obviously break backward compatibility.
Do we forget the Zen of Python: "Explicit is better than implicit"?
Update 2022-07-05:
An article about how Meta use lazy imports to speed up Instagram Python server's slowdown caused by complex dependency hell.
RFC 3339 vs ISO 8601
date: 2022-05-13 · Tags: #til, #devShocked me. I just learned they have such great difference betweetn two standard specs.
Try use their intersected part as possible as you can in most scenarios.
Stroing State in the URL
date: 2022-05-10 · Tags: #backend, #devIt's simple but useful. Learn how to parse url arguments in common way. Remember that do not play too complex tricks, KISS as possible as you can.
Timeouts and Cancellation for Humans
date: 2022-05-09 · Tags: #python, #dev, #good-readingCaddy 2.5.0 Upgrade Issues
date: 2022-05-01 · Tags: #dev, #newsIf you put your servers behind CDN like Cloudflare or Caddy is not reaced firstly, there are serveral notable changes while updating Caddy to 2.5.0:
⚠️ Reverse proxy: Incoming
X-Forwarded-*
headers will no longer be automatically trusted, to prevent spoofing. Now,trusted_proxies
must be configured to specify a list of downstream proxies which are trusted to have sent good values. You only need to configure trusted proxies if Caddy is not the first server being connected to. For example, if you have Cloudflare in front of Caddy, then you should configure this with Cloudflare's list of IP ranges.
References:
- https://github.com/caddyserver/caddy/releases/tag/v2.5.0
- https://caddyserver.com/docs/caddyfile/directives/reverse_proxy
- https://caddy.community/t/caddy-v2-5-0-rc-1-and-x-forwarded-headers/15694
- https://blog.hlyue.com/2021/12/01/cloudflare-caddy-mutual-TLS
- https://developers.cloudflare.com/ssl/origin-configuration/authenticated-origin-pull