小编Ale*_*x M的帖子

服务工作者和AJAX

我试图使用AJAX来检索我想在用户端显示的推送通知的详细信息,但它还没有工作.

/*
*
*  Push Notifications codelab
*  Copyright 2015 Google Inc. All rights reserved.
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      https://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES …
Run Code Online (Sandbox Code Playgroud)

javascript ajax service-worker

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

Arrays.copyOfRange(byte [],int,int)背后的逻辑是什么奇怪的行为?

谁能解释一下Arrays.copyOfRange(byte [],int,int))奇怪行为背后的逻辑?我可以用简单的例子来说明我的意思:

byte[] bytes = new byte[] {1, 1, 1};
Arrays.copyOfRange(bytes, 3, 4); // Returns single element (0) array
Arrays.copyOfRange(bytes, 4, 5); // Throws ArrayIndexOutOfBoundsException
Run Code Online (Sandbox Code Playgroud)

在这两种情况下,我都会复制数组边界之外的范围(即start >= array.length),因此错误的条件对我来说至少是奇怪的(如果from < 0from > original.length).在我看来应该是:如果from < 0from >= original.length.也许我错过了什么?

java arrays standard-library

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

Facebook广告Sdk不允许通过API发布广告.子代码:1487930

我已经阅读了很多关于facebook广告和东西的内容,使用GUI它可以做我正在做的事情,并且出于某种原因,它没有.

我在Facebook广告sdk子代码1487930上得到了这个suberror代码.

消息说:

您必须选择要推广的对象,用户消息说明:您的广告系列必须>包含一个广告集,其中包含与您的目标相关的所选对象>>(例如:页面,网址,事件).请更新您的广告集以继续.

响应不返回任何字段,并且在创建广告素材时发生错误: $creative->create();

我设置我的adset是这样的:

    use Facebook;
    use FacebookAds\Api;
    use FacebookAds\Object;
    use Facebook\Exceptions;

        $inventory = new Models\AdvertisingInventory();
        $item = $inventory->getListing($id)->getAttributes();
        $item['properties'] = json_decode($item['properties'], true);

        /**
         * Step 1 Instantiate an API
         *
         * @link https://developers.facebook.com/docs/marketing-api/sdks#init-sdk
         */

        try {
            Api::init($this->app_id, $this->app_secret, $this->access_token);
        } catch (\Exception $e) {
            return $this->AdvertisingRenderErrorMessage($e);
        }

        /**
         * Step 2 Query to create campaign
         * @var $campaign
         * @link https://developers.facebook.com/docs/marketing-api/reference/ad-campaign-group
         *
         * TODO: Implement ad image widget sizing: https://www.facebook.com/business/help/103816146375741
         */
        try …
Run Code Online (Sandbox Code Playgroud)

facebook facebook-graph-api facebook-ads-api facebook-php-sdk

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

如何从承诺中退出承诺?

如何从承诺中退出承诺?perl6文档不提供简单的方法.例如:

