From 9d7184b4ef8be81a9c6b7c7c5f21fff94e0ea23a Mon Sep 17 00:00:00 2001
From: muqiuhan baby is an OCaml library that offers several implementations of balanced binary search trees. [ANN] Preview of Stripe client and mock server - DkStdRestApis. [ANN] CAISAR release 2.0, a platform for characterizing AI safety and robustness. llama: A library for building software-defined modular synthesizers in a declarative style. baby is an OCaml library that offers several implementations of balanced binary search trees. [ANN] Preview of Stripe client and mock server - DkStdRestApis. [ANN] CAISAR release 2.0, a platform for characterizing AI safety and robustness. TDD 和 DDD 并不冲突,实际上它们可以互补。TDD 可以帮助确保代码的正确性和可靠性,而 DDD 可以确保系统与业务需求紧密结合。在进行 TDD 时,可以使用 DDD 的领域模型和 Ubiquitous Language 来编写测试用例,确保测试覆盖了业务需求。在进行 DDD 时,可以使用 TDD 来驱动实现,确保每个领域模型的实现。 It’s hard to miss things when you don’t know different things exist The first problem is, and personally, I believe it’s the biggest JavaScript problem ever: we don’t know what can throw an error. From a JavaScript error perspective, it’s the same as the following: JavaScript doesn’t know; JavaScript doesn’t care. You should know. Second thing, this is perfectly viable code: No errors, no linters, even though this can break your app. Right now, in my head, I can hear, “What’s the problem, just use try/catch everywhere.” Here comes the third problem: we don’t know which one is thrown. Of course, we can somehow guess by the error message, but what about bigger services/functions with many places where errors can happen? Are you sure you are handling all of them properly with one try/catch? The most verbose of the three shown here and, ironically, the best one. So, first of all, Rust handles the errors using its amazing enums (they are not the same as TypeScript enums!). Without going into detail, what is important here is that it uses an enum called The summary here is that Rust always know where there might be an error. And it force you to deal with it right where it appears (mostly). No hidden ones, no guessing, no breaking app with a surprise face. And this approach is just better. By A MILE. We cannot make TypeScript errors work like the Rust. The limiting factor here is the language itself; it doesn’t have the proper tools to do that. But what we can do is try to make it similar. And make it simple: we do need a few try/catches. The good thing is we only need about two, not 100,000: This is just a wrapper with our New solution is longer, but it performs better because of the following reasons: 本快速入门文档参照 Turborepo 2.x 官方文档: https://turbo.build/repo/docs It’s hard to miss things when you don’t know different things exist The first problem is, and personally, I believe it’s the biggest JavaScript problem ever: we don’t know what can throw an error. From a JavaScript error perspective, it’s the same as the following: JavaScript doesn’t know; JavaScript doesn’t care. You should know. Second thing, this is perfectly viable code: No errors, no linters, even though this can break your app. Right now, in my head, I can hear, “What’s the problem, just use try/catch everywhere.” Here comes the third problem: we don’t know which one is thrown. Of course, we can somehow guess by the error message, but what about bigger services/functions with many places where errors can happen? Are you sure you are handling all of them properly with one try/catch? The most verbose of the three shown here and, ironically, the best one. So, first of all, Rust handles the errors using its amazing enums (they are not the same as TypeScript enums!). Without going into detail, what is important here is that it uses an enum called The summary here is that Rust always know where there might be an error. And it force you to deal with it right where it appears (mostly). No hidden ones, no guessing, no breaking app with a surprise face. And this approach is just better. By A MILE. We cannot make TypeScript errors work like the Rust. The limiting factor here is the language itself; it doesn’t have the proper tools to do that. But what we can do is try to make it similar. And make it simple: we do need a few try/catches. The good thing is we only need about two, not 100,000: This is just a wrapper with our New solution is longer, but it performs better because of the following reasons: 这世上也不是所有事都算得准的。 云仰望着太阳,羡慕他的炙热,或许太阳也在仰望着云,渴求他的停留。 地球距离太阳1.5亿公里,如无意外,两者此生不会相遇,但从此以后,我与世间美好再也不会分离。
+
+新消息
+
+有价值的文章
+
+dune build.有趣的项目
+
]]>
-
-新消息
-
-有价值的文章
-
-dune build.有趣的项目
-
]]>
try {
let data = “Hello”;
} catch (err) {
console.error(err);
}const request = { name: “test”, value: 2n };
const body = JSON.stringify(request);
const response = await fetch("https://example.com", {
method: “POST”,
body,
});
if (!response.ok) {
return;
}
+let greeting_file_result = File::open(“hello.txt”);
let greeting_file = match greeting_file_result {
Ok(file) => file,
Err(error) => panic!("Problem opening the file: {:?}", error),
};Result with two variants: Ok and Err. As you might guess, Ok holds a value and Err holds…surprise, an error :D.export type Safe<T> =
| {
success: true;
data: T;
}
| {
success: false;
error: string;
};export function safe<T>(promise: Promise<T>, err?: string): Promise<Safe<T>>;
export function safe<T>(func: () => T, err?: string): Safe<T>;
export function safe<T>(
promiseOrFunc: Promise<T> | (() => T),
err?: string,
): Promise<Safe<T>> | Safe<T> {
if (promiseOrFunc instanceof Promise) {
return safeAsync(promiseOrFunc, err);
}
return safeSync(promiseOrFunc, err);
}
async function safeAsync<T>(
promise: Promise<T>,
err?: string
): Promise<Safe<T>> {
try {
const data = await promise;
return { data, success: true };
} catch (e) {
console.error(e);
if (err !== undefined) {
return { success: false, error: err };
}
if (e instanceof Error) {
return { success: false, error: e.message };
}
return { success: false, error: "Something went wrong" };
}
}
function safeSync<T>(
func: () => T,
err?: string
): Safe<T> {
try {
const data = func();
return { data, success: true };
} catch (e) {
console.error(e);
if (err !== undefined) {
return { success: false, error: err };
}
if (e instanceof Error) {
return { success: false, error: e.message };
}
return { success: false, error: "Something went wrong" };
}
}Safe type as the return one. But sometimes simple things are all you need. Let’s combine them with the example from above.const request = { name: “test”, value: 2n };
const body = safe(
() => JSON.stringify(request),
“Failed to serialize request”,
);
if (!body.success) {
// handle error (body.error)
return;
}
const response = await safe(
fetch("https://example.com", {
method: “POST”,
body: body.data,
}),
);
if (!response.success) {
// handle error (response.error)
return;
}
if (!response.data.ok) {
// handle network error
return;
}
// handle response (body.data)
+
]]>
-]]>
-
最后一次编辑:二〇二四年九月二十七日下午六点〇七分try {
let data = “Hello”;
} catch (err) {
console.error(err);
}const request = { name: “test”, value: 2n };
const body = JSON.stringify(request);
const response = await fetch("https://example.com", {
method: “POST”,
body,
});
if (!response.ok) {
return;
}
-let greeting_file_result = File::open(“hello.txt”);
let greeting_file = match greeting_file_result {
Ok(file) => file,
Err(error) => panic!("Problem opening the file: {:?}", error),
};Result with two variants: Ok and Err. As you might guess, Ok holds a value and Err holds…surprise, an error :D.export type Safe<T> =
| {
success: true;
data: T;
}
| {
success: false;
error: string;
};export function safe<T>(promise: Promise<T>, err?: string): Promise<Safe<T>>;
export function safe<T>(func: () => T, err?: string): Safe<T>;
export function safe<T>(
promiseOrFunc: Promise<T> | (() => T),
err?: string,
): Promise<Safe<T>> | Safe<T> {
if (promiseOrFunc instanceof Promise) {
return safeAsync(promiseOrFunc, err);
}
return safeSync(promiseOrFunc, err);
}
async function safeAsync<T>(
promise: Promise<T>,
err?: string
): Promise<Safe<T>> {
try {
const data = await promise;
return { data, success: true };
} catch (e) {
console.error(e);
if (err !== undefined) {
return { success: false, error: err };
}
if (e instanceof Error) {
return { success: false, error: e.message };
}
return { success: false, error: "Something went wrong" };
}
}
function safeSync<T>(
func: () => T,
err?: string
): Safe<T> {
try {
const data = func();
return { data, success: true };
} catch (e) {
console.error(e);
if (err !== undefined) {
return { success: false, error: err };
}
if (e instanceof Error) {
return { success: false, error: e.message };
}
return { success: false, error: "Something went wrong" };
}
}Safe type as the return one. But sometimes simple things are all you need. Let’s combine them with the example from above.const request = { name: “test”, value: 2n };
const body = safe(
() => JSON.stringify(request),
“Failed to serialize request”,
);
if (!body.success) {
// handle error (body.error)
return;
}
const response = await safe(
fetch("https://example.com", {
method: “POST”,
body: body.data,
}),
);
if (!response.success) {
// handle error (response.error)
return;
}
if (!response.data.ok) {
// handle network error
return;
}
// handle response (body.data)
-
]]>
天空泛起一丝鱼肚白,那是每年夏至,凌晨四点多就会早起的日出。
+而身后那栋为我而建的世界上独一无二的小屋子,正通宵达旦地亮着灯火,里面是我的痕迹,我的热爱,我的温暖和祝福。
+身前,我的山林和小狗,正笨拙地试图从自然的馈赠里找到那份属于它们的礼物。
+它们那样爱着我,那样忠诚于我。
+那一刻,我突然就想起了曾经在书上看过的一句很喜欢的话——“世界先爱了我,我不能不爱他.”
+曾经在冬季日出的时候,我见过海岸线浮满碎冰的模样,那是连太阳都会显得寂寥和落寞的冷清。
+可是太阳始终当着太阳,守着一个恒星的职责,不知疲倦地用自己炽热的温度和光芒试图唤醒沉睡的冬日。
+直到终于有一天,有人在冬夜里复苏,爱上了那个比夏天更炽烈的温度,然后海浪成了新娘白色的花环,我成了太阳一生的爱人。
+所以我始终愿意相信,是这个世界先温柔地爱了我。
+哪怕世界给予我的这份爱,在最初的时候,来得并不那么明显,也并不那么浓烈,我也曾因此孤独过,无助过,迷茫过,放弃过。
+可是那份爱最终还是随着冰雪消融,春暖花开,随着夏天剧烈摇晃过后的气泡水,滋滋地冒了出来,连盖上盖子,也没有办法捂住。
+所以我拥有了世界上最好的义无反顾的爱。
+看着前方,轻轻叫了一声:“毛毛”
+狗狗立马回了头,和乍出的日光,和突然转动的风力发电机,和突然被风吹动的山林,同步发生。好像只要我一声令下,这个世界就愿意为我而生动。
+可这世间哪里会在乎茫茫人海中这不值一提的爱
+我们都只不过是平凡世界里平凡生活着的人们,如果非要说有什么不同,那就是我只爱着这个世界而已。
+于是我看着那只大笨狗,看着并没有被虚化成背景的世界,温柔地弯起了唇角:“有句话今天我一直忘记告诉你了。”
+狗狗叼起一根树枝,歪头不解地看着我。
+然后我就在山峰浮现出第一缕阳光时,笑着对这个世界说:“我爱你,会永远爱你,永远最爱你。”
+我爱这个因为有我而变得温柔的世界。
+这将是我与周遭的一切,热爱一生,共度一生的地方。
]]>还是广袤宇宙中的一颗有名有姓的星星,
宇宙、银河、太阳,都不重要。
热爱这个世界,是我成长里最美妙的勇敢事迹。
-]]> -天空泛起一丝鱼肚白,那是每年夏至,凌晨四点多就会早起的日出。
-而身后那栋为我而建的世界上独一无二的小屋子,正通宵达旦地亮着灯火,里面是我的痕迹,我的热爱,我的温暖和祝福。
-身前,我的山林和小狗,正笨拙地试图从自然的馈赠里找到那份属于它们的礼物。
-它们那样爱着我,那样忠诚于我。
-那一刻,我突然就想起了曾经在书上看过的一句很喜欢的话——“世界先爱了我,我不能不爱他.”
-曾经在冬季日出的时候,我见过海岸线浮满碎冰的模样,那是连太阳都会显得寂寥和落寞的冷清。
-可是太阳始终当着太阳,守着一个恒星的职责,不知疲倦地用自己炽热的温度和光芒试图唤醒沉睡的冬日。
-直到终于有一天,有人在冬夜里复苏,爱上了那个比夏天更炽烈的温度,然后海浪成了新娘白色的花环,我成了太阳一生的爱人。
-所以我始终愿意相信,是这个世界先温柔地爱了我。
-哪怕世界给予我的这份爱,在最初的时候,来得并不那么明显,也并不那么浓烈,我也曾因此孤独过,无助过,迷茫过,放弃过。
-可是那份爱最终还是随着冰雪消融,春暖花开,随着夏天剧烈摇晃过后的气泡水,滋滋地冒了出来,连盖上盖子,也没有办法捂住。
-所以我拥有了世界上最好的义无反顾的爱。
-看着前方,轻轻叫了一声:“毛毛”
-狗狗立马回了头,和乍出的日光,和突然转动的风力发电机,和突然被风吹动的山林,同步发生。好像只要我一声令下,这个世界就愿意为我而生动。
-可这世间哪里会在乎茫茫人海中这不值一提的爱
-我们都只不过是平凡世界里平凡生活着的人们,如果非要说有什么不同,那就是我只爱着这个世界而已。
-于是我看着那只大笨狗,看着并没有被虚化成背景的世界,温柔地弯起了唇角:“有句话今天我一直忘记告诉你了。”
-狗狗叼起一根树枝,歪头不解地看着我。
-然后我就在山峰浮现出第一缕阳光时,笑着对这个世界说:“我爱你,会永远爱你,永远最爱你。”
-我爱这个因为有我而变得温柔的世界。
-这将是我与周遭的一切,热爱一生,共度一生的地方。
]]>那露珠消散后去了哪里?它们是因缘聚散吗?
-一个人买菜,做饭,洗衣服,搞卫生,弹琴,睡觉,一个人爬雪山,过沙漠。
我从未因为一个人而悸动,却因为看见朝露凝于叶尖,看见惊雷震碎山月而灵魂震颤不已。
我送走了太多太多人,在病床前伴着动态心电的蜂鸣声祈祷自己亲人的人最终也躺在了病床上。
-楼下就是妇产科,我看见了死亡,也看见了新生,看见老人临终前的眼中儿时门前的溪水倒流,看见婴孩啼哭时眼底星河闪烁,看见生死之幕薄如蝉翼,和众生颠倒梦想处。
-但这些都不影响我等下下班后要去买菜,做饭,洗衣服,搞卫生,弹琴,然后睡觉。
+看见死亡,看见新生,看见朝露凝于叶尖,看见惊雷震碎山月,
+它们是因缘聚散吗?
+那露珠消散后去了哪里?
+此有故彼有,此生故彼灭。
+当晨光加热露珠表面至
这种相变并非整齐划一的队列解散,而是呈现量子隧穿效应——单个水分子以
逃逸的 H2O 分子并非直线升空,而是在空气分子碰撞下进行三维随机游走。
根据爱因斯坦-斯托克斯方程,其扩散系数
水中捞月,伸手时,涟漪碎了三千世界。
+人类的眉睫处有十方虚空,三藏经书不过指月之指,
+看见儿时门前溪水倒流,看见婴孩啼哭时眼底星河闪烁。
+看见生死之幕薄如蝉翼,和众生颠倒梦想处。
+某些水分子可能抵达对流层顶(约
经过
它们的氧原子核内,八个质子正以
诸法从本来,常自寂灭相。
那在这之前呢?
在这之前我刚吃完一碗辣椒炒肉,
香
-- cgit v1.2.3