网友语录 - 第2期

世界上没有叛逆的孩子,只有不被理解的孩子。

点赞订阅虽然好 自由思考价更高

别人喜欢你,那是你给他的福利,别人不喜欢你,那是你给他的惩罚。哈哈哈记住了。

产品是丰富的,营销更是过量的。比起研究多少购物攻略,更核心的步骤是确定自己的需求和预算,越明确越坚持越好。“筛选”比“比较”更简单。

朱丽叶 名字有那么重要吗? 把玫瑰叫成别的名字,它还是有芬芳香气。

不要浪费你的无知。当你对一门知识毫无所知时,最容易问出简单而重要的问题。 一旦你习惯了某种现象或事物,认为它是理所当然时,思维就不知不觉受到了限制。 -- David Kohn

ayaduji:恨是很没意义的事,因为大家都会死。还是抓紧时间爱吧,可爱的东西那么多,时间根本不够啊

如果你无须转译就能直接理解另一种语言及构筑其上的世界观,能欣赏它们的效用与美感,那么你往往就不那么容易偏执盲从,不那么容易把非你族类全都看作妖魔鬼怪。《语言塑造人类思维》

性别代词特别容易产生隐含的联想,影响人们对自己和他人的认知。

拥有另一种语言,就是拥有另一个灵魂。 ——查理大帝

旧时明月照无眠 人总是透过语言的lens在观察/理解世界,因此多掌握一门语言也意味着多一个不同的看世界的lens,而这是翻译软件或者AI所无法做到的,因为翻译完成的那一刻,原始语言的维度就坍塌了。人使用翻译软件/AI是problem-solving,而人学习语言是generative的。反过来,禁止使用原本的语言一向是settler colonialism的assimilation agenda上最高优先级的任务之一。

旧时明月照无眠 精力/energy并不是homogenous,而是由许多适配不同活动/task的不同种类精力组合在一起的。比如每天有一些可以全神贯注的精力,也有一些“按部就班/autopilot”的精力,有些事情只能用专注精力去处理,但有些可以fit进autopilot精力里;然而即便是专注精力也未必能全部用来做比较重要的decision-making,但消耗完了decision-making的容量可能还剩一些可以探索/学新东西的或者是做planning的。

...

精力这个看似和精神更相关的东西其实和肉体的关系也许比想像得更紧密。除了身体状态好会精力更充足之外,最近发现精力的使用和体力运动很像:每天有上限,超过上限去用会伤(接下来几天得“躺平”,否则积累下来就会burn-out),但不使用/锻炼精力“肌肉”又会让每天休息后再生出来的精力变少(某种意义上的用进废退),然而人又是有极限的,并不是锻炼就能无限“长肌肉”。

我发现纸质/电子笔记已经可以很有效分担大量的记忆saving & loading了,因为光是“记住在脑子/working memory里但暂时不(能)执行”已经是在消耗精力了(e.g. 女性们经常抱怨的看似家里男性干活了但还是需要自己去记着什么时候该干什么活因此累得不行却仿佛什么都没干)。

我感觉任务切换的时候感觉翻笔记比纯凭脑子回忆之前停在哪里对精神的taxing要少。以及笔记并不只局限在todo list,完全可以搭更复杂的结构去支持更多externalization(我用logseq,有象友推荐过obsidian)。比如目前我把厨房里的事几乎大部分都externalize给了笔记:架子上和冰箱里的存货/购买or开封时间、某种食物能在冰箱里放的最长时限、某种食材的平均消耗速度(用来估算下次要买大概是什么时候)、不同用具的上一次深度清洁时间、爱吃的菜谱库(按菜式分但可以按食材检索,对于买最小包装食材也一次用不完的救星)、买的大包装食材的使用规划&近期的meal planning(我不太meal prep,但是有一定planning不需要每顿现场想吃什么可以直接拎刀做对我很重要)……这样做的好处一来是脑子需要记的东西和事大量减少,二来是decision-making变少+变简单了(“摊开在眼前”迅速提供了可行方案或者铲除了不可行的,比在脑子里想容易),各种精力消耗得都少了。

更多 RSS

How to Enable User-Level Systemd Services to Start Automatically on Ubuntu After Reboot

