小编Ben*_*uer的帖子

找不到本地gulp(尝试运行:npm install gulp)

我创建了一个module(webapp-module-storage),它有以下定义:

的package.json

{
  "dependencies": {
    ...
  },
  "devDependencies": {
    "gulp": "^3.9.1",
    ...
  },
  "name": "webapp-module-storage",
  "scripts": {
    "postinstall": "gulp build",
    "test": "gulp test"
  }
}
Run Code Online (Sandbox Code Playgroud)

我想我可以在安装它时使用我的模块在另一个模块中:

  • npm install github:myorg/webapp-module-storage#master

但是,当我安装我的模块时,我收到此错误:

找不到当地的一口气

尝试运行:npm install gulp

截图

在此输入图像描述

我的理解是,它gulp与我的模块一起发货,因为我宣布它,devDependencies但看起来我的npm postinstall脚本找不到gulp.

我错过了什么吗?

npm post-install gulp npm-install

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

如何使用-Xlint重新编译:在Ant构建任务中未选中?

当我运行我的Ant"build.xml"文件的"编译"目标时,我收到以下消息:

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Run Code Online (Sandbox Code Playgroud)

我的编译目标如下:

  <target name="compile">
    <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,source" includeantruntime="false">
      <classpath refid="class.path" />
    </javac>
    <javac srcdir="${test.dir}" destdir="${classes.dir}" debug="true" debuglevel="lines,source" includeantruntime="false">
      <classpath refid="class.path" />
    </javac>
  </target>
Run Code Online (Sandbox Code Playgroud)

我需要在build.xml文件中更改什么才能在那里完成-Xlint:unchecked

ant build.xml compilation target

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

如何使用Apache HttpClient 4获取文件上传的进度条?

我有以下代码用于使用Apache的HTTP-Client(org.apache.http.client)上传文件:

  public static void main(String[] args) throws Exception
  {
    String fileName = "test.avi";
    File file = new File(fileName);

    String serverResponse = null;
    HttpParams params = new BasicHttpParams();
    params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, true);
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpClient client = new DefaultHttpClient(params);
    HttpPut put = new HttpPut("http://localhost:8080/" + fileName);

    FileEntity fileEntity = new FileEntity(file, "binary/octet-stream");
    put.setEntity(fileEntity);   

    HttpResponse response = client.execute(put);
    HttpEntity entity = response.getEntity();
    if (entity != null)
    {
      serverResponse = EntityUtils.toString(entity);
      System.out.println(serverResponse);
    }
  }
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但现在我想要一个进度条,显示文件上传的进度.怎么做到这一点?我在File Upload with Java(带进度条)中找到了一个代码片段,但是它是为Apache HTTP Client 3(org.apache.commons.httpclient)设计的,并且Apache HTTP Client …

java apache client http progress

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

如何本地化Windows应用商店的应用程序的显示名称?

我在Windows Store Dashboard中为我的Windows 8应用程序注册了德语和英语名称.

之后我在我的解决方案中创建了两个文件:

Strings/de/Resources.resw with name "AppName" and value "German Title"
Strings/en/Resources.resw with name "AppName" and value "English Title"
Run Code Online (Sandbox Code Playgroud)

然后我点击了Edit App Manifest.在显示名称字段中,我输入了"ms-resource:/ AppName",但是当我想构建我的应用程序时,我收到一条错误,指出无法找到"NamedResource".

我究竟做错了什么?

文档仅写道:"显示名称:指定向用户显示的应用程序的友好名称.此字符串是可本地化的".但是我的应用清单中只有一个字段(称为显示名称)来指示我的应用名称.

localization manifest windows-8 windows-store-apps windows-phone-8.1

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

Knex.JS自动更新触发器

我正在使用Knex.JS迁移工具.但是,在创建表时,我希望updated_at在数据库中更新记录时,会自动更新一个名为column的列.

例如,这是一个表:

knex.schema.createTable('table_name', function(table) {
    table.increments();
    table.string('name');
    table.timestamp("created_at").defaultTo(knex.fn.now());
    table.timestamp("updated_at").defaultTo(knex.fn.now());
    table.timestamp("deleted_at");
})
Run Code Online (Sandbox Code Playgroud)

created_atupdated_at列默认为创建记录的时间,这是罚款.但是,当更新该记录时,我希望该updated_at列显示自动更新的新时间.

我宁愿不用原始的postgres写.

谢谢!

javascript postgresql knex.js

19
推荐指数
3
解决办法
8183
查看次数

filemtime()[function.filemtime]:对于带有变音符号的文件名,stat失败

我使用PHP函数filemtime来获取PHP 5.3的最后修改时间.这个函数效果很好,但是当文件名有特殊字符时(例如变音符号),它似乎有些问题.

如果我用变音符号在文件名上运行它

$stat = filemtime('C:/pictures/München.JPG');
Run Code Online (Sandbox Code Playgroud)

然后我得到输出:

Warning: filemtime() [function.filemtime]: stat failed for C:/pictures/München.JPG
Run Code Online (Sandbox Code Playgroud)

如果我将文件从"München.JPG"重命名为"Muenchen.JPG"并再次执行相同的操作:

 $stat = filemtime('C:/pictures/Muenchen.JPG');
