Xinye Tao | Blog - Collection - Résumé | RSS
# Created: 2020-12-30; Modified: 2021-06-26
# echo rule.vim
highlight Group ctermbg=green guibg=green
call matchadd("Group", "foo")
# vim text
:so rule.vim
delete some files
use sudo lsof +L1
to kill process referencing those files
use tune2fs -m <root-reserved-percentage> <device>
to grab more space from root
python2 -m SimpleHTTPServer <port>
python3 -m http.server
void initialize(size_t n, size_t m, double A[n][m]);
Pros: hide implementations (declare XXImpl
), circular dependence, faster compilation
Cons: can’t use alias, potential inheritance is elided, delete an incomplete class is UB
f(std::shared_ptr(new A()), g())
is risky if g()
can be interleaved between object allocation and shared_ptr
initialization.
This is explicitly prohibited after C++17 (StackOverflow)
_
variables are dropped immediatelyI have a process table and I want to grep it for the phrase “banana”:
ps auxww | grep banana
root 87 Jun21 0:26.78 /System/Library/CoreServices/FruitProcessor --core=banana
mikec 456 450PM 0:00.00 grep banana
Argh! It also greps for the grep for banana! Annoying!
Well, I’m sure there’s pgrep or some clever thing, but my coworker showed me this and it took me a few minutes to realize how it works:
ps auxww | grep [b]anana
root 87 Jun21 0:26.78 /System/Library/CoreServices/FruitProcessor --core=banana
Doc Brown spoke to me: “You’re just not thinking fourth dimensionally!” Like Marty, I have a real problem with that. But don’t you see: [b]anana matches banana but it doesn’t match ‘grep [b]anana’ as a raw string. And so I get only the process I wanted!
Fields are procedural texts that are automatically generated based on the context. Take PAGE
as an example, it is a field representing current page number. You can insert it via Insert > Parts > Field > Page
, or manually type in the script { PAGE }
(the braces are inserted using Ctrl+F9
, need to right click Update Field
to generate text). A more completed script would be like { IF { = MOD( {PAGE}, 2 ) } = 0 "{ PAGE } (even)" "{ PAGE } (odd)" }
.
(How to control the page numbering in a Word document, List of field codes in Word)