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 |
|---|---|---|---|---|---|
4,197,485 | 4,197,486 | How to repeat <h> tag using php | <p>I have a html syntax code as shown below </p>
<pre><code> <h3>Main Category</h3>
<h3>cat2</h3>
<h3>cat3</h3>
<h3>cat4</h3>
</code></pre>
<p>I need to repeat the list tag using php...</p>
<p>I have stored the query result in $cat, how can i repeat the header tag according to this
looking for for loop</p>
| php | [2] |
4,540,260 | 4,540,261 | could not find part of path | <p>i'm trying to convert a <code>DataTable</code> to an excel-file but at the time of creation of file it gives me error: <em>could not find part of path</em>.</p>
<pre><code>string strDirectorypath = HttpContext.Current.Server.MapPath("~/ExcelUpload/");
DateTime dtbatchtime = Convert.ToDateTime(strBatchProcesstime);
strBatchProcesstime = dtbatchtime.ToString("MM-dd-yyyy_hh_mm_ss");
string strFilename = "FailedExcel_" + strBatchProcesstime + ".csv";
string csvdownloadPath = Path.Combine(strDirectorypath, strFilename);
using (FileStream File_Stream = new FileStream(csvdownloadPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
{
using (StreamWriter FileWriter = new StreamWriter(File_Stream))
{
FileWriter.BaseStream.Seek(0, SeekOrigin.End);
string[] columns = { "Opportunity Name", "Property Id", "Error Type", "Error Message", "Time" };//set columns here as in the Excel Sheet.
CreateColumns(FileWriter, columns);
FileWriter.WriteLine();
if (dtRecords.Rows.Count > 0)
{
for (int i = 0; i < dtRecords.Rows.Count; i++)
{
string[] values = {
dtRecords.Rows[i]["OpportunityName"].ToString(),
dtRecords.Rows[i]["PropertyId"].ToString(),
dtRecords.Rows[i]["ErrorType"].ToString(),
dtRecords.Rows[i]["ErrorMessage"].ToString(),
dtRecords.Rows[i]["TimeStamp"].ToString()
};
CreateColumns(FileWriter, values);
FileWriter.WriteLine();
}
}
}
}
</code></pre>
| c# | [0] |
28,718 | 28,719 | Two forward slashes in Python | <p>I came across this sample of code from a <a href="http://en.wikipedia.org/wiki/Radix_sort#Example_in_Python" rel="nofollow">radix sort</a>:</p>
<pre class="lang-py prettyprint-override"><code>def getDigit(num, base, digit_num):
# pulls the selected digit
return (num // base ** digit_num) % base
</code></pre>
<p>What does the '<code>//</code>' do in Python?</p>
| python | [7] |
5,743,396 | 5,743,397 | Is there a way for an Android app to know the name of the APK which installed it? | <p>I wrote a sample on PackageManager, but found only the dir of the app is provided, and renamed it to package-name related. But not the apk file name which installed it.</p>
<p>Is there a way for an Android app to know the name of the APK which installed it?</p>
| android | [4] |
3,164,640 | 3,164,641 | How to receive multiple parts with BeginReceive? | <p>I have problem with reading buffer, when reading is not completed.</p>
<p>If the received XML data is valid, then I have no problem. But when the received XML data is not correct then I am waiting for the second part of the data, and there I get an error.</p>
<p>My code looks like:</p>
<pre><code>int currentDataSize = socket.EndReceive(iar);
string currentData = convertToString(buffer, currentDataSize);
if (IsValidXml(currentData))
{
//Here I am parsing the xml data and writing into the sql db.
runParseWorker(currentData);
//Here I am sending the xml-data to all clients.
runSendWorker(currentData);
//Here I am calling the BeginRecieve Method again.
socket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None,
new AsyncCallback(dataRecievedCallback), null);
}
else
{
//It gives error when I use offset..
socket.BeginReceive(buffer, currentDataSize, buffer.Length, SocketFlags.None,
new AsyncCallback(dataRecievedCallback), buffer);
}
</code></pre>
<p>How can I get the rest of the data and how do I use offset correctly?</p>
<p>I am getting this error:</p>
<pre><code>specified argument was out of the range of valid values. parameter name : size
</code></pre>
| c# | [0] |
1,975,556 | 1,975,557 | How to trace on asp.net page(server side) that user clicked the browser close button | <p>How to trace on asp.net that user clicked on the browser close button.i tried with page unload event but its not fired when user clicked on the browser close button.I need to perform some operation to remove the temp file that time.</p>
| asp.net | [9] |
1,475,165 | 1,475,166 | How can I check string starts with using javascript / jQuery? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/9425533/how-can-i-check-the-start-of-a-string-with-jquery">How can I check the start of a string with jQuery?</a> </p>
</blockquote>
<p>I have the following:</p>
<pre><code>if ($(this).data('action') == "Editing" || $(this).data('action') == "Create")
{
// how to Check ?
}
</code></pre>
<p>How can I check for where Editing or Create are just the first words and not the complete string?</p>
| jquery | [5] |
1,541,613 | 1,541,614 | jQuery return onClick | <p>I want to know if is it possible to do the same javascript code with Jquery:</p>
<pre><code><input type="button" value="Save" onclick="javascript:return CheckPasswords()" />
</code></pre>
<p>What it does is return true or false on user click.</p>
<p>With Jquery I would write:</p>
<pre><code>$(function()
{
$("#btnSalvar").click(function(){
if([...])
{
return false;
}
return true;
});
}
</code></pre>
<p>But i dont know in case return false it would have the same effect.</p>
<p>*<em>UPDATED:</em>*Solution is </p>
<pre><code>$("btnSalvar").click(function(e){
if([...])
{
e.preventDefault();
}
});
</code></pre>
<p>thk you all!</p>
| jquery | [5] |
3,822,520 | 3,822,521 | why can't I programmtically set the imageurl on an Image control? | <p>I have an ASP.NET 2010 app and am trying something very simple. I use Image control through out and basically wanted to say, before I assign an image to it (from a class) look for the image; if it's not there, use the default no_image jpeg I have. I have verified the image is there ad naseum. If I set the property in the IDE to point to this image, it'll display. However, if I set it programmtically, even if I hard-code the path programmatically, it doesn't show. </p>
<p>Forgettign about getting the proper path and all that, (of which Ive tried several things) I can;t even hard code the relative path. Here I copied & pasted the relative path from the properties window...</p>
<pre><code>Image1.ImageUrl = "~/UploadedPictures/Users/no_profile_picture.jpg"
</code></pre>
<p>This doesn't work. It translates into src="../../UploadedPictures/Users/no_profile_picture.jpg" which is correct but the image doesn't display.</p>
<p>If I hardcode the absolute path it doesn't work either...</p>
<pre><code>Image1.ImageUrl = "C:\Inetpub\wwwroot\myApp\UploadedPictures\Users\no_profile_picture.jpg"
</code></pre>
| asp.net | [9] |
1,570,129 | 1,570,130 | Multiple Inheritence Related Confusion in Java | <p>I have confusion in java inheritance. As I studied Java does not support Multiple Inheritance. So that it does not have diamond problem of inheritance at all.</p>
<p>But, every class of Java inherits Object class by default, and if we extend a class then there are two inherited classes first is Object and second is our inherited class. As I know if any class inherits two or more classes, its known as Multiple Inheritance. It shows that java supports multiple inheritance because its inheriting two classes at same time.</p>
<p>Then why its said that java does not support multiple inheritance and is there any possibility to have diamond problem in java? </p>
| java | [1] |
305,642 | 305,643 | How to calculate .MP3 file BPM(Beat per minute) in android | <p>I am working an android application.How to calculate .MP3 file BPM(Beat Per Minute).Please </p>
<p>help me......................</p>
| android | [4] |
2,495,374 | 2,495,375 | object problems in javascript | <p>How can I create object and put in on array so I can use it multiple time I tried like this</p>
<pre><code>var createNew = new enemyMove(id);
</code></pre>
<p>So every Time I use it Iwill have a different values and fields</p>
<pre><code>function enemyMove() {
var enemyimagew = document.getElementById("enemy");
var leftenemy = parseInt(enemyimagew.style.left);
var topenemy = parseInt(enemyimagew.style.top);
if (leftenemy < leftplayer) {
leftenemy = leftenemy + 5;
}
if (leftenemy > leftplayer) {
leftenemy = leftenemy - 5;
}
if (topenemy < topplayer) {
topenemy = topenemy + 5;
}
if (topenemy > topplayer) {
topenemy = topenemy - 5;
}
enemyimagew.style.left = leftenemy + "px";
enemyimagew.style.top = topenemy + "px";
var hit_list = $("#x").collision(".lollol");
hit_list.remove();
}
function enemyMovetow() {
var enemyimage = document.getElementById("enemy2");
var leftenemy = parseInt(enemyimage.style.left);
var topenemy = parseInt(enemyimage.style.top);
if (leftenemy < leftplayer) {
leftenemy = leftenemy + 5;
}
if (leftenemy > leftplayer) {
leftenemy = leftenemy - 5;
}
if (topenemy < topplayer) {
topenemy = topenemy + 5;
}
if (topenemy > topplayer) {
topenemy = topenemy - 5;
}
enemyimage.style.left = leftenemy + "px";
enemyimage.style.top = topenemy + "px";
var hit_list = $("#x").collision(".lollol");
hit_list.remove();
}
</code></pre>
<p>I want this 2 funtion on an array so I wont write another one</p>
| javascript | [3] |
5,723,824 | 5,723,825 | Check version of Python library that doesn't define __version__ | <p>I'm dealing with a Python library that does not define the __version__ variable (<a href="http://code.google.com/p/sqlalchemy-migrate/" rel="nofollow">sqlalchemy-migrate</a>), and I want to have different behavior in my code based on what version of the library I have installed. </p>
<p>Is there a way to check at runtime what version of the library is installed (other than, say, checking the output of <code>pip freeze</code>)?</p>
| python | [7] |
1,979,897 | 1,979,898 | Add mailto link to static email with JQuery | <p>I'm trying to add a mailto link to static email addresses found within a list of results from a database, using JQuery. I was able to find the following excerpt online which works for the first result, but it does not work for any email addresses after the first one.</p>
<p>I'm curious why this is.. and how I can get it to apply the mailto: attribute to every email address found in the results. :-)</p>
<p>Current code:</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
var regEx = /(\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)/;
$("table td").filter(function() {
return $(this).html().match(regEx);
}).each(function() {
$(this).html($(this).html().replace(regEx, "<a href=\"mailto:$1\">$1</a>"));
});
});
</code></pre>
<p></p>
<p>Thanks!</p>
| jquery | [5] |
5,892,553 | 5,892,554 | Cant get javascript DOM selectors to work | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/14028959/why-does-jquery-or-a-dom-method-such-as-getelementbyid-not-find-the-element">Why does jQuery or a DOM method such as `getElementById` not find the element?</a> </p>
</blockquote>
<p>I've been trying to learn js, but im having trouble getting a very simple example to work and i cant seem to find what im doing wrong. From all i understand the below example should work. When i click on the second button, it calls the function f2 and outputs "batman" as an alert, so i know the javascript page is linked correctly. But when i click on the first button nothing happens.</p>
<p>HTML:</p>
<pre><code><head>
<script type="text/javascript" src="Positioning and flow tests.js"></script>
</head>
<body>
<p id="par1">Test</p>
<button onclick="f1()">Click me for par 1 content</button>
<button onclick="f2()">Click me for predefined text</button>
</body>
</html>
</code></pre>
<p>Javascript</p>
<pre><code>// JavaScript Document
var var1 = document.getElementById("par1");
function f1()
{
alert(var1.innerHTML);
}
function f2()
{
alert("batman");
}
</code></pre>
| javascript | [3] |
5,163,926 | 5,163,927 | Moving a small C++ project from XCode to Visual studio. Ceiling/floor unrecognized? | <p>I have a small c++ project I've been working on in XCode, that I'd like to do some work with on my Windows machine, on Visual Studio. I made a new project and copied all of the source files into the new project. There are no external dependencies.</p>
<p>Now, Visual Studio does not like any of my floor or ceil calls. I get the following compiler error for every call to ceil or floor.</p>
<blockquote>
<p>'ceil': ambiguous call to overloaded
function</p>
</blockquote>
<p>These functions are not overloaded, and I've imported math.h in the header file to this .cpp file. What gives?</p>
| c++ | [6] |
318,511 | 318,512 | getting function name in which a Global object was initilized/created | <p>I have a DatePicker class, which is called from different functions at different locations with different options.</p>
<p>Now I have added a selectbox, which loads extra options for DatePicker depending on selected value.</p>
<p>on Selectbox's onchange event I want to refresh the DatePicker, with the extra options.</p>
<p>But as the DatePicker can be called from Different functions, with different options/setting
and the onChange event actually don't knows which function was lastly called, But I have a Global datapicker object.</p>
<p>Is there a way to call the Same function again which was lastely called to display DataPicker?</p>
| javascript | [3] |
1,103,515 | 1,103,516 | How java default API functions call operating system services? | <p>How java default API functions call operating system services through JVM? </p>
| java | [1] |
910,134 | 910,135 | Boolean_conversions Using reinterpret_cast<> | <p>Can any one Give the example for </p>
<pre><code> Boolean_conversions Using reinterpret_cast<>
</code></pre>
<p>Iam getting the execution failure..Any one explain ..</p>
<p>Ex:</p>
<pre><code> void Boolean_Conversions()
{
bool b = 0;
int *i = reinterpret_cast<int*> (&b);
// iam expecting as *i is 0/false ,but it is showing runtime error
}
</code></pre>
<p>Edit:
In ISO Standard
Section $5.2.10, para 1:</p>
<pre><code> "The result of the expression reinterpret_cast<T>(v) is the
result of converting the expression v to type T. If T is a
reference type, the result is an lvalue; otherwise, the re
sult is an rvalue and the l-value to r-value (4.1), array
to pointer (4.2), and function to pointer (4.3) standard c
onversions are performed on the the expression v. Types sh
all not be defined in a reinterpret_cast."
</code></pre>
<p>From this Iam trying ..I did many conversions ..like Array_to_Pointer,Function_To_Pointer,Integral/Pointer_Conversions ,etc...But i don't know why it is failing For Boolean Conversions.</p>
<p>Can any one tell why it is failing ..Otherwise Tell the Boolean COnversions using reinterpret_cast.</p>
<p>Mostly It is Giving Run time failure in G++.CC/EDG/COdepad..etc compilers</p>
<p>Please Explain</p>
| c++ | [6] |
1,284,051 | 1,284,052 | JQUERY copy contents of a textbox to a field while typing | <p>I am trying to copy the contents of a textbox into a div simultaneously while the user is typing. Here is <a href="http://jsfiddle.net/6HmxM/" rel="nofollow">THE CODE ON JSFIDDLE</a>
The error that is am facing is, <strong>the length of the value copied inside the div is always one less than that of the textbox</strong>. what error am i making in the script?</p>
| jquery | [5] |
1,682,900 | 1,682,901 | best way to compare sequence of letters inside file? | <p>I have a file, that have lots of sequences of letters.<br>
Some of these sequences might be equal, so I would like to compare them, all to all.<br>
I'm doing something like this but this isn't exactly want I wanted: </p>
<pre><code>for line in fl:
line = line.split()
for elem in line:
if '>' in elem:
pass
else:
for el in line:
if elem == el:
print elem, el
</code></pre>
<p>example of the file:</p>
<pre><code>>1
GTCGTCGAAGCATGCCGGGCCCGCTTCGTGTTCGCTGATA
>2
GTCGTCGAAAGAGGTCT-GACCGCTTCGCGCCCGCTGGTA
>3
GTCGTCGAAAGAGGCTT-GCCCGCCACGCGCCCGCTGATA
>4
GTCGTCGAAAGAGGCTT-GCCCGCTACGCGCCCCCTGATA
>5
GTCGTCGAAAGAGGTCT-GACCGCTTCGCGCCCGCTGGTA
>6
GTCGTCGAAAGAGTCTGACCGCTTCTCGCCCGCTGATACG
>7
GTCGTCGAAAGAGGTCT-GACCGCTTCTCGCCCGCTGATA
</code></pre>
<p>So what I want if to known if any sequence is totally equal to 1, or to 2, and so on.</p>
| python | [7] |
1,493,954 | 1,493,955 | C# Client Server learning | <p>I would like to know where I can go and learn more about client server C#, XMAL, and MS SQL server programming. I am doing a lot of ASP.NET MVC, Silverlight, and even a lot of PHP/MYSQL MVC with Joomla and Wordpress but I want to learn more about client server.</p>
| c# | [0] |
2,246,869 | 2,246,870 | Access violation writing location? | <p>I am trying to write a function to reverse a string, but I got such exception when I am doing: *str++ = *end; anyone who knows what's the reason? Thanks in advance. </p>
<pre><code>void reverse(char* str)
{
char *end = str;
char temp;
if(str)
{
while(*end)
{
end++;
}
end--;
while(str<end)
{
temp = *str;
*str++ = *end;
*end--=temp;
}
}
}
</code></pre>
| c++ | [6] |
2,099,157 | 2,099,158 | How to sort an (associative) array by value? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5199901/how-to-sort-an-associative-array-by-its-values-in-javascript">How to sort an associative array by its values in Javascript?</a> </p>
</blockquote>
<p>So first off I know technically Javascript doesn't have associative arrays, but I wasn't sure how to title it and get the right idea across.</p>
<p>So here is the code I have,</p>
<pre><code>var status = new Array();
status['BOB'] = 10
status['TOM'] = 3
status['ROB'] = 22
status['JON'] = 7
</code></pre>
<p>And I want to sort it by value such that when I loop through it later on <code>ROB</code> comes first, then <code>BOB</code>, etc.</p>
<p>I've tried,</p>
<pre><code>status.sort()
status.sort(function(a, b){return a[1] - b[1];});
</code></pre>
<p>But none of them seem to actually DO anything.</p>
<p>Printing the array out to the console before and after result in it coming out in the same order.</p>
| javascript | [3] |
2,697,818 | 2,697,819 | Java Insert a string after 2nd paragraph | <p>I'm new to Java and this is what I'm trying to do:
I have a String content which is a string with html tags</p>
<pre><code> <p><strong>First Paragraph</strong></p>
<p><i>Second paragraph....</i></p>
<a>....more tags etc...
</code></pre>
<p>There are several paragraphs with other html tags in between. I'm trying to insert a link after the 2nd paragraph.</p>
<p>I tried with string.split but it's not really working.</p>
<pre><code> String str = content;
String[] temp;
String delimiter = "[<p>]+";
temp = str.split(delimiter);
for(int i =0; i < temp.length ; i++)
System.out.println(temp[i]);
</code></pre>
<p>Any ideas on how to do this?
thanks</p>
| java | [1] |
3,981,886 | 3,981,887 | Multiple files combined in one static library | <p>So I was wondering whether it's possible to have a static library with multiple files in it? Right now I can use a static library attached to a specific .h and corresponding .cpp in other programs. But when I try to add addional .h's and .cpps to the static library my other programs that try using them come back with error LNK2019. Just want to know if its even possible before searching even more.</p>
| c++ | [6] |
721,853 | 721,854 | ASP.NET: Adding a form to post to another site | <p>I have an ASP website and I need to add a form that will post to another site and open in another window. I can't use JavaScript (which would make it easy). The issue is that I can only post a few fields to the other site, so I can't just add the inputs and redirect the post back to the other site because all of the ASP info would be posted, too.</p>
<p>Basically, I need to get the following code working (or something equivalent), but I can't add the form tag because of the ASP form.</p>
<pre><code><form id="frm_post" action="https://anothersite.com" target="_blank" method="POST">
<input type="hidden" id="accountnumber" name="accountnumber" value="123456" />
<input type="submit" value="Submit" />
</form>
</code></pre>
<p>All the fields will be hidden, so it will basically look like a link, but it will be a post request with the specified fields/values.</p>
<p>Thanks.</p>
| asp.net | [9] |
3,598,064 | 3,598,065 | What should be the default launcher icon size | <p>I refer to the documentation at <a href="http://developer.android.com/guide/practices/ui_guidelines/icon_design.html#icon-sets">http://developer.android.com/guide/practices/ui_guidelines/icon_design.html#icon-sets</a></p>
<p>Hence, I plan to have the following directory structures.</p>
<pre><code>res/
drawable/
icon.png (? x ? px)
drawable-ldpi/
icon.png (36x36 px)
drawable-mdpi/
icon.png (48x48 px)
drawable-hdpi/
icon.png (72x72 px)
</code></pre>
<p>However, I cannot find any documentation, to mention the size of default launcher icon size.</p>
<p>May I know what should be the default launcher icon size?</p>
| android | [4] |
4,812,851 | 4,812,852 | How to animate span to correct position? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/10643303/how-to-recalculate-correct-position">How to recalculate correct position</a> </p>
</blockquote>
<p>I have been trying to achive this effect: When I hover over menu , span with class <b>"problem"</b> follows my mouse and it's expandig dynamicly (has the same width as hovered li tag). The width of my span is working OK but its position is messed up because I don't know
how to make proper calculations. <br/><i><b>Try to hover over my menu to see the problem.</b></i>
<br/><a href="http://jsfiddle.net/w3DrE/" rel="nofollow">FIDDLE HERE</a> <br/>Does anybody knows how to solve this problem or point me in the right direction? </p>
<pre><code> $(document).ready(function(){
$('.menu ul li').hover(function(){
var index=$(this).index();
var width=$(this).outerWidth();
$('.problem').stop().animate({'marginLeft':135*index+195,'width':width},1000);
});
});
</code></pre>
| jquery | [5] |
2,007,815 | 2,007,816 | Phprunner the event code on changin row background color | <p>I know there is a forum for this issue but seems like WOT has warned something. Don't know exactly what is happening to the site but hope some guys out there can help me since no one answered my question there.</p>
<p><img src="http://i.stack.imgur.com/HaJun.png" alt="enter image description here"></p>
<p><strong>Main Problem:</strong> </p>
<p>Here is my code on List Page: After record processed event</p>
<pre><code> if (strtoupper($data["Availability"]) =="SOLD"){
$row["rowstyle"]='style="background:red; color:white"';
}
</code></pre>
<p>I even tried to print the value of "Availability" inside the condition and it prints exactly as SOLD but seems like nothing happened.</p>
<p><strong>NOTE This is important:</strong></p>
<p>I can see that the row background changes when refreshed or during few seconds of loading (SEEMS WORKING!) but after that the color gets back to its original settings.</p>
<p>Hope anyone can tell me that this is a bug or am I really missing something.</p>
<p>References: PhpRunner Manual and <a href="http://xlinesoft.com/blog/2011/01/03/tutorial_conditional_formatting/" rel="nofollow">http://xlinesoft.com/blog/2011/01/03/tutorial_conditional_formatting/</a></p>
| php | [2] |
284,540 | 284,541 | How to Use Ternary Operator in Python | <p>I have this method:</p>
<pre><code>def get_compression_settings(self, media_type=None):
return self.transmit('GET', 'compression?mediatypeid={0}'.format(media_type))
</code></pre>
<p>Is there a way I can check if media_type == None and only append mediatypeid={0} if it is ~=None in a single line using a ternary operator?</p>
<p>I know I could do the following, but it would nicer if my method could just be a single return:</p>
<pre><code>def get_compression_settings(self, media_type=None):
endpoint = 'compression?mediatypeid={0}'.format(media_type) if media_type is not None else 'compression'
return self.transmit('GET', endpoint)
</code></pre>
| python | [7] |
4,085,410 | 4,085,411 | Can I provide a download button for content in an iPhone app? | <p>I am working on an iPhone application called IYoga-Classic which will provide high quality videos for Yogs instructions. I want to add a download option to the videos so that the users can download their desired positions even when they are offline? Is there a way to do this?</p>
| iphone | [8] |
3,056,868 | 3,056,869 | Understanding the javascript THIS keyword | <p>I have tried to find an answer to this question by searching the web, but haven't had any luck. Most information is much more complicated then I expected this answer to be, and none actually answered this question.</p>
<p>In this tag:</p>
<pre><code><form method="post" action="process.php" name="processform" id="form1" onsubmit="return validate(this)">
</code></pre>
<p>What does "this" refer to?</p>
<p>If I was going to replace "this" with a hard-coded reference to the same object what would I replace it with?</p>
| javascript | [3] |
4,023,901 | 4,023,902 | Is there any one website which contains many good C# screencasts? | <p>Is there any one website which contains many good C# screencasts?</p>
| c# | [0] |
1,053,963 | 1,053,964 | Making jQuery's .prev().prev().prev().find("selector") calls easier | <p>How can I avoid the <code>.prev().prev().prev()</code> calls? Is there a shortcut for this?</p>
| jquery | [5] |
6,006,037 | 6,006,038 | How to get the other image using jQuery | <p>My DOM looks like this:</p>
<pre><code><div class="stuff">
<a href="#"><img src=""></a> <b>hello</b>
<a href="#"><img src=""></a>
</div>
</code></pre>
<p>Sometimes I have a reference on the first image, and sometimes on the second image.</p>
<ol>
<li>When I have the first image using $() how do I select the second image?</li>
<li>When I have the second image using $() how to I select the 1st image?</li>
</ol>
| jquery | [5] |
1,913,854 | 1,913,855 | The cheapest Android 1.5 device | <p>I am searching for the cheapest Android 1.5 device <strong>suitable for developing on it</strong>. As the emulator is too sluggish for my needs, I want a real device.
Can you recommend any source where to get such an old device? I looked at eBay, but do not know which device to search for. Maybe you can recommend a list of Android 1.5 devices still available?</p>
| android | [4] |
1,607,312 | 1,607,313 | Why the below piece of code is not crashing , though i have deleted the object? | <pre><code>class object
{
public:
void check()
{
std::cout<<"I am doing ok..."<<std::endl;
}
};
int main()
{
object *p = new object;
p->check();
delete p;
p->check();
delete p;
p->check();
}
</code></pre>
<p><strong>EDIT</strong>:
Gurus, i am confused by many of the statements "it may crash or may not".. why isnt there a standard to say, this how we deal with a block of memory that is deleted using 'delete operator'..? Any inputs ?</p>
| c++ | [6] |
1,544,478 | 1,544,479 | Obtaining domain name using Java | <p>How do I obtain the domain name of the machine I am running on using Java code?<br>
For eg, my machine is a server whose domain name could be ec2-44-555-66-777.compute-1.amazonaws.com</p>
<p>I tried InetAddress.getLocalHost().getHostName() but that doesn't give me the name above. That gives me the hostname which looks similar to ip-0A11B222</p>
| java | [1] |
4,656,641 | 4,656,642 | JavaScript Future Date Failing | <p>Checking Date these dates fail What do I need to change?</p>
<pre><code>20 Jan 2013
20 jan 2013
20 JAN 2013
2 Jan 2013
30 Jan 2013
20 feb 2013
20 jun 2013
</code></pre>
<p>Code:</p>
<pre><code>function ValidateFutureDate(alertstring,pCheckDate)
{
// Default Return Variable to return success.
var returnSuccess = 1;
// setup a temporary array.
var temp = new Array();
// split the date into the array.
temp = pCheckDate.split(' ');
// Setup the Test Date
var testDate = new Date ( temp[1]+" "+temp[0]+", "+temp[2] );
var testMonth=testDate.getMonth()+1;
if (testMonth<10)
{
testMonth = "0"+testDate.getMonth();
}
// This is the Date to test if it is a valid date.
var testIsDate = ( testMonth+"/"+temp[0]+"/"+temp[2] );
// Is this a valid Date
if(!(isDate(testIsDate))) {
returnSuccess = 0;
} else if
// Check to see if this date is greater then today.
(!(testDate.getTime() > (new Date().getTime()))) {
//return Failure zero is a failure.
returnSuccess = 0;
alertstring = alertstring + 'Expiration must be in the future. \n';
}
// Return the Success or Failure of the Date Format Validation
return returnSuccess;
}
</code></pre>
| javascript | [3] |
2,027,812 | 2,027,813 | how to access items from datalist | <p>How to access to Label5 from behind page file(default.aspx.cs)?</p>
<pre><code> <ItemTemplate>
<asp:Image ID="Image1" runat="server" />
<asp:HyperLink ID="HyperLink1" CssClass="nav_url_odg" runat="server"><%# Eval("user") %></asp:HyperLink> <span class="odgovorio">je odgovorio:</span><br />
<div>
<asp:Label ID="Label5" runat="server" Text=""></asp:Label></div>
</div>
<br /></div> </div>
</ItemTemplate>
</asp:DataList>
</code></pre>
| asp.net | [9] |
2,777,304 | 2,777,305 | Javascript - trying to locate an image | <p>I am not expert in javascript, so, excuse my lack of knowledge.</p>
<p>I am trying to interact with an image on a page on the web, to create some automation.</p>
<p>I need to click on that image using javascript, from a script.</p>
<p>I did everything to discover how to access that image and no success at all. The image is not responding to anything. I suppose I am not reaching the right object.</p>
<p>Trying to discover the object, I created a very simple script, that will scale every image on that page, to see at least if I can reach all img object.</p>
<p>This is the script</p>
<pre><code>for (i=0;i<=100;i++) {
document.image[i].width.value = '300';
}
</code></pre>
<p>No changes at all.</p>
<p>Is the script correct? is that anything that may be preventing the image to respond from external scripts?</p>
<p>Any clues? thanks.</p>
<p><em><strong></em>___</strong> EDIT</p>
<p>the image I need to click is declared like this:</p>
<pre><code> <div class="leaderboard-text">
<span id="addon-add-language-button"><image class="ajaxListAddButtonEnabled" listId="localizationList" src="/itc/images/blue-add-language-button.png"><image class="ajaxListAddButtonDisabled" listId="localizationList" style="display:none;" src="/itc/images/blue-add-language-button-disabled.png"></span>
</div>
</code></pre>
| javascript | [3] |
146,754 | 146,755 | The function should return a new string, which has the same vowels (any of ‘aeiou’ or ‘AEIOU’) | <p>The function receives an input string (st) and a character (ch). The string st may have letters, digits and symbols. The function should return a new string, which has the same vowels (any of ‘aeiou’ or ‘AEIOU’) that the original string has, and in the same positions as in st , and for the other positions it should have the symbol ‘$’, but only including these characters until and not including the first appearance of the character ch (even if ch is a vowel) . (The string being returned may be shorter than the original string, possibly the empty string as well).</p>
<p>An example:
vowels_or_not('abcdeAghi', 'A') should return 'a$$$e'</p>
<p>the replacing has to stop before the character (ch)</p>
<pre><code>def vowels_or_not(string, char):
left, middle, right = string.parition(char)
left = [(c if (c.lower() in "aeiou") else '$')
for c in left]
return ''.join(left)
return vowels_or_not(st, 'char')
</code></pre>
<p>I can't figure out how not to include the character and how to only replace vowels up until that point.</p>
| python | [7] |
1,669,685 | 1,669,686 | How do I display my phone number in a text field in an ios iphone app | <p>I'm very new to ios development and am trying to get my phone number to display in a text field, or something similar, without hard coding it in. Is there a way to 'call' that data from my phone and display it in a text field, Is this even possible? Thanks!</p>
| iphone | [8] |
3,592,836 | 3,592,837 | Uppercase url in fromHTML results in crash | <p>Why does this crash when touched:<br>
<code>text_link.setText(Html.fromHtml("<a href="HTTP://WWW.GOOGLE.COM">Test</a>"));</code> </p>
<p>But this works fine:<br>
<code>text_link.setText(Html.fromHtml("<a href="http://www.google.com">Test</a>"));</code> </p>
<p>The only difference is the url in the first is UPPERCASE and the bottom is not.</p>
| android | [4] |
5,489,598 | 5,489,599 | How many clients can connect to this server? | <p>How many clients can connect to this server?</p>
<pre><code>private void btnserverconect_Click(object sender, EventArgs e)
{
Form1_Load(sender, e);
}
private void Form1_Load(object sender, EventArgs e)
{
try {
server =
new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
//IPAddress local = IPAddress.Parse("127.0.0.1");
EndPoint destination = new IPEndPoint(IPAddress.Any, 8000);
server.Bind(destination);
server.Listen(5);
Thread wait = new Thread(wa);
wait.Start();
}
catch(Exception) {
MessageBox.Show("connection error !");
}
}
void wa()
{
label1.Text = "please wait...";
server = server.Accept();
label1.Text = "connect";
while (true) {
try {
byte[]by = new byte[100];
int n = server.Receive(by);
lstserver.Items.Add("client :" +
Encoding.ASCII.GetString(by, 0, n));
}
catch(Exception) {
}
}
}
</code></pre>
| c# | [0] |
2,335,466 | 2,335,467 | how to solve memory warning level 1 in ipad? | <p>I have implemented pdf reader application in which i have load one controller in UIScrollvew and implemented pagging functionality.Its working fine.But after 28 pagging show memory warning level 1.I dont know where is the memory leak.Please help me solve this problem.
Thanks in advance.</p>
| iphone | [8] |
266,606 | 266,607 | JavaScript and subscribing to Events | <p>I have something like this in a JavaScript control that someone I with (short of asking the guy as he's on holiday) how does one subscribe to this event. </p>
<pre><code>if(typeof(pnlDialog.onclose) == 'function')
pnlDialog.onclose();
</code></pre>
<p>I thought it was something like, but havent been successful. </p>
<pre><code>var mycontrol = document.getElementById('myDialog');
mycontrol.attachEvent('onclose', function()
{
alert('closed');
});
</code></pre>
| javascript | [3] |
5,642,343 | 5,642,344 | Retrieve label content in Jquery | <p>I am using JQuery for my application.
In my code, I want to get only the text 'Firstname' in the label.</p>
<p>I tried it with </p>
<pre><code> $("#label"+div_id+"").html(); //but displays Firstname along with the span tag..
</code></pre>
<p>But I only need Firstname. How can i do so?</p>
<p>The following is my Html code</p>
<pre><code> <label id="label1">Firstname<span class="req"><em> * </em></span></label>
</code></pre>
| jquery | [5] |
3,721,820 | 3,721,821 | Add a "Remember me" checkbox | <p>I know there are already plenty of articles on here that describe how to add a "Remember me" function on the Android App but, I still cant quite figure it out after 3 hours of researching and experimenting.</p>
<p>Basically, I am a begginner at Android development. I would like to have a Checkbox button to Remember User Id and Password. Can anyone please guide me in the right direction as to how to get it started? </p>
<p>Thanks.</p>
| android | [4] |
4,982,093 | 4,982,094 | python reverse tokens in a string | <p>I have the following string:</p>
<pre><code>apple.orange.red.green.yellow
</code></pre>
<p>How can i reverse it to get the following:</p>
<pre><code>yellow.green.red.orange.apple
</code></pre>
| python | [7] |
5,537,469 | 5,537,470 | Case insensitive string::find | <p>Is there exist a case insensitive find() method for std::string?</p>
| c++ | [6] |
2,660,131 | 2,660,132 | PHP: skipping a default parameter in a function call | <p>The below is a php function: </p>
<blockquote>
<p>bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] )</p>
</blockquote>
<p>I would like to call the function, specifying the first and the third parameters, leaving the second default. Can I?</p>
| php | [2] |
3,438,638 | 3,438,639 | Verifying if the password field is empty | <p>I have a login form in which the user enters the username and the password in an attempt to login to his profile. I want to dynamically verify that both the fields are filled before i start doing the server side processing. </p>
<hr>
<pre><code><form id="form" method="post" action="student.jsp">
<label><strong>Username :</strong><br/><br/>
<input type="text" value="" name="username" id="idusername">
</label><br/><br/>
<label><strong>Password :</strong><br/><br/>
<input type="text" value="" name="password" id="idpassword">
</label><br/><br/><br/>
<input id="minibutton" name="send" type="submit" value="Login" />
</form>
</code></pre>
<hr>
<p>I am using javascript which correctly verifies and alerts whenever the username is left blank and we attempt to login. However, it does not do so with the password field and we can get away with it being left blank.</p>
<hr>
<pre><code>$(document).ready(function(){
//global vars
var form = $("#form");
var username= $("#idusername");
var password = $("idpassword");
//On Submitting
form.submit(function(){
if(username.val().length==0 || password.val().length==0){
alert('Please enter the username');
return false;
}
else
{
if(password.val().length==0)
{
alert('Please enter the password');
return false;
}
else
return true;
}
});
});
</code></pre>
<hr>
<p>I am not good at javascript but i need to use it for dynamic validation. Plaese pointy out the error in verifying the password field.</p>
| javascript | [3] |
3,965,625 | 3,965,626 | How to get id of previous element by using mouseovered element's id which was taken from its class | <p>I did this but it didn't work. Can anyone help me? Thanks.</p>
<pre><code>$('.current_element').mouseover(function() {
var currentElementId = $(this).attr('id');
var previousElementId = $('#' + currentElementId).prev('.previous_element').attr('id');
});
</code></pre>
| jquery | [5] |
1,433,777 | 1,433,778 | how block scrolling in pageAdapter | <p>For example: I have 2 pages in PageAdapter. When I go to second page, I click on button "Lock" and horizontal scrolling is off. I click "Unlock" and again can scrolling. How block scrolling ?
Code:</p>
<pre><code>public class slide extends PagerAdapter
{
List<View> pages = null; // empty list views
public slide (List<View> page)
{
this.pages = page;
}
@Override
public int getCount()
{
return pages.size();
}
@Override
public boolean isViewFromObject(View view, Object obj)
{
return view.equals(obj);
}
@Override
public Object instantiateItem (View views, int position)
{
View v = pages.get(position);
((ViewPager) views).addView(v, 0);
return v;
}
@Override
public void destroyItem(View views, int position, Object view)
{
((ViewPager) views).removeView((View) view);
}
@Override
public void finishUpdate(View view)
{
}
@Override
public void restoreState(Parcelable arg0, ClassLoader arg1)
{
}
@Override
public Parcelable saveState()
{
return null;
}
@Override
public void startUpdate(View view)
{
}
</code></pre>
<p>In Activity:</p>
<pre><code> List<View> pages = new ArrayList<View>();
View page = inflater.inflate(R.layout.page, null);
TextView textView = (TextView) page.findViewById(R.id.text_view);
textView.setText("Page 1"); // first page
pages.add(page);
page = new surfaceControl(this); // second page with some modul
pages.add(page);
slide pageAdapter = new slide(pages);
ViewPager viewPager = new ViewPager(this);
viewPager.setAdapter(pageAdapter);
viewPager.setCurrentItem(0);
</code></pre>
| android | [4] |
743,500 | 743,501 | is Service an abstract class? | <p>This question was asked in an interview, let me know if anyone does know, while I crawl the web for the answer and understanding..</p>
<p><strong>Edit</strong></p>
<p>found it...</p>
| android | [4] |
407,878 | 407,879 | iPhone SDK: Testing for valid string date | <p>I want to be able to validate a date.</p>
<p>It's valid entry is 4 characters with a mmyy mask.</p>
<p>I want to make sure that the value entered is indeed a date.</p>
<p>Thanks in advance.</p>
| iphone | [8] |
4,366,497 | 4,366,498 | Showing and hiding a div with jQuery | <p>When you click on the link, it with display the div "somecontent". And if you click on the link again, it will hide. How can I make the div show when hovering over the link and hide when moving away instead of showing and hiding on click?</p>
<p>Here is the code:</p>
<pre><code><script type="text/javascript">
$(document).ready(function(){
$(".showcontent").click(function(){
$(".somecontent").toggle("fast");
});
});
</script>
<a class="showcontent" href="">Show</a>
<div class="somecontent">
<p>some content</p>
</div>
</code></pre>
| jquery | [5] |
1,057,881 | 1,057,882 | How to getLocationOnScreen from a Shortcut or Widget? | <p>When a user presses a shortcut on the screen and that shortcut starts up an activity, how can I get the location of where the shortcut is on the screen?</p>
<p>I have the same question for a widget. When a user has a widget on the screen and pressing it fires off the setOnClickPendingIntent how can I know the location on the screen where the widget is?</p>
<p>In both scenarios there is no View to run View.getLocationOnScreen.</p>
| android | [4] |
4,017,902 | 4,017,903 | Problem in Disabling JButton in Java | <p>Good day!</p>
<p>I want to disable a button once I click it. My code is as follows..</p>
<pre><code>for (char buttonChar = 'a'; buttonChar <= 'z'; buttonChar++) {
String buttonText = String.valueOf(buttonChar);
JButton letterButton = new JButton(buttonText);
letterButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String actionCommand = e.getActionCommand();
System.out.println("actionCommand is: " + actionCommand);
letterButton.setEnabled(false); //I disable the button here
}
});
</code></pre>
<p>But an error appears: <code>local variable letter Button is accessed from the inner class; needs to be declared final</code>.. What does it mean? how can i resolve the issue?
Thank you...</p>
| java | [1] |
847,905 | 847,906 | Achieving x% height and width of the physical android device | <p>I have read a couple of pages on stackoverflow regarding android and display sizes but still, I could not find a simple/elegant solution to my problem..</p>
<p>I want a button to be 60% height and width of the physical device. I could not use dips since I do not know how big the screen will be in advance.</p>
<p>What's the solution to do something near to this:</p>
<pre><code> <Button android:layout_width="60%" android:layout_height="60%"/>
</code></pre>
| android | [4] |
1,026,149 | 1,026,150 | C++ error: expected unqualified-id | <p>I'm getting an error "error: expected unqualified-id before '{' token" on line 6. </p>
<p>I can't tell what's wrong.</p>
<pre><code>#include <iostream>
using namespace std;
class WordGame;
{
public:
void setWord( string word )
{
theWord = word;
}
string getWord()
{
return theWord;
}
void displayWord()
{
cout << "Your word is " << getWord() << endl;
}
private:
string theWord;
}
int main()
{
string aWord;
WordGame theGame;
cin >> aWord;
theGame.setWord(aWord);
theGame.displaymessage();
}
</code></pre>
| c++ | [6] |
1,419,367 | 1,419,368 | Copy content from textarea to input and trim characters | <p>First time here :)</p>
<p>I have a textarea and an input and I would like that, when something is typed into the texarea, it copies it to the input onkeypress. But the input must be limited to 10 characters. Then I would like to add 5 numbers to the end of the value of the input</p>
<p>EG:
Textarea content: "Hello world, how are you?"
Input content: "Hello worl12345"</p>
<p>I have tried <a href="http://jsfiddle.net/bxHQ5/" rel="nofollow">this</a> and <a href="http://jsfiddle.net/4kS65/523/" rel="nofollow">this</a><br>
but on the second one I think its really messed up code and requires some "cleaning". Besides, it lacks the function of adding 5 numbers at the end.</p>
| jquery | [5] |
411,256 | 411,257 | Get Tried Paths for PHP's include | <p>Is it in any way possible to tell PHP that I want to have a list of tried paths whenever <code>include</code> fails? The file is there, yet PHP is telling me the <code>include</code> failed.</p>
| php | [2] |
38,148 | 38,149 | Why java character print number? | <p>I have the following class, see</p>
<pre><code> public class Go {
public static void main(String args[]) {
System.out.println("G" + "o");
System.out.println('G' + 'o');
}
}
</code></pre>
<p>And this is compile result;</p>
<pre><code> Go
182
</code></pre>
<p>Why my output contain a number?</p>
| java | [1] |
1,452,122 | 1,452,123 | making functions in Jquery | <p>I`m making some functions with Jquery.
but I got problem.</p>
<pre><code>function fader(elm,delaytime) {
elm.each(function(index){
$(this).css('visibility','visible').delay(delaytime*index);
$(this).fadeIn(1500);
});
}
fader($('.subImgs').children(),200);
</code></pre>
<p>It was good, and I wanted more.</p>
<pre><code>$.fn.fader2 = function(elm,delaytime) {
elm.each(function(index){
$(this).css('visibility','visible').delay(delaytime*index);
$(this).fadeIn(1500);
});
}
$('.subImgs').children().fader2(200);
</code></pre>
<p>It doesn't work. I know something was different but I couldn't find it.
anyone can help me?</p>
| jquery | [5] |
5,299,307 | 5,299,308 | Make Large image black and white | <p>Is there any way I can load a large Image(which android phone cannot handle if taken all at once) from SD card make it b/w And save it back to SD card.
NB:I don't need to display the image.
Thanking You In advance for Your valuable suggestions.</p>
| android | [4] |
1,477,456 | 1,477,457 | PHP - Push Notifications | <p>What methods can be used to make PHP capable of becoming a push notification server?</p>
| php | [2] |
1,101,610 | 1,101,611 | How to use keyboard event and timer? | <p>I want the next:
when you press spacebar - label1.Text become to "Up", after several second (random from 1 to 5) label1.Text will change to "Remove hand" and then KeyUp label1.Text will change "Down".
I know how to use KeyUp and KeyDown, but I don't understand how to use timer???</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private Timer timer = new Timer();
public Form1()
{
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
label1.Text = "Down";
timer.Interval = 5000;//5 seconds
timer.Tick += new EventHandler(timer1_Tick);
timer.Start();
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
label1.Text = "Up";
}
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = "Remove";
timer.Stop();
}
}
}
</code></pre>
| c# | [0] |
2,848,046 | 2,848,047 | PHP echo from MySQL variable split price with commas? | <p>I have a column in the database called price that stores values like 200000 and I've been able to successfully use MySQL to split this up by comma like 200,000 but my understanding is that this is not a very good use of MySQL syntax and could be a disaster on larger queries.</p>
<p>How do I take this as a PHP variable and perform the same thing?</p>
<p>Example: <code>echo '<title>$' . $price . '.00- ' .</code></p>
| php | [2] |
2,220,824 | 2,220,825 | Unable to Retrieve data from PHP class | <p>In the following code I am getting error: <code>Undefined variable: base_url on line 27</code> and <code>Cannot access empty property on line 27</code>.</p>
<p>I need to echo the parameter <code>http://google.com</code> passed in get_url() from render().</p>
<pre><code><?php
$smart_url = new smart();
$smart_url -> get_url('http://google.com');
echo $smart_url -> render();
/**
* Smart URL
*/
class smart {
private $base_url;
/**
*
* @param string $url
*/
public function get_url($url) {
$this -> $base_url = $url;
}
/**
* @return string $base_url
*/
public function render() {
return $this -> $base_url;
}
}
?>
</code></pre>
| php | [2] |
4,766,549 | 4,766,550 | Enabling and disabling draggable elements | <p>I'm disabling some 'li' draggable elements and then attempting to enable an 'li' element based on its id and class.
The class is being removed but the li element is still not draggable ?</p>
<pre><code>//Disabling draggable on li elements using 'not'
$(".myLi:not(.disable)").sortable({
revert : true,
}).draggable({
helper : "clone"
}
});
<li id="test" class="myLi disable" >Li Point1</li>
var toTest = $('#test');
//Enabling li element to draggable again using id and class
toTest.removeClass('disable');
</code></pre>
| jquery | [5] |
4,676,147 | 4,676,148 | Calling on onDestroy() method in my Expandable list Activity | <p>My AndroidApp containing 5 classes in that 4 activities are normal activities and one activity is ExpandableListActivity ,for the 4 activities am using onDestroy() method and am using below code </p>
<pre><code>@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
unbindDrawables(findViewById("AM using layout id"));
System.gc();
}
private void unbindDrawables(View view) {
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
unbindDrawables(((ViewGroup) view).getChildAt(i));
}
((ViewGroup) view).removeAllViews();
}
}
</code></pre>
<p>now i want to apply same code for expandablelistactivity class but the problem is am not using any layout ( setContentView(R.layout.ans);) am using below code</p>
<pre><code>public class Mainactivity extends ExpandableListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.layout); but am not writing this line
setListAdapter("adapter am calling");
}
</code></pre>
<p>and my doubt is how can i implement onDestroy() method as same as above in this class..</p>
<p>please provide any code for that..thanking you</p>
<p>T&R
Rajinikanth M </p>
| android | [4] |
4,316,539 | 4,316,540 | jquery mask output | <p>I have a jquery masked textbox which has a mask:</p>
<pre><code>$("#txthtml").mask("99/99/9999");
</code></pre>
<p>When I check the output, it has the '/' in its value. Is there an easy way to get only what the user entered and nothing else? So if text box read <code>01/01/1990</code> I want <code>01011990</code> .</p>
<p>Same thing if I have a phone number mask, how can I get the user input only?</p>
| jquery | [5] |
917,963 | 917,964 | find parent of the opener iframe | <p>lets say we have an iframe in page test1.html</p>
<pre><code><iframe src=test2.html"></iframe>
</code></pre>
<p>and there is a link in test2.html:</p>
<pre><code><a href="test3.html" target="_blank">open in new window"</a>
</code></pre>
<p>in test3.html how can I know the parent of the opener? (that is test1.html)</p>
| javascript | [3] |
3,155,722 | 3,155,723 | What is the best value to use for id in an ActiveRecord pattern (PHP) | <p>What is the best value to use for id in an ActiveRecord pattern (PHP).</p>
<p>auto-increment is out of the question. I would like to generate an id value that I can use to create a new record, but will be unique.</p>
<p>random values have a chance of creating collision.</p>
<p>querying to get the last id used, and then incrementing that value has the chance that another record will be created at approximately the same time with the same id value.</p>
<p>what do most use in this situation? what is the best thing to use for this situation?</p>
| php | [2] |
903,187 | 903,188 | Creating a .txt File and Changing its Directory in Java | <p>I am creating a .txt file with this:</p>
<pre><code>FileWriter fstream = new FileWriter("out.txt");
BufferedWriter out = new BufferedWriter(fstream);
</code></pre>
<p>And I am writing something in it. But I want to also determine its directory. For example, my workspace is under C, but I want to create .txt under D. How can I do that?</p>
| java | [1] |
5,302,705 | 5,302,706 | multiple class selctor in jquery | <p>I have this css role</p>
<pre><code>.sf-menu a.sf-with-ul{padding-left:20px}
</code></pre>
<p>I want to change this role using jquery</p>
<p>I tried without success the follwing commands</p>
<pre><code>$(function()
{
$("a.sf-with-ul").css("padding-left", "10px");
$("a").hasClass(".sf-with-ul").css("padding-left", "10px");
$("a").filter(".sf-with-ul").css("padding-left","10px")
});
</code></pre>
<p>Any idea what is the problem?</p>
<p>p.s</p>
<p>I do I change the roll of this css using jquery?</p>
<pre><code>.sf-menu li ul li a
</code></pre>
| jquery | [5] |
2,243,177 | 2,243,178 | showing a message dialog only once , when application is launched for the first time in android | <p>I've developed an application in android and one of the important requirements is to show a message dialog for language support ONLY when the application is running for the first time ,then it will disappear each time the user is running the application again , I've tried to use shared preferences but it didn't work , is there is any other way to do that ?? </p>
| android | [4] |
1,153,978 | 1,153,979 | Locking button clicke event, using lock in asp.net? | <p>Using Lock in asp.net how can i prevent more than one user to click on button. I mean only one user has to click on button at a time, more than one user not to click on button.
How can i use lock, any refrence to study.</p>
| asp.net | [9] |
4,574,256 | 4,574,257 | PHP repeating piece of code wtih access to variables | <p>How to repeat the same PHP snippet in different PHP files?
For example I define the variable <code>$user</code>, then I insert PHP code, which have an access to this variable.
<strong>Update:</strong>
I'm going to use this with if statement</p>
<blockquote>
<p>Example(without if statement):</p>
</blockquote>
<pre><code> function sanitizeString($var)
{
$var = htmlentities($var, ENT_QUOTES, "UTF-8");
return mysql_real_escape_string($var);
}
$user = sanitizeString($_POST['user']);
$pass = sanitizeString($_POST['pass']);
//code i want to repeat in different files
$user=$user;
$pass=$pass;
#salt generation
$salt=uniqid(mt_rand(), true);
#Add data to tables
queryMysql("INSERT INTO accounts VALUES('$user', '".hash('sha512',$pass+$salt)."', '$salt', '$cookie_value')");
mysql_query("INSERT INTO passwordreset VALUES('$user', NULL, NULL)");
//end of code to repeat
</code></pre>
| php | [2] |
1,057,625 | 1,057,626 | Turn image SRC into background-image in jQuery | <p><a href="http://stackoverflow.com/questions/2183347/how-to-set-the-image-src-using-jquery">http://stackoverflow.com/questions/2183347/how-to-set-the-image-src-using-jquery</a></p>
<p>I am looking to do the opposite of what this jQuery snippet does. I need a bit of code that will turn</p>
<pre><code><img src="images/filename.jpg">
</code></pre>
<p>to become </p>
<pre><code><div class="imageBox" style="background:url(images/filename.jpg)"></div>
</code></pre>
<p>I've searched up and down trying to find something that will do this but have come up empty. I'm no jQuery guru, so I would appreciate any help someone could offer. Thanks</p>
| jquery | [5] |
1,943,943 | 1,943,944 | Reference to running Thread is null | <p>I can't get a spawned thread to stop:</p>
<p>I'm implementing the vibration-part of the Ringer-class in the regular Android Phone.apk (basically word for word), but after vibrating once (and stopping) correctly, the second time I call <code>startVibration()</code> and subsequently <code>stopVibration()</code>, it <em>doesn't</em> stop the thread (the log prints out that mVibratorThread is null, even though an instance of it is clearly still active, because the phone is vibrating :-)!)...</p>
<pre><code>public volatile boolean mContinueVibrating;
public VibratorThread mVibratorThread;
private static final int VIBRATE_LENGTH = 1000; // ms
private static final int PAUSE_LENGTH = 1000; // ms
public void startVibration(){
//Start the vibration alarm
if (mVibratorThread == null) {
mContinueVibrating = true;
mVibratorThread = new VibratorThread();
Log.i(TAG, "Starting vibration...");
mVibratorThread.start();
}
}
public void stopVibration(){
//Stop the vibration alarm
Log.i(TAG, "Stopping vibration...");
if (mVibratorThread != null){
mContinueVibrating = false;
mVibratorThread = null;
Log.i(TAG, "Thread wasn't null, but is now set to null...");
} else {
Log.i(TAG, "Thread was null...");
}
}
private class VibratorThread extends Thread {
public void run() {
Vibrator mVibrator = (Vibrator) m_context.getSystemService(Context.VIBRATOR_SERVICE);
while (mContinueVibrating) {
mVibrator.vibrate(VIBRATE_LENGTH);
SystemClock.sleep(VIBRATE_LENGTH + PAUSE_LENGTH);
Log.i(TAG, "VIBRATING NOW!!" + mContinueVibrating);
}
}
}
</code></pre>
<p>I've already tried the method described in <a href="http://stackoverflow.com/questions/680180/where-to-stop-destroy-threads-in-android-service-class">Where to stop/destroy threads in Android Service class?</a></p>
<p>Thanks for your help,<br>
Nick</p>
| android | [4] |
697,536 | 697,537 | Unzipping a .gz file using C# | <p>I have a tarred gunzip file called ZippedXmls.tar.gz which has 2 xmls inside it.
I need to programmatically unzip this file and the output should be 2 xmls copied in a folder.
How do I achieve this using C#?
Can someone help me with the code please?</p>
<p>Thanks a bunch.</p>
| c# | [0] |
2,975,687 | 2,975,688 | How to execute script from an Input field on JS? | <p>I want to execute script from an editable input field when clicking a button</p>
<p>for example, If you type "<em>alert("x");</em>", I want to alert you "x", but also if you type "<em>for(i=0;i<3;i++){alert(i);}</em>" I want it to execute it.</p>
<p>How can I achieve this?</p>
<blockquote>
<p><strong>Edit:</strong> eval() is the only solution? Because I read that it is dangerous:
<a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/eval#section_5" rel="nofollow">https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/eval#section_5</a></p>
</blockquote>
| javascript | [3] |
2,884,233 | 2,884,234 | Saving strings that contain empty variables for later use | <p>Here goes again at my attempt at explaining, hopefully this is clearer. here is my core class.</p>
<pre><code>function __construct()
{
$nav = array
(
"foo" => "bar",
"foo" => "bar",
);
$navBar = $var_dev->navBar;
function navGenerator($navBar)
{
return $navBar;
/*foreach ($nav as $link_name => $link)
{
return $var_dev->navBar;
//return '"<li><a href="'. $link_name . '">' . $link . '</a></li>';
}*/
}
}
</code></pre>
<p>Here is the other class where navBar is being called...</p>
<pre><code>class standardHandle
{
public $navBar = 'lawl';
}
</code></pre>
<p>The above works fine, however I would like <code>$navBar = '<li><a href="'. $link_name . '">' . $link . '</a></li>'</code></p>
| php | [2] |
4,882,514 | 4,882,515 | guidelines on usage of size_t and offset_t? | <p>This is probably a C++ 101 question: I'm curious what the guidelines are for using <code>size_t</code> and <code>offset_t</code>, e.g. what situations they are intended for, what situations they are not intended for, etc. I haven't done a lot of portable programming, so I have typically just used something like <code>int</code> or <code>unsigned int</code> for array sizes, indexes, and the like. However, I gather it's preferable to use some of these more standard typedefs when possible, so I'd like to know how to do that properly.</p>
<p>As a follow-up question, for development on Windows using Visual Studio 2008, where should I look to find the actual typedefs? I've found <code>size_t</code> defined in a number of headers within the VS installation directory, so I'm not sure which of those I should use, and I can't find <code>offset_t</code> anywhere.</p>
| c++ | [6] |
5,600,321 | 5,600,322 | When is __proto__ useful? | <p>When is <code>__proto__</code> useful?</p>
<p>A lot of browsers support it, but because not all do, programmers seem to be scared of using it. I've never seen it in any code (such as the libraries jQuery and backbone.js).</p>
<p>When is <code>__proto__</code> useful? Is it just a geeky thing for completeness?</p>
| javascript | [3] |
2,634,684 | 2,634,685 | How to append a listitem in first position of list using Jquery | <p>How to append a listitem in first position of list using Jquery?</p>
<pre><code><ul id="mylist">
<li>First</li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
</ul>
</code></pre>
<p>is it possible to append a list item before first <code><li></code> with jquery. I try to <code>$('#mylist li:eq(1)').before("<li></li>")</code>. But it not works?</p>
| jquery | [5] |
601,707 | 601,708 | Android - how to display large text | <p>I have a txt file which is around 2MB. I need to display it in android. I have tried out WebView and it takes around 5 seconds to load and display the file. Is there any way I can get it rendered faster? Moreover, I dont want to load all the text at the start. Something like a scrollbar which displays elements efficiently is what I require. I need not stick to WebView alone, but can choose to show it using any efficient way.</p>
| android | [4] |
3,079,450 | 3,079,451 | java.util.log , using 3 different logger instances/log files, getting .1 .2 etc | <p>I'm trying to figure out why I'm generating multiple versions of my log files (.1, .2 ,etc). My project has a need for 3 separate loggers, I'm using java.util.log and setting up my loggers as follows:</p>
<pre><code>logger = Logger.getLogger("Logger");
logger.addHandler(new FileHandler(logFileName));
statsLogger = Logger.getLogger("StatsLogger");
statsLogger.addHandler(new FileHandler(statsLogFileName));
alarmLogger = Logger.getLogger("AlarmLogger");
alarmLogger.addHandler(new FileHandler(alarmLogFileName));
</code></pre>
<p>my logging properties file:</p>
<pre><code>handlers=java.util.logging.ConsoleHandler java.util.logging.FileHandler
java.util.logging.FileHandler.append=true
java.util.logging.FileHandler.level=INFO
java.util.logging.ConsoleHandler.level=INFO
java.util.logging.ConsoleHandler.formatter=com.package.LogFormatter
java.util.logging.FileHandler.formatter=com.package.LogFormatter
</code></pre>
<p>This seems to work, well as far as I can tell anyway... things seem to be getting logged to the correct log files. Any ideas on what could be causing this? </p>
<p>Thanks for any ideas</p>
| java | [1] |
4,968,731 | 4,968,732 | using asp.net how to get ip address from remote sites | <p>My webserver has a number of IP addresses. My web site has a dedicated ip. I need to get my dedicated ip from a remote website. Now my question is how my client site is going to get my
dedicated ip address. They are using <code>request.serverVariables("REMOTE_ADDR")</code> but they get only the ip address of the domain name server 1 instead of my dedicated ip. What is the problem? How do I fix this issue through asp.net?</p>
| asp.net | [9] |
2,160,006 | 2,160,007 | this.image.width / number yields 0 | <p>I'm trying to calculate the width of a sprite using the image width, but the number always comes out as 0, why is that?</p>
<pre><code>function SpriteSheet(image, numFramesX, numFramesY, totalFrames) {
this.image = image;
this.numFramesX = numFramesX;
this.numFramesY = numFramesY;
this.totalFrames = totalFrames;
this.spriteWidth = this.image.width / this.numFramesX;
this.spriteHeight = this.image.height / this.numFramesY;
}
image.onload = function() {
console.log('Image has been loaded');
}
image.src = 'dance.png';
spritesheet = new SpriteSheet(image, 8, 10, 80);
</code></pre>
<p>spritesheet.spriteWidth and spritesheet.spriteHeight always yields 0. I cornered the problem to 'this.image.width' since it works if I put in the width of the image manually.</p>
<pre><code>this.spriteWidth = 880 / this.numFramesX;
</code></pre>
<p>instead of</p>
<pre><code>this.spriteWidth = this.image.width / this.numFramesX;
</code></pre>
<p>It also works if I calculate it using the object in the console:</p>
<pre><code>spritesheet.image.width / spritesheet.numFramesX
</code></pre>
<p>yields 110</p>
<p><a href="http://jsfiddle.net/sunwooz/kxrEH/1" rel="nofollow">jsfiddle</a></p>
| javascript | [3] |
3,021,073 | 3,021,074 | C++: Create object of certain type mapped to an enum | <p>Considering the following code example:</p>
<pre><code>class Base;
class A; class B; class C; //A, B and C are inherited from Base
enum TypeID
{
TYPE_A = 0, TYPE_B, TYPE_C, TYPE_MAX;
}
class SomeContainer
{
private Base* objects[ TYPE_MAX ];
public void Add( TypeID what )
{
if( objects[ what ] ) return;
switch( what )
{
case TYPE_A: objects[ TYPE_A ] = (Base*) new A;
case TYPE_B: objects[ TYPE_B ] = (Base*) new B;
case TYPE_C: objects[ TYPE_C ] = (Base*) new C;
default: printf( "Invalid type\n" ); return NULL;
}
}
public A* GetA()
{
return (A*) objects[ TYPE_A ];
}
public B* GetB()
{
return (B*) objects[ TYPE_B ];
}
public C* GetC()
{
return (C*) objects[ TYPE_C ];
}
}
</code></pre>
<p>I think it is better than words to describe what my real system currently does.</p>
<p>Now in reality I have even more classes derived from base, it's about 15.</p>
<ul>
<li><p>Do I have repetitive code for all of the classes derived from Base? As add a line for them in the switch statement, and an additional helper function to get them from the array?</p></li>
<li><p>Is there a way to automate this?</p></li>
</ul>
| c++ | [6] |
4,351,739 | 4,351,740 | Javascript : Change the function of the browser's back button | <p>Is there a way to make the user's back button on their browser, call a javascript function instead of going back a page?</p>
| javascript | [3] |
4,073,599 | 4,073,600 | JavaScript: IF time >= 9:30 then | <p>I'm trying to write a statement that says "if time is this and less than that then". I can use get hours and get min. However, I'm having problems combining a time such as 9:30.</p>
<p>Example,</p>
<pre><code>var now = new Date();
var hour = now.getHours();
var day = now.getDay();
var mintues = now.getMinutes();
if (day == 0 && hour >= 9 && && mintues >= 30 } && hour <= 11) {
document.write(now);
}
</code></pre>
<p>This only if the time is less between 9:30 10. As soon as the clock hits 10 the minutes are then < 30 and the script breaks.</p>
<p>Any thoughts on how to better incorporate the time function to make this theory work?</p>
<p>Thanks,</p>
| javascript | [3] |
4,531,318 | 4,531,319 | Full Text justification in android | <p>I am browsing data from the server and getting through page.getContent(), My textview has default gravity(left), so text is left aligned, I want right alignment as well(As we justify text in MS Office)....Is there any way to justify the text.</p>
<p>I have put android:garavity="left|right" it also doesn't work.</p>
<pre><code>TextView textview=(TextView)findViewbyId(R.id.text);
textview.setText(Html.fromHtml(page.getContent()));
</code></pre>
| android | [4] |
416,820 | 416,821 | Elastic Image Slideshow autoplay resume after thumbnail clicked | <p>Hi I am using Elastic Image Slideshow downloaded from here:</p>
<p><a href="http://tympanus.net/Tutorials/ElasticSlideshow/index2.html" rel="nofollow">http://tympanus.net/Tutorials/ElasticSlideshow/index2.html</a></p>
<p>But the autoplay will stop after the thumbnail is clicked. I wonder how to resume the autoplay again after some seconds. I saw this code in js:</p>
<pre><code> // click the thumbs
this.$thumbs.on( 'click.eislideshow', function( event ) {
if( _self.options.autoplay ) {
clearTimeout( _self.slideshow );
_self.options.autoplay = false;
}
var $thumb = $(this),
idx = $thumb.index() - 1; // exclude sliding div
_self._slideTo( idx );
return false;
});
</code></pre>
<p>I wonder how to modify it. Let the autoplay resume after 5 second or certain duration i specify. Thanks! </p>
| javascript | [3] |
421,551 | 421,552 | Is instantiating a new Rectangle repeatedly slower than changing all its fields? | <p>Currently I have this code:</p>
<pre><code>selectorRect.X = (e.X + hscTileset.Value) / tileLayer.TileSize * tileLayer.TileSize;
selectorRect.Y = (e.Y + vscTileset.Value) / tileLayer.TileSize * tileLayer.TileSize;
selectorRect.Width = 32;
selectorRect.Height = 32;
</code></pre>
<p>I am just changing all of the rectangle's fields. What if I did something like this?</p>
<pre><code>selectorRect = new Rectangle((e.X + hscTileset.Value) / tileLayer.TileSize * tileLayer.TileSize, (e.Y + vscTileset.Value) / tileLayer.TileSize * tileLayer.TileSize, 32, 32)
</code></pre>
<p>I know the second line is a lot longer and less readable and generally not recommended but I'm still curious over the speed differences or its effects on the stack or heap. Since this code is within a control's MouseMove event handler it is called quite often and I'm wondering whether or not instantiating a new object that often will cause considerable speed differences.</p>
<p>Thanks!</p>
| c# | [0] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.