loops

WordPress Rewind Posts

I have the following code: http://pastebin.com/ng99augD It basically spits out five posts for the five authors I have specified in the query posts in each chunk of code and then rewinds the posts prior to the next query. This is far from ideal and would like to make the code more efficient without having to repeat all the template code ...

How do I loop this program?

Once the program prints, it shuts down. How do I make it returns to the top of the code so that it loops, indefinitely asking for the users name? code: from time import sleep name = raw_input ("Please enter your name: ") print "Hello", name, "- good to see you!" sleep(2.00) pseudo-code: from time import sleep A name = raw_input (...

Keep U.I Updated using Threads

Hello, I have a lot of long-running activities and think that spawning this activity off to another thread will be a good way to have my U.I be able to update to show its current status. However, when I use the following: Thread t = new Thread(() => { /* do magic here */ }); Nothing inside the foreach loop that's inside the threa...

BASH: read in while loop

while [ $done = 0 ] do echo -n "Would you like to create one? [y/n]: " read answer if [ "$(answer)" == "y" ] || [ "$(answer)" == "Y" ]; then mkdir ./fsm_$newVersion/trace echo "Created trace folder in build $newVersion" $done=1 elif [ "$(answer)" == "n" ] || [ "$(answer)" == "N" ]; then $done=2 else echo ...

How to create an effect higher up in the view than the logic that determines it?

I have a simple if statement in my view that returns x = 0 or 1. Based on this simple result, I want to change the styling of the div that contains the entire section. <div> conditional that returns x=1 vs x=0 (and a few displayed items) based on this loop, restyle the div </div> Let's say, if x = 1, I want to make background-colo...

Confusing loop problem (python)

this is similar to the question in http://stackoverflow.com/questions/3559807/merge-sort-in-python I'm restating because I don't think I explained the problem very well over there. basically I have a series of about 1000 files all containing domain names. altogether the data is > 1gig so I'm trying to avoid loading all the data into r...

How to invoke an external library function on an object within a JSTL loop before outputting it?

Let's say I have the following JSTL loop: <c:forEach items="${foos}" var="foo" varStatus="status"> <c:out value="${processedFoo}"/> </c:forEach> And let's say I have an external library com.foo.processor which contains a ProcessorFactory class with a process method. How do I import this library and call the following code from in...

Dynamic amount of '.parent'

I have 2 object. In different depths of MovieClip. I would like to know if object A parent is same with object B parent. I wanted to dynamically add '.parent' to object A/B till it both reaches the same level (having the same parent object). How can I do that? My idea was to have something like objectA = objectA + ".parent" and make ...

Help with a loop

I'm looking for the best way to do the following.. I've got a loop like so... while(mcursor.moveToNext()){ String tname = mcursor.getString(4); String tmessage = mcursor.getString(7); String tlink = mcursor.getString(5); String tsname = mcursor.getString(3); Double tlat = mcursor.getDoubl...

Webbrowser request useragent reverting back to normal

I have a VB.net application that I'm using to load a webpage with a specific useragent, it works once, but then the useragent reverts back to the default browser's useragent, why is this? It uses a loop on a timer like this: Private Sub Timer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer.Tick Try c...

jQuery - Seperate text into strings

Lets say my HTML looks like this: <p>12345, 23, 64229, 359</p> This paragraph can have hundreds of values seperated by comma. It can also be empty. I wanna make these values into links. The first value should link to "http://www.example.com/?id=12345" The second value to "http://www.example.com/?id=23" ..and so on. What would be the...

Getting Current Item of Higher Scope While Loop

I have a nested switch statement inside a switch statement. I am wondering if it is possible to grab the un-nested current item within the scope of the nested switch statement. I know I can accomplish this with a for loop with moderate difficulty but I am hoping there is some elegance I am missing to accomplishing this with switch statem...

tsql Loop with external query

I am looping through all my databases and aggregating the results into an aggregates database. In my loop I call master.dbo.xp_cmdshell osql C:\whatever.SQL As the loop progresses, the cmdshell takes longer and longer to execute. If I stop the loop and run a single aggregate for one database it executes quickly. Is there anything...

better way to design loop

Hi I am wondering is there any better way to design loops. AS you see function1 and function2 has almost similar code expect getting Hash Map. *Current Code 1 * //Field ResultSet rs = null; HashMap<Object, Object> hashMap1; HashMap<Object, Object> hashMap2; if(somecondition) { function1() } else { function2(); } void fun...

Please explain the use of JavaScript closures in loops

I have read a number of explanations about closures and closures inside loops. I have a hard time understanding the concept. I have this code: Is there a way to reduce the code as much as possible so the concept of closure can be made clearer. I am having a hard time understanding the part in which the i is inside two parenthesis. Thanks...

How to have a sound consistently looped while button is pressed and stopped on release?

My question is a very simple one i'm sure. It's just I'm not quite sure how to effectively describe what i'm trying to achieve. Anyway to the point, I have a simple button, I know how to "link" a raw sound file to hand make it play. BUT what i want to do is maybe link a 3 second sound to the button and just have it loop while the user ...

In VB.NET, wait for a Timer Or a KeyPress

I have a console application which is intended to just keep running until it is killed. Essentially: <setupCode> Do <doProcessing> Thread.Sleep(<interval>) Loop Essentially this will keep running until the user kills it, obviously. What I'd like to do is replace the Thread.Sleep call with a wait-condition waiting on eith...

How to make a loop that will get info from a txt file?

Right now I have a loop that is going up by one until it hits its page limit. (this is a mini book/magazine) I have them inserted into a drop down so a user could select the number they want and it will jump to that page. Is there any way to instead of use numbers, somehow get titles into it instead? Like Front cover, table of contents...

PHP arrays & nested loops

I have a list of URLs, each page is a specific category: http://www.site.com/category-1/page.html http://www.site.com/category-2/page.html http://www.site.com/category-3/page.html On each page are let's say 4 items. I want to extract each item on each page and assign it it's corresponding category number i.e. category-1_ITEM - CAT-1 ...

Invoking a method at the end of Cocoa's main event loop

How would it be possible to invoke a method at the end of Cocoa's main event loop after each iteration? I want to do the exact same thing that NSManagedObjectContext's -processPendingChanges does. According to the documentation, "In AppKit-based applications, this method is invoked automatically at least once during the event loop (at ...