小编par*_*ent的帖子

检查所有元素是否满足条件

我需要一个jQuery过滤器/ map /每个类型函数来检查所有元素是否满足条件:

function areAllValid(inputs){
     return $.someFunction(inputs, function(input) { return input.length > 0; }); 
}
Run Code Online (Sandbox Code Playgroud)

如果所有输入的长度> 0,someFunction则返回true.在jQuery中有这样的东西吗?

jquery

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

SQL NO CHECK FOREIGN KEY数据后,重新启用查询优化器

我有一个带有引用的外键约束的SQL Server 2012数据库 Countries.CountryID = States.CountryID

我需要重新创建Countries表,所以我从States表中删除这个FOREIGN KEY (否则它不允许我DROP国家)

在我这样做之后,我想重新创建FK,States但除非我这样指定,否则它不允许我NO CHECK:

ALTER TABLE States 
    WITH NOCHECK
    ADD CONSTRAINT FK_StatesCountries FOREIGN KEY (CountryID) REFERENCES Countries(CountryID) 
GO
Run Code Online (Sandbox Code Playgroud)

我起初并没有意识到有些国家的行CountryID没有匹配Countries.CountryID记录.显然WITH NOCHECK允许我毫无错误地继续前进.

现在SQLServer将此FK标记为"不受信任",MSDN表示通过检查所有约束来重新启用查询优化器.那么,为什么即使某些国家的CountryID无效,以下行也不会给我一个错误?

 ALTER TABLE States
      CHECK CONSTRAINT ALL
 GO
Run Code Online (Sandbox Code Playgroud)

我认为这应该会引起错误.

sql-server foreign-keys

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

如何在Windows的离子视图中调试应用程序?

我非常喜欢我能做到的,ionic upload并立即将我的应用程序放在我的iPhone上!

但我该怎么调试呢?我在Windows上,我发现的所有选项都需要在OSX上.

1)Safari 6远程调试 - 用于Windows的Safari已停止在5.1

2)XCode - nope,在windows上

3)ionic emulate ios -l -c -s 不,在窗户上

我有一台Mac在待机状态下通过vs-mda-remoteVisual Studio Cordova Tools的服务监听构建请求,因此我可以构建和部署到这样的实时设备,但这非常耗时.

如果这是以某种方式与离子视图集成

 ionic upload -l -c -s 
Run Code Online (Sandbox Code Playgroud)

我的生活将会完整.好吧好吧也许我们现在可以没有现场重装,但它有可能吗?

为了澄清,我知道离子服务,但我正在谈论使用IonicView移动应用程序调试电话.我有一个问题,只能通过IonicView应用程序在手机上发生,但无法在浏览器中复制.

cordova ionic-framework visual-studio-cordova ionic ionic-view

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

angular-mocks - 只有模拟显式请求.通过所有意外的请求

我发现角度模拟阻止所有请求BY DEFAULT,并迫使我"直接"发生我想要的东西,这令人非常沮丧.

有时我只想用模拟测试1个url,我必须为每个"意外请求"错误跳过严重的箍.

我不知道正则表达式,我不喜欢正则表达式,我不想使用正则表达式!

看一下我需要的一个简单的模拟这个可怕的代码

 $httpBackend.whenGET(/\/atlas\/account\/[0-9]+$/)
     .respond(atlasAccounts[0]);

  $httpBackend.whenGET(/\/scripts$/).passThrough();     
  $httpBackend.whenGET(/^\w+.*/).passThrough();     
  $httpBackend.whenPOST(/^\w+.*/).passThrough(); 
Run Code Online (Sandbox Code Playgroud)

为什么这不能简化为一行???

 $httpBackend.whenGET(/\/atlas\/account\/[0-9]+$/)
     .respond(atlasAccounts[0]); 
Run Code Online (Sandbox Code Playgroud)

或者甚至更好,为什么它不支持该死的通配符?他们是否试图让开发人员的生活变得更难?

  $httpBackend.whenGET("/atlas/account*") 
     .respond(atlasAccounts[0]);
Run Code Online (Sandbox Code Playgroud)

这就是我所需要的,只要它是直观的......

