array

Convert JSON array in MySQL to rows

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm loving the new JSON functions in MySQL 5.7, but running into a block trying to merge values from JSON into a normal table structure. Grabbing JSON, manipulating and extracting arrays from it etc. is simple. JSON_EXTRACT all the way. But what about the inverse, going from a JSON array to rows? Perhaps I am dense on the existing MySQL JSON functionality, but I haven't been able to figure that one out. For example, say I have a JSON array and want to insert a row for each element in the array with its value? The only way I have found is to

How to convert string array to int array in java

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an string array in java program like this String results[] = { "2", "1", "5", "1" }; I want to convert this to integer array as like this: int results[] = { 2, 1, 5, 1 }; And finally I want to find the summation of all the int elements of that array. 回答1: If you are using java 8 Try this : int[] array = Arrays.stream(resultsStr).mapToInt(Integer::parseInt).toArray(); 回答2: String resultsStr[] = {"2", "1", "5", "1"}; ArrayList intermediate = new ArrayList(); for(String str : resultsStr) { intermediate.add(Integer.parseInt(str, 10)); /

Searching in an array for numbers with each element +1 or -1 of preceding element [closed]

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: An array of integers contains elements such that each element is 1 more or less than its preceding element. Now we are given a number, we need to determine the index of that number's first occurrence in the array. Need to optimize linear search. Its not homework. 回答1: My algorithm would be like this: p=0 if (A[p] == x) then idx=p and the algorithm is finished else goto next step set p += |x-A[p]| goto 2. say A[p] > x. Then, since A items increase or decrease by 1, idx is for sure at least (A[p] - x) index away from p. Same principle goes for

Accessing UserDefault Array URL to Populate CollectionView

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is a follow-up from a previous post here . I am now trying to access the array and use it to populate my collectionView. When I try the following code, my imageData comes back as nil and I get a crash, even though the imageURL correctly shows as a filepath. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let usD = UserDefaults.standard let array = usD.stringArray(forKey: "WeatherArray") ?? [] let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell",

CakePHP Form Validation only on Entering Data

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to Upload a photo for one of the models and when i am going to the edit mode. It still asks me to upload the photo when the user only wants to edit the text related to that record. Below is my Validation Rules. 'display_photo' => array( 'uploadError' => array( 'rule' => array('uploadError'), 'message' => 'Please select a Photo.', 'allowEmpty' => true, ), 'mimeType' => array( 'rule' => array('mimeType', array('image/gif', 'image/png', 'image/jpg', 'image/jpeg')), 'message' => 'Please only upload images (gif, png, jpg).',

F# lazy pixels reading

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to make a lazy loading of image pixels to the 3 dimensional array of integers. For example in simple way it looks like this: for i=0 to Width for j=0 to Height let point=image.GetPixel(i,j) pixels.[0,i,j] <- point.R pixels.[1,i,j] <- point.G pixels.[2,i,j] <- point.B How it can be made in lazy way? 回答1: What would be slow is the call to GetPixel . If you want to call it only as needed, you could use something like this: open System.Drawing let lazyPixels (image:Bitmap) = let Width = image.Width let Height = image.Height let pixels :

assigning multidimensional php array to javascript array

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know this may be a duplicate, but I cant wrap my brain around the other examples. Help would be appreciated. I have a php array that i need to assign to a javascript array. Here is my amateur way of doing it now. You can see source at http://www.preferweb.com/accentps/index.php <?php $i=0; while ($result1 = mysql_fetch_array($query1)){ print "<script>"; print "var size[".$i."]=" .$result1['type'].";\n"; print "var 25[".$i."]=" .$result1['25'].";\n"; print "var 50[".$i."]=" .$result1['50'].";\n"; print "var 100[".$i."]=" .$result1['100'].";

Java Convert this string to JSONArray [closed]

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting the following String response from a server: {"fid":"1272","uri":"http://someurl/services/file/1272"} I need to convert it into a JSONArray . Any help? By the way, I tried this and it does not work: String response=getResponseFromServer(); JSONArray array = new JSONArray(response); I get the error: org.json.JSONException: Value {"fid":"1272","uri":"http://someurl/services/file/1272"} of type org.json.JSONObject cannot be converted to JSONArray 回答1: If you're talking about using the JSON in java library, then since your input

Binding an NSTableView to an array of strings in Swift

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm showing the contents of an array of strings with an NSTableView via binding through an Array Controller. I have "NSString" in Class Name in the attributes inspector for the Array Controller and in the Model Key Path of the Array Controller's binding inspector I have the path to my array. And I have the only column of the table bound in its Value section to the Array Controller without Model Key Path specified (it's just an array of strings). As a result, the array's strings are displayed fine in the table. But I can't edit any of the

OpenCV / Array should be CvMat or IplImage / Releasing a capture object

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Edit : Array should be CvMat or IplImage is not an error message specific to this issue, that's the only most relevant error message i got. I'm trying to make an *.exe out of an application using opencv. I'm using Python 2.6 and openCV 2.1 . I can run part of the *.exe, i'm having a menu from where i can choose to process some pictures from 2 differents sources my webcam & a static image. The static image part works but when i'm chosing the webcam here is the output: OpenCV Error: Bad argument (Array should be CvMat or IplImage) in unknown