小编chi*_*ngc的帖子

jQuery获取当前元素(x)html

我有下一个输入元素:

<input type="text" name="username" id="username" value="user name" 
    helper="formText" defvalue="user name" class="filling" />
Run Code Online (Sandbox Code Playgroud)

如何"username"在jQuery的帮助下通过id获取此HTML ?

我试着让它get(),html().但我想获得当前元素的HTML.

先感谢您.

对不起我的英语不好.

html javascript jquery

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

使用"WHERE UNIX_TIMESTAMP(date)"执行SQL查询的性能

我正在运行一个MySQL服务器(5.5),它有一个大表(大约有10M记录).此表是某种日志,其中包含2列主键:

id <- integer,
date <- datetime
Run Code Online (Sandbox Code Playgroud)

连接到此数据库的应用程序正在发送一个类似于以下内容的查询:

SELECT * FROM bigtable  
INNER JOIN other_table
ON ....
WHERE UNIX_TIMESTAMP(date) BETWEEN #somevalue# AND #somevalue2#;
Run Code Online (Sandbox Code Playgroud)

我发现这个查询花了很多时间来执行.我知道有些函数可以阻止MySQL使用索引并使其执行全表扫描.

问题:如图所示,在主键的列上使用UNIX_TIMESTAMP函数是否存在性能,而不是"... WHERE date BETWEEN'2012:01:01 00:00:00'AND'2012:02:01 00:00:00'"

查询:

SELECT r.f_registro, r.latitud, r.longitud, r.velocidad, r.status, r.odometro, r.heading, r.sensor, a.nombre FROM registros r INNER JOIN activos a ON a.id_tracker = r.id_tracker WHERE a.id_activo = 2366 AND r.satelites > '3' AND UNIX_TIMESTAMP(r.f_registro) BETWEEN 1342159200 AND 1342760400 ORDER BY r.f_registro
Run Code Online (Sandbox Code Playgroud)

执行需要几秒甚至几分钟!运行说明返回:

id,select_type,table,type,possible_keys,key,key_len,ref,rows,Extra
1,SIMPLE,a,const,PRIMARY,PRIMARY,4,const,1,"Using filesort"
1,SIMPLE,r,range,"id_tracker,satelites",satelites,4,NULL,1,"Using index condition; Using where"
Run Code Online (Sandbox Code Playgroud)

mysql sql performance

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

如何拆分基于R data.frame列的正则表达式条件

我有一个data.frame,我想根据正则表达式将其中一列拆分为两列.更具体地说,字符串在括号中有一个后缀,需要将其提取到它自己的列中.

所以我想从这里得到:

dfInit <- data.frame(VAR = paste0(c(1:10),"(",c("A","B"),")"))
Run Code Online (Sandbox Code Playgroud)

到这里:

dfFinal <- data.frame(VAR1 = c(1:10), VAR2 = c("A","B"))
Run Code Online (Sandbox Code Playgroud)

regex r dataframe

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

在eloquent中自动提取时重命名关系名称

    class Order extends Elequent{
        protected $table = 'order';
        const CREATED_AT = "createdAt";
        const UPDATED_AT = "updatedAt";

        protected $with = array('orderItem', 'address');
        public function orderItem(){
            return $this->hasMany("OrderItem","orderId");
        }
        public function address(){
            return $this->hasOne("OrderAddress","orderId","id");
        }
    }

    //in controller
    $order = Order::findOrFail($orderId);
    echo $order;
Run Code Online (Sandbox Code Playgroud)

当使用上面的类将序列序列化为json时,如何将order_item命令为orderItem(我喜欢骆驼案例比蛇案例更多)