有没有办法在ngMock中禁用这个全有或全无的约定,并且只是拦截我明显嘲笑的网址?

angular-mock

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

打字稿在保存时编译为单个文件

我正在使用TypeScript 0.8.3并试图在保存时进行编译工作.

我的设置有点不同但应该真的有效.请记住,当我构建项目时,它工作正常,而不是保存:

显然,第一件事:工具>选项>文本编辑器> TypeScript>项目>编译保存设置为"自动编译作为项目一部分的TypeScript文件"

然后在我的.csproj文件中

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptSourceMap>true</TypeScriptSourceMap>
    <TypeScriptIncludeComments>true</TypeScriptIncludeComments>
    <TypeScriptGeneratesDeclarations>false</TypeScriptGeneratesDeclarations>
    <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
    <TypeScriptOutFile>application.js</TypeScriptOutFile>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptSourceMap>false</TypeScriptSourceMap>
    <TypeScriptIncludeComments>false</TypeScriptIncludeComments>
    <TypeScriptGeneratesDeclarations>false</TypeScriptGeneratesDeclarations>
    <TypeScriptModuleKind>AMD</TypeScriptModuleKind>
    <TypeScriptOutFile>application.js</TypeScriptOutFile>
  </PropertyGroup>

  <!-- this imports the code below from Microsoft.Typescript.targets -->
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />
Run Code Online (Sandbox Code Playgroud)

我更改了Microsoft.TypeScript.targets,如下所示:

<Target Name="CompileTypeScript">
   <Message Text="Compiling TypeScript files" />
   <Message Text="Creating response file typescriptcompiler.input" />
   <WriteLinesToFile
      File="typescriptcompiler.input"
      Lines="&quot;C:\MyProject\MyProject.Web\Scripts\_references.ts&quot;" <!-- recursively gets individual file paths referenced therein -->
      Overwrite="true"
      Encoding="Unicode"/>

  <Message Text="Executing tsc $(TypeScriptBuildConfigurations) @typescriptcompiler.input" />
  <Exec …
Run Code Online (Sandbox Code Playgroud)

typescript

15
推荐指数
2
解决办法
6769
查看次数

Angular - 使用Restangular时中止ajax请求

我有一个调用角度服务的方法,因此通过服务发出ajax请求.我需要确保如果多次调用它,则中止先前的请求(如果尚未解决的话).

这种方法可以被多次调用.这个方法实际上来自ngTable ngTableParams:

getData = function($defer, params) {

      myService.getRecord(params).then(function(res){ 
             ...
             $defer.resolve(res.Records);
      }); 
}
Run Code Online (Sandbox Code Playgroud)

这是服务的方法:

this.getRecords = function(params) {
    ...

    return Restangular
          .all('/api/records')
          .post(filters);
};
Run Code Online (Sandbox Code Playgroud)

如果ngTable进行3次调用,我希望中止前2次(除非他们返回得太快以至于它已经解决)

angularjs restangular

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

控制柔性容器中垂直排列的柔性物品的宽度

我试图达到标记为"HALF"的框的效果,仅占据宽度的50%(也就是说它们均匀地共享第一行).

基本要求是它们保留在单个容器中.这有可能实现使用flexbox吗?

我试着玩弄flex-grow,flex-shrink以及flex-basis但是我怕我不理解如何使它工作,或者如果它给出的单容器的要求甚至有可能.

考虑这个小提琴:http://jsfiddle.net/GyXxT/270/

div {
  border: 1px solid;
}

.container {
  width: 400px;
  display: flex;
  flex-direction: column;
}
.child {
  
  height: 200px;
}
.child.half {
  flex: 1 1 10em;
  color: green;
}

