Hello,
I have the exact same problem posted here a year ago:
http://stackoverflow.com/questions/1347853/ruby-loop-failing-in-thread
Here the code (pretty much the same as in the topic above)
class NewObject
def my_funk
t = Thread.new {
until false do
puts sleep 15 # sleeps way too much
...
How can I run a loop in Python and code it to stop when the user press a button (not ctr+c)?
...
ok so i have this array and i need to loop through
<?php foreach($classes as $class){ ?>
the html needs to look like this
<li class="active"><span class="l"></span><a href="#">Standard Class</a><span class="r"></span></li>
<li><span class="l"></span><a href="#">Business Class</a><span class="r"></span></li>
<li><span class="l"></sp...
This is my situation:
i need the code to run in a loop, over and over again asking the same question(s) to the user, until the user types a "q" for any point to terminate/exit the loop, thus exiting the program.
The problem is that i tried to used a do-while/while loop, and those loops executes only if the conditions comes out to be t...
Hi everyone,
I've been writing a long GUI in Python using Tkinter. One thing that I don't understand is why I can't bind events to widgets in a loop. In the code below, binding works well if I do it manually (commented out code) but not in a for loop. Am I doing something wrong?
import Tkinter
root = Tkinter.Tk()
b1 = Tkinter.Button(...
I am trying to repeat something inside a jquery function. I tried a for loop, but it seems it doesnt like the syntax.
for instance i have the variable
var number = 2;
now i have
$('tr').html('<td id="'+number+'"></td>');
what i want to do is loop from 0 to number (0,1,2) so that in the end i end up having 3 .
Thanks
...
Hi,
I'm working on a script which will get a JSON array of id's. Based on the results, I then loop over all the checkboxes on the page and check the boxes where the id exists in the JSON array.
The checkboxes are named like so name="name[id]" id="name[id]"
How do I loop the checkboxes and determine if the id (between [ and ] ) exists ...
Hey,
I'm trying to figure out how to re-arrange a string using every x position so that an example input string of "ABCDEFGHI" and the x being 4 would yield DHCIFEGBA. Here's how I got that:
The 1st letter is easy: it's character 4. [A, B, C, D]
The 2nd letter is also easy: it's character 8. [E, F, G, H]
The 3rd letter is mostly easy:...
I have a random amount of DIVs (minimum 1, max of 10)
<div id="container">
<div class="foo">Content</div> <!-- div 1 -->
<div class="foo">Content</div> <!-- div 2 -->
<div class="foo">Content</div> <!-- div 3 -->
<div class="foo">Content</div> <!-- div 4 -->
<div class="foo">Content</div> <!-- div 5 -->
<div class="foo">Content</div> <!...
Many times I need to do things TWICE in a for loop. Simply I can set up a for loop with an iterator and go through it twice.
for (i = 0; i < 2; i++)
{
// Do stuff
}
Now I am interested in doing this as SIMPLY as I can, perhaps without an initializer or iterator ... or any really simple and elegant way ...
How would you do it?
x
...
Hello,
Here is my code within (document).ready
$('.checkfirst').click(function() {
if ($(".textbox").is('.required')) {
var x = $(this).offset().top - 200;
$(this).focus();
$('html,body').animate({
scrollTop: x
}, 500);
divHint = '<div class="formHint">This is required!</div>';
...
I came across through a presentation(dalvik-vm-internals) on Dalvik VM, in that it is mentioned as for the below loops, we have use (2) and (3) and to avoid (7).
(1) for (int i = initializer; i >= 0; i--)
(2) int limit = calculate limit;
for (int i = 0; i < limit; i++)
(3) Type[] array = get array;
for (Type obj : array)
(4) for (int...
<% source.strains.each_with_index do |strain, j| %>
<% if (j == (source.strains.size - 1)) %>
<font size="3">Strain <%= strain[0].appendix %> </font>
<% end %>
<% end %>
I need to get output as
If j value is last one of a loop, then i need to print first value of loop (j[0]). Kindly suggest me or correct abo...
What I'm looking for is a how to build a function that takes a child folder an loops through it and backwards in the directory hierarchy to find the first matching file that is specified.
A example is that i lets say i have the directory structure:
Home / Folder 1 / Folder 2 / Folder 3
And I'm looking for the file style.css.
I would l...
I'm trying to filter my posts to only show the ones with that have a custom value for the field "Model" while sorting the posts by another custom field called "Price."
Here's the function I'm using (not working):
<?php
global $query_string;
query_posts( $query_string . "&meta_value=Model&orderby=meta_value&meta_key=Price&order=ASC");...
For some reason, I can't understand the logic of a program that:
Takes in a list of numbers
Goes through them (via a for each loop) to find the least number
displays the least number via writeline
If leastNumber must be initialized to 0, then won't the leastNumber ALWAYS be 0?
(I've provided a basic txt file containing a list of var...
If I know I have n records, and I want to do something to a group of r records at a time (basically do stuff to n in batches because n is really large), what is the algorithm for that? Any language is OK (though I'm using PHP).
The algorithm should keep in mind that in the final iteration, there may not be enough records to create a co...
How do I pass a variable into a URL in a Perl script?
I am trying to pass the variables in an array to url. For some reason it is not working. I am not sure what I am doing wrong. The code roughly looks like this:
@coins = qw(Quarter Dime Nickel);
foreach (@coins) {
my $req = HTTP::Request->new(POST =>'https://url/$coins.com');
} ...
Hi,
I want to get the value of productId and addressTypeID in this array:
Array
(
[0] => Array
(
[entityId] => 7100122
[orderId] => 110631
[createDate] => 2010-10-19T05:40:00
[lastUpdateDate] => 2010-10-19T05:40:00
[deleted] =>
[products] => Array
(
[Produ...
I am new to javascript/jquery so this is a noob question :)
I am trying to get stuff into table with jquery. The stuff/data is in attributes and array and I would need to go trough that array to get that stuff.
In this I put some content into a array:
$(Stuff).find("desc").each(function(index) {
stuffArray[index]=$(this).text();
});
...