我有一个小的Perl脚本(在Windows上),它为我检查一些文件,以帮助我的日常业务.目前它打印出类似......的东西
0%
25%
50%
75%
Complete
Run Code Online (Sandbox Code Playgroud)
但我记得我以前用过的脚本并没有逐行打印,而是更新了显示器上的输出,可能是通过移动光标并过度打印那里的内容.
谁知道需要什么魔法?便携性对我来说并不重要,脚本非常易于使用.
我有一个Set类(这是J2ME,所以我对标准API的访问权限有限;只是为了解释我明显的轮子改造).我正在使用我的set类在类和子类中创建常量集.它看起来像这样......
class ParentClass
{
protected final static Set THE_SET = new Set() {{
add("one");
add("two");
add("three");
}};
}
class SubClass extends ParentClass
{
protected final static Set THE_SET = new Set() {{
add("four");
add("five");
add("six");
union(ParentClass.THE_SET); /* [1] */
}};
}
Run Code Online (Sandbox Code Playgroud)
除了[1]处的行导致空指针异常外,所有看起来都很好.据推测,这意味着子类中的静态初始化程序在父类的运行之前运行.这让我感到惊讶,因为我认为它会先在任何新的导入中运行静态块,然后再在instatiated子类中运行.
我在这个假设中是对的吗?有没有办法控制或解决这种行为?
更新:
事情甚至更奇怪.我尝试了这个(注意'new ParentClass()'行):
class ParentClass
{
public ParentClass()
{
System.out.println(THE_SET);
}
protected final static Set THE_SET = new Set() {{
add("one");
add("two");
add("three");
}};
}
class SubClass extends ParentClass
{
protected final static Set THE_SET = new …Run Code Online (Sandbox Code Playgroud) 我有这种形式的XSD:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/example"
xmlns:tns="http://www.example.org/example" elementFormDefault="qualified">
<complexType name="bType">
</complexType>
<complexType name="aType">
<choice maxOccurs="unbounded">
<element name="a" type="tns:aType" />
<element name="b" type="tns:bType" />
</choice>
</complexType>
<element name="topelement">
<complexType>
<sequence>
<element name="a" type="tns:aType" maxOccurs="1" />
</sequence>
</complexType>
</element>
</schema>
Run Code Online (Sandbox Code Playgroud)
我希望与之匹配的XML文件,例如:
<?xml version="1.0" encoding="UTF-8"?>
<topelement xmlns="http://www.example.org/example"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/example example.xsd ">
<a> <!-- Error on this line. -->
<a/>
<b/>
<b/>
<a/>
</a>
</topelement>
Run Code Online (Sandbox Code Playgroud)
不幸的是,XSD说这对以下错误无效:
cvc-complex-type.2.4.b: The content of element 'a' is not complete. One of '{"http://www.example.org/example":a, "http://www.example.org/example":b}' is expected. example.xml line …Run Code Online (Sandbox Code Playgroud) 在我的C#项目中使用doxygen和graphviz,我可以在文档页面中生成类图.这些图中包含完整的类名和命名空间,例如
Acme.MyProduct.MyClasses.MyClass
Run Code Online (Sandbox Code Playgroud)
是否可以配置doxygen将其减少到只是类名?
MyClass
Run Code Online (Sandbox Code Playgroud)
完全合格的路径使得简单的图表变得相当宽泛和笨重.我想尽量减少水平滚动的需要.
我一直在玩ABC字节码,并希望有人可以为我解决一个混乱点.我有一个简单的Flash文件,可以在舞台上放置一个剪辑,并有一个小脚本来更新它在每个帧上的位置.代码看起来像:
package
{
import flash.display.MovieClip;
import flash.events.Event;
public class RedCircle extends MovieClip
{
public function RedCircle()
{
this.addEventListener(Event.ENTER_FRAME, moveit);
}
function moveit(e:Event)
{
this.x -=1;
}
}
}
Run Code Online (Sandbox Code Playgroud)
其编译类似于:
protected package protected RedCircle
{
class RedCircle extends flash.display.MovieClip
{
static () : Void
{
getlocal_0();
pushscope();
returnvoid();
}
RedCircle () : Void
{
getlocal_0();
pushscope();
getlocal_0();
constructsuper(0);
getlocal_0();
getlex(flash.events.Event);
getproperty(ENTER_FRAME);
getlex(internal .moveit); // ###1
callpropvoid(addEventListener, 2);
returnvoid();
}
function (anonymous) (flash.events.Event param1) : Void // ###2
{
getlocal_0();
pushscope();
getlocal_0(); …Run Code Online (Sandbox Code Playgroud) 我的Flash应用程序中有几个按钮可以调用两个不同的javascript函数.它们适用于除IE9之外的所有浏览器(我没有尝试过早期的IE).我调用函数的代码是这样的:
ExternalInterface.call(
"myLovelyFunction",
string1, string2);
Run Code Online (Sandbox Code Playgroud)
并且JS中的代码如下所示:
function myLovelyFunction(string1, string2) {
window.open('https://twitter.com/share?url=http%3A%2F%2Fwww.mysite.com%2Fapage.php&via=atwitteraccount&text=Some%20text%22&related=atwitteraccount',
'windowname',
'height=290,width=510');
}
Run Code Online (Sandbox Code Playgroud)
在IE9中,该功能绝对没有任何功能,但控制台抱怨:
SCRIPT438: Object doesn't support property or method 'SetReturnValue'
index.php, line 1 character 1
Run Code Online (Sandbox Code Playgroud)
第1行,字符1显然没有特别指向任何东西.
我可以通过打开兼容性视图使其工作正常,虽然控制台错误不会消失.
是否有任何关于IE9导致这一点,更重要的是,我该如何解决这个问题?
据我所知,如果连接因任何原因失败,SignalR会不断尝试重新连接.测试我的服务器和客户端对此的响应的最佳方法是什么?
我正在使用grunt-mocha通过phantomJS运行单元测试.
我知道phantomJS有很多有用的功能.我可以从摩卡测试中访问它吗?
我已经查看了明显的window对象,例如对象,看看我是否可以以某种方式访问页面对象,但似乎没有什么是显而易见的.
具体来说,我想呈现正在测试的页面的屏幕截图.
我的网站上有一些我需要启用跨域访问的图像,但我不想将其添加到所有图像中.我知道我可以这样做:
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但有没有办法将自定义标题限制在我的网站上只有一个文件夹?
我有一个线程,我在一个大的,无所不包的catch块中捕获所有错误.我这样做,以便我可以在我的应用程序中报告任何错误,而不仅仅是预期的错误.我的Runnable看起来像这样:
public final void run()
{
try
{
System.out.println("Do things"); /* [1] */
doUnsafeThings();
}
catch (Throwable t)
{
System.out.println("Catch"); /* [2] */
recover();
}
finally
{
System.out.println("Finally"); /* [3] */
}
}
Run Code Online (Sandbox Code Playgroud)
我希望NPE能被Throwable catch块捕获.相反,不打印[2]处的输出,也不打印[3].打印[1]处的输出.
我在控制台上得到的是:
Uncaught exception java/lang/NullPointerException.
Run Code Online (Sandbox Code Playgroud)
这到底是怎么回事?
对于法庭记录,我正在使用J2ME,这是在Sun的WTK v2.5.2模拟器中运行的.
我很想把它归结为JVM实现的笨拙,但我不禁觉得我只是错过了一些东西.
澄清是为了避免怀疑(因为示例代码明显改变了我的生产代码)
asp.net ×2
c# ×2
flash ×2
java ×2
javascript ×2
actionscript ×1
avm2 ×1
bytecode ×1
command-line ×1
cors ×1
diagram ×1
doxygen ×1
exception ×1
http ×1
iis ×1
iis-7 ×1
inheritance ×1
java-me ×1
mocha.js ×1
perl ×1
phantomjs ×1
progress-bar ×1
signalr ×1
static ×1
try-catch ×1
uml ×1
unit-testing ×1
windows ×1
xml ×1
xsd ×1