{
  "id": 1,
  "userId": 1,
  "createdAt": "2015-04-30 12:08:26",
  "deletedAt": "0000-00-00 00:00:00",
  "updatedAt": "2015-04-30 12:08:26",
  "state": "activated",
  "deliveryNote": null,
  "order_item": [
    {
      "id": 1,
      "specialProductId": 29,
      "volume": 750,
      "quantity": 2,
      "price": "543.38",
      "orderId": 1,
      "updatedAt": "2015-04-30 12:08:26",
      "createdAt": "2015-04-30 …
Run Code Online (Sandbox Code Playgroud)

php laravel eloquent laravel-4

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

无法使用$ state.go发送数据

我的角度应用程序中有这个代码.因此,正如代码所说,有多个视图正在加载,我想传递一个参数.

.state('root.moduleListing', {
    params: ['registerData'],
    views: {
        "main_container": {
            controller: 'ModuleListingController as model',
            templateUrl: 'misc/module-listing/module-listing.tpl.html',
            resolve: {
                registerData: ['$stateParams', function($stateParams) {
                    return $stateParams.registerData;
                }]
            }
        },
        "components_header_header": {
            controller: 'HeaderController as model',
            templateUrl: 'components/header/post-login.tpl.html',
        },
        "components_footer_footer": {
            controller: 'FooterController as model',
            templateUrl: 'components/footer/footer.tpl.html',
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用它

$state.go('root.moduleListing', {'registerdata': response});
Run Code Online (Sandbox Code Playgroud)

&在控制器中,我只是想将它记录到控制台.

module.controller('ModuleListingController', function ($scope, $state, registerData) {
    var model = this;
    console.log("registerData : " + registerData);
}
Run Code Online (Sandbox Code Playgroud)

现在应用程序甚至没有启动,即我在控制台中收到错误说:

failed to instantiate module amcatUI due to:
TypeError: id.match is not a …
Run Code Online (Sandbox Code Playgroud)

angularjs ngroute

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

多列唯一mongoose nodejs组合

客观的

为两列创建唯一性

我试过的

这是我的架构,

var mongoose = require('mongoose');

// location table Schema

var locationSchema = new mongoose.Schema({

    locationId: { type: String, required: true },
    stockingLocationId: { type: String, required: true},
    parentStockingLocationId: { type: String },
    stockingLocationDescription: { type: String },
    created: { type: Date, default: Date.now  },
    lastModified: { type: Date, default: Date.now },
    isActive: { type: Boolean , default : true },
    isDeleted: { type: Boolean , default : false }

});
Run Code Online (Sandbox Code Playgroud)

两列是locationIdstockingLocationId

我试过 locationSchema.index({locationId:1, …

mongoose mongodb node.js

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

键盘中断不会阻止我的翻译

我正在测试一个Log-parser,它执行一个无限循环(故意),每次重复都会降温3秒.

最后,我将所有数据链接到GUI前端,这样当用户准备好解析时,我可以调用停止循环.

现在的(小)问题是,当我执行CTRL+ Z取消进程时,在终端(在OSX中)测试输出时,我的活动监视器一直将进程显示为活动状态(可能是因为循环?).

所以问题是:如何调用(如果可能的话,没有额外的非本地库)在终端中调用CTRL+ 时停止整个过程Z?当我退出终端时,所有python进程都被杀死了,但我想知道在终端运行时如何做到这一点:).

python terminal infinite-loop osx-lion

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

创建新的 AD B2C 应用程序时出现 REDIRECT_URI 问题

我目前正在创建一个 Azure B2C 应用程序,供我们公司网站使用。

我按照以下网站上的说明进行操作:

https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-app-registration

https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-policies

具体来说,我做了以下事情:

  1. 在“应用程序”下,我创建了一个 B2C 应用程序,名为“我的 B2C 应用程序”
  2. 生成了密钥。记下这一点以及应用程序 ID
  3. 将回复 URL 设置为“ https://mysite.test.com/login/
  4. 在“识别提供商”下,我选择“Microsoft”,并使用应用程序 ID 和 #2 中的密钥
  5. 在“登录策略”下,我创建了一个名为“B2C_signin1”的新策略。
  6. 将识别提供商设置为“Microsoft”。
  7. 在“应用程序声明”下,我选择了“显示名称”、“电子邮件地址”、“名字”、“识别提供商”、“姓氏”和“用户对象 ID”
  8. 保存后,我选择应用程序“我的 B2C 应用程序”,然后选择“回复 URL”-->“ https://mysite.test.com/login/ ”,默认情况下该 URL 已存在于下拉列表中。
  9. 我点击“立即运行”。

我暂时重定向到下面生成的 URL:

https /login.microsoftonline.com/mytenant.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_signin1&client_Id=&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fmysite.test.com%2Flogin%2F&scope=openid&response_type=id_token&prompt=登录

然后我得到错误:

https /login.live.com/err.srf?lc=34313#error=invalid_request&error_description=The+provided+value+for+the+input+parameter+'redirect_uri'+is+not+valid。+The+expected+value+ is+'https //login.live.com/oauth20_desktop.srf'+or+a+URL+which+matches+the+redirect+URI+registered+for+this+client+application.&state=

当我为应用程序设置的回复 URL 与我在创建策略时使用的回复 URL 相同时,为什么会出现此错误?我设置 B2C 应用程序的方式正确吗?这可能是 B2C 应用程序创建中的错误吗?

我确实遵循了这封信上面链接中的说明。

任何有关此问题的帮助将不胜感激。

azure-ad-b2c

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

如何逃避使用PreparedStatement.setNull?

我的数据库中有一个很大的表。其中一些字段可能为空。

我只想逃避使用:

PreparedStatement.setNull(index, Type.X)
Run Code Online (Sandbox Code Playgroud)

喜欢:

if(obj.getSomaData() == null){
  insertStmt.setNull(++i, java.sql.Types.VARCHAR);
}else{
  insertStmt.setString(++i, obj.getSomaData());
}
Run Code Online (Sandbox Code Playgroud)

有更好更好的方法吗?

PS:我正在使用PostgreSQL。

java postgresql jdbc

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