是否可以在批处理文件中使用管道stdin流?
我希望能够将一个命令的输出重定向到我的批处理文件process.bat列表中,这样:
C:\>someOtherProgram.exe | process.bat
Run Code Online (Sandbox Code Playgroud)
我的第一次尝试看起来像:
echo OFF
setlocal
:again
set /p inputLine=""
echo.%inputLine%
if not (%inputLine%)==() goto again
endlocal
:End
Run Code Online (Sandbox Code Playgroud)
当我用type testFile.txt | process.bat它测试时,它会反复打印出第一行.
还有另外一种方法吗?
我有一个git repo设置core.eol=crlf,core.autocrlf=true和core.safecrlf=true.
当我从另一个crlf仓库和我的仓库应用补丁时,受影响文件的所有行结尾都将更改为lf.目前我正在应用补丁:
git apply --ignore-whitespace mychanges.patch
Run Code Online (Sandbox Code Playgroud)
(似乎我必须使用--ignore-whitespace才能成功应用补丁.)
我目前的工作是运行unix2dos该文件.是否有更好的方法来申请符合我的eol设置?
我正在尝试连接到 websocket。我想从实际的网站登录中添加 cookie,因此服务器(不是我的)知道我是谁(事件是特定于帐户的)。
var opts = {
extraHeaders: {
'Cookie': "_ga=GA1.2.17432343994.1475611967; _gat=1; __cfduid=dc232334gwdsd23434542342342342475611928"
},
}
function socket() {
var socket = io(websiteURL, opts);
var patch = require('socketio-wildcard')(io.Manager); patch(socket);
socket.on('connect', function () {
console.log(" > [Connected]");
});
socket.on('*', function (data) {
console.log(" >>> " + data);
});
socket.on('disconnect', function () {
console.log(" > [Disconnected]");
});
}
Run Code Online (Sandbox Code Playgroud)
连接本身工作正常,因为我从网站(不是每个帐户的)接收公共事件。
我试图使用节点检查器找到问题。
这是正在完成的第一个请求。似乎请求标头是空的,并且那里缺少 cookie。
(是的,我在节点中发送的 cookie 较少,只是为了查看它们是否在请求 cookie 中弹出)
难道我做错了什么?我将如何以正确的方式添加 cookie?
我有一个nodejs express应用程序,我试图捆绑webpack 4(加上babel 7.1.0).我已经按照这两篇文章中的一些设置进行了操作:
我可以在捆绑后构建和运行服务器,但我希望能够使用VS Code的调试环境对其进行调试.
我尝试了以下webpack和vscode配置的组合,但它没有设置断点或让我进入代码.
.vscode/launch.json
{
"type": "node",
"request": "launch",
"name": "bundle-server.js",
"program": "${workspaceFolder}\\bundle-server.js",
"sourceMaps": true,
"smartStep": true,
}
Run Code Online (Sandbox Code Playgroud)
的WebPack-server.config.js
const path = require('path');
const nodeExternals = require('webpack-node-externals');
module.exports = {
target: "node",
entry: "./server.js",
output: {
path: path.resolve(__dirname, "./"),
filename: "bundle-server.js",
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: "babel-loader"
}
],
},
externals: [nodeExternals()],
devtool: 'inline-source-map',
};
Run Code Online (Sandbox Code Playgroud)
我错过了什么?甚至可以直接从VSCode调试吗?我希望能够跨越原始源文件,这样我就可以进行快速的debug-edit-rerun循环.
我正在使用带有 jsdoc 类型提示和 vscode typescript 类型检查的 javascript。
为父方法添加 jsdoc 类型信息时,我希望子类中的覆盖继承参数/返回类型。
例如,我有这样的课程:
class Parent {
/**
* @param {string} a ...
* @param {number} b ...
*/
method(a, b) {
// ...
}
}
class Child extends Parent {
/** @inheritdocs */
method(a, b) {
super(a, b);
// ... do extra stuff ...
}
}
Run Code Online (Sandbox Code Playgroud)
我想Child#method自动从Parent#method. 我试过了@inheritdocs,但它似乎没有这样做。有没有办法标记这个?
当我使用vim的quickfix跳转到我的构建中的错误时,如果包含错误的文件尚未打开,则会在我的一个分区中打开它,替换我打开的文件.
有没有办法在拆分中重新打开最后关闭的文件或获取quickfix以在新拆分中打开文件?
在vim 7.3中,我想在标尺栏上显示当前时间和git信息.
我怎样才能做到这一点?
从vim的指南来看,似乎我应该修改rulerformat选项,但是如何?
我已经创建了一个ruby C扩展TestExt,成功编译了它,但是当我尝试在irb中使用它时,我只能在调用之后访问它的方法include TestExt.
我正在测试它:
c:/test>irb -I lib
irb(main):001:0> require 'TestExt'
=> true
irb(main):002:0> TestExt.hello()
NoMethodError: undefined method `hello' for TestExt:Module
from (irb):2
from C:/Ruby192/bin/irb:12:in `<main>'
irb(main):003:0> TestExt.instance_methods
=> [:hello]
irb(main):004:0> include TestExt
=> Object
irb(main):005:0> TestExt.hello()
=> 0
irb(main):006:0> hello()
=> 0
Run Code Online (Sandbox Code Playgroud)
你总是需要include延期吗?是否有一种替代的包含方式不会使方法成为hello全局?为什么我可以hello在TestExt.instance_methods但不能访问它?