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,911,145
4,911,146
Why to scroll webpage to top, i need to scroll the $("html")
<p>i am referencing the code from <a href="http://snipplr.com/view/8782/jquery-animated-scroll-to-top/" rel="nofollow">snipplr</a></p> <pre><code>$('html, body').animate({scrollTop:0}, 'slow'); </code></pre> <p>i found out actually i need to use <code>$('html')</code>, <code>$('body')</code> does not work, <code>$('html, body')</code> seems redundant? </p>
jquery
[5]
1,363,320
1,363,321
Opening email attachments in Android
<p>I try to open a specific email attachment type with my activity, the attachment itself is a plain text windows style ini file with the extension *.os. In the email this file is attached as "application/octet-stream". I tried the following intent-filter to catch the attachment with my activity:</p> <pre><code> &lt;intent-filter&gt; &lt;action android:name="android.intent.action.VIEW"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;category android:name="android.intent.category.BROWSABLE"/&gt; &lt;data android:scheme="http" android:host="*" android:pathPattern=".*\\.os"/&gt; &lt;data android:scheme="https" android:host="*" android:pathPattern=".*\\.os"/&gt; &lt;data android:scheme="content" android:host="*" android:pathPattern=".*\\.os"/&gt; &lt;data android:scheme="file" android:host="*" android:pathPattern=".*\\.os"/&gt; &lt;/intent-filter&gt; </code></pre> <p>The Email app is fetching the attachment but is then telling me "The attachment cannot be displayed". What can I do? How can I debug this?</p>
android
[4]
3,161,074
3,161,075
Application spy for android
<p>Can any one help me for writing an application spy for android..</p> <p>I need to monitor if any application is accessing the sim contacts or phone contacts.</p> <p>thank you..</p>
android
[4]
914,853
914,854
Digital Stop Watch
<p>Hii,</p> <p>I have an input time in millisecounds. I want to include a digital stop watch in my application.i.e The time will dynamically change like a digital clock in every seconds. </p>
javascript
[3]
3,264,180
3,264,181
Field-like events and anonymous delegates
<p>When name of a field-like event <code>SomeNews</code> is used inside a class that declares this event, this name doesn't refer to the event itself, but to the anonymous private delegate <code>D</code> created by compiler, and for that reason <code>D</code> can be invoked indirectly ( inside <code>MyClass</code> ) via <code>SomeNews();</code></p> <pre><code>class MyClass { public event MyDelegate SomeNews; ... } </code></pre> <p>But if instead <code>MyClass</code> declares an event <code>SomeNews</code> by also specifying <code>add</code> and <code>remove</code> accessors:</p> <pre><code>class MyClass { private delegate MyDelegate _someNews; public event MyDelegate SomeNews { add { _someNews += value; } remove { _ someNews -= value; } } ... } </code></pre> <p>does then even inside <code>MyClass</code> the name <code>SomeNews</code> refer to the event itself and not to the underlying delegate <code>_someNews</code>? I'm assuming this since trying to invoke <code>_someNews</code> delegate via <code>SomeNews()</code> will cause a compile-time error saying "<em>SomeNews event can only appear on the left hand side of += or -=</em>" </p> <p>thanx</p>
c#
[0]
1,527,022
1,527,023
Convert string to Python class object?
<p>Given a string as user input to a python function, I'd like to get a class object out of it if there's a class with that name in the currently defined namespace. Essentially, I want the implementation for a function which will produce this kind of result:</p> <pre><code>class Foo: pass str_to_class("Foo") ==&gt; &lt;class __main__.Foo at 0x69ba0&gt; </code></pre> <p>Is this possible?</p>
python
[7]
4,612,862
4,612,863
JQuery : Count children that is checked in a <li> tag
<p>I have a tree view using html tags, when the "tvcheckbox attrParent" is checked, how can I count all its children "tvcheckbox attr" which where checked using JQuery.</p> <pre><code> &lt;li class="others"&gt;&lt;input type="checkbox" value="ALPHABETS" class="tvcheckbox attrParent"&gt;ALPHABETS &lt;ul&gt; &lt;li&gt;&lt;input type="checkbox" class="tvcheckbox attr" value="A"&gt;A&lt;/li&gt; &lt;li&gt;&lt;input type="checkbox" class="tvcheckbox attr" value="B"&gt;B&lt;/li&gt; &lt;li&gt;&lt;input type="checkbox" class="tvcheckbox attr" value="C"&gt;C&lt;/li&gt; &lt;li&gt;&lt;input type="checkbox" class="tvcheckbox attr" value="D"&gt;D&lt;/li&gt; &lt;li&gt;&lt;input type="checkbox" class="tvcheckbox attr" value="E"&gt;E&lt;/li&gt; &lt;li&gt;&lt;input type="checkbox" class="tvcheckbox attr" value="F"&gt;F&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; </code></pre> <p>I tried </p> <pre><code> `$('input.tvcheckbox.attrParent:checked').each(function(){ var len = $(this).parent().children(".checked").length; });` </code></pre> <p>but is not successful. Can anyone help? Thank you in advance. </p>
jquery
[5]
243,451
243,452
Python script problems
<p>So this is a script that I am coding for my buddies companies customer support. Basically, what it does is call using the IP phones that are in the script, it works, but with problems. Here is the code:</p> <pre><code>import urllib, urllib2, sys num = sys.argv[1] print 'Calling' phones = [ 'http://phone1/index.htm', 'http://phone2/index.htm', 'https://phone3/index.htm', 'https://phone4/index.htm', 'https://phone5/index.htm' ] data = urllib.urlencode({"NUMBER":num, "DIAL":"Dial", "active_line":1}) while 1: for phone in phones: try: urllib2.urlopen(phone,data) # make call urllib2.urlopen(phone+"?dialeddel=0") # clear logs except: pass </code></pre> <p>The first problem is that it only calls using phone one... Right now it is setup to keep calling over and over, for debugging purposes, and I seem to only be getting calls from phone one... The second problem is that the script will not terminate. ctrl+c does not work... The only way to terminate it (that I know of) is to end the ssh session. Now, I am new to python so both of these are probably just stupid mistakes so hopefully someone can help. Thanks!</p>
python
[7]
4,289,385
4,289,386
String replace in Android
<p>To try string replace in Android, I wrote a small snippet:</p> <pre><code>public class cs{ public static void main(String[] args){ String a,c; int b; b=1; c="12345"; a="12345,54321"; a.replace(c,String.valueOf(b)); System.out.println(a); } } </code></pre> <p><b>Expected Output:</b> 12345,54321 changes to 1,54321</p> <p><b>Actual Output:</b> 12345,54321 。Please help。</p>
android
[4]
792,693
792,694
Javascript window.onbeforeunload not work without Alert
<p>Hi I use javascript to save information after page going to be close or navigate to another page.My problem is when I call webservice in window.onbeforeunload it is not going to fire and I dont get result. But If I put alert at the end of function webservice going to fire and I get result.I don't want to use alert at all .Is there any way.my code is as follows:</p> <pre><code> window.onbeforeunload = InitializeService; function InitializeService() { if (window.XMLHttpRequest) { var url = "http://localhost:54329/WebServices/PageUnloadCall.asmx?op=Page_Unload"; myReq.onreadystatechange = checkStatus1; myReq.open("GET", url, true); // true indicates asynchronous request myReq.send(); // alert("Your Call Record Has Been Saved!"); } } function checkStatus1() { if (myReq.readyState == 4) // Completed operation { myReq.open("POST", "http://localhost:54329/WebServices/PageUnloadCall.asmx/Page_Unload", false); myReq.send(); } } </code></pre> <p>As you can see in function InitializeService ,I dont want to use Alert there but if I dont I dont get result.</p>
javascript
[3]
983,023
983,024
when to use and when not to use the DP and PX measures Android
<p>I am trying to understand the "Best practices for Screen Independence". Can someone explain me when to use and when not to use the DP and PX measures ? (of course it is in documentation but my understanding is little vague from it..)</p> <p>Thanks</p>
android
[4]
944,545
944,546
java Delete a Binary Tree node containing two children
<p>This is the last case where the node to be deleted has two children. I cant figure out what I am doing wrong . Please help.</p> <pre><code> //BTNode has two children else if (u.getLeft() != null &amp;&amp; u.getRight() != null){ //if node to delete is root BTNode&lt;MyEntry&lt;K,V&gt;&gt; pred = u.getRight(); while (pred.getLeft().element() != null){ pred = pred.getLeft(); } BTNode&lt;MyEntry&lt;K,V&gt;&gt; predParent = pred.getParent(); if (!hasRightChild(pred)){ predParent.setLeft(new BTNode&lt;MyEntry&lt;K,V&gt;&gt;(null,predParent,null,null));} if (hasRightChild(pred)){ BTNode&lt;MyEntry&lt;K,V&gt;&gt; predChild = pred.getRight(); predParent.setLeft(predChild); predChild.setParent(predParent); } return returnValue; </code></pre> <p>ok so modify it like this ?? </p> <pre><code> u.setElement(succ.element()); BTNode&lt;MyEntry&lt;K,V&gt;&gt; succParent = succ.getParent(); if (!hasLeftChild(succ)){ succParent.setRight(new BTNode&lt;MyEntry&lt;K,V&gt;&gt;(null,succParent,null,null));} if (hasLeftChild(succ)){ BTNode&lt;MyEntry&lt;K,V&gt;&gt; predChild = succ.getLeft(); succParent.setRight(predChild); predChild.setParent(succParent); } return returnValue; </code></pre>
java
[1]
3,210,895
3,210,896
What is the best practice for timezone conversions?
<p>I want to give users the option to change their timezone and display their data in that timezone. I'm currently storing a unix timestamp and would like to know what the best way to handle this conversion would be.</p> <hr> <p>I am storing my timestamp in unix format. My concern is what function can I use to do the conversion on the presentation layer?</p>
php
[2]
1,682,524
1,682,525
Does it make any sense to develop for iPhone OS 3.0 instead of 3.2?
<p>When it comes to backwards-compatibility, I want to stick to iPhone OS 3.0 so also some of the poor iPod Touch users who aren't rich enough for iPhones use my apps. But iPhone OS 3.2 has some pretty cool features that would be nice to have. </p> <p>Problematic thing: Since it's just a minor upgrade, I can imagine most iPod Touch users who decided to upgrade to 3.0 probably never upgraded to 3.2. I'm not sure if Apple actually asked them to pay like 10 bucks for going from 3.0 to 3.2. However, if Apple did ask them for money, I'm sure like 90% of all iPod Touch users didn't upgrade. </p> <p>So the big question is: IF you decide to go with iPhone OS 3.0, is it a stupid idea to stick to 3.2 just because of a few more features? Will this effectively kill half of your iPod Touch userbase?</p>
iphone
[8]
2,027,666
2,027,667
Why it gives wrong output i.e 2.... But i
<pre><code>// A program to allocate the memory to integer from using of "free()" function. #include &lt;iostream.h&gt; void main() { int *integer; integer=new int[5]; cout &lt;&lt; sizeof(integer); } </code></pre>
c++
[6]
1,207,998
1,207,999
Location awareness
<p>I have this javascript code which takes a list of locations and reorders the list items according to the users location. how can i change the code so that it only displays the locations within a vicinity of 1KM rather than just reordering the whole list. </p> <pre><code> &lt;script type="text/javascript"&gt; $(document).bind("mobileinit", function () { $.mobile.ajaxEnabled = false; }); &lt;/script&gt; &lt;script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"&gt;&lt;/script&gt; &lt;script&gt; function findMe() { if (navigator.geolocation != undefined) { navigator.geolocation.watchPosition(onFound, onError); } } function onFound(pos) { var userLat = pos.coords.latitude; var userLong = pos.coords.longitude; $('ol li').each(function (index) { var locationLat = $(this).find('.lat').html(); var locationLong = $(this).find('.long').html(); var distance = getDistance(userLat, locationLat, userLong, locationLong); $(this).data("distance", distance); }) reOrder(); } function onError(pos) { alert("Something Went wrong"); } function reOrder() { $('ol li').sort(sortAlpha).appendTo('ol'); } function sortAlpha(a, b) { return $(a).data('distance') &gt; $(b).data('distance') ? 1 : -1; }; function getDistance(lat1, lat2, lon1, lon2) { var R = 6371; // km var d = Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)) * R; return d; }; &lt;/script&gt; &lt;style&gt; ol .long, ol .lat { display: none; } &lt;/style&gt; </code></pre>
javascript
[3]
3,123,746
3,123,747
Howto add onclick event to button in listview added by addFooterView?
<p>I'm using a listview with my own implementation of baseadapter. Before adding the main list items to the listview and setting the Adapter i add a footer, with addFooterView(), to the listview. The footer is a normal listview item with a custom view and two buttons.</p> <p>And here comes my problem:</p> <p>How can i add a onClick() event to this buttons? i tried it in the getView() method of my baseadapter but that does not work. :/</p> <p>I need these two buttons at the bottom of my listview as back and forward buttons, cause i don't want too much items at once in the listview.</p> <p>thx</p>
android
[4]
3,356,097
3,356,098
prevent javascript executing \n
<p>Is it possible to prevent javascript in executing \n from string.</p> <p>I have string which contains \n (i.e. "<code>ksqOOEe+sqQwexx12lMf31V\nLqW23ds</code>"). This is encrypted string and I have to handle it in Javascript. Problem is that JS break it into two rowns, than browser register Illegal operation. I don't want to escape it with other special characters because it is encrypted string and I have to use decryption process for data reconstruction in next steps.</p>
javascript
[3]
1,927,922
1,927,923
how to display different currencies symbols in android?
<p>i want to display different currencies symbols in combo box(Spinner). The currencies may me follows:</p> <pre><code>usa euro pounds </code></pre> <p>e.t.c</p> <p>i preferred to read these symbols from the xml. is there any code for the currencies symbols.</p> <p>how can i do it?</p> <p>thanks</p>
android
[4]
5,617,073
5,617,074
Optional `new` operator
<p>Reading through the jQuery documentation about the event object and its constructor <code>$.Event()</code> I see:</p> <blockquote> <p>The <code>new</code> operator is optional [when calling the constructor].</p> </blockquote> <p>That's cool! How did the jQuery people pull such a trick?</p>
jquery
[5]
489,176
489,177
passing paramters using ksoap2 to .net web service, always passes nulls (empty) values
<p>I am new to android applications,I am using Ksoap2 to access .Net webservice and The call is executed just fine without parameters. But with parameters I am getting Empty. I followed all the steps provided in sites. I tried everything possible but no luck so far. I hope someone can help, </p> <pre><code> private static final String SOAP_ACTION = "http://www.agilelearning.com/GetProvincelist1"; private static final String METHOD_NAME = "GetProvincelist1 "; private static final String NAMESPACE = "http://www.agilelearning.com" ; private static final String URL = "http://192.168.1.24/Service.asmx"; //Method executed when Province is selected private OnItemSelectedListener selectListener = new OnItemSelectedListener() { public void onItemSelected(AdapterView parent, View v, int position, long id) { try { ArrayList&lt;String&gt; districts=new ArrayList&lt;String&gt;(); int Provinceid=position+1;//parent.getItemAtPosition(position).toString(); SoapObject request1 = new SoapObject(NAMESPACE, METHOD_NAME1); request1.addProperty("Provincename","East Province"); SoapSerializationEnvelope envelope1 = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope1.dotNet = true; envelope1.setOutputSoapObject(request1); HttpTransportSE at = new HttpTransportSE(URL); at.debug = true; at.setXmlVersionTag("&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;"); at.call(SOAP_ACTION1, envelope1); SoapObject rs = (SoapObject)envelope1.getResponse(); int count=rs.getPropertyCount(); for(int i=0;i&lt;count;i++) { districts.add(rs.getProperty(i).toString()); } ArrayAdapter&lt;String&gt; aa; aa = new ArrayAdapter&lt;String&gt;(home1.this, android.R.layout.simple_spinner_item, districts); aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sd.setAdapter(aa); } catch(Exception ex) { MessageBox("No Districts found"); } } </code></pre>
android
[4]
4,501,132
4,501,133
Testing for null and something else on the same line of code
<p>I have a user object and I have a variable named userID.</p> <p>I would like to test 2 things:</p> <ul> <li>user == null</li> <li>user.UserID != userID</li> </ul> <p>The second test must be done only if user is not null otherwise I have a runtime error.</p> <p>I wonder if it is possible to test both on the same line, something like below:</p> <pre><code>return ((user == null) &amp;&amp; (user.UserID != userID)) </code></pre> <p>But coded like above doesn't work because when user is null I have a runtime error.</p> <p>Thanks.</p>
asp.net
[9]
865,380
865,381
how to change css rules in style using javascript when the style media is print?
<p>How do you change the css rule of #div1 in the style type="text/css" media="print" using javascript? I want to change the display to none on the click event of a checkbox/button.</p> <pre><code>&lt;style type="text/css" media="screen"&gt; #div1{ display:visible; } &lt;/style &lt;style type="text/css" media="print"&gt; #div1{ display:visible; } &lt;/style </code></pre> <p>Thank You in advance</p>
javascript
[3]
3,480,604
3,480,605
What is connection pooling?
<p>Can somebody please explain connection pooling to me please?</p> <p>I am just not understanding it by searching the internet.</p>
asp.net
[9]
4,327,006
4,327,007
How to submit form on webpage in PYTHON?
<p>I want to tick checkboxes, select radio buttons, write in text boxes and finally click on submit button to submit the form on a page. Programming in PYTHON only. How do i achieve this?</p>
python
[7]
467,412
467,413
how to send first initial request via Socket in CIFS in C#?
<p>HI,</p> <p>how to send first initial request via Socket in CIFS in C# ? I want to send first initial request and get a response from destination address in C#. I want to send CIFS request in form of CIFS format.</p> <p>Any code snippet is highly appreciated.</p> <p>Thanks in Advance.</p>
c#
[0]
6,000,419
6,000,420
Why am I getting null when trying to retrieve a value from a ContentValues object?
<p>I am getting a NullPointerException when trying to retrieve/insert values from a ContentValues object that I'm a passing to my database method. I have several columns in my db table and instead of passing all those as params to the method, I'm trying to simplify it a little bit.</p> <p>Here's a sample of the code:</p> <pre><code>public class MyActivity extends Activity { private Calendar calendar = Calendar.getInstance(); // other methods in here.... public void onClick( View v ) { int year = calendar.get( Calendar.YEAR ); int month = calendar.get( Calendar.MONTH ); int date = calendar.get( Calendar.DAY_OF_WEEK ); int weekOfYear = calendar.get( Calendar.WEEK_OF_YEAR ); ContentValues values = new ContentValues(); values.put( YEAR, year ); values.put( MONTH, month ); values.put( DATE, date ); values.put( WEEK_OF_YEAR, weekOfYear ); if( everythingIsGood ) { // the problem starts after this. mDb.addToDatabase( values ); } } </code></pre> <p>Here's the database method:</p> <pre><code>public class Database { // other methods.... public long addToDatabase( ContentValues values ) { // I'm getting a NullPointerException right here, trying to retrieve // a value from this ContentValues object int weekOfYear = values.getAsInteger( WEEK_OF_YEAR ); values.remove( WEEK_OF_YEAR ); // do other stuff long pId = this.getParentId( weekOfYear ); // And, if I take the above out, right here values.put( PARENT_ID, pId ); mDb.insert( table_name, null, values ); } } </code></pre> <p>So, am I not allowed to manipulate the ContentValues object? Is this bad practice, should I just pass all those variables to the method?</p> <p>Note: I know for a fact that the values are not null.</p> <p>Thanks in advance.</p>
android
[4]
2,329,512
2,329,513
how to create vector in c#
<p>I have a set of servers for which I need the names, but I only want those that are currently available so I need a dynamically sized array. What data structure can I use to store these.</p>
c#
[0]
3,134,100
3,134,101
php html decode string
<p>I have an array which returns various strings which I'm trying to html-decode. But I can't seem to find a function which will work on all the strings. For example, one of my strings looks like this:</p> <pre><code>"a detail of The School of Athens&lt;!-- this should link to an article about the famous artwork --&gt;, a fresco by Raphael" </code></pre> <p>While the other looks like this:</p> <pre><code>""Aristotle" by Francesco Hayez (1791–1882)" </code></pre> <p>I can either use <code>html_entity_decode</code> to get rid of the comment (<code>&lt;!--/--&gt;</code>) in the first string, or <code>htmlentities</code> in the second to change the <code>–</code> to a <code>-</code>, but I can't find anything that will change ALL my strings to regular text. Is there a function that can do this?</p> <p>TIA! </p>
php
[2]
1,973,120
1,973,121
Pass data as code
<p>I'm trying to interpret a formula given as input:</p> <pre><code>y= y argv[1][s] 5; </code></pre> <p>where <code>argv[1][s]</code> can be <code>+ - *</code> for example.<br> y= y+5;<br> y= y*5; </p> <p>I could use a check for specific values, but it's more interesting to find out why this doesn't work.</p> <blockquote> <p>error C2146: syntax error : missing ';' before identifier 'argv'</p> </blockquote> <p>I think what happens is that <code>+</code> is passed as <code>'+'</code> so no operation results. Is there a way to unquote this?</p>
c++
[6]
5,602,085
5,602,086
How handle an element of elements having same class name using jquery
<pre><code>&lt;div id="user" class="user"&gt;akhilreddy&lt;/div&gt; &lt;div id="user" class="user"&gt;subodh&lt;/div&gt; </code></pre> <p>I many of elements but am showing only two, when ever I click on div I want text inside that div to be diplayed in alert box.</p> <p>Thank you </p>
jquery
[5]
309,764
309,765
ashx method call - make reusable
<p>i have an ashx file that creates a binary csv file for me. i'd like to be able to pass it any generic list.</p> <p>i know i can put the list in session and then pick it up in the generic handler but will that acceptable under heavy loads?</p> <pre><code> byte[] csvData = Utility.ToCsv(",", DAL.GetProducts()); context.Response.OutputStream.Write(csvData, 0, csvData.Length); </code></pre> <p>it would be nice if i can run any query within the handler (instead of hard-coding DAL.GetProducts()). what are some ways to do this?</p>
c#
[0]
3,072,177
3,072,178
How to get all filenames inside a folder in assets folder in android?
<p>How to get all filenames inside a folder in my assets folder in android? Please help. Thanks in advance.</p>
android
[4]
1,150,073
1,150,074
jQuery - select parent by child class?
<p>How can I select the <code>&lt;tr&gt;</code> containing the child <code>&lt;div class="test"&gt;</code>, as below?</p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;!-- this tr is what I want to select --&gt; &lt;td&gt; &lt;div class="test"&gt; text &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
jquery
[5]
5,137,282
5,137,283
Good article on GDI+
<p>Actually, I have never before use GDI+, Can anybody suggest me some good articles on this. I am trying to create custom controls.</p>
c#
[0]
4,623,222
4,623,223
Is there another way to create an object with a classname returned by a method?
<p>I have this method : </p> <pre><code>public function getInstance() { $classname = $this-&gt;getFullyQualifiedClassName(); return new $classname(); } </code></pre> <p>Is there a way to write this without the <code>$classname</code> variable, which gets used only once?</p>
php
[2]
2,777,610
2,777,611
Always launch activity X after resume from background and new launch - Android
<p>I need to implement the following:</p> <p>When the app starts, activity A is shown (a login screen) that goes to activity B if login credentails are correct.</p> <p>Activity B is a dasbhoard, that can start several other activities C,D .. (and thus remains active, the user should be able to go back to B if he/she is at C or D).</p> <p>Now when the user presses the home button, and goes back to the app (ie. by pressing the home button for a long time), the app should show activity A again. It should not resume the activity (B,C,D) it was currently on.</p> <p>In other words, the app should 'close' when it goes to the background (by launching another app or pressing the home button). However, this seems not so trivial in Android.</p> <p>I have tried several strategies:</p> <ul> <li>use launchmode = singletask for activity A (app can still be resumed when long pressing home)</li> <li>track the activity stack to see if app is going to the background on onPause (detection does not work flawlessly) and if resumed from background clear activity stack and start activity A again</li> <li>use clearstack on Activity A and finishTaskOnTaskLaunch on all other activities </li> <li>use nohistory (no going back to activity B)</li> <li>use launchmode = singleinstance (actually dont want to go there)</li> </ul> <p>All seem to have their edge cases in which it doesnt work (ie. activity B is still resumed in some cases, activity B is closed when going back from activity C or D)</p> <p>Any ideas? Am I perhaps overlooking something?</p>
android
[4]
4,135,635
4,135,636
How to periodically poll some value using Java (Swing)?
<p>I am using swing based model.My form contains one Jbutton its called "polling(function name is getvalue())".I have a function name as "getvalue()".This function does retrieve values(this value will change after some span of time) and print it in console. I want code and idea about, that function will call automatically every 5 minutes ( or some span of time interval)and retrieve values and print it in console.I want code using timer concept .</p> <p>my button function is like</p> <p>private void ActionPerformed(java.awt.event.ActionEvent evt) {</p> <p>}</p> <p>where will write my Automatic polling code.</p>
java
[1]
1,352,661
1,352,662
In asp.net how to play Multiple swf files in single Object control
<p>In aspx pages i had a single object and plays the .swf file.but i need to change dynamically the object will change another swf file depends on Impressions.</p>
asp.net
[9]
4,236,132
4,236,133
iphone SDK: How can I get the current selected row for UIPicker?
<p>How can I get the current selected row for UIPicker?</p> <p>I want to use it to get at the associated string. Like this. The problem is I do not know how to get the row.</p> <pre><code>//need to get currently selected row NSString *strPeriodSelection = [arrayRecurChoices objectAtIndex:periodPicker.row???]; </code></pre> <p>Thanks in advance.</p>
iphone
[8]
2,737,870
2,737,871
Why am I getting the error "parameter pack 'F' must be at the end of the template parameter list"
<p>I have code that uses a variadic template and I'm trying to understand where to put the ellipsis. In the below code I put them, like the error says, at the <em>end</em> of the template parameter list. But I still get errors. What am I doing wrong?</p> <pre><code>template &lt;typename T&gt; struct S { void operator &lt;&lt; (const T &amp;) {} }; template &lt;template &lt;typename, typename...&gt; class ... F, typename T = int&gt; struct N : S&lt;F&lt;T&gt;&gt; ... {}; </code></pre> <blockquote> <p><code>prog.cpp:10:82: error: parameter pack 'F' must be at the end of the template parameter list</code></p> </blockquote>
c++
[6]
1,036,024
1,036,025
When should a music player gain and give up audio focus?
<p>I'm writing an Android music player, and is stuck on audio focus issue.</p> <p>It seems like audio focus mainly affects media button receiving, but after reading the document I have no idea about when to gain and give up focus.</p> <p>My music app will run in background, and need to detect play/pause button <strong>every time</strong>. That is, even when my app is not running, a user should be able to press headset's play button and start music.</p> <p>It seems I should never give up audio focus, so why should I implement it?</p> <p>Does anyone know practically how audio focus should be used? Thank you!</p>
android
[4]
313,407
313,408
jquery fadein addClass
<p>I am using jQuery to apply a class to an element on hover i.e. <code>addClass('active')</code></p> <p>The class adds a border and changes the background color but i would like to have these changes faded in as opposed to just on or off.</p> <p>Is this possible using jQuery i.e. to add a class and have the effects that the class adds to be faded in?</p>
jquery
[5]
2,410,310
2,410,311
Android: How to schedule?
<p>In my app I would like that a certain method of mine (call it toSched) will run at a given time in the future (I'm using <code>Timestamp</code> for knowing when).</p> <p>How can this be done, and is it possible to do it even if the phone is turned off (assume there is enough battery) ?</p> <p>*I know I should use <code>AlarmManager</code> but I'm not sure how </p>
android
[4]
2,484,654
2,484,655
SDL Alternative with multiple windows and multiple display devices
<p>I'm looking for an alternative to SDL that supports multiple windows on multiple display devices for OpenGL.</p> <p>Is there any mature library that provides this?</p> <p>I'm aware taht SDL 1.3 will support this but it seems that's a bit into the future.</p>
c++
[6]
640,904
640,905
Parent window resize?
<p>basically, I need to access the parent window of an iframe, this script is also loaded in the iframe window as well.. So basically I have this markup. </p> <p>BODY | IFRAME | BODY | SCRIPT</p> <pre><code>$(window.parent.document).resize(resizeModal); </code></pre> <p>So I need once inside the modal window, for the fundition "resizeModal()" to run once it's parent window is resized, but it doesn't work :( </p> <p>Any ideas? </p> <p>Kind regards, Shannon</p>
jquery
[5]
1,000,498
1,000,499
What is the best way to load heavy bitmap in the imageview?
<p>I as a new programmer, totally confused of the <code>OutOfMemoryException</code> whenever I use <code>BitmapFactory.decodeStream(is,option)</code> method which <code>returns</code> <code>Bitmap</code> object. As every application have its <code>virtual machine</code> budget, if it exceeds it throws <code>OutOfMemoryException</code> and application crashes as <code>bitmap</code> is heavy. So can anyone help me out for this. I have to set the image as on <code>ImageView</code> using <code>setImageBitmap(bitmap)</code> method. unless until m not able to make <code>Bitmap</code> reference how can i set it to <code>ImageView</code>? </p>
android
[4]
2,223,473
2,223,474
Calling fprintf from dynamic library (c++)
<p>I'm creating a windows DLL library that contains a logging class, the log function in that class simply calls fprintf like this for testing purposes:</p> <p>fprintf(stderr, "DEBUG: %s\n", "Hello"); </p> <p>Now this call works fine if i use it from any function in any file in my other project (that uses the library) but if i put it anywhere in my library with the logging class it simply wont print anything.<br> I can see it runs the function correctly (using a simple exit(0); to test). </p> <p>Now i'm still kinda new to the whole Library concept in c/c++ so there might be something i just don't understand, but otherwise i don't know why it doesn't work. </p> <p>I tried searching here and on google, but i couldn't find anyone else with the same exact problem.<br> I use VC++ 2010</p> <p>EDIT: I got the idea of passing the filepointer instead of just using stderr from the library, this causes an exception to be thrown however (the _tmpfname pointer of the file is NULL at the time of the throw, which im not sure is correct)</p>
c++
[6]
1,294,426
1,294,427
jquery get checked checkboxes
<p>i'm trying to get the list of checkboxes and the count that are checked. I have this:</p> <pre><code> var obj = $(this).closest('li').find(':checkbox'); var childCount=$(obj).size(); var checkedCount=$(obj).(':checked').length; </code></pre> <p>I get error on checkedCount</p> <p>??</p>
jquery
[5]
2,288,351
2,288,352
Is there any way to create a listener to accept the errors in the patternlock in gingerbread?
<p>Iam trying to create an app without editing the android os in such a way to notify my app whenever the user enters the patten wrong. is this possible. i was thinking about using a listener that listens to the log of the phone. i am not sure this will work though because iam quite a beginner in android. </p>
android
[4]
566,292
566,293
What's the difference between Number.somepropertyormethod and Number().somepropertyormethod?
<p>So the following works:</p> <pre><code>alert(Number().toString.call(1)); </code></pre> <p>But this does not work:</p> <pre><code>alert(Number.toString.call(1)); </code></pre> <p>Furthermore, the following works:</p> <pre><code>alert(Number.prototype.constructor(1)); </code></pre> <p>But this does not work:</p> <pre><code>alert(Number().prototype.constructor(1)); </code></pre> <p>Why do we need the parentheses following Number in the first example, and why must we omit the parentheses in the second example?</p>
javascript
[3]
826,444
826,445
C++ Assigning an int to a char - why does this work without at least a warning?
<p>Why does C++ (and probably C as well) allow me to assign and int to a char without at least giving me a warning?</p> <p>Is it okay to directly assign the value, like in </p> <pre><code>int i = 12; char c = i; </code></pre> <p>i.e. do an implicit conversion, or shall I use a <code>static_cast&lt;&gt;</code>?</p> <p><strong>EDIT</strong></p> <p>Btw, I'm using <code>gcc</code>.</p>
c++
[6]
3,033,585
3,033,586
Are external scripts in the head of an HTML document guaranteed to execute before scripts contained within the body?
<p>I'm trying to execute some inline javascript within an HTML page as early in page processing as possible that makes use of library functions in an external .js file. </p> <p>While I've always seen that putting library scripts in the head, and client scripts in the body just seems to work, I can't find documentation anywhere that says that external scripts included within the head of a document are guaranteed to run before script located within the body of a document (except on the w3schools site, but they don't count as a reputable reference)</p> <p>To illustrate, I'm wondering about the User-Agent behavior for HTML that looks like this:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript src="libraryModule.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; // is this guaranteed to run after the external script? // or is it possible this module that the external library // adds to the global namespace won't be there yet? var result = ModuleInExternalLibrary.DoLibraryThing(); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Is this documented anywhere? I can't find anything in the W3C spec or any good post that sums up the behavior in this area of all the major browsers. Please provide a link.</p> <p>Am I stuck having to wait until the onload event fires in order to guarantee that external scripts have executed?</p>
javascript
[3]
2,856,932
2,856,933
how to get service class's public member variable to TabActivity
<p>I want to get service class's member variable to a Class which extends TabActivity.</p> <pre><code> public class MainActivity extends TabActivity { private TabHost tabHost; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab); this.tabHost = (TabHost)findViewById(android.R.id.tabhost); TabSpec thirdTabSpec = tabHost.newTabSpec("tid1"); firstTabSpec.setIndicator("출근").setContent(new Intent(this,FirstTab.class)); tabHost.addTab(firstTabSpec); } protected void onPause(){ super.onPause(); // HERE I WANT TO receive value from FirstTab Activity // firstabOption = ??? .CURRENT_OPTION_IDX ?? } } </code></pre> <p>and the <code>FirstTab</code> class is</p> <pre><code> public class FirstTab extends Activity { public int CURRENT_OPTION_IDX; ...... .... .... .... @Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); CURRENT_OPTION_IDX = item.getItemId(); // save option } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.first_tab); } } </code></pre> <p>because of the lack of my english, please excuse my brevity</p> <p>I have a <code>TabActivity</code> class which has 3 tabs. and I did some action changing TextView's text on the one of tab. and I want to save the values when <code>TabActivity</code>'s <code>OnPause</code> occurs.</p>
android
[4]
5,446,300
5,446,301
Full Text justification in android
<p>I am browsing data from the server and getting through page.getContent(), My textview has default gravity(left), so text is left aligned, I want right alignment as well(As we justify text in MS Office)....Is there any way to justify the text.</p> <p>I have put android:garavity="left|right" it also doesn't work.</p> <pre><code>TextView textview=(TextView)findViewbyId(R.id.text); textview.setText(Html.fromHtml(page.getContent())); </code></pre>
android
[4]
3,782,522
3,782,523
How To Detect If Type is Another Generic Type
<p>example:</p> <pre><code>public static void DoSomething&lt;K,V&gt;(IDictionary&lt;K,V&gt; items) { items.Keys.Each(key =&gt; { if (items[key] **is IEnumerable&lt;?&gt;**) { /* do something */ } else { /* do something else */ } } </code></pre> <p>Can this be done without using reflection? How do I say IEnumerable in C#? Should I just use IEnumerable since IEnumerable&lt;> implements IEnumerable? </p>
c#
[0]
1,296,947
1,296,948
How can I use setString procedure properly?
<p>I have the following situation...</p> <p>I use CallableStatement from java.sql package. When I use setDate function prior to executing stored procedure, I get an error:</p> <blockquote> <p>Cannot find symbol symbol: method setDate(int, java.util.Date) location: interface java.sql.CallableStatement"</p> </blockquote> <p>Here's the sample code:</p> <pre><code>Connection con = null; CallableStatement proc_stmt = null; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); con = DriverManager.getConnection("jdbc:sqlserver://servername;databaseName=DBName", "UNAME", "PASS"); proc_stmt = con.prepareCall("{ call InsertSomething(?, ?) }"); proc_stmt.setString(1, "A00999999"); proc_stmt.setDate(2, new Date()); proc_stmt.executeQuery(); proc_stmt.close(); con.close(); </code></pre> <p>I even tried this using Calendar class with appropriate functions, but the effect was the same.</p>
java
[1]
2,319,666
2,319,667
How to use IActivityWatcher
<p>Hi Can anyone tell me how IActivityWatcher interface is used??</p> <p>I'm trying to develop an application that records the amount of time that all installed applications were run. It is similar to an application "AppUsage" on Google play. When i decompiled it and checked he is using IActivityWatcher interface in his app. I googled regarding the same but hardly finding very little info which is not enough to proceed. Please help. </p>
android
[4]
1,270,267
1,270,268
Retrieving Android API version programmatically
<p>Is there any API in the Android SDK that allows me to get the API version that the phone is currently running?</p>
android
[4]
5,105,445
5,105,446
iPhone 3rd Party Controls?
<p>I was wondering if there are any 3rd party controls for use with the iPhone that are available, even better if usable from Interface Builder. From what I can gather, the answer is no.</p> <p>I come from a Microsoft .NET background where of course there are tons of controls available from 3rd parties. I'm curious if this is a general Mac development ecosystem fact, i.e. no 3rd party controls for sale, or just an iPhone one, or if I've just missed finding them. </p>
iphone
[8]
17,040
17,041
PHP repeat progress after waking up
<p>I want to repeatedly check a variable every time php wakes up from sleep(). Further, if 3 minutes have passed without finding a particular variable then the function should stop checking. How would I go about this? This is the code I have thus far:</p> <pre><code>&lt;?php $file = file_get_contents("file.txt"); if($file == 0){ sleep(3);// then go back to $file } else { //stuff i want } ?&gt; </code></pre>
php
[2]
4,346,280
4,346,281
jquery - selecting multiple elements with same class and then filtering by id
<p>.post is the class of elements which also have an unique id such as "c1", "c14" etc (representing the post count on the page).</p> <p>The code below will be part of an ajax call which regularly pulls new posts while also checking the current amount of posts on the page. Should the amount exceed 5, the older posts are removed.</p> <p>Posts to be removed will have the smallest ids. How could I select them? Or would there be a better method of selecting the older messages (which are in bottom, similar to youtube).</p> <pre><code>var postcount = $(".post").length; while(postcount &gt; 5){ $("#c" + divtoremove).fadeOut(1000); } &lt;div class="post" id="c6"&gt;Post 6&lt;/div&gt; &lt;div class="post" id="c5"&gt;Post 5&lt;/div&gt; &lt;div class="post" id="c4"&gt;Post 4&lt;/div&gt; &lt;div class="post" id="c3"&gt;Post 3&lt;/div&gt; &lt;div class="post" id="c2"&gt;Post 2&lt;/div&gt; &lt;div class="post" id="c1"&gt;Post 1&lt;/div&gt; </code></pre> <p>In this example "c1" should be removed. I can't keep count of the elements, I need to recalculate it on each call since it got messed up when I tried to keep a count.</p>
jquery
[5]
266,951
266,952
Javascript Bitwise Operators
<p>I'm trying to figure out some differences between C# and Javascript. Ok, take this code in Javascript:</p> <pre><code>var j = 0x783a9b23; var bt = ((16843134 ^ (16843134 - 1)) * j); </code></pre> <p>After executing this, "bt" will be 6051320169. </p> <p>Now after doing this in C#:</p> <pre><code>int j = 0x783a9b23; int bt = ((16843134 ^ (16843134 - 1)) * j); </code></pre> <p>"bt" will be 1756352873. Certainly not the same. Any ideas why Javascript is not seeing how C# sees it?</p>
javascript
[3]
2,342,646
2,342,647
Getting specific days in a month
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5421972/how-to-find-the-3rd-friday-in-a-month-with-c">How to find the 3rd Friday in a month with C#?</a> </p> </blockquote> <p>There's a condition that a specific event will occur only on <strong>first</strong> and <strong>third</strong> *<em>Wednesday</em>* of every month. I am trying to achieve this like below,</p> <pre><code>DateTime nextMeeting = DateTime.Today.AddDays(14); int daysUntilWed = ((int)DayOfWeek.Wednesday - (int)nextMeeting.DayOfWeek + 7) % 7; DateTime nextWednesday = nextMeeting.AddDays(daysUntilWed); </code></pre> <p>But I am not getting the desired result. I am sure, I am missing out on a logic or is there any method in ASP.NET through which I can do that? More Detail: I am trying to display the next Wednesday (whichever is first) by clicking on a button which will set the label.</p>
asp.net
[9]
1,463,337
1,463,338
How to remove automatic picture rotation?
<p>I have a problem with pictures; after I take a picture, it automatically rotates 90-degrees. How I can remove this? I need a portrait picture.</p> <pre><code> public void surfaceCreated(SurfaceHolder holder) { try { camera.setPreviewCallback(this); camera.setPreviewDisplay(holder); Camera.Parameters p = camera.getParameters(); p.setPictureSize(1024, 768); p.setPictureFormat (PixelFormat.RGB_565); camera.setParameters(p); } catch (IOException e) { e.printStackTrace(); } if (this.getResources().getConfiguration().orientation != Configuration.UI_MODE_TYPE_CAR) { camera.setDisplayOrientation(90); } else { camera.setDisplayOrientation(0); } preview.setLayoutParams(lp); camera.startPreview(); } public void onPictureTaken(byte[] paramArrayOfByte, Camera paramCamera) { FileOutputStream fileOutputStream = null; try { File saveDir = new File("/sdcard/CameraExample/"); if (!saveDir.exists()) { saveDir.mkdirs(); } BitmapFactory.Options options = new BitmapFactory.Options(); Bitmap myImage = BitmapFactory.decodeByteArray(paramArrayOfByte, 0,paramArrayOfByte.length, options); Bitmap bmpResult = Bitmap.createBitmap(myImage.getWidth(), myImage.getHeight(),Config.RGB_565); Paint paint = new Paint(); Canvas myCanvas = new Canvas(bmpResult); myCanvas.drawBitmap(myImage, 0, 0, paint); fileOutputStream = new FileOutputStream("/sdcard/CameraExample/"+ sdf.format(new Date())+".bmp"); BufferedOutputStream bos = newBufferedOutputStream(fileOutputStream ); bmpResult.compress(CompressFormat.PNG, 100, bos); bos.flush(); bos.close(); </code></pre>
android
[4]
5,676,736
5,676,737
Is there a compliance test for C++ compilers?
<p><b>Is there, somewhere, a freely usable/accessible script, source file, or whatever, that is able to measure the compliance of a given C++ compiler?</b></p> <p>For example, the Acid3 test for browsers: <a href="http://acid3.acidtests.org/">http://acid3.acidtests.org/</a></p> <p>The results I dream of would be a global percentage note (or multiple notes, one for each standard, e.g. , c++98, c++11, c++14, etc.), and then detailed tests with "success" or "failure" for each of them.</p> <p><i>Background: I had a discussion at work about boost and some challenged compilers. My interlocutor spoke about boost being an academic project, because it won't work in major C++ compilers, and me answering that mentally challenged compilers should not count. Being able to measure with code the actual conformance of a compiler would help both in evaluating the compiler, and discovering the "corner cases" that should be avoided in cross-platform code compiled with them.</i></p>
c++
[6]
856,715
856,716
javascript returns undefind for a globally declared variable
<p>I am a beginer to javascript.I have a doubt.my code is given bellow.when i run this the 1st alert box displaying "undefind".i can not understand why?thanks alot..</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; var a = 123; function foo() { alert(a); var a = 890; alert(a); } foo(); alert(a); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
673,749
673,750
play selected songs
<p>I have a reqiurement, I need to play multiple audio songson ASP.Net page.Can anyone suggest the best way to implement this.</p> <p>I have page. There I will display the list of the songs in grid view. The gridview contains checkboxes and songs name. User should able to select the multiple check boxes and click play.</p> <p>When ever user click play button on new popup window I have to play the all audio songs selected by user one by one.</p> <p>I will appreciate your help.</p>
asp.net
[9]
5,740,896
5,740,897
Parsing images through php - issue with duplicates
<p>So, this is the only issue I am having left to fix on my site. When it fetches a post from the database and is then called to parse/replace the URL as a it has a problem. The problem is only with duplicates or image names containing a space in them.</p> <pre><code>$result = mysql_query("SELECT * FROM posts ORDER BY postid DESC"); while($row = mysql_fetch_array($result)) { $str = $row['post_content']; $str = preg_replace_callback('#(?:https?://\S+)|(?:www.\S+)|(?:\S+\.\S+)#', function($arr) { if(strpos($arr[0], 'http://') !== 0) { $arr[0] = 'http://' . $arr[0]; } $url = parse_url($arr[0]); // images if(preg_match('#\.(png|jpg|gif)$#', $url['path'])) { return '&lt;img src="'. $arr[0] . '" /&gt;&lt;br /&gt;&lt;br /&gt;'; } </code></pre> <p>Here is what it does for the first uploaded image:<br /> <a href="http://domain.com/server/php/files/filename.jpg" rel="nofollow">http://domain.com/server/php/files/filename.jpg</a><br /> Here is what it does for the second uploaded image:<br /> <a href="http://domain.com/server/php/files/filename" rel="nofollow">http://domain.com/server/php/files/filename</a> http://(1).jpg<br /></p> <p>I need to either control the naming convention for how names the file or control how it reads the spaces in the URL.</p>
php
[2]
1,873,615
1,873,616
PHP: calculating the average 3
<p>Im working on a star rating (5 stars is best, 1 is bad), and i have 4 records of 4 users voted.</p> <pre><code>user1: 3 user2: 4 user3: 5 user4: 3 </code></pre> <p>How can i calculate out the average of this in php?</p> <p>Is it just simple math, $count = $user1 + $user2 + $user3 + $user4/4 ?</p> <p>I tried:</p> <pre><code>echo round(3+4+5+3/4); </code></pre> <p>and got the number "13" which is not right</p>
php
[2]
3,312,187
3,312,188
Can someone explain the difference to me between the different .stop() properties in jQuery?
<p>I've read the API documentation on .stop()... <a href="http://api.jquery.com/stop/" rel="nofollow">http://api.jquery.com/stop/</a></p> <p>But I'm still confused as to the difference between the following:</p> <pre><code>.stop(false, false) .stop(true, false) .stop(false, true) .stop(true, true) </code></pre> <p>Could someone explain? Thanks.</p>
jquery
[5]
2,837,942
2,837,943
Don't fire onfocus when selecting text?
<p>I'm writing a JavaScript chatting application, but I'm running into a minor problem.</p> <p>Here is the HTML structure:</p> <pre><code>&lt;div id="chat"&gt; &lt;div id="messages"&gt;&lt;/div&gt; &lt;textarea&gt;&lt;/textarea&gt; &lt;/div&gt; </code></pre> <p>When the user clicks/focuses on the chat box, I want the textbox to be automatically focused. I have this <code>onfocus</code> handler on the chat box:</p> <pre><code>chat.onfocus = function () { textarea.focus(); } </code></pre> <p>This works, but the problem is that in Firefox, this makes it impossible to select text in the messages <code>div</code>, since when you try to click on it, the focus shifts to the <code>textarea</code>. How can I avoid this problem?</p> <p>(Semi-related issues: In Chrome, <code>textarea.focus()</code> doesn't seem to shift the keyboard focus to the <code>textarea</code>; it only highlights the box. IE8 does not seem to respond to the <code>onfocus</code> at all when clicking, even if it <code>tabindex</code> is set. Any idea why?)</p>
javascript
[3]
2,757,658
2,757,659
jquery plugin which puts a transparent overlay over a div with a loader in the center
<p>I'm looking for a jquery plugin as described in the title and it has to be cross browser compatible.</p> <p>Any ideas?</p> <p>Thanks</p>
jquery
[5]
1,342,444
1,342,445
why are concrete types rarely useful as bases for further derivation
<p>I read "Concrete types are rarely useful as bases for further derivation"------------ Stroustrup p. 768</p> <p>How to interpret this? Does it mean that we should get derived class from the base class with pure virtual function? However, I see a lot of code with derived class derived from concrete types.</p> <p>Can anyone help me out?</p>
c++
[6]
3,992,579
3,992,580
Facebook share button for website
<p>i need to use share button in my website. Different share button for different products.. mostly we need to use like this,</p> <pre><code>http://www.facebook.com/sharer.php? </code></pre> <p>In the above url what are all the parameters we need to pass for showing it as our website, product and some image of that product in that share page...</p>
php
[2]
557,222
557,223
jQuery not comparing variables correctly in table cells
<p>I have a table like this:</p> <pre><code>&lt;table id="comparison"&gt; &lt;tr&gt; &lt;th&gt;Hotels&lt;/th&gt; &lt;th&gt;Jan 2013&lt;/th&gt; &lt;th&gt;Feb 2013&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Lorem Ipsum Hotel&lt;/td&gt; &lt;td&gt; &lt;div class="rooms"&gt;165&lt;/div&gt; &lt;div class="sob"&gt;352&lt;/div&gt; &lt;/td&gt; &lt;td&gt; &lt;div class="rooms"&gt;215&lt;/div&gt; &lt;div class="sob"&gt;30&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I prepared this jQuery script to compare the Rooms and SOB in each cell.<br /> - If the SOB is less than the Rooms then I color the SOB red to signal a negative result.<br /> - If the SOB is greater than the Rooms then I color SOB green to signal a positive result.</p> <pre><code>$('#comparison td .sob').each(function() { var rooms = $(this).prev().text(); var sob = $(this).text(); if (rooms &gt; sob) { $(this).css({'color': 'red'}); } else { $(this).css({'color': 'green'}); } }); </code></pre> <p>The problem is that this script is not comparing the Rooms and SOB correctly. It seems to be running at random in the variable comparison, sometimes producing the correct result and other times not.</p> <p>What am I missing?</p>
jquery
[5]
1,905,132
1,905,133
Gridview binding without using a Database
<p>Can a GridView be bound to a List&lt;>?</p> <p>I want to create a Master Details scenario. So The first List&lt;> contains Master data and the second Child data. When the user clicks on the Master Data, the child data, should appear in a pop.</p> <p>Is that possible? Please share some code.</p>
asp.net
[9]
5,140,615
5,140,616
Python mulitple inheritence property
<p>In the following code C is inherited from A and B so when c.get() is get which classes get method is called can anyone explain this.....</p> <pre><code>class A: def get(self): print "In A get" class B: def get(self): print "In B get" class C(A,B): def __init__(self): print "In c init" c=C() c.get() </code></pre>
python
[7]
4,529,335
4,529,336
Variable content is different upon content-type
<p>Upon transfering my site from one server to another, some functions started behaving differently.</p> <p>The problem lies in building my rss feed. My feed are composed of database posts containing html, and to show them correctly in the feed I then need to change the picture paths to full domain paths, instead of just server root. For this purpose I use simple html dom (http://simplehtmldom.sourceforge.net).</p> <p>When outputting the varaible html in Content-type: appilication/rss+xml it will show "Object id #1". Should I choose to output it before setting content-type, I get the right html. (in this case &lt; p >test&lt; /p >)</p> <p>How come I can't output the variable html inside content-type rss+xml?</p> <pre><code>require_once($_SERVER['DOCUMENT_ROOT'].'/lib/config.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/lib/functions/simple_html_dom.php'); $html = str_get_html("&lt;p&gt;test&lt;/p&gt;"); foreach($html-&gt;find('img') as $e) { $e-&gt;src = $siteconfig['full_domain'].$e-&gt;src; } header("Content-Type: application/rss+xml; charset=UTF-8"); $rssfeed = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n"; $rssfeed .= "&lt;rss version=\"2.0\"&gt;\n"; $rssfeed .= "&lt;channel&gt;\n"; $rssfeed .= "&lt;title&gt;Headline&lt;/title&gt;\n"; $rssfeed .= "&lt;language&gt;da&lt;/language&gt;\n"; $rssfeed .= "&lt;item&gt;\n\t"; $rssfeed .= "&lt;description&gt;&lt;![CDATA[".$html."]]&gt;&lt;/description&gt;\n\t"; $rssfeed .= "&lt;/item&gt;\n"; $rssfeed .= "&lt;/channel&gt;\n"; $rssfeed .= "&lt;/rss&gt;"; echo $rssfeed; </code></pre>
php
[2]
5,351,234
5,351,235
What's the best way to force the user of a C++ function to acknowledge the semantic meaning of parameters that are numerical constants?
<p>I'd like to write function interfaces that force the user to acknowledge the semantic meaning of built-in constants. For example, I'd like to take</p> <pre><code>void rotate(float angle); // Rotate the world by an angle in radians. </code></pre> <p>and change it to</p> <pre><code>void rotate(Radians angle); </code></pre> <p>Am I right in believing that the problem with making a Radians class is that it adds code and makes the program slower. Is there a better way to do this?</p>
c++
[6]
5,344,355
5,344,356
How do you trim the BigDecimal division results
<pre><code>BigDecimal numerator = new BigDecimal(numerator); BigDecimal denominator = new BigDecimal(denominator); double result = numerator.divide(denominator).doubleValue(); </code></pre> <p>Division on certain conditions results in a zero at the end <code>(e.g. 0.0060)</code>. Dividing equal numbers results in a zero at the end <code>(e.g 1.0)</code>.</p> <p>I would prefer to trim the trailing zero in both cases. How should I do this?</p>
java
[1]
5,302,117
5,302,118
when to declare an member of class
<p>According to Bjarne Stroustrup:</p> <blockquote> <p>if (and only if) you use an initialized member in away that requires it to be stored as an oject in memory ,the member must be(uniquely) defined somewhere. The initializer may not be repeated.</p> </blockquote> <p>(<em>The C++ Programming Language, 3rd Edition</em>, Section 10.4.6.1)</p> <p>He gives this example:</p> <pre><code>class curious{ public: static const int c1=7; //.. }; const int curious::c1; //necessary </code></pre> <p>Then why it is necessary to define a <code>static</code> member, because we may not be initializing it at all?</p> <p>Also, <code>const</code> and reference members are not declared anywhere, even though it is necessary to initialize them (no default constructor).</p>
c++
[6]
3,313,266
3,313,267
Code for finding string between "" in a data structure
<p>I need help to solve the following:</p> <p>Lets say I have the number 70368 in int var and that I want to find the corresponding string "EVT_ACP_CAPT_MIC_FLT" in the structure below and load it ( including the "") to a char* event variable</p> <p>The code solution must work for any number lenght between 1 to 5.</p> <pre><code>struct NameOffset TestEvents[] = { { "EVT_ACP_CAPT_LAST1", 70387 }, { "EVT_ACP_CAPT_LAST1", 70387 }, { "EVT_ACP_CAPT_LAST2", 70512 }, { "EVT_ACP_CAPT_LAST2", 70512 }, { "EVT_ACP_CAPT_MASK_BOOM_SWITCH", 70385 }, { "EVT_ACP_CAPT_MIC_FLT", 70368 }, { "EVT_ACP_CAPT_MIC_HF1", 70510 }, { "EVT_ACP_CAPT_MIC_HF2", 70511 }, }; </code></pre> <p>The table is in real very long, this is just a few lines to show the structure.</p>
c++
[6]
5,220,143
5,220,144
Using $_POST information only once
<p>I have some information which gets passed from a form and needs to be used once and only once. I can collect it nicely from $_POST but I'm not sure which is the "best" way to ensure that I can only use it once, i.e. I want to avoid the user pressing F5 repeatedly and accessing the function more than once. </p> <p>My initial thought was to set a session variable and time the function out for a set period of time. The problem with that is thay could have access to the function again after the set period has elapsed.</p> <p>Better ideas welcomed!</p>
php
[2]
2,272,398
2,272,399
Trying to reassign and output new set values in Java
<p>I am trying to create a fun Java "Gibberish Translator" for my little brother. He is mentally disabled and I believe he will get a kick out of this. :) I know how to accept input and how to display output. What I am wanting to do, however, is far above my Java knowledge. (If it is even at all possible.) I am hoping that when my brother types something in a text field and then presses a button, a totally different text will display in a text area. I am hoping to be able to assign <strong>different</strong> letters or letter combinations to each letter. This way, every time he uses the letter "i", for example, it will always display "ti" instead. I am wanting the output to be totally gibberish and funny to read. If this is possible to do, please help me with assigning, and outputting different set values to each letter. I am fairly new to coding, so please include examples.</p> <p>Thanks in advance.</p> <p>(I have not inserted code as of yet because I have not started coding on the computer yet. I want to make sure it can be done before I begin the hard work. :))</p>
java
[1]
1,527,104
1,527,105
How to initialize the custom Widget in kindo grid TD(grid cell)?
<p>I have a jQuery Custom widget, how to initialize that widget in Kendo Grid cell using the template?</p> <p>This is my Template</p> <pre><code>&lt;script id="IDCOL-tmpl" type="text/x-kendo-tmpl"&gt; &lt;div class="IDCOL"&gt; &lt;script type="text/javascript"&gt; $('.IDCOL').Block(); {{html "&lt;/sc"+"ript&gt;"}} &lt;/div&gt; &lt;/script&gt; </code></pre> <p>and Kendo Grid initialization</p> <pre><code>$("#container").kendoGrid({ .......... columns : [{ title : "ID", template : kendo.template($("#IDCOL-tmpl").html()) }, "StartTime", "EndTime"] }); </code></pre> <p>This is the error:</p> <blockquote> <p>"Microsoft JScript runtime error: Could not complete the operation due to error 80020101.") in globalEval (which is in jquery-1.7.1.js)</p> </blockquote>
jquery
[5]
3,009,986
3,009,987
jQuery plugin: character count for textareas
<p>i am using the below plugin for counting the char in the textarea but the only feature i would like to add is that when the character is exceed the limit then it should stop and not allow any more characters to be entered.. so should i just return when it match the allowed character?</p> <p>below is the sample link with source code.</p> <p><a href="http://cssglobe.com/lab/charcount/01.html" rel="nofollow">http://cssglobe.com/lab/charcount/01.html</a></p> <pre><code>(function($) { $.fn.charCount = function(options){ // default configuration properties var defaults = { allowed: 140, warning: 25, css: 'counter', counterElement: 'span', cssWarning: 'warning', cssExceeded: 'exceeded', counterText: '' }; var options = $.extend(defaults, options); function calculate(obj){ var count = $(obj).val().length; var available = options.allowed - count; if(available &lt;= options.warning &amp;&amp; available &gt;= 0){ $(obj).next().addClass(options.cssWarning); } else { $(obj).next().removeClass(options.cssWarning); } if(available &lt; 0){ $(obj).next().addClass(options.cssExceeded); } else { $(obj).next().removeClass(options.cssExceeded); } $(obj).next().html(options.counterText + available); }; this.each(function() { $(this).after('&lt;'+ options.counterElement +' class="' + options.css + '"&gt;'+ options.counterText +'&lt;/'+ options.counterElement +'&gt;'); calculate(this); $(this).keyup(function(){calculate(this)}); $(this).change(function(){calculate(this)}); }); }; })(jQuery); </code></pre>
jquery
[5]
5,338,942
5,338,943
Checking for secure network in C#
<p>I have an application that uploads sensitive information over the network. The information is encrypted, but I do not want the data to be uploaded over non-secured, or WEP secured wireless networks. How can I check for this?</p>
c#
[0]
1,805,288
1,805,289
Using foreign keys and ContactsContract
<p>I'm building an app where I need the user to select some "favorite" contacts and a phone number. I'm able to select a contact using </p> <pre><code> startActivityForResult(new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI), PICK_CONTACT_REQUEST); </code></pre> <p>and I'm able to extract all the information I need. </p> <p>I then proceed to save the _id of the contact into my own database. My plan is to later list all the "favorited" contacts and display the name and phonenumber in a listview. </p> <p>I want to save the contact id instead of the name and number so my listview will reflect any changes the user makes to his or her contacts.</p> <p>But now I'm stuck. I don't know how to transform my table with contacts ids into a table with contact names. </p> <p>I would like to something like this</p> <pre><code>my_table LEFT OUTER JOIN contacts_table ON (my_table.contact_id = contacts_table._id) </code></pre>
android
[4]
4,456,555
4,456,556
jquery tab not working
<p>i am creating the tab by jquery and my code is bellow</p> <p>jquery</p> <pre><code>$("document").ready(function() { $("#tabs").tabs(); }); </code></pre> <p>and the html</p> <pre><code>&lt;div id="tabs"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#tabs-1"&gt;Nunc tincidunt&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tabs-2"&gt;Proin dolor&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tabs-3"&gt;Aenean lacinia&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="tabs-1"&gt; &lt;p&gt;Proin ur nec arcu m sodal mpus lectus.&lt;/p&gt; &lt;/div&gt; &lt;div id="tabs-2"&gt; &lt;p&gt; llus p Mauris consectetur tortor et purus.&lt;/p&gt; &lt;/div&gt; &lt;div id="tabs-3"&gt; &lt;p&gt; sus he nec, luctus a, lacus.&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>css</p> <pre><code> &lt;link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css"&gt; </code></pre> <p>and the jquer i have included is </p> <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="http://code.jquery.com/ui/1.8.21/jquery-ui.min.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>but the tab is not working ?</p>
jquery
[5]
1,153,524
1,153,525
Dictionary values by reference
<p>In our application we have some strings coming from translation that can contain variables. For example in <code>Can i have a {beverage}?</code> the <code>{beverage}</code> part should be replaced with a variable. My current implementation works by having a Dictionary of the name and value of all variables, and just replacing the correct string. However i'd like to register the variables by reference, so that if the value is ever changed the resulting string is changed as well. Usually passing a parameter with the <code>ref</code> keyword would do the trick, but i'm unsure on how to store those in a Dictionary. </p> <p>TranslationParser:</p> <pre><code>static class TranslationParser { private const string regex = "{([a-z]+)}"; private static Dictionary&lt;string, object&gt; variables = new Dictionary&lt;string,object&gt;(); public static void RegisterVariable(string name, object value) { if (variables.ContainsKey(name)) variables[name] = value; else variables.Add(name, value); } public static string ParseText(string text) { return Regex.Replace(text, regex, match =&gt; { string varName = match.Groups[1].Value; if (variables.ContainsKey(varName)) return variables[varName].ToString(); else return match.Value; }); } } </code></pre> <p>main.cs</p> <pre><code> string bev = "cola"; TranslationParser.RegisterVariable("beverage", bev); //Expected: "Can i have a cola?" Console.WriteLine(TranslationParser.ParseText("Can i have a {beverage}?")); bev = "fanta"; //Expected: "Can i have a fanta?" Console.WriteLine(TranslationParser.ParseText("Can i have a {beverage}?")); </code></pre> <p>Is this possible at all, or am i just approaching the problem incorrectly? I fear that the only solution would involve unsafe code (pointers).</p> <p>So in short, i'd like to store a variable in a Dictionary, change the original variable and get the changed value from the Dictionary. Like you would do with the <code>ref</code> keyword. </p>
c#
[0]
2,397,415
2,397,416
Prevent Direct Access To PHP File
<p>Let's say I have two domains: <em>domainA.com</em> and <em>domainB.com</em>. On <em>domainB.com</em> im going to use an iframe to access a PHP file on <em>domainA.com</em>. </p> <p>Is there a way I can set an <code>if/else</code> statement so that no user can access that PHP file by going to <code>domainA.com/file.php</code>? That file should only load from an iframe on <em>domainB.com</em>. </p>
php
[2]
2,588,244
2,588,245
Cos(90) returning a value very close to 0, but I need 0?
<p>The values for temp_x_btm_left = 0 &amp; temp_y_btm_left=1;</p> <pre><code>angle = 90; //Moving the bottom left coordinates _btm_left.real() = (temp_x_btm_left * cos(angle*PI/180)) - (temp_y_btm_left * sin(angle*PI/180)); _btm_left.imag() = (temp_x_btm_left * sin(angle*PI/180)) + (temp_y_btm_left * cos(angle*PI/180)); </code></pre> <p>The code is supposed to rotate the object 90 degrees counter-clockwise, which it does but the <code>_btm_left.imag()</code> returns a value really close to 0 = 1.437949e-009, and I really need it being 0. </p> <p>I've tried <code>setprecision()</code> and <code>setw()</code> but it doesn't seem to have any effect. Are there any methods for anything like this or do I need to create my own to solve this?!</p>
c++
[6]
3,076,220
3,076,221
why use an 'apply' function in this situation?
<p>in Chrome's console,</p> <pre><code>&gt; $$ bound: function () { return document.querySelectorAll.apply(document, arguments) } </code></pre> <p>why is this code like this? what's difference with </p> <pre><code> return document.querySelectorAll(arguments) </code></pre> <p>?</p>
javascript
[3]
4,043,987
4,043,988
How to create list of horizontal image galleries in a vertical Listview in android..?
<p>Thanks in advance..</p> <pre><code>I have a task like creating list of image (Horizontal)galleries in an vertical listview in android. </code></pre> <p>I spend so much time but i didn't get any idea on that.</p> <p>For the required screen please check the link as a reference :</p> <p><a href="http://www.appbrain.com/app/pulse-news/com.alphonso.pulse" rel="nofollow">http://www.appbrain.com/app/pulse-news/com.alphonso.pulse</a>.</p> <p>So please help me by providing the logic..</p>
android
[4]
869,990
869,991
pass Socket , ObjectInputStream , ObjectOutputStream between Activites
<p>I have 2 Activities in my client/server project:<br> 1 - login (openning connection)<br> 2 - Handeling the game. </p> <p>i tired passing Socket , ObjectInputStream , ObjectOutputStream objects with Intenet and startActivity but it can pass only serializable objects.<br> how can i pass this objects ?<br> i read that i can use the application tag for this use but i didn't understand how.<br> can you guys lead me to the solution<br> thanks. </p>
android
[4]
4,166,530
4,166,531
MySQL select using an array
<p>I edit my code working good but still one problem ... the data that selected from my database and displayed in my suggestion input ( only one row and last ID ) !!! How can I do it to display all data rows from my database ???? </p> <pre><code>&lt;?php $q = strtolower($_GET["q"]); if (!$q) return; $host = "localhost"; $user = "root"; $password = ""; $database = "private_message_system"; //make connection $server = mysql_connect($host, $user, $password); $connection = mysql_select_db($database, $server); $query = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_array($query)){ $items = array($row["user_name"] =&gt; $row["user_email"]); } $result = array(); foreach ($items as $key=&gt;$value) { if (strpos(strtolower($key), $q) !== false) { array_push($result, array( "name" =&gt; $key, "to" =&gt; $value )); } } echo json_encode($result); ?&gt; </code></pre>
php
[2]
4,819,177
4,819,178
Make Div appear after scrolling past the bend
<p>I want replicate the technique used in the site below so that after the viewer scrolls past the fold, a div is automatically displayed.</p> <p><a href="http://www.talentgarden.it/it/#!/home" rel="nofollow">http://www.talentgarden.it/it/#!/home</a></p> <p>I am familiar with hiding divs using jquery and using the scrollTop function, but I am not sure exactly how to let jquery know that the user has passed the fold.</p> <p>I am a noob so any help is appreciated. </p> <p>Thanks,</p> <p>Joe</p>
jquery
[5]
464,019
464,020
jQuery - Get child input based on name selector
<p>I've got an onclick event which is calling a function, passing the current div:</p> <pre><code>&lt;div onclick="deleteline($(this));"&gt; </code></pre> <p>In my deleteline function, how do I get a child of the parent of $(this) where the name contains Qty?</p> <p>In this example I'm looking to get the ProdQty input box:</p> <pre><code>&lt;div&gt; &lt;input id="PrdQty" type="hidden" value="1"&gt; &lt;div onclick="deleteline($(this));"&gt; &lt;/div&gt; </code></pre> <p>EDIT: This page is getting included multiple times within another page via an ajax call. Therefore if I assign the clickable div an ID, it's going to cause a conflict after this code is injected into the parent for the 2nd time.</p> <p>As a result, I've used the suggestions below, kept the inline onclick and I'm getting the qty using: sender.parent().find('input[id*="Qty"]')</p>
jquery
[5]
6,016,073
6,016,074
Javascript random number
<p>I need to generate a number between 0-15 and there after add or substract that number to make:</p> <p>Spring/ fall between -5 - 10 Summer between 10 - 25 Winter between -20 - -5</p> <p>After that I would like to link 4 different CSS - styles that matches these numbers. For example when it's summer the numbers should be generated between 10 - 25 and be linked to a CSS with green color, when it's winter a number between -20 - -5 should be generated and linked to a CSS with blue color and so on.</p> <p>Please help me!</p>
javascript
[3]