我有一个像这样定义的对象:
Blah = {
hideTimer:null,
setTimer: function() {
this.hideTimer = window.setTimeout(Blah.hidePopupInner, 500);
// must be done via window due to Greasemonkey
},
hidePopupInner: function() {
log("This? " + this);
},
hidePopupInnerPublic: function() {
Blah.hidePopupInner();
}
}
Run Code Online (Sandbox Code Playgroud)
问题是killTimer中的'this' 没有设置为Blah.如果我改变行说
this.hideTimer = window.setTimeout(Blah.hidePopupInnerPublic, 500);
Run Code Online (Sandbox Code Playgroud)
然后'this'指向Blah,因此可以使用hideTimer.
为每种方法制定一个"公共"方法可以解决问题,但必须有一个更简单的解决方案......?
注意:这一切都在Greasemonkey中,但我认为这是一个普遍的Javascript问题.
知道为什么会发生此错误以及如何修复它吗?尝试解析/加载配置文件时出现此错误:
错误
Warning: validation was turned on but an org.xml.sax.ErrorHandler was not
set, which is probably not what is desired. Parser will use a default
ErrorHandler to print the first 10 errors. Please call
the 'setErrorHandler' method to fix this.
Error: URI=null Line=3: Document root element "persistence", must match DOCTYPE root "null".
Error: URI=null Line=3: Document is invalid: no grammar found.
null
[]
null
Run Code Online (Sandbox Code Playgroud)
主要代码
public static void main(String[] args) throws ConfigurationException {
config = new XMLPropertiesConfiguration(new File("META-INF/vamola.xml"));
System.out.println(config.getString("persitence-unit.provider"));
System.out.println(config.getList("persistence-unit.properties.name")); …Run Code Online (Sandbox Code Playgroud) 我有一个网页,其中包含通过HTTP加载的登录表单,但它通过HTTPS提交数据.
我正在使用python-mechanize登录这个站点,但似乎数据是通过HTTP提交的.
我的代码看起来像这样:
import mechanize
b = mechanize.Browser()
b.open('http://site.com')
form = b.forms().next() # the login form is unnamed...
print form.action # prints "https://login.us.site.com"
form['user'] = "guest"
form['pass'] = "guest"
b.form = form
b.submit()
Run Code Online (Sandbox Code Playgroud)
提交表单时,连接是通过HTTP进行的,包含以下内容:
send: 'POST https://login.us.site.com/ HTTP/1.1\r\nAccept-Encoding: identity\r\nContent-Length: 180\r\nHost: login.us.site.com\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n'...
Run Code Online (Sandbox Code Playgroud)
任何人都可以确认这一点并最终发布解决方案,以便通过HTTPS提交表单吗?
稍后编辑:
1)我正在使用HTTP代理进行http/https流量(在环境中设置 - Linux机器)
2)我用Wireshark观察了流量,我可以确认流量是通过普通HTTP发送的(我可以看到POST和mechanize的内容不会像webbrowser那样向代理发送相同的请求 - 后者发送CONNECT login.us.site.com:443,而机械化只发送POST https://login.us.site.com) .但是,我不知道数据离开代理时会发生什么; 也许它建立了与目标站点的ssl连接?
我正在使用.NET GDI +绘制业务对象的自定义图表.除其他外,该图由连接对象的几行组成.
在特定场景中,我需要将一条线缩短一个特定数量的像素,比如说10个像素,即找到线的终点之前10个像素的线上的点.
想象一个半径为r = 10像素的圆,以及一条带有起点(x1,y1)和终点(x2,y2)的直线.圆圈以线的终点为中心,如下图所示.
插图http://i45.tinypic.com/140b5w5.gif
如何计算用红色圆圈标记的点,即圆与线之间的交点?这将为我提供该线的新终点,将其缩短10个像素.
感谢您的答案,我可以将以下程序放在一起.我将它命名为LengthenLine,因为如果我想缩短线条,我发现传递负像素数更自然.
具体来说,我试图组合一个可以绘制圆角线的功能,可以在这里找到.
public void LengthenLine(PointF startPoint, ref PointF endPoint, float pixelCount)
{
if (startPoint.Equals(endPoint))
return; // not a line
double dx = endPoint.X - startPoint.X;
double dy = endPoint.Y - startPoint.Y;
if (dx == 0)
{
// vertical line:
if (endPoint.Y < startPoint.Y)
endPoint.Y -= pixelCount;
else
endPoint.Y += pixelCount;
}
else if (dy == 0)
{
// horizontal line:
if (endPoint.X < startPoint.X)
endPoint.X -= pixelCount; …Run Code Online (Sandbox Code Playgroud) 此代码适用于IE以外的浏览器:
table.tbl.tr.td:first-child { display: none; }
Run Code Online (Sandbox Code Playgroud)
我应该使用什么来使它适用于所有浏览器?
我正在尝试根据鼠标光标的位置获取两个显示器的当前显示分辨率.
即,当鼠标光标在第一个显示器上时,我想获得该显示器的分辨率.
使用shell脚本我可以得到两个解决方案:
set screenWidth to (do shell script "system_profiler SPDisplaysDataType | grep Resolution | awk '{print $2}'")
Run Code Online (Sandbox Code Playgroud)
但我不知道哪个显示器目前处于"活动状态".
有任何想法吗?
我在Mac上运行Carbon Emacs,我的GUI emacs设置了非常令人愉悦的配色方案.不幸的是,在终端窗口中运行"emacs"时看起来很糟糕,它会解析我的根文件夹中的相同.emacs文件.
那么,有没有办法在我的.emacs文件中有条件地执行代码,这样我就可以为命令行和"GUI"emacs选择不同的颜色方案?
谢谢!
我正在尝试连接我的FooServlet,它扩展了HttpServlet和ApplicationContext,它位于同一个Project中.Wicket Servlet已经使用了应用程序上下文
它适用于
servletContext = this.getServletContext();
wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
(IMyBean)wac().getBean("myServiceBean")
Run Code Online (Sandbox Code Playgroud)
现在我尝试在我的代码(WebApplicationContextUtils)中使用显式Spring类,因为它不是IoC方式.
Wicket Servlet与web.xml中的Application上下文相关联
<servlet>
<servlet-name>ExampleApplication</servlet-name>
<servlet-class>org.apache.wicket.protocol.http.WicketServlet</servlet-class>
<init-param>
<param-name>applicationFactoryClassName</param-name>
<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Run Code Online (Sandbox Code Playgroud)
我找到了类Spring HttpServletBean,但我不知道它是否适用于我的Case
是否存在operator new[]用作分配器的STL实现?在我的编译器上,Foo::operator new[]私有化并没有阻止我创建一个vector<Foo>......是什么行为保证了什么?
替代标题
- 如何在iPhone上的Objective-C下载网页数据?
- 如何将html资源文件的全部内容读入
NSString *- 如何在Swift中下载网页数据?
- 将NS页保存在NSString中
如何获取网页数据并将数据放入字符串?
就像是:
NSString *webPageBody = GetWebPageData("www.mysite.com/webpage.html");
Run Code Online (Sandbox Code Playgroud)
在webPageBody,我想看到"HTML我的网页HTML".
.net ×1
allocator ×1
applescript ×1
c# ×1
c++ ×1
cocoa ×1
command-line ×1
css ×1
drawing ×1
emacs ×1
forms ×1
gdi+ ×1
geometry ×1
html ×1
https ×1
ios ×1
java ×1
javascript ×1
mechanize ×1
new-operator ×1
nsstring ×1
objective-c ×1
oop ×1
post ×1
python ×1
resolution ×1
spring ×1
stl ×1
xml ×1