小编Pas*_*ten的帖子

ssh -L转发多个端口

我目前正在运行一堆:

sudo ssh -L PORT:IP:PORT root@IP
Run Code Online (Sandbox Code Playgroud)

其中IP是安全机器的目标,PORT代表我转发的端口.

这是因为我使用了许多我没有这种转发无法访问的应用程序.执行此操作后,我可以访问localhost:PORT.

现在出现的主要问题是我实际上有4个这样的端口我必须转发.

我的解决方案是打开4个shell并不断向后搜索我的历史记录以查找需要转发的确切端口等,然后运行此命令 - 每个shell中一个(必须填写密码等).

如果我能做的事情如下:

sudo ssh -L PORT1+PORT2+PORT+3:IP:PORT+PORT2+PORT3 root@IP
Run Code Online (Sandbox Code Playgroud)

那真的会有所帮助.

有没有办法让它更容易做到这一点?

ssh port portforwarding

97
推荐指数
7
解决办法
6万
查看次数

父组件的angular2调用函数

我有一个应用程序,我有一个上传组件,我可以上传文件.它嵌入在body.component.

在上传时,它应该使用BodyComponent.thefunction()父组件的一个函数(例如)(执行调用来更新数据):但是只有父元素是特定的body.component.上传也可能在其他地方使用,具有不同的行为.

有点像parent(this).thefunction(),怎么做?

angular

75
推荐指数
4
解决办法
8万
查看次数

从<input type ="file">上传文件

使用角度2 beta,我似乎<input type="file">无法上班.

使用诊断,我可以看到其他type的双向绑定,如text.

<form>
    {{diagnostic}}
    <div class="form-group">
        <label for="fileupload">Upload</label>
        <input type="file" class="form-control" [(ngModel)]="model.fileupload">
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

在我的TypeScript文件中,我有以下诊断线:

get diagnostic() { return JSON.stringify(this.model); }
Run Code Online (Sandbox Code Playgroud)

可能是因为它不是JSON的问题吗?价值是null.

我无法真正验证它的价值input.У尽管"选择文件..."旁边的文字更新了,但由于某种原因,我无法看到DOM的差异.

file-upload input angular

62
推荐指数
4
解决办法
13万
查看次数

使用SciPy/Numpy在Python中连接稀疏矩阵

使用SciPy/Numpy在Python中连接稀疏矩阵的最有效方法是什么?

我在这里使用了以下内容:

>>> np.hstack((X, X2))
array([ <49998x70000 sparse matrix of type '<class 'numpy.float64'>'
        with 1135520 stored elements in Compressed Sparse Row format>,
        <49998x70000 sparse matrix of type '<class 'numpy.int64'>'
        with 1135520 stored elements in Compressed Sparse Row format>], 
       dtype=object)
Run Code Online (Sandbox Code Playgroud)

我想在回归中使用两个预测变量,但目前的格式显然不是我想要的.是否有可能获得以下内容:

    <49998x1400000 sparse matrix of type '<class 'numpy.float64'>'
     with 2271040 stored elements in Compressed Sparse Row format>
Run Code Online (Sandbox Code Playgroud)

它太大而无法转换为深层格式.

python numpy scipy sparse-matrix

27
推荐指数
1
解决办法
2万
查看次数

Emacs Dired重命名了很多文件

如何重命名:

VAR1_1F_text.txt
VAR2_1F_text.txt
VAR3_2F_text.txt
Run Code Online (Sandbox Code Playgroud)

1F_VAR1_text.txt
1F_VAR2_text.txt
2F_VAR3_text.txt
Run Code Online (Sandbox Code Playgroud)

如何切换部分文件名?

emacs dired

26
推荐指数
1
解决办法
5541
查看次数

如何在两个node.js实例之间进行通信,一个客户端一个服务器

我是node.js的初学者(事实上刚刚开始).其中一个基本概念对我来说并不清楚,我在这里要求并且在SO上找不到.

在网上阅读一些教程,我写了一个客户端和服务器端代码:

服务器端(比如server.js):

var http = require('http'); //require the 'http' module

//create a server
http.createServer(function (request, response) {
  //function called when request is received
  response.writeHead(200, {'Content-Type': 'text/plain'});
  //send this response
  response.end('Hello World\nMy first node.js app\n\n -Gopi Ramena');
}).listen(1337, '127.0.0.1');

console.log('Server running at http://127.0.0.1:1337/');
Run Code Online (Sandbox Code Playgroud)

客户端(比如client.js):

var http=require('http');

//make the request object
var request=http.request({
  'host': 'localhost',
  'port': 80,
  'path': '/',
  'method': 'GET'
});

//assign callbacks
request.on('response', function(response) {
   console.log('Response status code:'+response.statusCode);

   response.on('data', function(data) {
     console.log('Body: '+data);
   });
});
Run Code Online (Sandbox Code Playgroud)

现在,要运行服务器,我键入 …

node.js

19
推荐指数
1
解决办法
4万
查看次数

Emacs:函数中的通用参数(Cu)

我想C-u在函数(例如,regexp)中使用,其中调用它C-u具有不同的效果.我怎么能在Emacs中做到这一点?该文档没有说明如何使用Emacs Lisp执行此操作.

(defun test ()
  (interactive)
  (align-regexp)) ; I would like to add the C-u prefix to this.
Run Code Online (Sandbox Code Playgroud)

emacs arguments function

14
推荐指数
2
解决办法
2569
查看次数

编辑距离,如Levenshtein考虑到键盘上的接近度

是否有一个编辑距离,如Levenshtein考虑到替换的距离?

举例来说,如果我们会考虑的话,如果是平等的,typo并且tylo是非常接近(pl物理上靠近键盘上),而typotyqo相距甚远.我想为更可能的错别字分配更小的距离.

必须有一个指标考虑到这种主张吗?

python levenshtein-distance

13
推荐指数
2
解决办法
3423
查看次数

R输出没有[1],如何很好地格式化?

我知道东西已经发布了,但没有我想要的那么完整.

采取任何帮助功能(即?mean),并意识到它的输出(或至少输出应该能够以相同的方式生成).

你如何进入,对齐/意图?

例:

strings <- c("t", "df", "p-value", "mean of x", "mean of y")
values  <- c(t, df, pvalue, mean1, mean2)
Run Code Online (Sandbox Code Playgroud)

如果这是你想要在R中输出的东西(当从函数调用时),你如何使[1]消失,并且值排成一行?

formatting r output

11
推荐指数
1
解决办法
1万
查看次数

Enthought Canopy中的Python 3

如何在Canopy Enthought中使用Python 3?它有底部的选项来选择Python 3,但是当我们使用时,这不会改变任何东西:

print(sys.version)
2.7.3 | 32-bit | (default, Mar 25 2013, 15:38:39) [MSC v.1500 32 bit (Intel)]
Run Code Online (Sandbox Code Playgroud)

enthought python-3.x canopy

11
推荐指数
1
解决办法
2万
查看次数