Homebrew Unknown command services

macOS运行brew services报错 …

➜  ~ brew services start jenkins-lts
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
error: could not lock config file /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services/.git/config: No such file or directory
fatal: could not set 'core.repositoryformatversion' to '0'
Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-services /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services --origin=origin --template= --config core.fsmonitor=false` exited with 128.
Error: Failure while executing; `/usr/local/bin/brew tap homebrew/services` exited with 1.
阅读更多

Not authorized on admin to execute command

NextJS使用mongoose连接数据库的时候报错 …

MongoServerError: Authentication failed.
at Connection.onMessage (/Users/net.cctv3.i/chnqoo-recollections-service/node_modules/mongodb/lib/cmap/connection.js:205:26)
at MessageStream.<anonymous> (/Users/net.cctv3.i/chnqoo-recollections-service/node_modules/mongodb/lib/cmap/connection.js:64:60)
at MessageStream.emit (node:events:518:28)
at processIncomingData (/Users/net.cctv3.i/chnqoo-recollections-service/node_modules/mongodb/lib/cmap/message_stream.js:117:16)
at MessageStream._write (/Users/net.cctv3.i/chnqoo-recollections-service/node_modules/mongodb/lib/cmap/message_stream.js:33:9)
at writeOrBuffer (node:internal/streams/writable:564:12)
at _write (node:internal/streams/writable:493:10)
at Writable.write (node:internal/streams/writable:502:10)
at Socket.ondata (node:internal/streams/readable:1007:22)
at Socket.emit (node:events:518:28)
at addChunk (node:internal/streams/readable:559:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
at Readable.push (node:internal/streams/readable:390:5)
at TCP.onStreamRead (node:internal/stream_base_commons:190:23)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
ok: 0,
code: 18,
codeName: 'AuthenticationFailed',
connectionGeneration: 0,
[Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' }
}
阅读更多

MongoDB 设置远程连接

修改配置文件mongod.conf

Linux配置文件路径,/etc/mongod.conf

net:
port: 27017
- bindIp: 127.0.0.1
+ bindIp: 0.0.0.0

# 密码登录
security:
authorization: enabled

创建用户

> use admin
switched to db admin
> db.createUser({
user: '??????',
pwd: '123456',
roles: [{role: 'userAdminAnyDatabase', db: 'admin'}],
});
阅读更多

Not authorized on admin to execute command

MongoDB 使用账号和密码登录,操作数据库的时候报错,

10:07:12 PM	Error: Failed to refresh 'Collections'. ListCollections failed: { ok: 0.0, errmsg: "not authorized on admin to execute command { listCollections: 1, filter: {}, cursor: {}, $readPreference: { mode: "secondaryPreferred" }, $db: "admin" }", code: 13, codeName: "Unauthorized" }
阅读更多

react-native-config 配置多包名&多环境 APKs 共存

以前都是准备几台不同的 android 手机安装不同环境的包,如果想一个手机安装不同环境的包,只能删了重新打然后重新安装。
解决问题的根本原因是,构建不同环境的包,假设我有三个环境

- Staging -> .env.Staging -> com.duolegamehelper.staging
- Alpha -> .env.alpha -> com.duolegamehelper.alpha
- Production -> .env.production -> com.duolegamehelper.production

那么我就打包的时候,通过不同的.env配置文件,动态的把包名和 APP 的名字打进去。
研究了半天,其实react-native-config是可以解决这个问题的,只不过需要修改打包的gradle脚本。

阅读更多

JavaScript 破解刘谦魔术

好运留下来,烦恼丢出去 …

这玩意儿说白了就是循环操作数组,但是注意delete array[0]是不会改变数组长度的,只有array.splice(0, 1)才会改变数组长度 …

随便四张牌[DACB]
对折完[DACBDACB]
自己的名字张数,放后面[CBDACBDA]
顶部三张牌插入中间[ACBDCBDA]
第一张牌A拿起来,放到屁股后面[CBDCBDA]
南方人/北方人,拿牌插中间[DCBCBDA]
男生扔一张[CBCBDA]
见[BCBDAC]
证[CBDACB]
奇[BDACBC]
迹[DACBCB]
的[ACBCBD]
时[CBCBDA]
刻[BCBDAC]
好运留下来,烦恼丢出去[BDACB]
好运留下来,烦恼丢出去[ACBB]
好运留下来,烦恼丢出去[BBA]
好运留下来,烦恼丢出去[AB]
好运留下来,烦恼丢出去[A]
剩了一张了 A
阅读更多