我正在运行我的nodejs应用程序 npm start
我刚安装了nodemon,
sudo npm install -g nodemon以便在保存对文件的更改时可以重新启动服务器.
但是当我尝试启动服务器时,就像这样
nodemon ./app.js localhost 3000 or nodemon start localhost 3000
我把它作为输出
LM-SJC-00871929:webapp gdeep$ nodemon ./app.js localhost 3000
28 May 23:34:30 - [nodemon] v1.1.1
28 May 23:34:30 - [nodemon] to restart at any time, enter `rs`
28 May 23:34:30 - [nodemon] watching: *.*
28 May 23:34:30 - [nodemon] starting `node ./app.js localhost 3000`
Run Code Online (Sandbox Code Playgroud)
但是当我去我的网页时,我明白了
Oops! Google Chrome could not connect to localhost:3000.我究竟做错了什么?
App.js在这里http://collabedit.com/t35dy
这个问题看似简单,但我无法理解它背后的真正工作.我知道人们会说,分解成512 Megs块并将它们排序,就像使用Map reduce一样使用Merge Sort.
所以这是我的实际问题:
假设我将文件分成512 Megs块,然后发送到不同的主机进行排序.假设这些机器使用了Merge Sort.现在说,我有2000台机器每个排序2000,512兆块.现在当我合并它们时,它是如何工作的?尺寸不会继续增加吗?例如,合并两个512兆的将产生1024Megs,这是我的RAM的大小,那么这将如何工作?任何机器都不能将超过512兆块的块与另一块块合并,因为那么大小> 1 GB.
在合并结束时我将能够将两个0.5 TB的块与另一个0.5 TB的块合并.虚拟内存的概念是否会在这里发挥作用?
我在这里澄清我的基础知识,我希望我正确地问这个非常重要的问题(正确).另外,谁应该做这个合并(排序后)?我的机器或那些2000机器中的一些?
我正在读一本提到这一点的书
如果编译器知道const的每次使用,则不需要分配空间来保存它.例如:
const int c1=1;const int c3=my_f(3);extern const int c4;鉴于c3和c4的值不称为编译时,必须为c3和c4分配存储.
我不明白这一点.我的怀疑是:
抱在这里意味着什么?难道它还不需要将所有内容存储在内存中吗?对于c1,我们不会有任何存储分配?
请清除我的疑虑.
谢谢.
我正在使用express-ws https://www.npmjs.com/package/express-ws(有助于为express和websocket客户端创建服务器的API).
app.ws('/', function(ws, req) {
console.log("New connection")
if (content.length > 0) {
console.log(content)
ws.send(content)
}
ws.on('message', function(msg, flags) {
console.log("Received "+ msg);
});
ws.on('data', function(msg, flags) {
var data = []; // List of Buffer objects
res.on("data", function(chunk) {
data.push(chunk); // Append Buffer object
console.log(data)
})
})
});
Run Code Online (Sandbox Code Playgroud)
现在您可以看到上面的代码,无论何时创建连接,它都会检查内容的长度,并在超过0时向客户端发送conetent.
遵循路由器代码,在Web请求上更新文件.如果在连接创建后的某个时间(如果此文件被修改),此连接不知道它,因此不会调用此函数,因此不会调用send函数.我也试过fs.watch但是我无法让它工作.
router.post('/run_restart', function(req, res, next) {
text = '{"to_do": "run_test", "devices":"all", "argv": { "test": "' + req.body.cmd + '", "cycles": "' + req.body.cycles + '", "awake_for": "' + req.body.wt …Run Code Online (Sandbox Code Playgroud) 我正在使用MacOS上的代码连接来连接设备,并且100次此代码仅连接1或2次,并且没有响应(因为没有超时)其余时间.
ser = serial.Serial(port="/dev/xyz",timeout = None, baudrate=115200, parity = serial.PARITY_NONE, bytesize = serial.EIGHTBITS, stopbits = serial.STOPBITS_ONE)
def exitSer(ser):
print("Closing")
ser.close()
atexit.register(exitSer, ser)
if ser.is_open:
time.sleep(2)
while(1):
print(ser.readline().decode("utf-8"))
Run Code Online (Sandbox Code Playgroud)
你能否告诉我如何使用像fcntl等程序来查找这个端口是否完全免费并且可以使用,以及如何在强制端口释放后将tty port的标志设置为free.
一旦这个工作,我必须运行这个多线程,其中每个线程运行不同的设备,期望在行中输出.有任何建议,以防万一这是有效的.
我需要做这样的事情
每小时运行此脚本并确保此变量的值现在是此脚本上次运行时设置的值。
我主要是在寻找如何设置和保留价值。我做了以下,但没有奏效。
export last_build="hello"
source .bashrc
Run Code Online (Sandbox Code Playgroud)
然后在我处理这个变量的脚本中
echo $last_build
export last_build="hello again"
echo $last_build
Run Code Online (Sandbox Code Playgroud)
当我运行这个脚本时,我得到类似的东西
hello
hello again
Run Code Online (Sandbox Code Playgroud)
当我第二次运行时,我希望输出是
hello again
hello again
Run Code Online (Sandbox Code Playgroud)
但它提供与第一次运行相同的输出。
你明白这个问题意味着什么吗?
在小于线性时间内查找整数数组中的顶部log(n)或顶部sqt(n)值.
如果你不这样做,那么问题是http://www.careercup.com/question?id=9337669.
能帮助我理解这个问题,然后可以解决它.(虽然一旦我理解我也可以解决它)
谢谢你的时间.
我们看到很多排序技术,如Merge,quick,Heap.你能帮我决定在哪种环境中使用哪种排序技术(如问题所示)?我们什么时候应该使用哪种排序算法?哪些不是(它们在时间和空间上的缺点)?
我期待着答案的东西以这种形式:1)我们将使用合并排序的时候......我们绝对不应该使用合并排序时...... b)我们将使用快速排序的时候......我们绝对不应该使用快速排序时...
我刚刚接受了各公司在采访中提出的问题.我发现一个是"找到一个精确数字的平方根.函数定义应该是这样的:double getSquareRoot(int num, int precision)".
我写了一个小函数,它给出了平方根,但不关心精度:
double getSquareRoot(int num){
int num1=0, num2=0;
for(int i=1 ;; i++){
if(i*i == num){
std::cout<<i <<" is the sq root"<<std::endl;
break;
}
else if(i*i > num){
num2 = i;
num1 = --i;
break;
}
}
// in the above for loop, i get the num1 and num2 where my input should lie
// between them
// in the 2nd loop below.. now i will do the same process but incrementing
// by 0.005 …Run Code Online (Sandbox Code Playgroud) 我正在尝试用 python 代码在我的云驱动器中创建一个文件。当我使用任何应用程序在此位置“/Users/agauravdeep/Library/Mobile Documents/com~apple~CloudDocs/Untitled.rtf”创建文件时,它可以工作,但通过代码,到目前为止我甚至没有成功(尽管没有错误)尝试通过超级用户后。
代码非常简单
# -*- coding: utf-8 -*-
#!/usr/bin/python
from os.path import expanduser
def createBugsFileInitiallyIfNotPresent():
global bugsFileLocation
bugsFileLocation = expanduser("~")+"/Library/Mobile Documents/com~apple~CloudDocs/abc.txt"
if(os.path.isfile(bugsFileLocation)):
f = open(bugsFileLocation, 'w+')
f.write(" dddd ")
Run Code Online (Sandbox Code Playgroud)
这也有效, vi ~/Library/Mobile\ Documents/com~apple~CloudDocs/abcd.txt 但是当我在路径周围加上引号时它不起作用。
任何建议都会非常有帮助。