1. 基于 redis 实现 RPC 开发框架
市面上没有基于 redis 实现的 Python 异步 RPC 框架。
干脆自己写了一个最简版的。
1.1 客户端
连接 redis 服务器:
1 | async def connect(self): |
市面上没有基于 redis 实现的 Python 异步 RPC 框架。
干脆自己写了一个最简版的。
连接 redis 服务器:
1 | async def connect(self): |
全程参照 Tars 官方文档的相关章节,最终搭建出了 TarsCPP 服务端环境和客户端开发环境。其间有些小波折,记录一下。
参照: 通过 Docker 部署 TarsCPP: https://tarscloud.github.io/TarsDocs_en/installation/docker.html。
我在 VirtualBox 里搞了一台 Ubuntu20 的虚拟机做服务器。
弃用 https://github.com/naver/egjs-infinitegrid,改用 css 原生的 columns
实现瀑布流。
这个 infinitegrid 乍一用还挺不错的,瀑布流布局、无限加载,完全符合我的需求。但是它的默认行为是阻塞式的,即在所有项(我的是图片)加载完成后再一次性渲染。虽然其文档上有提到异步加载方式,我简单尝试了下,没成功。
columns
默认会打断(break)元素。比如我的元素是这样的:
1 | <div class="container"> |
下游就是这么苦,上游一句“我这没事啊”,问题就成了你的了。拼了老命、挠破头皮地搞了一天,发现实在是找不出问题,还得想尽办法把问题定位到上游的“黑盒盒”里,人家才会不疾不徐地开展工作。
遇到这种同事能怎么办?我只能在心里暗爽:嘿嘿,又“帮”儿子解决了一个 bug。
这次的故事是这样的。
最近在搞的一个 Unity 项目是以插件形式运行在服务端的,对内存碎片问题有比较高的要求,正好有机会深入学习了下 Unity 的 GC。这篇文章便是从 Unity 2019.4 官方文档 Garbage collection best practices 翻译、摘要而来。
自动内存管理让你写起代码时又快又简单,还能减少出错。但是这种便利有可能带来性能影响。为了优化代码以提高性能,你必须避免频繁触发 GC 的情形。
本文基于官方 v18.1.0 文档。
They let you use state and other React features without writing a class.
It’s hard to reuse stateful logic between components
现在可以通过自定义 Hook 提取封装带状态的逻辑。
Complex components become hard to understand
useEffect
可以把复杂逻辑分拆到多个小的函数中。
本文基于官方 v18.1.0 文档。
You need to keep an eye on the code you are including in your bundle so that you don’t accidentally make it so large that your app takes a long time to load.
Code-Splitting is a feature supported by bundlers like Webpack, Rollup and Browserify (via factor-bundle) which can create multiple bundles that can be dynamically loaded at runtime.
Code-splitting your app can help you “lazy-load” just the things that are currently needed by the user, which can dramatically improve the performance of your app.
本文基于官方 v18.1.0 文档。
React embraces the fact that rendering logic is inherently coupled with other UI logic:
how events are handled, how the state changes over time, and how the data is prepared for display.
Instead of artificially separating technologies by putting markup and logic in separate files,
React separates concerns with loosely coupled units called “components” that contain both.
这是当初 React 最吸引我的地方,不执著于将 UI 和逻辑分开。MVC 大行其道几十年后,Android 跟 iOS 也都在尝试返濮了。
在我实际工作经验中,进行视图子类化定制的出发点往往就是为了将 UI 和其逻辑写在一起。这个需求越靠近业务层就越强烈。
ubuntu 上安装完 nginx 后发现默认首页不能访问,可以优先检查 ufw 防火墙:
1 | sudo ufw status |
结果显示 status: active
,说明 vultr 上的防火墙是默认开启的。
执行命令将 http、https 端口加入到白名单:
1 | sudo ufw allow 'Nginx HTTP' |
可以了。
How to Set Up Nginx on a Ubuntu Server with Vultr: https://coderrocketfuel.com/article/how-to-set-up-nginx-on-a-ubuntu-server-with-vultr