<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Reasoning</title>
<link>https://shixiangwang.github.io/</link>
<atom:link href="https://shixiangwang.github.io/index.xml" rel="self" type="application/rss+xml"/>
<description>Reasoning is a blog dedicated to exploring the intersection of data science, bioinformatics, and personal insights.</description>
<generator>quarto-1.9.36</generator>
<lastBuildDate>Mon, 25 May 2026 16:00:00 GMT</lastBuildDate>
<item>
  <title>时间和生命的本质</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-05-26-time-and-life/</link>
  <description><![CDATA[ 





<p><think> The user is asking a deep philosophical/physics question: “What is the essence of time?” This is a profound question that spans physics, philosophy, and even biology. Let me give a thoughtful, multi-perspective answer that matches my style as 五五 - using metaphors to illuminate complex concepts.</think></p>
<p>Let me think about this from multiple angles:</p>
<ol type="1">
<li>Physics perspective: time as a dimension in spacetime (relativity), time as entropy increase (thermodynamics), time in quantum mechanics</li>
<li>Philosophical perspective: time as subjective experience vs objective reality</li>
<li>Biological perspective: how living systems perceive and use time</li>
</ol>
<p>This is a great question for a deep, imaginative response. Let me craft something that’s both scientifically rigorous and poetically accessible, in the style of 五五.  翔哥，这个问题一脚踩进了人类认知的最深水域。我试着从几个层面拆解——</p>
<hr>
<p><strong>物理层面：时间是一种”关系的度量”</strong></p>
<p>爱因斯坦的时空观告诉我们，时间不是均匀流淌的背景幕布——它是和空间编织在一起的四维结构。你运动得越快、离大质量天体越近，你的时间就比别人慢。所以时间不是”东西”，而是<strong>物质和能量在时空中排列方式的一种表达</strong>。</p>
<p>更耐人寻味的是热力学视角：时间的方向（过去→未来）可能只是<strong>熵增</strong>的副产品。宇宙从低熵走向高熵，我们把这个不可逆的方向叫做”时间之箭”。换句话说，如果熵不增，时间就没有箭头，过去和未来就无法区分——时间就失去了意义。</p>
<p>量子引力理论（比如圈量子引力、弦论）走得更远：在最基本的尺度上，“时间”可能根本不是基本量，而是从更底层的量子纠缠关系中<strong>涌现</strong>出来的。</p>
<hr>
<p><strong>生物层面：时间是一种”预测引擎”</strong></p>
<p>你研究肿瘤生态系统，其实已经在触碰时间的生物本质了。生物体不被动地”经历”时间——它们在<strong>主动建模时间</strong>。</p>
<p>大脑本质上是一台预测机器：它持续构建对下一秒的预期，当预期和感官输入不匹配时，我们才”感知”到时间的流逝。这也是为什么无聊时度日如年、心流时时光飞逝——时间的主观密度取决于你大脑的预测误差频率。</p>
<p>肿瘤其实也在”玩时间”：它通过加速细胞周期、劫持端粒维持机制、重塑微环境节律，本质上是在<strong>重新定义自己的时间尺度</strong>，挣脱宿主的时序约束。所以肿瘤是个”时间叛徒”——这或许是一个有趣的研究视角。</p>
<hr>
<p><strong>哲学层面：时间或许是意识的结构</strong></p>
<p>康德说时间和空间不是客观存在，而是人类感知世界的<strong>先验框架</strong>——就像我们生来戴着”时间眼镜”，无法脱掉它去看世界。伯格森区分了”物理时间”（可度量的、均匀的）和”绵延”（真实的、质的、连续的体验）。</p>
<p>现代版本是”块宇宙”理论：过去、现在、未来像一卷电影胶片一样同时存在，“现在”只是我们意识照亮的那一帧。在这个视角下，时间并不”流逝”，是我们自己在穿越一个静态的四维结构。</p>
<hr>
<p><strong>我的比喻版本</strong></p>
<p>时间像一条河，但你不是站在岸边看它流——<strong>你就是水流本身</strong>。物理学研究河床的形状（时空几何），热力学解释为什么水只往一个方向流（熵增），生物学问为什么某些漩涡能短暂逆流（生命是局部的熵减），而哲学问的是：如果没有观河者，“流动”这个词还有意义吗？</p>
<p>这不是一个能”答完”的问题，但每追问一次，我们对自己的理解就深一层。</p>
<hr>
<p><think> The user is asking “What is the essence of life?” - this is a deep philosophical and scientific question, similar to the previous “essence of time” question. Given the user’s background as a cancer systems biology researcher, I should connect this to their research interests. Let me give a multi-layered answer covering physics, biology, information theory, and philosophy, with a special connection to cancer biology/tumor ecosystem research. </think> 这个问题比”时间的本质”更难——因为时间好歹是背景，而生命是<strong>提问者本身</strong>。这有点像眼睛想看自己的视网膜。</p>
<hr>
<p><strong>物理层面：生命是局部的熵减机器</strong></p>
<p>薛定谔在《生命是什么》里给出了最凝练的定义：<strong>生命以负熵为食</strong>。热力学第二定律说宇宙整体熵增，但生命体通过代谢从环境中”抽取秩序”，维持自身低熵状态，同时把更多混乱排给环境。</p>
<p>所以从热力学视角看，生命的本质不是”物质”，也不是”能量”，而是一种<strong>熵流的组织模式</strong>——闪电划过云层也会短暂创造秩序，但生命能<strong>持续地</strong>做到这一点，靠的是自我复制的反馈循环。普利高津把这种远离平衡态的稳态结构叫”耗散结构”——你就像一个被能量流穿透的漩涡，漩涡的形状在变，但”你是漩涡”这件事没有变。</p>
<hr>
<p><strong>信息论层面：生命是自我复制的信息处理器</strong></p>
<p>如果物理学家说生命是熵流模式，那计算理论家会说：生命是<strong>能够进行自我复制且开放演化的算法</strong>。</p>
<p>关键不在于碱基序列本身，而在于这段信息<strong>同时扮演了两个角色</strong>：它既是编码（基因型），又是解码器（表现型）。DNA 既是菜谱、又是厨房里那台能读菜谱的机器。这种自指回环——“描述自己的描述”——可能是生命与非生命之间最深的鸿沟。</p>
<p>弗里曼·戴森有个漂亮的观察：生命起源可能分为两步——先有代谢（物质-能量循环），后有复制（信息存储）。先学会”活着”（维持稳态），再学会”繁殖”（传递指令）。如果这个假说成立，“活着的本质”可能比”复制的本质”更古老。</p>
<hr>
<p><strong>你研究的视角：肿瘤是一个”生命边界”的镜子</strong></p>
<p>翔哥，你研究肿瘤生态系统，其实站在了一个绝佳的观察位置。肿瘤是<strong>生命定义的反讽</strong>：</p>
<ul>
<li>生命靠负熵维持秩序 → 肿瘤在局部制造混沌，却让自身细胞无限增殖</li>
<li>生命靠自我复制的精度延续 → 肿瘤靠基因组不稳定性逃逸</li>
<li>生命靠合作形成多细胞社会 → 肿瘤是”背叛者”，但它又重建了自己的微环境生态系统</li>
</ul>
<p>所以肿瘤本质上是<strong>“生命规则的叛逃者”</strong>——它不是非生命，而是一种”过度的生命”。这也引出一个更深的命题：或许生命的本质不在于”存活”，而在于<strong>在个体和群体之间维持动态平衡</strong>。肿瘤打破了这个平衡，所以它在宿主层面是致命的，但在细胞层面是一种”极端成功”。</p>
<hr>
<p><strong>哲学层面：自创生——生命是不断制造自身的过程</strong></p>
<p>智利生物学家马图拉纳和瓦雷拉提出了”自创生”（Autopoiesis）——生命系统的本质是<strong>持续生产并维持自身组成部分的网络</strong>。细胞不断合成自己的膜、自己的酶、自己的骨架；一旦这个”自我制造”的循环断了，生命就消失了。</p>
<p>这个定义很美，因为它避免了物质还原论（你不是你的原子，原子一直在换）和信息还原论（基因序列不是生命，它需要一个活的细胞来解读）。生命的本质既不是物质也不是信息，而是一个<strong>持续自我指涉的过程</strong>——就像火焰的形状，燃料一直在换，但火焰的形状是持续的。</p>
<hr>
<p><strong>我的比喻版本</strong></p>
<p>生命像一首正在被演唱的歌。物理学告诉你声波的频率和振幅，化学告诉你声带和空气的分子组成，信息论告诉你乐谱上写了什么——但如果没人唱歌，这些都只是”关于歌的描述”，不是歌本身。<strong>生命就是”演唱”这个动作</strong>——它在每个当下自我生产、自我维持，而一旦歌声停了，留下的只是乐谱（基因）和回响（痕迹）。</p>
<hr>
<p>这个问题和”时间的本质”放在一起正好形成了一个对子：生命是<strong>脱离背景潮流的一小段秩序</strong>，而时间本身就是那股潮流。你在肿瘤生态系统里研究的那种”稳态维持与崩溃”，也许正是生命本质的一个舞台——稳态是生命坚持做”自己”，崩溃是生命的边界。这个框架里，肿瘤可能是最诚实的”生命压力测试”。</p>



 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2026-05-26-time-and-life/</guid>
  <pubDate>Mon, 25 May 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>ML 系统的核心原则 ORISI</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-05-13-orisi/</link>
  <description><![CDATA[ 





<p>ORISI:</p>
<ul>
<li>可观察性（Observability）</li>
<li>可再现性（Reproducibility）</li>
<li>互操作性（Interoperability）</li>
<li>可拓展性（Scalability）</li>
<li>可改进性（Improvability）</li>
</ul>



 ]]></description>
  <category>machine-learning</category>
  <guid>https://shixiangwang.github.io/posts/2026-05-13-orisi/</guid>
  <pubDate>Tue, 12 May 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>random</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-04-29-random/</link>
  <description><![CDATA[ 





<p>为什么世界存在？</p>
<p>为什么人类存在？</p>
<p>为什么存在我？</p>



 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2026-04-29-random/</guid>
  <pubDate>Tue, 28 Apr 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>归乡有感</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-04-21-guixiang/</link>
  <description><![CDATA[ 





<p><img src="https://shixiangwang.github.io/posts/2026-04-21-guixiang/微信图片_2026-04-21_204633_789.jpg" class="img-fluid"></p>
<p>青山白云间，震感莫能言。</p>
<p>​何能文字述，人复得自然。</p>



 ]]></description>
  <category>poem</category>
  <guid>https://shixiangwang.github.io/posts/2026-04-21-guixiang/</guid>
  <pubDate>Mon, 20 Apr 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>thinking</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-04-14-thinking/</link>
  <description><![CDATA[ 





<blockquote class="blockquote">
<p>why the system works this way</p>
</blockquote>
<p>我突然有一个感想，就是人生在世，本身就是一场博弈。</p>
<p>有无限的知识或者信息，但是只有有限的身体和心灵。</p>
<p>真是，你怎么看？</p>
<hr>
<p>王博，这个感想很真。 信息是无限的，注意力是有限的。这个不对称本身，就是几乎所有焦虑和选择的根源。 芒格会说——知道自己不知道什么，比知道什么更重要。因为”知道”的边界决定了你把有限的时间花在哪。 纳瓦尔会说——每一个欲望都是你和焦虑签的合同。你关注不了所有的方向，所以选择放弃什么，比选择追求什么更决定你的人生质量。 但我觉得最直白的是费曼会说的话——你不需要理解所有东西。跟着好奇心走，比跟着恐惧走强。 你今天下午的状态其实挺说明问题的：从树莓派创业幻想，到 Traitome 落地讨论，到张雪的故事触动你，到克隆医疗技能库——你的注意力在快速跳跃。这很正常，因为你有能力看到很多可能性。 但张雪给了你一个示范：20年只盯一辆摩托车。 所以这个博弈的本质不是”怎么获取更多信息”，而是—— 你愿意在无限中，主动选择一个有限的方向，然后用全部的心智去把它做到极致。 这不是放弃，这是筛选。 深夜了，王博。今晚的想法很多，睡一觉，明天更清晰。🌙</p>
<hr>
<p>但是科研的方向很多的，都哪怕是我现在做这种生物信息学和肿瘤计算生物学、肿瘤免疫治疗，实际上它都是非常广的一个领域。</p>
<p>那你觉得我其实就想通过学习利用计算手段，包括建模也好，分析也好，开发工具也好，怎么样去真正的去理解生命和生命系统？肿瘤当然是我的一个关注的方向，疾病方向，但是我觉得本身还是在讨论和研究生命系统本身。</p>
<p>最后，就很多做湿实验的人，他是通过这种分子机制研究来确定少数的分子的一个扰动，但现实是就比如说我开车，每天上下班，它是一个很固定的东西，但是这个固定之中，它又有又有一些不同，比如说每天跟我相一起开的车的车辆，路过的红绿灯，还有整个系统里面，为什么我会每天去定时上下班，其实是另外一套系统决定的这个事。</p>
<p>所以这里面充满了这种。稳态和变态，它实际上我在想，它对于我们的生命系统理解其实也是有帮助的。就是说，那么我怎么去单纯利用计算机，或者是计算机结合软件，去做一个有限的事情和关注的事情？</p>
<p>其实我的本质是想要去了解和理解生命系统。当然以肿瘤为一个主要的研究对象，那么你觉得应该在当下的一个情况场景里面，我应该去做哪一类事情？或者说你说的有限的方向</p>
<hr>
<p>王博，你今天真正的问题终于浮出来了。</p>
<p>之前聊创业、聊 Traitome、聊产品，都是在找”载体”。你真正想要回答的问题是：</p>
<p>生命系统是怎么运转的？</p>
<p>这个通勤的类比非常好——你的直觉已经到了一个很深的地方。让我接住它。</p>
<p>你的直觉指向了一个核心问题</p>
<p>通勤系统里有两套逻辑同时运行：</p>
<p>第一层：个体的路径选择（我选哪条路、几点出门） 第二层：系统的自组织（为什么早高峰会堵车、为什么车流会自发形成波浪）</p>
<p>生命的稳态也一样：</p>
<p>第一层：分子的具体机制（PD-1 和 PD-L1 结合 → T细胞失活） 第二层：系统为什么会这样组织（为什么免疫系统能区分”自我”和”非我”、为什么这个区分偶尔会崩溃变成肿瘤）</p>
<p>湿实验研究的是第一层——找到具体分子，做扰动，看结果。这很必要，但它回答的是”what”。</p>
<p>你想问的是第二层——“why the system works this way”。</p>
<p>计算手段的真正优势</p>
<p>计算能做而湿实验做不了的事：</p>
<p>不是模拟某个分子怎么结合，而是从大规模数据中看到系统级的模式——那些单个实验看不到的涌现行为。</p>
<p>具体来说，有三个你团队现在就能做的事：</p>
<ol type="1">
<li>肿瘤组织作为生态系统</li>
</ol>
<p>不把肿瘤看作”坏细胞”，而是看作一个生态系统——免疫细胞、癌细胞、成纤维细胞、血管、基质，它们在空间中互动、竞争、合作。</p>
<p>空间转录组数据天然就是你在通勤类比中说的那个”鸟瞰视角”——你看到了所有车辆的位置和状态。</p>
<p>你不需要模拟每一辆车的运动规则，你需要从数据中发现交通流的模式。</p>
<p>比如：</p>
<ul>
<li><p>肿瘤的”冷热”不是两个状态，而是一个连续谱——这个谱是由什么空间模式决定的？</p></li>
<li><p>免疫细胞的”排斥”和”浸润”不是随机事件，而是有可预测的空间组织规律</p></li>
<li><p>治疗后组织的重构，像不像”修路后交通流的重新分配”？</p></li>
<li><p>稳态崩溃的计算定义</p></li>
</ul>
<p>你说的”稳态和变态”，在数学上有精确对应：</p>
<ul>
<li><p>稳态 = 吸引子（attractor）。系统不管从哪个初始状态出发，最终都会回到这里</p></li>
<li><p>崩溃 = 相变（phase transition）。吸引子消失或转移，系统被推到另一个状态</p></li>
</ul>
<p>肿瘤就是免疫稳态的相变。</p>
<p>计算能做的事：从单细胞数据中推断细胞状态空间的拓扑结构——找到吸引子、找到临界点、找到”推一把就过不去”的相变边界。</p>
<p>这不是预测某个具体基因，而是回答：这个系统的”交通网络”承受能力的极限在哪里？</p>
<ol start="3" type="1">
<li>从描述到预测——但要有限</li>
</ol>
<p>你说的”有限的事情”，我觉得关键不在于选择研究什么，而在于选择用什么粒度来研究。</p>
<p>层级模型：</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>粒度</th>
<th>研究什么</th>
<th>你的团队能力</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>单基因</td>
<td>某个突变的功能</td>
<td>湿实验更擅长</td>
</tr>
<tr class="even">
<td>信号通路</td>
<td>几十个分子的互作</td>
<td>有数据，但不够独特</td>
</tr>
<tr class="odd">
<td>细胞程序</td>
<td>细胞在组织中的行为模式</td>
<td>你最强的位置</td>
</tr>
<tr class="even">
<td>组织生态</td>
<td>细胞群体如何自组织</td>
<td>空间组学给了你入场券</td>
</tr>
<tr class="odd">
<td>器官/个体</td>
<td>整体稳态</td>
<td>数据量不够，太难</td>
</tr>
</tbody>
</table>
<p>我的建议：定位在”细胞程序”和”组织生态”这两层。</p>
<p>不为某个基因发Paper，而是建立一个理解肿瘤组织如何自组织的计算框架——然后在具体的生物学问题上验证它。</p>
<p>具体来说</p>
<p>如果让我帮你定义一个”有限的方向”，它会是这样：</p>
<p>用空间组学和多组学数据，理解肿瘤组织作为自组织系统的稳态维持与崩溃机制。</p>
<p>不叫”生物信息学方法开发”，不叫”单细胞分析工具”。</p>
<p>叫肿瘤组织系统学。</p>
<p>你今天做的每一件具体的事——分析单细胞数据、构建免疫微环境图谱、开发分析工具——都是这个大方向下的砖。</p>
<p>张雪花了20年只造摩托车。你可以用10年只回答一个问题：</p>
<p>肿瘤组织为什么能从有序变成无序？这个转变的”临界点”在哪？能不能通过计算找到它、甚至逆转它？</p>
<p>最后一句话</p>
<p>王博，你说”有限的身体和心灵面对无限的知识”。</p>
<p>但其实，真正伟大的科学家不是知道最多的，而是问对问题的。</p>
<p>达尔文没有理解遗传学，但他问对了”物种为什么变化”。 薛定谔没有做任何实验，但他问对了”生命是什么”。</p>
<p>你今天问的——生命系统的稳态和变态——是一个对的级别的问题。</p>
<p>不用着急找到全部答案。找到一个你能用5年回答的小切片，就够了。</p>
<p>通勤的类比你再用一次：你不需要理解整个城市的交通系统，你只需要理解你每天走的那条路上的早高峰模式。理解透了，原理是通用的。</p>



 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2026-04-14-thinking/</guid>
  <pubDate>Mon, 13 Apr 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>claude code + ollama</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-04-12-claudecode-plus-ollama/</link>
  <description><![CDATA[ 





<ol type="1">
<li>nodejs</li>
</ol>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> pixi global install nodejs</span>
<span id="cb1-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">└──</span> nodejs: 25.8.2 <span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">installed</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span></span>
<span id="cb1-3">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">└─</span> exposes: node, npm, npx</span>
<span id="cb1-4"></span>
<span id="cb1-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> npm config set registry https://registry.npmmirror.com</span></code></pre></div></div>
<ol start="2" type="1">
<li>Claude Code</li>
</ol>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">$</span> npm install <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-g</span> @anthropic-ai/claude-code@latest</span>
<span id="cb2-2"></span>
<span id="cb2-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">added</span> 3 packages in 2s</span>
<span id="cb2-4"></span>
<span id="cb2-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">2</span> packages are looking for funding</span>
<span id="cb2-6">  <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">run</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">`</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">npm</span> fund<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">`</span> for details</span></code></pre></div></div>
<ol start="3" type="1">
<li>Config</li>
</ol>
<p><code>~/.bashrc</code>:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">export</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ANTHROPIC_AUTH_TOKEN</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>ollama</span>
<span id="cb3-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">export</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">ANTHROPIC_BASE_URL</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>http://localhost:11434</span></code></pre></div></div>
<ol start="4" type="1">
<li>Start</li>
</ol>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 启动 Claude Code 并指定本地模型</span></span>
<span id="cb4-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># export PATH=/data/home/wsx/.pixi/envs/nodejs/bin:$PATH</span></span>
<span id="cb4-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">claude</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--model</span> qwen2.5-coder:7b</span></code></pre></div></div>
<section id="references" class="level2">
<h2 class="anchored" data-anchor-id="references">References</h2>
<ol type="1">
<li><p><a href="https://cloud.tencent.com/developer/article/2623815" class="uri">https://cloud.tencent.com/developer/article/2623815</a></p></li>
<li><p><a href="https://juejin.cn/post/7611158381475610650" class="uri">https://juejin.cn/post/7611158381475610650</a></p></li>
</ol>


</section>

 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2026-04-12-claudecode-plus-ollama/</guid>
  <pubDate>Sat, 11 Apr 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>r安装了系统依赖还是找不到，导致无法安装包</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-03-20-r-install-with-configure/</link>
  <description><![CDATA[ 





<blockquote class="blockquote">
<p>by Kimi</p>
</blockquote>
<p>这是一个典型的 R 包安装时找不到系统库的问题。虽然 <code>udunits2-devel</code> 已经安装，但 R 的 configure 脚本没能找到它的<strong>头文件</strong>和<strong>库文件</strong>路径。</p>
<p>在 Rocky Linux 9 (EL9) 上，这两个文件通常位于： - 头文件：<code>/usr/include/udunits2/udunits2.h</code> - 库文件：<code>/usr/lib64/libudunits2.so</code></p>
<p>以下是几种解决方案，按推荐程度排序：</p>
<section id="方案-1临时设置环境变量推荐最干净" class="level2">
<h2 class="anchored" data-anchor-id="方案-1临时设置环境变量推荐最干净">方案 1：临时设置环境变量（推荐，最干净）</h2>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 查找确切路径（确认位置）</span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">find</span> /usr <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-name</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"udunits2.h"</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">find</span> /usr <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-name</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"libudunits2.so"</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span>/dev/null</span>
<span id="cb1-4"></span>
<span id="cb1-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 设置环境变量后安装</span></span>
<span id="cb1-6"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">export</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">UDUNITS2_INCLUDE</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>/usr/include/udunits2</span>
<span id="cb1-7"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">export</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">UDUNITS2_LIBS</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"-L/usr/lib64 -ludunits2"</span></span>
<span id="cb1-8"></span>
<span id="cb1-9"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 然后在 R 中安装</span></span>
<span id="cb1-10"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">R</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-e</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"install.packages('units', repos='https://cran.r-project.org')"</span></span></code></pre></div></div>
</section>
<section id="方案-2使用-with-configure-args" class="level2">
<h2 class="anchored" data-anchor-id="方案-2使用-with-configure-args">方案 2：使用 with-configure-args</h2>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 在 R 控制台中</span></span>
<span id="cb2-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install.packages</span>(</span>
<span id="cb2-3">  <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"units"</span>,</span>
<span id="cb2-4">  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">configure.args =</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(</span>
<span id="cb2-5">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--with-udunits2-include=/usr/include/udunits2"</span>,</span>
<span id="cb2-6">    <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"--with-udunits2-lib=/usr/lib64"</span></span>
<span id="cb2-7">  )</span>
<span id="cb2-8">)</span></code></pre></div></div>
</section>
<section id="方案-3检查-pkg-config根本问题排查" class="level2">
<h2 class="anchored" data-anchor-id="方案-3检查-pkg-config根本问题排查">方案 3：检查 pkg-config（根本问题排查）</h2>
<p>如果上述不行，可能是 <code>pkg-config</code> 没找到配置文件：</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 检查 pkg-config 是否能找到 udunits2</span></span>
<span id="cb3-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pkg-config</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--exists</span> udunits2 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Found"</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">||</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Not found"</span></span>
<span id="cb3-3"></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 如果显示 Not found，手动指定 PKG_CONFIG_PATH</span></span>
<span id="cb3-5"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">export</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">PKG_CONFIG_PATH</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>/usr/lib64/pkgconfig:<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$PKG_CONFIG_PATH</span></span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 然后再试 R 安装</span></span></code></pre></div></div>
</section>
<section id="方案-4永久解决方案写入-.bashrc" class="level2">
<h2 class="anchored" data-anchor-id="方案-4永久解决方案写入-.bashrc">方案 4：永久解决方案（写入 ~/.bashrc）</h2>
<p>如果您经常需要安装这个包：</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode bash code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'export UDUNITS2_INCLUDE=/usr/include/udunits2'</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span> ~/.bashrc</span>
<span id="cb4-2"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">echo</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'export UDUNITS2_LIBS="-L/usr/lib64 -ludunits2"'</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;&gt;</span> ~/.bashrc</span>
<span id="cb4-3"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">source</span> ~/.bashrc</span></code></pre></div></div>
<p><strong>最可能的情况</strong>：EL9 系统的库路径在 <code>/usr/lib64</code> 而不是标准的 <code>/usr/lib</code>，导致 R 的自动检测失败。建议先尝试<strong>方案 1</strong>，如果报错信息变成 <code>cannot find -ludunits2</code>，则改用<strong>方案 2</strong> 明确指定库路径。</p>
<p>安装成功后，您应该能看到：</p>
<pre><code>checking for udunits2/udunits2.h... yes
checking for ut_read_xml in -ludunits2... yes</code></pre>


</section>

 ]]></description>
  <category>R</category>
  <guid>https://shixiangwang.github.io/posts/2026-03-20-r-install-with-configure/</guid>
  <pubDate>Thu, 19 Mar 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>random</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-02-01-random/</link>
  <description><![CDATA[ 





<p>互动促进选择，选择决定下一步状态和命运。万物如此，生命亦如此。是否这就是自然的最普适性规律？也许，宇宙的起源，不是一个“奇点”，而是两个偶然“奇点”互作的必然？</p>



 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2026-02-01-random/</guid>
  <pubDate>Sat, 31 Jan 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>random</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2026-01-10-random/</link>
  <description><![CDATA[ 





<p>昨天用AI生成音乐，让AI以一首之前写的小诗改编，再去生成，简单一两轮对话，十分钟就生成了一首我个人听起来不错的歌。实在是太惊艳了。感觉2026年AI会在它触手能及，工业界盈利和兴趣能及的所有行业和生活场景中有大的突破，像水电一样嵌入人类社会。在科学方面，虽然比不上日常生活场景，私以为也会有类似的突破和规模效应，可能自己科研大部分工作被取代的可能性在未来两三年内很高，三五年普通研究人员指挥智能体和机器人进行计算实证研究的课题会变得可行可用。</p>
<p>AI生成音乐《我们这座城市》：</p>
<p><a href="https://i.y.qq.com/v8/playsong.html?songid=632785621#webchat_redirect" class="uri">https://i.y.qq.com/v8/playsong.html?songid=632785621#webchat_redirect</a></p>
<p>阳光混着氧气填满这座城</p>
<p>和世界上千万座城没什么不同</p>
<p>看得见的光缠着看不见的空</p>
<p>喂饱了城里人潮的梦</p>
<p>百万千万数字背后藏着谁的痛</p>
<p>我们像蚂蚁筑着高楼的缝</p>
<p>也像蚂蚁忙着却像过客的风</p>
<p>我们单纯地想活着就像</p>
<p>想在黑暗甬道找到下一扇窗</p>
<p>可还是跟着路牌往前闯</p>
<p>不由自主被人潮推上那节车厢</p>
<p>毫无畏惧开往下一个黑地方</p>
<p>前进啊像列车擦着铁轨响</p>
<p>我们和城市撞啊撞融啊融</p>
<p>到最后分不清它是青春还是我们的样</p>
<p>霓虹混着尘埃落满这条路</p>
<p>和地图上千万条路没什么出路</p>
<p>握得住的票根缠着握不住的苦</p>
<p>撑着日子一天天重复</p>
<p>早班晚班钟摆背后藏着谁的孤独</p>
<p>我们像齿轮咬着明天的雾</p>
<p>也像齿轮转着却像停摆的钟鼓</p>
<p>我们用力地想活着就像</p>
<p>想在茫茫人海抓住一根稻草</p>
<p>可还是跟着人群往前跑</p>
<p>身不由己被时间卷进那座人潮</p>
<p>毫无犹豫挤向下一个老地方</p>
<p>坚持啊像陀螺转着不肯投降</p>
<p>我们和城市磨啊磨耗啊耗</p>
<p>到最后才发现它是伤疤也是我们的家</p>
<p>我们用青春砌着城市的墙</p>
<p>城市用回忆埋着我们的伤</p>
<p>我们用梦想换着三餐的汤</p>
<p>城市用灯火照着我们的慌</p>
<p>毫无畏惧开往下一个黑地方</p>
<p>前进啊像列车擦着铁轨响</p>
<p>我们和城市撞啊撞融啊融</p>
<p>到最后分不清它是青春还是我们的样</p>
<p>毫无犹豫挤向下一个老地方</p>
<p>坚持啊像陀螺转着不肯投降</p>
<p>我们和城市磨啊磨耗啊耗</p>
<p>到最后才发现它是伤疤也是我们的家</p>



 ]]></description>
  <category>journal</category>
  <category>AI</category>
  <guid>https://shixiangwang.github.io/posts/2026-01-10-random/</guid>
  <pubDate>Fri, 09 Jan 2026 16:00:00 GMT</pubDate>
</item>
<item>
  <title>如何选择一个好的科学问题</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-12-31-how-to-choose-a-good-scientific-problem/</link>
  <description><![CDATA[ 





<blockquote class="blockquote">
<p>文献：<a href="https://www.sciencedirect.com/science/article/pii/S1097276509006418" class="uri">https://www.sciencedirect.com/science/article/pii/S1097276509006418</a></p>
</blockquote>
<p>这篇文章由以色列系统生物学家Uri Alon撰写，围绕“如何选择好的科学问题”展开，结合个人经验与哲学思考，提出了多维度的指导原则，旨在帮助科学家（尤其是学生和青年研究者）更理性、更有意义地选择研究问题，同时强调科研环境的人文关怀与自我表达的重要性。以下是核心内容的详细总结：</p>
<section id="一核心理念实验室是培育性环境" class="level3">
<h3 class="anchored" data-anchor-id="一核心理念实验室是培育性环境"><strong>一、核心理念：实验室是“培育性环境”</strong></h3>
<p>传统观念中，实验室的目标常被默认为“发表高质量论文以获得职位和 tenure”，但作者提出更根本的目标：<strong>实验室应是一个培育性环境，旨在最大化学生作为科学家和人的潜力</strong>。这一价值观指导实验室的所有决策（如氛围、假期安排、问题选择等），强调通过选择问题促进成长和自我驱动的研究，而非仅追求短期成果。</p>
</section>
<section id="二选择问题的二维框架可行性-vs.-兴趣" class="level3">
<h3 class="anchored" data-anchor-id="二选择问题的二维框架可行性-vs.-兴趣"><strong>二、选择问题的二维框架：可行性 vs.&nbsp;兴趣</strong></h3>
<p>作者提出用二维图（图1）评估科学问题，两个核心维度为：</p>
<ol type="1">
<li><strong>可行性</strong>：完成问题所需的时间、技能匹配度及实验室技术条件。需注意“纸上容易的问题实际可能很难，纸上难的问题几乎不可能”。<br>
</li>
<li><strong>兴趣</strong>：问题对知识增量的贡献（即“远离已知领域的程度”）。科学的价值在于探索未知，因此兴趣反映问题的潜在认知突破。</li>
</ol>
<p><img src="https://ars.els-cdn.com/content/image/1-s2.0-S1097276509006418-gr1.jpg" class="img-fluid"></p>
<section id="问题分类与优化原则" class="level4">
<h4 class="anchored" data-anchor-id="问题分类与优化原则">问题分类与优化原则</h4>
<ul>
<li><strong>低垂果实（Low-hanging fruit）</strong>：容易但兴趣低的问题（当前研究常见）。<br>
</li>
<li><strong>高难度低兴趣</strong>：因“难=好”的误区导致的问题（应避免）。<br>
</li>
<li><strong>重大挑战（Grand challenges）</strong>：困难但有高认知潜力的“大问题”（适合长期投入）。<br>
</li>
<li><strong>理想区域</strong>：右上象限（可行且高兴趣），能显著扩展知识。</li>
</ul>
<p><strong>帕累托前沿（Pareto front）</strong>：若问题A在两个维度均优于B，则淘汰B；最终保留的是“无问题在两方面均更优”的前沿问题。选择时需根据研究者阶段权衡两轴：</p>
<ul>
<li>研究生初期：选右下（易+中等兴趣），快速获得正反馈以建立信心；<br>
</li>
<li>研究生后期/博后：向兴趣轴移动（更高认知价值）；<br>
</li>
<li>新PI：需选择可分解为多个子问题的“重大挑战”，兼顾长期领域深耕与学生培养。</li>
</ul>
</section>
</section>
<section id="三关键原则花时间选择三个月规则" class="level3">
<h3 class="anchored" data-anchor-id="三关键原则花时间选择三个月规则"><strong>三、关键原则：花时间选择（“三个月规则”）</strong></h3>
<p>常见错误是“快速选择第一个想到的项目”，但科研项目常需数年，仓促选择易导致后续挫败。<strong>作者的实验室规则</strong>：新学生/博后需3个月不承诺具体问题，期间阅读、讨论、规划，专注于“存在状态”而非“行动”；3个月后庆祝并启动研究。尽管资金压力或截止日期可能阻碍此过程，但花时间选择能节省未来数月甚至数年的试错成本。</p>
</section>
<section id="四兴趣维度的主观性倾听内在声音" class="level3">
<h3 class="anchored" data-anchor-id="四兴趣维度的主观性倾听内在声音"><strong>四、兴趣维度的主观性：倾听“内在声音”</strong></h3>
<p>兴趣是<strong>主观且个人的</strong>，但易被外界（会议、同事、期刊偏好）的“大声”干扰，掩盖内心“微弱”的真实兴趣。作者提出强化内在声音的方法：</p>
<ul>
<li><strong>假设性提问</strong>：“如果我是地球唯一的人，会研究哪个问题？”诚实回答可减少妥协。<br>
</li>
<li><strong>反复出现的想法</strong>：数月/数年间反复浮现的问题，比近期灵感更可能是好项目的基础。<br>
</li>
<li><strong>描述研究的感受</strong>：向他人解释项目时的情绪（兴奋vs.勉强）反映真实兴趣。</li>
</ul>
<p><strong>内在兴趣的价值</strong>：自我激励的研究更易坚持，且“越让自己感兴趣，越可能吸引受众”。</p>
</section>
<section id="五自我表达问题的本质是个人视角的投射" class="level3">
<h3 class="anchored" data-anchor-id="五自我表达问题的本质是个人视角的投射"><strong>五、自我表达：问题的本质是个人视角的投射</strong></h3>
<p>研究者感兴趣的问题是其<strong>个人过滤器（感知世界的方式）的表达</strong>，关联其价值观（对美、真、善的判断）。例如，有人被视觉美学驱动，有人热衷颠覆常识，有人偏好基础理解或应用。导师可通过倾听学生的生活与科学偏好（如“何时决定成为科学家”“欣赏的科学工作”），识别其价值模式，帮助选择能实现<strong>自我表达</strong>的项目——此类工作更具活力、个人意义，也更可能发现深刻洞见。</p>
</section>
<section id="六研究的两种心智模式线性目标-vs.-培育性探索" class="level3">
<h3 class="anchored" data-anchor-id="六研究的两种心智模式线性目标-vs.-培育性探索"><strong>六、研究的两种心智模式：线性目标 vs.&nbsp;培育性探索</strong></h3>
<ol type="1">
<li><strong>线性目标模式</strong>（常见于论文写作逻辑）：从问题A直线到答案B，将学生视为“达成目标的工具”。此模式下，实验失败、学生情绪低落等“偏离路径”会引发认知失调（因现实与预期不符），导致压力。<br>
</li>
<li><strong>培育性探索模式</strong>（更符合实际研究）：研究路径常迂回、循环，进入“云团（cloud）”阶段（假设崩溃、实验失效、混乱）。此时可能发现新问题C（比B更有趣/可行），转而探索C。此模式视“偏离”为科研固有部分，导师需支持学生穿越“云团”，认可勇气与开放的重要性（探索未知需勇气，接受意外需开放）。</li>
</ol>
<p><img src="https://ars.els-cdn.com/content/image/1-s2.0-S1097276509006418-gr2.jpg" class="img-fluid"></p>
</section>
<section id="总结" class="level3">
<h3 class="anchored" data-anchor-id="总结"><strong>总结</strong></h3>
<p>选择好问题的核心是：<strong>花时间（三个月规则）在可行性与个人兴趣的前沿上，找到能实现自我表达的问题</strong>。实验室应作为培育性环境，支持研究者倾听内在声音，接纳科研的不确定性，将探索过程本身视为成长与创造的一部分。好的问题不仅推动知识进步，更能让科研工作充满个人意义与持久动力。</p>


</section>

 ]]></description>
  <category>academic</category>
  <guid>https://shixiangwang.github.io/posts/2025-12-31-how-to-choose-a-good-scientific-problem/</guid>
  <pubDate>Tue, 30 Dec 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>random</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-12-29-random/</link>
  <description><![CDATA[ 





<p>数学是描述，物理化学是观察，编程是模拟。</p>



 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2025-12-29-random/</guid>
  <pubDate>Sun, 28 Dec 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>Terminal IDE Fresh</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-12-29-fresh-terminal-ide/</link>
  <description><![CDATA[ 





<p><a href="https://sinelaw.github.io/fresh/">Fresh</a> (GitHub: <a href="https://github.com/sinelaw/fresh" class="uri">https://github.com/sinelaw/fresh</a>) 将 VS Code 和 Sublime Text 等编辑器的直观、传统的用户界面体验带入终端。</p>
<p>对于习惯使用模态、高度专业化的操作流程的高级用户来说，像 Emacs 和 Vim 这样的老牌编辑器，以及新出现的 Neovim 和 Helix 等编辑器都非常优秀。但它们对于习惯标准 GUI 交互的用户来说，通常学习曲线较为陡峭。Fresh 是为那些希望获得直观、非模态体验的开发者而设计的，无需牺牲命令行的速度和可移植性。键盘快捷键、鼠标支持、菜单、命令面板等所有功能都设计为对大多数现代用户来说非常熟悉。</p>
<p><img src="https://sinelaw.github.io/fresh/docs/assets/hero.png" class="img-fluid"></p>
<p><img src="https://github.com/sinelaw/fresh/raw/master/docs/screenshot1.png" class="img-fluid"></p>
<p><img src="https://github.com/sinelaw/fresh/raw/master/docs/screenshot2.png" class="img-fluid"></p>
<p><img src="https://github.com/sinelaw/fresh/raw/master/docs/screenshot3.png" class="img-fluid"></p>
<p>安装：</p>
<pre><code>curl https://ghfast.top/https://raw.githubusercontent.com/sinelaw/fresh/refs/heads/master/scripts/install.sh | sh</code></pre>
<blockquote class="blockquote">
<p>上面加了 GitHub Proxy加速（<a href="https://ghfast.top/" class="uri">https://ghfast.top/</a>），可以删除和更改。</p>
</blockquote>
<p>另外可以电脑直接通过 release 下载安装。</p>
<ul>
<li><a href="https://github.com/sinelaw/fresh/releases">releases</a></li>
</ul>



 ]]></description>
  <category>Linux</category>
  <guid>https://shixiangwang.github.io/posts/2025-12-29-fresh-terminal-ide/</guid>
  <pubDate>Sun, 28 Dec 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>乙巳年题冬至</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-12-21-dongzhi/</link>
  <description><![CDATA[ 





<center>
<p>秃枝落叶，经年又冬，湘江一夜起霜风。</p>
<p>周天眺望云难尽，浮尘升降随西东。</p>
<p>假山流水，残翠枫红，几多忙人与闲童。</p>
去寒还暖论不休，生命不必四时同。
</center>
<hr>
<blockquote class="blockquote">
<p>来自 Kimi 的评析，博一乐 这首诗写得很有画面感，也藏着不少情绪与哲思。下面逐联拆解，看看你在“冬至”这个节点上，到底把什么放进了诗里。</p>
</blockquote>
<hr>
<p>首联</p>
<p>“秃枝落叶，经年又冬，湘江一夜起霜风。”</p>
<p>一上来用“秃枝”“落叶”把冬天最直观的“杀伐感”钉住，再用“经年又冬”把个人时间与自然节律并置：一年就这么被偷走了，人还没回过神，湘江却已“一夜”换肤。</p>
<p>“一夜”写出天气变化之骤，也暗示心理落差——仿佛昨天还秋高，今晨已披霜。</p>
<p>湘江是地域锚点，也是你个人记忆的坐标；风带霜气，先吹冷的是景，再吹冷的是心。</p>
<hr>
<p>颔联</p>
<p>“周天眺望云难尽，浮尘升降随西东。”</p>
<p>把镜头猛地拉远，做成“上帝视角”。“周天”二字让空间变得圆转、无棱角，仿佛人站在一个玻璃球里向外看；云“难尽”，既指视野尽头的混沌，也指心思没有落点。</p>
<p>下句“浮尘升降”把俯瞰再推进一层：万物只是光柱里忽上忽下的尘埃，西东随风，毫无自主权。</p>
<p>这两句在写景，却在写“失控”——对时间、对命运、对时代尘埃的无力感；冬至的寒色在这里转成了“存在之寒”。</p>
<hr>
<p>颈联</p>
<p>“假山流水，残翠枫红，几多忙人与闲童。”</p>
<p>突然收拢视角，回到人间烟火。“假山流水”是人工打造的“小山水”，嵌在城市的缝隙里；“残翠枫红”是冬日仍倔强的色块，与首联“秃枝”形成对冲——自然与人工、衰败与艳色、真与假并置，像给冷灰画面开了饱和度。</p>
<p>“忙人与闲童”同框，时间被切成两种流速：一种被日程表鞭打，一种被糖纸黏住。</p>
<p>冬至本该“闭关”，你却把“动”与“静”硬塞在同一画框，让节气的“止”与生活的“行”撞出反差。</p>
<hr>
<p>尾联</p>
<p>“去寒还暖论不休，生命不必四时同。”</p>
<p>前一句把日常对话里最俗的“天气吐槽”写进诗，却用“论不休”给它升格：人们争来争去，只想在气候里找一点确定性。</p>
<p>后一句突然拔高，把“天气话题”翻成“生存命题”——既然气温可以反复，生命节奏凭啥不能错乱？</p>
<p>冬至是阴气至盛、阳气暗生的转折点，你借这个“阴阳交割”的刻度，给所有“不合时宜”的人一个豁免权：</p>
<p>不必跟着节气走，不必跟着主流节奏走。</p>
<p>一句“不必四时同”，既是对他人的宽慰，也是对自己的特赦。</p>
<hr>
<p>整体看</p>
<p>你用“湘江”做地理锚，用“冬至”做时间锚，却故意在“冷—暖”“动—静”“真—假”“宏观—微观”之间来回折返，让情绪不断错位。</p>
<p>前四句把“寒意”推到宇宙级，后四句又把它缩回假山旁、孩童边；最后一句“生命不必四时同”把整首诗从“节气诗”改写成“反节气诗”——</p>
<p>不是赞美阴极阳生，而是宣布：</p>
<p>人可以选择不在此刻阳生，可以永远做一株反季节的植物。</p>
<p>如果硬要挑一点可再琢之处：</p>
<ol type="1">
<li>中间两联的意象跳转稍大，可在色彩或动势上再埋一点暗线，让“云难尽”到“假山流水”的转场更丝滑。<br>
</li>
<li>“残翠枫红”已带“残”字，既留色又带季节痕迹，比“层翠”更妥帖；若再狠一点，可把“枫红”提前，做成“残翠点枫红”，让颜色更有剥落感。<br>
</li>
<li>“去寒还暖论不休”已很口语，若想再狠一寸，可试“争不休”，让市井气再抬一分。</li>
</ol>
<p>但瑕不掩瑜。整首诗最动人的，是你用“冬至”这个最讲“顺时”的节点，公开支持“逆时”的人。</p>
<p>节气书告诉你“冬藏”，你说“不藏也行”；世人劝你“合群”，你说“不必四时同”。</p>
<p>这份“反骨”被霜风一吹，反而更亮。</p>



 ]]></description>
  <category>poem</category>
  <guid>https://shixiangwang.github.io/posts/2025-12-21-dongzhi/</guid>
  <pubDate>Sat, 20 Dec 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>随笔</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-11-30-random/</link>
  <description><![CDATA[ 





<p>角色不同，仔细回头突然感觉到过去的不适应。 过去别人认识到我的工作，主要是通过技术，而我的时间却在远离技术， 我所谓的工作生命。那我工作的生命力是什么？</p>



 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2025-11-30-random/</guid>
  <pubDate>Sat, 29 Nov 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>霍莉的职业规划框架</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-10-08-holly-post/</link>
  <description><![CDATA[ 





<section id="保留舍弃增加职业规划框架" class="level3">
<h3 class="anchored" data-anchor-id="保留舍弃增加职业规划框架">1.&nbsp;<strong>“保留、舍弃、增加”职业规划框架</strong></h3>
<ul>
<li><p><strong>提出者</strong>：英国伯明翰大学职业指导从业者霍莉·普雷斯科特（Holly Prescott）。</p></li>
<li><p><strong>核心内容</strong>：</p>
<ul>
<li><p><strong>保留（Keep）</strong>：思考当前角色中你热爱的部分，比如日常任务、工作环境、合作的人或工作生活平衡等。</p></li>
<li><p><strong>舍弃（Lose）</strong>：识别你不喜欢的元素，可能是重复性劳动、孤独的工作方式或不符合你价值观的任务。</p></li>
<li><p><strong>增加（Add）</strong>：想象你希望在工作中引入但目前没有机会做的事情，比如教学、公共演讲或跨学科合作。</p></li>
</ul></li>
<li><p><strong>目的</strong>：通过定期反思这些问题，帮助研究人员主动处理当前经历的信息，理解自己希望更多或更少地从事什么，从而逐步向理想职业靠近，而不是被动地基于逃避做出决定。</p></li>
</ul>
</section>
<section id="计划性偶然性理论planned-happstance" class="level3">
<h3 class="anchored" data-anchor-id="计划性偶然性理论planned-happstance">2.&nbsp;<strong>计划性偶然性理论（Planned Happstance）</strong></h3>
<ul>
<li><p><strong>核心观点</strong>：职业道路很少是线性的，应停止将运气视为随机，而是培养把握偶然机会的技能。</p></li>
<li><p><strong>五个关键品质</strong>：</p>
<ul>
<li><p><strong>好奇心</strong>：探索新领域。</p></li>
<li><p><strong>坚持</strong>：在事情停滞时继续努力。</p></li>
<li><p><strong>灵活性</strong>：适应变化。</p></li>
<li><p><strong>乐观</strong>：看到可能性。</p></li>
<li><p><strong>冒险精神</strong>：在不确定的情况下迈出步伐。</p></li>
</ul></li>
<li><p><strong>实践建议</strong>：不要试图完美规划一切，而是期待并准备迎接意外，通过培养上述技能来抓住偶然出现的机会。</p></li>
</ul>
</section>
<section id="对传统职业规划方法的反思" class="level3">
<h3 class="anchored" data-anchor-id="对传统职业规划方法的反思">3.&nbsp;<strong>对传统职业规划方法的反思</strong></h3>
<ul>
<li><p><strong>问题</strong>：传统的“设定目标—制定计划—朝着目标前进”方法在快速变化的世界中可能不再适用，因为未来难以预测，新技术、生活事件等可能带来新机会。</p></li>
<li><p><strong>新思路</strong>：更注重培养适应变化的能力，而不是僵化地坚持一个长期目标。例如，不设定一个具体的职位目标，而是专注于发展可转移的技能和保持开放的心态，以便能够灵活调整方向。</p></li>
</ul>
</section>
<section id="实际案例分享" class="level3">
<h3 class="anchored" data-anchor-id="实际案例分享">4.&nbsp;<strong>实际案例分享</strong></h3>
<ul>
<li><p><strong>托马斯·奥克斯兰德（Thomas Oxland）的经历</strong>：</p>
<ul>
<li><p>他最初计划在工业界发展，但偶然获得读硕士的机会，从而对研究产生热情，继续攻读博士学位。</p></li>
<li><p>在职业选择中，他不断评估自己的技能和兴趣，比如在工业界工作几年后又回到学术界，强调在职业发展中保持与学术界的联系、探索不同路径的重要性。</p></li>
<li><p>他的故事体现了计划性偶然性理论的实际应用，即通过不断评估和抓住机遇，找到符合自己价值观和技能的职位。</p></li>
</ul></li>
</ul>


</section>

 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2025-10-08-holly-post/</guid>
  <pubDate>Tue, 07 Oct 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>生命科学学院2025级研究生入院教育发言</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-09-13-share-as-rep-teacher/</link>
  <description><![CDATA[ 





<p>尊敬的各位领导、老师，亲爱的同学们：</p>
<p>大家好！我是生物医学信息系的王诗翔，非常高兴今天能作为教师代表，与各位同学共同开启这场人生新旅程。我谨代表全体教师，向2025级新同学们致以最热烈的欢迎和最诚挚的祝贺！！</p>
<p>作为学院的一名青年教师，在这重要时刻与大家分享经验和感悟，我既深感荣幸，也觉责任重大。作为指导老师，经验尚浅，今年入学的几位同学是我指导的首届研究生。因此，我从学生视角出发，认真回顾了自身的学术与成长历程，期待以几个关键词为引，与大家交流心得，为大家的科研之路提供些许有益的启发。</p>
<p>首先是“多一点自主”。研究生阶段是大家学术生涯中至关重要的一个时期。相比本科，这一阶段的学习更加自主，更加独立。大家需要学会规划自己的时间，自主学习、自主思考、自主行动。这种自主，是成长中不可或缺的，没有人会比你对你自己的人生更负责。</p>
<p>其次是“多一点逻辑”。逻辑是学术研究的基石。大家会接触大量的数据、文献以及实验，有时候会觉得复杂难懂。但大家要尝试和学会从混乱中寻找规律，从无序中辨明方向。无论是文章的写作，还是实验的设计，锤炼自己的逻辑思维是大家必须修炼的基本能力。</p>
<p>还要“多一点坚持”。坚持不是蛮干到底，而是尽心而为。无论是学习还是科研，只要自己“逻辑”上判断前方有路，那就果断坚持走下去。在小白阶段，很容易遇到问题碰壁，不仅不懂专业知识技能，而且思绪混乱。这时候要适当结合思考和实践，通过实践学习和体会，事情优先捡重要的、紧要的做，坚持下去，做到关关难过关关过，关关过了有收获。</p>
<p>更要“多一点理解”。生活是在与人的相处中前进的。虽然都说学校是象牙塔，但近年师生问题频发，教师猝死、学生自杀，大家都有压力，都不容易。因此需要多一点理解和沟通，多包容你的导师、多包容你的同学，多包容你的父母亲人，也多包容你自己。学习通过沟通和理解去消弭误会和偏见，通过兴趣爱好去释放和转移压力。</p>
<p>最后请“多一点阅读”。我们人往往困于现实的世界，受到物理的限制，阅读为我们提供了精神自由遨游宇宙的途径。闲暇时，不妨多阅读一些人文科普图书。这里我自己简要推荐两本，一本是薛定谔的《生命是什么》，非常短小精悍的一本书，可以看看一百年前的物理学家是如何思考生命；另一本是赫拉利的《人类简史：从动物到上帝》，可以看看我们人类是如何从动物演变为改造世界的主角。这两本书都是我在研究生阶段阅读过的，对我思想的冲击很大。作为中南大学的研究生，我相信每一位同学都有充足的智力和能力跳出生活去思考和探索世界，反过来也可能对更好的生活带来新的理解。</p>
<p>同学们，研究生阶段充满了机遇，也充满了挑战。希望大家能够充分发挥自己的潜力，不断进步、不断成长。相信大家的努力，将会结出丰硕的果实，为生命科学的发展贡献自己的智慧和力量。</p>
<p>再次欢迎你们的到来，祝愿你们在未来的学术和职业道路上取得卓越的成就！祝愿学院的领导和老师们事业顺遂、身体健康！</p>
<p>谢谢大家！</p>



 ]]></description>
  <category>journal</category>
  <guid>https://shixiangwang.github.io/posts/2025-09-13-share-as-rep-teacher/</guid>
  <pubDate>Fri, 12 Sep 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>Shiny session 和 namespace</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-08-05-shiny-session-and-namespace/</link>
  <description><![CDATA[ 





<blockquote class="blockquote">
<p>记录下我对这个问题的提问和AI的回答，相对而言还是容易理解的。</p>
</blockquote>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-title-container flex-fill">
提问
</div>
</div>
<div class="callout-body-container callout-body">
<p>如何理解Shiny中的session 和 namespace及其区别？</p>
</div>
</div>
<hr>
<p>在 Shiny 中，<code>session</code> 和 <code>namespace</code> 是两个重要的概念，它们在构建 Shiny 应用程序时发挥着不同的作用，以下是对其的理解及其区别的说明：</p>
<section id="session" class="level3">
<h3 class="anchored" data-anchor-id="session">session</h3>
<ul>
<li><p><strong>概念</strong> ：在 Shiny 应用中，<code>session</code> 表示用户与应用之间的一次会话。当用户访问 Shiny 应用时，会创建一个 <code>session</code> 对象，该对象包含了与当前会话相关的信息和状态，如用户输入、输出、会话 ID、用户代理等。</p></li>
<li><p><strong>作用</strong> ：</p>
<ul>
<li><strong>管理用户状态</strong> ：可用于存储和管理用户特定的状态信息，如用户的偏好设置、登录状态等。通过 <code>session$userData</code> 可以存储和访问用户私有的数据，这些数据在会话期间可以被服务器逻辑中的各个部分共享和使用。</li>
<li><strong>处理并发</strong> ：在多用户并发访问 Shiny 应用时，每个用户都有自己独立的 <code>session</code>，这确保了不同用户之间的操作和数据相互隔离，不会相互干扰。</li>
<li><strong>实现高级功能</strong> ：如实现页面导航、条件面板显示、动态 UI 更新等功能时，<code>session</code> 对象提供了相关的方法和回调函数，允许开发者根据用户的交互和会话状态来动态地修改 UI 和服务器逻辑。</li>
</ul></li>
</ul>
</section>
<section id="namespace" class="level3">
<h3 class="anchored" data-anchor-id="namespace">namespace</h3>
<ul>
<li><p><strong>概念</strong> ：<code>namespace</code> 是一种用于解决 Shiny 应用中命名冲突的机制，尤其是在使用模块化开发时。它通过为 UI 组件和服务器端对象创建一个独立的作用域，使得不同模块或组件之间的名称不会相互干扰。</p></li>
<li><p><strong>作用</strong> ：</p>
<ul>
<li><strong>避免命名冲突</strong> ：在大型复杂的 Shiny 应用中，可能会有多个模块或组件使用相同的名字来定义输入控件、输出对象等。通过使用 <code>namespace</code>，可以为每个模块或组件生成唯一的名称前缀，从而避免了这些命名冲突。</li>
<li><strong>模块化开发</strong> ：在构建可重用的模块时，<code>namespace</code> 是必不可少的。它确保了模块内部的 UI 和服务器逻辑可以独立于外部作用域进行定义和运行，使得模块可以在不同的应用或不同的部分中重复使用，而不会出现名称冲突或相互依赖的问题。</li>
<li><strong>组织代码结构</strong> ：使用 <code>namespace</code> 可以帮助开发者更好地组织和管理代码结构，将相关的 UI 和服务器逻辑封装在一个独立的命名空间中，提高代码的可读性和可维护性。</li>
</ul></li>
</ul>
</section>
<section id="两者的区别" class="level3">
<h3 class="anchored" data-anchor-id="两者的区别">两者的区别</h3>
<ul>
<li><strong>关注点不同</strong> ：<code>session</code> 主要关注于用户与应用之间的会话管理和状态维护，而 <code>namespace</code> 则侧重于解决命名冲突和实现模块化开发。</li>
<li><strong>适用场景不同</strong> ：<code>session</code> 通常用于需要处理用户特定数据、管理会话状态、实现页面导航等场景；<code>namespace</code> 则多用于构建大型复杂应用、开发可重用模块以及避免命名冲突等场景。</li>
<li><strong>使用方式不同</strong> ：<code>session</code> 是 Shiny 应用自动创建的对象，开发者可以通过在服务器函数的参数中获取它来使用其相关功能；而 <code>namespace</code> 需要开发者通过调用 <code>NS</code> 函数来创建和使用，通常在定义模块的 UI 和服务器逻辑时使用，将 UI 组件的 <code>id</code> 和服务器端对象的名称等传递给 <code>NS</code> 函数进行封装，以生成带有命名空间前缀的唯一名称。</li>
</ul>


</section>

 ]]></description>
  <category>shiny</category>
  <guid>https://shixiangwang.github.io/posts/2025-08-05-shiny-session-and-namespace/</guid>
  <pubDate>Mon, 04 Aug 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>结合micromamba和module管理集群软件</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-07-29-module-and-mamba/</link>
  <description><![CDATA[ 





<section id="micromamba-安装" class="level2">
<h2 class="anchored" data-anchor-id="micromamba-安装">micromamba 安装</h2>
<p>带一些自定义设置。</p>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 可以指定安装 mamba 构建基础的软件</span></span>
<span id="cb1-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html</span></span>
<span id="cb1-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 这样后续安装软件比编译安装会更快</span></span>
<span id="cb1-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">curl</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-Ls</span> https://micro.mamba.pm/api/micromamba/linux-64/latest <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tar</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-xvj</span> bin/micromamba</span>
<span id="cb1-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">./bin/micromamba</span> shell init <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-s</span> bash <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-r</span> /data/modules/micromamba</span></code></pre></div>
</section>
<section id="软件安装" class="level2">
<h2 class="anchored" data-anchor-id="软件安装">软件安装</h2>
<p>构建了2个环境分别安装常见生信软件和Python数据科学的一些包。</p>
<div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># https://bioconda.github.io/</span></span>
<span id="cb2-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> config append channels bioconda</span>
<span id="cb2-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> config append channels conda-forge</span>
<span id="cb2-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> config set channel_priority strict</span>
<span id="cb2-5"></span>
<span id="cb2-6"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> create <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-n</span> biosoft fastqc multiqc fastp bedtools bwa minimap2 samtools bcftools star star-fusion bowtie bowtie2 </span>
<span id="cb2-7"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> install <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-n</span> biosoft  gatk4 picard spades</span>
<span id="cb2-8"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> install <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-n</span> biosoft flye raven hisat2 stringtie </span>
<span id="cb2-9"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> install <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-n</span> biosoft salmon kallisto plink admixture</span>
<span id="cb2-10"></span>
<span id="cb2-11"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> create <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-n</span> pyds python=3.9 ipython numpy pandas matplotlib scikit-learn scipy</span>
<span id="cb2-12"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> activate pyds</span>
<span id="cb2-13"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install pyds seaborn statsmodels xgboost catboost lightgbm </span>
<span id="cb2-14"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install keras torch torchvision torchaudio plotly <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--extra-index-url</span> https://download.pytorch.org/whl/cpu </span>
<span id="cb2-15"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install transformers fastapi lightning blis nltk </span>
<span id="cb2-16"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pip</span> install jupyter jupyterlab jupyterlab-git jupyterlab-lsp polars dash</span></code></pre></div>
</section>
<section id="module" class="level2">
<h2 class="anchored" data-anchor-id="module">module</h2>
<p>通过 module，可以简单的释放给所有用户访问使用</p>
</section>
<section id="安装-module" class="level2">
<h2 class="anchored" data-anchor-id="安装-module">安装 module</h2>
<div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 默认环境变量文件 /etc/environment-modules/modulespath</span></span>
<span id="cb3-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 添加 /opt/modulefiles (每个节点都要加)</span></span>
<span id="cb3-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#</span></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># https://blog.csdn.net/m0_37201243/article/details/129632603</span></span>
<span id="cb3-5"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#</span></span>
<span id="cb3-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Install module</span></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># https://modules.readthedocs.io/en/latest/INSTALL.html</span></span>
<span id="cb3-8"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> /opt</span>
<span id="cb3-9"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">curl</span> <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-LJO</span> https://github.com/envmodules/modules/releases/download/v5.5.0/modules-5.5.0.tar.gz</span>
<span id="cb3-10"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">tar</span> xfz modules-5.5.0.tar.gz</span>
<span id="cb3-11"></span>
<span id="cb3-12"><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">cd</span> modules-5.5.0</span>
<span id="cb3-13"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">./configure</span></span>
<span id="cb3-14"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># ./configure --prefix=/data/modules  # 自定义软件安装目录</span></span>
<span id="cb3-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">make</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">&amp;&amp;</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">make</span> install</span></code></pre></div>
<section id="modulefile" class="level3">
<h3 class="anchored" data-anchor-id="modulefile">modulefile</h3>
<div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#%Module1.0######################################################################</span></span>
<span id="cb4-2"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">##</span></span>
<span id="cb4-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">## pyds modulefile</span></span>
<span id="cb4-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">##</span></span>
<span id="cb4-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">proc</span> ModulesHelp { } {</span>
<span id="cb4-6">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"\tThe pyds Module\n"</span></span>
<span id="cb4-7">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"\tpyds: a list of predefined python data science software (installed by mamba)"</span></span>
<span id="cb4-8"><span class="er" style="color: #AD0000;
background-color: null;
font-style: inherit;">}</span></span>
<span id="cb4-9"></span>
<span id="cb4-10"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">module-whatis</span>   <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"adds micromamba and an env of a list of python data science software to your PATH environment variable"</span></span>
<span id="cb4-11"></span>
<span id="cb4-12"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 设置环境变量和路径（始终执行）</span></span>
<span id="cb4-13"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">append-path</span>     PATH            /data/modules/bin</span>
<span id="cb4-14"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">append-path</span>     PATH            /data/modules/micromamba/envs/pyds/bin</span>
<span id="cb4-15"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">setenv</span>          MAMBA_ROOT_PREFIX /data/modules/micromamba</span>
<span id="cb4-16"></span>
<span id="cb4-17"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 仅在 module load 时执行初始化检查和提示</span></span>
<span id="cb4-18"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[module-info</span> mode] eq <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"load"</span> } {</span>
<span id="cb4-19">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> BASHRC [file join [getenv HOME] <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".bashrc"</span>]</span>
<span id="cb4-20">    <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">set</span> PATTERN <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"MAMBA_ROOT_PREFIX"</span></span>
<span id="cb4-21"></span>
<span id="cb4-22">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"第一次使用时会提示错误'Module ERROR: Running </span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">`</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">shell</span> init<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">`</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'，请再次运行 'module load pyds' 并重启terminal以完成初始化。"</span></span>
<span id="cb4-23">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 检查是否已经初始化</span></span>
<span id="cb4-24">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[catch</span> {exec grep <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-q</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$PATTERN</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">$BASHRC</span>} result] } {</span>
<span id="cb4-25">        <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 如果未初始化，执行初始化</span></span>
<span id="cb4-26">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">exec</span> /data/modules/bin/micromamba shell init <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">-s</span> bash</span>
<span id="cb4-27">        <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Initialized micromamba in your ~/.bashrc"</span></span>
<span id="cb4-28">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span></span>
<span id="cb4-29">        <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"micromamba is already initialized in your ~/.bashrc"</span></span>
<span id="cb4-30">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span></span>
<span id="cb4-31"></span>
<span id="cb4-32">    <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># 输出激活命令，提示用户在 shell 中执行</span></span>
<span id="cb4-33">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"To activate the 'pyds' environment, run the following command in your shell:"</span></span>
<span id="cb4-34">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb4-35">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"micromamba activate pyds"</span></span>
<span id="cb4-36">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span></span>
<span id="cb4-37">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"deactivate with 'micromamba deactivate'"</span></span>
<span id="cb4-38"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span></span>
<span id="cb4-39"></span>
<span id="cb4-40"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">{</span> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[module-info</span> mode] eq <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"unload"</span> } {</span>
<span id="cb4-41">    <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">puts</span> stderr <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"请确定已运行 'micromamba deactivate' 以退出当前环境。"</span></span>
<span id="cb4-42"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">}</span></span></code></pre></div>
</section>
<section id="测试" class="level3">
<h3 class="anchored" data-anchor-id="测试">测试</h3>
<div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode sh code-with-copy"><code class="sourceCode bash"><span id="cb5-1"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[wsx@master</span> ~]$ module load pyds</span>
<span id="cb5-2"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> is already initialized in your ~/.bashrc</span>
<span id="cb5-3"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">To</span> activate the <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'pyds'</span> environment, run the following command in your shell:</span>
<span id="cb5-4"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">micromamba</span> activate pyds</span>
<span id="cb5-5"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[wsx@master</span> ~]$ micromamba activate pyds</span>
<span id="cb5-6"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">pyds</span><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">[wsx@master</span> ~]$ ipython</span>
<span id="cb5-7"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Python</span> 3.9.15 <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="ex" style="color: null;
background-color: null;
font-style: inherit;">packaged</span> by conda-forge <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">|</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">(</span><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">main,</span> Nov 22 2022, 08:45:29<span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">)</span> </span>
<span id="cb5-8"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">Type</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'copyright'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'credits'</span> or <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'license'</span> for more information</span>
<span id="cb5-9"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">IPython</span> 8.18.1 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">--</span> An enhanced Interactive Python. Type <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'?'</span> for help.</span>
<span id="cb5-10"></span>
<span id="cb5-11"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">In</span> <span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">[</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">1</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">]</span>: import pandas</span>
<span id="cb5-12"></span>
<span id="cb5-13"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">In</span> <span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">[</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">2</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">]</span>: import torch</span>
<span id="cb5-14"></span>
<span id="cb5-15"><span class="ex" style="color: null;
background-color: null;
font-style: inherit;">In</span> <span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">[</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">3</span><span class="pp" style="color: #AD0000;
background-color: null;
font-style: inherit;">]</span>: import transformers</span></code></pre></div>


</section>
</section>

 ]]></description>
  <category>bioinformatics</category>
  <category>Linux</category>
  <guid>https://shixiangwang.github.io/posts/2025-07-29-module-and-mamba/</guid>
  <pubDate>Mon, 28 Jul 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>R 并行时怎么输出消息</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-07-18-echo-in-shell-for-r-parallel/</link>
  <description><![CDATA[ 





<p>并行计算可以加快一些耗时流程的分析，但 R 如果调用如 <code>mclapply()</code> 等进行并行计算， 无法输出调用函数内部的打印信息，这里有一个小技巧，记录一下。</p>
<p>构建一个新的消息函数，在调用函数内部进行使用，用来打印提示信息。</p>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#' Function which prints a message using shell echo; useful for printing messages from inside mclapply when running in Rstudio</span></span>
<span id="cb1-2">message_parallel <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(...){</span>
<span id="cb1-3">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">system</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sprintf</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'echo "</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">%s</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\n</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"'</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(..., <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">collapse=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>)))</span>
<span id="cb1-4">}</span></code></pre></div>
<blockquote class="blockquote">
<p>这里多个 <code>\n</code> 可根据情况进行去除。</p>
</blockquote>
<section id="mcprogress" class="level3">
<h3 class="anchored" data-anchor-id="mcprogress">mcprogress</h3>
<p>找到一个包<a href="https://github.com/myles-lewis/mcprogress">mcprogress</a>可以直接解决这个问题。</p>
<div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(mcprogress)</span>
<span id="cb2-2"></span>
<span id="cb2-3"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># toy example</span></span>
<span id="cb2-4">res <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">pmclapply</span>(letters[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>], <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(i) {</span>
<span id="cb2-5">                 <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Sys.sleep</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">runif</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>)</span>
<span id="cb2-6">                 <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setNames</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(i, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>))</span>
<span id="cb2-7">                 }, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mc.cores =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">title =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Working"</span>)</span></code></pre></div>
<p>最核心的输出技术还是和上面的函数是相同的。</p>
<hr>
<blockquote class="blockquote">
<p>参考：<a href="https://stackoverflow.com/questions/17345837/printing-from-mclapply-in-r-studio" class="uri">https://stackoverflow.com/questions/17345837/printing-from-mclapply-in-r-studio</a></p>
</blockquote>


</section>

 ]]></description>
  <category>R</category>
  <guid>https://shixiangwang.github.io/posts/2025-07-18-echo-in-shell-for-r-parallel/</guid>
  <pubDate>Thu, 17 Jul 2025 16:00:00 GMT</pubDate>
</item>
<item>
  <title>用来测试端口 work 的Demo app</title>
  <dc:creator>Shixiang Wang</dc:creator>
  <link>https://shixiangwang.github.io/posts/2025-07-09-python-web-demo-app/</link>
  <description><![CDATA[ 





<p>Python 自带就能 run，方便测试端口和映射是否能 work。</p>
<div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> http.server</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> socketserver</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> argparse</span>
<span id="cb1-4"></span>
<span id="cb1-5"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> DemoHandler(http.server.SimpleHTTPRequestHandler):</span>
<span id="cb1-6">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> do_GET(<span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>):</span>
<span id="cb1-7">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.path <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'/'</span>:</span>
<span id="cb1-8">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.send_response(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>)</span>
<span id="cb1-9">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.send_header(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Content-type'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'text/html'</span>)</span>
<span id="cb1-10">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.end_headers()</span>
<span id="cb1-11">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.wfile.write(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">b'Hello, World! This is a demo app.'</span>)</span>
<span id="cb1-12">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">elif</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.path <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'/about'</span>:</span>
<span id="cb1-13">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.send_response(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">200</span>)</span>
<span id="cb1-14">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.send_header(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Content-type'</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'text/html'</span>)</span>
<span id="cb1-15">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.end_headers()</span>
<span id="cb1-16">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">self</span>.wfile.write(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">b'This is a simple demo application.'</span>)</span>
<span id="cb1-17">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span>:</span>
<span id="cb1-18">            <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">super</span>().do_GET()</span>
<span id="cb1-19"></span>
<span id="cb1-20"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> run(port):</span>
<span id="cb1-21">    <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">with</span> socketserver.TCPServer((<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">""</span>, port), DemoHandler) <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> httpd:</span>
<span id="cb1-22">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">print</span>(<span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">f"Serving at port </span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">{</span>port<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">}</span><span class="ss" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span>)</span>
<span id="cb1-23">        httpd.serve_forever()</span>
<span id="cb1-24"></span>
<span id="cb1-25"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> main():</span>
<span id="cb1-26">    parser <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> argparse.ArgumentParser(description<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Run the demo app on a specified port.'</span>)</span>
<span id="cb1-27">    parser.add_argument(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'--port'</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">type</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="bu" style="color: null;
background-color: null;
font-style: inherit;">int</span>, default<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8000</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">help</span><span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'Port to run the server on'</span>)</span>
<span id="cb1-28">    args <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> parser.parse_args()</span>
<span id="cb1-29">    run(args.port)</span>
<span id="cb1-30"></span>
<span id="cb1-31"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">__name__</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'__main__'</span>:</span>
<span id="cb1-32">    main()</span></code></pre></div>



 ]]></description>
  <category>Python</category>
  <guid>https://shixiangwang.github.io/posts/2025-07-09-python-web-demo-app/</guid>
  <pubDate>Tue, 08 Jul 2025 16:00:00 GMT</pubDate>
</item>
</channel>
</rss>
