2025-06-30
2025-06-26
“The boolean trap” is just one example of how seemingly simple modeling decisions can have unexpected consequences as systems grow. While booleans are perfect for their intended purpose – representing true/false technical states – they often fall short when applied to a domain. By choosing enums and enum sets we create code that is better prepared for the “real world”‘ of the problem domain.
Sometimes it’s better to rethink how we represent the state instead of blindly adding another boolean flag.
https://katafrakt.me/2024/11/09/booleans-are-a-trap
乱语:这位老哥说在领域模型内,使用布尔值不是很好,得用枚举或者是状态机。
2025-06-25
Record a weird behavior about Map data structure in javascript
I found that if a Map‘size is more and more bigger, and it will cause map’s operation more and more slowly, that is weird because I think all kinds of operations about map is constanly and not affected by it’s size as before.
If we wanna actually understand this question, we should real know the data strucure behind Map.
https://leetcode.com/problems/design-spreadsheet/solutions/6884801/record-a-weird-behavior-about-map-data-s-txl7/
乱语:力扣 3484 题题解,速度击败 100%。Map 的 size 越大,对 Map 操作越慢,为啥。
2025-06-24
或许很多人都注意到了,各高校复印店的叔叔阿姨小哥小妹里,有不少长相差不多,口音也类似的人——没错,他们不仅都是湖南人,而且来自同一个地方:湖南省新化县。
2010年的北京高校抽样调查显示,新化人拥有大学里65%的复印店。更夸张的是,不管你在东北、陕西、上海、拉萨还是海口,只要走进街边随便哪家复印店,都有85%的概率碰见一群湖南新化人。
https://zhuanlan.zhihu.com/p/27340132
2025-06-23
想出一个原创一点,不会太难,也不会太简单,考察候选人的平时练习和思维。有一个对象如下:
let obj = {
a:1,
b:{
c: 2
}
}
需要转换成:
<root>
<a>1</a>
<b>
<c>2</c>
</b>
</root>
该怎么实现呢?
标题:想了一个面试题
内容来自曾小乱的blog:https://zengyuxin.com/have-a-new-problem/
2025-06-22
2014年3月19日,小米公司发布红米Note,采用联发科MT6592八核心处理器、5.5英寸 720P IPS屏幕,分标准版与增强版,标准版采用1.4GHz主频CPU、1GB RAM,售价799元;增强版采用1.7GHz主频CPU、2GB RAM,售价999元。根据网络制式不同,红米Note有移动版/联通版两个版本,分别支持TD-SCDMA+GSM及WCDMA+GSM双卡双待。
乱语:这么多年了,红米 note 系列价格依然是这么亲民,搞一部支持雷军把小米汽车价格打下来。
2025-06-21
不知道大家有没有看到过网络上曾经流传过一个帖子,一个女子闲来无事把自己累积了 20 多年的牙结石一点点抠下来的故事。
https://m.dxy.com/article/32421
2025-06-20
There are many great ways we express states and parameters of a component without having to shoehorn them into an archaic system like the class attribute. We have mechanisms today to replace it, we just need to unleash ourselves from our own shackles. Upcoming standards will allow us to express ideas in powerful new ways.
https://www.keithcirkel.co.uk/css-classes-considered-harmful
乱语:这位老哥说我们现在写 css 面临一些问题,这个也不是这些问题的解决方案,那个也不是这些问题的解决方案,最后自己提出了几种方案,他的话已经讲完,有人跟吗?
2025-06-17
震惊!深圳一全球独角兽企业的前端面试题的 5 种解法都泄漏了,其中最快的解法居然是 ai 写的。
2025-06-16
女儿未出嫁,是颗无价之宝;出了嫁,不知怎么就变出许多的不好的毛病来,虽是颗珠子,却没有光彩宝色,是颗死珠了;再老了,更变的不是珠子,竟是鱼眼睛了。分明一个人,怎么变出三样来?
https://www.peopleapp.com/rmharticle/30022696778
乱语:还是宝玉懂女人啊。
2025-06-15
2025-06-13
你知道 csv 是哪几个单词的首字母缩写吗?
Comma-separated values (CSV) is a text file format that uses commas to separate values, and newlines to separate records. A CSV file stores tabular data (numbers and text) in plain text, where each line of the file typically represents one data record. Each record consists of the same number of fields, and these are separated by commas in the CSV file. If the field delimiter itself may appear within a field, fields can be surrounded with quotation marks.
https://en.wikipedia.org/wiki/Comma-separated_values
2025-06-12
为什么 js 里使用了 await 的方法必须定义成 async 的? – 胖茶的回答 – 知乎
https://www.zhihu.com/question/308089255/answer/968251318
async is as much a signal to the JavaScript engine that the function will be executed in this special way, as well as to human code readers that it returns a Promise, not the returned value (unless the returned value was already a promise in the first place, and did not need wrapping).
2025-06-11
DES全称为Data Encryption Standard,即数据加密标准,是一种使用密钥加密的块算法,1977年被美国联邦政府的国家标准局确定为联邦资料处理标准(FIPS),并授权在非密级政府通信中使用,随后该算法在国际上广泛流传开来。
需要注意的是,在某些文献中,作为算法的DES称为数据加密算法(Data Encryption Algorithm,DEA),已与作为标准的DES区分开来。
DES算法就是一个把64位的明文输入块变为64位密文输出块的算法,它所使用的密钥也是64位(其实只使用到了56位,其余8位为奇偶校验位)
DES算法的入口参数有三个:Key、Data、Mode。
> Key(密钥):为7个字节共56位,是DES算法的工作密钥(若说密钥为64位,其指的也是56位的秘钥加上8位奇偶校验位,奇偶校验位为第8,16,24,32,40,48,56,64位)
> Data(数据):为8个字节64位,是要被加密或被解密的数据
> Mode(模式): 为DES的工作方式,有两种:加密或解密。
算法特点:分组比较短、密钥太短、密码生命周期短、运算速度较慢。
https://www.cnblogs.com/luogi/p/15508933.html
2025-06-10
The main advantage of iterator helpers over array methods is that they are lazy, meaning that they only produce the next value when requested. This avoids unnecessary computation and also allows them to be used with infinite iterators. With infinite iterators, find() returns the first satisfying element as soon as it is found. If the callbackFn always returns a falsy value, the method never returns.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Iterator/find
乱语:这就是惰性求值吗?
2025-06-08
可移植文档格式(PDF)是世界领先的页面描述语言, 第一种同样适用于打印和在线使用的格式。
PDF文档现在几乎无处不在于印刷行业, 文档交换以及分页内容的在线分发。 然而,它们被广泛认为是不透明和脆弱的, 即使是技术性质的人也很难理解。
部分原因是缺乏文档;文件格式参考是免费提供的, 但其大小和复杂性要求大多数使用PDF的人 不太可能花费时间。
本书旨在成为一本平易近人的介绍。 它既适合技术专家,也适合那些只想了解一些 PDF格式的人,使用生成或处理PDF文档的工具 为他们的工作提供背景信息。
https://zxyle.github.io/PDF-Explained/preface.html
乱语:推荐一本书 pdf explained
2025-06-06
Many changes, including bug fixes and documentation improvements can be implemented and reviewed via the normal GitHub pull request workflow.
Some changes though are “substantial”, and we ask that these be put through a bit of a design process and produce a consensus among the React core team.
The “RFC” (request for comments) process is intended to provide a consistent and controlled path for new features to enter the project.
https://github.com/reactjs/rfcs
乱语:软件行业的一些思路倒是挺有意思的。
2025-06-03
最近看到了凯撒密码,挺适合编程实现的。比如有一个密文是:PELCGBTENCUL,那他表示的明文是什么呢?
标题:凯撒密码的 js 实现
内容来自曾小乱的blog:https://zengyuxin.com/caesar-cipher-in-javascript/
2025-06-02
看王熙凤这个贾家的 ceo 如何识人辩人。我们总是能判断别人,但很少能看到自己
2025-06-01
My /var/log/btmp file is 1.3 GB in size. I’ve read that the file is “Used to store information about failed login”.
What does this mean for my server? And can I delete this file?
This means people are trying to brute-force your passwords (common on any public-facing server).
It shouldn’t cause any harm to clear out this file.
One way to reduce this is to change the port for SSH from 22 to something arbitrary. For some additional security, DenyHosts can block login attempts after a certain number of failures. I’d highly recommend installing and configuring it.
https://serverfault.com/questions/119299/my-var-log-btmp-file-is-huge-what-should-i-do
乱语:2025 年 05 月 01 日,有人疯狂破解我的服务器,怎么办?