Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,928,913
1,928,914
Is there software to send Internet connection from my laptop to an iPhone?
<p>Is there an iPhone app and software which let me send my 3G key Internet connection to my iPhone using Wi-Fi. It's kind of complex. Let me explain more.</p> <p>1) I have an Intel Core 2 Duo laptop with Wi-Fi</p> <p>2) I have a 3G key for Internet</p> <p>3) I have an <a href="http://en.wikipedia.org/wiki/IPhone_3G" rel="nofollow">iPhone 3G</a></p> <p>I want to share my laptop connection with my iPhone using Wi-Fi or cable, so I work with 2 devices at the same time, is there a way?</p> <p>I know there is a way to transfer Internet from iPhone to the laptop, but I want to do it from the laptop.</p>
iphone
[8]
1,808,932
1,808,933
window and tab close detection
<p>there are many articles for window and tab close detection, however, since the newest browser published, those codes since not working anymore. <a href="http://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/" rel="nofollow">webkit-page-cache-ii-the-unload-event</a> is an article for webkit browsers. It use onPageHiden() to detect the leave page event, however, it seems no longer work in chrome. Also, if I just close the browser, It won't do anything also.</p> <p>How I can trigger an event when I not only close the tab but also close the browser?</p>
javascript
[3]
3,324,058
3,324,059
Preventing form empty submit
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/10950470/check-if-multiple-strings-are-empty">Check if multiple strings are empty</a> </p> </blockquote> <p>today i got this answer <a href="http://stackoverflow.com/questions/10950470/chek-if-multiple-strings-are-empty/10950581#10950581">here</a> on stackoverflow:</p> <pre><code>&lt;input type="text" name="required[first_name]" /&gt; &lt;input type="text" name="required[last_name]" /&gt; ... $required = $_POST['required']; foreach ($required as $req) { $req = trim($req); if (empty($req)) echo 'gotcha!'; } </code></pre> <p>This is ok, but what if someone change </p> <pre><code> name="required[first_name]" </code></pre> <p>To</p> <pre><code> name="" </code></pre> <p>Then i will have some data missing in further code (i use form to send submited data to email). How to fix this?</p>
php
[2]
3,769,080
3,769,081
Unable to clear a TextBox using javascript
<p>I'm unable to clear the text box when I hit the button with value <code>C</code>.</p> <p>In Opera when I press the number buttons it properly inputs them into the text box but for some reason the <code>C</code> button never works! Here is the <a href="http://jsfiddle.net/pwQpV/9/" rel="nofollow">jsfiddle</a>.</p> <p>Thanks.</p> <p><hr> <em>Edit:</em> I haven't implemented all the functionality yet! Only the number buttons work.</p>
javascript
[3]
3,992,907
3,992,908
goto and RAII in C++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3179936/goto-out-of-a-block-do-destructors-get-called">Goto out of a block: do destructors get called?</a> </p> </blockquote> <p>I know that goto operator both in C and C++ is useless in almost all situations, but i want to know the answer for this question only by interest, it has no practical meaning.</p> <p>Does C++ standard guarantees that in such situations destructors of objects must be called properly?</p> <pre><code>#include &lt;iostream&gt; class Foo { public: Foo() { std::cout &lt;&lt; "Foo::Foo() \n"; } ~Foo() { std::cout &lt;&lt; "Foo::~Foo() \n"; } }; int main() { { std::size_t i = 0; _1: Foo instance; if (!++i) { goto _1; } } { Foo instance; goto _2; } _2: ; } </code></pre> <p><a href="http://liveworkspace.org/code/06031e6699c8fddda94b8594ccab1387" rel="nofollow">http://liveworkspace.org/code/06031e6699c8fddda94b8594ccab1387</a></p> <p>And what about other stange situations with goto and C++ RAII?</p> <p>It would be really cool if you can post here the quotes from the C++ standard.</p>
c++
[6]
3,099,278
3,099,279
What does this Javascript do?
<p>What is this line doing:</p> <pre><code> var tfun = new Function("_", "at" , "with(_) {return (" + text + ");}" ); </code></pre> <p>What is the <code>_</code>, <code>at</code>, and <code>with(_)</code>?</p> <p>I've read this: <a href="http://www.permadi.com/tutorial/jsFunc/index.html" rel="nofollow">http://www.permadi.com/tutorial/jsFunc/index.html</a></p> <p>I understand that it's creating a new function object, but am still quite puzzled at what his is supposed to do.</p> <p>Thanks.</p> <p>Forgot to put the source: <a href="http://kite.googlecode.com/svn/trunk/kite.js" rel="nofollow">http://kite.googlecode.com/svn/trunk/kite.js</a></p> <p><a href="http://www.terrainformatica.com/2011/03/the-kite-template-engine-for-javascript/" rel="nofollow">http://www.terrainformatica.com/2011/03/the-kite-template-engine-for-javascript/</a></p>
javascript
[3]
5,961,758
5,961,759
Media player on android
<p>I want to set volume control to my audio streaming project in android .how to do this</p>
android
[4]
2,074,094
2,074,095
javascript function modification
<p>I am trying to write a logger object which logs messages to screen. here is my code. <a href="http://github.com/huseyinyilmaz/javascript-logger" rel="nofollow">http://github.com/huseyinyilmaz/javascript-logger</a> in every function that needs to log something, I am writing loggerstart and loggerEnd functions at start and end of my functions. But I want to run thos codes automaticalls for every function. is there a way to modify Function prototype so every function call can run automatically. (I am not using any javascript framework.)</p>
javascript
[3]
5,864,820
5,864,821
Split string and get first value only
<p>I wonder if it's possible to use split to devide a string with several parts that are separated with a comma, like this:</p> <pre><code>title, genre, director, actor </code></pre> <p>I just want the first part, the title of each string and not the rest?</p>
c#
[0]
773,004
773,005
Recursive call on main C++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2128321/can-main-function-call-itself-in-c">Can main function call itself in C++?</a> </p> </blockquote> <p>I found this problem very interesting but illusive a bit. Question 6.42 C++ how to program by Dietel "Can main be called recursively on your system? write a program containing a function main. Include Static local variable count and initialize to 1. Post-increment and print the value of count each time main is called. Compile your program. What happens ?</p> <p>I wrote the program as below but instead I made the recursion stops after 10 times as if I were to keep it running it will stops at a value around 41000.</p> <p>my question: how is it legal to call recursively main function in c++, should this program be executed to stack over flow or memory fault, etc.. ? Please explain.</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { static int count = 0; count++; if(count &lt;= 10) { cout &lt;&lt; count &lt;&lt; endl; return main(); //call main }//end if system("pause"); return 0;//successful completion }//end main </code></pre> <p>thank you</p>
c++
[6]
3,908,546
3,908,547
a generic error occurred in gdi+. while saving an image
<p>Dear Expert i am getting an error while saving an image the code is as follows </p> <pre><code> ClsImageManager objImgManager = new ClsImageManager(); Bitmap ImageBitmap = objImgManager.GetBitmapFromBytes(ImageData); Response.ContentType = "image/tiff"; ImageBitmap.Save(Response.OutputStream, ImageFormat.Tiff); ImageBitmap.Dispose(); Response.End(); </code></pre> <p>when i used Image.format.jpeg the code is working good but when i changes it to ImageFormat.Tiff then i am getting an error <strong>a generic error occurred in gdi+.</strong></p>
asp.net
[9]
1,791,818
1,791,819
Javascript - verify the values of fields with dynamic names
<p>I have a set of text fields qty with dynamic names: like <code>qty541</code> ; <code>qty542</code> ; <code>qty957</code> formed by the word: <code>"qty"</code> and the <code>product id</code></p> <p>How can I verify if all my qty fields are empty or not with Javascript ?</p> <p>Thanks a lot.</p>
javascript
[3]
4,267,113
4,267,114
setattribute in javascript
<p>This is my code to dynamically set the onclick attribute to links .But without me clicking the links itself the alert is triggerd.Pls help</p> <pre><code>window.onload = function() { var links = document.getElementsByTagName("a") ; for(var i=0;i&lt;links.length;i++) { elm = links[i]; elm.setAttribute("onclick", alert("you clicked a lik")); } } </code></pre>
javascript
[3]
797,426
797,427
Why doesn't `{}.toString.apply(array)` work?
<p>Usually, when I want to check the type of an object (whether it's an array, a NodeList, or whatever), I use the following:</p> <pre><code>var arr = [] // I don't do this, but it's for the sake of the example var obj = {} obj.toString.apply(arr) // This works </code></pre> <p>The question is: why can I <em>not</em> do the following?</p> <pre><code>var arr = [] {}.toString.apply(arr) // Syntax error: Unexpected token . </code></pre> <p>I don't get where the syntax error is.</p> <p>I can do something approaching with <code>[]</code> though, the following works:</p> <pre><code>var nodeList = document.getElementsByClassName('foo') [].forEach.call(nodeList, function(bar) { console.log(bar) }) // Works </code></pre> <p>So... I'm confused.</p>
javascript
[3]
5,332,464
5,332,465
disable the notification of sms in android
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1741628/can-we-delete-an-sms-in-android-before-it-reaches-the-inbox">Can we delete an SMS in Android before it reaches the inbox?</a> </p> </blockquote> <p>i am working on android sms app and i just want to disable the sms notification for particular messages. I had tried shared preference to uncheck the sms notification but it didn't work;after that i tried to update the message status using broadcast receiver onreceive method but then also notification appers....can someone suggest me how to disable the sms notificatioin of native android sms app using shared preference or any other way</p> <p>Thank you in advance</p>
android
[4]
3,784,958
3,784,959
Speech recognition in iphone sdk?
<p>Is there any via which we can identify the speech saved by the user at any time.what i want to do i want to save some user voices in the iphone and when user call any one sound iphone should react on that way i.e like if i say camera it would open the camera and if i say gallry it would open the photo gallery.</p> <p>Is there any API provided by apple in any SDK upto 4.0 beta.or we have to use any third party tool for it .</p> <p>Thanks </p>
iphone
[8]
981,112
981,113
SMS send twice Android 2.2
<p>Im using sms receiver and sending auto reply to the number from where its coming from but its sending same sms twice to that number with same body..im using following code (Android 2.0)</p> <pre><code>public void sendMultipartSMS(String phoneNumber, String message) { try { String SENT = "SMS_SENT"; SmsManager sms = android.telephony.SmsManager.getDefault(); ArrayList&lt;String&gt; parts = sms.divideMessage(message); int messageCount = parts.size(); ArrayList&lt;PendingIntent&gt; sendIntents = new ArrayList&lt;PendingIntent&gt;(messageCount); for (int i = 0; i &lt; sendIntents.size(); i++) { Intent sendInt = new Intent(SENT); PendingIntent sendResult = PendingIntent.getBroadcast(baseContext, 0, sendInt, 0); sendIntents.add(sendResult); } if (phoneNumber.length()&gt;0 &amp;&amp; message.length()&gt;0) { sms.sendMultipartTextMessage(phoneNumber, null, parts, sendIntents, null); } } catch (Exception e) { e.printStackTrace(); } </code></pre>
android
[4]
3,576,502
3,576,503
How can I emulate jQuery's trigger()?
<p>I have a small script I am writing (to ignore the hundreds of stupid requests I get on FaceBook).</p> <pre><code>var inputs = document .getElementById('contentArea') .getElementsByTagName('input'); for (var i = 0, inputsLength = inputs.length; i &lt; inputsLength; i++) { if (inputs[i].value !== 'Ignore') { continue; } // What I would do with jQuery, if inputs[i] was a jQuery object. inputs[i].click(); } </code></pre> <p>So basically I want to call the click event on all these ignore buttons, and let FaceBook's AJAX do the rest.</p> <p>How can I emulate the click without jQuery? I have Googled but haven't found the answer.</p>
javascript
[3]
4,352,637
4,352,638
Android - Disable all other items on dialog when clicked on another
<p>How to disable all other items on dialog when clicked on another? Below is my code</p> <pre><code>final CharSequence[] items = {"Red", "Green", "Blue"}; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle("Select Sources"); builder.setMultiChoiceItems(items, null, new OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if(items[which] == "Red"){ //Disabled Green and Blue items } } }); AlertDialog alert = builder.create(); alert.show(); </code></pre>
android
[4]
5,605,735
5,605,736
Select from Array to get ID based on Name
<p>Here is my var_dump:</p> <pre><code>array(2) { [1]=&gt; object(stdClass)#382 (3) { ["name"]=&gt; string(12) "Other fields" ["sortorder"]=&gt; string(1) "1" ["id"]=&gt; int(1) } [3]=&gt; object(stdClass)#381 (3) { ["name"]=&gt; string(6) "custom" ["sortorder"]=&gt; string(1) "2" ["id"]=&gt; int(3) } } </code></pre> <p>I need some PHP to select the 2nd object, obviously it wont always be the 2nd object, so I need to select it based on its ["name"] which will always be "custom".</p> <p>The below code give's me all the names but I just want "custom" and the get the ID of custom.</p> <pre><code>foreach ($profilecats as $cat) { $settings .= $something-&gt;name; } </code></pre>
php
[2]
2,526,068
2,526,069
Sending a string using a bundle
<p>I have two Activities, say Activity A and Activity B, which are both dialogs. When I click on a button on Activity A it triggers Activity B. When I'm on Activity B, I click on a button, which sends a string to Activity A by using a bundle, which Activity A receives. When I go back to Activity B to send another string,it causes Activity A which is currently behind it to force close and not send the string. I'm not sure why this is.</p> <p>Your help will be most appreciated Thank you.</p>
android
[4]
5,291,290
5,291,291
findViewById() not found id in nested layout?
<p>My xml :</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="240dp" android:layout_height="320dp" android:gravity="center" android:background="@drawable/borders" &gt;....&lt;LinearLayout android:id="@+id/arearight" android:layout_above="@+id/areabotleft" android:layout_below="@id/txtDate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignParentRight="true" android:gravity="center_vertical" &gt; &lt;ImageView android:id="@+id/img_sun" android:scaleType="fitXY" android:src="@drawable/sun-icon" android:contentDescription="@string/shop" android:layout_width="48dp" android:layout_height="48dp" /&gt; ...... </code></pre> <p>i use findViewbyid find img_sun (ImageView) but it not find ? LinearLayout nested in RelativeLayout. i should do ...get img_sun ?</p>
android
[4]
3,306,592
3,306,593
What is the idiomatic way of invoking a list of functions in Python?
<p>I have a list of callback functions that I need to invoke when an event is fired. Is this idiomatic python? </p> <pre><code>def first_callback(m): print 'first ' + m def second_callback(m): print 'second ' + m lst = [first_callback, second_callback] map(lambda x: x("event_info"),lst) #is this how you do it? </code></pre>
python
[7]
1,114,557
1,114,558
Bug in Treasure Hunt game for android
<p>I have placed images (ImageView) in relative layout and onClicking event I am setting it invisible. Now while playing my game I found one bug myself and i dont know how to solve it because whole logic depends on that ...Android takes Image as square i.e. WrapContent of width nd height eg boomrang It should be in U shape ..since android takes it square when i click in the blank space of boomrang i.e. in between that U part it gets found...When I place MatchStick(Which is 45 deg tilted) it again takes it as square ..and again if i touch at the near by area which should not happen but it finds the object ... See if this is the image </p> <p><img src="http://i.stack.imgur.com/BqEa9.png" alt="enter image description here"></p> <p>then when u click on the topmost black area even though it will get selected likewise many objects if i place in 45 deg it will cause bug</p> <p>How to solve this ? is there any way that i can make it happen that if click only this pixel than it should find the object? what will be solution for that ?</p>
android
[4]
260,565
260,566
pass function by reference
<p>Well, I know what references are and when it's use is obvious.</p> <p>One thing I really can't get is that when it's better to pass function by reference.</p> <pre><code>&lt;?php //right here, I wonder why and when function &amp;test(){ } </code></pre> <p>To avoid confusion, there're some examples as how I understand the references,</p> <pre><code>&lt;?php $numbers = array(2,3,4); foreach ($numbers as &amp;$number){ $number = $number * 2; } // now numbers is $numbers = array(4,6,8); $var = 'test'; $foo = &amp;var; //now all changes to $foo will be affected to $var, because we've assigned simple pointer //Similar to array_push() function add_key(&amp;$array, $key){ return $array[$key]; } //so we don't need to assign returned value from this function //we just call this one $array = array('a', 'b'); add_key($array,'c'); //now $array is ('a', 'b', 'c'); </code></pre> <p>All benefits of using the references are obvious to me, except the use of "passing function by reference", </p> <p>Question: When to pass function by reference (I've searched answer here, but still can't grasp this one) Thanks </p>
php
[2]
4,411,193
4,411,194
Check if this Monday is last Monday in a month
<p>I use this code from another question:</p> <pre><code>private bool NthDayOfMonth(DateTime date, DayOfWeek dow, int n){ int d = date.Day; return date.DayOfWeek == dow &amp;&amp; (d-1)/7 == (n-1); } </code></pre> <p>It works fine. But it not checks a last day ( for me it's when n = 5). How to modify it?<br> Thanks.</p>
c#
[0]
2,418,997
2,418,998
C2678 error on remove from list of custom datatypes
<p>I'm currently hard at work on an assignment piece, which contains several custom datatypes. I've run into a problem where list is complaining that I am trying to remove a custom data type from a list of that same data type.</p> <pre><code>Error 3 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'customer' (or there is no acceptable conversion) c:\program files (x86)\microsoft visual studio 10.0\vc\include\list 1194 1 Assignment 1 - Video Store MIS </code></pre> <p>The relevant code is here:</p> <pre><code>void customerCollection::removeCustomer(customer person) { customers.remove(person); } </code></pre> <p>and the custom data type does have a == operator defined:</p> <pre><code>bool customer::operator==(customer &amp;other) const { return (l_fullName == other.getName()) &amp;&amp; (l_contactNumber == other.getNumber()) &amp;&amp; (l_password == other.getPassword()) &amp;&amp; (l_username == other.getUsername()); } </code></pre> <p>Is there any reason that the list type can't see the overloaded operator?</p> <p>The customerCollection and customer data types are required parts of the program.</p> <p>[EDIT] The overloaded operator is defined as public in the header file.</p>
c++
[6]
5,111,244
5,111,245
Why Java implements so hard to reading a file
<p>I really don't know, why this is so complex and hard just for reading a file with a lot of classes</p> <ul> <li>InputStream</li> <li>DataInputStream</li> <li>InputStream</li> <li>BufferReader</li> </ul> <p>What are advantages of below? And what are philosophy at here?</p> <pre><code>private static String fileToString(String filename) throws IOException { InputStream resourceAsStream; resourceAsStream = "".getClass().getResourceAsStream(filename); DataInputStream in = new DataInputStream(resourceAsStream); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuilder builder = new StringBuilder(); String line; // For every line in the file, append it to the string builder while((line = reader.readLine()) != null) { builder.append(line); } return builder.toString(); } </code></pre>
java
[1]
1,660,981
1,660,982
Matplotlib: plot multiple graphs as subplots on the same figure when different functions in the same class call the plot routine?
<p>So, say I have a function plot(self) within the class Pendulum that calls plot. Then I have another function plot2(self) within the same class Pendulum that also calls plot. How would I set up pyplot such that both functions would set up multiple graphs as separate subplots on the same figure?</p>
python
[7]
113,561
113,562
a question related to Apple Push Notification Service iphone developement
<p>I have 1 basic question, server sends me badge number = 5 first time server sends me badgenumber = 3 second time when my application is not running</p> <p>but i seen that second time my bade number 3 is replaced by 5</p> <p>but in my application i need that second time my badge number will be seen 3 + 5 = 8</p> <p>is there any way to do it????</p>
iphone
[8]
1,839,478
1,839,479
Why SoundPool is not playing bigger file? - Android
<p>I am playing .ogg file in SoundPool, But it stops after 2-3 seconds.</p> <p>I referred this <a href="http://www.vogella.com/articles/AndroidMedia/article.html" rel="nofollow">LINK</a></p> <p>Can anybody please tell me?? Why it is not playing entire audio file?</p> <p>Thank you.</p>
android
[4]
4,344,041
4,344,042
How to download *.ics file from the browser in android?
<p>How to register a new MIME type in android? I am very much new to android. I need to download a *.ics file from the browser (Email attachment).but the browser response is unsupported file format.Can anyone help me ??? </p>
android
[4]
4,049,466
4,049,467
android app froze when received a call
<p>i a new programmer. i created an app and it works good. When i was playing in the app i got a call, did not answer and went back to application.</p> <p>application froze, could not do ANYTHING in the app. Had to exit and restart the app.</p> <p>how to avoid this problems.</p> <p>pls anyone teach me</p>
android
[4]
2,720,528
2,720,529
How to show power point presentations on web, without using Inerop or PowerPoint installation on server?
<p>Need to show power point presentations on web with its animations. Is there any converter to convert Presentations to Silverlight/flash/Html without using any Interop or PowerPoint installation on web server?</p>
asp.net
[9]
4,106,832
4,106,833
Close application javascript webview
<p>Is there a way to using javascript on a page in web view to close the application. I have a website using a web view and webviewclient and if the user does not agree to the terms and conditions on first load of that webpage for that device ID then I want the app to close.</p>
android
[4]
3,004,160
3,004,161
Javascript String to JSON
<p>How to can get this </p> <pre><code>var myString = 'a,b'; </code></pre> <p>in the following in most efficient way</p> <pre><code>var myObject = { a:1, b:1}; </code></pre> <p>I need 1 to be associated with each param. Thank you.</p>
javascript
[3]
2,150,641
2,150,642
Geting contents of javascript loaded in browser
<p>How do I get the contents of a loaded script at runtime without using ajax to read the script from the source?</p>
javascript
[3]
4,912,791
4,912,792
the dir function in python
<pre><code>help(dir): </code></pre> <blockquote> <pre><code>dir([object]) -&gt; list of strings If called without an argument, return the names in the current scope. Else, return an alphabetized list of names comprising (some of) the attributes of the given object, and of attributes reachable from it. If the object supplies a method named __dir__, it will be used; otherwise the default dir() logic is used and returns: for a module object: the module's attributes. for a class object: its attributes, and recursively the attributes of its bases. for any other object: its attributes, its class's attributes, and recursively the attributes of its class's base classes. </code></pre> </blockquote> <p>i found maybe there are problems in the help file of dir builtin function.for example:</p> <pre><code>class AddrBookEntry(object): 'address book entry class' def __init__(self,nm,ph): self.name=nm self.phone=ph def updatePhone(self,newph): self.phone=newph print 'Updated phone # for :' ,self.name dir(AddrBookEntry('tom','123')) ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'name', 'phone', 'updatePhone'] </code></pre> <p>1.<code>dir()</code> can list the method of object ,not only attributes<br> the <code>updatePhone</code> is method ,not attribute. </p> <p>2.how can i know which is the attribute,which is method in the output of dir()? </p>
python
[7]
2,625,199
2,625,200
jquery add newline or linebreak on enter
<p>I have a simple textarea. Is it possible with jquery to add a 'br' when I hit the enter button? I've read around here, and the only solution I see is to add a linebreak at the very end of the val().</p> <p>But I need it to work on every enter press.</p>
jquery
[5]
1,232,555
1,232,556
jQuery toggle show Issue
<pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { $('#showhidetarget').show(); $('a#showhidetrigger').click(function () { $('#showhidetarget').toggle(400); }); }); &lt;/script&gt; </code></pre> <p>I Want this script to be hidden on load and should then be shown everytime, then it can only be hidden if i click on that hide action, because my search form is on toggle, so if someone searches this the form gets closed on the result page which i don't want. Thank you</p>
jquery
[5]
3,148,244
3,148,245
Java Calendar: calculate start date and end date of the previous week
<p>What is most convenient and shortest way to get start and end dates of the previous week? Example: today is 2011-10-12 (input data),but I want to get 2011-10-03 (Monday's date of previous week) and 2011-10-09 (Sunday's date of previous week).</p>
java
[1]
1,371,396
1,371,397
jQuery element binding is delayed, how to avoid it?
<p>I am trying to create a few elements &amp; then bind them to different methods, e.g., </p> <pre><code>for( key in object ){ var vals = someMap[key]; var element = jQuery(parentElements[key]).find('.someClass'); var markup; for( someKey in vals ){ markup += "&lt;a href='#' &gt;" + vals[someKey] + "&lt;/a&gt;"; } jQuery(element).empty().html(markup); jQuery(element).find('a').bind('click', function(element){ alert(key); }); } </code></pre> <p>Now after running this code, I am able to create all the anchor elements, and so the alert should print the key within which the anchor tags were created, e.g., if I had 2 keys key1 &amp; key2, so anchor tags were created inside the parentElements[key1] &amp; parentElements[key2], so whenever I click on an anchor tag, I should have got alerted with either key1 or key2, depending on whose anchor tag i clicked. But the problem is that always key2 is alerted. So , I am thinking that the issue here might be that the binding is delayed till a click is performed, and when it is performed, the value of key alerted would always be the last key, i.e., key2. I am not very sure what the issue here is, but since its always the last key being alerted, I have an impression that the binding is happening at the end, when both the loops have completed.</p> <p>So is there something I am doing wrong, or should I do it in a different way? Any help appreciated.(maybe the question is not very explanatory, please let me know incase I should replace it with something else).</p>
jquery
[5]
3,930,594
3,930,595
Find device type(smartphone/tablet) in android
<p>How can I find the device is a smart phone or table through my program? I tried with all fields of android.os.Build class. The info which I got is </p> <p>OS Version: 2.6.35.7(DXKL2)<br/> OS API Level: 10<br/> Device: GT-S5360<br/> Model (and Product): GT-S5360 (GT-S5360)<br/> Board: totoro<br/> Brand: samsung<br/> CPU_ABI: armeabi<br/> Display: GINGERBREAD.DXKL2<br/> Fingerprint: samsung/GT-S5360/GT-S5360:2.3.6/GINGERBREAD/DXKL2:user/release-keys<br/> Host: DELL152<br/> Id: GINGERBREAD<br/> Manufacturer: samsung<br/> Type: user<br/> User: root <br/></p> <p>This information is not helpful for me. Can someone tell me how to find it?</p>
android
[4]
5,960,765
5,960,766
Jcarousel Active class
<p>There are other posts on this, but mine is set up slightly differently and I can't quite figure out the last step.</p> <p>This is my Jquery for the Jcarousel slider:</p> <pre><code>function mycarousel_initCallback(carousel) { jQuery('.jcarousel-control a').bind('click', function() { carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr("id"))); return false; }); jQuery('#mycarousel-next').bind('click', function() { carousel.next(); carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value); return false; }); jQuery('#mycarousel-prev').bind('click', function() { carousel.prev(); carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value); return false; }); jQuery('#offerings li a').bind('click', function() { var index = $(this).attr("id").split("_"); carousel.scroll(jQuery.jcarousel.intval(index[1])); //carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text())); $("#offerings li a").removeClass("active"); //Remove any "active" class $(this).addClass("active"); return false; }); }; </code></pre> <p>This works great for adding an active class when you click on a link in the external control (#offerings), but when you use the prev and next buttons, it does not update the menu active class.</p> <p>Any help appreciated :)</p>
jquery
[5]
2,081,042
2,081,043
Android Listview Replacing Strings
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/14018950/android-replace-strings">Android Replace Strings</a> </p> </blockquote> <p>Below is my listview. The data are gathered from the sdcard and listed out on a listview. But the filenames retrieved from the sdcard ends with ".txt" How do I remove the ".txt" from my listed filenames? </p> <pre><code>mainListView = (ListView) getActivity().findViewById( R.id.mainListView ); myList = new ArrayList&lt;String&gt;(); File sdCard = Environment.getExternalStorageDirectory(); file = new File(sdCard.getAbsolutePath() + "/St/") ; File list[] = file.listFiles(); for( int i=0; i&lt; list.length; i++) { myList.add( list[i].getName() ); } listAdapter = new ArrayAdapter&lt;String&gt;(getActivity(),R.layout.simplerow, myList); mainListView.setAdapter( listAdapter ); mainListView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // TODO Auto-generated method stub String textToPass = myList.get(position); Intent i = new Intent(getActivity(), ViewActivity.class); i.putExtra("textToPass", textToPass); startActivity(i); } }); </code></pre>
android
[4]
4,538,560
4,538,561
I have an array contains string values, in that same name i have image in drawable.so i want to add in integer array how to do that?
<p>I have an array contains string values, in that same name i have image in drawable.so i want to add in integer array how to do that? ex string newarray[]={"jj","kk","ll"}; i want to access R.drawable.jj ,R.drwable.kk,R.drawable.ll</p>
android
[4]
3,109,952
3,109,953
File upload in iphone
<p>I am developing an iphone application which needs to upload some image files to server.The images needs to be uploaded as binary data.I converted the image to NSData using [NSData dataWithContentsOfFile:filepath];</p> <p>But i dont know how to convert this NSData to Binary data.Looking for a solution</p> <p>Thanks,</p>
iphone
[8]
5,871,909
5,871,910
Problem with dataset to sql
<pre><code>{ string selectDesc = @" SELECT [Descripion id], [Sub Collection FROM Descripion "; DataSet dsD = new DataSet(); SqlCommand comD = new SqlCommand(); comD.Connection = con; comD.CommandText = selectDesc; SqlDataAdapter daD = new SqlDataAdapter(); daD.SelectCommand = comD; SqlCommandBuilder cbD = new SqlCommandBuilder(da); daD.Fill(dsD, "Descripion"); DataRow new_row_Desc = dsD.Tables[0].NewRow(); new_row_Desc["Descripion id"] = 58589; new_row_Desc["Sub Collection"] = TextBox18.Text; dsD.Tables[0].Rows.Add(new_row_Desc); daD.Update(dsD.Tables[0]); } </code></pre> <p>I am getting this error:</p> <blockquote> <p>Update requires a valid InsertCommand when passed DataRow collection with new rows.</p> </blockquote> <p>What is the problem?</p>
c#
[0]
4,206,741
4,206,742
PHP: working with checkboxes
<p>I have a form, and inside it there's a while() with checkboxes. </p> <p>I wish to have so when you mark and then press submit, the message will remove.</p> <p>Now, I have the checkboxes, and the submit button and so. Now all my checkboxes are like this:</p> <pre><code> &lt;input class="cbPick" name="cbPick" type="checkbox" value="&lt;?php echo $id; ?&gt;"&gt; </code></pre> <p>How can i work with that in PHP? Should i do, $_POST["cbPick"] to know if its marked or not ?</p> <p>And when i have more with these, how can i know which is which?</p>
php
[2]
1,483,048
1,483,049
Why in C++ extra method qualification is not allowed?
<p>Is there a reason we can not write in C++</p> <pre><code>class MyClass { public: void MyClass::MyMethod(); // &lt;---- } </code></pre> <p>it gives 'extra qualification' or some such compile error but is there a reason for that or it's just so happened?</p>
c++
[6]
6,032,741
6,032,742
Newly added elements on page aware of previously defined Javascript code
<p>In this very simplified and minimized example click event handler has been defined for every <em>a</em> tag (simple alert is displayed after link is clicked). Once you click the button, second link is added to the page. </p> <p>But if you click this newly added link, event handler wan't be called. Any idea why? What should be added/changed so that newly added elements are aware of the scripts defined on the main page?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $("document").ready(function() { $("a").click(function() { alert("link is clicked"); return false; }); $("#btn").click(function() { $("#second").html("&lt;a href='#'&gt;Second link&lt;/a&gt;"); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="first"&gt; &lt;input id="btn" type="button" value="Get new content"/&gt; &lt;a href="#"&gt;Original link&lt;/a&gt; &lt;/div&gt; &lt;div id="second"/&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In this particular case, what should be done so that second link is aware of event handler defined in <em>script</em> section so that alert is being displayed after link is clicked?</p> <p>What's your advice on resolving these kind of situations? How do you make newly added elements on the page be aware of previously defined Javascript code?</p>
jquery
[5]
2,925,339
2,925,340
Maximum size of a method in java?
<p>I come to know that the maximum size of a method in java is 64k. And if it exceeds, we'll get a compiler warning like "Code too large to compile". So can we call this a drawback of java with this small amount of memory.</p> <p>Can we increase this size limit or is it really possible to increase ? </p> <p>Any more idea regarding this method size ? </p>
java
[1]
4,016,118
4,016,119
Use Android framework from console apps
<p>I have a feeling I know the answer to this question, but I figure I would see what SO had to say.</p> <p>I'm hoping to create a console app that can take an .apk file and extract metadata (such as version name/version number). I'm able to use <code>PackageManager.getPackageArchiveInfo()</code> from my Android app just fine, but I'd need to be able to call it from the command line. However, the classes in the android.jar appear to just be stubs, so it doesn't end up working.</p> <p>Does anyone know of a way to do that?</p>
android
[4]
1,660,781
1,660,782
I would like to move an element to the left using loop
<p>I bet I've got elementary question, but I couldn't solve it for two nights. I've got 1 "ul" element and I just want it to move any amount of pixels every e.g. 2 sec to the left. I want him to move like this step by step and then come back to the original position and start moving again. I've been stucked, my script only moves it to the final position and finish. </p> <pre><code>window.onload = function moveUl(){ var eUl = document.getElementById('change'); var eLi = eUl.getElementsByTagName('li'); x = -300; function move(){ for(i=0;i&lt; eLi.length;i++){ eUl.style.marginLeft = i*x+'px'; } } setInterval(move,1000); } </code></pre> <p>This is the simpliest I can think of. I know this script executes whole loop after 1 sec, but I try to do something like this : Move this element to the left, wait, move more to left and so on. </p>
javascript
[3]
5,449,603
5,449,604
Using the HTTP Accept Header from JavaScript
<ul> <li>I have a web service that performs a database search. It accepts both GET and POST requests, and can return data in either JSON, CSV, or HTML format based on the HTTP <code>Accept</code> header.</li> <li>I have a web page that makes an Ajax request to this web service, and displays the search results.</li> <li>I have been asked to add a button to this page that will allow the user to save the data in CSV format.</li> </ul> <p>Earlier this year, someone was <a href="http://stackoverflow.com/questions/2515162/need-to-save-html-table-to-csv-using-javascript">in the same boat</a>, and got the response</p> <blockquote> <p>You cannot do it using javascript capabilities, since javascript has no permission to write on client machine, instead you can send request to server to create csv file and send it back to client.</p> </blockquote> <p>So I added a button that does</p> <p><code>window.open("MyWebService.cgi?" + theSameQueryStringIPassedInTheAjaxCall)</code>,</p> <p>which opens the HTML version in a new browser tab. I want the CSV version. Is there a way I could pass an <code>Accept: text/csv</code> HTTP header? (I know how to do it with XMLHttpRequest and setRequestHeader, but that doesn't help me.)</p>
javascript
[3]
4,361,949
4,361,950
How do I use INTERNET_HANDLE_TYPE_INTERNET to constrain the effects of END_BROWSER_SESSION to the current WebBrowser?
<p>We have a WebBrowser that needs to have login information reset. </p> <p>There is a solution in <a href="http://stackoverflow.com/questions/1335617/is-it-possible-to-sandbox-ie-in-a-windows-form">this</a> question that suggests using <code>INTERNET_HANDLE_TYPE_INTERNET</code> with <code>INTERNET_OPTION_END_BROWSER_SESSION</code>. However, I'm not sure where <code>INTERNET_HANDLE_TYPE_INTERNET</code> should go.</p> <pre><code>private const int INTERNET_OPTION_END_BROWSER_SESSION = 42; private const int INTERNET_HANDLE_TYPE_INTERNET = 1; [DllImport("wininet.dll", SetLastError = true)] private static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength); </code></pre> <p>I call it right before I navigate:</p> <pre><code>InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0); browserCtrl.WebBrowser.Navigate(loginUrl); </code></pre>
c#
[0]
5,152,946
5,152,947
automated job triggering and cron job execution in php
<p>I am currently developing a notification system which gets data from a BUG tracking system and checks if a specific BUG was attended or not within a threshold time , say 2 weeks. If its more than 2 weeks , an automated email should be sent to 2 persons(person who created the BUG and person from the QA team). </p> <p>I am running apache, php, curl on win server 2003. I am currently thinking about running a php script every night, which monitors all the BUG reports to check if any of them crossed the threshold time , and send an email if necessary. i am currently relying on windows task scheduler to automate email delivery- running a batch file with a curl -xxxx command in it. </p> <p>Is there a better way to implement this Job monitoring script? Any advise will be really helpful and appreciated.</p> <p>Thanks Rajesh</p>
php
[2]
3,064,251
3,064,252
Bitmap working fine on normal density; and getting blank screen for High density
<p>I have written the code for splitting the bitmap into smaller bitmaps. And displaying each into each cell (ImageView) of Grid View. Its works fine on NORMAL DENSITY (i.e. 160). But for higher density I am getting blank screen.</p>
android
[4]
325,274
325,275
Complete action using dialog does not appear on some devices
<p>I try to setup my application to be able to handle call event from system contact book. As it was described in documentation and answered to many similar questions I have added the following to my manifest:</p> <pre><code> &lt;activity android:name=".ui.ExternalCallLauncher" android:excludeFromRecents="true" &gt; &lt;intent-filter android:icon="@drawable/ic_launcher"&gt; &lt;action android:name="android.intent.action.CALL"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;action android:name="android.intent.action.CALL_PRIVILEGED"/&gt; &lt;data android:scheme="tel"/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>But I found out that this does not work on some devices. It works in Samsung Galaxy Tab 7 (v 2.1), and does not work on Samsung Nexus S3 (v 4.1.2), Samsung Galaxy Tab 10.1 (v 4.0.2).</p> <p>What I'm doing wrong?</p> <p>Thanks in advance</p>
android
[4]
1,930,978
1,930,979
How to avoid duplicate names of class and method?
<p>Currently I use same convention for class names and method names. They have a leading capital letter without prefix. And I don't use "Get" prefix to get an attribute. However, I meet a name conflict problem in the following code</p> <pre><code>class Material {}; class Background { public: Material* Material() const {return m_material;} // Name conflict void SetMaterial(Material* material) {m_material = material;} private: Material* m_material; }; </code></pre> <p>What is the easiest way to solve the problem but keeping or with minimum modification of my conventions? Thanks a lot!</p>
c++
[6]
1,749,071
1,749,072
Detecting activex object using modernizr
<p>How to detect activex object using modernizr?any help will be appreciated Thank you</p>
javascript
[3]
3,483,158
3,483,159
Append new line to Java StringBuilder with Outlook Email
<p>I'm using a StringBuilder that is going to be passed to a email service that I created so that the StringBuilder is set as the body of the email being sent. This is what I have now:</p> <pre><code>StringBuilder buffer = new StringBuilder(); buffer.append("Hello World! " ); buffer.append(something.getMessage()); buffer.append (" \n "); buffer.append("Welcome to " ); buffer.append(something.getAnother()); buffer.append (" \n "); emailObject.setBody(buffer.toString()); emailService.sendEmail(emailObject); </code></pre> <p>I would like the message to be displayed in multiple lines, but for some reason even with \n the message still turns out to be in one single continuous line. Does anyone have any idea why this is not working?</p>
java
[1]
4,374,002
4,374,003
removing one character from a string
<p>Given the address: 12345 West Palm Rd., #7B Daytona, FL</p> <p>I am trying to remove the '.' character from 'Rd.' and the '#' character from '#7B'. However, I would like for these characters to be removed no matter what string is given...</p> <p>Is there an easy way to do this?</p> <p>I am familiar with strstr but it seems like a complicated way to do what I am trying to do...</p> <p>I appreciate any advice.</p>
php
[2]
822,270
822,271
Google+ Platform for Android - getCurrentPerson
<p>I use the Google+ Platform for Android with</p> <pre><code>PlusClient plusClient = new PlusClient.Builder(this, this, this).setScopes(Scopes.PLUS_LOGIN).build(); </code></pre> <p>In the onConnected-Listener I want to read the data of the logged in user</p> <pre><code>@Override public void onConnected() { super.onConnected(); Person person = plusClient.getCurrentPerson(); } </code></pre> <p>The method call getCurrentPerson returns null. Has anyone managed to read the user-data?</p>
android
[4]
3,687,535
3,687,536
Use php to open and click a button?
<p>I am wondering if there is a way to open a document with php and click a button. I can open the document with xpath using a new DOM document, but my knowledge isn't that good. If anyone can help, I'd appreciate it. Thanks</p> <p>More info: I have this site I go to and I can poke people, not facebook. I open up there page and I want to click it without me having to do it manually. I want to have the most pokes but I dont want to do it manually so i thought of making this script to do it. I use curl to open the page and then I dont know how to click the form button to submit the poke.</p> <p>thanks</p>
php
[2]
4,368,198
4,368,199
How to get current PHP page name
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4221333/get-the-current-script-file-name">Get the current script file name</a> </p> </blockquote> <p>I've a file called <code>demo.php</code> where I don't have any GET variables in the url so If I want to hide a button if am on this page I can't use something like this :</p> <pre><code>if($_GET['name'] == 'value') { //Hide } else { //show } </code></pre> <p>So I want something like</p> <pre><code>$filename = //get file name if($filename == 'file_name.php') { //Hide } else { //show } </code></pre> <p>I don't want to declare unnecessary GET variables just for doing this..</p>
php
[2]
21,104
21,105
ASP.NET Can I manually submit my form at code behind stage
<p>I want to set a hidden field for a form when I set a button then have this maintain its state through all subsequent button clicks. </p> <p>Is it possible to do a form post in the code behind to faciliate this, at the moment I'm doing a response.redirect but this loses the state of the button.</p>
asp.net
[9]
472,143
472,144
how to exit android application from exit button?
<p>I am finding the way to exit android application to home screen(android phone).</p> <p>My code is not completely exit application but it turn to the root activity of application.</p> <h1>Here is my code</h1> <pre><code>//Expression Button exit = (Button) findViewById(R.id.exit); exit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub finish(); System.exit(0); } }); </code></pre> <p>Can you tell me how to exit application and go to home screen of android phone?</p> <p>Regards,</p>
android
[4]
2,538,356
2,538,357
how to sum two or three big number?
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/2148149/how-to-sum-a-large-number-of-float-number">how to sum a large number of float number?</a><br> <a href="http://stackoverflow.com/questions/565150/bigint-in-c">&ldquo;BigInt&rdquo; in C?</a><br> <a href="http://stackoverflow.com/questions/1559737/handling-integer-having-large-number-of-digits">handling integer having large number of digits</a> </p> </blockquote> <p>I want to sum two different number . think we have two different number that length of anyone is more than 20 number , how can I sum both ? as far as I know , I can not do this with int .</p> <p>like these :</p> <p>26565468416574156465651652464234245645945643526 + 6264635454513215421541412154121541544455412315</p>
c++
[6]
752,361
752,362
Determine the most common occurance in an array
<p>Assume I have an array of doubles that looks like the following:</p> <pre><code>Array[10] = {10, 10, 10, 3, 10, 10, 6, 10, 10, 9, 10} </code></pre> <p>I need a function that can determine what the MAJORTY vote is in the array, in this case "10" because it is the number that appears the most often... And of course there is the situation when no majority exists (where they are equal), in that case I need to throw an exception...</p> <p>Any clues? Aside from doing some really nasty looping on the array (for each index, determine how many exist with the same value, store a count in the array, and then scan the count array for the highest number and the value at that position is the winner, etc...)</p> <p>Thanks,</p>
java
[1]
1,921,984
1,921,985
Copy 1 file content in another in c#
<p>I want to copy select parts of one file into another with C#</p> <p>For example, suppose I have a file with following contents:</p> <pre><code>&lt;div id="1"&gt; contents of this div.. &lt;/div&gt; &lt;div id="2"&gt; contents of this div.. &lt;/div&gt; &lt;div id="3"&gt; contents of this div.. &lt;/div&gt; </code></pre> <p>Now if I want to copy only the line <code>&lt;div id="2"&gt; contents of this div.. &lt;/div&gt;</code> into a new file. Then how can i do this efficiently?</p>
c#
[0]
5,222,444
5,222,445
JavaScript - cannot set property of undefined
<p>My code:</p> <pre><code> var a = "1", b = "hello", c = { "100" : "some important data" }, d = {}; d[a]["greeting"] = b; d[a]["data"] = c; console.debug (d); </code></pre> <p>I get the following error: Uncaught TypeError: Cannot set property 'greeting' of undefined.</p> <p>I'm trying to do something similar to an associative array. Why isn't this working?</p>
javascript
[3]
5,404,555
5,404,556
Error converting miles to kilometers
<p>I'm trying to learn python and am attempting to create a simple formula that converts miles to kilometers and returns some text with the conversion.</p> <p>Here's what I have:</p> <pre><code>def mile(x): z = x * 1.609344 print "%.2f" % z x = float(raw_input("How many miles are you traveling? ")) z = mile(x) print "That's about % kilometers." % z </code></pre> <p>Can someone explain why this doesn't work? I could definitely set up the mile function to print a sentence with the conversion, but I didn't want to do that. </p>
python
[7]
1,805,442
1,805,443
Need Help With Middle Click To Open In New Tab
<p>I have a custom button add-on for Firefox that will goes to Facebook in the currently viewing tab and would like to add middle click to open Facebook in a new tab but im not sure how. I looked around and found that I need to use the if window.open(url) but im not sure where to put them to get it to work. Here is the current java script code.</p> <p>EDIT: The button is on the Firefox toolbar, not in a webpage. Link to add on <a href="https://addons.mozilla.org/en-US/firefox/addon/facebook-button/" rel="nofollow">https://addons.mozilla.org/en-US/firefox/addon/facebook-button/</a></p> <pre><code>CustomButton = { 1: function () {const url = "http://www.facebook.com" document .getElementById("content") .webNavigation .loadURI(url, 0, null, null, null) }, } </code></pre> <p>Thanks for any help and guidance, If you see anything else wrong with the code, feel free to mention it.</p>
javascript
[3]
4,085,577
4,085,578
What is the difference between these codes, and what does the repr do?
<p>1.</p> <pre><code>&gt;&gt;&gt; s = u"4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf" &gt;&gt;&gt; print s 4-12个英文字母、数字和下划线 &gt;&gt;&gt; print repr(s) u'4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf' </code></pre> <p>2.</p> <pre><code>print repr("4-12个英文字母、数字和下划线") '4-12\xb8\xf6\xd3\xa2\xce\xc4\xd7\xd6\xc4\xb8\xa1\xa2\xca\xfd\xd7\xd6\xba\xcd\xcf\xc2\xbb\xae\xcf\xdf' </code></pre> <p>1 and 2 are different, but the original string is the same,both are '4-12个英文字母、数字和下划线'</p> <p>what does the repr exactly do?</p> <p>the same value is :</p> <pre><code>&gt;&gt;&gt; print '4-12个英文字母、数字和下划线'.decode('gb2312').encode('unicode-escape') 4-12\u4e2a\u82f1\u6587\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf </code></pre>
python
[7]
1,758,377
1,758,378
ASP.net HTTP 404 - File not found instead of MaxRequestLength exception
<p>I have a file upload control on my webpage. The maximum request length is set to 8 MB (maxRequestLength = 8192). I also have server validation that throws an error if the file is more than 4MB. The reason that its 8MB in the config is the leverage that's given to the user and also so that the application can be tested.</p> <p>If I upload a file that's 9MB, I get thrown an exception "Maximum request length exceeded.", which is fine and working as expected. But when I try to upload a file that's 1GB, it shows me a HTTP 404 - File not found. Can someone please explain why this is happening and how can I get it to throw me a maxRequestLength exception?</p> <p>I'm using IIS6.</p> <p>Thanks.</p>
asp.net
[9]
1,809,764
1,809,765
Converting string to digits in Python
<p>I have a string:</p> <pre><code>x = "12.000" </code></pre> <p>And I want it to convert it to digits. However, I have used int, float, and others but I only get <code>12.0</code> and i want to keep all the zeroes. Please help!</p> <p>I want <code>x = 12.000</code> as a result.</p>
python
[7]
2,976,395
2,976,396
Android:How to change the GridView Images while clicking the imageview
<p>I am developing a game in which i used 4*3 grid size using gridview.i initially loaded images for each imageView in gridView.i want to change the images while clicking the previous image.</p>
android
[4]
4,735,318
4,735,319
How to pdb Python code with input?
<p>I'm debugging Python code with pdb. The code need input from stdin, like:</p> <pre><code>python -m pdb foo.py &lt; bar.in </code></pre> <p>Then the pdb will accept the bar.in as commands. How to tell pdb that the input is for foo.py and not for pdb?</p>
python
[7]
5,536,950
5,536,951
All combinations of a list
<p>I'd like to be able to take a list like this</p> <pre><code>var list = new List&lt;int&gt;{0,1,2}; </code></pre> <p>And get a result like this</p> <pre><code>var result = new List&lt;List&lt;int&gt;&gt;{ new List&lt;int&gt;{0,1,2}, new List&lt;int&gt;{0,2,1}, new List&lt;int&gt;{1,0,2}, new List&lt;int&gt;{1,2,0}, new List&lt;int&gt;{2,0,1}, new List&lt;int&gt;{2,1,0} }; </code></pre> <p>I'm not interested in sets with missing numbers, just combinations of the numbers that exist.</p> <p>Any ideas?</p> <h1>Also, I've looked into solutions like <a href="http://stackoverflow.com/questions/3319586/getting-all-possible-permutations-from-a-list-of-numbers">Getting all possible permutations from a list of numbers</a> already, and they don't fit. That one gives me something like this</h1> <pre><code>var result =new List&lt;List&lt;int&gt;&gt;{ //[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] //Serialized the result to JSON so it would be quicker. }; </code></pre> <h1>And it doesn't spit out all of the combinations.</h1>
c#
[0]
5,108,946
5,108,947
C++: Redefine one or the other operation in the child class
<p>In the following code:</p> <pre><code>class GraphicalCardDeck : public CardDeck, public GraphicalObject { public: virtual void draw () { return CardDeck::draw(); } virtual void paint () { GraphicalObject::draw(); } } GraphicalCardDeck gcd; gcd-&gt;draw(); // selects CardDeck draw gcd-&gt;paint(); // selects GraphicalObject draw </code></pre> <p>When in the class <code>CardDeck</code> there is a function named <code>draw</code>, and in the class <code>GraphicalObject</code> there is a function named <code>draw</code>.</p> <p>The book mentions a problem when we do:</p> <pre><code>GraphicalObject* g = new GraphicalCardDeck(); g-&gt;draw(); // opps, doing wrong method! </code></pre> <p>Why will it call the wrong method? It will not call the function <code>draw</code> in the class <code>CardDeck</code> as we define? </p> <p>Thank you.</p>
c++
[6]
3,476,974
3,476,975
Create Generic Method in C#
<p>I have the following structure:</p> <pre><code>public enum MyTypes { Type1 = 1, Type2 = 2, Type3 = 3 } public abstract class class1 { int id; string name; MyType type; } public class class2 : class1 { } public class class3 : class1 { } public class class4 : class1 { } </code></pre> <p>now what I want to do is to make a generic method , I want to give it the type of object say class 3 and it will create object from class 3 and define it's variables and return it to be able to add it to a list of class1 </p> <p>like that </p> <pre><code>private class1 myFunction (MyType t , int id , string name) { T obj = new T(); obj.type = t ; obj.id = id ; obj.name = name; return obj; } </code></pre> <p>how to create this generic method ?</p> <p>please Help me as soon as you can</p> <p>Thanks in Advance</p>
c#
[0]
5,260,070
5,260,071
Displaying paused/static analogue clock
<p>My application needs to display the time. Rather then displaying time as 11:00 I am wondering whether it is possible to have to have static/paused/stopped analogue clock showing 11' o clock?</p>
android
[4]
5,235,701
5,235,702
Can someone teach me how to write this Paragraph Entry as a boolean expression?
<p>Note: I am a beginner Programmer but love the hobby and I'm wanting to get a degree in computer science so I'm not to experienced so if anyone has tips that may benefit me as a beginner that'd be awesome. But here is the question. </p> <p>Chicago's Wrigley Field is a baseball field with a vine-covered wall in the outfield, that has a railing above the wall. A ball that hits the wall and does not leave the playing field is sometimes still in play and sometimes a dou- ble according to the following rules: A ball striking the railing and rebounding onto the playing field is still in play. A ball that lodges in the screen that is attached to the bleacher wall is a double. A ball that lodges in vines on the bleacher wall is a double. A ball entering the vines on the bleacher wall and rebounding onto the playing field is still in play. A ball that hits the wall is ruled a double IF (condition), else the ball is still in play. </p> <p>Rewrite this as a single Boolean condition of the form??</p> <p>I almost clueless!</p>
java
[1]
5,250,124
5,250,125
C++ typecasting when passing std::string as function argument
<p>Is passing a string by <code>""</code> equivalent to passing a string by calling <code>std::str("")</code> in C++?</p> <p>e.g. given a function which accepts <code>std::str</code> as an argument:</p> <pre><code>void funcA(std::string arg) { arg = "abc"; } </code></pre> <p>Should I call it by <code>funcA(std::string("abc"));</code> or <code>funcA("abc");</code> ? i.e. is the second version a typecast from an array of char?</p>
c++
[6]
581,782
581,783
Not able to dynamically add the event handler to a button element using jQuery
<p>In this fiddle, i am not able to get the <a href="http://jsfiddle.net/saravanan/YNM68/" rel="nofollow">Dynamic Event Handler</a></p> <p>onclick event to be triggered for the dynamically generated button.</p>
jquery
[5]
843,714
843,715
Segmentation fault,C++,g++,
<p>I have this simple program, when I run this program, I get segmentation fault, I can not recognize where is my mistake. any help welcomed.(segmentation fault for Di>=27). The point is that when I remove function immediately segmentation fault disappears. Or when I transform the function to a void function. I know there is a leak memory because not uses delete operator, it causes leak memory,but easily is not responsible for segmentation fault(This leak memory is very far to produce segmentation fault).for simplicity I didn't use delete operator.</p> <pre><code> #include &lt;iostream&gt; #include&lt;complex&gt; using namespace std; const int Di=27; typedef struct { complex&lt;double&gt; Matrix[Di][Di][Di][Di]; } O; O initializing(int ); int main() { O * Operator=new O[1]; int p; int n; Operator[0]=initializing(n); cout&lt;&lt;"hi"; return 0; } O initializing(int point) { int i,j,m,n; O *Operator=new O[1]; for(i=0;i&lt;Di-1;i++) for(j=0;j&lt;Di-1;j++) for(n=0;n&lt;Di-1;n++) for(m=0;m&lt;Di-1;m++) Operator[0].Matrix[i][j][m][n]=2; cout&lt;&lt;Operator[0].Matrix[Di-1][Di-1][Di-1][Di-1]; return Operator[0]; } </code></pre>
c++
[6]
3,743,421
3,743,422
Reading web contents, getting exception
<p>Im making an Android application, and for that i have to get JSON content from a URL (which is output by some python script).</p> <p>I found a method for that on SO, but i can't get it to work. This is the code:</p> <pre><code>public String webGet(String URL) throws Exception { BufferedReader in = null; try { HttpClient client = new DefaultHttpClient(); client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "android"); HttpGet request = new HttpGet(); request.setHeader("Content-Type", "text/html; charset=utf-8"); request.setURI(new URI(URL)); // Crashes after executing this line HttpResponse response = client.execute(request); in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readLine()) != null) { sb.append(line + NL); } in.close(); String page = sb.toString(); //System.out.println(page); return page; } finally { if (in != null) { try { in.close(); } catch (IOException e) { Log.d("BBB", e.toString()); } } } } </code></pre> <p>This crash happends after this line:</p> <pre><code>HttpResponse response = client.execute(request); </code></pre> <p>It then simply jumps to the <code>finally</code> part and all i can get from the exception message is that something was <code>null</code>. That's all it says.</p> <p>Anyone any idea what the problem could be?</p> <hr> <p>Screenshot of the Exception description:</p> <p><img src="http://i.stack.imgur.com/QVVue.png" alt="enter image description here"></p>
java
[1]
5,802,882
5,802,883
finding index of element
<p>I have some HTML like this:</p> <pre><code>&lt;div class="TopClass"&gt; &lt;div class="ContentClass"&gt; &lt;div class="ActionClass"&gt;action&lt;/div&gt; &lt;/div&gt; &lt;div class="ContentClass"&gt; &lt;div class="ActionClass"&gt;action&lt;/div&gt; &lt;/div&gt; &lt;div class="ContentClass"&gt; &lt;div class="ActionClass"&gt;action&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I'm looking to get the index of the action class relative to TopClass; if the user clicks on the second Action class, it should return 2.</p> <pre><code>$('.ActionClass').click(function () { alert($(this).parent().parent().index()); // not working }); </code></pre>
jquery
[5]
325,253
325,254
SQLConnection Objects Declarative vs C# code
<p>I am curious about developer opinions regarding creating and using SQL connection objects. </p> <p>We are transitioning our software application from ASP to ASP.Net, i.e. new features are being added using .Net.</p> <p>We have created SQL Connection objects through C# code and and through the designer which declares the connection object in asp markup. We've also created the connection object bypassing the designer and just coding the asp markup. We can add parameters and SQL statements to the asp designer/markup that make the connection object quite usable for the application... or we can do this through code.</p> <p>What are the opinions of experienced .Net developers on the options for creating and using the connection object. Pros/cons for using c# code vs. the asp interface (design tool and markup).</p>
asp.net
[9]
2,794,859
2,794,860
.mov files not working in iphone
<p>In my App i have .mov audio files.But it doesn't work.But the mp3 files are working fine in the App.I have already added the audiotoolbox,Foundation,AVFoundation frame works.Still it is not working.Please help.Thanks in advance. I used this code:</p> <p>NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Floating arms sp 1" ofType:@"MOV"]]; MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];</p> <pre><code>[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; moviePlayer.controlStyle = MPMovieControlStyleDefault; moviePlayer.shouldAutoplay = YES; [self.view addSubview:moviePlayer.view]; [mp.view addSubview:moviePlayer.view]; [moviePlayer setFullscreen:YES animated:YES]; </code></pre>
iphone
[8]
4,896,777
4,896,778
How to implement "Press Any Key To Exit"
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1449324/how-to-simulate-press-any-key-to-continue">How to simulate &ldquo;Press any key to continue?&rdquo;</a> </p> </blockquote> <p>Here is a simple code in C++:</p> <pre><code>cout &lt;&lt; "Press Any Key To Exit..."; </code></pre> <p>What is the code for closing program when user presses any button on keyboard. What should I write after above code? I know I can use cin.ignore(); and if user presses Enter the program will close, But my target is any key.</p> <p>How to do that?</p>
c++
[6]
5,713,507
5,713,508
Populate DropDown and Get Selected Value From Database
<p>I have the code to select the values from a database for populating my drop down list. But my question is if I stored the value of what the user selected in another database, how would I go about pulling that back out and making that the selected choice.</p> <pre><code>&lt;select name="dropdown1" id="dropdown1"&gt; &lt;?php for ($i = 0; $i &lt; 5; $i++) { print '&lt;option id="'.$options[$i]["ID"].'" value="'.$options[$i]["Value"].'"&gt;'.$options[$i]["Name"].'&lt;/option&gt;'."\n"; } ?&gt; &lt;/select&gt; </code></pre> <p>So the users stored value is lets say red. How would I make red the selected value as it populates my drop down list?</p> <p>Thanks e</p>
php
[2]
3,395,895
3,395,896
Convert string to list in python
<p>I need to convert an string to a list in python, The string format is as follows,</p> <pre><code>'[{"name":"Tom","adress":"adress1"},{"name":"Mari","adress":"adress2"}]' </code></pre> <p>I need to convert this <strong>string</strong> in to python <strong>list</strong> data type and want to get the dictionaries by iterating that generated list.</p> <p>I have tried json library and no luck. > correction (<strong>json.loads is working</strong>.)</p> <p>Can you please tell me the correct way to do so ?</p>
python
[7]
3,305,565
3,305,566
C++ const reference member extending lifetime of object
<p>This is related to <a href="http://stackoverflow.com/questions/6936720/why-lifetime-of-temporary-doesnt-extend-till-lifetime-of-enclosing-object">a question posted yesterday</a>. </p> <pre><code>class A { public: mutable int x; A() { static int i = 0; x = i; i++; std::cout &lt;&lt; " A()" &lt;&lt; std::endl; } ~A() { std::cout &lt;&lt; "~A()" &lt;&lt; std::endl; } void foo() const { x = 1; }; }; class B { public: const A &amp; a; B(const A &amp; a) : a(a) { std::cout &lt;&lt; " B()" &lt;&lt; std::endl; } ~B() { std::cout &lt;&lt; "~B()" &lt;&lt; std::endl; } void doSomething() { a.foo(); }; }; int main() { B b((A())); b.doSomething(); } </code></pre> <p>Now, a's destructor is called before the call to doSomething. However, the call works although the function basically changes a member of A. Is it not the same instance. No other A's are created. I used the static inside A's constructor to keep track of that. Can anyone explain?</p>
c++
[6]
5,610,052
5,610,053
Why does this sometimes mean base?
<p>Given</p> <pre><code>public class Animal { public Animal() { Console.WriteLine("Animal constructor called"); } public virtual void Speak() { Console.WriteLine("animal speaks"); } } public class Dog: Animal { public Dog() { Console.WriteLine("Dog constructor called"); this.Speak(); } public override void Speak() { Console.WriteLine("dog speaks"); base.Speak(); } } </code></pre> <p><code>this.Speak()</code> calls <code>Dog.Speak()</code>. Remove <code>Speak()</code> from dog and suddenly <code>this.Speak()</code> calls <code>Animal.Speak()</code>. Why does <code>this</code> behave this way? In other words, why does <code>this</code> mean <code>base</code> or <code>this</code>? </p> <p>To me, an explicit call to <code>base.Speak()</code> makes more sense. Especially when speak is not virtual, surprisingly Speak() is still called when <code>virtual</code> is removed. I understand IS-A relationships from an OO sense, but I can't wrap my head around this specific problem in C#. This gets especially annoying when people write God class UI's (practically every business does). I'm looking for "Speak()" inside "this" when I should be looking at "base".</p>
c#
[0]
5,178,784
5,178,785
php big integers
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2490888/how-to-work-with-big-numbers-in-php">How to work with big numbers in PHP?</a> </p> </blockquote> <p>i am developing a web app on RSA algorithm. as to make RSA more secure u have to use large numbers so here it goes.... so first i convert the alphabets (all A to Z) into their ASCII codes, i m using ord().</p> <p>but the problem is the function <code>ciphertext=m(pow)e*[mod n]</code> in which m (message which is a number) to the power e is to be calculated now if ascii of a is 97 , and suppose e=57 then 97 to the power 57 will be huge.... i have a 32 bit laptop.</p> <p>so plz tell the right data type which i should use thanks.</p>
php
[2]
563,768
563,769
How to globally disable lock screen on boot?
<p>I am flashing my developer board with root access and I need to start my Android always unlocked. Is there a way to do it <strong>without</strong> making an app through internal Android configuration files or something similar?</p>
android
[4]
179,191
179,192
How to apply background color to listview dynamically in Android?
<p>How to apply background color to listview dynamically in <a href="http://en.wikipedia.org/wiki/Android%5F%28operating%5Fsystem%29" rel="nofollow">Android</a>?</p>
android
[4]
896,614
896,615
How to upload an image in image view +iphone
<p>I am a new iphone developer. How can i upload an image in Image view which is taken from camera and from photo library. </p> <p>Thanks to all. </p>
iphone
[8]