小编BAD*_*EED的帖子

关于调用命名函数的click事件的jquery

我有一个jQuery onClick处理程序,用这样的匿名函数写:

$("#selector").on("click" function(){
    // do something
})
Run Code Online (Sandbox Code Playgroud)

我会概括在命名函数中提取逻辑的匿名函数,它驱使我做类似的事情:

$("#selector").on("click" namedFunction())

function namedFunction(){
    // do something
}
Run Code Online (Sandbox Code Playgroud)

对我来说似乎是个好方法.但是有一个缺点,因为在namedFunction脚本加载后执行.在这里你可以测试不良行为.

jquery event-handling

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

未安装LaunchNavigator Ionic2插件

我是Ionic 2的新手和周围的一切.我正在尝试设置我的第一个移动应用程序:触摸按钮我会打开原生导航(例如Google Maps for Android).我安装了launchnavigator插件:

ionic plugin add uk.co.workingedge.phonegap.plugin.launchnavigator
Run Code Online (Sandbox Code Playgroud)

并在cremony.ts页面内:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { LaunchNavigator, LaunchNavigatorOptions } from 'ionic-native';

@Component({
  selector: 'page-ceremony',
  templateUrl: 'ceremony.html'
})
export class Ceremony {

  constructor(public navCtrl: NavController) {

  }

  navigate() {
    let options: LaunchNavigatorOptions = {
      start: ""
    };

    LaunchNavigator.navigate("London, UK", options)
      .then(
      success => alert('Launched navigator'),
      error => alert('Error launching navigator: ' + error)
      );
  }
}
Run Code Online (Sandbox Code Playgroud)

制作一个构建npm run build并将其上传到IonicView …

android cordova ionic2

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

带有SAM的API网关未正确更新

我们使用Cloud Formation来定义一堆Lambda函数:

AWSTemplateFormatVersion: '2010-09-09'
Transform:
- 'AWS::Serverless-2016-10-31'

Resources:
  MyLambda:
    Type: 'AWS::Serverless::Function'
    Properties:
      Handler: com.handler::MyLambda
      Runtime: java8
      CodeUri: .
      Description: Some desc
      MemorySize: 512
      Timeout: 15
      Role: !Ref LambdaRole
      FunctionName: MyLambda
      Events:
        MyLambdaEvt:
          Type: Api
          Properties:
            RestApiId: !Ref MyApiDef
            Path: /lambda/my
            Method: get

  MyApiDef:
    Type: AWS::Serverless::Api
    Properties:
      DefinitionUri: s3://a-bucket/api-gateway.yml
      StageName: prod

Outputs:
  ApiUrl:
    Description: URL of your API endpoint
    Value: !Join
      - ''
      - - https://
        - !Ref MyApiDef
        - '.execute-api.'
        - !Ref 'AWS::Region'
        - '.amazonaws.com/prod'
Run Code Online (Sandbox Code Playgroud)

CodePipeline生成变更集并执行它.

通过这种方式,所有Lambda函数都已正确更新,但API Gateway端点未正确更新,我们需要s3://a-bucket/api-gateway.yml手动导入和部署YML …

amazon-web-services aws-cloudformation aws-lambda aws-api-gateway aws-codepipeline

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

CakePHP和子查询

如何使用cake语法编写SQL子查询?我知道如何编写简单的查询,但我无法处理子查询.

这是原始查询:

SELECT Assumption.id, Referee.id, Referee.first_name, Referee.second_name
FROM referees AS Referee
INNER JOIN (

    SELECT a.id, a.referee_id
    FROM assumptions a
    WHERE a.season_id =7
) AS Assumption ON Referee.id = Assumption.referee_id
Run Code Online (Sandbox Code Playgroud)

sql cakephp

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

Gpx文件格式,使用哪些段?

Gpx文件是用于跟踪时空信息的XML文档.它看起来像:

<gpx>
    <trk>
       <segment>
           <trkpt lat="...", lon="..."></trkpt>
       </segment>
    </trk>
</gpx>
Run Code Online (Sandbox Code Playgroud)

gpx超标签外,每个标签都可以越来越多地被替换.问题是:segment标签的用途是什么?为什么trkpt标签不能直接在父trk标签内收集?组织背后的概念trkptsegment什么?我在官方gpx网站上搜索了这个,http://www.topografix.com/gpx.asp,但我一无所获!:(

最诚挚的问候MC

gpx

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

AWS Amplify REST API 找不到 API

我正在使用 AWS Amplify,因为我必须在没有框架(没有 React,没有 Angular:只有普通 JS)的遗留应用程序中引入它的一些功能。

我成功地使用了 Auth 模块,所以我重新创建了一个简单的注册/加入/退出策略。我现在想要的是使用 REST API 模块调用 REST API。所以我使用 API Gateway PetStore 示例创建了一个 API,我将与它进行交互。

