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
156,646
156,647
Android AppWidget Lifecycle
<p>I am finding during a reboot that the AppWidget onUpdate method is being called twice - on very clean basic code - with a correct manifest. My code is not an issue, this problem is definitely system related (hence I'm not posting any code).</p> <p>Has this been resolved post 2.3.7 (my current development platform)?</p> <p>How does one eliminate this programmatically? As my onUpdate often calls a service (to eliminate ANR on slow stuff) I am forced to resolve the issue with a pseudo-semaphore approach. Not ideal. </p> <p>Thanks.</p>
android
[4]
3,189,893
3,189,894
How do I determine if a class extends another class in Java?
<p>In Java how do I go about determining what classes a class extends?</p> <pre><code>public class A{ } public class B extends A{ } public class C extends A{ } public class D{ } public class E extends B{ } public class doSomething{ public void myFunc(Class cls){ //need to check that cls is a class which extends A //i.e. B, C and E but not A or D } } </code></pre> <p>would <code>cls.getSuperClass()</code> do what I need?</p>
java
[1]
631,917
631,918
Reading Python source code to improve programming skills
<p>I am trying improve my programming skills reading other peoples code, but I'd like to know what's the best source code to read?</p> <p>EDIT</p> <p>I have read some books:</p> <ul> <li><p><a href="http://www.openbookproject.net/thinkCSpy/" rel="nofollow">How to Think Like a Computer Scientist</a></p></li> <li><p><a href="http://oreilly.com/catalog/9780596158071" rel="nofollow">Learning Python, Fourth Edition</a></p></li> <li><p><a href="http://rads.stackoverflow.com/amzn/click/184719494X" rel="nofollow">Expert Python Programming</a></p></li> <li><p><a href="http://en.wikipedia.org/wiki/Core_Python_Programming" rel="nofollow">Core Python Programming</a></p></li> </ul> <p>I am not new to programming, I am just trying to improve my skills.</p>
python
[7]
5,254,827
5,254,828
Not able to change <label> text using jquery in IE
<p>I am using below code to change label value using JQuery.</p> <pre><code>$("#labelId").text('Some Text here:'); </code></pre> <p>although it is working in mozilla and chrome but it is not working in IE (any versions).</p> <p>What should be the solution for this?</p>
jquery
[5]
1,321,879
1,321,880
Javascript performance consideration. Is dot operator faster than subscript notation?
<p>Is dot operator faster than subscript notation?</p> <pre><code>var obj = {x: '5'}; obj.x = 'some value'; obj['x'] = 'some value'; </code></pre>
javascript
[3]
5,605,167
5,605,168
advantages of php over other scripting language
<p>What are the advantages of using php over other scripting languages for website development?? When should we use php??</p>
php
[2]
3,634,346
3,634,347
How a floating point literal is treated either double or float in Visual C++?
<p>Suppose <code>float a = (1.5 * b)</code> where <code>b</code> is float then how is this expression evaluated? Is <code>1.5</code> treated as double or float?</p>
c++
[6]
4,221,877
4,221,878
Apply jquery toggle function based on element structure
<p>Please I need to apply the <code>toggle()</code> function to only <code>li</code> that has <code>ul</code> has children in its structure.</p> <p>For example</p> <pre><code>&lt;div&gt; &lt;ul&gt; &lt;li&gt; &lt;a&gt;&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>From the above my aim is to apply the <code>toggle()</code> function to the <code>a</code> element(s) that have no <code>ul</code> has a sibling.</p> <p>How can I achieve this.</p>
jquery
[5]
5,550,446
5,550,447
Pass the values from ListView control to text boxes in c#
<pre><code>private void deleteDisplayGamesButton_Click(object sender, EventArgs e) { //Game game = new Game(homeTeamComboBox.Text, int.Parse(homeScoreUpDown.Value.ToString()), awayTeamComboBox.Text, int.Parse(awayScoreUpDown.Value.ToString())); deleteDisplayGamesListView.Items.Clear(); deleteDisplayGamesListView.View = View.Details; foreach (Game currentgame in footballLeagueDatabase.games) { ListViewItem row = new ListViewItem(); row.SubItems.Add(currentgame.HomeTeam.ToString()); row.SubItems.Add(currentgame.HomeScore.ToString()); row.SubItems.Add(currentgame.AwayTeam.ToString()); row.SubItems.Add(currentgame.AwayScore.ToString()); deleteDisplayGamesListView.Items.Add(row); } } </code></pre> <p>I need to pass the values from above ListView control to following text boxes when I use the deleteDisplayGamesListView_SelectedIndexChanged method.</p> <pre><code>private void deleteDisplayGamesListView_SelectedIndexChanged(object sender, EventArgs e) { deleteModifyHomeTeamTxt.Text = ""; deleteModifyHomeScoreUpDown.Text = ""; deleteModifyAwayTeamTxt.Text = ""; deleteModifyAwayScoreUpDown.Text = ""; foreach (Game currentgame in footballLeagueDatabase.games); { ?----------------------------- } } </code></pre> <p>Futhermore I need to clear the row after inserting to the textboxes,which i selected from the ListView Control. </p> <p>If you know how to do this please let me know.</p>
c#
[0]
1,360,068
1,360,069
Introduction to Python
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/207701/python-tutorial-for-total-beginners">Python tutorial for total beginners?</a> </p> </blockquote> <p>Hi</p> <p>I am new in the forum and would like to have advices concerning books to learn Python.</p> <p>Thanks in advance.</p> <p>Mamane</p>
python
[7]
3,357,149
3,357,150
Speech Recognition, ListView ArrayAdapter: What is the best way to use if("certain word spoken"){ } is there methods i can use?
<p>The Speech Recognition puts all the possibilities into the list view, im just wondering how i can use the values in ListView to use an if("word was spoken"){ "do something" }, do i have to make my own search or is there already methods, proper syntax</p>
android
[4]
1,346,236
1,346,237
Split String FullName
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/225337/how-do-i-split-a-string-with-any-whitespace-chars-as-delimiters">How do I split a string with any whitespace chars as delimiters?</a> </p> </blockquote> <p>I need to split full name so I return just the surname.</p> <p>For example F. J. Hill (we assume that last name is always after first name or after initials)</p> <p>so this is what i got so far</p> <pre><code>public String getLastName(){ String surname; surname = FullName.split; } </code></pre> <p>but this doesn't work. Can i get some help please ? Dont really understand how split string works</p>
java
[1]
360,497
360,498
android: If Activity killed, on restart what happens?
<p>Lets say, activity A starts activity B with a intend and passes data in the extra. Then the system kills my <strong>process</strong> because of memory issues. Then lets say my app is brought to the foreground by some mean, also assume activity A is the launch activity in the manifest, then will it bring up activity B (possibly bringing up A first) since it was the last Activity. </p> <p>If it brings up Activity B then in the onCreate() do I have access to my original intend or do I have any way to know that the system restarted my activity?</p>
android
[4]
5,771,649
5,771,650
Explain me "document.getElementById("div_name").innerHTML=xmlHttp.responseText;"
<p>I would really appreciate If anyone can explain methe following:</p> <pre><code>document.getElementById("txtHint2").innerHTML=xmlHttp.responseText; </code></pre> <p>I understand that result (right side after equal sign) will be written within div tag in this case...But what is this RESPONSETEXT actually?</p> <p>I have html calling some *.js. In this I have url to php. In php is command connect to database and give results after my query.</p> <p>So result of this query sholud be related to =responseText ...</p> <p>I am confused and not so familiar about this ...Please help me!!!</p>
javascript
[3]
2,259,152
2,259,153
asp.net Server.Transfer() exception
<p>Why am I getting the exception While executing the Server.Transfer()...</p> <pre><code>Server.Transfer(@"~/Student/StudentSendMail.aspx?username=" + username); {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.} </code></pre>
asp.net
[9]
2,458,254
2,458,255
What is the Difference between Web.config and global.asax?
<p>What is the Difference between Web.config and global.asax ?</p>
asp.net
[9]
247,983
247,984
Converting month name to month number using JavaScript
<p>Is there a a better solution than what I have below to convert a month name to a month number using JavaScript or PHP?</p> <p>I did like this:</p> <pre><code>$monNum = date('n',strtotime($staff-&gt;curMonth)); </code></pre>
javascript
[3]
3,065,305
3,065,306
JavaScript global scope
<p>I ran this code in my console but got undefined. However I expected it to return <code>1</code> because function 2 returns a, which is a var in the global scope. </p> <p>Can you please explain where I'm mistaken? thank you.</p> <pre><code>var a = 1; function f1() {var a = 1; f2();} function f2() {return a;} f1(); </code></pre>
javascript
[3]
4,731,068
4,731,069
How do I change an URL ID to a more secure (unguessable) number?
<p>Just trying to do some security on my website and trying to figure out the best route to secure an ID into another number.</p> <p>EXAMPLE: <a href="http://localhost/page.php?id=190" rel="nofollow">http://localhost/page.php?id=190</a> TO: <a href="http://localhost/page.php?id=2234923498734" rel="nofollow">http://localhost/page.php?id=2234923498734</a></p>
php
[2]
3,720,252
3,720,253
What is the first element in a vector?
<p>I have a vector and I am adding elements using push_back.</p> <p>When I am debugging I have added one element to the vector, but the vector contains elements for [0] and [1]. The [1] is the element which I pushed on, but [0] looks like some sort of nullable object.</p> <p>The vector size is 2 also- even though I have only inserted once.</p> <p>Later in my code I will traverse the vector using <code>vector_name[i]</code>. Initially I would start with <code>i=0</code>, does this mean with a vector you should use 1 (or some sort of iterator)?</p>
c++
[6]
2,713,859
2,713,860
How to decode JSON in PHP and insert it into Mysql table?
<p>I am using the following code in PHP..its creating the file post.json ..but inserting values into the table is not reflecting..</p> <pre><code>&lt;?php $input = file_get_contents('php://input'); logToFile("post.json",$input); $json_a=json_decode($input,true); $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydb", $con); mysql_query("INSERT INTO order_table (Table_id, Menu_Item_Name, Menu_Item_Price, Menu_Item_quantity) VALUES('$json_a[TableId]','$json_a[ItemName]','$json_a[ItemPrice]','$json_a[ItemQuantity]')"); function logToFile($filename,$msg) { $fd=fopen($filename,"a"); $str="[".date("Y/m/d h:i:s")."]".$msg; fwrite($fd,$str."\n"); fclose($fd); } ?&gt; </code></pre>
php
[2]
4,350,808
4,350,809
how to remove pppoe layer from packet using pcapdot.net DLL's
<p>i have Wireshark dump file with PPPOE layer and i want to remove this layer from the packet, i am using pcapdot.net DLL's and don't know how to do it.</p>
c#
[0]
2,229,722
2,229,723
Java Error 'else' without 'if'
<p>I need to have the largest number displayed of three given numbers. 'Z' should be displayed as 25 is the largest number. Anyway, while compiling this shows up. <img src="http://i.stack.imgur.com/ga5UH.png" alt="Error Message"></p> <p>I have no idea how to fix it, the examples I am given in my lessons are incorrect and when looking online most other code is way more complicated than mine and are of little help. My code is as follows: </p> <pre><code>class Greater { public static void main(String args[]) { int x = 10, y = 5, z = 15; if (x&gt;y) and (x&gt;z); { System.out.println(x); } else if(y&gt;z); { System.out.println(y); } else { System.out.println(z); } } } </code></pre>
java
[1]
2,116,854
2,116,855
Conversion of a Char variable to an integer
<p>why is the integer equivalent of '8' is 56 in C sharp? I want to convert it to an integer 8 and not any other number.</p>
c#
[0]
1,339,164
1,339,165
Is it possible to use an external image as notification icon?
<p>I want to let users could select an external images in sdcard as notification icon. However, it seems to be impossible, and only an internal image with resource id could be used as notification icon.</p> <p>Therefore, I may need a method to set a bitmap as notification icon.</p> <p>Sample for notification, and only the resource id could be set as notification icon not a bitmap.</p> <pre> int icon = R.drawable.notification_icon; CharSequence tickerText = "Hello"; long when = System.currentTimeMillis(); Notification notification = new Notification(icon, tickerText, when); </pre> <p>Also, I know that a Custom Expanded View for notification is possible to use external image, but still it's not for notification icon. </p> <p>Appreciated.</p>
android
[4]
1,329,313
1,329,314
BulletedList in asp.net
<p>How I can give separate style to custom image of Bulletdlist in .net?</p>
asp.net
[9]
5,583,498
5,583,499
Error when get content in CKEditor with jquery
<pre><code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="ckeditor/ckeditor.js"&gt;&lt;/script&gt; &lt;textarea cols="80" id="content" name="content" rows="10"&gt;html format here&lt;/textarea&gt; &lt;input type="submit" id="submit" value="Submit" /&gt; &lt;div id="data"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; CKEDITOR.replace( 'content'); $(document).ready(function(){ $('#submit').click(function(){ var content = $('#content'); alert(content); //$('#data').html(content); }); }); &lt;/script&gt; </code></pre> <blockquote> <p>When I alert(content) is result is error, can't get value html, how to fix it ?</p> </blockquote>
jquery
[5]
5,545,529
5,545,530
Merging two jQuery selections
<pre><code>var _sel1 = $('.red'); var _sel2 = $('.yellow'); </code></pre> <p>How can I merge them into one, without using different selectors?</p> <pre><code>// I don't want to do it this way var _sel3=$('.red,.yellow') or $('.red').add('.yellow'); </code></pre>
jquery
[5]
2,861,570
2,861,571
Start application in background on bootup
<p>I would like to start my application when the phone boots up. But the user should not know that the application has started. I am doing the boot up by receiving the BOOT_COMPLETE event in a broadcast receiver and am able to minimize the application by using moveTaskToBack(true). But my application is visible for a split second before it gets minimized and I do not want this to happen. My application does not have any services. Is there any way in which I can start the application minimized without the end user noticing ? </p> <p>Thanks</p>
android
[4]
4,165,124
4,165,125
Javascript Array`s
<p>Just want to loop an array in javascript.</p> <p>This is my base array</p> <pre><code>var family = ["1A+1C","1A+2C","1A+3C","2A","2A+1C","2A+2C","2A+3C"]; </code></pre> <p>and i want the ageset0 to ageset6 array values in to be fetched as per the slot. currenlty the ageset0 values are getting printed all the way</p> <p>how to achieve it. thanks in advance.</p> <p>this is the sample page.</p> <p><a href="http://jsfiddle.net/baVU2/2/" rel="nofollow">http://jsfiddle.net/baVU2/2/</a></p>
javascript
[3]
1,459,743
1,459,744
Upload file larger than 5MB
<p>I tried to create an application wich allows me to upload files larger then 5 MB but I always get an error that says that the file is to large. I modified php.ini upload_max_filesize and post_max_size and set it to 1GB but it did not work.</p> <p>This is my code:</p> <pre><code>if(is_uploaded_file($_FILES['pdf']['tmp_name'])&amp;&amp;($_FILES['pdf']['error'] == UPLOAD_ERR_OK)){ $file = $_FILES['pdf']; $size = round($file['size']/10485760); if($size &gt; 10485760){ echo 'The uploaded file was to large.'; } if(($file['type'] != 'application/pdf') &amp;&amp; (substr($file['name'], -4) !='.pdf')){ echo 'The uploaded file was not a PDF.'; } if(!array_key_exists('pdf', $add_pdf_errors)){ $tmp_name = sha1($file['name'].uniqid('', TRUE)); $dest = '../pdfs/'.$tmp_name.'_tmp'; if(move_uploaded_file($file['tmp_name'], $dest)){ $_SESSION['pdf']['tmp_name'] = $tmp_name; $_SESSION['pdf']['size'] = $size; $_SESSION['pdf']['file_name'] = $file['name']; echo '&lt;h4&gt;The file has been uploaded!&lt;/h4&gt;'; }else{ trigger_error('The file coul not be moved.'); unlink($file['tmp_name']); } } }else{ switch ($_FILES['pdf']['error']){ case 1: case 2: echo 'The uploaded file was to large.'; break; case 3: echo 'The file was only partially uploaded.'; break; case 6: case 7: case 8: echo 'The file could not be uploaded to a system error.'; break; case 4: default: echo 'No file was uploaded.'; break; } } </code></pre> <p>How can I resolve this problem?</p>
php
[2]
3,814,901
3,814,902
Parse Args that aren't declared
<p>I'm writing a utility for running bash commands that essentially takes as input a string and a list optional argument and uses the optional arguments to interpolate string.</p> <p>I'd like it to work like this:</p> <pre><code>interpolate.py Hello {user_arg} my name is {computer_arg} %% --user_arg=john --computer_arg=hal </code></pre> <p>The <code>%%</code> is a separator, it separates the string to be interpolated from the arguments. What follows is the arguments used to interpolate the string. In this case the user has chosen <code>user_arg</code> and <code>computer_arg</code> as arguments. The program can't know in advance which argument names the user will choose.</p> <p>My problem is how to parse the arguments? I can trivially split the input arguments on the separator but I can't figure out how to get optparse to just give the list of optional args as a dictionary, without specifying them in advance. Does anyone know how to do this without writing a lot of regex?</p>
python
[7]
573,717
573,718
How to use Radio Button values in a button URL?
<p>I have a form with a few radio buttons and I want to use the value of the radio button selection to change what url you go to when you click a button.</p> <pre><code>&lt;input type="radio" name="Server" value="ftp://one.com" checked&gt;One &lt;input type="radio" name="Server" value="ftp://two.com"&gt;Two &lt;button type="button" name="" onClick="location.href='document.getElementsByName("Server").checked + "/file.ext"'"&gt;Download </code></pre> <p>I want to select the FTP server with the radio button and change the download link of the button.</p>
javascript
[3]
2,528,072
2,528,073
Group by and count in List
<p>I have an List which is filled with ints, like this:</p> <pre><code>[0] 1 [1] 4 [2] 4 [3] 8 [4] 9 [5] 1 [6] 1 </code></pre> <p>So basically random numbers in there, but the same number can occure multiple times in that list.</p> <p>What i want is to group them by number, but that i can also tell how many times that number was in the list. So that i have a something like:</p> <pre><code>[0] [number] 1 [total] 3 // Occured 3 times in the list [1] [number] 4 [total] 2 [2] [number] 8 [total] 1 [3] [number] 9 [total] 1 </code></pre> <p>Is there a fast/easy way to accomplish this? Or do i have the write out all sorts of loops and checks to construct something like this manually?</p>
c#
[0]
869,017
869,018
Android onUpgrade Database causing IllegalStateException
<p>in my <code>dbHelper</code>:</p> <pre><code>onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) </code></pre> <p>function I save one table to an external database.</p> <p>Therefore I </p> <ol> <li>attach and copy to the external database</li> <li>delete the db file in this function and copy it from external</li> <li>restore from external database to db.</li> </ol> <p>this works until the function returns to getWritableDatabase()</p> <p>Here I get this exception:</p> <pre><code>java.lang.IllegalStateException: no transaction pending </code></pre> <p>What is wrong? Thanks Tata</p>
android
[4]
2,377,533
2,377,534
how to get last date of NSDAte?
<p>I have implemented one iphone application in which i want to get last date of current month. I don't know how it possible.</p> <p>Please help me for this question.</p> <p>Thanks in advance.</p>
iphone
[8]
3,922,026
3,922,027
Reference Value Parameter VS Return value which one is good?
<p>When we want to modify some value in one object we may use two different methods, just want to know which one is better or there is no big different between them.</p> <ol> 1. </ol> <pre><code> void SomeMethod() { UserInfo newUser = New UserInfo(); ModifyUserInfo(newUser); //Modify UserInfo after calling void method GetUserInfo } void ModifyUserInfo(UseerInfo userInfo) { userInfo.UserName = "User Name"; ..... } </code></pre> <ol> 2. </ol> <pre><code> void SomeMethod() { UserInfo newUser = New UserInfo(); //Assign new userinfo explicitly newUser = GetUserInfo(newUser); } UserInfo ModifyUserInfo(UseerInfo userInfo) { userInfo.UserName = "User Name"; ..... return userInfo; } </code></pre>
c#
[0]
2,234,696
2,234,697
Trouble with while loop in python function
<p>I have a small app that asks for a movie. When the rating is over 50, return watch it. If it doesn't, choose another movie. Though when I get to the condition in movieDec, it won't go back to the top of the function to calculate the score of the movie. Can't figure this one out.</p> <pre><code>def getScore(): choose = raw_input("pick a movie ") rt = RT() info = rt.search(choose) rating1 = info[0].get('ratings').get('critics_score') rating2 = info[0].get('ratings').get('audience_score') stars = (rating1 + rating2) / 2 return rating1, rating2, stars def movieDec(): critic, aud, stars = getScore() print 'Critics gave it a %s' %critic print 'Audiences gave it a %s' %aud print 'The average rating is %s' %stars while stars &lt; 50: print "That's no good, pick again" getScore() print 'Good choice.' </code></pre>
python
[7]
5,355,416
5,355,417
python testing equality of three values
<p>does this do what I think it does? I seems to me that yes, I am asking to be sure..</p> <pre><code>if n[i] == n[i+1] == n[i+2]: return True </code></pre> <p>is it equal to:</p> <pre><code>if n[i] == n[i+1] and n[i+1] == n[i+2]: return True </code></pre> <p>?</p>
python
[7]
6,026,223
6,026,224
search word in google and want to find hits of each word using java program
<p>I have 30000 dictionary words. In that i wanna to search each word in google and want to find hits of each word using java program. Is it possible.I am new to java.Anybody help. Its very urgent</p>
java
[1]
2,831,944
2,831,945
Upgrading a database keeping the older version
<p>i have to kept the older database and to upgrade the newly added items to the database.Is it possible to store the old table????????</p>
android
[4]
2,378,156
2,378,157
Layout related error and query with xml file
<p>Unable to resolve <code>R.layout.main</code> error. what is the reason for this error?</p> <p>Description</p> <pre><code>Resource Path Location Type activity_yamba cannot be resolved or is not a field Yamba.java /Yamba_Project/src/com/abhishek/yamba_project line 33 Java Problem </code></pre>
android
[4]
1,524,719
1,524,720
Android:: how Contact app is connected with Contact provider
<p>I have separated Android Contact app and Contact Provider. Both are installed perfectly in phone. When i create a contact with my contact app, this contact is not using my contact provider; it is using android default contact provider, and db file is created in the following location i.e /data/data/com.android.provider.contact/database/contacts2.db. I want my contact app using my contact provider so that contact.db is saved in the following location i.e /data/data/com.android.xyz.provider.contact/database/contacts2.db. Where do I need to change in my contact app so that it will use my contact provider ? </p>
android
[4]
2,057,733
2,057,734
Python float value from Price tags
<p>Is there any standard python package to interpret the price tags from the websites. Eg Input: Rs. 117,650.00</p> <p>Output: Unit: Rs Val: 117650</p> <p>We can write a function to accomplish this but more curious abt re-using the code.</p>
python
[7]
30,438
30,439
What is the diffrence between return and return () in c#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2186595/c-is-there-a-difference-between-return-myvar-vs-return-myvar">C#: Is there a difference between return myVar vs. return (myVar)?</a> </p> </blockquote> <p>Hi All what is the difference between these two statements</p> <pre><code>return x </code></pre> <p>and</p> <pre><code>return (x) </code></pre>
c#
[0]
4,891,475
4,891,476
For in In lists
<p>I'm trying to do something like that, in a nutshell...</p> <pre><code>house = ['yes', 'no','maybe'] x = range(3) for x in house print[x] </code></pre> <hr> <p>I want to loop over a list but I got 'type error: list indices must be integers not Tags.' How can I achieve this ?</p>
python
[7]
2,105,629
2,105,630
Notice: Undefined Offset: 0
<p>I am trying to get a value from an array, but when I use <code>$array[0]</code>, I get a PHP notice 'Undefined Offset: 0'. However, when I use <code>$array['id']</code> (should be the same as using '0', since 'id' is the first key in the array), I am able to get the value. I did a print_r and this was outputted:</p> <pre><code>Array ( [id] =&gt; 1 [username] =&gt; test ) </code></pre> <p>Shouldn't I be able to get the key using its index? I believe it was working earlier, but I don't know what I could have done to make it stop working. Any ideas?</p>
php
[2]
3,286,196
3,286,197
Text automatically scrolling downward on Android
<p>Does anyone know of a good way for text to appear on the screen scrolling vertically downward from top to bottom. </p>
android
[4]
3,375,845
3,375,846
jquery element same class
<p>I search a simple/clean way to get every element with the same classes than a selected element.</p> <p>something like that (not working)</p> <pre><code>var myElement = $("#elementId"); var listSameClass = $.hasClass(myElement.attr("class")); </code></pre>
jquery
[5]
2,389,028
2,389,029
OnCompletionListener
<p>Anyone explain me how to use OnCompletionListener in android program to play audio one after another...here cannot able to get second audio file..</p> <pre><code>private void playRecording() throws IllegalArgumentException, SecurityException, IllegalStateException, IOException { player = new MediaPlayer(); player.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { // TODO Auto-generated method stub player.stop(); if (i &lt; numberOfFiles) { i++; playAudio(Environment.getExternalStorageDirectory() .getAbsolutePath() + "/android" + i + ".3gp"); } } }); player.start(); } private void playAudio(String filename) { try { Toast.makeText(getApplicationContext(), filename, Toast.LENGTH_LONG) .show(); player.setDataSource(filename); player.prepare(); player.start(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre>
android
[4]
3,379,873
3,379,874
ASP.NET and Help file
<p>I am trying to get some input in regard to creating a help file:</p> <ol> <li>Prefered to have a help show up based on what active screen is.</li> <li>Obviosuly, it can be searched</li> <li>It can be browse</li> <li>So it's like normal help file if you press F1 for Internet Explorer that sort of thing.</li> </ol> <p>I'm appreciated your feedback</p> <p>Thanks</p>
asp.net
[9]
4,892,558
4,892,559
why does mysql_fetch_array() expect parameter 1 to be resource? why isn't parameter 1 resource?
<p>Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\test\index.php on line 19</p> <pre><code> &lt;?php $con = mysql_connect('localhost'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("schedule", $con); $sql = "SELECT * FROM classes LIMIT 0,50\n"; mysql_query($sql); IF (!$sql) { ECHO 'broken'; }; while($row = mysql_fetch_array($sql, MYSQL_BOTH)) { echo $row['language'] . " " . $row['level']; echo "&lt;br /&gt;"; } mysql_close($con); ?&gt; </code></pre> <p>why? the query works in phpmyadmin</p>
php
[2]
2,677,427
2,677,428
display data in grid using php
<p>I am trying to display the retrieved data in grid.</p> <p>I used while loop and retrieved every thing.I applied css but now all rows are getting displayed in same color.</p> <p>I am trying to do like this row0 blue color row1 green color row2 blue color row3 green color.How do i do it?</p>
php
[2]
804,895
804,896
Java : Couldn't understand method Syntax
<p>I am working on an existing code. In one of the classes I have this method, with the folowing syntax:</p> <pre><code>public Response getData(Request serviceRequest, Class&lt;? extends APIResponse&gt; expectedResponseClass) { } </code></pre> <p>My question is, I couldn't understand the second parameter of this method.</p> <p>Could anybody please tell me, what is that second parameter, and how should we must understand that?</p> <p>Thank you!</p> <p>Modified as to prove that we can pass the subclass also as a parameter to a method which expects superclass</p> <p><strong>Superclass.java</strong></p> <pre><code> public class Superclass {} </code></pre> <p><strong>One.java</strong></p> <pre><code>public class One extends Superclass{} </code></pre> <p><strong>Main.java</strong></p> <pre><code>public class Main { public static void main(String args[]) { One one = new One(); Main main = new Main(); main.mainMethod(one); } public void mainMethod(Superclass sc) { System.out.println("Inside the Main Method"); } } </code></pre>
java
[1]
4,515,210
4,515,211
how to retrieve a content of a table in database(with html tags)
<p>i have made some inputs in my database table and it is saved together with its html tags. now, i want it to be downloaded by a user. i want to remove the html tags. Since the file input at my database table has no format, i want the download file to be downloaded as a document file and must be compatible in MS word.</p> <p>so far i have this for the download page</p> <pre><code>&lt;?php if(isset($_GET['id'])) { include 'connect.php'; $id = $_GET['id']; $result = mysql_query("SELECT title, content, format FROM activity WHERE id = '$id'"); list($title, $content, $format) = mysql_fetch_array($result); strip_tags($content); header("Content-type: $format"); header("Content-Disposition: attachment; filename=$title"); echo $content; mysql_close; exit; } ?&gt; </code></pre>
php
[2]
4,032,911
4,032,912
Jquery: Timing issue in jquery
<p>I am using PHP with zend framework as the technology. I am sending my encoded json string via controller and sending it to my view. Now the actual scenario is that, When I submit my form and if the errors occur than what ever items I have selected, needs to be appear on my form. This works fine when I debug the jquery, but if I do it directly its not working.</p> <p>Below is the code I am using:-</p> <pre><code>function repopulateItems() { if (typeof existingItems != 'undefined') { $.each(existingItems, function() { repopulateItemById(this.id); $("#description\\[" + counter + "\\]").val(this.description); $("#quantity\\[" + counter + "\\]").val(this.quantity); }); } } function repopulateItemById(id){ var rowId = createItem('prepareItemForCreate'); var proElement = $("#id\\[" + rowId + "\\]"); id = $.trim( id ); $("#id\\[" + rowId + "\\] option").filter(function() { return $(this).val() == id; }).attr('selected', true); proElement.change(); $(this).val(''); $(this).focus(); } </code></pre> <p>In the above code after the execution of the repopulateItemById(), the item is being displayed with its value as per the database. But now if you notice in the repopulateItems(), after the execution of repopulateItemById(), I am resetting some of the properties because I want to have them as entered by the user. So the actual problem occurs here. If I start debugging, the values entered by the user is properly displayed but if I do it without debugging, it displays the items only with its actual database value.</p>
jquery
[5]
5,087,252
5,087,253
Android: proguard with rhino jar?
<p>I have added the Rhino js-14.jar to my project and am no longer able to build with proguard. When I attempt to build I get many messages like: </p> <blockquote> <p>Warning: org.mozilla.javascript.tools.debugger.ContextWindow: can't find superclass or interface javax.swing.JPanel</p> </blockquote> <p>And then the build fails with message: </p> <blockquote> <p>Proguard returned with error code 1. See console.</p> </blockquote> <p>Any recommendations for how to fix this?</p>
android
[4]
708,904
708,905
Can't find ant in the Android SDK
<p>Hey all, I'm working my way through APress's Beginning Android 2 and I've made it all the way to chapter 3, where we build a skeleton app. The book tells me to compile my application by typing "ant" in the command line, but my pc doesn't know what "ant" is yet. I checked in the SDK files and it looks like it wasn't included with the Android SDK. Does anybody know where ant is?</p> <p>Thanks</p>
android
[4]
2,965,626
2,965,627
Capture webview's current display to bitmap
<p>I have a webview , which would be loaded with a large html file. The webview is scrollable, and the user is able to see the rest of the pages by scrolling it. As the user scrolls down the page, at some point of time I want to get a bitmap image of the webview ( currently what the user is seeing) , not the entire page's image. I know the webView.capturePicture() can create a picture , but it gives the entire webpage's image. I tried the following code snippet, but it gives me the image of the starting-page of the html file, even if the user has scrolled down the page many times.</p> <pre><code> WebView webView = new WebView(getApplicationContext()); webView.setVerticalScrollBarEnabled(true); webView.setHorizontalScrollBarEnabled(false); webView.getSettings().setBuiltInZoomControls(false); webView.getSettings().setUseWideViewPort(false); webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS); webView.getSettings().setDefaultZoom(ZoomDensity.MEDIUM); webView.setWebViewClient(new WebViewClient(){ @Override public void onPageFinished(WebView view, String url) { // TODO Auto-generated method stub super.onPageFinished(view, url); //pageFinished = true; } }); webView.getSettings().setJavaScriptEnabled(true); webView.setWebChromeClient(new WebChromeClient()); webView.loadUrl("file://"+Environment.getExternalStorageDirectory() + "/main.html"); </code></pre> <p>In onClick() of a Button, I used the following code to get the snapshot of the webview:</p> <pre><code> try { Bitmap bitmap = Bitmap.createBitmap(webView.getWidth(), webView.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); webView.draw(canvas); FileOutputStream out = new FileOutputStream( Environment.getExternalStorageDirectory() + "/out.png"); bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); // saving bitmap } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>Any help is appreciated.</p> <p>Thanks in advance, Suji</p>
android
[4]
5,881,126
5,881,127
copy memory content from intptr
<p>Aloha-everyone, I would like to to know how to convert a memory content of an intptr into its equivalent data. I should be missing the meaning of IntPtr that I think it is a pointer to somewhere in memory, for example a string, I would like to get that string. Is there a method to do that ? Thank you</p>
c#
[0]
666,112
666,113
Cast object array to byte array
<p>I have an object array containing array of a different type that is not known at compile time, but turns out to be <code>int[]</code>, <code>double[]</code> etc.</p> <p>I want to save these arrays to disk and I don't really need to process their contents online, so I looking for a way to cast the <code>object[]</code> to a <code>byte[]</code> that I then can write to disk.</p> <p>How can I achieve this?</p>
c#
[0]
1,188,150
1,188,151
a generic function to find height for label by passing the string that the label is to be populated
<p>i need to find height for a label with certain text based on its font and length. It requires to be generic to hold font as well as a parameter.</p>
iphone
[8]
4,979,558
4,979,559
Android Intent usage (Call_action & new_task_launch)
<p>I have faced the following error while running my application. The code of my app is</p> <pre><code>public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); final Button callButton = (Button) findViewById(R.id. callButton); callButton.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { Intent callIntent = new Intent(Intent.CALL_ACTION,Uri.parse("tel:123456789")); callIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH); startActivity(callIntent); } }); } </code></pre> <p>the problem that I am facing is, the CALL_ACTION and the NEW_TASK_LAUNCH are giving me an error informing me that they are not fields. Could any one please resolve this.</p> <p>Thanks in advance.</p>
android
[4]
5,319,065
5,319,066
Unread email notifier, most practical approach
<p>I'm in the process of writing a small php-cli script that will loop over my personal inbox and then send me an SMS via a gateway.</p> <p>The question I have is:</p> <p>As will have the script launch via cron every 10 minutes, if there is an email sitting in my inbox that is not read before the next script launch then I will receive 2 sms.</p> <p>Does any one (pseudocode will do) have any idea what the best practice would be in php5 to ensure only 1 SMS is sent?</p> <p>What I am currently learning towards is storing the message ID in a sqlite DB and flagging a field whether an SMS has been sent or not - but wondering if there is an easier way?</p>
php
[2]
3,792,613
3,792,614
Android display.getWidth/height returning wrong sizes for device?
<p>I have a small class that needs to keep track of the devices width and height.</p> <pre><code>public class BrScreenMetrics { public static int screenX=0; public static int screenY=0; public static void setMetrics(Activity activity) { WindowManager w = activity.getWindowManager(); Display d = w.getDefaultDisplay(); screenX = d.getWidth(); screenY = d.getHeight(); } </code></pre> <p>}</p> <p>With each new activity i unvoke the line:</p> <pre><code>BrScreenMetrics.setMetrics(this); </code></pre> <p>which updates the values on rotation etc... This works great, except that it is returning 320x522, not my desire's 480x800. What am i doing wrong?</p> <p>Slight Update:</p> <p>I tried it with this code as well using androids own metrics class:</p> <pre><code> public static void setMetrics(Activity activity) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); screenX = metrics.widthPixels; screenY = metrics.heightPixels; } </code></pre> <p>but it is still 320x522 :(</p>
android
[4]
5,954,219
5,954,220
How is template function call ambiguity resolved?
<p>I want to make a function <code>conj</code> which will be applied only if the type of the argument is NOT <code>std::complex&lt;T&gt;</code>. I could use <code>enable_if</code>, but do I need to?</p> <p>If I have the following:</p> <pre><code>namespace{ template&lt;typename T&gt; T conj (T x) { return x; } } </code></pre> <p>And we already have in <code>std</code></p> <pre><code>template&lt;typename T&gt; std::complex&lt;T&gt; conj (std::complex&lt;T&gt; x); </code></pre> <p>Will a call to <code>conj(z)</code> where <code>z</code> is <code>std::complex&lt;double&gt;</code> be resolved to the std version (since it is a 'better' match?) </p>
c++
[6]
363,379
363,380
Find a string in a text file and add text at the beginning to that line in php
<p>I have a text file:</p> <p>John customerA <br> Michael customerB <br> Joe CustomerA<br> Jacky CustomerC<br></p> <p>How to add 'active' string into the beginning of the text and only for 'customerA', so the output will be</p> <p>active John customerA <br> Michael customerB <br> active Joe CustomerA <br> Jacky CustomerC <br></p> <p>Thanks</p>
php
[2]
367,470
367,471
Encapsulating a self referencing console application method
<p>If the method <code>iAmPrivate</code> is <code>Private</code> then how does the following execute it? If I try to run PrivateMethod's myPrivateMethod it is encapsulated why doesn't the same apply to <code>iAmPrivate</code> ? </p> <pre><code>class PrivateMethod { private int myPrivateMethod() { return 1; } } static void Main(string[] args) { Program myProgram = new Program(); myProgram.iAmPrivate("private"); myProgram.iAmPublic("public"); PrivateMethod pm = new PrivateMethod(); //Console.WriteLine("this won't run {0}", pm.myPrivateMethod); //not possible Console.WriteLine("press [enter] to exit"); Console.ReadLine(); } public void iAmPublic(string s) { Console.WriteLine("I am {0}", s); } private void iAmPrivate(string s) { Console.WriteLine("I am {0}", s); } </code></pre>
c#
[0]
2,636,782
2,636,783
WebView leaks entire Activities - with a simple example!
<p>I'm starting to notice, that, even on honeycomb, you'll leak an entire Activity and WebView if you're using WebView and you rotate your phone a few times.</p> <p>I've got some test code here for proof:</p> <pre><code>public class WebViewTestActivity extends Activity { /** Called when the activity is first created. */ private WebView mWeb; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mWeb = (WebView)findViewById(R.id.web); } @Override public void onDestroy() { super.onDestroy(); mWeb.destroy(); mWeb = null; // just making sure. } } </code></pre> <p>This seems simple enough, but if you launch the app, rotate your device a few times, and then dump an hprof to view it in MAT or something similar, you'll see two things:</p> <p>First, there are <strong>two</strong> instances of WebViewTestActivity hanging around, and <strong>two</strong> instances of WebView. This seems to be the case no matter how many times you rotate your device.</p> <p>This seems like a huge problem, leaking an entire Activity, and I've googled it to no avail. I see several complaints about this issue, but no official responses or workarounds. </p> <p>Can anyone shed some light on this?</p> <p>Edit: MAT screenshots of shortest path to GC roots, excluding soft, weak, and phantom references: <a href="http://vimtips.org/media/mat.png" rel="nofollow">http://vimtips.org/media/mat.png</a></p> <p>Edit: I was wrong, this bug is fixed in Gingerbread and up. Wish there was a way to work around it in previous releases.</p>
android
[4]
4,199,491
4,199,492
Android and reflection
<p>I get the impression that Android supports reflection. But does it really? How sensible would it be to rely on reflection heavily? What's the penalty?</p>
android
[4]
5,303,443
5,303,444
MPMoviePlayerController with MPMovieControlModeHidden
<p>I am trying to hide the controls on a MPMoviePlayerController. Using:</p> <p><code> moviePlayer.movieControlMode = MPMovieControlModeHidden; </code></p> <p>Works fine on my 3GS and in the simulator, however on a 3G (running 3.1.3) it refuses to hide.</p> <p>Any Suggestions?</p> <p>Thanks, John</p>
iphone
[8]
1,828,640
1,828,641
Dynamic array, which can also be saved to file
<p>In my Android application, I need to make a list of favorite items. Each of these items consists of 3 key/value pairs. I want a dynamic array capable of:</p> <ul> <li>Insertion at end only</li> <li>Sortable</li> <li>Deletion at any point</li> <li>Can be saved to File</li> </ul> <p>Any suggestions?</p>
android
[4]
2,932,362
2,932,363
iphone video
<p>How do I add a video in my iphone application?</p> <p>I just want to show a video in 1st screen.</p>
iphone
[8]
2,007,354
2,007,355
Are these interview questions too challenging for beginners?
<p>So I just interviewed two people today, and gave them "tests" to see what their skills were like. Both are entry level applicants, one of which is actually still in college. Neither applicant saw anything wrong with the following code.</p> <p>I do, obviously or I wouldn't have picked those examples. <strong>Do you think these questions are too harsh for newbie programmers?</strong></p> <p>I guess I should also note neither of them had much experience with C#... but I don't think the issues with these are language dependent. </p> <pre><code>//For the following functions, evaluate the code for quality and discuss. E.g. //E.g. could it be done more efficiently? could it cause bugs? public void Question1() { int active = 0; CheckBox chkactive = (CheckBox)item.FindControl("chkactive"); if (chkactive.Checked == true) { active = 1; } dmxdevice.Active = Convert.ToBoolean(active); } public void Question2(bool IsPostBack) { if (!IsPostBack) { BindlistviewNotification(); } if (lsvnotificationList.Items.Count == 0) { BindlistviewNotification(); } } //Question 3 protected void lsvnotificationList_ItemUpdating(object sender, ListViewUpdateEventArgs e) { ListViewDataItem item = lsvnotificationList.Items[e.ItemIndex]; string Email = ((TextBox)item.FindControl("txtEmailAddress")).Text; int id = Convert.ToInt32(((HiddenField)item.FindControl("hfID")).Value); ESLinq.ESLinqDataContext db = new ESLinq.ESLinqDataContext(); var compare = from N in db.NotificationLists where N.ID == id select N; if (compare.Count() &gt; 0) { lblmessage.Text = "Record Already Exists"; } else { ESLinq.NotificationList Notice = db.NotificationLists.Where(N =&gt; N.ID == id).Single(); Notice.EmailAddress = Email; db.SubmitChanges(); } lsvnotificationList.EditIndex = -1; BindlistviewNotification(); } </code></pre>
c#
[0]
1,542,585
1,542,586
Time between client inputs in socket communication
<p>I have a simple socket server client communication in java where the clinet introduce a string and the server return the number of spaces from that string. I want to finish the communication if the client does'n introduce nothing for more than 10 seconds but i don't know how. Any idea please?</p>
java
[1]
883,303
883,304
Android Resource for Survey App design
<p>I am creating a survey app for android. If I have 50 questions do I create 50 activities and 50 XMLs for each question or there is a better way to do it? I'd appreciate if someone could direct me to a good resource for this problem. How can I ask selected questions based on answers or design skip patterns? Thanks.</p>
android
[4]
1,871,518
1,871,519
Android programming: Store Class properties to another class
<p>I am developing an android application for our project in our University. This app is supposed to function as reservation system for movie theaters. </p> <p>How do I start a new Intent without losing the properties of the previous intent?</p>
android
[4]
4,095,576
4,095,577
Opening the sharepoint modal dialog from asp.net code behind? Sharepoint 2010
<p>Is it possible to open the sharepoint 2010 javascript modal dialog from asp.net code behind? I have tried..</p> <pre><code> System.Web.HttpContext.Current.Response.Write("&lt;script type=\"text/javascript\"&gt;"); System.Web.HttpContext.Current.Response.Write("var options ="); System.Web.HttpContext.Current.Response.Write("{"); System.Web.HttpContext.Current.Response.Write(" url: 'ok.aspx',"); System.Web.HttpContext.Current.Response.Write(" width: 100,"); System.Web.HttpContext.Current.Response.Write(" height: 100,"); System.Web.HttpContext.Current.Response.Write(" allowMaximize: false,"); System.Web.HttpContext.Current.Response.Write(" title: 'HATA'"); System.Web.HttpContext.Current.Response.Write("};"); System.Web.HttpContext.Current.Response.Write("modalDialog = SP.UI.ModalDialog.showModalDialog(options);"); System.Web.HttpContext.Current.Response.Write("&lt;/script&gt;"); </code></pre> <p>.. and it fails. </p>
asp.net
[9]
1,730,336
1,730,337
Android ExpandableListView onClickListener for Group row
<p>Tab1 is a expandablelistview and the Tab2 is a view. Default selected tab is Tab1. When I click on a group row, a webview pops up. </p> <p>When I select Tab2 and again Tab1, group row web view doesn't open on a first click. It opens on 2nd click. so what happening ? I am confused...</p>
android
[4]
2,801,889
2,801,890
How JQuery identifies whether the response is success or failure
<p>I am new to JQuery. I found $.ajax() method for making ajax request. Here we add success and failure methods. But how JQuery internally finds whether the response from server is success or failure and calls the appropriate method ?</p>
jquery
[5]
2,869,937
2,869,938
Set running time limit on a method in java
<p>I have a method that returns a String, is it possible that after a certain time treshold is excedeed fot that method to return some specific string? </p>
java
[1]
4,683,824
4,683,825
Access 'DONE' button on 'create new contact' form in android
<p>I am a beginner in android and have a following problem.</p> <p>I had created OCR app in android. After OCR'ing the text, details are fetched and prefilled in add new contact form of android. When we click 'Done' button, the details are saved in phonebook and page is navigated to phonebook.</p> <p>I want to navigate the page to my app. when user clicks 'Done' button. I don't know how to change click event of the button, as it is predefined by the android OS.</p> <p>Sample code for 'add new contact'</p> <pre><code> Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); intent.putExtra(ContactsContract.Intents.Insert.NAME, fName); intent.putExtra(ContactsContract.Intents.Insert.PHONE,phno.toString()); intent.putExtra(ContactsContract.Intents.Insert.EMAIL,email); startActivity(intent); </code></pre> <p>I am using eclipse adt bundle for android development Ubuntu 12.04</p> <p>Any Help will be appreciated...</p> <p>Thanks in advance.</p>
android
[4]
2,952,775
2,952,776
How to insert text to rich edit control in Win32 while preserving any previous formatting
<p>I'm developing chat application in win32. Currently i'm dynamically allocating memory for rich edit controls text, append new line and set the new text with SetWindowText.</p> <p>When a message arrives with specific keywords the app colors the line and appends it to the chat window. Everything's fine. Problem arises when next message is received - any previous formatting is lost!</p> <p>How to solve this issue?</p>
c++
[6]
5,005,469
5,005,470
C++ Beginner - 'error' as a command in code
<p>I am trying to work my way through a c++ textbook to learn some programming, but I've run into an issue with some of the sample code. The goal is to write a simple calculator program, and the text supplies parts of the code as examples. A portion is:</p> <p>if (!cin) error("no second operand");</p> <p>The text makes it seem like 'error' will the output the text that comes after it if your input is incorrect, but my compiler just says 'error' hasn't been defined. I'm copying the code from the text word for word, so I'm not sure if I'm missing something with my compiler, or if I've misunderstood how I should be writing the code. Can anyone give some advice?</p>
c++
[6]
5,823,191
5,823,192
Multiplication in PHP
<p>I have to do a calculation, here is a simplification of what I am trying to achieve:</p> <pre><code>$box['dim1'] = 1; $box['dim2'] = 1; $box['dim3'] = 1; $volume = (($box["dim1"]/100) * ($box["dim2"]/100) * ($box["dim3"]/100)); echo $volume; </code></pre> <p>In this case I see:</p> <pre><code>1.0E-6 </code></pre> <p>Rather than 0.000001 as I would expect.</p> <p>This is a rather extreme example and dim1, dim2 and dim3 are unlikely to ever all equal 1 but I need the value of $volume to be a number as this is passed to a 3rd party API and they don't like 1.0E-6.</p> <p>Is there anyway I can get $volume to equal 0.000001 and not 1.0E-6?</p>
php
[2]
2,939,676
2,939,677
How to start developing Javascript apps?
<p>I started out with Rails development, but soon I realized Rails without JS is pretty much useless. So, I am trying to play with JS in my free time.</p> <p>So, what are the "<strong>tools of trade (IDEs if any)</strong>" for JS development?</p> <p>My primary focus is usage of APIs, Ajax etc, so that I don't get lost when I get develop Rails apps which uses JS. </p> <p>There are many tutorials for using JS for Open graph API or twitter API, but that is to get things done and abstract some feature sets which a beginner should know.</p> <p>I generally start learning a language by making a calculator, end to end (always works for me). But I cannot make a calculator and use API/Ajax calls.</p> <p>So, what are your suggestions?</p> <p>PS: I am aware about Douglas Crockford's video lectures, they are awesome, but I need some thing more concrete.</p> <p><strong>UPDATE</strong>:</p> <p>My 2 original questions:<br> 1. What are the tools of trade for JS? <strong>Like Eclipse:Java::X:Javascript, What is X</strong> (multiple Xs are allowed)?<br> 2. What sample app do you recommend for me to start with?</p>
javascript
[3]
2,798,762
2,798,763
JavaScript to C++ conversion: error with the % operator
<p>JavaScript:</p> <pre><code>var lon2 = (lon1.toRad()+L+3*Math.PI)%(2*Math.PI) - Math.PI; </code></pre> <p>I have converted to c++:</p> <pre><code>double lon2 = (Deg2Rad(lon1)+L+3*PI)%(2*PI) - PI; </code></pre> <p>Note: Deg2Rad func returns double, PI is a double also, L and lon1 also double. Then I got the following errors for the same line:</p> <pre><code>error C2296: '%' : illegal, left operand has type 'double' error C2297: '%' : illegal, right operand has type 'double' </code></pre> <p>Whats wrong with this <code>%</code> modulo?</p>
c++
[6]
2,893,338
2,893,339
Can subprocess.call be invoked without waiting for process to finish?
<p>I'm currently using subprocess.call() to invoke another program, but it blocks the executing thread until that program finishes. Is there a way to simply launch that program without waiting for return?</p>
python
[7]
3,243,276
3,243,277
open new window with javascript and send POST parameters
<p>I would like to open a new window with javascript and pass POST parameters to it. I've tried a lot of things. </p> <p>My latest code looks like this so far, but not working (I haven't tried to pass post parameters but after it will work I can only add hidden input to make it work. I guess.):</p> <pre><code>&lt;form method="POST" name="showgraph" onsubmit="javascript:window.open('graph.php', 'Graph', 'scrollbars=yes,titlebar=no,top=300,left=400');" action="javascript:void(0)"&gt; &lt;a href="#" onClick="document.showgraph.submit();"&gt;Show graph&lt;/a&gt; &lt;/form&gt; </code></pre>
javascript
[3]
4,056,830
4,056,831
Mousemove event in C# on Windows 7
<p>i have an issue with the mousemove event in Windows 7. I was trying to display a tooltip message on the mousemove event of my custom control It works fine in XP but not in Windows 7. In windows 7, it started firing the mousemove event continuously even though the mouse cursor stays over the control and not moving. I removed the code to display tooltip from the mousemove event and it starts working fine. Is there any problem in displaying the tooltip on mousemove event?? Any other solution to display the tooltip in mousemove??</p>
c#
[0]
2,379,718
2,379,719
Determine turn taking in game
<p>I am creating a game and I would highly appreciate any advise on this. </p> <p>I have an activity which loads a class and as that class is loaded, the text view would shows player 1 turn. I understand I can set this in the xml. </p> <p>But then when player 1 loses the game the text field should show player 2 turn. </p> <p>It would be great if someone could explain how I could do this. </p> <p>Even better would be if two people could enter there names one as player 1 and then as player 2 which would then show the names of whose turn it is. </p> <p>Many thanks.</p>
android
[4]
3,717,196
3,717,197
processing stdout in python
<p>I have a script that keeps on dumping some values to the screen. Lets call this script 1</p> <p>I need the values that gets dumped to the screen to be processed by another python script.Lets call this script2. I Script1 cant be stopped</p> <p>I currently use <strong>python 2.2</strong> so it would be great if someone could provide an example without using subprocess </p> <p>script 1 looks something like this</p> <pre><code>import sys import os i = 0 while 1: print i sys.stdout.write(str(i)+"\n") i = i + 1 </code></pre> <p>I need to write script2 such that every output generated by script1 is processed by script2</p> <p><strong>-- edit --</strong></p> <p>I need it to run on a legacy implementation ie no power shell just the command prompt available in Windows XP</p>
python
[7]
247,072
247,073
iphone - transforming a view-based project
<p>sorry bothering you guys with this silly question, but I am a kind of noob in iphone development. What I need to do is this. I have a project developed by a friend of mine, that is view-based. He created it based on the original apple template on Xcode.</p> <p>After banging my head on the wall, I realized that I need to transform this project from view based to UINavigation based project. What I mean is: his project has one view controller and one delegate. When it runs, the delegate calls the view controler and the equivalent view loads.</p> <p>What I need is to insert a UINavigationController before the ViewController, because I am planning to have a second ViewController managed by this UINavigationController, so I can do slide transitions between them and things like that.</p> <p>My question is: I imagine this is not a complex operation if you want where to change. Which changes and where should I do them, in order to add a UINavigationController before the viewController? I imagine this will change the hierarchy to:</p> <p>Delegate > UINavigagionController > ViewController</p> <p>Remember that this project was based on the Xcode View-based template, so I will probably have to change stuff on Interface Builder.</p> <p>Thanks.</p>
iphone
[8]
3,249,864
3,249,865
is it possible to put an image from a URL in a imagebutton in android?
<p>What I want to do is a database listview With a small image button and text on the right side The I want the small image to change with a URL given by A text file but I am stuck and the 2 hour rule is up</p> <p>For(file lenght) So URL is www.site.com/images/(i++).png</p>
android
[4]
4,680,364
4,680,365
get Intent from specific class or Activity because PutExtras() from Intents not resolving
<p>ok am having a funny problem here, scenario is like this:</p> <p>Intent i of Activity "B" calls Activity "A" and the method in onCreate() of Activity "A" runs; </p> <p>intent j of activity "B" calls Activity "A" and puts an "Int" extra which i can use to call a method in Activity "A"</p> <p>intent x, y and z of TabActivity "C" calls Activity "A" and puts a "String" Extra in other to start a different method in Activity "A";</p> <p>problem am having is that, regardless of what i put in the intent of Activity "C", the method from intent j keeps executing.</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); fillData(); // intent i of Activity B HandleIntent(getIntent()); // other intents } public void HandleIntent(Intent intent){ getIntent(); if(getIntent().getExtras() != null){ int priorityrequest = intent.getIntExtra("com.MyApp.PriorityRequestCode" PRIORITY_REQUEST_CODE); if(priorityrequest == 1){ PSData(); // from intent j of Activity B this keeps executing } int homerequest = intent.getIntExtra("com.MyApp.HomeRequestCode", HOME_REQUEST_CODE); if(homerequest == 3){ HomeData(); // doesn't execute keeps executing PSData(); } } } public void onNewIntent(Intent newIntent){ HandleIntent(getIntent()); super.onNewIntent(newIntent); } </code></pre> <p>From the code, PSData() keeps executing regardless of if i send another intent from another activity with the HOME_REQUEST_CODE. or is it possible to get Intent from a specific class or activity?...</p>
android
[4]
3,069,273
3,069,274
Allow only certain websites to access a PHP page
<p>I am trying to make a basic API for my website so certain other websites that I approve of can show content from my site. I have a PHP script on my server that the other websites can access to pull content in XML format. How can I make sure that only certain websites can access this php page on my server?</p>
php
[2]
4,955,624
4,955,625
how to make the section header of a SeparatedListAdapter push the previous section while scrolling?
<p>I am using a SeparatedListAdapter. The Next section's header when reaches the top, the section header changes abruptly. In case of an iOS app, the next section's header pushes up the old section header and takes its position. how to implement that in an android app? any help? </p>
android
[4]
5,334,021
5,334,022
problems creating an executable file with .o files in different folders using g++
<p>I have two c++ files at different locations </p> <ol> <li>hello.cc in /home/testing/src/impl/hello.cc</li> <li>messages.cc in /home/testing/src/msg/messages.cc</li> </ol> <p>in hello.cc we have an include for messages.h </p> <p>so i was sucessfull to compile hello.cc using below command g++ -c -I/home/testing/src/msg hello.cc (this generated an hello.o file in /home/testing/src/impl/)</p> <p>now i compiled the messages.cc using command g++ -c messages.cc (this generated an messages.o file in /home/testing/src/msg/)</p> <p><strong>now what i want is to make and executable file using hello.o</strong></p> <p>using below command</p> <p>g++ -o hello hello.o</p> <p>this is the error i am getting</p> <pre> Undefined first referenced symbol in file message hello.o ld: fatal: Symbol referencing errors. No output written to hello collect2: ld returned 1 exit status </pre> <p>please help me to solve this issue</p>
c++
[6]
789,741
789,742
iPhone Remote IO Issues
<p>I've been playing around with the SDK recently, and I had an idea to just build a personal autotuner (because I am just as awesome as T-Pain).</p> <p>Intro aside, I wanted to attach a high-quality microphone into the headphone jack, and I wanted my audio to be processed in a callback, and then copied to the output buffer. This has several implications:</p> <ol> <li><p>When my audio-in is being routed through the built-in microphone, I need to be able to process this input, and send it once my input has stopped (this works).</p></li> <li><p>When my audio-in is being routed through the microphone-in input from the headset jack, I want the output to be sent immediately.</p></li> </ol> <p>Routing, however, doesn't seem to work properly when using AudioSession modes and overrides, which technically should allow you to reroute output to the iPhone speakers, no matter where the input is coming from. This is documented to work, but in practice, doesn't really work.</p> <p>Remote IO, however, is not documented at all. Anyone with experience using Remote IO audio units, can you give me a reasonable high-level overview on how to do this properly? I have been using the aurioTouch example code, but I am running into errors where I get error codes like -50 and -10863, none of which are documented.</p> <p>Thanks in advance.</p>
iphone
[8]
5,393,726
5,393,727
Lifetime of temporary within operator+ sequence
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/584824/guaranteed-lifetime-of-temporary-in-c">Guaranteed lifetime of temporary in C++?</a><br> <a href="http://stackoverflow.com/questions/4214153/lifetime-of-temporaries">Lifetime of temporaries</a> </p> </blockquote> <p>I have a quick question regarding the lifespan of a temporary object, when returned from an overloaded <code>operator+</code> method. For example, if the expression...</p> <pre><code>a = b + c + d + e </code></pre> <p>...is evaluated by overloaded <code>operator+</code> methods which return temporary objects, is the scope of the temporary returned by the sub-expression <code>b + c</code> that of the entire expression?</p> <p>As g++ appears to hold onto all temporaries whilst the entire expression is within scope, references to these values may be held for delayed evaluation during the <code>a =</code> assignment.</p> <p>Could somebody please confirm whether or not this behaviour is guaranteed for all C++ implementations?</p>
c++
[6]