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
4,239,049
4,239,050
Progressbar Android: default color
<p>Hi i used the default horizontal bar. It looks exactly the same in all the devices except in android version 4.0.3 it shows up completely in white color. The progress color is fine but the background of the bar shows up white any idea why only on 4.0.3? Note that my build version is 2.2 and the theme i am using is Theme.Black.noTitleBar.Fullscreen.</p>
android
[4]
5,983,433
5,983,434
Why can I call a non-const member function pointer from a const method?
<p>A co-worker asked about some code like this that originally had templates in it.</p> <p>I have removed the templates, but the core question remains: why does this compile OK?</p> <pre><code>#include &lt;iostream&gt; class X { public: void foo() { std::cout &lt;&lt; "Here\n"; } }; typedef void (X::*XFUNC)() ; class CX { public: explicit CX(X&amp; t, XFUNC xF) : object(t), F(xF) {} void execute() const { (object.*F)(); } private: X&amp; object; XFUNC F; }; int main(int argc, char* argv[]) { X x; const CX cx(x,&amp;X::foo); cx.execute(); return 0; } </code></pre> <p>Given that CX is a const object, and its member function <em>execute</em> is const, therefore inside CX::execute the <em>this</em> pointer is const.</p> <p>But I am able to call a non-const member function through a member function pointer.</p> <p>Are member function pointers a documented hole in the const-ness of the world?</p> <p>What (presumably obvious to others) issue have we missed?</p>
c++
[6]
3,365,240
3,365,241
textarea to database including <p>
<p>I receive a large chunk of text in a text area. Usually it's divided into a few paragraphs. How can I wrap these paragraphs in <code>&lt;p&gt;</code> tags so the text will be formatted the same when I read it out of the database again?</p>
php
[2]
3,082,855
3,082,856
Static field initializer runs before Application_start, sometimes
<p>I've got an ASP.NET web app that is starting to show some very strange behavior. Here's some example code:</p> <pre><code>// in Bar.cs public class Bar { public static Baz baz = Something.Step2(); } // in Global.asax public void Application_Start(...) { Something.Step1(); } </code></pre> <p>The short version of the story is this: On some machines, Something.Step2 is executed before Something.Step1 and is throwing an unhandleable exception. On other machines, Step1 correctly executes before Step2. Global.asax and all the objects it uses do not refer to Bar at all.</p> <p>When are static fields supposed to execute in relation to other programming elements? Why would two machines (both Win7 64-bit, both with .NET 4.0, same IIS version, etc) execute things in different orders? The order is consistent on each machine too. On my machine, it <em>always</em> executes Step2 before Step1, but on my coworker's machine it <em>always</em> executes Step1 before Step2.</p> <p>Help very much appreciated.</p> <p><strong>Update</strong> I've found the root cause why my static field is being accessed. Class "Bar" from my example is actually a custom authentication module, and is referenced in web.config as the Authentication handler under System.webServer. If I remove that line from web.config, my system calls Step1 first and never calls Step2 at all. My question changes subtly to: "Why does web.config cause my static initializers to fire, and why does it cause them to fire before Application_Start executes?"</p>
asp.net
[9]
115,351
115,352
NSURLConnection connectionDidFinishLoading called before all file is downloaded
<p>I am using NSURLConnection to download a zipped file from a web service. In the didReceiveData I append the data to a file and using a good internet connection all appears to work correctly. The file is transparently unzipped as it is downloaded. If, however, I have a poor internet connection the connectionDidFinishLoading appears to be called before all the data has been received. Is there another delegate method that I should be trapping or some kind of timeout in NSURLConnection that is making it think that the download is finished as opposed to calling didFailWithError?</p>
iphone
[8]
2,981,642
2,981,643
Any solution for response.redirect in a user control
<p>I am using the Response.Redirect method in a User Control to allow visitors to click an ImageButton to take them to another page. However, when I click the ImageButton I recieve the following error:</p> <p>Object reference not set to an instance of an object.</p> <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</p>
asp.net
[9]
484,073
484,074
Changing current version of Java within Windows
<p>I'm working in a Windows XP environment and have recently installed java 1.6 because it was required by an application. </p> <p>However I don't want this to be the default version of java to be used. How do I set it so that the command java -version will return 1.5.x</p>
java
[1]
5,805,524
5,805,525
Adding double quotes in <a> using C#
<p>I have below code behind in c# </p> <pre><code> if (Session["cmpDictionaryTitle"]!= null) { downloadLinks.Text += @"&lt;li&gt;&lt;a onclick='pageTracker._trackEvent('dictionary', 'spanish');' target ='_blank' href=" + Session["cmpDictionaryTitle"] + "&gt;" + GetResourceString("c_DictionaryPDFName") + "&lt;/a&gt;&lt;/li&gt;"; } </code></pre> <p>I am trying to make below <code>&lt;a&gt;</code> link as shown below:</p> <pre><code>&lt;li&gt;&lt;a target ="_blank" href="/spa/Images/Diccionario_tcm25-18044.pdf" onclick="pageTracker._trackEvent('dictionary', 'spanish');"&gt;Diccionario de Español-Inglés GRATIS&lt;/a&gt;&lt;/li&gt; </code></pre> <p>However my c# code is generating below output when html page get renders, the reason is that I am not able to put proper quotes in my code behind.</p> <pre><code>&lt;li&gt;&lt;a );="" spanish="" ,="" dictionary="" onclick="pageTracker._trackEvent(" href="/spa/Images/Diccionario_tcm25-18044.pdf" target="_blank"&gt;Diccionario de Español-Inglés GRATIS&lt;/a&gt;&lt;/li&gt; </code></pre> <p>Can you please suggest how can I achieve above result in code behind.</p> <p>Thanks &amp; Best Regards</p>
c#
[0]
3,805,273
3,805,274
Assert behaviour in java?
<p>I am getting compilation error in Line 3, Is it any special case for asserts in java ? i am not sure why it's expecting some return type from methodB() , can somebody help me here ? Thanks</p> <pre><code>public class AssertTest { public void methodA(int i) { assert i &gt;= 0 : methodB(); System.out.println(i); } public void methodB() { System.out.println("The value must not be negative"); } public static void main(String args[]) { AssertTest test = new AssertTest(); test.methodA(-10); } } </code></pre>
java
[1]
3,947,455
3,947,456
Replace first character of string
<p>I have a string <code>|0|0|0|0</code></p> <p>but it needs to be <code>0|0|0|0</code></p> <p>How do I replace the first character (<code>'|'</code>) with (<code>''</code>). eg <code>replace('|','')</code></p> <p>(with JavaScript)</p>
javascript
[3]
440,993
440,994
How to implement dynamic element container in C++
<p>Given the following prototype, is it possible to implement it in C++? I am looking for resources(books, web) that can give me some concrete ideas to implement it in C++.</p> <pre><code>class Container { public: vector&lt;Element&gt; getElementsByCategory(Category _cate); bool AddElement(Element _element); bool DelElement(Element _element); private: vector&lt;Element&gt; vec; }; struct Element { Category cate; DataType type; DataValue value; }; Category can be CategoryA, CategroyB, CategoryC, etc. DataType can be Date, int, float, double, string, etc. DateValue is correspoding to DataType. </code></pre> <p>As you can see, the class <code>Container</code> can hold dynamic element each of different data type. The user is responsible for adding each different field(column in DB) to the <code>Container</code> and later <code>Container</code> provides way to return categorized data back to the user.</p> <p>For example, the user can add Element of int type, Element of double type, and Element of Date type into container at the very beginning. Then later, the user would like to query all elements that belong to int type.</p>
c++
[6]
783,483
783,484
About return in C++
<p>Sorry for this newbie question, but I can't find on google what I need to know.</p> <p>I understand <em>return</em>, but don't understand this... What does it mean this?</p> <pre><code> return (tail+1)%N == head%N; </code></pre> <p>Thanks a lot for patience.</p>
c++
[6]
231,581
231,582
Pulling a string (link) from file_get_contents?
<p>So, I just got home from work and my mind's dead, but let me see if I have this right..</p> <p>Write <code>file_get_contents(website)</code> to a variable. Use <code>strstr</code> to determine where the string first occurs. Use <code>strpos</code> to determine the exact position, write the position to another variable. Then I use <code>substr</code> to pull the exact string from it, writing THAT to another variable, and opening using <code>header()</code> to open the variable containing the link?</p> <p>Sorry if that didn't make much sense. But I think that sounds right. The links I'm stripping are all the same length, so that will simplify things a lot. Thanks!</p> <p>(by the way, I copied/pasted this from another forum I posted on. Too lazy to rewrite it)</p>
php
[2]
4,816,410
4,816,411
Definition of ONE asp.net application?
<p>How do you define <strong>ONE</strong> asp.net application? Does it have to be built under one solution or does it have to be deployed under one application under IIS? </p> <p>Can multiple web projects be deployed under one IIS application (so that they have access to each other's session, cache etc) ?</p> <p>This is just a theoretical question.</p> <p><strong>Update:</strong> What I am stressing on is what makes it <strong>ONE</strong> application. </p>
asp.net
[9]
5,425,666
5,425,667
how to parse $_REQUEST?
<p>here i am checking for and getting part of the request, (the ids). i also print out the entire request:</p> <pre><code>if (isset($_REQUEST['ids'])){ $amount = sizeof($_REQUEST['ids']); print_r($_REQUEST); echo "&lt;br&gt;$amount invitations Successfully Sent"; } </code></pre> <p>this is how the entire $_REQUEST prints out:</p> <pre><code>Array ( [mfs_typeahead_req_form_4cf74f96db3688507476560] =&gt; Start Typing a Name [ids] =&gt; Array ( [0] =&gt; 510149460 ) [fbs_258181898823] =&gt; \"access_token=258181898823|2.q_qb_yoReO0_xc4H8PxKRQ__.3600.1291280400-100000664203700|LqtGr_OiJTASGmek61awxmxfvFk&amp;expires=1291280400&amp;secret=85eTEELZj8lkV82V_PwRSA__&amp;session_key=2.q_qb_yoReO0_xc4H8PxKRQ__.3600.1291280400-100000664203700&amp;sig=d4cc0e4c0992ea29c0adfd60dc27185b&amp;uid=100000664203700\" ) </code></pre> <p>i need to parse the part at the end: &amp;uid=100000664203700, specifically '100000664203700'</p>
php
[2]
4,356,060
4,356,061
Tracking visitors to help support
<p>I am looking to find a way to gain information about how my visitors are going through my website and if they come across any errors, the errors are known along with the information about the visitor, so when they email for support I will have this information available. I don't want to be thought of spying on the visitor, but our audience does not provide much details about the problems they encounter which makes it difficult at times to track down the incident. Does anyone have suggestions on php programs that might be available, or simply php code that would handle this? Any suggestions would be appreciated to help me out. Thank you in advance. </p>
php
[2]
607,128
607,129
Removing frames
<p>I am trying to reorganize a site. There are some frame pages which I would like to remove as the same result can be achieved with less overhead. However, the frame below:</p> <pre><code>&lt;frame name="right" src="/PageTurn/BrowsePub.aspx? PublicationID=&lt;%=PubID%&gt;&amp;RunDate=&lt;%=Server.URLEncode(PubDate)%&gt;" scrolling="auto" marginwidth="0" marginheight="0"&gt; </code></pre> <p>I would like to remove but I have tried to use an include but I get the error message that the file cannot be found? Why does it work within a frame but not as an include? I also tried with an iframe and got the same result.</p> <p>Curious to know why it works as a frame.</p> <p>I tried a virual include:</p> <pre><code>&lt;!--#include virtual="/PageTurn/BrowsePub.aspx? PublicationID=&lt;%=PubID%&gt;&amp;RunDate =&lt;%=Server.URLEncode(PubDate)%&gt;"--&gt; </code></pre> <p>to no avail.</p> <p>Thanks, R.</p>
asp.net
[9]
5,739,593
5,739,594
JS Create A Date Object from value passed via AJAX Call
<p>I have a Python script that returns me a calculated date time in XML format like below:</p> <pre><code>&lt;prev&gt;&lt;date&gt;2012,07,16&lt;/date&gt;&lt;time&gt;22:00:00&lt;/time&gt;&lt;/prev&gt; </code></pre> <p>Though I can change the format but my issue is that when I try creating a JS date object using the value returned - I get 'Invalid date':</p> <pre><code>$.ajax({ async: false, type: "POST", url: "/cgi-bin/prev_hour.py", success: function(xml) { pdate = $(xml).find('date').text(); ptime = $(xml).find('time').text(); //alert prints correct date time ex 2012-07-16 22:00:00 }, error:function(xhr,err,html) { alert("Failed\nreadyState: "+xhr.readyState+"\nstatus: "+xhr.status + "\nresponseText: "+xhr.responseText); } var max_date = new Date("'" + pdate + ptime + "'"); alert(max_date); </code></pre> <p>I tried a couple of possibilities like Python script returning in various format:</p> <pre><code>&lt;prev&gt;&lt;date&gt;2012/07/16 &lt;/date&gt;&lt;time&gt;22:00:00&lt;/time&gt;&lt;/prev&gt; &lt;prev&gt;&lt;date&gt;2012,07,16 &lt;/date&gt;&lt;time&gt;22,00,00&lt;/time&gt;&lt;/prev&gt; </code></pre> <p>But still I get invalid date when trying to create a JS date object?</p> <p>Please let me know the correct way to implement it.</p>
javascript
[3]
3,849,134
3,849,135
C++ converting string to time_t question
<p>Im trying to convert a string such as "12 August 2011" into time_t or that seconds elapsed, or whatever so I can use it to compare a list of dates.</p> <p>At the moment, I have tried the following but the output seems to equal false! Also, the seconds elapsed seem to keep changing?</p> <p>Is this correct?</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;cstdlib&gt; #include &lt;cstring&gt; #include &lt;time.h&gt; #include &lt;stdio.h&gt; using namespace std; int main() { struct tm tmlol, tmloltwo; time_t t, u; t = mktime(&amp;tmlol); u = mktime(&amp;tmloltwo); //char test[] = "01/01/2008";string test = "01/01/2008"; strptime("10 February 2010", "%d %b %Y", &amp;tmlol); strptime("10 February 2010", "%d %b %Y", &amp;tmloltwo); t = mktime(&amp;tmlol); u = mktime(&amp;tmloltwo); cout &lt;&lt; t &lt;&lt; endl; cout &lt;&lt; u &lt;&lt; endl; if (u&gt;t) { cout &lt;&lt; "true" &lt;&lt; endl; } else if (u==t) { cout &lt;&lt; "same" &lt;&lt; endl; } else { cout &lt;&lt; "false" &lt;&lt; endl; } cout &lt;&lt; (u-t); } </code></pre>
c++
[6]
1,335,706
1,335,707
removeClass jquery statement not working
<p>I have the following JQuery statement and it is adding the class 'current' but it is not removing the class form the siblings.</p> <p>Any ideas why?</p> <pre><code>$('.page_link[longdesc=' + page_num + ']') .addClass('current').siblings('.current').removeClass('current'); </code></pre> <p>Malcolm</p>
jquery
[5]
3,826,465
3,826,466
Search through an openoffice spread sheet
<p>So I have my program now opening an openoffice spreadsheet. I need it to search for a sting and give me the row and column. I don't know what I would use to search the spreadsheet. </p>
java
[1]
4,897,933
4,897,934
Short circuit evaluation assignment in python?
<p>Ruby supports this:</p> <pre><code>name = name || "default" </code></pre> <p>If I try it in python: </p> <pre><code>name = name or "default" </code></pre> <p>Interpreter reports:</p> <pre><code>NameError: name 'name' is not defined </code></pre> <p>What is the equivalent of the short circuit evaluation assignment in python?</p>
python
[7]
202,123
202,124
How to find invoked element without passing this
<p>I have a Javascript function called many times from many pages. </p> <p>Inside this function I have to check the element which is invoked this function.</p> <p>I know a method to pass 'this' with the function call. I cannot use that method. Because I am working only on a single module. There are many other modules using this function. So if I change the function definition it will throw error for other modules/pages. </p> <p>Is there any other way to find the invoked element without passing 'this' or without changing the function definition. </p>
javascript
[3]
4,424,916
4,424,917
How to give a value of 1 to a textbox with a class
<p>I want to know if the code below removes all <code>input type='text'</code> values back to <code>""</code>:</p> <pre><code>var inp = document.getElementsByTagName('input'); for (var i = inp.length - 1; i &gt;= 0; i--) { if ('text' === inp[i].type) inp[i].value = ""; } </code></pre> <p>Then I want to know if I have an <code>input</code> which is <code>type='text'</code> but which <code>class</code> is <code>.num_questions</code>. How can I code that so that it looks for the class name and gives it a value of <code>"1"</code>? </p>
javascript
[3]
1,071,481
1,071,482
Android app version targeting
<p>If I target my android app for version 2.2, will my app work on further versions (2.3 / 3.0 / 3.1 / 3.2 / 4.0) phones without errors?</p>
android
[4]
3,061,430
3,061,431
ASP.NET Application Daytime Release
<p>We have an Intranet with about 300 users whom actively use it thoroughly during the day. We need to be able to release a precompiled version of the application during the day as users usually give us incorrect requirements and then need it that day. At the moment we release a non-precompiled version and let the web server compile individual code-behind pages. The problem is when we release things like App_Code, it hits the server big style.</p> <p>Is it possible to release DLL's during the day without screwing up someone's actions on a web page?</p>
asp.net
[9]
180,326
180,327
PHP redirect isn't working for some reason
<p>I'm trying to redirect this PHP page to another page as soon as I get successful update in the database .. but I get a warning from PHP and nothing happens .. Below is the code .. Where did I go wrong ?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/&gt; &lt;link rel="stylesheet" type="text/css" href="css/madscore.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;?php require('../database/connect.php'); ?&gt; &lt;?php $id = $_POST["id"]; $value = $_POST["score"]; database_connect(); $query = "update people set Score= Score +".$value." WHERE ID ='".$id."'"; $result = $connection-&gt;query($query); if($result) { ?&gt; &lt;?php @header("Location: http://www.europe-zone.com/"); exit(); } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
php
[2]
13,639
13,640
python: Is this a wrong way to remove an element from a dict?
<p>I use this way to remove an emelment from a dict:</p> <pre><code> d["ele"] = data ... d["ele"] = None </code></pre> <p>I think by this I can remove the reference on the original element so that the removed data can be freed, no memory leak.</p> <p>Is it the right way to do this?</p>
python
[7]
3,424,947
3,424,948
a question related to sqlite
<p>hi i have 1 update query in db and it is by use of sqlite</p> <pre><code>int success = SQLITE_STEP(insert_statement); </code></pre> <p>i get success value 21</p> <p>what s meaningof it?</p>
iphone
[8]
4,249,906
4,249,907
Popen remote commands
<p>Looking to run the command: ssh user@some_host "echo 'some_sql' | /usr/bin/mysql -u some_args"</p> <p>How would I do this using Popen?</p> <pre><code>p1 = sp.Popen(["ssh", "user@some_host", "echo \"%s\"" % sql], stdout=sp.PIPE) p2 = sp.Popen(["/usr/bin/mysql", "-u some_args"], stdin=p1.stdout, stdout=sp.PIPE) </code></pre> <p>Returns "OSError: [Errno 2] No such file or directory" since it's looking for /usr/bin/mysql on the local machine.</p>
python
[7]
3,162,123
3,162,124
Adding a Class to PHP Menus
<p>I have a small php website that has a menu that is included via include_once. I need an HTML class added to the current menu item for each page. </p> <p>So if a user clicks on a link and goes to that page the new page will load with the new menu item with class="current". How can I go about doing this?</p>
php
[2]
2,800,316
2,800,317
Is it possibile to write on a file put into an apk?
<p>Is it possibile to write on a file (for instance a .txt) put into an apk? When a user close my app, i'd like to write something on a file and then read it when my app is re-opened.</p>
android
[4]
655,971
655,972
Wrap the content of text view in java code in android
<p>I am dynamically creating layout and text view in android. If the text view content is large, how to wrap the content of text view dynamically? </p>
android
[4]
4,662,275
4,662,276
div background based on % in Jquery
<p>I have this in my html. I want to apply the background dynamically based on %.</p> <p>If I pass 30, the 30% of the div should be green. If it's 60, 60% of the div should be green</p> <pre><code> &lt;div id="progress_bar" class="meter-bg"&gt; by default white &lt;/div&gt; </code></pre> <p>by default its background white. But when I click the button.</p> <pre><code> &lt;input type="submit" value="30"/&gt; </code></pre> <p>It has to apply 30% of the green color to the progress_bar. How can I do that in Jquery</p> <p>Thanks.</p>
jquery
[5]
5,507,642
5,507,643
Is there a Math3d function to multiply a vertex array with a 4x4 matrix?
<p>I've looked at the source code and I haven't found anything, but I want to be shure, just in case. Is there any math3d function that takes a vertex array and multiplies it by a m3dmatrix44f? </p>
c++
[6]
69,205
69,206
Handwriting Recognition Application in Android
<p>I'm working on a application for handwriting recognition,ie, the user draws their character into the screen,and then that particular alphabet is generated automatically.</p> <p>The approach I'm taking(after a reading from <a href="http://drdobbs.com/security/184408923?pgno=2" rel="nofollow">here</a>),is to first train the system. While training, I store the Path(<a href="http://developer.android.com/reference/android/graphics/Path.html" rel="nofollow">android.graphics.Path</a>) values. Thanks to <a href="http://stackoverflow.com/questions/4919740/how-to-serialize-an-object-of-android-graphics-path">this</a>, <a href="http://stackoverflow.com/questions/8832931/can-i-serialize-the-paths-drawn-on-canvas-for-redrawing-the-paths-on-relaunch-of">this</a> and <a href="http://stackoverflow.com/questions/1243181/how-to-store-object-in-sqlite-database">this</a>, I know how to serialize and store the Path values to a database during the training phase.</p> <p>Now while comparing the values for comparison with what the user has drawn as a character, I can increase the accuracy by calculating the centroid and the number of strokes of every character,to differentiate between cases like <code>b</code> and <code>d</code>.</p> <p>The problem I'm facing is :</p> <p><img src="http://i.stack.imgur.com/jPori.jpg" alt="enter image description here"></p> <p>The three a's written on the screen are all different, and will all generate a different Path value. How do I compare such characters?</p> <p>Now,I know there are many such questions on SO regarding handwriting recognition. But since I have already taken up an approach, I don't think those questions would be relevant to me. But if anyone has better and easier solutions to handwriting recognition,can feel free to suggest. :-)</p>
android
[4]
148,676
148,677
Anyway of getting am/pm from time?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2605470/displaying-the-time-in-am-pm-format-in-android">Displaying the Time in AM/PM format in android</a> </p> </blockquote> <p>I can get the time and turn it into string using:</p> <pre><code>public static final String TIME_FORMAT = "h:mm a"; SimpleDateFormat dateTimeFormat = new SimpleDateFormat(TIME_FORMAT); String getstring = dateTimeFormat.format(when.gettime(); </code></pre> <p>but how do i get am/pm from it and turn it into string beccause i need it?</p>
android
[4]
5,310,762
5,310,763
PHP login cookies security
<p>In most of past questions on SO about security in 'Remember me' feature in login systems, <a href="http://fishbowl.pastiche.org/2004/01/19/persistent_login_cookie_best_practice/" rel="nofollow">Persistent Login Cookie Best Practice</a> is suggested.</p> <p>If I understand correctly, this approach goes like this:</p> <ol> <li><p>If user checks to remember the password, the cookie consisting the username, followed by a separator character, and some large random number should be set. For example:</p> <p><code>$_COOKIE["login"]; ="adam:8794383bb07608636dab808df6c9e29c"</code></p></li> <li>store username and hash string in database.</li> <li>if both cookies exist, and are mapped to each other in db, the login is accepted.</li> <li>After authentication, remove the random number from cookie, generate a new number and store in cookie. (<strong>Do I need to update this newely generated hashed string in the database as well?</strong>)</li> <li>When user is logged out, current cookie number is also invalidated.(<strong>Should I remove username and the random string from the database?</strong>)</li> </ol> <p><strong>Is it all?</strong> </p> <p>As in my previous question, I was told that if someone can access the cookie, they can easily authenticate. So how does this approach solves that problem?</p> <p>Many thanks.</p>
php
[2]
3,825,901
3,825,902
TypeError: object not callable when making instance
<p>I've searched around other threads with similar questions, but I'm not finding the answer. Basically, I have a class:</p> <pre><code>import Android_Class class Android_Revision(object): def __init__(self): # dict for storing the classes in this revision # (format {name : classObject}): self.Classes = {} self.WorkingClass = Android_Class() self.RevisionNumber = '' def __call__(self): print "Called" def make_Class(self, name): newClass = Android_Class(name) self.Classes.update({name : newClass}) self.WorkingClass = newClass def set_Class(self, name): if not(self.Classes.has_key(name)): newClass = Android_Class(name) self.Classes.update({name : newClass}) self.WorkingClass = self.Classes.get(name) </code></pre> <p>I'm trying to make an instance of this class:</p> <pre><code>Revision = Android_Revision() </code></pre> <p>and that's when I'm getting the error. I'm confused because I have another situation where I'm doing almost the exact same thing, and it's working fine. I can't figure out what differences between the two would lead to this error. Thanks.</p>
python
[7]
1,936,344
1,936,345
Open setting area in IOS 5.1
<p>how can i open setting area of iphone in objective c iphone app in ios 5.1?</p> <p>In IOS 5.0, It's working fine but in IOS 5.1 It is not working.</p> <pre><code> [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&amp;path=Network"]]; </code></pre> <p>Please provide me a link of apple development center, which ensure me it is not working in IOS 5.1. </p>
iphone
[8]
4,555,559
4,555,560
PHP how to limit lines in a string?
<p>i have a variable like the following and i want a function to only keep the first 20 lines, so it will strips any additional \n lines more than 20.</p> <pre><code>&lt;?php $mytext="Line1 Line2 Line3 ....." keeptwentyline($mytext); ?&gt; </code></pre>
php
[2]
4,838,027
4,838,028
define a local and live environment path
<p>I'm using a form to upload files into a specific upload folder. Now, in my local development environment, the local folder is harcoded in a variable like this</p> <pre><code>$destination = 'c:/public_html/discography/artwork/'; </code></pre> <p>Once the script is completed and ready to be moved in the live environment, the upload folder will be</p> <pre><code>$destination = '/home/my_name/public_html/discography/artwork/'; </code></pre> <p>My question is the following: Right now, both variables are hard coded. How do i make it so depending on the environment, the correct path is selected?</p> <p>If possible, i'd like it to be in a define statement, so i can use it anywhere in my script:</p> <pre><code>define('UPLOAD_ARTWORK', ????); </code></pre> <p>local:</p> <pre><code>$destination = 'c:/public_html/discography/artwork/'; $move = move_uploaded_file($_FILES['artwork']['tmp_name'], $destination.$_FILES['artwork']['name']); </code></pre> <p>live: </p> <pre><code>$destination = '/home/my_name/public_html/discography/artwork/'; $move = move_uploaded_file($_FILES['artwork']['tmp_name'], $destination.$_FILES['artwork']['name']); </code></pre> <p>wishing for </p> <pre><code>define('UPLOAD_ARTWORK', ????); $move = move_uploaded_file($_FILES['artwork']['tmp_name'], UPLOAD_ARTWORK.$_FILES['artwork']['name']); </code></pre> <p>Thanks</p>
php
[2]
2,377,654
2,377,655
Open 2 windows javascript
<p>How do I use javascript to redirect the current page and also open another popup window! would that be possible? is there a risk? thank you</p> <p>Update: </p> <pre><code> I am trying now to: var myid= "&lt;xsl:value-of select="@ID" /&gt;" which works for document.location.href = http://... + myid but won't work for window.open=("http://... "+ myid) </code></pre> <p>Any idea what I am doing wrong. the is no value with windo.open </p>
javascript
[3]
2,591,961
2,591,962
How do we find the width of scroll bar?
<p>Do you know any cross-browser methods?</p>
javascript
[3]
5,175,371
5,175,372
what does .attr('name',$this.attr('name')) mean?
<p>Somebody posted me this code to me with a problem I had:</p> <pre><code> $('#txtWeight').each( function() { var $this = $(this); var $weightText = $("&lt;input type='text' class='txtWeightRow' maxlength='5' onkeypress='return isNumberKey(event)'/&gt;").attr('name',$this.attr('name')) .attr('value',$this.val()) $weight.append($weightText).append('%'); }); </code></pre> <p>What I want to know is what does <code>.attr('name',$this.attr('name'))</code>. Am I not going to be able to call my input to whatever name I want it to. Does this link the "name" with a previous "name"?</p> <p>Thanks</p>
jquery
[5]
5,372,761
5,372,762
Cannot set property 'innerHTML' of null
<p>In google chrome Console, the error showing is</p> <p><strong>Uncaught TypeError: Cannot set property 'innerHTML' of null</strong> </p> <pre><code>var description=["a","b","c","d","e"]; var count=1; document.getElementById("productdescription").innerHTML = description[count-1]; </code></pre> <p>I am calling this function on an onclick event to imagebutton</p>
javascript
[3]
3,737,104
3,737,105
What's the quickest way to output the list<String> as space seperated list
<pre><code>List&lt;String&gt; test </code></pre> <p>which contains several items,</p> <p>what would be the quickest way to output a string as "item1 item2 item3"?</p>
java
[1]
1,829,178
1,829,179
Jquery finding firrt element of specific class
<p>I am using jquery to find a first element having a class "error" applied to it using the below code</p> <pre><code>$('#mainDiv input.error:eq(0)') </code></pre> <p>But the above one working only for input elements only. How to make this one to work for both input and select elements?</p>
jquery
[5]
2,662,620
2,662,621
Android: strecthing background
<p>I want to have a gradient on my app background. The picture is only ten pixels wide and I would like it to repeat horizontally. Then I have the background set to the color where the gradient ends vertically. In CSS I could easily do this by this code:</p> <pre><code>background: url("bg.png") repeat-x #0f0f0f; </code></pre> <p>But I have no idea how to do this on android. I tried setting a bitmap but everytime I put it in the XML the app force closes on me and there doesn't seem to be "repeat-x" like option on it.</p> <p>So what would be the best way to handle this?</p>
android
[4]
1,463,484
1,463,485
Why doesn't JQuery's removeAttr always work?
<p>When trying to see why removeAttr doesn't always seem to work I tried. </p> <pre><code>$("div#mydiv").css('height','200px'); $("table").removeAttr("border"); $("#mydiv").removeAttr("height"); </code></pre> <p>The table borders attribute is removed OK but not the div height attribute. I need to use other suggested methods such as </p> <pre><code>$("#mydiv").css('height','auto') </code></pre> <p>to alter it but not actually remove it. </p> <p>I would be interested to know what makes removeAttr not work in this scenario? There is no other css anywhere. </p>
jquery
[5]
5,847,342
5,847,343
How should I set up configs in PHP that can be accessed in includes?
<p>I'm building a PHP application and I'm not quite sure how to store global configuration settings that can be truely accessed anywhere - it seems that content that <strong>is</strong> included cannot access other content included from the main, starting page. For example, if index.php includes foo.php and bar.php, bar.php don't have foo.php but index.php has both of them - the included files just can't refer to the other ones. Is this correct? </p> <p>If yes, how would I set up something like this up? </p> <p>index.php</p> <pre><code>&lt;?php include 'functions/load.php' echo getHeader(); ?&gt; </code></pre> <p>functions/load.php:</p> <pre><code>&lt;?php include_once 'config.php' include_once 'header.php' //loads the includes ?&gt; </code></pre> <p>functions/config.php:</p> <pre><code>&lt;?php //I want to store the site URL here. $siteURL = "http://127.0.0.1"; ?&gt; </code></pre> <p>functions/header.php:</p> <pre><code>&lt;?php function getHeader(){ return "Header for " . $siteURL; } ?&gt; </code></pre> <p>How can I set up an config file that can be then accessed anywhere, including inside other included files? Also, is including a file that lists the other includes good practice?</p>
php
[2]
1,618,718
1,618,719
URLConnection.getContentLength() returns -1
<p>I have a URL which, when I enter in browser, opens the image perfectly. But when I try the following code, I get getContentLength() as -1:</p> <pre><code>URL url = new URL(imageUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); // determine the image size and allocate a buffer int fileSize = connection.getContentLength(); </code></pre> <p>Please guide me what can be the reason behind this?</p>
android
[4]
380,725
380,726
Limited number of results in Google Search using Python
<p>I am trying to do a custom google search from python. I found the relevant code at <a href="https://developers.google.com/web-search/docs/#fonje" rel="nofollow">developer.google.com</a>.</p> <p>My Code:</p> <pre><code>url = ('https://ajax.googleapis.com/ajax/services/search/web' '?v=1.0&amp;q=teen%20wolf%20s02e01%20divxstage.eu&amp;userip=USERS-IP-ADDRESS') request = urllib2.Request(url, None, {'Referer': "http://www.my-ajax-site.com"}) response = urllib2.urlopen(request) results = simplejson.load(response) print results </code></pre> <p>As you can see I am querying for <code>Teen Wolf S02E01 divxstage.eu</code>. The above script returned a <a href="http://pastie.org/4027579" rel="nofollow">json response</a>. </p> <p>Now, when I simply search for <code>Teen Wolf S02E01 divxstage.eu</code> from my browser the first link that google gives me is the link of site <code>divxstage.eu</code> which is my required link.</p> <p>Now, if you closely look at the <code>json response</code> it doesn't contain the <code>divxstage.eu</code> link and the results are also limited.</p> <p>So, my question is why there is a <strong>difference in output</strong> of the above two approaches and how do I customize my query to get the required <code>divxstage.eu</code> link which is <code>www.divxstage.eu/video/6qihgxf1ejzx1</code>.</p>
python
[7]
4,596,388
4,596,389
How to exit a Windows Forms Application in C#
<p>I'm writing a Windows Forms Application in C# that uses only 1 form. When I want to exit and close the application, I put the code</p> <pre><code> private void Defeat() { MessageBox.Show("Goodbye"); this.Close(); } </code></pre> <p>Inside the class <code>Form1 : Form</code>, which is the form class that was automaticly created by Visual Studio. But when this code runs, I get the fallowing message:</p> <pre><code>An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll Additional information: A generic error occurred in GDI+. </code></pre> <p>A picture of the message:</p> <p><img src="http://i.stack.imgur.com/nBRpA.jpg" alt="Error message"></p> <p>What is the problem?</p> <p>How should I exit my application?</p>
c#
[0]
1,727,063
1,727,064
How to enforce EditText to start text in capital letter?
<p>I have an <code>EditText</code> and I need the text in it (when user types in) to be started with capital letter.</p>
android
[4]
4,415,639
4,415,640
Accessing variables and methods across threads
<p>I am using java to create an interface to connect to a database. Each time I want to make a call to the database I need to create new connections to the database, which would make calling the database say 10 times slow.</p> <p>To avoid having to create new connections each time I want to call the database I have a java thread running that holds all of the connection information. </p> <p>To write/read from the database I want to create a thread that uses the connection information stored in the thread that's already running, use it to execute specified read/write functions, and then exit.</p> <p>However I am having trouble accessing this information from the thread which is already running. What would be the best way to accomplish this?</p>
java
[1]
317,673
317,674
Splitting a large object into multiple smaller byte arrays
<p>I have a huge POJO (1G - 6G) that I want to split into multiple byte arrays of 100Kb each. My algo currently is as follows:</p> <ol> <li>serialize the large object to a large byte[] I.e. 1G object to 1G byte[]</li> <li>Split the large byte[] into smaller 100k byte[]</li> </ol> <p>However this creates a lot of memory pressure as I now have 1 object + 1 byte[] + some 100k byte[]</p> <p>Splitting a large file into multiple smaller byte arrays is relatively easy to do with the FileInputStream as follows</p> <pre><code>File file = new File("asd"); FileInputStream fis = new FileInputStream(file); BufferedInputStream bis = new BufferedInputStream(fis); byte[] buffer = new byte[1024*1024*10]; int n = -1; while((n = bis.read(buffer))!=-1) { bos.write(buffer,0,n): } </code></pre> <p>How can I achieve the same for regular POJO's? Is there a way I can read the object into 100K byte arrays iteratively rather than creating the large byte array and splitting it?</p>
java
[1]
2,516,509
2,516,510
IPhone picture gallery source code
<p>HI all can anyone please refer me, the iphone image gallery source code? Any link ,sample code will be great help.</p> <p>i am trying to show some 70 to 100 images as thumbnails , and on selecting any image, it should give a full view of that image,i am trying to accomplish, whatever is in iphone's picture gallery, i thought, there must any sample code available. suggestions are always appreciated</p> <p>regards</p>
iphone
[8]
54,112
54,113
Access by one client at a time
<p>My requirements are as follows.</p> <p>I have a web application developed in java.</p> <p>I have a link in the html page. When the first client clicks submit button in the html page the batch file should run.</p> <p>Meanwhile when the other client clicks the submit button he should get message that the page is busy.</p> <p>If the first client clicks release button then the other clients must be able to run the batch file.</p> <p>How can I do that?</p>
java
[1]
1,096,209
1,096,210
How to check whether a field has been declared or not?
<p>Here is my code:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt; JS Test &lt;/title&gt; &lt;script type="text/javascript" src="jquery-1.4.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; if(someObj != null || typeof someObj != 'undefined') { alert("Success."); } else { alert("Failed."); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; </code></pre> <p> </p> <p>Why it always return an error message-"someObj is not defined" to me? I want to put the codes to foot of page to check whether the someObj has been declared or not.</p>
javascript
[3]
4,333,608
4,333,609
Setting default APN
<p>I want set an default apn in android gingerbread. Any1 know the solution please try to help me.</p>
android
[4]
2,911,528
2,911,529
jquery ajax request cached
<p>when i request something via ajax if the input is the search the content seems to be cached? do i add a random number at the end of my query?</p> <p>/search?input=test</p> <p>to</p> <p>/search?input=test&amp;random=283928392</p> <p>i think this would solve my problem. right? how do i write this in javascript</p>
jquery
[5]
3,268,207
3,268,208
PHP encrypt password before storing it to database
<p>I found the following example on php.net to secure password before storing it. However, I don't quite understand line 3. Could someone explain this a little bit? Thanks! </p> <pre><code>1 &lt;?php 2 $password = crypt('mypassword'); // let the salt be automatically generated 3 if (crypt($user_input, $password) == $password) { 4 echo "Password verified!"; 5 } 6 ?&gt; </code></pre>
php
[2]
1,466,003
1,466,004
Android: automatic animation
<p>I have a Button that needs to be slide in from the bottom automatically after the activity starts for 5 seconds. How do I do that? There shouldn't be any user intervention (Should be done without click).</p> <p>Thanks</p>
android
[4]
4,092,443
4,092,444
C++ - Timezone conversion
<p>I've the following piece of code to find the difference between the UTC and local time zone. </p> <pre><code>struct tm *local_time, *gmt_time; time_t t = time(NULL); local_time = localtime(&amp;t); gmt_time = gmtime(&amp;t); int y = mktime(local_time); int x = mktime(gmt_time); tzone_diff = y - x; </code></pre> <p>This doesn't work. However if i move the statement gmt_time = gmtime(&amp;t) below int y = mktime(local_time); it works. That is the following piece of code works:</p> <pre><code>struct tm *local_time, *gmt_time; time_t t = time(NULL); local_time = localtime(&amp;t); int y = mktime(local_time); gmt_time = gmtime(&amp;t); int x = mktime(gmt_time); tzone_diff = y - x; </code></pre> <p>This seems wierd to me.. Any clues?</p>
c++
[6]
1,696,429
1,696,430
Python - print bold text
<p>How to print bold text in python?</p> <p>for example:</p> <pre><code>print "hello" </code></pre> <p>what's the code that enables the text "hello" to be displayed in bold?</p> <p>thanks.</p>
python
[7]
5,735,088
5,735,089
Drawing an image is completely out
<p>Hi I'm using this code below to let a user "draw" their signature on a UIView component on my app:</p> <pre><code> UIGraphicsBeginImageContext(signature.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, signature.frame.size.width, signature.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); CGContextFlush(UIGraphicsGetCurrentContext()); drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext() </code></pre> <p>The issue I am having is that the drawing is not only is the drawing not in line with the pointer when in use in the simulator, the image is going outside of the designated UIView compontent and is getting smaller/out of focus the more I draw, as you can see in this image: <img src="http://dl.dropbox.com/u/1545603/iphone-signature-issues.png" alt="alt text"></p> <p>And after a few lines, showing the boundaries of the exact are of where I can draw: <img src="http://dl.dropbox.com/u/1545603/iphone-signature-issues2.png" alt="alt text"></p> <p>Any ideas on what's happening here?</p> <p><code>lastPoint.y</code> is defined as: <code>lastPoint.y -= 20;</code></p> <p>Any ideas on what on earth is happening here?</p>
iphone
[8]
1,900,957
1,900,958
How can I add stringbuilder (semi colon delimited) values to arraylist in C#?
<p>I have a stringbuilder that will look like something close to this smith;rodgers;McCalne etc and I would like to add each value to an arraylist. Does anyone have any C# code to show this?</p> <p>many thanks</p>
c#
[0]
1,106,601
1,106,602
Non-Type parameters for templates
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/499106/what-does-template-unsigned-int-n-mean">What does template &lt;unsigned int N&gt; mean?</a> </p> </blockquote> <p>Hi ! Are non-type template parameters and constants same ? Do the following code work because template parameter cannot be modified ? If can be modified, the compiler should have thrown error while declaring array "a[T]". Is my understanding correct ?</p> <pre><code>template &lt; int T &gt; void foo() { int a[T] ; } int main( int argc, const char* argv[] ) { foo &lt;3&gt; () ; system("pause") ; return 0 ; } </code></pre>
c++
[6]
3,046,602
3,046,603
calculate the user's month of birth from prompt
<p>Made a start but I need a tad bit of help...</p> <p>I'm trying to take a string/answer from what someones given me via a prompt (question is: what month were you born?), taking the first three letters of the answer, converting that to lowercase, then checking with my variable called 'months', if it exists convert to the month as a number.</p> <p>e.g. If someone entered October, it would change from October to oct to 10 (if that makes sense), I would like to use the answer later in the code... anyway this what I've got so far.</p> <pre><code>var month=prompt("Please enter your month of birth"," "); var answer=(month.slice(0,3)); // found string needed var months = 'janfebmaraprmayjunjulaugsepoctnovdec'; </code></pre> <p>I know that I have to use toLowerCase( ) but don't know how to go about/express that..</p> <p>Thanks.</p>
javascript
[3]
803,197
803,198
How to get each Bar CGMutablePathRef in Bar chart created by using Core Plot?
<p>I found below method in existing framework. Can any one please suggest me how can i use this method</p> <p>-(CGMutablePathRef)newBarPathWithContext:(CGContextRef)context recordIndex:(NSUInteger)index</p> <p>Thanks in advance</p>
iphone
[8]
3,223,122
3,223,123
Javascript newbie : Array.isArray() query
<p>I have been reading that in Javascript :</p> <ul> <li><strong>Everything</strong> is an object (except primitives such as number,string, boolean, null &amp; undefined)</li> <li>Objects can be treated as associative <strong>arrays</strong>.</li> </ul> <p>From what I conclude, Array.isArray() should return true for everything (with primitive exceptions aforementioned). What wrong did I understand ?</p> <p>Thanks !</p>
javascript
[3]
3,037,102
3,037,103
Slow startup of second activity
<p>What should I look when my settings <code>Activity</code> is starting up really slow? Sometimes I get <code>ANR keyDispatch error</code> if it takes to long.</p> <p>Should also say that I am using <code>PreferenceActivity</code>. The absolute first time I go into settings the delay time is really slow (about 5-10 seconds), but otherwise it goes super smooth. This does appear when I'm reinstalling the application and start the settings for another first time (so it's a first time thing).</p> <p>Some code in my settings <code>PreferenceActivity</code>:</p> <pre><code>@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); pref = getPreferenceManager(); pref.setSharedPreferencesName(LiveWallpaper.PREFERENCES); addPreferencesFromResource(R.xml.live); pref.getSharedPreferences().registerOnSharedPreferenceChangeListener(this); pref.findPreference("Username").setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { // Stuff... return true; } } ); // And so on... </code></pre> <p>Basically, I want to find out where this error is located, the question is how? Can I see in LogCat WHAT it is that's causing the delay?</p> <p>Thanks for any answer!</p>
android
[4]
1,085,435
1,085,436
comments post time display concept
<p>I need to display comment post time like facebook .i'm using this code but i dont know how to give mysql database date in this function and display time...can any one help me..</p> <pre><code>function time_since($original) { $chunks = array( array(60 * 60 * 24 * 365 , 'year'), array(60 * 60 * 24 * 30 , 'month'), array(60 * 60 * 24 * 7, 'week'), array(60 * 60 * 24 , 'day'), array(60 * 60 , 'hour'), array(60 , 'minute'), ); $today = time(); /* Current unix time */ $since = $today - $original; // $j saves performing the count function each time around the loop for ($i = 0, $j = count($chunks); $i &lt; $j; $i++) { $seconds = $chunks[$i][0]; $name = $chunks[$i][1]; // finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { // DEBUG print "&lt;!-- It's $name --&gt;\n"; break; } } $print = ($count == 1) ? '1 '.$name : "$count {$name}s"; if ($i + 1 &lt; $j) { // now getting the second item $seconds2 = $chunks[$i + 1][0]; $name2 = $chunks[$i + 1][1]; // add second item if it's greater than 0 if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) { $print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s"; } } return $print; } </code></pre>
php
[2]
5,712,777
5,712,778
Grab the values from some url using curl concept
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/12615733/get-the-inner-text-using-curl-concept-in-php">Get the inner text using curl concept in php</a> </p> </blockquote> <p>code is like this so on .... </p> <pre><code> &lt;ul class="listings"&gt; &lt;li&gt; &lt;a href="../episode/a_bit_of_fry_and_laurie_s1_e1-106555.html"&gt; &lt;span class=""&gt;Episode 1&lt;/span&gt; &lt;span class="epnum"&gt;13/01/1989&lt;/span&gt; &lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>By means of curl concept i am grabbing the links at <strong>span</strong> Episode 1 13/01/1989 I have used like this </p> <pre><code>foreach($html-&gt;find('ul.listings li a span') as $e) $e-&gt;innertext; </code></pre> <p>But my values are getting like </p> <p><strong>Episode 1 Taste of Tokyo08/01/2002</strong>,I want only this <strong>Episode 1 Taste of Tokyo</strong></p>
php
[2]
2,763,172
2,763,173
Collections.addAll, Queue<Integer> and int[]
<p>The following code doesn't work though it seems quite correct:</p> <pre><code>import java.util.*; public class Jaba { public static void main(String args[]) { Random rand = new Random(); int[] array = new int[10]; for (int i = 0; i &lt; array.length; ++i) { array[i] = rand.nextInt(30); } Queue&lt;Integer&gt; que = new PriorityQueue&lt;Integer&gt;(); Collections.addAll(que, Arrays.asList(array)); } } </code></pre> <p>What should be fixed?</p>
java
[1]
2,669,634
2,669,635
Javascript arrays of Objects; Subtract one from another
<p>Put simply, I want to subtract one array from another.</p> <p>The arrays are arrays of objects. I understand I can cycle through one array and on each item, comparing values in the other array, but that just seems a little messy.</p> <p>Thanks for the help, hopefully this question isnt too basic, I have tried googling it with no luck :(</p> <p>EDIT:</p> <p>The Objects in the Arrays I wish to remove will have identical values but are NOT the same object (thanks @patrick dw). I am looking to completely remove the subset from the initial array.</p>
javascript
[3]
2,611,298
2,611,299
Memmory Referene for a HashTable
<p>I have a small question regarding a Hash Table. Suppose i have a String as a key and a complex object as a value stored in a Hash Table. </p> <p>Now i use "get" to obtain the object from the same Hash Table. Now if the variable that i stored the reference of the object that i got from the Hash Table is set to null, this would have no affect on the memory of the object in the Hash Table. How can i destroy the object in the Hash Table?</p> <p>One way might be to put null as the value for my given key ? Is there another other more elegant way ? </p>
java
[1]
3,312,148
3,312,149
How to determine what is the super class or an interface of an object
<p>say one of my object implements X interface but is returning false when checking with 'instanceof'. How to determine what is the super class or an interface of an object. I am looking for something like </p> <p>for example:</p> <pre><code>object.getSuperClassORInterface(); </code></pre>
java
[1]
5,314,672
5,314,673
to display username on all aspx pages
<p>How to Dispaly the username on all aspx pages....?</p> <p>Can any one help me in this context.....</p> <p>am thinking that by using "session object" we can able to do this...bt am not sure</p> <p>Can any send the code or links</p>
asp.net
[9]
4,152,537
4,152,538
how keep the radio button position at selected one when changes from portrait to landscape
<p>how andrid radio button code but when changes from portait to landscape selected possition appear plz help me any one</p>
android
[4]
3,028,074
3,028,075
Returning a String from a public String (...) class
<p>here is the code</p> <pre><code>import java.io.*; import java.lang.*; import java.util.*; public class createfile { private Formatter x; Scanner keyboard = new Scanner(System.in); String s1,s2,s3,s4,s5,s6; String aa,bb,cc,dd,ee,ff; public void openFile() { try { x = new Formatter("password.txt"); }catch(Exception e) { System.out.println("\nError"); } } public void add(String s1,String s2,String s3,String s4,String s5,String s6) { Bugatti v = new Bugatti(); fw m = new fw(); fw2 s = new fw2(); fw3 EB = new fw3(); fw4 e = new fw4(); fw5 r = new fw5(); x.format("%s%s%s%s%s%s",aa,bb,cc,dd,ee,ff); } public void close() { x.close(); } } </code></pre> <p>Ok so in a another file i have returned aa bb cc dd ee ff and now x.format is not seeing that!!! but i have in fact returned it in the classes defined as Bugatti and fw,2,3,4,5. now how is't the x.format looking at the return. i know i am doing something wrong as i am a noob at this so please teach me how i can fix this!! thanks </p>
java
[1]
4,311,569
4,311,570
Creating a set of sub-sets of size K from a given interval- using Set In Java
<p>I'd love your help with this following problem:</p> <p>I want to write in Java a method that will gets three values: first, last and K, so and creates all the sub-sets of size L of numbers within the bounded interval [first,last],</p> <p>For example: If first=1, last=3 and K=2, so the result will be {1,2},{1,3},{2,3}.</p> <p>Ok, So I decided that the result value of the function will be <code>Set&lt;Set&lt;Integer&gt;&gt;</code> , But I'm not sure of how exactly I need to do that, What is the algorithm and the right way to write it.</p> <pre><code>public static Set&lt;Set&lt;Integer&gt;&gt; generateKsubsets( int first, int last, int K){ Set&lt;Set&lt;Integer&gt;&gt; result = new HashSet&lt;Set&lt;Integer&gt;&gt;(); </code></pre> <p>question 1: Is this the right Implemention of set to use in this case? To be honest, I'm not sure why do I use it here. Can I use here HasgTree? Is there any difference between theme in this case?</p> <pre><code>If(K==0) { </code></pre> <p>question 2: So here I would Like to return an empty set of the type that I defined, How should I do that?Can I add an empty set into the result set? </p> <pre><code>return result; } </code></pre> <p>And now the main question(3): I can't understand how my algorithm should work and how should I write it using this set.</p> <p>Thank you for the help.</p>
java
[1]
1,598,994
1,598,995
android don't restart thread when orientation changes
<p>my apps was based on this code <a href="http://www.41post.com/4588/programming/android-coding-a-loading-screen-part-1" rel="nofollow">http://www.41post.com/4588/programming/android-coding-a-loading-screen-part-1</a> .on the doInBackground my app will connect to the internet and download some data and populate the database and it will usually take some time to complete. the problem is when the orientation changes, the doInBackground function is restarted and it will cause problems.</p> <p>I referred <a href="http://developer.android.com/guide/topics/resources/runtime-changes.html" rel="nofollow">http://developer.android.com/guide/topics/resources/runtime-changes.html</a> and it says to do something like </p> <pre><code>@Override public Object onRetainNonConfigurationInstance() { final MyDataObject data = collectMyLoadedData(); return data; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final MyDataObject data = (MyDataObject) getLastNonConfigurationInstance(); if (data == null) { data = loadMyData(); } ... } </code></pre> <p>but on my apps, I don't know what should I put under the onRetainNonConfigurationInstance() because as you can see from the codes at <a href="http://www.41post.com/4588/programming/android-coding-a-loading-screen-part-1" rel="nofollow">http://www.41post.com/4588/programming/android-coding-a-loading-screen-part-1</a> I called a class instead of functions..</p>
android
[4]
599,870
599,871
How can I assign the contents of a form text field?
<p>How can I assign the contents of a form text field called "username" which is in the first form in a document to a variable called "thename"</p>
javascript
[3]
1,335,271
1,335,272
Why you can create class self intance in class's main method
<p>Why you can do this in C#?</p> <pre><code>class Test { static void Main() { Test test = new Test(); } } </code></pre>
c#
[0]
4,548,886
4,548,887
select tag in php and get href
<p>i want <strong>get all link in page by class "page1" in php</strong>. the same code in jquery </p> <pre><code>$("a#page1").echo(function() { }); </code></pre> <p>can do that in php?</p> <pre><code>$pattern = '`.*?((http|ftp)://[\w#$&amp;+,\/:;=?@%.-]+)[^\w#$&amp;+,\/:;=?@%.-]*?`i'; preg_match_all($pattern,$page_g,$matches); </code></pre> <p>this code get all href in the $page_g but its not work for class="page1". <strong>i want only all href in $page_g by class="page1"</strong> can help me for optimize reqular ex or other way? for example</p> <pre><code>$page_g="&lt;a href="/?s=cache:16001429:office+s01e02" title="" class="big"&gt;the &lt;strong&gt;office&lt;/strong&gt; us s01 05 xvid mu&lt;/a&gt; &lt;a href="asd.com" class="a"&gt;asd&lt;/a&gt;"; </code></pre> <p>i want return only /?s=cache:16001429:office+s01e02 tnx</p>
php
[2]
5,128,341
5,128,342
Why different behaviors between running Python module as an executable vs. Python [filename]
<p>So, I created a simple python module, test.py</p> <pre><code>import commands def main(): cmd = 'ls -l' (status, output) = commands.getstatusoutput(cmd) print status, output if __name__ == '__main__': main() </code></pre> <p>When I ran it using "Python test.py", I got the result that I expected. But when I ran it as an executable (yes, it has the 'x' permission), the program didn't respond at all and I had to Ctrl+C to quit it. Why is that? Shouldn't both ways give the same result?</p>
python
[7]
3,172,106
3,172,107
FragmentTransaction: ReplaceFragment
<p>I'm making a simple application to understand Fragments in android. Everything seems simple, except one i.e. I added multiple fragments dynamcially in a LeniarLayout. It worked fine, but now when <strong>I try to call replace on that container layout with some other fragment , it doesn't removes all the previously added fragments</strong>. Why such kind of behaviour ?</p> <p>Android api says "<em>Replace an existing fragment that was added to a container. This is essentially the same as calling remove(Fragment) for all currently added fragments that were added with the same containerViewId and then add(int, Fragment, String) with the same arguments given here</em>."</p> <p>Please guide me.</p>
android
[4]
104,762
104,763
how to redirect in other page when browser close event called
<p>I want to redirect in another page when browser is closed. My code is following:</p> <pre><code>&lt;script language="Javascript"&gt; var needToConfirm = true; window.onbeforeunload = confirmExit; function confirmExit(){ if (needToConfirm){ my_window = window.open ("1.html","mywindow1","status=1,width=350,height=150"); return "You have attempted to leave this page. If you have made any changes " +"to the fields without clicking the Save button, your changes will be " +"lost. Are you sure you want to exit this page?"; } } </code></pre> <p>But when I am clicking on close button of browser, I am seeing an <strong>system confirmation message</strong> and I am also not getting pop up page opening in mozilla. How will i resolve this problem?</p> <p>Thanks</p>
javascript
[3]
4,306,445
4,306,446
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,260,327
3,260,328
How to use a CSS class on all table elements within an application
<p>I've realised that I'm going to need to use a css class on all tables within my application.</p> <pre><code> &lt;table id="tblSearch" class="eFoo-text" </code></pre> <p>The problem is that I've got lots of pages, which contain lots of user controls.</p> <p>Luckly they all inherit from a single master page. Is there some way to say "use this class on all tables" somewhere in the master page?? </p>
asp.net
[9]
98,157
98,158
jQuery: Button enable is not working
<p>My jsfiddle is here- <a href="http://jsfiddle.net/hhimanshu/HVRLA/" rel="nofollow">http://jsfiddle.net/hhimanshu/HVRLA/</a></p> <p><strong>Need</strong><br> - As soon as text is entered the "create" button should enable<br> - if there is no text(text length = 0), "create" button should be disabled again </p> <p><strong>UPDATE</strong></p> <p>The proposed solution works for the solution, but it doesn't work with the I have the form in dropdown. Here is the fiddle - <a href="http://jsfiddle.net/hhimanshu/ukYek/" rel="nofollow">http://jsfiddle.net/hhimanshu/ukYek/</a></p>
jquery
[5]
781,024
781,025
How can i create a webservice which is checking table for some periodically in database in asp.net?
<p>I wanted to checking my database table for periodically.So how can i create a webservice and how can i configure it.</p>
asp.net
[9]
3,939,968
3,939,969
Using $this within $.ajax inside a function of success
<p>When I use the line below, $(this) inside my jQuery function (example below) it works great.</p> <pre><code>$(this).closest('.item').children('h3').children('a').text('UPDATED'); </code></pre> <p>However, inside the same function I try to then move it within a function of success: area of $.ajax and it no longer works. I've checked that the success function works with an alert.</p> <p>Is there a way to preserve the scope of $(this) inside $.ajax?</p> <p>Thanks in advance for any suggestions.</p> <p>Problem area:</p> <pre><code>success : function(msg){ $(this).closest('.item').children('h3').children('a').text('UPDATED'); }, </code></pre>
jquery
[5]
717,036
717,037
avoid hard coding path in ReadAllText
<p>My exact file path is as follows. This .txt file is not supposed to be deployed to bin/debug</p> <pre><code>string str = File.ReadAllText(@"C:\development\slnfolder\projfolder\myfile.txt"); </code></pre> <p>How can I write the code so that I do not have to hard code full path to get to the file </p> <p>I am trying to avoid hard coding path in the above line of code as follows:</p> <pre><code>string file = @"myfile.txt"; string str = Path.GetFullPath(file); </code></pre> <p>but the str ends up being as follows and is not able to find the file.</p> <blockquote> <p>C:\development\slnfolder\projfolder\bin\debug\myfile.txt</p> </blockquote>
c#
[0]
4,142,693
4,142,694
Modal Dialog Box working with Mozilla but Not working with Chrome
<p>Hi All I am trying to use modal dialog box in my code. like</p> <p>window.showModalDialog('pageurl');</p> <p>Ideally when a modal dialog box is open one should not be able to go to parent window until it is closed.</p> <p>it is working fine with Mozilla. But in Chrome the one can take control to parent window even if it is open.</p> <p>Can anyone tell why the problem is occuring? And please help me solving this problem. I t is necessary for me to show same type of modal dialog box in Chrome.</p>
javascript
[3]
5,890,579
5,890,580
How can i find out if my app is installed on SD card
<p>I would like something do something like:</p> <pre><code>val cacheDir = if (installedOnSD) { getContext.getExternalCacheDir } else { getContext.getCacheDir } </code></pre> <p>and I am a bit at a loss for the <strong>installedOnSD</strong> part. Can anybody point me to the right direction?</p> <p>PS: Pseudo-Code sample in Scala, just for the fun of it.</p>
android
[4]
1,226,492
1,226,493
Opposite of array_intersect
<p>I'm looking for the opposite of the function <code>array_intersect</code>, basically a function that returns the element that are <strong>not</strong> present in <strong>each</strong> of the provided arrays. </p> <p>Example:</p> <pre><code>$a1 = array(1, 2, 3); $a2 = array(2, 3, 4); $result = array(1, 4); </code></pre> <p>I know how to do it programmatically (I just have two array so <code>array_merge(array_diff($a1, $a2), array_diff($a2, $a1))</code> would do the job), but I'd like to know whether there's a built-in function that I can't find.</p> <p>Thanks.</p>
php
[2]
4,250,667
4,250,668
Combining multiple conditions into one in Javascript
<p>How can i shorten this code? I want to return all values except "abc" or "xyz" or "pqr"</p> <pre><code>return this.value != "abc" &amp;&amp; this.value != "xyz" &amp;&amp; this.value != "pqr"; </code></pre>
javascript
[3]