是否可以将项目问题存储在其 git 存储库中?
我知道 git 不支持此功能,问题存储在提供者站点(例如 Bitbucket、Github)中。
我想在 Bitbucket 上开发一个项目作为免费的私有存储库,并在完成后将其开源移至 Github。问题是 Bitbucket 存储库中报告的问题在 Github 存储库中不可用,因为它们存储在 Bitbucket 数据库中。
哪个是最好的解决方案?
我观察到以下Javascript行为:
> Math.pow(4, 2)
16
> Math.pow(4, 2.1)
18.37917367995256
> Math.pow(4, 0.5)
2
> Math.pow(-4, 2)
16
> Math.pow(-4, 2.1)
NaN
> Math.pow(-4, 0.5)
NaN
Run Code Online (Sandbox Code Playgroud)
为什么给出一个负数和一个非整数但有理数的数字会让人Math.pow回归NaN?
例如,为什么Math.pow(4, 0.5)是不是 NaN,但Math.pow(4, -0.5) 就是 NaN?
该问题的解决方案工作正常:
而不是做:
$ mongo my_db_name -u superuser -p 1234
Run Code Online (Sandbox Code Playgroud)
我做
$ mongo admin -u superuser -p 1234 # connecting as super user to admin db
> use anotherDb
Run Code Online (Sandbox Code Playgroud)
在外壳中。
NodeJS中的解决方案是什么?
我尝试连接,mongodb://superuser:1234@localhost:27017/my_db_name但出现此错误:
{ [MongoError: auth fails] name: 'MongoError', code: 18, ok: 0, errmsg: 'auth fails' }
我的代码是:
var Db = require('mongodb').Db,
MongoClient = require('mongodb').MongoClient;
MongoClient.connect("mongodb://superuser:1234@localhost:27017/my_db_name",
function(err, db) {
if (err) { return console.log(err); }
console.log("Successfully connected.");
}
);
Run Code Online (Sandbox Code Playgroud)
请注意,超级用户是可以在任何数据库中写入和读取权限的全能用户。 …
我想找到许多只做1个查询的随机记录.
我试过了:
var count = db.collections.count()
var rand = function(){return Math.floor( Math.random() * count )}
db.collection.find().limit(-1).skip(rand()).next();
Run Code Online (Sandbox Code Playgroud)
但是这只返回一个文档.我需要获得更多随机记录.
我怎样才能做到这一点?
我想toString为数据类型创建自己的函数.
我们来举个例子:
JSON.stringify({}) // "{}"
Run Code Online (Sandbox Code Playgroud)
我想要"test"归还.所以,我试图修改对象原型:
Object.prototype.toString = function () { return "test"; }
Run Code Online (Sandbox Code Playgroud)
然后:也JSON.stringify({})回来"{}"了.
我确信有一个函数可以重写以返回自定义值.
那是什么功能?
node.js help命令输出以下内容:
debug> help
Commands: run (r), cont (c), next (n), step (s), out (o), backtrace (bt), setBreakpoint (sb), clearBreakpoint (cb),
watch, unwatch, watchers, repl, restart, kill, list, scripts, breakOnException, breakpoints, version
Run Code Online (Sandbox Code Playgroud)
我可以使用setBreakpoint以下命令添加新的断点:
debug> setBreakpoint(12)
...
Run Code Online (Sandbox Code Playgroud)
但我可以让它有条件吗?例如:
*only if `foo() === true`, stop here*
Run Code Online (Sandbox Code Playgroud)
另一种方法是if在脚本中添加它:
if (foo()) { debugger; }
Run Code Online (Sandbox Code Playgroud)
这是通过NodeJS调试器实现的吗?
$(window).on("keydown", function (e) {
alert(e.keyCode);
});
Run Code Online (Sandbox Code Playgroud)
W有87关键代码。我也知道,e.ctrlKey就是true如果Ctrl在那一刻被按下。
是否可以抓住Ctrl+ W键并阻止制表符关闭?
我试过了:
$(window).on("keydown", function (e) {
if (e.keyCode === 87 && e.ctrlKey) {
return false;
}
});
Run Code Online (Sandbox Code Playgroud)
但是在这种情况下,似乎浏览器快捷方式具有优先权,并且该选项卡已关闭。
我正在寻找一种解决方案:如果无法通过JavaScript进行操作,则可能是浏览器插件可以执行此操作。
假设我有提交哈希,但没有对git存储库的访问权限,是否有可能获得提交提交的时间?
如何才能做到这一点?
根据此答案,提交哈希包含完成的日期和时间。
例:
1484e89060b2043be0b71209bacc2254161f1a8f被做了Wed Sep 3 09:30:59 2014 +0300。
我有一个非常基本的http服务器:
require("http").createServer(function (req, res) {
res.end("Hello world!");
}).listen(8080);
Run Code Online (Sandbox Code Playgroud)
如何监听服务器崩溃,以便我可以发送500状态代码作为响应?
process.on("uncaughtException", handler)在process级别上听作品,但我没有请求和响应对象.
我看到的一个可能的解决方案是try - catch在createServer回调中使用语句,但我在寻找是否有更好的解决方案.
我试着error在server对象上侦听事件,但没有任何反应:
var s = require("http").createServer(function (req, res) {
undefined.foo; // test crash
res.end("Hello world!");
});
s.on("error", function () { console.log(arguments); });
s.listen(8080);
Run Code Online (Sandbox Code Playgroud) 我在NodeJS shell中发现了以下行为:
$ node
> function foo () { _ }
undefined
> _
undefined
Run Code Online (Sandbox Code Playgroud)
为什么_定义变量?我期望得到ReferenceError: _ is not defined.
如果我创建一个箭头函数,_它将是函数引用:
$ node
> () => _
[Function]
> _
[Function]
> _.toString()
'() => _'
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
调用后toString()的_变量时,_被转换成字符串:
> _
'() => _'
Run Code Online (Sandbox Code Playgroud)
我尝试使用_ => (),我们有同样的问题:
$ node
> _ => {}
[Function]
> _
[Function]
> _.toString()
'_ => {}'
> _
'_ => {}' …Run Code Online (Sandbox Code Playgroud)