Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,171,219
1,171,220
Pollard's Rho Heuristic in Python
<p>This a homegrown function with some problems. My guess is that I've fudged somewhere in the loop. It doesn't give consistent answers - I get that that's what "heuristic" means, but I think this should no problem for, say, n==57.</p> <pre><code>def Rho_Heuristic(n): import random cum_d = 1 x = random.randint(0, n-1) y = x k = 2 i = 1 while not(cum_d == n): i = i + 1 x = (x*x-1)%n d = GCD(y-x, n) if (not(d == 1) and not(d == n)): print d cum_d = (d * cum_d) if i==k: y = x k = 2*k; </code></pre>
python
[7]
4,088,941
4,088,942
Can i code C++ for non-os x based frameworks and such on Xcode?
<p>I have just begun learning C++ through a flemmish government funded course. I was given 'thinking in c++' by Bruce Eckel as my educative material.</p> <p>Besides learning c++ i'm also picking up objective-c on my own as I go, my long-tearm goal is to be a independent osx/ios dev, but i have to learn an succeed in c++ for the funding to continue. Betting on two horses and such.. you're getting the picture, i'm sure. </p> <p>So now it begins. I have to choose an IDE. Xcode seems only to serve the os x oriented C++ development as far as I understand... Am i right? </p> <p>I would consider other IDE's like eclipse or even go linux and what not, but in the end, long term, I'm going to be coding in Xcode because of my independent ambitions... So it would be really convenient if I could get started with Xcode right away, nice and comfy, so i don't have to divide my 'learning curve' an lose valuable time</p> <p>So the question nice and short; is it possible to code C++ for non-osx based sources and frameworks and what not. More importantly, can i learn everything in the book by Eckel if i stick to Xcode?</p> <p>I'm a new kid on the block. Forgive stupid questions and wrong usage of dev lingo. </p> <p>much obliged.</p>
c++
[6]
1,408,833
1,408,834
How to identify checkbox element nested within multiple span element using jquery
<p>I want to identify the checkbox element which has been nested within multiple span element, below is my code snippet</p> <pre><code>&lt;asp:Label ID="Label13" runat="server" AssociatedControlID="chk1" CssClass="required" Style="vertical-align : baseline ; margin:0px;" &gt; &lt;span style="background : none transparent scroll repeat 0% 0% ; cursor: pointer ; display : inline-block ; margin-right : 8px ; text-align : right ; vertical-align : top ; width : 160px"&gt; HI HOW ARE YOU...&lt;/span&gt; &lt;span style="cursor : pointer ; font : 99% sans-serif ; height : 27px ; margin : 0px ; padding-bottom : 0px ; padding-left : 8px ; padding-right : 10px ; padding-top : 7px ; text-align : left ; vertical-align : top ; width : 257px"&gt; &lt;span style="display:inline-block;width:38%;text-align : left; margin : -20px;padding-left : 10px ; padding-right:10px"&gt; &lt;asp:CheckBox runat="server" ID="chk1" Text="Yes" Checked="false" /&gt;&lt;/span&gt; &lt;span style="display:inline-block;width:38%;"&gt; &lt;asp:CheckBox runat="server" Checked="false" ID="chk2" Text="No" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/asp:Label&gt; </code></pre> <p>So, My form will be sumbitted using jquery and it will find all the elements that i have mentioned below.</p> <pre><code>$this.find('.required :input, .required select').each(function () { var $input = $(this), fieldValue = $.trim($input.val()), labelText = $input.closest('label').text().replace(o.removeLabelChar, ''), errorMsg = ''; </code></pre> <p>So, this find method method will looks for all the input elements. But unfortunately i am not able to find my checkbox. Kindly proivde some solutions.</p>
jquery
[5]
2,780,216
2,780,217
How do I read and write details from a file in C#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/220097/read-write-extended-file-properties-c">Read/Write &#39;Extended&#39; file properties (C#)</a> </p> </blockquote> <p>I'm doing a list of files from a folder on a webpage and getting the files using DirectoryInfo and then using FileInfo. FileInfo has pretty much all info I need, but I'm missing one thing. It's the Author from the details "tab". I need to read and write the author so I can present that on the webpage. It doesn't really have to be the author in the details, just adding metadata or what not... </p> <p>Anyone that can assist me with this issue?</p>
c#
[0]
2,472,705
2,472,706
jquery- how should I extract value of href
<pre><code>ol class="result-list"&gt; &lt;li class="result item_1 odd first"&gt; &lt;h2&gt; &lt;div class="number-description"&gt; &lt;div class="search-field c_patent_id"&gt; &lt;p class="value"&gt; &lt;a href="?mq=*%3A*&amp;fa=c_application_type_name,owners,c_acquired_from,c_reference_number,c_status_type_name,c_territory_name,c_patent_type_name,url,inventors,c_case_mgr_name&amp;f=c_patent_id%5B%2283779616%22%5D"&gt;83779616&lt;/a&gt; &lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="search-field capsule c_patent_type_name"&gt; &lt;a class="poplight" rel="popup2" href="#"&gt; &lt;/h2&gt; &lt;div class="item-details"&gt; &lt;/li&gt; &lt;li class="result item_2 even"&gt; &lt;li class="result item_3 odd"&gt; &lt;li class="result item_4 even"&gt; &lt;li class="result item_5 odd"&gt; &lt;li class="result item_6 even"&gt; &lt;li class="result item_7 odd"&gt; &lt;li class="result item_8 even"&gt; &lt;li class="result item_9 odd"&gt; &lt;li class="result item_10 even last"&gt; &lt;/ol&gt; </code></pre> <p>This is the complete code and in this, every li tag has "a href tag" in the same way as previous li one(also same structure is follow- but I have expanded only first li tag-for reference) so now how can I extract the value of "a href, "</p>
jquery
[5]
5,723,249
5,723,250
slidesjs plugin displaying
<p>guys i have put a "slidesjs" plugin to my page but it doesnt display properly. im kinda new to jquery. here's my code</p> <pre><code>&lt;style type="text/css" media="screen"&gt; .slides_container { width:570px; height:270px; } .slides_container div { width:570px; height:270px; display:block; } &lt;/style&gt; &lt;script src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt; &lt;script src="Slides/examples/Product/js/slides.min.jquery.js"&gt;&lt;/script&gt; &lt;script&gt; $(function(){ $("#slides").slides(); }); &lt;/script&gt; &lt;div id="slides"&gt; &lt;div class="slides_container"&gt; &lt;div&gt; &lt;img src="http://placehold.it/570x270"&gt; &lt;/div&gt; &lt;div&gt; &lt;img src="http://placehold.it/570x270"&gt; &lt;/div&gt; &lt;div&gt; &lt;img src="http://placehold.it/570x270"&gt; &lt;/div&gt; &lt;div&gt; &lt;img src="http://placehold.it/570x270"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and here's my screen shot on what im refering to as a problem.</p> <p><a href="http://i45.tinypic.com/ejark8.jpg" rel="nofollow">http://i45.tinypic.com/ejark8.jpg</a></p>
jquery
[5]
166,864
166,865
Using non-hashable Python objects as keys in dictionaries
<p>Python doesn't allow non-hashable objects to be used as keys in other dictionaries. As pointed out by Andrey Vlasovskikh, there is a nice workaround for the special case of using non-nested dictionaries as keys:</p> <pre><code>frozenset(a.items())#Can be put in the dictionary instead </code></pre> <p>Is there a method of using arbitrary objects as keys in dictionaries?</p> <p><strong>Example</strong>:</p> <p>How would this be used as a key?</p> <pre><code>{"a":1, "b":{"c":10}} </code></pre> <p><strong>It is extremely rare that you will actually have to use something like this in your code. If you think this is the case, consider changing your data model first.</strong></p> <p><strong>Exact use case</strong></p> <p>The use case is caching calls to an arbitrary keyword only function. Each key in the dictionary is a string (the name of the argument) and the objects can be quite complicated, consisting of layered dictionaries, lists, tuples, ect.</p> <p><strong>Related problems</strong></p> <p>This sub-problem has been split off from <a href="http://stackoverflow.com/questions/1600591/using-a-python-dictionary-as-a-key">the problem here</a>. Solutions here deal with the case where the dictionaries is not layered.</p>
python
[7]
2,539,027
2,539,028
Output Response in ANSI Characters format in ASP.net
<p>I am writing the data to the output browser using Response.write(some byte arrary)</p> <pre><code> Response.ContentType = "application/ms-excel"; Response.ContentEncoding = System.Text.Encoding.Default; Response.OutputStream.Write(report, 0, report.Length); Response.Flush(); Response.Close(); </code></pre> <p>In my file I am having ANSI characters I need to write the information in the format ANSI when i open my excel file. Do we need to add anything.</p> <p>I have encoded it to ANSI but its not working.</p>
asp.net
[9]
3,199,948
3,199,949
Days Since (negaive result)
<p>Can anyone help me modify this code so that it returns a negative number if date is passed?</p> <p>Thanks</p> <pre><code>$renewaldate = strtotime(getsetting('renewaldate')); $timetorenewal = abs(time() - $renewaldate); $numberDays = $timetorenewal/86400; $numberDays = intval($numberDays); return $numberDays; </code></pre>
php
[2]
869,054
869,055
Asp.net Progress Bar
<p>I am working on a project in which i post the deals regarding the clothing product. In the deal i set the buing limit of the product such i have shirt it price is $5 but if get 1oo item sale within the specified time i will sell the shirt in $4. In this senario need to use progress bar to show the status of deal such many items are booked for sale. Can any body tell is there a control in asp.net which i can use? </p>
asp.net
[9]
3,145,968
3,145,969
facebook integration with .net
<p>i am working on c#, where in i want to integrate a login button and a like button on my application . from where the user can update his status . can i get that code in c#.</p>
c#
[0]
3,800,910
3,800,911
C# the name 'sr' doesn't exist in current context
<p>I was following example from microsoft <a href="http://msdn.microsoft.com/en-us/library/db5x7c0d.aspx" rel="nofollow">site</a> for reading from text file. They say to do it like this:</p> <pre><code>using System; using System.IO; class Test { public static void Main() { try { using (StreamReader sr = new StreamReader("TestFile.txt")); { String line = sr.ReadToEnd(); Console.WriteLine(line); } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } } } </code></pre> <p>but when I do it like that in Visual C# 2010 it brings me errors:</p> <blockquote> <p>Possible mistaken empty statement</p> <p>The name 'sr' does not exist in current context</p> </blockquote> <p>I removed the <code>using</code> part and now the code looks like this and is working:</p> <pre><code>try { StreamReader sr = new StreamReader("TestFile.txt"); String line = sr.ReadToEnd(); Console.WriteLine(line); } </code></pre> <p>Why is that?</p> <p>EDIT: there was semicolon at te end of using(....);</p>
c#
[0]
1,780,320
1,780,321
what's the difference bewteen document.defaultView.getComputedStyle and window.getComputedStyle
<p>when get a element's style, we always use </p> <p><code>if(document.defaultView &amp;&amp; document.defaultView.getComputedStyle)</code> to check whether the browser support the method or not.</p> <p>why not use <code>if(window.getComputedStyle)</code>?</p>
javascript
[3]
4,813,416
4,813,417
Element accessible with ID
<p>I saw a strange behavior. I created a <code>Input</code>.</p> <pre><code>&lt;input id='inputid' value='value'/&gt;​ </code></pre> <p>and tried to access it directly from id. Instead of throwing an exception console was showing above input element.</p> <pre><code>console.log(inputid); </code></pre> <p>After that I tried to compare it with <code>getElementById</code></p> <pre><code>console.log( inputid == document.getElementById('inputid')); </code></pre> <p>console was showing <code>true</code>.</p> <p>You can see this behavior on <a href="http://jsfiddle.net/XwWcS/">jsfiddle</a>.</p> <p>Is it a strange behavior or am I missing something?</p> <p>I tested it in <code>Chrome 23.0.1271.10 dev-m</code> and <code>firefox 15.0.1</code>.</p>
javascript
[3]
1,553,171
1,553,172
.append jquery, limit to one character per <span>
<p>I have these two functions:</p> <pre><code>jQuery.fn.enterText = function(e){ if( $("#cursor").val() &amp;&amp; e.keyCode != 32 ){ var character = $("#cursor").val(); $("#cursor").val(""); this.append("&lt;span class = 'text'&gt;"+character+"&lt;/span&gt;"); $("#cursor").insertAfter(".text:last"); $("#cursor").focus(); } }; jQuery.fn.markCursor = function(e){ $(this).focus(); $(this).keyup(function(e) { $("#cursor-start").enterText(e); }); }; </code></pre> <p>What my problem is that if I text is entered rapidly, some elements will have more than one character, for example (abc). I wanted to know how to limit to one character in an efficient manner, I thought of using an array, but would that not be too efficient?</p>
jquery
[5]
5,594,420
5,594,421
how to get float value from integer in java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4377842/how-can-i-convert-integer-into-float-in-java">How can I convert integer into float in Java?</a> </p> </blockquote> <p>I got the problem with this code. I have two variable <code>int i</code> and <code>float f</code>.</p> <p><code> int i = 23;</p> <p>float f = i/10; </code></p> <p>I suppose the value in <code>f</code> variable should be <code>2.3</code></p> <p>but the real output value in <code>f</code> is <code>2.0</code></p> <p>Why result occurred like this and how can i get the float value <code>2.3</code></p>
java
[1]
966,403
966,404
Non scrolling GridView
<p>I want to use a <code>GridView</code> that will just expand it's height to show all it's children. The reason for this is that I want to place a custom view above the <code>GridView</code>, which should scroll along with the <code>GridView</code>:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;com.myapp.myview android:id="@+id/myview" android:layout_width="match_parent" android:layout_height="50dp" /&gt; &lt;GridView android:id="@+id/gv" android:layout_width="match_parent" android:layout_height="wrap_content" android:horizontalSpacing="@dimen/spacing_small" android:numColumns="2" android:padding="@dimen/spacing_small" android:verticalSpacing="@dimen/spacing_small" /&gt; &lt;/LinearLayout&gt; &lt;/ScrollView&gt; </code></pre> <p>How can I achieve this?</p>
android
[4]
2,184,651
2,184,652
How to use PHP to return only the first part of my file name, not the extension, ".php"
<p>I am trying to set the ID of the <code>&lt;body&gt;</code> tag to be the name of the current page...</p> <pre><code>&lt;body id="&lt;?= basename($_SERVER['PHP_SELF'])?&gt;"&gt; </code></pre> <p>Why is this returning:</p> <pre><code>&lt;body id="wildlife.php"&gt; </code></pre> <p>?</p> <p>I want just the word "wildlife."</p>
php
[2]
2,676,058
2,676,059
Unable to fetch Mobile number on Android 2.2
<p>I have used the standard code below to fetch the mobile number on my ANDROID 2.2 GSM device, BUT I ALWAYS GET AN EMPTY STRING. Is this feature supported on 2.2? Any suggestion as to how I can fetch the mobile number on Android 2.2 device.</p> <pre><code>private String getMyPhoneNumber(){ TelephonyManager mTelephonyMgr; mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); return mTelephonyMgr.getLine1Number(); } </code></pre>
android
[4]
4,349,782
4,349,783
Capturing setOnClickListener() and setOnFocusChangeListener()
<p>I'm writing an API for Android and I need to know when the developer using the API calls <code>View.setOnClickListener()</code> and <code>View.setOnFocusChangeListener()</code>. I don't want to override either because that would mean to extend <code>View</code> and I don't want to force the developer to use my subclass -basically because he wouldn't be able to use the Android GUI editor for Eclipse-.</p> <p>I tried to override <code>Activity.dispatchTouchEvent()</code> but then I cannot capture movements done with keypad/virtual keyboard.</p> <p>Any ideas or guidelines on how to do this?</p>
android
[4]
4,786,134
4,786,135
Text viewed as HTML
<p>Hey everyone this is a update from my previous question <a href="http://stackoverflow.com/questions/6676440/android-showing-a-edittext-text-in-webview">[Android] Showing a EditText text in webview</a></p> <p>I got the webview to see the text inside my Edit text field but its displaying it as text this is the coding im using </p> <pre><code> case R.id.Preview: Intent j = new Intent(this, Preview.class); j.putExtra(com.afajje.htmlzero.Preview.URL, myEditText.getText().toString()); startActivity(j); } return false;} </code></pre> <p>Want im trying to have it do is view the Edit text, text as HTML</p> <p>For example if I put in the Edittext field</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;This is a Preview&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In the web view itll just just the "This is a Preview"</p>
android
[4]
2,012,279
2,012,280
sendOrderedBroadcast example code for receiving SMS in Android
<p>I have to receive an SMS on port in my android application. Does anyone have an example code for receiving SMS message using sendOrderedBroadcast. I want to use sendOrderedBroadcast because my messages should not be stored in native message inbox. So, i have to use sendOrderedBroadcast. Does anyone have an example code for how to do this?</p> <p>-chinnadurai</p>
android
[4]
3,565,322
3,565,323
difference between $ and $() in jQuery
<p>Could someone take the effort to explain me the difference between <code>$</code> and <code>$()</code> in jquery?</p> <p>I know <code>$()</code> is shorthand form of <code>$jQuery()</code> which takes any DOM element and turns it into a jQuery object. </p> <p>But what I am not sure of is what is <code>$</code> and how different is it from <code>$()</code>. Kindly enlighten me.</p> <p>Thanks heaps, Chaitanya </p>
jquery
[5]
2,595,925
2,595,926
Java-String is never read error!
<p>This is driving me insane! Here's the code:</p> <pre><code>public static void main(String[] strings) { int input; String source; TextIO.putln("Please enter the shift value (between -25..-1 and 1..25)"); input=TextIO.getInt(); while ((input &lt; 1 || input &gt; 25) &amp;&amp; (input &lt;-25 || input &gt;-1) &amp;&amp; (input != 999 &amp;&amp; input !=-999)) { TextIO.putln(input + " is not a valid shift value."); TextIO.putln("Please enter the shift value (between -25..-1 and 1..25)"); input=TextIO.getInt(); } TextIO.putln("Please enter the source text (empty line to quit)"); //TextIO.putln(source); source = TextIO.getln(); TextIO.putln("Source :" + source);?"); } } </code></pre> <p>However, its telling me that 'source' is never read! It's not allowing me to get input! Can anyone see what the problem may be?</p>
java
[1]
231,487
231,488
rename directory(error Could not find a part of the path.)
<pre><code>string sourceDir = @"E:\Images\3\2\1"; string destDir = @"E:\Images\33\22\11"; Directory.Move(sourceDir, destinationDir); </code></pre> <p>I have to rename directory I use Directory.Move() but gives me error:</p> <pre><code>Could not find a part of the path. </code></pre>
c#
[0]
5,508,528
5,508,529
What does the term Principal mean in .NET Security?
<p>I'm reading this article <a href="http://www.codeguru.com/Csharp/.NET/net_security/authentication/article.php/c7415/" rel="nofollow">http://www.codeguru.com/Csharp/.NET/net_security/authentication/article.php/c7415/</a></p> <p>I still don't understand the concept of "Principal" (why this name) what's difference with just Identity in common language ?</p> <p>For example in the tutorial I don't understand the distinction between UserIdentity and SecurityPrincipal ?</p>
asp.net
[9]
1,937,765
1,937,766
Creating a phone software lock Application for android
<p>I need to create an Application that can lock the handset at some specific Event.</p> <p>either i want to make use of Require Pattern programatically.</p> <p>or create a lock application, just like windows mobile in which there are digits to be entered instead of a Pattern.</p> <p>please guide me to the path if creating this application is possible.</p> <p>regards Aftab Alam</p>
android
[4]
986,839
986,840
What can prevent a working (when "opened with" Python) Python application from starting by double-click?
<p>A Python application (having a permission to be executed by the user) doesn't start with double click on it. If I run it (directly, by <code>./theapp.pyw</code>) in terminal I get ": No such file or directory" error (while there is no such a string in the application code and the file surely exists (renaming it and using a different name results in the same)).</p> <p>But If I explicitly open it with Python (by issuing <code>python ./theapp.pyw</code> or right-clicking and choosing to open with Python 2.7) it works just fine.</p> <p>The first line of the file says</p> <pre><code>#!/usr/bin/env python </code></pre> <p>Issuing "/usr/bin/env python" command launches Python 2.7 console.</p> <p>The OS is XUbuntu Linux 11.10. The only Python installed is Ubuntu's default 2.7.</p> <p>Any ideas?</p>
python
[7]
376,946
376,947
Check if CSS pseudoElement after/before exist on an element using JS
<p>edit: Actually... none of that works properly!</p> <p>For a non-existent pseudo-element, it returns the actual element's style, so to check a pseudo-element's background-image for existence, you need to do: </p> <p><code>(window.getComputedStyle(emElem,'after').backgroundImage!=window.getComputedStyle(emElem).backgroundImage)&amp;&amp;window.getComputedStyle(emElem,'after').backgroundImage</code></p> <p>I'm pretty sure that shouldn't be necessary.</p> <hr> <pre><code>window.getComputedStyle(element,'after').content!='none'; </code></pre> <p>That seems to work, but it is slow, and needs to be executed many times on some pages(I've seen upwards of 4 seconds delay using this.) Is there not a more sane way of getting this information?</p>
javascript
[3]
3,560,577
3,560,578
iPhone enumerateGroupsWithTypes finishing selector
<p>I'm using </p> <pre><code>[assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:listGroupBlock failureBlock:failureBlock]; </code></pre> <p>to enumerate Photo Albums.</p> <p>The enumerator is acting in an "asynchronous" way, in other words the methods returns before enumerating all items.</p> <p>How can I know when the enumeration is finished?</p> <p>I'm populating a NSMutableArray with the groups, and would to call <code>[myTableView reloadData]</code> after enumeration is finished.</p>
iphone
[8]
3,716,195
3,716,196
how to get back to Activity from Activity called by startActivityForResult in the TabWidget?
<p>There is tabwidget as MainActivity with tab1 and tab2. And, Activity1 is set to tab1as contentview, Activity2 is set to tab2.</p> <p>User need to input information to use tab2 page. So i want to call an Activity by startActivityForResult() . </p> <p>My question is 'in this situation, how to get back to tab2 on tabwidget?'</p> <p>Just finish()?</p>
android
[4]
1,553,990
1,553,991
GET parameters are not recognized
<p>I have two URLs.</p> <p>This one works: <code>equipo.php?equipo=sk+gaming&amp;page=2&amp;ipp=24</code><br> This one does not: <code>equipo/sk+gaming.html?page=2&amp;ipp=24</code></p> <p><code>equipo/sk+gaming.html</code> does the same thing as <code>equipo.php?equipo=sk+gaming</code>, as it should.</p> <p>My problem is that when using <code>equipo/sk+gaming.html?page=2&amp;ipp=24</code>, the <code>page</code> parameter isn't there.</p> <p>Why am I not getting the <code>page</code> parameter and how can I fix it?</p>
php
[2]
3,586,575
3,586,576
I have to search for a file with extension .txt, but the path is changing every day
<p>I have a problem with file management. I have to search for a file with extension .txt, but the path is changing every day.</p> <p>I have an another file which contain the actual path, I can store it in a string, but when I give the searching algorithm the windows drop an error message.</p> <p>Here my script: </p> <pre><code>path= 'c:\..... this is the path what I get back from an another script' os.chdir(path) for files in os.listdir("."):`` if files.endswith(".txt"): print files </code></pre> <p>Error message: WindowsError: [Error 3] The system cannot find the path specified: 'c:....'</p>
python
[7]
2,054,276
2,054,277
How does compiling happen only for the first time in projectless development?
<p>I read these words in a book:</p> <blockquote> <p><strong>Projectless development simplifies debugging</strong>: When creating a web project, you must recompile the entire application when you change a single page. With projectless development, each page is compiled separately, <em>and the page is only compiled when you request it for the first time.</em> </p> </blockquote> <p>How does compiling happen only for the first time in projectless development? Should it recompile every time I run the page to reflect the new code I wrote it?</p>
asp.net
[9]
4,237,010
4,237,011
C# - List member needs deep copy?
<p>I have class with a <code>List&lt;int&gt;</code> member. If I want to clone an instance of this class, do I need a deep copy or the <code>MemberwiseClone()</code> shallow copy is enough?</p> <p>We need a deep copy if at least one member is a reference to an object, right? Does that mean having List, DateTime, String, MyClass, ..., will need a deep copy?</p>
c#
[0]
3,699,108
3,699,109
Android Application: Got Internet Connection
<p>How can I check got a successful internet connect (Wifi/3G/whatever else) I already display an error to the user if they don't have Wifi connection but how can I make sure then that the user does got 3G connection if they wish to connect to use the application without the Wifi connection?</p>
android
[4]
1,975,581
1,975,582
Can i call setContentView() method in getView() method of Android?
<p>Can I call <code>setContentView()</code> method in a <code>getView()</code> method? If so, how?<br> Actually, I have a List that I am using to show some views like TextView, Imageview, and Button. Now on a button click event I want to show some other View. Here is my code:</p> <pre><code>Button select = (Button)findViewById(R.id.button1); select.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { setContentView(R.layout.search); } }); </code></pre> <p>But it is giving me a syntax error because I am using this method in a BaseAdapter class.</p> <p>Is there any other way to do this.?</p> <p>Thanks in advance.</p>
android
[4]
3,751,257
3,751,258
Chaining JQuery animations through iteration
<p>I have a number of divs next to each other (horizontally) and want the width of each of them, sequentially. Ideally they should look like one long div that grows to the right from the left. My issue is that they all start growing simultaneously. Each div has the name 'div' with a number at the end, and I'm using 'i' as that number. This should be dynamic because I don't know what 'i' is going to be. Can I chain this through iteration? Thank you.</p> <pre><code>for (i = 0; i &lt;= count; i++) { $('#div' + i).animate( { "width": "toggle" }, 1500 ); } </code></pre>
jquery
[5]
4,690,222
4,690,223
How can i call a C# server side function on click of asp:navigationmenu item?
<p>I am using a function for logout of client in asp.net C# previously i was using asp.net button's click event for calling it but now i want to call it from one of navigation menu item.</p>
asp.net
[9]
3,433,668
3,433,669
getting hidden elements
<p>Say I have the following unordered list</p> <pre><code>&lt;ul class="container"&gt; &lt;li class="item" style="display: none;"&gt;first item&lt;/li&gt; &lt;li class="item"&gt;second item&lt;/li&gt; &lt;li class="item"&gt;third item&lt;/li&gt; &lt;li class="item"&gt;forth item&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>how can I carry out a task only if all the items in the container are hidden?</p> <p>regards...</p>
jquery
[5]
3,479,933
3,479,934
how to set input value based on sending anchor using jQuery
<p>I've got a list of OpenID's, and I'd like to populate an input field based on the sending anchor.</p> <p>Basically the goal will be to populate the input with "<strong>Google</strong>" if the first button is clicked, "<strong>Yahoo!</strong>" for the second, etc.</p> <p>Does anyone know how I would do this?</p> <pre><code> &lt;div&gt; &lt;div class="openid openid_large_btn google-large"&gt; &lt;a href="#" class="openid_btn" &gt;&lt;span&gt;Google&lt;/span&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="openid openid_large_btn yahoo-large"&gt;&lt;a href="#" class="openid_btn" &gt;&lt;span&gt;Yahoo!&lt;/span&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="openid openid_large_btn myopenid-large"&gt;&lt;a href="#" class="openid_btn"&gt;&lt;span&gt;myOpenID&lt;/span&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="openid openid_large_btn aol-large"&gt;&lt;a href="#" class="openid_btn"&gt;&lt;span&gt;AOL&lt;/span&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="openid openid_large_btn facebook-large"&gt;&lt;a href="#" class="openid_btn"&gt;&lt;span&gt;facebook&lt;/span&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; &lt;script&gt; $('.openid_btn').click(function () { //I'd like to set this to the info contained within the &lt;span&gt; tags $("#openid_identifier").val("???"); $('#OpenIDForm').submit(); }); &lt;/script&gt; </code></pre>
jquery
[5]
3,012,619
3,012,620
Remove top level UL
<pre><code>&lt;li&gt; &lt;/li&gt; &lt;li class="wordwrap"&gt;&lt;/li&gt; </code></pre> <p>i want to remove <code>li</code> on top level .ie <code>li</code> without a class which resides just on top of <code>li</code> with class .i don't want to remove any other <code>li</code> ? How can we do this with Jquery</p>
jquery
[5]
3,933,063
3,933,064
Want to start iPhone development
<p>Hey, i am done with .NET and web dev. and want to start writing applications for iPhone.</p> <p>Where do i need to start like - any SDK or something i need to get - what language\s need to learn - i use windows, will i have to switch to mac for iPhone development - is there any iPhone device simulator or will i have to buy iPhone as well</p>
iphone
[8]
2,780,181
2,780,182
How to migrate from a paid android application to an application paid for with in-app billing?
<p>I currently have two versions of my app in the Android market, a paid one and a free one. But I want to integrate in-app billing into my free application, and charge customers on a subscription base, for a lower price than the current price of the paid app. </p> <p>But how should I handle this for existing customers? It seems unfair to let them pay again for use of the paid functionality, while they were the early adopters of my application. Ideally I implement something that will give the existing users access to the unlocked functionality in my free application. </p> <p>Any ideas of how to accomplish this? An outline of a good approach to take is enough, I don't mind to do some research on how to actually implement such an approach.</p>
android
[4]
3,493,531
3,493,532
replace function in javascript array
<p>We know javascript array.push appends elements to the array. Is there an option to replace the elements in the array? The below function gets called twice and I have no control over event.mediaCollection.mediaIds. So mediaDTOs array gets populated with same number of mediaIds twice. I wish to prevent that from happening.I'm looking to add new mediaIds everytime this function is called instead of pushing mediaIds to the same array.</p> <pre><code>function calledTwice(){ var mediaIds = event.mediaCollection.mediaIds; var mediaDTOs = []; for(var i = 0; i &lt; mediaIds.length; i++) { mediaDTOs.push({id:mediaIds[i]}); } } </code></pre> <p>Edit: Can't afford to create a temporary object to achieve this. Got to get the ids in the mediaDTOs array to be unique.</p>
javascript
[3]
3,046,044
3,046,045
jQuery: keydown event fires multiply times
<p>At present, when I press the Ctrl button and hold it pressed for a while, the handler that I binded to the keydown event with the help of jQuery is triggered multiply times - I would like to avoid triggering it more than once per a separate press. How would I accomplish that?</p>
jquery
[5]
4,088,700
4,088,701
How to glob for iterable element
<p>I have a python dictionary that contains iterables, some of which are lists, but most of which are other dictionaries. I'd like to do glob-style assignment similar to the following:</p> <pre><code>myiter['*']['*.txt']['name'] = 'Woot' </code></pre> <p>That is, for each element in myiter, look up all elements with keys ending in '.txt' and then set their 'name' item to 'Woot'.</p> <p>I've thought about sub-classing dict and using the fnmatch module. But, it's unclear to me what the <em>best</em> way of accomplishing this is.</p>
python
[7]
1,999,569
1,999,570
Using compare validator
<p>Is there a way in using compare validator that when you use lessthanequal or greaterthanequal operator it automatically treat the type as int? Let's say adding additional tag in web config or any setup? thanks</p>
asp.net
[9]
6,028,561
6,028,562
android - check which language text file (DE, EN) is loaded in the RAW directory
<p>I've a text file in the RAW DIrectory</p> <p>called test.txt</p> <p><strong>My java Code checks correctly the test.txt</strong> file with device language german. How can i check the EN-File, when the device language is english?</p> <p>I think in line 3 of my code i have to set an if-else block to proof the raw directory?</p> <p>THX a lot for HELP!</p> <p><strong>My Java Code (works):</strong></p> <hr> <pre><code> TextView HelpTxtMain; HelpTxtMain = (TextView)findViewById(R.id.TextViewMain); HelpTxtMain.setText(readTxtDe()); private String readTxtDe() { InputStream inputStream = getResources().openRawResource(R.raw.test); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); int i; try { i = inputStream.read(); while (i != -1) { byteArrayOutputStream.write(i); i = inputStream.read(); } inputStream.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return byteArrayOutputStream.toString(); } </code></pre>
android
[4]
5,379,428
5,379,429
How do I get an overview and a methodology for programming in Python
<p>I've started to learn Python and programming from scratch. I have not programmed before so it's a new experience. I do seem to grasp most of the concepts, from variables to definitions and modules. I still need to learn a lot more about what the different libraries and modules do and also I lack knowledge on OOP and classes in Python.</p> <p>I see people who just program in Python like that's all they have ever done and I am still just coming to grips with it.</p> <p>Is there a way, some tools, a logical methodology that would give me an overview or a good hold of how to handle programming problems ?</p> <p>For instance, I'm trying to create a parser which we need at the office . I also need to create a spider that would collect links from various websites. </p> <p>Is there a formidable way of studying the various modules to see what is needed ? Or is it just nose to the grind stone and understand what the documentation says ?</p> <p>Sorry for the lengthy question..</p>
python
[7]
2,924,004
2,924,005
Is it best to uninstall Java via Control panel or JavaRa software?
<p>I see there is an update released for Java (oracle).</p> <p>I have JavaRa software installed for removing old versions of Java. Should I remove the old one before I install the new one and which method of removal ? For example, should I only use JavaRa if Java wont uninstall? </p>
java
[1]
2,198,378
2,198,379
How to avoid if cond. for stack operation
<p>I have created a stack class which holds std::vector. I have written stack operation like pop() and exch() like</p> <pre><code>int Stack::pop() { if (v.size() &lt; 0) throw("Error : Stack Underflow"); int tos = v.back(); stack.erase(v.end()-1); return tos; } void Stack::exch() // Exchange top 2 element { if (v.size() &lt; 2) throw("Error : Stack Underflow"); size_t n = v.size(); int tmp = v[n-1]; v[n-1] = v[n-2]; v[n-2] = tmp; } </code></pre> <p>My application consist of lot of 'pop()' &amp; 'exch()' operations. But due to 'if' conditions the performance is little bit slow. Can you tell me how to avoid 'if' conditions ? Is there any way Or work around to avoid 'if'.</p> <p>Thanks in advance.</p> <p>Thanks, Nilesh</p>
c++
[6]
5,620,300
5,620,301
C++ optimise away private variable
<p>Does ISO C++ (11) permit a private non-static class member variable to be optimised away? This could be detected:</p> <pre><code>class X { int x; }; assert (sizeof(X) &gt;= sizeof(int)); </code></pre> <p>but I am not aware of a clause that demands the assertion above. </p> <p>To clarify: (a) Is there a clause in the C++ Standard that ensure the assertion above.</p> <p>(b) Can anyone think of any other way to detect the elision of x? [offsetof?]</p> <p>(c) Is the optimisation permitted anyhow, despite (a) and (b)?</p> <p>I have a feeling the optimisation could be possible if the class is local to a function but not otherwise (but I'd like to have a definitive citation).</p>
c++
[6]
1,956,706
1,956,707
how to set the background color for single cell in the table view on iphone
<p>I'm having one Table view. In that i want to set the color for the First cell alone..Others should be in white...How can i do that</p> <p>I need your help....</p> <p>Thanks in advance.....</p>
iphone
[8]
1,837,386
1,837,387
Unexpected runtime error: Could not load main Class
<p>I was trying on some code to better understand the access modifiers. Everything was running great after I added jus one line of code</p> <pre><code>class SomeClass2 { protected static void method4() { } protected static int x=0; } class SomeClass3 extends SomeClass2{ int c=SomeClass2.x; public void somemethod() //Everything was compiling fine until { //Until I added this method SomeClass2.method4(); } } class DemoClass1{ public static void main(String[] parameters) { SomeClass2 sc = new SomeClass2(); SomeClass3 sc1 = new SomeClass3(); sc.method4(); System.out.println(sc1.c); sc1.somemethod(); } } </code></pre> <p>I am getting an error: <code>Could not find or load main class DemoClass1</code> All the classes belong to same directories and same package. And environmental variables are all set too. It was compiling and running fine until I added <code>somemethod()</code>. It compiles fine but does not run.</p>
java
[1]
3,427,655
3,427,656
Difference between creating a global variable, vs one in a constructor function in JavaScript
<p>If I declare a global variable x as:</p> <pre><code>var x = "I am window.x"; </code></pre> <p>x will be a public property of the window object. If I call a global function (without using "call", "apply" or attaching it to another object first), the window object will be passed in as the context (the “this” keyword). It is like it is siting the x property on the current context, which happens to be the window.</p> <p>If, however, I declare a variable in the same way inside a function, then use that function as a constructor, the property x will not be a public property of the object I just constructed (the current context). I am happy (I know I can do this.x = …), but it just seems like a bit of a contradiction.</p> <p>Have I misunderstood something (about it being a contradiction / different behaviour)? Would anyone be able to explain what is going on, or is it just something I have to accept?</p> <p>Hope that my question is clear.</p>
javascript
[3]
3,225,249
3,225,250
Why android does not let me update my UI in my own thread
<p>I understand I need to put the code for long processing time to my own thread, not the UI thread. My question is why in my own thread, android does not let me update the UI, e.g. update the text of my TextView in UI?</p> <p>Thank you.</p>
android
[4]
2,698,593
2,698,594
C# - How to print aspect ratio / full page
<p>I am printing the CHART control on button click:</p> <pre><code>chart1.SaveImage(ms, ChartImageFormat.Bmp); Bitmap bm = new Bitmap(ms); PrintDocument doc = new PrintDocument(); doc.PrintPage += (s, ev) =&gt; { ev.Graphics.DrawImage(bm, Point.Empty); // adjust this to put the image elsewhere ev.HasMorePages = false; }; doc.DefaultPageSettings.Landscape = true; doc.Print(); </code></pre> <p>How do I force it to print the control so that it fits to the size of the page (preserving the aspect ratio)?</p>
c#
[0]
830,498
830,499
Why this jsfiddle wont run?
<p>This is probably a stupid mistake, but I'm new to jsFiddle, and I can't run this piece of code: <a href="http://jsfiddle.net/rnG4n/" rel="nofollow">my fiddle</a></p> <p>The code should put either <code>OK</code> or <code>not ok</code> in the .output div. It doesn't do it. Thanks</p>
javascript
[3]
5,908,119
5,908,120
How to create a table in a MS access database in C#
<p>I need to create a table in MS access database. Consider, 'ConfigStructure.mdb' being my database name and i need to create a table in this database in C#.</p> <p>How can i do this? I tried with the below code but its not working. </p> <pre><code> OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + frmMain.strFilePath + "\\ConfigStructure.mdb"); myConnection.Open(); string strTemp = " KEY Text, VALUE Text "; OleDbCommand myCommand = new OleDbCommand(); myCommand.Connection = myConnection; myCommand.CommandText = "CREATE TABLE table1(" + strTemp + ")"; myCommand.ExecuteNonQuery(); myCommand.Connection.Close(); </code></pre> <p>This is the error that i get,</p> <pre><code>"System.Data.OleDb.OleDbException: Syntax error in field definition System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object&amp; executeResult)\r\n at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&amp; executeResult)\r\n at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object&amp; executeResult)\r\n at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)" </code></pre>
c#
[0]
1,859,616
1,859,617
how to get cursor from one activity to another activity
<p>hi i need cursor value from one activity to another but its display null. </p> <pre><code>public class TitleActivity extends ListActivity { /** Called when the activity is first created. */ public Cursor titleCursor = null; public String blogid; public String language; public String titleRowid; public String rowid; public int COUNT; public JSONArray jarray; protected NotificationManager notify = null; private int requiredSpace = 0; private String contentUrl = null; private String updateTitlesUrl = null; Cursor ePubDownloadCursor = null; private Cursor deleteTitleCursor = null; protected String magid; protected String pdate; protected int pos; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { initializeAllCursors(); } catch (Exception e) { VSLog.error(this.getClass(), "Error in start up activity" + e.getMessage()); } } private void initializeAllCursors() { try { // Contains download status , content and id ePubDownloadCursor = managedQuery( BlogProvider.Constants.CONTENT_URI, ConstantValues.EPUBDOWNLOAD, null, null, BlogProvider.Constants.PDATE + " DESC "); // Contains deleted status , content and id deleteTitleCursor = managedQuery( BlogProvider.Constants.CONTENT_URI, ConstantValues.EPUBDOWNLOAD, null, null, BlogProvider.Constants.PDATE + " ASC "); notify = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); } catch (Exception e) { VSLog.error(this.getClass(), "Error cursor inizilization" + e.getMessage()); } } </code></pre> <p>i want deletetitle cursor in my another activity how i get plz help...i want know how i get deleteTitlecursor to my another activity because i need to pass that cursor for my another class. but i need deleteTitle cursor titleactivity also </p>
android
[4]
3,369,631
3,369,632
Dealing With This Generics Bug
<p>I need a little help in generics in the following code:</p> <pre><code>public &lt;T extends Comparable&lt;T&gt;&gt; int insertionSort(T[] a) { // throw new RuntimeException("not implemented"); final int L = a.length; int compares = 0; for(int i = 1; i &lt; L; i++){ for(int j = i; j &gt; 0 &amp;&amp; a[j].compareTo(a[j - 1]) &lt; 0; j--){ Comparable tmp = a[j]; // PROBLEM HERE a[j] = a[j - 1]; a[j - 1] = tmp; // PROBLEM HERE compares++; } } return compares; } </code></pre> <p>// PROBLEM HERE those two lines in the code are fault and need help in fixing them.</p> <p>thanks</p> <p><strong>edit</strong></p> <p>the errors are i can't make the assignments</p>
java
[1]
1,202,790
1,202,791
using jQuery to get other buttons not clicked in a div
<p>I have an HTML div</p> <pre><code>&lt;div id="buttons"&gt; &lt;button type="button" id= "button_1" &gt;I am button one&lt;/button&gt;&lt;/br&gt;&lt;/br&gt; &lt;button type="button" id= "button_2"&gt;I am button two&lt;/button&gt;&lt;/br &gt;&lt;/br&gt; &lt;/div&gt; </code></pre> <p>I have attached the following jQuery handler</p> <pre><code>$("#buttons").click(function(event) { } </code></pre> <p>I want to put in code that colors the clicked button’s label type color to red and the other button or buttons (I may add more) label type color back to black. Using this type of code: </p> <pre><code> $("#button_1").css("color","red”); </code></pre> <p>I thought that using .not would work to get me the unclicked divs, something like: <code>$("#buttons").not(“#” + event.target.id).css("color”,”black”)</code> would set all unclicked buttons- basically those that are not event.target - to black, then I would set the clicked on to red <code>$(“#” + event.target.id).css("color”,”black”)</code> -</p> <p>It is not working- hence my query. Thanks for any answers.</p>
jquery
[5]
4,391,767
4,391,768
What is this enum for in the destructor?
<pre><code>// Destructor. If there is a C object, delete it. // We don't need to test ptr_ == NULL because C++ does that for us ~scoped_ptr() { enum { type_must_be_complete = sizeof(C) }; delete ptr_; } </code></pre> <p>Note: C is a template parameter</p> <p>I know we cant delete a null pointer, an exception will be raised. So in this case, the enum definition must be doing something to prevent that. In production, sometimes we dont want to end a program simple because we have a null pointer, we may want to look at alternative scenario, when the pointer is null. And this code is used in production, almost everywhere?</p> <p>Thanks guys.</p>
c++
[6]
570,622
570,623
ASP.NET DATE type validaiton
<p>How i do check whether DateTime data type variable is null/empty in asp.net ?</p>
asp.net
[9]
5,625,967
5,625,968
Logging without loss of time
<p>Greetz fellows!</p> <p>I'm looking for a way to log actions of a CLI script without losing time. I did some benchmarks and I figured out that by <code>echo</code>ing someting after each action, the script will be nearly 2x slower and by appending actions to a log file it'll be 17x times slower.</p> <p>So, anyone has a solution?</p>
php
[2]
1,581,459
1,581,460
How to catch an exception from a private member subclass object?
<p>Given the pseudo-code below, I want to catch the exception thrown by the sub-object a in class B, maintaining this object private in B. The catch clause as stated below doesn't work because the object a is private in B. How can I catch this exception ?</p> <p><strong>Edit</strong> I have changed the pseudo-code to embed class A within class B.</p> <pre><code>class B { class A { public: class Exception{}; A() throw(Exception) { ... } // A ctor throws an Exception class object } a; public: B() { ... } // B ctor }; int main() { try { B b; } catch( B::A::Exception&amp; ) { ... } } </code></pre>
c++
[6]
3,870,435
3,870,436
How to prevent Reload activity in android?
<p>Have two activity A,B :Activity A contains list,onclick of list am taking to B activity.In B activity i have 3 buttons let it[B,q,r] on click of each button am taking to new activity loading data from server.So i dont want to reload everytime that data.And from any of these p,q,r on back pressed i want to take him back to Activity A</p>
android
[4]
2,291,752
2,291,753
jquery flash and dynamic variables
<p>How can I include this varibale without it shooting me an error</p> <p>The variable is vid on the vars line</p> <pre><code>$('.playVideo').live('click',function(z){ z.preventDefault();//Disable Default Method var vid = $(this).attr('data'); </code></pre> <p>.... </p> <pre><code>$('#video').empty().flash({ "src":"video/videoplayer-loop.swf", "width":322, "height":275, "vars":{"image":"img/video-posterframe-product.jpg","videoLink=player/video/"+vid+".flv","hideAudio1":"false","videoVolume":"50"}, }); </code></pre> <p>I get thrown a </p> <blockquote> <p>Uncaught SyntaxError: Unexpected identifier</p> </blockquote>
jquery
[5]
3,397,724
3,397,725
PHP - Tricky... array into columns, but in a specific order
<pre><code>&lt;?php $combinedArray = array("apple","banana","watermelon","lemon","orange","mango"); $num_cols = 3; $i = 0; foreach ($combinedArray as $r ){ /*** use modulo to check if the row should end ***/ echo $i++%$num_cols==0 ? '&lt;div style="clear:both;"&gt;&lt;/div&gt;' : ''; /*** output the array item ***/ ?&gt; &lt;div style="float:left; width:33%;"&gt; &lt;?php echo $r; ?&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;div style="clear:both;"&gt;&lt;/div&gt; </code></pre> <p>The above code will print out the array like this:</p> <p><strong>apple --- banana --- watermelon</strong></p> <p><strong>lemon --- orange --- mango</strong></p> <p>However, I need it like this:</p> <p><strong>apple --- watermelon --- orange</strong></p> <p><strong>banana --- lemon --- mango</strong></p> <p>Do you know how to convert this? Basically, each value in the array needs to be placed underneath the one above, but it must be based on this same structure of 3 columns, and also an equal amount of fruits per column/row (unless there was like 7 fruits there would be 3 in one column and 2 in the other columns.</p> <p>Sorry I know it's confusing lol</p>
php
[2]
1,221,914
1,221,915
How to Read the Latest rss feed in android?
<p>I am doing one project and i want to read the latest rss feeds and i want dispaly,i ahve read lot of blogs about reading rss feeds.</p> <p>But all of them given reading only the html or xml,but i want ro read diffarent one,and i have given link below ,plz if any buddy know help me</p> <pre><code> http://onsoranje2012.mobgen.com/?mod=feeds&amp;action=coach </code></pre> <p>thanks in advance .</p> <p>Regards, Gangadhr</p>
android
[4]
2,204,318
2,204,319
Breaking creation of object in constructor
<p>Constructor in my class checks for some condition. In some case it should break the creation of the object. Should I put there a destructor or just return statement?</p> <p>It goes something like this:</p> <p>Somewhere in the code:</p> <pre><code>new Obj( string ); </code></pre> <p>and my constructor:</p> <pre><code>Obj::Obj( string ) { if( string == "something" ) { // should I put this here or only return? Obj::~Obj(); return; } // ... } </code></pre> <p>I know that I can check the condition before creation of the object, but I just wonder if it's correct (if there are no memory leaks) because it compiles well without crashing at runtime.</p>
c++
[6]
3,853,450
3,853,451
Using base class methods to initialize derived class members
<p>Is it legal? If so, do you consider it as good coding practice?</p> <p>I want to do something like this (nonessential details are not shown):</p> <pre><code>class ItemStorage { int size() const; }; class SpecialStorage : public ItemStorage { public: SpecialStorage (...) : ItemStorage(...), items(ItemStorage::size()) {...} private: int items; }; </code></pre> <p>I am pretty sure that it is OK if the method <strong>size</strong> is not virtual. What if it is virtual and the derived class doesn't overwrite it?</p>
c++
[6]
4,309,162
4,309,163
How to share an Android app in development with a remote user
<p>I would like to know what options are available and what recommendations are for sharing an Android app that is in development. I basically have the same question that can be found here, but for Android rather than iPhone <a href="http://stackoverflow.com/questions/3764255/xcode-how-to-share-the-app-in-development-with-clients">Xcode - How to share the app in development with clients?</a></p> <p>I have a friend that I would like to show an app that I just developed. My friend is a non-developer, so the easiest method to do this would be great. I'm new to Android development, so I would like to know what suggestions some of you have who are more versed on the subject. </p> <p>Thanks in advance!</p>
android
[4]
5,722,921
5,722,922
A little C++ help please(repeated output)
<p>SO i have this code:</p> <pre><code>#include &lt;iostream&gt; #include &lt;cstdlib&gt; using namespace std; int main() { int x; x=rand(); int guess; do{ cout&lt;&lt;"Enter your guess:"; cin&gt;&gt;guess; if(guess==x)cout&lt;&lt;"You got it ! ;)\n"; else { cout&lt;&lt;"Wrong("; if (guess&lt;x) cout&lt;&lt;"too small)\n"; else cout&lt;&lt;"too big)\n"; } } while (guess != x); return 0; } </code></pre> <p>question: After compiling and running this program, i enter "999999999999" and it keeps repeating the "too big". why is this so?</p> <p>additional info: when i set the value of x to constant 10, and i entered 11, i notice it only repeats "too big" once. is there something i am not aware of? or is the code flawed?</p> <p>many thanks :)</p>
c++
[6]
1,158,452
1,158,453
Using PHP sessions to change change html menu items
<p>I'm trying to create a session once a user logs in so that the 'log in' menu item changes to 'log out' for the duration they are logged in. Once logged in, my success.php file runs which is just</p> <pre><code>&lt;?php session_start(); $_SESSION['loggedin'] = 1; ?&gt; </code></pre> <p>Now under the menu I have</p> <pre><code>&lt;?php if($_SESSION['loggedin']=1) echo '&lt;a href="logout.php"&gt;Logout&lt;/a&gt;'; else echo '&lt;a href="login.html"&gt;Login&lt;/a&gt;'; ?&gt; </code></pre> <p>I also have a logout page which is just </p> <pre><code>&lt;?php session_start(); session_destroy(); ?&gt; </code></pre> <p>What's happening here though is that by default, the logout option is showing rather than log in even though the user hasn't yet logged in to create the session.</p> <p>I'm not sure if this is the correct way of handling this, but some advice is very much appreciated.</p> <p>Thanks.</p>
php
[2]
3,038,107
3,038,108
jquery hover to show menu issue
<p>I'm trying to add a hover effect to show/hide a dropdown menu. The problem is when I hover over the link the menu shows but disappears again.</p> <pre><code>$(".hoverli").hover( function () { $('ul.file_menu').slideDown('medium'); }, function () { $('ul.file_menu').slideUp('medium'); } ); </code></pre> <p>Please take a look at the demo here: <a href="http://jsfiddle.net/4jxph/912/" rel="nofollow">fiddle</a>.</p> <p>Can you tell me what I'm missing in the code?</p> <p>thanks</p>
jquery
[5]
2,826,597
2,826,598
Custom tap window on Google Map
<p>I was just looking at one of the <strong>Google map</strong> implemented in IPhone which contains labels and buttons. </p> <p><img src="http://i.stack.imgur.com/8HPSs.png" alt="enter image description here"></p> <p>How can I get this kind of window in Android containing labels, buttons and an image as well?<br> Kindly provide me source for the same. </p> <p>Stone</p>
android
[4]
5,922,716
5,922,717
Error on Settings.System
<p>I am getting an error every time that Settings.System is in the code it just says <code>System cannot be resolved</code> or is <code>not a field</code>. How can I fix this?</p> <pre><code>public class InternetSpeedup extends Activity { ImageView toggle; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_internet_speedup); toggle = (ImageView) findViewById(R.id.imageView1); new CountDownTimer(31000, 1000) { public void onTick(long millisUntilFinished) { //toggle.setText("You have "+ millisUntilFinished / 1000 + " seconds left"); } public void onFinish() { // read the airplane mode setting boolean isEnabled = Settings.System.getInt( getContentResolver(), Settings.System.AIRPLANE_MODE_ON, 0) == 1; // toggle airplane mode Settings.System.putInt( getContentResolver(), Settings.System.AIRPLANE_MODE_ON, isEnabled ? 0 : 1); // Post an intent to reload Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); intent.putExtra("state", !isEnabled); sendBroadcast(intent); } }; } } </code></pre>
android
[4]
5,635,207
5,635,208
dice up a string in JS
<p>I have a string like this</p> <pre><code>4741:GREEN,CIRHOSIS,ORANGE,Long-term,GREEN,HIS B CHIC,4642:GREEN,CRHOSIS,GREEN,HSysk B CC, </code></pre> <p>the sting contains two records with record ID 4741 and 4642 separated by character. Also within the records everything else is separated by comma(,)</p> <p>how can I split this sting. Please note that this example string contains only 2 records but the other ones may contain more or less or none. Thank you for your help!</p>
javascript
[3]
2,523,612
2,523,613
what is serialization, can't i do it for methods or varibales in a class
<p>Could some body explain me why we do serialization an what is profit of this ?</p> <p>can we put serialize word on method or not, like in the following program on complete class the serialization is done can i do it on a method or a variable</p> <pre><code>Serializable] public class StudentInfo { //Default Constructor public StudentInfo() { } /// &lt;summary&gt; /// Create object of student Class /// &lt;/summary&gt; /// &lt;param name="intRoll"&gt;Int RollNumber&lt;/param&gt; /// &lt;param name="strName"&gt;String Name&lt;/param&gt; public StudentInfo(int intRoll, string strName) { this.Roll = intRoll; this.Name = strName; } private int intRoll; private string strName; public int Roll { get { return intRoll; } set { intRoll = value; } } public string Name { get { return strName; } set { strName = value; } } } </code></pre>
asp.net
[9]
950,378
950,379
how to get pages information using facebook.rest.pages.getinfo() in asp.net
<p>I have created one page in my facebook account so i want to find that page name in my asp.net application.</p> <p>Please send me reply how to get page name in asp.net using facebook.rest.pages.getinfo() Regards. Bhagirath raval.</p>
asp.net
[9]
5,149,408
5,149,409
C++ weird thing
<p>anyone can explain me, why this parts of code are acting differently?</p> <pre><code>while((c = fread(buf, sizeof(char), 1, f)) != 0); { if(write(t, buf, c) &lt; 0) { return E_MSGSEND; } } ///////////////////////////////////// do { c = fread(buf, sizeof(char), 1, f); if(write(t, buf, c) &lt; 0) { return E_MSGSEND; } } while(c != 0); </code></pre> <p>while {} runs only 1time but do {} while 5times. Whats is the difference? Before while {} c is intialized to 1.</p> <p>Thanks an advice</p>
c++
[6]
5,593,387
5,593,388
Ordering in python dictionary
<pre><code> r_dict={'answer1': "value1",'answer11': "value11",'answer2': "value2",'answer3': "value3",'answer4': "value4",} for i in r_dict: if("answer" in i.lower()): print i Result is answer11,answer2,snswer4,answer3 </code></pre> <p>I am using python 2.4.3 I there any way to get the order in which it is populated</p> <p>Or is there a way to do this by regular expression since i am using the older python version?</p>
python
[7]
2,708,622
2,708,623
registerForContextMenu on gridview adapter not called
<p>I have this code:</p> <pre><code> gridview = (GridView) findViewById(R.id.gridview); gridview.setAdapter(createAdapter(this)); this.registerForContextMenu(gridview); </code></pre> <p>and</p> <pre><code>public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.datacorrection: onCorrectData(); return true; case R.id.postfacebook: onPostFacebook(); return true; default: return super.onContextItemSelected(item); } } protected void onCorrectData() { } protected void onPostFacebook() { } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // TODO Auto-generated method stub super.onCreateContextMenu(menu, v, menuInfo); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.context_menu, menu); } </code></pre> <p>My custom adapter creates multiple TextViews arranged in the GridView. I want to listen to a long click on each of the TextViews in order to show a context menu. For some reason the onCreateContextMenu is never called even though I called registerForContextMenu on the GridView. I thought through this call all individual views (here: TextViews) will listen to a long click? Pls advice. Thanks!</p>
android
[4]
2,251,062
2,251,063
How the bit.ly system get the path from url?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3901635/php-passing-parameters-via-url">PHP passing parameters via URL</a> </p> </blockquote> <p>I know that if you have a page <code>www.domain.com/?id=ABC</code> you can get the <em>ABC</em> in the <code>index.php</code> file using a </p> <p><code>$_GET['id'];</code></p> <p>My question is how does a <code>bit.ly/ABC</code> can give the <em>ABC</em> to their php file without having an <code>?id=ABC</code> in the path?</p>
php
[2]
1,364,585
1,364,586
Java: how to allow choose a variable depending on parameter passed?
<p>This is my class:</p> <pre><code>class StockQuote { Float[] high, low, close, open; public float GetMax(String choose_data_type) { if data_type="high" { Routine_Searchmax(high) } elseif strdata_type="low" { Routine_Searchmax(low) } } private float Routine_Searchmax(float[] variable) { // here i search max value into my array } } </code></pre> <p>My Question is: it is possible to pass a string variable with <em>the name of a variable array</em>, then .. work on that specific variable ? Is there a way to do that ? Thanks</p>
java
[1]
1,675,446
1,675,447
Is there a way to call automatically function when class created by new
<p>I need to call function whenever class is created using new. Currently I need to write something like this:</p> <pre><code>MyClass *myClassPointer = new MyClass(...); myFunction(myClassPointer); </code></pre> <p>When MyClass is created as local object myFunction cannot be called. MyClass have at lest 2 constructors with different arguments. Is there a way to automatize it, that other programmers didn't need to remember to call it.</p> <p>I work with quite old framework and myFunction is used for maintenance without breaking it.</p> <p>edited</p> <p>myFunction is a public member function of application main window, witch is visible in all code of application. But myFunction my be moved out of class mainWindow and be changed into global function if it is needed. </p> <p>I was thinking of some kind of macro in header file of myClass, because this way I don't need to inspect all code that is already written, and add those modifications. But I couldn't find any solution. </p> <p>Thanks in advance for any ideas and suggestions.</p> <p>After accept.</p> <p>The problem is because of bad design of MyClass and it's use in framework. I accepted Mark's answer, because MyClass should be created by ClassFactory from the start.</p>
c++
[6]
1,337,140
1,337,141
How to count data rows in jqgrid and prevent display if a threshold is exceeded
<p>I need to count the number of rows of data returned to JQgrid before they are displayed and if an upper limit is exceeded display a dialog to the user like "maximum number of search results exceeded. Please refine search criteria". Does anyone know how to do this? One idea I have is that since I have this definition: jsonReader : { root: "rows", page: function(obj) { return 1; }, total: function(obj) { return (obj.rows.length/numberOfRowsPerPage); }, records: function(obj) { return obj.rows.length; }, repeatitems: false, cell: "cell", id: "id", userdata: "userData" } </p> <p>I might be able to make use of the value in 'records' but I don't know if this is a dead end or not or how or where to get that value from.</p>
jquery
[5]
5,100,960
5,100,961
Android - How to control numbers of item on each scroll on ListView?
<p>How can I set the list view just scroll 5 items on each scroll? <br /> Or I just want to slow down the scroll speed. <br /> The reason for this is I want my scrolling smoother.</p>
android
[4]
4,819,641
4,819,642
Registering derived classes in central list
<p>I have a central list of implementations of an interface and would like for derived classes to be able to register themselves in that list without having to add them in some central place. For example:</p> <pre><code>// interface.h struct MyInterface; std::vector&lt;MyInterface*&gt;&amp; InterfaceList(); struct MyInterface { MyInterface() { InterfaceList().push_back(this); } virtual ~MyInterface() {} // ... }; // derived.cpp #include "interface.h" class MyImplementation: public MyInterface { public: MyImplementation() { } // ... }; MyImplementation impl; </code></pre> <p>This doesn't seem to work. For reasons I don't understand, the constructor of MyInterface never gets called - I would have thought that the instance of the derived class would call it at startup. I know it's possible to do something along these lines since I've seen other libraries doing it - but haven't managed to figure out what it is that I'm doing wrong.</p> <p>Thanks :)</p> <p>Edit: Sorry, missed a pair of braces and a reference. InterfaceList() is a function that returns a reference to a vector.</p> <p>Edit part 2: Have now got it working in a reduced example, but can't get it to work in the files for the derived implementations - but that technique is working in another project. There must be something slightly different in those files which is causing it to fail - but it appears the problem isn't in the code I posted. Don't really want to post big chunks of my employer's projects though so I guess I'll have to keep fiddling myself. Thanks for the suggestions so far though :)</p>
c++
[6]
3,168,438
3,168,439
Questions about handling data and error in $.ajax response
<p>I'm using jquery and php for some async job. I'm using <code>$.ajax</code> with <code>beforesend</code>, <code>complete</code>, <code>success</code> and <code>error</code>. I made the async POST request to a php that execute some mysql query and return true (string "1" in fact) if all is ok and false (string "0"). Back to js I procedd the data return in the success function (or complete?). Should I have to handle data with</p> <pre><code>if (data=="1") alert("ok") else alert("ko")? </code></pre> <p>Is this the correct way?</p> <p>Another question, the error function of $.ajax is for the ajax request itself nad not for the result of the operation? Thanks</p>
jquery
[5]
2,802,617
2,802,618
Package in Java
<p>When do we actually use the package keyword? What does it mean?</p> <p>Suppose I write the following code:</p> <pre><code>package masnun; public class masnun{ public static void main(String args[]) { System.out.println("Hello maSnun!"); } } </code></pre> <p>What does this package thing do? I get a masnun.class file that doesn't run. I am new to Java. Can somebody please explain?</p> <p>Thanks</p>
java
[1]
3,099,782
3,099,783
find which view was clicked
<p>I have a view controller where there are several uiview object. I need to know on which uiview user have tapped. how is this possible? any guidance will help a lot....</p> <p>Thanks<br> Pankaj</p>
iphone
[8]
1,455,245
1,455,246
jquery serialize not sorted?
<p>I have a javascript function that reads an entire form into a serialized</p> <pre><code> $.ajax({ type: 'POST', url: '/cart/update.js', dataType: 'json', data: $("#add-to-cart").serialize() + '&amp;id=' + $("select[name=id]").val(), success: goToCart, error: goToCart }); </code></pre> <p>However it seems to be not organizing the data. It should be <code>pattern, line 1, line 2, line 3, line 4, line 5, line 6</code>, however it seems to be going <code>line 1, line 2, line 3, line 4, pattern, line 5, line 6</code>.</p> <p>Is there a way to sort the serialized data somehow?</p> <p>html is in proper order, pattern is first then lines 1-6.</p> <p>Any help?</p>
jquery
[5]
5,509,476
5,509,477
TypeError: unhashable type: 'list', Remove duplicate items in a list
<p>When I type the following code. I just try to remove the duplicate items in an list. There may be 10K pairs in this list.</p> <pre><code>&gt;&gt;&gt; t = [['a','1'],['a','1'],['a','2']...] &gt;&gt;&gt; t = list(set(t)) Traceback (most recent call last): File "&lt;pyshell#19&gt;", line 1, in &lt;module&gt; t = list(set(t)) TypeError: unhashable type: 'list' &gt;&gt;&gt; </code></pre>
python
[7]
5,363,918
5,363,919
Getting error using ContactManager Sample
<p>I have created some contacts data in the emulator. When I run the ContactManager sample app downloaded from the Android site, I get an error. Specifically, when trying to add a Contact through the app, I get a NullPointerException. </p> <p>I think it is because the "Target Accounts" spinner on the scree is not getting populated, and hence I cannot select a Target Account before adding a contact. </p> <p>Has anyone run across this problem or has any clues on how to fix this?</p>
android
[4]
5,767,865
5,767,866
What is logtype=100 OR logtype=500?
<p>When I use <code>ContentResolver.query(Calls.CONTENT_URI, null, Calls._ID = 'call ID here', null,null);</code> the text <code>(logtype=100 OR logtype=500)</code> is added to the query.</p> <p>what do 100 and 500 mean ?</p>
android
[4]
4,716,674
4,716,675
How to detect when the program is idle?
<p>For example, how does the program detect when the user hasn't used it for 5 minutes?</p>
c#
[0]
1,830,315
1,830,316
it there an Android event lister for speed?
<p>I have an app for speed measuring and would to detect when a user goes above or below certain speed. Do I have to constantly monitor the speed or there an event I can create?</p>
android
[4]