小编Kri*_*iss的帖子

使用linux bash替换文件中两个字符串之间的文本

我有文件"acl.txt"

 192.168.0.1
 192.168.4.5
 #start_exceptions
 192.168.3.34
 192.168.6.78
 #end_exceptions
 192.168.5.55
Run Code Online (Sandbox Code Playgroud)

和另一个文件"例外"

 192.168.88.88
 192.168.76.6
Run Code Online (Sandbox Code Playgroud)

我需要用例外文件的内容替换#start_exceptions和#end_exceptions之间的所有内容.我在这个论坛上尝试了很多解决方案,但没有一个能有效.

linux bash sed

9
推荐指数
1
解决办法
6672
查看次数

在路由中访问app.js变量但没有全局表达

这是我在app.js中的配置:

var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path')
, Server = mongo.Server
, Db = mongo.Db;
, mongo = require('mongodb');
, BSON = mongo.BSONPure;


var app = express();
var server = new Server('localhost', 27017, {auto_reconnect: true, });
var db = new Db('tasksdb', server); //i need to remove this "var" to access db in routes


db.open(function(err, db) {
if(!err) {
 console.log("Connected to 'tasksdb' database");
 db.collection('tasks', {safe:true}, function(err, collection) …
Run Code Online (Sandbox Code Playgroud)

node.js express

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

验证保存并保存().完成 - 在主干中

我的模型验证有问题.似乎不可能使用save().complete(function(){.....与验证同时 - 这里是代码:

我的模特:

 App.Models.Task = Backbone.Model.extend({

defaults: {

    title:'',
    completed: 0

},

validate: function (attrs, options) {

    if(attrs.title == '' || attrs.title === undefined) {
        return "fill title pls"
    }

},

urlRoot: 'tasks' 
});
Run Code Online (Sandbox Code Playgroud)

然后在我的视图中我尝试将其保存在添加方法中:

 App.Views.TaskAdd = Backbone.View.extend({

tagName: 'div',

template: template('taskTemplateAdd'),

events : {

    'click .addTask' : 'add'
},

initialize: function () {

    this.model.on('add',this.render, this)


},

add : function () {

    var title = $("#addNew input:eq(0)").val();
    var completed = $("#addNew input:eq(1)").val();

    this.model.set('title', title);
    this.model.set('completed', completed);

    this.model.save({},
                 {
                   success: …
Run Code Online (Sandbox Code Playgroud)

backbone.js

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

标签 统计

backbone.js ×1

bash ×1

express ×1

linux ×1

node.js ×1

sed ×1