我刚刚翻译了这个程序,
#include <stdio.h>
int dam[1000][1000];
int main (int argc, const char * argv[]) {
// insert code here...
printf("Hello, World!\n");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
使用gcc生产组装,
.cstring
LC0:
.ascii "Hello, World!\0"
.text
.globl _main
_main:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $20, %esp
call L3
"L00000000001$pb":
L3:
popl %ebx
leal LC0-"L00000000001$pb"(%ebx), %eax
movl %eax, (%esp)
call L_puts$stub
movl $0, %eax
addl $20, %esp
popl %ebx
leave
ret
.comm _dam,1000000,5
.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5
L_puts$stub:
.indirect_symbol _puts
hlt ; hlt ; hlt ; …Run Code Online (Sandbox Code Playgroud) 我们有大量的xml配置文件,我们希望在构建时将它们合并到一个主版本中.较小的配置文件更容易维护,一个大文件加载更快,所以我想这是一个流行的构建转换过程,我会在网上找到很多很好的例子.
我能够在StackOverflow找到问题的一部分的一些好的解决方案,但它们都依赖于知道需要合并的xml文件的名称.这对我来说似乎是一种不必要的开销.应该可以编写一个构建脚本,它可以动态计算需要哪些输入xml文件.
不幸的是,我能找到的唯一方法是实现这一目标.它的工作原理如下,
这是蚂蚁脚本
<taskdef name="xml-dir-list"
classname="net.matthaynes.xml.dirlist.AntFileListing"
classpath="antlib/xml-dir-listing.0.1.jar;
antlib/jakarta-regexp-1.5.jar;antlib/log4j-1.2.14.jar"/>
<macrodef name="build-plugin-xml" description="todo">
<attribute name="pluginName"/>
<xml-dir-list depth="0" verbose="false"
srcDir="${src.dir}/@{pluginName}/forms/" includesRegEx="\.xml$"
destFile="${src.dir}/@{pluginName}/forms/fileList.xml"/>
<xslt in="${src.dir}/forms/fileList.xml"
out="${src.dir}/@{pluginName}/@{pluginName}_extn.yuix
style="${src.dir}/@{pluginName}/forms/extn.yuix.xsl" />
<delete file="${src.dir}/@{pluginName}/forms/fileList.xml"/>
</macrodef>
Run Code Online (Sandbox Code Playgroud)
这是样式表,
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<Forms applicationId="YFSSYS00011">
<GlobalExtensions>
<Tasks/>
</GlobalExtensions>
<xsl:apply-templates select="directory/file"/>
</Forms>
</xsl:template>
<xsl:template match="file">
<xsl:copy-of select="document(@name)/Forms/Form"/>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
有没有人找到一种更简单的方法来实现在XSLT中合并哪些文件的动态发现?XSLT无法直接读取目录并不奇怪,但我希望找到一种更简单的方法来传递文件名列表,而不是通过另一个xml文件.
一旦我对蚂蚁脚本做了一些额外的调整,Dimitre的解决方案效果很好,
<taskdef name="saxon-xslt" classname="net.sf.saxon.ant.AntTransform"
classpath="antlib/saxon9.jar;antlib/saxon9-ant.jar"/>
Run Code Online (Sandbox Code Playgroud)
[...]
<macrodef name="build-plugin-xml" description="todo">
<attribute name="pluginName"/>
<saxon-xslt
in="build.xml"
out="${compca.src.dir}/temp/@{pluginName}/@{pluginName}_extn.yuix"
style="antscripts/extn.yuix.xsl">
<param …Run Code Online (Sandbox Code Playgroud) 我正在尝试以编程方式解析Atom提要.我将原子XML下载为字符串.我可以将XML加载到XmlDocument.但是,我无法使用XPath遍历文档.每当我尝试,我都会null.
我一直在使用这个Atom提要作为测试:http://steve-yegge.blogspot.com/feeds/posts/default
除了我使用" " 时,调用SelectSingleNode()总是返回.这是我现在正在尝试的:null/
using (WebClient wc = new WebClient())
{
string xml = wc.DownloadString("http://steve-yegge.blogspot.com/feeds/posts/default");
XmlNamespaceManager nsMngr = new XmlNamespaceManager(new NameTable());
nsMngr.AddNamespace(string.Empty, "http://www.w3.org/2005/Atom");
nsMngr.AddNamespace("app", "http://purl.org/atom/app#");
XmlDocument atom = new XmlDocument();
atom.LoadXml(xml);
XmlNode node = atom.SelectSingleNode("//entry/link/app:edited", nsMngr);
}
Run Code Online (Sandbox Code Playgroud)
我以为它可能是因为我的XPath,所以我也尝试了一个简单的根节点查询,因为我知道root应该工作:
// I've tried both with & without the nsMngr declared above
XmlNode node = atom.SelectSingleNode("/feed");
Run Code Online (Sandbox Code Playgroud)
无论我做什么,似乎都无法选择任何东西.显然我错过了一些东西,我只是无法弄清楚是什么.为了使XPath能够在这个Atom提要上工作,我需要做些什么?
虽然这个问题有答案,但我发现这个问题几乎完全重复:SelectNodes不能处理stackoverflow feed
import os
xp1 = "\Documents and Settings\"
xp2 = os.getenv("USERNAME")
print xp1+xp2
Run Code Online (Sandbox Code Playgroud)
给我错误
File "1.py", line 2
xp1 = "\Documents and Settings\"
^
SyntaxError: EOL while scannning single-quoted string
Run Code Online (Sandbox Code Playgroud)
你能帮帮我吗,你看到了问题吗?
string[]查看它是否包含元素的最佳方法是什么.这是我的第一枪.但也许我有一些东西可以忽略.数组大小不超过200个元素.
bool isStringInArray(string[] strArray, string key)
{
for (int i = 0; i <= strArray.Length - 1; i++)
if (strArray[i] == key)
return true;
return false;
}
Run Code Online (Sandbox Code Playgroud) 我在一台debian机器上有一个高度流量的应用程序,而apache开始表现得很奇怪.
每次我启动apache时,会产生大量的apache进程,应用程序根本不加载,并且很快整个机器冻结,必须重新启动才能重启.
这是我在启动apache后立即获得的顶部:
top - 20:14:44 up 1:16, 2 users, load average: 0.48, 0.10, 0.03 Tasks: 330 total, 5 running, 325 sleeping, 0 stopped, 0 zombie Cpu(s): 12.0%us, 21.4%sy, 0.0%ni, 65.7%id, 0.2%wa, 0.1%hi, 0.7%si, 0.0%st Mem: 8179920k total, 404984k used, 7774936k free, 60716k buffers Swap: 2097136k total, 0k used, 2097136k free, 43424k cached 10251 www-data 15 0 467m 8100 4016 S 6 0.1 0:00.04 apache2 10262 www-data 15 0 467m 8092 4012 S 6 0.1 0:00.05 apache2 10360 www-data 15 …
我有一个下拉菜单,除了IE6和IE7之外,它可以完美地运行.
这是它隐藏在IE 6/7下面的div的CSS
#featured-programs-left img,
#featured-programs-right img{
overflow:auto;
border:0;
}
#featured-programs-left,
#featured-programs-right {
height:625px;
float:left;
overflow:auto;
clear:left;
clear:right;
width:100%;
}
#featured-programs-left div,
#featured-programs-right div {
overflow:auto;
clear:left;
clear:right;
width:352px;
height:345px;
}
#featured-programs-left {
float:left;
}
#featured-programs-right {
float:right;
}
Run Code Online (Sandbox Code Playgroud)
这是jQuery(在源代码中你会看到每个主要div中的多个div(特色 - 程序 - 左和 - 正),并且jQuery在循环中淡入和淡出)以显示多个项目(淡化div内两侧的内容(#featured-programs-leftfeatured-programs-right)
<script type="text/javascript">
$(document).ready(function() {
$('#featured-programs-left').cycle({
fx: 'fade',
speed: 'slow',
timeout: 15000,
next: '#next2',
prev: '#prev2'
});
});
$(document).ready(function() {
$('#featured-programs-right').cycle({
fx: 'fade',
speed: 'slow',
timeout: 21000,
next: '#next3',
prev: '#prev3'
});
}); …Run Code Online (Sandbox Code Playgroud) 我有一个cocoa类设置,我想用它连接到我正在构建的RESTful Web服务.我决定在我的PHP后端使用HTTP基本身份验证,就像这样......
<?php
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
//Stuff that users will see if they click 'Cancel'
exit;
}
else {
//Validation Code
echo "You entered info.";
}
?>
Run Code Online (Sandbox Code Playgroud)
此时我正在使用同步NSURLConnection,我了解Apple文档状态对身份验证的支持较少.
但它甚至可能吗?我可以非常轻松地进行cookie身份验证,无需NSURLProtectionSpaces或NSURLCredentials或任何身份验证类.此外,是否有任何资源,我可以阅读更多关于Cocoa身份验证类?
谢谢.
更新:mikeabdullahuk您提供的代码(第二个示例)几乎与我所写的相同.我做了一些调查,发现NSURLConnection正在返回错误......
Error Domain=NSURLErrorDomain Code=-1012 UserInfo=0x1a5170 "Operation could not be completed. (NSURLErrorDomain error -1012.)"
Run Code Online (Sandbox Code Playgroud)
该代码对应于NSURLErrorUserCancelledAuthentication.显然我的代码没有访问NSURLCredentialStorage,而是取消了身份验证.这可能与PHP HTTP身份验证功能有关吗?我现在很困惑.
我正在编写Ruby脚本,并希望使用n-ary树数据结构.
是否有一个很好的实现可用作源代码?谢谢.
虽然与这个关于在数学和学术界之外使用的LaTeX的问题有关,但我特别想知道是否有人使用或熟悉使用LaTeX生成与软件相关的任何类型文档的任何人.如果是这样,你能否说你是否喜欢LaTeX以及你使用它的目的?谢谢.