Search Results

Search found 15239 results on 610 pages for 'array population'.

Page 72/610 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • [JavaScript] Function making a slight miscalculation.

    - by Stanni
    Hi, To begin with, I have a database that holds map data for a game I am creating. A script on my page uses JSON to retrieve a certain amount of that data from the database and store it in an array. When the data is retrieved it goes through a function that finds out how many individual tiles are used in that particular area. Here is the code: var xmlhttp = new XMLHttpRequest; xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 4){ var map = JSON.parse(xmlhttp.responseText); var mapTiles = new Array; for(var count = 0; count < map.length; count ++){ if(map[count]){ if(map[count]['tile'] in mapTiles == false){ mapTiles.push(map[count]['tile']); } } } alert(mapTiles); } } For each time the script finds a tile number that isn't already in the mapTiles array it adds it to it. Currently, the script is fetching 1024 records that all but one contain the tile value of '1' the other of which contains the tile value of '2'. This means that when I alert the mapTiles array it should display "1, 2" but instead it displays "1, 1, 2". So there is a slight error in the script but I cannot find it.

    Read the article

  • how to get the value of an php array in jQuery

    - by user1933824
    i have a PHP code that will obtain the total images of a certain website via CURL, and put it inside an PHP loop. $z=1; for ($i=0;$i<=sizeof($images_array);$i++) { ....<img src = "$images_array[$i]" id="$z"> .. $z++; } a user can then scan through the array with a prev/next button and the current image being shown will be displayed in my $('$current_image').val(1); $.post("curl_fetch.php?url="+ extracted_url, { }, function(response){ $('#loader').html($(response).fadeIn('slow')); $('#current_image').val(1); // insert loop value in .val() when i click a button, i want to get the value of the array, and not the loop value $(function() { $(document).on('click','.submit', function () { var img = $('#current_image').val(); //get the array value, not the loop value alert(img); });}); now, how do i properly get the array value in my $('#current_image').val(1); in Jquery.

    Read the article

  • Device cannot be added on software-raid-1 array on Ubuntu 12.04

    - by George Pligor
    Unfortunately all tutorials I have found online until now on how to setup software-raid-1 are outdated on ubuntu 12.40 My target is to setup it on a system with a secondary disk drive that is already running. Format is not an option! I am trying to follow and adapt from 11.10 to 12.04 the following tutorial: http://www.howtoforge.com/how-to-set-up-software-raid1-on-a-running-lvm-system-incl-grub2-configuration-ubuntu-11.10-p2 On the above tutorial there is a successful command which creates a raid-1 array by setting the first disk drive with the installed system as missing: mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1 But when the time comes to add the first main drive with the installed system on the raid-array with this command: mdadm --add /dev/md0 /dev/sda1 I receive an error message. The error message says that the device /dev/sda is (which makes sense) busy! Note: hardware raid solution is not available since the system is a laptop with two disk drives! Thank you

    Read the article

  • mongoexport csv output array values

    - by 9point6
    I'm using mongoexport to export some collections into CSV files, however when I try to target fields which are members of an array I cannot get it to export correctly. command I'm using: mongoexport -d db -c collection -fieldFile fields.txt --csv > out.csv and the contents of fields.txt is similar to id name address[0].line1 address[0].line2 address[0].city address[0].country address[0].postcode where the BSON data would be: { "id": 1, "name": "example", "address": [ { "line1": "flat 123", "line2": "123 Fake St.", "city": "London", "country": "England", "postcode": "N1 1AA" } ] } what is the correct syntax for exporting the contents of an array?

    Read the article

  • Advantages of multiple SQL Server files with a single RAID array

    - by Dr Giles M
    Originally posted on stack overflow, but re-worded. Imagine the scenario : For a database I have RAID arrays R: (MDF) T: (transaction log) and of course shared transparent usage of X: (tempDB). I've been reading around and get the impression that if you are using RAID then adding multiple SQL Server NDF files sitting on R: within a filegroup won't yeild any more improvements. Of course, adding another raid array S: and putting an NDF file on that would. However, being a reasonably savvy software person, it's not unthinkable to hypothesise that, even for smaller MDFs sitting on one RAID array that SQL Server will perform growth and locking operations (for writes) on the MDF, so adding NDFs to the filegroup even if they sat on R: would distribute the locking operations and growth operations allowing more throughput? Or does the time taken to reconstruct the data from distributed filegroups outweigh the benefits of reduced locking? I'm also aware that the behaviour and benefits may be different for tables/indeces/log. Is there a good site that distinguishes the benefits of multiple files when RAID is already in place?

    Read the article

  • Database OR Array

    - by rezoner
    What is the exact point of using external database system if I have simple relations (95% querries are dependant on ID). I am storing users and their stats. Why would I use external database if I can have neat constructions like: db.users[32] = something Array of 500K users is not that big effort for RAM Pros are: no problematic asynchronity (instant results) easy export/import dealing with database like with a native object LITERALLY ps. and considerations: Would it be faster or slower to do collection[3] than db.query("select ... I am going to store it as a file/s There is only ONE application/process accessing this data, and the code is executed line by line - please don't elaborate about locking. Please don't answer with database propositions but why to use external DB over native array/object - I have experience in a few databases - that's not the case. What I am building is a client/gateway/server(s) game. Gateway deals with all users data, processing, authenticating, writing statistics e.t.c No other part of software needs to access directly to this data/database.

    Read the article

  • cant recognize the path of hard drive which is not a part of an array

    - by Abhishek
    hi there, I have a problem on my server as below.. On my server i configured a raid array of 3 hard disks, in my c drive their is a web applications running on Apache Tomcat server. Now because of shortage of storage i entered a new hard disk to the server which is not a part of that raid array. Now through my web application i upload some images to new hard drive and file uploaded successfully but when through that same application, i try to retrieve those images and show on a web site i does not recognize that and dose not give any error. i try to access that drive with absolute path but it not works. Can any one help me to find the solution of this problem? Thank You in advance.

    Read the article

  • I have a 21TB array but only 16TB is visible from Windows

    - by Relentim
    CONTROLLER Raid Controller: 3Ware 9650SE-24M8 Disks: 21 x 1TB RAID5 Stripe 64KB WINDOWS OS: Windows Server 2003 SP2 32x Disk: Dynamic 19557.44GB Volume: Capacity 15832.19GB I guess my array must have a 4KB block size which is limiting it to 16TB. I think I would have to switch to a 64KB block size to be able to see a maximum of 256TB. Or create another unit on my controller to go above 16TB of storage. Unfortunately I have already added over 16TB, ideally I would like to shrink the array and reclaim the 5 disks that aren't doing anything. I don't think this is possible. More likely, can I change the block size so 20TB becomes visible in windows?

    Read the article

  • OSX Dirve dropped out of RAID 5 Array?

    - by user41724
    I had a drive "Fail" and drop out of our raid 5 array... After reboot the drive came back up, but its "Roaming". How do I re-integrate it back into the RAID 5? Right now I have no redundancy with only 2 disks in the array. The migrate RAID Set feature of RAID Utility seems to want to crate a RAID 0 only? I have provided links to some screen caps. http://tiny.cc/3ns5r Any help would be appreciated. Thanks

    Read the article

  • Create a subarray reference in C# (using unsafe ?)

    - by Wam
    Hello there, I'm refactoring a library we currently use, and I'm faced with the following problem. We used to have the following stuff : class Blah { float[][] data; public float[] GetDataReference(int index) { return data[index]; } } For various reasons, I have replaced this jagged array version with a 1 dimensionnal array version, concatenating inner arrays. My question is : how can I still return a reference to a sub array of data ? class Blah { float[] data; int rows; public float[] GetDataReference(int index) { // Return a reference data from offset i to offset j; } } I was thinking that unsafe and pointers stuff may be of use, is it doable ?

    Read the article

  • Replace empty cells with logical 0's before cell2mat in MATLAB

    - by Doresoom
    I've got a cell array of empty cells and ones that I want to convert to a logical array, where the empty cells are zeros. When I use cell2mat, the empty cells are ignored, and I end up with a matrix of solely 1's, with no reference to the previous index they held. Is there a way to perform this operation without using loops? Example code: for n=1:5 %generate sample cell array mycellarray{n}=1; end mycellarray{2}=[] %remove one value for testing Things I've tried: mylogicalarray=logical(cell2mat(mycellarray)); which results in [1,1,1,1], not [1,0,1,1,1]. for n=1:length(mycellarray) if isempty(mycellarray{n}) mycellarray{n}=0; end end mylogicalarray=logical(cell2mat(mycellarray)); which works, but uses loops.

    Read the article

  • What's wrong with this javascript?

    - by Arlen Beiler
    What's wrong with this code? var divarray = document.getElementById("yui-main").getElementsByTagName("div"); var articleHTML = array(); var absHTML; var keyHTML; var bodyHTML = array(); var i = 0; for ( var j in divarray) { if(divarray[i].className == "articleBody"){ alert("found"); articleHTML = divarray[i]; break; } bodyHTML[i] = ''; if(articleHTML[i].className == "issueMiniFeature"){continue;} if(articleHTML[i].className == "abstract"){absHTML = articleHTML[i]; continue;} if(articleHTML[i].className == "journalKeywords"){keyHTML = articleHTML[i]; continue;} bodyHTML[i] = articleHTML[i]; i++; } This is the error I am getting: ReferenceError: array is not defined I am using Google Chrome if it helps any.

    Read the article

  • PHP While Loops from Arrays

    - by Michael
    I have a table that contains members names and a field with multiple ID numbers. I want to create a query that returns results where any values in the ID fields overlap with any values in the array. For example: lastname: Smith firstname: John id: 101, 103 I have Array #1 with the values 101, 102, 103 I want the query to output all members who have the values 101 or 102 or 103 listed in their id field with multiple ids listed. Array ( [0] => 101 [1] => 102 [2] => 103 ) $sql="SELECT firstname, lastname, id FROM members WHERE id LIKE '%".$array_num_1."%'"; $result=mysql_query($sql); while ($rows=mysql_fetch_array($result)) { echo $rows['lastname'].', '.$rows['firstname'].'-'.$rows['id']; }

    Read the article

  • Struggling with a loop

    - by Emil
    Hey. I am trying to make an integer match another integer by adding a number to one of them. I have tried several loop types, but none has worked. Take a look at the code: int favoriteLoop = [favoriteThing intValue]; if (favoriteLoop != [[[array objectAtIndex:favoriteLoop] description] intValue]){ NSLog(@"%d", [[[array objectAtIndex:favoriteLoop] description] intValue]); int favTemp = favoriteLoop; for (int x = favTemp; (favoriteLoop == [[[array objectAtIndex:favoriteLoop] description] intValue]); x++) { NSLog(@"Still not there.."); } } Could anyone help me clear up this mess? It just won't work! Could it have something to do with it allready being inside a for-loop?

    Read the article

  • Inserting an element into a sorted list

    - by Russell Cargill
    Ok I'm using getSharedPreferences to store my high score but before I fill it up I wanted to sort the scores into ascending order via and array, but if it finds a Score less than it in the first pos then it wont check the rest for the smallest? //function to add score to array and sort it public void addscoretoarray(int mScore){ for(int pos = 0; pos< score.length; pos++){ if(score[pos] > mScore){ //do nothing }else { //Add the score into that position score[pos] = mScore; break; } } sortArray(score); } should I call sortArray() before and after the loop to fix this problem or is there a better method to achive the same results? I should also mention that the sortArray(score) funtion is just calling Arrays.sort(score) where score is an array of mScore

    Read the article

  • Finding the sum of 2D Arrays in Ruby

    - by Bragaadeesh
    Hi, I have an array of two dimensional Arrays. I want to create a new two dimensional array which finds the sum of these values in the 2D arrays. Sum at x,y of new array = Sum at x,y of arr1 + Sum at x,y of arr2 + .... |1,2,4| |1,1,1| |1,1,1| |2,4,6| |1,1,1| |1,1,1| |2,4,6| |1,1,1| |1,1,1| |2,4,6| |1,1,1| |1,1,1| Now adding the above two dimensional arrays will result in, |3,4,6| |4,6,8| |4,6,8| |4,6,8| How to achieve this in Ruby (not in any other languages). I have written a method, but it looks very long and ugly.

    Read the article

  • Library of ALL countries and their states for address forms

    - by Chris
    I need a library that includes all countries and respective codes in 1 array and a second multidimensional array for country to its states and a last array for state code to state name. I found tons of matches for similar requests but none actually have a simple CSV or XML with just that. My goal is to build an address form where you select your country and it then pre-populates the state dropdown - if the country has states - with the country's states. Shouldn't be so hard to find, but I guess i'm blind. Thanks so much for all help!

    Read the article

  • How to do a random-and-unique generator?

    - by javaLearner.java
    I already wrote a random generator which take arguments a and b, where a is minimun and b is maximum value, like this randomGenerator(int a, int b) What I want to do next is: Using a loop, then generate unique number from a to b. Example: I want to have 8 unique numbers, int a = 1; int b = 10; int value; If I do the loop, there is a high % that same number will appear more than once. Any idea how to do it? My own way is: while(int i <= 8){ randomGenerator(a,b); // if value is not in array, then insert into array } I am stuck at the comment part. Is there any way to check if a variable is exists in an array?

    Read the article

  • Quickest and most efficient method to search top 3 numbers?

    - by Donal Rafferty
    I currently have an array of around 8 - 10 numbers that changes on a periodic basis. So around every 5 - 10 seconds the numbers get updated. I need to get the top 3 numbers in the array every 10 seconds. This is all done on a mobile device. At the minute I iterate through the array 3 times and each time I take out the three highest numbers and place them in three previously declared variables. My question is what should I look to do to increase speed and efficiency in this instance?

    Read the article

  • Subplots of multidimensional arrays in Matlab

    - by altes4ia
    I have a 10x10x10 array, z. How do I plot everything in the SAME window so that I would have the 3 plots for z(:,:,1) and below it the three plots for z(:,:,2) etc ? This is what I have so far: for i = 1:10 z=z(:,:,i); figure(i) subplot(1,2,1) surf(z) %code, obtain new array called "new1"... subplot(1,2,2) surf(new1) %code, obtain new array called "new2"... subplot(1,3,3) surf(new2) end;

    Read the article

  • Economical way to get many harddrives into rack mount?

    - by Industrial
    Hi everyone, Please bear with me as being a bit of a newcomer at 19" rack-mounted equipment. I've thought a fair bit lately about the best way of getting 4x or 6x of 2.5" hard drives into my rack and are right now currently slightly confused about would be the best (economical) solution. After scouting the market, I've found this type of disk array units that offers built in RAID and a lot of drive slots and a truckload of geek cred, but at a price that just isn't going to fit in my budget. I've also found these type of cute adapters that takes two 2.5" drives in one 3.5" slot, but I will obviously need a chassie with a lot of 3.5" spaces in order to make it work. So what is the most economical way to house my harddrives in my rack?

    Read the article

  • Java single Array best choice for accessing pixels for manipulation?

    - by Petrol
    I am just watching this tutorial https://www.youtube.com/watch?v=HwUnMy_pR6A and the guy (who seems to be pretty competent) is using a single array to store and access the pixels of his to-be-rendered image. I was wondering if this really is the best way to do this. The alternative of Multi-Array does have one pointer more, but Arrays do have an O(1) for accessing each index and calculating the index in a single array seems to take one addition and one multiplication operation per pixel. And if Multi-Arrays really are bad, can't you use something with Hashing to avoid those addition and multiplication operations? EDIT: here is his code... public class Screen { private int width, height; public int[] pixels; public Screen(int width, int height) { this.width = width; this.height = height; // creating array the size of one index/int for every pixel // single array has better performance than multi-array pixels = new int[width * height]; } public void render() { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { pixels[x + y * width] = 0xff00ff; } } } }

    Read the article

  • How do I make these inputs relate to each other?

    - by dmanexe
    I have a series of checkbox inputs and corresponding text area inputs to allow specification of quantity. Here's what the two fields look like when the item is static (i.e. only 1): <input type="checkbox" name="measure[checked][]" value="<?=$item->id?>"> <input type="hidden" name="measure[quantity][]" value="1" /> Here's what the input fields look like for all items that have a specifiable quantity: <input type="checkbox" name="measure[checked][]" value="<?=$item->id?>"> <input class="item_mult" value="0" type="text" name="measure[quantity][]" /> This would play nicely, if within the array, it didn't output like this, after collecting it with: $field = $this->input->post('measure',true); Array ( [quantity] => Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 1 [4] => 1 [5] => 1 [6] => 25 [7] => 0 [8] => 0 [9] => 0 [10] => 1 [11] => 1 [12] => 1 [13] => 1 [14] => 1 [15] => 1 [16] => 1 [17] => 1 [18] => 1 [19] => 1 [20] => 1 [21] => 1 [22] => 0 [23] => 0 [24] => 0 [25] => 0 [26] => 0 [27] => 0 [28] => 0 [29] => 0 [30] => 0 [31] => 0 [32] => 0 [33] => 0 [34] => 0 [35] => 0 [36] => 0 [37] => 0 [38] => 0 [39] => 0 [40] => 0 [41] => 1 [42] => 1 [43] => 1 [44] => 1 [45] => 1 [46] => 1 [47] => 1 [48] => 1 [49] => 1 [50] => 1 [51] => 1 [52] => 0 [53] => 0 [54] => 0 ) [checked] => Array ( [0] => 4 [1] => 6 [2] => 13 ) ) I understand what the values in the checked array are, I just do not understand how to relate the first field to the second, later in the program. How do I incorporate the correct code to relate checked items to quantities?

    Read the article

  • Using Array Variables For FILE_GET_CONTENTS

    - by Whoshooter
    I have a script all done now and everything has been debugged and it works, except for the last hurdle. This script grabs pertinent information on bank web sites, takes that data and uses it to populate a template and then it's all posted to Wordpress - BUT I get an error because the file_get_contents function fails taking each url from the Array. I've var_dumped the array and all the URLS are there in the [0] key, so this is what I tried. master data is the scraped URL source the script uses urlscrape_array is the collection of URLS $master_data = file_get_contents($urlscrape_array[0]); When I run the script using a URL like below it works beautifully every time; $master_data = file_get_contents("http://www.somesite/somepage.html"); This is the error I get when I try to use the first example' Warning: file_get_contents() expects parameter 1 to be string, array given in /home3/path/public_html/mysite.com/boise_project/scriptmainpage.php on line 13 As requested here is a sample of the var_dump on $urlscrape_array[0] array(504) { [0]=> string(56) "http://www.somepage.com/somepage-3178.html" [1]=> string(54) "http://www.somepage.com/somepage-16.html" [2]=> string(56) "http://www.somepage.com/somepage-3202.html" [3]=> string(56) "http://www.somepage.com/somepage-4324.html" [4]=> string(56) "http://www.somepage.com/somepage-4777.html" [5]=> string(56) "http://www.somepage.com/somepage-5140.html" [6]=> string(56) "http://www.somepage.com/somepage-5220.html" [7]=> string(56) "http://www.somepage.com/somepage-9205.html" [8]=> string(56) "http://www.somepage.com/somepage-3251.html" [9]=> string(56) "http://www.somepage.com/somepage-3323.html" [10]=> string(56) "http://www.somepage.com/some-page-3797.html" [11]=> string(56) "http://www.somepage.com/some-page-4145.html" [12]=> string(56) "http://www.somepage.com/some-page-3191.html" [13]=> string(55) "http://www.somepage.com/some-page-329.html" [14]=> string(56) etc.... Error as per the foreach statement provided by Uptown Warning: Invalid argument supplied for foreach() in /home3/bettyt45/public_html/bdbud.com/boise_project/boise-wordpress.php on line 12 NULL print_r resulst below; Array ( [0] => Array ( [0] => http://www.somesite.com/some-page-3178.html [1] => http://www.somesite.com/some-page-16.html [2] => http://www.somesite.com/some-page-3202.html [3] => http://www.somesite.com/some-page-4324.html [4] => http://www.somesite.com/some-page-4777.html [5] => http://www.somesite.com/some-page-5140.html [6] => http://www.somesite.com/some-page-5220.html [7] => http://www.somesite.com/some-page-9205.html [8] => http://www.somesite.com/some-page-3251.html [9] => http://www.somesite.com/some-page-3323.html [10] => http://www.somesite.com/some-page-3797.html [11] => http://www.somesite.com/some-page-4145.html [12] => http://www.somesite.com/some-page-3191.html [13] => http://www.somesite.com/some-page-329.html [14] => http://www.somesite.com/some-page-3341.html [15] => http://www.somesite.com/some-page-3758.html [16] => http://www.somesite.com/some-page-4180.html [17] => http://www.somesite.com/some-page-9014.html [18] => http://www.somesite.com/some-page-5987.html [19] => http://www.somesite.com/some-page-1542.html [20] => http://www.somesite.com/some-page-3004.html [21] => http://www.somesite.com/some-page-9034.html [22] => http://www.somesite.com/some-page-3385.html [23] => http://www.somesite.com/some-page-3435.html [24] => http://www.somesite.com/some-page-6389.html [25] => http://www.somesite.com/some-page-6992.html [26] => http://www.somesite.com/some-page-7051.html HERE IS THE CODE I USED TO CREATE THE ARRAY ABOVE; $urlscrape_data = file_get_contents('http://www.bdbud.com/boise_project/boise-urls.htm'); preg_match_all('~http\:\/\/www.creditunionsonline.com\/credit\-union\-\d{1,4}?\.html~', $urlscrape_data, $urlscrape_matches); $urlscrape_array = $urlscrape_matches;

    Read the article

  • Blackberry Development, adding dynamic number of buttons and setting Fieldchangelistener() for them

    - by Nikesh Yadav
    Hi, I am adding dynamic number of buttons in a Blackberry application and trying to get different events on each button click. I am not able to apply the setchangelistener() for these array of buttons as once the loop finishes after adding all the buttons, the events gets generated only for the last indexed button. If I make us of getIndex(), it runs fine only if I am not adding any other fields on my screen, but if I add other fields along with these array of buttons, the getIndex() function count them in the indexing as well. Can anyone please help me out in setting FieldChangeListener to array of ButtonField? Here is a sample code of the way I am using the array of ButtonField. I the code I have added two test LabelField at the top of the screen, if I remove them the code will run fine and I will get different result for each button click, but if I keep them active, the indexing gets effected and the Button wont work. package buttonclickloop; import net.rim.device.api.ui.DrawStyle; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.FieldChangeListener; import net.rim.device.api.ui.component.ButtonField; import net.rim.device.api.ui.component.LabelField; import net.rim.device.api.ui.container.HorizontalFieldManager; import net.rim.device.api.ui.container.MainScreen; public class ButtoncClickLoop extends MainScreen { int i = 0; private ButtonField[] btn = new ButtonField[50]; public ButtoncClickLoop() { // TODO Auto-generated constructor stub LabelField Field1 = new LabelField("Field1"); LabelField Field2 = new LabelField("Field2",DrawStyle.RIGHT | ButtonField.USE_ALL_WIDTH); HorizontalFieldManager FieldHmgr = new HorizontalFieldManager(); FieldHmgr.add(Field1); FieldHmgr.add(Field2); FieldHmgr.setMargin(0,0,10,5); add(FieldHmgr); while (i < 3){ FieldChangeListener listener = new FieldChangeListener() { public void fieldChanged(Field field, int context) { context = field.getIndex(); if (field == btn[context]){ add(new LabelField("Label" + context + "")); } } }; btn[i] = new ButtonField("Button" + i + ""); btn[i].setChangeListener(listener); add(btn[i]); i = i + 1; } } } Thanks, Nikesh

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >