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
67,972
67,973
Form submission on web - image containing characters for user to type in
<p>Often when you fill in a form on the web you are asked to type in some characters from an image to validate you aren't a robot etc.</p> <p>Does anyone know A) what you actually call these things? B) are there any third party tools that can be used to generate the images? (.NET focus here)</p>
asp.net
[9]
3,485,375
3,485,376
How to ignore a jQuery event when a certain button is clicked?
<p>In my code I have an Ajax lookup bound to the <code>focusout</code> event of a textbox. The Ajax request will display an error message if the data provided was invalid. I also have a "cancel" button on a form that, when clicked, hides some fields including the one with the request. However, if an invalid value is specified in the textbox, clicking the Cancel button fires off the Ajax request (because the textbox loses focus) and the error message gets displayed.</p> <p>What I want is when I click the cancel button, this Ajax event is <strong>not</strong> fired, so even if the user entered an invalid entry the form will be "closed" without the error message displaying.</p> <p>Is this possible?</p> <p>Code is this, basically:</p> <pre><code>$('#txtPostalCode').focusout(function() { postalCodeLookup($(this).val()); // ajax method wrapper }); $('button#cancelButton').click(function() { $('#txtPostalCode').attr('disabled', true).addClass('disabled'); // applies CSS style to make textbox look like a label $('#txtPostalCode').val($('#oldPostalCode').val()); // restore old value }); </code></pre> <p>as I said since the focusout fires before the click, you can't "cancel" the form if there's an invalid entry in the textbox since it will fire the ajax request and come up with the error message. This issue is from a usability point of view, in that someone might enter an invalid zip code, realize their mistake and then try to cancel the form, but the form won't let itself it be cancelled until they enter a valid zip code (which is then just overridden when the form actually does cancel).</p> <p>If there's a better way to handle what I want to do I'm all for hearing that as well, this was the first thing that popped into mind when I received the requirement :)</p>
jquery
[5]
2,286,609
2,286,610
C++ Strange output during extraction of integers using cin.ignore()
<p>The following program expects user input in the mixed fraction format 'whole_numbernumerator/denominator' and assigns values to respective variables.</p> <pre><code>#include&lt;iostream&gt; using namespace std; int main() { int whole, numerator, denominator; cout &lt;&lt; "Input format: i&lt;space&gt;n/d" &lt;&lt; endl; cin &gt;&gt; whole; cin.ignore(1000, ' '); cin &gt;&gt; numerator; cin.ignore(1000, '/'); cin &gt;&gt; denominator; cout &lt;&lt; whole &lt;&lt; endl; cout &lt;&lt; numerator &lt;&lt; endl; cout &lt;&lt; denominator &lt;&lt; endl; return 0; } </code></pre> <p><strong>Input1:</strong><br> 123 345/678 <br> <strong>Output1:</strong><br> 123<br> 345<br> 678<br> <br><strong>Input2</strong>:<br> 1111111111 1111111111/1111111111<br> <strong>Output2:</strong><br> 1111111111<br> 1111111111<br> 1111111111<br> <br><strong>Input3:</strong><br> 2222222222 2222222222/222222222<br> <strong>Output3:</strong><br> 2147483647<br> 0<br> 0<br> <br> I haven't been able to figure out why the program doesn't work for Input3. </p>
c++
[6]
4,960,882
4,960,883
How to share a jquery function
<p>I have the following code that edits text. Normally there is an id used instead of a class. I've changed it to a class because I'd like to share a single instance. Now that it's a class, I can't tell which element the user clicked on.</p> <p>I want to use one instance of the following code and send in an additional argument that can be passed to my PHP that distinguishes the element and pass that to my PHP code.</p> <pre><code>$(".edit").edit({ url:'server.php' }); </code></pre> <p>So, maybe something like:</p> <pre><code>function myFunc(arg){ $(".edit").edit({ url:'server.php?arg='+arg }); } </code></pre> <p>Of course, this doesn't work because I need the click function and I'm not sure how to do that. Can someone help?</p>
jquery
[5]
499,862
499,863
unable to download all songs from server
<p>in my app i am having a button called download all clicking on which i have to download all songs present on my server. i am able to download one song at a time. Below is my code:</p> <p>NetworkManager *manager = [[NetworkManager alloc] init];</p> <pre><code>NSString *Mp3filePath = [manager GetFile:SongUrl]; NSLog(@"aaaaa"); SongUrl= [[NSString alloc] initWithString:@"my URL"]; NSLog(@"aaaaa"); NSLog(@"songurl--%@",SongUrl); </code></pre>
iphone
[8]
1,028,462
1,028,463
What does this do in C#?
<p>I'm newbie at C# and couldn't find anything about this:</p> <pre><code>public bool HasUPedidos { get { return upedidos &gt; 0; } } </code></pre> <p>What does this expression does? Thank you.</p>
c#
[0]
2,142,469
2,142,470
Use string in switch case in java
<p>I need to change the following if to switch case to improve the cyclomatic complexity.</p> <pre><code>String value = some methodx; if ("apple".equals(value )) { method1; } if ("carrot".equals(value )) { method2; } if ("mango".equals(value )) { method3; } if ("orance".equals(value )) { method4; } </code></pre> <p>But i am not sure wat value is going to get.</p>
java
[1]
497,329
497,330
Is the video recording possible in the background service?
<p>I've tried video recording in the background. But had failed.</p> <p>Under normal circumstances, the recording works properly. However, if HOME key down-> Home screen or Other Activity is running, recording terminates.</p> <p>In such a situation, I want to record continuously. I want to record whole process!</p> <p>What should I do?</p> <p>thanks. -Michael</p>
android
[4]
1,816,545
1,816,546
Call webpage from another server into your website using php
<p>I am sorry if this is a duplicate.</p> <p>I am creating an application in PHP and Codeigniter for my client and he has a strange request. There is a link on the website which shows diamond report from IGI website. The IGI website is made in ASP.net and uses query strings to show a report. My application opens that report in a new pop up window. Since, it is another server and uses query string the url is shown in web page source. </p> <p>Now, he wants to camouflage the url or does not want anybody to see the external IGI report url in the source of the webpage. How can I implement this functionality? I told him that this is not possible as the IGI server itself uses query strings.</p> <p>Is this possible? Here is the url to the report:</p> <pre><code>http://www.igiworldwide.com/search_report.aspx?PrintNo=S3B30818&amp;Wght=0.13 </code></pre> <p>Now he does not want that the above url be shown in the source but want it something like <a href="http://www.hiswebsite.com/certificate/1234567879" rel="nofollow">http://www.hiswebsite.com/certificate/1234567879</a> which shows the report from IGI website.</p> <p>I am puzzled.</p> <p>Gaurav</p>
php
[2]
2,375,211
2,375,212
How to close the android app on onBackPressed?
<p>I have three screens (activities).Let's say A,B,C.</p> <p>The screen transition is in the order A,B,C.</p> <p>I want to close the application once the user tap "back" button from the third screen (screen C).</p> <p>How to do it?</p>
android
[4]
4,047,668
4,047,669
Custom form in iOS
<p>I want to create a custom form that a user can fill out for ios, then email to themselves or upload to cloud etc. What is the best way of approaching this?</p> <p>Eg a gas engineer has to complete a gas safe certificate for his work. He/she fills out the form on his device and then sends as email or uploads to cloud. Creating the cert is no problem, capturing the entered data and emailing it as it appears on the screen seems to have me stuck.</p>
iphone
[8]
837,027
837,028
Why is my element giving me 'undefined' in this jquery .each() function...?
<p>I'm having some problems with this jQuery....I'm new to it. It looks like it's the same as the example I'm taking it from...</p> <pre><code>$.getJSON('&lt;%= Page.ResolveUrl("~/MyService.aspx") %&gt;', function(data) { $.each(data, function(index, elem) { alert(elem.Name); }); } ); </code></pre> <p>elem.Name always says 'undefined'! I'm getting the following data returned from my service...</p> <pre><code>{"ID":1,"Name":"David Bowie"} </code></pre>
jquery
[5]
5,558,234
5,558,235
Python: generate random integers between 0 and 9
<p>How can I generate random <strong>integers</strong> numbers <strong>between 0&lt;9</strong> (included extremes) in python ?</p> <p>i.e. 0 1 2 3 4 5 6 7 8 9</p> <p>thanks</p>
python
[7]
5,509,710
5,509,711
Document root not displaying
<p>I have a script which uses its absolute path to all other included files; the script is going to be execute as a cron job. When I run the script in the terminal the <code>$_SERVER["DOCUMENT_ROOT"]</code> returns a null value, but in the browser it returns the correct document root.</p> <p>What would cause this problem?</p>
php
[2]
1,922,516
1,922,517
Understanding the Map function. python
<pre><code>map(function, iterable, ...) </code></pre> <p>Apply function to every item of iterable and return a list of the results. If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel. If one iterable is shorter than another it is assumed to be extended with None items. If function is None, the identity function is assumed; if there are multiple arguments, map() returns a list consisting of tuples containing the corresponding items from all iterables (a kind of transpose operation). The iterable arguments may be a sequence or any iterable object; the result is always a list.</p> <p>what role does this play in making a Cartesian product?</p> <pre><code>content = map(tuple, array) </code></pre> <p>what effect does putting a tuple anywhere in there have?</p> <p>I also noticed that without the map function the out put is 'abc' and with it, its 'a,b,c'</p> <p>I want to fully understand this function. The reference definitions is also had to understand. Too much fancy fluff. </p>
python
[7]
5,883,681
5,883,682
Modular approach for pluralizing nouns
<p>I think we've all run into the issue before where an app says that there are "1 minutes remaining", or something along those lines. I think this observation is a testament to the fact that many programmers ignore this issue.</p> <p>In my projects, I've typically done something along these lines to account for pluralizing nouns: </p> <pre><code>$Count = count($Items); $Noun = 'minute'; if ($Count != 1) { $Noun .= 's'; } echo sprintf('There are %u %s remaining.', $Count, $Noun); </code></pre> <p>I have a couple issues with this approach:</p> <ol> <li>It places the onus on the programmer to do this pluralization check every single time a string needs to be generated, so code can never be reused. </li> <li>It needlessly bloats the application code and inhibits readability.</li> <li>It is not generic. The example worked because "minutes" is the plural of "minute". What about "sheep", "ox", or "fungus"?</li> </ol> <p>Does anyone have any ideas for a generic, modular approach to solve this problem? I'm ok with there being more than just one answer. </p> <p>Thanks in advance,<br /> Zach</p>
php
[2]
3,894,661
3,894,662
Normal UpdatePanel behaviour? ASP.NET
<p>Am I doing this correctly?</p> <p>I have two dropdowns. The first is populated on form load, and it is a trigger for an updatepanel that contains the 2nd dropdown.</p> <p>When I change the value in the first dropdown box, it triggers the 2nd one's updatepanel, which populates it.</p> <p>However, when I select a value in the 2nd dropdownbox, it triggers itself and repopulates... so if I select the 2nd or 3rd item in the dropdown, it repopulates and selects the first item again.</p> <p>Am I doing something wrong, or is this normal? Should I put the first dropdown into an updatepanel instead and have it trigger itself, and in its own trigger, populate the 2nd listbox?</p>
asp.net
[9]
3,320,699
3,320,700
Can you call a PHP defined value inside of a function call?
<p>Please look at the example code below, when I run it, the defined part is nottranslated in the header function call, is there a special way to do the syntax or is this exact method not possible?</p> <pre><code>&lt;?PHP session_start(); define('SITE_URL', 'http://testsddf.com'); $_SESSION['user_role'] = 0; //if a user is not active, redirect to verification/suspended page if($_SESSION['user_role'] == 0){ header('Location: SITE_URL'); } ?&gt; </code></pre>
php
[2]
3,231,767
3,231,768
SocketPermission - Client Port?
<p>I've been developing a web application that gets deployed in Apache Tomcat 6, running Java 6 Update 31. There is a requirement to include a module that will simply listen to incoming TCP traffic on port X for future processing. Everything was working great until we went to enable the Java Security Manager (an IA requirement).</p> <p>Once it was enabled, we started getting AccessControlExceptions, but this was expected, since nothing in our policy file was explicitly allowing this traffic. So, I added the following lines to Tomcat's "catalina.policy" file (where 54321 is the port the app is listening on):</p> <pre><code>grant { permission java.net.SocketPermission "*:54321", "accept, resolve"; }; </code></pre> <p>However, we were still seeing AccessControlExceptions, such as:</p> <pre><code>java.security.AccessControlException: access denied (java.net.SocketPermission 192.168.1.50:1527 accept,resolve) </code></pre> <p>Looking at that error line, I noticed that "192.168.1.50" is in fact the IP of the client, so "1527" must be the client-side port for the socket. This is verified by the fact that this port changes each time this is attempted...</p> <p>So, my question is: why does my web application need to care about the client port? My understanding is that outgoing connections simply use arbitrary/random ports. It seems to me that on my side, with respect to this policy file, I should only need to specify the ports I want to listen to. However, the only way I can get this to work is if I change "54321" to "*" in the above permission line, thereby opening the JVM up to the world.</p> <p>Am I misunderstanding something about the syntax here? How can I make sure that my application accepts connections from ANY host, from ANY client-side port, on server port 54321?</p> <p>Thanks, Doug</p>
java
[1]
2,324,126
2,324,127
Telerik RadAsyncUpload IIS cpu memory 100% and not deleting Rad Upload temporary files
<p>I am using Telerik RadAsyncUpload and uploaded a size of 1 GB files to server and when i am checking CPU Usage it is taking 100% and also not deleting the temporary files. Kindly give me a suggestion to reduce the CPU Usage and also for deleting the Rad uploaded temporary files.</p>
asp.net
[9]
2,025,074
2,025,075
Button Layout Issue
<p>my problem is as follows:</p> <ul> <li>If if start my application all is fine. </li> <li>Then I exit it (using <strong>moveTaskToBack(true)</strong> , because the androids built in functionality has to be disabled (I know thats that no good idea, but it was not mine...)) </li> <li>After starting an activity I see, that the button has not the background I specified in my XML using android:background="@drawable/button_accept" (Self designed button, which worked before moving task to back!)</li> <li>Using any other button I designed would work just fine e.g. the deny button</li> <li>In the source code the only thing I do with this button is adding Listeners to it</li> </ul> <p>This is the accept buttons XML(inside the selector tag)</p> <p> </p> <pre><code>&lt;item android:drawable="@drawable/accept_300x100" android:state_focused="true"/&gt; &lt;item android:drawable="@drawable/accept_effect_300x100" android:state_pressed="true"/&gt; &lt;item android:drawable="@drawable/accept_effect_300x100" android:state_focused="false" android:state_pressed="true"/&gt; &lt;item android:drawable="@drawable/accept_300x100"/&gt; </code></pre> <p></p> <p>by the way: i tested it on a tablet using android 2.2.1 and the app is designed for this android version</p> <p>Any ideas?</p>
android
[4]
3,110,525
3,110,526
how to rewrite a recursive method by using a stack?
<p>Since C# doesn't support the optimization of recursive call very well (e.g tail recursion). It seems I have to switch my code style from functional programming to something I am not familiar with.</p> <p>I know sometimes iterative method alternative exists to a recursion method, but usually it is quite hard to find an efficient one.</p> <p>Now, in generally, I believe all recursive methods can be rewritten by using <code>stack&lt;T&gt;</code> data structure somehow.</p> <p>Where can I find the tutorial or introduction or general rule to this?</p> <p>e.g., what if I wanna rewrite greatest common divisor method? given m>n</p> <pre><code> int gcd(int m, int n) { if (n==0) return m; else return gcd(n,m%n); } </code></pre> <p><strong>Update</strong></p> <p>Probably it is a bad example as it indeed is tail recursive. Plz just ignore the fact and consider it is a normal recursive method.</p>
c#
[0]
2,054,208
2,054,209
find dupicates in html table using jquery
<p>I have a html table whose rows are added by click add button. The row will contain 4 drop downs Product Type , Product Description,Source,destination1,destination 1</p> <p>How Can I restrict the combination of these are not duplicated in any of the rows.</p> <p>Thanks </p>
jquery
[5]
3,922,134
3,922,135
Python: IndentationError: expected an indented block
<pre><code>if len(trashed_files) == 0 : print "No files trashed from current dir ('%s')" % os.path.realpath(os.curdir) else : index=raw_input("What file to restore [0..%d]: " % (len(trashed_files)-1)) if index == "*" : for tfile in trashed_files : try: tfile.restore() except IOError, e: import sys print &gt;&gt; sys.stderr, str(e) sys.exit(1) elif index == "" : print "Exiting" else : index = int(index) try: trashed_files[index].restore() except IOError, e: import sys print &gt;&gt; sys.stderr, str(e) sys.exit(1) </code></pre> <p>I am getting:</p> <pre><code> elif index == "" : ^ IndentationError: expected an indented block </code></pre>
python
[7]
2,247,590
2,247,591
Regex to include negative numbers in java
<p>In this program I'm parsing input into integers and I can't seem to be able to take in negative numbers and have tried a bunch of regular expressions. I can get positive integers no problem by removing the &amp;&amp;^- it's just the negative integers I'm having problems with.</p> <p>Example:</p> <pre><code>input = console.readLine("?&gt; ").split("\\D+&amp;&amp;^-"); </code></pre> <p>Any idea and what I'm doing wrong? Thanks for any help in advance.</p> <p>Sample input: -7 * 4</p> <p>Output: -7 and 4 should be stored into an array of strings.</p>
java
[1]
5,170,487
5,170,488
Storing the Soap values in raw folder
<p>I am working with web service using soap parser. I need to retrieve the values from the web service and store it in local. I have lot of string values in it.</p> <p>My question is, how and where to store all the string values in my application. Like, this sort of storage normally we use raw folder.</p> <p>Thanks in advance</p>
android
[4]
4,440,286
4,440,287
How to debug multithreaded application for Android
<p>how to debug multithreaded application for Android..</p> <p>I am new to this android platform I want to debug a native multithreaded application on android. Please let me know the procedure.</p>
android
[4]
3,228,155
3,228,156
How to partition bits in a bit array with less than linear time
<p>This is an interview question I faced recently.</p> <hr> <p>Given an array of 1 and 0, find a way to partition the bits <code>in place</code> so that 0's are grouped together, and 1's are grouped together. It does not matter whether 1's are ahead of 0's or 0's are ahead of 1's.</p> <p>An example input is <code>101010101</code>, and output is either <code>111110000</code> or <code>000011111</code>.</p> <p>Solve the problem in less than linear time.</p> <p>Make the problem simpler. The input is an integer array, with each element either 1 or 0. Output is the same integer array with integers partitioned well.</p> <hr> <p>To me, this is an easy question if it can be solved in <strong>O</strong>(N). My approach is to use two pointers, starting from both ends of the array. Increases and decreases each pointer; if it does not point to the correct integer, swap the two.</p> <pre> int * start = array; int * end = array + length - 1; while (start &lt end) { // Assume 0 always at the end if (*end == 0) { --end; continue; } // Assume 1 always at the beginning if (*start == 1) { ++start; continue; } swap(*start, *end); } </pre> <p>However, the interview insists there is a sub-linear solution. This makes me thinking hard but still not get an answer.</p> <p>Can anyone help on this interview question?</p> <p><strong>UPDATE</strong>: Seeing replies in SO stating that the problem cannot be solved in sub-linear time, I can confirm my original idea that there cannot be a solution of sub-linear. </p> <p>Is it possible the interviewer plays a trick?</p>
c++
[6]
5,096,350
5,096,351
GetAdaptersInfo (c++)function not working on vista and windows 7
<p>i am using GetAdaptersInfo on windows xp to retrieve mac address.its working well on xp but neither on vista nor on windows 7. Is GetAdaptersInfo supported by windows 7 and vista. if no what api should i use to get mac address</p>
c++
[6]
4,293,172
4,293,173
Creating SQL Session state store
<p>Implemented the SqlSessionStateStore by inheriting from SessionStateStoreProviderBase. Created the dll and placed the dll in the bin folder (as im not able to register it into GAC as im using MS Visual Web Developer 2010 Express).</p> <p>And add the below Session State Configuration setting in the web.config.</p> <pre><code> &lt;sessionState cookieless="true" regenerateExpiredSessionId="true" mode="Custom" customProvider="SqlSessionProvider"&gt; &lt;providers&gt; &lt;add name="SqlSessionProvider" type="Sample.AspNet.Session.SqlSessionStateStore" connectionString="SqlConnenctionString" writeExceptionToEventLog="false"/&gt; &lt;/providers&gt; &lt;/sessionState&gt; </code></pre> <p>Now im getting this error. </p> <p>Parser Error Message: Could not load type 'Sample.AspNet.Session.SqlSessionStateStore'. Source Error: </p> <pre><code>Line 15: &lt;providers&gt; Line 16: &lt;add name="SqlSessionProvider" Line 17: type="Sample.AspNet.Session.SqlSessionStateStore" Line 18: connectionString="SqlConnenctionString" Line 19: writeExceptionToEventLog="false"/&gt; </code></pre> <p>Can any one help me with the reason for this error.</p>
asp.net
[9]
3,115,874
3,115,875
Trying to split a string
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4998629/python-split-string-with-multiple-delimiters">Python: Split string with multiple delimiters</a> </p> </blockquote> <p>I have a small syntax problem. I have a string and another string that has a list of seperators. I need to split it via the <code>.split</code> method.</p> <p>I can't seem to figure out how, this certainly gives a Type error.</p> <pre><code>String.split([' ', '{', '=']) </code></pre> <p>How can i split it with multiple seperators?</p>
python
[7]
3,771,608
3,771,609
Accelerometer sample projects
<p>I want some accelerometer sample projects through which i can understand how i can move my object by moving iPhone or iPod?</p>
iphone
[8]
724,425
724,426
compare To object enum
<p>I have to create a method which tests if two object enum are equal.</p> <p>Here is the code:</p> <pre><code>public Passenger{ private String name_pass; public enum StatePass{ b,c,p }; private StatePass state; public Passenger(String name_pass,StatePass state){ this.name_pass=name_pass; this.state=state; } public boolean isConfirmed(){ if() return true; return false; } } </code></pre> <p>Inside the <code>if()</code> I have to check if the field state is equals to <code>p</code>.</p> <p>How can I do that?</p>
java
[1]
2,648,151
2,648,152
array length property not found within javascript object prototype
<p>I am trying to create a simple javascript/html5 canvas engine to support my animation(this is mainly for learning purposes.)</p> <p>Engine:</p> <pre><code>/* BOF GLOBAL REFERENCES*/ var BM = BM || {}; /* EOF GLOBAL REFERENCES */ /* BOF GLOBAL VARIABLES */ /* EOF GLOBAL VARIABLES */ /* BOF FUNCTIONS */ BM.World = function(container,width,height,name){ this.container = $("#"+container); this.width = width; this.height = height; this.name = name || "DefaultWorld"; this.layers = new Array(); } BM.World.prototype.Layer = function(options){ var options = options || {}; options.bgcolor = options.bgcolor || "transparent"; this.container.html( "&lt;canvas id='"+this.name+"_layer_"+this.layers.length+"' style='position:absolute;top:0;left:0;width:"+this.width+";height:"+this.height+";background:"+options.bgcolor+";'&gt;" +"&lt;/canvas&gt;"); } /* EOF FUNCTIONS */ </code></pre> <p>And the simple caller code:</p> <pre><code>$(function(){ var World = new BM.World("background_container",400,600); var layer1 = new World.Layer({bgcolor:"#ff0000"}); }); </code></pre> <p>Can someone please tell me what I am doing wrong in the <code>Layer</code> definition? the error I get is:<code>Uncaught TypeError: Cannot read property 'length' of undefined</code></p>
javascript
[3]
3,722,185
3,722,186
How to create user level themes like Orkut?
<p>I am doing a community website. Assume that I am giving an option to all my users to choose a theme. That we happen see on websites like Orkut , Gmail etc..Actually we can keep only one theme inside the web config right ?. During dynamic change all the other user's themes will also change. How to avoid this?</p>
asp.net
[9]
5,645,831
5,645,832
Call JavaScript method on dynamic form element
<p>I am creating new textbox using JavaScript. I want to call a JavaScript method onkeyup event of this newly created textbox. How will I do this?</p> <p>Below is my code:</p> <pre><code>var element2 = document.createElement("input"); element2.type = "text"; element2.id='complete-field'+tableID; element2.name=tableID; </code></pre>
javascript
[3]
658,269
658,270
iOS initWithCoder/decodeObjectForKey memory leak
<p>The Leaks instrument tells me that I have a memory leak when I use <code>decodeObjectForKey</code> within <code>initWithCoder</code>. For example:</p> <pre><code>Class.h { MyObject *myObject; } @property (nonatomic, retain) MyObject *myObject; Class.m @synthesize myObject -(void)dealloc{ [myObject release]; [super release]; } -(id)initWithCoder:(NSCoder *)decoder{ if (self = [super init]{ self.myObject = [decoder decodeObjectForKey:@"MyObject"]; } return self; } </code></pre> <p>Per request in the comments:</p> <pre><code>-(void)encodeWithCoder:(NSCoder *)encoder{ [encoder encodeObject:myObject forKey:@"MyObject"]; } </code></pre> <p>Leaks reports a leak of type NSCFString on the line;</p> <pre><code> self.myObject = [decoder decodeObjectForKey:@"MyObject]; </code></pre> <p>As I understand it, decodeObjectForKey returns an autoreleased object. Since I immediately assign that value to the myObject property, which is specified as (nontoxic, retain) in the property definition, I retain the autoreleased object through the setter method of the myObject property. The myObject is then released in the dealloc method. I don't understand where the leak is if I understand the sequence correctly. Also why is it reported as a NSCFString when the type is MYObject?</p> <p>Any thoughts would be appreciated, including if my assumptions above are correct.</p>
iphone
[8]
4,181,830
4,181,831
jquery.addClass() is not working on adding the already existing attribte with different value
<p>I have a div with <code>style="display:none"</code>. On mouse hover on a link I want to show it by adding a class with <code>display=block</code> but it is not working.</p>
jquery
[5]
3,027,720
3,027,721
swearing in code
<p>I have an application that uses predefined word lists but I want to extend it to give the option of using their own custom lists. </p> <p>Unfortunately lists like SOWPODS (the official Scrabble word list) are quite comprehensive and contain words I wouldn't want popping up on the screen.</p> <p>I can easily get hold of a banned word list and build it into my application as a kind of swear filter. Is this likely to get my app trapped by any application filtering that may be present on Google Marketplace and, if so, is there a way around it? (encryption, compression etc.)</p> <p>EDIT: Most of the answers so far are missing the point that the user will be supplying the list so I have no control over its content and need to filter it in my app either on import or as it is used. (Though they will still blame me if the app "swears" at them)</p>
android
[4]
244,743
244,744
how to store previous activity value in android?
<p>how to store previous activity value in android</p>
android
[4]
2,871,167
2,871,168
what does the "@+android:id/title" mean?
<p>In normal, we should use <code>@+id/</code> to define an id and use <code>@id</code> to reference an id. Today I found <code>@+android:id/title</code> in <code>apps/settings/res/layout/preferenc_progress.xml</code>.</p> <p>How to understand it and how to use it? </p>
android
[4]
411,726
411,727
Enter Text in PopUp Box
<p>I'd like my prog to pop up a box in which the user can enter text to store it in a variable. Do i have to create a new form for this?</p>
c#
[0]
5,529,175
5,529,176
How to get a URL from HTML code block?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3820666/grabbing-the-href-attribute-of-an-a-element">Grabbing the href attribute of an A element</a> </p> </blockquote> <p>I have the following code :</p> <pre><code>&lt;?php $a= "&lt;a href="http://www.kqzyfj.com/click-6331466-10751223" target="_top"&gt; &lt;img src="http://www.tqlkg.com/image-6331466-10751223" width="300" height="250" alt="Kaspersky Anti-Virus 2013" border="0"/&gt;&lt;/a&gt;" ?&gt; </code></pre> <p>Please suggest me any Idea that how can I retrieve the URL (http://www.kqzyfj.com/click-6331466-10751223) in php.</p>
php
[2]
1,534,639
1,534,640
Why we need to go for set_time_limit() instead of ini_set() in PHP?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8914257/difference-between-set-time-limit-and-ini-setmax-execution-time">Difference between set_time_limit() and ini_set(&#39;max_execution_time&#39;, &hellip;)</a> </p> </blockquote> <p>Please explain the difference. </p> <pre><code>ini_set('max_execution_time', 25); </code></pre> <p><strong>VS</strong></p> <pre><code>set_time_limit(25); </code></pre>
php
[2]
1,785,459
1,785,460
Is there a way to assign an APN manually for each network interface?
<p>How do you assign for example rmnet0 to connect to APN#1, rmnet1 to connect to APN#2 in Android? </p> <p>I know the phone I'm using has hardware support for multiple PDP context (Qualcomm developer phone). But the app that controls it is closed source and we need an app that is able to start/stop PDP contexts via an adb shell.</p>
android
[4]
18,063
18,064
How to search in a string in java
<p>I have a text file that stores as following</p> <pre><code>FileWriter fw=new FileWriter("Records.txt",true); PrintWriter pw= new PrintWriter(fw, true); pw.println(refField.getText()+"\t"+documentPathField.getText()+"\t" + abstractLabelArea.getText()+"\t"); clearField(); pw.close(); </code></pre> <p>Now I need to make a application that searches based on the value of refField or documentPathField or abstractLabelArea. The choice is made by a JComboBox containing these three items.Then The a value is provided on JTextField and pressing the search Button should initiate the searching and should print the result of search on JList based on that value. </p> <p>How do I do this?</p>
java
[1]
4,818,749
4,818,750
java int size fixed or variable?
<p>Is integer size in java of fixed length or variable size? </p> <p>ex: 1 or 10000 does both the number takes same space during allocation?</p>
java
[1]
3,153,375
3,153,376
Why should exec() and eval() be avoided?
<p>I've seen this multiple times in multiple places, but never have found a satisfying explanation as to why this should be the case. </p> <p>So, hopefully, one will be presented here. Why should we (at least, generally) not use <code>exec()</code> and <code>eval()</code>?</p> <p>EDIT: I see that people are assuming that this question pertains to web servers – it doesn't. I can see why an unsanitized string being passed to <code>exec</code> could be bad. Is it bad in non-web-applications?</p>
python
[7]
2,592,861
2,592,862
PendingIntent not launching /data apps
<p>I have a keyguard appwidget where I'm launching a few different Intents. It seems I can launch /system apps (mms, settings etc. ) . but not /data apps ( chrome for example )</p> <p>I have the following PendingIntentTemplate defined:</p> <pre><code>Intent startApplicationIntent = new Intent(); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, startApplicationIntent, 0); mainLayout.setPendingIntentTemplate(R.id.stackview, pendingIntent); </code></pre> <p>In my RemoteViewsFactory, I have the following FillInIntent:</p> <pre><code>Intent i = pm.getLaunchIntentForPackage(pkgName); i.addCategory(Intent.CATEGORY_LAUNCHER); i.setAction(Intent.ACTION_MAIN); stackviewRemoteView.setOnClickFillInIntent(R.id.stackview_image, i); </code></pre> <p>There are no errors, the intent just unlocks the keyguard. It also definitely isn't null as the toString() method shows the following:</p> <pre><code>Intent { act=android.intent.action.MAIN cat= [android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.android.chrome cmp=com.android.chrome/com.google.android.apps.chrome.Main } </code></pre> <p>Is there something special I need to do for non-system apps? I thought getLaunchIntentForPackage would give me everything I needed to launch an app the same way as it would launch if it were selected from the home screen.</p>
android
[4]
2,316,918
2,316,919
Android EdgeEffect Orientation
<p>I want to add the Android EdgeEffect to my custom view when it is touched. I overrode onDraw and then used EdgeEffect.draw(canvas) to draw the effect. However it is always drawn on the top edge of the view when I want it on the right edge. I tried to rotate the canvas with Canvas.rotate(90) but that made the effect disappear altogether. </p> <p>Any help would be appreciated. </p>
android
[4]
1,535,867
1,535,868
Issue with complex fonts displaying too large
<p>I have this issue with complex fonts showing in DIVs the wrong way. Once the page loads, the texts pends out of the box... and if I zoom in and out, everything shows the right way. </p> <p>Is there any way to trigger this zoom in and out (ctrl++ and ctrl+-) automatically in every page load? </p> <p>I was thinking about jQuery, but, my javascript knowledge is limited. </p> <p>Any thoughts? </p>
jquery
[5]
4,464,084
4,464,085
Set MaxDisplayedLines into gridView
<p>I want to set MaxDisplayedLines to the gidView . Have you got any idea please ?</p>
asp.net
[9]
1,106,765
1,106,766
Why makes storing a reference instead of requesting it twice my application so much slower?
<p>An object <code>memory</code> has a method with the signature</p> <pre><code>BinaryPattern const&amp; getPattern(unsigned int index) const; </code></pre> <p>I'm using this in the following for-loop:</p> <pre><code>for (unsigned int k = 0; k &lt; memory-&gt;size(); k++) { const BinaryPattern s = memory-&gt;getPattern(k); w += s.at(i) * s.at(j); } </code></pre> <p>This is very slow. Surprisingly, I found that the following is much faster:</p> <pre><code>for (unsigned int k = 0; k &lt; memory-&gt;size(); k++) { w += memory-&gt;getPattern(k).at(i) * memory-&gt;getPattern(k).at(j); } </code></pre> <p>"getPattern()" does not do any computations, it pretty much just returns the pattern that is stored in a vector.</p> <p>Why is it so much slower when I store the reference in a variable? I initially did this to speed things up, as I expected retrieving the reference twice to be slower.</p>
c++
[6]
1,191,218
1,191,219
Simple event in C# for MyControl
<p>I want to Create Event for a time that AllowDrop Changes in MyControl.</p> <p>In MyControl :</p> <pre><code>public event EventHandler AllowDropChanged; private void MyControl_Load(object sender, EventArgs e) { AllowDropChanged +=new EventHandler(MyControl_AllowDropChanged); } private void MyControl_AllowDropChanged(object sender, EventArgs e) { MessageBox.Show("Dropping Changed"); } </code></pre> <p>How Can I Raise My Event ?</p>
c#
[0]
5,314,550
5,314,551
Best Practice for Dialog for Selecting a Bookmark
<p>I haven't written any code for this yet, but I've been researching how to implement bookmarks in my custom web browser. From what I've read, I believe the way to go is to show the user a dialog (I saw <a href="http://stackoverflow.com/questions/4473940/android-best-practice-returning-values-from-a-dialog">this article</a> on how to return the value from the dialog) containing, I think, a ListView for the bookmarks... I'm honestly stuck at something pretty simple - how to present the bookmarks to the user and select one.</p> <p>So, where my questions: </p> <ol> <li>what's "best practice" for displaying a list to the user and having him select one? </li> <li>is doing this in a Dialog "best practice"?</li> </ol> <p>Thanks.</p>
android
[4]
4,195,540
4,195,541
Mixing DEFINEs with Literal Strings in C++
<p>I've created a #define which points to a particular directory. I would then like to use this definition in combination with a string literal:</p> <pre><code>#define PATH_RESOURCES "/path/to/resources/" std::ifstream datafile(PATH_RESOURCES + "textures.dat"); </code></pre> <p>However, the compiler complains about adding char types using the + operator:</p> <pre>error: invalid operands of types ‘const char [11]’ and ‘const char [13]’ to binary ‘operator+’</pre> <p><br/> So how can I combine a #define with a string literal? Or, is there a better way of doing this altogether? I imagine using a const variable would be an alternative, but this would mean having to pass around yet another parameter which I'd rather prefer to keep as a global definition.</p>
c++
[6]
2,311,253
2,311,254
Check another activity's bundle
<p>I'm making a game and I have a menu activity and a gameplay activity. If I save the state of my gameplay activity to a bundle, will I be able to see from the menu activity whether that bundle is null or has anything in it? I have a new game button and continue game button on the menu activity but if there isn't anything to reload in the gameplay activity, I want to disable the continue game button. So in other words, from the menu activity, I want to check in the gameplay activity has something to load. If it does, the user can hit the continue button, otherwise I want it disabled. Is this possible with bundles?</p>
android
[4]
5,539,823
5,539,824
create a new class object on the fly using a foreach loop and the DirectoryIterator functions
<p>I have a class that parses XML documents into an array.</p> <p>I have 2 XML documents I want to parse and want to create a new class object on the fly using a foreach loop and the DirectoryIterator functions.</p> <p>so far this is my attemp:</p> <pre><code>$settingsIterator = new DirectoryIterator(SETTINGS_PATH); foreach ($settingsIterator as $fileInfo) { if ($fileInfo-&gt;isFile()) { $xmlFileObjName = strtolower(str_replace(".xml", "", $fileInfo-&gt;getFilename())); ${$xmlFileObjName} = new XML(); ${$xmlFileObjName}-&gt;loadXML(SETTINGS_PATH . $fileInfo-&gt;getFilename()); } } </code></pre> <p>but of course this won't work. Is there a method to accomplish something like this?</p> <p>My end goal is to have my script on execution iterate through my settings folder and create new XML object from each xml file in the directory.</p>
php
[2]
2,195,621
2,195,622
Soundpool game with mp3 questions
<p>I am making a game which will be using questions stored on a mp3, so for each question there will be a mp3 file. </p> <p>The user will then press play to hear the mp3 and then add an answer for the mp3 in an edittext field. Which would then show correct or incorrect answer. </p> <p>When the user clicks confirm answer the mp3 will move to the next question. So when the user presses play it will be question 2. Is it possible to do this and if so how would I go about implementing this. I would highly appreciate any advice on this. </p> <p>Thanks. </p>
android
[4]
4,667,814
4,667,815
Android List view color change
<p>I am having a list view in which i wanna to change the color when user clicks or scroll down over the List.. I included listSelector in the XML attributes its not working.. Is there any way to color change when the list scroll down..</p> <p>My code is :</p> <pre><code>&lt;ListView android:id="@+id/allcity" android:listSelector="@drawable/list" android:cacheColorHint="#00000000" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; </code></pre> <p>where drawable/list is the blue background image..</p>
android
[4]
1,447,508
1,447,509
Regarding javascript new Date() and Date.parse()
<pre><code> var exampleDate='23-12-2010 23:12:00'; var date=new Date(exampleDate);//returns invalid Date var date1=Date.parse(exampleDate);//returns NAN </code></pre> <p>i want convert a above string into date. so i havea written a code as u have seen above. these code is runing fine IE and opera, but 'date' variable returning me a invalid Date and 'date1' returning NAN in mozilla Firefox, what should i do. Its urgent help me. Thankh you</p>
javascript
[3]
1,495,016
1,495,017
Move files to server
<p>How is it possible to move files from a folder to web server through FTP, using ASP.Net with C# ?</p>
asp.net
[9]
5,065,413
5,065,414
how to search a japanese pdf file with ios
<p>I can search english pdf files by scanning the 'Tj' and 'TJ' flags. like this: <a href="http://www.random-ideas.net/posts/42" rel="nofollow">http://www.random-ideas.net/posts/42</a></p> <p>But i can not search japanese pdf file. The result of scanning is like these:</p> <blockquote> <p>C ¥ ¢ * £ y y y y<br> y w ù › C ¥ ¢ * £ y y y ¹ Ñ Ä ¢ £ ž › C t x | Â © µ Ä ¤ Ã » | ¯ ï Í € å “ ž · ï Ò å s r w t €</p> </blockquote> <p>I have tried</p> <pre><code>NSString *destString = [data stringByReplacingPercentEscapesUsingEncoding:kCFStringEncodingUnicode]; </code></pre> <p>and</p> <pre><code>NSString* destString = [NSString stringWithCString:(const char*)CGPDFStringGetBytePtr(string) encoding:kCFStringEncodingUnicode]; </code></pre> <p>but it didnt work. How to get correct encoding string?</p>
iphone
[8]
6,030,793
6,030,794
Background Image in RelativeLayout has artifacts
<p>I created a background .png for my application in GIMP. It's resolution is 640x480, which from googling, seems to be the resolution for a default emulator. My problem is when I apply the background to the <code>RelativeLayout</code> with <code>android:background=@drawable/bg</code> and run it, there are lots of artifacts in the image. As if the emulator could not provide enough colors to display the .png correctly. What is going on here?</p> <p>P.S. This image is nothing to fancy, just simple lines and radial gradients.</p>
android
[4]
4,530,379
4,530,380
Whats the difference between <?php functionhere(); ?> and <?=functionhere();?>
<p>Can someone explain to me when <code>&lt;?=</code> needs to be used or why this programmer would code this way? I'm working on creating a third party module for <a href="http://www.spbas.com/" rel="nofollow">SPBAS</a> and I nearly figured it out, I just don't know the significance of the two different options I've specified.</p> <p>Thanks in advance.</p>
php
[2]
2,292,740
2,292,741
Write To a Template
<p>How do I write data to a template, that the user has entered.</p> <p>Ex:</p> <p>Suppose there is a file named <code>template.txt</code> under C:, and the content is:</p> <pre><code>My Name is __________ I Am __ Years Old. </code></pre> <p>So with <code>raw_input</code> I get the users input, now how to i replace those blank area so that when the file is opened from windows, it should have the name and the age in place of those underlines?</p>
python
[7]
342,127
342,128
How to apply hover effect to show and hide buttons on each div?
<pre><code>$(document).ready(function () { $("#divHeader")) { $(this).hover(function () { $(this).find('#edit').show(); $(this).find('#spandate').removeClass("datetime"); $(this).find('#spandate').addClass("edit"); }, function () { $(this).find('#edit').hide(); $(this).find('#spandate').addClass("datetime"); $(this).find('#spandate').removeClass("edit"); }); }); </code></pre> <p>In my page I have 3 div with same name ("divHeader") , But it apply only first div and skip for other two.</p> <p>please tell me how to apply on all using ID ? </p>
jquery
[5]
5,223,792
5,223,793
terminate called throwing an exceptionAbort trap: 6
<p>I have the following code and when I compiled and went, I got following message</p> <blockquote> <p>terminate called throwing an exceptionAbort trap: 6</p> </blockquote> <p>I looked for this ,but I was not able to understand this error message. Please tell me, what this error message means and how I fix the code. Here is the code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int main(){ int n,r; while(cin&gt;&gt;n&gt;&gt;r){ if(n==0&amp;&amp;r==0)break; string s; for(int i=0;i&lt;n;i++) s[i]='i'; for(int i=0;i&lt;r;i++){ int p,c; cin&gt;&gt;p&gt;&gt;c; string left=s.substr(p-1,p+c-1); string right=s.substr(0,p-2)+s.substr(p+c, (int)s.size()); s=left+right; } cout &lt;&lt; (int)(s[0]-'0')+1 &lt;&lt; endl; } return 0; } </code></pre> <p>compile with g++, on Mac OSX 10.7.4</p>
c++
[6]
4,279,121
4,279,122
Object exists in two states when overwriting prototype in javascript
<p>I am trying to get my head around Object Oriented Programming in Javascript and bumped into the following issue: (This is a simplified example of what can be found in Stoyan Stefanov's book)</p> <p>I create a constructor function to create Dog objects:</p> <pre><code>function Dog(){ this.tail = true; } </code></pre> <p>Then I instantiate an object using Dog constructor function:</p> <pre><code>var benji = new Dog(); </code></pre> <p>Then I assign a new property to Dog's prototype object:</p> <pre><code>Dog.prototype.shout = 'Woof!'; </code></pre> <p>Now, benji has access to both tail, as well as shout, as expected. All is well until I overwrite Dog's prototype:</p> <pre><code>Dog.prototype = {paw : 4}; </code></pre> <p>Now, benji.paw becomes undefined. My question is, shouldn't benji have access to the new prototype object as well? What's more baffling is, when I create a new instance of Dog after the prototype object was re-defined:</p> <pre><code>var lucy = new Dog(); </code></pre> <p>lucy.paw evaluates to 4. lucy's constructor object definition seems to be different from benji's. I am quite confused what's going on here, can someone explain how javascript's memory model for objects work? Thanks.</p>
javascript
[3]
5,097,201
5,097,202
Extension method have any limitation in c#
<p>I want to ask, does adding extension methods to datatypes works in the same way as Microsoft's methods or do they have any limitaion. </p> <p>This is relevant to experienced programmers who had find some limitations while using them.</p>
c#
[0]
5,753,232
5,753,233
Android url.openStream slow?
<p>Im using the following code to retrieve some text from a http-server. The size is less than 1 kB and is generated in 0.002 milliseconds</p> <p>However, retreiving the data may take 600 ms, but mostly between 2000 and 5000 ms.</p> <p>the following code is used:</p> <pre><code>long starttime = System.currentTimeMillis(); StringBuffer SB = new StringBuffer(); Common.toLog("101 took "+ (System.currentTimeMillis() - starttime) + " ms"); try { URL url = new URL(Common.server+request); Common.toLog("102 took "+ (System.currentTimeMillis() - starttime) + " ms"); InputStreamReader ISR = new InputStreamReader(url.openStream()); Common.toLog("102a took "+ (System.currentTimeMillis() - starttime) + " ms"); BufferedReader in = new BufferedReader(ISR); Common.toLog("103 took "+ (System.currentTimeMillis() - starttime) + " ms"); String inputLine; while ((inputLine = in.readLine()) != null) { SB.append(inputLine); } in.close(); Common.toLog("105 took "+ (System.currentTimeMillis() - starttime) + " ms"); } catch (IOException e) { Common.toLog("Could not make connection 1"); showMSG(R.string.ERROR_NO_INTERNET, true); } </code></pre> <p>The most timeconsuming method is between log-point 102 and point 102a. When using chrome i can load <a href="http://home.peterelzinga.eu/phpjsinterface/browse.php?action=getCPL" rel="nofollow">the page</a> within 300-350 ms. I would like to know if there is a more efficient way to retrieve this data</p>
android
[4]
5,821,211
5,821,212
Android setContentView(view) will not draw
<p>I am making a graph drawer that takes in a equation and draws the line from the equation, but when I run the function generate_table_and_graph() in my class Graph the screen turns white. What am I doing wrong?</p> <p>Thanks :-)</p> <p>Graph: <a href="http://pastebin.com/uPPgmvbG" rel="nofollow">http://pastebin.com/uPPgmvbG</a> GraphLine: <a href="http://pastebin.com/PjZL62Sr" rel="nofollow">http://pastebin.com/PjZL62Sr</a></p>
android
[4]
4,162,369
4,162,370
GridView Binding with text and Image
<p>I am parsing a xml File which returns an object containing name address and image. Now i want to display the text and image in a gridview but not in the same column.Any suggestion will be appreciated, Thanks in advance.</p>
android
[4]
5,321,468
5,321,469
how to i input a sentence so that the program will recognize the sentence as a single word?
<p>lets say i input : 'dog is mammal'</p> <p>i would like to search for this sentence in a text document. How do i do this in java ?</p> <pre><code> System.out.println("Please enter the query :"); Scanner scan2 = new Scanner(System.in); String word2 = scan2.nextLine(); String[] array2 = word2.split(" "); </code></pre> <p>this code snippet accepts the string 'dog is mammal' and process each tokens separately.</p> <p>For example : 'dog is mammal'</p> <p>dog</p> <p>></p> <p>></p> <p>is</p> <p>></p> <p>></p> <p>mammal</p> <p>></p> <p>></p> <p>i would like to process the input as </p> <p>dog is mammal</p> <p>></p> <p>></p> <p>I doesnt want it to process it separately. I wanted it to process it as a single string and look for matches. Can anyone let me know where i am lacking ? </p>
java
[1]
5,120,994
5,120,995
jQuery right click - insert a hidden comment
<p>I want to use jQuery to add notes/comments to a table.</p> <p>It's easy enough to fire up a dialog from jQuery UI.</p> <p>The problem is, I want a text box (in the dialog) to accept text from the user, and insert that text as a hidden comment on a particular element.</p> <p>insertAfter works and can be used. </p> <p>How do I link the dialog box to know what spawned it though, so it can link back to do the insertAfter on that element?</p>
jquery
[5]
3,636,959
3,636,960
Need to move from try block to catch
<p>I have written some code in the try block as follows.</p> <pre><code>try { if (server1IPAddress != "") { if ( InetAddress.getByName(server1IPAddress).isReachable(1000) == false) { } InsertUploadedTrancasctionDetails(server1IPAddress, deviceId, XMLTransactionData); } } catch (Exception exception) { if ((server1IPAddress != server2IPAddress) &amp;&amp; (server2IPAddress != "")) { InsertUploadedTrancasctionDetails(server2IPAddress, deviceId, XMLTransactionData); } </code></pre> <p>when we are not able to reach an IP Address i need to move from try block if condtion to catch block ie when IP address reachable is false.</p> <pre><code>if ( InetAddress.getByName(server1IPAddress).isReachable(1000) == false) { } </code></pre> <p>I am not able to make an exception in the if block.</p> <p>Is there any way to move from the If block to the catch block without making an exception or by making an exception in the if block.</p> <p>Will any one help me please.</p>
android
[4]
2,078,412
2,078,413
Accessing rows in a ListView
<p>I'm having trouble changing the data held within a TextView inside of a listView. I can access the data and send a toast of the text, but the list isn't updated when I change it.</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setListAdapter(new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, presidents)); ListView lv = getListView(); lv.setTextFilterEnabled(true); ListAdapter list_adapter = lv.getAdapter(); TextView var_x = (TextView) list_adapter.getView(0,null,null); ListView list = getListView(); int count = list.getChildCount(); Toast.makeText(getApplicationContext(),(var_x).getText(),Toast.LENGTH_SHORT).show(); var_x.setText("not a president"); } </code></pre> <p>How can I change the text/styling of a row once I've already created it?</p> <p>Thanks for any help</p>
android
[4]
1,596,343
1,596,344
jquery not working to change inner html?
<p>hey people I'm new at jquery and i have been trying to figure this out for like the past couple of hours... what the hell am I doing wrong here? All I want to do is change the innerHTML of a div. </p> <pre><code>$("left_menu_bar").innerHTML = "You clicked me!"; </code></pre> <p>but the div doesn't change at all when I call the function with that code init.</p>
jquery
[5]
1,097,213
1,097,214
Finding midnight from a stored variable
<p>I have a web page that will allow customers to enter a date/time and I want to be able to stored that variable and then add to that time until Midnight, store that as a second variable and pass it to my sql server. Is there an easy way to do that?</p>
asp.net
[9]
1,458,376
1,458,377
How to turn this JavaScript string "myArray[0].myPrice" in to a reference to myPrice?
<p>If I have a string of <code>"myArray[0].myPrice"</code>, how do I turn this in to a reference to <code>myPrice</code>?</p> <p>This is the code context:</p> <pre><code>binding.value = convert(binding.data[binding.field], binding.converter, binding.data, elem); </code></pre> <p><code>binding.field</code> is what contains "myArray[0].myPrice".</p> <p><code>binding.data</code> has a reference to the hierarchical object which has an Array property of myArray, and the first element is an object with a property of myPrice.</p> <p>EDIT: based on the answers, this worked:</p> <pre><code>binding.value = convert(eval('(binding.data.' + binding.field + ')'), binding.converter, binding.data, elem); </code></pre> <p>Is it good to use eval like this? I thought eval was going away in newer JavaScript?</p>
javascript
[3]
4,992,070
4,992,071
Iterating over os.walk in linux
<p>We have multiple linux server and i would like to get all the details of files and directories in a particular linux server. I know this can be done with os.walk function but it is storing only single file information. Please find the below code</p> <pre><code>import os for d in os.walk('/'): F = open('/home/david/Desktop/datafile.txt', 'w') F.write(str(d) + '\n') F.close() </code></pre> <p>Thanks in advance</p>
python
[7]
1,142,637
1,142,638
In C++, how much programmer time is spent doing memory management
<p>People who are used to garbage collected languages are often scared of C++'s memory management. There are tools, like <code>auto_ptr</code> and <code>shared_ptr</code> which will handle many of the memory management tasks for you. Lots of C++ libraries predate those tools, and have their own way to handle the memory management tasks.</p> <p><strong>How much time to you spend on memory management tasks?</strong></p> <p>I suspect that it is highly dependent on the set of libraries you use, so please say which ones your answer applies to, and if they make it better or worse.</p>
c++
[6]
1,729,184
1,729,185
Why is my method going into infinite recursion?
<p>I've written a method to help build a quadtree. Each quadtree has a root node, and a root node has 4 children. I'm using depth recursion to stop this function from dividing too many times. The depth that is passed in is equal to the log base 2 of the side of the square (a square is always passed in). However, I get infinite recursion from this. Anyone see why?</p> <p>When I run it, the output is "Depth=0" infinitely many times..</p>
c++
[6]
1,949,007
1,949,008
Android File Path URL
<p>I am trying to see if a file exists in my app, for reasons I wont go into I put the resource in this location:</p> <p>MyAppFolder/src/assets/data/mymp3.mp3</p> <p>But what should the file path be for:</p> <pre><code>String path = "??"; File file = new File( path ); if( file.exists() ) message = "exists"; else message = "does not exists"; </code></pre>
android
[4]
473,557
473,558
Convert Degrees/Minutes/Seconds to Decimal Coordinates
<p>In one part of my code I convert from decimal coordinates to degrees/minutes/seconds and I use this:</p> <pre><code>double coord = 59.345235; int sec = (int)Math.Round(coord * 3600); int deg = sec / 3600; sec = Math.Abs(sec % 3600); int min = sec / 60; sec %= 60; </code></pre> <p>How would I convert back from degrees/minutes/seconds to decimal coordinates?</p>
c#
[0]
4,456,073
4,456,074
android listview Keep scrolled position and selected highlited position
<p>i have listview in one activity when user scroll and click the listview ,go to next activity,my problem is when user hit back button ,user needs to see the listview in same style,ie it should selected and maintain scroll position . it possible to maintain scrolled position ,but when am trying to select an item through java ,then the item scrolled to top , how can i maintain scrolled position and selection ? . Please help me</p> <p>//// i need to maintain scrolled position and selected position </p>
android
[4]
2,410,287
2,410,288
how to create dynamic swipe screens in android?
<p>I am not asking for code or anything, but I am learning android myself while making an app. And my app requires to use swiping gesture to move across multiple dynamic lists. So I am thinking I can spawn 3 listviews widgets initially, and show the middle one while hiding the other 2, so when the user swipe either left or right, I would have something right at the moment ready to show. Then whenever a transition is made, the 2 hidden listviews would have to update their data to be the new left listview and right listview. So these listviews have to be in circular order too, like 1 -> 2 -> 3 then back to 1 like that.</p> <p>I need some general directions on how to do it, online reading material would be great too.</p> <p>If it should not be done in the way I described, give me the standard way of doing something like that.</p> <p>It would be awesome if there's a library that can help me out with this.</p> <p><img src="http://i.stack.imgur.com/kL5Ei.png" alt="enter image description here"></p>
android
[4]
4,226,695
4,226,696
Widget-based web framework in Python (similar to vaadin, GWT or zkoss)
<p>I am basically from Java, but I need to use Python for a new project. I prefer widget based web framework like zkoss, vaadin, GWT etc.</p> <p>Does python has widget based framework?</p>
python
[7]
2,069,914
2,069,915
jquery check all hidden elements for similarity of values and return boolean
<p>How can I check a group of hidden fields for their values and if there are dissimilarities in their values, I will return false. But empty values and "False" should be treated as equal. There are 3 possible values only, empty, True and False but I want to treat empty as False.</p> <p>I want something like</p> <pre><code>var isTrue = true; // is there a way to do this in jquery or similar to this? var values = $("#group input:hidden").distinct().take(2); if(values.length == 2) { // only make it false if there is a true in the values. if(values[0] == 'True' || values[1] == 'True') { isTrue = false; } } </code></pre> <p>output should be like</p> <pre><code>{values[0] = '', values[1] = 'False'} = true {values[0] = 'True', values[1] = 'False'} = false {values[0] = '', values[1] = 'True'} = false </code></pre> <p>Index in the index can be interchanged.</p>
jquery
[5]
1,014,351
1,014,352
Impact of Android Customizations by device manufacturers
<p>I am trying to write an android application that uses several of the android apis(like policy manager, package manager, wifi apis etc).</p> <p>The concern i have is, android being open, manufacturers/carriers are free to take any specific version of android as their start point and customize the same and ship it with the device.</p> <p>Note:Please excuse me if this post is in anyway a repeat of earlier posts on the same/similar topic. In such a case, appreciate anyone sharing the earlier post.</p> <p>Few things that bother me are:</p> <ul> <li>Does android enforce/require manufacturers/carriers to retain the default apis and only over-ride/customize the look-and-feel?</li> <li>even if manufacturers change the implementation/behavior of the basic apis that comes from android, do they adhere to the interfaces so that my code doesnt break?</li> <li>how do i ensure/test that my code works on all of the android devices since there is a possibility that one or more customizations could break my whole application?</li> </ul> <p>I know these are some naive questions for many of you who may have been on android for a while, but any pointers in this regard would be of immense help.</p> <p>Any other information in general w.r.t cross version, cross device incompatibilities and strategies to deal with them would be very helpful.</p> <p>Thanks a lot in advance.</p> <p>Regards, Deepak</p>
android
[4]
5,470,443
5,470,444
No Line Break after PHP result?
<p>I've got a code to generate minimum height equal to window height (no, setting it in CSS to 100% doesn't work.)</p> <p>so in the end, in a PHP file, I've got</p> <pre><code>min-height:&lt;?php if (isset($_GET['width']) AND isset($_GET['height'])) { echo "". $_GET['height'] ."&lt;br /&gt;\n"; } else { echo "&lt;script language='javascript'&gt;\n"; echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}" . "&amp;width=\" + screen.width + \"&amp;height=\" + screen.height;\n"; echo "&lt;/script&gt;\n"; exit(); } ?&gt;px; </code></pre> <p>I know that's kind of yucky, but it's just on one line. I've got this working properly and it DOES work but my end result is</p> <pre><code>"min-height:1080 px;" </code></pre> <p>and I need it to NOT be broken, just "min-height:1080px;"</p> <p>I'm sure the fix is incredibly simple, it's been a long day :P</p>
php
[2]
581,923
581,924
Python - Weird UnboundLocalError
<p>When I run the following function:</p> <pre><code>def checkChange(): for user in userLinks: url = userLinks[user] response = urllib2.urlopen(url) html = response.read() </code></pre> <p>I get </p> <pre><code>Traceback (most recent call last): File "InStockBot.py", line 34, in &lt;module&gt; checkChange() File "InStockBot.py", line 24, in checkChange html = response.read() UnboundLocalError: local variable 'response' referenced before assignment </code></pre> <p>Which makes no sense to me. I have no global var response. I expect it to work as below, normally.</p> <pre><code>&gt;&gt;&gt; url="http://google.com" &gt;&gt;&gt; response = urllib2.urlopen(url) &gt;&gt;&gt; html = response.read() &gt;&gt;&gt; html '&lt;!doctype html&gt; </code></pre> <p>Anyone know why I get this error?</p>
python
[7]
5,065,108
5,065,109
Prepend 0 to a single digit if it leads, ends, or exists in the middle of a string separate from another character
<p>Examples of "sentences" that would require a prepend of 0:</p> <p><code>5 this is 3</code> becomes <code>05 this is 03</code></p> <p><code>44 this is 2</code> becomes <code>44 this is 02</code> (note 44 is not prepended because it is not a single digit)</p> <p><code>this 4 is</code> becomes <code>this 04 is</code></p> <hr> <p>Examples of "sentences" that would not get a prepend of 0:</p> <p><code>44 this is</code></p> <p><code>22 this3 is</code> (note 3 is not prepended because it exists as part of a string)</p> <p><code>this is5</code></p> <p>I tried coming up with a regex and failed miserably.</p>
php
[2]
5,049,646
5,049,647
Send value of a variable from phone app to another phone real time
<p>Im a little new to the android development, I believe I have the basics down but I am wondering the best way to communicate between two phones running the same app. I am looking for something that would be close to instant. For an example, if you sent a message or somekind of variable or string it would appear on the other phones app providing the app was open on both phones. Would be great if I could be pointed in the correct direction here, Thank you!</p>
android
[4]
283,390
283,391
Unable to start Activity at startup of phone in android
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/9247096/start-activity-at-startup-of-phone-in-android">start Activity at startup of phone in android</a> </p> </blockquote> <p>i am trying to start activity at start up of phone but whole program is not running there is a no error in program , see my coding <a href="http://pastebin.com/BKaE4AaU" rel="nofollow"> Click here </a> </p>
android
[4]
1,230,405
1,230,406
C++ Vector of vectors is messing with me
<p>If I put this code in a .cpp file and run it, it runs just fine:</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;string&gt; using namespace std; typedef vector&lt;int&gt; row; typedef vector&lt;row&gt; myMatrix; void main() { //cout &lt;&lt; endl &lt;&lt; "test" &lt;&lt; endl; myMatrix mat(2,2); mat[0][1] = 2; cout &lt;&lt; endl &lt;&lt; mat[0][1] &lt;&lt; endl; } </code></pre> <p>But, if I make a .h and a .cpp file with the .h file like this, it gives me boatloads of errors.</p> <pre><code>#ifndef _grid_ #define _grid_ #include&lt;iostream&gt; #include&lt;vector&gt; #include&lt;string&gt; using namespace std; typedef vector&lt;int&gt; row; typedef vector&lt;row&gt; myMatrix; class grid { public: grid(); ~grid(); int getElement(unsigned int ri, unsigned int ci); bool setElement(unsigned int ri, unsigned int ci, unsigned int value); private: myMatrix sudoku_(9,9); }; #endif </code></pre> <p>These are some of the errors I get:</p> <pre><code>warning C4091: 'typedef ' : ignored on left of 'int' when no variable is declared error C4430: missing type specifier - int assumed. Note: C++ does not support default-int </code></pre>
c++
[6]
490,880
490,881
how do i set a conditional statement here?
<pre><code>&lt;ul&gt; &lt;li class="artist-website"&gt;&lt;a href="&lt;?php=$artist_website?&gt;" target="_blank"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="artist-youtube"&gt;&lt;a href="http://youtube.com/&lt;?php=$artist_youtube?&gt;" target="_blank"&gt;&lt;/a&gt;&lt;/li&gt; &lt;li class="artist-twitter"&gt;&lt;a href="http://twitter.com/&lt;?php=$artist_twitter?&gt;" target="_blank"&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I want to add an if exists statement before each of the 'li' items. For example, if "artist-website" exists, then echo <code>&lt;li class="artist-website"&gt;&lt;a href="&lt;?php=$artist_website?&gt;" target="_blank"&gt;&lt;/a&gt;&lt;/li&gt;</code></p> <p>How can I do make this work?</p>
php
[2]
4,512,403
4,512,404
remove LCK file from /data/local/tmp when app starts
<p>How can I remove a LCK file from /data/local/tmp in android when app starts? The USB serial port detection on the device creates a LCK file in /data/local/tmp when the app starts. However, this prevents the device from opening a serial port connection the next time the app is launched.</p>
android
[4]
544,124
544,125
DropDownList_OnSelectedIndexChanged event, In a UserControl is not firing on postback
<p>I forgot to mention this asp.net 2.0.</p> <p>The user control has a unique id and it is loaded in the PageLoad event. The user control is loaded into a panel and the panel is inside of a webpart. The dropdown has autopostback set to true.</p> <p>EnableViewState = true on the dropdown. The ListItems are created in the dropdowns pre-render event method.</p> <p>This is why I don't understand why it is not firing, the dropdown is the only thing that causes postback on this user control.</p> <p>The event methods for the dropdown should occur since the user control is loaded in the page load method on postback again right?</p>
asp.net
[9]
1,079,509
1,079,510
Hide button conditionnaly using javascript and css
<p>I need to display conditionnaly my shopping cart button using Javascript and Css. My goal is to hide the button when no items are present inside the cart.</p> <p>The code of my button is:</p> <pre><code>&lt;span id="mycartbutton" style="float: right; clear: both;"&gt; &lt;a class="button"href="$(shopping_cart_url)"&gt;Mon panier&lt;/a&gt; &lt;/span&gt; </code></pre> <p>When nothing is present in the cart, the url look simply like this:</p> <pre><code>/.../mode=show_cart </code></pre> <p>When one or more items are present, the url look like this:</p> <pre><code>/.../mode=show_cart&amp;cart_id=10332&amp;first_reservation_id=717 </code></pre> <p>Unfortunately I'm not a coder and I don't have any knwoledges of javascript but I suppose is possible to make a check according to rendered url.</p> <p>Actually I use the follow javascript:</p> <pre><code>&lt;script type='text/javascript'&gt; function on_site_form_loaded(event) { if (event=='product_list') document.getElementById('mycartbutton').style.display='none'; } &lt;/script&gt; </code></pre> <p>..this allow me to hide the button on product list as desired BUT even if some items are inside the cart.</p> <p>Somebody can tell me which conditional code I must use for check if the url contain for example the text "cart_id"? This will mean something is present inside the cart and will let me hide the button.</p> <p>thank for your time.</p>
javascript
[3]