my $x = start {
    loop { # loop forever until "quit" is seen
        my $y = prompt("Say something: ");
        if $y ~~ / quit / { 
            # I want to exit the promise from here; 
            # "break" and "this.break" are not defined;
            # "return" does not break the promise;
            # I do NOT want an error exception when exiting a promise;
            # I want to return a value as the result of this promise;
        }
        else { say …
Run Code Online (Sandbox Code Playgroud)

break perl6 promise

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

如何根据sql中的当前日期获取上周的日期范围?

我在水晶报告中有这个代码,根据当前日期给我上周的日期范围.

一周的第一天:

If DayOfWeek(currentdate) = 2 Then
currentdate
Else If DayOfWeek(currentdate) = 3 Then
dateadd ("d",-1,currentdate)
Else If DayOfWeek(currentdate) = 4 Then
dateadd ("d",-2,currentdate)
Else If DayOfWeek(currentdate) = 5 Then
dateadd ("d",-3,currentdate)
Else If DayOfWeek(currentdate) = 6 Then
dateadd ("d",-4,currentdate)
Else If DayOfWeek(currentdate) = 7 Then
dateadd ("d",-5,currentdate)
Else If DayOfWeek(currentdate) = 1 Then
dateadd ("d",-6,currentdate)
Run Code Online (Sandbox Code Playgroud)

一周的最后一天:

If DayOfWeek(currentdate) = 2 Then
dateadd ("d",+6,currentdate)
Else If DayOfWeek(currentdate) = 3 Then
dateadd ("d",+5,currentdate)
Else If DayOfWeek(currentdate) = 4 Then
dateadd ("d",+4,currentdate) …
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2008

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

Angular-cli构建文件夹结构

默认的angular-cli构建生成具有非常扁平结构的dist文件夹 - assets文件夹和js,html文件.有没有办法创造fe.脚本文件夹并在构建过程中将所有js文件放入其中?

typescript angular-cli angular

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

不一致的可访问性:基类比类不易访问

我有下面的代码,我正在尝试做一些继承练习,但是当我尝试运行这段代码时,它给了我一个错误:

Inconsistent Accessability: Base Class is less accessible than class
Run Code Online (Sandbox Code Playgroud)

代码:

class Program
{
    static void Main()
    {

        FoodProducts Test = new FoodProducts();

        Test.Limit();



    }
}

public class FoodProducts : Products
{
    public void FoodProduct()
    {
        Console.WriteLine("This is food product");
    }

    public void Limit()
    {
        Console.WriteLine("This is an Attribute of a Product");
    }

}
Run Code Online (Sandbox Code Playgroud)

有人能帮助我吗?

c# inheritance

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

用户'root'@'localhost'拒绝访问 - 终端,Mac

我试图访问mysql时遇到困难.这是我的第一次,所以请耐心等待我.

最初我尝试设置Ruby和Rails,并且在连接到服务器时,一切都正常工作,期望访问被拒绝,所以我运行了这个命令.

mysql -uroot -p
Run Code Online (Sandbox Code Playgroud)

我尝试了各种密码,包括将其留空并得到此错误.

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Run Code Online (Sandbox Code Playgroud)

我假设我需要重置root用户的密码,但我似乎无法让它工作.

mysql terminal

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

图像的路径不在Angular 2中工作

我放在我网站上的所有内容都能正常运行,但我尝试放入网站的每个图像(背景除外)都会返回一个404 Not Found Error.

我的所有图像都位于"Project/src/assets/images",我在我的html文档中尝试了以下img标记.文档位于"Project/src/app/tabs"中.

<img src="src/assets/images/image_name.jpg"> 
<img src="/src/assets/images/image_name.jpg">
<img src="./src/assets/images/image_name.jpg">
Run Code Online (Sandbox Code Playgroud)

我使用css为我的页面设置了背景图像,它可以工作.这是我应用的选择器和属性:

background: url('assets/images/greybackground.jpg') no-repeat center center fixed;
Run Code Online (Sandbox Code Playgroud)

如何在不收到404错误的情况下将图像添加到HTML文档中?

html css image angular

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

pdb:在不在 sys.path 中的文件上设置断点

我正在编写一个 python 包,我想使用 pdb 来调试它。当我尝试在其中一个文件中设置断点时,出现错误:

The specified object 'CaptureManager.frame' is not a function or was not found along sys.path
Run Code Online (Sandbox Code Playgroud)

我google了一下,找到了解决办法:

将包含我的文件的目录附加到 sys.path

sys.path.append(os.path.join(os.getcwd(),"project_cameo"))
Run Code Online (Sandbox Code Playgroud)

但是几次之后,我变得非常恼火,因为每次重新启动调试会话时我都必须这样做。有没有一种“聪明”的方法来做到这一点?

python pdb

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