Is there an easy way to loop through all td tags and change them to th? (etc).
My current approach would be to wrap them with the th and then remove the td, but then I lose other properties etc.
looper = (0..3).cycle
20.times { puts looper.next }
can I somehow find the next of 3? I mean if I can get .next of any particular element at any given time. Not just display loop that starts with the first element.
UPDATE
Of course I went though ruby doc before posting my question. But I did not find answer there ...
I am using PHP script for some backend tasks(not web) and I found sometime curl_exec will terminate the executing of script without outputing any errors. I want my script to run in a loop forever and any idea about this?
hello all
i have an application with two main panel LEFT and RIGHT
when a component got focus i want to know
how is the container that holds that component (LEFT or RIGHT)
the component can be inside some other panel's ,
but eventually sits inside the LEFT or RIGHT panel
is there a more simple way to know who is the container without
running in loop on get parent each time a component got focus
thank you
I thought about this: Is there a performance difference in these two practices:
Store the return value of a function in a temporary variable than
give that variable as a parameter to another function.
Put the function into the other function.
Specification
Assuming all classes and functions are written correctly.
Case 1.
ClassA a = function1();
ClassB b = function2(a);
function3(b);
Case 2.
function3(function2(function1()));
I know there aren't a big difference with only one run, but supposed that we could run this a lot of times in a loop, I created some tests.
Test
#include <iostream>
#include <ctime>
#include <math.h>
using namespace std;
int main()
{
clock_t start = clock();
clock_t ends = clock();
// Case 1.
start = clock();
for (int i=0; i<10000000; i++)
{
double a = cos(1);
double b = pow(a, 2);
sqrt(b);
}
ends = clock();
cout << (double) (ends - start) / CLOCKS_PER_SEC << endl;
// Case 2.
start = clock();
for (int i=0; i<10000000; i++)
sqrt(pow(cos(1),2));
ends = clock();
cout << (double) (ends - start) / CLOCKS_PER_SEC << endl;
return 0;
}
Results
Case 1 = 6.375
Case 2 = 0.031
Why is the first one is much slower, and if the second one is faster why dont we always write code that way? Anyway does the second pratice has a name?
I also wondered what happens if I create the variables outside the forloop in the first case, but the result was the same. Why?
Hi experts.
This is the example:
for(int i = 0; i < 10;i++)
{
for(int ? = 0;? < 10 ; ?++)
{
}
}
I usually use an "o" for the second loop, but is there any standard out there?
ideas? Thanks.
I'm getting twice the frame rate with the earlier Java 6 u 3, than with the new ones. Very weird. Can anyone give some explanation?
On Core 2 Duo 1.83ghz, integrated video (only one core is used) - 1500 (older java) vs 700 fps
On Athlon 64 3500+, discrete video - 120 (older java) vs 55 fps
The app is a simple game with a moving rectangle. I'm using Graphics2D to draw from a loop.
How can I reduce the amount of similar commands into a loop?
Something like
pictureBox7.BackColor = Color.FromArgb(187, 187, 187);
pictureBox9.BackColor = Color.FromArgb(187, 187, 187);
pictureBox10.BackColor = Color.FromArgb(187, 187, 187);
pictureBox11.BackColor = Color.FromArgb(187, 187, 187);
pictureBox12.BackColor = Color.FromArgb(187, 187, 187);
pictureBox13.BackColor = Color.FromArgb(187, 187, 187);
G2g for now, will add on later.
Tools such as WebAii can be used to visit a website, and with a simple loop, in succession.
If I code a lot of hits to a site in succession and/or with the ability for custom patterns, is this the same functionality as a load/stress testing tool?
Thanks
I'm new to PHP and MySQL I want a user to be able to store multiple names and there meanings in a MySQL database tables named names using PHP I will dynamically create form fields with JQuery every time a user clicks on a link so a user can enter 1 to 1,000,000 different names and there meanings which will be stored in a table called names.
Since I asked my last question I figured out how to store my values from my form using the forloop but every time I loop my values when I add one or more dynamic fields the second form field named meaning will not save the value entered also my dynamic form fields keep looping doubling, tripling and so on the entered values into the database it all depends on how many form fields are added dynamically. I was wondering how can I fix these problems?
On a side note I replaced the query with echo's to see the values that are being entered.
Here is the PHP code.
<?php
if(isset($_POST['submit'])) {
$mysqli = mysqli_connect("localhost", "root", "", "site");
$dbc = mysqli_query($mysqli,"SELECT * FROM names WHERE userID='$userID'");
$name = $_POST['name'];
$meaning = $_POST['meaning'];
if(isset($name['0']) && mysqli_num_rows($dbc) == 0 && trim($name['0'])!=='' && trim($meaning['0'])!=='') {
for($n = 0; $n < count($name); $n++) {
for($m = 0; $m < count($meaning); $m++) {
echo $name[$n] . '<br />';
echo $meaning[$m] . '<br /><br />';
break;
}
}
}
}
?>
And here is the HTML code.
<form method="post" action="index.php">
<ul>
<li><label for="name">Name: </label><input type="text" name="name[]" id="name" /></li>
<li><label for="meaning">Meaning: </label><input type="text" name="meaning[]" id="meaning" /></li>
<li><input type="submit" name="submit" value="Save" /></li>
</ul>
</form>
If needed I will place the JQuery code.
here is that case....i have an String array that contains only method names of yyyyyy.java file
in xxxxxx.java file am creaing yyyyyy.java 's instance (say obj)
now i have access obj.fuction_name....that function i should get from that String array in loop ...is that possible ...
thank u
Can anybody Explain me why records are required. Can't we perform the same operation in pl/sql using loop and all. Also when multiset, records query can be used i.e. in which type of situation and which one will be the preference.
I've a root directory and it contains many directories,in turn each sub-directory contains many directories and so on.For example if "A" is a root directory it contains sub-directories "A.a","A.b",so on... and each directory("A.a","A.b",etc) contains many directories.I want to copy the inner directories of "A.a" , "A.b" ,etc.. to other directory structure similar to the "A".Instead of copying the each directory I want to use loop that iterates every directory and it's sub-directories(even files).How to do that...Please help me out as I'm new to Ant...
Hey everyone,
I'm trying to make a jabber bot and I am having trouble keeping it running while waiting for messages. How do I get my script to continuously run? I have tried calling a subroutine that has a while loop that I , in theory, have set up to check for any messages and react accordingly but my script isn't behaving that way.
Here is my source: http://pastebin.com/03Habbvh
Say we have a table
table posts
+---------+-----------+--------------------------------+
| postId | title | status | bodyText |
+---------+-----------+--------------------------------+
| 1 | Hello! | deleted | A deleted post! |
| 2 | Hello 2! | deleted | Another one! |
Can we, in SQL, retrieve a concatenation of a field across rows, by issuing a single query, not having to do the join up in a loop in our back-end code?
Something like
select title from posts group by status ;
Should give "Hello!, Hello 2!"
Is there any fast way to find the largest power of 10 smaller than a given number?
I'm using this algorithm, at the moment, but something inside myself dies anytime I see it:
10**( int( math.log10(x) ) ) # python
pow( 10, (int) log10(x) ) // C
I could implement simple log10 and pow functions for my problems with one loop each, but still I'm wondering if there is some bit magic for decimal numbers.
HI everyone
I hope you can help me, I have a problem with a requirement, I need to make a list of images that go to cycle.
I have this website, here I have some business cards and I need the images to be repeated after the end of the first cycle and continue like a loop.
here I leave the website, look that the list has a final.
http://tradelinks.com.au/index.php?service=painters
Thanks in Advance
For example, I have an empty tabControl in my Windows during the compile time, and I have an undetermined amount of images need to be added onto the tabControl, so I used loop + tabControl.Children.Add("image1 to x") to add those images... but after that during runtime, I want to perform events on those image controls, such as dragging the image from the tabControl to another Panel. Is it possible to do so? If it's possible, how?
What's your opinion about using #region folding using application semantic, instead of folding for "syntax".
For example:
#region Application Loop
#region User Management
#region This Kinf of stuffs
instead of
#region Private Routines
#region Public Properties
#region ThisRoutine // (Yes, I've seen this also!)
In this logic, I'm starting fold even routine bodies. I'm starting to love #region directive (even using #pragma region when using C++!).
I have a procedure my program calls tens of thousands of times that uses a generic structure like this:
procedure PrintIndiEntry(JumpID: string);
type
TPeopleIncluded = record
IndiPtr: pointer;
Relationship: string;
end;
var
PeopleIncluded: TList<TPeopleIncluded>;
PI: TPeopleIncluded;
begin { PrintIndiEntry }
PeopleIncluded := TList<TPeopleIncluded>.Create;
{ A loop here that determines a small number (up to 100) people to process }
while ... do begin
PI.IndiPtr := ...;
PI.Relationship := ...;
PeopleIncluded.Add(PI);
end;
DoSomeProcess(PeopleIncluded);
PeopleIncluded.Clear;
PeopleIncluded.Free;
end { PrintIndiEntry }
Alternatively, I can declare PeopleIncluded globally rather than locally as follows:
unit process;
interface
type
TPeopleIncluded = record
IndiPtr: pointer;
Relationship: string;
end;
var
PeopleIncluded: TList<TPeopleIncluded>;
PI: TPeopleIncluded;
procedure PrintIndiEntry(JumpID: string);
begin { PrintIndiEntry }
{ A loop here that determines a small number (up to 100) people to process }
while ... do begin
PI.IndiPtr := ...;
PI.Relationship := ...;
PeopleIncluded.Add(PI);
end;
DoSomeProcess(PeopleIncluded);
PeopleIncluded.Clear;
end { PrintIndiEntry }
procedure InitializeProcessing;
begin
PeopleIncluded := TList<TPeopleIncluded>.Create;
end;
procedure FinalizeProcessing;
begin
PeopleIncluded.Free;
end;
My question is whether in this situation it is better to declare PeopleIncluded globally rather than locally. I know the theory is to define locally whenever possible, but I would like to know if there are any issues to worry about with regards to doing tens of thousands of of "create"s and "free"s? Making them global will do only one create and one free.
What is the recommended method to use in this case?
If the recommended method is to still define it locally, then I'm wondering if there are any situations where it is better to define globally when defining locally is still an option.
Say I have a query like the one below. What would be the best way to put each value into an array if I don't know how many results there will be? Normally I would do this with a loop, but I have no idea how many results there are. Would I need run another query to count the results first?
<CFQUERY name="alllocations" DATASOURCE="#DS#">
SELECT locationID
FROM tblProjectLocations
WHERE projectID = '#ProjectName#'
</CFQUERY>
I want to create a stored procedure in MySQL and one of the input parameters will need to be a comma separated list of integers. How do I loop through each integer and run an update statement on it?
I've googled it but can't seem to find anything that will work for MySQL.
I want to access the raw HTML code that my ASP.NET System.Web.UI.Page is about to render.
How can i do that? Is there a property or method like System.Web.UI.Page.HTML or something like that.
I know I could loop through the Controls List of the page and get access to all the Literal Controls etc, but I was wondering if there's a direct property or method that can return me the raw html, which I can modify just before rendering the page.
In the JDBC code, I have the following that is working with SQL Server:
CallableStatement stmt = connection.prepareCall("{ call getName() }");
ResultSet rs = stmt.executeQuery();
if(rs != null)
{
while(rs.next())
{
//do something with rs.getString("name")
}
}
Multiple rows are returned for the above situation.
I understand that the use of a cursor is required to loop through the table in Oracle, but is there any way to keep the above code the same and accomplish the same thing?
Thanks in advance.
I'm getting data from a database and I need to add the string field value and the record id.
However, I need this to work with some existing code...
I'm replacing this (see code below) and getting data from my database.
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
self.allCategories = dict;
[dict release];
But needs to work with these key and value search functions.
- (void)resetSearch {
NSMutableDictionary *allCategoriesCopy = [self.allCategories mutableDeepCopy];
self.Categories = allCategoriesCopy;
[allCategoriesCopy release];
NSMutableArray *keyArray = [[NSMutableArray alloc] init];
[keyArray addObject:UITableViewIndexSearch];
[keyArray addObjectsFromArray:[[self.allCategories allKeys]
sortedArrayUsingSelector:@selector(compare:)]];
self.keys = keyArray;
[keyArray release];
}
.
- (void)handleSearchForTerm:(NSString *)searchTerm {
NSMutableArray *sectionsToRemove = [[NSMutableArray alloc] init];
[self resetSearch];
for (NSString *key in self.keys) {
NSMutableArray *array = [Categories valueForKey:key];
NSMutableArray *toRemove = [[NSMutableArray alloc] init];
for (NSString *name in array) {
if ([name rangeOfString:searchTerm
options:NSCaseInsensitiveSearch].location
== NSNotFound)
[toRemove addObject:name];
}
if ([array count] == [toRemove count])
[sectionsToRemove addObject:key];
[array removeObjectsInArray:toRemove];
[toRemove release];
}
[self.keys removeObjectsInArray:sectionsToRemove];
[sectionsToRemove release];
[table reloadData];
}
Keep getting an error from this code...
NSDictionary *arrayTmp= [[NSDictionary alloc] init];
... loop records
int cid = sqlite3_column_int(statementTMP, 0);
NSString *category = [[NSString alloc]
initWithUTF8String:(char *)sqlite3_column_text(statementTMP, 1)];
[arrayTmp setObject:category forKey:[NSString stringWithFormat:@"%i", cid]];
Error caused by line above
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString count]: unrecognized selector sent to instance 0x4d4c500' * Call stack at first throw *
... end loop
self.allCategories = arrayTmp;
[arrayTmp release];