我想为我的MongoDB实例设置用户名和密码验证,以便任何远程访问都会要求输入用户名和密码.我尝试了MongoDB网站上的教程并做了以下事情:
use admin
db.addUser('theadmin', '12345');
db.auth('theadmin','12345');
Run Code Online (Sandbox Code Playgroud)
在那之后,我退出并再次运行mongo.而且我不需要密码来访问它.即使我远程连接到数据库,也不会提示我输入用户名和密码.
更新这是我最终使用的解决方案
1) At the mongo command line, set the administrator:
use admin;
db.addUser('admin','123456');
2) Shutdown the server and exit
db.shutdownServer();
exit
3) Restart mongod with --auth
$ sudo ./mongodb/bin/mongod --auth --dbpath /mnt/db/
4) Run mongo again in 2 ways:
i) run mongo first then login:
$ ./mongodb/bin/mongo localhost:27017
use admin
db.auth('admin','123456');
ii) run & login to mongo in command line.
$ ./mongodb/bin/mongo localhost:27017/admin -u admin -p 123456
Run Code Online (Sandbox Code Playgroud)
用户名和密码将以相同的方式用于mongodump和mongoexport.
我想要查看字典中的更改,但由于某种原因,不会调用监视回调.
这是我使用的控制器:
function MyController($scope) {
$scope.form = {
name: 'my name',
surname: 'surname'
}
$scope.$watch('form', function(newVal, oldVal){
console.log('changed');
});
}
Run Code Online (Sandbox Code Playgroud)
这是小提琴.
我希望每次更改名称或姓氏时都会触发$ watch回调,但不会发生.
这样做的正确方法是什么?
我有以下代码重复并显示用户的名称和他的分数:
<div ng-controller="AngularCtrl" ng-app>
<div ng-repeat="user in users | orderBy:predicate:reverse | limitTo:10">
<div ng-init="user.score=user.id+1">
{{user.name}} and {{user.score}}
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和相应的角度控制器.
function AngularCtrl($scope) {
$scope.predicate = 'score';
$scope.reverse = true;
$scope.users = [{id: 1, name: 'John'}, {id: 2, name: 'Ken'}, {id: 3, name: 'smith'}, {id: 4, name: 'kevin'}, {id: 5, name: 'bob'}, {id: 6, name: 'Dev'}, {id: 7, name: 'Joe'}, {id: 8, name: 'kevin'}, {id: 9, name: 'John'}, {id: 10, name: 'Ken'}, {id: 11, name: 'John'}, {id: 1, name: 'John'}, …Run Code Online (Sandbox Code Playgroud) 我正在使用jQuery和AngularJS开发Ajax应用程序.
当我使用jQuery的html函数更新div的内容(包含AngularJS绑定)时,AngularJS绑定不起作用.
以下是我要做的代码:
$(document).ready(function() {
$("#refreshButton").click(function() {
$("#dynamicContent").html("<button ng-click='count = count + 1' ng-init='count=0'>Increment</button><span>count: {{count}} </span>")
});
});Run Code Online (Sandbox Code Playgroud)
</style><script src="http://docs.angularjs.org/angular-1.0.1.min.js"></script><style>.ng-invalid {
border: 1px solid red;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="">
<div id='dynamicContent'>
<button ng-click="count = count + 1" ng-init="count=0">
Increment
</button>
<span>count: {{count}} </span>
</div>
<button id='refreshButton'>
Refresh
</button>
</div>Run Code Online (Sandbox Code Playgroud)
我在带有ID的div中有动态内容#dynamicContent,并且我有一个刷新按钮,可以在单击刷新时更新此div的内容.如果我不刷新内容,增量将按预期工作,但在刷新后,AngularJS绑定将停止工作.
这可能在AngularJS中无效,但我最初使用jQuery构建应用程序并稍后开始使用AngularJS,因此我无法将所有内容迁移到AngularJS.任何有关在AngularJS中工作的帮助都非常感谢.
当使用sScrollX,sScrollXInner和/或sScrollY以实现在其内的内容的滚动固定报头表,表中的标题出去对准的与所述主体的在Chrome和IE的其余部分.另一方面,Firefox完美地显示它们.
使用版本1.9.4,据我所知,只有在存在大量宽度波动的数据时才会出现此问题,并且在与小列相同的列中使用非常长/不可包含的单词.此外,该表格需要相当广泛.
所有这些因素都在这个小提琴中得到证明:
之前已经提出过这些解决方案,但对我的实施没有任何影响.由于其中一些建议,我设置了一个干净的普通香草演示,因为我想确保没有其他代码有助于这种效果.
setTimeout( function () { oTable.fnAdjustColumnSizing(); }, 10 );oTable.fnFilter( "x",0 )和oTable.fnFilter( "",0 )按顺序"sScrollXInner": "100%"我发现失准头,唯一溶液取出sScrollX和sScrollY,但你失去了固定的页眉/内部内容的滚动功能这不能算作一个解决方案.可悲的是,这是一个暂时的黑客,而不是一个修复!
编辑/播放最新的小提琴.
我尝试了各种组合,可以通过使用链接http://jsfiddle.net/pratik136/etL73/#REV#在小提琴的修订历史中观察到1 <= #REV# <= 12
StackO
这个问题以前有人问:jQuery的数据表头对准相垂直滚动
,但重要的区别是,这个问题的任择议定书提到,他们能够在所有CSS被删除,这是在我的情况不实,以解决这个问题,我尝试了一些排列,因此认为值得重新发布的问题.
外部
此问题也已在DataTables论坛上标记:
这个问题让我疯了!请提出你的想法!
我有click()来自jquery 的-function 的问题.我创建了一个<a>-element,document.createElement('a')并希望调用click()关于这个元素的-function.关于这个元素,我想创建一个Excel文件并将其保存在桌面上.
我的代码:
$('body').on('click', '#test', function(event) {
var link = document.createElement('a');
link.download = 'test.xls';
link.href = 'data:application/vnd.ms-excel;utf-8,test';
link.click();
});
Run Code Online (Sandbox Code Playgroud)
此功能在chrome下运行,但不在Firefox下运行.
有谁知道为什么那不起作用?
我正在使用算法开发一些应用程序,如Runtastic计步器,但我没有得到结果之间的任何相似性.
我的代码如下:
public void onSensorChanged(SensorEvent event)
{
Sensor sensor = event.sensor;
synchronized (this)
{
if (sensor.getType() == Sensor.TYPE_ORIENTATION) {}
else {
int j = (sensor.getType() == Sensor.TYPE_ACCELEROMETER) ? 1 : 0;
if (j == 1) {
float vSum = 0;
for (int i=0 ; i<3 ; i++) {
final float v = mYOffset + event.values[i] * mScale[j];
vSum += v;
}
int k = 0;
float v = vSum / 3;
//Log.e("data", "data"+v);
float direction = (v > …Run Code Online (Sandbox Code Playgroud) 这是一个如此简单的基本问题我不认为有很多人问这个,但我只是如何通过localhost phpmyadmin与laravel连接到mySql(我搜索过,有一些东西,但我需要问,因为我是一个菜鸟,我想问一下,我看到的东西我不是100%得到的,或者我尝试了它并没有帮助)?
我正在使用backbone.js并且是laravel的新手,我在里面安装了laravelC:\wamp\www\laravel-project
我试过了
c:\wamp\www\laravel-project> php artisan migrate:make create_tasks_table --table tasks --create
Run Code Online (Sandbox Code Playgroud)
和
c:\wamp\www\laravel-project> php artisan migrate
Run Code Online (Sandbox Code Playgroud)
我希望必须定义数据库信息,我检查C:\wamp\www\laravel-project\app\config\database.php它看起来是正确的,mySQL设置默认root为用户名,''为密码.
运行后我得到的命令行错误php artisan migrate是
[PDOException]
SQLSTATE[HY000] [1049] Unknown database 'database'
Run Code Online (Sandbox Code Playgroud)
我正在使用Windows 8,并为我的localhost服务器wamp,它当然包括phpmyadmin和mySql.所以我相信有很多方法可以使用mySql,但我认为我没有正确设置laravel和phpmyadmin.
因此,任何见解都将是惊人的,简单的点.
编辑:
实际上想到这一点,也许我需要创建一个名为的数据库database让我试试.马上回来.好的,我会回答我的问题,或者有人可以,以防万一有人搜索这个主题...... 确保数据库中定义的数据库与phpmyadmin中存在的数据库匹配是关键C:\wamp\www\laravel-project\app\config\database.php.没问题!
我知道这已被覆盖了很多次,大多数文章都引用了这段代码:AngularJS中带有自定义URL的模态窗口
但我只是不明白.我发现根本不清楚.我也发现这个jsfiddle实际上很棒,非常有帮助,除了这不添加网址并允许我使用后退按钮关闭模态.
编辑:这是我需要帮助的.
那么让我试着解释一下我想要实现的目标.我有一个表单来添加一个新项目,我有一个链接'添加新项目'.我希望当我点击"添加新项目"时,会弹出一个模式,其中包含我创建的"add-item.html"表单.这是一个新状态,因此url更改为/ add-item.我可以填写表格,然后选择保存或关闭.关闭,关闭模态:p(多奇怪).但我也可以点击返回关闭模态并返回上一页(状态). 此时我不需要Close的帮助,因为我仍然在努力实现模态的工作.
这是我的代码:
导航控制器:( 这甚至是放置模态功能的正确位置吗?)
angular.module('cbuiRouterApp')
.controller('NavbarCtrl', function ($scope, $location, Auth, $modal) {
$scope.menu = [{
'title': 'Home',
'link': '/'
}];
$scope.open = function(){
// open modal whithout changing url
$modal.open({
templateUrl: 'components/new-item/new-item.html'
});
// I need to open popup via $state.go or something like this
$scope.close = function(result){
$modal.close(result);
};
};
$scope.isCollapsed = true;
$scope.isLoggedIn = Auth.isLoggedIn;
$scope.isAdmin = Auth.isAdmin;
$scope.getCurrentUser = Auth.getCurrentUser;
$scope.logout = function() {
Auth.logout();
$location.path('/login');
};
$scope.isActive = …Run Code Online (Sandbox Code Playgroud) angularjs bootstrap-modal angular-ui-router angular-bootstrap
我有一种情况,我有一个表格,我有一行,我有两个文本字段条目,我要上传该行的文件,这种行可以是'N'然后那里是一个主文件,可以输入整个表单,而这些是表单的一部分,我要点击一个保存按钮一次提交所有这些文件.
我有点坚持使用ng-upload它需要api调用,而且我真的不能有多个api调用这个表单.示例html代码如下:
<!DOCTYPE html>
<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<form editable-form name="xyzForm" ng-submit="create(model)">
<label>Tags: </label><input class="col-xs-12 col-md-12" ng-model="model.tags" type="text" name="Tags">
<label>Notes: </label> <input class="col-xs-12 col-md-11" ng-model="model.notes" type="text" name="notes">
<table class=" col-xs-3 col-md-11 table" border="1px solid red;">
<thead>
<tr>
<th>Product</th>
<th>Manufacturer</th>
<th>Location</th>
<th>Specification</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="itemRow in item.singleItem">
<td><input type="text" class="xdTextBox" name="itemRow.name" ng-model="model.itemRow[$index].name" /></td>
<td><input type="text" class="xdTextBox" name="itemRow.manufacturer" ng-model="model.itemRow[$index].manufacturer" /></td>
<td><input type="text" class="xdTextBox" name="itemRow.location" ng-model="model.itemRow[$index].location" /></td>
<td><i class="pull-left glyphicon …Run Code Online (Sandbox Code Playgroud)