bar

How do I create XML using Nokogiri::XML::Builder with a hyphen in the element name?

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to build an XML document using Nokogiri. Some of the elements have hyphens in them. Here's an example: require "nokogiri" builder = Nokogiri::XML::Builder.new do |xml| xml.foo_bar "hello" end puts builder.to_xml Which produces: <?xml version="1.0"?> <foo_bar>hello</foo_bar> However, when I try: builder = Nokogiri::XML::Builder.new do |xml| xml.foo-bar "hello" end I get: syntax error, unexpected tSTRING_BEG, expecting kDO or '{' or '(' xml.foo-bar "hello" Now I realise this is because the hyphen is being interpreted as foo MINUS

What is the maven-shade-plugin used for, and why would you want to relocate java packages?

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I found the maven-shade-plugin being used in someone's pom.xml. I've never used maven-shade-plugin before (and I'm a maven n00b) so I tried to understand the reason for using this and what it does. I looked at the maven docs , however I can't understand this statement: "This plugin provides the capability to package the artifact in an uber-jar, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies." The documentation on the page doesn't seem very newbie-friendly. What is an "uber jar?" Why would

Bash bad substitution with subshell and substring

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: A contrived example... given FOO="/foo/bar/baz" this works (in bash) BAR=$(basename $FOO) # result is BAR="baz" BAZ=${BAR:0:1} # result is BAZ="b" this doesn't BAZ=${$(basename $FOO):0:1} # result is bad substitution My question is which rule causes this [subshell substitution] to evaluate incorrectly? And what is the correct way, if any, to do this in 1 hop? 回答1: First off, note that when you say this: BAR=$(basename $FOO) # result is BAR="baz" BAZ=${BAR:0:1} # result is BAZ="b" the first bit in the construct for BAZ is BAR and not the

What&#039;s the proper way to escape URL variables with Spring&#039;s RestTemplate when calling a Spring RestController?

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When calling RestTemplate.exchange to do a get request, such as: String foo = "fo+o"; String bar = "ba r"; restTemplate.exchange("http://example.com/?foo={foo}&bar={bar}", HttpMethod.GET, null, foo, bar) what's the proper to have the URL variables correctly escaped for the get request? Specifically, how do I get pluses ( + ) correctly escaped because Spring is interpreting as spaces , so, I need to encode them. I tried using UriComponentsBuilder like this: String foo = "fo+o"; String bar = "ba r"; UriComponentsBuilder ucb =

Android - Show/Hide system bar on 4.2.2 (Nexus 10)

匿名 (未验证) 提交于 2019-12-03 02:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I got issue with Nexus 10 - 4.2.2. I was testing code below on Galaxy Tab 10.1 with 4.0.4 and it was working fine: try { Process proc = Runtime.getRuntime().exec(new String[]{"sh","startservice","-n","com.android.systemui/.SystemUIService"}); proc.waitFor(); } catch (Exception e) { e.printStackTrace(); } try { //REQUIRES ROOT Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 42 s16 com.android.systemui"}); //WAS 79 proc.waitFor(); } catch(Exception ex) { //Toast.makeText(getApplicationContext(), ex

Change tab bar item selected color in a storyboard

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to change my tab bar items to be pink when selected instead of the default blue. How can i accomplish this using the storyboard editor in Xcode 6? Here are my current setting which are not working, the blue background works but the pink doesnt work: 回答1: Add Runtime Color attribute named "tintColor" from StoryBoard. This is working. 回答2: This elegant solution works great on SWIFT 3.0 and SWIFT 4.0 : On the Storyboard: Select your Tab Bar Set a Runtime Attibute called tintColor for the desired color of the Selected Icon on the tab bar

GNUPLOT Each Histogram Bar with different color

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to visualize the amount of different colors of a bitmap file. My Datasheet looks like: 1 163073164 4 185122087 3 255242000 8 255255255 3 000162232 1 181230029 1 127127127 1 136000021 3 200191231 I want to draw each color bar with its own color by using gnu plot histogram style. I just try something out by using "lc variable" but it doesnt work. :-( My GNUPLOT script by now: set style data histograms set boxwidth 1 set grid set style histogram cluster gap 0 set style fill solid 1.0 border -1 set yrange [0:*] set xrange [0:*] set xtics

Progress Bar while download file over http with Requests

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I need to download a sizable (~200MB) file. I figured out how to download and save the file with here . It would be nice to have a progress bar to know how much has been downloaded. I found ProgressBar but I'm not sure how to incorperate the two together. Here's the code I tried, but it didn't work. bar = progressbar . ProgressBar ( max_value = progressbar . UnknownLength ) with closing ( download_file ()) as r : for i in range ( 20 ): bar . update ( i ) 回答1: I suggest you try tqdm [1], it's very easy to use. Example code for

How to add buttons to navigation controller visible after segueing?

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have set up a view controller in Storyboard which is embedded in a navigation controller. In this nav controller I have checked Shows Navigation Bar and Shows Toolbar and enabled a navigation bar and toolbar in Top Bar and Bottom Bar respectively in Simulated Metrics. I then "Show e.g. Push" segue from the view controller to another view controller. On both view controllers I've set up Simulated Metrics the same way, so both the navigation bar and toolbar are visible on all three controllers. The problem is, I can add bar button items to

Annotate bars with values on Pandas bar plots

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I looking for a way to annotate my bars in a Pandas bar plot with the values (rounded) in my DataFrame. >>> df=pd.DataFrame({'A':np.random.rand(2),'B':np.random.rand(2)},index=['value1','value2'] ) >>> df A B value1 0.440922 0.911800 value2 0.588242 0.797366 I would like to get something like this: I tried with this, but the annotations are all centered on the xthicks: >>> ax = df.plot(kind='bar') >>> for idx, label in enumerate(list(df.index)): for acc in df.columns: value = np.round(df.ix[idx][acc],decimals=2) ax.annotate(value, (idx,