Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
2,543,490
2,543,491
How do I incorporate the AutoAnchors jquery plugin into my web page?
<p>I'm very new to the HTML5 world and I could use some help with how to use this javascript file. </p> <blockquote> <p>jquery.autoanchors-0.3</p> </blockquote> <p>It is found here. <a href="http://fredibach.ch/jquery-plugins/autoanchors.php" rel="nofollow">http://fredibach.ch/jquery-plugins/autoanchors.php</a></p> <p>How do I do use this? How can I include this in the html file in the and the js file how will it automatically add the anchors/links to the html file?</p> <pre><code> &lt;script src="js/jquery.autoanchors-0.3.js"&gt;&lt;/script&gt; </code></pre> <p>Any help would be great.</p> <p>Thanks damon</p>
javascript
[3]
3,019,734
3,019,735
handling php eval syntax error for mathematic equations
<p>suppose I do this in php:</p> <pre><code> eval("\$answer=1--1;"); </code></pre> <p>The expression 1--1 will lead to a syntax error in eval, my question is how do I detect the error and handle it gracefully? ie: catch error in eval and then print out a helpful message. Right now, it just spits out "Parse error: syntax error, unexpected T_DEC". Unfortunately, the php manual states that it is not possible to catch parse errors with the set_error_handler() function.</p> <p>This is for a simple school assignment and they have suggested using "eval()". As the assignment is trivial, perhaps there is no need to worry about these rare cases.</p>
php
[2]
2,473,419
2,473,420
For Question About a Warning In Objective-c Coding
<p>I have one file viewcontroller.h and .m and viewcontroller1.h and .m</p> <p>In viewcontroller1.m file , i write function like BOOL rechable = [viewcontroller functionrechable];</p> <p>it gives me warning like warning:initialization makes integer from pointer without a cast</p> <p>how to remove this warning??? is it any way to do it?</p>
iphone
[8]
2,127,768
2,127,769
how to pass, from a class to another, the name of a variable (NOT the value)
<p>I need to pass name of a variable created in <code>Class A</code> to the <code>Class B</code>, so I can put a value in that variable (in <code>Class B</code>). But, in Class B I do not know the name of that variable. The code is something like this:</p> <p>Class A</p> <pre><code>public class A { int valore; // this is the variable, in Class b, I don't know this name! public void callClassB(){ ClassB.Method(what shoudld i put here?) } } </code></pre> <p>This is the Class B</p> <pre><code>public class B { public void Method(the_Name_Of_TheVariable_I_get){ the_Name_Of_TheVariable_I_get = 5; // i need to do this } } </code></pre>
android
[4]
1,839,656
1,839,657
How to convert 2 dimensional float array to byte array and viceversa
<p>I have data in the form of </p> <p><code>float [1000,2]</code> data.</p> <p>I want to convert that data in the form of byte []b.</p> <p>and again I want to convert <code>byte []b</code> to 2 dimensional array of <code>float [1000,2]</code> data</p> <p>I want to do this because i can save data to server in the form of byte easily.</p>
c#
[0]
1,278,551
1,278,552
How to find UILabel's number of Lines
<p>I displayed the text in UILabel by using wrap method. Now I want to need to find the how many number of line is there in UILabel.</p> <p>If there is any possible way to find the UILabel's number of lines count.</p> <p>Thanks.</p>
iphone
[8]
5,171,068
5,171,069
how to connect android phone(client) to laptop using only one ip address(static)?
<p>I am doing a android project. I want to connect my client(android phone) using ip address to my laptop(server). I am using ip address of wireless modem(MTS). Each time i reconnect the ip address changes. So how can I keep this ip address constant so that only one ip address can be used for connection via wireless internet connection?</p>
android
[4]
3,883,322
3,883,323
Implementing Fisher–Yates shuffle loop not working
<p>I am trying to implement the Fisher–Yates shuffle but when I test this code just with alert, it doesn't seem to loop, stops after first time I think.</p> <pre><code>function scrambleWord() { var letterArray = currentWord.split(""); var m = letterArray.length, t, i; while (m) { x = Math.floor(Math.random() * m--); t = letterArray[m]; letterArray[m] = array[i]; array[i] = t; } scrambledWord = letterArray.join(""); } </code></pre>
javascript
[3]
4,726
4,727
Adding suffix to a number using cultures
<p>I have a need to write dates in various languages. Is it possible to write a date like 1st July -3rd October using cultures?</p> <p>Cannot find a way to do it Any suggestions?</p> <p>EDIT</p> <p>What I Mean is that if the choosen culture is English it should show 1st October 2010 if Spanish should show the equivalent for spanish note suffix(1st etc...)</p>
c#
[0]
4,428,899
4,428,900
jQuery intercept slideToggle()
<p>I'm doing a very simple slideToggle() here:</p> <pre><code> $("#loginBtn").click(function(){ $("#login").slideToggle(); return false; }); </code></pre> <p>What i'm asking is, how do i intercept the slideToggle, so once the user clicks #loginBtn and #login slides down, they can either click #loginBtn again to slide it up OR they can click another element to slide #login up? But only the #loginBtn slides down the #login?</p> <p>Thanks</p>
jquery
[5]
1,779,830
1,779,831
how to control the buttons or tabs in the launch application using python
<p>i launched the application using the following code i.e.</p> <p>import os</p> <p>cmd = r'start C:\WindowsMediaPlayer\wmplayer.exe'</p> <p>os.system(cmd)</p> <p>say i launched win media player.. now i want to control the buttons/the menus to open a file . or do some audio settings.. any thing that is related to media player using the python script.. please any on can help me with this....</p>
python
[7]
1,508,843
1,508,844
Looping each() loop infinitely
<p>I am using jQuery to loop through each li element under a ul displaying them one by one. Here is the code:</p> <pre><code> $('.article_ticker li:first').siblings().hide(); var list=$('.article_ticker li:first').siblings(); list.each(function(index) { $(this).siblings().hide().delay(2000).fadeOut(); $(this).fadeIn('fast'); }); </code></pre> <p>This code works fine but once the 'each' loop ends, it doesn't repeat the sequence. I want to cycle to be repeated infinitely. Like after the last element fades out, first element should fade in.</p>
jquery
[5]
2,825,860
2,825,861
Jquery multiselect DDCL not refreshed after database change until manual refresh
<p>Hi I have a Jquery DDCL widget with multiselect list box for users. When I delete or add users the same is not replicated in the list box untill i manually refresh the application.</p> <p>I can see that the list is updated in the model every time the call is made but the DDCL displays the same data untill manual refresh of the whole application.</p> <p>My code :</p> <p>View: </p> <pre><code> &lt;%= Html.ListBox("userlist", new MultiSelectList(Model.Users, "Id", "FullName")) %&gt; </code></pre> <p>Controller:</p> <pre><code>public ActionResult Index() { var userlist1= this.UnitOfWork.Users.FindAllBy(x.Type.Value == (int)UserType.Primary)).OrderBy(x =&gt; x.LastName).ThenBy(x =&gt; x.FirstName).ToList(); var model = new MessageModel { Users = userlist1 }; return View(model); } </code></pre> <p>Jquery :</p> <pre><code>$("#userlist option:selected").removeAttr("selected"); if (selected) { $("#userlist &gt; option[value=" + selected + "]").attr("selected", true); } $('#userlist').dropdownchecklist('destroy'); $('#userlist').dropdownchecklist({ icon: {}, emptyText: "Select User", width: 300 }); </code></pre> <p>I tried the following to make the cache false</p> <pre><code>$.ajax({url: 'abc', cache: false, success: function(data){ alert("succ"); } }); </code></pre> <p>But still the list is not refreshed untill a manual refresh of application.</p> <p>Kindly suggest!!</p>
jquery
[5]
2,560,240
2,560,241
if setInterval is cleared?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2679141/is-there-a-way-to-check-if-a-var-is-using-setinterval">Is there a way to check if a var is using setInterval() ?</a> </p> </blockquote> <p>how can I check if a setInterval is cleared?</p> <pre><code>var i = 0; var refreshLoop = setInterval(function(){ i++; }, 250); clearInterval(refreshLoop); </code></pre>
javascript
[3]
2,197,328
2,197,329
anchor title attribute
<p>The title is showing only the first word when you mouse over the link. How can I get the whole order description to show? Thanks</p> <pre><code>&lt;a title=$row[order_description] href=order.php?order_id=$row[qid]&gt;&lt;font class=fontblueData_sub&gt; $row[prod_title]&lt;/font&gt;&lt;/a&gt; </code></pre>
php
[2]
2,875,047
2,875,048
In python, how to convert a hex ascii string to raw internal binary string?
<p>In python, how to convert a hex ascii string to binary string?</p> <p>Example, "01000001B8000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435362021222324"</p> <p>Need to be converted to a binary string.( "0A" need to be converted to 1010, not to ascii bit 1000001 which is 65)</p> <p>edit : Changed "raw binary" in question to "raw internal binary" string for better clarity.</p>
python
[7]
3,743,392
3,743,393
PHP Create and delete cookies using query strings
<p>I have the following two links:</p> <pre><code>&lt;a href="index.php?showDesktop=true"&gt;Show Desktop&lt;/a&gt; &lt;a href="index.php?showMobile=true"&gt;Show Mobile&lt;/a&gt; </code></pre> <p>What I want to do is make it so that if the showDesktop query is clicked then create a cookie called showDesktop and delete the cookie showMobile and the vice-versa. I have tried the following so far, but think I'm doing it wrong. Can anyone help me get this working as proposed.</p> <pre><code>if($_GET['showDesktop']) { $_COOKIE('showDesktop', 'yes'); $_COOKIE('showMobile', null); } else if($_GET['showMobile']) { $_COOKIE('showDesktop', null); $_COOKIE('showMobile', 'yes'); } </code></pre>
php
[2]
3,523,969
3,523,970
Why won't jQuery accept this string?
<p>When I run this function:</p> <pre><code>onUnCheck: function(el) { var thenames = "icon-"+el.find("label:first").text().replace(/ /g,'').toLowerCase(); alert(thenames); $("'."+thenames+"'").hide("fast"); } </code></pre> <p>I generate a string. I can see in the alert() that it is indeed the correct string. Example: </p> <pre><code>icon-jira </code></pre> <p>But when I pass the string in as a jQuery selector it does not work. </p> <p>I know the funtion's logic is sound because pasting in the result of my alert() makes it work. </p> <p>Why won't jQuery accept my string?</p>
jquery
[5]
3,578,365
3,578,366
JavaScript - How to get at specific value in a string?
<p>I have a string from which I am trying to get a specif value. The value is buried in the middle of the string. For example, the string looks like this:</p> <pre><code> Content1Save </code></pre> <p>The value I want to extract is "1";</p> <p>Currently, I use the built-in substring function to get to remove the left part of the string, like this:</p> <pre><code>MyString = "Content1Save"; Position = MyString; Position = Position.substring(7); alert(Position); // alerts "1Save" </code></pre> <p>I need to get rid of the "Save" part and be left with the 1;</p> <p>How do I do that?</p> <p>+++++++++++++++++++++++++++++++++++++++++ ANSWER</p> <pre><code>Position = Position.substr(7, 1); </code></pre> <p>QUESTION</p> <p>What's the difference between these two?</p> <pre><code>Position = Position.substr(7, 1); Position = Position.substring(7, 1); </code></pre>
javascript
[3]
3,481,970
3,481,971
java middleware webservices - exception handling
<p>I usually see a code, which pretty much wraps with try block for the entire operation of a web service. The reasoning is to take care of un-expected results. What is the best way to convince programmers not to follow such styles? </p> <p>Of course, we do want to provide meaningful message to the client. How can we handle such situations?</p>
java
[1]
3,664,472
3,664,473
jQuery focus/blur on form, not individual inputs
<p>How could this be achieved via jQuery?</p> <p>When the user clicks on any input in the form, it is focussed. When a user clicks out of the form from any input it is blurred, but, the blur does not get triggered between tabbing between inputs in the form itself.</p> <p>For something like this, we're looking at this basic structure:</p> <pre><code>&lt;form&gt; &lt;input ... /&gt; &lt;input ... /&gt; &lt;input ... /&gt; &lt;/form&gt; </code></pre> <p>So again, lets say I click on any input in the form, we know the form is focused. Next, when the user clicks off of ANY input the blur is triggered ONLY if we clicked outside the form.</p> <p>I've asked this question previously and kindly received input on how to achieve the blurring effect when the last input field in the form was blurred, but not from any element in the input list.</p> <p>Thanks, Mark Anderson</p>
jquery
[5]
4,095,709
4,095,710
1000 by 1000 for loop in android sep
<p>I have a code like this running on Android 2.3.3 (Nexus One)</p> <pre><code>for(i=0; i&lt;1000; i++){ for(j=0;j&lt;1000;j++){ do AND calculation do XOR calculation } } </code></pre> <p>Is this too much calculation for android? I went through the debugger and the debugger lost its control after 3 iteration of the first for loop (3000 iteration total)</p> <p>I am running this on a new thread like this and call this function on main ui thread..</p> <pre><code>public void startCalculation(ArrayList&lt;data&gt; featA, ArrayList&lt;data&gt; featB){ newThread= new Thread(new Runnable(){ public void run(){ theFunction(); } }); newThread.start(); } </code></pre> <p>Thanks in advance...</p>
android
[4]
1,134,300
1,134,301
image quality is missing while using thumb.php
<p>I am using thumb.php to restrict image sizes.</p> <pre><code>&lt;img src="thumb.php?src=&lt;?php echo $imgurl; ?&gt;&amp;h=150&amp;w=180&amp;z=0" alt="&lt;?php the_title(); ?&gt;" width="180" height="150" /&gt; </code></pre> <p>The problem is image quality. If i do not use thumb.php and mention the width and height attribute directly in the image tag, the quality is good but while using thumb.php the image looks a little blur.</p> <p>How to overcome this?</p>
php
[2]
4,410,800
4,410,801
100K curl requests
<p>I am using curl_multi_exec to process over 100K requests. I do 100 requests at a time because curl_multi_exec can only handle 100 requests at a time to eventually get to 100K requests. We have added multiple servers to this system to spread the load [we are using load balancing]. What is the best way to have curl handle 100K requests and make use of these additional servers? What is the downside (other than time) of handling that many requests on one server? How can I use the additional servers to help handle those requests?</p> <p>I was thinking about having each server handle a batch of requests (like one server handles 500 requests, another 500, another 500, etc.. </p> <p>To elaborate- basically, we are using curl to send out over 100K requests to third party servers. The problem with only using 1 server is that there is a memory limit in the number of requests 1 server can handle. So we decided to add additional servers, but we are not sure how to design this system to use curl to handle that many requests..</p> <p>The third party server is an API like Facebook; they are aware that we will be making that many requests to their servers.</p> <p>For load balancing, we use Rackspace cloud server, basically the load balancer directs incoming requests to separate servers. </p>
php
[2]
3,321,062
3,321,063
Determine minimum required PHP version
<p>I have to find out the earliest PHP4 version my code will run under (I already know it runs on PHP5 and on PHP 4.4.9 (the last PHP4 version -- included in MAMP).</p> <p>Are there code inspection tools that will do this? Do I need to install each PHP version and see what happens :-)</p>
php
[2]
313,932
313,933
Android android.media.audiofx not importing
<p>I am not able to import android.media.audiofx in my project.</p> <p>Is audiofx have some dependency with android version. I'm currently working on 2.2.</p> <p>Thanks in advance.</p>
android
[4]
1,428,171
1,428,172
How to go back to the last accessed activity?
<pre><code> back = (Button) findViewById(R.id.back); back.setOnClickListener(new View.OnClickListener() { public void onClick(View v1) { Intent setIntent = new Intent(Intent.ACTION_MAIN); setIntent.addCategory(Intent.CATEGORY_HOME); setIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(setIntent); } }); </code></pre> <p>I have created a back button in my application and once the user click on the back button, it will go back to the last accessed activity, but when i click back button, it brings me to exit the apps... what is wrong with the code?</p>
android
[4]
5,593,235
5,593,236
how to turn 'C:\Music\song.mp3' into r'C:\Music\song.mp3'
<p>I have been making an mp3 player with Tkinter and the module mp3play.</p> <p>Say i had the song to play: C:\Music\song.mp3</p> <p>and to play that song i have to run this script:</p> <pre><code>import mp3play music_file=r'C:\Music\song.mp3' clip = mp3play.load(music_file) clip.play() </code></pre> <p>Easy enough, my problem though is getting the "r" there.</p> <p>i have tried:</p> <pre><code>import mp3play import re music_file="'C:\Music\song.mp3'" music_file='r'+music_file music_file=re.sub('"','',music_file) print music_file clip = mp3play.load(music_file) clip.play() </code></pre> <p>Which gets the output: <code>r'C:\Music\song.mp3'</code></p> <p>but it is a string, so it wont read the file.</p>
python
[7]
4,364,767
4,364,768
Strange behavior with ++i twice in single std::cout <<
<p>Can someone please explain this to me. </p> <p>below is the simplest of all codes, I am running a while loop 9 or 10 times and inside it I am displaying a variable incrementing it everytime the loop runs. But I do not understand the output or the warning message I get during compilation.</p> <p><strong>code- with post-incremation</strong></p> <pre><code>#include &lt;iostream&gt; int main() { int i=0; while(i&lt;9) std::cout&lt;&lt;i++&lt;&lt;"\t"&lt;&lt;i++&lt;&lt;std::endl; return 0; } </code></pre> <p>*<strong><em>output</em>*</strong> 1 0 3 2 5 4 7 6 9 8</p> <p><strong>code2 -- I am pre-incrementing now</strong></p> <pre><code>#include &lt;iostream&gt; int main() { int i=0; while(i&lt;9) std::cout&lt;&lt;++i&lt;&lt;"\t"&lt;&lt;++i&lt;&lt;std::endl; return 0; } </code></pre> <p><strong>output</strong></p> <p>2 2 4 4 6 6 8 8 10 10</p> <p><strong>Warning message on both instances</strong></p> <blockquote> <p>main.cpp: In function ‘int main()’:</p> <p>main.cpp:37:39: warning: operation on ‘i’ may be undefined</p> </blockquote> <p><strong>The program shows correct behavior for the below code</strong></p> <pre><code>#include &lt;iostream&gt; int main() { int i=0; while(i&lt;9) { std::cout&lt;&lt;++i&lt;&lt;"\t"; std::cout&lt;&lt;++i&lt;&lt;std::endl; } return 0; } </code></pre>
c++
[6]
545,251
545,252
jQuery: missing ] after element list
<p>I have that error in the code below. What's wrong ? I have no ideas left.</p> <pre><code>missing ] after element list [object XMLHttpRequest] $(function () { setInterval($.post('/Sale/UpdatePrice', {SaleId : @Model.Id}, function(data){ $('#mPrice').val(data); } ) ,5000); //refresh every 5 seconds }); C# public JsonResult UpdatePrice(int SaleId) { ... return Json(NewPrice, JsonRequestBehavior.AllowGet); //NewPrice is a decimal number } </code></pre>
jquery
[5]
861,842
861,843
Stop scheduled JavaScript execution
<p>I have a function, where I define lots of setTimeout() functions . When user presses the button, it's starting the execution.</p> <p>How can I cancel it ?</p> <p>Is there any way to cancel ALL timeouts (assuming that I have multiple without the name)</p>
javascript
[3]
1,689,838
1,689,839
Combine 3 strings into one
<p>I've been trying to combine 3 strings into one and having trouble doing so.</p> <p>the strings are below.</p> <pre><code>$from="/2/3/4/5/6/"; $to="/30/31/32/33/34/"; $sub="/2/3/4/5/6/7/8/9/10/11/12/";#this is dynamic, ever changing past &gt; (/2/3/4/5/6/) </code></pre> <p>the output must look like this below.</p> <pre><code>$output="/30/31/32/33/34/6/7/8/9/10/11/12/"; </code></pre> <p>else if <code>$sub</code> changes like below then.</p> <pre><code>$from="/2/3/4/5/6/"; $to="/30/31/32/33/34/"; $sub="/2/3/4/5/6/7/8/"; $output="/30/31/32/33/34/6/7/8/"; </code></pre> <p>and else if <code>$to</code> changes then this.</p> <pre><code>$from="/2/3/4/5/6/"; $to="/30/31/"; $sub="/2/3/4/5/6/7/8/"; $output="/30/31/6/7/8/"; </code></pre> <p>the <code>$to</code> needs to be first, then the <code>$sub</code> at the end, minus the <code>$from</code> before the end <code>/*/(eg./6/)</code> to be combined into 1 string.</p> <p>how is this possible?</p>
php
[2]
5,896,155
5,896,156
Help with expandable div in javascript
<p>Hi i'm new to JavaScript and i am looking to learn how to put a <code>&lt;div&gt;</code> within a <code>&lt;div&gt;</code> so when the user clicks on the first one it opens the content of the second(hidden until clicked) and closes so my page wont be a million miles of scrolling down . but my problem is the all the content is displayed on page load instead of on click </p> <p>heres the code </p> <pre><code>&lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script type="text/javascript"&gt; function toggleMe(a){ var e=document.getElementById(a); if(!e)return true; if(e.style.display=="none"){ e.style.display="block" } else{ e.style.display="none" } return true; } &lt;/script&gt; &lt;/head&gt; </code></pre> <p>thank's in advance</p> <pre><code>&lt;input type="button" onclick="return toggleMe('para1')" value="Toggle"&gt;&lt;br&gt; &lt;p id="para1"&gt;(lots of text)&lt;/p&gt; &lt;br&gt; &lt;input type="button" onclick="return toggleMe('para2')" value="Toggle"&gt;&lt;br&gt; &lt;div id="para2"&gt;(lots of text)&lt;/div&gt; &lt;br&gt; &lt;input type="button" onclick="return toggleMe('para3')" value="Toggle"&gt;&lt;br&gt; &lt;span id="para3"&gt;(lots of text)&lt;/span&gt; </code></pre>
javascript
[3]
1,413,499
1,413,500
Call a function based on the device's screen size (hdpi/ldpi/mdpi)
<p>On mdpi device I would like to call this method:</p> <pre><code>final float scale = getResources().getDisplayMetrics().density; double height_px = 45 * scale + 0.5; </code></pre> <p>but I want to ignore the method when the app is run on hdpi devices, how am I able to determine the screen size on my class?</p>
android
[4]
1,691,481
1,691,482
When I prepend data to an existing page, it doesn't perfom any jQuery actions
<pre><code>&lt;div id="partition"&gt; hello &lt;input type="button" id="btn" value="submit"&gt; &lt;/div&gt; &lt;!-- partitions ends --&gt; &lt;!-- this posts the data and prepends the return data to partition div --&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#button').click(function(){ var content = $('#content').val(); var contentType = $('input[id=contentType]:checked').val(); $.post('classes/updateStatus.php', { content: content, contentType: contentType }, function(data) { $('#partition').prepend($('&lt;div id="partition"&gt;'+data+'&lt;/div&gt;').html(data)); }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#btn').click(function(){ alert("hello"); }); &lt;/script&gt; </code></pre> <p>The problem with this script is that after prepending the data to partition div, it doesn't perform the necessary action. In this case, it doesn't popup an alert box.</p>
jquery
[5]
5,134,592
5,134,593
php - Website cannot be displayed
<p><strong>Below is the Code</strong></p> <pre><code>&lt;? include('config.php'); // table name $tbl_name=temp_members_db; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $email=$_POST['email']; $country=$_POST['country']; // Insert data into database $sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')"; $result=mysql_query($sql); // if suceesfully inserted data into database, send confirmation link to email if($result){ // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email; // Your subject $subject="Your confirmation link here"; // From $header="from: your name &lt;your email&gt;"; // Your message $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; $message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code"; // send email $sentmail = mail($to,$subject,$message,$header); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } ?&gt; </code></pre>
php
[2]
5,045,243
5,045,244
Virtual templates members of class workaround
<p>Let's say that I want to implement some classes for containers. All of them should implement such functions like insert, remove etc. So I write some interface:</p> <pre><code>template &lt;class T&gt; class ContainerInterface { public: virtual void insert(T element) = 0; template&lt;class Predicate&gt; virtual void remove(Predicate p) = 0; }; </code></pre> <p>Now I can write something like:</p> <pre><code>template &lt;class T&gt; class MyVector : public ContainerInterface&lt;T&gt;{}; template &lt;class T&gt; class MyList : public ContainerInterface&lt;T&gt;{}; </code></pre> <p>And I am sure that MyVector and MyList must implement functions insert and remove. However, there is the error:</p> <pre><code>error: templates may not be ‘virtual’ </code></pre> <p>It comes from:</p> <pre><code>template&lt;class Predicate&gt; virtual void remove(Predicate p) = 0; </code></pre> <p>I don't know the Predicate when I define some container and I dont'see any sense to bind deleter object to container class, for example one time I can pass Predicate to delete integers less than 50 and other time I want delete even integers. What can be done in such case - to declare some templated thing in base class and simulate virtual behaviour of function?</p>
c++
[6]
2,695,879
2,695,880
alert when not satisfying the condition should stay on the same pane in a wizard
<p>I am trying to check if the user entered particular info or not...if entered on click of the next button on a wizard pane that should be redirected to next pane or else should be on the same pane..</p> <p>I tried the below code..but when the user doesn't enter info the alert message is popped but it is redirected to next page...what is the mistake i am doing? any help please...</p> <pre><code>checkinginfo: function () { if (!this.info) { alert("Enter info to proceed!"); return false; } else return true; }, </code></pre> <p>Thanks in Advance.</p>
javascript
[3]
1,464,086
1,464,087
Multiple Web.Config files - from a code point-of-view
<p>ASP.NET allows for Web.Config files at sub-levels within a site structure. However, I can't find any articles discussing how this looks from code.</p> <p>In the Orchard CMS there are config files all over the shop. There's even a config file in a folder containing only .CSS files! I'm new to larger-scale ASP.NET apps so...</p> <p>Can someone just tell me if I'm right in my assumptions.</p> <ul> <li><p>The config file can affect server settings, and hence how a server processes a request to a resource further down a site structure.</p></li> <li><p>From a code point of view, if the same line of code in the same class queries the config file during a request for <code>http://level1.resource</code> then it could read a different value to when the same code executes during a request for <code>http://level1/level2.resource</code> (if there is a web.config at level2)</p> <ul> <li>Overall, the way it works is based on the current request path.</li> </ul></li> </ul> <p>Right?</p>
asp.net
[9]
2,674,087
2,674,088
C++: overloaded destructor?
<p><a href="http://www.boost.org/doc/libs/1_46_1/libs/utility/enable_if.html" rel="nofollow">enable_if doc page</a> says:</p> <blockquote> <p>Constructors and destructors do not have a return type; an extra argument is the only option.</p> </blockquote> <p>Are destructors overloadable?</p> <p>Thank you.</p>
c++
[6]
985,154
985,155
best way to reference event arguments in asp.net
<p>Best practices question.</p> <p>While I was writing some event handlers, I ran into an issue where I as looking at the incorrect event (GridViewRowEventArgs) when I should have been looking at something else.</p> <p>Now to solve my problem, instead of referencing the very specific event I was looking at, I just used EventArgs, which seems to catch any possible event. So, finally to the question; is there an issue with using EventArgs instead of the specific event? is it better to use the specific one for debugging issues? What is everyone's opinion?</p> <p>Thanks</p>
asp.net
[9]
4,343,383
4,343,384
Why are my objects showing up as "[object Object]"?
<p>I'm trying to bubble sort an array of records by age but all I get is: </p> <blockquote> <p>[object Object], [object Object], [object Object]</p> </blockquote> <p>How can I get it to display the values of the record?</p> <pre><code>students = [ {name: "timothy", age: "9"}, {name: "claire", age: "12"}, {name: "michael", age: "20"} ]; for (var i = 0; i &lt; students.length; i++) { for (var j = i + 1; j &lt; students.length; j++) { if (Number(students[i].age) &gt; Number(students[j].age)) { tempValue = students[j].age; students[j].age = students[i].age; students[i].age = tempValue; } } } alert(students); </code></pre>
javascript
[3]
2,348,402
2,348,403
c++ program gets segmentation fault
<p>I've been working on some coding and I ran into a segmentation fault. I've tried my best to make it work but I kept failing. Now I am asking for help. This is my code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int main() { string symbols = "ABCDEFGHIJKLMNOPRSTUVYZ_"; int sim, a = 0; sim = symbols.size(); string temp[sim]; while(sim &gt; 0) { sim--; temp[sim] = symbols.substr(sim, 1); cout &lt;&lt; temp[sim] &lt;&lt; endl; } } </code></pre> <p>Well this kinda works but if I do some changes it crashes.</p> <p>I change:</p> <pre><code> while(sim &gt; 0) { sim--; temp[sim] = symbols.substr(sim, 1); cout &lt;&lt; temp[sim] &lt;&lt; endl; } </code></pre> <p>To this:</p> <pre><code> while(a &lt; sim) { a++; temp[a] = symbols.substr(a, 1); cout &lt;&lt; temp[a] &lt;&lt; endl; } </code></pre> <p>I get SIGFAULT, I don't really understand that is wrong. I used debugger and it doesn't really show at which line it crashes, it just show this:</p> <p>Program received signal SIGSEGV, Segmentation fault.</p> <p>In <code>__gnu_cxx::__exchange_and_add(int volatile *, int) () ()</code></p>
c++
[6]
2,137,035
2,137,036
Restrict additional pagehead in sharepoint popup window
<p>hi i have added additionalpagehead in sharepoint which will run a javascript functions to show some texts. It is working fine in all the sharepoint pages but it is working in sharepoint popup window also. How can i restrict it from popup windows</p>
javascript
[3]
4,628,809
4,628,810
javascript executing then undoing
<p>I have an aspx page where I'm trying to hide a div based on a button click. It seems as though the javascript executes but then the div shows back up immediately. It seems like the page is refreshing as well.</p> <pre><code>function hideDiv2() { document.getElementById("div2").style.display = "none"; } </code></pre> <p>This is the html</p> <pre><code>&lt;body&gt; &lt;form id="form1"&gt; &lt;div style="background-color:gray;"&gt; &lt;div id="div1" style="width:300px; background-color:blue;"&gt; &lt;button onclick="hideDiv2()"&gt;&lt;/button&gt; &lt;/div&gt; &lt;div id="div2" runat="server" style="width:300px; background-color:black; display:none;"&gt;test&lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p></p>
javascript
[3]
5,831,417
5,831,418
Loop json parsed data
<p>I have this data:</p> <pre><code>[ [ {"id":"1", "sentiment":"0", "name":"Company 1", "count":"10"}, {"id":"2", "sentiment":"0", "name":"Company 2", "count":"5"}, {"id":"3", "sentiment":"0", "name":"Company 3", "count":"7"} ], [ {"id":"1", "sentiment":"1", "name":"Company 1", "count":"3"}, {"id":"2", "sentiment":"1", "name":"Company 2", "count":"2"}, {"id":"3", "sentiment":"1", "name":"Company 3", "count":"4"} ] ] </code></pre> <p>How can I loop through this data in order to have two tables as shown below: </p> <pre><code>id Company sentiment count 1 Company 1 0 10 2 Company 2 0 5 3 Company 3 0 7 id Company sentiment count 1 Company 1 1 3 2 Company 2 1 2 3 Company 3 1 4 </code></pre> <p>I have started this but got stuck: </p> <pre><code>var obj = JSON.parse(data); $.each(obj, function(i, obj_item){ $.each(obj_item, function(j, item){ // got stuck here }) }) </code></pre> <p>Any help would be appreciated. Thanks</p>
jquery
[5]
4,103,321
4,103,322
How decode url to windows-1251 in python
<p>How decode url to windows-1251 in python 2.7 and python 3.2?<br> Example:</p> <pre><code>a = "пример" urllib.quote_plus(a) '%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D1%80' (unicode) </code></pre> <p>How to make It in windows-1251 (%EF%F0%E8%EC%E5%F0)</p>
python
[7]
4,851,609
4,851,610
cover flow in iphone
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/718984/open-source-iphone-coverflow-like-library">Open source iPhone Coverflow like library</a> </p> </blockquote> <p>hello all i want to develop cover flow application in my native iphone application please guide me how could i do that </p> <p>thanks in advance</p>
iphone
[8]
5,094,535
5,094,536
Class member functions static and private
<p>Does it make sense to have some class member function say f() both private and static? e.g.</p> <pre><code>class MyClass { ... private: static int foo(); } </code></pre> <p>Thanks.</p> <p>Hi thanks for all your comments! Ok, I got it. Yes, indeed initially I started using static functions in my class because they were not related to the objects of my class- were doing some other operations. Now I also realized they needn't be public. So, I think I'll leave them like this. I started to get some errors when I removed static keyword (apparently due to the way it was used throughout class, so I am lazy now to fix those, will just make it private and leave static :)).</p>
c++
[6]
4,656,455
4,656,456
Java: How do I check if array has been initialized?
<p>I want to check if a certain element in an array has been initilized, how can I do this?</p>
java
[1]
546,372
546,373
Can't store too lengthy int type
<p>Consider the problem:</p> <pre><code>It can be shown that for some powers of two in decimal format like: 2^9 = 512 2^89 = 618,970,019,642,690,137,449,562,112 </code></pre> <p>The results end in a string consisting of 1s and 2s. In fact, it can be proven that for every integer R, there exists a power of 2 such that 2K where K > 0 has a string of only 1s and 2s in its last R digits.</p> <p>It can be shown clearly in the table below:</p> <pre><code>R Smallest K 2^K 1 1 2 2 9 512 3 89 ...112 4 89 ...2112 </code></pre> <p>Using this technique, what then is the sum of all the smallest K values for 1 &lt;= R &lt;= 10? Proposed sol: Now this problem ain't that difficult to solve. You can simply do int temp = power(2, int) and then if you can get the length of the temp then multiply it with</p> <pre><code>(100^len)-i or (10^len)-i </code></pre> <p>// where i would determine how many last digits you want.</p> <p>Now this <strong>temp = power(2,int) gets much higher with increasing int that you can't even store it in the int type or even in long int</strong>.... So what would be done. And is there any other solution based on bit strings. I guess that might make this problem easy. Thanks in advance.</p>
c++
[6]
5,680,836
5,680,837
list within a list within a list in python
<p>I wrote this but I don't understand why it is not working. By the way I am a beginner in programming.</p> <pre><code>fav_colours=[["bob"["likes:blue, hates:red"]],["john"["likes:red,hates:black"]], ["adam"["likes:purple,hates:pink"]]] print fav_colours </code></pre> <p>I don't think there is any error.Thanks in advance.</p>
python
[7]
373,415
373,416
MVC pattern with SimpleData ( mapping class )
<p>I writing application based on database and framework SimpleData. This is my classes:</p> <pre><code>public class Clients { public int ID_C { get; set; } public string Corporation { get; set; } public string Name { get; set; } public string Surname { get; set; } public string Note { get; set; } public DateTime Date { get; set; } } class E_mail { public int ID_E { get; set; } public int ID_C { get; set; } public string E__mail { get; set; } public string Note { get; set; } } </code></pre> <p>When I want add recrod to database ( Client or E_mail ) - it is ok because this classes represent two table in database. Class Clients is ok because my viewClients needs all atributes from Clients but viewEmail needs only Name ( from Clients ) and E__mail ( from E_mail Class ). How I can present model for viewEmail?? Create new class(this is bad).</p> <p>Example:</p> <pre><code> Controller: List&lt;Clients&gt; ListClients = new List&lt;Clients&gt;(); public void LoadView() { var con = Database.Open(); ListClients = con.ShowAllClients(); //This is stored procedure in database. _clientsView.AddClientsToGrid(ListClients); } View: public void AddClientsToGrid(List&lt;Clients&gt; listClients) { listView1.BeginUpdate(); for (int i = 0; i &lt; listClients.Count; i++) { ListViewItem item = new ListViewItem(new string[] { listClients[i].ID_C.ToString(), listClients[i].Corporation, listClients[i].Name, listClients[i].Surname, listClients[i].Date.ToShortDateString() }); listView1.Items.Add(item); } listView1.EndUpdate(); } </code></pre> <p>Thanks for advanced.</p>
c#
[0]
2,845,952
2,845,953
DataTable.Select() Distinct then add values
<p>I just need to SELECT Distinct values from columnA then ADD the values that has joined to columnB</p> <p>Sample:</p> <pre><code>columnA | columnB A 3 B 4 A 3 A 2 B 1 C 3 </code></pre> <p>Result:</p> <pre><code>columnA | columnB A 8 B 5 C 3 </code></pre> <p>i found <a href="http://stackoverflow.com/questions/1199176/how-to-select-distinct-values-from-datatable">this</a> but it just have the array of column names as parameter.</p> <p>is there any other way or a sample using DataTable.Select()</p> <p>Thanks in advance</p>
c#
[0]
3,702,378
3,702,379
Autocreate object when property is called
<p>Im wondering if there is a way to autocreate object if a property is called. An example:</p> <pre><code>&lt;?php echo $myObj-&gt;myProperty ?&gt; </code></pre> <p>This code will of course fail because i did not initiate $myObj before reading the property. What im looking for is a way to automaticly initiate $myObj based on "myObj".</p> <p>Something like:</p> <pre><code>&lt;?php class myObj { public myProperty = 'BlaBla'; } echo $myObj-&gt;myProperty; //outputs BlaBla instead of failing ?&gt; </code></pre> <p>I know about __autoload($classname) but that only works of initiating classcode with i.e. an include(), so that is not what im after.</p>
php
[2]
5,524,646
5,524,647
java find a biginteger within specific range
<p>Im developing an application with java which needs to find two big integers (Y and Z) that meet this two conditions:</p> <pre><code>Y^k &lt; N and Z^j &lt; N &lt; Z^(j+1) </code></pre> <p>N, k and j are known. N is a big integer(1024bit). </p> <p>My current implementations finds Y and Z by choosing a random BigInteger and tests if the conditions are met. But the problem is that sometimes it takes really long to find the solution or it doesn't find one at all (probably the bitSize isn't correctly computed). Is there any way i could speed this up?</p> <p>The code:</p> <pre><code>BigInteger getMessage(int bitSize, int lowerBound, int upperBound, BigInteger module) { boolean foundOne = false; BigInteger candidate = null; while( !foundOne ) { candidate = new BigInteger(bitSize,random); foundOne = (upperBound == 0 || candidate.pow(upperBound).compareTo(module) &gt; 0 ) &amp;&amp; (lowerBound == 0 || candidate.pow(lowerBound).compareTo(module) &lt; 0); } return candidate; } </code></pre>
java
[1]
901,774
901,775
onActivityResult() Intent data is always null
<p>Can somebody tell my why the <code>Intent data</code> is always null?</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { if (requestCode == UPDATE_PROFILE_REQUEST_CODE) { if (data != null) { User user = (User) data.getExtras().getSerializable(USER_DATA_EXTRA); if (user != null) { notifyNeedUpdate(user); } } else { Log.e("Dev", "data is null"); } } } </code></pre> <p>}</p> <p>and this is how I set the result:</p> <pre><code>setResult(RESULT_OK, getIntent().putExtra(ProfileActivity.USER_DATA_EXTRA, constructUser())); </code></pre> <p><code>constructUser()</code> just creates an Object I need.</p> <p>I always get <code>Log.e("Dev", "data is null");</code>. </p>
android
[4]
168,861
168,862
Pass a variable from one file to another c#
<p>I have two .cs files (<code>Hex2Bin.cs</code> and <code>Program.cs</code>) and I want to pass the variable <code>end_addr</code> from <code>Program.cs</code> to <code>Hex2Bin.cs</code></p> <p>My code in Program.cs:</p> <pre><code>class Program { enum to_exit { exit_ok = 0, exit_invalid_args, exit_to_few_args, exit_invalid_input_file, exit_invalid_args_file, exit_permission_denied, exit_unexpected_eof }; // class value holders static String args_file_name = ""; static String in_u1_name = ""; static String in_u22_name = ""; static String out_name = ""; static short end_addr = 0x0000; // 4-digit Hexadecimal end address static Byte[] version_code = { 0, 0, 0, 0 }; // 3 bytes version, 1 for extra info } </code></pre> <p>Is there anyway I could do this? I know how to do it in c, but I'm very new to c#. Thanks.</p>
c#
[0]
2,270,879
2,270,880
How to remove black border from AlertDialog builder
<p>Actually i have created an custom dialog using AlertDialog.builder.In this dialog i am not displaying the titile.All works fine but there is an black border appear in the dialog.so can anyone tell me how can i remove this black boder.The code and screenshot are below.</p> <p><strong>code in java:</strong></p> <pre><code> AlertDialog.Builder start_dialog = new AlertDialog.Builder(this); Context mContext = getApplicationContext(); LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.custom_dialog2, (ViewGroup) findViewById(R.id.layout_root)); layout.setBackgroundResource(R.drawable.img_layover_welcome_bg); Button btnPositiveError = (Button)layout.findViewById(R.id.btn_error_positive); btnPositiveError.setTypeface(m_facedesc); start_dialog.setView(layout); final AlertDialog alert = start_dialog.create(); alert.show(); btnPositiveError.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { alert.dismiss(); } }); </code></pre> <p><strong>ScrrenShot</strong></p> <p><img src="http://i.stack.imgur.com/ZxPWr.png" alt="enter image description here"></p>
android
[4]
1,825,603
1,825,604
Errors while using VideoView in Android
<p>The following sample code I am using from the API demo app for playing the streaming videos</p> <p>public class VideoViewDemo extends Activity {</p> <pre><code>/** * TODO: Set the path variable to a streaming video URL or a local media * file path. */ private String path = ""; private VideoView mVideoView; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.videoview); mVideoView = (VideoView) findViewById(R.id.surface_view); if (path == "") { // Tell the user to provide a media file URL/path. Toast.makeText( VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show(); } else { /* * Alternatively,for streaming media you can use * mVideoView.setVideoURI(Uri.parse(URLstring)); */ mVideoView.setVideoPath(path); mVideoView.setMediaController(new MediaController(this)); mVideoView.requestFocus(); } } </code></pre> <p>}</p> <p>I faced the following errors.</p> <p>i> While playing the videos , if an incoming call comes &amp; the user receives &amp; then disconnects the call , then a black screen is displayed &amp; the video is no longer played again.</p> <p>2> Similarly if an user rejects an incoming call , a black screen is displayed &amp; the video is no longer played.</p> <p>3> When a low battery error message is displayed while a video is being played &amp; the user clicks on OK button of the error message , a black screen is displayed &amp; the video is no longer played.</p> <p>4> When an incoming SMS comes while viewing the streaming video &amp; the user views the SMS &amp; closes it , a black screen is displayed &amp; the video is no longer played.</p> <p>Kindly provide me the suggestions/sample code to handle the conditions to solve the errors.</p> <p>Warm Regards,</p> <p>CB</p>
android
[4]
2,623,836
2,623,837
Prevent imagecreatefromjpeg from stopping script
<p>I am using imagecreatefromjpeg on a shared host, so if the image is to big then imagecreatefromjpeg will give me an "out of memmory error" and terminate the script.</p> <p>Is there anyway to catch the out of memmory error, and simply let imagecreatefromjpeg fail(Return false) instead of terminating the script?</p>
php
[2]
1,701,899
1,701,900
Maintain usercontrol state accross pages
<p>i want to maintain user control state accross two to three pages,</p> <p>how can i do it?</p> <p>that two to three pages have same user control(with out session)</p> <p><em>flow</em></p> <p>i have two pages one for listing page ,whaen clicking on any listing goes to detail page so with these two pages left side i am using search user control.</p>
asp.net
[9]
3,415,587
3,415,588
How to call .html() within .html()?
<p>I need to create something like this. when I click on an image, it will fire the script below.</p> <pre><code>$("#txtHint").html("&lt;form action='inline_spec.php' id = 'upLoadForm' method='post' enctype='multipart/form-data'&gt;&lt;center&gt;&lt;input type='text' id='file' name = 'file' style='visibility:show' &gt;&lt;/center&gt;&lt;/form&gt;"); </code></pre> <p>the script will open an text file input form. Upon submit the form, I need to display the result in txtHint. Is it possible?</p>
jquery
[5]
1,065,431
1,065,432
Decrement 2 in For C++
<p>I decrement a number twos, but over all I can do FOR 1.</p> <p>How I can do? Here is the basic FOR</p> <pre><code>for (i=n;i&gt;0;i--) </code></pre> <p>But decrement 1. </p> <pre><code>int main(int argc, char *argv[]) { int n,i,e; char op; cout&lt;&lt;"ingrese un numero para realizar las operaciones descriptas a continuacion :"&lt;&lt;endl; cin&gt;&gt;n; cout&lt;&lt;"Su numero es : "&lt;&lt;n&lt;&lt;endl; cout&lt;&lt;"Este programa mostrara una lista de los numeros pares menores a su numero.\n\n\tEn que forma desea ver la lista? "&lt;&lt;endl; cout&lt;&lt;"\t \t a)De manera creciente"&lt;&lt;endl&lt;&lt;"\t \t b)De manerda decreciente "&lt;&lt;endl; cin&gt;&gt;op; if (op=='a') { if (n%2==0){ cout&lt;&lt;"El numero que usted ingreso es par "&lt;&lt;endl; for (i=n;i&gt;0;--i) { cout&lt;&lt;i&lt;&lt;endl; } } } </code></pre>
c++
[6]
5,149,136
5,149,137
Show time from microtime in top of page
<p>I am using microtime to get the script execution time</p> <pre><code>$time_start = microtime(true); .... .... //many process here, many result be printed here $time_end = microtime(true); $time = substr(($time_end - $time_start),0,5); echo time; </code></pre> <p>is it possible to print <code>$time</code> in above of result page? I've tried using css too, too print it in above, but, <code>$time</code> still be printed in the bottom of resul page. </p>
php
[2]
5,861,472
5,861,473
How to get numerical value from String containing digits and characters
<p>Is there any built in method to get which can parse int from string ("23px")?</p> <p>I know I can use <code>substring</code> and then <code>parseInt</code> but I want to know if there is any other way available to do this.</p>
javascript
[3]
627,472
627,473
forward declaration of class in c++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1885471/c-forward-declaration-of-class-doesnt-seem-to-work">C++: Forward declaration of class doesn&#39;t seem to work?</a> </p> </blockquote> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; class BigObject; using namespace std; int main(int argc, char *argv[]) { BigObject one; string str = "this is a stirng"; cout&lt;&lt;str; } class BigObject { public: BigObject(){ cout&lt;&lt;"big object \n"; } virtual ~BigObject(){} }; </code></pre> <blockquote> <p>Untitled.cpp:8:12: error: variable has incomplete type 'BigObject'</p> <p>BigObject one;</p> <p>^ Untitled.cpp:5:7: note: forward declaration of 'BigObject' class BigObject;</p> <p>^ 1 error generated.</p> </blockquote> <p>Why this can't be compiled? </p>
c++
[6]
5,505,293
5,505,294
how to use include tag for setting herder in all activity android?
<p>i want toe create common template for my android application.i don't know how? some body told use include tag.I need some example for this.</p>
android
[4]
1,741,755
1,741,756
Build android source in user mode
<p>I want to build the android sdk in user mode .Could any one guide me in this.Please tell me the steps in achieving this.</p> <p>Thanks in advance</p>
android
[4]
4,018,022
4,018,023
Android ServerSocket Authentication, how?
<p>I made a serversocket, what is connected to my WIFI's inner IP. 192.168...:8080</p> <p>i'd like to make a basic authentication, how Can i do that? (name, pass authentication)</p>
android
[4]
2,009,039
2,009,040
write formated file
<p>I want to to write <code>np.double</code> to formated file:</p> <pre><code>import numpy as np a='12 45 87 34 65'; s=np.double(a.split()) fid=open('qqq.txt','wt') fid.write('%5.1f %5.1f %5.1f %5.1f %5.1f ' %(s[0],s[1],s[2],s[3],s[4])) fid.close() </code></pre> <p>Can this "write" row be written in a shorter way?</p> <pre><code>fid.write('%5.1f %5.1f %5.1f %5.1f %5.1f ' %(s[0],s[1],s[2],s[3],s[4])) </code></pre>
python
[7]
2,612,649
2,612,650
change the image name in php
<p>hello i have the following code to change the image name of upload picture <pre> $TARGET_PATH="pics/"; $TARGET_PATH =$TARGET_PATH . basename( $_FILES['photo']).'.jpg'; while (file_exists($TARGET_PATH)) { $TARGET_PATH =$TARGET_PATH . basename( $_FILES['photo']) . uniqid() . '.jpg'; }</pre></p> <p>This change the name of image or file but dont sho the extention it just show dot(.) at end of name i.e 1=>file.<br/>2=>filefile9534803.</p>
php
[2]
4,838,101
4,838,102
javascript syntax $
<p>i'm reading a javascript source code , and i haven't written javascript before. i'm confused about some syntax of it. </p> <pre><code>&lt;script id="source" language="javascript" type="text/javascript"&gt; $(function () { window.onload=function() { mkAjaxObj(0,0); } }); &lt;/script&gt; </code></pre> <p>could you tell me , why the anonymous function is putted in the $( ), what is the use of $( ) , is the anonymous function will be called ? or will be execute automatically.</p> <p>another one :</p> <pre><code>var plot = $.plot($("#placeholder"), [ { data: monkeyavgtime, label: "monkey average run time"}, { data: monkeymixtime, label: "monkey shortest run time" } ], { series: { lines: { show: true }, points: { show: true } }, grid: { hoverable: true, clickable: true }, yaxis: { min: 0, max: maxtime }, xaxis: {ticks:[[0,version[0]],[1,version[1]],[2,version[2]], [3,version[3]], [4,version[4]],[5,version[5]],[6,version[6]]]} }); </code></pre> <p>1 : $.plot , what $. stand for ?</p> <p>2 : $("#placeholder") there is a tag in the html : <br> dose $("#placeholder") is a reference to it ? but is there any different with var obj=document.getElementById("product") ?</p> <p>thanks very much !</p>
javascript
[3]
2,415,107
2,415,108
How to implement search function on Android?
<p>I am trying to have a simple search function be it a bar or what ever with suggestion or do you call it autocomplete. And when i tab/click on these suggestions, it brings me to the xml(layouts) pages i already created.</p>
android
[4]
3,327,779
3,327,780
Adding calendar source files in Java problem
<p>I am trying to create a calendar instance.</p> <p>I have imported the java.util.calendar but when I mouse over my code to create a calendar instance, it tells me that it cannot find the element in the attached javadoc or the source file.</p> <p>From researching on google, I tried adding rt.jar but it hasn't changed anything.</p> <p>When I look at the Calendar Class Editor, it tells me (apart from not finding the source):</p> <pre><code> "// (version 1.5 : 49.0, super bit) // Signature: Ljava/lang/Object;Ljava/io/Serializable;Ljava/lang/Cloneable;Ljava/lang/Comparable&lt;Ljava/util/Calendar;&gt;; public abstract class java.util.Calendar implements java.io.Serializable, java.lang.Cloneable, java.lang.Comparable {..." </code></pre> <p>I have tried to look for these jar files on the computer too and I cannot find them. Does anyone know what I need to attach to resolve this problem?</p> <p>Code Snippet:</p> <pre><code> import java.util.*; ..... Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE,2); ..... </code></pre>
java
[1]
4,769,692
4,769,693
in java how to make sure the passed object is modified by only object to which it is passed?
<p>Suppose that I have a class which takes an array of Key object to construct an object of class keyHandler, like this:</p> <pre><code>class KeyHandler { Key[] keys; public KeyHandler(Key[] keys) { this.keys=keys } //more methods which modify key; } </code></pre> <p>now I call this constructor from main</p> <pre><code>KeyHandler keyhandler = new KeyHandler(keys); </code></pre> <p>I want to make sure that keys array is not modified from main(). How can I do this?</p>
java
[1]
1,925,854
1,925,855
How can I use / in strings in java?
<p>I would like to know how I can use <code>/</code> in java because it doesn't consider it as a simple <code>/</code> .</p>
java
[1]
2,624,275
2,624,276
looping .load jquery setting rel
<pre><code>var resultValue = $("#"+temp+" .panId").val(); for(var i=0; i&lt;totalPanel;i++) { $("#"+temp+" .panelDiv").append('&lt;div class="panelDiv' + resultValue + '"&gt;&lt;/div&gt;'); $("#"+temp+" .panelDiv" +resultValue ).load("Panel.html #w", function(){ $(".panelDiv"+(resultValue-1)+" .txtWidth").attr('rel',resultValue-1); $(".panelDiv"+(resultValue-1)+" .txtHeight").attr('rel',resultValue-1); $(".panelDiv"+(resultValue-1)+" .btnRemovePanel").attr('rel',resultValue-1); }); resultValue++; $("#"+temp+" .panId").val(resultValue); } </code></pre> <p>Basically i trying to trigger a load function. after the load function is trigger i want to set a rel &lt;- into each so if my for loop loop 5 time rel will be 1 2 3 4 5 but now it is being set as 5 5 5 5 5 because .loop callbackfunction only execute after the loop is complete then it is being load.therefore my value resultValue is at the max of the value. how can i solve by setting rel 1 2 3 4 5.</p>
jquery
[5]
3,031,022
3,031,023
Notifications in android by comparing the system time with database values using background service
<p>I am developing an android app.I wan to provide five notifications per day.I will store the notification time in sqlite database.Then I compare this db notification time with the devices time in a repeating loop using service.But the notification will not work properly.Forceclose appeared.....I need the help</p>
android
[4]
3,693,346
3,693,347
Searching text files to get specific double
<p>I am writing a bank account program for my Comp Sci class, and need to search a .txt file for a account number a user enters (which is an int) and then pull out the next row which is the balance. i.e. the user enters the account #12345679 and i need to pull out the balance of it. Below is an example of the txt file</p> <pre><code>12345678 133.87 12345679 500.00 12345670 123.00 </code></pre> <p>So far I have and I know that i'm going to have to put how to get the balance in the if statment</p> <pre><code>while (accountTries &lt; 3) { System.out.println("Please enter your 8 digit account number"); accountNumber = console.next(); accountLength = accountNumber.length(); while (in.hasNextInt()) { line = in.hasNextInt(); if (accountLength == 8 &amp;&amp; line == accountNumber ) { accountTries = 3; } } System.out.println("INVALID ACCOUNT NUMBER."); accountTries++; } }//End of while loop </code></pre>
java
[1]
2,356,643
2,356,644
How to find an element with a specific "left" value in jQuery
<p>So lets say i have the following html:</p> <pre><code>&lt;div class="con"&gt; &lt;ul&gt; &lt;li class="a"&gt;1&lt;/li&gt; &lt;li class="b"&gt;2&lt;/li&gt; &lt;li class="c"&gt;3&lt;/li&gt; &lt;li class="d"&gt;4&lt;/li&gt; &lt;li class="e"&gt;5&lt;/li&gt; &lt;li class="f"&gt;6&lt;/li&gt; &lt;li class="g"&gt;7&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Lets say i have given <code>&lt;li class="g"&gt;</code> an absolute position of <code>-20px</code> (and the containing div <code>.con</code> has a relative position).</p> <p>How would i tell jquery to select the LI element at <code>-20px</code> within the <code>.con</code> div and do an action on it?</p>
jquery
[5]
4,336,162
4,336,163
to show an error message while entering duplicates when column is primary key
<p>As in table named Emp i have Name Column is Primary key,when i add duplicate name like (Bharat Mali) which is already present in database,this record is not get added in database,but showing me this message( employee added successfully) i want to show a message to user like(duplicate values can't be stored). I am using this code behind Add button Click</p> <pre><code>private void button3_Click(object sender, EventArgs e) { DBHandling db = new DBHandling(); if (name.Text.Trim().Equals("")&amp;&amp; name.Text.Trim().Equals("select Emp.name from Emp")) { name.Focus(); MessageBox.Show("Name cannot be blank or same!"); } else if(Payment.Text.Trim().Equals("")) { Payment.Focus(); MessageBox.Show("Payment cannot be blank!"); } else if (!IsNumeric(Payment.Text.Trim())) { Payment.Focus(); MessageBox.Show("Payment should contain Numerical Values!"); } else if(CellNumber.Text.Trim().Equals("")) { CellNumber.Focus(); MessageBox.Show("Cell Number cannot be blank!"); } else if (!IsNumeric(CellNumber.Text.Trim()) || CellNumber.Text.Trim().Length&lt;10) { CellNumber.Focus(); MessageBox.Show("Invalid Cell Number!"); } else if(JoiningDate.Text.Trim().Equals("")) { JoiningDate.Focus(); MessageBox.Show("set Joining Date!"); } else { db.AddEmp(name.Text, Payment.Text, CellNumber.Text, Education.Text, JoiningDate.Text); MessageBox.Show("Employee added successfully!"); } name.Clear(); Payment.Clear(); CellNumber.Clear(); Education.Clear(); name.Focus(); } </code></pre> <p>so how should i do it ,thanks . </p> <p>I am checking PK using this below line of code ,I am not getting any answer for this but not even an error,do you know any other way that how should i do it?</p> <pre><code>if (name.Text.Trim().Equals("")&amp;&amp; name.Text.Trim().Equals("select Emp.name from Emp")) { name.Focus(); MessageBox.Show("Name cannot be blank or same!"); } </code></pre>
c#
[0]
2,915,240
2,915,241
Easy way (with out eval) to turn a passed string into an object refereance in JS?
<p>So let's say I have a in page function:</p> <pre><code>&lt;img src="someImage.jpg" onclick="doSomething(this.id)" id="someVar" alt="blah" /&gt; </code></pre> <p>and I have a class set up:</p> <pre><code>function anObject(someProp) { this.someProp=someProp; } someVar=anObject("prop"); </code></pre> <p>Where I have trouble is in the doSomething function:</p> <pre><code>function doSomething(theObject) { alert(theObject.someProp); //this is treated as "someVar".someProp as far as I can tell instead of someVar.someProp } </code></pre> <p>Basically, I would like to be able to use that reference as an object reference instead of a string, is there an easy way to do this without eval?</p> <p>Also is there some way to ensure the oppisite, that it is treated as a string instead of an object?</p> <p><strong>EDIT: I am attempting to reference the object with the same name as the image's ID NOT the image itself.</strong></p>
javascript
[3]
1,426,469
1,426,470
Question about references
<p>I think the following is really basic but I don't really get what would be the "advantages" of one of these code.</p> <p>Having this:</p> <pre><code>int main() { int a = 10; f(a); return 0; } </code></pre> <p>What would be the difference between</p> <pre><code>void f(int&amp; a) { int&amp; b = a; } </code></pre> <p>and</p> <pre><code>void f(int&amp; a) { int b = a; } </code></pre> <p>In particular, in the case where <code>f</code> would instead be the constructor of a class and where instead of an <code>int</code> we have a big object.</p> <p>I would go with the second possibility... What do you think ?</p> <p>Thanks.</p> <p><strong>Edit:</strong></p> <p>First, looking at the answers, I though I was brain dead when I posted the question, but actually I found interesting subquestions (and answers !) in the comments.</p>
c++
[6]
2,552,558
2,552,559
Caller function in PHP 5?
<p>Is there a PHP function to find out the name of the caller function in a given function?</p>
php
[2]
1,694,848
1,694,849
Create folder during application installation in android
<p>Can we create a directory on the internal storage of the device during application installation .Also after creating that i need to copy some images and music to that directory from our res folder. Does anyone have any ideas as to create a directory at install time? Thanks in advance </p>
android
[4]
5,305,319
5,305,320
Multiply 2 input fields on keyup?
<p>I've got 2 fields </p> <pre><code>&lt;input id="E_Item1" name="E_Item1"&gt; &lt;input id="E_CCNM" name="E_CCNM"&gt; </code></pre> <p>In JQuery, how would I go about multiplying the values of these fields together on keyup into a div?</p>
jquery
[5]
5,308,432
5,308,433
Jquery .flv player
<p>I already google this but unfortunately couldn't find any answer! can you please let me know if you are aware of any jQuery plugin or tuto which is able to display ".flv" videos? I have lots of .flv video and no time to convert them to other html5 supported formats.</p> <p>Thanks alot</p>
jquery
[5]
198,930
198,931
How to remove strings with numbers and special characters using javascript regular expressions?
<pre><code>var string = "[Account0].&amp;[1]+[Account1].&amp;[2]+[Account2].&amp;[3]+[Account3].&amp;[4]"; var numbers = string.match(/(\d+)/gi); alert(numbers.join(',')); </code></pre> <p>here outpout is : 0,1,1,2,2,3,3,4</p> <p>Here I need to elimanate all the strings with numbers and special characters.</p> <p>can you please help me,is there any solution for the output : 1,2,3,4</p> <p>Thanks,</p> <p>Rajasekhar</p>
javascript
[3]
2,707,329
2,707,330
Accessing object properties by variable
<p>I've seen this asked before, but my particular case appears to be someone odd, and I'm unable to resolve it - any insight would be appreciated.</p> <p>I'm trying to access an object property with a variable value, ie.</p> <pre><code>$foo = new Object(); $foo-&gt;first = 'bar'; $array = array(0 =&gt;'first', 1 =&gt;'second'); $var = 0; return $foo-&gt;{$array[$var]}; </code></pre> <p>This is throwing an error "Notice: Undefined property: stdClass::$first". Removing the braces returns an identical result.</p> <p>What don't I understand? (Actual code and error below - the error is as recorded in a Drupal Watchdog log.)</p> <pre><code>private function load_questionnaire_queue($type, $comparator_id, $comparing_id_array) { $queue = array(); $type_map = array( 0 =&gt; "field_portfolio_district['und'][0]['nid']", 1 =&gt; "field_time_period['und'][0]['tid']", ); foreach ($this-&gt;questionnaires as $q) { // The commented code below works as expected // if ($q-&gt;field_portfolio_district['und'][0]['nid'] == $comparator_id &amp;&amp; // in_array($q-&gt;field_time_period['und'][0]['tid'], $comparing_id_array)) // This returns an identical error, with or without braces: if ($q-&gt;{$type_map[$type]} == $comparator_id &amp;&amp; in_array($q-&gt;{$type_map[!$type]}, $comparing_id_array)) { $queue[] = node_view($q, $view_mode = 'full'); } } $this-&gt;queue = $queue; } </code></pre> <blockquote> <p>Notice: Undefined property: stdClass::$field_portfolio_district['und'][0]['nid'] in ComparisonChart->load_questionnaire_queue()</p> </blockquote>
php
[2]
1,974,916
1,974,917
script is send then Page is not redirect
<p>If click the submit button, then this code should execute, but this is not working.</p> <pre><code>header('Location: http://www.yourtargeturl.com'); //script api echo '&lt;script&gt;window.open("'.$_SERVER['PHP_SELF'].'","_self")&lt;/script&gt;'; </code></pre>
php
[2]
4,669,373
4,669,374
convert .gif image from an url to .png
<p>how to convert .gif image from an url to .png ?, i have a url containing .gif images. Do simulator support .gif image?</p> <pre><code>self.imageView.image = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: [dic objectForKey:@"PictureURL"]]]]; </code></pre>
iphone
[8]
1,119,922
1,119,923
JavaScript - Get calling object
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/280389/javascript-how-do-you-find-the-caller-function">Javascript how do you find the caller function?</a> </p> </blockquote> <p>Hi guys!</p> <p>Is there a way to get the value of <code>this</code> from the function which has called the current function? Look at this:</p> <pre><code>function TraceMySelf(){ console.log(this); } function A(){ TraceMySelf(); console.log(this); } var a = new A(); </code></pre> <p>When this code is executed, the console displays first the <code>window</code> object and then the <code>a</code> object. How can I make the code display the <code>a</code> object twice, with only changing line 2? I know that I could apply the function inside <code>A</code> with <code>this</code>, but that isn't what I want.</p> <p>Is this possible?</p> <p>Thanks for your help!</p>
javascript
[3]
2,743,064
2,743,065
Switching out an object's prototype
<p>I'm trying to understand how prototypes work. Why does the following break?</p> <pre><code>var A = function A(){this.a = 0}, aa = new A; A.prototype = {hi:"hello"}; aa.constructor.prototype //-&gt;{hi:"hello"} ok so far :) aa.hi //undefined?? why? :( </code></pre> <p>Thanks in advance!</p>
javascript
[3]
5,111,183
5,111,184
Closure confusion
<p>I am having some confusion regarding this Closure thing. I have two separate codes below that look similar but their output are different. </p> <pre><code>function setup(x) { var array = []; for(var i=0;i&lt;arguments.length;i++){ array[i]= arguments[i]; } return array; } console.log(setup('a','b')); // will output ["a","b"] -------------- function f() { var i, array = []; for(i = 0; i &lt; 3; i++) { array[i] = function(){ return i; } } return array; } var a = f(); console.log(a()); //output: [function(),function(),function()] console.log(a[0]()); //output: 3 //same output in a[1]() and a[2]() calls as well </code></pre> <p>Now my question is, how come the output is different? both of the codes above return an array. in the first code, it prints all elements in array correctly whereas in the second code, why doesn't it print [1,2,3]??? </p>
javascript
[3]
513,254
513,255
Crashing issue in differnt Kernel version of Android SDk 2.2
<p>I have my application working fine with : Firmware Version : 2.2 Model Number GT-P1000 Kernel Version 2.6.32.9 root@SE-S605 #4 Build Number :FROYO.DDJK3</p> <p>But same application is getting crash with details:</p> <p>Firmware version 2.2 Build number FROYO.VFJM2 Kernel version 2.6.32.9 root@SEI-27#1</p> <p>The crash is due to database. Can anyone help me out of these?? Thanks in Advance..</p>
android
[4]
3,784,056
3,784,057
how do I check image size in android while uploading from phone gallery?
<p>i want to check image size once user select an image from gallery.Because big size images are not allowed in my app. Can anyone help me ?</p>
android
[4]
1,261,465
1,261,466
Using (void)awakeFromNib
<p>I am trying to run an action when the application starts. The action checkAtStart is supposed to display an alert if there is no text in field1 and hide startView if there is text in field1. checkAtStart works fine if assigned to a button, but when I try to run it using (void)awakeFromNib, the alert will display no matter what and startView will never hide. Its probably something really simple that I'm forgetting. Any help is appreciated!</p> <p>Here is my code:</p> <pre><code>- (void)awakeFromNib { [self checkAtStart:self]; } - (IBAction)checkAtStart:(id)sender { if (field1.text == nil || [field1.text isEqualToString:@""]) { NSString *msg = nil; msg = nil; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Test Message" message:@"Test Message" delegate:self cancelButtonTitle:@"Close" otherButtonTitles: nil]; [alert show]; [alert release]; [msg release]; } else { startView.hidden = YES; } } </code></pre>
iphone
[8]
2,918,694
2,918,695
How to hide ajax modal popup extender when clicking browser's back button?
<p>I have shown one confirmation message using ajax modal pop up extender during button click in server side in asp.net. After showing that confirmation message, when i click browser's back button, the same pop up confirmation message coming again. How to hide that pop up message when i click browser's back button?</p> <p>My Code is </p> <pre><code> &lt;asp:Button ID="btnShowPopup" runat="server" Style="display: none" /&gt; &lt;asp:Panel runat="server" ID="pnlInterfaceDetails" Style="display: none;"&gt; &lt;asp:Label ID="Label1" runat="server" Text="Confirmation Message" Font-Bold="true" Font-Size="10pt" Style="color: White; font-family: Sans-Serif Verdana Arial"&gt;&lt;/asp:Label&gt; &lt;table&gt; &lt;tr style="height: 35px"&gt; &lt;td colspan="2"&gt; &lt;b&gt;&lt;span style="color: Black;"&gt;Data Saved Successfully.&lt;/span&gt;&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr style="height: 35px"&gt; &lt;td align="center" colspan="2"&gt; &lt;asp:Button runat="server" ID="btnConfirmClose" Text="Close" ToolTip="Close" Width="65px" OnClick="btnConfirmClose_Click" CssClass="buttonOrangebg" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/asp:Panel&gt; &lt;asp:ModalPopupExtender runat="server" ID="mpeInterfaceDetails" TargetControlID="btnShowPopup" BackgroundCssClass="modalBackground" PopupControlID="pnlInterfaceDetails" /&gt; &lt;/div&gt; </code></pre>
asp.net
[9]
4,939,978
4,939,979
python function that modifies parameters
<pre><code>def add(a,b): for i in range(len(a)): a[i] = a[i] + b def main(): amounts = [100,200] rate = 1 add(amounts,rate) print amounts main() </code></pre> <p>The function add does not have a return. I read that changes are available to only mutable objects like list. But why did the person omits the return? Either with or without return is fine. Why? This is so different from C++.</p> <p>Thanks</p>
python
[7]