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
3,107,430
3,107,431
Resize function by adding 100 pixels on top of what is there now?
<p>I recently learned that I could do this: height()+100);</p> <p>So I when I tried to do:</p> <pre><code>$('.modal1').colorbox.resize({height()+100}); </code></pre> <p>I was confused why that did not work. What I want to do is (if possible, without variables) just add extra 100 pixels to the height, is this possible? Thanks :)</p>
jquery
[5]
5,292,827
5,292,828
Javascript to get elements by its attribute
<pre><code>&lt;body&gt; &lt;span someAttribute="xyz"&gt;.....&lt;/span&gt; ... &lt;div&gt; ... &lt;span someAttribute="abc"&gt;.....&lt;/span&gt; ... &lt;div someAttribute="pqr"&gt;.....&lt;/div&gt; ... &lt;/div&gt; &lt;/body&gt; </code></pre> <p>Here is a sample html page.. I need to select the html elements by its attributes i can get the attribute values by <code>getAttribute()</code> but i need to select all the elements first.</p> <p>How in javascript to get elements which has the attribute name as "someAttribute". Once i get the elements i can get the attribute values and use my function.</p> <p>Note: i want to do this without using jquery.</p>
javascript
[3]
3,717,960
3,717,961
How to make sure a batch file is executed properly through a CMD from a c# applicaiton?
<p>I have a c# applications which writes to a batch file and executes it. The application to be started and the path of application will be written in batch file and executed. which is working fine.</p> <p>How can i make sure that the application launched successfully via my batch file run in command prompt ?</p> <p>Is there any value that cmd returns after executing a batch file ? or any other ideas please...</p> <p>Code i am using now : </p> <pre><code> public void Execute() { string LatestFileName = GetLastWrittenBatchFile(); if (System.IO.File.Exists(BatchPath + LatestFileName)) { System.Diagnostics.ProcessStartInfo procinfo = new System.Diagnostics.ProcessStartInfo("cmd.exe"); procinfo.UseShellExecute = false; procinfo.RedirectStandardError = true; procinfo.RedirectStandardInput = true; procinfo.RedirectStandardOutput = true; System.Diagnostics.Process process = System.Diagnostics.Process.Start(procinfo); System.IO.StreamReader stream = System.IO.File.OpenText(BatchPath + LatestFileName); System.IO.StreamReader sroutput = process.StandardOutput; System.IO.StreamWriter srinput = process.StandardInput; while (stream.Peek() != -1) { srinput.WriteLine(stream.ReadLine()); } stream.Close(); process.Close(); srinput.Close(); sroutput.Close(); } else { ExceptionHandler.writeToLogFile("File not found"); } } </code></pre>
c#
[0]
2,240,747
2,240,748
Divide problem
<p>I was very surprised when I found out my code wasn't working so I created a console application to see where the problem lies and I've got even more surprised when I saw the code below returns 0</p> <pre><code> static void Main(string[] args) { float test = 140 / 1058; Console.WriteLine(test); Console.ReadLine(); } </code></pre> <p>I'm trying to get the result in % and put it in a progress(meaning (140 / 1058) * 100) bar on my application,the second value(1058) is actually ulong type in my application,but that doesn't seem to be the problem.</p> <p>The question is - where the problem is?</p>
c#
[0]
4,485,877
4,485,878
What is the purpose of jQuery clean and cleanData methods?
<p><a href="http://code.jquery.com/jquery-1.6.2.js">jQuery</a> has <strong>clean</strong> and <strong>cleanData</strong> methods. What is the purpose of jQuery <strong>clean</strong> and <strong>cleanData</strong> methods? </p>
jquery
[5]
1,743,365
1,743,366
Can I run ASP.NET 2.0 and 3.5 code on the same website?
<p>Can I run ASP.NET 2.0 and 3.5 code on the same website? ...or, do I need to separate them by applications, and/or servers?</p>
asp.net
[9]
812,913
812,914
How to add to TOP of unordered list with jQuery
<p>I've created a Facebook/Twitter like status update and can add the new status to an element. I recently found a great article that explains "<a href="http://stackoverflow.com/questions/1208467/how-to-add-items-to-a-unordered-list-ul-using-jquery">How to add items to an unordered list using jquery</a>" but I'm not skilled enough to edit it to make it add to the TOP of my unordered list.</p> <p>Any help would be greatly appreciated.</p>
jquery
[5]
1,926,043
1,926,044
Google analytics not showing Real time data
<p>I had integrated Google analytics in my android application but on dashboard of GA it is not showing any user. please help me where i am getting wrong.</p> <p>I am writing code as below</p> <pre><code>public void onCreate(Bundle icicle) { tracker=GoogleAnalyticsTracker.getInstance(); tracker.startNewSession(TRACKER_ID,20,this); </code></pre> <p>//also want to know what is this second parameter is used for. i am using 20 sec but I dont why to use that parameter.As written in GA it automatic dispatch after 20 sec is it right?</p> <pre><code>tracker.trackPageView("MyPage"); } @Override public void onDestroy() { super.onDestroy(); tracker.stopSession(); } </code></pre> <p>and there are multiple activities in my application using same type of code in all activities.</p> <p>still not coming any data on GA. Completed 24 hours after integrated the GA in my app. please help why GA data is not coming.</p>
android
[4]
468,142
468,143
Controls Handle
<p>how to get a handle of a particular control from a exe and set that handle to a control present in another exe?</p>
c#
[0]
640,902
640,903
Setting text in activity using Button
<p>I was wondering what is the correct way to set the text of a TextView after a button has been pushed? I currently have an app that would change the text every time the activity was created (but for now it only sets the text as one value for testing purposes):</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mama); TextView joke = (TextView) findViewById(R.id.TextView02); joke.setText("This is a test"); Button nextButton = (Button) findViewById(R.id.Button01); nextButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivity(new Intent(JokesMamaActivity.this, JokesMamaActivity.class)); finish(); } }); } </code></pre> <p>How would I be able to set the text without creating a new activity, and have the ability to continually change the text after the button has been clicked?</p>
android
[4]
2,636,499
2,636,500
Disable an HTML element, but not a form element
<p>Is there a way to disable an HTML element with jQuery that it's not a form element?</p> <p>For example:</p> <pre><code>&lt;ul class="selectors"&gt; &lt;li class="clear-selected"&gt;Clear Selected&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt; &lt;li class="select-all"&gt;Select All&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Can I 'disable' the LI "clear-selected"?</p> <p>What I'm trying to do is so that that LI can't be clicked on.</p> <p>I've tried something like this but it doesn't work:</p> <pre><code>$('#x').attr('disabled', true); </code></pre> <p><a href="http://docs.jquery.com/FAQ#How_do_I_disable.2Fenable_a_form_element.3F" rel="nofollow">http://docs.jquery.com/FAQ#How_do_I_disable.2Fenable_a_form_element.3F</a></p> <p>Thanks,</p> <p><strong>EDIT--</strong></p> <p>This question is part of a bigger case, here's the <a href="http://stackoverflow.com/questions/4762777/buttons-activate-deactivate-elements-in-list-complex-case"><strong>Main Question</strong></a>. </p> <p>Thanks to everyone that answered.</p>
jquery
[5]
2,959,634
2,959,635
Is $_SERVER['REQUEST_METHOD'] guaranteed to be uppercase?
<p>I've currently got <code>strtoupper($_SERVER['REQUEST_METHOD'])</code> in my code.</p> <p>But is the <code>strtoupper</code> call necessary? Is <code>$_SERVER['REQUEST_METHOD']</code> guaranteed to be uppercase already?</p>
php
[2]
2,986,671
2,986,672
Complex variable (variable name change with others variable) possible?
<p>I would like to use a way for use variable to change the name of an other variable... Because an example is always appropriate :</p> <pre><code>&lt;?php for ($i = 1; $i &lt;= 5; $i++) { ${a.$i} = "value"; } echo "$a1, $a2, $a3, $a4, $a5"; //Output is value, value, value, value, value ?&gt; </code></pre> <p>For me, I got 5 steps, for each step, I have a description like step1_desc, can I do something like step{step}_desc in java ?</p> <p>Thanks in advance</p>
java
[1]
336,596
336,597
how to modified xml fields when click on the save button?
<p>hi all according to below code when change the country name and currency if i click on the save button it has to modified when i edit it modified should be appear in the xml tags for this anyone help me to solve the problem.</p> <p>xml string : </p> <pre><code>&lt;GetCountries&gt; &lt;CountryID&gt;10&lt;/CountryID&gt; &lt;/GetCountries&gt; </code></pre> <p>method name : <code>UpdateCountryDetails</code></p> <p>xml string : </p> <pre><code>&lt;UpdateCountryDetails&gt; &lt;CountryID&gt;10&lt;/CountryID&gt; &lt;CountryName&gt;Zimbabwe&lt;/CountryName&gt; &lt;Currency&gt;Zimbabwe Dollar&lt;/Currency&gt; &lt;GMTDiff&gt;&lt;/GMTDiff&gt; &lt;/UpdateCountryDetails&gt; </code></pre>
android
[4]
2,605,706
2,605,707
how to bind single field of grid with multiple values using DataBinder.Eval
<p>i have one hidden field and i want to bind it with two values of my data base separated by an coma. some thing like ->asp:HiddenField ID="hfRstidDate" runat="server" Value=&lt;%# DataBinder.Eval(Container.DataItem, "tsk_ID"),DataBinder.Eval(Container.DataItem, "Date_Worked").ToString())%><br> pleas help </p>
asp.net
[9]
2,004,697
2,004,698
Alternative to a bunch of while (true) loops when awaiting messages or client connections? (TcpClient C#)
<p>I thought C# was an event-driven programming language.</p> <p>This type of thing seems rather messy and inefficient to me:</p> <pre><code>tcpListener.Start(); while (true) { TcpClient client = this.tcpListener.AcceptTcpClient(); Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientCommunication)); clientThread.Start(client); } </code></pre> <p>I also have to do the same kind of thing when waiting for new messages to arrive. Obviously these functions are enclosed within a thread.</p> <p>Is there not a better way to do this that doesn't involve infinite loops and wasted CPU cycles? Events? Notifications? Something? If not, is it bad practice to do a Thread.Sleep so it isn't processing as nearly as often?</p>
c#
[0]
3,549,547
3,549,548
Trulia app and google api
<p>I downloaded the application Trulia, on my smartphone, and I would be interested to inquire about the use of google maps, which are used in the above application. I would be interested to know how I could achieve a similar interaction with maps, in which the pointer directs me to a specific "product", where with a simple click I can view a detailed description.</p> <p>web site of Trulia: <a href="http://www.trulia.com/" rel="nofollow">http://www.trulia.com/</a></p> <p>Best Regads</p> <p>A.</p>
android
[4]
5,834,715
5,834,716
What is the correct way to silently close InputStream in finally block without losing the original exception?
<p>I am wondering if the below code closes InputStream in finally block correctly</p> <pre><code>InputStream is = new FileInputStream("test"); try { for(;;) { int b = is.read(); ... } } finally { try { is.close(); } catch(IOException e) { } } </code></pre> <p>If an exception happens during is.read() will be it ignored / suppressed if an exception happens during is.close()?</p>
java
[1]
5,817,102
5,817,103
Replace a control on the screen
<p>I have an instance of a FlowCoverView (a great library that emulates cover flow on the iPhone). And it works great, with the exception of an update. When I update my table behind the scenes, I have no way of telling this control (that is defined in IB) that it has been updated, and to reload. (much like you can with a table using reloadData)</p> <p>To the question, is there a way to replace a control that is on the screen with another control to force the reload?</p>
iphone
[8]
4,462,308
4,462,309
How to get a list of available network providers?
<p>Hey everybody, i'm trying to get a list of the available cellular network providers. Unfortunately i can't find any service or class that might help me out :( Does anyone have an idea on how to manage this? It has to be possible since you can see the list when you go to the settings on your Android device...</p> <p>Gr33tz Goddchen</p>
android
[4]
5,524,444
5,524,445
height of page with jQuery
<p>What is the best way to measure the height of the entire page, and not just a screen. The reason I am asking is because i need to add an overlay div that should cover it entirely. Perhaps i can measure the height and add some more pixels for good measure?</p> <p>If i do something like this, is it a move in the right direction of is there a better way?</p> <pre><code>$('#myOverlay').height($('#myPage').height() + 100) ; </code></pre>
jquery
[5]
1,092,399
1,092,400
mysql_num_rows() expects parameter 1 to be resource error message on register form
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in-select">mysql_fetch_array() expects parameter 1 to be resource, boolean given in select</a> </p> </blockquote> <p>I am working on a registration form which corresponds with two mysql tables in my database.</p> <ol> <li>userlogin - contains all the details registered with the site</li> <li>userlogin_fb - contains all the details of users using the fb connect facility</li> </ol> <p>Now when a user signs up there cannot be a clash of username or email address. I am now implementing the validation code for checking the email addresses across the two tables (which will be used as a reference for the username validation):</p> <p>But i keep receiving the following error message:</p> <blockquote> <p>Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in register.php on line 144</p> </blockquote> <p>How do i go about resolving this?</p> <pre><code>//select all rows from our users table where the emails match $res1 = mysql_query("SELECT * FROM `userloginl.email`,`userlogin_fb.email` WHERE `email` = '".$email."'"); $num1 = mysql_num_rows($res1); //if the number of matchs is 1 if($num1 == 1){ //the email address supplied is taken so display error message echo "&lt;center&gt;The &lt;b&gt;e-mail&lt;/b&gt; address you supplied is already taken&lt;/center&gt;"; include_once ("resources/php/footer.php"); exit; }else{ //finally, otherwise register there account } </code></pre> <p>Any help would be appreciated - thanks!</p>
php
[2]
1,517,253
1,517,254
What is the purpose of variable duplication in a method?
<p>I see this [below] all over in the Android code (and some other code sources). What is its point or purpose?</p> <pre><code>class Foo { int mBar = 1337; static void main(String... args) { System.out.println(isFubar()); } boolean isFubar() { int ret = mBar; // &lt;--- Focus of attention if (ret == 666) return true; else return false; } } </code></pre> <p>It seems like a waste of time and resources. mBar clearly isn't being modified. There is no risk of it being modified (in the given context), so why would one duplicate the primitive just to preform a noninvasive check on it and return?</p> <p>EDIT Specific example from the class CellLayout in the Android Source</p> <pre><code>public void cellToRect(int cellX, int cellY, int cellHSpan, int cellVSpan, RectF dragRect) { final boolean portrait = mPortrait; &lt;--- Here it is final int cellWidth = mCellWidth; final int cellHeight = mCellHeight; final int widthGap = mWidthGap; final int heightGap = mHeightGap; final int hStartPadding = portrait ? mShortAxisStartPadding : mLongAxisStartPadding; final int vStartPadding = portrait ? mLongAxisStartPadding : mShortAxisStartPadding; int width = cellHSpan * cellWidth + ((cellHSpan - 1) * widthGap); int height = cellVSpan * cellHeight + ((cellVSpan - 1) * heightGap); int x = hStartPadding + cellX * (cellWidth + widthGap); int y = vStartPadding + cellY * (cellHeight + heightGap); dragRect.set(x, y, x + width, y + height); } </code></pre>
java
[1]
5,535,722
5,535,723
Error while using onActivityResults() method
<p>I am doing a test Paypal Application from this <a href="http://androiddevelopement.blogspot.in/2011/04/adding-paypal-payment-in-android.html" rel="nofollow">link</a>. Following is part of my code, </p> <pre><code>@Override protected void onActivityResults(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); System.out.println ( "Result Code : " + resultCode ); switch(resultCode) { case Activity.RESULT_OK: System.out.println ( "Success" ); break; case Activity.RESULT_CANCELED: System.out.println ( "Canceled" ); break; case PayPalActivity.RESULT_FAILURE: System.out.println ( "Result Failure" ); } } </code></pre> <p>As long as I add <code>@Override</code> it starts showing me the following error:</p> <blockquote> <p>The method onActivityResults(int,int,Intent) of type MainActivity must override or implement a supertype method </p> </blockquote> <p>This is the image : </p> <blockquote> <p><img src="http://i.stack.imgur.com/XTwMX.png" alt="enter image description here"></p> </blockquote> <p>If I remove <code>@Override</code> line, everything works fine but method <code>onActivityResults()</code> doesn't get called.</p> <p>What should I do to remove this error?</p>
android
[4]
4,100,658
4,100,659
Access Android's dictionary for autocompletion
<p>I want to create an autocompletion function in Android, and I want it to lookup words from the existing language dictionary on the device.</p> <p>What dictionaries are there an Android devices? (maybe several languages, and some user dictionaries?) How can I access Android's existing dictionaries?</p>
android
[4]
2,356,406
2,356,407
How to close all activities?
<p>I want to know how to close all activities from the stack on button click?</p> <p>Please help.</p> <p>Thanks, Monali</p>
android
[4]
974,558
974,559
Android Content Provider tied to external storage (text file)
<p>I'm trying to code a system for running user studies. I have a webpage and a webservice on top of a user DB. My Android app is a client to run the studies on. I'm use the Account Manager to store user credentials authenticated via the webservice. The point is to then implement a sync adapter that will send a text file with study data to my server, via the webservice (using the credentials).</p> <p>My problem is that I'm having difficulty with the Content Provider, I've searched a lot throught the web but I can't seem to find an example of how to code a Content Provider tied to a file on external storage. All the examples I find use Content Providers tied to database tables. Can someone please point me in the right direction or shed some coding light? (BTW, I have read the Android Developer texts on Content Providers, also, I'm using Android 2.2).</p> <p>Any help is appreciated.</p> <p>Cheers, André Coelho</p>
android
[4]
2,409,747
2,409,748
How can I pass this defined value to iclude a file in my PHP script?
<p>I require a file in my PHP file</p> <pre><code>require('config.local.php'); </code></pre> <p>that contains the database credentials but it doesn't allow me to use some variables because of</p> <pre><code>if ( !defined('AREA') ) { die('Access denied'); } </code></pre> <p>How can I pass this and access the variables instead of forcing people to add their database login/password?</p> <p>Thank you.</p>
php
[2]
1,222,773
1,222,774
Can i play video in portrait mode?
<p>Can anybody explain me how to play video in portrait mode in iphone device. It will be very helpful to if you provide some sample code for referance. Thanks in advance.</p>
iphone
[8]
970,173
970,174
Binding listbox content to another listbox
<p>I have 2 listboxes in my form and I binded some data to first listbox from the database. Now I have to show the selected items of the first listbox in the second listbox when a buton is pressed. im able to show one selected item at a time, but im unable to show multiple selected items. I used a hash table and the follwing code please help me im new to this concept thank in advance.</p> <pre><code>Hashtable ht = new Hashtable(); ht.Add(listbox1.SelectedValue.ToString(),listbox1.Text.ToString()); int i = 0; foreach (string ent in ht.Values) { string[] name = new string[listbox1.Items.Count]; for (i = 0; i &lt; listbox1t.SelectedItems.Count; i++) { name[i] = listbox1.Text; this.listbox2.Items.Add(name[i]); } listbox2.DisplayMember = ht.Values.ToString(); listbox2.ValueMember = ht.Keys.ToString(); } </code></pre>
c#
[0]
5,879,941
5,879,942
Compare a drawing to letters
<p>I'm allowing a user to draw on a canvas. Once tapped OK, I want to compare the drawing with one or more letters (could be double byte). How do I best map the drawing to the letter sequence? I need an approach for scaling, comparing and visualizing. For the later I though to use a 3 color approach: mapping pixels black, letter only pixels green, drawing only pixels red. Would that work?</p>
android
[4]
3,805,726
3,805,727
How to create a list view as a part of a form in android
<p>How to create a <code>ListView</code> as a part of a form in Android using <code>ListView</code> as a part of the form something similar to select option in <code>html</code> is what I am looking for.</p>
android
[4]
4,930,374
4,930,375
Android - WebViewClient
<p>I am trying to load URL inside a WebViewClient as below:</p> <pre><code>webview.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } public void onPageFinished(WebView view, String url) { } public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { } }); webview.loadUrl(articleLink); </code></pre> <h2>Problem:</h2> <p>Web URL is loading successfully but in some occurrence i got the following errors, at the same time i would like to display Alert Dialog instead of Webview with Error message.</p> <p>So can you please let me know ,<strong>How do i handle the following kind of errors:</strong></p> <ol> <li>"Web page not available" error</li> <li>"Directory listing Denied"</li> </ol> <p>I have attached the 2nd one's image for your reference:</p> <p><img src="http://i.stack.imgur.com/ftD1i.png" alt="alt text"></p>
android
[4]
5,896,410
5,896,411
How can i sum two polynomials? in python
<p>I have to make a program that can take from the user two polynomials (string) to calculate the result. The problem is that in polynomials the program must sum the coefficients that have the same power. I have to make it using class. I'm beginner in python. Thank you </p>
python
[7]
5,096,385
5,096,386
My .text('') is not replacing the form field data as expected
<p>I have an 11 row table with an id=’eliminate’, in which 6 rows have id’s of no. 1-6, the others w/o id’s.</p> <p>For example: </p> <pre><code> &lt;tr id="1" style="visibility:&lt;?php if(empty($row_rsUpdate2['teacher_last_name'])) echo 'hidden;'; else echo 'visible;';?&gt;"&gt; &lt;td&gt;&lt;a href="#" id="clear1"&gt;clear&lt;/a&gt;&lt;/div&gt;&lt;/td&gt; </code></pre> <p>There are seven input fields in each row and, since this is an update form, they are fed from the db with existing data. I want the viewer to be able to remove the existing data from the seven form fields in the row, prior to updating, simply by clicking ‘clear’ and to replace it all with empty strings, i.e. ‘’.</p> <p>I am trying this (and many variations of it,) without success:</p> <pre><code>$(document).ready(function() { $('#clear1').click(function(){ $('#eliminate #1 input').text(''); }); }); </code></pre> <p>The click function has alerted the form fields correctly (7), so that's not it, other edits and tests have shown some life, but all to no avail. As I am new to jQuery, I’m chasing my tail today. How do I get the results I want? Thank you.</p>
jquery
[5]
643,028
643,029
Socket Connection failure
<p>Socket Connection fails after sometime when connecting my application to dotnet server. While it works fine with Java server. Does any compatibility issues there?</p>
android
[4]
1,148,686
1,148,687
Regarding screen lock and unlock
<p>I am doing one application to lock and unlock a screen. I am using disableKeygaurd and reeanbleKeygaurd to lock and unlock. the below code i used to unlock:</p> <pre><code>if(mKeyguardLock == null){ mKeyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE); mKeyguardLock = mKeyGuardManager.newKeyguardLock("****"); mKeyguardLock.disableKeyguard(); } </code></pre> <p>and for lock:</p> <pre><code>if(mKeyguardLock != null){ mKeyguardLock.reenableKeyguard(); mKeyguardLock = null; } </code></pre> <p>It is working fine. but problem is when user unexpectedly unlock a screen by dragging keygaurd(without using my app) then my app will not lock the screen for next time.. I want to work my application when user used unlock by dragging keygaurd also. what should I have to do this? Thanks in advance</p>
android
[4]
756,796
756,797
Why is getattr() not working like I think it should? I think this code should print 'sss'
<p>the next is my code:</p> <pre><code>class foo: def __init__(self): self.a = "a" def __getattr__(self,x,defalut): if x in self: return x else:return defalut a=foo() print getattr(a,'b','sss') </code></pre> <p>i know the <code>__getattr__</code> must be 2 argument,but i want to get a default attribute if the attribute is no being. </p> <p>how can i get it, thanks</p> <p><hr /></p> <p>and </p> <p>i found if defined <code>__setattr__</code>,my next code is also can't run</p> <pre><code>class foo: def __init__(self): self.a={} def __setattr__(self,name,value): self.a[name]=value a=foo()#error ,why </code></pre> <p><hr /></p> <p>hi alex, i changed your example:</p> <pre><code>class foo(object): def __init__(self): self.a = {'a': 'boh'} def __getattr__(self, x): if x in self.a: return self.a[x] raise AttributeError a=foo() print getattr(a,'a','sss') </code></pre> <p>it print {'a': 'boh'},not 'boh' i think it will print self.a not self.a['a'], This is obviously not want to see</p> <p>why ,and Is there any way to avoid it</p>
python
[7]
4,782,639
4,782,640
What is the best way to limit text input entry to numbers, lowercase letters, and certain symbols?
<p>Without using jQuery, what is the best way to limit text entry of a textbox to numbers, lowercase letters and a given set of symbols (for example <code>-</code> and <code>_</code>)? If the user enters an uppercase letter, I would like it to be automatically converted to a lowercase letter, and if the user enters a symbol not within the given set, I would like to be able to instantly show a validation error (show some element adjacent to or below the text box).</p> <p>What's the cleanest cross-browser way of doing this without the aid of jQuery?</p>
javascript
[3]
4,569,305
4,569,306
What is difference between Instanted then using and Uninstant using?
<p>Please looking in the below codes:</p> <pre><code>new StreamWriter("c:/myText.txt").Write("Some thing..."); </code></pre> <p>And,</p> <pre><code>using (var streamWriter = new StreamWriter("c:/myText.txt") { streamWriter.Write("Some thing..."); } </code></pre> <p>The first code creating the file but doesn't write "Some thing..." in that. But the second code works as well and write in that.</p> <p>Why this issue happens? What is the difference?</p>
c#
[0]
1,514,824
1,514,825
Replace date in a DateTime with another date
<p>How do you change the day part of a <code>DateTime</code> structure?</p> <p>I have a <code>DateTime</code> with the value of 3/31/2009 8:00:00 AM and would like to change it to any other date but the time should be same. I don't need a solution to add day(s), I need to replace it with any arbitrary date.</p> <p>How do I achieve this?</p>
c#
[0]
4,655,616
4,655,617
How to populate all the listViews in click of a button?
<p>I have three tabs with three screens A,B,C screens.The screen A has a listview and a download button, screen B has a different listview and screen C again has a differnt listView. In screen A when I am pressing the dowmnload button the database is getting populated and the ListView in Screen A is getting polpulated. I am trying to polpolte the other two screens as well when I am clicking on the download button but I am not able to do this.How can I polpulate all the three listviews on a single click of the button in scree A. Please help me out in doing this. Thanks in Advance.</p>
android
[4]
728,969
728,970
MySQL SELECT / QUERY - How can I select all datarecords by a string independet of write art?
<p>I have follow php code:</p> <pre><code>$query = "SELECT * FROM catalog WHERE Keywords LIKE '%$Keywords%'" ; </code></pre> <p>where Keywords contains a string in the greek language ( as you know greek words have an accent (like: ξυλουργεία νομού Ηλείας). I want to search the column of the mysql-column independet of the writting art of the words that Keywords contains. Those words are given from visitors of my site. The visitor can write as follow those key words: ΞΥΛΟΥΡΓΕΙΑ ΝΟΜΟΥ ΗΛΕΙΑΣ, or Ξυλουργεία νομού Ηλείας etc. </p> <p>Thnx</p> <p>it would be for me much better if you could answer my question in the German or Greek languange. </p>
php
[2]
3,666,476
3,666,477
What is the difference between this function call?
<pre><code>setInterval("RunSlide()", 5000); </code></pre> <p>First, call a function with brackets and quotes.</p> <pre><code>setInterval("RunSlide", 5000); </code></pre> <p>Second, call a function without brackets but still using a quotes.</p> <pre><code>setInterval(Runslide, 5000); </code></pre> <p>Third, call a function without brackets and quotes.</p> <pre><code>RunSlide(); </code></pre> <p>Fourth, call a function with brackets.</p> <pre><code>RunSlide; </code></pre> <p>Fifth, call a function without brackets.</p>
javascript
[3]
2,806,787
2,806,788
Get profile picture of specific phone number from contacts information
<p>I am developing message send/receive application, and i need to get profile picture of phone number. Could any one please help me to get the profile picture of specific number?</p> <p>Thanks in advance :)</p>
android
[4]
5,748,426
5,748,427
access # part of the URL via PHP
<p>Say I have this url.</p> <pre><code>http://mydomain.local/category/12/garden#31/decking-treatment </code></pre> <p>Can the part after the # i.e <code>31/decking-treatment</code> be retrieved on serverside?</p> <p>I checked in the <code>$_SERVER</code> and <code>$_REQUEST</code> superglobals but it is not there.</p> <p>Thanks</p> <p>Regards Gabriel</p>
php
[2]
1,857,968
1,857,969
iPhone: UILocalNotification doesn't repeat the notification
<p>I am trying to use UILocalNotification in my project. I want my application to get notified every 5 seconds (non stop) in the background. I am trying the following code. It is notifying my application only for the first time after 5 seconds, after installed. I want it to be notified continuously every 5 seconds without stop. How can i achieve it?</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; // Initiating notification at app startup [self InitiateLocalNotification]; return YES; } -(void) InitiateLocalNotification { NSDate *notificationDate = [NSDate dateWithTimeIntervalSinceNow:5]; UILocalNotification *notify = [ [UILocalNotification alloc] init ]; notify.fireDate = notificationDate; //notify.applicationIconBadgeNumber = 1; notify.soundName = UILocalNotificationDefaultSoundName; notify.timeZone = [NSTimeZone defaultTimeZone]; //notify.alertBody = @"Local notification test"; //notify.repeatInterval = 1; NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@"notifiValue" forKey:@"notifiKey"]; notify.userInfo = infoDict; // Schedule the notification [[UIApplication sharedApplication] scheduleLocalNotification:notify]; [notify release]; } - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { } </code></pre>
iphone
[8]
5,525,520
5,525,521
loopin in .load in jquery
<p>why load() function loops almost 23 times when i have only eight elements with .image class</p> <pre><code>$(document).ready(function() { var i=0; $('.image').load(function(){ console.log(i++); }); }); </code></pre> <p>my html is</p> <pre><code>&lt;div class="pel homepics"&gt; &lt;div class="left i1" &gt;&lt;a href="#" &gt;&lt;img class="image" src="image1.png"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="left i1" &gt;&lt;a href="#" &gt;&lt;img class="image" src="image1.png"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="left i1" &gt;&lt;a href="#" &gt;&lt;img class="image" src="image1.png"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="left i1" &gt;&lt;a href="#" &gt;&lt;img class="image" src="image1.png"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="left i1" &gt;&lt;a href="#" &gt;&lt;img class="image" src="image1.png"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="left i1" &gt;&lt;a href="#" &gt;&lt;img class="image" src="image1.png"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="left i1" &gt;&lt;a href="#" &gt;&lt;img class="image" src="image1.png"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;div class="left i1" &gt;&lt;a href="#" &gt;&lt;img class="image" src="image1.png"/&gt;&lt;/a&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
3,801,470
3,801,471
jQuery $('div').html() - function problem
<p>This code should not generate any HTML button dynamically. Coz there is no div in the <code>&lt;html&gt;&lt;/html&gt;</code> section.</p> <p>But it is generating one.</p> <p>Why?</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HtmlReWriting.aspx.cs" Inherits="JQuery_Intellisence_Test.HtmlReWriting" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script src="Javascript/jquery-1.3.2.js" type="text/javascript"&gt; /// &lt;reference path="Javascript/jquery-1.3.2-vsdoc.js" /&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; function ReWrite() { $('div').html('&lt;input type="button" value="Button1" /&gt;'); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;/form&gt; &lt;input id="Button1" type="button" value="ReWrite HTML Element" onclick="ReWrite()" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
525,744
525,745
PHP variable like $myvar-test is not valid?
<p>I need to create a var like <code>$myvar-test;</code> but thats not valid or? </p>
php
[2]
4,368,400
4,368,401
Cardio graph for android
<p>I want to make an app which shows cardio graph in real time. That means i want to measure heart bit and want to show the bit rate in graph in my application. But i wondering to draw the cardio graph. I have gone through many sample graph codes but dint get any clue to draw cardio graph. Is there any clue from any body?</p> <p>Thanks &amp; Regards</p>
android
[4]
2,957,202
2,957,203
How to make a timer to shutdown computer with c# windows form application
<p>i'm having trouble finding enough resources to create the windows form application that i want.As title says i want to create an application on which i can set a timer to shutdown computer.Any example or help would be appreciated.Regards</p> <p>Edit:so i've mananged to put current date/time button and individual shutdown button the problem is i dont know how to set a timer on shutdown during the program is running.</p> <p>Heres what i've put so far:</p> <p>public partial class Form1 : Form { public Form1() { InitializeComponent(); }</p> <pre><code> private void buttonTimerStart_Click(object sender, EventArgs e) { timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { labelDate.Text = DateTime.Now.ToString(); } private void buttonTimerStop_Click(object sender, EventArgs e) { timer1.Stop(); } private void buttonShutdown_Click(object sender, EventArgs e) { Process.Start("Shutdown", "-s -t 0"); } </code></pre>
c#
[0]
1,732,667
1,732,668
Bad practice in php?
<p>I have some PHP code that generates a calendar and then outputs html to display it. </p> <p>To display it on a page all I need to do is <code>&lt;?php include('calendar.php'); ?&gt;</code>. </p> <p>Is this bad practice?</p>
php
[2]
890,243
890,244
Email/Exchange app in android
<p>I am trying to write an app like <code>Email/Exchange app</code> in android. This is exactly like <code>Email/Exchange</code> app. i will take input from user for user name, password, domain, POP/IMAP, push etc. How should i proceed? are there any jars available in android for developing this app?</p>
android
[4]
1,129,380
1,129,381
Chained Method Calls in Python with dict
<p>I needed to flatten a dictionary today. Meaning I wanted:</p> <pre><code>{'_id': 0, 'sub': {'a': 1, 'b':2}} </code></pre> <p>to become:</p> <pre><code>{'_id': 0, 'a':1, 'b':2} </code></pre> <p>So I thought I could be clever and pull off the following one-liner.</p> <h2>One-liner:</h2> <pre><code>x = dict(_id=0, sub=dict(a=1, b=2)) y = x.pop('sub').update(x) # incorrect result </code></pre> <p>This results in <code>y = None</code>.</p> <p>So I obviously resorted to:</p> <h2>Multi-Step:</h2> <pre><code>x = dict(_id=0, sub=dict(a=1, b=2)) y = x.pop('sub') y.update(x) # correct result </code></pre> <p>Setting "good expressive coding practices" asside for a moment, I would like to understand why the <strong>One-liner</strong> approach above yields <code>None</code>. I would have thought that x.pop('sub') would have resulted in a temporary dict on a stack somewhere and the original x dict would be immediately updated. Then the stack object would receive the next method in the chain which is the update. This obviously does not seem to be the case.</p> <p>For the communities better understanding (and clearly mine) - how does python resolve the one-liner and result in <strong>None</strong>? </p>
python
[7]
4,225,870
4,225,871
Reading Data from a File as it grows
<p>I have a binary data file that is written to from a live data stream, so it keeps on growing as stream comes. In the meanwhile, I need to open it at the same time in read-only mode to display data on my application (time series chart).<br><br> Opening the whole file takes a few minutes as it is pretty large (a few 100' MBytes). <br> What I would like to do is, rather than re-opening/reading the whole file every x seconds, read only the last data that was added to the file and append it to the data that was already read.</p>
c#
[0]
5,784,437
5,784,438
How to communicate between two servers
<p>We have an application will dump files into a location which will be needed by a customer and vice versa, where in the customer side they are have a file server which contains the files that we need. </p> <p>The process should start from our side, when we upload a file in our server, it should triger request to the customer side, for them to upload also a file to be map to be file we uploaded and send us the file.</p> <p>How can do this? we are using Java in the application and also thinking about using webservice.</p> <p>Thanks in advance.</p>
java
[1]
220,921
220,922
Update Table or drop and recreate?
<p>Hii i have a table in which i have to insert values is only one row..so when the values are updated should i update it or drop it and recreate?SQlite Android</p>
android
[4]
4,640,962
4,640,963
Free Native Launcher For Java At Linux and Mac
<p>My Java application require a huge memory heap. I need to launch my application using</p> <p>java -Xms32m -Xmx128m xyz.jar</p> <p>Hence, I would like to create native launcher for my Java application, where I can pass the JVM heap size parameters in. I plan to use JSmooth <a href="http://jsmooth.sourceforge.net/" rel="nofollow">http://jsmooth.sourceforge.net/</a> for Windows platform.</p> <p>However, I would also like to create native launcher for Linux and Mac. May I know which open source/ free software can help me to do so?</p> <p>LaunchAnywhere <a href="http://www.zerog.com/iamanual/usermanual_ia55/WebHelp/launchanywhere/abo12e.htm" rel="nofollow">http://www.zerog.com/iamanual/usermanual_ia55/WebHelp/launchanywhere/abo12e.htm</a></p> <p>seem good. But it is a commercial software.</p> <p>Thanks.</p>
java
[1]
2,320,836
2,320,837
checking if there is a folder with a name that start with a specific string
<p>I'm writing a python script that is supposed to manage my running files. I want to make sure that the source and target folder exist before I run it and I can do this with <code>os.path.exists</code>. However, I have a set of foldernames <code>runner&lt;i&gt;</code>. Is there a way to check that there is some folders begining with that name?</p> <p>For example, if in the path <code>/path/to/runners</code> I have at least one folder named <code>runner</code>:</p> <blockquote> <p>/path/to/runners/ $ ls file1.txt<br> file2.txt<br> folder1<br> folder2<br> runner1 runner35<br> zfolder </p> </blockquote> <p>Then the result is true. Remove runner1 <em>and</em> runner35 and it will be false.</p>
python
[7]
1,229,853
1,229,854
Android : getting result from an activity without finish call in that activity
<p>In my application Activity A has a list of items on choosing a product i go to activity B that give details of that item and a button "Choose this item" which will go to activity C. In actvity C this choosen item is displayed and there is a button "choose more items" on clicking this i have to go back to activity A, and repeat the same steps. BUt when another item is choosen, activty C should display both items.</p> <p>SO i thought from actvity C, i start activity A, by calling <code>startActivityForResult()</code> and add the result to existing list of items. In that case, i have to call <code>finish()</code> of A to retrn value. Is this right way of implementing</p> <p>Since "choose more items" can be clicked many times in real life, wont it end up killing and starting many times the same activity I have set the launch mode as single task for the activities</p> <p>What would be the best way to handle this situation</p> <p>thanks a lot for your time and help</p>
android
[4]
3,021,099
3,021,100
Get current URL and trim with PHP
<p>Im getting the URL using:</p> <pre><code>$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; </code></pre> <p>This returns something like:</p> <p><a href="http://me.domain.co.uk" rel="nofollow">http://me.domain.co.uk</a></p> <p>How can I select 'me' only?</p>
php
[2]
4,184,763
4,184,764
Display Ads To % of Users
<p>I have a site that I want to display ads to 10% of my traffic. I am getting on average around 30,000 hits a day and want 10% of those users to see an ad from one of my advertisers.</p> <p>What's the best way to go about implementing this?</p> <p>I was thinking about counting the visitors in a database, and then every 10 people that visit 1 user gets an ad. Or is there a better way of going about it?</p> <p>I'm no good with math, so I'm not sure what's the best approach.</p>
php
[2]
1,229,634
1,229,635
Is it possible to hardcode constructor arguments?
<p>Before I was using;</p> <pre><code>public static void main(String args[]) { try { ORB orb = ORB.init(args, null); } } </code></pre> <p>and then having parameter argument </p> <pre><code>-ORBInitialPort 1050 </code></pre> <p>I now want to remove the main section of the code and have the class being created inside another class, so is it possible to hardcode these arguments? Or do i have to pass the data from the new class into the class that needs it?</p>
java
[1]
1,314,850
1,314,851
C#: Converting byte array to string and printing out to console
<pre> public void parse_table(BinaryReader inFile) { byte[] idstring = inFile.ReadBytes(6); Console.WriteLine(Convert.ToString(idstring)); } </pre> <p>It is a simple snippet: read the first 6 bytes of the file and convert that to a string.</p> <p>However the console shows <code>System.Byte[]</code>.</p> <p>Maybe I'm using the wrong class for conversion. What should I be using? It will eventually be parsing filenames encoded in UTF-8, and I'm planning to use the same method to read all filenames.</p>
c#
[0]
669,889
669,890
Name for a public const and private writable atrribute?
<p>Programming in C++, I often want to give the user of a class read-only access to an attribute, and the class itself read-write access. I hate <code>XxxGet()</code> methods, so I often use a <code>public const &amp;</code> to a private attribute, like this:</p> <pre><code>class counter { private: int _count; public: const int &amp; count; counter : _count( 0 ), count( _count ){} void inc( void ){ _counter++; } }; </code></pre> <p>Is there a common name for this trick?</p>
c++
[6]
754,308
754,309
Horizontal LinearGradient with android
<p>Hey everyone, This must be an easy one but I'm really at a loss... The following code draws a rectangle with a linear gradient going from left to right, from white to black, </p> <pre><code>int x1 = 0, y1 = 0, x2 = 100, y2 = 40; </code></pre> <p>Shader shader = new LinearGradient(x1, y1, x2, y2, Color.WHITE, Color.BLACK, TileMode.CLAMP); Paint paint = new Paint(); paint.setShader(shader); canvas.drawRect(new RectF(x1, y1, x2, y2), paint); Ok, fine. Now what I'd like to do is to change this gradient into a <strong>horizontal</strong> one, so that the color goes from white to black, from top to bottom. What I tried to do is to add:</p> <pre><code>Matrix trans = new Matrix(); </code></pre> <p>trans.setRotate(90); shader.setLocalMatrix(trans); but instead the gradient goes at a funny angel, or there is just a single color... I also tried to play with the coordinates of the gradient in all sorts of way (thinking that maybe they should be transformed) to no avail. What am I missing?</p>
android
[4]
55,139
55,140
Refresh contents of dialog
<p>I need to update a custom dialog content whenever that dialog is ready to be drawin. I am not sure this could be refreshed directly or if I need to close it first and re-instatiate it?</p>
android
[4]
5,179,013
5,179,014
How are Intent-Categories matched?
<p>I don't get the Android Intent matching concept! I must be missing something, but I read and re-read the docs and don't get it. Maybe some kind soul can shed some light on this? </p> <p>I am able to start an Activity if I specify a Category filter <code>android.intent.category.DEFAULT</code> in the manifest:</p> <pre><code> ... &lt;activity android:name="mmmo.android.test.ItemDetails" &lt;intent-filter&gt; &lt;action android:name="android.intent.action.INSERT" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; ... </code></pre> <p>and if I then don't add any Category to the Intent object:</p> <pre><code> ... Intent intent = new Intent(Intent.ACTION_INSERT); startActivity(intent); ... </code></pre> <p>That works. However, as soon as I define any other category than <code>android.intent.category.DEFAULT</code> I am only getting <code>ActivityNotFoundException</code>s. E.g. if I specify:</p> <pre><code> ... &lt;activity android:name="mmmo.android.test.ItemDetails" &lt;intent-filter&gt; &lt;action android:name="android.intent.action.INSERT" /&gt; &lt;category android:name="foo.bar" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; ... </code></pre> <p>and then try to start that Activity using:</p> <pre><code> ... Intent intent = new Intent(Intent.ACTION_INSERT); intent.addCategory("foo.bar"); startActivity(intent); ... </code></pre> <p>this does not work. The doc reads "... every category in the Intent object must match a category in the filter. ...". The category name I add to the Intent matches the category I specified in the filter. So why does this not match up and just throws an exception???</p> <p>Michael</p>
android
[4]
5,614,703
5,614,704
Python wildcard search in string
<p>Lets say that I have a list </p> <pre><code>list = ['this','is','just','a','test'] </code></pre> <p>how can I have a user do a wildcard search?</p> <p>Search Word: 'th_s'</p> <p>Would return 'this'</p>
python
[7]
4,745,486
4,745,487
Only count article from directory from file
<p>I'm trying to count the amount of articles that are in a large file - example-</p> <pre><code>103.239.234.105 -- [2007-04-01 00:42:21] "GET articles/learn_PHP_basics HTTP/1.0" 200 12729 "Mozilla/4.0" 207.3.35.52 -- [2007-04-01 01:24:42] "GET index.php HTTP/1.0" 200 11411 "Mozilla/4.0" 51.4.190.113 -- [2007-04-01 02:07:04] "GET articles/php_classes_and_oop HTTP/1.0" 200 7674 "MSIE 7.0" </code></pre> <p>They ideas where i start?</p>
php
[2]
5,736,582
5,736,583
is it possible to simulate file upload form?
<p>I'm trying to test a file upload function. This function I'm trying to test is where the file data is posted to from a form.</p> <p>Is there a way to test this function without the need of an upload form?</p>
php
[2]
5,897,705
5,897,706
Pass a string value from one view controller to another
<p>I am using this way to pass a string value from one view controller to another but still it's not working. Please help! From the main menu login method I pass a result value of a web service to SecondMenu:</p> <pre><code>- (IBAction)MainMenuLogin_Method:(id)sender { SecondMenu *lc2=[[SecondMenu alloc] initWithNibName:@"SecondMenu" bundle:nil]; lc2.username_TextField.text=@"hello";// in actual it is a soap result //[self presentModalViewController:lc2 animated:YES]; [[[[UIApplication sharedApplication] delegate] window] addSubview:lc2.view]; } </code></pre>
iphone
[8]
1,685,839
1,685,840
Don't want to maintain Webview state in android
<p>I have created a webview with javascript interface. While clicking on webview's button i am opening the google play activity, i don't want to maintain the same state after relaunching the app.</p> <p>App-->webview interface-->opening a new activity for google play-->go back to home-->re lanching the app-->showing the google play activity</p> <p>Here after relaunching the app don't want to display the google play acitivity, it has to display the webview.</p> <p>Anyone can help me out this.</p>
android
[4]
3,516,565
3,516,566
Exception inside catch block
<blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="http://stackoverflow.com/questions/833946/in-c-will-the-finally-block-be-executed-in-a-try-catch-finally-if-an-unhandled">In C# will the Finally block be executed in a try, catch, finally if an unhandled exception is thrown ?</a> </p> </blockquote> <p>Will finally be executed in this scenario (in C#)?</p> <pre><code>try { // Do something. } catch { // Rethrow the exception. throw; } finally { // Will this part be executed? } </code></pre>
c#
[0]
5,087,886
5,087,887
Change Textbox Background When it Receives Focus (asp.net)
<p>I want to reset the background image of a textbox when it receives focus. How can I do this?</p>
asp.net
[9]
2,187,561
2,187,562
create an array in jquery of all section ids
<p>I have a site that I am building that involves quite a bit of animation. I need to create an array of all the section id in the page. I really have no idea how to do this but a pretty sure this is the right direction. I am first just trying to get those values:</p> <pre><code> var $find = $('body').find('section[id]'); </code></pre> <p>I have tried alerting the output and I just get object Object? Can someone poijt me in the right direction. Thanks</p>
jquery
[5]
2,168,556
2,168,557
android location with pin on map
<p>I'm working on an Android application which basically shows the real time location of user on map with a pin.</p> <p>When the user moves the pin should also move. I want to show multiple user's with image and moving pin as location changes on map.</p>
android
[4]
5,814,903
5,814,904
Draw oval with option thickness in Android
<p>I want to Draw an oval with option thickness </p> <pre><code>Paint paintt = new Paint(); paintt.setColor(Color.RED); paintt.setStyle(Paint.Style.STROKE); RectF ovalBounds = new RectF(leftx, topy, rightx, bottomy); canvas.drawOval(ovalBounds, paintt); </code></pre> <p>If I want to increase the thickness of the oval , What can I do ?</p>
android
[4]
420,875
420,876
How to perform drag and drop among multiple tables
<p>Hello i found the plugin for drag and drop with in the table.. But unable to found the same operation among multiple tables. if u know any plugin please send me the link..</p> <p>Thank you</p>
jquery
[5]
3,696,961
3,696,962
Same click event two different results?
<p>I have a click event lets take this example: </p> <pre><code>$('p').click( function() { $('.xclass').css( { 'background' : 'green' } ); }); </code></pre> <p>The above code will change the background color of a div if I click the p tag. </p> <p>Now my question is again clicking the same p tag I want to change the color to yellow!!. How can I do this?. </p>
jquery
[5]
2,584,080
2,584,081
How to optimize the code in my java application
<p>A java app I have been writing for the last few years has now become quite bloated and I am conscious of including unused code etc… I know for css and javascript you perform code cleanups and compact the code etc.. does anything like this exist for java?</p>
java
[1]
2,106,532
2,106,533
Looping through selected values in multiple select combobox JQuery
<p>I have the following scenario. </p> <p>I have a combobox where multiple selection is available.</p> <pre><code> &lt;select id="a" multiple="multiple"&gt; &lt;option value=""&gt;aaaa&lt;/option&gt; &lt;option value=""&gt;bbbb&lt;/option&gt; &lt;option value=""&gt;cccc&lt;/option&gt; &lt;option value=""&gt;dddd&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Now I also have a button</p> <pre><code>&lt;button type="button" id="display"&gt;Display&lt;/button&gt; </code></pre> <p>When a user clicks on this button, it should list all the selected values of the dropdown in an alert box</p> <p>My JS code looks as follows</p> <pre><code> $(document).ready(function() { $('#display').click(function(){ alert($('#a').val()); }); }); </code></pre> <p>Any pointers will be appreciated</p>
jquery
[5]
2,066,975
2,066,976
A question regarding a class and it's methods
<p>I am currently trying to write an ircbot and have gotten stuck. As you can see I define a method for the ircBot class, connect, which creates a socket object. I want to use this object in the sendCmd method, is this possible?</p> <p>I have been looking around google and stackoverflow but have not been able to work out a solution(probably because I'm rather new to Python). Any hints appreciated!</p> <pre><code>import socket import sys import os class ircBot: def sendCmd(self, cmd): SEND_TEXT_ON_OPEN_SOCKET def connect(self, server, port): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) c = s.connect_ex((server, port)) if c == 111: print("Error: " + os.strerror(c)) sys.exit(1) print("Making connection to " + server + "\n") </code></pre> <p>Regards,</p> <p>David</p>
python
[7]
5,608,815
5,608,816
Trying to make a write function for a class and getting error
<p>I have implemented a write function for my class but iam getting error:</p> <pre><code>class Fa{ private: string Q_; string F_; public: void write(ostream&amp; out = cout) const{ out&lt;&lt;Q_&lt;&lt;endl; out&lt;&lt;F_&lt;&lt;endl; } }; </code></pre> <blockquote> <p>Error:default argument given for parameter 1 of `void Fa::write(std::ostream&amp;) const' </p> </blockquote> <p>Can anybody please tell me what does this error mean and how could i avoid it?</p>
c++
[6]
1,999,449
1,999,450
Distinguish between a single click and a double click in Java
<p>I search the forum and see this codes:</p> <pre><code> public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { System.out.println(" and it's a double click!"); wasDoubleClick = true; } else { Integer timerinterval = (Integer) Toolkit.getDefaultToolkit().getDesktopProperty( "awt.multiClickInterval"); timer = new Timer(timerinterval.intValue(), new ActionListener() { public void actionPerformed(ActionEvent evt) { if (wasDoubleClick) { wasDoubleClick = false; // reset flag } else { System.out.println(" and it's a simple click!"); } } }); timer.setRepeats(false); timer.start(); } } </code></pre> <p>but the code runs incorrectly(Sometime it prints out " and it's a single click!" 2 times . It should print out " and it's a double click!"). Can anybody show me why? or can you give me some better ways to do this? Thank you!</p>
java
[1]
2,186,748
2,186,749
Which TD did I click on? jquery
<p>I have a table with some rows and I am using jQuery to apply a click event to the TRs</p> <pre><code>$("tr").click(function(e) { console.log($(this).data("rowid")); }); </code></pre> <p>That works fine. One of the TDs, I have an actual link and when I click the link, I still get the console.log to print out. Is there a way to exit that click function if I am clicking the link?</p>
jquery
[5]
2,416,938
2,416,939
Automatic email from iphone application
<p>I have seen some similar questions here on stack-overflow, but in my application i want when user click on confirm button automatic email go to the email id specified in the form with other details. </p> <p>How can i implement this.</p>
iphone
[8]
2,820,209
2,820,210
TypeInitializationException in my singleton. How can I fix it?
<p>I have a singleton and when I call it from my UnitTest I get </p> <p>"System.TypeInitializationException was unhandled by user code Message=The type initializer for 'mycompany.class'threw an exception"</p> <pre><code>public sealed class MySingleton { private static MySingleton instance = new MySingleton(); private MySingleton() { ConnectionString = GetConnectionstring(); } public static MySingleton NewConnectivity { get { return instance ?? (instance = new MySingleton()); } } public string ConnectionString { get; set; } private static string GetConnectionstring() { return "bla"; } } </code></pre>
c#
[0]
2,164,124
2,164,125
PHP: switch() default for all?
<p>I have this:</p> <pre><code>case true: echo '&lt;textarea rows="2" cols="35" name="message_friend" id="message_friend"&gt;&lt;/textarea&gt;'; break; default: echo '&lt;textarea rows="2" cols="35" name="message_friend" id="message_friend" readonly="readonly"&gt;&lt;/textarea&gt;'; break; </code></pre> <p>I am trying to ONLY if it's true, then show normal else do READONLY.</p> <p>The switch is checking from a function</p> <pre><code>switch( ( check_friend_state($showU["id"], 'friend') ) ) </code></pre> <p>And I tried to echo the function, and it returned err2 and not true, so why does it run true?</p> <p>I also tried if/else</p> <pre><code>if(check_friend_state($showU["id"], 'friend') == true){ echo '&lt;textarea rows="2" cols="35" name="message_friend" id="message_friend"&gt;&lt;/textarea&gt;'; }else{ echo '&lt;textarea rows="2" cols="35" name="message_friend" id="message_friend" readonly="readonly"&gt;&lt;/textarea&gt;'; } </code></pre> <p>But as said previously it returns "err2" and still it runs true?</p> <p>My function at the return:</p> <pre><code>if($USER == $uID){ // not yourself return "err1"; }elseif( $checkIsFriend-&gt;rowCount() == 1 ){ // already friends return "err2"; }elseif( $checkAlready-&gt;rowCount() == 1 ){ // already send a request return "err3"; }elseif( $checkBlock-&gt;rowCount() == 1 ){ // blocked return "err4"; }else{ return true; } </code></pre>
php
[2]
3,728,543
3,728,544
Javascript: resize image to fit window, then toggle full size and adjust size on click?
<p>I'm trying to create a small snippet to allow the onloaded image to be adjusted to fit the users resolution. And then allow the user to toggle between the actual image size, and the adjusted image size for their resolution. Here's what I got so far:</p> <pre><code>&lt;img src="&lt;?=$file['direct_url']?&gt;" border="0" onload="if(this.width&gt;screen.width/1.5) {this.width=screen.width/1.5;this.alt='Click image to view full size';}window.status=this.width;" onmouseover="if(this.alt) this.style.cursor='hand';" onclick="if (this.width=screen.width/1.5) {this.width=screen.width*1.5} else {this.width=screen.width/1.5}"&gt; </code></pre> <p>Any help is greatly appreciated!</p>
javascript
[3]
807,633
807,634
How does android decide to cache a process
<p>In Gingerbread Settings->Applications->MyApplications, the Running tab has been divided into two. Running Services and Cached Background Process. So how and when does Android decide to cache a process? Mainly is there anything my app can do to tell the system to never cache my process? Thanks KK</p>
android
[4]
1,524,756
1,524,757
Commas after a loop
<p>I want to add a comma to every username except last one. For example: User1, User2, User3 How do I do this? here is my code:</p> <pre><code>$user_online_sql = $db-&gt;query("SELECT DISTINCT account_id FROM online WHERE account_id != '-1';"); $users = ''; while ($user_online_row = mysql_fetch_array($user_online_sql)) { $users .= $user-&gt;name($user_online_row['account_id']) . ' '; } </code></pre> <p>I tried the implode function but it just outputted a blank result, here is the code with the implode function: </p> <pre><code> $user_online_sql = $db-&gt;query("SELECT DISTINCT account_id FROM online WHERE account_id != '-1';"); $users = ''; while ($user_online_row = mysql_fetch_array($user_online_sql)) { $users .= implode(', ',$user-&gt;name($user_online_row['account_id'])) . ' '; } </code></pre>
php
[2]
2,587,821
2,587,822
running java on linux server
<p>I would like to run a jar file extracted from my java project to be run on a Linux server I connect through SSH Tunneling. There are few problems, first there is something wrong with the Display: I get the error </p> <pre><code>No X11 DISPLAY variable was set, but this program performed an operation which requires it. at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173) at java.awt.Window.&lt;init&gt;(Window.java:437) at java.awt.Frame.&lt;init&gt;(Frame.java:419) at java.awt.Frame.&lt;init&gt;(Frame.java:384) at javax.swing.JFrame.&lt;init&gt;(JFrame.java:174) at random_v2.v2Frame.&lt;init&gt;(v2Frame.java:127) at random_v2.Wrapper.main(Wrapper.java:25) </code></pre> <p>and second is that I am not sure if I have to install other applications as well. In my code, the java program needs to get run other applications like weka, do I have to install weka with the same directory name and specs that is in my mac? I appreciate your help in advance. Best wishes</p>
java
[1]
195,585
195,586
How can implement search bar in android?
<p>I am working in android. i am trying to display name of university using listView.</p> <p>my list view is looking like this. <img src="http://i.stack.imgur.com/8wv0y.png" alt="enter image description here"></p> <p>Now i want to add a search bar on the top of this list view. if i press <strong>A</strong> in search bar then this list view should display all the name of university start with <strong>A</strong>, if i press some other character then according university name must be displayed.</p> <p>Please tell me how can implement this. Is any way to make search bar in android. I have seen in iPhone, it works very efficiently in iPhone. Please help me how can make this search bar ?</p> <p>Thank you in advance...</p>
android
[4]
1,146,991
1,146,992
jquery remove direct child element
<p>Using jQuery, how can I remove an anchor tag in my html body which also consists of a wrapper div, and this wrapper div is above the anchor tag that I want to remove. </p> <p>It is like</p> <pre><code>&lt;body&gt; &lt;div id="wrapper"&gt; &lt;a id="not_me" href="#"&gt;hi&lt;/a&gt; &lt;/div&gt; &lt;a id="remove_me" href="#"&gt;Remove Me&lt;/a&gt; &lt;/body&gt; </code></pre> <p>If I use </p> <pre><code>$("body").find("a:first-child").remove(); </code></pre> <p>it removes the first anchor tag in my wrapper div i.e. one with id "not_me", while I want "remove_me" to be removed.</p>
jquery
[5]
4,123,088
4,123,089
Incorrect logic flow? function that gets coordinates for a sudoku game
<p>This function of mine keeps on failing an autograder, I am trying to figure out if there is a problem with its logic flow? Any thoughts?</p> <p>Basically, if the row is wrong, "invalid row" should be printed, and clearInput(); called, and return false. When y is wrong, "invalid column" printed, and clearInput(); called and return false.</p> <p>When both are wrong, only "invalid row" is to be printed (and still clearInput and return false.</p> <p>Obviously when row and y are correct, print no error and return true.</p> <p>My function gets through most of the test cases, but fails towards the end, I'm a little lost as to why.</p> <pre><code>bool getCoords(int &amp; x, int &amp; y) { char row; bool noError=true; cin&gt;&gt;row&gt;&gt;y; row=toupper(row); if(row&gt;='A' &amp;&amp; row&lt;='I' &amp;&amp; isalpha(row) &amp;&amp; y&gt;=1 &amp;&amp; y&lt;=9) { x=row-'A'; y=y-1; return true; } else if(!(row&gt;='A' &amp;&amp; row&lt;='I')) { cout&lt;&lt;"Invalid row"&lt;&lt;endl; noError=false; clearInput(); return false; } else { if(noError) { cout&lt;&lt;"Invalid column"&lt;&lt;endl; } clearInput(); return false; } } </code></pre>
c++
[6]
1,974,422
1,974,423
Javascript line number mapping
<p>Magically formatted comments will change the reported line number of javascript errors in some browsers; They look like this:</p> <pre><code>//@line n "f" </code></pre> <p><code>n</code> is the line number and <code>f</code> is the file name. Unfortunately, <code>//@line</code> appears to be ungoogleable. Does anyone know where there is documentation on this feature, and which browsers support it?</p> <p>(I found references to it <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=618650" rel="nofollow">here</a> and <a href="http://intertwingly.net/blog/2010/11/25/Hobgoblin-of-Little-Minds#c1292142367" rel="nofollow">here</a>.)</p>
javascript
[3]
1,568,606
1,568,607
strange ^M at file name
<pre><code>[root@file Engineer]# ls resume_Al_Kassar_9-29-08.doc.txt^M resume_Al_Kassar_9-29-08.doc.txt? [root@file Engineer]# </code></pre> <p>But I browse into that directory by "File Transfer Window",didn't see ^M at all</p> <p>it's simply "resume_Al_Kassar_9-29-08.doc.txt"</p> <p>Any anyone step into this issue ever?And how to solve this?</p> <p>This .txt^M file is generated by another program,and is processed by "bashFileConvert" function(it's a PHP function).</p> <pre><code>$toF = bashFileConvert($toF);//this step generated ^M $cmd = "$parser $file $arrow_str $toF"; </code></pre> <p>How can I get rid of this annoying ^M?</p> <p>Later on I found:</p> <pre><code>$arrow_str = $arrow ? '&gt;' : ''; $file = bashFileConvert($file); $toF = bashFileConvert($toF); $cmd = "$parser $file $arrow_str $toF"; echo $cmd . "\r\n"; file_put_contents('resumeSh',$cmd."\r\n",FILE_APPEND); </code></pre> <p>It should be the last line that caused this issue!</p>
php
[2]
2,924,342
2,924,343
What's the difference in this while loop?
<p>What is difference between</p> <pre><code>while(condition){ var variable; ... } </code></pre> <p>and</p> <pre><code>while(condition){(function(){ var variable; ... })();} </code></pre> <p>Can somebody explain me defference?</p>
javascript
[3]