A Journal Through My Activities, Thoughts, and Notes
只要好好爱自己,想玩就去玩,想学去就去学,把自己的时间有效的利用好,就不仅仅会产出成果,而且会产出魅力。#网摘
把时间用在你最终不会引以为豪的东西上面,是一件可怕的事情,浪费了你在地球上的短暂旅程。

#网摘
#书摘 #费曼语录

米歇尔这样写道:我记得我从我父亲那里得到了很多建议:思考一个数学问题,看看你的答案是否有道理。与人交流,要努力直接而诚实。要友好而和气。要明白生活是一次令人兴奋的探险。找到某种你喜欢的事情去做。事事要卖力。永远,永远记住你的感觉和幽默!我不总是能嘲笑我自己,但这是我父亲擅长的事。
#grep #tips

## Basic Regular Expressions (BRE)

Basic Regular Expressions are the default regular expression syntax used by grep when no special options are provided. BRE uses a more limited set of metacharacters compared to Extended Regular Expressions (ERE).

Some key points about BRE:

- Metacharacters like +, ?, |, (, ) are treated as literal characters and need to be escaped with a backslash (\) to use their special meaning.

- The $$ and $$ constructs are used for grouping in BRE, instead of just ( and ) as in ERE.

- Alternation is done using \| instead of just |.

- Repetition operators like * and \{n,m\} are used to match zero or more and ranges of repetitions respectively.

For example, to match lines containing either "cat" or "dog" using BRE:

grep 'cat\|dog' filename


And to match lines with 3 to 6 digits:

grep '\([0-9]\{3,6\}\)' filename


The backslashes are necessary to use the grouping and repetition metacharacters in BRE syntax.

So in summary, BRE provides a more limited set of regex features compared to ERE, but is still very powerful for common text matching tasks. The main difference is the need to escape certain metacharacters in BRE.

One thing I would to mention here is that most metacharacters in Basic Regular Expressions (BRE) need to be escaped, but the * character does not. This might seem inconsistent, but it's due to historical reasons and the way BRE was designed.

### Historical Context

In the early days of Unix, the grep command was developed, and it used BRE as its default syntax. At that time, the * character was already a special character in many programming languages and shell scripts, often used for wildcard matching. To avoid conflicts and make BRE more intuitive for users familiar with shell globbing, the designers of grep decided to treat the * character as a special character without needing an escape.

### Why Not Escape *?

Escaping every special character would make BRE more verbose and less readable, especially for simple patterns. By treating * as a special character without an escape, it simplifies common tasks like matching any number of characters (including zero) before or after another character.

### Example

For instance, to match any number of characters before or after a specific string, you can use:

grep 'pattern*' filename


This will match any line containing "pattern" followed by zero or more characters.

### Summary

While most metacharacters in BRE require escaping, the * character is an exception due to its historical significance and the desire to keep BRE syntax simple and intuitive. This makes it easier for users to learn and use basic regular expressions without needing to worry about escaping every special character.
#网友语录

很多人看到国足踢日本零比七惨败,就想与之切割?其实我们就是国足,国足就是我们,国足的问题就是我们的问题,我们的问题就是国足的问题……

中华民族是一个勤于反省但“这个我们可改变不了”的民族。
#网友语录 #jessie

Some tests just make sure the happy path works, but good tests make sure the failure cases fail in the way you expect AND that any engineer who comes into the codebase after you will not fuck up your functionality with zero context of it because if they do, tests will fail.
#读完了

读完了《费曼手札—不休止的鼓声》。读费曼的信真是一种享受。By the way, 他真是写拒绝信的高手,而且绝对不会让被拒绝的人难过!
#网友语录
说起来我在澳洲的第一个困惑经历就来自这方面。

那天老师问:在中国,你生病了是去医院还是去看医生。

我心里想:这不是一回事吗?
老师心里想:看起来她没有听懂我的问题,我换个说法试试。
😂

解释:在澳洲和新西兰,看医生是指看社区诊所的全科医生,要先预约,要付诊费,但等待时间短。去医院一般是去急诊。比如全科医生已经下班了,这时候就要去医院。医院分公立和私立。公立不要钱,但通常要排队排很久,非紧急病情排几个小时很正常。还有一种是24hours诊所,非工签,非PR,非公民有紧急情况,一般只能去24Hours诊所,收费相对贵(以基督城为例,普通诊所$54一次,但24Hours要$170一次)。
前几天婉拒了一个机会,因为问过了自己的内心,并不想更换赛道,虽然那个赛道我很喜欢玩。我更满足现在的生活,担心以那个方向为业会挤掉我的业余项目,也担心会毁掉我对它本来的兴趣。

年岁渐长就会变得保守?并不。我问过自己的内心了,就是不想要。
#网友语录 #非洲

1880 年代后,欧洲列强加速了对非洲大陆的瓜分,几乎将整个非洲划分完毕。只有埃塞俄比亚 Ethiopia 和利比里亚 Liberia 成功保持了独立。埃塞俄比亚以其强大的军事实力和坚强的民族意识抵抗了意大利的侵略,地形险峻和复杂的气候也阻碍了外军的入侵。埃塞俄比亚的地图离远了乍一看像是临海,但其实一点都没有,它是全球人口最多的内陆国家,有一亿人口。早期基督教从公元 1 世纪开始就已经在埃塞俄比亚传播了,现在国民大多数信仰基督教。埃塞俄比亚还是咖啡的原产地。利比里亚创立的初衷是为被解放的黑人提供一个新的定居地,受到了美国的庇护,得以避免被欧洲列强吞并,但其独立地位仍依赖于美国的保护,因为其国力相对较弱。Liberia 得名于自由 liberty 和解放 liberation,国旗和宪法仿效美国,首都蒙罗维亚 Monrovia 纪念的是美国总统 James Monroe。利比里亚的官方语言是英语,我好几次在博洛尼亚搭讪到说英语的非洲人都是利比里亚来的。
#grep #tips
The -o option in grep stands for "only matching." When this option is used, grep will print only the parts of the lines that match the specified pattern, rather than the entire line. This is particularly useful when you want to extract specific substrings from lines of text.

The -E option in grep enables the use of Extended Regular Expressions (ERE) in the pattern. This allows for more powerful and flexible pattern matching compared to basic regular expressions (BRE), which is the default behavior of grep.

### Key Differences with Extended Regular Expressions

When using -E, you can utilize additional metacharacters and constructs that are not available in basic regular expressions. Here are some of the key features of ERE:

1. Metacharacters: In ERE, the following metacharacters are treated as special without needing to be escaped:
- + : Matches one or more occurrences of the preceding element.
- ? : Matches zero or one occurrence of the preceding element.
- | : Acts as a logical OR between expressions.
- () : Groups patterns for applying quantifiers or for alternation.

2. Example Usage:
- To match either "cat" or "dog", you can use:
     grep -E "cat|dog" filename
     


- To match one or more digits, you can use:
     grep -E "[0-9]+"
     


3. Combining with Other Options: You can combine -E with other options like -i for case insensitivity or -o to print only the matching parts:
   grep -Eio "cat|dog" filename
把nginx部分挪出来整了一个单独的仓库。responsive-image-server
#macos #rustdesk
For people experiencing this problem, if you have SSH access to the mac in question, the caffeinate command can be used to wake the machine and allow RustDesk connectivity; e.g. caffeinate -u -t 2.
#网友语录 #recipe
发明用电饭锅煮意面的这位网友,我崇拜你。真的,凭什么意面就非得用水煮开了才能调味啊,它凭什么就不能像做焖饭一样直接和蔬菜、芝士、熟肉、意面酱和一点儿水自己组成意面?就这种圆筒的螺旋的意面,它多么适合做成焖面啊,我甚至想搞点扁豆和肉丝来焖它。亲测可行,方便省事儿。

Reference: https://mastodon.social/@inklingsdaily/113069324432944325
在mastodon碰到了我超喜欢的饭否网友猪小宝!虽然他可能都不知道我,甚至他有可能也不是那个猪小宝,但我心头的狂喜仍是难以表达!这不就是失落许久的好友突然有了音讯!
#如月中天 #网友语录
狗尾巴草是单子叶植物,竟然是小米的祖先!
#网友语录
加拿大小孩闹,群众烦不烦?烦得要命。别管孩子多大,群众不吭声,没人人觉得父母不管,该死。因为 you don't know what's going on with the kid.并不是每一个有问题的孩子都是可以看出来的。一般设定是父母有尽力,但是,就是有无能为力的时候。走开,戴上耳机,特别热心的过去问问能不能帮忙,或者安慰一下父母。贵国跟加拿大,有个最最基础的区别。加拿大从人好的方面看待一件事,贵国从人的恶劣方面看待一件事,他也没办法,和他就是故意的。不同的是,在加拿大“他就是故意的”到一定程度,会有警察来收拾他。所以,你且认为他也是没办法好了。
#书摘
一个准备好的心灵,随时可以吸收知识:但同样的心灵,如果自行设定“我是学不会的”,则也固执得无法突破和穿透。在我的授课经验里,当然经常必须克服学生的这种心态。我一直以为自己没有这种毛病,已经免疫了,现在终于明白无法身免。到了50多岁,居然还能从教学大师那里学到一些新东西,实在是一件很开心的事。原本我以为自己永远无法了解这件事的,但是你对我解释了那是什么,而在解说之前并没有先告诉我,你现在要解释的是什么东西。我的心灵没有设防,因此没有抗拒你传达进来的东西。我以后会记得这个高明的手法,在教学的时候用上去。你并不是有意如此,不过若是学生存心排斥学习某个主题时,这是一个非常有效的穿透技巧。
Back to Top