在Clojure中,添加自定义阅读器标签真的很简单
;; data_readers.clj (on classpath, eg. src/clj/)
{rd/qux datareaders.reader/my-reader}
;; Define a namespace containing the my-reader var:
(ns datareaders.reader)
(defn my-reader [x] 'y)
;; use special tag in other namespace. Readers have to be required first.
(require 'datareaders.reader)
(defn foo [x y]
(println #rd/qux x "prints y, not x due to reader tag."))
Run Code Online (Sandbox Code Playgroud)
我正在尝试为 ClojureScript 实现相同的目标,但出现#rd/qux未定义的错误。我正在lein cljsbuild once用来构建项目。这是 ClojureScript 的限制还是cljsbuild在读者得到解决之前构建项目?在这种情况下,如何在 cljsbuild 启动之前强制 leiningen 加载 reader 命名空间?
编辑:请注意,此示例打算在 ClojureScript 源代码中使用阅读器标签,而不是在通过read-string.
我无法理解gradle中的groovy语法.
如果命名参数(在groovy中)使用:后缀,那么我假设代码apply plugin: 'java'意味着调用该函数apply(plugin = 'java').这很奇怪,因为apply甚至没有定义函数.以下在我的gradle脚本中给出了一个错误:
println apply.getClass()
> Could not get unknown property 'apply' for root project 'Simple' of type
org.gradle.api.Project.
Run Code Online (Sandbox Code Playgroud)
那么apply它定义的是什么?为什么上面的代码不打印apply元素的类?
还有一件我觉得奇怪的事情如下:
dependencies {
compile 'org.slf4j:slf4j-api:1.7.12'
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)
语法表明包含的代码{}是一个闭包,但是什么是compile和testCompile元素?如果它是一个闭包,那么上面的代码将只返回'junit:junit:4.12'一个字符串,其余的应该无法编译.它看起来更像是地图的定义.但同样,如果上面的代码是数据,那么我应该能够在groovyshshell中输入它.
groovy:000> dependencies {
compile 'org.slf4j:slf4j-api:1.7.12'
testCompile 'junit:junit:4.12'
}
groovy:001> groovy:002> groovy:003> ERROR groovy.lang.MissingMethodException:
No signature of method: groovysh_evaluate.dependencies() is applicable for argument types: (groovysh_evaluate$_run_closure1) values: [groovysh_evaluate$_run_closure1@b7c4869] …Run Code Online (Sandbox Code Playgroud) 我有一个 hdfs 集群正在监听192.168.50.1:9000,这意味着它只接受通过该 IP 的连接。我希望在 收听0.0.0.0:9000。当我输入 时127.0.0.1 localhost master,/etc/hosts它从 开始127.0.0.1:9000,这会阻止所有节点连接。
这个问题类似于How to make Hadoopservers Listening on all IPs,但针对的是hdfs,而不是yarn。
core-site.xml是否有类似的等效设置yarn.resourcemanager.bind-host或任何其他方式来配置它?如果不是,那么这背后的原因是什么?这是一个安全功能吗?
我的目标是获取 java 进程的命令行参数。我正在跑去ps aux | grep java> out.log查看完整的参数列表。问题是它被截断为大约 4k 字节。Java 是从构建工具(maven)调用的,所以我对参数没有太大影响。大多数长参数列表都与类路径条目相关。在 Windows 平台上,参数列表大约为 12Kb。
如何在 Linux 中查看完整的命令行参数,即使它们的长度超过 4K?我在 Linux Mint Petra 上运行。我尝试过使用进程资源管理器,但它也会截断(并且它不会让我复制粘贴参数)
据我所知float:left,它会将后续元素推到左侧而不是新线上.
在下面的例子中,我希望第二个div从第一个div的右边开始,但正如你在下面的jsfiddle中看到的那样,它仍然跨越整个宽度.
另一方面,内容神奇地从它应有的地方开始.请问float规则只浮于内容而不是利润?
.inline {
float:left;
}
.yellow {
background-color:yellow;
}Run Code Online (Sandbox Code Playgroud)
<div class="inline">
first line<br>
second line<br>
third line<br>
</div>
<div class="yellow" >floated div</div>Run Code Online (Sandbox Code Playgroud)
编辑:我希望上面的代码看起来像这样,但没有明确需要使用边距.
对于windows azure队列,每个存储的可伸缩性目标应该是大约500条消息/秒(http://msdn.microsoft.com/en-us/library/windowsazure/hh697709.aspx).我有以下简单的程序,只是将一些消息写入队列.该程序需要10秒钟才能完成(4条消息/秒).我从虚拟机(西欧)运行程序,我的存储帐户也位于西欧.我没有为我的存储设置地理位置复制.我的连接字符串设置为使用http协议.
// http://blogs.msdn.com/b/windowsazurestorage/archive/2010/06/25/nagle-s-algorithm-is-not-friendly-towards-small-requests.aspx
ServicePointManager.UseNagleAlgorithm = false;
CloudStorageAccount storageAccount=CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
var cloudQueueClient = storageAccount.CreateCloudQueueClient();
var queue = cloudQueueClient.GetQueueReference(Guid.NewGuid().ToString());
queue.CreateIfNotExist();
var w = new Stopwatch();
w.Start();
for (int i = 0; i < 50;i++ )
{
Console.WriteLine("nr {0}",i);
queue.AddMessage(new CloudQueueMessage("hello "+i));
}
w.Stop();
Console.WriteLine("elapsed: {0}", w.ElapsedMilliseconds);
queue.Delete();
Run Code Online (Sandbox Code Playgroud)
知道如何才能获得更好的性能吗?
编辑:
根据Sandrino Di Mattia的回答,我重新分析了我最初发布的代码,发现它不够完整,无法重现错误.实际上我在调用ServicePointManager.UseNagleAlgorithm = false之前创建了一个队列; 重现我的问题的代码看起来更像是这样的:
CloudStorageAccount storageAccount=CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
var cloudQueueClient = storageAccount.CreateCloudQueueClient();
var queue = cloudQueueClient.GetQueueReference(Guid.NewGuid().ToString());
//ServicePointManager.UseNagleAlgorithm = false; // If you change the nagle algorithm here, the performance will be …Run Code Online (Sandbox Code Playgroud)