each

Warning: Each child in an array or iterator should have a unique “key” prop

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: G'Day. I want to iterate over a bunch of JSON objects and turn them into React Elements. The objects look like this "fields" : [ { key : "testname" , "name" : "testname" , "altName" : "" , "visible" : true , "groupVisibility" : "public" , "type" : "text" , "component" : "input" , "label" : "Test Smart Input" , "placeholder" : "Some default Value" , "required" : "required" , "validated" : false , "data" : [] }, { key : "password" , "name" : "password" , "altName" : "" , "visible" : true , "groupVisibility" : "public" , "type" :

Call a stored procedure for each row returned by a query in MySQL

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want a MySQL stored procedure which effectively does: foreach id in (SELECT id FROM objects WHERE ... ) CALL testProc(id) I think I simply want the MySQL answer to this question but I don't understand cursors well: How do I execute a stored procedure once for each row returned by query? 回答1: You need a stored procedure! CREATE PROCEDURE foo () BEGIN DECLARE done BOOLEAN DEFAULT FALSE ; DECLARE _id BIGINT UNSIGNED ; DECLARE cur CURSOR FOR SELECT id FROM objects WHERE ...; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done := TRUE ;

Filter each column of a data.frame based on a specific value

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Consider the following data frame: df Using dplyr , how can I filter, on each column (without implicitly naming them), for all values greater than 2. Something that would mimic an hypothetical filter_each(funs(. >= 2)) Right now I'm doing: df %>% filter(X1 >= 2, X2 >= 2, X3 >= 2, X4 >= 2, X5 >= 2) Which is equivalent to: df %>% filter(!rowSums(. Note: Let's say I wanted to filter only on the first 4 columns, I would do: df %>% filter(X1 >= 2, X2 >= 2, X3 >= 2, X4 >= 2) or df %>% filter(!rowSums(.[-5] Would there be a more efficient

How many units of each iOS version are currently in usage? [closed]

匿名 (未验证) 提交于 2019-12-03 01:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Anyone know where I can find stats on how many units are currently running each major version of iOS (1-4). I'm trying to decide if it's prudent to use functionality only available in iOS 4. Thanks! 回答1: I've found this article on the web : http://blog.jcmultimedia.com.au/2010/08/recent-ios-version-statistics-from-delhi-city-metro.html Updated : March 2011 回答2: The same company that provided the data for the accepted answer (Chitika, Inc.) has published data for January 2011: iOS 3.x for iPhone's share appears to have decreased by 33%! 回答3:

Heatmap with text in each cell with matplotlib's pyplot

匿名 (未验证) 提交于 2019-12-03 01:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use matplotlib.pyplot.pcolor() to plot a heatmap with matplotlib: import numpy as np import matplotlib.pyplot as plt def heatmap(data, title, xlabel, ylabel): plt.figure() plt.title(title) plt.xlabel(xlabel) plt.ylabel(ylabel) c = plt.pcolor(data, edgecolors='k', linewidths=4, cmap='RdBu', vmin=0.0, vmax=1.0) plt.colorbar(c) def main(): title = "ROC's AUC" xlabel= "Timeshift" ylabel="Scales" data = np.random.rand(8,12) heatmap(data, title, xlabel, ylabel) plt.show() if __name__ == "__main__": main() Is any way to add the corresponding

Argmax of each row or column in scipy sparse matrix

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: scipy.sparse.coo_matrix.max returns the maximum value of each row or column, given an axis. I would like to know not the value, but the index of the maximum value of each row or column. I haven't found a way to make this in an efficient manner yet, so I'll gladly accept any help. 回答1: From scipy version 0.19, both csr_matrix and csc_matrix support argmax() and argmin() methods. 回答2: I would suggest studying the code for moo . _min_or_max_axis where moo is a coo_matrix . mat = mat . tocsc () # for axis=0 mat . sum_duplicates ()

Creating Firebase topic for each user

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We have a design approach which is creating a topic for each registered user. Creating a new user Save it to our database with a generated token Subscribe to /topics/{user-token} when user login on android or ios device. So if user have more than one device and if we want to send a user specific notification, we just send it to /topics/{user-token} so it received by all devices. We've not encountered any problem with a few users yet, but is that ok for Firebase limitations and is it a good approach? 回答1: (I am moving my comments into an

Text On each bar of a stacked bar chart d3.js

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 选择语言 中文(简体) 日语 英语 中文(繁体) 由 翻译 强力驱动 问题: I would like to have some text in each bar of a stacked bar in stacked bar chart provided in d3.js library. Thanks for your help. I have customized the example here link but I have not changed anything else in the javascript code and here is the result 回答1: Here is the important piece of code: state . selectAll ( "rect" ) . data ( function ( d ) { return d . ages ; }) . enter (). append ( "rect" ) . attr ( "width" , x . rangeBand ()) . attr ( "y" , function ( d ) { return y ( d . y1 ); }) . attr ( "height"

Count number of occurrences for each char in a string

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to count the number of occurrences of each character in a given string using JavaScript. For example: var str = "I want to count the number of occurances of each char in this string"; Output should be: h = 4; e = 4; // and so on I tried searching Google, but didn't find any answer. I want to achieve something like this ; order doesn't matter. 回答1: This is really, really simple in JavaScript (or any other language that supports maps): // The string var str = "I want to count the number of occurances of each char in this string"; // A

Context unique to each group at a specified level

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Recent versions of Mathematica provide the option of having a unique $Context for each cell group, via: Evaluation > Notebook's Default Context > Unique to Each Cell Group This is an appealing concept, but I find it unusable, as my code spans multiple cell groups. I would like a way to specify a unique context for cell groups of a certain level such as every Section , but not a separate context for every Subsection or Subsubsection . A solution will need to affect new cell groups as they are created. 回答1: You should be able to do this by