小编san*_*den的帖子

在Visual Studio代码中提取TypeScript方法

在编写TypeScript时是否有可能在Visual Studio Code中使用快捷方式提取方法?

function printOwing() {
  printBanner();

  // Print details
  console.log("name:  " + name);
  console.log("amount " + amount);
}
Run Code Online (Sandbox Code Playgroud)

因此,我可以通过一个快捷方式提取printDetails():

function printOwing() {
  printBanner();
  printDetails();
}

function printDetails() {
  console.log("name:  " + name);
  console.log("amount " + amount);
}
Run Code Online (Sandbox Code Playgroud)

类似的Eclipse→右键→ 重构提取方法.......

refactoring typescript visual-studio-code

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

Eclipse OS X调试历史记录的快捷方式

有没有一种快速方法可以通过使用键盘在OS X上的eclipse中获取调试历史记录?

在Windows上,你可以做到

Alt,R,H,Number

从历史记录或简单地调用第n个条目

Alt,R,H,Return

调用最后一个条目(例如最后一个测试).

OS X有哪些可能性?

java eclipse macos

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

JQuery datepicker允许用户设置年份

我正在使用datepicker jquery插件以及下面的设置.

$("#date").datepicker({
    showButtonPanel: true,
    changeMonth: true,
    changeYear: true,
    showOtherMonths: true,
    selectOtherMonths: true 
});
Run Code Online (Sandbox Code Playgroud)

现在我想要做的是允许用户设置年份.我的意思是通过手动更改选择下拉列表的输入.

有没有设置呢?

我想这样做的原因是因为我不知道,如果用户选择的是1920年或2220年或任何年份的日期.所以我没有一个好的默认日期值.如果你必须点击20次从2000年到1600年,下拉界面对用户不友好.

编辑:我想做的是来自keith-wood.name/datepick.html#monthyear的"显示无限年份:".是否有与标准jquery datepicker类似的东西.我在jquery datepicker文档中找不到设置yearRange:'any'.

jquery jquery-ui jquery-ui-datepicker

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

Solr Suggestion(Spellcheck)多项查询的动态字段选择

我正在使用具有以下配置的solr建议组件:

schema.xml中

<fieldType name="textSpell" class="solr.TextField">
 <analyzer>
   <tokenizer class="solr.StandardTokenizerFactory"/>
   <filter class="solr.LowerCaseFilterFactory"/>
 </analyzer>
</fieldType>
<field name="image_memo" type="text_general"/>
<field name="username" type="text_general"/>
<field name="image_memo" type="text_general"/>
<field name="image_text" type="text_general"/>
<!-- More fields included here -->
<field name="spell" type="textSpell" indexed="true" stored="true" multiValued="true"/>
<copyField source="*" dest="spell"/>
Run Code Online (Sandbox Code Playgroud)

solrconfig.xml中

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
        <str name="name">suggest</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
        <str name="field">spell</str>
        <str name="buildOnCommit">true</str>
    </lst>
</searchComponent>

<requestHandler class="org.apache.solr.handler.component.SearchHandler"
    name="/suggest">
    <lst name="defaults">
        <str name="spellcheck">true</str>
        <str name="spellcheck.dictionary">suggest</str>
        <str name="spellcheck.onlyMorePopular">true</str>
        <str name="spellcheck.count">6</str>
        <str name="spellcheck.collate">true</str>
        <str name="spellcheck.collateExtendedResults">true</str>
        <str name="spellcheck.collate">true</str>
        <str name="spellcheck.maxCollations">6</str>
        <str name="spellcheck.maxCollationTries">1000</str> …
Run Code Online (Sandbox Code Playgroud)

lucene solr solr-schema

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

RESTFul平面层次结构与搜索资源的动态层次结构

我们正在创建REST API,目前我们有两种方法来定义资源.

基本上我们有Patients,Studies并且Imagesa Patientn Studies和a Studyn Images.

分层方法

/webapi/patients/0/studies/12/images 
Run Code Online (Sandbox Code Playgroud)

层次结构在URI中可见

要搜索所有图像,我们需要搜索资源

 /webapi/search?q=imageName:mountain
Run Code Online (Sandbox Code Playgroud)

扁平的方法

/webapi/patients/0
/webapi/studies/12
/webapi/images/
Run Code Online (Sandbox Code Playgroud)

层次结构由属性完成(例如,study 12具有patientId0).

要搜索所有图像,我们可以搜索资源本身:

 /webapi/images?q=imageName:mountain
Run Code Online (Sandbox Code Playgroud)

是否有最佳实践方法或者是否有人遇到类似的情况?是一个搜索资源REST还是在平面方法中图像的关系不可见是不好的.

我们还需要考虑移动和修改.

rest uri restful-architecture

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

Gradle合并Junit报告

gradle中有没有一种方法可以将junit xml报告合并到单个测试报告文件中。

当我们在ant中使用cp-suite执行IntegrationTestSuite.java时,只有一个junit报告。在gradle上创建了多个junit报告。

IntegrationTestSuite.java

@RunWith(Categories.class)
@Categories.IncludeCategory(IntegrationTests.class)
@Categories.ExcludeCategory(DebugJenkinsTests.class)
@Suite.SuiteClasses(AllTestSuite.class)
public class IntegrationTestSuite { /* nop */
}
Run Code Online (Sandbox Code Playgroud)

摘自 build.xml

<junit>
   <formatter type="xml" />
      <batchtest todir="${testreport.dir}">
          <fileset dir="${test-src.dir}">
              <include name="**/IntegrationTestSuite.java" />
          </fileset>
       </batchtest>
</junit>
Run Code Online (Sandbox Code Playgroud)

摘自 build.gradle

task integrationTestSandro(type: Test) {
    reports.html.enabled = false
    include '**/IntegrationTestSuite*'
    reports.junitXml.destination = "$buildDir/test-results/integration"
    maxHeapSize = testTaskMaxHeapSize
    jvmArgs testTaskJVMArgs
}
Run Code Online (Sandbox Code Playgroud)

junit gradle

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

Servlet Ajax全局异常处理

我有一个AJAX调用的全局处理程序

$.ajaxSetup({
    error: function(xhr, textStatus, errorThrown) {
             //do something 
    }
});
Run Code Online (Sandbox Code Playgroud)

如果出现错误,我的servlet过滤器会发送一个特定的错误

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
        ServletException {

    if(somethingwrong()) {
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "unavailableimage");    
    }
}
Run Code Online (Sandbox Code Playgroud)

你会建议做点什么吗?

$.ajaxError({
    error: function(xhr, textStatus, errorThrown) {
        if (xhr.status == 408) {
            //doSomething
        }
        else if xhr.responseText.contains("unavailableimage"){
            //doSomething
        }
    }
}); 
Run Code Online (Sandbox Code Playgroud)

因为我认为每个浏览器中的responseText都不同.

error-handling jquery servlets

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

当表达式上的 Kotlin 智能转换

我对 kotlin 智能转换感到困惑。在我看来if(condition) / else相当于when(condition) true -> /false ->,但是智能转换不适用于我的 when 表达式。

我正在使用科特林 1.5.30

data class Person(val name: String)
data class Address(val id: String, val person: Person?)

fun getPersonFromAddress(address: Address?): String {
    return if (address?.person != null) {
        address.person.name
    } else {
        "Not found"
    }
}

fun getPersonFromAddress(address: Address?): String {
    return when (address?.person != null) {
        true -> address.person.name // <-- Does not compile
        false -> "Not found"
    }
}
Run Code Online (Sandbox Code Playgroud)

kotlin

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