我创建了一个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.
我错过了什么吗?
当我运行我的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?
我有以下代码用于使用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 …
我在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
我正在使用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_at与updated_at列默认为创建记录的时间,这是罚款.但是,当更新该记录时,我希望该updated_at列显示自动更新的新时间.
我宁愿不用原始的postgres写.
谢谢!
我使用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)
但它没有帮助.
我想@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 …
考虑一下,对于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模块, …
我使用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我可以解决模板,但我总是需要一个单独的内联脚本.:-(
这如何与外部文件一起使用?
随着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) javascript ×2
ant ×1
apache ×1
build.xml ×1
client ×1
commonjs ×1
compilation ×1
diacritics ×1
external ×1
filemtime ×1
getter ×1
gulp ×1
hogan.js ×1
http ×1
jacoco ×1
java ×1
knex.js ×1
localization ×1
manifest ×1
mustache ×1
npm ×1
npm-install ×1
php ×1
post-install ×1
postgresql ×1
progress ×1
servlets ×1
setter ×1
statistics ×1
target ×1
templates ×1
typescript ×1
utf-8 ×1
windows-8 ×1