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
1,565,225
1,565,226
Testing all Letters?
<p>I am working on a script and the script should read a text file and test to see if the specified letters(a,a,r,d,v,a,r,k) are on each line. Im having a problem as I am trying to check for 3 different a's instead of just one. My code is below:</p> <pre><code>#Variables advk = ['a','a','r','d','v','a','r','k'] textfile = [] number = 0 life = 0 for line in open('input.txt', 'rU'): textfile.append(line.rstrip().lower()) while life == 0: if all(word in textfile[number] for word in advk): printed = number + 1 print ("Aardvark on line " + str(printed)) number+=1 if number == len(textfile): life+=1 else: number+=1 </code></pre>
python
[7]
1,248,964
1,248,965
Can someone help me properly set-up jquery?
<p>This is what I have so far and for some reason the text just doesn't turn blue--></p> <p>Testing.html:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src = "jquery-1.5.min.js" type = "text/javascript"&gt;&lt;/script&gt; &lt;script src = "get_comments.js" type = "text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id = "button"&gt;testing this out&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>get_comments.js:</p> <pre><code>$("#button").css("color","blue"); </code></pre>
jquery
[5]
5,856,550
5,856,551
Android Database Creation
<p>i have created a class for creating database in android, but there are some compilation errors in this..... I am not able to identify why these errors are coming.. My Code is</p> <pre><code>public DbHelper(Context ctx) { try { db = ctx.openDatabase(DATABASE_NAME,null); } catch (FileNotFoundException e) { try { db = ctx.createDatabase(DATABASE_NAME, DATABASE_VERSION, 0, null); db.execSQL(DATABASE_CREATE); } catch (FileNotFoundException e1) { db = null; } } } </code></pre> <p>When i am opening database with "Context" object , it is giving me error that "openDatabase" method is undefined. ?</p>
android
[4]
3,365,587
3,365,588
Store score at the time of completing game & get data on HighScore button press in iphone
<p>I have done this code to store score.</p> <p>But this is giving me the last added score only, not storing data every time on new index.</p> <pre><code>-(IBAction)btnSaveScore:(id)sender { if(!dictWinData) dictWinData = [[NSMutableDictionary alloc] init]; array = [NSMutableArray arrayWithObjects:txt_EnterName.text, [NSString stringWithFormat:@"%i",iTap], nil]; int increment = 0; NSLog(@"array data is:--&gt; %@",array); for (int intWinData = 1; intWinData &lt; [array count]; intWinData++) { [dictWinData setObject:array forKey:[NSString stringWithFormat:@"NameScore%d",increment]]; increment++; } } </code></pre> <p>If any mistake is there in my code then please let me guide for this.</p> <p>Is there anyother way to store the data..?</p> <p>Is <code>NSUserDefaults</code> helpful to store &amp; display data...?</p> <p>How to use <code>NSUserDefaults</code> to store &amp; retrive data.</p> <p>Thanks.</p>
iphone
[8]
2,473,795
2,473,796
Android how to get wifi signal strength and connection subType
<p>i i am checking network type by calling this function</p> <pre><code> ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo Info = cm.getActiveNetworkInfo(); if (Info == null || !Info.isConnectedOrConnecting()) { Log.i(TAG, "No connection"); } else { int netType = Info.getType(); int netSubtype = Info.getSubtype(); if (netType == ConnectivityManager.TYPE_WIFI) { Log.i(TAG, "Wifi connection"); //Need to get wifi strength } else if (netType == ConnectivityManager.TYPE_MOBILE) { Log.i(TAG, "GPRS/3G connection"); //Need to get differentiate between 3G/GPRS } } </code></pre> <p>i do not want to poll wifi strength regularly,but when i do some network stuff i need to check connected wifi strength which i am unable to get. Secondly when i get netType() as MOBILE how can i determine its 3G/GPRS form netSubType, i mean what are the integer values for 3g/Gprs etc.</p> <p>Please anyone have idea how to do this.</p> <p>Thanks </p>
android
[4]
2,880,468
2,880,469
Copy BufferedImage to clipboard
<p>How do I store a BufferedImage into the system clipboard?</p>
java
[1]
5,922,864
5,922,865
resignFirstResponder for numberpad
<p>There is a text field to enter PIN in my login form. When i press "login" button i call the following method:</p> <pre><code>* (IBAction) loginBeforeAction:(id) sender { [pin resignFirstResponder]; [progressView performSelectorInBackground:@selector(startAnimating) withObject:nil]; [self login]; } </code></pre> <p>but i the number pad is not hiding before the control moves to login method. In effect, i am can see the progress view with the number pad up. Is there any way to hide the number pad first and then show progress view ? plz help</p>
iphone
[8]
2,938,797
2,938,798
Unable to cast object of type 'System.Single[]' to type 'System.Double[]', why?
<pre><code>double[] vTessTriangles = (double[])swFace.GetTessTriangles(true); double VTTx2 = vTessTriangles[2]; </code></pre> <p>Why I get this <code>InvalidCastExpection</code></p> <blockquote> <p>Unable to cast object of type 'System.Single[]' to type 'System.Double[]'.</p> </blockquote>
c#
[0]
5,879,223
5,879,224
Python httplib2.Http not sending post parameters
<p>I have been trying to make an API request to Twilio using the httplib2 Http class and no matter how I try to setup the request, it doesn't send my post DATA. I know this, because I posted to a local URL and the post arguments are empty. Here is my code:</p> <pre><code>_TWILIO_URL = 'https://api.twilio.com/2010-04-01/Accounts/%s/%s' class Api(object): ''' A Python interface to the Twilio API ''' def __init__(self, AccountSid, AuthToken, From): self.AccountSid = AccountSid self.AuthToken = AuthToken self.From = From def _get_from(self, From): """Use the provided From number or the one defined on initialization""" if From: return From else: return self.From def call(self, To, Url, From=None): """Sends a request to Twilio having it call a number; the provided URL will indicate how to handle the call""" url = _TWILIO_URL % (self.AccountSid, 'Calls') data = dict(From=self._get_from(From), To=To, Url=Url) return self.request(url, body=urlencode(data)) def request(self, url, method='POST', body=None, headers={'content-type':'text/plain'}): """Send the actual request""" h = Http() h.add_credentials(self.AccountSid, self.AuthToken) resp, content = h.request(url, method=method, body=body, headers=headers) print content if resp['status'] == '200': return loads(content) else: raise TwilioError(resp['status'], content) def sms(self, To, Body, From=None): """Sends a request to Twilio having it call a number; the provided URL will indicate how to handle the call""" url = _TWILIO_URL % (self.AccountSid, 'SMS/Messages') data = dict(From=self._get_from(From), To=To, Body=Body) return self.request(url, body=urlencode(data)) </code></pre> <p>I can't find anything on google talking about troubleshooting </p>
python
[7]
128,218
128,219
What are the pitfalls of a Java noob?
<p>I've gone through a few Java questions on SO. And I must say the content here is <a href="http://stackoverflow.com/questions/457822/what-are-the-things-java-got-right">pretty well written</a> and the Java guys on SO can really pump out the answers.</p> <p>But what I always found was Java answers for Java people. Which is great on its own, but I'm a Java noob. So I don't really care for the workings of <a href="http://stackoverflow.com/questions/15496/hidden-features-of-java/42686#42686">"Joint union in type parameter variance"</a>. It's probably handy down the line but for now.. it's not.</p> <p>So Java for a noob (coming from PHP and Python) what are the cheatcodes?</p> <p>If you could link to an SO answer (which is probably out there but I couldn't find) or write up what are the things Java does differently than other languages? (on a basic level)</p> <p>Some might call these the Java Gotchas (I couldn't find the official one though)</p>
java
[1]
5,900,537
5,900,538
php Syntax error at first property definition. Appears to be an environment issue. Any suggestions on how to fix?
<p>I am learning php and have put a very simple class definition on my host and am getting syntax errors at the first property definition.</p> <p>See the first few lines below - the error is </p> <blockquote> <p><strong>Parse error</strong>: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'</p> </blockquote> <p>on the line with the first "public" declaration.</p> <p>The PHP version is "5.3.3-7+squeeze13 with Suhosin-Patch".</p> <p>If I change the "public" to "var", the code gets past this point but dies on some other simple statements (like "throw exception"). Helpful friendly types have claimed that the code works fine in their local development environment.</p> <p>Any suggestions on what could be happening and how I can fix it? Do I need to migrate my (almost 20 year old) entire website somewhere else?</p> <p>Thanks.</p> <p>Code sample:</p> <pre><code>&lt;?php /* Class name: reBOOKed_User * Description: Everthing that a user needs to have associated with them, * including contact information, circle memberships, bookshelves, and * points/pages earned. */ class reBOOKed_User { public $Username; public $Password; public $Emails = array(); #can have multiple emails associated with an account </code></pre>
php
[2]
23,226
23,227
How to turn on speaker programmatically in android
<p>How to turn on speaker programmatically when incoming calls received and headphone attached on audio jack?</p>
android
[4]
3,492,206
3,492,207
C++ Extension functions?
<p>Are there extensions for C++ like there are in C#?</p> <p>For example in C# you can do:</p> <pre><code>public static uint SwapEndian(this uint value) { var tmp = BitConverter.GetBytes(value); Array.Reverse(tmp); return BitConverter.ToUInt32(tmp, 0); } someuint.SwapEndian(); </code></pre> <p>Is there anything like that in C++?</p>
c++
[6]
4,100,675
4,100,676
Javascript writing to window
<p>How do you print onto seperate lines like in Java with println? </p> <pre><code>&lt;script language = "javascript"&gt; document.write("Your name is:" + fullName); document.write("You were born in:" + birthYear); document.write("You already had your birthday this year"); document.write("Your age is an &lt;i&gt;even&lt;/i&gt; number."); &lt;/script&gt; </code></pre>
javascript
[3]
759,206
759,207
how to add icons beside app_name in android
<p>I need a help regarding an issue in android...</p> <p>I have an application with a name "Example" which i declared it in string<code>&lt;string name="app_name"&gt;Example&lt;/string&gt;</code>and now i want to add some buttons/icons like search beside my app_name...</p> <p>on emulator it should look in this format: app_name-------------------------icon1--icon2--icon3</p> <p>hope my question is clear at least up to some extent</p> <p>can anyone help me how to achieve this i'm new to android clear explanation will be more helpful please help me................</p> <p>Thank you in advance</p>
android
[4]
2,467,192
2,467,193
using PHP foreach loop to add ID's to table columns
<p>I am looking to add column IDs to a table created by a foreach loop like this. Help is appreciated!:</p> <pre><code>echo "&lt;h1&gt;Table: {$table}&lt;/h1&gt;"; echo "&lt;table border='0'&gt;&lt;tr&gt;"; echo "&lt;/tr&gt;\n"; // printing table rows while($row = mysql_fetch_row($result)) { echo "&lt;tr&gt;"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row as $cell) echo "&lt;td&gt;$cell&lt;/td&gt;"; echo "&lt;/tr&gt;\n"; </code></pre> <p>Thanks, Mike </p>
php
[2]
1,229,219
1,229,220
Changing background color for items of Spinner
<p>I am working on Android application.I am using Spinner control and added items to it. Is there a way to change the background color of items in spinner. <br> can any one help me in sorting out this issue. <br> Thanks in Advance,</p>
android
[4]
1,502,675
1,502,676
Calculate number of pages which will print using Javascript window.print
<p>My Client requirement is to show to make a customized page print using window.print method of js. major Issues are</p> <p>How I can check how many pages are creating of letter size page when content is populated dynamically?</p> <p>If content is choping at the end of page it may automatically transfer content to next page. Now is it possible to check whether content will chop or not at the end of page when data in populated dynamically depending upon number of entries filled?</p>
javascript
[3]
1,204,490
1,204,491
Why deepcopy doesnt create new references to lambda function?
<p>Found this strange in python:</p> <pre><code>class SomeClass(): def __init__(self): pass a = [SomeClass()] b = copy.deepcopy(a) </code></pre> <p>Output:</p> <pre><code>&gt;&gt;&gt; a [&lt;__main__.Some instance at 0x10051b1b8&gt;] &gt;&gt;&gt; b [&lt;__main__.Some instance at 0x10051b092&gt;] </code></pre> <p>This is just as expected- deepcopy created new <code>SomeClass()</code> object for b.</p> <p>But if,</p> <pre><code>f = lambda x:x+1 a = [f] b = copy.deepcopy(a) </code></pre> <p>I get:</p> <pre><code>&gt;&gt;&gt; a [&lt;function &lt;lambda&gt; at 0x10056e410&gt;] &gt;&gt;&gt; b [&lt;function &lt;lambda&gt; at 0x10056e410&gt;] </code></pre> <p>Why deepcopy doesnt create a new lambda instance in the second case? does that mean lambda functions are atomic?</p>
python
[7]
4,760,447
4,760,448
I am having an "Illegal start of expression" error with user imput
<p>I am trying to get user input, however I am getting <code>illegal start of expression</code> at:</p> <pre><code>public static String askTheUser() throws IOException </code></pre> <p>Complete code:</p> <p>Edit: I have made most of the changes you guys suggested so now I have this:</p> <pre><code>import java.io.BufferedReader; public class Driver { public static void main(String[]args) { Dice dice; Craps craps; userResponse = askTheUser(); while(userResponse.equalsIgnoreCase("yes")) { craps = new Craps(); while(!craps.gameOver()) { craps.roll(); //print out results of roll } //print out game results: if(craps.gameWon()... userResponse.askTheUser(); } } public static String askTheUser() throws IOException { BufferedReader dataIn = new BufferedReader( new InputStreamReader(System.in) ); String data; System.out.print("Want to play craps? Yes or No"); data = dataIn.readLine(); if(data.equals("y") || data.equals("yes")) { return "yes"; } else { return "no"; } } } </code></pre> <p>However I am still getting <code>cannot find symbol</code> at <code>public static String askTheUser() throws IOException</code>. So might I be missing an import that I don't know of?</p>
java
[1]
5,010,706
5,010,707
Android ICS Youtube app(tablet) coverflow
<p>I'm looking for a control that most closely resembles the ICS tablet version youtube app's coverflow. The requirements are: 2-4 row coverflow(depending on the screen orientation), and rows must scroll together.</p> <p><img src="http://i.stack.imgur.com/ydC7k.png" alt="enter image description here"></p>
android
[4]
2,914,940
2,914,941
Best solution for getting referral information in PHP
<p>I am currently redoing some link structuring on a website. In the past we have used specific php files on the last step to direct the user to the proper place.</p> <p>Example:</p> <pre><code>www.example.com/action/go-to-blue.php </code></pre> <p>or</p> <pre><code>www.example.com/action/short/go-to-red.php www.example.com/action/tall/go-to-red.php </code></pre> <p>We are now restructuring to eliminate the <code>/short/</code> or <code>/tall/</code> directory. What this means is now <code>go-to-blue.php</code> will be doing some extra processing to make sure it sends the visitor to the proper place.</p> <p>The static method of the past was quite effective, because, well, if they left from that page we knew we had it right. Now since we are 301 redirecting <code>action/short/go-to-red.php</code> to just <code>action/go-to-red.php</code> it is quite important on <code>go-to-red.php</code> that we realize a user may have been redirected from <code>/short/</code> or <code>/tall/</code>.</p> <p>So right now I am using HTTP_REFERRER and of course in my testing that works fine, but after a lot of reading it is clear that this is not a solid solution, so I was starting to brainstorm on other ways to check and make sure we get the proper referral information.</p> <p>If we could check HTTP_REFERRER plus some other test, I would feel confident we have a pretty good system in place to send the visitor to the right place.</p> <p>Some questions/comments:</p> <ol> <li>Could I use a session variable or a cookie to accomplish this goal?</li> <li>If so, would that be maintained through the 301 redirect? I don't see why it wouldn't be..</li> <li>Passing the url in the url is not an option in this case.</li> </ol>
php
[2]
1,196,024
1,196,025
C# Timer run every 5th minute
<p>How can I run some function every 5th minute? Example: I want run sendRequest() only at time 14:00, 14:05, 14:10 etc. Update: Need to do it programmatically, in C#, application is windows service.</p>
c#
[0]
4,465,664
4,465,665
How to center a jQuery popup title?
<p>I have this jQuery popup that I am invoking like this:</p> <pre><code>$("#createprofilepopup").dialog( { title: 'Title text' , height: 490, width: 580 } ); </code></pre> <p>But it appears aligned left. Is there a way to center the title? </p> <p>Thanks!!</p>
jquery
[5]
1,128,943
1,128,944
Get image src from java file android
<p>I have an imageButton :</p> <pre><code>img = (ImageButton)findViewById(R.id.image3); </code></pre> <p>I wanted to check if this img has a specific image , if yes then it changes to another image. </p> <p>How can I get and store the image resource and later can be used to compare with the current image source?</p> <p>this is da code :</p> <pre><code>ImageButton img = (ImageButton)findViewById(R.id.image3); int resource = img.getResources().getInteger(android.R.drawable.btn_star_big_off); if(resource==android.R.drawable.btn_star_big_off) { img.setImageResource(android.R.drawable.btn_star_big_on); } </code></pre> <p>Doesn't seem to be working Any other way?</p>
android
[4]
4,545,662
4,545,663
PHP Post & Redirect
<p>I have the following code which checks the post for a "no" and if it exists prints and error or if not it redirects. It currently redirects everytime regardless of the fact the post array has 'NO' as a value.</p> <pre><code>if($_POST["minRequirementsForm"] == '1') { foreach($_POST as $key =&gt; $value) { if ($value == 'no') { $error = 1; } else { header('Location: mysite.com/app-stage1.php'); } } //print_r($_POST); } </code></pre>
php
[2]
2,348,520
2,348,521
How to solve javax.crypto.IllegalBlockSizeException: data not block size aligned
<p>I am doing an assignment about use blowfish to do encryption &amp; decryption in java.</p> <p>I had added a provider, and get instance "Blowfish/ECB/NoPadding", but I still get this error when I do the encryption. </p> <pre><code>Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); </code></pre> <p>e.g.:</p> <pre><code>public static byte[] encrypt(byte to_encrypt[], byte strkey[]) { try { SecretKeySpec key = new SecretKeySpec(strkey, "Blowfish"); Cipher cipher = Cipher.getInstance("Blowfish/ECB/NoPadding"); cipher.init(Cipher.ENCRYPT_MODE, key); return cipher.doFinal(to_encrypt); // &lt;=========== error } catch (Exception e) { e.printStackTrace(); return null; } } </code></pre> <p>leads to</p> <pre><code>javax.crypto.IllegalBlockSizeException: data not block size aligned at org.bouncycastle2.jce.provider.JCEBlockCipher.engineDoFinal(JCEBlockCipher.java:686) at javax.crypto.Cipher.doFinal(Cipher.java:1171) </code></pre> <p>Thank you.</p>
java
[1]
3,895,473
3,895,474
Use cases for referencing to a constant variable
<p>I understand the reference variable concept. It's an alias to the other variable.</p> <pre><code>int varA = 100; int &amp;varB = varA; </code></pre> <p>Here <code>varB</code> is a referring to <code>varA</code>, both pointing to same memory location. Changes to one variable reflect in the other. </p> <p>Question:</p> <ol> <li><p>a) <code>int &amp;c = 100;</code><br> What is the meaning of the above statement, and how does it differ from the following?<br> b) <code>int c = 100;</code><br></p></li> <li><p>Is there any scenario where we need to use 1(a) rather than 1(b)?</p></li> </ol>
c++
[6]
2,829,476
2,829,477
Parser Error Message: Ambiguous match found
<p>Im running a web application in visual studio 2008.. i got this error when particular page was loaded.. help me to proceed.... Thank u.....</p> <blockquote> <p>Server Error in '/PSS.NET' Application.<br> Parser Error<br> Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. </p> <p>Parser Error Message: Ambiguous match found.</p> <p>Source Error: </p> </blockquote> <pre><code>&lt;%@ Register TagPrefix="uc1" TagName="CtrlButtonControl" Src="../../WebControls/CtrlButtonControl.ascx" %&gt; &lt;%@ Page language="c#" Codebehind="SPSearchFromToDtStorLocMatTypRank.aspx.cs" AutoEventWireup="false" Inherits="Sdi.Pss.Reports.SP.SPSearchFromToDtStorLocMatTypRank" %&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" &gt; </code></pre> <blockquote> <p>Source File: /PSS.NET/Reports/SP/SPSearchFromToDtStorLocMatTypRank.aspx Line: 1 </p> <p>Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3614</p> </blockquote>
asp.net
[9]
4,615,912
4,615,913
String Constructor_networking
<p>One of the constructor defined in String class is <code>String(char chars[],int startindex,int *numChars*)</code>, but i came across this <code>String(p.getData(),0,p.getLength())</code>.</p> <p><em>Note:p has reference of DatagramPacket Object.</em></p> <p><strong>Since getData() returns byte array of data contained in the datagram,it should give an error.But to my surprise it does not give error.</strong></p> <p>Why is this so? Please explain.</p>
java
[1]
1,537,653
1,537,654
Encoding issue PHP-- special characters
<p>i have the url in my php code:</p> <pre><code>echo "http://s7g1.scene7.com/is/image/LOREALDPP/?src=is{BLOREALDPP/dl-big?&amp;$image-name=LOREALDPP/bad-mud-homme_illustration_HD&amp;$text=test?$png-alpha$}&amp;mask=is{BLOREALDPP/download-big}&amp;&amp;fmt=png-alpha"; </code></pre> <p>When executed I got:( '{' becomes '%7' and '}' becomes '%7B').</p> <pre><code>http://s7g1.scene7.com/is/image/LOREALDPP/?src=is%7BLOREALDPP/dl-big?&amp;$image-name=LOREALDPP/bad-mud-homme_illustration_HD&amp;$text=test?$png-alpha$%7D&amp;mask=is%7BLOREALDPP/download-big%7D&amp;&amp;fmt=png-alpha </code></pre>
php
[2]
3,949,082
3,949,083
Setting up a process to deal with GPS for multiple activities
<p>I am writing an application that uses GPS to give distance to a starting line and speed and direction to that line. I have GPS running fine in a test file I wrote that prints out latitude and longitude and time to my cell phone display but it is a single activity. I need to have my program do calculations in the background on the GPS data, for example calculating speed from differences in location 10 seconds apart. This information needs to be viewed from several of my activity pages, which are individual classes. I think I need to create a helper class that contains the GPS service but I am not sure and not sure of the many things that are on the web what I should be looking at. Not sure how or where to fire off the helper and even if it is called helper as I can't find that in the Android docs. Also not sure what the best way to get the information from the GPS helper, if that is what it is called. After several hours of googling and searching Youtube, I am coming here for help.</p>
android
[4]
2,111,495
2,111,496
how to get the negative factors of a positive product with a sum
<p>I may not have explained this very well in the title simply because I don't really know how to explain it in the length a title has so I apologize for that. Anyways this is my current code:</p> <pre><code>// Gets the product that is used to get the factors cout &lt;&lt; "Enter a number that you want to be factored" &lt;&lt; endl; cin &gt;&gt; y; system("cls"); // Gets the sum from the user that the two factors need to add up to cout &lt;&lt; "Input the sum that is needed" &lt;&lt; endl; cin &gt;&gt; neededSum; secondary = y; system("cls"); // Lists the factors that add up to the specified sum cout &lt;&lt; "The numbers that add up to " &lt;&lt; neededSum &lt;&lt; " are:" &lt;&lt; endl; for (int i = 0; i &lt; 100; i++) { x++; increment++; y = secondary / x; product = x * y; if (product == secondary) { sum = x + y; if (sum == neededSum) { cout &lt;&lt; x &lt;&lt; " and " &lt;&lt; y &lt;&lt; endl; } } } </code></pre> <p>Basically it takes a product lists all the factors of that product. Then, it adds all of the factors together until it finds the one that adds up to the specified sum.</p> <p>However, if the specified sum is negative like '-11' for instance it won't work because the factors of '28' (an example) are 4 and 7 not -4 and -7. I need to figure out a way to fix this so it knows when it has to be -4 and -7 instead of the positive reverse.</p> <p>Thanks in advance for the help.</p>
c++
[6]
1,552,616
1,552,617
Header cannor be sent
<p>I got some error when I uploaded my site to server. The error is:</p> <p>Cannot modify header information - headers already sent by (output started at.....)</p> <p>My site works fine on my localhost. Whats the possible error?</p>
php
[2]
1,623,256
1,623,257
Reading content from site in background using javascript
<p>Have been looking around for some time now and didn't seem to find a solution that worked for me. I'm newbie regarding javascript (only done basic JAVA) but that haven't kept me from trying >D</p> <p>I have to check whether a site exist before opening it. This is an example of a site not working:</p> <p><a href="http://stackoverflow.com.ep.fjernadgang.kb.dk/questions/1591401/javascript-jquery-check-broken-links" rel="nofollow">Site not working</a></p> <p>I tried <a href="http://stackoverflow.com/questions/1591401/javascript-jquery-check-broken-links">this</a> answer, but couldn't make it work. I notice that the tab in chrome does not have a header name like <code>404</code> or <code>404 Error</code>. So was thinking if I could read other info from the site. Can I read the</p> <pre><code> &lt;h1&gt;404 Not found&lt;/h1&gt; </code></pre> <p>from the web site in the background and if it does not equal this string then direct the user to the site?</p>
javascript
[3]
4,839,288
4,839,289
Append LinkedList to the end of another LinkedList?
<p>Let's say I have the following:</p> <pre><code>LinkedList&lt;int&gt; list1 = new LinkedList&lt;int&gt;(); LinkedList&lt;int&gt; list2 = new LinkedList&lt;int&gt;(); list1.AddLast(1); list1.AddLast(2); list2.AddLast(1); list2.AddLast(2); </code></pre> <p>As far as I know you cannot do the following;</p> <pre><code>list1.AddLast(list2.First); </code></pre> <p>and except the lists to be connected together. </p> <p>What is the proper way to merge two LinkedLists in C#? I know there is a <code>Union()</code> method, but it seems like such strong point of LinkedList in C++ is that you can easily combine and break lists apart if need be.</p> <blockquote> <p>The LinkedList class does not support chaining, splitting, cycles, or other features that can leave the list in an inconsistent state.</p> </blockquote>
c#
[0]
3,842,923
3,842,924
Invalid Conversion Error When Using Function Pointers in C++
<p>So I have been trying and battling with this for a few hours now. I am relatively new to c++ but I read about function pointers and it looked pretty useful. Essentially, what I am attempting to do below is to pass two integer values to the function foo and then multiply it by 10. However, I keep getting the following error: "invalid conversion from 'int' to 'int (*)(int, int)' [-fpermissive]".</p> <pre><code>#include &lt;iostream&gt; using namespace std; int foo(int nX, int nY){ return nX*nY; } int multTen(int a, int b, int (*Fn)(int, int)){ return 10*Fn(a,b); } int main(){ cout &lt;&lt; multTen(3,4,foo(3,4)) &lt;&lt; endl; } </code></pre> <p>Your kind help in this regard is highly appreciated. :)</p>
c++
[6]
1,236,895
1,236,896
Image should not lose quality and add white spaces around the image
<p>Hi guys i have a bitmap with size 600*420 and i need to post the image in size 900*900..so the image is stretched.but i don't want it to be stretched i need that image to add white spaces and save the quality.</p>
android
[4]
5,233,521
5,233,522
Matching files using python program
<p>I have to two files as follows</p> <pre><code>File1 ids CID5265 CID7263 CID9289 .... File 2 ids CID7363 3.5e-06 -3837 CID5265 4.5 -938 CID9289 8.9 -9873 .... </code></pre> <p>I want compare file1 with file2 to match any ids in file1 is present in file2 if yes i should print whole line as follows</p> <pre><code>CIDS9289 8.9 -9873 .... </code></pre> <p>to acheive this wrote python script as follows</p> <pre><code>infile = open("file1","r") searchtxt = open("file2.txt","r") for line in infile.readlines(): if searchtxt in line: print line </code></pre> <p>but i gives following error</p> <pre><code>Traceback (most recent call last): File "finding_words.py", line 7, in &lt;module&gt; if searchtxt in line: TypeError: 'in &lt;string&gt;' requires string as left operand, not file </code></pre> <p>I know im doing very simple mistake but not able to figure it out can anybody tell how to solve this..</p> <p>THanks in advance</p> <p>NI</p>
python
[7]
4,394,635
4,394,636
How to post/get with asp:Button to another page and with custom data
<p>I have a simple button on the page:</p> <pre><code> &lt;asp:Button ID="generateIsp" runat="server" style="float: right;" Text="" SkinID="Classic" PostBackUrl="../Handlers/ISPOutput.ashx" /&gt; </code></pre> <p>But <strong>ISPOutput.ashx</strong> handler needs an <strong>input parameter</strong>, let's say <strong>id</strong>. Is there a way to pass that information when <strong>generateIsp</strong> button is clicked ?</p> <p>I know I could use a link control, but then it will break my layout...</p>
asp.net
[9]
2,688,692
2,688,693
CLLocationManager updates location when user select location button
<p>In my application ,in initial lunch i have to used cllocationmanager class to find current location ([locationManager startUpdatingLocation];) using this method.After find a location i fired this method ([locationManager stopUpdatingLocation];).</p> <p>Now a user will move from one place to other place.It will automatically detects newlocation or we need to fire ([locationManager startUpdatingLocation];) this method again.</p> <p>Help me?</p> <h2>Note:</h2> <p>If i will call ([locationManager startUpdatingLocation];) method again it will give a newlocation or old location.How to differentiate it ?</p>
iphone
[8]
3,007,369
3,007,370
Can't echo variable
<p>I'm thinking it's the smarty templates setup that is preventing me from echo'ing the $setlnk variable elsewhere on the page. Or, am i'm doing something else wrong. Is there another method I could use?</p> <pre><code>&lt;?php $setlnk = "&lt;img src='/files/pvtexp.php?mid=" . $set[2] . "&amp;iid=" . $set[3] . "&amp;idat=" . $set[4] . "/" . $set[5] . "&amp;sec=" . $set[6] . "'&gt;"; </code></pre> <p>echo $setlnk; // works<br> ?></p> <pre><code>..... html code &lt;?=$setlnk;?&gt; // doesn't work &lt;?php echo $setlnk; ?&gt; // doesn't work </code></pre>
php
[2]
3,796,014
3,796,015
Creating an array of a type depending on runtime
<p>... is what I want to do. I have the following code:</p> <pre><code>... int len = 0; char c; bool fp = false; while (infile.good()) { c = infile.get(); if (c == '\n') ++len; else if (c == '.') fp = true; } if (fp == true){ float Ai[N]; float *Ao = new float [len]; } else { int Ai[N]; int *Ao = new int [len]; } for (int i=0; i&lt;L; ++i){ for (int j=0; j&lt;N; ++j) infile &gt;&gt; Ai[j]; Ao[i] = findmax(Ai); } ... </code></pre> <p>It is supposed to make the array out of doubles if a decimal point is detected in the file or, if not, out of integers.</p> <p>I didn't check the first loop yet because I didn't get it to compile:</p> <pre><code>warning: unused variable ‘Ai’ warning: unused variable ‘Ao’ warning: unused variable ‘Ai’ warning: unused variable ‘Ao’ error: ‘Ai’ was not declared in this scope error: ‘Ao’ was not declared in this scope </code></pre> <p>I suppose I have a fundamental problem with how to deal with this task and not just a simple error.</p> <p>So, what is wrong and how to fix/make it right from the beginning?</p>
c++
[6]
3,391,626
3,391,627
Android force app to use mobile data channel
<p>I am doing some investigation on an app I am developing. The issue is the app requires connection to mobile data network so when wifi is on, it will not route properly since the servers are on the carrier network vs public network. Can a single app target mobile data while others fall back onto Wifi or is this something non standard?</p>
android
[4]
2,652,677
2,652,678
Convert python script to binary executable
<p>I wrote a number crunching python code. The calculations involved can take hours. Is it possible somehow to compile it to binary?</p> <p>Thanks</p>
python
[7]
951,765
951,766
Android: Programmatically change android:name attribute for Application and BroadcastReceiver
<p>Is it possible to programmatically change the <code>android:name</code> attribute in code for Application and BroadcastReceiver? I would like to change the name of my App icon and Widget names programmatically, in order to reuse our existing localization infrastructure.</p>
android
[4]
4,414,717
4,414,718
trim of extra character from the dropdown box
<p>I have one text box in the User Interface where in user is asked to key in some input , which in turn i am saving in database , which finally i have to show in the dynamically populated dropdown list . since the user can type in any ways in the text box as in </p> <ol> <li>XXXXXX</li> <li><p>XXXXXX or </p> <p>1.XXXXXX ,2. XXXXXXX</p></li> </ol> <p>or XXXXXXXXX, XXXXXXXX</p> <p>but i want to just get the value of these so that i can show just text value in my dropdown .</p> <p>Can someone help in parsing this stuff.</p>
java
[1]
3,714,065
3,714,066
decode encode between String and byte in java
<pre><code>byte[] bytes = new byte[] { 1, -1 }; System.out.println(Arrays.toString(new String(bytes, "UTF-8").getBytes("UTF-8"))); System.out.println(Arrays.toString(new String(bytes, "ISO-8859-1").getBytes("ISO-8859-1"))); </code></pre> <p>output:</p> <pre><code>[1, -17, -65, -67] [1, -1] </code></pre> <p>why???</p>
java
[1]
1,411,354
1,411,355
PHP Exchanging numbers for words
<p>I have the following code:</p> <pre><code>for($n=1; $n&lt;=100; $n++) { echo $n . '&lt;br /&gt;'; } </code></pre> <p>How could I change it so it shows a word for:</p> <p>multiples of three</p> <p>multiples of three and five</p>
php
[2]
3,768,671
3,768,672
PHP - read date results and add style at different
<p>I have the following set of results from a query:</p> <pre><code>name date_added ---- --------- dan 15/11/2012 jane 15/11/2012 ted 14/11/2012 larry 13/11/2012 corben 13/11/2012 </code></pre> <p>These results are from a simple MySQL query and I display the results e.g.</p> <pre><code>while($users = mysql_fetch_array($result)){ echo $users[name].' -- '.$users[date_added]; } </code></pre> <p>This produces a simple list e.g.</p> <pre><code>dan -- 15/11/2012 jane -- 15/11/2012 ted -- 14/11/2012 larry -- 13/11/2012 corben -- 13/11/2012 </code></pre> <p>What I want to do is the head the results with the different dates, starting with the first one, e.g.</p> <pre><code>15/11/2012 dan -- 15/11/2012 jane -- 15/11/2012 14/11/2012 ted -- 14/11/2012 13/11/2012 larry -- 13/11/2012 corben -- 13/11/2012 </code></pre> <p>The dates change daily as this is a living document so nothing is hard coded.</p> <p>Is there a simple and efficient way to do this within the while loop?</p>
php
[2]
4,712,030
4,712,031
browser starts , then closes quickly in Android Simulator
<p>I started the Android Emulator in Windows 7.</p> <p>The emulator windows pops up. I can see the menu. I can see the icon of the browser. I click on it. It starts up. The screen changes. I can see a white screen and the black stripe at the top. Then it closes quicly after 1 second. The same happens with Google Search.</p> <p>What can be wrong?</p>
android
[4]
5,496,418
5,496,419
Leading zero in javascript
<p>Try this:</p> <pre><code>&lt;script language="javascript"&gt; var iTest=040; alert(iTest); &lt;/script&gt; </code></pre> <p>Since when is 40 = 32?</p>
javascript
[3]
377,508
377,509
How to use pythons map with a non-iterable and iterable set of parameters?
<p>To make a simple example, I don't care about the practicality, just the implemenation. Say I create some class with a few methods. I want to create a list containing whether or not they're callable. So I can take this example from: <a href="http://stackoverflow.com/questions/34439/finding-the-methods-an-object-has">Finding the methods an object has</a></p> <pre><code>[method for method in dir(object) if callable(getattr(object, method))] </code></pre> <p>It's great for what it does, but if for the heck of it, I want to use map and I have object, which is a non-iterable item...</p> <pre><code>map(callable,map(getattr,object,dir(object))) </code></pre> <p><strong>To focus on the real problem:</strong></p> <p>I have an iterable list, and a non iterable item. What is the best solution that lets me use some non-iterable item and an iterable item, so that I can utilize map?</p>
python
[7]
705,551
705,552
Get the maximum time of a date
<p>How can I get the maximum time of a DateTime value selected from datetimepicker? For example '08/21/2011 23:59:59'</p>
c#
[0]
5,338,827
5,338,828
How to play two mp3 audio?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5026105/2-mp3-sounds-at-the-same-time-in-iphone">2 mp3 sounds at the same time in iphone?</a> </p> </blockquote> <p>Hi i am creating test application where i am using two mp3 audio file.One for the background music and second file play when user clicked the button.I am using AVAudioPlayer for both and the background music is playing in appDelegate class but i am handling it from the ViewController class.Please if anybody know about this problem please help me out.</p>
iphone
[8]
1,297,225
1,297,226
Refreshing part of the DOM via jQuery
<p>Is it possible to refresh part of the DOM via jQuery?</p> <p>I'm using drag &amp; drop and when a div is dropped I need to update the dom so that dropped item new position is accessable via the dom.</p> <p>BTW I'm not looking for any information with regards jQuery to drag and drop</p> <p>So for example just refresh all elements contained within a specific <code>&lt;div&gt;</code>?</p>
jquery
[5]
745,700
745,701
Sharing variables acoss several python files
<p>I have tasked to modify a wx python gui based program which has several .py files. I would like to share some variables defined in a.py and use them in b.py The 10 -15 variables are of this form:</p> <pre><code> Amode = [SINGLE] Format = [A] etc... </code></pre> <p>I would like to use them in b.py. How do I go about it? I read about Pickle but still not clear how to use it well.</p>
python
[7]
2,429,280
2,429,281
John Resig Advanced Javascript Question
<p>Im in a little over my head, but I was wondering if anyone can help me with this one:</p> <p><strong>taken from: <a href="http://ejohn.org/apps/learn/#43" rel="nofollow">http://ejohn.org/apps/learn/#43</a></strong></p> <pre><code>function highest(){ return arguments.slice(1).sort(function(a,b){ return b - a; }); } assert(highest(1, 1, 2, 3)[0] == 3, "Get the highest value."); assert(highest(3, 1, 2, 3, 4, 5)[1] == 4, "Verify the results."); </code></pre> <p><strong>I thought it should be:</strong></p> <pre><code>Array.prototype.highest = function(){ return arguments.slice(1).sort(function(a,b){ return b - a; }); } assert(highest(1, 1, 2, 3)[0] == 1, "Get the highest value."); assert(highest(3, 1, 2, 3, 4, 5)[1] == 1, "Verify the results."); </code></pre> <p>But this is giving me errors of undefined. </p>
javascript
[3]
4,184,199
4,184,200
How to use different object in javascript on click?
<p>Using Javascript, I have two arrays called "array1" and "array2".</p> <p>I set currentArrray to be array1. Later when user clicks on some button, currentArray switches to Array2 and back to array1 if I click on it again.</p> <p>This way, whenever there is any part of the code that needs to use an array, I just use something like in pseudocode:</p> <pre><code>{currentArray}.getText; {currentArray}.getText; </code></pre> <p>Is it possible to do something like this? If so, how? I know you can use if statement, but because currentArray is used in different parts of code, it would be nice if I had a simple way like this where all I have to modify is currentArray variable so I dont have if statements scattered all over the place checking what currentArray is.</p>
javascript
[3]
2,833,963
2,833,964
Android: 50dip is different size on different devices?
<p>My understanding of the density independent pixel, is that it will render as the same size regardless of the screen dpi and dimensions. I created an image button of with and height of 50dip. On my medium dpi Samsung Galaxy Tab, this button measures about 10mm x 10mm (measured with a ruler. On my large, hdpi Acer Iconia Tab, the button measures about 7mm x 7mm. I would have expected the two buttons to have the same actual size. Am I doing something wrong, or is my understanding incorrect?</p>
android
[4]
4,465,821
4,465,822
Checking if character is a part of Latin alphabet?
<p>I need to test whether character is a letter or a space before moving on further with processing. So, i </p> <pre><code> for (Character c : take.toCharArray()) { if (!(Character.isLetter(c) || Character.isSpaceChar(c))) continue; data.append(c); </code></pre> <p>Once i examined the data, i saw that it contains characters which look like a unicode representation of characters from outside of Latin alphabet. How can i modify the above code to tighten my conditions to only accept letter characters which fall in range of [a-z][A-Z]?</p> <p>Is Regex a way to go, or there is a better (faster) way?</p>
java
[1]
5,221,735
5,221,736
How do i replicate 10060 ( WSAETIMEDOUT ) error in c++ socket programming?
<p>In Socket programming, i am getting an error 10060 while sending data using <strong>WSASend</strong>, Can anyone help to replicate the error in code.This error occurs after 3 or more hours of continuous sending of data.</p>
c++
[6]
1,910,410
1,910,411
typecasting in inheritance
<p>Given:</p> <pre><code>class TestA { public void start() { System.out.println(”TestA”); } } public class TestB extends TestA { public void start() { System.out.println(”TestB”); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } </code></pre> <p>What is the result?</p> <blockquote> <p>A. TestA</p> <p>B. TestB</p> <p>C. Compilation fails.</p> <p>D. An exception is thrown at runtime.</p> </blockquote> <p>The answer I gave to this question was <code>B</code></p> <p>What is the advantage of typecasting that is done at line 7 as we know that Method to be called depends on the actual object type.can anyone please give an example where the typecasting comes into play???????</p>
java
[1]
972,191
972,192
min3d for Android
<p>I have just downloaded min3d framework for Android and tried to change the .3ds object and I</p> <p>get IndexOutOfBundsException : Invalid index 0 , size is 0.Anyone else had the same problem?</p> <p>Thank you.</p>
android
[4]
5,987,475
5,987,476
Python (2.x) multiplication is not happening properly
<p>Here is the code ...</p> <pre><code>a=4 b=8.0 if a and a &gt;0: a=a*int(b) print "Value:",a </code></pre> <p>The desired o/p should be 32. i am also getting the same in python console. But the same code is present in my product where instead of 32 the out put is coming as 44444444 (eight fours) i.e whatever value i'am giving to multiply with "a" it is just printing that much a's. If you give 12 then twelve fours will print.</p> <p>Any idea what is the problem ?</p>
python
[7]
5,349,538
5,349,539
Best scaleable way to find many keywords in a large amount of text?
<p>Ever few minutes around 500 paragraphs are supposed to be submitted to the database in a table called "Content" (this number will go to over 2,500 in a few months). There is another table called "Keywords" which has over 4,000 rows (and is expected to grow to over 10,000).</p> <pre><code>Keywords +------------+-------------------+ | Keyword_id | keyword | +------------+-------------------+ | 1 | "Venture Capital" | | 2 | "Financing" | +------------+-------------------+ </code></pre> <p>The question is: <strong>What is the best way to scale a solution where each keyword is cross-referenced among an incoming paragraphs of text to see if there is a match?</strong></p> <p>Since I'm not concerned about where in the paragraph there is a match (my only concern is that there IS a match); <code>if(preg_match()){}</code> could possibly work but even at the low-end that's 2,000,000 times you're running over a paragraph searching for a keyword. Plus, correct me if I'm wrong, preg_match is pretty expensive.</p> <p>One of the possibilites that crossed my mind was to keep an array of the keywords in the cache instead of having to call on the DB for every row. That would definitely help speed things up I think.</p> <p>I'm not concerned with this being only in PHP. If this section of the application needs to be in Python (correct me if I'm wrong, but I hear Python is a lot less expensive at parsing text), then I'm all ears.</p>
php
[2]
4,153,089
4,153,090
Validate plugin and CK Editor?
<p>Before submitting my form I:</p> <pre><code>CKEDITOR.instances.ckEditor.updateElement(); </code></pre> <p>This copies the content of CKEditor to the text area it replaced (id of ckEditor, name of article).</p> <p>Using validate plug in I have the following rules:</p> <pre><code>rules: { article: { required: true } }, </code></pre> <p>The problem is I get no error when CK editor is empty, I check that the content is being copied across to the text area, and it is. I only get errors when I remove the style display:none from my text area (but then it shows up in the page which I do not want).</p> <p>Any ideas how to get it to validate?</p> <p>Thanks</p>
jquery
[5]
1,860,338
1,860,339
Back key behavior after up action
<p>Here <a href="http://developer.android.com/design/patterns/navigation.html" rel="nofollow">http://developer.android.com/design/patterns/navigation.html</a> is some tips about <strong>back</strong> and <strong>up</strong> navigation. It's quite clear what does <strong>up</strong> do on <a href="http://developer.android.com/design/media/navigation_between_siblings_market1.png" rel="nofollow">this example</a>, it closes those activities. </p> <p>But what happen <a href="http://developer.android.com/design/media/navigation_between_siblings_market2.png" rel="nofollow">here</a>? I go to the market, open book, then another one, then open movie, and then I decide to press <strong>up</strong> to go to movies category.<br> What has happened to books activities?<br> Can I somehow go to them?<br> Where do I go when I click back button, to the market?</p>
android
[4]
4,333,227
4,333,228
get javascript data in a tweet
<p>On my website, client will type a message, says "John loves Gmail because..." I have this message in javascript and I can display it dynamically. Now on the same page, I have a button twitter. I would like to tweet this entire message I know I can do in in php, but I don't refresh the page so I can't Do you have any idea? Thanks!</p>
javascript
[3]
1,148,397
1,148,398
Trouble with Javascript object manipulation
<p>Let's say I have a JavaScript object that is made up of several key/value pairs of string keys and JavaScript objects.</p> <pre><code>var obList = { key:{..}, key2:{..}, key3:{..}, ... } </code></pre> <p>And I construct a new set, obList2</p> <pre><code>var obList2 = { key:{..}, key2:{..}, key3:{..}, ... } </code></pre> <p>I want to write a function that modifies obList based on obList2. The initial step I'm having trouble with is removing all objects in obList that have a key not present in obList2. Any thoughts/implementation of this would be v helpful. Thank you!</p>
javascript
[3]
3,223,319
3,223,320
Why put a constructor function directly into a variable?
<p>Im trying to set up a variable and pass it constructor function essentailly like an anonymous type in c# but javascript doesnt seem to like it...</p> <pre><code>var aPerson = function Person(){ }; $(document).ready(function(){ Person.prototype.age = 22; window.alert(aPerson .age); }); </code></pre> <p>Why cant I do this?</p>
javascript
[3]
4,536,735
4,536,736
iPhone, Order UIImages Programatically
<p>So essentially I would like to add a UIImage programmatically to my interface, using:</p> <p>[[self view] addSubview: myImage]</p> <p>However, I would like to add the image BEHIND an existing image already present in the interface builder. Is there a method to accomplish this?</p> <p>Thanks a lot!</p>
iphone
[8]
915,921
915,922
hidden field usage
<p>what are the possible usage of hiddden field control of VWD in asp.net page</p>
asp.net
[9]
2,067,667
2,067,668
returning member function display with string? C#
<p>So with this member function I'm suppose to "invoke the base class displayTime method and then add the time zone to the output message" </p> <pre><code> public string DisplayTime() { //return base.displayTime(); return "okay"; }//end of DisplayTime </code></pre> <p>base class:</p> <pre><code>public void displayTime() { DateTime time = DateTime.Now; // Use current time string format = "MMM ddd d HH:mm yyyy"; // Use this format MessageBox.Show(time.ToString(format)); // Write to console }//end of displayTime </code></pre> <p>Sadly my first DisplayTime isn't setup correctly because i'm not entirely sure how to set it up. i've tried different conbomations when it comes to "return (" " + base.displayTime());" etc etc and that didn't work. I'm not sure where to go from here. </p>
c#
[0]
3,365,116
3,365,117
How to get a Fragment to remove itself, i.e. its equivalent of finish()?
<p>I'm converting an app to use fragments using the compatibility library. Now currently I have a number of activities (A B C D) which chain onto one another, D has a button 'OK' which when pressed calls finish which then bubbles up through onActivityResult to additionally destroy C and B.</p> <p>For my pre Honycomb fragment version each activity is effectively a wrapper on fragments Af Bf Cf Df. All activities are launched via startActivityForResult and onActivityResult within each of the fragments can happily call getActivity().finish</p> <p>The problem that I am having though is in my Honeycomb version I only have one activity, A, and fragments Bf, Cf, Df are loaded using the FragmentManager.</p> <p>What I don't understand is what to do in Df when 'OK' is pressed in order to remove fragments Df, Cf, and Bf? </p> <p>I tried having the fragment popping itself off the stack but this resulted in an exception. onActivityResult is useless because I have not loaded up the fragment using startActivityForResult.</p> <p>Am I thinking about this completely the wrong way? Should I be implementing some sort of listener that communicates with either the parent fragment or activity in order to do the pop using the transaction manager?</p> <p>Thanks in advance. Peter. </p>
android
[4]
3,246,454
3,246,455
Checking for input with space
<p>I've made an offline currency convertor that gets the users input in the EditText section using a TextWatcher and returns the required ouptut from methods...and I"ve made it an a way that the user cannot insert a "null" value in the EditText section and then press the convert button by using euro.getText !==null for example.But I don't know how to proceed when the user leaves some space between the input,for instance 29 50.This will make my program to crash.My question what should I use to check for an input with space in order to avoid a program crash?Thank you.</p>
android
[4]
4,104,718
4,104,719
GetFiles using path and pattern while ignoring a certain file name in C#
<p>I am trying to get all the .cs files in a certain path. I am doing this using </p> <pre><code>string [] files = Directory.GetFiles(path, pattern); </code></pre> <p>Where path is a valid folder path and pattern is *.cs. However this also returns AssemblyInfo.cs and i dont want that file to be included although it matches the pattern. I want to ignore all the files with the name AssemblyInfo.cs</p>
c#
[0]
3,035,565
3,035,566
How to find out currently used DNS namesevers on iPhone
<p>How to find out currently used DNS nameservers on iPhone? Using SDk 4. Basically i am looking for an equivalent function on iPhone OS to GetNetworkParams on Windows</p> <p>Thanks</p>
iphone
[8]
849,404
849,405
Response Code 202, Not a Qualified Error Code
<p>I'm working with an API which I post files to. However, when I receive the response, the HTTP status code is a 202. This is to be expected, but in addition the API will also respond with XML content.</p> <p>So in my try/except block urllib2.urlopen will result in a raised urllib2.HTTPError and destroying the XML content.</p> <pre><code>try: response = urllib2.urlopen(req) except urllib2.HTTPError, http_e: if http_e.code == 202: print 'accepted!' pass print response.read() # UnboundLocalError: local variable 'response' referenced before assignment </code></pre> <p>How can I expect the 202 and keep the response content, but not raise an error?</p>
python
[7]
5,982,179
5,982,180
Python: Self is not defined
<pre><code>class a(object): def __init__(self): self.b = 1 self.c = 2 </code></pre> <p>This gives the error: NameError: name 'self' is not defined</p> <p>I looked at a previous post, but the error was for a different reason. Any help with this?</p>
python
[7]
4,779,757
4,779,758
JQuery slideDown doesn't work when first clicked
<p>When I use slideDown my box just appears and doesn't slideDown when I first click on the link, but every subsequent click, it works as intended:</p> <p><a href="http://jsfiddle.net/3Gc6Q/" rel="nofollow">http://jsfiddle.net/3Gc6Q/</a></p>
jquery
[5]
2,399,260
2,399,261
Best function for Title capitlization?
<p>Should I be using <code>mb_convert_case</code> with <code>MB_CASE_TITLE</code> or <code>ucwords</code>? Or something else? What will the differences be?</p>
php
[2]
43,690
43,691
javascript switch/case : are types compared?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6989902/is-it-safe-to-assume-strict-comparison-in-a-javascript-switch-statement">Is it safe to assume strict comparison in a Javascript switch statement?</a> </p> </blockquote> <p>Does a switch/case statement in javascript compare types or only values?</p> <p>In other words, when I have the following code:</p> <pre><code>switch (variable) { case "0": [...] break; case "1": [...] break; default: [...] break; } </code></pre> <p>is it equivalent to</p> <pre><code>if ( variable == "0" ) { [...] } else if ( variable == "1" ) { [...] } else { [...] } </code></pre> <p>or to</p> <pre><code>if ( variable === "0" ) { [...] } else if ( variable === "1" ) { [...] } else { [...] } </code></pre> <p>edit: is there a way to force compare values and types at once?</p>
javascript
[3]
2,606,315
2,606,316
Replacing built-in types with more complex types. Python
<p>I want to create a replacement class of the built-in type <code>set</code> that can be constructed exactly like set. Inheritance must not be used because some functions are removed to trigger <code>method not found</code> exceptions. This class is also used to find places where there might be implicit type conversions of the built-in python collection types.</p> <pre><code>class SetFacade: def __init__(self, iterable): self.lst = list(iterable) # other allowed member functions... </code></pre> <p>The problem with this constructor definition is, that I cant call the constructor <code>SetFacade()</code> without arguments.</p> <p>How can I create a constructor that behaves exactly like the built-in set?</p> <p>Thus it must allow</p> <ul> <li><code>SetFacade([a,c,b])</code></li> <li><code>SetFacade([])</code> </li> <li><code>SetFacade()</code></li> </ul>
python
[7]
2,231,188
2,231,189
image change every a fixed time in iPhone
<p>I have 4 images. I want to load image in first screen and change images after every 10 second. when we click any images than next screen come up.</p> <p>please give me help i am new in iPhone.</p>
iphone
[8]
5,288,738
5,288,739
how to make gallary with viewpager effect?
<p>i want to make gallary in that after clicking on the gridview image item it should have to open in next layout which is viewpager view with next previous effect.just like android gallary view and one more thing is that view pager is used pager adapter and gridview is used baseadapter so i am going to use both in one.</p>
android
[4]
1,845,469
1,845,470
Invalid Entitlement.plist for my iphone?
<p>i m sending .ipa file and ad-hoc provisional profile to my friend for installing my application in his iphone through itunes of windowsXP But it shows invalid entitlement.plist for his iphone. please reply me as soon as possible, And i also does not know about importance of entitlement.plist file. Thanks in advance for sending me answer.</p>
iphone
[8]
2,806,073
2,806,074
Intializing classes in module for namespace
<p>There is a module <code>car.py</code>.</p> <p>There are engine and tires, and I want them (theirs methods and properties) to be accessible as </p> <pre><code>car.engine.data # and car.tires.data </code></pre> <p>So file <code>parts.py</code> looks like </p> <pre><code>class engineClass(object): def __init__(self): self.data = 'foo data 1' class tiresClass(object): def __init__(self): self.data = 'foo data 2' engine = engineClass() tires = tiresClass() </code></pre> <p>And now after <code>import car</code> I can access them as I want - <code>car.engine.data</code> </p> <p>Is it a right thing to do for this task?</p>
python
[7]
1,505,218
1,505,219
Simple Android Broadcast does not show toast
<p>I'm just trying to create a simple broadcast in Androids activity but its not working. </p> <pre><code>/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent i = new Intent("android.intent.action.UMS_CONNECTED"); IntentFilter filter = new IntentFilter(); filter.addAction("android.intent.action.UMS_CONNECTED"); receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(getApplicationContext(), "connected", Toast.LENGTH_LONG).show(); } }; registerReceiver(receiver, filter); } } </code></pre> <p>The XML </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="usb.usbd" android:versionCode="1" android:versionName="1.0"&gt; &lt;uses-feature android:name="android.hardware.usb.host" /&gt; &lt;uses-sdk android:minSdkVersion="12" /&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;activity android:name=".UsbddActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.UMS_CONNECTED" /&gt; &lt;action android:name="android.intent.action.UMS_DISCONNECTED" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>The screen shows on my Xoom but the toast does not display. The Xoom is connected through the USB so it should display the toast/ </p>
android
[4]
5,016,988
5,016,989
PHP Selecting HTML from the DB and apply changes
<p>With a normal <code>SELECT</code> in the mySQL DB I select the HTML content of the final page.</p> <p>I am building a way to create pages on the fly ( as any CMS does ) and I am saving the HTML code for each page inside a specific table fo my DB.</p> <p>The problem is I want the content to be multi-language. But I do not know how to SELECT html code from the DB and before printing it, working on it with PHP.</p> <p>I know it's hard to understand, this is why I have an example :)</p> <pre><code>$q='SELECT * FROM pages WHERE Page="'.$page.'"'; $r=mysql_query($q) or die(mysql_error()); while($row = mysql_fetch_array($r)) { $content = $row['Content']; } return $content; } </code></pre> <p>The Content of the variable <code>$content</code>, will be something like: </p> <pre><code>&lt;div id="hello"&gt;{$foo}&lt;/div&gt; </code></pre> <p>where <code>{$foo}</code> is in fact a PHP variable and must be run by the PHP code before printing the final HTML.</p> <p>How can I do that? Also please consider I will have many {$foo} variables into the content, so I must find a way to replace all of them and to make the PHP working on them before printing the final HTML code.</p> <p>Can you help me? :)</p>
php
[2]
4,952,578
4,952,579
Can I work with only PYC files
<p>I have a program that uses couple of PY files. The code works perfectly till I use the PY files. However, for encryption when I delete the PY files and just keep the PYC files the program fails with message: <strong>ImportError: No module named abc</strong> </p> <p>Any ideas/thoughts why python does not like the PYC here when everyting was working fine with the PY files?</p>
python
[7]
1,283,478
1,283,479
How to store text with special characters in php?
<p>My description paragraph contains ("" and ') but when I try to save data, slash(\) get saved in database before these characters. I am using <code>mysql_real_escape_string($_POST['des'],$link);</code> but that is not working.</p>
php
[2]
5,431,561
5,431,562
Converting date formats in PHP
<p>I have a date:</p> <pre><code>20-01-2013 </code></pre> <p>I need it to be in a format for the database:</p> <pre><code>2013-01-20 20:39:39 </code></pre> <p>So far I have this:</p> <pre><code>$originalDate = "20-01-2013"; $newDate = date("Y-m-d", strtotime($originalDate)); </code></pre> <p>But how do I get the time added to the end? I just want it to be 00:00:00.</p> <p>Thanks</p>
php
[2]
2,382,681
2,382,682
How to store a cookie with php
<p>How can a save a cookie using php for every visitor on my site? My website also has a unique ID generator. I want to know how to make the id stay the same using cookies</p>
php
[2]
3,551,522
3,551,523
xmlHttpRequest.send(Params) not working in tomcat 7
<p>I am trying to send some parameters through xmlHttpRequest.send(params) written in a JS file to my servlet where I try to get the parameters by req.getParameter("some_Parameter"); it returns null on the servlet. though if i send the parameters by appending them in url it works fine. but when the url will be large it will break the code. so please someone help me out.</p> <p>Thanks in advance. </p> <pre><code>function doHttpPost(theFormName, completeActivity) { var xmlhttp = new ActiveXObject("MSXML2.XMLHTTP"); var xmlMessage = buildPOST(theFormName, completeActivity); var responseTxt; try { xmlhttp.Open(document.forms[theFormName].method, document.forms[theFormName].action+'?'+xmlMessage, false); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { responseTxt = xmlhttp.responseText; } } xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); enableDisableLinks(true); setPointer(); xmlhttp.Send(); if(xmlhttp.Status != 200) { alert("Post to server failed"); } } catch (e) { responseTxt = "Exception while posting form data: Error No: " + e.number + ", Message: " + e.description; } resetPointer(); enableDisableLinks(false); var expectedTxt = "Form Data had been successfully posted to the database." if(responseTxt.toString() == expectedTxt.toString()) { // MNP: New requirement from Jeanne, should not refresh CM page, commenting it off for now //if(completeActivity) { // if (typeof (ViewCaseDetailBtn) != 'undefined') { // ViewCaseDetailBtn.click(); // } //} return true; } else { alert (responseTxt); } return false; } </code></pre>
javascript
[3]
3,319,414
3,319,415
Prevent an effect running twice in jQuery mouseenter/leave when used with .on()
<p>I have a dropdown box that operates with the following:</p> <pre><code>$(document).on("mouseenter mouseleave", "#dropdown", function(event){ if (event.type == 'mouseenter') $('#dropdown ul.children').slideDown(1000); else $('#dropdown ul.children').slideUp(1000); //stop();? }); </code></pre> <p>However if you move the mouse out and in fast then you can make another event run before the other has finished, how can I ensure the current on finishes before the next starts?</p> <p>If I use <code>.stop()</code> then it's possible to mouseover and move the mouse back off and on and it will just restart the animation from the beginning making it look jerky?</p>
jquery
[5]
5,439,618
5,439,619
Find substring or exact string in php
<p>When I use strpos it returns false if the both strings are equal. Is there a function or a parameter to this function that returns tru if there is a substring in the main string or both strings are equal?</p> <p>Or am i wrong and it does it for the full string also?</p>
php
[2]
1,856,130
1,856,131
Jquery failing to detect change in select in IE7&8 but works in FF
<p>I can get this to run in IE9 and FF but does not work in IE7&amp;8 can anybody point me in the right direction. Any ideas what to look out for?</p> <p>JQuery</p> <p></p> <pre><code>$(document).ready(function() { $('#page').change(function(){ alert('--not-calling-in-IE8-or-IE7-Mode-Works-Fine-In-FF-'); var url = 'galleryoptions.php?page=' + $('#page option:selected').val(); $.getJSON(url, function(j){ var options = '&lt;option value="0"&gt;None&lt;/option&gt;'; for (var i = 0; i &lt; j.length; i++) { options += '&lt;option value="' + j[i].optionValue + '"&gt;' + j[i].optionDisplay + '&lt;/option&gt;'; } $("#proj").html(options); }); }); }); </code></pre> <p>HTML</p> <pre><code>&lt;label for="page" style="margin-top:10px;padding:2px; margin-left:-15px;"&gt;P&amp;aacute;gina&lt;/label&gt; &lt;select id="page" name="page" type="text" style="width:135px; margin-top:8px;margin-bottom:8px;padding:2px; margin-left:10px;"&gt; </code></pre> <p>What I have tried:</p> <p>I placed an onchange on the select and called an alert and it worked. I placed an onchange on the select and called a function which never worked.</p> <pre><code>&lt;select id="page" name="page" type="text" onchange="alert('This works')"&gt; function dofn(){ alert('This fails') } &lt;select id="page" name="page" type="text" onchange="dofn();"&gt; </code></pre> <p>Any ideas?</p>
jquery
[5]
5,890,780
5,890,781
Converting const unsigned int to unsigned int in template parameter
<p>With the following code:</p> <pre><code>#include &lt;iostream&gt; template&lt; class T, unsigned int NVectorDimension = 3 &gt; class Vector { }; template&lt; unsigned int TDimension &gt; int RunTest( void ) { const unsigned int VectorDimension = 4; typedef Vector&lt; int, VectorDimension &gt; VectorPixelType; } int main(int argc, char *argv[]) { return 0; } </code></pre> <p>I get:</p> <pre><code>In function ‘int RunTest()’: 12:40: error: could not convert template argument ‘VectorDimension’ to ‘unsigned int’ error: invalid type in declaration before ‘;’ token </code></pre> <p>Any ideas what is wrong with that?</p> <p>David</p>
c++
[6]
4,473,248
4,473,249
Can we store 30mb of data in our android application?
<p>Actually my project database size is <strong>30mb</strong>. I have used only <strong>7mb</strong> of data till now. But now <strong>I need to place the complete database(30mb) in my assets folder</strong> of my project. <strong>Can we place that much data for android application?</strong> Please help me regarding this. Will be thankful to you</p>
android
[4]