TL;DR

If your user-level systemd service on Ubuntu doesn't start automatically after a reboot, enable it with systemctl --user enable HappyNotes.Api.service. If you encounter an error about an existing symlink, remove it first. To allow the service to run without an active user session, enable lingering using loginctl enable-linger <username>. Finally, ensure your service file has the correct [Install] section and reboot to check if the service starts as expected.

The Problem

After configuring a user-level service with systemd, you might find that it remains inactive after rebooting your server. For example, you may run the command:

systemctl --user status HappyNotes.Api.service

And see output indicating that the service is inactive (dead) and disabled.

Solution Steps

  1. Enable the Service: First, ensure your service is enabled to start at boot:

    systemctl --user enable HappyNotes.Api.service
    

    If you encounter an error stating that the service is already linked, you may need to remove the existing symlink:

    rm ~/.config/systemd/user/default.target.wants/HappyNotes.Api.service
    
  2. Check for Linger: User-level services require an active user session to run. To allow your user services to run even when you're not logged in, enable lingering:

    loginctl enable-linger $USER
    
  3. Verify Service Configuration: Ensure your service file has the correct [Install] section:

    [Install]
    WantedBy=default.target
    
  4. Reboot and Test: After enabling lingering and ensuring your service is set up correctly, reboot your server:

    sudo reboot
    

    After rebooting, check the status of your service again:

    systemctl --user status HappyNotes.Api.service
    

By following these steps, you can ensure that your user-level systemd services start automatically after a reboot on Ubuntu. Enabling lingering is the key, which is particularly useful for server environments where continuous operation of services is desired.

Docker Volumes in Production: A Practical Guide to Named Volumes vs Bind Mounts

When working with Docker containers in production, understanding volume management is crucial. This guide will help you make informed decisions about when to use named volumes versus bind mounts (directory mapping).

TL;DR

  • Use named volumes for persistent data (databases, application state)
  • Use bind mounts for config files and development
  • Combine both in production for optimal setup

Understanding the Basics

Named Volumes

volumes:
  - postgres_data:/var/lib/postgresql/data

Docker manages these volumes internally. Think of them as "black boxes" that Docker handles for you.

Bind Mounts (Directory Mapping)

volumes:
  - ./config:/etc/app/config

You manage these directories directly on your host machine.

When to Use What?

Use Named Volumes For:

  1. Database storage
  2. Application state
  3. Generated assets
  4. Any data that needs persistence but not direct access

Benefits:

  • Managed by Docker
  • Better performance
  • Automatic permissions handling
  • Easier backups
  • Portable across environments
  • Built-in volume management commands

Use Bind Mounts For:

  1. Configuration files
  2. Static files during development
  3. Source code in development
  4. Any files you need to edit from host

Benefits:

  • Direct access from host
  • Easy to edit
  • Version control friendly
  • Quick updates without container restart
  • Shareable across environments

Real-World Example

Here's a typical production setup combining both approaches:

version: '3'
services:
  db:
    image: postgres:15
    volumes:
      # Data persistence with named volume
      - postgres_data:/var/lib/postgresql/data
      # Configuration with bind mounts
      - ./config/postgres.conf:/etc/postgresql/postgresql.conf:ro

  nginx:
    image: nginx
    volumes:
      # Config files with bind mounts
      - ./config/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./config/nginx/conf.d:/etc/nginx/conf.d:ro
      # Static files with bind mount
      - ./static:/usr/share/nginx/html:ro

  app:
    image: node:18
    volumes:
      # Application data with named volume
      - app_data:/app/data
      # Config with bind mount
      - ./config/app.json:/app/config/app.json:ro

volumes:
  postgres_data:
  app_data:

Migration Tips

Moving from Bind Mounts to Named Volumes

If you're currently using bind mounts for data and want to switch to named volumes:

# Create new volume
docker volume create myapp_data

# Copy data
docker run --rm \
  -v /old/path:/source:ro \
  -v myapp_data:/destination \
  ubuntu \
  bash -c "cp -av /source/. /destination/"

