我正在node.js中编写一个函数来查询PostgreSQL表.
如果该行存在,我想从该行返回id列.
如果它不存在,我想插入它并返回id(insert into ... returning id).
我一直在尝试变体case和if else语句,似乎无法让它发挥作用.
我有一个表,我需要实现可拖动的标题列.我使用Chrome作为我的浏览器实现了它,一切正常.当我在Firefox(17.0.1)中测试它时,我注意到drag事件没有触发.dragstart但是,确实如此.我简化了下面标记中的问题.在Chrome中加载时,每次鼠标移动时顶部标签都会更新.在Firefox中,它仍为0.
<!DOCTYPE html>
<html>
<head>
<title>TH Drag Test</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<style>
table,td,th {
border: solid thin black;
}
</style>
<script>
$(document).ready(function() {
$("th").bind("drag", function(event) {
$("#lbl").html(event.originalEvent.offsetX);
});
});
</script>
</head>
<body>
<span id="lbl">0</span>
<table>
<thead>
<tr>
<th draggable="true">Column A</th>
<th draggable="true">Column B</th>
</tr>
</thead>
<tbody>
<tr>
<td>One</td>
<td>Two</td>
</tr>
<tr>
<td>Three</td>
<td>Four</td>
</tr>
</tbody>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我在OSX上运行Docker 1.9.1,并且我通过Cisco AnyConnect VPN连接到我的私人工作网络.我在Docker容器中运行的服务连接到工作网络中的数据库,并且无法从容器内访问,但可以从OSX中的容器外部访问.如果我直接连接到工作网络,而不是通过VPN连接,也可以从容器内访问.我怀疑我可能不得不使用docker-machine VM进行一些网络配置,但我不确定从这里开始.
我必须从类似下面的评级标签中选择评级代码,但仅限于代理商为"SP"或"SNP"时.现在我有:
./ratings/rating/agency[text()='SNP'|text()='SP']/../code
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用.我究竟做错了什么?
<ratings>
<rating>
<agency>SP</agency>
<provider>SP</provider>
<type>LONG TERM</type>
<currencyType>LOCAL</currencyType>
<description>SP Standard LT LC rating</description>
<code>BBB+</code>
<date>2011-09-07</date>
</rating>
</ratings>
Run Code Online (Sandbox Code Playgroud)
谢谢,
贾里德
我在Godaddy上托管了一个ASP.NET应用程序,我希望从中发送电子邮件.当它运行时,我得到:不允许邮箱名称.服务器响应是:抱歉,从您的位置拒绝转发.代码和Web.config的重要部分如下:
msg = new MailMessage("accounts@greektools.net", email);
msg.Subject = "GreekTools Registration";
msg.Body =
"You have been invited by your organization to register for the GreekTools recruitment application.<br/><br/>" +
url + "<br/><br/>" +
"Sincerely,<br/>" +
"The GreekTools Team";
msg.IsBodyHtml = true;
client = new SmtpClient();
client.Host = "relay-hosting.secureserver.net";
client.Send(msg);
<system.net>
<mailSettings>
<smtp from="accounts@greektools.net">
<network host="relay-hosting.secureserver.net" port="25" userName="********" password="*********" />
</smtp>
</mailSettings>
Run Code Online (Sandbox Code Playgroud)
我正在使用 JUnit 4/Mockito/PowerMock 作为遗留应用程序的单元测试套件。PowerMock 依赖于 javassist:org.javassist:javassist:jar:3.20.0-GA:test
我们还依赖于旧版本的 Hibernate,它引入了旧版本的 javassist: javassist:javassist:jar:3.12.0.GA:compile
旧版本的 javassist 混淆了单元测试,导致了一个神秘的异常: java.io.IOException: invalid constant type: 18
当直接通过 Maven 运行测试时,我可以通过从 POM 中运行的单元测试中排除旧的 jar 来解决问题。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<classpathDependencyExcludes>
<!-- our version of Hibernate pulls in a javassist dependency that is incompatible with Java8
this can be removed once we upgrade Hibernate -->
<classpathDependencyExclude>javassist:javassist</classpathDependencyExclude>
</classpathDependencyExcludes>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然而,当直接在 IntelliJ 中运行测试时,错误仍然发生。无法从 IDE 轻松调试测试是一个主要问题,所以我希望有什么方法可以让 IntelliJ 也排除旧的依赖项,直到我们最终可以升级我们的 Hibernate 依赖项。
我正在使用TypeScript(2.4.2)首次涉足React(15.6.1),并且试图创建一个表示可拖动JSON字段的组件。这是我的组件代码:
import * as React from "react";
interface JsonFieldProps {
name: string;
type: string;
indent: number;
}
export class JsonField extends React.Component<JsonFieldProps, undefined> {
marginStyle = {
'text-indent': `${this.props.indent * 15}px`
};
render() {
return <div draggable={true} onDragStart={handleDrag} style={this.marginStyle}>{this.props.name}: {this.props.type},</div>;
}
}
function handleDrag(ev: DragEvent): void {
let id = (ev.target as HTMLDivElement).id;
ev.dataTransfer.setData("text/plain", id);
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用webpack对其进行编译时,出现以下错误:
ERROR in [at-loader] ./src/components/JsonField.tsx:15:21
TS2322: Type '{ draggable: true; onDragStart: (ev: DragEvent) => void;
style: { 'text-indent': string; }; child...' is not assignable …Run Code Online (Sandbox Code Playgroud) 我正在创建一个可以轻松插入图像的RichTextBox子类.我提到这个问题开始,但我不能让生成的RTF字符串工作.当我尝试设置RTB的SelectedRtf时,它出错"文件格式无效".这是我的代码:
internal void InsertImage(Image img)
{
string str = @"{\pict\pngblip\picw24\pich24 " + imageToHex(img) + "}";
this.SelectedRtf = str; // This line throws the exception
}
private string imageToHex(Image img)
{
MemoryStream ms = new MemoryStream();
img.Save(ms, ImageFormat.Png);
byte[] bytes = ms.ToArray();
string hex = BitConverter.ToString(bytes);
return hex.Replace("-", "");
}
Run Code Online (Sandbox Code Playgroud)
我已经看到了我正在尝试做的工作示例,但使用wmetafiles,但我不想使用该方法.有任何想法吗?
谢谢,
贾里德
我正在使用Spring 3 MVC构建一个Web应用程序,它具有通用布局和经常更改/刷新的"内容"div.内容标记位于自己的Tile中,我希望能够通过AJAX刷新该tile,而无需刷新整个页面.我知道如何从客户端激活AJAX请求并在控制器中处理它.我对Spring配置(查看,查看解析器等)感到困惑.有人有例子吗?
我正在编写一个Node.js脚本,该脚本使用node-imap从我的gmail收件箱中检索未读的电子邮件,使用mailparser解析它们,然后使用已解析的电子邮件进行处理.我遇到的问题是,收到的原始电子邮件似乎没有被mailparser正确解析.我不确定我在调用node-imap或mailparser时是否做错了什么,或者由于某种原因电子邮件本身是否格式错误.我已经包含了我正在运行的代码以及生成的输出.
var Imap = require("imap"),
MailParser = require("mailparser").MailParser,
Promise = require("bluebird"),
request = require("request-promise").defaults({jar: true}),
log = require("winston"),
_ = require("underscore"),
config = require("config").jobs;
var logConfig = _.clone(config.logConfig.email);
if (process.env.LOG_DIR) {
logConfig.filename = process.env.LOG_DIR + "/" + logConfig.filename;
}
log.add(log.transports.File, logConfig || config.logConfig);
Promise.longStackTraces();
var imap = new Imap(config.emailConfig);
Promise.promisifyAll(imap);
imap.once("ready", execute);
imap.once("error", function (err) {
log.error("Connection error: " + err.stack);
});
imap.connect();
function execute() {
imap.openBoxAsync("INBOX", false)
.then(function () {
return imap.searchAsync(["UNSEEN"]);
})
.then(function (results) {
var f = …Run Code Online (Sandbox Code Playgroud) java ×2
javascript ×2
node.js ×2
.net ×1
ajax ×1
asp.net ×1
c# ×1
css ×1
docker ×1
email ×1
firefox ×1
gmail ×1
gmail-imap ×1
html5 ×1
junit ×1
maven ×1
networking ×1
postgresql ×1
reactjs ×1
richtextbox ×1
rtf ×1
silverlight ×1
smtpclient ×1
spring ×1
sql ×1
sql-insert ×1
tiles ×1
typescript ×1
unit-testing ×1
vpn ×1
xml ×1
xpath ×1