Saturday, 31 August 2013

passing bool array to a function

passing bool array to a function

I am passing a bool array to function and doing some modifications in the
passed array inside the function, the changes that I do in the function
are reflected in the original array that I passed to the function.For
example ,in the code below the output is 1 .Why am I getting this output ?
When we pass an integer variable for example ,the local variable maintains
its local value .How can I retain local copy of the original bool array
locally in the code below.
#include<iostream>
using namespace std;
void fun(bool A[30])
{
A[0]=true;
}
int main()
{
bool used[3];
used[0]=used[1]=used[2]=0;
fun(used);
cout<<used[0];
}

c# asynchronous server with beginReceive

c# asynchronous server with beginReceive

Hi stack overflow members. I'm struggling with some simple code but I
can't get it done. I have this asynchronous server which waits for
connections.
while (clientSocket.Connected)
{
try
{
clientSocket.BeginReceive(so.buffer, 0, 200, SocketFlags.None
, new AsyncCallback(wait),so);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
where so(shorted StateObject) it's my class:
internal class StateObject
{
public TcpClient client;
public byte[] buffer;
public StateObject()
{
buffer = new byte[200];
client = new TcpClient();
}
}
I use this class to put out the information on the callback function.
However I get the system lacked sufficient buffer space or because a queue
was full. I posted a short piece from the actual program. One interesting
issue, is that if I write:
while (clientSocket.Connected)
{
try
{
byte[] buffer = new byte[200];
clientSocket.BeginReceive(buffer, 0, 200, SocketFlags.None
, new AsyncCallback(wait),so);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
it will work, but I will not be able to pull out the buffer from the
asynchronous function(wait). I'm struggling with this and I can't find
answers.

Javascript change input value

Javascript change input value

In my website I have a box that is not displayed. When the user types his
username and password, if they are correct, the box must be displayed.
Here you see the HTML code:
<div id="mainbox" style="display: none;">
<p class="classm">Test.</p>
</div>
<input type="text" id="user"/>
<br />
<input type="text" id="password" value="a"/>
<br />
<input type="button" value="Log in" onclick="login();">
And here the javascript function:
function login() {
var a = document.getElementById('password').value;
var b = document.getElementById('user').value;
if ((a == 'qwe') && (b == 'rty')) { //the problem is not here
document.getElementById('password').style.display="none";
}
else
{
alert('You are not logged in.');
}
}
When I click the button Log in looks like the function login(); is not
called because anything happen. Do you know why?

Friday, 30 August 2013

twitter bootstrap dropdown links not working

twitter bootstrap dropdown links not working

I am using bootstrap version 2.0
I have the following html structure -
Now when I click on the Filter by Team the dropdown shows properly. Now
when I click on the link, I should be taken to the page. But the links do
not work. I mean, when I click on the dropdown elements, they should take
me to a url, which they are href'ed to, this does not happen.
<li style="margin-left: 12px;">
<div class="dropdown" style="margin-top: 5px;">
<a class="dropdown-toggle" style="margin-left: -2px;"
data-toggle="dropdown" href="#">
Filter by Team
</a>
<ul class="dropdown-menu" data-toggle="dropdown" role="menu"
aria-labelledby="dropdownMenu">
<li>
<a tabindex="-1" class="disabled"
href="/task/list/orgteam/8/">funvilla</a>
</li>
<li class="divider"></li>
<li>
<a tabindex="-1" class="disabled"
href="/task/list/orgteam/6/">Dev Team</a>
</li>
<li class="divider"></li>
<li>
<a tabindex="-1" class="disabled"
href="/task/list/orgteam/5/">Design Team</a>
</li>
<li class="divider"></li>
</ul>
</div>
</li>
The fiddle can be found here - http://jsfiddle.net/ktgrw/

Thursday, 29 August 2013

how to call a function from another function in Jquery

how to call a function from another function in Jquery

<script>
$(document).ready(function(){
//Load City by State
$('#billing_state_id').live('change', function() {
//do something
});
$('#click_me').live('click', function() {
//do something
//need to recall $('#billing_state_id').live('change', function() {
but how?
});
});
</script>
Load City by State working fine but i don't know whether it's possible or
not to call it within another function like $('#click_me').live('click',
function().

What is the correct output of this statement?

What is the correct output of this statement?

int a=9,b=6,c=3;
printf("%d%d%d");
I executed this in code blocks 10.05. I got some garbage values. But in a
website the output was given as 3 6 9. What is the correct one?

Wednesday, 28 August 2013

Offsetting the start time of SQL Server Agent job schedules between instances

Offsetting the start time of SQL Server Agent job schedules between instances

I have an agent job set to run log backups every two hours from 2:00 AM to
11:59 PM (leaving a window for running a full or differential backup). A
similar job is set up in every one of my 50 or so instances. I may be
adding several hundred instances over time (we host SQL Servers for some
of our customers). They all backup to the same SAN disk volume. This is
causing latency issues and otherwise impacting performance.
I'd like to offset the job run times on each instance by 5 minutes, so
that instance one would run the job at 2:00, 4:00, etc., instance two
would run it at 2:05, 4:05, etc., instance three would run it at 2:10,
4:10, etc. and so on. If I offset the start time for the job on each
instance (2:00 for instance one, 2:05 for instance two, 2:10 for instance
three, etc.), can I reasonably expect that I will get my desired result of
not having all the instances run the job at the same time?