小编sat*_*tya的帖子

如何使用AWS EC2创建stun turn服务器实例

实际上我想使用我自己的stun/Turn服务器实例,我想使用Amazon EC2.如果有人对此有任何想法,请与我分享创建步骤或任何参考链接.

amazon-ec2 amazon-web-services stun webrtc turn

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

如何使用 Node.js 计算两个日期之间的差异?

我需要datetime使用 node.js计算差异。我正在使用该dateformat包来获取当前的日期时间格式。我的代码如下:

var dateFormat = require('dateformat');
var prev_date=2017-08-09T19:00:58+0530;
var now = new Date();
var current_date=dateFormat(now, "isoDateTime");
Run Code Online (Sandbox Code Playgroud)

在这里,我已经有了以前的日期和当前的日期datetime。我需要分别计算两个日期的小时、分钟和秒之间的差异。

datetime node.js

7
推荐指数
2
解决办法
3万
查看次数

使用 Node.js 和 Socket.io 获取丢失错误处理程序套接字消息

您好,我收到以下错误,该错误使用 Node.js 和 socket.io 运行服务器。

错误:

Missing error handler on `socket`.
TypeError: Cannot read property 'connected' of undefined
    at Socket.<anonymous> (C:\Documents and Settings\Subhrajyoti\Desktop\Restore
\htdocs\video broadcast\server.js:68:13)
    at Socket.emit (events.js:95:17)
    at Socket.onevent (C:\Documents and Settings\Subhrajyoti\Desktop\Restore\htd
ocs\video broadcast\node_modules\socket.io\lib\socket.js:330:8)
    at Socket.onpacket (C:\Documents and Settings\Subhrajyoti\Desktop\Restore\ht
docs\video broadcast\node_modules\socket.io\lib\socket.js:290:12)
    at Client.ondecoded (C:\Documents and Settings\Subhrajyoti\Desktop\Restore\h
tdocs\video broadcast\node_modules\socket.io\lib\client.js:193:14)
    at Decoder.Emitter.emit (C:\Documents and Settings\Subhrajyoti\Desktop\Resto
re\htdocs\video broadcast\node_modules\socket.io\node_modules\socket.io-parser\n
ode_modules\component-emitter\index.js:134:20)
    at Decoder.add (C:\Documents and Settings\Subhrajyoti\Desktop\Restore\htdocs
\video broadcast\node_modules\socket.io\node_modules\socket.io-parser\index.js:2
47:12)
    at Client.ondata (C:\Documents and Settings\Subhrajyoti\Desktop\Restore\htdo
cs\video broadcast\node_modules\socket.io\lib\client.js:175:18)
    at Socket.emit (events.js:95:17)
    at Socket.onPacket (C:\Documents and Settings\Subhrajyoti\Desktop\Restore\ht …
Run Code Online (Sandbox Code Playgroud)

node.js socket.io

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

使用Angular.js在一些值之后中断表行

我需要一个帮助.我有一个表,我需要当序列号将高于10它时将再次转移到下一列序列号将从11.

我在下面解释我的代码.

 <table class="table table-bordered table-striped table-hover" id="dataTable" >
    <colgroup>
       <col class="col-md-1 col-sm-1">
       <col class="col-md-4 col-sm-4">
    </colgroup>
    <thead>
       <tr>
          <th>Sl. No</th>
          <th>Generated Code</th>
       </tr>
    </thead>
    <tbody id="detailsstockid">
        <tr ng-repeat="c in listOfViewCode">
            <td>{{$index+1}}</td>
            <td>{{c.generated_code}}</td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

其实我需要以下格式.

sl no  Generated Code  sl no  Generated Code

1          aaa          11        ssss

2          sss          12        gggg
3          eee
4          cccc
5          tttt
6          bbbb
7          nnnn
8          nnnn
9          bbbb
10         cccc
Run Code Online (Sandbox Code Playgroud)

newtable的:

<table class="table table-bordered table-striped table-hover" id="dataTable" …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

5
推荐指数
1
解决办法
1339
查看次数

使用Python获取无效的函数名称警告

我正在使用格式化Python代码pylint并获取一些不需要的警告消息,如下所示.

C:204, 0: Invalid function name "sendPasswordViaEmail" (invalid-name)
C:207, 4: Invalid variable name "to" (invalid-name)
W:213, 4: Statement seems to have no effect (pointless-statement)
Run Code Online (Sandbox Code Playgroud)

我正在解释与以下消息相关的代码.

if request.method == 'POST':
        name = request.POST.get('uname')
        email = request.POST.get('uemail')
        range_start = 10 ** (4 - 1)
        range_end = (10 ** 4) - 1
        password = randint(range_start, range_end)
        passw = User(
            uname=name,
            password=password,
            raw_password=password,
        )
        passw.save()
        sendPasswordViaEmail(str(password), email)
    return render(request, 'bookingservice/login.html')


def sendPasswordViaEmail(password, email):
    """ Send email to user"""

    to = email
    gmail_user …
Run Code Online (Sandbox Code Playgroud)

python pylint

5
推荐指数
1
解决办法
7018
查看次数

如何使用Javascript和Canvas在图像上添加文本

我需要使用javascript/jquery在现有图像上添加文本.我在下面解释我的代码.

<form name="billdata" id="billdata"  enctype="multipart/form-data" novalidate>
    <input name="text" id="txt" class="form-control" placeholder="Add Text"  type="text" required>
    <div class="col-md-6">
        <img src="703960808_1011008937_images.png">
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

这里我有一个文本字段.当用户在该文本字段中写入内容时,它将写在该图像上,并且在表单提交时应该获取已编辑的图像.

html javascript jquery canvas

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

使用 MongoDB 出现错误索引键模式错误

我收到一个与 mongodb 相关的错误。实际上我有一个集合,其数据如下。

"_id" : ObjectId("55bd9b7adfa5d64c057de74f"),
 "username" : "admin",
 "emailid" : "*****************************",
 "password" : "adminuser",
 "image" : "images/Image0895.jpg",
 "firstname" : "subhrajyoti",
 "lastname" : "pradhan"
Run Code Online (Sandbox Code Playgroud)

在这里,我想保持用户名文档唯一。为此,我编写了命令db.collectionname.createIndex( {"username":"admin"},{unique:true})。但它给了我以下错误。

错误:

        "ok" : 0,
        "errmsg" : "bad index key pattern { username: \"admin\" }: Unknown index
 plugin 'admin'",
        "code" : 67
Run Code Online (Sandbox Code Playgroud)

请帮助我解决此错误,使我的一份文档对于该集合保持唯一。

mongodb

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

如何使用 Ubuntu 在 crontab 中保存文件

crontab我正在Ubuntu 上使用 Nano 编辑器编辑文件。我需要将文本保存为crontab文件。当我尝试保存文件时,它会要求我提供文件名,但是在我给出文件名后,它不会接受或者我没有提供正确的路径或其他内容。我在下面提供了一个屏幕截图。

在此输入图像描述

感谢您的帮助!

cron nano ubuntu-14.04

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

无法使用 Nodemailer 和 Node.js 发送邮件

我无法使用 Node.js 发送邮件。我收到以下错误。

{
    "error": {
        "code": "EAUTH",
        "response": "534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbvp\n534-5.7.14 j_smRtzyG0TYeMSMFUYlhfCGtpt9DmDE4ZR140rMTKNkk0ZwgtIEQ6Kik51kVBedggHrBA\n534-5.7.14 3mM-ha-68KYhP-IPiHTVQkjUj6HlwdSciwJUgyRqIYKTxTtA9N96CmRzCRiPpIPMf6UGu3\n534-5.7.14 ismcOTMvxqQK2naujp_fgkbLjzwPMj47j5cOoaWdIkdwy4qmqMXnw8ib3sdkRfBeUgjVGB\n534-5.7.14 iiSXqql1vBLMkKnk_HNyGdeQu8OwI> Please log in via your web browser and\n534-5.7.14 then try again.\n534-5.7.14  Learn more at\n534 5.7.14  https://support.google.com/mail/answer/78754 k97sm25351307qkh.29 - gsmtp",
        "responseCode": 534,
        "command": "AUTH PLAIN"
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

    var nodemailer = require("nodemailer");
    var smtpTransport = nodemailer.createTransport({
        service: 'Gmail',
        auth: {
            user: 'subhrajyoti@gmail.com',
            pass: '********'
        }
    });
    rand=crypto.randomBytes(20).toString('hex');
    host=req.get('host');
    link="http://"+req.get('host')+"/api/users/verify?id="+rand;

mailOptions={
              from: "subhrajyotipradhan@gmail.com",
              to : email,
              subject : "Please confirm your Vodex account",
              html : "Hello,<br> Please …
Run Code Online (Sandbox Code Playgroud)

heroku node.js nodemailer

3
推荐指数
1
解决办法
2653
查看次数

如何防止python代码中的目录遍历攻击

我需要directory traversal attack使用Python 来阻止我的代码.我在下面解释我的代码.

if request.GET.get('param') is not None and request.GET.get('param') != '':
    param = request.GET.get('param')
    startdir = os.path.abspath(os.curdir)
    requested_path = os.path.relpath(param, startdir)
    requested_path = os.path.abspath(requested_path)
    print(requested_path)
    tfile = open(requested_path, 'rb')
    return HttpResponse(content=tfile, content_type="text/plain")
Run Code Online (Sandbox Code Playgroud)

在这里我需要用户运行这样http://127.0.0.1:8000/createfile/?param=../../../../../../../../etc/passwd它应该防止目录遍历攻击.

python directory-traversal

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