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
2,596,787
2,596,788
Javascript Shorthand for getElementById
<p>Is there any shorthand for the JavaScript document.getElementById? Or is there any way I can define one? It gets repetitive retyping that <strong>over</strong> and <strong>over</strong>.</p>
javascript
[3]
5,916,228
5,916,229
Get class of selected radio in a button group
<p>How to hide a div if the selected radio of a radio button group has a class other than "red"?</p> <pre><code>&lt;form&gt; &lt;input class="blue" name="model" value="XTC_01" type="radio"&gt; &lt;input class="red" name="model" value="XTC_02" type="radio"&gt; &lt;input class="red" name="model" value="XTC_03" type="radio"&gt; &lt;input class="blue" name="model" value="XTC_04" type="radio"&gt; &lt;/form&gt; &lt;div id="red_info"&gt;Hidden if selected radio class is not "red".&lt;/div&gt; </code></pre> <p>Thanks for Your advice.</p>
jquery
[5]
5,137,847
5,137,848
How to always run some piece of code in android regardless of which activity or service run first in android?
<p>I would like to run a piece of code every time any activity or service is started. In this piece of code, I might do things such as set the default uncaught exception handler and manage log levels.</p> <p>The problem is that I have an activity which starts with the user clicking the application icon. I have another which starts if a certain intent is broadcasted, possibly from another app and possibly called before the user click the launch icon. Same goes for services.</p> <p>I need to guarantee that a certain piece of code will be run while keeping the code clean; that is to say, without having to manually add that snippet of code to every activity and service class that I have.</p>
android
[4]
4,548,727
4,548,728
Embedded excel user control in C#
<p>I have a user control (in c#) with an embedded excel worksheet and other gridcontrols. I have this user control in a form. I need to print the form but I found that embedded excel worksheet is not supported in DevExpress Xtrareport. I can print the excel worksheet separately but I need to print the whole form not just that excel worksheet. How can I go about it? </p>
c#
[0]
3,637,916
3,637,917
Rvalues vs temporaries
<p>Somebody generalized the statement "Temporaries are <code>rvalues</code>". I said "no" and gave him the following example</p> <pre><code> double k=3; double&amp; foo() { return k; } int main() { foo()=3; //foo() creates a temporary which is an lvalue } </code></pre> <p>Is my interpretation correct?</p>
c++
[6]
504,601
504,602
How to show multiple callouts on single pin
<p>I want to know if it is possible to show multiple callouts(annotations) by selecting just a single pin.if yes then how?</p>
iphone
[8]
4,030,474
4,030,475
Problem with using javascript to insert <input> tags in html
<p>I am trying to take text that is in an array (one word per value) and insert it into html. All the code is here: <a href="http://jsfiddle.net/chromedude/r6wVq/3/" rel="nofollow">http://jsfiddle.net/chromedude/r6wVq/3/</a>.</p> <p>Update: My question is what am I doing wrong? It does not do anything which is weird.</p> <p>Just for everybody who was wondering what this code is supposed to help me do is memorize long passages for school.</p>
javascript
[3]
4,948,511
4,948,512
Is this a website integrated with this iPhone app?
<p>First of all I'm totally not advertising for this app or for this team. I came a cross to their apps and I noticed that all their apps are using the same interface.</p> <p>But what wondered me are these inside the apps are a special design websites inside their apps or what? because I'm interested how did they make it.</p> <p>hxxp://itunes.apple.com/us/app/awesome-laws-pro/id320196287?mt=8</p> <p>By the way, I'm a Objective-c beginner and still learning.</p>
iphone
[8]
5,705,053
5,705,054
Forced to pass by value
<p>I just ported my code (originally written in msvc) to Code::Blocks (running GNU GCC) and I'm having a few problems in compiling my code.</p> <p>The compiler is giving me an error when I try to pass a variable as an argument.</p> <p>For example,</p> <pre><code>void foo(int a, int b, int c){...} //Works on calling like this: foo(1,2,3); //But not like this: foo(x,y,z); </code></pre> <p>The compiler says that there is no matching function call to void foo(int &amp;a, int &amp;b, int &amp;c);</p> <p>I don't want to make too many changes in my code, I've already cleaned the temporaries being passed as reference, which msvc allowed.</p> <h3>Edit Copied from comment:</h3> <pre><code>Index i; std::string s("..."); onPlayerInteraction(i,s); </code></pre> <blockquote> <p>error: no matching function for call to 'Object::onPlayerInteraction(Index&amp;, std::string)'<br> note: candidates are:<br> virtual void Object::onPlayerInteraction(Index, std::string&amp;) </p> </blockquote>
c++
[6]
4,462,437
4,462,438
How to clear Activity Stack on Button Click in Android
<p>I have a question that I have a logout button in my App on which we have called an App login Screen but at this point when user press the Back Button of Android Phone, he entered in the App again without Authentication, which is not desirable. I want when we click on Logout button All previous Activity Stack being cleared or we can say that All previous onPause Activities have to be cleared.</p> <p>Please Suggest me the right solution for this problem.</p> <p>Thanks in advance.</p>
android
[4]
1,405,748
1,405,749
How does this work? type = type || 'any';
<p>Can anyone explain me how this expression works?</p> <pre><code>type = type || 'any'; </code></pre> <p>Does it mean that if type is undefined use 'any'?</p>
javascript
[3]
3,760,202
3,760,203
Android secure communications: JSSE or Apache Http?
<p>After having all kinds of problems taking my functioning JSSE-based HttpsURLConnection implementation using a custom truststore on Windows to Android I have come across a number of issues that I cannot get answers to: (the Android app still does not work)</p> <ol> <li><p>Does Android 4.0 still only support the BKS format for keystores and truststores (and not JKS)? My Windows application used JKS.</p></li> <li><p>Is JSSE or ApacheHttp better to use for secure TLS communications on the Android platform? (My Windows application used JSSE HttpsURLConnection and friends)</p></li> </ol> <p>Before I start struggling with getting custom truststores working on Android I would like to know if using JSSE is barking up the wrong tree. Surely there must be a reason for having both of these APIs available! Then again, maybe not.</p>
android
[4]
3,745,048
3,745,049
android: how to modify starStyle
<p>I'm doing a "favorite" view in my android app.</p> <p>In favorite.xml I have:</p> <pre><code> android:id="@+id/star" android:layout_height="wrap_content" android:layout_width="wrap_content" android:visibility="visible" style="?android:attr/starStyle" android:padding="10sp" </code></pre> <p>I want to change the color in "focused" view, but I'm not able!</p> <p>How can I do it?</p>
android
[4]
2,827,774
2,827,775
Make my java application shut down if it stops working
<p>Is there a way to make my java application shut down there is an error? e.g. if I have a nullpointerexception, can I just make it completely close out?</p>
java
[1]
5,392,748
5,392,749
handling error in gridview
<p>I had gridview whch bind datasource and I add edit command to gridview to update data and when updating errors apeared so I want to handle these error in label in row_updated event without asp error</p>
asp.net
[9]
3,300,308
3,300,309
Max execution time of 30 sec in http.php
<p>i am using http class and it stuck at setting up cookies on the line where it says fuction setcookies.</p> <p>this is my code</p> <pre><code>require_once ('../http.php'); $http=new http_class; $http-&gt;user_agent="Mozilla/5.0 (Intel Mac OS X) Gecko/20070515 Firefox/2.0.0.4"; $error=$http-&gt;GetRequestArguments($url,$arguments); foreach ($cookie as $c) { $t = explode('=',$c); $http-&gt;SetCookie($t[0],$t[1],"","/",".example.com"); //problem is here i think } $arguments["Headers"]["Referer"] = $referer; </code></pre>
php
[2]
4,113,054
4,113,055
hide layouts when softkeyaboard is open
<p>I want to know is there any way to hide layouts when soft keyboard is open ,</p> <p>think I have a 3 layouts that fill the the screen , I want when I open soft keyboard , soft keyboard be over of screen , and layouts do not fill to match keyboard </p> <p>is it possible </p> <p>Also I do not want to set then Gone , because they are advertise . . .</p>
android
[4]
5,370,325
5,370,326
Java Deflater always returning 0 issue
<p>So I have a input stream from which I read a smaller fixed-size buffer which I'm trying to Deflate inside a Runnable class.</p> <pre><code>randomClass implements Runnable { public void run() { ... byte[] output = new Byte[FIXED]; Deflater deflater = new Deflater(); deflater.setInput(uncompressed); deflater.setLevel(Deflater.DEFLATED); int length = deflater.deflate(output); ... } } </code></pre> <p>The issue I'm running into is that length is always returning 0 which means I need more input according to the doc? However, I've checked that the uncompressed is not null. How can I get the bytes out of the output?</p> <p>Also I believe I should be calling deflater.finish() only at the last block. Is this correct?</p>
java
[1]
5,610,082
5,610,083
What's the difference between `HTMLElement` and `Element`?
<p>What's the difference between <code>HTMLElement</code> and <code>Element</code> ?</p> <p><code>document.createElement("div") instanceof Element</code> gives true</p> <p><code>document.createElement("div") instanceof HTMLElement</code> gives true</p> <p><code>HTMLElement === Element</code> gives false</p>
javascript
[3]
5,757,249
5,757,250
Grab htmls results from a php statement?
<p>I was wonder if there was a way to take the html results that was created from a php script and take that html code generated and put it inside another php script?</p> <p>The problem I'm having is that I'm working inside a huge php script and I always have errors when I'm working inside it. I want to make additions to the code, but it never works. Files aren't opening. However, when I work outside it and within the same folder, my code works. </p> <p>So I'm thinking if there's an "Iframe" for php code or maybe I should use an iframe instead?</p>
php
[2]
1,494,295
1,494,296
How to refer to the target value of list/dictionary comprehension in condition clause?
<p>In the following examples,</p> <pre><code>[f(a) for a in range(10) if f(a) &lt; 50] {k: f(a) for k in range(10) if f(a) &lt; 50} </code></pre> <p>Is it possible to eliminate the repeated <code>f(a)</code>, without introducing a wrapping list/dictionary comprehension?</p>
python
[7]
2,274,852
2,274,853
Ext.Ajax.request failure() does not work?
<p>This is my implementation class.</p> <pre><code> @Override public void loginPage(String uid, String Passwd) throws Exception { Connection connection = persister.getConnection(); Statement statement = connection.createStatement(); String sql = "select mailid,password from account where mailid = '"+ uid + "'"; ResultSet rs = statement.executeQuery(sql); while (rs.next()) { String User = rs.getString("mailid"); String pass = rs.getString("password"); if (User.equals(uid)&amp;&amp;pass.equals(Passwd)) { System.out.println("Login Successfull"); } else { System.out.println("Login Unsuccessful"); } } } } </code></pre> <p>And the following is my java ExtJS part</p> <pre><code>{ xtype:'button', x:115, y:10, text:'Login', anchor : '15%', scale:'medium', handler:function() { var userid=Ext.getCmp('Usertxt'); var password=Ext.getCmp('Passwordtxt'); Ext.Ajax.request({ url:'Form/login_account', method:'POST', params:{userid:userid.getValue(), password:password.getValue()}, failure:function(response, opts){ //Alert the user about communication error response = Ext.decode(response.responseText); Ext.MessageBox.alert('Login Unsuccessfully',response.message); }, success:function(response, opts) { //Received response from the server response = Ext.decode(response.responseText); Ext.MessageBox.alert('Login Successfully', response.message); } }); } }, </code></pre> <p>Please help me on this as I am new to extjs and java too.</p>
javascript
[3]
5,411,879
5,411,880
How to get access to hostfile on different machines(WIndows,linux etc) using Java
<p>Hi I am trying to parse host files kept at different locations on different machines. Plz help me in getting access to host files assuming i can have all types of machines(Windows,linux,mac etc). I want a complete method in java that parses hostfile irrepective of the underlying system.</p> <p>Till now i was hardcoding the location of hostfile in windows :</p> <pre><code>private final String mHostFileLocation = "C:\\WINDOWS\\system32\\drivers\\etc\\hosts"; </code></pre> <p>but I think this is a bad idea. Please let me know how I can parse the host file on any system.</p>
java
[1]
1,408,308
1,408,309
Searching Access Database based on Textbox choice
<pre><code>private void btnSearchDB_Click(object sender, EventArgs e) { OleDbConnection accessConnect = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\ECM\ECM\ECM\ECM.mdb"); DataTable dt = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM ECMeasurements WHERE [Job Number] LIKE " + txtJobNumber.Text, accessConnect); da.Fill(dt); dataGridView1.DataSource = dt; } </code></pre> <p>There are also choices that can be searched by Date.....(txtDate.Text) and a comboBox (cbAlloyyTemper.Text). Do I write three different queries or can all the search criteria be together?</p>
c#
[0]
3,211,326
3,211,327
each implementation in the underscore.js library
<p>Question about the implementation of the "each" function I found in the underscore.js source code (source below). </p> <p>First, could someone explain what the line "else if (obj.length === +obj.length) " is checking for.</p> <p>Second, could someone explain why hasOwnProperty.call(obj, key) is used, as opposed to obj.hasOwnProperty? Is it because the passed in obj may not implement hasOwnProperty (which I thought every javascript object did)</p> <p>any insights appreciated. Thanks.</p> <pre><code> // The cornerstone, an `each` implementation, aka `forEach`. // Handles objects with the built-in `forEach`, arrays, and raw objects. // Delegates to **ECMAScript 5**'s native `forEach` if available. var each = _.each = _.forEach = function(obj, iterator, context) { if (obj == null) return; if (nativeForEach &amp;&amp; obj.forEach === nativeForEach) { obj.forEach(iterator, context); } else if (obj.length === +obj.length) { for (var i = 0, l = obj.length; i &lt; l; i++) { if (i in obj &amp;&amp; iterator.call(context, obj[i], i, obj) === breaker) return; } } else { for (var key in obj) { if (hasOwnProperty.call(obj, key)) { if (iterator.call(context, obj[key], key, obj) === breaker) return; } } } }; </code></pre>
javascript
[3]
3,968,146
3,968,147
Child Page Activity not Started after inflating ChildView
<p>I am new to Android. </p> <p>I want to do iPhone like <code>SplitView</code> in Android. I did it using <code>LayoutInflater</code>.</p> <p>The view is coming in my child <code>LinearLayout</code> but the activity of that view is not started.</p> <p>So it just render the view it is not starting activity of that <code>childview</code>. </p> <p>I tried using Intent but it does not give me the parent view it only gives <code>childview</code>. </p> <p>Help me to come out of this. </p> <p>How can I start activity of the inflating view?</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setContentView(R.layout.ParentActivity); LinearLayout ChildView; ChildView = (LinearLayout) findViewById(R.id.ChildView); ChildView.removeAllViews(); setContentView(R.layout.ChildActivity); } </code></pre> <p>and I also override the <code>setContentView</code> Method like</p> <pre><code> @Override public void setContentView(int id) { LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(id, ChildView); } </code></pre>
android
[4]
26,101
26,102
How to get all files from folders and subfolders with full path using scandir
<p>I am looking for a solution how to get all files from folders and subfolders with full path using scandir?</p> <p>I wrote this so far:</p> <pre><code>function listFolderFiles($dir){ $ffs = scandir($dir); $i = 0; $list = array(); foreach ( $ffs as $ff ){ if ( $ff != '.' &amp;&amp; $ff != '..' ){ if ( strlen($ff)&gt;=5 ) { if ( substr($ff, -4) == '.php' ) { $list[] = $ff; echo dirname($ff) . $ff . "&lt;br/&gt;"; } } if( is_dir($dir.'/'.$ff) ) listFolderFiles($dir.'/'.$ff); } } return $list; } $files = array(); $files = listFolderFiles(dirname(__FILE__)); </code></pre> <p>but that does not load files with full path. it only shows filenames. and I filtered files that ends with .php</p> <p>Thanks a lot for help!!</p>
php
[2]
2,866,807
2,866,808
Understanding the scope of a typedef in two structs (functors)
<p>If I <code>typedef</code> some type within a struct (functor), is the scope of the <code>typedef</code> local to the struct? </p> <p>Consider the following example where I have typdef'ed foo to be an <code>int</code> and a <code>double</code> in the two separate functors. Is this example correct? </p> <pre><code>template &lt;typename T&gt; struct firstfunctor { typedef int foo; foo operator()(const foo&amp; a, const foo&amp; b) { return /*whatever*/ } }; template &lt;typename T&gt; struct secondfunctor { typedef double foo; foo operator()(const foo&amp; a, const foo&amp; b) { return /*whatever*/ } }; </code></pre>
c++
[6]
165,640
165,641
Android - get the activity result when the calling activity finished
<p>is there a way to get result from activity to one activity before the calling activity becuse the calling activity have noHistory attribute and the back button passing me to the one before?! </p> <p>thanks for the help!</p>
android
[4]
3,262,610
3,262,611
CompositeControl design time GUI creation
<p>I don't know if this is a right question, but i need to understand how it works. </p> <p>I want to create CompositeControl with design time support, the GUI of the design time support is rendered CreateChildControls().</p> <p>My question is: When i drop this control on aspx page, what is actually happening in the background for gui to appear on design view?<br /> Does it executes CreateChildControls()?<br /> Is it possible to debug the gui creation process?</p>
asp.net
[9]
2,915,528
2,915,529
how to delete first line in a txt file
<p>i am new in c#.</p> <p>I want to delete the first line in the txt file .</p>
c#
[0]
686,069
686,070
How to send secure variable from one page to another in php
<p>I want to send a variable to a page, so that data is displayed from database using that variable. I cannot use session variable because i have many pages each with different value for the variable. For example I have four pages, A,B,C,D. When a user visits A, it will redirect to a master page with a variable from A, extract A's data from db and display A's data on the master page, similarly for B,C,D. I don't want to use session because these pages will increase, and I will have to use a different session variable for each page. Please tell me a good solution to this problem.</p>
php
[2]
5,780,408
5,780,409
Run code when Android app is closed/sent to background
<p>I have an Android application which sends some data to a webservice. I need to send this data as soon as the application is closed or sent to background.. But how do I accomplish this?</p> <p>My current solution is to run it on the OnPause() on my home activity, but I need this to run no matter which activity the user is on when closing the app.. Is this possible or do I have to add the OnPause method to all activities?</p>
android
[4]
788,643
788,644
Generate calling graph for C++ code
<p>I'm trying to generate calling graph with wish to find out all the possible execution paths that hitting a particular function (so that I don't have to figure out all the paths manually, as there are many paths that leading to this function). For instance:</p> <p>path 1: A -> B -> C -> D<br> path 2: A -> B -> X -> Y -> D<br> path 3: A -> G -> M -> N -> O -> P -> S -> D<br> ...<br> path n: ...</p> <p>I have tried Codeviz and Doxygen, somehow both results show nothing but callees of target function, D. In my case, D is member function of a class whose object will be wrapped within a smart pointer. Clients will always obtain the smart pointer object through a factory in order to invoke D.</p> <p>Does anyone know how to achieve this?</p> <p>Thanks,<br> shiouming</p>
c++
[6]
1,619,158
1,619,159
saving the file content in the memory
<p>I have a fairly large pickled (dict) file in binary format that takes few seconds to load every time I look up a score from it. I was wondering if it's possible to load the file just once in the memory and look up from it until I'm logged out of the program. Also, if there's any other way around to speed up my search.<br> Many thanks in advance. </p>
python
[7]
5,196,796
5,196,797
Specialization of 'template<class _Tp> struct std::less' in different namespace
<p>I am specializing the 'less' (predicate) for a data type.</p> <p>The code looks like this:</p> <pre><code>template&lt;&gt; struct std::less&lt;DateTimeKey&gt; { bool operator()(const DateTimeKey&amp; k1, const DateTimeKey&amp; k2) const { // Some code ... } } </code></pre> <p>When compiling (g++ 4.4.1 on Ubuntu 9.10), I get the error:</p> <p>Specialization of 'template struct std::less' in different namespace</p> <p>I did some research and found that there was a 'workaround' which involved wrapping the specialization in a std namespace - i.e. changing the code to:</p> <pre><code>namespace std { template&lt;&gt; struct less&lt;DateTimeKey&gt; { bool operator()(const DateTimeKey&amp; k1, const DateTimeKey&amp; k2) const { // Some code ... } } } </code></pre> <p>which indeed, shuts the compiler up. However, that solution was from a post 5 years old (By the 'great' Victor Bazarof no less [pun unintended]). Is this fix still the way to go, or is there a better way of resolving this, or is the "old way" still valid?</p>
c++
[6]
5,475,777
5,475,778
Saving array of remote images in server
<p>So, I have this code, but didn't worked</p> <pre><code>&lt;? foreach($itemlist as $item) { $imagepic = $item['mainpictureurl']; for($k=0;$k&lt;count($imagepic);$k++){ echo $imagepic++; echo "&lt;br&gt;"; $isok=copy($imagepic[$k] , $_SERVER . dirname(__FILE__).'/test/item_'.($k+1).'.jpg'); if($isok==true){ echo' success!'; }else{ echo ' Fail'; } } } ?&gt; </code></pre> <p>I kept on getting this error</p> <pre><code>Warning: copy(h) [function.copy]: failed to open stream: No such file or directory in /home/decultur/public_html/shop/templatescustom/main/itemlist.html on line 111 Fail </code></pre> <p>What am I missing, please tell me</p>
php
[2]
2,173,533
2,173,534
Global variables in Python
<p>Hi I tried the following example (i <strong>don't</strong> have <code>im</code> in the global) and found that the program actually runs and outputs 10. </p> <p>Is Python dynamic scoped? </p> <pre><code>def useGlobal(): def inSide(): print 'inside', print b b = 5 print im inSide() if __name__ == '__main__': im = 10 useGlobal() </code></pre>
python
[7]
5,941,034
5,941,035
assistance with using the £ symbol in php echo
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3716178/encoding-issue-pound-symbol-appearing-as-symbol">Encoding issue: &#163; pound symbol appearing as &lt;?&gt; symbol</a> </p> </blockquote> <p>I am doing some basic echo statements and when i use echo "£" it puts a capital A before the pound sign any ideas why?</p> <pre><code> echo ("£"): output = A£ </code></pre> <p>the A has a symbol above.</p>
php
[2]
1,107,513
1,107,514
Insert html table row to a specific location with jquery
<p>I have a HTML table that contains price information. The table is sorted be price Ascending. I'm looking to update the table with a new price item. I'm pretty sure jquery should be able to solve this issue. Here is my starting table:</p> <pre><code>&lt;table id='priceTable'&gt; &lt;tr id="25607"&gt; &lt;td&gt; Item 1 &lt;/td&gt; &lt;td&gt; $256.07 &lt;/td&gt; &lt;td&gt;USD&lt;/td&gt; &lt;/tr&gt; &lt;tr id="30100"&gt; &lt;td&gt; Item 2 &lt;/td&gt; &lt;td&gt; $301.00 &lt;/td&gt; &lt;td&gt;USD&lt;/td&gt; &lt;/tr&gt; &lt;tr id="30557"&gt; &lt;td&gt; Item 3 &lt;/td&gt; &lt;td&gt; $305.57 &lt;/td&gt; &lt;td&gt;USD&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I need to insert a new row.</p> <pre><code>&lt;tr id="29000"&gt; &lt;td&gt; Item 5 &lt;/td&gt; &lt;td&gt; $290.00 &lt;/td&gt; &lt;td&gt;USD&lt;/td&gt; &lt;/tr&gt; </code></pre> <p>This row needs to be inserted between the with id 25607 and id 30100.</p> <p>I'm thinking that there should be a way to use the id of the tr's (Which are the prices with only numbers). Possibly sort the ids and figure out where the new item should be inserted.</p>
jquery
[5]
1,514,910
1,514,911
What does the ./ (dot slash) operator represent in Python?
<p>I am trying to port a piece of code from Python to PHP. I've come across a line that I don't understand the notation for.</p> <pre><code>secLat = 1./cos(lat) </code></pre> <p>What does the ./ operator do in this context?</p>
python
[7]
3,424,639
3,424,640
Android Layout Highlight?
<p>How to Highlight the Layout in Android?</p>
android
[4]
5,044,414
5,044,415
how can i post the value of this dynamic textbox to php script
<p>i make a dynamic textbox through javascript now i want to post the data of all dynamically generated textboxes to php script and then insert into a table. how can i do this...</p> <pre><code> &lt;head> &lt;title>Dynamic Form&lt/title> &lt;script language="javascript"> function changeIt() { var i = 1; my_div.innerHTML = my_div.innerHTML +"&ltbr>&lt;input type='text' name='mytext'+ i>" } &lt;/script> &lt;/head&gt; &lt;body&gt; &lt;form name="form" action="post" method=""> &lt;input type="button" value="add another textbox" onClick="changeIt()"> &lt;div id="my_div"> &lt;input type="submit" value="save"> &lt/body></code></pre>
php
[2]
392,779
392,780
Searching for strings in files along with using os.walk
<p>I have written a Python Script to find out lines containing a particular script from each of the files within a directory. It works fine if i make this script run in the directory having those files. </p> <pre><code>#!/usr/bin/env python import os def searchthis(location, searchterm): for fname in os.listdir(location): fullpath = os.path.join(location, fname) for line in file(fullpath): if searchterm in line: print line searchthis(os.getcwd(), "mystring") </code></pre> <p>Is there any way I could do this with <code>os.walk</code> and search for recursively in each of the files present in all the directories as well as subdirectories. </p>
python
[7]
2,437,996
2,437,997
Tell me the detail of virtual table in C++
<p>Can anybody tell me about the virtual table concept?</p>
c++
[6]
1,129,884
1,129,885
Settings option on click of Menu button - Launcher
<p>I am successfully making a launcher, but i need to add another settings option. When i click on the menu button it will show. When you click on it, it goes to an activity.</p> <p>For example. In the default launcher, when you hit menu on a home screen you can add, or set a wallpaper, ect. When you click on wallpaper it takes you to change the wallpaper.</p> <p>What i need to do is create a button like that under the menu, and when it is clicked take me to an activity.</p> <hr> <h2>Here is part of my Launcher.Java...</h2> <pre><code> private static final int MENU_GROUP_ADD = 1; private static final int MENU_ADD = Menu.FIRST + 1; private static final int MENU_WALLPAPER_SETTINGS = MENU_ADD + 1; private static final int MENU_MYHOME_SETTINGS = MENU_WALLPAPER_SETTINGS + 1; private static final int MENU_SEARCH = MENU_MYHOME_SETTINGS + 1; private static final int MENU_STYLES = MENU_SEARCH + 1; private static final int MENU_SETTINGS = MENU_STYLES + 1; </code></pre> <hr> <h2>And here is the other part</h2> <pre><code>super.onCreateOptionsMenu(menu); menu.add(MENU_GROUP_ADD, MENU_ADD, 0, R.string.menu_add).setIcon( android.R.drawable.ic_menu_add).setAlphabeticShortcut('A'); menu.add(0, MENU_WALLPAPER_SETTINGS, 0, R.string.menu_wallpaper).setIcon( android.R.drawable.ic_menu_gallery).setAlphabeticShortcut('W'); menu.add(0, MENU_MYHOME_SETTINGS, 0, R.string.myhome_settings).setIcon( R.drawable.ic_menu_customize); menu.add(0, MENU_SEARCH, 0, R.string.menu_search).setIcon( android.R.drawable.ic_search_category_default).setAlphabeticShortcut( SearchManager.MENU_KEY); menu.add(0, MENU_STYLES, 0, R.string.menu_customize).setIcon( R.drawable.ic_menu_customize); </code></pre> <hr> <p>Any suggestions??</p>
android
[4]
1,396,468
1,396,469
grid view rows at once
<p>i have a grid view where each row has a check box so for all those roes which are checked i want to save in data base how can i achieve this?</p> <p>do i need to perform separate database operation for each datarow or i can send all row to database at once do i need to write some special query?</p> <p>or i can have some temporary table then i can insert all at once please enlighten me on this</p>
asp.net
[9]
2,729,477
2,729,478
Using Parent Directories in Manifest.in
<p>I know MANIFEST.in recognizes relative paths. However, can I use relative paths that point to directories outside of the project?</p> <p>For example:</p> <pre><code>/home /random_dir /python_project MANIFEST.in setup.py /packages </code></pre> <p>And then inside MANIFEST.in</p> <pre><code>graft ../random_dir/ </code></pre> <p>If not, is there an alternative way of including such directories other than just copying and pasting the directory into the project?</p>
python
[7]
3,571,413
3,571,414
What does this PHP (function/construct?) do, and where can I find more documentation on it?
<p>Simple question. Here is this code.</p> <pre><code> $r = rand(0,1); $c = ($r==0)? rand(65,90) : rand(97,122); $inputpass .= chr($c); </code></pre> <p>I understand what it does in the <strong>end</strong> result, but I'd like a better explanation on how it works, so I can use it myself. Sorry if this is a bad question. </p> <p>If you're unsure of what I'm asking about, its the (function?) used here: </p> <p><code>$c = ($r==0)? rand(65,90) : rand(97,122);</code></p>
php
[2]
731,342
731,343
if statement executing when condition is false
<p>I'm tinkering with a projecteuler problem and I encountered the following really odd behaviour. And I can't for the life of me figure out whats going on. </p> <p><img src="http://i.imgur.com/0Ds4I.png" alt="Screenshot"></p> <p>As the screenshot shows. The condition evaluates to false, and the if-statment executed as if it was true. </p> <p>I feel like I'm going crazy here. </p> <p>Updated code: <a href="http://ideone.com/L7KMu" rel="nofollow">http://ideone.com/L7KMu</a></p> <p>Edit: The actual values for next.x and next.y just prior to the condition are 0.324583, 9.97891</p> <p>The are unchanged after the if statement. </p>
c++
[6]
3,074,056
3,074,057
How I can access Database running in UNIX OS using ASP.NET
<p>I'm new in ASP.NET Programming .. I want to build a simple program which communicates Informix-Database running on HP-UNIX server. I have the following information:</p> <p>DB Name Server IP Username Password</p> <p>I want to know how I can establish a connection through my ASP program?</p> <p>Thank you for your help</p> <p>Safraawi</p>
asp.net
[9]
2,010,340
2,010,341
Javascript Scrolling Image edge detection
<p>Currently I am experimenting with a little Image Zoom/Scroller script that I am trying to create, and yes I know there are plugins out there that do this but I am developing this for a lightweight version and for learning to. The main problem I have now is, that I am not sure how to constrain my image scrolling to only the width and height of my image. I would like to set up my script to stop the image from scrolling when the user gets to a ceartin width or height of the image to stop the image from being scrolled out of the div. Below is a fiddle to my script, any suggestions or tips to help me move in the right direction would be much appreciated <a href="http://jsfiddle.net/WpMyU/14/" rel="nofollow">click here to go to fiddle</a></p>
javascript
[3]
505,346
505,347
Pass on variable to set in C#
<p>I want a pass several variables to a function to and set them to something else instead of reading from them. I am planning to use this in a scenario where i can create a object, and add it to a execution queue. Would a pointer be right for this?</p> <p>I am aware my question has a poor explanation, but I don't know a better way to explain it.</p>
c#
[0]
4,127,875
4,127,876
Using AccessKey in asp.net
<p>I am confused. Should I use AccessKey to create a shortcut or use plain javascript to create shortcuts on the buttons on my asp.net page. What's the difference in the two approaches?</p>
asp.net
[9]
1,014,353
1,014,354
I am reading file but while reading,it is reading last character one time extra?
<p>I am trying to read file by following code</p> <pre><code>void main() { int i=0; ifstream fout1 ("Aj.txt",ios::binary); if (fout1.is_open()) { while(fout1) { i++; fout1.get(ch1); cout&lt;&lt;ch1; } cout&lt;&lt;i; fout1.close(); } else { cout &lt;&lt; "Unable to open file"; } return 0; } </code></pre> <p>here this code reads whole file but it goes into loop one extra time i.e if there are 4character in file then in loop it will iterate 5 time .how to correct it or overcome it.</p>
c++
[6]
741,472
741,473
What does Layout Inflater in Android do?
<p>What is the use of <a href="http://developer.android.com/reference/android/view/LayoutInflater.html"><code>LayoutInflater</code></a> in Android?</p>
android
[4]
1,225,689
1,225,690
c++ how to prevent function parameter evaluation
<p>Is it possible to prevent function parameter evaluation? As I don't want to evaluate the function parameter in some situation.</p> <p>E.g. To log a debug message,</p> <pre><code>void log(int severity, ...); </code></pre> <p>I want to log a message</p> <pre><code>log(DEBUG, "%s", getErrorMsg().c_str()); </code></pre> <p>If the severity is DEBUG, the log function is just to return in release binary. So, it is not necessary to evaluate getErrorMsg();</p>
c++
[6]
1,776,473
1,776,474
how to get the sound fade in functionality in alarm application using media player in android
<p>Hi i am new to android. I am developing a application with alarm functionality. Here i need to provide the sound fade in functionality. I am using media player to invoke the ringtone for alarm. here is my code for playing alarm sound</p> <pre><code> try { if(mp==null){ System.out.println("-------mp is null now------------"); Uri myUri = Uri.parse("android.resource://com.android.crazy/raw/airtel"); mp=MediaPlayer.create(Alarm.this, myUri); } mp.setDataSource(songName); mp.prepareAsync(); mp.setLooping(true); } catch (Exception e) { e.printStackTrace(); } mp.start(); </code></pre> <p>Here i need to give the sound fadein functionality. please advise me how to put the sound fade in for a particular amount of time like 5 mins</p> <p>Thanks in advance</p>
android
[4]
1,700,776
1,700,777
Passing array by value
<p>Is it possible to pass an array by value to a C++ function?</p> <p>If it is, how would I do that?</p>
c++
[6]
1,965,872
1,965,873
Android Login page design
<p>I am android "beginner". I want to create login page design (using user name password ) reterive data from the sqllite database? Can you help me?For Example like G mail etc</p>
android
[4]
1,122,614
1,122,615
FORCE limit the value of a column
<p>How do you force a limit total? Is this correct syntax? or am I missing something cause it's exceeding total number from my calculation.</p> <pre><code> switch (ddlVal) { case RequestTypes["Sick"]: case RequestTypes["Late"]: case RequestTypes["Jury Duty"]: tbEffectiveDate.disabled = false; ddlTotalHoursEffect.disabled = true; tbFromDate.disabled = true; tbToDate.disabled = true; cb.disabled = true; cb.checked = false; approvalRequired = false; commentsRequired = false; $("#spnDayOff").hide(); break; case RequestTypes["Day Off"]: tbEffectiveDate.disabled = false; ddlTotalHoursEffect.disabled = true; TotalHoursEffect &lt;= 241 //THIS IS THE PART I WANT TO LIMIT DATA. tbFromDate.disabled = true; $("#spnDayOff").show(); break; default: break; </code></pre>
javascript
[3]
154,873
154,874
Refactor my data reader to work with multiple tables
<p>How can I improve this method so that it works with multiple tables? </p> <pre><code> public void ExecuteStoredProcedure(string StoredProcedureName) { using (var connection = new SqlConnection(provider.ConnectionString)) { using (var command = new SqlCommand(StoredProcedureName, connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; using (var reader = command.ExecuteReader()) { while (reader.Read())//problem is here { Console.WriteLine(reader[0].ToString()); } } } } } </code></pre> <p>I could return the reader (but I think that means I'd have to drop my using statements). Or, I could create a factory that processes each table depending on a parameter that I add to the ExecuteStoredProcedure(). Or whatever. </p> <p>How can I get the reader functionality outta here?</p>
c#
[0]
2,958,818
2,958,819
jQuery plugin: certain code should be called only once
<p>I am trying to write a jQuery plugin. For simplicity let's say that my code is</p> <pre><code>$.fn.myplugin = function() { return this.each(function() { $('a.mypluginToken').live('click', function(){}) } } </code></pre> <p>As per above code every single time $('a').myplugin is called, a binding is done for 'click' event because of 'live'. I need that binding to be done only once and not for each element that invokes my plugin.</p> <p>one solution is that after binding the click event I set a data on document saying 'binding_done'. And check for that data every single time. Even though that solution will work I am wondering if there is a better jQuery design pattern that I am missing.</p> <p>Thanks.</p> <p>I am using jQuery 1.4.2</p>
jquery
[5]
3,795,327
3,795,328
How do I print the binary representation of the first character in a string
<p>i want to retrieve the binary values of the data in the file. so i have written the following the code:</p> <pre><code>while ((fileData = br.readLine()) != null) { byte b[] = fileData.getBytes("UTF-8"); BigInteger bi = new BigInteger(b); String s = bi.toString(2); System.out.println("Original message in binary: " + s); System.out.println("Original message length: " + s.length()); } </code></pre> <p>output:</p> <pre><code>abca (this is the data in a text file) Original message in binary: &lt;here&gt;1100001011000100110001101100001 Original message length: 31 </code></pre> <p>Everything is fine but while i am printing the data in binary format i am not able to print the first bit (<code>&lt;here&gt;</code>) can anyone help me?</p>
java
[1]
672,649
672,650
Simple javascript form reset when certain text boxes are clicked
<p>Morning all...thicky, newbie Rich here!</p> <p>I have a very simple set up, three different search options for finding product information i.e. a cascading drop down list, a product search text box and a radio button list.</p> <p>Ideally, I do not want the form to get cluttered with information or have to use a 'click here to reset' button. </p> <p>What I would like is for the form to reset/clear itself when a user either hits the drop down, the text box or the radio button list. Therefore this will ensure the searching does not get cluttered with information that potentially isn't being used.</p> <p>How would one go about doing this? As per my other questions, please excuse my ignorance.</p>
javascript
[3]
5,530,178
5,530,179
button click method doesn't work as it's visibility changes
<p>I have a picturebox(called pic_Image) and 2 buttons(called btn_AddImage &amp; btn_RemoveImage). I want to make the buttons visible as user moves the mouse on the pic_Image and make them invisibe as mouse leaves the pic_Image. this is the code for making visible:</p> <pre><code>private void pic_Image_MouseMove(object sender, MouseEventArgs e) { btn_AddImage.Visible = true; btn_RemoveImage.Visible = true; } </code></pre> <p>and this is the code for making invisible:</p> <pre><code>private void pic_Image_MouseLeave(object sender, EventArgs e) { btn_AddImage.Visible = false; btn_RemoveImage.Visible = false; } </code></pre> <p>The problem is that after I use the pic_Image_MouseMove method the Onbutton click method doesn't work.</p> <p>thanks in advance</p>
c#
[0]
1,714,448
1,714,449
how to display elements in an array of arrays in java
<p>Following is the code i tried</p> <pre><code>import java.lang.String.*; import java.io.*; public class Main { public static void main(String[] args) { String [][] array1 = new String[][] { {"One"}, {"One", "Two", "Three"}, {"One"," Four"," Five"}, {"One"," Four", "Six"," Seven"}, {"Seven", "Eight"," One"}, {"One"}, {"One"," Nine"}, {"One", "Nine"," Seven"}, {"One"," Nine"} }; for (int row1=0;row1&lt;=array1.length;row1++){ for ( int cols=1 ;cols&lt;array1[row1].length ;cols++){ System.out.println(array1[0][0] +" "+ array1[row1][cols]); } } } } </code></pre> <p>I want to display the elements as </p> <pre><code>One One Two One Three One Four One Five One Four One Six One Seven Seven Eight Seven One One One Nine and so on till the end of the array. </code></pre> <p>The output is :</p> <pre><code>One Two One Three Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 9 One Four One Five One Four at javaapplication12.Main.main(Main.java:45) One Six One Seven One Eight One One One Nine One Nine One Seven One Nine Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) </code></pre> <p>Please suggest me what I should do to get the preffered output..Any help will be appreciated ...</p>
java
[1]
4,017,089
4,017,090
Can we use multiple forms in a web page?
<p>So far, all the web pages I met contain at most 1 <code>&lt;form&gt;</code> tag. Why not multiple ones? I can not think of reasons why multiple forms can't coexist within the same web page.</p> <p>Also, to be speicific to ASP.NET - why all the server controls are placed within the <code>&lt;form&gt;</code> tag? Why not place it somewhere else?</p> <p>Plus,</p> <p>I noticed that in an <code>.aspx</code> file, the <code>&lt;form&gt;</code> tag has the <em>runat=server</em> attribute, while a normal server control such as Button also has one. So it seems the <code>&lt;form&gt;</code> is also a <strong>server control</strong>. But strange enough, I cannot find it in the Visual Studio Toolbox.</p>
asp.net
[9]
3,102,346
3,102,347
suitable datastructure to store the parsed data from webservice
<p>I am developing an iphone app that utilizes webservice. Which is the most suitable datastructure that can be used to store the data as the XML obtained from the webservice is parsed ...?</p>
iphone
[8]
4,432,987
4,432,988
In python, how do I get the same behavior as when __name__ == '__main__':
<p>What is the best way to get this block of code to run when I import main.py rather than run it? </p> <pre><code>#main.py if __name__ == '__main__': #Do something interesting. #Do something to have the interesting code run after importing the file. import main.py main.__main__() # wrong of course. </code></pre>
python
[7]
3,470,685
3,470,686
wrong output code
<p>The following code gives the wrong binary output: The input is a HEX number and the output should be a binary number.</p> <p>It always outputs:</p> <pre><code>0 0 0 0 </code></pre> <p>How can I change it so it outputs the right binary number?</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main () { int Number; cin &gt;&gt; Number; bool Binary[sizeof(int) * CHAR_BIT]; for(unsigned int i = 0; i &lt; sizeof(int) * CHAR_BIT; i++) Binary[(sizeof(int) * CHAR_BIT - 1) - i] = Number &amp; (1 &lt;&lt; i); for(unsigned int i = 0; i &lt; sizeof(int); i++) std::cout &lt;&lt; Binary[i] &lt;&lt; std::endl; system ("pause"); return 0; } </code></pre>
c++
[6]
3,864,694
3,864,695
How can i make a function that finds an object in a set?
<p>I'm making a program that generates a maze and then uses bredth first search to find a way in the maze. My function that checks if an element is present in a container-class now uses the vector like this (where coordinatePath is a typedef for vector) :</p> <pre><code>bool Labyrinth::inVisited(const Coordinate &amp;c, const coordinatePath &amp;visited ) const { for each (Coordinate coord in visited) { if(coord == c) return true; } return false; } </code></pre> <p>Since this method has to traverse the full container if an element is not present it's very ineffective for large searches. I tried to implement the same function that uses a set instead of a vector and wrote it like this:</p> <pre><code>bool Labyrinth::inVisited(const Coordinate &amp;c, const set&lt;Coordinate&gt; &amp;visited ) const { return (visited.find(c) != visited.end()); } </code></pre> <p>when i try to recomplie i get a lot of errors where the topmost is</p> <p>Error 22 error C2676: binary '&lt;' : 'const Coordinate' does not define this operator or a conversion to a type acceptable to the predefined operator c:\program files (x86)\microsoft visual studio 11.0\vc\include\xstddef 193</p> <p>I don't really understand these particular debug-messages and wonder if there is a way to implement this faster search!</p>
c++
[6]
3,049,686
3,049,687
Got hit by an UnsupportedOperationException
<p>I have the following code:</p> <pre><code> private static ArrayAdapter&lt;String&gt; adapter; private static List&lt;Chapter&gt; chapters; public void update(Book book) { adapter.clear(); if (chapters != null) { chapters.clear(); } chapters = DataBaseConnector.getChaptersFromBook(book.getID()); for (Chapter chapter : chapters) { adapter.add(chapter.getTitle()); } header.setText(book.getAbbreviation()); subHeader.setText(book.getName() + " (" + book.getNumber() + ")"); subHeader.setVisibility(View.VISIBLE); } </code></pre> <p>If I call the method <code>update(Book book)</code> and the variable <code>chapters</code> is not <code>null</code>, I get hit by an <code>UnsupportedOperationException</code> in the line <code>chapters.clear()</code>. Any hints how to solve the problem?</p>
android
[4]
894,405
894,406
Sorting arrays: second last
<pre><code>ksort ($votes); foreach ($votes as $total =&gt; $contestant){ $ordervotes[]= $contestant; } echo "&lt;li&gt; And the winner is: {$ordervotes[4]}&lt;/li&gt;"; echo "&lt;li&gt; And the loser is: {$ordervotes[0]}&lt;/li&gt;"; echo "&lt;li&gt; {$ordervotes[1]} came second last&lt;/li&gt;"; </code></pre> <p>This works fine when none of the '$total's are the same, if they are the same i get an error code. I realise I could use the 'max/min' to get the first and last elements of the array, but how do i go about finding the second last?</p> <p>Thank you</p> <p>Joe </p>
php
[2]
3,866,574
3,866,575
stopping variables from resetting on self call
<p>In the following PHP code, I'm trying to generate a random number if its not already and store it in a variable called <code>$number</code>, also I'm taking user input and storing it in <code>$userInput</code>.</p> <p>Every time the submit button is pressed , the same page is called again using <code>$_SERVER['PHP_SELF']</code>.</p> <p>My problem is that I want the <code>$number</code> to keep its value once its set. no matter how many times the submit button is pressed, which is something that is not happening now. the <code>$number</code> is set every time I press submit button.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Number Guessing Game!&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php $userInput = $_POST['number']; if(!$number){ $number = rand(1, 500); } else{ echo "random number is $number &lt;br&gt;"; echo "you entered $userInput"; } echo "&lt;h3&gt; $number &lt;/h3&gt;"; //just to see if the number is changing everytime ?&gt; &lt;form method="post" action="&lt;?php echo $_SERVER["PHP_SELF"];?&gt;"&gt; &lt;input type="text" name="number" /&gt; &lt;input type="submit" name="Submit" value="Submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
php
[2]
511,137
511,138
Need to display name in a toast
<pre><code>protected final Dialog onCreateDialog(final int id) { Dialog dialog = null; switch(id) { case DIALOG_ID: AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Certificate saved successfully. Would you like to add another certificate?") .setCancelable(false) .setPositiveButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { SaveData.this.finish(); } }); }}} </code></pre> <p>In <code>builder.setMessage</code> I want to display the name that I entered in the <code>EditText</code>:</p> <pre><code>builder.setMessage(default, "Certificate saved successfully. Would you like to add another certificate?") </code></pre> <p>How can I do this?</p>
android
[4]
5,324,735
5,324,736
Datatables table tool design change?
<p>I am using datatables table tool plugin for exporting to csv file..the button usually shown on the top of the datatables...but i want to show below the table how to do that?</p>
jquery
[5]
1,859,551
1,859,552
jQuery Delay and Queue not always running after window.onhashchange
<p>This code seems to work perfectly:</p> <pre><code>window.onhashchange = function(){ if (!window.location.href.match('#pop')) { //alert('go back last'); $('#main').removeClass('hidden'); $('.pop').removeClass('pop-ready'); $('.pop').addClass('pop-hidden'); } /* navigate back after back button */ if (!window.location.href.match('#secondpage')) { $('#pageCont').removeClass('posTwo'); $('#pageOne').removeClass('hidden'); $('#pageTwoInner').addClass('hidden'); } if (window.location.href.match('#secondpage')) { $('#pageCont').addClass('posTwo'); $('#pageTwoInner').removeClass('hidden'); } }; </code></pre> <p>However when I when I add a delay and queue to one function the code becomes temperamental and sometimes that class is not added: </p> <pre><code>window.onhashchange = function(){ if (!window.location.href.match('#pop')) { //alert('go back last'); $('#main').removeClass('hidden'); $('.pop').removeClass('pop-ready'); $('.pop').addClass('pop-hidden'); } /* navigate back after back button */ if (!window.location.href.match('#secondpage')) { $('#pageCont').removeClass('posTwo'); $('#pageOne').removeClass('hidden'); /* CHANGE HERE */ $('#pageTwoInner').delay(200).queue(function(){ $(this).addClass('hidden'); }); } if (window.location.href.match('#secondpage')) { $('#pageCont').addClass('posTwo'); $('#pageTwoInner').removeClass('hidden'); } }; </code></pre>
jquery
[5]
5,769,262
5,769,263
How to use onSaveInstanceState with a lot of data and objects
<p>When my application became sophisticated and main activity started holding in memory a lot of data (loaded and parsed from files in response to user actions) I have (mistakenly) switched from <code>onSaveInstanceState</code> to <code>onRetainNonConfigurationInstance</code> without noticing that <code>onRetainNonConfigurationInstance</code> is not called when application is killed to save device memory. So as now I has to switch back to <code>onSaveInstanceState</code> I want to as what is the proper way to handle a huge amount of data distributed by tens of objects? Do I have to implement serialization for all these objects (<code>Parcelable</code>?) or may be put all the data into <code>Service</code> thread hoping it would not be killed? What is the best practice?</p>
android
[4]
1,352,716
1,352,717
How to dismiss the iPhone number pad?
<p>Is there any simple method other than the one seen in</p> <p><a href="http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key" rel="nofollow">http://www.neoos.ch/news/46-development/54-uikeyboardtypenumberpad-and-the-missing-return-key</a></p> <p>to dismiss a Number pad in iPhone??</p> <p>This code for a single text Field seems a lot.!!</p>
iphone
[8]
3,631,155
3,631,156
ASP.Net connection keep alive for long running server-side task
<p>I have an ASP.Net C# web application, running on IIS, that I'm supporting which involves generation of word documents. Some of these word documents take a very long time (i.e. upwards of 20-30 minutes) to generate. What I notice while testing on my dev server is that the server closes the connection long before the process completes, the server-side ASP.Net code itself enters a loop and updates the status of a boolean value when the word doc generation completes. </p> <p>My workaround for this is to keep the connection alive by implementing a dynamically animated wait screen ( using jquery and ajax) on the client-side that's updated by a repeated asynchronous AJAX call to the server that checks on the status of the operation from a server-side web method. I'm asking about that piece in another <a href="http://stackoverflow.com/questions/9660819/delay-between-repeated-ajax-call-to-a-web-method">question</a>.</p> <p>Is the solution I'm looking at implementing the best approach to this problem? Are there more efficient or common methods for keeping the connection alive during a long running server-side operation? Any help or insight is appreciated, thanks.</p> <p>UPDATE:</p> <p>I tried Brian's suggestion, unfortunately I still get the same error from Chrome that no data is being sent from the server and the entirety of the error is as follows:</p> <blockquote> <p>No data received Unable to load the webpage because the server sent no data. </p> <p>Here are some suggestions: Reload this webpage later. </p> <p>Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.</p> </blockquote> <p>I'll try again by setting the connection timeout in the advanced website settings as described and increasing the connection idle setting.</p>
asp.net
[9]
1,384,858
1,384,859
Need every permutation of capitalized letters in php
<p>I want to build an array in php that contains every possible capitalization permutation of a word. so it would be (pseudocode)</p> <pre><code>function permutate($word){ for ($i=0; $i&lt;count($word); $i++){ ...confused here... array_push($myArray, $newWord) } return $myArray; } </code></pre> <p>So say I put in "School" I should get an array back of</p> <p>{school, School, sChool, SCHool, schOOl, ... SCHOOL}</p> <p>I know of functions that capitalize the string or the first character, but I am really struggling with how to accomplish this.</p>
php
[2]
1,547,308
1,547,309
how to raise event if method was not called in last 5 seconds?
<p>Sorry about that probably too simple question but I do not know how to implement this. If certain method was not called for certain ammount of time I need to raise an event (when I receive this event I will try troubleshoot problem. This is kind of connetion problem and I need to be notified about it to try to solve it - i will change connection method.)</p> <pre><code>public void MethodThatShouldBeCalledFrequently // acutally datagram from UDP received { // if not called for 5 seconds than raise event } public event EventHandler&lt;/*no parameters*/&gt; MethodNotCalledForFiveSeconds; // connection problem, switch from UDP to TCP </code></pre>
c#
[0]
2,974,447
2,974,448
How can I stream rmvb files from Desktop to my android phone
<p>Is there a way for me to stream RMVB files from my Desktop to my android phone? I have both phone and desktop on the same Wifi network, I just want to know how can I stream from desktop to my android phone?</p> <p>Thank you.</p>
android
[4]
1,603,528
1,603,529
How to send form values to external url and to email id at the same time using php
<p>I like to know how to send the form details to an external url as well as to email id. I had an experience in programming to the form details to email id, but one of my client is asking to redirect the copy of form details to the url as like this <code>http://someipaddress/XDKRT/SalLeadEntWeb.ASP</code> , my website is developed by wordpress, can anyone guide me how to achieve this?</p>
php
[2]
4,740,766
4,740,767
Where to get Android Video tutorials?
<p>Hi I am new in android programming, in fact I am new in programming and want to learn quickly, my question is how and where to get free android video tutorials? I also have lynda tutorials but is there anything else?</p>
android
[4]
1,358,908
1,358,909
Displaying Photos in a ListView, how to get adapter to preload before users can see the list?
<p>I need to display a number of photos in a list view which are pulled from urls in a list view. Unfortunately there is some variance in the download time. The actual downloading is being done in the adapter for the ListView. these downloads are runOnUIThread. (Yes, i know this is horrible design). So whats happening is the images are being displayed when the download completes, which is causing the images to show up slowly and in a bit of disorder, although I am caching them.</p> <p>I intent to rewrite the logic, but in the meantime, I would like to know to get the adapter to take action before the photos actually need to be displayed. In other words I want to run the adapter before I actually intend to display the list to the user. How can I do this? I want this downloading to take place before the user ever sees the list.</p> <p>In other words I need the below method in the adapter to run before the list is ever visible to the user:</p> <pre><code> public View getView(final int position, View convertView, ViewGroup parent) { // Inside here I am requesting the photo bitmap from url and setting to ImageView. } </code></pre>
android
[4]
2,111,483
2,111,484
Expandable ListView
<p>How we can create Expandable ListView with group icon on Right.have any one implement it...</p>
android
[4]
4,863,670
4,863,671
Android - How to delivery result to any activity?
<p>suppose that you have 3 Activities (A, B and C) and Activity A starts B, and B starts C. </p> <p>I need that activity C delivery result to Activity A, because activity B is finished when starts activity C.</p> <p>This code do not works:</p> <pre><code>public class ActivityA extends Activity { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == ActivityC.REQUEST_CODE) { // need this code be called when activityC finish } super.onActivityResult(requestCode, resultCode, data); } } public class ActivityB extends Activity { void startActivityC() { Intent intent = new Intent(); intent.setClass(this, ActivityC.class); startActivityForResult(intent, ActivityC.REQUEST_CODE); finish(); } } public class ActivityC extends Activity { public static final int REQUEST_CODE = 12345; void finishActivity() { Intent intent = new Intent(); intent.putExtra("example", "example"); setResult(RESULT_OK, intent); finish(); } } </code></pre> <p>Any idea how to implement this?</p> <p>Thank you!</p>
android
[4]
420,223
420,224
Red exclamation mark over the project in eclipse
<p>I am trying to run a project but there is a red exclamation mark over the project name. When checked in Problems, its throwing an error "project is missing required library". The library is pointed to android.jar located in some path. When checked in package explorer, I found the android.jar in Android 2.3.1 folder structure of project in package explorer. The android.jar located in Android 2.3.1 folder is pointing to some other path. Is the build error occurring due to the difference in paths for android.jar files? I have imported the project.So, how should I modify the path which is shown in the problems window? I am newbie to android and so pls help me.</p> <p>Thanks!!!</p>
android
[4]
191,446
191,447
Exclude numbers starting with a certain three digits in C#
<p>I am currently building a C# application that is generating a random 9 digit number each run through. I am looking for a way to exclude numbers starting with "666". How would I go about writing a statement to exclude numbers starting with certain digits. </p> <p>Here's the code snippet just in case it helps.</p> <pre><code>Random SSN = new Random(); string temp = ""; int num = SSN.Next(100000000, 999999999); temp = num.ToString(); </code></pre> <p>Thanks!</p>
c#
[0]
475,347
475,348
how do you pass a parameter to a function when it is called by reference?
<p>I've created a global variable to pass informatin to a method that is called via a method reference</p> <pre><code>d_g.onerror=i_bm_err_fix; </code></pre> <p>I tried passing it the variable like this(below) but it did not work.</p> <pre><code>d_g.onerror=i_bm_err_fix(d_g); </code></pre> <p>All I'm trying to do is have a generic image load if the site favicon does not.</p> <pre><code>function i_bm_err_fix(d_g) { d_g.src='http://www.archemarks.com/favicon1.ico'; } </code></pre> <p>Currently I'm using a global variable to pass this info. but this does not seem like good practice.</p>
javascript
[3]
5,163,563
5,163,564
System.IO.FileStream is super slow on huge files
<p>I have a piece of code that needs to be able to modify a few bytes towards the end of a file. The problem is that the files are huge. Up to 100+ Gb.</p> <p>I need the operation to be as fast as possible but after hours of Googeling, it looks like .Net is rather limited here???</p> <p>I have mostly been trying using System.IO.FileStream and know of no other methods. A "reverse" filestream would do but I have know idea how to create one (write from the end instead of the beginning).</p> <p>Here is sort of what I do: (Note: the time is spent when closing the stream)</p> <pre><code> static void Main(string[] args) { //Simulate a large file int size = 1000 * 1024 * 1024; string filename = "blah.dat"; FileStream fs = new FileStream(filename, FileMode.Create); fs.SetLength(size); fs.Close(); //Modify the last byte fs = new FileStream(filename, FileMode.Open); //If I don't seek, the modification happens instantly fs.Seek(-1, SeekOrigin.End); fs.WriteByte(255); //Now, since I am modifying the last byte, //this last step is very slow fs.Close(); } } </code></pre>
c#
[0]
2,190,680
2,190,681
How to pass optional parameters to a method in C++?
<p>How to pass optional parameters to a method in C++ ? Any code snippet...</p>
c++
[6]
2,318,697
2,318,698
java print out a double array
<p>i have an array with some double value inside:</p> <pre><code>private double speed[] = {50, 80, 120, 70.3}; public void printSpeed() { for(int i = 0; i&lt;=speed.length-1; i++ ) { System.out.println(speed[i]); } } output 50.0 80.0 12.0 70.3 wanted output 50 80 12 70.3 </code></pre> <p>How to do print the exactly string of the array?</p>
java
[1]
44,995
44,996
cpp unit set up and teardown functions
<p>can any one tell me how and when setup and teardown functions are called in cppunit. Thanks</p>
c++
[6]
4,880,365
4,880,366
fetching the label text from database in C#
<pre><code> private void button5_Click(object sender, EventArgs e) { SqlConnection conn = new SqlConnection("Data Source=MAZI-PC\\PROJECTACC;Initial Catalog=programDB;Integrated Security=True"); SqlCommand cmd = new SqlCommand("select label_sh from label_text where label_form='2' and label_form_labelID='1'", conn); conn.Open(); label1.Text = cmd.ExecuteReader().ToString(); conn.Close(); SqlConnection conn1 = new SqlConnection("Data Source=MAZI-PC\\PROJECTACC;Initial Catalog=programDB;Integrated Security=True"); SqlCommand cmd1 = new SqlCommand("select label_sh from label_text where label_form='2' and label_form_labelID='2'", conn1); conn1.Open(); label2.Text = cmd1.ExecuteReader().ToString(); conn1.Close(); SqlConnection conn2 = new SqlConnection("Data Source=MAZI-PC\\PROJECTACC;Initial Catalog=programDB;Integrated Security=True"); SqlCommand cmd2 = new SqlCommand("select label_sh from label_text where label_form='2' and label_form_labelID='3'", conn2); conn2.Open(); label3.Text = cmd2.ExecuteReader().ToString(); conn2.Close(); } </code></pre> <p>I am developing a small project in C#... Using Visiual Studio 2010... I want to fetch the label texts from database in order to change the user interface language with a button... I wrote this code but there is a problem in SQLDATAREADER</p> <p>in label text parts it shows System.Data.SqlClient.SqlDataReader</p> <p>I cant fix, could you help me?</p>
c#
[0]
4,813,190
4,813,191
php session_destroy browser remembering username and password
<p>I am using the php authentication method for digest authentication as shown on the <a href="http://php.net/manual/en/features.http-auth.php" rel="nofollow">php manual</a>. All is working well except for the logout part.</p> <p>I am using <code>session_destroy()</code> to try and log my users out, which it does. However my problem is if the user goes to log back in before closing the browser out they are not prompted for a username and password and they are automatically logged back in with the last username and password they entered.</p> <p>It seems the credentials are somehow being remembered by the browser. In Firefox if I manually clear "active logins" in the "clear browsing history" before trying to log back in then I am prompted for the username and password even though the user has been logged out with <code>session_destroy()</code>.</p> <p>I am also using <a href="http://php.net/manual/en/function.session-destroy.php" rel="nofollow">an example from the php manual</a> to clear the cookie but that doesn't seem to help, it doesn't seem to be a cookie problem.</p> <p>Here is my logout.php code</p> <pre><code>&lt;?php session_start(); $_SESSION = array(); //destroy cookie if it exists if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] ); } //destroy session session_destroy(); header("location:form.php"); exit(); ?&gt; </code></pre> <p>What am I missing? Thanks for any help!</p>
php
[2]
2,382,674
2,382,675
C# log base 10 and rounding up to nearest power of 10?
<p>if i have a number between 100 and 1000 i want to get the value 3 because 10^3 = 1000. Likewise, if i had a number between 10 and 100 i would want to get the value 2, because 10^2 is 100.</p> <p>Incase you're wondering, its to do with calculating a probability and i always need to divide through by 10^value, to keep the probability between 0 and 1. For example if i calculate 9256, i need to divide through by 10^4, so that i get a probability of 0.92</p> <p>I'm not sure how to do the rounding up and how to do the base 10, could someone please help? </p>
c#
[0]
4,418,091
4,418,092
Error: "an object reference is required for the non-static field, method or property..."
<p>Im creating an application on C#. Its function is to evualuate if a given is prime and if the same swapped number is prime as well. When I build my solution on Visual Studio, it says that "an object reference is required for the non-static field, method or property...". Im having this problem with the "volteado" and "siprimo" methods. Can you tell me where is the problem and how i can fix it? thank you! </p> <pre><code>namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.Write("Write a number: "); long a= Convert.ToInt64(Console.ReadLine()); // a is the number given by the user long av = volteado(a); // av is "a" but swapped if (siprimo(a) == false &amp;&amp; siprimo(av) == false) Console.WriteLine("Both original and swapped numbers are prime."); else Console.WriteLine("One of the numbers isnt prime."); Console.ReadLine(); } private bool siprimo(long a) {// evaluate if the received number is prime bool sp = true; for (long k = 2; k &lt;= a / 2; k++) if (a % k == 0) sp = false; return sp; } private long volteado(long a) {// swap the received number long v = 0; while (a &gt; 0) { v = 10 * v + a % 10; a /= 10; } return v; } } } </code></pre>
c#
[0]