.child:not(.half) {

  flex-shrink: 2;
  flex-basis: 50%;
  color: purple; 
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div class="child half">
    HALF
  </div>
  
  <div class="child half">
    HALF
  </div>
  
   <div class="child">
    FULL
  </div>
   <div class="child">
    FULL
  </div>
  <div class="child">
    FULL
  </div>
   <div class="child">
    FULL
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

html css css3 word-wrap flexbox

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

DateTime Round Up和Down

我一直在寻找一个合适的舍入机制,但我找不到似乎正是我需要的东西.

我需要分别向上和向下舍入,我还需要考虑到已经四舍五入的情况.

我需要进行以下四舍五入

5:00 -> RoundDown() -> 5:00
5:04 -> RoundDown() -> 5:00
5:09 -> RoundDown() -> 5:00
5:10 -> RoundDown() -> 5:10

4:00 -> RoundUp() -> 4:00
4:50 -> RoundUp() -> 4:50
4:51 -> RoundUp() -> 5:00
4:56 -> RoundUp() -> 5:00 
Run Code Online (Sandbox Code Playgroud)

基本上我需要将RoundUp()或RoundDown()显式地提交到最近的10分钟,但如果它已经是10分钟的倍数,它也应该保持时间不变.此外,我想截断它们对舍入过程没有影响的任何秒数

4:50:45 - > 4:50:00 - > RoundUp() - > 4:50

有没有人有任何方便的代码来实现这一目标.

我在某个地方找到了这个代码,但是它在5:00 - > RoundUp() - > 5:10之后发现,而不是保持完整,因为它已经是10的倍数而不需要舍入.我也不确定秒会影响它

public static DateTime RoundDateTime(this DateTime dt, int minutes, RoundingDirection direction)
{
    TimeSpan t;
    switch (direction)
    {
        case RoundingDirection.Up: …
Run Code Online (Sandbox Code Playgroud)

.net c# datetime rounding

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

Autofac - 无法创建请求生命周期范围,因为HttpContext不可用 - 由于异步代码?

简短问题:与此未解决的问题相同

长问题:

我刚刚从MVC 4 + Web Api解决方案中移植了一些代码,该解决方案使用Autofac进入我的新解决方案,该解决方案也使用Autofac但仅使用Web Api 2(没有MVC 5.1项目,只有web api).

在我之前的解决方案中,我有MVC4和Web Api所以我有2个Bootstrapper.cs文件,每个文件一个.我复制了新项目的Web Api引导程序.

现在我在新解决方案中有两个需要依赖的项目.让我们假设我必须使用DependencyResolver.Current.GetService<T>()尽管它是一个反模式.

起初,直到我将MVC依赖关系解析器设置为同一个容器,这才起作用:

GlobalConfiguration.Configuration.DependencyResolver = 
     new AutofacWebApiDependencyResolver(container);

//I had to pull in Autofac.Mvc and Mvc 5.1 integration but this line fixed it
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
Run Code Online (Sandbox Code Playgroud)

奇怪的是,这样做只能在其中一个项目中修复它!情况如下:

 Solution.Web project
      Bootstrapper.cs that registers both dependency resolvers for web api and mvc.

 Solution.ClassLib project
      var userRepo = DependencyResolver.Current.GetService<IUserRepo>(); //Good! :)

 Solution.WindowsWorkflow project
      var userRepo = DependencyResolver.Current.GetService<IUserRepo>(); //Throws exception :(
Run Code Online (Sandbox Code Playgroud)

例外情况是:无法创建请求生存期范围,因为HttpContext不可用.

现在,在我们开始指责工作流程之前,只知道我已经在另一个解决方案中使用了这个确切的设置,工作流程能够正常使用DependencyResolver.所以我怀疑这与使用更新版本的Autofac以及工作流异步运行的事实有关(就像我关于异步代码链接的问题一样)

我尝试使用切换所有注册代码InstancePerLifetimeScope()而不是InstancePerHttpRequest()尝试创建范围:

using (var …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc autofac asp.net-web-api dependency-resolver

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

jQuery UI保持工具提示打开以进行调试(为其设置样式)

我正在尝试设置jQuery UI工具提示的样式,但它一直在关闭.我试过以下但没有成功:

 $("td label").tooltip({

    disabled: true,
    close: function (event, ui) { return false; }

 }).on("click", function () {

    $(this).tooltip("open");
 }).off('focusout mouseleave mouseenter');
Run Code Online (Sandbox Code Playgroud)

似乎没有什么能保持开放.当我右键点击它去Firebug时,它在我有机会之前消失了.

jquery jquery-ui jquery-ui-tooltip

13
推荐指数
3
解决办法
9258
查看次数