Search Results

Search found 834 results on 34 pages for 'looping'.

Page 10/34 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Java java.util.ConcurrentModificationException error

    - by vijay
    Hi all, please can anybody help me solve this problem last so many days I could not able to solve this error. I tried using synchronized method and other ways but did not work so please help me Error java.util.ConcurrentModificationException at java.util.AbstractList$Itr.checkForComodification(Unknown Source) at java.util.AbstractList$Itr.remove(Unknown Source) at JCA.startAnalysis(JCA.java:103) at PrgMain2.doPost(PrgMain2.java:235) Code public synchronized void startAnalysis() { //set Starting centroid positions - Start of Step 1 setInitialCentroids(); Iterator<DataPoint> n = mDataPoints.iterator(); //assign DataPoint to clusters loop1: while (true) { for (Cluster c : clusters) { c.addDataPoint(n.next()); if (!n.hasNext()) break loop1; } } //calculate E for all the clusters calcSWCSS(); //recalculate Cluster centroids - Start of Step 2 for (Cluster c : clusters) { c.getCentroid().calcCentroid(); } //recalculate E for all the clusters calcSWCSS(); // List copy = new ArrayList(originalList); //synchronized (c) { for (int i = 0; i < miter; i++) { //enter the loop for cluster 1 for (Cluster c : clusters) { for (Iterator<DataPoint> k = c.getDataPoints().iterator(); k.hasNext(); ) { // synchronized (k) { DataPoint dp = k.next(); System.out.println("Value of DP" +dp); //pick the first element of the first cluster //get the current Euclidean distance double tempEuDt = dp.getCurrentEuDt(); Cluster tempCluster = null; boolean matchFoundFlag = false; //call testEuclidean distance for all clusters for (Cluster d : clusters) { //if testEuclidean < currentEuclidean then if (tempEuDt > dp.testEuclideanDistance(d.getCentroid())) { tempEuDt = dp.testEuclideanDistance(d.getCentroid()); tempCluster = d; matchFoundFlag = true; } //if statement - Check whether the Last EuDt is > Present EuDt } //for variable 'd' - Looping between different Clusters for matching a Data Point. //add DataPoint to the cluster and calcSWCSS if (matchFoundFlag) { tempCluster.addDataPoint(dp); //k.notify(); // if(k.hasNext()) k.remove(); for (Cluster d : clusters) { d.getCentroid().calcCentroid(); } //for variable 'd' - Recalculating centroids for all Clusters calcSWCSS(); } //if statement - A Data Point is eligible for transfer between Clusters. // }// syn } //for variable 'k' - Looping through all Data Points of the current Cluster. }//for variable 'c' - Looping through all the Clusters. }//for variable 'i' - Number of iterations. // syn }

    Read the article

  • Sending out 20,000+ emails with asp.net

    - by Kyle
    I am writing an application that will need to send a massive amount of emails to our students who will be selected from our database (each email will be personalized to the extent that will include their name, course of study etc...so needs to be sent one at a time). I could do this looping over an SmtpClient, but I'm afraid that with the numbers I'm trying to send, I'll ultimately run into timeout issues or my thread being killed because of lack of machine resources. At this point I'm just looking for suggestions of a better way to handle this, or if looping over SmtpClient is an ok solution, how I should go about handling it to prevent what I posted above. Would a web service be a better alternative? Please advise, TIA

    Read the article

  • How to loop 3 dimension array using foreach PHP

    - by vzhen
    Below is foreach and the 3 dimension arrays, no problem with the looping but i cannot sepcify which array to echo, they must me the whole arrays like echo $subvalue, any better solutions with looping 3 dimension array? i actually feel weird with this looping. Thanks in adv foreach ($stories as $key => $story){ //echo "<br />"; foreach($story as $subkey => $subvalue){ echo $subvalue."<br />"; foreach($subvalue as $key => $subsubvalue){ echo $subsubvalue."<br />"; } } } Array ( [270] => Array ( [uid] => 36 [user_email] => [email protected] [sid] => 270 [story_name] => Story C [photo_url] => Array ( [0] => story_photos/2012/0322/361332381418153311.jpg [1] => story_photos/2012/0322/361332393792911587.jpg ) [photo_added_date] => Array ( [0] => 1332381418 [1] => 1332393792 ) ) [269] => Array ( [uid] => 36 [user_email] => [email protected] [sid] => 269 [story_name] => Story B [photo_url] => Array ( [0] => story_photos/2012/0322/361332381406580761.jpg ) [photo_added_date] => Array ( [0] => 1332381406 ) ) [268] => Array ( [uid] => 36 [user_email] => [email protected] [sid] => 268 [story_name] => Story A [photo_url] => Array ( [0] => story_photos/2012/0322/361332381393552719.jpg ) [photo_added_date] => Array ( [0] => 1332381393 ) ) )

    Read the article

  • Copying a database into a new database including structure and data

    - by Jason
    In phpMyAdmin under operations I can "Copy database to:" and select Structure and data CREATE DATABASE before copying Add AUTO_INCREMENT value I need to be able to do that without using phpMyAdmin. I know how to create the database and user. I have a source database that's a shell that I can work from so all I really need is the how to copy all the table structure and data part. (I know, the harder part) system() & exec() are not options for me which rules out mysqldump. (I think) How can I loop through each table and recreate it's structure and data? Is it just looping through the results of SHOW TABLES then for each table looping through DESCRIBE tablename Then, is there an easy way for getting the data copied?

    Read the article

  • animate each child jquery

    - by Martavis P.
    It's amazing how simple this should be but I can't get it to work. I'm looking to animate a set of divs one at a time. I am using animate.css for those familiar with it. I thought I may have found the answer here but jsFiddle is not working at the moment. Anywho, the code is $('.elements').each(function(i) { $(this).addClass('animated slideInLeft').delay(500); }); The problem is that when I debug and step through each element, the animation is happening for each element but when I let it run, it appears to all do it at once. What is needed to actually show the animation one at a time? Thanks EDIT: jsFiddle is back up and that link provided below did not help. The answer did not include looping through elements, but looping the animation itself. EDIT 2 Here is a Fiddle to play with if you guys need one.

    Read the article

  • Facebook - Filter Page posts by #hashtag [on hold]

    - by beppe9000
    I'm trying to gather all the posts (official posts and people's posts) on my page which contain a specified #tag, to later show them on website. But I've no clue on how to accomplish this. Is there any API capable of this or anything else that could help? I basically need to get all those posts IDs looping spidering trought them for my hashtag. I'm planning to do this server-side so PHP is my choice.

    Read the article

  • Problem animating in Unity/Orthello 2D. Can't move gameObject

    - by Nelson Gregório
    I have a enemy npc that moves left and right in a corridor. It's animated with 2 sprites using Orthello 2D Framework. If I untick the animation's play on start and looping, the npc moves correctly. If I turn it on, the npc tries to move but is pulled back to his starting position again and again because of the animation loop. If I turn looping off during runtime, the npc moves correctly again. What did I do wrong? Here's the npc code if needed. using UnityEngine; using System.Collections; public class Enemies : MonoBehaviour { private Vector2 movement; public float moveSpeed = 200; public bool started = true; public bool blockedRight = false; public bool blockedLeft = false; public GameObject BorderL; public GameObject BorderR; void Update () { if (gameObject.transform.position.x < BorderL.transform.position.x) { started = false; blockedRight = false; blockedLeft = true; } if (gameObject.transform.position.x > BorderR.transform.position.x) { started = false; blockedLeft = false; blockedRight = true; } if(started) { movement = new Vector2(1, 0f); movement *= Time.deltaTime*moveSpeed; gameObject.transform.Translate(movement.x,movement.y, 0f); } if(!blockedRight && !started && blockedLeft) { movement = new Vector2(1, 0f); movement *= Time.deltaTime*moveSpeed; gameObject.transform.Translate(movement.x,movement.y, 0f); } if(!blockedLeft && !started && blockedRight) { movement = new Vector2(-1, 0f); movement *= Time.deltaTime*moveSpeed; gameObject.transform.Translate(movement.x,movement.y, 0f); } } }

    Read the article

  • Why does ubuntu 11.10 freeze when playing video?

    - by psylockeer
    I run ubuntu 11.10 on i5 CPU with 4GB RAM nvdia geforce GTS 250 connected to widescreen tv (HDMI) When using vlc, xbmc or boxee to play movies the system randomly freeze, the audio is looping the last words of the video file and nothing is responding. So I have to manually reset the system. Can anybody help? P.S. I forgot to mention the the log file was full of line regarding xbox 360 wireless receiver (I dual boot with windwos 7) so I unplugged it to see if that counts

    Read the article

  • LAG function – practical use and comparison to old syntax

    - by Michael Zilberstein
    Recently I had to analyze huge trace – 46GB of trc files. Looping over files I loaded them into trace table using fn_trace_gettable function and filters I could use in order to filter out irrelevant data. I ended up with 6.5 million rows table, total of 7.4GB in size. It contained RowNum column which was defined as identity, primary key, clustered. One of the first things I detected was that although time difference between first and last events in the trace was 10 hours, total duration of all sql...(read more)

    Read the article

  • LAG function – practical use and comparison to old syntax

    - by Michael Zilberstein
    Recently I had to analyze huge trace – 46GB of trc files. Looping over files I loaded them into trace table using fn_trace_gettable function and filters I could use in order to filter out irrelevant data. I ended up with 6.5 million rows table, total of 7.4GB in size. It contained RowNum column which was defined as identity, primary key, clustered. One of the first things I detected was that although time difference between first and last events in the trace was 10 hours, total duration of all sql...(read more)

    Read the article

  • SQL Server For Each Row Next

    - by Derek Dieter
    It is difficult for me to write this particular article and I’ll tell you why. If you don’t care then just skip down to the example, but here goes anyway. It is very rare that you should have to perform looping in SQL. There are certain situations that do require it, and [...]

    Read the article

  • Making a more reliable and flexible sp_MSforeachdb

    While the system procedure sp_MSforeachdb is neither documented nor officially supported, most SQL Server professionals have used it at one time or another. This is typically for ad hoc maintenance tasks, but many people (myself included) have used this type of looping activity in permanent routines. Sadly, I have discovered instances where, under heavy load and/or with a large number of databases, the procedure can actually skip multiple catalogs with no error or warning message. Since this situation is not easily reproducible, and since Microsoft typically has no interest in fixing unsupported objects, this may be happening in your environment right now

    Read the article

  • Parsing Parameters in a Stored Procedure

    This article shows a clean non-looping method to parse comma separated values from a parameter passed to a stored procedure. NEW! Deployment Manager Early Access ReleaseDeploy SQL Server changes and .NET applications fast, frequently, and without fuss, using Deployment Manager, the new tool from Red Gate. Try the Early Access Release to get a 20% discount on Version 1. Download the Early Access Release.

    Read the article

  • Nginx and Wordpress side-by-side with static directory alias?

    - by user117161
    I'm a Nginx novice, but I have it set up with Wordpress Multisite (subdirectories) and php-fpm, and it's working great as is. This lets me set up Wordpress sites off the web root: domain.com/site1 - a Wordpress network single site, which renders as expected. domain.com/site2 - ditto etc. Concurrently, I can easily create static files in the web root that don't conflict or interact with Wordpress, and they are also rendered normally. domain.com/hello.html - rendered normally domain.com/hello.php - rendered normally, including php processing domain.com/static/hello.php - rendered normally (along as "static" isn't a WP single site name) What I'd like to do, and this is where I'm out of my depth with nginx.conf, is create a root directory domain.com/static and put static sites in there domain.com/static/site3 domain.com/static/site4 and have Nginx check the request that comes into the root request comes in for: domain.com/site3 and before handing off to Wordpress, check to see if it exists in the /static folder checks: domain.com/static/site3 - static content exists there and if so, serves that content while maintaining the root URI. serves: domain.com/site3 (with content from domain.com/static/site3) if not, it lets Wordpress check if /site3 is a Wordpress single network site as it does now, and the process continues normally. In nginx.conf, in the server section, I start with this try_files rule: location / { try_files $uri $uri/ /index.php?q=$uri&$args; } I then include a bunch of Wordpress specific rules as identified at http://codex.wordpress.org/Nginx under the subdirectory section. I can see that rewrite rules might take care of it easily, but in my experimentation I've only achieved a bunch of looping (/static/static/static, etc.) and managed to bypass Wordpress if the looping stopped. Sorry if this is a very long-winded way of asking a simple question, but I'm definitely learning some of this stuff for the first time. Thanks!

    Read the article

  • More efficient way to find media item in WMP media library?

    - by RoseOfJericho
    Hello, all. I am messing around with the WMPLib component provided by Windows Media Player 12 (wmp.dll) in VB.NET with .NET Framework 3.5 SP1. I am trying to retrieve a media item from my media library based on its name (assuming there are no duplicate names). At the moment, I'm grabbing the entire media library, and looping through every media item, and quitting the loop when I've found the correct media item. This works well (except for when a media item with that name cannot be found), but I was hoping there was a more efficient way of doing this. Here is my code so far: Public Class WMPTest Private myWMP As WMPLib.IWMPCore Private myMediaCollection As WMPLib.IWMPMediaCollection Private myTrack As WMPLib.IWMPMedia Private allTracks As WMPLib.IWMPPlaylist Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. myWMP = New WMPLib.WindowsMediaPlayer myMediaCollection = myWMP.mediaCollection allTracks = myMediaCollection.getAll Dim theTrack As WMPLib.IWMPMedia = findTrack("Yellow Submarine") MessageBox.Show(theTrack.name) End Sub Public Function findTrack(ByVal strTrackName As String) As WMPLib.IWMPMedia For i As Integer = 0 To (allTracks.count - 1) If allTracks.Item(i).name = strTrackName Then myTrack = allTracks.Item(i) Exit For End If Next 'myTrack is now the track that we wanted to retrieve Return myTrack End Function End Class So what I really want is a way to optimize findTrack() to do its thing without looping through the entire media library (which could be huge). Anyone have a clue?

    Read the article

  • C# Wholesale Order form - textboxes in Gridviews in Repeater

    - by tnriverfish
    I'm building a wholesale order form on a website. The current plan is to... -get an ArrayList of DepartmentUnits -a DepartmentUnit has various attributes like "deptId", "description" and its own ArrayList of StoreItems -The StoreItems have attached ArrayList of various SizeOptions -The SizeOptions have an inventory count integer along with their description -Planning on putting an asp:Repeater on the page that has an asp:GridView in it -Each DepartmentUnit will have its own GridView -EachStore item will have a row in the GridView -Each SizeOption will have a TextBox in the row (approximately 10 options) -Each inventory count will be watermarked over the size option textbox The question becomes how will I then collect all this information correctly once the form has been filled out? I don't like the idea of putting all this information in an update panel and then posting back each time a GridView row or worse one of the row's textboxes changes. Any advice on putting a single save button on the page and looping through each Repeater item - and each GridViewRow - and each textbox - to get all the values entered? Better to try collecting all the items added in a single table at the bottom of the page and updating the string with jquery each time a text box is modified? Then just looping through the new table when saved? Not sure I know how to loop through that table though - updating if quantity is changed might be a bear too. If it considerably simplifies the process I could just remove the Repeater aspect and put separate GridViews on separate pages. Thanks!

    Read the article

  • Django model operating on a queryset

    - by jmoz
    I'm new to Django and somewhat to Python as well. I'm trying to find the idiomatic way to loop over a queryset and set a variable on each model. Basically my model depends on a value from an api, and a model method must multiply one of it's attribs by this api value to get an up-to-date correct value. At the moment I am doing it in the view and it works, but I'm not sure it's the correct way to achieve what I want. I have to replicate this looping elsewhere. Is there a way I can encapsulate the looping logic into a queryset method so it can be used in multiple places? I have this atm (I am using django-rest-framework): class FooViewSet(viewsets.ModelViewSet): model = Foo serializer_class = FooSerializer bar = # some call to an api def get_queryset(self): # Dynamically set the bar variable on each instance! foos = Foo.objects.filter(baz__pk=1).order_by('date') for item in foos: item.needs_bar = self.bar return items I would think something like so would be better: def get_queryset(self): bar = # some call to an api # Dynamically set the bar variable on each instance! return Foo.objects.filter(baz__pk=1).order_by('date').set_bar(bar) I'm thinking the api hit should be in the controller and then injected to instances of the model, but I'm not sure how you do this. I've been looking around querysets and managers but still can't figure it out nor decided if it's the best method to achieve what I want. Can anyone suggest the correct way to model this with django? Thanks.

    Read the article

  • In .NET, What Is Fastest Way to Initialize Multi-Dimensional Array to Non-Default Value

    - by AMissico
    How do I initialize a multi-dimensional array of a primitive type as fast as possible? I am stuck with using multi-dimensional arrays. My problem is performance. The following routine initializes a 100x100 array in approx. 500 ticks. Removing the int.MaxValue initialization results in approx. 180 ticks just for the looping. Approximately 100 ticks to create the array without looping and without initializing to int.MaxValue. Routines similiar to this are called a few tens-of-thousands to several million times. I am open to suggestions on how to optimize this non-default initialization of an array. One idea I had is to use a smaller primitive type when available. For instance, using byte instead of int, saves 100 ticks. I would be happy with this, but I am hoping that I don't have to change the primitive data type. public int[,] CreateArray(Size size) { int[,] array = new int[size.Width, size.Height]; for (int x = 0; x < size.Width; x++) { for (int y = 0; y < size.Height; y++) { array[x, y] = int.MaxValue; } } return array; }

    Read the article

  • How to pair users? (Like Omegle.com)

    - by Carlos Dubus
    Hi, I'm trying to do an Omegle.com clone script, basically for learning purposes. I'm doing it in PHP/MySQL/AJAX. I'm having problems finding two users and connecting them. The purpose of omegle is connecting two users "randomly". What I'm doing right now is the following: When a user enters the website a session is assigned. There are 3 states for each session/user (Normal,Waiting,Chatting) At first the user has state Normal and a field "connected_to" = NULL If the users clicks the START button, a state of "Waiting" is assigned. Then it looks for another user with state Waiting, if doesn't find one then it keeps looping, waiting for the "connected_to" to change. The "connected_to" will change when other user click START and then find another user waiting and updates the sessions accordingly. Now this have several problems, like: A user only can be connected to one user at a time. In omegle you can open more than one chat simultaneously. I don't know if this is the best way. About the chat, each user is polling the events from the server with AJAX calls, I saw that omegle, instead of several HTTP requests each second (let's say), does ONE request and wait for an answer, that means that the PHP script is looping indefinitely until gets an answer.I did this using set_time_limit(30) each time the loop is started. Then when the Ajax call is done start over again. Is this approach correct? I will appreciate a LOT your answers, Thank you, Carlos

    Read the article

  • jQuery animation loop not working

    - by Marko Ivanovski
    Hi, I'm trying to create a looping animation that starts on onmousedown and stops on onmouseout. The effect is a simple scroll that will continue looping until you release the mouse. I've created a function which performs the .animate method and it passes itself as a callback but the code only runs once. Here's the entire code: $(document).ready(function() { var $scroller = $("#scroller"); var $content = $("#content", $scroller); // lineHeight equal to 1 line of text var lineHeight = $content.css('line-height'); //Amount to scroll = 3 lines of text a time var amountToScroll = lineHeight.replace("px","")*3; var maxScroll = $content.height() - $scroller.height(); function scrollDown() { var topCoord = $content.css("top").replace("px",""); if(topCoord > -maxScroll) { if((-maxScroll-topCoord) > -amountToScroll) { $content.stop().animate({ top: -maxScroll }, 1000 ); } else { $content.stop().animate({ top: "-=" + amountToScroll }, 1000, function(){ scrollDown() } ); } } } function scrollUp() { var topCoord = $content.css("top").replace("px",""); if(topCoord < 0) { if(topCoord > -amountToScroll) { $content.stop().animate({ top: 0 }, 1000 ); } else { $content.stop().animate({ top: "+=" + amountToScroll }, 1000, function(){scrollUp()} ); } } } $("#scroll-down").mousedown(function() { scrollDown(); }); $("#scroll-down").mouseup(function() { $content.stop(); }); $("#scroll-up").mousedown(function() { scrollUp(); }); $("scroll-up").mouseup(function() { $content.stop(); }); });

    Read the article

  • one key multiple values from different sources c#

    - by user2964034
    I am trying to make a c# program that will compare two files for me, and tell me the differences of specific parts. I have been able to get the parts I need into variables while looping through, but I now want to add these to a key with 3 values per file, so a key with 6 values overall which I will then compare to eachother later on. But I can only add 3 values at a time using the loop I have, so I need to be able to add the last 3 values to the key without overwriting the first 3. example of data from file: [\Advanced\Rules\Correlation Rules\Suspect_portscan\]; CheckDescription =S Detect Port scans; Enabled =B 0; Priority =L 3; I have managed to get what I need into variables so I have: string SigName would be "Suspect_portscan" Int Enabled, Priority, Blocking as 0 3 and null respectivly. I then want to make a dictionary type thing, with a key which would be the SigName and the first 3 values as enabled, priority, blocking. Then when looping through the second file, I want to add the 2nd files settings for the enabled, priority, blocking for the same SigName (so to the key) in the last 3 value slots. I will then compare this against itself, like 'if signame(0) != signame(3)' so if file 1 enabled is not the same as file two enabled make a note and tell me. But the problem I have is not being able to get the data into a dictionary or lookup, I'm completely stumped. It seems like I should use a dictionary with a list for the values but I cant get it working on the second loop through. Thanks.

    Read the article

  • jquery how to access the an xml node by index?

    - by DS
    Hi, say I've an xml returned from server like this: <persons> <person> <firstname>Jon</firstname> </person> <person> <firstname>Jack</firstname> </person> <person> <firstname>James</firstname> </person> </persons> If I want to access the 3rd firstname node (passed dynamically and stored in i, assumed to be 3 here), how do I do that? My weird attempt follows: var i=3; $(xml).find('firstname').each(function(idx){ if (idx==i) alert($(this).text()); }); It does fetch me the right content... but it just feels wrong to me especially the looping part. Basically I'm looping through the whole tree using .each()! Is there any better approach than this? Something that'd take me to the nth node directly like: alert( $(xml).find('firstname')[idx].text() ); // where idx=n I'm new to jquery so please excuse my jquery coding approach.

    Read the article

  • PHP: Check if 0?

    - by tarnfeld
    Hi, I am using a class which returns me the value of a particular row and cell of an excel spreadsheet. To build up an array of one column I am counting the rows and then looping through that number with a for() loop and then using the $array[] = $value to set the incrementing array object's value. This works great if none of the values in a cell are 0. The class returns me a number 0 so it's nothing to do with the class, I think it's the way I am looping through the rows and then assigning them to the array... I want to carry through the 0 value because I am creating graphs with the data afterwards, here is the code I have. // Get Rainfall $rainfall = array(); for($i=1;$i<=$count;$i++) { if($data->val($i,2) != 'Rainfall') // Check if not the column title { $rainfall[] = $data->val($i,2); } } For your info $data is the excel spreadsheet object and the method $data->val(row,col) is what returns me the value. In this case I am getting data from column 2. Screenshot of spreadsheet http://cl.ly/1Dmy Thanks! All help is very much appreciated!

    Read the article

  • How does ospf control flooding?

    - by iamrohitbanga
    What method is used by ospf protocol to prevent looping of flooded packets for link state advertisements? The packet header does not contain any timestamp. How do the routers recognize that it is the same advertisement that they sent before?

    Read the article

  • how does ospf control flooding?

    - by iamrohitbanga
    what method is used by ospf protocol to prevent looping of flooded packets for link state advertisements? The packet header does not contain any timestamp. How do the routers recognize that it is the same advertisement that they sent before?

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >