Search Results

Search found 12044 results on 482 pages for 'foreach loop'.

Page 21/482 | < Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >

  • can't install anything anymore with apt-get

    - by Aymane Shuichi
    Welcome this is the log I have when trying to install anything (php5-fpm after removing it) apt-get install php5-fpm Reading package lists... Done Building dependency tree Reading state information... Done php5-fpm is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue [Y/n]? y Setting up php5-fpm (5.4.4-14+deb7u10) ... insserv: warning: script 'S55IptabLes' missing LSB tags and overrides insserv: warning: script 'S55IptabLex' missing LSB tags and overrides insserv: There is a loop between service IptabLes and mountnfs if started insserv: loop involving service mountnfs at depth 8 insserv: loop involving service networking at depth 7 insserv: loop involving service mountnfs-bootclean at depth 10 insserv: There is a loop between service rc.local and mountall if started insserv: loop involving service mountall at depth 6 insserv: loop involving service checkfs at depth 5 insserv: loop involving service kbd at depth 11 insserv: There is a loop between service rc.local and mountall-bootclean if started insserv: loop involving service mountall-bootclean at depth 7 insserv: loop involving service urandom at depth 9 insserv: There is a loop between service IptabLes and mountdevsubfs if started insserv: loop involving service mountdevsubfs at depth 2 insserv: loop involving service udev at depth 1 insserv: There is a loop at service rc.local if started insserv: There is a loop at service IptabLes if started insserv: Starting IptabLes depends on rc.local and therefore on system facility `$all' which can not be true! (x99 times repeated ) insserv: Max recursions depth 99 reached insserv: loop involving service postfix at depth 2 insserv: There is a loop between service IptabLes and udev if started insserv: loop involving service mountkernfs at depth 1 insserv: loop involving service IptabLes at depth 1 Now here is the error i get insserv: exiting now without changing boot order! update-rc.d: error: insserv rejected the script header dpkg: error processing php5-fpm (--configure): subprocess installed post-installation script returned error exit status 1 Errors were encountered while processing: php5-fpm E: Sub-process /usr/bin/dpkg returned an error code (1) The biggest operation I held before this was updating nginx from 1.2 to 1.6 and it was thanks to this site : here is the link : How to upgrade nginx from 1.2 to 1.6 on debian 7 Please help !

    Read the article

  • single for-loop runtime explanation problem

    - by owwyess
    I am analyzing some running times of different for-loops, and as I'm getting more knowledge, I'm curious to understand this problem which I have still yet to find out. I have this exercise called "How many stars are printed": for (int i = N; i > 1; i = i/2) System.out.println("*"); The answers to pick from is A: ~log N B: ~N C: ~N log N D: ~0.5N^2 So the answer should be A and I agree to that, but on the other side.. Let's say N = 500 what would Log N then be? It would be 2.7. So what if we say that N=500 on our exercise above? That would most definitely print more han 2.7 stars? How is that related? Because it makes sense to say that if the for-loop looked like this: for (int i = 0; i < N; i++) it would print N stars. I hope to find an explanation for this here, maybe I'm interpreting all these things wrong and thinking about it in a bad way. Thanks in advance.

    Read the article

  • While loop error?

    - by user134134
    I believe the problem with my code lies within my while loop. Admittedly, I'm rather new to Javascript programming. Does this look okay: <! DOCTYPE html> <head><title>title</title></head> <body> <script type="text/javascript"> alert("Hello, stranger. Please note that at this current moment, we do not have a save function. It might be a good idea to record your answers."); var preAnswer = 0; while (var preAnswer = 0) { var name = prompt("What is your name? Please capitalise it, for the sake of grammar.") if (name === "") { alert("What are you playing at? You didn't type anything."); var preAnswer = 0; } else { var preAnswer = 1 } } alert("Nice name, " + name + ", bro.") </script> </body> </html> I'm sure I've done something wrong, as it isn't functioning.

    Read the article

  • How to loop section from a song correctly?

    - by Teflo
    I'm programming a little Music Engine for my game in C# and XNA, and one aspect from it is the possibility to loop a section from a song. For example, my song has an intropart, and when the song reached the end ( or any other specific point ), it jumps back where the intropart is just over. ( A - B - B - B ... ) Now I'm using IrrKlank, which is working perfectly, without any gaps, but I have a problem: The point where to jump back is a bit inaccurate. Here's some example code: public bool Passed(float time) { if ( PlayPosition >= time ) return true; return false; } //somewhere else if( song.Passed( 10.0f ) ) song.JumpTo( 5.0f ); Now the problem is, the song passes the 10 seconds, but play a few milliseconds until 10.1f or so, and then jumps to 5 seconds. It's not that dramatic, but very incorrect for my needs. I tried to fix it like that: public bool Passed( float time ) { if( PlayPosition + 3 * dt >= time && PlayPosition <= time ) return true; return false; } ( dt is the delta time, the elapsed time since the last frame ) But I don't think, that's a good solution for that. I hope, you can understand my problem ( and my english, yay /o/ ) and help me :)

    Read the article

  • Moving while doing loop animation in RPGMaker

    - by AzDesign
    I made a custom class to display character portrait in RPGMaker XP Here is the class : class Poser attr_accessor :images def initialize @images = Sprite.new @images.bitmap = RPG::Cache.picture('Character.png') #100x300 @images.x = 540 #place it on the bottom right corner of the screen @images.y = 180 end end Create an event on the map to create an instance as global variable, tada! image popped out. Ok nice. But Im not satisfied, Now I want it to have bobbing-head animation-like (just like when we breathe, sometimes bob our head up and down) so I added another method : def move(x,y) @images.x += x @images.y += y end def animate(x,y,step,delay) forward = true 2.times { step.times { wait(delay) if forward move(x/step,y/step) else move(-x/step,-y/step) end } wait(delay*3) forward = false } end def wait(time) while time > 0 time -= 1 Graphics.update end end I called the method to run the animation and it works, so far so good, but the problem is, WHILE the portrait goes up and down, I cannot move my character until the animation is finished. So that's it, I'm stuck in the loop block, what I want is to watch the portrait moving up and down while I walk around village, talk to npc, etc. Anyone can solve my problem ? Or better solution ? Thanks in advance

    Read the article

  • A Star Path finding endless loop

    - by PoeHaH
    I have implemented A* algorithm. Sometimes it works, sometimes it doesn't, and it goes through an endless loop. After days of debugging and googling, I hope you can come to the rescue. This is my code: The algorythm: public ArrayList<Coordinate> findClosestPathTo(Coordinate start, Coordinate goal) { ArrayList<Coordinate> closed = new ArrayList<Coordinate>(); ArrayList<Coordinate> open = new ArrayList<Coordinate>(); ArrayList<Coordinate> travelpath = new ArrayList<Coordinate>(); open.add(start); while(open.size()>0) { Coordinate current = searchCoordinateWithLowestF(open); if(current.equals(goal)) { return travelpath; } travelpath.add(current); open.remove(current); closed.add(current); ArrayList<Coordinate> neighbors = current.calculateCoordAdjacencies(true, rowbound, colbound); for(Coordinate n:neighbors) { if(closed.contains(n) || map.isWalkeable(n)) { continue; } int gScore = current.getGvalue() + 1; boolean gScoreIsBest = false; if(!open.contains(n)) { gScoreIsBest = true; n.setHvalue(manhattanHeuristic(n,goal)); open.add(n); } else { if(gScore<n.getGvalue()) { gScoreIsBest = true; } } if(gScoreIsBest) { n.setGvalue(gScore); n.setFvalue(n.getGvalue()+n.getHvalue()); } } } return null; } What I have found out is that it always fails whenever there's an obstacle in the path. If I'm running it on 'open terrain', it seems to work. It seems to be affected by this part: || map.isWalkeable(n) Though, the isWalkeable function seems to work fine. If additional code is needed, I will provide it. Your help is greatly appreciated, Thanks :)

    Read the article

  • Pipe an infinite stream to internal loop?

    - by Sh3ljohn
    I've seen a lot of things about redirecting stdout to a TCP socket, but no real example of how to do it in practice, specifically when the output stream generated by the first "command" never ends. To talk about something concrete, let's take programs like servers that typically output their log endlessly to stdout (well, as long as they run). If you redirect the output to a log file on the disk, then this file is always open (therefore not readable by others?) and grows infinitely, which eventually is going to cause problems. This might be a nood question, but I don't know what it does or how to do it so. How to redirect the output of a command to the internal loop? I want to make sure that data is sent EVERY time something is written to stdout, and that the pipe won't wait for the command to end (never happens ideally!). Is that right? If 2 is true, is there a buffer system to send chunks of data once it reaches a certain size only? Could you give me concrete command line examples to do the above? Thanks in advance

    Read the article

  • Razor - Unexpected "foreach" keyword after "@" character

    - by Jaco Pretorius
    I have a partial view done in razor. When I run it I get the following error - it seems like Razor gets stuck into thinking I'm writing code everywhere. Unexpected "foreach" keyword after "@" character. Once inside code, you do not need to prefix constructs like "foreach" with "@" Here is my view @model IEnumerable<SomeModel> <div> @using(Html.BeginForm("Update", "UserManagement", FormMethod.Post)) { @Html.Hidden("UserId", ViewBag.UserId) @foreach(var link in Model) { if(link.Linked) { <input type="checkbox" name="userLinks" value="@link.Id" checked="checked" />@link.Description<br /> } else { <input type="checkbox" name="userLinks" value="@link.Id" />@link.Description<br /> } } } </div>

    Read the article

  • How do I delete multiple rows in Entity Framework (without foreach)

    - by Jon Galloway
    I'm deleting several items from a table using Entity Framework. There isn't a foreign key / parent object so I can't handle this with OnDeleteCascade. Right now I'm doing this: var widgets = context.Widgets .Where(w => w.WidgetId == widgetId); foreach (Widget widget in widgets) { context.Widgets.DeleteObject(widget); } context.SaveChanges(); It works but the foreach bugs me. I'm using EF4 but I don't want to execute SQL. I just want to make sure I'm not missing anything - this is as good as it gets, right? I can abstract it with an extension method or helper, but somewhere we're still going to be doing a foreach, right?

    Read the article

  • Does Parallel.ForEach require AsParallel()

    - by dkackman
    ParallelEnumerable has a static member AsParallel. If I have an IEnumerable<T> and want to use Parallel.ForEach does that imply that I should always be using AsParallel? e.g. Are both of these correct (everything else being equal)? without AsParallel: List<string> list = new List<string>(); Parallel.ForEach<string>(GetFileList().Where(file => reader.Match(file)), f => list.Add(f)); or with AsParallel? List<string> list = new List<string>(); Parallel.ForEach<string>(GetFileList().Where(file => reader.Match(file)).AsParallel(), f => list.Add(f));

    Read the article

  • Item value in JSTL foreach loop not working in Portlet

    - by danimajo
    Given the following Portlet Code: ArrayList nameList = new ArrayList(); nameList.add("Willi Willisch"); nameList.add("Seppi Seppisch"); renderRequest.setAttribute("names", nameList); And the following JSP Code: <c:forEach var="aName" items="${names}"> <tr> <td>${aName} </td> </tr> </c:forEach> Prints out: ${aName} ${aName} I don't have any clue why a $(aName) isn't evaluated. The forEach loops works, because ${aName} is printed out twice ....

    Read the article

  • Code won't exit foreach block

    - by Matt
    I've got the following C# code segment that takes a list, finds objects that are ready to update, then shoves them into a temp list, deletes from the main list, and then goes on its merry way. My issue is that the foreach block, which cycles through my main list, won't exit. TempLog.Clear(); //Ensure TempLog is empty foreach (CLogger ready in PlayerLog) { if (ready.UpdateReady == true) // Record is ready to be updated in database { TempLog.Add(ready); // Add record to templog PlayerLog.Remove(ready); // Remove from playerlog } } <---- Never reaches this point if (TempLog.Count > 0) // Just check that templog isn't empty { new Thread(Update).Start(); // Run update code } I've put heaps of debugging in, and I can watch PlayerLog start at 1, TempLog at 0, then it enters the foreach loop, picks up that the record UpdateReady flag is on, TempLog goes to 1, PlayerLog goes to 0, then it just stops.. No errors, just stops.. Thanks for the help :)

    Read the article

  • C# Lists, Foreach, and Types

    - by user406470
    I was wondering if there is a version of foreach that checks only for a specific type and returns it. For example consider this class tree: org.clixel.ClxBasic - org.clixel.ClxObject - org.clixel.ClxSprite - WindowsGame1.test Then consider this code public List<ClxBasic> objects = new List<ClxBasic>(); foreach(GroupTester tester in objects) { tester.GroupTesterOnlyProperty = true; } tester.GroupTesterOnlyProperty is a property created in GroupTester. Is there some way to make something like this work, like an overload of foreach, or another snippet that might help me? I want to make it easy for a programmer to sort through the lists grabbing only what type they need.

    Read the article

  • Traverse multi dimensional array recusively without using foreach

    - by ejaz
    I have an array like this and the code using foreach loop. $arr = array( array ( array( 'CAR_TIR', 'Tires', 100 ), array( 'CAR_OIL', 'Oil', 10 ), array( 'CAR_SPK', 'Spark Plugs', 4 ) ), array ( array( 'VAN_TIR', 'Tires', 120 ), array( 'VAN_OIL', 'Oil', 12 ), array( 'VAN_SPK', 'Spark Plugs', 5 ) ), array ( array( 'TRK_TIR', 'Tires', 150 ), array( 'TRK_OIL', 'Oil', 15 ), array( 'TRK_SPK', 'Spark Plugs', 6 ) ) ); function recarray($array) { foreach($array as $key=>$value) { if(is_array($value)) { RecArray($value); } else { echo "key = $key value = $value"; } } } recarray($arr); I have to traverse the array using recursion and without using foreach. I would appreciate it if any one can help me

    Read the article

  • Best practice for creating objects used in for/foreach loops

    - by StupidDeveloper
    Hi! What's the best practice for dealing with objects in for or foreach loops? Should we create one object outside the loops and recreate it all over again (using new... ) or create new one for every loop iteration? Example: foreach(var a in collection) { SomeClass sc = new SomeClass(); sc.id = a; sc.Insert(); } or SomeClass sc = null; foreach(var a in collection) { sc = new SomeClass(); sc.id = a; sc.Insert(); } Which is better?

    Read the article

  • Powershell enters foreach loop with null object

    - by SteB
    I'm listing all backups in a given directory: $backups = Get-ChildItem -Path $zipFilepath | Where-Object {($_.lastwritetime -lt (Get-Date).addDays(-7)) -and (-not $_.PSIsContainer) -and ($_.Name -like "backup*")} If I set it to deliberately return no files (.addDays(-600) then the following prints "Empty" (as expected): if (!$backups) { "Empty" } If I try to list the names with an empty $backups variable: foreach ($file in $backups) { $file.FullName; } I get nothing (as expected), if I change this to: "test"+ $file.FullName; then I get a single "test" under the "Empty". How is this possible if $backups is empty?

    Read the article

  • Upper Bound in FOR loop does not get altered in loop,Why?

    - by Vineet
    Hi ALL, I am trying to change the value of upper bound in For loop ,but the Loop is running till the upper bound which was defined in the starting. According to logic loop should go infinite, since value of v_num is always one ahead of i,But loop is executing three time.Please explain This is the code DECLARE v_num number:=3; BEGIN FOR i IN 1..v_num LOOP v_num:=v_num+1; DBMS_OUTPUT.PUT_LINE(i ||' '||v_num); END LOOP; END; Ouput Coming 1 4 2 5 3 6

    Read the article

  • Java: how to have try-catch as conditional in for-loop?

    - by HH
    I know how to solve the problem by comparing size to an upper bound but I want a conditional that look for an exception. If an exception occur in conditinal, I want to exit. import java.io.*; import java.util.*; public class listTest{ public static void main(String[] args){ Stack<Integer> numbs=new Stack<Integer>(); numbs.push(1); numbs.push(2); for(int count=0,j=0;try{((j=numbs.pop())<999)}catch(Exception e){break;}&& !numbs.isEmpty(); ){ System.out.println(j); } // I waited for 1 to be printed, not 2. } } Some Errors javac listTest.java listTest.java:10: illegal start of expression for(int count=0,j=0;try{((j=numbs.pop())<999)}catch(Exception e){break;}&& ^ listTest.java:10: illegal start of expression for(int count=0,j=0;try{((j=numbs.pop())<999)}catch(Exception e){break;}&& ^

    Read the article

  • Refactoring code/consolidating functions (e.g. nested for-loop order)

    - by bmay2
    Just a little background: I'm making a program where a user inputs a skeleton text, two numbers (lower and upper limit), and a list of words. The outputs are a series of modifications on the skeleton text. Sample inputs: text = "Player # likes @." (replace # with inputted integers and @ with words in list) lower = 1 upper = 3 list = "apples, bananas, oranges" The user can choose to iterate over numbers first: Player 1 likes apples. Player 2 likes apples. Player 3 likes apples. Or words first: Player 1 likes apples. Player 1 likes bananas. Player 1 likes oranges. I chose to split these two methods of outputs by creating a different type of dictionary based on either number keys (integers inputted by the user) or word keys (from words in the inputted list) and then later iterating over the values in the dictionary. Here are the two types of dictionary creation: def numkey(dict): # {1: ['Player 1 likes apples', 'Player 1 likes...' ] } text, lower, upper, list = input_sort(dict) d = {} for num in range(lower,upper+1): l = [] for i in list: l.append(text.replace('#', str(num)).replace('@', i)) d[num] = l return d def wordkey(dict): # {'apples': ['Player 1 likes apples', 'Player 2 likes apples'..] } text, lower, upper, list = input_sort(dict) d = {} for i in list: l = [] for num in range(lower,upper+1): l.append(text.replace('#', str(num)).replace('@', i)) d[i] = l return d It's fine that I have two separate functions for creating different types of dictionaries but I see a lot of repetition between the two. Is there any way I could make one dictionary function and pass in different values to it that would change the order of the nested for loops to create the specific {key : value} pairs I'm looking for? I'm not sure how this would be done. Is there anything related to functional programming or other paradigms that might help with this? The question is a little abstract and more stylistic/design-oriented than anything.

    Read the article

  • Change a Recursive function that has a for loop in it into an iterative function?

    - by Bill
    So I have this function that I'm trying to convert from a recursive algorithm to an iterative algorithm. I'm not even sure if I have the right subproblems but this seems to determined what I need in the correct way, but recursion can't be used you need to use dynamic programming so I need to change it to iterative bottom up or top down dynamic programming. The basic recursive function looks like this: Recursion(i,j) { if(i>j) return 0; else { //This finds the maximum value for all possible subproblems and returns that for this problem for(int x = i; x < j; x++) { if(some subsection i to x plus recursion(x+1,j) is > current max) max = some subsection i to x plus recursion(x+1,j) } } } This is the general idea, but since recursions typically don't have for loops in them I'm not sure exactly how I would convert this to iterative. Does anyone have any ideas?

    Read the article

  • Ruby/Rails - Add records to an object with each loop iteration / Object vs Arrays

    - by ChrisWesAllen
    I'm trying to figure out how to add records to an existing object for each iteration of a loop. I'm having a hard time discovering the difference between an object and an array. I have this @events = Event.find(1) @loops = Choices.find(:all, :limit => 5) #so loop for 5 instances of choice model for loop in @loops @events = Event.find(:all,:conditions => ["event.id = ?", loop.event_id ]) end I'm trying to add a new events to the existing @events object based on the id of whatever the loop variable is. But the ( = ) operator just creates a new instance of the @events object. I tried ( += ) and ( << ) as operators but got the error "You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil" I tried created an array events = [] events << Event.find(1) @loops = Choices.find(:all, :limit => 5) #so loop for 5 instances of choice model for loop in @loops events << Event.find(:all,:conditions => ["event.id = ?", loop.event_id ]) end But I dont know how to call that arrays attributes within the view With objects I was able do create a loop within the view and call all the attributes of that object as well... <table> <% for event in @events %> <tr> <td><%= link_to event.title, event %></td> <td><%= event.start_date %></td> <td><%= event.price %></td> </tr> <% end %> </table> How could i do this with an array set? So the questions are 1) Whats the difference between arrays and objects? 2) Is there a way to add into the existing object for each iteration? 3) If I use an array, is there a way to call the attributes for each array record within the view?

    Read the article

  • Why will this for loop not return one field from list rather than the list?

    - by Dick Eshelman
    import csv """sample row = 10/6/2010,73.42,74.43,72.9,74.15,2993500""" filename_in = 'c:/python27/scripts/fiverows.csv' reader = csv.reader(open(filename_in, "rb"), dialect="excel", delimiter="\t", quoting =csv.QUOTE_MINIMAL) for row in reader: for item in row: print 'row = ',row print 'item = ', item When you run this script and print the row you get the sample row returned in [] as a list. When you print the item you get the sample row as an unquoted string. Why do I not get each field ie, (10/6/2010), (73.42), etc. returned as an item? How do I return a single item?

    Read the article

  • Can a shell loop unzip all the files in a directory?

    - by helpwithshell
    I've seen loops to unzip all zip files in a directory. However, before I run this, I would rather make sure what I'm about to run will work right: for i in dir; do cd $i; unzip '*.zip'; rm -rf *.zip; cd ..; done Basically I want it to look at the output of "dir" see all the folders, for each directory cd into it, unzip all the zip archives, then remove them, then cd back and do it again until there are no more. Is this something I should do in a single command or should I consider doing this in Perl?

    Read the article

  • Getting "too many rows" error inside a "for" cursor loop

    - by Will
    I have a trigger that contains two cursors loops, one nested inside the other like this: FOR outer_rec IN outer_cursor LOOP FOR inner_rec IN inner_cursor LOOP -- Do some calculations END LOOP; END LOOP; Somewhere in this it is throwing the following error: ORA-01422: exact fetch returns more than requested number of rows I've been trying to determine where it's coming from for an hour or so.. but should this error never happen? Also.. I am assuming the inner loop automatically closes and opens itself again every time the outer loop goes the next record, i hope this is correct.

    Read the article

  • Can I automate a loop query based on category with the page's title?

    - by jordaninternets
    To explain further, I need to get a page to display posts from a specific category. I want to automate this process so I don't have to make a template for each category. How would I do that? (keep in mind the person I'm building this is for has no coding experience.) The only way I could think off from the top of my head is to use the title or slug. So if the category is named the same thing as the slug, could I filter by category using the slug? Maybe this isn't the best way... what should I do? This is what I came up with, but it doesn't work, I'm sure due to improper use on may part, but I've been pouring over the WP codex and Google with no avail to tell me my problem. <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args= array( 'orderby' => 'date', 'order' => 'ASC', 'paged' => $paged, 'category_name' => echo the_title('\'','\'',) ); query_posts($args); ?>

    Read the article

< Previous Page | 17 18 19 20 21 22 23 24 25 26 27 28  | Next Page >