“给同学们的建议”

今天翻iCloud老相册时,找到了大四在T大的某张PPT截图,照片的时间戳是2014年9月21日的晚上7点55,我早已不记得这是哪门课或者是哪门讲座,但是从相片的前后文来看,大概是推研时的介绍会所说的吧。 这段话听上去像是“毒鸡汤”,但我在翻看到这张相片时仍不免回忆,自己从读研到毕业工作后的这几年,是否做到了这几点。扪心自问,我似乎并没有做到这些看上去很明显应该做到的事情,很多时候因小失大钻牛角尖,只是感动自己罢了。 劝自己不沮丧,诫自己努力改正并持续努力。 大家共勉。 给同学们的建议(14个字) 从更长远的眼光看待(包括读研、就业与求学等的)各种关系;弃燕雀之小志,慕鸿鹄而高翔。 学会用辩证的方法分析一个决策行为的得失利弊 学会调研,消除由于自身懒惰而导致的信息不全,降低决策中的不确定性;学会根据主客观条件的变化,及时、主动地调整决策。 学会从别人那里学习、借鉴正反两个方面的经验教训。 决策中的不确定性常常不能完全避免。提高对决策失误的心理承受能力,吃一堑,长一智。 努力争取在人生中避免掉入决策的心理陷阱。

February 5, 2023 · 1 min · ChaosNyaruko

Vim's completion behaviour in insert mode

现象 在使用Vim的补全的时候,可能从其他IDE/编辑器过来的同学可能会对Vim在弹出补全菜单后,Tab和Enter的行为感到不理解,例如经常会直接插进一个制表符或者换行回车,这其实是Vim自己在插入模式下补全功能的特殊设计,至于为什么这么设计,那就得问开发者了:) 原因 以下摘自Vim的帮助文档 :help popupmenu-completion,简单来说就是Vim的插入模式处于补全状态时,其实有3个状态,不同状态下Enter的功能表现是不一样的,而Tab在Vim补全的上下文和Space几乎是一样的,就是插入对应的空格/制表符 There are three states: A complete match has been inserted, e.g., after using CTRL-N or CTRL-P. A cursor key has been used to select another match. The match was not inserted then, only the entry in the popup menu is highlighted. Only part of a match has been inserted and characters were typed or the backspace key was used. The list of matches was then adjusted for what is in front of the cursor. In all three states these can be used: CTRL-Y Yes: Accept the currently selected match and stop completion. CTRL-E End completion, go back to what was there before selecting a match (what was typed or longest common string). Select a match several entries back, but don’t insert it. Select a match several entries further, but don’t insert it. Select the previous match, as if CTRL-P was used, but don’t insert it. Select the next match, as if CTRL-N was used, but don’t insert it. or Stop completion without changing the match and insert the typed character. ...

February 1, 2023 · 2 min · ChaosNyaruko

Rob Pike's 5 Rules of Programming

Rob Pike’s 5 Rules of Programming Rule 1. You can’t tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don’t try to second guess and put in a speed hack until you’ve proven that’s where the bottleneck is. Rule 2. Measure. Don’t tune for speed until you’ve measured, and even then don’t unless one part of the code overwhelms the rest. Rule 3. Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don’t get fancy. (Even if n does get big, use Rule 2 first.) Rule 4. Fancy algorithms are buggier than simple ones, and they’re much harder to implement. Use simple algorithms as well as simple data structures. Rule 5. Data dominates. If you’ve chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming. Pike’s rules 1 and 2 restate Tony Hoare’s famous maxim “Premature optimization is the root of all evil.” Ken Thompson rephrased Pike’s rules 3 and 4 as “When in doubt, use brute force.”. Rules 3 and 4 are instances of the design philosophy KISS. Rule 5 was previously stated by Fred Brooks in The Mythical Man-Month. Rule 5 is often shortened to “write stupid code that uses smart objects”.

January 20, 2023 · 2 min · ChaosNyaruko

今天摸鱼水段子时,在/r/ProgrammerHumor/上发现一个有意思的现象 熟悉Python的同学可能都踩过坑,但我确实是第一次知道这个现象,于是我在本地试了一下,发现确实如此,于是我求助于谷歌,并最终在Python的官方文档里找到了解释 Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input. For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus ndigits; if two multiples are equally close, rounding is done toward the even choice (so, for example, both round(0.5) and round(-0.5) are 0, and round(1.5) is 2). Any integer value is valid for ndigits (positive, zero, or negative). The return value is an integer if ndigits is omitted or None. Otherwise, the return value has the same type as number. ...

January 3, 2023 · 1 min · ChaosNyaruko

Get Server A basic VPS is enough for personal usage. Nginx Setup apt install nginx main directories and files: /etc/nginx/sites-available /etc/nginx/sites-enabled(typically symbolic links for “available”) /etc/nginx/nginx.conf /var/log/nginx/access.log /var/log/nginx/error.log Get HTTPS Cert Support Using HTTPS should be modern and more secure. https://snapcraft.io/docs/installing-snap-on-debian https://certbot.eff.org/instructions?ws=nginx&os=debianbuster We use certbot to get https support for your website, and renew automatically. Debian10/11 operation example: apt install snapd snap install core snap install hello-world snap refresh core snap install --classic certbot ln -s /snap/bin/certbot /usr/bin/certbot certbot --nginx / certbot certonly --nginx certbot renew --dry-run The job should be in: ...

December 16, 2022 · 1 min · ChaosNyaruko