Search Results

Search found 8557 results on 343 pages for 'infinite loop'.

Page 25/343 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • Bash loop command until file contains n duplicate entries (lines)

    - by Andrew
    Hello, I'm writing a script and I need to create a loop that will execute same commands until file does contain a specified number of duplicate entries. For example, with each loop I will echo random string to file results. And I want loop to stop when there are 10 lines of of the same string. I thought of something like while [ `some command here (maybe using uniq)` -lt 10 ] do command1 command2 command3 done Do you have any idea how can this problem be solved? Using grep can't be done since I don't know what string I need to look for. Thank you for your suggestions.

    Read the article

  • Erlang message loops

    - by Roger Alsing
    How does message loops in erlang work, are they sync when it comes to processing messages? As far as I understand, the loop will start by "receive"ing a message and then perform something and hit another iteration of the loop. So that has to be sync? right? If multiple clients send messages to the same message loop, then all those messages are queued and performed one after another, or? To process multiple messages in parallell, you would have to spawn multiple message loops in different processes, right? Or did I misunderstand all of it?

    Read the article

  • border highlighting loop with jquery

    - by Tek
    I'm having trouble coming up with a loop that changes the border color of an image from black to yellow and yellow to black over x seconds. Then applying an interrupt to the loop when the image gets clicked on. I don't know where to start, can someone point me in the right direction? I think I may be using the wrong tools to properly write this. Here's what I've come up so far, though if there's a better way to write this, do share! for( i = 100; i >= 0; i--) { $("#imgid").css("border-color", 'rgb(' + i + '%,' + i + '%,0)'); } I'm having trouble picturing how I could combine two loops so that I can also count upwards as well so that it will turn into yellow and back to black. I also don't know how to go about controlling the amount of time it takes for that loop to execute and creating an interrupt when #imigid is clicked. Which is where I'm not sure how to write.

    Read the article

  • a nicer way to create structs in a loop

    - by sandra
    Hi guys, I haven't coded in C++ in ages. And recently, I'm trying to work on something involving structs. Like this typedef struct{ int x; int y; } Point; Then in a loop, I'm trying to create new structs and put pointers to them them in a list. Point* p; int i, j; while (condition){ // compute values for i and j with some function... p = new Point; p* = {i, j}; //initialize my struct. list.append(p); //append this pointer to my list. } Now, my question is it possible to simplify this? I mean, the pointer variable *p outside of the loop and calling p = new Point inside the loop. Isn't there a better/nicer syntax for this?

    Read the article

  • Write the longest possible loop.

    - by Abhay
    Hello Group, Recently I was asked this question in a technical discussion. What is the longest possible loop that can be written in a programming language? This loop has to be as long as possible and yet not an infinite loop and should not end-up crashing the program (Recursion etc...) I honestly did not know how to attack this problem, so I asked him if is it practically possible. He said using some computer science concepts, you can arrive at a hypothetical number which may not be practical but nevertheless it will still not be infinite. Anyone here; knows how to analyse / attack this problem. P.S. Choosing some highest limit for a type that can store the highest numerical value is apparently not an answer. Thanks in advance,

    Read the article

  • Breaking from for loop in MATLAB GUI

    - by Nick
    I have a for loop in the opening function of a GUI in MATLAB and I'm trying to use a callback button to break the loop. I'm new to MATLAB. Here's the code I have: %In the opening function of the GUI handles.stop_now = 0; for i=1:inf if handles.stop_now==1 break; end end % Executes on button press function pushbutton_Callback(hObject, eventdata, handles) % hObject handle to end_segmenting_button (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) handles.stop_now=1; guidata(hObject, handles); For some reason, despite defining the variables with handles, the loop doesn't break upon pressing the button. Anyone know what's going on? Thanks.

    Read the article

  • PHP Casting as Object type in foreach Loop

    - by Coulton
    Within the following code, $quiz_object->personalities contains an array of Personality() objects. // Loop through each personality that exists for the quiz foreach($quiz_object->personalities AS $existing_personality) { // Show all of the existing personalities echo $existing_personality->GetQuizMakerPersonalityHTML(); } How do I "cast" (I think that's the right word) my variable $existing_personality within the foreach loop as the object type? I wish to do this so that when I type $existing_personality->, I get the list of public functions available for that object type. At the moment, Zend doesn't know that it refers to a Personality object within the loop.

    Read the article

  • String loops in Python

    - by Steve Hunter
    I have two pools of strings and I would like to do a loop over both. For example, if I want to put two labeled apples in one plate I'll write: basket1 = ['apple#1', 'apple#2', 'apple#3', 'apple#4'] for fruit1 in basket1: basket2 = ['apple#1', 'apple#2', 'apple#3', 'apple#4'] for fruit2 in basket2: if fruit1 == fruit2: print 'Oops!' else: print "New Plate = %s and %s" % (fruit1, fruit2) However, I don't want order to matter -- for example I am considering apple#1-apple#2 equivalent to apple#2-apple#1. What's the easiest way to code this? I'm thinking about making a counter in the second loop to track the second basket and not starting from the point-zero in the second loop every time.

    Read the article

  • How to improve the speed of a loop containing a sqlalchemy query statement as conditional

    - by LtPinback
    This loop checks if a record is in the sqlite database and builds a list of dictionaries for those records that are missing and then executes a multiple insert statement with the list. This works but it is very slow (at least i think it is slow) as it takes 5 minutes to loop over 3500 queries. I am a complete newbie in python, sqlite and sqlalchemy so I wonder if there is a faster way of doing this. list_dict = [] session = Session() for data in data_list: if session.query(Class_object).filter(Class_object.column_name_01 == data[2]).filter(Class_object.column_name_00 == an_id).count() == 0: list_dict.append({'column_name_00':a_id, 'column_name_01':data[2]}) conn = engine.connect() conn.execute(prices.insert(),list_dict) conn.close() session.close() edit: I moved session = Session() outside the loop. Did not make a difference.

    Read the article

  • C++: Allocation of variables in a loop

    - by Rosarch
    Let's say I have a loop like this: vector<shared_ptr<someStruct>> vec; int i = 0; while (condition) { i++ shared_ptr<someStruct> sps(new someStruct()); WCHAR wchr[20]; memset(wchr, i, 20); sps->pwsz = wchr; vec.push_back(sps); } At the end of this loop, I see that for each sps element of the vector, sps->pwsz is the same. Is this because I'm passing a pointer to memory allocated in a loop, which is destructed after each iteration, and then refilling that same memory on the next iteration?

    Read the article

  • Can't subtract in a for loop in C/Objective-C

    - by user1612935
    I'm going through the Big Nerd Ranch book on Objective-C, which takes you through some early C stuff. I've played with C before, and am pretty experienced in PHP. Anyhow, I'm doing the challenges and this one is not working the way I think it should. It's pretty simple - start at 99, loop through and subtract three until you get to zero, and every time you get a number that is divisible by 5 print "Found one." Pretty straightforward. However, subtracting by three in the for loop is not working #include <stdio.h> int main (int argc, const char * argv[]) { int i; for(i = 99; i > 0; i-3){ printf("%d\n", i); if(i % 5 == 0) { printf("Found one!\n"); } } return 0; } It creates and endless loop at 99, and I'm not sure why.

    Read the article

  • Windows server reboot loop - uninstalling hotfixes

    - by Jack
    After installing 3 updates, my system is stuck in a reboot loop. I am using server 2008 r2. I have tried deleting pending.xml from the windows directory, so pelase don't suggest that. I tried dism /image:d:\ /cleanup-image /revertpendingactions which completed successfully but did not solve my issue I then tried: dism /image:d:\ /Remove-Package /PackageName: and sucusfully removed one of the 3 updates. The two updates that are left are not listed with the dism get-packages command, but are listed with the get-apppatches command. I cannot find a way to uninstall them with dism however. So my question is, how can I manually uninstall specific updates or hotfixes from within the winre environment?

    Read the article

  • Windows 7 installation reboot loop

    - by Auswoolf
    Upgrading from Vista home premium to win 7 hoe premium from DVD ex Digital river on gigabyte VM900m; core 2 duo 2.13GHz 2GB ram; Western digital 250GB HD. Got as far as "Expanding Windows files ...100% the error message "Computer encountered unexpected error... To install windows press OK to restart computer and reinstall windows" The computer then reboots, loads Windows 7 (new logo) a essage that says "setup is starting services" then the error message comes back. I can get into BIOS to change boot priority but the computer just ignores this and goes through the same sequence. At the point of "to boot from CD/DVD press any key" my keyboard is deactivated and i cannot make a choice and the sae sequence occurs. I cannot break the sequence - I have push every key, disconnected every external device including HDMI screen, but nothing stops the loop. Any ideas? Auswoolf

    Read the article

  • How to ensure full path in Windows batch FOR loop

    - by palswim
    I've created a generic batch (or Windows Command) file that lets me loop through the contents of a directory and call a command for each item. IF a%1==a ( set _DIR="%CD%") ELSE ( set _DIR="%~1") IF a%2==a ( set _COMMAND=rem) ELSE ( set _COMMAND=%2) IF a%3==a ( set _FILTER=*.*) ELSE ( set _FILTER=%3) set _OPTS=%4 FOR /F "delims=" %%f IN ('dir %_DIR%\%_FILTER% %_OPTS% /b') DO ( %_COMMAND% "%%f" ) But, I'm trying to determine how to ensure that I call %_COMMAND% on the correct file. I've tried pre-pending the directory variable onto the front, like %_COMMAND% %_DIR%\"%%f", but this leaves a quotation mark in the parameter I pass. For example, if I call my batch file exec_dir.bat, and call it with the following echo_test.bat, I see that all of the files have a quotation mark when echo_test.bat runs. echo %~dpn1.mp4 That batch script produces: > exec_dir.bat "C:\Users\User\Desktop\Test Folder" echo_test.bat *.txt C:\Users\User\Desktop\Test Folder\"Test File.txt C:\Users\User\Desktop\Test Folder\"Test2.txt My thought is that it has something to do with the \ as an escape character, but I can't seem to work around it.

    Read the article

  • Mail Enabled Sharepoint 2010 Loop Detected

    - by vlannoob
    I have setup a small Sharepoint 2010 deployment and it is working fine, for now. I have run through one of the more popular step by step guides to mail enable the install and what I have is internal and external mail going to my mail enabled list hitting my Exchange 2010 server (on another Win2k8R2 box) and sitting in the submissions queue with a Loop Detected error and they progres no further. Everything appears OK as per the guide. I have setup an SMTP role on the Sharepoint box, as per the guide. I have setup a new Send Conenctor on the Exchange 2010 server, as per the guide. Any ideas on troubleshooting here?

    Read the article

  • "mv: cannot stat file" in for loop

    - by F.C.
    I wanted to rename a lot of files with a pattern so I tried this for loop: $ for f in *; do mv \""$f"\" \""HouseMD-S06E${f#*Episode }"\"; done But I got this error: mv: cannot stat `"House MD Season 6 Episode 01 - Broken (Parts 1 & 2).avi"': No such file or directory So what I did was echo the mv commands to a file like this: $ for f in *; do echo mv \""$f"\" \""HouseMD-S06E${f#*Episode }"\">>mv.txt; done And the run the file with source. Any ideas why the first for didn't work and how can I fix it?

    Read the article

  • Reboot loop after Windows XP Service Pack 3 update

    - by espais
    Recently I upgraded to Service Pack 3, and now it seems that something has gone terribly wrong with the update. After logging in, my computer will blue screen after about 5 minutes and then go into a reboot loop (I don't have the exact error message handy). I have a Sager NP2092 notebook, running an Intel chipset. I'd rather avoid having to reformat my XP, especially with my copy of Windows 7 arriving right around the corner. After doing some Googling, I came across this article: Does your AMD-based computer boot after installing XP SP3? However, it deals with the AMD chips, and specifically states not to use its fix on Intel based systems. EDIT After killing the reboot, this is the error that pops up: STOP: 0x000000F4 (0x00000003, 0x8A187118, 0x8A18728C, 0x80604438) EDIT2 I have run Memtest86, and it reported 0 errors.

    Read the article

  • running more than one command line commands inside for loop

    - by klijo
    i have a folder containing images and i want to determine its Compression method used. So i would loop through the folder and do a grep Compression like this and note i have installed grep for windows for %f in (*.jpg) do identify -verbose "%f" | grep Compression >> info.txt However i need to write the file name and compression technique used so i modified the above command for %f in (*.jpg) do identify -verbose "%f" | grep Compression & echo "%f" & echo: >> info.txt But the problem is that i get a blank txt file. Could someone pleas help me.

    Read the article

  • Boot Loop contiues [closed]

    - by user1894750
    I am facing boot loop. My backend Linux works flawlessly, But the Zygote and System server does not workout. I can still use ADB and LIVE cat .. ps show that both Zygote and system_server process are there, But boot animation remains forever !! I have : 1 Wiped Data + Cache Partition 2 System Partition has been RESTORED.. There is NO PERMISSION problem... I think that there is *problem with Zygote and System_server ..* my device: Karbonn A9+ Dual Core Snap Dragon 1.2 Ghz Ram 386MB OS : ICS 4.04 Any suggestions ??

    Read the article

  • Protect foreach loop when empty list

    - by SteB
    Using Powershell v2.0 I want to delete any files older than X days: $backups = Get-ChildItem -Path $Backuppath | Where-Object {($_.lastwritetime -lt (Get-Date).addDays(-$DaysKeep)) -and (-not $_.PSIsContainer) -and ($_.Name -like "backup*")} foreach ($file in $backups) { Remove-Item $file.FullName; } However, when $backups is empty I get: Remove-Item : Cannot bind argument to parameter 'Path' because it is null. I've tried: Protecting the foreach with if (!$backups) Protecting the Remove-Item with if (Test-Path $file -PathType Leaf) Protecting the Remove-Item with if ([IO.File]::Exists($file.FullName) -ne $true) None of these seem to work, what if the recommended way of preventing a foreach loop from being entered if the list is empty?

    Read the article

  • Windows 7 reboot loop on startup

    - by blade5
    Hi, I am running Windows Server 2008 Datacenter X64 on my server at home. It's using Hyper-V so I have several VMs. All apart from one are Windows Server 2008-based. The other is Windows 7 Ultimate x64 and it was rebooting in a loop when at the login screen. Afterwards, I installed Windows Updates on this VM and now, because after the login, Windows comes up with the text "now configurating, do not restart your PC" before the login screen, I cannot get past this screen because the VM is constantly rebooting so this configuring step does not get completed. So I cannot login. Will an upgrade reinstall of Windows 7 fix this? It seems that the problem is with the system on the VM (system files/updates etc, as opposed to the apps I have installed). Thanks

    Read the article

  • How can I reset addAttributeToFilter in Magento searches

    - by Bobby
    I'm having problems getting the addAttributeToFilter function within a loop to behave in Magento. I have test data in my store to support searches for all of the following data; $attributeSelections=array( array('size' => 44, 'color' => 67, 'manufacturer' => 17), array('size' => 43, 'color' => 69, 'manufacturer' => 17), array('size' => 42, 'color' => 70, 'manufacturer' => 17)); And my code to search through these combinations; foreach ($attributeSelections as $selection) { $searcher = Mage::getSingleton('catalogsearch/advanced')->getProductCollection(); foreach ($selection as $k => $v) { $searcher->addAttributeToFilter("$k", array('eq' => "$v")); echo "$k: $v<br />"; } $result=$searcher->getData(); print_r($result); } This loop gives the following results (slightly sanitised for veiwing pleasure); size: 44 color: 67 manufacturer: 17 Array ( [0] => Array ( [entity_id] => 2965 [entity_type_id] => 4 [attribute_set_id] => 28 [type_id] => simple [sku] => 1006-0001 [size] => 44 [color] => 67 [manufacturer] => 17 ) ) size: 43 color: 69 manufacturer: 17 Array ( [0] => Array ( [entity_id] => 2965 [entity_type_id] => 4 [attribute_set_id] => 28 [type_id] => simple [sku] => 1006-0001 [size] => 44 [color] => 67 [manufacturer] => 17 ) ) size: 42 color: 70 manufacturer: 17 Array ( [0] => Array ( [entity_id] => 2965 [entity_type_id] => 4 [attribute_set_id] => 28 [type_id] => simple [sku] => 1006-0001 [size] => 44 [color] => 67 [manufacturer] => 17 ) ) So my loop is function and generating the search. However, the values fed into addAttributeToFilter on the first itteration of the loop seem to remain stored for each search. I've tried clearing my search object, for example, unset($searcher) and unset($result). I've also tried magento functions such as getNewEmptyItem(), resetData(), distinct() and clear() but none have the desired effect. Basically what I am trying to do is check for duplicate products before my script attempts to programatically create a product with these attribute combinations. The array of attribute selections may be of varying sizes hence the need for a loop. I would be very appreiciative if anyone might be able to shed some light on my problem.

    Read the article

  • STL find performs bettern than hand-crafter loop

    - by dusha
    Hello all, I have some question. Given the following C++ code fragment: #include <boost/progress.hpp> #include <vector> #include <algorithm> #include <numeric> #include <iostream> struct incrementor { incrementor() : curr_() {} unsigned int operator()() { return curr_++; } private: unsigned int curr_; }; template<class Vec> char const* value_found(Vec const& v, typename Vec::const_iterator i) { return i==v.end() ? "no" : "yes"; } template<class Vec> typename Vec::const_iterator find1(Vec const& v, typename Vec::value_type val) { return find(v.begin(), v.end(), val); } template<class Vec> typename Vec::const_iterator find2(Vec const& v, typename Vec::value_type val) { for(typename Vec::const_iterator i=v.begin(), end=v.end(); i<end; ++i) if(*i==val) return i; return v.end(); } int main() { using namespace std; typedef vector<unsigned int>::const_iterator iter; vector<unsigned int> vec; vec.reserve(10000000); boost::progress_timer pt; generate_n(back_inserter(vec), vec.capacity(), incrementor()); //added this line, to avoid any doubts, that compiler is able to // guess the data is sorted random_shuffle(vec.begin(), vec.end()); cout << "value generation required: " << pt.elapsed() << endl; double d; pt.restart(); iter found=find1(vec, vec.capacity()); d=pt.elapsed(); cout << "first search required: " << d << endl; cout << "first search found value: " << value_found(vec, found)<< endl; pt.restart(); found=find2(vec, vec.capacity()); d=pt.elapsed(); cout << "second search required: " << d << endl; cout << "second search found value: " << value_found(vec, found)<< endl; return 0; } On my machine (Intel i7, Windows Vista) STL find (call via find1) runs about 10 times faster than the hand-crafted loop (call via find2). I first thought that Visual C++ performs some kind of vectorization (may be I am mistaken here), but as far as I can see assembly does not look the way it uses vectorization. Why is STL loop faster? Hand-crafted loop is identical to the loop from the STL-find body. I was asked to post program's output. Without shuffle: value generation required: 0.078 first search required: 0.008 first search found value: no second search required: 0.098 second search found value: no With shuffle (caching effects): value generation required: 1.454 first search required: 0.009 first search found value: no second search required: 0.044 second search found value: no Many thanks, dusha. P.S. I return the iterator and write out the result (found or not), because I would like to prevent compiler optimization, that it thinks the loop is not required at all. The searched value is obviously not in the vector.

    Read the article

  • Loop an UIScrollView

    - by Ilya
    Hi, I've got an UIScrollView and in it different images(about 30). I'd like to make it possible, when user reaches the last image to show the first one after it and so on. And I want to implement the same feature with the first image(to go to the last one). I'd like to loop the images smoothly that user won't even notice that he is making another loop. What is the best way to achieve this? Thanks.

    Read the article

  • Loop OpenAL source with offset

    - by ressaw
    The OpenAL API states that an setting an offset still causes the sound to loop back to zero for looping sources. But is there a way to loop and still have an offset somehow? I have an mp3, and since it contains headers with information at the start of the file, there's a small, but noticable, delay in looping when it rewinds. If not, are there any other compressed formats that don't contain these empty headers?

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >