Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
4,891,770
4,891,771
Why we assigned the the value of variable "option" 1 before loops?
<p>I'm a new to programming and I chose python as my first language because its easy. But I'm confused here with this code:</p> <pre><code>option = 1 while option != 0: print "/n/n/n************MENU************" #Make a menu print "1. Add numbers" print "2. Find perimeter and area of a rectangle" print "0. Forget it!" print "*" * 28 option = input("Please make a selection: ") #Prompt user for a selection if option == 1: #If option is 1, get input and calculate firstnumber = input("Enter 1st number: ") secondnumber = input("Enter 2nd number: ") add = firstnumber + secondnumber print firstnumber, "added to", secondnumber, "equals", add #show results elif option == 2: #If option is 2, get input and calculate length = input("Enter length: ") width = input("Enter width: ") perimeter = length * 2 + width * 2 area = length * width print "The perimeter of your rectangle is", perimeter #show results print "The area of your rectangle is", area else: #if the input is anything else its not valid print "That is not a valid option!" </code></pre> <p>Okay Okay I get every thing below the <code>Option</code> variable. I just want to know why we assigned the value of <code>Option=1</code>, why we added it on the top of the program ,and what is its function. Also can we change its value. Please make me understand it in simple language as I'm new to programming.</p>
python
[7]
4,409,415
4,409,416
Java, converting string to numbers then add all the numbers together
<p>I need to add 8 numbers together from a string.E.g. If someone enters say 1234 it will add the numbers together 1 + 2 + 3 + 4 = 10 then 1 + 1 = 2. I have done this so far. I cannot figure out how to add these numbers up using a for loop.</p> <pre><code>String num2; String num3; num2 = (jTextField1.getText()); num3 = num2.replaceAll("[/:.,-0]", ""); String[] result = num3.split(""); int inte = Integer.parseInt(num3); for (int i = 0; i &lt; 8; i++){ // Stuck } </code></pre>
java
[1]
4,463,861
4,463,862
Java Hit Formulas
<p>I'm making a simple RPG game and finding out formulas is hard. So far I hav this:</p> <pre><code>import java.lang.Math.*; import java.util.*; import java.text.*; public class expTable { public static void main(String[] args) { int myLevel = 6; int myAttack = 6; int myDefense = 1; DecimalFormat df = new DecimalFormat("###,###,###"); int rawr = monsterFormula(myLevel, myAttack, myDefense); System.out.println("At level " +myLevel+ " you hit for " + df.format(rawr) + " attack points!"); } public static int monsterFormula(int e,int myAttack, int myDefense) { int xTotal = 0; for(int i=1; i&lt;e; i++) { xTotal += (int)Math.floor(i + myAttack * Math.pow(myDefense, (i / 42.0))); } return (int)Math.floor(xTotal/8.0); } } </code></pre> <p>but...it seems overpowered because at level 10 with attack 10, you hit for 10. Do you see anyway I can improve my hit formula?</p>
java
[1]
4,146,898
4,146,899
PHP variable in an ing src
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/12645493/use-img-source-with-php-variable">use Img source with php variable</a> </p> </blockquote> <p>I have a small issue here, i am sure it is an easy one but I am terribad at php.</p> <p>I am using a WP plugin which pulls at a certain moment the first image attached to a post, in my case, a picture that user uploads upon a business submission (it is a business directory plugin).</p> <p>I don't want that, instead, I want thumbshots.com generated thumbnails. My code looks like this (I replaced the defaul value of <em>$thumbnail</em>):</p> <pre><code>if (!$thumbnail &amp;&amp; wpbdp_get_option('use-default-picture')) $thumbnail = 'http://images.thumbshots.com/image.aspx?cid=HIPFHapOLHw%3d&amp;v=1&amp;w=283&amp;url=URLHERE'; </code></pre> <p>Now, instead of URLHERE, should be placed an actual URL, the listing´s one. Which is created by this:</p> <pre><code>&lt;?php echo wpbusdirman_the_listing_meta('single'); ?&gt; </code></pre> <p>How do I do it?</p> <p>Thanks a lot!</p>
php
[2]
1,096,606
1,096,607
How to create a static library from an Xcode project?
<p>I struggling with a problem. I am having two apps. I want to link/integrate those two apps to my third app. I need to keep all these three apps class files and other resource files independent. Because most of them have the same name. How can I do this? I have to convert them to library and integrate them? If so, how to do that? Is there any other way to do it?..</p> <p>I am having all these three apps as Xcode projects. I want only one app as the result after integrating.. </p> <p>I read in few forums that this is possible to do using static libraries. Can you suggest me the best way to create a static library from an existing Xcode project?</p> <p>Any help pls..</p> <p>Thanks..</p>
iphone
[8]
5,936,645
5,936,646
KeyDown in jquery not updating when pressed
<p>I am trying to get the div to change the font size and update it on the screen. The following code works but there is a problem when you press a key you need to press another key to register the last key was pressed i dont know want that to happen. How would i make it update as soon as you press a key? </p> <pre><code> $('#font_size_title').keydown(function() { var font_size_title = $(this).val(); $('#preview_title').css("font-size",font_size_title); }); </code></pre>
jquery
[5]
992,588
992,589
php drop down detect selection
<p>I have a date of birth, and when the user is over Feb (02), the days should go only to 29. As you can see I'm using <code>$month="1"</code> just to test it. I'm supposed to use PHP only, no JavaScript or anything else. How would i go about making that?</p> <pre><code>&lt;?php $month="1"; // &lt;-- currently using this to make it 29,30 or 31 days print "&lt;select name='day'&gt;"; if ($month==1){ for ($i=0; $i&lt;=28; $i++) { $day = 1 + $i; print "&lt;option value = $day&gt;" . $day ."&lt;/option&gt;"; } } if ($month==2){ for ($i=0; $i&lt;=29; $i++) { $day = 1 + $i; print "&lt;option value = $day&gt;" . $day ."&lt;/option&gt;"; } } print "&lt;/select&gt;"; print "&lt;select name='month'&gt;"; for ($i=0; $i&lt;=11; $i++) { $month = 1 + $i; print "&lt;option value = $month&gt;" .$month ."&lt;/option&gt;"; } print "&lt;/select&gt;"; </code></pre> <p>?></p>
php
[2]
5,556,163
5,556,164
Advice with String and Char array
<p>For the application I am working on ,I want my text to be displayed as ticker text and I am using a Notification for that, the constructor is Notification(int,char array[],when).The problem is the second argument should be a char array but all I have is a string, now would the string serve the same purpose ,if I use it instead of the char array.</p>
android
[4]
4,186,005
4,186,006
How do i persist this change of layout in database using JQuery Portlet?
<p>I just saw this cool feature of JQuery which is JQuery Portlet</p> <p><a href="http://jqueryui.com/demos/sortable/portlets.html" rel="nofollow">http://jqueryui.com/demos/sortable/portlets.html</a></p> <p>I was just wondering how do i persist this to my database? so that it's available even for future sessions to all users of my website?</p>
jquery
[5]
2,529,677
2,529,678
In which situation we use jmp_buf in C programming
<p><code>jmp_buf</code> is used in which situation durinf C Programming.</p> <p><code>jmp_buf</code> is what? I mean is it Keyword/data type ??</p>
c++
[6]
3,588,021
3,588,022
jQuery dynamically append table rows without flickering
<p>I have a page that every 5 seconds fetch new data from the server with jQuery ajax and append it to a table. <br> Everything is working fine except from one annoying issue.every append action causing the table to flickers. <br> I am looking for a way to smooth things a bit, and make this action more "eye friendly" for the user. <br> HTML:</p> <pre><code> &lt;table id="myTable"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;COL A&lt;/th&gt; &lt;th&gt;COL B&lt;/th&gt; &lt;th&gt;COL C&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p><br> jQuery: <br></p> <pre><code>setInterval(function () { $('#myTable tbody').empty(); $.ajax({ type: "POST", url: "/MySite/WebMethods/AjaxTestMethods.aspx/GetActivityTable", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { var d = data.d; for (var i = 0; i &lt; d.length; i++) { $('#myTable tbody').append('&lt;tr&gt;&lt;td&gt;' + d[i].DATA1 + '&lt;/td&gt;&lt;td&gt;' + d[i].DATA2 +'&lt;/td&gt;&lt;td&gt;' + d[i].DATA3 + '&lt;/td&gt;&lt;tr&gt;'); } } }); }, 5000); </code></pre>
jquery
[5]
2,742,271
2,742,272
how to find modulus of a number in c#
<p>how to find modulus of a number in c# .net?</p>
c#
[0]
1,537,101
1,537,102
Weird javascript output
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/850341/workarounds-for-javascript-parseint-octal-bug">Workarounds for JavaScript parseInt octal bug</a> </p> </blockquote> <p>I was learning the parseInt() function of javascript and was just trying out, and out of nowhere</p> <pre><code>parseInt('08') returns 0 </code></pre> <p>moreover,</p> <pre><code>parseInt('07') returns 7 //which is correct </code></pre> <p>but again</p> <pre><code>parseInt('09') returns 0 // really, are you kidding me.? </code></pre> <p>Either I am crazy or I am missing something?</p>
javascript
[3]
3,403,931
3,403,932
jQuery image fader slow in IE6 & 7
<p>I'm using the following jQuery script to rotate through a series of images pulled into an unordered list using PHP:</p> <pre><code>function theRotator() { $('#rotator li').css({opacity: 0.0}); $('#rotator li:first').css({opacity: 1.0}); setInterval('rotate()',5000); }; function rotate() { var current = ($('#rotator li.show') ? $('#rotator li.show') : $('#rotator li:first')); var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#rotator li:first') :current.next()) : $('#rotator li:first')); next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 2000); current.animate({opacity: 0.0}, 2000).removeClass('show'); }; $(document).ready(function() { theRotator(); }); </code></pre> <p>It works brilliantly in FF, Safari, Chrome and even IE8 but IE6 &amp; 7 are really slow. Can anyone make any suggestions on making it more efficient or just work better in IE6 &amp; 7?</p> <p>The script is from <a href="http://www.alohatechsupport.net/webdesignmaui/maui-web-site-design/easy_jquery_auto_image_rotator.html" rel="nofollow">here</a> btw. Thanks.</p>
jquery
[5]
3,736,527
3,736,528
Android Start Preference Activity Intent results in Exception
<p>i have a problem, i want to run an activity which handles a preference dialog</p> <pre><code>Intent i= new Intent(getBaseContext(), PreferencesActivity.class); startActivity(i); </code></pre> <p>when i run the app i only get an nullpointerexcepltion when the activity should start. what is wrong?</p> <p>PreferencesActivity looks this way: </p> <pre><code>import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.Preference.OnPreferenceClickListener; import android.widget.Toast; public class PreferencesActivity extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.layout.preferences); // Get the custom preference Preference customPref = (Preference) findPreference("customPref"); customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Toast.makeText(getBaseContext(), "The custom preference has been clicked", Toast.LENGTH_LONG).show(); SharedPreferences customSharedPreference = getSharedPreferences( "myCustomSharedPrefs", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = customSharedPreference.edit(); editor.putString("myCustomPref","The preference has been clicked"); editor.commit(); return true; } }); } } </code></pre>
android
[4]
3,954,319
3,954,320
Last Time Contacted
<p>How does android calculate the value for last time contacted. It provides the value in integer format but I am unable to decipher the given value. For example what if I want to compare the two give values to know which contact has been contacted later. Any type of help would be appreciated. </p>
android
[4]
802,059
802,060
can copy constructor be a conversion operator?
<p>Consider the following code.</p> <pre><code>#include &lt;iostream&gt; using namespace std; class Test { private: int x,y; public: Test () { cout &lt;&lt;" Inside Constructor "&lt;&lt;endl; x=100; } explicit Test (const Test &amp; t) { cout &lt;&lt;"Inside Copy Constructor "&lt;&lt;endl; x = t.x; } void display() { cout &lt;&lt;" X is "&lt;&lt;x&lt;&lt;endl; } }; int main (int argc, char ** argv){ Test t; t.display(); cout &lt;&lt;"--- Using Copy constructor "&lt;&lt;endl; Test t2(t); t2.display (); Test t3=t2; t3.display (); } </code></pre> <p>Test (const Test &amp; t) -> is a copy constructor</p> <p><strong>Question:</strong></p> <p>Is the same used as a "Conversion Operator" ? Test t3 = t2 [ Here copy Constructor is treated as a conversion operator]</p> <p>I am not sure if my understanding is correct?. Kindly correct me if i am wrong? </p>
c++
[6]
1,007,838
1,007,839
jquery remove behavior
<p>I have the following html</p> <pre><code>&lt;div class="foobar"&gt; &lt;div&gt; child 1 &lt;/div&gt; &lt;div&gt; child 2 &lt;/div&gt; &lt;ul&gt; &lt;li&gt; list elem 1 &lt;/li&gt; &lt;li&gt; list elem 2 &lt;/li&gt; &lt;li&gt; list elem 3 &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>When I try the following jquery the list is removed as expected:</p> <pre><code>$(".foobar ul").remove(); </code></pre> <p>However when I try this, it does not seem to work:</p> <pre><code>$(".foobar").remove("ul"); </code></pre> <p>Just trying to understand....</p>
jquery
[5]
1,168,658
1,168,659
pass functions as a parameter in JavaScript
<p>How do I pass functions as a parameter in JavaScript.</p> <p>In the code below if I call <code>whatMustHappen (TWO(),ONE())</code> I want to them to fall in the sequence of the <code>x</code> and the <code>y</code> on the <code>whatMustHappen</code> function.</p> <p>Right now it fires as it sees it in the parameter.</p> <pre><code>var ONE = function() { alert("ONE"); } var TWO = function() { alert("TWO"); } var THREE = function() { alert("THREE"); } var whatMustHappen = function(x, y) { y; x; } whatMustHappen(TWO(), null); whatMustHappen(TWO(), ONE()); </code></pre>
javascript
[3]
3,914,394
3,914,395
Sanitising a POST array for INSERT query
<p>Morning SO,</p> <p>I have a checkbox array (name = "cat[]") in a form which at present, contains six values, 1- 6 (it may contain more in the future). A user can select any number of these. </p> <p>These values are then collected in:</p> <pre><code>$_SESSION['cat'] = $_POST['cat']; </code></pre> <p>(They're in a session because there's a step or two before the actual insert query)</p> <p>What i want to do is Sanitise them. I have tried </p> <pre><code>$_SESSION['cat'] = (int)$_POST['cat']; </code></pre> <p>But that seems to strip all values from it. </p> <p>Can someone help with the appropriate method of sanitising this for safe insertion into a database?</p> <p>Thanks in advance, as always, Dan</p>
php
[2]
774,408
774,409
retrieve EditText multiline text as it is android?
<p>I want to get text from Edit text as it is and display in TextView.But whenver i get text using getText() it gives me text in one line. How to entered text in multiline EditText as it is. Please give me guidance?</p>
android
[4]
355,956
355,957
Track changes of atributes in instance. Python
<p>I want to implement function which takes as argument any object and trackes changes of value for specific attribute. Than saves old value of attribute in old_name attribute.</p> <p>For example:</p> <pre><code>class MyObject(object): attr_one = None attr_two = 1 </code></pre> <p>Lets name my magic function <code>magic_function()</code></p> <p>Sot than i can do like this:</p> <pre><code>obj = MyObject() obj = magic_function(obj) obj.attr_one = 'new value' obj.attr_two = 2 </code></pre> <p>and it saves old values so i can get like this</p> <pre><code>print obj.old_attr_one None print obj.attr_one 'new value' </code></pre> <p>and </p> <pre><code>print obj.old_attr_two 1 print obj.attr_two 2 </code></pre> <p>Something like this.. I wonder how can i do this by not touching the class of instance?</p>
python
[7]
1,455,540
1,455,541
posting back with a textbox vs label
<p>Here is my code - </p> <pre><code>dtDetails = getDataSet(); foreach (DataRow dr in dtDetails.Rows) { int rowID = 1; HtmlTableRow row = new HtmlTableRow(); { HtmlTableCell cell = new HtmlTableCell(); TextBox tb = new TextBox(); tb.ID = "tbJanuary" + rowID; tb.Text = dr["Jan"].ToString(); cell.Controls.Add(tb); row.Cells.Add(cell); } rowID ++; } </code></pre> <p>When this initially runs, I get correct values within my textboxes.</p> <p>However, when I update a value in the database through a button click on the page, it causes the expected PostBack. When I come back into this loop, dr["Jan"].ToString() has the new correct value base don that change, but the textbox on the oage never gets updated.</p> <p>If I change the code to this - </p> <pre><code>dtDetails = getDataSet(); foreach (DataRow dr in dtDetails.Rows) { int rowID = 1; HtmlTableRow row = new HtmlTableRow(); { HtmlTableCell cell = new HtmlTableCell(); Label lbl = new Label(); lbl.ID = "lblJanuary" + rowID; lbl.Text = dr["Jan"].ToString(); cell.Controls.Add(lbl); row.Cells.Add(cell); } rowID ++; } </code></pre> <p>the label contains the correct new value.</p> <p>What is it about the text box that doesn't display the correct value?</p>
c#
[0]
512,481
512,482
Read Value from ArrayList
<p>I have an array List as:</p> <pre><code>{IDS=[10, 12], SALARY=[10000, 20000]} </code></pre> <p>What I want is, I should be able to print like</p> <pre><code>IDS=10,12 SALARY=10000,20000 </code></pre> <p>Code:</p> <pre><code> ArrayList&lt;HashMapImpl&gt; ds = XmlUtils.getListFromXml("Abc", "XYZ", str); System.out.println("Array Content====&gt;"); Object[] elements = ds.toArray(); for(int i=0;i&lt;elements.length;i++){ System.out.println(elements[i]); } </code></pre>
java
[1]
4,986,244
4,986,245
List uploaded files
<p>I have som files uploaded on a server. Lets say a mixture of .jpg, .doc and .txt I want to list these on a webpage and supply a downloadlink. Preferably using only php/html/jQuery. (ie no SQL) Can anyone help me how to do this? </p>
php
[2]
3,965,978
3,965,979
Calculating overtime work
<p>Here's my code. </p> <pre><code>&lt;p&gt;You worked &lt;?php echo $hours ?&gt;hour(s) this week.&lt;/p&gt; &lt;p&gt;Your pay for the week is: &lt;?php $wage = $_GET["wage"] * ($hours &gt; 40 ? $hours * 1.5 : $hours); ;echo number_format("$wage",2); ?&gt;&lt;/p&gt; </code></pre> <p>Thing about this is it calculated by 1.5 if it works over 40+ .. But i want it like this. Lets say you work 41 hours. I want 40 hours to be the standard rate and the 1 hour is multiply by 1.5</p> <p>How can i do that? </p>
php
[2]
6,020,395
6,020,396
How to call root parent's function from n-th child window using javascript?
<p>there. Let's say that I don't know how many child window would be open by window.showModalDialog. If it's only 1 depth between child and parent, it would be easy to call parent's function using javascript. But I have to open a child window and from that child window to another child window, and another, and another. I can't say how many depth. Now, from the last child window, how can I call the root parent's function? Anyone has any idea?</p> <p>"Root Parent Window" -> child window -> child window -> child window ........n-th child window</p>
javascript
[3]
2,890,739
2,890,740
Submit a form in a hidden php script
<p>I am working in a form, which is in a hidden script called by Ajax method.<br> In this php script, I want t submit the information using an URL,using this piece of code:</p> <pre><code>header("location: https://www.page.com/servlet/?encoding=UTF-8&amp;oid=333&amp;first_name=$first_name&amp;last_name=$last_name"); </code></pre> <p>But the informaton is not submitted.</p> <p>Any idea?? Thanks in advance.</p>
php
[2]
3,095,128
3,095,129
How to pause an Activity till I get facebook id while signing in in Android?
<p>While using facebook in Android to log in/register, it takes a while for facebook to send the request. Thus, how do I pause the activity(show a process dialog) till I get the facebook id/username of the user who is trying to register? I can't do this in the base Listener as it is a background process. </p> <p>I tried out using AsyncTask but I'm either confused how to do it or it can't be done. Mostly the former. I did this: </p> <pre><code> public class FacebookOperation extends AsyncTask&lt;Void, Void, Void&gt; { @Override protected void onPreExecute() { super.onPreExecute(); mFacebook = new Facebook(APP_ID); mAsyncRunner = new AsyncFacebookRunner(mFacebook); reg = "facebook"; SessionStore.restore(mFacebook, Register.this); SessionEvents.addAuthListener(new SampleAuthListener()); //SessionEvents.addLogoutListener(new SampleLogoutListener()); } @Override protected void onProgressUpdate(Void... values) { super.onProgressUpdate(values); } @Override protected void onPostExecute(Void result) { fillFormFb(); //Fills the form with the data from fb } @Override protected Void doInBackground(Void... params) { mLoginButton.init(Register.this, mFacebook,permissions); return null; } } </code></pre>
android
[4]
5,968,178
5,968,179
Is it possible to use Loaders class in MapActivity?
<p>I have an android app to regularly record locations and store in a db in the background. db comes with content provider. use alarm receiver and service to set repetitive record task. </p> <p>Now I'd like to put pins on a map using data(lat&amp;long) in the db. I currently use a Loader to load the cursor and read data from db and then put them into a list view in a <code>fragment activity</code> (using support package v13 in 2.3.3 platform). However I could not figure out a way to convert this into drawing on a map view in a map acvivity instead. If my activity extends <code>MapActivity</code>, I cannot use method <code>getSupporLoaderManager().iniLoader(...)</code> to initialize the loader as it says error.</p> <p>I want to keep the loader because it seems it processes faster if data size is large. My question is, how to read data using <code>Loader</code> class in <code>MapActivity</code>? If not possible, what is a better way to read data and draw on the map?</p> <p>Any suggestion or answer appreciated.</p>
android
[4]
1,900,424
1,900,425
Sharing an object through several classes
<p>I need to share 1 instance between several classes. The Connect class has methods to create a URL and to download data, and the ui is the interface (swing form) through which I get the data to build the url (dates theat comprise the url).</p> <p>What's the best way to do it?</p> <p>Thought of:</p> <p>1) Making it global by:</p> <pre><code>public class Global { public static Connect c; } </code></pre> <p>2) Making the instance in main(), and passing it through objects.</p> <pre><code>public static void main(String[] args) throws IOException { Connect c = new Connect(); // get url to download from ui form = new ui(c); // the form to get data from . . . </code></pre> <p>What seems more reasonable, if any?</p> <p>Thank you.</p>
java
[1]
4,154,617
4,154,618
Color flash in Jquery?
<p>I am working on a JQuery, which hides &amp; shows a particular element whenever user checks a box. I want to do a color flash on the element which is changed from hidden to visible, so that user knows where it is.</p> <p>I tried doing this </p> <pre><code>jQuery("#login-form").show() .css({backgroundColor: "red"}) .delay(2000) .queue(function() { jQuery("#login-form").css({backgroundColor: "#FFFFFF"}); }); </code></pre> <p>but it works for the first time only, after then it just stops. Any ideas?</p>
jquery
[5]
3,738,596
3,738,597
Parents selector in jQuery
<p>I need to get all elements whose n-th parent (i.e. elem.parent().parent()...parent()) has a specific class. Is that possible?</p> <p>For example:</p> <pre><code>&lt;div class="success"&gt; &lt;div id="depth-1"&gt; &lt;div id="depth-2"&gt; &lt;div&gt;Return me&lt;/div&gt; &lt;div&gt;Return me&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>the command with parent depth of 3 and class "success" will return the <code>"Return me"</code> divs.</p>
jquery
[5]
4,760,713
4,760,714
Can I have a common Queue to queue up the requests received through function call?
<p>I will be happy, if you can give me some suggestions to solve my problem.</p> <p>I have to make a function call from one program to another program (separate package). Now my question is, can i have a common Queue in the called program in which all the calling requests will be queued up ???? is it possible to maintain a queue??</p> <p>Example.</p> <pre><code>package1: public class Callingprogram { public static void main(String args[]) { CalledProgram cp=new Calledprogram(); cp.function(hashset); } } package2: public class Calledprogram { public void function(Hasheset hs) { here i am going to make use of the hashset sent by them } } </code></pre> <p>now here by i repeat my question :can i make any queue in Calledprogram such that it keeps track of all the calls made by Callingprogram and serves one by one...if so can i have a sample code such that i can proceed further....</p> <p>Thank you..</p>
java
[1]
4,691,681
4,691,682
Namespaces and List Comprehension in python 2.7
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4575698/python-list-comprehension-overriding-value">Python list comprehension overriding value</a> </p> </blockquote> <p>I did some googling around, but no solutions to this issue. It seems like list comprehensions mess with the current namespace, which seems really odd to me.</p> <pre><code>print i print [i for i in range(10)] print i </code></pre> <p>The first is an error, the second prints range(10) as expected, and the last line prints 9, the 'last value of i' for the list comprehension. This is completely unexpected to me. What's more, if i was previously defined, it's now been overwritten.</p> <p>I'm running on Apple's build of Python 2.7 (OS X Lion), if that means anything.</p>
python
[7]
3,711,463
3,711,464
Prevent android from sleeping in webapp
<p>I'm developing a <strong>webapp</strong> that receive notifications from a server. Currently, The target device is only an Android 4 device [a Samsung Galaxy Nexus]). As normal, when the user doesn't touch the screen for a while the screen goes off, lock screen.</p> <p>I have search in the developers.adnroid.con page, but all i have seen is handling scale, and screen dimensions.</p> <p>I wouldn't like to make a native app with a webview, because the great thing about a webapp is that it doesn't require installation, and you can just share a link ....</p> <p>Is there a way to prevent android from sleeping from a webapp <strong>without</strong> using a native app with webview?</p>
android
[4]
3,916,520
3,916,521
PHP url question
<p>Is there a way I can strip out the variables from a link using PHP for example, if I have a link that reads <code>http://localhost/link/index.php?s=30&amp;p=3</code> how would I strip out <code>?s=30&amp;p=3</code> so my link reads <code>http://localhost/link/index.php</code></p>
php
[2]
260,164
260,165
Android: Detecting application backgrounding
<p>Hey all, I have an application that has many screens. Is it possible to detect if the screen NOT belonging to the application (not defined in my android manifest) comes into visibility?</p>
android
[4]
5,842,157
5,842,158
Dynamically Specify the First Activity
<p>The main activity is specified in AndroidManifest.xml with:</p> <pre><code> &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; </code></pre> <p>But I don't know how to dynamically specify the first activity according code logic.</p>
android
[4]
1,246,458
1,246,459
JavaScript open in a new window, not tab
<p>I have a select box that calls <code>window.open(url)</code> when an item is selected. Firefox will open the page in a new tab by default. However, I would like the page to open in a new window, not a new tab. </p> <p>How can I accomplish this?</p>
javascript
[3]
5,155,053
5,155,054
Understanding Traceview
<p>I am trying to understand how a traceview works. I have tried to analyze a method using the traceview but have a query about it. </p> <p>I have attached the snapshot of the .trace. It indicates that the majority time is taken by (toplevel) marked in blue. however no further info is available on the same. (when this method is executed or what function it performs.)</p> <p><img src="http://i.stack.imgur.com/T2pPy.jpg" alt="traceViewSnapshot"></p> <p>Can anyone please explain to me why its consuming so much time?</p> <p>Thanks in advance!</p>
android
[4]
1,572,856
1,572,857
how to return newest object from the FIFO Queue without removing it
<p><code>Peek</code> Returns the object at the beginning of the Queue without removing it.</p> <p>What if I want to do the same thing with the "last object in the queue". I.e. the "newest" one (the one was just inserted).</p> <p>I've tried <code>queue.Reverse().Peek()</code> but this doesn't compile.</p>
c#
[0]
2,759,216
2,759,217
Do I have to disable in-app purchase if I don't need it?
<p>I can see my new created iOS applications are defaulted to In-App purchase to enabled. I don't need in-app purchase. Do I have to explicitly disable it? Or It's okay for me to submit an app but simply without attaching any in-app purchases with the submission?</p>
iphone
[8]
1,863,591
1,863,592
Code inside submit event executes after or before form submitting?
<p>Does the code inside <code>$('form').submit(function() {});</code> executes <strong>before</strong> or <strong>after</strong> the form submit?</p> <p>For example, if I edit the value of one of the inputs there, will the new value be included on the request?</p>
jquery
[5]
1,829,936
1,829,937
Multiple file_put_contents with with str_replace?
<p>I am trying to replace multiple parts of a string in a file with <code>file_put_contents</code>. Essentially what the function does is finds a particular phrase in the file (which are in the <code>$new</code> and <code>$old</code> arrays and replaces it.</p> <pre><code>$file_path = "hello.txt"; $file_string = file_get_contents($file_path); function replace_string_in_file($replace_old, $replace_new) { global $file_string; global $file_path; if(is_array($replace_old)) { for($i = 0; $i &lt; count($replace_old); $i++) { $replace = str_replace($replace_old[$i], $replace_new[$i], $file_string); file_put_contents($file_path, $replace); // overwrite } } } $old = array("hello8", "hello9"); // what to look for $new = array("hello0", "hello3"); // what to replace with replace_string_in_file($old, $new); </code></pre> <p>hello.txt is: <code>hello8 hello1 hello2 hello9</code></p> <p>Unfortunately it outputs: <code>hello8 hello1 hello2 hello3</code></p> <p>So it outputs only 1 change when it should have outputted 2: <code>hello0 hello1 hello2 hello3</code></p>
php
[2]
5,488,226
5,488,227
jQuery Time Refresh
<p>I am using the jQuery countdown timer at <a href="http://keith-wood.name/countdown.html" rel="nofollow">http://keith-wood.name/countdown.html</a></p> <p>I am trying to get the time remaining to refresh automatically without reloading the page. It is getting the remaining time from a MySQL DB and if I change the value in the DB the time still countdowns from the original time. I have an onTick event which checks a script for the new time.</p> <p>If I use the destroy command the script attaches multiple times for every onTick.</p> <p>Is there a way to reinitialize the timer without reload?</p> <p>Cheers</p>
jquery
[5]
3,576,257
3,576,258
C++ dynamic cast
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/28002/regular-cast-vs-static-cast-vs-dynamic-cast">Regular cast vs. static_cast vs. dynamic_cast</a> </p> </blockquote> <p>is there any harm in using static_cast when I know the type for sure? Any issue if it has virtual functions?</p> <pre><code>class Base { public: virtual void foo(); }; class Derived1 { public: virtual void foo(); void bar(); }; Base* b1 = new Derived1(); Derived1* d1 = static_cast&lt;Derived1*&gt;b1; d1-&gt;bar(); </code></pre>
c++
[6]
4,928,890
4,928,891
Jquery window.location - how to open a blank window
<p>I have a login script and currently when all is done the client is redirected to the billing page.</p> <p>I'd like this page to open in a new browser window not the existing one as the current code does.</p> <p>Thank you for your help</p> <p>Dave</p> <pre><code>function go_to_private_pageb() { window.location = '../########/billing.php'; // Members Area } </code></pre>
javascript
[3]
5,427,507
5,427,508
FF keeps spinning after document.write()
<pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" &gt; function fn() { document.write("Hello there!!!"); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;button onclick="fn()"&gt;click&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>After clicking the button , FF keeps on spinning (11.0), while as if I directly call the fn() without wiring it to the button , it works fine.Could anyone please look into this ?</p>
javascript
[3]
1,430,894
1,430,895
What would be a good sample project to ask a prospective programmer to code during the hiring process?
<p>My understanding is that asking for a work sample is a good way to determine if someone has the skillset you are looking for, as some people just interview well. So I want to ask potential developers to write some sample code for me.</p> <p>I'm looking for ideas on what kind of small project would be something they could do in an hour or two, and would show that they have a good grasp of OOP, good coding practices, etc. And what to look for once they finish - how to evaluate it fairly and usefully.</p> <p>For context, I'm a small business owner, interviewing prospective developers, for PHP development on internal projects. I can code PHP but am not an expert (some of the work is refactoring code I've written to be better structured and consistent), and so I'm also looking for what to look for when evaluating the samples, given that I'm not a trained or super experienced programmer.</p> <p>Especially for people who have done hiring of this type before and used this method.</p> <p>I was also thinking I could give them some code to refactor, and see how they do on it. Has anyone ever given a refactoring test as part of the hiring process?</p> <p>Clarification: I'm not talking about coding during an interview. I'm talking about coding <em>instead</em> of an interview. For context the inspiration for this question came from this article in FastCompany about how work samples are better predictors of job success than interviews:</p> <p>Why It May Be Wiser To Hire People Without Meeting Them <a href="http://www.fastcompany.com/magazine/136/made-to-stick-hold-the-interview.html" rel="nofollow">http://www.fastcompany.com/magazine/136/made-to-stick-hold-the-interview.html</a></p>
php
[2]
3,160,768
3,160,769
How can I connect to a database on the web through netbeans/java
<p>I am developing a chat program in java for mobiles. I have to connect to a database that is located in my web host, so how should I connect to that db?</p> <p>Thanks in advance :)</p>
java
[1]
3,217,541
3,217,542
regular expression : the dollar sign ($) work with re.match() or re.search() ?
<p>I only know the dollar sign <code>$</code> will match a pattern from the end of a string, but which method does it work with, <code>re.match()</code> or <code>re.search()</code>?</p>
python
[7]
755,363
755,364
problem of while loop and array
<pre><code>$result=array(); $table_first = 'recipe'; $query = "SELECT * FROM $table_first"; $resouter = mysql_query($query, $conn); while ($recipe = mysql_fetch_assoc($resouter, MYSQL_ASSOC)){ $result['recipe']=$recipe; $query2="SELECT ingredients.ingredient_id,ingredients.ingredient_name,ingredients.ammount FROM ingredients where rec_id = ".$recipe['rec_id']; $result2 = mysql_query($query2, $conn); while($ingredient = mysql_fetch_assoc($result2)){ $result['ingredient'] = $ingredient; } echo json_encode($result); }</code></pre> <p>this code show me all the recipes but only the last ingredients i.e</p> <pre><code>{"recipe":{"rec_id":"14","name":"Spaghetti with Crab and Arugula","overview":"http:\/\/www","category":"","time":"2010-11-11 14:35:11","image":"localhost\/pics\/SpaghettiWithCrabAndArugula.jpg"},<br/>"ingredient":{"ingredient_id":"55","ingredient_name":"test","ammount":"2 kg"}}{"recipe":{"rec_id":"15","name":"stew recipe ","overview":"http:\/\/www","category":"","time":"2010-11-11 14:42:09","image":"localhost\/pics\/stew2.jpg"},<br/>"ingredient":{"ingredient_id":"25","ingredient_name":"3 parsnips cut into cubes","ammount":"11"}}</code></pre> <p>i want to output all the ingredient records relevant to recipe id 14 and this just print the last ingredient.</p>
php
[2]
3,687,630
3,687,631
problem in jar file
<p>hi I created one jar file in following folder:</p> <h2> '/usr/local/bin/niidle.jar'</h2> <p>But when I type command as follows:</p> <h2>>>jar tf /usr/local/bin/niidle.jar</h2> <p>then it is showing following error:-- --The program 'jar' can be found in the following packages: * java-gcj-compat-headless * gcj-4.2 * sun-java5-jdk * kaffe * gcj-4.3 * cacao-oj6-jdk * openjdk-6-jdk * fastjar * sun-java6-jdk Try: apt-get install </p> <h2>bash: jar: command not found</h2> <p>I am not getting that why this kind of error is showing, Please give me detail solution for this....</p>
java
[1]
2,240,269
2,240,270
Use Python format string in reverse for parsing
<p>I've been using the following python code to format an integer part ID as a formatted part number string:</p> <pre><code>pn = 'PN-{:0&gt;9}'.format(id) </code></pre> <p>I would like to know if there is a way to use that same format string (<code>'PN-{:0&gt;9}'</code>) in reverse to extract the integer ID from the formatted part number. If that can't be done, is there a way to use a single format string (or regex?) to create and parse?</p>
python
[7]
1,507,338
1,507,339
Practice exercises?
<p>Is there anything like: <a href="http://nathansjslessons.appspot.com/lesson?id=1000">http://nathansjslessons.appspot.com/lesson?id=1000</a></p> <p>Something where I can learn and practice javascript? I remember when I was going to start with c++, there was a list of practice exercises for command prompt programs. Anything like that for javascript?</p> <p>I know the best way to improve is to figure out what I want to do and learn how to do it, but I'm able to do everything I want for the time being, and want to have the ability to do whatever else I want without having to learn it.</p>
javascript
[3]
415,078
415,079
Finding dollar sign with strpos
<p>So I'm trying to find several special characters, such as {, $ in a string returned by DOM element</p> <p>When I run</p> <pre><code>if(strpos("$", $u) === FALSE AND strpos("{", $u) === FALSE AND $u != "#") { echo "Attempting {$u} ecoded: ".urlencode($u)."&lt;br/&gt;"; return true; } </code></pre> <p>However when I run it, it prints out:</p> <pre><code>Attempting register.php ecoded: register.php Attempting {$url} ecoded: %7B%24url%7D Attempting $authUrl ecoded: %24authUrl Attempting services.php ecoded: services.php </code></pre> <p>So I tried using HEX values and ASCII but still had no luck!</p>
php
[2]
4,687,403
4,687,404
how to check bundle version for our application by programming?
<p>I have make application and i have installed in iphone.But i want to check my application bundle version by programming.How it possible can you give me advice?</p>
iphone
[8]
3,494,434
3,494,435
can I use float[] to hold ints?
<p>we have one class which has one <code>float[]</code> and one <code>int[]</code>. Sometimes the user of that class needs put float valuse and sometimes int values, but will not be both for each instance.</p> <p>We know all the possilbe float and int values will not be big (less than 100000). I am thinking we may not need the <code>int[]</code>, just use the <code>float[]</code> to hold int values when necessary. At the time we use them, we can cast them to int when necessary. One storage array will be much clear.</p> <p>How do you think about my idea? put int into float[] will not lose anything. I am right?</p> <p><strong>EDIT:</strong></p> <p>One class have one <code>float[]</code> class variable and one <code>int[]</code> class variable to hold values for user. Users of that will use either float[] or int[] but not both. So we have get float[]and set float[] methods, AND get int[] and set int[] methods, and different constructors. I am thinking to simplify this class by remove int[] class variable and use a float[] for both int values and float values for different users.</p>
java
[1]
493,291
493,292
How do I set time limit for loop?
<p>I do have a loop, say:</p> <pre><code>$lines = file('file.txt'); foreach ($lines as $line) { // some function } </code></pre> <p>Some times this take more time to complete one loop if data is not available. So how do I set a time limit to each loop so if any info isn't available it will move to next?</p>
php
[2]
4,046,437
4,046,438
how to track two keyboard key when they are down at same time
<p>think user pressed two keys at same time .</p> <p>I want to be notified of this two keys , not one .</p> <p>like <code>Up + Left</code></p> <p>how can I find out this ?</p>
c#
[0]
1,906,138
1,906,139
How can i make some image analyzing using android API ?
<p>How can i make some loop that run on all the pixels on the image that i got from the camera ? </p> <p>I want to be able to scan all the pixels and according to the RGB of some pixel i need to make some decision about the next activity that my application will make. </p>
android
[4]
3,155,426
3,155,427
Generating all subsets from a single set
<p>I was trying to understand the code to generate all the subsets from one set. Here is the code</p> <pre><code>#include &lt;stdio.h&gt; /* Applies the mask to a set like {1, 2, ..., n} and prints it */ void printv(int mask[], int n) { int i; printf("{ "); for (i = 0; i &lt; n; ++i) if (mask[i]) printf("%d ", i + 1); /*i+1 is part of the subset*/ printf("\\b }\\n"); } /* Generates the next mask*/ int next(int mask[], int n) { int i; for (i = 0; (i &lt; n) &amp;&amp; mask[i]; ++i) mask[i] = 0; if (i &lt; n) { mask[i] = 1; return 1; } return 0; } int main(int argc, char *argv[]) { int n = 3; int mask[16]; /* Guess what this is */ int i; for (i = 0; i &lt; n; ++i) mask[i] = 0; /* Print the first set */ printv(mask, n); /* Print all the others */ while (next(mask, n)) printv(mask, n); return 0; } </code></pre> <p>I am not understand the logic behind this line <code>for (i = 0; (i &lt; n) &amp;&amp; mask[i]; ++i)</code> inside the next function. How is the next mask being generated here?</p> <p>Code and algorithm looked here: <a href="http://compprog.wordpress.com/2007/10/10/generating-subsets/" rel="nofollow">http://compprog.wordpress.com/2007/10/10/generating-subsets/</a></p>
c++
[6]
5,082,872
5,082,873
Editing properties files w/o losing formatting
<p>I have a properties (Java world) file with comments and key=value. I simply want to take backup of the file and edit few key=value. I need to edit the key in loop as the number of keys are not fixed and also the key names differ partly which is not a problem, but i am struggling to know how to maintain the format of the file (comments, spaces)?</p> <pre><code> # ABC System Admin Database abc_jdbc.password=5667P7JiL7k221j+DmnVQ== # XYZ System Admin Database xyz_jdbc.password=489slP7JiL7k221j+LmnVQ== </code></pre> <p>and so on......</p>
java
[1]
23,002
23,003
Update text with submitted data w/jQuery
<p>I have a form on a page. I have a link acting as submit button. The value is sent to a php page via ajax where the value is set into a session.</p> <p>After submit I swap the form with text field where the text is displayed. How do I use the text from the submitted form to display withing <code>&lt;pre&gt;&lt;/pre&gt;</code> tags?</p> <pre><code>$("#btnPreview").click(function() { var custM = $("#inviteMsg").val(); $.ajax({ url: "ajax.php", type: "POST", data: "msg="+custM }); }); &lt;div id="customMsgPreview"&gt; &lt;div class="rollSec"&gt; &lt;pre&gt; // SUBMITTED TEXT NEEDS TO APPEAR HERE '.$tstLnk.' &lt;/pre&gt; &lt;/div&gt; </code></pre>
jquery
[5]
5,334,410
5,334,411
iPhone UITableView shows one cached view in it's UITableCellView, the last one added!
<p>I have an object that return a cached image view (UIImageView), which do the loading, showing the loading image, and then populate the view with the loaded image.</p> <p>In my case, the TableView shows multiple rows, where the same user photo might appears more than once, and I noticed that because it is cached, it shown in the last cell it is been added to. I've tried to construct the UIImageView each time the table ask for a cell, it works, so the problem is with the cached image view!, but i don't know why! hints? </p>
iphone
[8]
2,804,865
2,804,866
How does JavaScript distinguish between objects?
<p>I have wriiten</p> <pre><code>document.createElement("p"); document.createElement("p") </code></pre> <p>How does Javascript intepreter knows do distinct between those two?</p> <p><strong>Id</strong> ? ( what is the Js <strong>property</strong> )? maybe something <strong>else</strong> ?</p>
javascript
[3]
5,454,962
5,454,963
Override browsers CTRL+(WHEEL)SCROLL with javascript
<p>In most browsers on linux, CTRL+(WHEEL)SCROLL allows the user to zoom in and out of the page by enlarging or shrinking the size of all elements. Now I want to override this behaviour and get CTRL+WHEEL to zoom into an SVG element I have by applying affine transformations.</p> <p>Is this possible? Specifically, is it possible to catch this keyboard/mouse event as well as suppressing the browser's default behaviour?</p>
javascript
[3]
380,331
380,332
Class specific new/delete
<p>Is it possible to overload class specific new/delete that is called when arrays of objects are created.</p> <pre><code>class Foo; Foo* f = new Foo[10]; // calls overloaded new delete[] f; // calls overloaded delete </code></pre> <p>Thank you.</p>
c++
[6]
944,223
944,224
Development environment for a LAMP-based website - Redirects to Server Default Page
<p>In our current environment, if any changes need to be made to the code, these changes are directly coded and updated to the Live server. GWe would like to set-up a development server where we can test our changes before uploading to the live site. </p> <p>I have attempted to build a development site locally by installing Apache, PHP &amp; MySQL and copying all the htdocs to the Apache folder. However, when I try to access localhost/ it redirects me to the server default page. Any ideas on why this may be happening?</p>
php
[2]
3,496,428
3,496,429
Use JQuery to Replace type of tag with same ID
<p>I wish to use JQuery to replace (backward and forward)</p> <pre><code>&lt;a id="my_id"&gt;abc&lt;/a&gt; </code></pre> <p>to</p> <pre><code>&lt;span id="my_id"&gt;abc&lt;/span&gt; </code></pre> <p>May I know how I can do so in JQuery?</p> <p>Thanks.</p>
jquery
[5]
1,366,548
1,366,549
How to Combine TemplateFields in ASP.Net GridView?
<p>Everyone.</p> <p>I have a question when combining cells in GridView. I konw how to combine BoundField cells, but I do not know how to combine TemplateField cells in asp.net GridView.</p> <p>EDIT:</p> <p>Perhaps I did not make my question clearly and I am sorry about that. My question is that I use <code>GridView</code> to bind data from <code>db</code> and There is a field named <code>UserName</code>, one user has several records in the db, so I want to combine UserName in one cell(i can combine it correctly). In the same way, I want to do some operation to this user such as Add, Delete. So i put these operations into <code>TemplateField</code>, but i do not konw how to combine <code>TemplateField</code> like <code>BoundField</code>. I have a low reputation, so i can not post images</p> <p>Any good ideas?</p> <p>Sorry for my poor english! Thanks in advance.</p>
asp.net
[9]
4,043,625
4,043,626
How can I get the variable of outer function in Javascript
<p>If only string is allowed to pass into function process(), what should we do inside the function process() to access the array value. Eval is one of the method, but its usage is not suggested by many people.</p> <pre><code>function demo2(name2) { var alpha = []; alpha["a"] = "test1"; var bravo = []; bravo["a"] = "test2"; function process(name) { alert(window[name]["a"]); } process(name2); // error } </code></pre> <p>name2 can be "alpha" or "bravo" or many other arrays' name.</p> <pre><code>var alpha = []; alpha["a"] = "test1"; var bravo = []; bravo["a"] = "test2"; function process(name) { alert(window[name]["a"]); } process("alpha"); </code></pre> <p>For the second example, it works fine. I just want to pass the string into the function and use it as the array name in the first example. I have the 2nd example and so I would like to know how I can do this inside a function. </p> <p>What should I write inside the function process to alert the alpha and bravo variables?</p>
javascript
[3]
5,341,858
5,341,859
Finding Parent form's button from frame in javascript
<p>i cant get my main form's button from frame by javascript.I am getting button's ID by querystring then i execute following script but cant get button.When i write parameter's name such as getElementByID('btnDelete'),it founds control?What can be reason and how can i solve this problem?</p> <pre><code> function okay() { var btn = getQuerystring('btn'); window.parent.document.getElementByID(btn).click(); </code></pre> <p>}</p> <pre><code>function getQuerystring(key, default_) { if (default_ == null) { default_ = ""; } var search = unescape(location.search); if (search == "") { return default_; } search = search.substr(1); var params = search.split("&amp;"); for (var i = 0; i &lt; params.length; i++) { var pairs = params[i].split("="); if (pairs[0] == key) { return pairs[1]; } } return default_; } </code></pre>
javascript
[3]
381,417
381,418
how to add numbers in various textboxs and the sum displayed in a label
<p>Am trying to add different numbers from different textbox, in a way that once the values are entered into each textbox, the summed value is displayed in a label showing the total value. eg. textbox1 + textbox 2 values to be displayed in label1. in C#. pls how do i go about this? thanks</p>
c#
[0]
3,550,624
3,550,625
How to compare a parameter string Visual C++
<p>I want to do something simple: check what a parameter is.</p> <pre><code>void _tmain(int argc, WCHAR *argv[]) { if(argv[4] == "-h"); { //do stuff } } </code></pre> <p>I am getting an incompatible error from WCHAR * to const char *.</p> <p>Such a conversion question has been asked, but the answers I have found are many and not simple. I am a total newbie at C++.</p> <p>What I am looking for is not pointers to some complicated functions, but rather the actual code to put into my program to make it work.</p> <p>Just looking for something simple, straightforward, working code. Thanks!</p>
c++
[6]
4,919,521
4,919,522
'no resource identifier found for attribute 'textcolor' in package 'android''
<p>When creating my hello android app, I am getting an error: </p> <blockquote> <p>'no resource identifier found for attribute 'textcolor' in package 'android''</p> </blockquote> <p>I am a complete newb to android development and I thought that I must have put in the wrong https in the location field when building my ADT, but from what I can see on <a href="https://dl-ssl.google.com/android/eclipse/" rel="nofollow">this site</a>, I did the right one. What or where to I go or do to solve this problem?</p>
android
[4]
4,820,756
4,820,757
Find Element in PHP Array (if exists)
<p>I'm wondering if there is a more elegant way to do this:</p> <pre><code>$foo = (isset($bar) and array_key_exists('meh', $bar)) ? $bar['meh'] : ''; </code></pre> <p>If I remove the <code>isset</code> part, PHP issues a warning if <code>$bar</code> isn't an array, if I remove the <code>array_key_exists</code> part, PHP issues a warning if the <code>meh</code> key isn't in the array. Is there a more graceful, warning free, way of achieving the same end?</p>
php
[2]
1,766,718
1,766,719
display a long string in a table row
<p>i have a tableview which displays the result from the web service the result fron the web sevice is in form of string array, where each string in the array is pretty long. It is like "1|123|JP Morgan|111|2000.0|Pending", similarly there are strings which i diplay in each row of the table. but as you can see the string is very long, to display it in a single table row. in the table view, i can just view first 3 ie "1|123|JP Morgan" the it shows.....</p> <p>how can i display the entire string in the table</p>
iphone
[8]
4,852,724
4,852,725
cast numerics to double efficiently
<p>I have a bunch of numeric values. They can be <code>Short</code>, <code>Integer</code>, <code>Long</code>, <code>Float</code> or <code>Double</code> (and are the output of an external library (snakeYaml) which returns these as type <code>Object</code>)</p> <p>I'd like to convert these Objects (which are guaranteed to be <code>Numbers</code>) to <code>Double</code> values in my program. (Storage space is not an issue).</p> <p>The Java compiler obviously throws a <code>ClassCastException</code> when attempting to cast from an object which is actually an <code>Short</code>/<code>Integer</code>/<code>Long</code>/<code>Float</code> to a <code>Double</code>.</p> <p>Any hints as to the most efficient method to adopt would be gratefully acknowledged.</p>
java
[1]
5,598,744
5,598,745
Replace text with JavaScript
<p>I need to replace text using Javascript. It's a little different than the other ones I've seen on S.O. because the text that needs to be added in is an incrementing integer.</p> <p>For example: Replace the string: "John Mary Ellen Josh Adam" with "John1 Mary2 Ellen3 Josh4 Adam5"</p>
javascript
[3]
5,730,282
5,730,283
numeric array sort()
<p>Is this part from the book "Learning PHP, MySql and Javascript by. Robin Nixon" wrong?</p> <pre><code>numbers = [7, 23, 6, 74]; numbers.sort(function(a,b){return a - b}); </code></pre> <p>output is 6,7,23,74</p> <p>The book says:</p> <blockquote> <p>If the anonymous function inside sort() returns a value greater than zero, the sort assumes <strong>a</strong> comes before <strong>b</strong>.</p> <p>If the anonymous function inside sort() return a value less than zero, the sort assumes <strong>b</strong> comes before <strong>a</strong>.</p> <p>The sort runs this function across all the values in the array to determine their order.</p> </blockquote> <p>is this wrong? Because....</p> <p><code>a</code> here is <code>7</code><br> <code>b</code> here is <code>23</code></p> <p><code>7 - 23 = -16</code> // a number less than zero. Book says it should b comes before a.</p> <p>so the final output should be <code>74, 23, 7, 6</code></p>
javascript
[3]
3,200,260
3,200,261
Row Transfer according to the person login
<p>I have two pages, called "Staff_Common" &amp; "Staff_Main". Both this page had griedview. "Staff_Common" can be view by all staff. but "Staff_Main" is personal for each staff. My question is, when a particular person login, how to tansfer a row from "Staff_Common" Gridview to "Staff_Main" Gridview if the user click on a row at "Staff_Common" according to the user which clicked it?</p>
asp.net
[9]
2,852,857
2,852,858
Incrementing hexa strings in Python
<p>I'm trying in python to increment hexa decimal values that are represented in strings like <code>'84B8042100FE'</code>, how can i increment this value with 1 to have <code>'84B8042100FF'</code> ?</p> <p>thank you.</p>
python
[7]
3,153,306
3,153,307
Calling a method from different class
<p>Hi so I'm still learning to use methods, but one of my assignments requires me to call a method from a method in a different .java file.</p> <p>The problem is "Sets" is not recognized and it displays an error message stating that both "Sets" cannot be resolved to a variable. Am I calling the method incorrectly?</p> <p>This is the method if it is relevant. It comes from a java file called Sets.</p> <pre><code>public static final int Initial_Pop = (int)(EARTH_AT * EARTH_BT * 0.4); </code></pre> <p>This is the method I'm trying to call the above method..</p> <pre><code>public static void plusPeople (int[][] earth, int newPerson) { int [][] earthpopulation = new int [Sets.EARTH_AT][Sets.EARTH_BT]; } </code></pre> <p>I apologize if I'm unclear or did not provide enough information. If so please tell me!</p>
java
[1]
4,711,735
4,711,736
Linq To SQL: a newbies Journey
<p>I am new to asp.net and I am trying to learn Linq to SQL. So I have found two different ways to pull from the database. The normal linq to SQL way and the direct SQL statement way. </p> <p>I have both working, but I want to know which way is the accepted standard? I want to use straight SQL statements, because that is what I am use to, but I am trying to go with whatever is best practice.</p> <p>Thanks</p>
asp.net
[9]
1,703,142
1,703,143
php delete array elements inside foreach loop?
<p>I have a foreach loop and I would like to completely remove the array elements that satisfy the criteria and change the keys to stay 1,2,3,4.</p> <p>I have:</p> <pre><code>$thearray=array(20,1,15,12,3,6,93); foreach($thearray as $key=&gt;$value){ if($value&lt;10){ unset($thearray[$key]); } } print_r($thearray); </code></pre> <p>But this keeps the keys as they were before...I want to make them 1,2,3,4...how to do?</p>
php
[2]
4,224,362
4,224,363
Python count sub lists in nested list
<p>I have created a list -></p> <pre><code>a = [[1,2,3],[4,5,6],[7,8,9]] </code></pre> <p>1) How do I get the count of number of sub-lists in a? Like in this case it is 3</p> <p>2) I am using iterator tool chain for traversing this list</p> <pre><code> for elt in itertools.chain.from_iterable(node): </code></pre> <p>Is there any way to know if I have traversed a sub list ?</p>
python
[7]
1,242,828
1,242,829
Image caching and loading in Linear layout
<p>I am searching for fast solution how to cash images. </p> <p>I found many done this in loading in ListView images. </p> <p>However i need to load images into ImageButton which is subview of Linear layout. </p> <p>Maybe someone saw this implemented or could give me some tips how to do this ? </p> <p>Thanks.</p>
android
[4]
2,391,727
2,391,728
How to Get Only Text from an HTML File in java
<p>How can we get only Body(Text) of an HTML file using regexp in java ?</p>
java
[1]
5,781,142
5,781,143
jTruncate / live()
<p>I been looking at <a href="http://blog.jeremymartin.name/2008/02/jtruncate-in-action.html" rel="nofollow">http://blog.jeremymartin.name/2008/02/jtruncate-in-action.html</a>. It doesn't seem to work for html added to the page after page load.</p> <p>Does anyone know how that would work or if there is a better solution? </p>
jquery
[5]
1,591,524
1,591,525
Changing document.domain to completely other domain
<p>I'm trying to prove that changing document.domain can be used only for cross scripting on the same upper level domain. For example if i will try to change document.domain to "google.com" on page which is located on www.test.com I will get a security exception in FF. Does anybody know where to locate an official proof of that?</p>
javascript
[3]
3,932,637
3,932,638
Curved text on outside of path
<p>How should I go about drawing text along a curved path, but facing out rather than in? I found this <a href="http://stackoverflow.com/questions/8337221/how-to-write-curved-text">answer</a> on drawing text to a curve and it' the method I currently use, but the text is unreadable when upside down(at the bottom of a circle). Thanks</p> <p><img src="http://i.stack.imgur.com/dS639.jpg" alt="enter image description here"></p>
android
[4]
4,004,907
4,004,908
JQuery Highlight is not working
<p>i have the following references to jquery on my page:</p> <pre><code>&lt;link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"&gt;&lt;/script&gt; </code></pre> <p>and the code within the</p> <pre><code> $('#goStep2btn').click(function () { if (haserrors == true) { //alert("Displaying Error Message"); $('#ErrDisplay').html(errortext); window.scrollBy(0, -600); $('#ErrDisplayContainer').slideDown({ duration: 100 }).animate({ opacity: 1 }, { queue: false }); // $('ErrDisplayContainer').animateHighlight(); $('ErrDisplayContainer').effect('highlight', { color: "#FF0000" }, 3000); } else if (haserrors == false) { //alert("no ERRORS"); //format personal details and display $('#PersonalDetailsContainer').slideUp({ duration: 200 }).animate({ opacity: 1 }, { queue: false }); $('#jq_PersonalDetailsDisplay').slideDown({ duration: 200 }).animate({ opacity: 1 }, { queue: false }); } } </code></pre> <p>the button click event has alot more coding in it which validates the user input for registration step 1 before it gives the user an overview of the entered data and then shows step 2 for them to enter their payment information, if there are any errors with the data entered in step 1 the button validation will then show an Error Div tag and i want the div tag to highlight to alert the user that there are issues with the data that need addressing.</p> <p>could anyone guide me as im quite new to jquery.</p> <p>thanks in advance :)</p>
jquery
[5]
188,042
188,043
Get Top position of Dialog in JQuery
<p>I am using the <a href="http://jqueryui.com/demos/dialog/#option-position" rel="nofollow">position option on JQuery dialog plugin</a>. I am trying to figure out how to get just the "top" and "left" values out of this position object. However, I'm having difficulty figuring this out. Right now, I have a dialog defined as follows:</p> <pre><code>&lt;a href="#" onclick="showHelp();"&gt;help&lt;/a&gt; &lt;div id="helpDialog" title="Help"&gt; Some Help related text &lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#helpDialog").dialog({ autoOpen: false, modal: true, buttons: { 'OK': function() { $(this).dialog('close'); } } }); }); function showHelp() { $("#helpDialog").dialog("open"); var p = ("#helpDialog").dialog( "option", "position" ); alert( /* what goes here? */); } &lt;/script&gt; </code></pre> <p>When this dialog opens, I want to display the "top" and "left" position of the dialog in an 'alert' window. But I can't figure it out. Can someone show me? Thanks!</p>
jquery
[5]
181,444
181,445
If vs. while in specific JavaScript code
<p>Why does the author of <em>Test-Driven JavaScript Development</em> (Christian Johansen) use the <code>while</code> statement instead of the <code>if</code> statement in the code below?</p> <pre><code>function getEventTarget(event) { var target = event.target || event.srcElement; while (target &amp;&amp; target.nodeType != 1) { target = target.parentNode; } return target; } </code></pre>
javascript
[3]
3,868,700
3,868,701
Android Rotation layouts not behaving properly on emultor 2.3 android
<p>I am using an eclipse ide.I am trying a simple Rotation program with xml files with one show Landscape mode and other with Potrait mode i have name this files as main.xml in res/layout and res/layout-land respetively but does not behaves properly.When i press ctrl+F12 for rotation on an emulator.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;Button android:id="@+id/pick" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:text="Pick" android:enabled="true" /&gt; &lt;Button android:id="@+id/view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:text="View" android:enabled="false" /&gt; </code></pre> <h1> </h1> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;Button android:id="@+id/pick" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:text="Pick" android:enabled="true" /&gt; &lt;Button android:id="@+id/view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:text="View" android:enabled="false" /&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
5,195,598
5,195,599
JavaScript images
<p>How do I display the same image on the same page multiple times?</p> <pre><code>&lt;head&gt; &lt;Script language="javascript"&gt; function xdf(){ for (i=0;i&lt;10;i++) { document.write('&lt;b&gt;hello world&lt;/b&gt;&lt;br&gt;'); } } &lt;/script&gt; &lt;/head&gt; </code></pre> <p>this code displays "hello world" 10 times. i would like the same thing but with certain image instead of "hello word"...</p>
javascript
[3]
1,465,142
1,465,143
Can one combine android resource strings into new strings?
<p>Android allows to create aliases of resource strings like:</p> <pre><code>&lt;resources&gt; &lt;string name="foo"&gt;somestring&lt;/string&gt; &lt;string name="bar"&gt;@string/foo&lt;/string&gt; &lt;/resources&gt; </code></pre> <p>by which the resource "bar" becomes an alias for the resource named "foo".</p> <p>What I would for my app is a possibility to combine an existing resource prefix with different suffixes, i.e. to extend it like:</p> <pre><code>&lt;resources&gt; &lt;string name="foo"&gt;foo&lt;/string&gt; &lt;string name="bar"&gt;@string/foo+bar&lt;/string&gt; &lt;string name="else"&gt;@string/foo+else&lt;/string&gt; &lt;/resources&gt; </code></pre> <p>where the resource "bar" would yield the string "foobar". Its clear that '+' doesn't work here but is there some other option to achieve such a string concatenation, so that one could define a bunch of string resources that have a common prefix?</p> <p>I realize of course that I could do such resource string concatenation at runtime but defining them statically in the resources would seem so much more elegant and simpler.</p> <p>Michael</p>
android
[4]
3,439,750
3,439,751
Android expandablelistview child click listener not working
<p>in my android project i am using <code>Expandablelistview</code> with <code>SimpleExpandableListAdapter</code>,its <code>onGroupexpand</code> function is working but <code>onChildClick</code> function whick is under <code>setOnChildClickListener(new OnChildClickListener() )</code> is not working.<br> I have read all the stackoverflow articles regarding this ,but its not working.What could be possible error....</p>
android
[4]