Run Code Online (Sandbox Code Playgroud)

一切正常!

我的PHP文件保存为UTF-8而没有BOM,我也尝试过:

clearstatcache();
$stat = filemtime(utf8_encode('C:/pictures/München.JPG'));
Run Code Online (Sandbox Code Playgroud)

但它没有帮助.

php statistics utf-8 diacritics filemtime

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

@WebServlet注释不适用于Tomcat 8

我想@WebServlet在Tomcat 8上运行的Java EE webapp中使用注释.

我已经读过,我需要在我的Servlet版本3.1中声明,web.xml并且我的Servlet需要扩展HttpServlet.我做了所有这些,但仍然@WebServlet不起作用.我正在获得HTTP 404.

我也试过我的配置用metadata-complete="false"在我web.xml,但还是没有成功.

这是我的web.xml和Servlet.

完整的示例代码可以在GitHub上找到.

web.xml中

<?xml version="1.0" encoding="UTF-8"?>
<web-app 
  version="3.1" 
  xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

  <context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
  </context-param>

  <!-- http://stackoverflow.com/a/7924117/451634 -->
  <!-- Put "-1" to disable this feature -->
  <context-param>
    <param-name>facelets.REFRESH_PERIOD</param-name>
    <param-value>1</param-value>
  </context-param>

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
  </welcome-file-list>

  <!-- JSF -->
  <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>   

  <!-- CDI -->
  <listener>
    <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
  </listener>

</web-app>
Run Code Online (Sandbox Code Playgroud)

TestServlet.java …

servlets embedded-tomcat-8

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

如何为导出函数的节点模块编写打字稿定义文件?

考虑一下,对于toml节点模块,我可以简单地使用:

// toml.d.ts
declare module TOML {
    export function parse(value:string):any;
}

declare module "toml" {
    export = TOML;
}
Run Code Online (Sandbox Code Playgroud)

然后:

/// <reference path="../../../../../defs/toml/toml.d.ts"/>
import toml = require('toml');
toml.parse(...);
Run Code Online (Sandbox Code Playgroud)

但是,那些只导出单个函数的节点模块呢,比如'glob'(https://github.com/isaacs/node-glob).

该模块的节点用法是:

var glob = require("glob")
glob("*.js", {}, callback(err, files) { ... });
Run Code Online (Sandbox Code Playgroud)

你天真地期望你能做到这一点:

// glob.d.ts
declare function globs(paths:string, options:any, callback:{(err:any, files:string[]):void;
Run Code Online (Sandbox Code Playgroud)

...但是因为typescripts'import'语义有点奇怪,所以你似乎只能使用'import .. = require()'语句来为别名模块.试着打电话:

/// <reference path="../../../../../defs/glob/glob.d.ts"/>
import blog = require('glob');
Run Code Online (Sandbox Code Playgroud)

结果是:

error TS2072: Module cannot be aliased to a non-module type.
Run Code Online (Sandbox Code Playgroud)

那么,你会如何为此编写定义文件?

NB.请注意,这是针对使用节点的commonjs模块, …

commonjs typescript

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

如何从外部文件加载Hogan.JS模板?

我使用Hogan.JS作为JavaScript模板库.它应该从外部文件加载JavaScript模板.人们可以在外部JavaScript文件中外包几个模板.

有谁知道这是怎么做到的吗?

我有以下代码示例:

<!DOCTYPE html>
<html>
  <head>
    <title>Hogan.JS Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="js/jquery-1.9.0.min.js"></script>
    <script src="js/hogan-2.0.0.min.js"></script>
    <script id="scriptTemplate" type="text/mustache">
      <p>Your text here: {{text}}</p>
    </script>
  </head>
  <body>
    <script>
      var data = {
        text: 'Hello World'
      };

      var template = $('#scriptTemplate').html();
      var compiledTemplate = Hogan.compile(template);
      var renderedTemplate = compiledTemplate.render(data);

      var box = document.createElement('div');
      box.innerHTML = renderedTemplate;
      document.body.insertBefore(box,document.body.childNodes[0]);
    </script>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

使用ID我可以解决模板,但我总是需要一个单独的内联脚本.:-(

这如何与外部文件一起使用?

javascript templates external mustache hogan.js

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

在JaCoCo代码覆盖范围中排除Setter和Getters

随着cobertura-maven-plugingetter和setter方法可排除使用代码覆盖ignoreTrivial选项.是否还有这种可能性jacoco-maven-plugin

这是我目前的配置:

<plugin>
  <groupId>org.jacoco</groupId>
  <artifactId>jacoco-maven-plugin</artifactId>
  <version>0.7.1.201405082137</version>
  <configuration>
    <excludes>
      <exclude>com/welovecoding/web/blog/test/**/*.class</exclude>
    </excludes>
  </configuration>
  <executions>
    <execution>
      <id>amend-unit-test-java-agent-option</id>
      <goals>
        <goal>prepare-agent</goal>
      </goals>
    </execution>
    <execution>
      <id>report</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>report</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

getter setter code-coverage jacoco jacoco-maven-plugin

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