这篇博客记录了我跟着 C++ Beginner's Guide 学习 C++ 的第一天,并通过一个猜数字游戏的实践来加深对 I/O、基本数据类型、控制流等基础知识的理解。
使用 Python 处理时间:time.time() vs time.monotonic()
在写 TiDB Cloud 的 Python SDK 时,我需要实现一个等待集群创建成功的函数 wait_for_available()
,以便用户等待集群变为可用状态。这个函数需要计算集群创建所花费的时间,并在超过用户设置的超时时间时抛出异常。这是一个常见的计算时间差的场景。可以通过记录集群创建的开始时间、获取当前时间,然后计算与开始时间开始时间的差值来实现该功能。伪代码如下:
start_time = GetCurrentTime()
while True:
current_time = GetCurrentTime()
duration = current_time - start_time
if duration > timeout:
raise TimeoutError
if cluster.status == "AVAILABLE":
break
如何找出 Git 仓库中可能过时的文件
Code-Driven Documentation: How to Eliminate Errors in Configuration Documentation
This document outlines how to utilize code to enhance the accuracy of configuration documentation, particularly for technical writers who might not be well-versed in coding but are responsible for creating or reviewing configuration files. By following the examples in this document, writers can ensure that their configuration files are correct, efficient, and easy to understand, while also reducing the risk of errors or inconsistencies.
My First Impressions of Bytebase
Introduction
Bytebase is an open-source database DevOps tool, it's the GitLab for managing databases throughout the application development lifecycle. It offers a web-based workspace for DBAs and Developers to collaborate and manage the database change safely and efficiently. ——What is Bytebase
Recently, I have been working on migrating a project's database from SQLite to TiDB Cloud. To facilitate the management of database changes, I decided to use a database DevOps tool and discovered Bytebase. As a new user, I will share my first experience with Bytebase as I tackle the following tasks:
- Install Bytebase on macOS
- Quick start with Bytebase
- Query data and modify schema using the sample data
- Integrate Bytebase with TiDB Cloud
How to Crawl Your Website Automatically Using GitHub Actions
This document introduces how to configure Algolia DocSearch for your Docusaurus website and crawl your website automatically using GitHub Actions.
How to Manage Your Python Project Using Poetry
前段时间在写 tidbcloudy(一个 TiDB Cloud Python SDK)的时候用到了 Poetry 来管理依赖以及发布到 PyPI。经历了五次小版本的迭代,感觉 Poetry 时常让我有一种“写 SDK 也不难,发版也可以很简单”的错觉,所以决定记录一下我是如何使用 Poetry 来完成我的第一个 SDK 的。
How to Bundle Your JavaScript Projects Using webpack
Scenario
I use webpack to bundle some JS scripts today, see openapi-scripts/pull/16. The following lists details of the project and reasons for bundling:
- The
openapi-scripts
repository is used to post-process the OpenAPI specification file generated bybuf.build
to be compatible with Redocly. - To use JS scripts, I build a Docker image
ghcr.io/oreoxmt/openapi-scripts
. - The Docker image is under rapid development, and it takes a long time to pull the latest image due to 3901 node modules.
How to Deploy an OpenAPI Documentation on Netlify
Scenario
- There is an API definition file
open-api-swagger.json
in a private repositoryproduction/api
and I have no write access to it. - I want to deploy a preview website of the
open-api-swagger.json
:- test some Redoc configuration in my repository
Oreoxmt/preview-api
- build the
open-api-swagger.json
specification file into a HTML fileindex.html
usingredoc-cli build
- deploy it on Netlify or other services
- test some Redoc configuration in my repository
RL 01 | I Don’t Need to Know How It Works
My Reading List from July 16, 2022 to July 31, 2022.
生活小技巧 | Barrier:低成本的键鼠共享
新一期的生活小技巧分享终于更新啦,这次是社畜奥奥的打工小技巧分享。
如果你需要同时使用多个终端,又不希望两个键盘、两个鼠标来回切换,或者说你只有一个键盘、一个鼠标却想要控制多个终端的话,那这个超级低成本的小技巧就非常适合你啦!
生活小技巧 | 一键下载+批量改名
轮子再造 | 使用 GitHub Actions 自动部署 Hexo 博客 - 上篇
Oreo 同学最近开始记笔记和写心情了,但是就是不走寻常路偏偏想整一个自己的网站来写博客。正巧之前有一个 oreo.life 的域名,很快就定下来了 Hexo + GitHub Pages + Cloudflare CDN 的方案,Oreo 自己折腾了一段时间,成功部署了现在你看到的博客并在坚持更新,可喜可贺可喜可贺。
但是有个问题,GitHub Pages 对应的 Repo 存的是渲染过后的 HTML 文件,我们总得有个地方来存原始的 Markdown 文档。于是更新博客首先需要在 _source
目录写 Markdown,然后在根目录执行 hexo generate
和 hexo deploy
更新网站。命令行操作就先不说了,还要研究什么 Node.js、npm 是不是太过分了,在 Windows 配置环境超麻烦的好吗。世界如此美好,我却还要存 node_modules,这样不好,不好。
成,好歹咱也是做过 CI 的,GitHub Actions 也出来一段时间了看起来反响不错,那肯定也可以用 Actions 完成从博客源码到 Pages 部署的完整流程。Google 一搜发现已经有很多很多人做了类似的事情了,但是总有一些小地方不够好看或者是不满足需求,那就只能自己重新造一遍轮子了。