问题列表 - 第144229页

找到 jsfiddle 的分叉

我正在研究一个 jsfiddle,我有它的 url。但是,我随后对其进行了分叉,但似乎无法在浏览器的历史记录中找到此分叉。它也不是在我的用户帐户下制作的。谁能建议我如何找到它?

jsfiddle

5
推荐指数
0
解决办法
662
查看次数

MVC5 ApplicationUser自定义属性

我试图掌握ASP.NET MVC 5中引入的新成员系统,我遇到了一个小问题,我相信你能帮助我.

我将基于本教程并向ApplicationUser引入自定义属性,例如Name,Surname,DOB等.

但是,我试图更新当前登录的用户,而不是创建用户.我正在查看当前用于更改密码的控制器方法.

public async Task<ActionResult> Manage(ManageUserViewModel model)
        {
            string userId = User.Identity.GetUserId();
            bool hasLocalLogin = await IdentityManager.Logins.HasLocalLoginAsync(userId);
            ViewBag.HasLocalPassword = hasLocalLogin;
            ViewBag.ReturnUrl = Url.Action("Manage");

            if (hasLocalLogin)
            {               
                if (ModelState.IsValid)
                {
                    IdentityResult result = await IdentityManager.Passwords.ChangePasswordAsync(User.Identity.GetUserName(), model.OldPassword, model.NewPassword);
                    if (result.Success)
                    {
                        return RedirectToAction("Manage", new { Message = "Your password has been changed." });
                    }
                    else
                    {
                        AddErrors(result);
                    }
                }
            }
            else
            {
                // User does not have a local password so remove any validation errors caused by …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc asp.net-mvc-5 asp.net-identity

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

词典在python的所有语言?

在python中获取单词同义词的代码是:

from nltk.corpus import wordnet

dog = wordnet.synset('dog.n.01')
print dog.lemma_names

>>['dog', 'domestic_dog', 'Canis_familiaris']
Run Code Online (Sandbox Code Playgroud)

然而dog.n.02给出了不同的词.对于任何单词我都不知道可能有多少单词.如何返回单词的所有同义词?

python nltk wordnet

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

如何在使用asp.net标识更改当前用户的UserName后更改身份验证cookie

将asp.net身份版本1.0.0-rc1与Entity Framework 6.0.0-rc1(Visual Studio 2013 RC附带的那些)一起使用.

试图让用户有机会改变他们的UserName.似乎没有功能AuthenticationIdentityManager,所以我使用EF更改数据(获取当前用户的User对象,更改UserName并保存更改).

问题是认证cookie保持不变,下一个请求失败,因为没有这样的用户.

在过去的表单身份验证中,我使用以下代码来解决此问题.

var formsAuthCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
var isPersistent = FormsAuthentication.Decrypt(formsAuthCookie.Value).IsPersistent;
FormsAuthentication.SetAuthCookie(newUserName, isPersistent);
Run Code Online (Sandbox Code Playgroud)

我该怎么做asp.net身份更新cookie?

UPDATE

以下代码似乎更新了身份验证cookie.

var identity = new ClaimsIdentity(User.Identity);
identity.RemoveClaim(identity.FindFirst(identity.NameClaimType));
identity.AddClaim(new Claim(identity.NameClaimType, newUserName));
AuthenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant
    (new ClaimsPrincipal(identity), new AuthenticationProperties {IsPersistent = false});
Run Code Online (Sandbox Code Playgroud)

剩下的问题是:如何IsPersistent从当前身份验证cookie中提取值?

owin asp.net-mvc-5 asp.net-identity

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

如何在SQL Server Management Studio中设置1到0 ... 1的关系

我有桌子:

Users{UserId ...}
Professors{UserId ...}
Run Code Online (Sandbox Code Playgroud)

UserId在两个表中都设置为PK并且建立了1:1的关系.

但是,如果我尝试插入新用户,它不起作用,因为它也需要在Professor表中插入.

我想让一个用户在教授表中只能有1条记录,但我也想让它不必存在于教授表中(我不想让所有用户教授:)).

如何在SQL Server Management Studio中设置1到(0 ... 1)的关系?

我知道set强制关键约束NO不是解决方案:)

sql database database-design ssms relational-database

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

部署Rails时Nginx未知指令"上游"错误

