cat

Method chaining + inheritance don’t play well together?

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question has been asked in a C++ context but I'm curious about Java. The concerns about virtual methods don't apply (I think), but if you have this situation: abstract class Pet { private String name; public Pet setName(String name) { this.name = name; return this; } } class Cat extends Pet { public Cat catchMice() { System.out.println("I caught a mouse!"); return this; } } class Dog extends Pet { public Dog catchFrisbee() { System.out.println("I caught a frisbee!"); return this; } } class Bird extends Pet { public Bird layEgg() { ...

Bash: add string to the end of the file without line break

那年仲夏 提交于 2019-12-03 01:26:09
How can I add string to the end of the file without line break? for example if i'm using >> it will add to the end of the file with line break: cat list.txt yourText1 root@host-37:/# echo yourText2 >> list.txt root@host-37:/# cat list.txt yourText1 yourText2 I would like to add yourText2 right after yourText1 root@host-37:/# cat list.txt yourText1yourText2 sed '$s/$/yourText2/' list.txt > _list.txt_ && mv -- _list.txt_ list.txt If your sed implementation supports the -i option, you could use: sed -i.bck '$s/$/yourText2/' list.txt With the second solution you'll have a backup too (with first

Difficulty getting the item count for the combinations of list of items from python dictionary

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have below input list of dictionaries inpdata = { "cat" : [{ "categories" : [{ "cid" : 27 }, { "cid" : 66 }, { "cid" : 29 }], "id" : 20 }, { "categories" : [{ "cid" : 66 }], "id" : 21 }, { "categories" : [{ "cid" : 66 }, { "cid" : 27 }], "id" : 22 }, { "categories" : [{ "cid" : 66 }, { "cid" : 27 }], "id" : 23 }, { "categories" : [{ "cid" : 66 }, { "cid" : 29 }, { "cid" : 27 }], "id" : 24 }]}; Am trying to get the count of id's for each cid along with the id values, I used below code for that - allcategories = set ( sec [ 'cid' ]

Downcast from Any to a protocol

匿名 (未验证) 提交于 2019-12-03 01:14:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the following code. How can I resolve the error in the last line? protocol Animal { func walk() } struct Cat: Animal { func walk() {} init() { } } var obj: Any = Cat() var cat = obj as Animal // ERROR: cannot downcast from Any to unrelated type Animal 回答1: Update: This has been fixed in Swift 1.2+ (Xcode 6.3+). The Xcode 6.3 beta release notes say: Dynamic casts (“as!", “as?" and “is”) now work with Swift protocol types, so long as they have no associated types. You can only check for protocol conformance (which includes is , as , and

Is it possible to move / merge messages between RabbitMQ queues?

匿名 (未验证) 提交于 2019-12-03 01:09:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm looking to know is it possible to move / merge messages from one queue to another. For example: main-queue contains messages ['cat-1','cat-2','cat-3','cat-4','dog-1','dog-2','cat-5'] dog-queue contains messages ['dog-1, dog-2, dog-3, dog-4] So the question is, (assuming both queues are on the same cluster, vhost) it possible to move messages from dog-queue to main-queue using rabbitmqctl ? So at the end I'm looking to get something like: Ideally: main-queue : ['cat-1','cat-2','cat-3','cat-4','dog-1','dog-2','cat-5', dog-3, dog-4] But

How can I `print` or `cat` when using parallel

匿名 (未验证) 提交于 2019-12-03 01:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: If I call a function using parSapply then print , message or cat statements inside that function don't seem to output to the console. My process takes a very long time, so I need some way of seeing the progress and getting the results output as they are done. Are there any special commands that would allow me to print to the console from a parallel process? Example: library(parallel) oneloop = function(x) { for(i in 1:50) { a = rnorm(100000) a = sort(a) } print(x) message(x) cat(x) } cl 回答1: Using outfile param in makeCluster you can

How to create listeners with javascript

匿名 (未验证) 提交于 2019-12-03 01:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to create a main class animal , then have two sub classes inherit properties from animal which are cat and dog , then I was to make multiple objects (multiple cat's and dog's) inherit from the class cat and dog (I read it's not really a class but it behaves as a class). The multiple objects (cat1, mycat, tomcat, dog1, mydog, topdog) need to be able to talk and listen to each other. When talking I would have them just alert or print a text line. What I am having trouble with is the listening part. I want the individual myDog to print

postgresql-sort array by words in each elements

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: There is string array ARRAY['CAT','CAT DOG CAT','DOG Cat'] Now i want to sort this array on count of words in each element. I have tried but cannot get any success. I want this output ARRAY['CAT DOG CAT','DOG CAT','Cat'] How i can do this? 回答1: This does feel rather clumsy, but I can't think of a simpler solution right now: with val (col) as ( values (ARRAY['CAT','CAT DOG CAT','DOG Cat']) ), word_list as ( select unnest(col) as pc from val ), wc as ( select array_length(string_to_array(pc, ' '),1) as word_count, pc from word_list ) select

Wordpress, get ID's of multiple categories from the URL

匿名 (未验证) 提交于 2019-12-03 00:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using WordPress 2.8.4. My question is, if I'm viewing a sub category ( cat-slug-2 in this example) is there a built in function to get it's category ID and its parents category ID ? Here's an example URL, where cat-slug-2 is a sub category of cat-slug-1 http://www.foo.com/category/cat-slug-1/cat-slug-2/ 回答1: Maybe something like this? <?php $current_category = single_cat_title("", false); $category_ID = $wpdb->get_var( "SELECT term_id FROM $wpdb->terms WHERE slug = '" . $current_category . "'" ); echo(get_category_parents($category_ID,

pinpoin监控安装

匿名 (未验证) 提交于 2019-12-03 00:39:02
Pinpoint是什么 简单的说,Pinpoint是一款对Java编写的大规模分布式系统的APM工具,有些人也喜欢称呼这类工具为调用链系统、分布式跟踪系统。我们知道,前端向后台发起一个查询请求,后台服务可能要调用多个服务,每个服务可能又会调用其它服务,最终将结果返回,汇总到页面上。如果某个环节发生异常,工程师很难准确定位这个问题到底是由哪个服务调用造成的,Pinpoint等相关工具的作用就是追踪每个请求的完整调用链路,收集调用链路上每个服务的性能数据,方便工程师能够快速定位问题。它对性能的影响最小(只增加约3%资源利用率),安装agent是无侵入式的 为什么要用Pinpoint 最重要的原因,对代码的零侵入,运用JavaAgent字节码增强技术,只需要加启动参数即可。 Pinpoint-Collector:收集各种性能数据 Pinpoint-Agent:和自己运行的应用关联起来的探针 Pinpoint-Web:将收集到的数据显示成WEB网页形式 HBase Storage:收集到的数据存到HBase中 部署: 1台Web,安装好jdk,tomcat 2台collector,安装jdk,tomcat 1台hbase ,安装好jdk,hbase必须给大点的存储,目前我挂的是300G的硬盘,预生产环境比较小,后面根据实际情况调整 War包下载: https://github.com