小编Phi*_*all的帖子

FB.init已被调用

我正在构建facebook iframe app.我的应用程序加载一次(我收到signed_request一次),然后使用内部域链接浏览iframe中的页面.我注意到我在Chrome和Firefox中看到了这些奇怪的消息

FB.init has already been called - this could indicate a problem
Run Code Online (Sandbox Code Playgroud)

我很确定这种方法只被调用一次,而且似乎Facebook要求我在每次应用程序加载时调用一次(不是每页一次).

window.fbAsyncInit = function() {
  FB.init({
    appId: param('facebook_app_id'),
    frictionlessRequests: true,
    oauth: true,
    channelUrl: site_url('/channel.html')
  })
}
Run Code Online (Sandbox Code Playgroud)

我在这里犯了什么错误(如果有的话)?

facebook opengraph

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

在.NET Core 2.0 Preview 1中使用R.NET.Community

有一段时间,我一直希望在.NET Core应用程序中使用R.NET.Community.显然虽然NuGet包没有移植到.NET Core,但这是一个非首发.但是,随着.NET Core 2.0 Preview 1的发布,你可以从.NET Core引用.NET Framework库,我又说了一遍:

using RDotNet;

namespace RDotNetCore2
{
    class Program
    {
        static void Main(string[] args)
        {
            REngine.SetEnvironmentVariables();
            var engine = REngine.GetInstance();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在新的Visual Studio 2017预览版中将其创建为.NET Core 2.0应用程序,至少可以进行编译和运行,但GetInstance调用时出现错误:

无法加载文件或程序集'System.Security.Permissions,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51'.该系统找不到指定的文件.

有什么我可以做的来解决这个问题,或者这只是.NET Core中不支持的那些内容之一(我怀疑可能是由于.NET Core不支持CAS的事实)?

c# r .net-core

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

Gridview中Parent和NamingContainer有什么区别

这两个陈述有什么区别?特别是,我对哪一个更优化感兴趣.

GridViewRow currentItem = (GridViewRow)drp_Vendor.Parent;
Run Code Online (Sandbox Code Playgroud)

GridViewRow currentItem = (GridViewRow)drp_Vendor.NamingContainer;
Run Code Online (Sandbox Code Playgroud)

asp.net gridview

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

关于抽象属性的MVC属性

我有一个抽象的模型

public abstract class Treasure {
    public abstract int Value { get; }
    public abstract string Label { get; }
}
Run Code Online (Sandbox Code Playgroud)

和实施

public class Coins : Treasure {
    [DisplayName("Coin Value")]
    public override int Value {
        get { ... }
    }

    [DisplayName("Coins")]
    public override string Label {
        get { ... }
    }
Run Code Online (Sandbox Code Playgroud)

当我使用Html.LabelFor它时,我的硬币对象在我的视图中不显示"硬币"作为其标签,它显示"标签".如果我将DisplayName属性移动到Treasure中,它可以工作......但是我需要能够为Treasure类的不同实现更改标签.这可能吗?

.net c# asp.net-mvc

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

是否可以在Spark Streaming中获取每个RDD的前n个元素?

使用Spark Streaming时,是否可以n在DStream中获取每个RDD 的第一个元素?在现实世界中,我的流包含许多地理标记的事件,我想采用最接近给定点的100(或其他)进行进一步处理,但是一个简单的例子显示我正在尝试做什么是这样的:

import org.apache.spark.SparkConf
import org.apache.spark.streaming.dstream.ConstantInputDStream
import org.apache.spark.streaming.{Seconds, StreamingContext}

object take {
  def main(args: Array[String]) {

    val data = 1 to 10

    val sparkConf = new SparkConf().setAppName("Take");
    val streamingContext = new StreamingContext(sparkConf, Seconds(1))

    val rdd = streamingContext.sparkContext.makeRDD(data)
    val stream = new ConstantInputDStream(streamingContext, rdd)

    // In the real world, do a bunch of stuff which results in an ordered RDD

    // This obviously doesn't work
    // val filtered = stream.transform { _.take(5) }

    // In the real world, …
Run Code Online (Sandbox Code Playgroud)

spark-streaming

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

swift中来自前缀头的引用类定义

我正在为现有的Objective-C项目添加swift代码.我在引用现有前缀标头中的定义时遇到问题.

我有一个名为MyClass的类,在Objective-C中用.h定义:

@interface MyClass
+(instancetype)myClass;
-(void)doStuff;
@end
Run Code Online (Sandbox Code Playgroud)

而.m:

@implementation MyClass
+ (instancetype) myClass
{
    // More to it than this, but this illustrates the setup
    return [[MyClass alloc] init];
}

- (void)doStuff
{
    // Do something interesting
}
@end
Run Code Online (Sandbox Code Playgroud)

前缀头MyProj-Prefix.pch包含:

#define MYCLASS MyClass
#define SOMEVAR @"Hello"
Run Code Online (Sandbox Code Playgroud)

我创建了一个桥接头,其中包含:

#import "MyProj-Prefix.pch"
Run Code Online (Sandbox Code Playgroud)

该项目包含使用类定义的Objective-C代码,例如

[[MYCLASS myClass] doStuff];
Run Code Online (Sandbox Code Playgroud)

我想在我的新swift代码中反映这一点.我可以看到并引用已定义的变量,但是定义的类是不可见的.例如

let someStr = SOMEVAR // This compiles
MYCLASS.myClass.doStuff() // MYCLASS isn't visible
Run Code Online (Sandbox Code Playgroud)

关于如何实现这一点的任何指针?我甚至不确定这是否可以迅速实现.

objective-c swift prefixheader.pch

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

notable_for和notable_types属性有什么区别?

我看到有两个/common/topic/notable_types/common/topic/notable_for中游离碱的话题转储性能.

这两者有什么区别?我假设两者都提供了一个值得注意的主题类型.

freebase mql

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

不同顺序的相同声明在gcc中产生不同的结果

问题在第7行: int ret=3, x, y;

如果我首先声明y(如第8行),结果将是不同的

在我的电脑上现在只打印Y值,声明中的这个更改只打印X的值

Makefile文件

gcc -g -o open_file_test open_file_test.c;
./pen_file_test input
Run Code Online (Sandbox Code Playgroud)

码:

#include <stdio.h>
#include <stdlib.h>

int worldsize = 0;

int main(int argc, char const *argv[]){
    int ret=3, x, y;
    //int ret=3, y, x;
    char chr;
    int teste;

    FILE * inputFile;
    inputFile = fopen(argv[1],"r");
    teste = fscanf(inputFile,"%d", &worldsize);
    printf("Tamanho: %d\n", worldsize);

    while(1){
        ret=fscanf(inputFile,"%d %d %s\n", &x, &y, &chr);
        if(ret != 3)
            break;
        printf("x: %d  y: %d\n", x, y);
    }
    printf("End File :D\n");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输入文件 …

c file-io

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

OpenIdConnectEvents中的AuthenticationValidated事件在AspNetCore 1.1中不存在,那么我应该在哪里添加声明客户端

我使用IdentityServer4和OpenId来验证我的MVC应用程序中的用户,并希望添加我自己的声明.但我不确定哪个OpenIdConnectEvents我应该这样做.

教程说我......

在身份验证流程中,您可能希望修改从IDP获得的声明.在ASP.NET Core 1.0中,您可以从OpenID Connect中间件在AuthenticationValidated事件中执行声明转换.

您在AuthenticationValidated期间添加的任何声明都存储在会话身份验证cookie中.

但是,此事件在ASP.NET Core 1.1中不可用

我试图在TokenValidated事件中做到这一点..

var principal = context.Request.HttpContext.User;
principal.Identities.First().AddClaim(new Claim("TenantId", user.TenantId.ToString()));
Run Code Online (Sandbox Code Playgroud)

但是当我在身份验证后列出用户声明时,它未列出.

@foreach (var claim in User.Claims)
{
    <dt>@claim.Type</dt>
    <dd>@claim.Value</dd>
}
Run Code Online (Sandbox Code Playgroud)

c# openid asp.net-core-mvc identityserver4

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

如何在不收到编译器警告的情况下使用C++枚举

我需要传达一个相同的枚举传递给多个调用.所以我这样做:

MiddleEarth::Creatures ally = MiddleEarth::Creatures::Elf;

myEnergy->Transfer(ally, 10);
myLives->Transfer(ally, 1);
Run Code Online (Sandbox Code Playgroud)

两种Transfer方法都声明如下:

Energy::Transfer(const Creatures& transferTo, (snip)
Run Code Online (Sandbox Code Playgroud)

但是,我对名为ally的变量的声明收到以下警告:

 warning C4482: nonstandard extension used: enum 'MiddleEarth::Creatures' used in qualified name
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?如何重写我的代码,以便它不会生成编译器警告?

c++ enums visual-c++

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