小编Sex*_*yMF的帖子

Javascript - 生成随机深色

我有这种方法为我生成随机颜色的字体:

function getRandomRolor() {
     var letters = '0123456789ABCDEF'.split('');
     var color = '#';
     for (var i = 0; i < 6; i++) {
         color += letters[Math.round(Math.random() * 15)];
     }
     return color;
}  
Run Code Online (Sandbox Code Playgroud)

问题是字体总是在白色背景上,我想生成深色.
可能吗?
谢谢

javascript random colors

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

PHP投射到我的班级

为什么这是不可能的:

$user = (User) $u[0];
Run Code Online (Sandbox Code Playgroud)

但这是可能的

$bool = (boolean) $res['success'];
Run Code Online (Sandbox Code Playgroud)

我使用PHP 7.0.

php casting

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

使用带有静态页面插件的前端编辑器

我真的很新ocms,我已经安装了静态页面,它的工作非常好.我想使用其中一个插件编辑首页(在上下文编辑中)的字段,例如:https://octobercms.com/plugin/netsti-editor我已经拖到我的布局页面,但我可以' t在首页编辑此内容.这是我如何使用静态页面插件的示例:

<img src="{mediafinder name="logo" label="Logo" tab="General" mode="image"}{/mediafinder}" />

{repeater name="side_logos" tab="General" prompt="Add another content section"} {text name="my_title" label="My Title"}{/text} {/repeater}
Run Code Online (Sandbox Code Playgroud)

谢谢

php octobercms octobercms-plugins

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

Resharper - 如何禁用查找用法或使用旧的查找用法

我无法忍受resharper找到用法.
我该如何回到默认状态?(F12/Shift F12)?
(Visual Studio 2010)

谢谢

resharper visual-studio-2010

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

WCF aspNetCompatibilityEnabled ="true"引发异常(无法加载)

我需要在我的WCF服务中启用会话.所以我必须要:

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我得到一个例外:

无法激活该服务,因为它不支持ASP.NET兼容性.为此应用程序启用了ASP.NET兼容性.在web.config中关闭ASP.NET兼容模式或将AspNetCompatibilityRequirements属性添加到服务类型,其RequirementsMode设置为"允许"或"必需"

这是我的web.config:

<compilation debug="true">
  <assemblies>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  </assemblies>
</compilation>
Run Code Online (Sandbox Code Playgroud)

<services>
  <service behaviorConfiguration="ExecutionEngine.AccountsBehavior" name="WebService.Services.Accounts">
    <endpoint address="" binding="wsHttpBinding" contract="WebService.Services.IAccounts" bindingConfiguration="SafeServiceConf">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>



<behaviors>
  <serviceBehaviors>
    <behavior name="defaultBehavior">
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceMetadata httpGetEnabled="true" />
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
    <behavior name="ExecutionEngine.AccountsBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceCredentials>
        <userNameAuthentication
             userNamePasswordValidationMode="Custom"
             customUserNamePasswordValidatorType="WebService.Services.Security.CustomValidator,WebService" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>



<bindings>





  <wsHttpBinding>
    <binding …
Run Code Online (Sandbox Code Playgroud)

c# asp.net session wcf

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

从Application_Error中抛出http异常(Unauthorized)

我试图从Global asax Application_Error中抛出此行

throw new HttpException((int)HttpStatusCode.Unauthorized, "Forbidden");
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,我在浏览器中得到200而不是401,你知道为什么吗?

更新:

protected void Application_Error(object sender, EventArgs e)
{        
    throw new HttpException((int)HttpStatusCode.Unauthorized, "Forbidden");
}
Run Code Online (Sandbox Code Playgroud)

c# httpexception http-status-code-403 asp.net-mvc-3

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

为什么在我的TypeScript项目中没有react-tap-event-plugin?

我正在尝试使用material-ui,react-tap-event-plugin但是在加载应用程序时出现此错误:

react-dom.js:18238 Warning: Unknown prop `onTouchTap` on <button> tag. Remove this prop from the element. For details, see https://....
  in button (created by EnhancedButton)
  in EnhancedButton (created by IconButton)
  in IconButton (created by AppBar)
  in div (created by Paper)
  in Paper (created by AppBar)
  in AppBar (created by AppLayout)
  in div (created by AppLayout)
  in div (created by AppLayout)
  in AppLayout
  in MuiThemeProvider
Run Code Online (Sandbox Code Playgroud)

这是我的index.tsx档案:

import * as injectTapEventPlugin from 'react-tap-event-plugin';

injectTapEventPlugin();//I am able to …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs

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

Nestjs 微服务 - 有一个 clientProxy 将消息发布到任何微服务

有时,你想说:“我有这个消息,谁能处理它?”
nestjs客户端代理中直接绑定到单个microservice.

因此,举个例子,假设我有以下微服务: CleaningServiceFixingService
上面两个都可以处理消息car,但是只能CleaningService处理消息glass

所以,我想要这样的东西:

this.generalProxy.emit('car', {id: 2});
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我想要2 个不同的 microservices来处理汽车:CleaningServiceFixingService

在这种情况下:

this.generalProxy.emit('glass', {id: 5});
Run Code Online (Sandbox Code Playgroud)

我只想CleaningService处理它。

这怎么可能?我如何创建clientProxy不直接绑定到specific microservice.

microservices nestjs

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

访问c#web应用程序中的内容文件

我现在已经有3天这个问题了.
我有一个标记为Content和的xml文件Always Copy.
该文件已复制到:
C:\Users\avi\Documents\Visual Studio 2010\Projects\ExpressBroker\ExpressBroker\bin\XMLMetadata\Actions.1.xml

访问文件时:

//like that:
XDocument actions = XDocument.Load("bin\\XMLMetadata\\Actions.1.xml");
//or like that:
XDocument actions = XDocument.Load("XMLMetadata\\Actions.1.xml");
//or like that:
XDocument actions = XDocument.Load("Actions.1.xml");
Run Code Online (Sandbox Code Playgroud)

我得到以下异常: Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Program Files\IIS Express\bin\XMLMetadata\Actions.1.xml'.

为什么在IIS文件夹中搜索过?我该如何访问该文件?

我正在使用IIs Express和VWD2010

c# xml iis linq-to-xml virtual-directory

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

从.cs文件获取特定方法源代码(在运行时)

1 -我在光盘上有这个文件内容(cs文件,未编译):

    namespace Test
    {
        using System;
        public class TestClass 
        {
            public string SomeTestMethod(){
                return "test here";
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

如何将运行时间输入变量方法:

public string SomeTestMethod(){
    return "test here";
}
Run Code Online (Sandbox Code Playgroud)

例如: SourceCodeParser.GetMothod("path to file","SomeTestMethod");

2 - 访问者成员的内容是否可能?

   public string SomeMember {
        get {
            return "test here";
        }
    }
Run Code Online (Sandbox Code Playgroud)

c# parsing

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