Docker 部署 Ollama
安装 ollama这里采用 docker 进行 ollama 的部署。部署支持 CPU 也支持 GPU, 详情参考https://hub.docker.com/r/ollama/ollama。这里采用 CPU 的安装模式,安装命令如下docker run -d -v /opt/...
Day 5 – 循环
for 循环 for 循环的基本语法,如下所示 for item in list_of_items: # do something to each item 示例代码 fruits = ['Apple', 'Peach', 'Pear'] for fruit in fruits: print(fruit) # Apple ...
Day 11 – 21点(黑杰克)
游戏介绍 黑杰克(英语:Blackjack),是使用扑克牌玩的赌博游戏。游戏目标是将选手的卡片计数添加到最大而不超过21。纸牌的计数规则:A可作1或11点,2-10作该牌之点数,J、Q、K作10点。 代码实...
ScrollViewReader
Scroll View Reader 让你可以访问一个名为 scrollTo 的函数。通过这个函数,你可以通过自动滚动使滚动视图中的某个视图可见。 介绍 使用 ScrollViewReader 访问 scrollTo 函数,以便以编程方式...
@Transient 宏忽略属性持久化
如果你的模型类有一个或多个存储属性,希望在写入持久化存储时忽略一些属性,可以使用 @Transient 宏进行标注,这样 SwiftData 就不会将它们的值写入磁盘。 默认情况下,SwiftData 会将所有计算...
How to use continuations to convert completion handlers into async functions 如何使用 continuations 将完成处理程序转换为异步函数
Older Swift code uses completion handlers for notifying us when some work has completed, and sooner or later you’re going to have to use it from an async function –&nbs...
How to create a task group and add tasks to it 如何创建任务组并向其添加任务
Swift’s task groups are collections of tasks that work together to produce a single result. Each task inside the group must return the same kind of data, but if you use enum assoc...