兰林
兰林
### git 项目配置备忘 **1. 直接利用全局 .gitconfig 的 personal access token** ```ini [remote "origin"] url = https://github.com//.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master ``` **2. 将...
### git 项目 ssh 访问参考 #51 如何科学访问github or github ssh proxy
### 2. shell 导出所有 collection 数据到指定目录 ```shell #!/bin/bash DB_NAME="your_db_name" DB_HOST="your_db_host" DB_USER="your_db_username" DB_PASS="your_db_password" TARGET=$1 MONGODB_URI="mongodb+srv://$DB_USER:$DB_PASS@$DB_HOST/$DB_NAME" COLLECTIONS=$(mongosh $MONGODB_URI --quiet --eval "show collections") for col in $COLLECTIONS; do echo "Exporting $col ..." mongoexport...
### 3. shell 从指定目录导入数据 ```shell #!/bin/bash DB_NAME="your_db_name" DB_HOST="your_db_host" DB_USER="your_db_username" DB_PASS="your_db_password" TARGET=$1 MONGODB_URI="mongodb+srv://$DB_USER:$DB_PASS@$DB_HOST/$DB_NAME" for f in `ls $TARGET`; do if [[ "$f" == *.json ]]; then echo "Importing ${f%.*} ..." mongoimport...
### PHP ```php // 10 characters \mb_strlen('hello 😹🐶😹🐶', 'UTF-8'); ```
### Go ```go // 10 characters len([]rune("hello 😹🐶😹🐶")) ```
### JavaScript ```javascript // 10 characters [...'hello 😹🐶😹🐶'].length; ``` 1. [JavaScript has a Unicode problem](https://mathiasbynens.be/notes/javascript-unicode) 2. [JavaScript 如何正确处理 Unicode 编码问题!](https://segmentfault.com/a/1190000017782406)
MongoDB 查询及索引设计原则 #79
### Rust ```rust use unicode_segmentation::UnicodeSegmentation; // 10 characters "hello 😹🐶😹🐶".graphemes(true).count(); ```
MongoDB Indexing Blog: https://www.mongodb.com/blog/tags/indexing 