在此处输入图片说明

所以我创建了配置:

import Amplify from '@aws-amplify/core';

Amplify.configure({
    Auth: {
       ...
    },
    API: {
        endpoints: [
            {
                name: "PetStore", // name of the API in API Gateway console
                endpoint: "https://XXX.execute-api.eu-central-1.amazonaws.com/dev",
                region: "eu-central-1",
                paths: ['/']
            }
        ]
    }
});
Run Code Online (Sandbox Code Playgroud)

和其他地方:

import Api from '@aws-amplify/api-rest'; 

Api.get('PetStore', '/pets', {})
   .then(response => {
       console.log(response)
   }).catch(error => {
       console.log(error);
   });
Run Code Online (Sandbox Code Playgroud)

但是,执行时,我总是遇到相同的错误:

API PetStore 不存在

任何的想法?请记住:

  • API …

amazon-web-services aws-amplify

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

如何将 URL 参数传递给 joomla 模块

我有我自己的好链接http://www.link.com/sometext,现在我会“增强”这个有机会写一些像http://www.link.com/sometext?parameters=myParam因为我需要向由 sometext 调用的文章发送参数。

我可以这样做吗???如何通过 URL 传递参数????我怎样才能得到它的价值?

问候

joomla joomla1.5

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

有效地计算空间中的共置

给定折线P = {(x1, y1), ..., (xn, yn)}和另一条折线Q = {(x1, y1), ..., (xm, ym)}(m不等于n,因此折线可以具有不同的长度),当移动物体P和Q的轨迹具有一些共同的位置时,空间中的共置发生(如示例所示的点A,B和C))

这个概念非常简单,视觉角度很容易识别托管发生的位置.最难的部分是如何实现一种有效计算主机托管的算法,并返回发生主机托管的x和y协议!这个算法将在matlab中开发,所以我有必要快速工作.

最好的祝福

gis matlab motion-detection

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

Mocked方法调用中的参数计数不匹配

我有这个方法:

public void Valida(Validazione.IValidator<MyType> validator)
{
    // do something...
    Validazione.IMapper<MyType> mapper = new MyTypeMapper();
    ValidationResult result = validator.Validate(myTypeObj, mapper, new ValidationConfiguration());
    // ...continue doing something else
}
Run Code Online (Sandbox Code Playgroud)

我想进行单元测试,所以我会模拟(使用Moq框架)validator来控制Validate方法的结果,所以我写了这个单元测试:

[TestMethod]
public void Long_test_name_as_best_practice()
{
    // arrange
    MyAggregateRoot aggregateRoot = AggregateRoot.Stub();
    var mockedValidator = new Mock<Validazione.IValidator<MyType>>();

    mockedValidator.Setup(a => a.Validate(
        It.Is<MyType>(x => x.Id == Guid.Parse("3F2504E0-4F89-11D3-9A0C-0305E82C3301")),
        It.IsAny<Validazione.IMapper<MyType>>(), 
        It.IsAny<ValidationConfiguration>()
    )).Returns<Validazione.ValidationResult>(x => x = It.IsAny<Validazione.ValidationResult>());

    // act
    aggregateRoot.Valida(mockedValidator.Object);

    // Assert (now showed for readability sake)
}
Run Code Online (Sandbox Code Playgroud)

它构建,听起来我非常正确,但最终我得到:

mscorlib.dll中出现"System.Reflection.TargetParameterCountException"类型的异常但未在用户代码中处理附加信息:参数计数不匹配

我谷歌周围,但我无法理解原因.对我来说似乎很好.

评论后编辑

这是异常的堆栈跟踪:

   in …
Run Code Online (Sandbox Code Playgroud)

testing automated-tests unit-testing moq mocking

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

使用Unity在WebAPI中注入依赖项

我有一个(应该)看起来像这样的WebAPI控制器:

public class MyController : ApiController
{
    private IRepository repository;

    public MyController(IRepository repository) 
    {
        this.repository = repositor;
    }

    // REST implementations
}
Run Code Online (Sandbox Code Playgroud)

WebApiConfig 配置如下:

public static class WebApiConfig
{
    public static void Register(HttpConfiguration config)
    {
        // Unity configuration
        var container = new UnityContainer();
        container
            .RegisterType<IRepository , CustomRepository>();
        config.DependencyResolver = new UnityResolver(container);

        // Web API routes
        // CORS
    }
}
Run Code Online (Sandbox Code Playgroud)

然后Global.asax.cs我有类似的东西:

public class WebApiApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        GlobalConfiguration.Configure(WebApiConfig.Register);
    }

    // CORS
    protected void Application_BeginRequest(object sender, …
Run Code Online (Sandbox Code Playgroud)

c# unity-container asp.net-web-api

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