当我跑步时,我想删除一个安装在brew抱怨的位置的Python brew doctor
警告: Python安装在/Library/Frameworks/Python.framework中
什么是最好的方法?
以下是更多细节/研究:
来自brew git 网站的消息:
重要提示:如果您选择安装不属于这两者的Python(系统Python或酿造的Python),那么Homebrew团队只能提供有限的支持.
在删除额外的python库之前,我想确保我没有遗漏任何内容. 具体来说,我想删除整个Python.framework,这些文件位于此处./Library/Frameworks/Python.framework/
我在本机上安装了Python 2.7.5,我将使用它 - 位于下面的路径中.(区别在于 - 我相信 - 它放在root/System文件夹而不是root/Library文件夹中.)好的原生位置在这里:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
我已经安装了python 3.x brew install python3
,它放在这里:
==> Summary
/usr/local/Cellar/python3/3.4.0 : 5076 files, 85M, built in 112 seconds
Run Code Online (Sandbox Code Playgroud)
我可以删除这些文件或它们的后果(除了必须重新链接)?
/Library/Frameworks/Python.framework/
以下是从2010年的stackoverflow问题中删除python的步骤以及类似的问题
这种方法仍然合理吗?有什么我应该知道的吗?
我正在尝试使用mongoimports
终端向mongodb添加一个JSON文件,这里:
mongoimport --db my_db --collection my_collection --file /content/2_read.json
Run Code Online (Sandbox Code Playgroud)
我一直在JavaScript execution failed: SyntaxError: Unexpected identifier
通过JSON Lint运行我的JSON:http://jsonlint.com/ ,它说它是有效的JSON.
我不确定什么可能绊倒导入过程?或者如何进一步调查以追捕这个问题?
UPDATE
simple.json
内容命名的json文件{'content' : 'simple'}
但是我仍然使用相同的错误mongoimport
.(我可以从mongo
shell 添加文件就好了.)下面是JSON的示例.
2_read.json
{
"name" : "John",
"tasks" : [
{
"ix" : "1",
"description" : "description of task",
"tags": []
},
{
"ix": "2",
"description" : "description of task",
"tags" : []
}
]
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在玩猫鼬的快速入门指南.
http://mongoosejs.com/docs/index.html
我假设当我使用未在模式中定义的字段保存文档时会抛出错误.相反,它在集合中创建了一个新文档,但没有该字段.(注意:我意识到mongodb本身就是"无模式",因此集合中的每个文档都可以完全不同.)
两个问题
mongoose
处理添加具有不属于模式的字段的文档?它似乎只是忽略它们,如果没有任何字段映射,将只使用ObjectId创建一个空文档.mongoose
即使文档成功保存,如果未添加文档的特定字段,您如何警告您?(问题是 - 我相信 - 很简单,所以我没有添加代码,但如果有人要求我肯定会.)
谢谢.
我想和Raynos一起玩mongo-client.但是,当我添加"mongo-client" : "0.2.1"
到我的package.json
依赖项时,我得到以下内容:
(node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bson/ext/bson.o
SOLINK_MODULE(target) Release/bson.node
SOLINK_MODULE(target) Release/bson.node: Finished
Run Code Online (Sandbox Code Playgroud)
这builderror log
是空的.如果我npm install
再次跑步,我会得到很多unmet dependencies
,例如:
npm WARN unmet dependency /node_modules/mongo-client requires reducible@'Raynos/reducible#v1.0.6' but will load
npm WARN unmet dependency /node_modules/reducible,
Run Code Online (Sandbox Code Playgroud)
现在,我之前没有遇到过这样的错误.GIT上没有报道的问题mongo-client
.所以,我想在高层了解发生了什么以及如何解释错误?
当然,我也用Google搜索了.我想这可能会解决它:
https://github.com/TooTallNate/node-gyp/wiki/Updating-npm's-bundled-node-gyp
但是当我跑步时:
$ sudo npm explore npm -g -- npm install node-gyp
Run Code Online (Sandbox Code Playgroud)
我明白了 TypeError: Bad argument
对下一步的任何见解和指导表示赞赏.
谢谢.
以下架构是正确定义还是writing
需要
writing: [Schema.Types.Mixed]
或 writing: [{}]
?
也就是说,如果你有一个字典数组 - [{},{},{}] - 除非你创建另一个模式并嵌入它,否则不能预定义内部结构.这是对文档的正确解释吗?
http://mongoosejs.com/docs/schematypes.html
var blogSchema = new mongoose.Schema({
title: String,
writing: [{
post: String,
two: Number,
three : Number,
four : String,
five : [{ a: String,
b : String,
c : String,
d: String,
e: { type: Date, default: Date.now },
}]
}],
});
Run Code Online (Sandbox Code Playgroud)
谢谢.
如何快速检查package.json文件是否包含可以更新到更新版本的模块?
例如,快速检查express或nodemailer是否有可用更新?
{
"name": "some_module_name"
, "description": ""
, "version": "0.0.3"
, "dependencies": {
"express": "3.1"
, "nodemailer" : "0.4.0"
}
}
Run Code Online (Sandbox Code Playgroud)
我阅读了常见问题解答,但没有看到任何内容:https: //npmjs.org/doc/faq.html
谢谢.
我正在阅读MongoDB手册.一些例子,围绕关键值引用,例如:db.test.find({"_id" : 5})
和其他人没有,例如:db.test.find({_id : 5})
引用和未引用的版本都有效.但我想知道这里是否有一些细微差别,我不知道或是一个首选的最佳做法?
谢谢.
我正在尝试$pull
从嵌入的数组中删除()一个对象.(使用javascript/node.js驱动程序.)
以下是示例数据,其中一个,两个,三个是级别:
{
one : "All",
one : [
{
name: "People",
two: [
{
three_id: 123,
three: "Jonny",
},
{
three_id: 456,
three: "Bobby",
}
]
},
{
name: "Animals",
two: [
{
three_id: 828,
three: "Cat",
},
{
three_id: 282,
three: "Dog",
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
在这个例子中,我正试图摆脱"鲍比".
如果我愿意,我可以在"三级"成功匹配文档,如下所示:
db.test.find({"one.two.three_id" : 456});
Run Code Online (Sandbox Code Playgroud)
但是,我不知道如何消除该记录update
.以下是一些尝试,其中没有一个工作:
// failed attempts
db.test.update({"one.two.three_id" : 456}, {$pull:{'one.$.two.$.three_id': 456}});
db.test.update({"one.two.three_id" : 456}, {$pull:{'three_id': 456}});
// deletes entire level two "People"
db.test.update({"one.two.three_id" : …
Run Code Online (Sandbox Code Playgroud) 某个对象上的事件和侦听器是否充当该侦听器的"识别对"?或者只是对象上的事件?
在这里阅读node.js文档:http: //nodejs.org/api/events.html#events_emitter_removelistener_event_listener
例如,如果您有两个回调函数,listener_1
并且listener_2
:
var stdin = process.stdin;
stdin.on('data',listener_1);
stdin.on('data',listener_2);
Run Code Online (Sandbox Code Playgroud)
然后你删除了监听器,用:
stdin.removeListener('data',listener_1);
Run Code Online (Sandbox Code Playgroud)
那么,listener_2
还在听吗?
谢谢.
PS.我尝试使用util.inspect
和listeners
方法测试自己,但仍然没有自信我明白这是如何工作的!
下面的代码构建文件夹中文件的字典(关联数组),跳过目录和隐藏(.*)文件.系数是因为在console.log(file_dict)
返回之前显示字典.然而,当我打电话的get_files
功能,从返回的值return file_dict
是 undefined
我很确定这个问题是因为readdir
异步.所以,我需要切换到readdirSync
.但从概念上讲,我不明白为什么异步版本中的返回值未定义.
我错过了什么?
文件explorer.js
var fs = require('fs');
var get_files = function() {
fs.readdir(__dirname + '/content/', function (err, files) {
if (!files.length) {
return console.log(' \033[31m No files to show\033[39m\n');
}
// called for each file walked in the directory
var file_dict = {};
var file_index = 0;
function file(i) {
var filename = files[i];
fs.stat(__dirname + '/' + filename, function (err, stat) {
if (stat.isDirectory() || filename[0] …
Run Code Online (Sandbox Code Playgroud) 你如何使用包含字典的数组?我正在努力将所有post
领域聚集在一起,以便我可以搜索他们的文本.
我的尝试继续无处使用mongo
shell.
User.Blog().find({}).where('post').in(writing).exec(function (err, result) {
//do something with results
}); // doesn't work
Run Code Online (Sandbox Code Playgroud)
schema(编辑:从@JAM评论修复)
var blogSchema = new mongoose.Schema({
group: String,
writing: [{
post: String,
name : Number
}]
});
var Blog = mongoose.model('Blog', blogSchema);
Run Code Online (Sandbox Code Playgroud)
更新:添加json数据和使用mongo shell将数据放入mongodb的命令:
{
group: "Design Writing",
writing: [{
post: "A very very very short post.",
name: 10
}, {
post: "An early morning post about everything.",
name: 11
}]
}
Run Code Online (Sandbox Code Playgroud)
*或者,这里作为一行插入名为的集合中的数据库my_collection
:*
db.my_collection.insert( {group: "Design Writing", writing: …
Run Code Online (Sandbox Code Playgroud) 我喜欢"跳转字典"的概念,其中包含键:值,其中值是函数.不过,我不确定我是否应该喜欢这个概念.
我想替换一个长列表if if-else if
语句.(我应该使用switch
声明吗?)
有没有办法在不使用eval的情况下实现"跳转字典"?(我已经读过这个关于eval 为什么不好的原因: 为什么使用JavaScript eval函数是一个坏主意? )
使用eval的示例
function some_func(arg) { console.log('I am a some func') };
function find_my(arg) { console.log('we are looing for your ' + arg); };
var jump = {
'1' : 'some_func()',
'2' : 'find_my("cat")',
'3' : 'find_my("dog")'
}
eval(jump['3'])
eval(jump['2'])
eval(jump['1'])
Run Code Online (Sandbox Code Playgroud)
谢谢.
node.js ×8
mongodb ×6
mongoose ×3
javascript ×2
brew-doctor ×1
eval ×1
homebrew ×1
listener ×1
macos ×1
mongoimport ×1
npm ×1
python ×1
schema ×1
unix ×1