我正在尝试安装标准的Rails应用程序.在完成教程https://coderwall.com/p/yz8cha后,我陷入了最后一步.

当尝试重新启动nginx时,我收到以下错误 - Restarting nginx: nginx: [emerg] unknown directive "upstream" in /etc/nginx/nginx.conf:1 ; nginx: configuration file /etc/nginx/nginx.conf test failed

我严格遵循https://coderwall.com/p/yz8cha中的所有步骤,因此我的conf文件和unicorn.rb文件与projectname和user中的更改非常相似.

我的nginx conf文件 - http://pastebin.com/bd0RRDxK

nginx unicorn

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

是否可以在C中进行递归类型定义

我想定义一个函数类型,它返回一个指向同一类型函数的指针.我试过这个:

typedef state* (*state)(lex*);
Run Code Online (Sandbox Code Playgroud)

但我得到的syntax error就像你猜的那样.

c syntax types

6
推荐指数
0
解决办法
423
查看次数

为什么iOS自动布局导致Retina前显示屏出现明显的舍入错误(包括单元测试)

我目前很难理解为什么以下单元测试在iPad 2上失败.相对于两个布局约束所需的精确居中,自动布局似乎略微(0.5点)view内部误定位superview.看起来特别奇怪的是,关键测试(但最后断言)传递给iPhone 5,因此明显的舍入错误仅影响一个(iOS 6)平台.这里发生了什么?

更新1我已经改变了代码,以确保这两个帧的宽度和高度方面得到充分的约束,即使translatesAutoresizingMaskIntoConstraintsNO,所建议的可能相关的补救措施在这里.但是,这显然不会改变这种情况.

#import "BugTests.h"

@implementation BugTests

- (void)testCenteredLayout {
    UIView *superview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 88)];
    superview.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
    superview.translatesAutoresizingMaskIntoConstraints = YES;

    UILabel *view = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    view.text = @"Single Round against iPad.";
    view.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
    view.translatesAutoresizingMaskIntoConstraints = NO;
    [view addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeWidth  relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:206.0]];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch ios retina-display autolayout

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

Linux中C/Socket编程中的聊天室

我有一个简单的服务器和客户端C代码,用于使用线程(pthread库)为多客户端做一个聊天室.我遇到的问题是我无法想到让服务器将客户端通过套接字发送的每条消息写入所有其他客户端的方法.我在这里读过其他类似的帖子,这很无奈.请帮帮我,我需要在学校这样做.我会马上发送两个代码.

Server.c:

#include<stdio.h>
#include<string.h>    //strlen
#include<stdlib.h>    //strlen
#include<sys/socket.h>
#include<arpa/inet.h> //inet_addr
#include<unistd.h>    //write

#include<pthread.h> //for threading , link with lpthread

void *connection_handler(void *);


int main(int argc , char *argv[])
{
    int socket_desc , new_socket , c , *new_sock;
    struct sockaddr_in server , client;
    char *message;

    //Create socket
    socket_desc = socket(AF_INET , SOCK_STREAM , 0);
    if (socket_desc == -1)
    {
        printf("Could not create socket");
    }

    //Prepare the sockaddr_in structure
    server.sin_family = AF_INET;
    server.sin_addr.s_addr = INADDR_ANY;
    server.sin_port = htons( 8888 );

    //Bind
    if( …
Run Code Online (Sandbox Code Playgroud)

c sockets linux chat pthreads

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

如何检查字符串是否可以在C++中转换为double?

我有一个字符串,可以是一个数字(甚至是浮点数或双精度型,不仅仅是整数),它也可以是一个非数字的单词.

我想检查这个字符串是否可以转换为double,如果是,那么我想进行转换.如果是非数字字符串,我想要不同的行为.

我试过这个:

double tmp;
string str;
stringstream ss;

ss << str;
ss >> tmp;

if (ss.fail())
{
    // non-numeric string
}
else
{
    // string to double conversion is successful
}
Run Code Online (Sandbox Code Playgroud)

这段代码的问题在于ss.fail()始终true,即使tmp包含了正确的价值.

有一个函数调用atof()将string转换为double,但这不适合我,因为0.0如果输入字符串是非数字的,它会返回值.这样我就无法区分非数字和零输入值.

c++ string double

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