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
3,829,583
3,829,584
Why does my comparison always return false?
<p>I have bunch of usernames in this arraylist and I want to check whether username exists in the arraylist or not but the method always returns false.</p> <pre><code>public bool check_username(ArrayList userList, string username) { for (int i = 0; i &lt; userList.Count; i++) { if (userList[i].ToString() == username) { return true; } } return false; } </code></pre>
c#
[0]
1,219,335
1,219,336
extracting file name from a link saved
<p>i have saved a link a database which looks like this</p> <pre><code>~\quizes\314757_499034200123763_1508831626_a.jpg </code></pre> <p>i used the following code to extract the filename </p> <pre><code>Uri uri = new Uri(BulletedList1.DataValueField.ToString()); string filename=Path.GetFileName(uri.LocalPath); </code></pre> <p>but it gives the following error <strong>The format of the URI could not be determined.</strong></p>
c#
[0]
3,706,966
3,706,967
Do functions attached to the prototype property not have closure
<p>I am trying to figure out how I can add methods to a constructor after I have created it.<br> In my code below, I cannot use Person's prototype property to add a new public method which has access to Person's vars. (Do the functions attached to the prototype property not close over the vars in the main function).<br> Unlike the first way, the second way works - Person 2. seems like these are called privileged methods -<a href="http://www.crockford.com/javascript/private.html" rel="nofollow">http://www.crockford.com/javascript/private.html</a>.</p> <pre><code>function Person(name, age){} Person.prototype.details = function(){ return "name: "+name+", age: "+age; }; function Person2(name, age){ this.details = function(){ return "name: "+name+", age: "+age;}; } var per1 = new Person("jim", 22); var per2 = new Person2("jack", 28); per1.details(); //=&gt; ReferenceError: age is not defined per2.details(); //=&gt; "name: jack, age: 28" </code></pre>
javascript
[3]
2,310,359
2,310,360
Get URL of ASP.Net Page in code-behind
<p>I have an ASP.Net page that will be hosted on a couple different servers, and I want to get the URL of the page (or even better: the site where the page is hosted) as a string for use in the code-behind. Any ideas?</p>
asp.net
[9]
1,928,861
1,928,862
Launching activity from another application not displaying the activity, but it is running
<p>I've done a lot of searching for the last day and haven't found anything that seems to match the problem I'm having.</p> <p>(For reasons I won't go into) the app is divided into two separate apks. Each have activities. Only the "core" apk has a MAIN activity that is launched from the Android Launcher. The "plugin" apk has activities that only exist to be called from the first apk's activities and does not have a Launcher icon.</p> <p>The issue I'm having is that when I create an intent to launch an activity from the "plugin" apk, it does the "launching new activity" sliding animation but immediately bounces back. But it is actually launching the activity because I'm seeing log statements in logcat coming from the new activity. I'm not getting any exceptions and it seems to be working other than the fact I'm not seeing the activity on the screen.</p> <p>I've tried creating the intent in both of the following ways:</p> <pre><code>Intent myIntent = new Intent(Intent.ACTION_VIEW); myIntent.setClassName("com.test.plugin", "com.test.plugin.PluginActivity"); startActivity(myIntent); </code></pre> <p>and </p> <pre><code>Intent myIntent = new Intent(); myIntent.setComponent(new ComponentName("com.test.plugin", "com.test.plugin.PluginActivity")); startActivity(myIntent); </code></pre> <p>But both result in the same thing happening as described above.</p>
android
[4]
3,178,346
3,178,347
When Open From Background
<p>I see the delegate has the 'didFinishLaunchingWithOptions' for when the first app first loads. I know each page has the DidLoad and WillAppear.</p> <p>Is there a method/function/class or whatever these things are called for when the app is opened while it is in the background. Either the user clicks it from the bottom row of icons (after double click) or simply just clicks the app icon when it is already open.</p> <p>I dont want to use the WillAppear because then it will happen on every page view and not just this reload from background.</p> <p>Thanks Alex</p>
iphone
[8]
4,486,893
4,486,894
Textarea like the one here in stackoverflow
<p>I have a website that allows it's members to make posts. To make the post, they have to enter their text in a box similar to this one. However, I would like for them to be able to edit the content with html tags (but not abuse this privilege by changing the background color or something using pure html). In addition, I would also like for them to be able to have Bold, Italics and other buttons on the top so that when they select the text and click on one of those, the text gets modified respectively. In essence, I am looking for a text-entering box pretty much like stackoverflow. </p> <p>Is there an open-source solution? If not, could you guys lead me in the right direction as to how to do this?</p> <p>Thanks!</p>
javascript
[3]
2,477,701
2,477,702
Regular expression for checking any word of at least one letter
<p>Regular expression for checking any word of at least one letter</p> <p>examples:</p> <p>fish (right)<br> fish12 (right)<br> 123 (wrong)<br> T (right)<br> 12n(right) </p>
php
[2]
3,535,086
3,535,087
I need to show/hide elements with jquery
<p><a href="http://jsfiddle.net/MEKRM/" rel="nofollow">http://jsfiddle.net/MEKRM/</a> This is my fiddle</p> <p>I want to show / hide elements when i click Next / Previous. However, IDs will be generated dynamically(mysql echo). Any ideas how i can proceed? Thanks </p>
jquery
[5]
2,097,036
2,097,037
why java doesn't support pointers?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6924236/why-cant-we-use-pointers-in-java">Why can&#39;t we use pointers in Java?</a> </p> </blockquote> <p>I want to know are there any pointer concepts in java?</p> <p>I know that there is no explicit declaration of pointers but implcitly pointer concept is implemented.Why there is no pointer in java</p>
java
[1]
5,208,005
5,208,006
In Java, is 'new' a type of function?
<p>My apologies if this is a silly question. In Java, I just found out that the following code is legal:</p> <pre><code>KnockKnockServer newServer = new KnockKnockServer(); KnockKnockServer.receiver receive = newServer.new receiver(clientSocket); </code></pre> <p>FYI, receiver is a helper class with the following signature:</p> <pre><code>public class receiver extends Thread { /* code_inside */ } </code></pre> <p>I've never seen the <code>XYZ.new</code> notation before. How does that work? Is there a way to code that in a more conventional way?</p>
java
[1]
363,968
363,969
C# Function Similar to PHP Eval()
<p>I'm looking for a way to display code snippets stored in a database on a webpage with .NET and C# and I saw the exact function that I was looking for a while back, but I cannot remember what search terms I used or the name of the C# function that designed to do that specifically. </p> <p>Essentially, it's a C# version of PHP's Eval() function, so I can render code examples that I've collected over the years and see the end result as well as the actual source code. I'm sure that this has already been asked, but I couldn't find what I was looking for when I looked through the existing questions on here. </p> <p>This will be a password protected page on my site for my eyes only (theoretically, at least), so I'm not overly concerned about someone running malicious code. But I appreciate the kind warnings that some may feel obliged to offer before answering my question. Seriously, I do.</p> <p>I have a feeling that about 10 people will see this question and go, "well, obviously it's (Insert Function Name Here), you silly wabbit." So this is my way of admitting my shame of not knowing right here, up front. Especially when I just saw it like a <strong><em>week</em></strong> ago. </p> <p>Thanks in advance! Paul</p> <hr> <p>Addendum: I found the following code and it works like a charm on HTML, JS &amp; CSS. Since I've only been working with C# for a few months, I don't have a lot of C# code to render so it works quite well.</p> <pre><code>String EncodedString = rs["Code"].ToString(); StringWriter writer = new StringWriter(); Server.HtmlDecode(EncodedString, writer); String DecodedString = writer.ToString(); codeDecoded.Text = DecodedString; </code></pre>
c#
[0]
5,643,816
5,643,817
Breakpoints are not fired
<p>I am doing one application. I am developing my application in</p> <p>Xcode version 4.2(4c199) with iOS 5.0(9A334) and iPhone simulator(9A334).</p> <p>I have iPhone 4 with iOS 5(9A334) device also.</p> <p>My problem is when I am running the application in my device, breakpoints are not fired. I was suggested to fix the build configuration to debug. But it's not useful. So please tell me how to solve this one.</p>
iphone
[8]
2,584,077
2,584,078
JQuery coding problem
<p>I'm really new to Jquery and I know my code below is wrong. Can someone help me fix it so it works properly?</p> <p>Here is my code.</p> <pre><code>$(document).ready(function() { setTimeout(function() { $('a.delete').click(function(){ $("div.delete-banner").delay(6000).fadeOut(); // prevent default action return false; },5000); }); }); </code></pre>
jquery
[5]
4,810,604
4,810,605
Is there a quasi-standard set of attributes to annotate thread safety, immutability etc.?
<p>Except for a blog post here and there, describing the custom attributes someone created, but that do not seem to get any traction - like one describing how to <a href="http://blogs.msdn.com/b/kevinpilchbisson/archive/2007/11/20/enforcing-immutability-in-code.aspx">enforce immutability</a>, another one on <a href="http://larryparkerdotnet.wordpress.com/2009/08/25/documenting-thread-safety/">Documenting Thread Safety</a>, modeling the attributes after <a href="http://jcip.net/">JCIP annotations</a> - is there any standard emerging? Anything MS might be planning for the future?</p> <p>This is something that should be standard, if there's to be any chance of interoperability between libraries concurrency-wise. Both for documentation purposes, and also to feed static / dynamic test tools.</p> <p>If MS isn't doing anything in that direction, it could be done on CodePlex - but I couldn't find anything there, either.</p> <p>&lt;opinion&gt;Concurrency and thread safety are really hard in imperative and object-languages like C# and Java, we should try to tame it, until we hopefully switch to more appropriate languages.&lt;/opinion&gt;</p>
c#
[0]
5,063,467
5,063,468
background color not working as expected
<p>I'm trying to apply a custom RGB color to background, but it is not displaying the intended color, instead it always shows white:</p> <pre><code>UIColor *color = [UIColor colorWithRed:76 green:76 blue:76 alpha:1.0]; mainTable.backgroundColor = color; self.scrollView.backgroundColor = color; </code></pre> <p>however if I change one param to max eg Red:255 then I do see red color, any idea why I'm not seeing the color I'm looking for: 76 76 76 should have given some kind of dark grey color.</p> <p>Thx</p>
iphone
[8]
3,369,444
3,369,445
jQuery and getting back to default settings
<p>I have following piece of code:</p> <pre><code>$(document).ready(function(){ $("#cont").hide(); $("#slide").show(); $('#slide').click(function(){ $("#cont").slideToggle(); $("#slide").css("background-image", "url('img/slideup.png')"); }); }); </code></pre> <p>The code simply calls of the div to be slided down from nowhere after clicking another div and getting back. And on start, as in CSS I've set the icon to be arrow pointing down, and then after a click it changes to be pointing up, it will just stay like this. I have simply no idea, how to make it "toogle" depending on the div status. I've tried a lot of things and the script simply falled down, could any one give me some clue or the code that will make the bg image toggle? Something like proper div statement, as my didn't work...</p> <p>Thanks alot!</p>
jquery
[5]
2,485,709
2,485,710
How to play video from application bundle in iPhone
<p>I have a video in my iPhone application documents directory. I am want to play that using mpmovieplayercontroller. can some one post code to do this.</p> <p>Thanks, Naresh</p>
iphone
[8]
3,932,898
3,932,899
Get file(name) in the dictionary as key and all directories(if file is in) as the value
<p>I have directories and subdirectories, I want to get all the files in the dictionary and also directories into dictionary... Like this:</p> <p>{'randomfile': '.\map\randomdirectory' , '\map\map2' , \somerandom\map\map3'}</p> <p>Where key is file(name) and all the directories where this file exsist are in value.</p> <p>I have my project saved in specific map -> there are also those maps which I want to search for files and folders.., lets say I want to search just the maps where I have saved my project.. How do I do it, .. I know that I do it with recursion but it gets tricky. </p> <p>And yeah,.. I cant use <em>os.walk</em>.</p> <p>Thanks for potential answer.</p>
python
[7]
4,657,280
4,657,281
singleton and classic constructor
<p>This question is fairly fundamental.I gave a simple and straighfoward test on my cygwin:</p> <pre><code> class Example { public: Example(){ cout&lt;&lt;"dude..."&lt;&lt;endl; } ~Example(){ cout&lt;&lt;"see ya"&lt;&lt;endl; } public: static Example *GetInstance(){ if(m_instance==NULL){ m_instance = new Example(); cout&lt;&lt;"watch out bro"&lt;&lt;endl; } return m_instance; } public: void exp(){cout&lt;&lt;"greetings"&lt;&lt;endl;} private: static Example *m_instance; }; int main(){ Example a; return 0; } </code></pre> <p>Obviously,the output is:</p> <pre><code> dude... greetings see ya </code></pre> <p>Technically singleton and typical constructor are pretty much different stories in c++ programming since singleton puts constructor as private while typical way is opposite.In my recent internship experiences I have noticed that most coders implement APIs in this manner.</p> <p>I just wonder if that is the case or unnecessary when both class construction approaches exist in parallel.</p> <p><em><strong>UPDATE</em></strong></p> <p>Is constructor &amp; singleton existing in one program practically nonsense cuz singleton stuff in this scope would become useless codes like unhazardous trash?</p> <p><em><strong>SUMMARY</em></strong> This is quite a nonsense question... and what's more,thanks to all of you brilliants constructor and singleton design pattern are "mutually exclusive" and in terms of vulnerbility,it is the same story as global variables kill our debug time...</p>
c++
[6]
1,405,713
1,405,714
javascript button target_blank?
<p>I have a button that links to a website, but i want it to open in a new window. I know its probably a dumb question but i am very new to javascript. Below is my code. it works but opens in the same window. I have tried a few things and they just arent working</p> <pre><code>&lt;input type="button" value="eStore" onclick="location='www.google.com'" style="width: 88px; text-align: center;" /&gt; </code></pre> <p>is there a way to make it targt_blank to open in a new window? Please and thank you.</p>
javascript
[3]
2,559,344
2,559,345
Not able to invoke jquey Ajax method for fileupload input value
<p>I am trying to invoke the serverside method from the jquery. It is working fine in FireFox but not in IE8 and IE9.</p> <p>Please find the below code sample :</p> <pre><code> &lt;div&gt; &lt;asp:FileUpload ID="flAppIcon" runat="server" onchange="GetFileSize();"/&gt; &lt;asp:HiddenField ID="_hdnAppIcon" runat="server" Value="0" /&gt; &lt;/div&gt; &lt;script type="text/javascript" language="javascript"&gt; function GetFileSize() { var PageURL = '&lt;%= ResolveUrl("~/WebForm16.aspx") %&gt;' var test = ($('#&lt;%=flAppIcon.ClientID%&gt;').val()).toString(); $("#&lt;%=_hdnAppIcon.ClientID%&gt;").val(test); alert($("#&lt;%=_hdnAppIcon.ClientID%&gt;").val()); $.ajax({ type: "POST", url: PageURL + '/GetFileSizeDetails', data: '{file: "' + $("#&lt;%=_hdnAppIcon.ClientID%&gt;")[0].value + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (response) { alert(response.d); } }); } function OnSuccess(response) { alert(response.d); } &lt;/script&gt; [System.Web.Services.WebMethod] public static string GetFileSizeDetails(string file) { return "100"; } </code></pre> <p>Can anyone help me to know the root cause of this issue.</p> <p>Thanks &amp; Regards, Santosh Kumar Patro</p>
jquery
[5]
5,417,670
5,417,671
[Python]How to convert/record the output from subprocess into a file
<p>I am using subprocess module, which Popen class output some results like:</p> <p>063.245.209.093.00080-128.192.076.180.01039:HTTP/1.1 302 Found 063.245.209.093.00080-128.192.076.180.01040:HTTP/1.1 302 Found</p> <p>and here is the script I wrote:</p> <pre><code>import subprocess, shlex, fileinput,filecmp proc = subprocess.Popen('egrep \'^HTTP/\' *', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,) stdout_value = proc.communicate()[0] print 'results:' print stdout_value </code></pre> <p>My question is: how to convert/record the results from stdout into a file?</p> <p>I appreciate all your responses and helps!</p>
python
[7]
3,711,137
3,711,138
PHP - How to display print_r() live
<p>Is it possible to have print_r() displayed live. By live I mean while the script is executed. I do not want to wait the end of the script to have it displayed. Hope I am clear. Thank you in advance for your replies. Cheers. Marc</p>
php
[2]
5,927,315
5,927,316
Not getting the full text in output
<p>I have 2 text files , from which I match the second column of txt1 with first column of txt2 before <code>|</code> , well I just mention it below , than I output if they are same , along with its discription , everything is going fine , but I didn't get the <code>new line discription</code> in the output , it just showed its first line.</p> <p>Here is the content for <strong>txt1.txt</strong></p> <pre><code>E5 E7 Bat </code></pre> <p>Here is the content for <strong>txt2.txt</strong>:</p> <pre><code>?E7|E5 Addsadsadsadsadsadsdasd Sdsdfsdfdsfdsfdfdsfdsfd AasadsaddccxcvcsAAGCAGT </code></pre> <p>This is the code which i am using</p> <pre><code>with open('txt1.txt', 'rb') as file1: #file1_data = dict(line.split()[1] for line in file1 if line.strip()) file1_data = [line.split()[1] for line in file1 if line.strip()] #print file1_data with open('txt2.txt', 'rb') as file2, open('output.txt', 'wb') as outputfile: output = "" file2lines = file2.readlines() for i in range(len(file2lines)): line = file2lines[i] if line[0] == '?': row = line.strip().split('|') key = row[0][1:] if key in file1_data: output += line + "\t" + file2lines[i+1] outputfile.write(output) outputfile.close() </code></pre> <p><code>Getting output</code></p> <pre><code>?E7|E5 Addsadsadsadsadsadsdasd </code></pre> <p><code>Required output</code></p> <pre><code>?E7|E5 Addsadsadsadsadsadsdasd Sdsdfsdfdsfdsfdfdsfdsfd AasadsaddccxcvcsAAGCAGT </code></pre>
python
[7]
118,023
118,024
Making a char** with std::?
<p>I have an opengl function that requires a const char**. So essentially a vector of strings. I was wondering if this could be done using the C++ Standard Library without making a vector of <code>const char*</code> which would demand heap allocation.</p>
c++
[6]
5,183,858
5,183,859
Developing an ExpressionBuilder
<p>I am planning to build an expressionbuilder, in which the expressions will be supplied in string format. Is there a way to write a grammar or parse the expressions to validate them for their proper formation and then execute them.</p> <p>I would like to accomplish this in C# programming language. However, a common suggestion is welcome so that I can try out in C#</p> <p><a href="http://stackoverflow.com/q/9602074/541917">Here</a> is the Original question that has been unanswered since days</p>
c#
[0]
4,828,029
4,828,030
scrollbar plugin doesn't always work, is there a preload or something I can do?
<p>So here is the site: <a href="http://graysonearle.com/newtest/#prettyPhoto/6/" rel="nofollow">http://graysonearle.com/newtest/#prettyPhoto/6/</a> That takes you to a little window with a sidebar housing some images. I'm using lionbar, which is great, but it only works 50% of the time. This is not a typical web problem in my experience. What would cause a script to randomly not function? Is there a tag I can throw in there that makes sure a script is loaded properly? Just reload it until you see it work/not work. Also does it have something to do with the way I am invoking the plugin?</p> <pre><code>&lt;script&gt; $('#sidebar').lionbars(); &lt;/script&gt; </code></pre> <p>Just before the /body tag. Would it be more reliable if I did it another way?</p>
jquery
[5]
1,111,666
1,111,667
What is difference between jquery parse and jquery load ? Isn't load and parse same thing?
<p>Difference between parsing data and loading data?</p>
jquery
[5]
1,334,850
1,334,851
jQuery: extend method - how to save/keep/do not break the initial reference?
<p>Here is an example.</p> <p><a href="http://jsfiddle.net/R9V4p/" rel="nofollow">http://jsfiddle.net/R9V4p/</a></p> <p>Is it possible to make <code>s.c==60</code> at the end and do not overlap provided values with default ones? For example i have provided <code>testing</code> function with <code>s.clean=true</code> instead of <code>false</code>.</p> <p>Ofc i can write my own <code>function</code> for this. But maybe it would be nice to post a suggestion topic for this feature on jQuery forum, to be able to select which <code>object</code> to <code>return</code> in <code>extend method options</code>?</p>
jquery
[5]
4,047,109
4,047,110
Count Down Clock doesn't return when time ran out.
<p>I'm using code from this answer: <a href="http://stackoverflow.com/a/6501353/494901">http://stackoverflow.com/a/6501353/494901</a></p> <p>Basically when the timer ends, I want it to return true to my functions such that when it's over I can do stuff only after it's over. But the script is never returning, it ends, but it never returns back to the method it's called. </p> <pre><code>function countdown( elementName, minutes, seconds ) { var element, endTime, hours, mins, msLeft, time; function twoDigits( n ) { return (n &lt;= 9 ? "0" + n : n); } function updateTimer() { msLeft = endTime - (+new Date); if ( msLeft &lt; 1000 ) { return true; } else { time = new Date( msLeft ); hours = time.getUTCHours(); mins = time.getUTCMinutes(); element.innerHTML = (hours ? hours + ':' + twoDigits( mins ) : mins) + ':' + twoDigits( time.getUTCSeconds() ); setTimeout( updateTimer, time.getUTCMilliseconds() + 500 ); } } element = document.getElementById( elementName ); endTime = (+new Date) + 1000 * (60*minutes + seconds) + 500; return updateTimer(); } </code></pre>
javascript
[3]
5,825,579
5,825,580
Sorting HashMap
<p>I have an <code>ArrayList</code> of <code>HashMap</code>. Each <code>HashMap</code> contains many key-value-pairs. I want to sort the <code>ArrayList</code> by the value of the key <code>distance</code> in the <code>HashMap</code>.</p> <pre><code>ArrayList&lt;HashMap&lt;String, String&gt;&gt; arrayListHashMap = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); { HashMap hashMap = new HashMap&lt;String, Object&gt;(); hashMap.put("key", "A key"); hashMap.put("value", "B value"); hashMap.put("distance", 2536); arrayListHashMap.add(hashMap); } { HashMap hashMap = new HashMap&lt;String, String&gt;(); hashMap.put("key", "B key"); hashMap.put("value", "A value"); hashMap.put("distance", 2539); arrayListHashMap.add(hashMap); } </code></pre>
java
[1]
4,790,710
4,790,711
Launching application on iPhone for non-developer
<p>Say I have created an application, and I want my friend to have it. (I am not going to submit it to the App Store; I just want my friend to run it on her iPhone). </p> <p>I am not going to give the code, but is there any way I could create something like an <code>.exe</code> file, where she could launch it easily ?</p> <p>Note, I used the word <code>exe</code>, to mean that I am looking for a easy way for a non-developer to launch the application on his/her iPhone.</p>
iphone
[8]
3,413,672
3,413,673
"java.net.MalformedURLException: Protocol not found" read to html file
<p>I receviced an error: <code>java.net.MalformedURLException: Protocol not found</code></p> <p>I want to read an HTML file on the web</p> <pre><code>mainfest ::::: uses-permission android:name="android.permission.INTERNET" uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" import com.doviz.R.id; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { public String inputLine; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String myUri = ""; myUri = "www.tcmb.gov.tr/kurlar/today.html"; Toast.makeText( this, "step-1 " , Toast.LENGTH_LONG).show(); try{ Toast.makeText( this, "step -2" , Toast.LENGTH_LONG).show(); myUri = "www.tcmb.gov.tr/kurlar/today.html"; URL url = new URL(myUri); Toast.makeText( this, "step-3" , Toast.LENGTH_LONG).show(); final InputStream is =url.openStream(); Toast.makeText( this, "step -4" , Toast.LENGTH_LONG).show(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); Toast.makeText( this, "step -5 " , Toast.LENGTH_LONG).show(); String line; Toast.makeText( this, "step-6" , Toast.LENGTH_LONG).show(); while ((line=reader.readLine())!=null){ // page.add(line); } Toast.makeText( this, " step-7" , Toast.LENGTH_LONG).show(); } catch(Exception e){ //e.printStackTrace(); TextView tx =(TextView)findViewById(id.TextView1); tx.setText(myUri + " &gt;&gt;&gt; "+ e.getMessage()); Toast.makeText( this, "problem = " + e.getMessage() + " -- "+ e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); //System.exit(1); } Toast.makeText( this, "step -8" , Toast.LENGTH_LONG).show(); } </code></pre>
java
[1]
1,536,287
1,536,288
Jquery loading Problem
<p>I have a JSP Page like Below</p> <pre><code>&lt; html &gt; &lt; head &gt; &lt; head &gt; &lt; script type="text/javascript" src=../../jquery.js"&gt; &lt;/head&gt; &lt;script type="text/javascript"&gt; $().ready(function() { alert("Page Is Loading...."); // Do Some }); &lt;/script&gt; &lt; body &gt; &lt; span id="Refresh"&gt; // here I wrote a Some HTML code &lt; %@include file="/../../some.jsp" %&gt; &lt; /span&gt; &lt; /body &gt; &lt; / html &gt; </code></pre> <p>The some.jsp also contains the some HTML element that are handled By the some JQuery Function. But I did'nt include the jquery.js in some.jsp</p> <p>All functions are working fine when first time is page loading.But My Problem is, I try to refresh the span with an id value is Refresh, I am not able to get the Jquery Functionality in between the Span Tag.But, The some.jsp Jquery Function is work well after the Span is Refresh.</p> <p>How Can I solve the Problem..</p> <p>Is there any way to dynamically load the jquery.js</p>
jquery
[5]
381,499
381,500
how to parse a list to get a value
<p>I need some ideas on how to parse a list and print a specific value,Lets say I want to parse dependsontext and then just print the number "249452",please suggest ideas</p> <pre><code>INPUT:- dependsontext = [{u'isCurrentPatchSet': True, u'revision': u'ad0beef66e5890cde6f0961ed03d8bc7e3defc63', u'ref': u'refs/changes/52/249452/1', u'id': u'Iad0beef66e5890cde6f0961ed03d8bc7e3defc63', u'number': u'249452'}] OUTPUT:- 249452 </code></pre>
python
[7]
332,076
332,077
excluding certain files from a search within an array of names
<p>This function grabs all the jpegs from folders which match the page name and prints a background image. On the homepage it searches all the sub directories and chooses one at random. What i would like is to exclude (on the homepage only) certain files which match an array of names...can anyone help?</p> <pre><code>$isHome = $this-&gt;level() == 0; $path = 'public/images/bg/'; if (!$isHome) $path .= $this-&gt;slug; $homepagefile = URL_PUBLIC.'public/images/bg/'.$this-&gt;slug.'/main.jpg'; $bgimagearray = array(); $iterator = new DirectoryIterator($path); foreach ($iterator as $fileinfo) { if ($fileinfo-&gt;isFile() &amp;&amp; !preg_match('\.jpg$/', $fileinfo-&gt;getFilename()) &amp;&amp; !$isHome) { $bgimagearray[] = "'" . $fileinfo-&gt;getFilename() . "'"; } else if ($fileinfo-&gt;isDir() &amp;&amp; $isHome) { $iterator2 = new DirectoryIterator($path . $fileinfo-&gt;getFilename()); foreach ($iterator2 as $fileinfo2) { if ($fileinfo2-&gt;isFile() &amp;&amp; !preg_match('\.jpg$/', $fileinfo2-&gt;getFilename())) { $bgimagearray[] = "'" . $fileinfo-&gt;getFilename() . '/' . $fileinfo2-&gt;getFilename() . "'"; } } } } $bgimage = array_rand($bgimagearray); </code></pre>
php
[2]
70,323
70,324
Getting objects from an Array
<p>I may be doing this very badly but I'm new to this! if I have an array that contains objects like this</p> <pre><code>var company = [H7 = {companyName:"company1"},F4 = {companyName:"company2"}] </code></pre> <p>If I get a reference as a string say "F4" is there any way I can go</p> <pre><code>myCompName = company "F4" companyName and get the result "company2" </code></pre> <p>I was trying to use inArray like this</p> <pre><code>myStand = $.inArray("F4", companyObjects) myCompName = companyObjects[myStand].companyName </code></pre> <p>but this doesn't work and yet</p> <pre><code>myStand = $.inArray(F4, companyObjects) myCompName = companyObjects[myStand].companyName </code></pre> <p>does work. Do I have my array set up wrong or is there a way to do this? Thank you Alex</p>
jquery
[5]
822,767
822,768
Window.innerheight minus number in javascript
<p>I need a way in javascript to get the inner window height minus 90px.</p> <p>I know how to get the inner height from te window by using 'window.innerheight' but i dont know how to get the 90px of it.</p> <p>Can anybody help me?</p> <p>Thanks</p>
javascript
[3]
4,975,571
4,975,572
$.map object properties to a new array with similar names
<p>I have the following array of objects:</p> <pre><code>var blah = [ { foo: 1, bar: 2 }, { foo: 2, bar: 1 } ]; </code></pre> <p>I would like to change the property names from <code>foo</code> to <code>Foo</code> and <code>bar</code> to <code>Bar</code>. So I gave <code>jQuery.map</code> a try. However, I'm not sure what to return:</p> <pre><code>var newBlah = $.map(blah, function(i, v){ return /* ...? */; }); </code></pre> <p>Desired result:</p> <pre><code>console.log(newBlah); //[{ Foo: 1, Bar: 2... etc </code></pre>
jquery
[5]
2,646,544
2,646,545
Android application download on SD card
<p>Can Android application request to download on SD card in android 2.1 and lower. Also I want to know if the application can request some folders that contain videos to download on the sd card ? and how to do that ?</p> <p>Thanks in advance.</p>
android
[4]
1,810,924
1,810,925
"on" not binding to dynamically added elements
<p>My HTML</p> <pre><code>&lt;div&gt; &lt;span class="more-available" data-completeMessage="This is the complete message you see after clicking more"&gt;Hello&lt;/span&gt;​ &lt;/div&gt; </code></pre> <p>I add a anchor tag to the end dynamically and then want to attach a click handler to the anchor tag. So I do this</p> <pre><code>$(document).ready(function() { //Attach future proof click event to an anchor tag $('a.more').on('click', function() { var $parent = $(this).parent(); $parent.text($parent.data('completemessage')); }); //Add the anchor tag $('span.more-available').append($('&lt;a class="more"&gt;...more&lt;/a&gt;')); });;​ </code></pre> <p>This does not work. <strong>If i replace "on" by "live" it works</strong>. (but live is depreciated)</p> <p>I know I can do this</p> <pre><code>$(document).ready(function() { $('div').on('click','a.more', function() { var $parent = $(this).parent(); $parent.text($parent.data('completemessage')); }); $('span.more-available').append($('&lt;a class="more"&gt;...more&lt;/a&gt;')); });;​ </code></pre> <p>and it works, but my question is...</p> <p>Was I wrong in assuming that "on" provides all the functionality of live? Does "on" not bind to future elements? Is this correct behavior, or am I doing something wrong. </p> <p>fiddle: <a href="http://jsfiddle.net/arishlabroo/pRBke/5/" rel="nofollow">http://jsfiddle.net/arishlabroo/pRBke/5/</a></p>
jquery
[5]
950,206
950,207
How are POST and GET variables handled in Python?
<p>In PHP you can just use <code>$_POST</code> for POST and <code>$_GET</code> for GET (Query string) variables. What's the equivalent in Python?</p>
python
[7]
1,684,310
1,684,311
Python urllib.urlretrieve Exception Handling
<p>Download the file to half, or because of network problems cause an error or a timeout when downloading this to do with them?</p>
python
[7]
2,638,036
2,638,037
Access from one linked object to another
<p>I have a problem in my c++ project. I compile 2 <code>.cpp</code> files and linked them to a shared library <code>.so</code>. I want to use a method form one of them to another,but receive <code>undefined reference vtable *</code>. Those files have header files. Anyone can provide any hint?</p>
c++
[6]
2,577,332
2,577,333
ASP.NET Viewstate Optimization/Analyzing Tools
<p>Are there any tools for analyzing the controls in an ASP.NET page, to make sure they do not need to use the viewstate?</p> <p>We are trying to optimize a website written in C# asp.net 3.5 , and wanted to see if a tool would automatically analyze the project and make recommendations.</p>
asp.net
[9]
3,310,075
3,310,076
Android Dev - Text based game within an app
<p>I am looking to add a simple text based trivia type game within an app I already have built for a Business. We would like to get more user interaction in the app. Further, I would like to have high scores...etc display in the app. </p> <p>Creating a web serice and MySQL database would be simply enough to capture scores and query to top score. However, Is there soemthing like a free game API or something that would make this a lot easier than creating a game from scratch? I have seen some really complex game api's, but I am not trying to make an entire app. Just add a simple trivia game inside my app.</p> <p>Any suggestions? Comments?</p> <p>What would be the easiest way to go about this?</p>
android
[4]
1,832,170
1,832,171
Does findViewById have any side effects?
<p>I'm looking at some code that has a call to <code>findViewById</code> without assigning the result or doing anything with it, and want to make sure that's safe to remove. Is there ever a case where someone might call this without doing anything with the result?</p>
android
[4]
3,720,067
3,720,068
How to play audio file of format wav in android webview?
<p>This is my code: mp3 format file plays without any error, but wav format brings MediaPlayer error(1,-1):</p> <pre><code>try { MediaPlayer player = new MediaPlayer(); player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource("h*.wav"); player.prepare(); player.start();} catch (Exception e) { // TODO: handle exception } </code></pre>
android
[4]
2,548,831
2,548,832
How can I run cygwin from Java?
<p>I want to start nutch from Java. How can I start cygwin from a Java program?</p>
java
[1]
5,928,189
5,928,190
Outgoing call duration when it received
<p>Can anybody tell me that how to get outgoing call duration when it received from other side in android.</p> <p>Thanks in advance ..</p>
android
[4]
879,843
879,844
add commas using String.Format for number and
<p>Using String.Format how can i ensure all numbers have commas after every 3 digits eg 23000 = "23,000" and that 0 returns "0".</p> <p>String.Format("{0:n}", 0); //gives 0.00 which i dont want. I dont want any decimal places, all numbers will be integers.</p>
c#
[0]
5,814,384
5,814,385
Running the app in AVD without opening the Eclipse
<p>I hav created Calcy app in Eclipse. It is running in Emulator properly. </p> <p>But i want to run it using AVD manager .</p> <p>the command for installing the app is "adb install Calcy.apk"</p> <p>but it is giving the message that </p> <pre><code>C:\Android\android-sdk\platform-tools&gt;adb install Calcy.apk 252 KB/s (39547 bytes in 0.153s) pkg: /data/local/tmp/Calcy.apk Failure [INSTALL_FAILED_ALREADY_EXISTS] </code></pre> <p>How to resolve this...</p>
android
[4]
4,811,004
4,811,005
Facing problem while importing project into the workspace
<p>I had the same issue before and tried many ways to slove it. Now it is working fine with importing project. Now am facing some related issue that is, there are some apiDemos in the plugin with my friend. I have copied it and tried to import it into the workspace but here is the same problem again showing that it has some or the other error in every line.</p> <p>And this is the screen shot of how the error look in every line. Can anyone help in this case.</p> <p><img src="http://i.stack.imgur.com/uJWD1.png" alt="Screenshot"></p>
android
[4]
5,876,545
5,876,546
java Arrays.binarySearch problem
<pre><code>String[] sortedArray = new String[]{"Quality", "Name", "Testing", "Package"}; // Search for the word "cat" int index = Arrays.binarySearch(sortedArray, "Quality"); </code></pre> <p>i always get -3. problem is in "Name". Why i can not have "Name" in my array? Any idea?</p>
java
[1]
2,180,871
2,180,872
How do i add words to the suggestions on top of the soft keyboard
<p>Is there any way to add words to the suggestions in the soft keyboard? For a specific Edittext field i would like to add a list of names to the suggestions that pops up on top of the soft keyboard in android 2.0.</p> <p>Does anyone know if this is possible?</p>
android
[4]
887,226
887,227
put comma after values but not for last one
<p>I am just a beginner in php. I used the following code to display the user names fetched from the database.</p> <pre><code>$select_tl = "SELECT `varTeamleader` FROM `tbl_team` WHERE `intTeamid` = '" . $id . "'"; $select_tl_res = mysql_query($select_tl); $select_tl_num = mysql_num_rows($select_tl_res); if ($select_tl_num &gt; 0) { $fetch_tl = mysql_fetch_array($select_tl_res); $tl = $fetch_tl['varTeamleader']; $sep_tl = explode(",", $tl); foreach ($sep_tl as $key =&gt; $value) { $sel_tlname = "SELECT * FROM `tbl_user` WHERE `intUserid` = '" . $value . "'"; $sel_tlname_res = mysql_query($sel_tlname); $sel_tlname_num = mysql_num_rows($sel_tlname_res); if ($sel_tlname_num &gt; 0) { $fetch_username = mysql_fetch_array($sel_tlname_res); $user_name = $fetch_username['varName']; echo $user_name . ", "; } } } </code></pre> <p>I need to echo the user_name with comma after every value but not after last one. How can i do that?</p>
php
[2]
5,513,191
5,513,192
What settings in php.ini should I adjust for php to accept data from javascript?
<p>I just installed LAMP. Everything seems to be working fine except when I send data from js to php via ajax, php does not receive the data sent. I suspect this has to do with a setting in php.ini but I don't know which to change. My js ajax function looks like this: </p> <p>function ajax (url, data_to_be_sent, callback_func) { </p> <pre><code>if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=callback_func; xmlhttp.open("POST",url,true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(data_to_be_sent); </code></pre> <p>}</p>
php
[2]
4,875,648
4,875,649
Javascript Number Formatting
<p>Certainly a stupid question, please forgive me. My customer wants decimal numbers to display with five digits. For example: 100.34 or 37.459. I was accomplishing this with <code>val.toPrecision (5);</code>; however, when my numbers get really small, I stop getting what I want. For example, if my number is 0.000347, it displays 0.00034700. Now, I understand why it's doing this, but what I don't know is how to get it to display 0.0003. Any thoughts?</p>
javascript
[3]
49,561
49,562
How to stop truncation in JavaScript number division
<p>In Java we use the double or float data type to get results in decimal points. However how do i do this in Javascript? The current calculation i am doing is:</p> <pre><code>a1 += (a1 * results[0][index]) / 100; </code></pre> <p>EDIT, My Apologises, There was a mistake on my side from using the wrong variables. </p>
javascript
[3]
476,112
476,113
Android Maps api release key not working
<p>I looked over all the stackoverflow questions related to this, but nothing worked. Sorry if this is asked already.</p> <p>I have the Google maps api integrated into my app, and everything works fine in development. I got a debug api key based on the debug.keystore file and it works just fine.</p> <p>Then I went ahead and got a release api key based on the keystore file that I use to sign the app. However, all I see are grey tiles - the maps don't show up. I have the <b>uses-library</b> tag inside of my <b>application tag</b> in the manifest. I have the permission for the internet in the manifest, as well as <b>android:debuggable="false"</b> (though this doesn't seem to change anything).</p> <p>What else could I be missing?</p>
android
[4]
3,379,220
3,379,221
jQuery selecting row inserted using
<p>I'm successfully inserting a row into my table via</p> <pre><code>$('#fbs tr:last').after('&lt;tr&gt;&lt;td&gt;&lt;input id="vm" type="checkbox" /&gt;&lt;/td&gt;&lt;/tr&gt;'); </code></pre> <p>However after that I'm trying to select $('#vm') and not receiving anything. Everything looks right but jQuery isn't finding the element.</p>
jquery
[5]
498,271
498,272
circular image flow using javascript
<p>is there any free javascript library like <a href="http://finnrudolph.de/ImageFlow/Examples#Enable_circular_mode" rel="nofollow">http://finnrudolph.de/ImageFlow/Examples#Enable_circular_mode</a> for GPL License? i like the ciruclar mode image rotate, but they uses Creative Commons Attribution-Noncommercial 3.0 Unported License </p>
javascript
[3]
6,009,737
6,009,738
Jquery Question about toggling a layer
<p>Website <a href="http://bit.ly/euXvuJ" rel="nofollow">http://bit.ly/euXvuJ</a></p> <p>I'm doing the following to toggle the mouse. But when your mouse travels about half way down on the #sideshoppingcart div, the whole div goes away.</p> <pre><code>$(document).ready(function() { $("li#menu-item-170").hover(function() { wwd_shopping_cart_collapser(); },function() { wwd_shopping_cart_collapser(); }); } function wwd_shopping_cart_collapser() { switch($("#sideshoppingcart").css("display")) { case 'none': $("#sideshoppingcart").slideToggle("fast",function(){ $.post( 'index.php', "ajax=true&amp;set_slider=true&amp;state=1", function(returned_data) { }); }); break; default: $("#sideshoppingcart").slideToggle("fast",function(){ $.post( 'index.php', "ajax=true&amp;set_slider=true&amp;state=0", function(returned_data) { }); }); break; } return false; } </code></pre>
jquery
[5]
4,909,569
4,909,570
Android 4.0 x86 full can install on all PC
<p>I want a download link for Android 4 x86 full install on pc - support all device - support numpad - support all resolution and any feature for working perfect and download size not important for me</p>
android
[4]
4,778,225
4,778,226
PHP & Implementing .Netish Properties
<p>I've decided to have some fun, and implement .Net Properties in PHP. </p> <p>My current design centers around something like:</p> <pre><code>$var; method Var($value = null) { if($value == null) { return $var; } else { $var = $value; } } </code></pre> <p>Obviously this runs into a bit of an issue if someone is trying to set the property (and associated variable) to null, so I am thinking of creating a throwaway class that would never be used. Thoughts, comments?</p>
php
[2]
1,074,858
1,074,859
$_SERVER VARS are empty
<p>I'm using PHP 5.3.12 on a Windows system , i am trying to use some of the <code>$_SERVER</code> variables, but the following <code>$_SERVER</code> variables are empty for me</p> <pre><code>$_SERVER['SERVER_NAME'] $_SERVER['SERVER_PORT'] $_SERVER['REQUEST_URI'] </code></pre> <p>i have set <code>ServerName</code> in the config file, but <code>SERVER_NAME</code> and <code>SERVER_PORT</code> are both empty and i have no idea why that is, how can i set those variables and prevent them from being empty?</p>
php
[2]
1,459,703
1,459,704
PhP Undefined Variables
<p>Okay, so I'm trying to teach myself php off of other peoples code; Some of the code is probably outdated, but it works for going through the essentials until I have time to go to school. My issue is an Undefined Variable error. All I can find on the subject at this time is how to hide the error, but I'm not looking to hide; if it's hidden that doesn't mean the issue has been resolved it means that you have found a way to ignore it which I see as a big no no. It's giving you the error for a reason.</p> <p>The line that I'm getting the error at.</p> <pre><code>&lt;form method=post &lt;?php echo "action=\"registration.php?f=".(!$flag)."&amp;amp;s=".$sort."\""; ?&gt; enctype="multipart/form-data" &gt; </code></pre> <p>Then this is the issue on the page.</p> <pre><code>Notice: Undefined variable: flag in C:\wamp\www\info\registration.php on line 236 </code></pre> <p>There's others that are identical, but I feel if I can learn how to fix this one here it will also be the solution for the others. If you need any extra information please let me know. Thanks in advance. Sorry for the being so finiky; I just don't want to ignore issues that are trying to broadcast right in my face.</p>
php
[2]
474,445
474,446
How to invalidate 3D list view with fresh data during rotation?
<p>I have downloaded 3D list View code.And I changed it to my requirement. Now the problem is that, I displayed data on each row of Listview, but the data do not invalidate continously, instead it invalidate during scrolling.</p> <p>Please tell how can i invalidate 3D ListView during rotation/stop with streaming data ?</p>
android
[4]
5,411,888
5,411,889
when to use Function in javascript?
<p>I have been writing javascript for one or two months , I never used Function keyword , like Function.method(); when I define function , I simply define it as :</p> <pre><code>function fooBar () {}; </code></pre> <p>Can you give me an example when using Function is more convenient ?</p>
javascript
[3]
1,091,820
1,091,821
Do I need two new List<ParentDetail>() constructors?
<p>I have the following class called Parent. It contains a list of ParentDetail classes:</p> <pre><code>public class Parent { public Parent() { this._parentDetails = new List&lt;ParentDetail&gt;(); } public IList&lt;ParentDetail&gt; ParentDetails { get { return _parentDetails; } } private List&lt;ParentDetail&gt; _parentDetails = new List&lt;ParentDetail&gt;(); } public class ParentDetail { public string FileName { get; set; } } </code></pre> <p>The class seems to work but I don't understand why "= new List();" appears twice. Can someone explain in a couple of lines what is happening?</p>
c#
[0]
1,479,023
1,479,024
regular expression to remove li in php
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3308530/php-strip-a-specific-tag-from-html-string">PHP: Strip a specific tag from HTML string?</a> </p> </blockquote> <p>Hi All,</p> <p>I want to remove li from a string. I'm using following regular expression, but it is not working. what can be the issue ?</p> <pre><code>$str = '&lt;div id="navigation" &gt;&lt;div class="menuwrap"&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="#"&gt;Home &lt;/a&gt;&lt;/li&gt;&lt;li class="select"&gt;&lt;a href="#"&gt;About Us&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#"&gt;Services &lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#"&gt;Clients&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#"&gt;Contact Us&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;/div&gt;&lt;div class="submenu"&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="#"&gt;Submenu1&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#"&gt;Submenu2&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="#"&gt;Submenu3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Submenu4&lt;/a&gt; &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;'; $replacelink = 'Contact Us'; echo $str = preg_replace('/&lt;li(.*?)&gt;\s*\b&lt;a(.*?)&gt;\s*\b'.$replacelink.'\b\s*&lt;\/a&gt; \b\s*&lt;\/li&gt;/i', '', $str); </code></pre>
php
[2]
5,548,910
5,548,911
How to create this selector
<p>I want create a selector like this on clicking on a div it must show other options like in image and after selecting another option it must show the selected value in div.</p> <p><img src="http://i.stack.imgur.com/bgDHs.jpg" alt="enter image description here"></p> <p>this image is from <a href="http://translate.google.com/#sk/en/" rel="nofollow">Google translator</a></p>
jquery
[5]
1,567,410
1,567,411
How to determine an Android View's size in pixels?
<p>Is there a direct programmatic way to get a fill_parent View's pixel height and width? For instance a view in a grid layout in a tab. Or do I have to get the window size and subtract the static sizes of the views around it?</p>
android
[4]
3,983,478
3,983,479
How to set Countdown Screen As Home Screen Wallpaper in Android.?
<p>In My application, I make one countdown Screen for remaining days (like Countdown the days till Christmas) and now i want to make that screen as a Home Screen Wallpaper.</p> <p>like this : </p> <p><img src="http://i.stack.imgur.com/Wya3b.png" alt="enter image description here"> </p>
android
[4]
394,848
394,849
Service runs then dies
<p>I'm running Win 7 Pro 64-bit. I wrote a service in C# using the .NET 4 framework. It installs properly and starts to run. I know that it runs because it writes some output to a log file. However, after a few seconds it dies. When I use Visual Studio 2010 Pro to run this same code not as a service it never dies. So, my obvious question is regarding the appropriate approach for debugging this since I can't figure out why it should die as a service but not die as a non-service. I've put writes to the log file in several places in the code but it seems to die in a different place every time. The application has 3 threads. Any suggestions are welcomed.</p>
c#
[0]
1,565,607
1,565,608
Is there any drawback of not closing the file after reading it?
<p>I often do not close the file after reading it</p> <pre><code>for line in open(FileName): # do something </code></pre> <p>I also reopen the file again in the same program.</p> <pre><code>for line in open(FileName): # do something else </code></pre> <p>My question is whether there are any drawbacks in this approach? I have seen posts that claim that file should be open with <code>with</code></p> <pre><code>with open(FileName) as fp: </code></pre> <p>But what is the advantage of this approach?</p>
python
[7]
3,104,457
3,104,458
Why while loop stop executing on 1 loop, when there is inside another loop?
<p>Example:</p> <pre><code>&lt;?php $text= "Taigi dabar skaiciuojam zodzius"; $zodziai = str_word_count($text, 1); $skaicius = str_word_count($text, 0); $n = 0; $i = 0; while ($i++ &lt; 5) { echo $zodziai[$n++]; echo ' '; $i = 1; while ($i &lt;= 10) { echo $i++; } } ?&gt; </code></pre> <p>Outputs: Taigi 12345678910 </p> <p>Without while outputs: Taigi dabar skaiciuojam zodzius </p>
php
[2]
1,440,562
1,440,563
Check format of URL
<p>I need a Java code which accepts an URL like <code>http://www.example.com</code> and displays whether the format of URL is correct or not.</p>
java
[1]
4,503,999
4,504,000
Need help with foreach and XML
<p>I have the following output (via link) which displays the var_dump of some XML im generating:</p> <p><a href="http://bit.ly/aoA3qY" rel="nofollow">http://bit.ly/aoA3qY</a></p> <p>At the very bottom of the page you will see some output, generated by this code:</p> <pre><code>foreach ($xml-&gt;feed as $entry) { $title = $entry-&gt;title; $title2 = $entry-&gt;entry-&gt;title; } echo $title; echo $title2; </code></pre> <p>For some reason $title2 only outputs once, where there are multiple entries?</p> <p>Im using <code>$xml = simplexml_load_string($data);</code> to create the xml.</p>
php
[2]
1,467,251
1,467,252
I want to learn Knockout js framework plz give some suggesstion
<p>I want to learn knockout js. which site is more helpful for learn things. Give some link. If you know familiar plz give overview of this framework.</p>
javascript
[3]
4,514,814
4,514,815
What is the idea behind creating levels for iPhone games?
<p>I want to know how different levels are made in iPhone games like "AngryBirds". Do they have some large array which has locations where to put the brick or something? How do those kinds of levels are developed? </p>
iphone
[8]
4,513,950
4,513,951
Trying to call a function in javascript
<p>This is my code all I need to do is call a function which will write the contents to a dynamic div</p> <pre> &lt;script language='javascript' type='text/javascript'&gt; function getComments(id) { alert(id); } var resultSet=""; function CreateDiv() { resultSet+="&lt;br/&gt;&lt;div id='"+rows.data[i].id+"'>&lt;/div&gt;&lt;script language='javascript' type='text/javascript'> getComments("+rows.data[i].id+"); &lt;\/script>"; } window.onload=CreateDiv; &lt;/script&gt; </pre> <p>The function getComments is not being called at all</p> <p>What's that I am missing here</p>
javascript
[3]
2,149,609
2,149,610
Best way to get data from "clean" and "dirty" URLs
<p>I'm writing an application that gets data from URLs, but I want to make it an option whether or not the user uses "clean" urls (ex: <a href="http://example.com/hello/world" rel="nofollow">http://example.com/hello/world</a>) or "dirty" urls (ex: <a href="http://example.com/?action=hello&amp;sub=world" rel="nofollow">http://example.com/?action=hello&amp;sub=world</a>).</p> <p>What would be the best way to get variables form both URL schemes?</p>
php
[2]
4,471,351
4,471,352
Enabling/Disabling the menu item from another thread
<p>I am trying to change a menu item from another thread. I am able to use the InvokeRequired/Invoke on other controls, but since the menu item is not a Control, I am having difficulty in achieving the same functionality.</p> <p>For other controls, I am doing this:</p> <pre><code>private delegate void SetControlEnableHandler(object sender, Boolean bValue); private void SetControlEnabled(object sender, Boolean bValue) { Control control = (Control)sender; if (control.InvokeRequired) control.Invoke( new SetControlEnableHandler(SetControlEnabled), new object[] { sender, bValue } ); else control.Enabled = bValue; } </code></pre> <p>From the worker thread I simple call:</p> <pre><code>this.SetControlEnabled(btnPress, true); </code></pre> <p>and it does the job.</p> <p>Can anyone help me with the menu item here?</p> <p>Thank You, -Bhaskar</p>
c#
[0]
5,454,390
5,454,391
BCL easypdf missing jars in trial
<p>I am trying to run <a href="http://www.pdfonline.com/easypdf/sdk/programming-pdf/java/raster-pdf-to-image.htm" rel="nofollow">this program</a> given on easypdf site. i downloaded their trial version. installed it. but jars are missing i guess. can u plz tell me how to execute this program? thanx</p>
java
[1]
3,432,984
3,432,985
Test iPhone App on physical iPhone rather than simulator
<p>I've just made a basic Hello World app for the iPhone. Compiling and running works fine for iPhone Simulator. But now I'd like to put it on my real physical iPhone, to test it. Is there any way to do this, or do I have to pay $100, put it in the app store and download it (with the chance Apple doesn't like it and just deletes it (what happened to Google Latitude too))?</p> <p>Thanks in advance.</p> <p>Nope, I'll not jailbreak it.</p>
iphone
[8]
480,736
480,737
comparing object identifier with string
<p>is there any possibilities to compare object identifier with string idiom without adding any member e.g. string variable variable to the class? </p> <pre><code>struct ObjectExample {}ObEX; string St; cin &gt;&gt; St &gt;&gt; endl; // you enter ObEX // What I need to reach is this comparing if(obEX == St) {......} </code></pre> <p>As you see both object have different data type.. </p> <h1>Edit</h1> <p>If the comparison not possible. I would re-formalize my question:</p> <p>is there any technique to copy the object identifier to a string object.</p> <p>The whole issue is if you can NOt modify or adding the class definition but you can only create instances of it and you want to compare a string name with the object identifier!!! </p>
c++
[6]
4,780,367
4,780,368
Android Proximity Alerts
<p>Does android Proximity Alerts works even if the phone is totally sleep? </p>
android
[4]
2,908,220
2,908,221
Restrict user from switching to video mode
<p>I have requirement in my application in which when he choose take photo option,he should only be allowed to capture photo and cannot switch to video mode. And same for choosing the photo from photolibrary he should only be allowed to choose from available photos, he should not be allowed to choose video.How can I restrict user from doing this? What mode should be set in source type to do it.</p>
iphone
[8]
5,936,958
5,936,959
Javascript : is given function empty?
<p>Let's have a function call</p> <pre><code>function doSomethingAndInvokeCallback(callback){ // do something callback(); } </code></pre> <p>I can check if given argument is function <code>if(typeof callback == 'function')</code> </p> <p>How can I discover, if given callback function is function and isn't empty?</p> <p>like</p> <pre><code>doSomethingAndInvokeCallback(function(){ //nothing here }) </code></pre>
javascript
[3]
845,949
845,950
Help refactoring this C# function
<p>I have written functions that look like this:</p> <pre><code>bool IsDry(bool isRaining, bool isWithUmbrella) { if (isRaining) { if (isWithUmbrella) return true; else return false; } else return true; } </code></pre> <p>I need to check, if it's raining, then the person needs to carry an umbrella in order to keep dry (don't laugh, this is just an example, our actual business rules are more serious than this).</p> <p>How can I refactor this, because right now it looks clumsy.</p> <p>Thanks for the help, guys! =)</p>
c#
[0]
4,252,171
4,252,172
Bounded stack of integers C++
<p>Hey, just doing some revision for upcoming exams and i'm looking at a past paper.</p> <p>I'm asked to write the class implementation for this:</p> <pre><code>class Stack { public: Stack(int n=1); int pop(); void push(int); int isEmpty(); int isFull(); ˜Stack(); private: int top; // index of element at top of stack int size; // maximum number of elements storable int * cell; // pointer to elements stored in stack }; </code></pre> <p>I understand the theory of stacks and i know what the methods have to do, the bit that confuses me is where are the integers that are passed to the stack stored, and how is this done? Maybe im missing something realy simple but im stumped?</p>
c++
[6]
2,717,933
2,717,934
How do I check if System.Data.SqlClient.SqlTransaction has an active transaction?
<p>I have a method which I use to execute all my SQL queries (inserts, updates, delete) and I want to put a check in to make sure the change is within a transaction before the code is executed but I can't find a property against the <code>SqlTransaction</code> to check for.</p> <p>How should I proceed?</p> <p>Note: I am using <code>FDBConnection.BeginTransaction("MY_TRANS");</code> to begin the transaction and standard rollback and commnit methods</p> <p>Using .NET 4.0 with VS 2010 Web Dev Express.</p>
c#
[0]
1,135,983
1,135,984
get a cookie value from document.open(ed adress)
<p>I want to use JavaScript's <code>document.open(url)</code> to open a website and run JavaScript on it to view a "specified cookie"</p> <p>For example:</p> <pre><code>var newone= document.open(mysite) newone.onload = alert(document.cookie.specified_one)" </code></pre>
javascript
[3]
2,045,832
2,045,833
Store data in executable
<p>I'm just curious about this for a long time.</p> <p>Is it possible for an application to store some changeable data (like configurations and options) inside its own executable? </p> <p>for example: is it possible to design a single executable which if a user ran, set some configurations, copied it into another PC, then the application runs by its last set config in new PC.</p> <p>is this possible by any means?</p> <p><strong>Update:</strong> it seems that it's possible. then How?</p>
c++
[6]
2,228,290
2,228,291
android draw rect
<p>is there any way to move the Rect drawn by touching</p> <p>it should keep on moving when touch action_move..... any one could help with a solution?</p> <p>thanks in advance</p>
android
[4]
2,943,118
2,943,119
Trigger a function (code) at particular time
<p>I have created a small app, but I want it to execute automatically at a particular time. The time must be entered by the user.</p> <p>For example : If my activity is, to start a particular game and I enter 5:30pm as the time, it should run that game at 5:30pm automatically, even if I close the application after I entered time.</p>
android
[4]
4,106,086
4,106,087
What are the proper dimensions for a background image in an android app?
<p>I would like to create a background image for my app in Photoshop. I understand that I will need to create three different files at the appropriate dpi for ldpi, mdpi and hdpi. But what are the appropriate dimensions and resolutions for each?</p>
android
[4]
3,176,440
3,176,441
ASP.net XMLSiteMap Rol Not Logged In
<p>I am using a XMLSitemap to show my menu. In my menu I have a node "Log in". But I only want to show this to the visitors who are not logged in. (Not to everyone like what the "*" does). Is there a rolename for those visitors or something like that?</p> <p>This is my XML SiteMap</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" &gt; &lt;siteMapNode title="MovieMonstr" description="Films huren" roles="*"&gt; &lt;siteMapNode url="Home" title="Home" description="Home Page" roles="*" /&gt; &lt;siteMapNode url="ShoppingCart" title="Shopping Cart" description="Het winkelmandje" roles="*" /&gt; &lt;siteMapNode url="Login" title="Log in" description="Inloggen" roles="*" /&gt; &lt;siteMapNode url="MyProfile" title="My Profile" description="Miijn profiel bekijken" roles="ADMIN,USER" /&gt; &lt;siteMapNode url="Admin" title="Admin" description="Administrator zone" roles="ADMIN" &gt; &lt;siteMapNode url="Admin/AddMovie" title="Add Movie" description="Een film toevoegen" roles="ADMIN" /&gt; &lt;siteMapNode url="Admin/AddEvent" title="Add Event" description="Event toevoegen" roles="ADMIN" /&gt; &lt;/siteMapNode&gt; &lt;/siteMapNode&gt; &lt;/siteMap&gt; </code></pre> <p>Thanks a lot, Vincent</p>
asp.net
[9]