Best Practices

  1. Named Volumes

    • Always use for persistent data
    • Name them descriptively
    • Regular backups
    • Don't manipulate directly on host
  2. Bind Mounts

    • Use read-only (:ro) when possible
    • Keep configs in version control
    • Use relative paths for portability
    • Store in a config/ directory
  3. General

    • Document your volume strategy
    • Regular backups for both types
    • Monitor disk usage
    • Use clear naming conventions

Common Pitfalls to Avoid

  1. Using bind mounts for database storage
  2. Hardcoding absolute paths
  3. Not setting proper permissions
  4. Forgetting to backup named volumes
  5. Direct manipulation of named volume directories

Conclusion

The key to successful Docker volume management is using the right tool for the job:

  • Named volumes for data that needs persistence
  • Bind mounts for configs and development
  • Combine both for a robust production setup

Remember: When in doubt, prefer named volumes for data and bind mounts for configuration.

How to Use `sed` for Replacements on Windows Without Breaking Line Endings

When using sed on Windows, you might run into unexpected behavior, especially with line endings. If you're editing files with Windows-style line endings (\r\n), sed can unintentionally modify them, causing issues with tools like git diff. Here’s how you can use sed effectively on Windows without breaking your line endings.

The Problem: Unexpected \r\n to \n Conversion

On Windows, text files usually use \r\n (carriage return + line feed) as line endings. However, sed, depending on its mode, may treat these as Unix-style \n line endings, removing the \r and leading to issues like:

  • Files appearing changed when they shouldn’t.
  • Tools like git diff showing extra changes due to the altered line endings.

Solution: Use sed -b to Prevent Line Ending Conversion

To avoid this, you need to force sed to operate in binary mode, which prevents automatic conversion of line endings.

Example:

sed -b 's/old_text/new_text/' filename.txt

In this example:

  • The -b flag ensures sed works in binary mode, preserving the \r\n line endings.
  • The s/old_text/new_text/ part performs the actual substitution.

网友语录 - 第1期

绝对支配别人会产生大量的多巴胺,比吸毒还 high,而且成瘾。不要給他人這樣的機會。

不直接创造财富的群体,如果始终处在分配财富的有利位置上,而创造财富的群体又无法制约他们,那么其长期结果一定是经济停滞与社会衰败。

一张图说清英文地理术语 image

除了生病以外,所有的痛苦都是价值观带来的。

哈耶克说:金钱是人类发明的最伟大的自由工具。只有金钱会向穷人开放,而权力不会;

愿意放弃自由来换取保障的人,最终既得不到自由,也得不到保障;

一个富人得势的世界,总比一个只有得势的人才能富有的世界要好得多;

如果一个人不需要服从任何人,只需服从法律,那么他就是自由的;

为什么一些问题永远得不到解决?因为解决问题的人,正是制造问题的人;

如果允许人类自由迁徒,那人流的方向就是文明的方向。

米福根:恨可以登堂入室,爱却需要躲藏。

过去,我们将已知最耐用的材料用于整座建筑,比如说花岗岩石块,其成果仍令当代人赞赏、惊叹。但我们却几乎不再模仿这种行为,因为石料的采集、切割、运输和搭建都极其考验耐心,而耐心正是我们不再具备的品质。摘自《没有我们的世界》

网摘:"与其担心宏观经济,不如关注自己。你对自己生活的影响,往往比宏观经济对你的影响大得多。" 公司裁员肯定会对一个人产生影响,但是它决定不了你的未来,你自己才是最大的影响因素。 世界最大对冲基金"桥水基金"创始人达里奥,说过一句话,可以用在这里:"如果你忧心忡忡,那是不必要的;如果你毫不担心,那么你需要担心。"

TNT007: 我可能比较老派,认为如果恋爱还需要技巧的话,那就不是爱情。爱情是双向的不可自抑的。

小青: I am who I am becoming.

网摘:作家兼冥想老师大卫·凯恩(David Cain)鼓励他的学生别当“好天气的冥想者”。同样,你也不想成为一名努力与否全凭心情好坏的运动员、作家,等等。当一个习惯对你来说真正重要时,你必须愿意在任何心情下坚持下去。专业人士不会因自己心情不好而改变行动的时间表。他们可能享受不到乐趣,但是他们仍能做到坚持不懈。