Hi
I have an asp:bulletedlist control, which sits inside a div tag, and I need to count the number of list items inside the control. Searching the internet, and noting the fact the html given back by the items is a list i.e. <li>, I thought I could use an example of:
var listcontrol = document.getElementById('BulletedList1');
var countItems = listcontrol.getElementByTagName('li').length;
However, when I do this, it throws and error saying that no object exists for this control.
So, my problem is, and because I must do this clientside because I want to use this to set the height of the div tag, is how do you count the number of items inside a asp:bulletedlist control with javascript?
How to create a function, which on every call generates a random integer number? This number must be most random as possible (according to uniform distribution). It is only allowed to use one static variable and at most 3 elementary steps, where each step consists of only one basic arithmetic operation of arity 1 or 2.
Example:
int myrandom(void){
static int x;
x = some_step1;
x = some_step2;
x = some_step3;
return x;
}
Basic arithmetic operations are +,-,%,and, not, xor, or, left shift, right shift, multiplication and division. Of course, no rand(), random() or similar staff is allowed.
I have to print the series shown below in java:
***1***
**2*2**
*3*3*3*
4*4*4*4
My current implementation is:
public static void printSeries(int number,int numberOfCharsinEachLine){
String s="*";
for(int i=1;i<=number;i++){
int countOfs=(numberOfCharsinEachLine-(i)-(i-1))/2;
if(countOfs<0){
System.out.println("Can't be done");
break;
}
for(int j=0;j<countOfs;j++){
System.out.print(s);
}
System.out.print(i);
for(int k=1;k<i;k++){
System.out.print(s);
System.out.print(i);
}
for(int j=0;j<countOfs;j++){
System.out.print(s);
}
System.out.println();
}
}
But there are lot of for loops, so I'm wondering whether this can be done in a better way or not?
I have a string like this:
33 00 4b 46 ff ff 03 10 30 t=25562
I am only interested in the five digits at the very end after the t=
How can I get this numbers with a regular expression out of it?
I tried grep t=..... but I also got all characters including the t= in the beginning, which I would like to drop?
After finding that five digit number, I would like to divide this by 1000. So in the above mentioned case the number 25.562. Is this possible with grep and regular expressions?
Thanks for your help.
I want to divide a list in "a specific number of" sublists.
That is, for example if I have a list List(34, 11, 23, 1, 9, 83, 5) and the number of sublists expected is 3 then I want List(List(34, 11), List(23, 1), List(9, 83, 5)).
How do I go about doing this? I tried grouped but it doesn't seem to be doing what I want.
PS: This is not a homework question. Kindly give a direct solution instead of some vague suggestions.
If I have a 32 bit two's complement number and I want to know what is the easiest way to know of two numbers are equal... what would be the fastest bitwise operator to know this? I know xor'ing both numbers and check if the results are zero works well... any other one's?
how about if a number is greater than 0?? I can check the 31'st bit to see if it's greater or equal to 0..but how about bgtz?
I know this might seem a controversial question but it really is not meant to be.
is there an optimal number of methods in an interface.
For example, I personally hate an interface with 20 methods. It is just difficult to implement. The contract seems to hard to maintain.
Similarly if the number of methods is just 1. It makes me wonder if it is really a good abstraction.
Any thoughts ?
I am having a problem in php switch case.
When i set $number=0 it should run very first case but here this code returns 10-20K that is in second case.
I checked comparison operators, tested them in if else case they return correct values but here first case do not run on $number=0
Why is this happening ? php consider 0 as false or something wrong in code ?
Link to codepad paste http://codepad.org/2glDh39K
also here is the code
<?php
$number = 0;
switch ($number) {
case ($number <= 10000):
echo "0-10K";
break;
case ($number > 10000 && $number <= 20000):
echo "10-20K";
break;
case ($number > 20000 && $number <= 30000):
echo "20-30K";
break;
case ($number > 30000 && $number <= 40000):
echo "30-40K";
break;
case ($number > 40000 && $number <= 50000):
echo "40-50K";
break;
case ($number > 50000 && $number <= 60000):
echo "50-60K";
break;
case ($number > 60000 && $number <= 70000):
echo "60-70K";
break;
case ($number > 70000 && $number <= 80000):
echo "70-80K";
break;
case ($number > 80000 && $number <= 90000):
echo "80-90K";
break;
case ($number > 90000):
echo "90K+";
break;
default: //default
echo "N/A";
break;
}
?>
How can I insert in a database the number of days of the year and at the same time insert in the same record the month, day of the month, and the day of the week?
This is my table:
tabela/coluna.Dias_ano(registo 1...365)
Year:=StrToInt(ano.Text);
diasano.Text:= IntToStr( DaysInAYear(Year) );
diasAno| Mes |diames |dia semana |
1 | janeiro | 1 |Segunda |
2 | janeiro | 2 | Terça |
...
365 | Dezembro | 31 | Segunda
Hi all,
My system is Vista Business 32 bits SP2.
When I click "Windows update", I can see there are 2 available optional updates. If I click the link "2 optional updates are available" to see what the updates are, I get:
http://leodip.s3.amazonaws.com/windows%5Fupdate2.PNG
The details about the updates are EMPTY. Any idea why this is happening? It doesn't happen only with optional updates, but with critical updates as well.
I would like to fix this, so I can see what the updates are.
Thanks!
I have a router that sets up rules like so:
TCP Any -> 5800
Any -> 5900
UDP Any -> 5800
Any -> 5900
Computer: ip-address
This would allow someone 'outside' to connect to my router's port 5800 and 5900 and forward that to the same port on my computer.
My issue is that I want the 'outside' port to be different without changing the port on my computer.
I have a MySQL table naming Invoice for a Inventory Monitoring site, invoice_number is bigint(19) AUTO_INCREMENT field.
Currently AUTO_INCREMENT value is 1.
Client want it to start the invoice_number from 50000.
With the following script reset the ALTER TABLE INVOICES AUTO_INCREMENT = 50000;
When I wrote an Insert Script to insert data in SQLDBX, it is putting the invoice_number from 50000.
But when i am trying to do insert a record using the application(web application), the invoice_number value is starting from 1.
We are making use of Spring-JDBC template to insert data into mysql database.
I have a virtual machine with Mandriva 2007.0 (yes, old - unfortunately we do not have a choice here). Anyway, the problem:
Before reboot: active network interface = eth0. No other interfaces present, and network manager confirms this. Static IP address set to 172.31.2.22. No issues, everything working properly, routing et al.
-------Reboot---------
After reboot: active network interface = eth1, with a DHCP address. Network manager shows eth0 as disconnected, and not connectable. When I try to set eth1 up with the static IP address (same one), it says "In Use". I then tried ifconfig eth0 172.31.2.29 just to free it up from the eth0 interface so I could use it with eth1 (since this is connected).
Result:
ifconfig eth0 172.31.2.29
SIOCSIFADDR: No such device
eth0: unknown interface: No such device
Nothing else changed. Any ideas what could be happening, or at least how I can get my IP address back?
I have seen automated support ticketing systems which will email the user as soon as their ticket is created with a custom email address for that ticket.
For example, [email protected]
Does postfix support such a system? Are there any examples out there that might explain how this system might work?
Hi,
Let's look at a sample word 2010 file here.
In this file you can see that the first group of text has their indent modified. The 2nd, 3rd group keep their default format.
I want to apply the changed I've made in the group 1st so group 2nd and 3rd and for the new group I'm going to add instead of recieving the default indent. How can I do that?
ps. Currently what I have to do is quite boring: Copy group 1 and paste to create new group to get the formatted, then remove the old text, adding new text :(
my server currently would temporarily refuse a user to login for certain amount of time (maybe ~20min) if the user consecutively frequent ssh login for 3 times. Can I change this behaviour (say relaxed the definition of frequent maybe from 'within 5 sec' to 'within 10 sec'; or increase the # of consecutive login from 3 to 5)? Thanks.
Added: Ah.. now I think the problem was not with the ssh. I just tried on another newly installed server. consecutive successful login won't block the user. I have no sudo permission on the server I mentioned above. Now I suspect this behaviour may cause by the firewall in the system. Thanks everyone's comments.
ADDED 2: Ah... after some searches. I think the server is using /sbin/iptables to do it as I can see the iptables program is there even though I don't have permission to list the rules. Thanks everyone, special thank to jaume and Mark!
I'm having a discussion with a work colleague. I'm saying that a network with 100 elements will have pretty much 10 times as many failures as a network with 10 elements, ie a tech will need to replace faulty hardware 10 times more often. He suggests that the failure rate doesn't go up in a linear fashion and the failure rate will be significantly less than 10x, in fact only slightly more failures. This is not the probability of an outage etc, we are just talking in relation to the amount of parts that a tech would need to swap out in a given time frame.