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,301,996 | 2,301,997 | Android implicit intents VS explicit intents | <p>Working with android I realized that implicit intents are good choice in most of cases due to their's flexibility. But what's about explicit intents?
What are benefits of using them? What are common cases when it's a good practice to use them?</p>
| android | [4] |
1,945,255 | 1,945,256 | Writing char array to file, with escape characters written with their corresponding literals | <p>I'm trying to write a char array to file, the the escaped characters should be written with their equivalent literals (for example newline should be written as '\n' instead of actual line break in the file).</p>
<p>if the array is <code>char *arr = "hello world\n";</code>
my code should write</p>
<pre><code>char tempArr[100] ={'h','e','l','l','o','\s','w','o','r','l','d','\n'};
</code></pre>
<p>to the file.</p>
<p>is there any way to accomplish this in C++?</p>
| c++ | [6] |
5,072,687 | 5,072,688 | Defining "templated class" functions outside of a class | <p>I have this class</p>
<pre><code>template <class T> class dynamic_array
{
</code></pre>
<p>and this function:</p>
<pre><code>void dynamic_array::randorder()
{
srand(time(NULL));
int *ap;
for(ap=array;k!=array+size;++k){*k=rand();}
}
</code></pre>
<p>The compiler is complaining about my function - "not having template parameters". How do I add this in?</p>
| c++ | [6] |
1,778,421 | 1,778,422 | Javascript -- Date Time picker | <p>I have problem with a javascript date script.</p>
<p>Scripts is that;</p>
<p><img src="http://i.stack.imgur.com/OQ49M.png" alt="enter image description here">
Choose a time and when you selected</p>
<p><img src="http://i.stack.imgur.com/wuA5w.png" alt="enter image description here"></p>
<p>and print the date. However, what
i want is to show this<br>
like </p>
<p>2012-02-04</p>
<p>i changed from .js from the places </p>
<p>and now it works</p>
<p><img src="http://i.stack.imgur.com/agcGD.png" alt="enter image description here"></p>
<p>i made it from function FormatDate(pDate) from .js file.</p>
<p>but also i want to add '0' to months and days if they are less than 10</p>
<p>i find this line in .js and make it</p>
<pre><code>if(this.Month < 10)
return(this.Year+DateSeparator+('0'+this.Month+1)+DateSeparator+pDate);
</code></pre>
<p>however, doesnt works :(</p>
<p>how can i achieve this ? how can i add '0' if months and days are less than 10</p>
<p>you can reach my .js from here
<a href="http://jsfiddle.net/hxzBP/" rel="nofollow">http://jsfiddle.net/hxzBP/</a></p>
| javascript | [3] |
5,963,518 | 5,963,519 | actual objects and its references in python | <p>I'm a bit confused about actual object and its reference in python.Googled a lot but didn't get what I need. </p>
<p>Does object creation also returns a reference to that object? Why i'm asking this is because I'm able to use actual object with <code>.</code> delimiter to call its methods.We usually use reference of the object to call methods.An example might give a clear idea of what I'm asking.</p>
<p><code>l = [2,4,1,3]</code> # 'l' is a reference to actual object.Right?</p>
<p>does the RHS part create the object and return a reference to that object which'll be assigned to LHS ?</p>
<p>Because I'm able to use both <code>list.sort()</code> and <code>[2,4,1,3].sort()</code> to sort the list. Is <code>[2,4,1,3]</code> an actual object or does it yield a reference along with creating an object?</p>
<p>Similar is the case with Classes.</p>
<p><code>obj=SomeClass()</code> #obj is a reference to object created by SomeClass().</p>
<p>Does <code>SomeClass()</code> return a reference along with creating an object?</p>
<p>Because we can use both <code>obj.method1()</code> and <code>SomeClass().method1</code> to call methods.</p>
| python | [7] |
3,580,403 | 3,580,404 | Android database conectivity problem | <p>i am trying to make android (2.3) connection with mysql the code is given below:</p>
<pre><code>public class ConnectionClass {
static String user = "root";
public static void main() {
String url = "jdbc:mysql://127.0.0.1:3306/mydatabase";
// String url = "jdbc:mysql://10.2.5.69:3306/test";
try {
Class.forName("com.mysql.jdbc.Driver");
***Connection con = DriverManager.getConnection(url, user, "mypassword");***
con.isReadOnly();
System.out.println("success");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from user");
while (rs.next()) {
System.out.println("id" + rs.getInt(1));
System.out.println("data" + rs.getString(2));
}
} catch (Exception e) {
e.printStackTrace();
}
}
</code></pre>
<p>}</p>
<p>but at the line "Connection con = DriverManager.getConnection(url, user, "mypassword")" i got com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure" exception. </p>
| android | [4] |
79,357 | 79,358 | How do I do this in Python? List to function | <pre><code>def getStuff(x):
return 'stuff'+x
def getData(x):
return 'data'+x
thefunctions = []
thefunctions.append("getStuff")
thefunctions.append("getData")
for i in thefunctions:
print i('abc')
</code></pre>
<p>Is this possible? Thank you.</p>
| python | [7] |
561,766 | 561,767 | Passing a bound object method in JavaScript | <p>For a Firefox extension, I'm trying to do the following:</p>
<ol>
<li>Setup an object with two methods and a field/property/attribute</li>
<li>One of the methods has to be able to call the other method and access the attribute</li>
<li>I want to register that method as an event listener.</li>
</ol>
<p>Right now, I have it setup like a class:</p>
<pre><code>var Obj = {
field: null,
a: function() { }
b: function() {
Obj.field = 'x';
Obj.a();
}
}
window.addEventListener('mouseup', Obj.b, false);
</code></pre>
<p>But it seems like it should be possible to have the mod not refer to the object "from the outside" (e.g. by using <code>Obj</code>), but using just <code>this</code> instead. However, I can't figure out how to get this to work correctly, pass a simple function reference to <code>addEventListener()</code> <em>and</em> (preferably) only polluting the namespace with a single name. Is that possible? I tried googling for it and found e.g. <a href="http://ejohn.org/blog/simple-class-instantiation/" rel="nofollow">http://ejohn.org/blog/simple-class-instantiation/</a>, but that didn't seem to lead to something that fits my criteria of a clean setup.</p>
| javascript | [3] |
5,267,897 | 5,267,898 | How to disable onChange for a number of elements, change then, then enable onChange in jQuery | <p>I have a bunch of input elements on a page. Each input element has an onchange event that triggers an ajax call to the server. I want to disable all these onchanges then make some programatic changes to the elements (reset them), then re-enable these onchange events. I want only one ajax call to happen as a result of this.</p>
<p>How do I do this using JQuery?</p>
<p>Many Thanks!</p>
| jquery | [5] |
2,246,162 | 2,246,163 | Nested if..else... breaking parental flow? | <p>I'm running through a few scenarios with some IFs and I'm running into something that defies my logic/understanding.</p>
<p>Yes, I'm very low-level with programming, so maybe I'm royally screwing up something very rudimentary.</p>
<p>Anyway, I have something like so:</p>
<pre><code>if(condition==1) {
if(conditionA==2) {
// SAY I LOVE YOU
} else {
// SAY HEY BABY
}
}
if(condition2==1) {
if(conditionAA==2) {
// SAY I LOVE YOU
} else {
// SAY HEY BABY
}
}
</code></pre>
<p>Now, when condition1 and condition2 are both equal to 1 and conditionA and conditionAA do NOT equal 2, the else statements are fine. However, when conditionA or conditionAA DO equal 2, the whole scenario breaks at that very spot.</p>
<p>For example, conditionA DOES NOT equal 2, the else fires and if conditionAA IS equal to 2 ,stuff breaks there. If conditionA DID equal 2, the whole thing breaks right there.</p>
<p>I don't understand why :(</p>
<p>Thanks in advance. Your advice will help me to restructure this mess. </p>
| php | [2] |
2,927,576 | 2,927,577 | Saving Images in to local folder in android | <p>I created android app which reads images from url. Now I want to store those images in local file structure or SD Card. so i created a folder names "images" in my android project and added image xyz.png manually to test reading of images. </p>
<p>and wrote below code to read.</p>
<pre><code> Bitmap bMap = BitmapFactory.decodeFile("/images/xyz.png");
ImageView imgView = (ImageView) this.findViewById(R.id.imgViewId);
imgView.setImageBitmap(bMap);
</code></pre>
<p>But eclipse says unable to find the resource!!</p>
<p>What is the best way to store and read images in android app? </p>
<p>I did caching but cache get clears if i force close the app.</p>
<p>I want to store in android mobile/tablet and it should be part of app.</p>
| android | [4] |
896,896 | 896,897 | PHP: create POSTER like Firefox plugin | <p>I would like to create a PHP application like FIREFOX "Poster" plug-in <a href="https://addons.mozilla.org/en-US/firefox/addon/2691/" rel="nofollow">thisone</a> </p>
<p>basically , I want to make a call to a url with post data, that will be the body of the URL.
(I want to send the contain of the body)</p>
| php | [2] |
4,537,153 | 4,537,154 | With jquery moving one table column to a new table | <p>What I am trying to do is take the last colomn in a table placed into a new table altogether. I got this working the problem is I want this to work for multiple tables with the same class names. Right now it only takes the first tables cols and repeats them. I have an idea of why but I am not sure how to target each table as an individual element even though they all have the same class name. </p>
<p>jquery </p>
<pre><code>function fixLastColumn() {
// makes new table
var nt = $('<table class="ft_fixedTable"></table>');
$(".ft_FixedTable tr").each(function(i) {
nt.append('<tr class="ft_fixTR"><td class="ft_fixTD">'+$(this).children('td:last').html()+'</td></tr>')
})
nt.appendTo('.fixedDiv');
// remove last column
$('.ft_FixedTable tr').each(function(i) {
$(this).children('td:last').remove();
});
}
$(document).ready(function() {
fixLastColumn();
});
</code></pre>
<p>html</p>
<pre><code><table class="ft_FixedTable">
<thead>
<tr>
<td>Title 1</td>
<td class="ft_fixedCol">fixed one</td></tr>
</thead>
<tr>
<td>Content Content Content Content Content</td>
<td>Fixed content </td>
</tr>
</table>
<div class="fixedDiv"></div>
</code></pre>
| jquery | [5] |
663,023 | 663,024 | Getting the names of files in the folder | <p>Decided to put the question differently, suppose we have a file-test, there is a lot of different files, some of this type indeks.html, kiki.tht, lololo.bin and so on, to get the names of all files in a folder, you can use this code:</p>
<pre><code>File folder = new File("C:\\test\\");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println(listOfFiles[i].getName());
}
}
</code></pre>
<p>But how to display only the file name without the extension? Indeks.html looolo.tht not like (just remember files in the lot, there is no duplicate names), and the index and looolo)</p>
| java | [1] |
2,934,246 | 2,934,247 | Help to identify python module (preprocessor?) "python -m dg" | <p>On the background of this image <img src="http://i.stack.imgur.com/PgPcR.jpg" alt="image"> you can find some code, that looks like written in extended python dialect, which have to be processed with “python -m dg” to get “normal” python code.
Google has no results for “python -m dg” query, and yandex.ru has only one page in cache, which briefly mention one example</p>
<pre><code>python -m dg <<< 'sum $ map int $ str 2 ** 1000'
</code></pre>
<p>which seems to be equivalent of</p>
<pre><code>sum(map(int, str(2**1000)))
</code></pre>
<p>Do you know what this is all about? I want to take a look at this tool, but can't find any links…</p>
| python | [7] |
687,063 | 687,064 | How to log each application activity in android? | <p>Hello I want to log application activity information on my android phone, I just need 2 things, the start time of the application and the end time of the application.</p>
<p>I just want to know for how much time a particular application/activity was running. </p>
<p>Say for example a user launched music player and after some time closed it? I just want to know how long the music player opened, or if he is talking on phone how long that activity to took after finishing?</p>
<p>My application will run as service, logging all this information is sqlLite. Once my application started it should log all the above information for each activity triggered there after.</p>
<p>Please let me know how can i do this??</p>
<p>I know about logcat but i want to know how they log this things or how can i code something similar??</p>
<p>Thanks
Pranay</p>
| android | [4] |
3,562,307 | 3,562,308 | Javascript: arguments change with further apply processing | <pre><code> function Foo(){
}
Foo.prototype={
method1:function(o){
console.log(o);
}
,shorthand:function(){
if(!arguments.length || typeof arguments[0]=='undefined') {
arguments[0]={};
}
arguments[0].bar='test';
return this.method1.apply(this,arguments);
}
}
var instance=new Foo();
instance.shorthand();
console.log(o); // returns undefined
</code></pre>
<p>After a while i figured out, that assigning arguments an array fixes this.</p>
<pre><code>arguments=[{bar:'test'}];
</code></pre>
<p>I figured out, that arguments is not an array after all, or semi-array. Well it doesn't have push method.</p>
<p>Why is it doing so(i mean returns undefined)? It's been made for some purpose?</p>
| javascript | [3] |
4,361,104 | 4,361,105 | how to add session cart table in database and give all ordered items one unique orderid? | <pre><code>ProductName price brand Quantity Net AmountNet Amount Update
</code></pre>
<p>I have the above table in which I have to insert the products which users have added to their cart.
Users can add multiple products to their cart.
I have that table of user added products in the session and I am reading it row by row by taking that session table as a datatable.
I have to insert all products row by row in above table.</p>
<p>I also have another table as follows:</p>
<pre><code>orderID CartItemID RegistrationID OrderDate NetAmount Remarks Created
</code></pre>
<p>My question is, how to give one unique order id to all products ordered by a user?</p>
| c# | [0] |
230,624 | 230,625 | jQuery: Radio button selected & <span> updates | <p>I have a DIV with a list of radio buttons and a 'selected search' area (a < span >). When clicking on the 'selected search' area, a drop down layer comes out and has the DIV with the list of radio buttons. When a radio button is selected, the 'selected search' area is updated with that radio button's text and the drop down layer collapses/disappears.</p>
<p><strong>Here's my HTML structure:</strong></p>
<pre><code><div class="radio-btns"><span class="selected-search">A</span>
<div class="radio-btns-wrapper">
<label><input type="radio" value="a" id="a" checked>A</label>
<label><input type="radio" value="b" id="b">B</label>
<label><input type="radio" value="c" id="c">C</label>
<label><input type="radio" value="d" id="d">D</label>
</div>
</div>
</code></pre>
<p>Any idea how to accomplish this with jQuery? Any help will be greatly appreciated.</p>
<p>Thanks.</p>
| jquery | [5] |
4,217,268 | 4,217,269 | Random background color from array - PHP | <p>I am a beginner when it comes to programming so I wanted to see if this would be the right way to code this. I was trying to generate a random background color from an array. If there is something im missing or there is something I could do better please let me know.</p>
<pre><code><?php
$background_colors = array('#282E33', '#25373A', '#164852', '#495E67', '#FF3838');
$count = count($background_colors) - 1;
$i = rand(0, $count);
$rand_background = $background_colors[$i];
?>
<html>
<head>
</head>
<body style="background: <?php echo $rand_background; ?>;">
</body>
</html>
</code></pre>
| php | [2] |
3,340,576 | 3,340,577 | How to deploy java app for Windows pc | <p>I have studied Java Web Start and found it complex and clumsy for my purposes. In addition, my app needs to access the PC resources, which causes more hoops to be jumped through with Java Web Start. To add to the difficulties I need to access a 32-bit native library (libvlc) so I need to insure that my app runs under 32-bit Java. Is there an easy way to deploy my app without resorting to Java Web Start? Needless to say, I want everything to be contained in a single .exe file.</p>
| java | [1] |
639,927 | 639,928 | problems in using cin | <p>The program is to copy the first element of 'marks' vector into the 'all_marks' vector.Note that marks vector will be changed dynamically.</p>
<pre><code>#include <iostream>
#include <vector>
using namespace std;
istream& read_info(istream& in,vector<double>& vec);
int main(int argc, const char * argv[])
{
vector<double> marks;
vector<double> all_marks;
while (read_info(cin,marks)) //fails aftr last iteration due to error state of cin
{
all_marks.push_back(marks[1]);
}
vector<double>::size_type indx;
for(indx=0;indx<all_marks.size();++indx)
{
cout<<all_marks[indx]<<endl;
}
return 0;
}
istream& read_info(istream& in,vector<double>& vec)
{
vec.clear();
cout<<"entr mrks with * after last i/p followed by EOF at the last iteration"<<endl;
double x;
while(in>>x && x!='*')
{
vec.push_back(x);
}
return in; //in will not be in error state until the end of last iteration
// which is followed by EOF
}
</code></pre>
<p>But im not able to take the second iteration itself.Whats the problem with the code.Using 'Cin' for input seems to be very error prone.Comment if the question is not clear.</p>
| c++ | [6] |
5,450,110 | 5,450,111 | How to Use JQuery to Find All Readonly Text Boxes on a Web Page | <p>I have been asked to identify all read only text boxes in an Asp.Net page and assign a particular style. I'm pretty sure I could iterate over all of the inputs to see if they were inputs that were text boxes with the readonly attribute but I just KNOW there's a one liner.</p>
<p>Any thoughts?</p>
| jquery | [5] |
4,527,171 | 4,527,172 | Generating a unique id of std::string | <p>I want to generate any limited std::string size unique id (i.e of size 6) in 32 bit application. what would be the best and quick way to do this?</p>
| c++ | [6] |
5,306,075 | 5,306,076 | excelApp.CreateDispatch() returns a zero value : failure | <p>I have the following piece of code in Visual C++ 2005 : : </p>
<p>class _Application:public COleDispatchDriver {....};</p>
<p>_Application excelApp;</p>
<p>excelApp.CreateDispatch((LPCTSTR)_T("Excel.Application")))</p>
<p>But the call to excelApp.CreateDispatch((LPCTSTR)_T("Excel.Application"))) returns a zero value indicating a failure . </p>
<p>Could you please tell me what could be the possible reason ?</p>
<p>PS : I copied the above piece of code from an another solution ( Visual C++ 2005) where this works perfectly fine on the same machine . </p>
| c++ | [6] |
1,916,068 | 1,916,069 | Use jQuery to hide a DIV when the user clicks outside of it | <p>I am using this code:</p>
<pre><code>$('body').click(function() {
$('.form_wrapper').hide();
});
$('.form_wrapper').click(function(event){
event.stopPropagation();
});
</code></pre>
<p>And this HTML:</p>
<pre><code><div class="form_wrapper">
<a class="agree" href="javascript:;">I Agree</a>
<a class="disagree" href="javascript:;">Disagree</a>
</div>
</code></pre>
<p>The problem is that I have links inside the DIV and when they no longer work when clicked.</p>
| jquery | [5] |
5,975,368 | 5,975,369 | Broadcast receiver at a specific Time | <p>I want to create a broadcast receiver which will be invoking at the specific time say 9'o clock in morning.Is it possible in android,If yes Somebody please help me to do it</p>
| android | [4] |
5,849,329 | 5,849,330 | C# ReceiveAsync Error | <p>Im currently developing an appserver. I would like to use AcceptAsync method. I got error "Object reference not set to instance of object." when calling ReceiveAsync method. If there any come up with this problem and got the solution to it?</p>
<pre><code>public class AppServer
{
public void Start()
{
Socket serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
serverSocket.Bind(new IPEndPoint(IPAddress.Any, 12345));
serverSocket.Listen(100);
SocketAsyncEventArgs e = new SocketAsyncEventArgs();
e.Completed += new EventHandler<SocketAsyncEventArgs>(e_Completed);
bool raiseEvent = serverSocket.AcceptAsync(e);
if (!raiseEvent)
AcceptCallback(e);
}
void e_Completed(object sender, SocketAsyncEventArgs e)
{
AcceptCallback(e);
}
private void AcceptCallback(SocketAsyncEventArgs e)
{
SocketAsyncEventArgs readEventArgs = new SocketAsyncEventArgs();
readEventArgs.Completed += new EventHandler<SocketAsyncEventArgs>(readEventArgs_Completed);
Socket clientSocket = e.AcceptSocket;
bool raiseEvent = clientSocket.ReceiveAsync(readEventArgs); // <-- Error goes here
if (!raiseEvent)
ReceiveCallback(readEventArgs);
}
void readEventArgs_Completed(object sender, SocketAsyncEventArgs e)
{
ReceiveCallback(e);
}
private void ReceiveCallback(SocketAsyncEventArgs e)
{
}
}
</code></pre>
| c# | [0] |
1,967,414 | 1,967,415 | Generating satellite assembly externally | <p>I have an third party application in which there are satellite assemblies.
This application is strong name signed.
I am externally creating new satellite assembly which is not included by the third party application.
But since the main assembly is strongly signed, my newly created assembly is not been recognized by the application.
How to achieve this ? </p>
<p>Please advice</p>
| c# | [0] |
5,590,561 | 5,590,562 | Forcing Download of file using php script on CentOs 5.6 | <p>I need to authenticate user to view/download some of the files in my site. My files are located in a folder say A inside <code>public_html/mySiteName/FoldesName(A)/subFolder/sample.(*.*)</code>. I used <code>.htaccess</code> to check that the user is authenticated or not.</p>
<hr>
<p>MY <code>.htaccess</code> code :</p>
<pre><code>RewriteEngine on # Enable rewrite
RewriteCond %{REQUEST_FILENAME} \.*pdf$|.*psd$|.*indd$ [NC]
RewriteRule (.*) http://MySiteIp/admin_panel/auth.php?file=$1 [NC,L]
</code></pre>
<p>My download script looks like :</p>
<pre><code>if($authed){
if(file_exists("../".$_GET['file'])) {
//Create the pointer to our file and open it as read-only binary data
$fp = fopen($file,'rb');
// Send headers telling browser to download our passed data
header("Content-Type: application/force-download");
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Length: " . filesize($file));
header("Accept-Ranges: bytes");
header("Content-Disposition: attachment; filename=\"$file\"");
while (!feof($fp)) {
echo(@fgets($fp, 8192));
}
//Here comes the data
fclose($fp);
//and quit
exit;
} else {
echo "No file exists !!!";
}
}
</code></pre>
<p>When I test it on my local machine with Xampp Server installed on it. It works. But on my host I get the error message "NO file exists".</p>
<p>Please help me to find where I am wrong...</p>
| php | [2] |
5,048,694 | 5,048,695 | Socket.Close() | <p>as i understand it in C# u pass a copy of the reference by default,
no for my Example </p>
<p>iv'e got 2 Forms witch in the first a Socket connects and then is being passed in the constractor to the other form </p>
<p>now as i understand it they both have a reference to the same place in memory ,
now in the second form i call Socket.Close()
when the second form closes , the first form is up</p>
<p>and the socket witch is used there was of course set to close, i want to detect that status of the socket
something like if(Socket.Closed) </p>
<p>this is because in some situations i Call Socket.Disconnect(true) , and when errors occur i call Socket.Close() </p>
<p>my questions are :
1) how to detect if a socket is closed and not disconnected on The side it was closed on,
(please try to understand that i could well of said a oledb connection,the socket is not
the issue as much as detecting if a closeable object was closed)
2) can the reference of the Socket object be set to null , then the other Socket would also reference null and that i could detect </p>
| c# | [0] |
685,498 | 685,499 | running java on linux server | <p>I would like to run a jar file extracted from my java project to be run on a Linux server I connect through SSH Tunneling. There are few problems, first there is something wrong with the Display: I get the error </p>
<pre><code>No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173)
at java.awt.Window.<init>(Window.java:437)
at java.awt.Frame.<init>(Frame.java:419)
at java.awt.Frame.<init>(Frame.java:384)
at javax.swing.JFrame.<init>(JFrame.java:174)
at random_v2.v2Frame.<init>(v2Frame.java:127)
at random_v2.Wrapper.main(Wrapper.java:25)
</code></pre>
<p>and second is that I am not sure if I have to install other applications as well. In my code, the java program needs to get run other applications like weka, do I have to install weka with the same directory name and specs that is in my mac?
I appreciate your help in advance.
Best wishes</p>
| java | [1] |
5,222,209 | 5,222,210 | Difference between '$("#foo")' and 'jQuery("#foo")' | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6608002/jquery-selecter-whats-difference-between-jqueryelement-and-element">jQuery selecter whats difference between jQuery(“element”) and $(“element”)?</a> </p>
</blockquote>
<p>Just a little curious..</p>
<p>Why sometime I see it written as <code>$("#SomeElementId")</code> and sometime as <code>jQuery("#SomeElementId")</code> ? What is the exact difference ?</p>
| jquery | [5] |
3,938,044 | 3,938,045 | for loop finding the prime numbers | <p>I am trying to run this code to print the sum of all the prime numbers less than 2 million. This loop is never ending. Can anyone tell me what is wrong with the code? It seems to work with smaller numbers though.</p>
<pre><code>public static void main(String[] args) {
long result = 1;
for(int i=0; i<2000000; i++) {
if(isPrime(i)) {
result+= i;
}
}
System.out.println(result);
}
private static boolean isPrime(long n) {
boolean result = false;
for(long i=2; i<(long)Math.sqrt(n); i++) {
if(n%i == 0) {
result = false;
break;
}
else result = true;
}
return result;
}
</code></pre>
| java | [1] |
2,264,523 | 2,264,524 | PHP: moving form $_FILES to $_GET | <p>I have one old function that i need to edit</p>
<pre><code>doSome($_FILES['image']);
</code></pre>
<p>my quesiton is how can i use the same function in order to get a file form GET instead of uploading it?</p>
<p>if i change to</p>
<pre><code>doSome($_GET['image']);
</code></pre>
<p>it doesn't sound to work...</p>
| php | [2] |
1,416,986 | 1,416,987 | How to reboot android phone from kernel code | <p>Is it possible to reboot by calling <code>SYSCALL(sys_reboot,sys_reboot,sys32_reboot_wrapper)</code>?</p>
| android | [4] |
2,167,102 | 2,167,103 | Unable to load default.aspx, 'App_Web_XXXX' | <p>I have done a project and it is working fine for me in local system but when i publish the website and uploaded through our site and checking the page i am getting the error as follows</p>
<p><code>unable to load default.aspx, 'App_Web_XXXX'</code></p>
<p>Can any one tell what the problem was</p>
| asp.net | [9] |
4,039,468 | 4,039,469 | PHP How to find a line begining with a word from a text file | <p>I have a text file with following lines</p>
<blockquote>
<p>Manifest-Version: 1.0<br>
MIDlet-Vendor: Croco Gamez<br>
MIDlet-Version: 1.0.0<br>
MIDlet-1: Quan, /icon.png, CGTQ<br>
MicroEdition-Configuration: CLDC-1.0<br>
Created-By: 1.4.2 (Sun Microsystems Inc.)<br>
MIDlet-Icon: /icon.png<br>
MIDlet-Name: Quan<br>
MicroEdition-Profile: MIDP-2.0</p>
</blockquote>
<p>I want to find the line start with <code>MIDlet-1</code> and Remove paragraph from end of this line
Please help me</p>
| php | [2] |
2,765,330 | 2,765,331 | Regarding using android ksoap2 web servies | <p>am trying do one example in android ksoap2 web services.i tried one example in below url</p>
<p><a href="http://naveenbalani.com/index.php/2011/01/invoke-webservices-from-android/" rel="nofollow">http://naveenbalani.com/index.php/2011/01/invoke-webservices-from-android/</a></p>
<p>now am getting java.net.sockettimeoutexception connection timed out in my logcat</p>
<p>can anyone please help in resolving this issue.</p>
| android | [4] |
511,149 | 511,150 | Why does sometimes DateTime.TryParse work and other time only DateTime.ParseExact work? | <p>I have two laptops both with windows xp sp3, vs 2010 and target framework .Net 3.5. When processing DateTime variable, I found that with laptop1 </p>
<pre><code>DateTime oldOrderDate;
string strnewdate = string.Empty;
CultureInfo provider = CultureInfo.InvariantCulture;
if (DateTime.TryParse(items[1], out oldOrderDate))
strnewdate = oldOrderDate.ToString("yyyy-MM-dd");
</code></pre>
<p>returned an exception "string was not recognized as a valid datetime" , but the codes below:</p>
<pre><code>oldOrderDate = DateTime.ParseExact(items[1], "dd/MM/yyyy", provider);
strnewdate = oldOrderDate.ToString("yyyy-MM-dd");
</code></pre>
<p>works. OTOH, with laptop2, </p>
<pre><code>oldOrderDate = DateTime.ParseExact(items[1], "dd/MM/yyyy", provider);
strnewdate = oldOrderDate.ToString("yyyy-MM-dd");
</code></pre>
<p>returned an exception "string was not recognized as a valid datetime" , but the code below:</p>
<pre><code>if (DateTime.TryParse(items[1], out oldOrderDate))
strnewdate = oldOrderDate.ToString("yyyy-MM-dd");
</code></pre>
<p>works. So, my question is how I should do processing of a DateTime variable to work in both laptops. I'd really appreciate any advice you could give me. Thank's in advance.</p>
| c# | [0] |
201,542 | 201,543 | How can I create directories recursively? | <p>Is there a Python method to create directories recursively? I have this path:</p>
<pre><code>/home/dail/
</code></pre>
<p>I would like to create</p>
<pre><code>/home/dail/first/second/third
</code></pre>
<p>Can I do it recursively or I have to create one directory after the other?</p>
<p>The same thing for:</p>
<p><strong>chmod</strong> and <strong>chown</strong> can I do it recursively without assign permissions for each file/dir?</p>
<p>Thank you!</p>
| python | [7] |
1,825,768 | 1,825,769 | Iphone-SDK "unable to read symbols error" when linking to IBOutlet in tab based app | <p>I built a very simple tab based app with 2 tabs, each tab tied to its own view controller. </p>
<p>Straightforward so far. I then create a simple IBOutlet on my 2nd view controller like so</p>
<pre><code>#import <UIKit/UIKit.h>
@interface bViewController : UIViewController {
IBOutlet UITextField *aField;
}
@property (nonatomic, retain) UITextField *aField;
@end
</code></pre>
<p>then i synthesize it in my .m file, then i go into my xib, drag a text field onto the view and then set the files owner to 'aField'. </p>
<p>Very textbook so far. </p>
<p>It builds, but when i run it and select the 2nd tab (which shows the view where i've linked the UITextfield IBOutlet), it throws this error. </p>
<pre><code>warning: Unable to read symbols for "/System/Library/Frameworks/UIKit.framework/UIKit" (file not found).
warning: Unable to read symbols from "UIKit" (not yet mapped into memory).
warning: Unable to read symbols for "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" (file not found).
warning: Unable to read symbols from "CoreGraphics" (not yet mapped into memory).
</code></pre>
<p>which is VERY ODD because this only started happening recently. Any clues?</p>
<p><strong>UPDATE:</strong></p>
<p>I'm beginning to suspect a config error rather than a syntax error because these are stripped down samples i created just to demonstrate the problem. This fails only when i create a tab-based application. </p>
<p>if i do the EXACT same thing in a view-based application, it works fine. </p>
| iphone | [8] |
1,455,951 | 1,455,952 | how to display the tamil content website in default browser | <p>how to show tamil language characters in android ,i have simple webview apllication ,it loads the url of tamil news site which contains tamil characters ,but its showing [][][][ at place of those characters ,even the default android browser shows the same (not showing the hindi or tamil characters ) the android version is 2.1, text encoding is set on unicode(UTF-8) in default android browser .,is there is any way to get the support for tamil characters i hope my question is clear ,</p>
| android | [4] |
5,271,418 | 5,271,419 | Python - call until I get a return value? | <p>I am calling a function to get the file a user selects in a simple gui. I am trying to determine the proper way to continue prompting the user until they select a file. Right now my call is:</p>
<pre><code> file_path = None
while file_path is None:
file_path = input_text_file() # calls function to prompt user
</code></pre>
<p>Is there a better way to do this without initially setting file_path to None? Is there a way to loop until a value is returned, or something along those lines?</p>
| python | [7] |
5,752,531 | 5,752,532 | Clone of jQuery Ui is not work | <p>I have jquery program to do for drag the clone of the element. When user drag the elements it make clone of it and dragged. But when another time trying to drag it did not work.<br>
Here is the code....<br>
for drag...</p>
<pre><code> jQuery('.item-art').draggable({
helper: function () {
return jQuery(this).clone(true).appendTo('body').css({'zIndex':5});
},
cursor: 'move'
});
</code></pre>
<p>for drop...</p>
<pre><code> jQuery('#canvas').droppable({
activeClass: 'ui-state-hover',
accept: '.item-art',
drop: function (event, ui) {
var $canvas = jQuery(this);
if(!ui.draggable.hasClass('canvas-element')) {
var $canvasElement = ui.draggable.clone(true);
$canvasElement.addClass('canvas-element');
$canvas.append($canvasElement);
$canvasElement.css({
left: (ui.position.left - $canvas.offset().left),
top: (ui.position.top - $canvas.offset().top),
position: 'absolute'
});
</code></pre>
<p>for resize and again draggable...</p>
<pre><code>var elementMethods = {
afterSpawn: function($spawnedElement) {
if(typeof $spawnedElement.data('resizable') !== 'object') {
$spawnedElement.resizable({
handles: 'n, e, s, w'
}).draggable({ cursor: 'move'});
}
</code></pre>
<p>I can't know why first time the widget element dragable but not the second time? </p>
| jquery | [5] |
5,280,536 | 5,280,537 | how to remove the exception, System.InvalidOperationException? | <p>code is given below </p>
<pre><code>Queue<int> queXpTrackerX = new Queue<int>(10);
Queue<int> queXpTrackerY = new Queue<int>(10);
if (iCounterForXpTrack < 10)
{
queXpTrackerX.Enqueue(X);
queXpTrackerY.Enqueue(Y);
iCounterForXpTrack++;
}//End IF
else
{
queXpTrackerX.Dequeue();
queXpTrackerY.Dequeue();
queXpTrackerX.Enqueue(X);
queXpTrackerY.Enqueue(Y);
}//End else
for (int indexXp = 0; indexXp < iCounterForXpTrack; indexXp++)
{
gXpTracker.DrawEllipse(Pens.Cyan, queXpTrackerX.ElementAt(indexXp) , queXpTrackerY.ElementAt(indexXp), 5, 5);
}//end for
</code></pre>
| c# | [0] |
161,965 | 161,966 | php in body -- missing something obvious | <p>My PHP is not PHPing, so made simple test... must be missing something obvious.</p>
<pre><code><html>
<head>
</head>
<body>
<?php echo '<script language=\"javascript\">confirm("Do you see this?")</script>;'; ?>
</body>
</html>
</code></pre>
<p>In code body, I get: <code>confirm("Do you see this?");'; ?></code></p>
<hr>
<p>When I "View Source", I see:</p>
<p><code>
<html>
<head>
</head>
<body>
<?php echo '<script language=\"javascript\">confirm("Do you see this?")</script>;'; ?>
</body>
</html>
</code></p>
| php | [2] |
4,910,781 | 4,910,782 | Obtaining Coordinates from "Share this place" in Google Maps | <p>When viewing the details of any location in Google Maps, there's an option for "Share this place". I have successfully added myself to the list of receivers by adding this intent-filter to my application in the manifest:</p>
<pre><code><intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</code></pre>
<p>The extras passed along with this bundle are Intent.EXTRA_SUBJECT and Intent.EXTRA_TEXT. I retrieved these extras in my activity using:</p>
<pre><code>Bundle extras = getIntent().getExtras();
</code></pre>
<p>Intent.EXTRA_SUBJECT contains a string with the title of the location.
Intent.EXTRA_TEXT contains a string with a detailed address of the location and a mobile maps URL.</p>
<p>Is it at all possible to retrieve the GPS co-ordinates (latitude and longitude) of the location from the "Share this place" action?</p>
| android | [4] |
4,470,116 | 4,470,117 | How to disable USB MTP-connection (Honeycomb) | <p>I'm using Samsung Galaxy tab 10.1. After connecting it to PC, I always get message "USB MTP-connection", when I connect it to AC to fill the battery. </p>
<p>I can only charge the battery if tablet is tuned off.</p>
<p>Any good solution how to turn this USB MTP connection off so I could normally charge battery.</p>
| android | [4] |
36,757 | 36,758 | Turn ISO 8601 date/time into "x minutes ago" type of string | <p>So I have an ISO 8601 date/time stamp like "2011-04-21T17:07:50-07:00", and I would like to convert it to say something like "23 minutes ago" or something of that sort. Is there a small bit of Java code or a library that would be able to do something like that easily?</p>
<p>Thanks!</p>
| java | [1] |
4,233,077 | 4,233,078 | Jquery how to get a hiddeninput given a data attribute | <p>I have some checkboxes with class mycheckbox and a html5 attribute position.</p>
<p>For every checkbox of this class that is checked I want to get the related hidden input with class header that has the same html5 attribute value for data-position. I want to make a list of the values of the hiddenfields.</p>
<p>So a checkbox would look like this</p>
<pre><code><input type="checkbox" class="mycheckbox" data-position="@item.Position"/>
</code></pre>
<p>and a hidden input wuold look like this:</p>
<pre><code><input type="hidden" data-position="@item.Position" />
</code></pre>
<p>So I came up with:</p>
<pre><code>$('input:checkbox.mycheckbox:checked').each(function () {
var position = $(this).data('position');
$('input:hidden.header[data-position=need somehow to get position in here]').each(function () {
});
});
</code></pre>
<p>So I'm unsure how to specify the position value from the checkbox in the search for the hidden elements and also how to set the values from each hidden field to a list</p>
| jquery | [5] |
2,043,859 | 2,043,860 | java.nio.channels.NonWritableChannelException when try to get backup apk file | <p>I want to get backup installed apk. by using H<a href="http://stackoverflow.com/questions/8307034/how-to-get-the-apk-file-of-an-application-programatically">ow to get the .apk file of an application programatically</a> and I get the apk File. and when I try to take backup to another file I get</p>
<pre><code>Caused by: java.nio.channels.NonWritableChannelException
</code></pre>
<p>code to get backup the file:</p>
<pre><code>File sourceFile = new File(app.publicSourceDir);
File backupFile = new File(Environment.getExternalStorageDirectory(), "SoundRecorder.apk");
if(!backupFile.exists())
backupFile.createNewFile();
if(sourceFile.exists()) {
FileChannel src = new FileInputStream(sourceFile).getChannel();
FileChannel dst = new FileInputStream(backupFile).getChannel();
dst.transferFrom(src, 0, src.size()); <--here I get the exception
src.close();
dst.close();
}
</code></pre>
<p>I write android.permission.WRITE_EXTERNAL_STORAGE in manifest.xml also.</p>
| android | [4] |
5,619,096 | 5,619,097 | Does setInterval leak? | <p>i'm doing some javascript, where I repeadetly click a button, using </p>
<pre><code>setInterval(function(){
clickmyButton()
}, 500);
</code></pre>
<p>Eventually clickmyButton will send the user to another page (via window.location.href="Other page"). I was wondering, since I never called clearInterval within the function will it cause a leak? I just assumed that since the page goes to another page, the javascript on the old page will stop running and be cleaned up.</p>
| javascript | [3] |
3,913,361 | 3,913,362 | Voice to text conversion : Help on opening a file through converted text and minimizing and maximizing an application | <p>The project is in c#</p>
<p>Process.Start(@"D:\Documents and Settings\All Users\Desktop\"+textBox1.Text+".exe");
It displays "cannot find the path specified.</p>
<p>Actually i am working on a project that converts voice to text and executes the applications through the converted text..</p>
<p>I am not able to find any way of maximizing and minimizing the application and opening it </p>
<p>Can you please suggest me some other way to open the file or correct me if i am terribly wrong here..
It will be really helpful for me to complete my project in C# i am a final year student
Thanx in advance :)</p>
| c# | [0] |
4,603,382 | 4,603,383 | How to best UNLOAD content in a DIV using LOAD or HTML to manage resources? | <p>I am using jQuery 1.6.2.</p>
<p>In a master page, I open up several divs that will later be populated with info through the use of buttons:</p>
<pre><code><input type="button" id="ButtonOne">
<input type="button" id="ButtonTwo">
<input type="button" id="ButtonThree">
<div class="SectionDiv" id="DivOne"></div>
<div class="SectionDiv" id="DivTwo"></div>
<div class="SectionDiv" id="DivThree"></div>
</code></pre>
<p>I make a call to populate the divs like this:</p>
<pre><code>$("#ButtonOne").click(function() {
$("#DivOne").load("FileOne.html");
});
</code></pre>
<p>When I popule a div, I want to get rid of everything in the other divs. I have done this two different ways. Like this:</p>
<pre><code>// METHOD ONE
$("#ButtonOne").click(function() {
// UNLOAD ALL DIVS
$(".SectionDiv").load("BlankPage.html");
// LOAD THE DIV THAT NEEDS TO BE LOADED
$("#DivOne").load("FileOne.html");
});
// METHOD TWO
$("#ButtonOne").click(function() {
// UNLOAD ALL DIVS
$(".SectionDiv").html("");
// LOAD THE DIV THAT NEEDS TO BE LOADED
$("#DivOne").load("FileOne.html");
});
</code></pre>
<p>In method one, I load the div with a page that has no content, a completely empty page. In method two, I use html("") with the same effect(?).</p>
<p>While these two methods have the same visual outcome, does one have a distinct advantage over the other for killing existing variables in the divs, or detaching elements better from the DOM, or anything? Is one faster in certain environments than the other? Does one hog more resources than the other?</p>
| jquery | [5] |
4,174,373 | 4,174,374 | How can you read and write to a MySQL database starting at a JavaScript web game? | <p>First of all, I'm not much of a programmer if at all. This question may seem silly but I would honestly like some advice from real programmers. </p>
<p>I'd like to make a bit of an adventure game on a webpage. </p>
<p>Could I make it by having a MySQL database setup to store variables while JavaScript, HTML and CSS is used for the user interface and JavaScript for the game programming and PHP to communicate with MySQL. </p>
<p>I don't entirely understand it but I followed a tutorial and got it working. It also showed me how you can replace text on the screen by giving that text an elementid and then just setting its value to other text.</p>
<p>In this tutorial script, it has it so when the JavaScript file wants to communicate with php, it will open the php file with a ?=value at the end of the hyperlink where the value part turns into some kind of MySQL search value. </p>
<p>Something like this:
xmlhttp.onreadystatechange=function()
xmlhttp.open("GET","index.php?q="+str,true);</p>
<p>and then in the PHP file:
$q=$_GET["q"];
$sql="SELECT * FROM user WHERE id = '".$q."'";</p>
<p>This means you will always search by specific id number. The problem with this is that the php file is always set to look at the exact same table. </p>
<p>Sometimes you want to look at different tables, or multiple values from multiple tables, etc. Basically, you should be able to select each value like it's a record from one of those automatic DJs that radio stations used to have. Also, sometimes you'd want to write or append the database like when variables change and need to be updated and all of that has to happen securely. </p>
<p>The only thing I can think of is to have a ton of php files that work the same way and call the appropriate file when you want a certain kind of response. But then if I have a file on my website that has a php file that lets me write TO the database then someone can just read the javascript code, see that, and then basically hijack the mysql database.</p>
<p>So how can I securely do this?</p>
| javascript | [3] |
496,431 | 496,432 | Hello, I want to translate my web from spanish to english and to use only english, this website is in making in php , how to do this? | <p>My website is: https:\literion.com , I use a php script what is in spanish and I want to make this website in english, but I am a really noob in php and I don't know how to make this easy, I don't want a auto-translation if is not possible but i want to know what need to modify or exist some plugins or something like this from codecanyon or other sites like this to can translate this site in english? Thanks for help!</p>
| php | [2] |
4,276,913 | 4,276,914 | how to launch my application in iphone? | <p>I have build one of my application on iphone but refuse to build that on m iphone .</p>
<p>Can u tell me the proper steps for launching my application on my iphone and step by step procedure for setting the project settings.</p>
| iphone | [8] |
3,321,676 | 3,321,677 | programming g-adic expansion in c++ | <p>I want to program the g-adic expansion in the c++ language, but whatever I try, the output is still wrong. Let me first explain what the g-adic expansion is. The g-adic expansion is a way to represent numbers. For example, binary numbers, this is the 2-adic expansion of numbers. And hexadecimal is 16-adic expansion. So here is my code:</p>
<pre><code>#include <iostream>
#include <cmath>
#include <complex>
#include <valarray>
using namespace std;
int main()
{
int x;
int g;
cin>>x;
cin>>g;
int k=log(x)/log(g)+1;
int e;
int b=0;
int* myArray=NULL;
myArray=new int[k];
for(int i=0;i<k;i++)
{
myArray[i]=0;
}
while(b!=k)
{
e=x/(g^(k-b-1));
myArray[b]=e;
x=x-e*g^(k-b-1);
b++;
}
b=0;
while(b!=k)
{
cout<<myArray[b]<<endl;
b++;
}
delete [] myArray;
myArray=NULL;
return 0;
}
</code></pre>
<p>So for example if I want to convert 105 to binary, x=105 and g=2, k is the length of the new number. In this case that is 7. int e=105/2^(7-1)=1. This is the first number. Then x=105-1*2^(7-1)=41. If you do this by hand, you will find that 105 becomes 1101001. But if I compile this piece of code, it just doesn't work. My question is what is wrong with this code?</p>
| c++ | [6] |
3,928,656 | 3,928,657 | What is _tmain at all? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/895827/what-is-the-difference-between-tmain-and-main-in-c">What is the difference between _tmain() and main() in C++?</a> </p>
</blockquote>
<p>I found it in <a href="http://msdn.microsoft.com/en-us/library/aa365588%28v=VS.85%29.aspx" rel="nofollow">this post</a>, but never see that before.</p>
| c++ | [6] |
5,357,723 | 5,357,724 | Alarm keeps triggering after set time | <p>could you please have a look at this</p>
<pre><code>if(current.getTimeInMillis() < cal.getTimeInMillis()){
//current.add(Calendar.MINUTE, 15);
alarms.setRepeating(AlarmManager.RTC_WAKEUP, current.getTimeInMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, alarmIntent);
Toast.makeText(this, "Alarm will go of 15mins from now", Toast.LENGTH_SHORT).show();
}else {
alarms.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), alarmIntent);
Toast.makeText(this, "Alarm set in " + cal.getTimeInMillis() + " seconds",
Toast.LENGTH_LONG).show();
}
</code></pre>
<p>current.getTimeInMillis() is the system time and cal.getTimeInMillis() is a set time that i want an event to occur. i am trying to make an alarm every 15 mins as long as the system time is not greater than the designated set time and when the set time has reached, the alarm should go off. but my problem is, it keeps repeating every 15 minutes even after the past set time and it completely ignores the code in the else block.Am i doing the logic incorrectly?.. Any ideas will be greatly appreciated. Thank you.</p>
| android | [4] |
1,032,608 | 1,032,609 | How to implement event listener in background of the main program in java? | <p>Hi im a beginner so sorry for my question if it sounds naive.</p>
<p>I want to implement a thread that runs in the background and listens all the time. By listening i mean, say it keeps check on a value returned from main thread and if the vaue exceeds certain figure, it executes some method, or say exits the program. </p>
<p>If you could give me some idea or at least refer me to something useful, that'll be great.</p>
| java | [1] |
2,357,008 | 2,357,009 | Legal use of countdown timer? | <p>I am using a countdown timer to perform a repeating task. I want to be sure what I'm doing is valid since I'm not sure if the countdown timer object gets destroyed when it times out. Same question applies if I call the cancel method. Here is my code:</p>
<pre><code> public class MyCount extends CountDownTimer
{
public MyCount(long millisInFuture, long countDownInterval)
{
super(millisInFuture, countDownInterval);
}
@Override
public void onFinish()
{
new myAsyncTask().execute();
this.start();
}
@Override
public void onTick(long millisUntilFinished)
{
}
}
</code></pre>
| android | [4] |
3,827,274 | 3,827,275 | ASP.NET [How to check if SqlDataSource1 is empty] | <p>I make SqlDataSource1.DataBind(); with some parameters on button click,</p>
<p>then I'm working with a Grid onDataBound();</p>
<p>but if my SqlDataSource1 returns empty data I've got an error even if I'm trying to check if (GridView2.HeaderRow.Cells.Count != 0) so I guess I need to check it on SqlDataSource1 someway.</p>
<p>Question : How ?</p>
<p>Thank you.</p>
| asp.net | [9] |
970,787 | 970,788 | How to record video in iphone | <p>HI,</p>
<p>I need to record video using iPhone. To do that i used UIImagePickerController. I have an iPhone 3G, with me. when i run my code to check if source type available it says device not supported. My OS is 3.2.1, where i am wrong, can some one tell me what i need to change. </p>
<p>Also is there some other way to record video. What i need to do is to get the video stream as it is recorded. </p>
<pre><code> UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
NSArray *sourceTypes =
[UIImagePickerController availableMediaTypesForSourceType:picker.sourceType];
if (![sourceTypes containsObject:(NSString *)kUTTypeVideo ]){
NSLog(@"device not supported");
return;
}
//picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeVideo];
picker.videoQuality = UIImagePickerControllerQualityTypeHigh;
[self presentModalViewController:picker animated:YES];
</code></pre>
<p>Thanks,</p>
| iphone | [8] |
4,601,397 | 4,601,398 | c++ bitset questions | <p>I want to ask two C++ bitset questions.</p>
<p>(1) How to create a bitset with a specified length from a function argument? I mean, for example, I have a function </p>
<pre><code>void f(int n)
</code></pre>
<p>And inside <code>f</code>, I need to create <code>bitset<n> bs;</code> Is this something doable?</p>
<p>(2) How to copy part of a bitset <code>bs</code> to form a new bitset? For example, given <code>starting index i1</code> and <code>ending index i2</code> where <code>i1</code>>=<code>i2</code>, I need to form a new bitset by copying those bits in <code>bs</code> from the least <code>i2</code>th significant bit exclusive to the least <code>i1</code>th significant bit inclusive (just to conform with <code>STL</code> convention).</p>
<p>Thank you.</p>
| c++ | [6] |
1,687,817 | 1,687,818 | Avoid Race Conditions in PHP on Submit: Please do not click submit more than once! | <p>A while back, online apps used to say, "do not click submit more than once." That's gone now, right? How do you guard against that in, say, PHP?</p>
<p>One solution I'm using involves putting a variable in the Session, so you cannot submit to a page more than once every 10 seconds. That way the database work will have completed so the normal checks can take place. Obviously, this feels like a hack and probably is.</p>
<p><strong>Edit:</strong> Thanks everybody for the Javascript solution. That's fine, but it is a bit of work. 1) It's an input type=image and 2) The submit has to keep firing until the <a href="http://labs.adobe.com/technologies/spry/" rel="nofollow">Spry stuff</a> says it's okay. This edit is just me complaining, basically, since I imagine that after looking at the Spry stuff I'll be able to figure it out.</p>
<p><strong>Edit:</strong> Not that anyone will be integrating with the Spry stuff, but here's my final code using Prototype for the document.getElementByid. Comments welcome!</p>
<pre><code>function onSubmitClick() {
var allValid = true;
var queue = Spry.Widget.Form.onSubmitWidgetQueue;
for (var i=0;i<queue.length; i++) {
if (!queue[i].validate()) {
allValid = false;
break;
}
}
if (allValid) {
$("theSubmitButton").disabled = true;
$("form").submit();
}
}
</code></pre>
<p>For some reason, the second form submit was necessary...</p>
| php | [2] |
1,804,052 | 1,804,053 | maemo or android | <p>Which one is better to use maemo or android!!as both of them are linux based ????</p>
| android | [4] |
2,255,555 | 2,255,556 | richtextbox dosn't support arabic | <p>hi all
when i replace english characters in richtextbox with arabic characters, it appears to be question marks instead of the arabic characters.
but when i try to write in the richtextbox directly with arabic, it accepts
is there is any solution for the problem of replacing?
thanks in advance.</p>
| c# | [0] |
4,527,145 | 4,527,146 | php if to include html | <p>PHP isn't really my language of choice, that being said I remember seeing a php <code>if</code> being used something like this:</p>
<pre><code><?php
if (blah) {
?>
// loads of html and js that doesn't need to be escaped since we closed
// the php already with "?>"
<?php
}
?>
</code></pre>
<p>Or something like this. I don't know what it's called and googling php if doesn't help.</p>
<p>What's this technique called and what's the correct syntax for it?</p>
| php | [2] |
3,692,893 | 3,692,894 | Javascript: generate random nice saturated colors (selected palette) | <p>i saw a lot of Js example but none fit my needs:</p>
<p>I'd like to have a script to generate colros, but if I use the common solution</p>
<pre><code>color = '#'+Math.floor(Math.random()*16777215).toString(16);
</code></pre>
<p>it generates pastel colors, where I'd like better more saturated colors...or more ambitious, how can i select the palette form which i pick the colors?</p>
<p>how can I "restrict" the randomness?</p>
| javascript | [3] |
4,595,112 | 4,595,113 | ThreadLocal Initialization in Java? | <p>I'm building a singleton that has a ThreadLocal as an instance variable, this singleton has a method that may be accessed by multiple threads and it is lazily instantiated. Right now I'm thinking on something like this:</p>
<pre><code>static final ThreadLocal<HashMap> bindingContext = new ThreadLocal<HashMap>();
</code></pre>
<p>But I'm not sure if it is a good idea, I also have the option to make it an instance variable since I'm using it (as I said on a singleton).</p>
<p>So the question is, where is the best place to initialize that class variable or should it be a class variable at all?</p>
| java | [1] |
2,268,328 | 2,268,329 | VM Limit in Android 2.0 | <p>Is there a way to expand the VM limit in Android 2.0 on an actual device? Using <code>java.lang.Runtime.maxMem()</code> on a Droid reveals a limit of 24MB, and I've written some code that incrementally allocates memory until failure to verify that figure. You can set the VM size in the emulator, but I haven't yet found a way to do that for a connected phone. Is there some type of a properties file on the device itself that can be modified?</p>
| android | [4] |
3,060,737 | 3,060,738 | How do I properly dereference a buffer? | <p>I am having some memory problems with a project of mine. After a bit of tracing memory on several positions in my program, I retraced the problem to this line:</p>
<pre><code>(FloatBuffer)lightBuffer.asFloatBuffer().put(lightAmbient).flip()
</code></pre>
<p>I am using the resultant buffer in a function straight away, but it seems that that float buffer is not emptied after it has been used.
So how do I properly empty/dereference a buffer in java? </p>
<p>ps: I tried the clear() method, but according to the java documentation that only resets the buffer; it does not remove the data from it.</p>
| java | [1] |
5,832,499 | 5,832,500 | PHP - extracting words from a list in a text | <p>I have a list of whitelisted words: <code>kitchen chair table</code>;</p>
<p>Given a text, I would like to know which of those white-listed words are in it.</p>
<p>What would be a <em>good</em> way to achieve this? I mean, easy to understand, with good performances?</p>
| php | [2] |
2,228,044 | 2,228,045 | Implied string comparison, 0='', but 1='1' | <p>I was debugging something and discovered some strangeness in JavaScript:</p>
<pre><code>alert(1=='') ==> false
alert(0=='') ==> true
alert(-1=='') ==> false
</code></pre>
<p>It would make sense that an implied string comparison that 0 should = '0'. This is true for all non-zero values, but why not for zero?</p>
| javascript | [3] |
5,324,826 | 5,324,827 | Youtube video play with android player | <p>How will we play youtube video with android media player???</p>
<p>Anybody has idea then please explain me.</p>
<p>I have to play the URL:"http://www.youtube.com/embed/bIPcobKMB94?autoplay=1" with android default media player.</p>
<p>When i played this url with android media player, i got MediaPlayer error (1, -2147483648).</p>
<p>I play that url in my android device media player but now i am not able play in tablet. Anybody help me. <strong>Why i am not able to play that video in tablet?</strong> </p>
<p>rtsp://v6.cache3.c.youtube.com/CiILENy73wIaGQnokCRYfXXPsBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp</p>
<p>Thanks</p>
| android | [4] |
5,576,137 | 5,576,138 | char and int in Java | <p>I was surprised to see this code work. I thought that char and int were two distinct data types in Java and that I would have had to cast the char to an int for this to give the ascii equivelent. Why does this work?</p>
<pre><code>String s = "hello";
int x = s.charAt(1);
System.out.println(x);
</code></pre>
| java | [1] |
1,272,430 | 1,272,431 | How do I set an empty list of a certain type | <p>We have <code>Collections.EMPTY_LIST</code> but it is not typed, which shows an eclipse warning. How do I set an empty list of a certain type.</p>
| java | [1] |
74,763 | 74,764 | JavaScript external file does not show variables | <p>Well I am pretty new at javascript. Problem is
when I write stuff , for example a variable or array in an external js file, and embed it with , VStudio 2008 intellisense does not show any of the variables ... is it because I cannot access to variables in one script tag from another? if so How do I use jQuery like stuff? .. I defined an array in a js file, embedded it, but the intellisense does not show it ... it s a problem with the intellisense i think, is it?</p>
| javascript | [3] |
398,126 | 398,127 | C++ Convert Binary File to Image | <p>I'm trying to make a C++ console app that can convert binary(mp3) files to images. How can I read every binary character in the file, convert to hex, and then save it as an image. <a href="http://stackoverflow.com/questions/3408864/how-can-i-convert-a-binary-file-to-another-binary-representation-like-an-image/3408998#3408998">Here</a> is what I want but in C++</p>
| c++ | [6] |
3,145,972 | 3,145,973 | Reset JavaScript Counter? | <p>I am trying to program a counter into a website via JavaScript and have found exactly what I need here:
<a href="http://www.w3schools.com/js/js_timing.asp" rel="nofollow">http://www.w3schools.com/js/js_timing.asp</a></p>
<p>What I am trying to do is count down from 30 to 0. Once the counter reaches zero I want to display an alert. I have been able to get this to work. The only function that I cannot figure out is how to reset my counter back to 30 on a certain button push. I have tried code such as <code>document.gameForm.txt.value=30;</code> but for whatever reason 30 does not replace whatever text is currently in the box.</p>
| javascript | [3] |
4,603,255 | 4,603,256 | What is a log file and how can we create a log file in android? | <p>I don't have any knowledge about the log files. what are log files and how can we create a log in android? Please help me out in creating log files. </p>
| android | [4] |
2,315,754 | 2,315,755 | Saving and retrieving values with SharedPreferences | <p>I want to save two values using shared preferences and get those values in other classes. Can any one please give me information about how to set shared preferences and getting value from shared preferences.</p>
<p>I am using following code:</p>
<pre><code>SharedPreferences settings =
getSharedPreferences("MyGamePreferences", MODE_WORLD_READABLE);
SharedPreferences gameSettings = getSharedPreferences("MyGamePreferences", MODE_WORLD_READABLE);
SharedPreferences.Editor prefEditor = gameSettings.edit();
prefEditor.putString("KEY", "e6c77c29021c9b3bd55aa0e9b7687ad9");
prefEditor.putString("SECRET", "ca85fa3fe86edaf2");
prefEditor.commit();
</code></pre>
| android | [4] |
808,361 | 808,362 | Why python has limit for count of file handles? | <p>I writed simple code for test, how much files may be open in python script:</p>
<pre><code>for i in xrange(2000):
fp = open('files/file_%d' % i, 'w')
fp.write(str(i))
fp.close()
fps = []
for x in xrange(2000):
h = open('files/file_%d' % x, 'r')
print h.read()
fps.append(h)
</code></pre>
<p>and I get a exception</p>
<pre><code>IOError: [Errno 24] Too many open files: 'files/file_509'
</code></pre>
| python | [7] |
2,342,149 | 2,342,150 | Validate that a string is a positive integer | <p>I would like the simplest, failsafe test to check that a string in JavaScript is a positive integer.</p>
<p><code>isNan(str)</code> returns true for all sorts of non-integer values and <code>parseInt(str)</code> is returning integers for float strings, like "2.5". And I don't want to have to use some jQuery plugin either.</p>
| javascript | [3] |
3,303,860 | 3,303,861 | Delphi's like decision cube for c# | <p>I'm looking for a pivot table like component for winforms and c#, like the good-old decision cubes that came with Delphi decades ago. Any pointers?</p>
<p>I need one able to be used independently of the underlying database, so capable of getting data programatically and not restricted to sqlserver olap or similar</p>
| c# | [0] |
4,763,855 | 4,763,856 | Getting the wrong count? | <p>I am getting the wrong count error and I can't figure out why.</p>
<p>In my database serverId = 1/2/3 has only one started value and 3 notstarted value for each server.</p>
<pre><code>painfo = (from paes in server.AppPM_Paes
where (paes.PaStatus == "Started" || paes.PaStatus == "NotStarted" ) && paes.ServerId != null
select new PaDetails { ServerID = paes.ServerId, PaStatus = paes.PaStatus }).ToList();
foreach (PaDetails a in painfo)
{
if (a.PaStatus.Contains("Started") && a.ServerID.Equals(1))
stCount1++;
if (a.PaStatus.Contains("Started") && a.ServerID.Equals(2))
stCount2++;
if (a.PaStatus.Contains("Started") && a.ServerID.Equals(3))
stCount3++;
if (a.PaStatus.Contains("NotStarted") && a.ServerID.Equals(1))
notStCount1++;
if (a.PaStatus.Contains("NotStarted") && a.ServerID.Equals(2))
notStCount2++;
if (a.PaStatus.Contains("NotStarted") && a.ServerID.Equals(3))
notStCount3++;
}
</code></pre>
<p>But in my above code (stCount#->started count), <code>stCount#</code> has the value 4 instead of 1. </p>
<p>What's wrong in my code?</p>
<p>Can you please help me?</p>
| c# | [0] |
2,201,371 | 2,201,372 | how to make asp.net v1.1 validation control compatible with IE9 | <p>How to make ASP.net v1.1 compatible with IE9? I have tried all the options available in the forums but nothing seems to work. As soon as i am launching the application its Login page appears with no image displayed (image should come), cross mark is coming for the image and after entering username and password the submit button is not working. It means the validation control of v1.1 is not supoorted in IE9. Can anyone give me a fix, I dont want to change code.</p>
<p>Button command is not working and also when the page is loaded its image is not being displayed and a cross mark is coming for the image. </p>
<p>Regards,
Anshul</p>
| asp.net | [9] |
4,789,102 | 4,789,103 | What C++ string classes/systems exist that have good unicode support and a decent interface? | <p>Using strings in C++ development is always a bit more complicated than in languages like Java or scripting languages. I think some of the complexity comes from a performance focus in C++ and some is just historical.</p>
<p>I know of the following major string systems and would like to find out if there are others and what specific drawbacks they have vs. each other:</p>
<ul>
<li>ICU : <a href="http://userguide.icu-project.org/strings#TOC-Using-Unicode-Strings-in-C-" rel="nofollow">http://userguide.icu-project.org/strings#TOC-Using-Unicode-Strings-in-C-</a></li>
<li>GLib::ustring : <a href="http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-basics-ustring.html.en" rel="nofollow">http://library.gnome.org/devel/gtkmm-tutorial/unstable/sec-basics-ustring.html.en</a></li>
<li>MFC CString : <a href="http://msdn.microsoft.com/en-us/library/5bzxfsea%28VS.100%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/5bzxfsea%28VS.100%29.aspx</a></li>
<li>std::basic_string : <a href="http://www.cplusplus.com/reference/string/string/" rel="nofollow">http://www.cplusplus.com/reference/string/string/</a></li>
<li>QT QString : <a href="http://doc.qt.nokia.com/4.6/qstring.html#details" rel="nofollow">http://doc.qt.nokia.com/4.6/qstring.html#details</a></li>
</ul>
<p>I'll admit that there can be no definite answer, but I think SOs voting system in uniquely suited to show the preferences (and thus the validity of arguments) of people actually using a certain string system.</p>
<hr>
<p>Added from answers:</p>
<ul>
<li>UFT8-CPP : <a href="http://utfcpp.sourceforge.net/" rel="nofollow">http://utfcpp.sourceforge.net/</a></li>
</ul>
| c++ | [6] |
2,236,844 | 2,236,845 | Python internals | <p>Can anyone please direct me to an online document or books where I can find and learn about the Python implementation in C, like this one for Perl: <a href="http://perldoc.perl.org/index-internals.html" rel="nofollow">http://perldoc.perl.org/index-internals.html</a>
or this book: <em>Extending and Embedding Perl by Simon Cozen</em>.</p>
| python | [7] |
4,111,134 | 4,111,135 | Reading other's code | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2429979/how-do-i-begin-reading-source-code">How do I begin reading source code?</a> </p>
</blockquote>
<p>I've been studying C++ and Lisp for a while now..</p>
<p>Bur, everytime I try getting others code to read.
WOW, it seems like I am very very lost.</p>
<p>Anything has some tips?</p>
<p>thank you,
Mario</p>
| c++ | [6] |
5,615,681 | 5,615,682 | document.body.clientHeight not working? (JavaScript) | <p>document.body.clientHeight not returning correct values (in below code return 0 onload and 20 onresize )</p>
<pre><code><html>
<head>
<title>Untitled</title>
<script type="text/javascript" >
function height1()
{
document.getElementById("viewheight").innerHTML = document.body.clientHeight;
}
</script>
</head>
<body onload="height1();" onresize="height1();">
<span id="viewheight"></span>
</body>
</html>
</code></pre>
<p>Any Comments..... plz help!</p>
| javascript | [3] |
3,576,163 | 3,576,164 | How can I get next week dates? | <p><strong>Problem</strong></p>
<p>I'm using the below code to get the next week's date and second week's date. It works fine for first few records but later it starts giving year <strong>1970</strong>.</p>
<p>If the start date is <strong>12/01/2013</strong> it shows me coorect result that is:</p>
<p>Next week: <strong>19/01/2013</strong></p>
<p>Second week: <strong>26/01/2013</strong></p>
<p>but in another record where the date is <strong>16/05/2013</strong> it shows the below</p>
<p>Next week: <strong>08/01/1970</strong></p>
<p>Second week: <strong>15/01/1970</strong></p>
<p>Please guide me where I might be going wrong ?</p>
<p><strong>Code</strong></p>
<pre><code> //Date of when game started
$starts_on = '12/01/2013';
//Next week's date from start date
$next_week = strtotime(date("d/m/Y", strtotime($starts_on)) . "+1 week");
$next_week = date('d/m/Y', $next_week);
//Second week's date from start date
$second_week = strtotime(date("d/m/Y", strtotime($starts_on)) . "+2 week");
$second_week = date('d/m/Y', $second_week);
echo $starts_on.", ".$next_week.", ".$second_week;
</code></pre>
| php | [2] |
5,470,366 | 5,470,367 | when download an image, does urllib have a return code if its sucessful or not? | <p>I want to download an image file from potentially 5 sites.</p>
<p>Meaning that if the image wasn't found in site#1, try site#2, etc.</p>
<p>How can I test if the file was downloaded?</p>
| python | [7] |
1,006,633 | 1,006,634 | This pointer and performance penalty | <pre><code>void do_something() {....}
struct dummy
{
//even I dont call this, compiler will call it fall me, they need it
void call_do_something() { this->do_something_member(); }
void do_something() {....}
};
</code></pre>
<p>According what I know, every class or struct in C++ will implicity call
this pointer when you want to access the data member or the member function
of the class, would this bring performance penalty to C++?</p>
<p>What I mean is</p>
<pre><code>int main()
{
do_something(); //don't need this pointer
dummy().call_do_something(); //assume the inline is prefect
return 0;
}
</code></pre>
<p>call_do_something need a this pointer to call the member function, but
the C like do_something don't need this pointer, would this pointer bring
some performance penalty when compare to the C like function?</p>
<p>I have no meaning to do any micro optimization since it would cause me so much
time but always don't bring me good result, I always follow the rule of "measure, don't think".
I want to know this pointer would bring performance penalty or not because of curiosity.</p>
| c++ | [6] |
3,560,219 | 3,560,220 | slide down effect with jquery | <p>suppose i have one div which has data. i want when i will click on a button then a new div will be created and which will cover the actual div like shutter down. here is sample code i got from a site which is very close but not the way i want.</p>
<pre><code> $(document).ready(function() {
var $box = $('#box')
.wrap('<div id="box-outer"></div>');
$('#blind').click(function() {
$box.blindToggle('slow');
});
});
</code></pre>
<p>check the demo of above code <a href="http://www.learningjquery.com/2008/02/simple-effects-plugins" rel="nofollow">http://www.learningjquery.com/2008/02/simple-effects-plugins</a>
just go to site and click on blind toggle button just to see how i want the things.
i want when button will be click then a new div will be created and the new div will cover the actual div with slide down effect and when i will click again then new div will slide up.how to implement it using jquery. guide me with sample code if possible. thanks</p>
| jquery | [5] |
6,023,118 | 6,023,119 | Can iphone app be developed in any other language? | <p>I was wondering if iphone apps can be developed in any other programming languages like java or C#?</p>
<p>Regards,
Arvind</p>
| iphone | [8] |
2,802,258 | 2,802,259 | string to int use parseInt or Number? | <p>As the title already says, what should I prefer when converting a string to an int? Is there any performance gain when using one over the other?</p>
| javascript | [3] |
3,486,989 | 3,486,990 | jquery weekcalender render events for single event source | <p>I am working with <a href="http://themouette.github.com/jquery-week-calendar/weekcalendar_demo_3.html" rel="nofollow">jQuery week calender</a>.</p>
<p>In "Event Data Source:" I am showing users list. My question is how can I render events only for particular user, also render the tables header listing the users to show that particular user.</p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.