Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
2,607,298
2,607,299
Pass 0 via URL as parameter
<p>for some reason whenevever i try to pass 0 using a url parameter variable, on the other end it ends up as empty or null. How do i pass 0 from let's say page A to page B using url parameters?</p> <p>In symfony<br> <code>echo form_tag('application/recognition?step=0')?&gt;</code> </p> <p>ends up being like</p> <p><code>application/recognition</code> </p> <p>and step is lost, however if 0 is changed to 1 it does work.</p> <p>Thanks..</p>
php
[2]
2,598,507
2,598,508
Android button hard to hit in 2.2
<p>Hi in my app contain a Button ,currently i customized using xml for changing the background and it work fine in 2.1 but when am reach to 2.2 ,The button is hard to hit ,how can i solve the issue?</p> <p>my button xml code given below</p> <pre><code> &lt;Button android:id ="@+id/Button_Continue1" android:background="@drawable/continue_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" /&gt; </code></pre>
android
[4]
4,155,623
4,155,624
want to know the exact size of a data contend in any specified url
<p>hi all i want to know that while specifying url in my iphone native application for downloading purpose it works fine but if i want to know the exact size of data either in kb or in Mb coming from that url how could i do that plz guide me to do that demonstarting a sample code would be a big boost thanks </p>
iphone
[8]
3,757,915
3,757,916
Java: get specific ArrayList item
<pre><code>public static ArrayList mainList = someList; </code></pre> <p>how can I get a specific arrayList item ? mainList[3] ?</p>
java
[1]
4,871,368
4,871,369
Best practice for giving back extra information from a Validate function
<p>I have a class Employee. I want to be able to Validate() it before I save it to make sure all the fields have been populated with valid values. The user of the class may call Validate() before they call Save() or they may call Save() directly and Save() will then call Validate() and probably throw an Exception if validation fails. </p> <p>Now, my (main) question is this;<br /> If my Validate() function returns a simple bool then how do I tell the user of the class what is wrong, i.e. "Email not filled in", "ID not unique" etc. For the purposes of this I just want the error strings to pass to the human user, but the principle is the same if I wanted a list of error codes (except that makes the use of a bitmap more logical).</p> <ul> <li>I could use an Out paramater in my Validate function but I understand this is frowned upon.</li> <li>Rather than returning a bool, I could return a string array from my function and just test if it was empty (meaning no errors) - but that seems messy and not right.</li> <li>I could create a Struct just to return from this method, including a bool and a string array with error messages, but just seems clunky.</li> <li>I could return a bitmap of error codes instead of a bool and look it up, but that seems rather excessive.</li> <li>I could create a public property "ValidationErrors" on the object which would hold the errors. However, that would rely on me calling Validate() before reading it or explicitly calling Validate from the Property() which is a bit wasteful.</li> </ul> <p>My specific program is in C# but this looks like a fairly generic "best practice" question and one I am sure I should know the answer to. Any advice gratefully received.</p>
c#
[0]
1,408,639
1,408,640
undefined behaviour with an un intialised member variable in javascript
<p>It's 20:30 and I'm after a 6 hour bug hunt of an irritating bug caused by an uninitialized member variable.</p> <p>In the our previous version we had the next few lines of code:</p> <pre><code>var aList = new Array; for (var iDx=0; iDx &lt; nNumOfElements; iDx++) { // Some code aList.nCount = someValue; //This line } aList.sort(function(a, b) { return b.nCount - a.nCount ; }); </code></pre> <p>In the last release someone accidentally removed the line with comment. and there was no other initialization of the member variable nCount.</p> <p>Some of our clients got a "Number expected" exception which is pretty obvious (in retrospect), strangely the error doesn't reproduce with our Q.A. nor 80% of our clients!</p> <p>How can it be? is there any strict mode that we can run with that will find such pesky bugs? what is the difference between the clients that got the exception and ones that didn't (it's not browser version nor windows version)</p> <p>(our system runs only on IE6+ in a special container which makes it hard for us to write the code in normal I.D.E.'s we pretty much write it all in notepad ++)</p> <p>Thanks!</p>
javascript
[3]
4,749,587
4,749,588
Difference between "0" and "new int()" in C#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5746873/where-and-why-use-int-a-new-int">Where and why use int a=new int?</a> </p> </blockquote> <p>What's the difference between these two below?</p> <pre><code>int i =0; int i = new int(); </code></pre> <p>Is there any difference in case of memory allocation ? Is there any other difference?</p>
c#
[0]
252,130
252,131
Session expire for popup aspx page
<p>I have query over session expire on popup aspx page.</p> <p>I have asp.net project where session expire funtionality is working. now i have add one new aspx that will open as popup on certain</p> <p>event on the login page after sign-in process.</p> <p>Now question is session expire funtionality will also work for the popup aspx page as it inherit same namespace OR</p> <p>we need to implement some thing else for this</p> <p>Thanks</p>
asp.net
[9]
3,008,695
3,008,696
Duplicate case in Switch
<pre><code> protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch(requestCode) { case BOOK_SELECT: if (resultCode == RESULT_OK) { String name = data.getStringExtra("SelectedBook"); Toast.makeText(this, "You have chosen the book: " + " " + name, Toast.LENGTH_LONG).show(); break; } case PEN_SELECT: if (resultCode == RESULT_OK) { String name = data.getStringExtra("SelectedPen"); Toast.makeText(this, "You have chosen the pen: " + " " + name, Toast.LENGTH_LONG).show(); break; } } } </code></pre> <p>here both the case are different I can not get it why it is showing </p>
android
[4]
2,221,724
2,221,725
reference objects on the stack
<p>Does C# allow you to put reference objects on the stack? Why would you want to do that? What does this mean?</p>
c#
[0]
1,115,279
1,115,280
How to disable the orange highlight of checkbox when pressing
<p>I have a checkbox in the a listview. I disabled the highlighting of listview upon pressing. Also, I disabled the focus of the listview as I have buttons in the row itself.</p> <p>This worked perfect. However the problem is that the checkbox still shows Orange highlight.</p> <p>Is there anyway to disable this orange highlight of the check box (whether it is through the list view or some way through the checkbox itself?</p> <p>Thank you</p>
android
[4]
4,804,419
4,804,420
Change background color and font of tool tip for ASP. Net controls
<p>For ASP.Net controls, how to change background color, font name, size, font color for tool tips? Is it possible to add background image for tool tips instead of the default yellow color background? </p>
asp.net
[9]
5,055,985
5,055,986
jquery emulate key press "ctrl and +"
<p>I know the tecnique for zoom the page using the shift of css......</p> <p>I wanna make a button for emulate the user that press "CTRL" and "+" in same time...</p> <p>explain well with an example...</p> <p>in firefox if i press CTRL and + in the same time the page ZOOM...i wanna write a function that i call and i emulate the press of CTRL and +</p> <p>Thanks!</p>
jquery
[5]
5,368,919
5,368,920
Android java.net.UnknownHostException: Host is unresolved
<p>This code doesn't work:</p> <pre><code>URL url = new URL( xmlPath ); InputSource input = new InputSource( url.openStream() ); </code></pre> <p>all the time, resulting in an UnknownHostException, even when the host exists, has been hit successfully using the same code if from a different development host (machine), and also from a browser.</p> <p>I'm probably out of line asking this question again, a repeat of <a href="http://stackoverflow.com/questions/3293659/android-java-net-unknownhostexception-host-is-unresolved-strategy-question">http://stackoverflow.com/questions/3293659/android-java-net-unknownhostexception-host-is-unresolved-strategy-question</a>. The forum software would not allow me to comment on the unsatisfactory answer to that question (in order to solicit more attention to the solution I ultimately found). Perhaps I'm not popular enough yet to be given that privilege. In the meantime, I'm essentially re-posting the question and a different answer.</p> <p>Basically, I accept that maybe the Android device has a hard time with DNS under certain circumstances, but I've tried, for example the anddev.org example of how to use the SAX parser, and it worked on one machine I have and not on another.</p> <p>Edit: As noted, I know a working answer and will post it.</p> <p>I am a) asking a question (that's already been asked and unsuccessfully answered) and b) answering it for the benefit of those for whom my answer will be useful.</p>
android
[4]
5,157,539
5,157,540
Result is maintained in javascript array
<p>If I search in an array of objects in javascript, why is the previous result still in memory? I got the following code:</p> <pre><code>function findTasks( date ) { var result = $.grep( tasks[current].tasks, function( task ) { return task.date == date; }); return result; } </code></pre> <p>When I fire this method and assign it to a variable :</p> <pre><code>var result = findTasks('24-12-2012'); // The hardcoded date is for demonstration (it is dynamic in my application) console.log( result ); </code></pre> <p>Then each time I do the <code>findTasks()</code> method, my result of the previous search is being maintained. Even when I do the following:</p> <pre><code>function findTasks( date ) { var result = null; // Notice this line var result = $.grep( tasks[current].tasks, function( task ) { return task.date == date; }); return result; } </code></pre> <p>The results are also maintained.</p> <p><strong>Edit:</strong> Each time the findTasks() method fires, the latest results must return. And not the return of the previous method invocations.</p>
javascript
[3]
3,410,694
3,410,695
Unable to set background for a surface view in android
<p>I am streaming video from a http url.i have a surface view for this purpose which u can see below</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/backgroundplain" &gt; &lt;com.myview.HttpIPCamView android:id="@+id/single_camera" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="right" android:duplicateParentState="true" android:drawingCacheQuality="low" android:text="Loading.." &gt; &lt;/com.myview.HttpIPCamView&gt; </code></pre> <p>when ever i tried to set a background bitmap it never allows to set it instead a black screen with video comes up.Please help me to solve this problem as i am stuck for days</p>
android
[4]
3,248,440
3,248,441
How to perform some action on background when the app exit
<p>I have build an app which store dates enter by the user in the an array. Now i want to perform some action on background of my app. In the background i want a check, which check the current date of the device with the date stored in an array. When the match found i want to pop an dialog. Is it possible to do some task in background when the app exit.</p> <p>Please help me with an example, I have no idea regarding this topic</p>
android
[4]
3,594,819
3,594,820
Better to return an empty string or null value
<p>If I were writing the below method (for example) is it considered good practice to either:</p> <p>A: return an empty string if the document didn't exist</p> <p>B: return a null value?</p> <p>Having done a lot of Java, and methods in Java requiring a return type I'm under the impression it is best practice to return a consistent type, is this also the case in PHP or is it better to return a null value instead?</p> <pre><code>DocumentClass { public function getDir($documentId) { /* Code to get location of document */ return (file_exists($document) ? $document : ''); } } if (!empty($documentClass-&gt;getDir(5)) { /* Do this */ } </code></pre> <p>If it is better to return a null value, can you explain why?</p> <p>Thanks!</p>
php
[2]
1,508,672
1,508,673
Include HTML file in C# code
<p>I have a page that has a left menu in it. This left menu is an HTML file [LeftFrame.htm] and is included in the aspx page using the following code.</p> <pre><code>&lt;!-- #include file="LeftFrame.htm"--&gt; </code></pre> <p>Now I need to change the file name to LeftFrameOthers.htm from C# code.</p> <p>Eg:</p> <pre><code>if ( arg == 1 ) { divMenu.InnerHTML = "&lt;!-- #include file="LeftFrame.htm"--&gt;"; } else { divMenu.InnerHTML = "&lt;!-- #include file="LeftFrameOthers.htm"--&gt;"; } </code></pre> <p>But it creates an error and left menu is not loaded. Is there a way to manage this from C# code.</p> <p>I don't want to use two divs for this purpose like..</p> <pre><code>&lt;div id="divOwnLeftFrame" runat="server" style="DISPLAY: block"&gt; &lt;!-- #include file="LeftFrame.htm"--&gt;&lt;/div&gt;&lt;div id="divOthersLeftFrame" runat="server" style="DISPLAY: block"&gt; &lt;!-- #include file="LeftProfileFrame.htm"--&gt; &lt;/div&gt; </code></pre> <p>and change the display property of the divs from C# code.</p> <p><strong>I am using VS 2003</strong></p>
c#
[0]
2,769,203
2,769,204
Android adapter list not working inside thread() for ProgressDialog
<p>Below is my code that is not working and i dont understand why it says <strong><em>"Only the original thread that created a view hierarchy can touch its views."</em></strong> when i want to set the adapter for my listview inside LoadValues() method.. <strong><em>"listView.setAdapter(adapter)"</em></strong> </p> <pre><code>public class ProgressDialogActivity extends Activity { private ProgressDialog progressDialog; private ListView listView; private ArrayList&lt;String&gt; lstValores; private Handler progressBarHandler = new Handler(); private int mProgressStatus, mProgressTotal; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); lstValores = new ArrayList&lt;String&gt;(); listView = (ListView) findViewById(R.id.listView1); this.LoadValues(); }//onCreate public void LoadValues(){ progressDialog = new ProgressDialog(ProgressDialogActivity.this); progressDialog.setTitle("Aguarde.."); progressDialog.setMessage("Cargando lista.."); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setProgress(0); progressDialog.show(); new Thread(new Runnable() { public void run() { mProgressTotal = (int) 1000; try { for (int i = 0; i &lt; mProgressTotal; i++) { lstValores.add("valor " + i); mProgressStatus = (int) ((i * 100) / mProgressTotal); progressBarHandler.post(new Runnable() { public void run() { progressDialog.setProgress(mProgressStatus); } }); }// end for ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(ProgressDialogActivity.this, R.layout.textviewlist_layout, lstValores); listView.setAdapter(adapter); progressDialog.dismiss(); } catch (Exception e) { e.printStackTrace(); } }// end run }).start();// end Thread }// end LoadValues } // Activity </code></pre>
android
[4]
4,257,137
4,257,138
how to hide header redirect on address bar?
<p>I do have a redirect from <code>search.php</code> to <code>get.php</code> using header command and then redirect back to <code>search.php</code> the whole process takes only around few seconds.</p> <p>what I want is I want to hide this redirect on address bar. say this redirect must happened behind the screen. so all the time</p> <p>the address line should show for example :- <a href="http://wwww.example.com/search" rel="nofollow">http://wwww.example.com/search</a></p>
php
[2]
5,557,490
5,557,491
how to display complete Bitmap in android using Canvas?
<p>friends,</p> <p>i am using following onDraw method to display bitmap on screen.</p> <pre><code> @Override public void onDraw(Canvas canvas) { Bitmap _scratch = BitmapFactory.decodeResource(getResources(), R.drawable.icon2); //ImageView img= new ImageView(Tutorial2D.this); //img.setImageBitmap(_scratch); canvas.drawColor(Color.BLACK); canvas.drawBitmap(_scratch, 0, 0, null); } </code></pre> <p>image is displayed on the screen but some part because android screen is small how can i display complete image in whole android screen?</p> <p>can i set ScaleType of image to fitxy in canvas ? </p> <p>or</p> <p>can i add android layout image to this canvas so that i could set fitxy property or image there as i have commented the code?</p> <p>any help would be appreciated.</p>
android
[4]
1,169,355
1,169,356
Name of emulator I'm using?
<p>I'm developing a project in Android. I know every emulator has some specific name like Gameboid,Frodo, Gearoid etc. How can I get to know the name of Emulator on which i am working??</p>
android
[4]
832,779
832,780
jquery event handlers on HTML redraw
<p>Suppose I have the following HTML and js</p> <pre><code>&lt;div&gt; &lt;div class="testdiv" id="test1"&gt;test&lt;/div&gt; &lt;div class="testdiv" id="test2"&gt;test&lt;/div&gt; &lt;/div&gt; function DynamicEvents() { $('.testdiv').click (function () { DoSomething(); }); } function RedrawHTML() { $('#test1').html('new HTML'); DynamicEvents(); } </code></pre> <p>Everytime I'm calling <code>RedrawHTML</code>, I'm also calling <code>DynamicEvents</code> to rebind test1. Suppose I'm calling <code>RedrawHTML</code> several times to update the div. My question is this: when I click on test2, does the function <code>DoSomething()</code> get executed once or get executed as many times as I've called <code>RedrawHTML()</code>?</p>
jquery
[5]
2,122,305
2,122,306
How to send Email through ASP.net using localhost
<p>I am creating a banking application in asp.net v 2.0.I need to send confirmation email when a user creates the new account.</p> <p>I am running the application in localhost.DO I need any special rights to send SMTP email?</p> <p>provide me a proper way to send email from my application.</p> <p>Regards Jeyaganesh</p>
asp.net
[9]
243,165
243,166
Anyone knows what `cimg::exception_mode() = 0;` does?
<pre><code> const unsigned int omode = cimg::exception_mode(); cimg::exception_mode() = 0; </code></pre> <p>Never see this kinda syntax before.</p>
c++
[6]
4,780,663
4,780,664
sending variables to a JQuery function
<p>I'm a novice in jQuery, but I hope somebody will be able to help me out. I have searched this forum (and others) but haven't been able to find an answer that I could make work.</p> <p>I have a link like this:</p> <pre><code>&lt;a href="#"&gt; </code></pre> <p>and a jQuery script:</p> <pre><code>$("div.show_dialogbox").click(function(){ $("div#dialogboxwraper").animate({ height: "400px" }, "slow") .animate({ height: "200px" }, "slow"); }); </code></pre> <p>I would like to be able to send a variable with the link and use it in the script for the height like this:</p> <pre><code>&lt;a href="#" OnClick="variable(200)"&gt; $("div.show_dialogbox").click(function(variable){ $("div#dialogboxwraper").animate({ height: variable+200+"px" }, "slow") .animate({ height: variable+"px" }, "slow"); }); </code></pre>
jquery
[5]
3,414,852
3,414,853
Compare two sound in Android
<p>Is possible to compare a voice with already recorded voice in the phone.Based on the comparison we can rate like Good, Very Good , Excellent etc. Most closed sound get high rating.</p> <p>Anybody know is it possible in Android?</p> <p>Help is highly appreciable.</p>
android
[4]
3,086,010
3,086,011
Action<T> is different event Action<T>?
<pre><code>public class TestA { public event Action&lt;int&gt; updateEvent; ... if(updateEvent != null) { Actin&lt;int&gt; tempEvent = updateEvent; updateEvent(1); } } public class TestB { public Action&lt;int&gt; updateEvent; ... if(updateEvent != null) { Actin&lt;int&gt; tempEvent = updateEvent; updateEvent(1); } } </code></pre> <p>however <code>event Action&lt;T&gt;</code> is eventQueue au</p> <p>use same and resutl same. What is more good? (i like TestB. Because simple using.)</p>
c#
[0]
1,715,717
1,715,718
android: eclipse compile error
<p>I create ninepatch image and copy it into drawable folders, the project becomes error, seems that the file cause error and not supported. I use photoshop to create PNG image then edit it using draw9patch tool.I'm using Eclipse 3.5 on win7 with latest sdk update.</p> <p>Another thing is that he accept another ninepatch image(titlelogin.9.png), but not accept (logohead.9.png)</p> <p>Here is my draw9patch image and error image.</p> <p><a href="http://i.stack.imgur.com/3e3xo.jpg" rel="nofollow">project folder image</a></p> <p><a href="http://i.stack.imgur.com/tU5KE.png" rel="nofollow">logohead.9 img</a></p>
android
[4]
3,825,920
3,825,921
substr the date function in php from the full representation of the day of the week to the first letter
<p>I'm uncertain on how to do it and it seems a bit tricky, is it possible?</p> <pre><code>date('l/m/d') </code></pre> <p>Using this date function it returns </p> <p>Tuesday 4/30</p> <p>I only want to return the first letter of the day of the week.</p> <p>T 4/30</p> <p>As usual any help would be greatly appreciated. Thanks in advance.</p> <p>I have to concat it into a sql query like so:</p> <pre><code>sum(case when DATEDIFF(dd,cast(GETDATE() as date),cast(a.follow_up as date))='1' then 1 else 0 end) 'W " . substr(date('l/m/d'), 0, 1) . strtotime('+1 day') . "', </code></pre> <p>update answer, i had to concat the second part of date again:</p> <pre><code>'" . substr(date('l/m/d', strtotime('+1 day')), 0, 1) . date('m/d') . "' </code></pre>
php
[2]
6,014,886
6,014,887
Why Activity keeps extras after orientation change
<p>Let's imagine the <code>ActivityB</code> invoked from <code>ActivityA</code> with extras in it. When <code>ActivityB</code> starts we check in <code>onCreate()</code> method the <code>bundle</code> holds these extras we put in <code>ActivityA</code>. I've noticed that <code>ActivityB</code> still holds extras after orientation change, i.e. after <code>ActivityB</code> has been just recreated, but not called by <code>ActivityA</code> which puts extras in <code>Intent</code>. Meaning extras are always "alive"? If I understand this right, where/how Activity keeps it?</p>
android
[4]
569,827
569,828
Differences between static and instance variables in python. Do they even exist?
<p>A random class definition:</p> <pre><code>class ABC: x = 6 </code></pre> <p>Setting some values, first for the abc instance, later for the static variable:</p> <pre><code>abc = ABC() abc.x = 2 ABC.x = 5 </code></pre> <p>and then print the results:</p> <pre><code>print abc.x print ABC.x </code></pre> <p>which prints</p> <pre><code>2 5 </code></pre> <p>Now, I don't really get what is going on, because if i replace in the class definition x = 6 for "pass", it will just output the same thing. My question is, what is the purpose of defining a variable in the class definition in python if it seems like i can anyone set at any time any variable without doing so? </p> <p>Also, does python know the difference between instance and static variables? From what I saw, I'd say so.</p>
python
[7]
4,782,729
4,782,730
How to encrypt SQLite DB using SQLiteCrypt
<p>I wanted to ecrypt the db file that i am storing on the sdcard. I have looked into SqliteCrypt library for serving my purpose but its using C libraries to perform the encryption/decryption.</p> <p>I would like to know if anyone has successfully included the library in their project? If yes, please guide me through the process. Any guidance or any samples will be of great help. </p> <p>Edit : Anyway, it's much more simpler to implement encryption yourself based on plain Java. It's not difficult – @barmaley</p> <p>I want to encrypt the whole db file as single unit. Not individual data fields. Please let me know if there is any alnerate mechanism to achieve this.</p>
android
[4]
3,838,940
3,838,941
Undefined variable when checking if variable is defined in Kohana view
<p>I'm running into this error when loading up my view:</p> <blockquote> <p>ErrorException [ Notice ]: Undefined variable: errors<br> APPPATH\views\admin\category\add.php [ 2 ]<br> <code>1 &lt;h3&gt;Add&lt;/h3&gt;</code><br> <code>2 &lt;?php if( $errors ): ?&gt;</code><br> <code>3 &lt;p&gt;&lt;?=$errors?&gt;&lt;/p&gt;</code><br> <code>4 &lt;?php endif; ?&gt;</code></p> </blockquote> <p>How is my checking not valid?</p>
php
[2]
460,558
460,559
ArrayList objects
<p>Need some inputs:</p> <p>Lets say i have N <code>ArrayList</code> and in each i am adding foo() object.</p> <pre><code>Foo foo = new Foo() A.add(foo); B.add(foo); N.add(foo); </code></pre> <p>Now modification done on any one <code>foo()</code> object will reflect in all the other arraylist?</p> <ol> <li><p>If YES WHY? and </p></li> <li><p>whether this behaviour can also be achieved using any other collection like Vector etc...?</p></li> <li><p>IF i make foo as null will it reflect in all arraylist?</p></li> </ol>
java
[1]
4,286,516
4,286,517
How to make Radio Button in Alert Dialog display very long text?
<p>How do I make a Radio button display a really long label inside an AlertDialog?</p> <pre><code>String[] labels = new String[]{"My Super Long Label That Will Result in an ellipses Garbage 1234567890"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setSingleChoiceItems(labels, 0 , new DialogInterface.OnClickListener() {...}); AlertDialog alert = builder.create(); alert.show(); </code></pre> <p>When I run the above code, it gets cut off rather than displaying it across multiple lines.</p>
android
[4]
5,654,888
5,654,889
Assign output of os.system to a variable and prevent it from being displayed on the screen
<p>I want to assign the output of a command I run using <code>os.system</code> to a variable and prevent it from being output to the screen. But, in the below code ,the output is sent to the screen and the value printed for <code>var</code> is 0, which I guess signifies whether the command ran successfully or not. Is there any way to assign the command output to the variable and also stop it from being displayed on the screen?</p> <pre><code>var = os.system("cat /etc/services") print var #Prints 0 </code></pre>
python
[7]
1,061,990
1,061,991
How to insert table row if and only if first cell value of a row is not equals to first cell value of next row?
<pre><code> &lt;table&gt; &lt;tr&gt; &lt;td&gt;aaa&lt;/td&gt; &lt;td&gt;111&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;aaa&lt;/td&gt; &lt;td&gt;222&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;bbb&lt;/td&gt; &lt;td&gt;111&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;bbb&lt;/td&gt; &lt;td&gt;222&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>In this example second row first cell value 'aaa' and third row first cell value 'bbb' are not same. Now How to add a new table row between second row and third row.</p>
jquery
[5]
1,159,484
1,159,485
Assigning "active" class to parent issue
<p>I have a three level deep menu and what I want is that the active class goes on the parent li, this code below works on two levels, it shows the top menu item as active and the one below it, but when go to a page on the third level (ul ul ul li) all those list items in that last ul menu are active. Any ideas. I'm REALLY new to jQuery, so be kind ;-)</p> <pre><code>$(document).ready(function(){ var path = location.pathname.substring(1); if ( path ) { $('#main_menu li a[href$="' + path + '"]').parents('li').addClass('active'); } }); </code></pre>
jquery
[5]
5,650,165
5,650,166
handling Application_Error in ASP.NET app's global.asax
<p>I wish to send mail to an administrator when the application crashes. So I simply do this in <code>global.asax</code>:</p> <pre><code>void Application_error(object sender, EventArgs e) { SendMessageToAdministarator(Server.GetLastError().ToString()); } </code></pre> <p>But actually many times <code>Application_Error</code> is called even though the application won't crash.</p> <p>And I wish to send mail to admin ONLY when the application crashed.</p> <p>Also, do I have a simple way to lift the application back on?</p> <p>I'm looking for the simplest solution.</p>
asp.net
[9]
4,675,214
4,675,215
multicast receiver only to my application in android
<p>Is it possible in android to multicast a message (not broadcast) to all my activities of current application i.e. current PID (without using observer observable pattern), so that, current running activity will receive the message and perform task based on that.</p> <p>Thanks,</p> <p>Biplab</p>
android
[4]
251,517
251,518
No overload for method 'OnTimerEvent' takes '1' arguments
<p>I want to show a text in a label for a particular time in my form and this is the code i tried so far :</p> <pre><code>private void ShowTextForParticularTime(String caption) { Timer t = new Timer { Interval = 2000, Enabled = true }; t.Tick += new EventHandler(OnTimerEvent(caption)); } private void OnTimerEvent(object sender, EventArgs e,String caption) { barStaticItem3.Caption = caption; } </code></pre> <p>My question is how can I set the "caption" parameter into OnTimerEvent method because that code I wrote doesn't work it gives me this error : </p> <blockquote> <p>No overload for method 'OnTimerEvent' takes '1' arguments</p> </blockquote>
c#
[0]
3,042,438
3,042,439
Difference between this and var in a function
<p>I have a javascript class that I'm creating. This class has private and public functions/properties. My understanding of private and public was that <code>this</code> was public and <code>var</code> was private to that function and its members. However, within the local function <code>buildFramework()</code>, when I call the <code>var settings.currentView</code> I get the error:</p> <blockquote> <p><code>settings.currentView</code> is not defined</p> </blockquote> <p>My question is, what is the difference between <code>this</code> and <code>var</code> in the scope of a function and its members as well as the global scope?</p> <pre><code>namespace('example'); example.InstagramViewer = function (options) { // this works when called within buildFramework() this.settings = $.extend({ currentView: 'grid' }, options); // this doesn't work when called within buildFramework() var settings = $.extend({ currentView: 'grid' }, options); var viewer; this.init = function () { buildFramework(); }; var buildFramework = function() { viewer = $(viewerWrapper).append('&lt;div id="instagramViewer" class="' + settings.currentView + '"&gt;&lt;/div&gt;'); // this doesn't work viewer = $(viewerWrapper).append('&lt;div id="instagramViewer" class="' + this.settings.currentView + '"&gt;&lt;/div&gt;'); // this does work }; } </code></pre> <p>and called like so...</p> <pre><code>$(function () { var viewer = new connectionsAcademy.publicWebsite.web.js.teenWebsite.InstagramViewer(); viewer.init(); }); </code></pre>
javascript
[3]
2,725,925
2,725,926
How to get call duration in android
<p>"I want to know the call duration, when I called to other number and when that call-ends. In android is it possible?"</p> <p>Thanks in advance.</p>
android
[4]
2,014,879
2,014,880
How to know whether a property exists or not in a property file?
<p>How to know whether a property exists or not in a property file in java?</p>
java
[1]
2,485,042
2,485,043
iPhone apps for company-internal use - possible?
<p>I hope this is still programming related, as SuperUser doesn't seem the appropriate place.</p> <p>Basically I wonder if it is possible to have Applications that are internal to a company on the iPhone? That is something like a companion Application to an Intranet (when Safari and Mail just don't cut it) which wouldn't make sense on the AppStore (and likely wouldn't get approved anyway).</p> <p>Is something like that possible (without Jailbreaking or doing anything else that Apple doesn't normally want)?</p>
iphone
[8]
1,250,944
1,250,945
Xcode Deployment Target: Should I trust "Compiler Default"?
<p>I have set my target deployment target to be: "Compiler Default". Should I trust that Xcode will do the right thing? The right thing being:</p> <blockquote> <p>Compiler Default - Code will load on any iPhone OS system that supports the APIs that are used.</p> </blockquote> <p>I'd like my app to run on any iPhone whose OS supports the APIs I use. If an API is unavailable, then I don't want my app to run on that iPhone (or iPod).</p> <p>The reason I ask is that I don't observe it doing the right thing, as far as I can tell, and I have no older OS devices to test this.</p>
iphone
[8]
4,760,119
4,760,120
Input Output API
<p>I need help with a program where I must take string inputs from user continuously until the user enters string "end". Then I must print all the inputs that the user entered till "end". I tried using a for loop but I can't get it.</p>
java
[1]
2,946,662
2,946,663
Android Sound Verification
<p>I would like to create an application, which will response on "Clap" sound.</p> <p>Means, if I have kept my mobile somewhere in my room, and if a clap it will start ringing.</p> <p>I would like to know how can I compare two sound [incoming sound of clap] and already stored clap sound?</p> <p>I think I need to create a service which will keep on listening through mobile Microphone, and check for incoming sound.</p> <p>[If you think any other approach for this application is good/better then please suggest that also.] Please guys any pointer or any help will be very much appreciated.</p> <hr> <p>Thanks for your quick response.</p> <p>As i have create a service which will continuously record sound from Mic, which class should i use to record the sound MediaRecorder / AudioRecord . </p> <p>Other requirement is like user can record their own custom music also, to find their phone. So for eg: if user records some random sound, which will be stored in application.</p> <p>Now once again user plays the same sound, to find their phone, then how will i compare currently played sound with previously stored sound ?</p> <p>Regards.</p>
android
[4]
1,423,737
1,423,738
I am calling a function in jQuery, using 'enter' event as well 'blur' event is it possible to shorten it?
<p>I would like to trigger a function when my user blurs or enters a text box. I wrote this code to implement that:</p> <pre><code>text:function(input,el){ var textCheck = function(){ var value = $.trim(el.val()); if(!value){ el.addClass('error'); }else{ el.removeClass('error'); } } $(el).on('blur click keyup', textCheck); //calling the function $(el).on('keyup', function(e){ ////calling the function again if(e.keyCode == 13){ textCheck(); } }); //instead of calling 2 times, how can i put together as single call? } </code></pre> <p>Can I shorten the code that binds the events?</p>
jquery
[5]
3,535,478
3,535,479
Capture output from unrelated process
<p>I was just wondering if it is possible to capture the output of a separate process running on windows?</p> <p>For instance if i have a console app running, could i run a second app, a forms app, and have that app capture the output from the console app and display it in a text box?</p>
c#
[0]
5,637,553
5,637,554
Give a parent li a background image?
<p>what im trying to do is give the parent li of a ul a background image.</p> <p>so i have a submenu within a menu.</p> <p>this is the jquery i am attempting..</p> <pre><code>$('li.on').closest('ul').parent('li').css({ backgroundImage: 'url(/content/images/point.png)', backgroundRepeat: 'no-repeat' }); ; </code></pre> <p>i think im going wrong at the parent bit?</p> <p>this is the menu...</p> <pre><code>&lt;div class="sideMenu2"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href&gt;retail&lt;/a&gt; &lt;ul class="subsideMenu2"&gt; &lt;li &gt;&lt;a href="/portfolio/5/0"&gt;cabot circus&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/portfolio/6/0"&gt;st. stephen&amp;#39;s&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/portfolio/7/0"&gt;silverburn&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="/portfolio/8/0"&gt;the elements&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;a href&gt;sports &amp;amp; leisure&lt;/a&gt; &lt;ul class="subsideMenu2"&gt; &lt;li class= "on"&gt;&lt;a href="/portfolio/19/0"&gt;test&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p></p> <p>so if i click on test, sports and leisure should get the background, but currently retail is. </p>
jquery
[5]
5,054,033
5,054,034
Can I have a part of a scrollable Listview (implemented using hashmap) non-scrollable?
<p>Im trying to make a list to enter the marks of students. I have an xml layout file which has the name of student as a textview and marks of 5 subjects as edittexts. Then I have another xml layout file which has a listview which is horizontally scrollable. Now in the java file Im using Hashmap to duplicate this layout for multiple students. I have the entire list horizontally scrollable. If I scroll left or right, I want all the rows to be scrolled together with the names being static horizontally. But I want only the marks to be scrollable. I want the name of student to be static. I tried to make the textview used 4 name as horizontallyscrollable="false". Doesn't help. Need help.</p>
android
[4]
3,151,024
3,151,025
button is not responding to click event,
<p>I am working on the table view and do customization for <code>tableFooterView</code>.What I am doing is :</p> <p>ClassA.m</p> <pre><code>- (void)viewDidLoad { FooterViewController *footerView = [[FooterViewController alloc] initWithNibName:@"FooterViewController" bundle:nil]; // Add selector of Class A to checkOutButton [footerView.checkOutButton addTarget:self action:@selector(goToCheckOut) forControlEvents:UIControlStateNormal]; self.shoppingListTable.tableFooterView.backgroundColor = [UIColor clearColor]; self.shoppingListTable.tableFooterView = footerView.view; } - (void)goToCheckOut { NSLog(@"this is a response from a button"); } </code></pre> <p>FootViewController.h</p> <pre><code>@interface FooterViewController : UIViewController @property (strong, nonatomic) IBOutlet UILabel *amount; @property (strong, nonatomic) IBOutlet UIButton *checkOutButton; @end </code></pre> <p>The outlet are also connected to the xib files as well</p> <p>However, when I click on the button, it does not respond at all and the log shows nothing....</p> <p>What I am doing wrong at here. Please help if you have any ideas about this. Thanks</p>
iphone
[8]
5,629,341
5,629,342
usage of (object) in assigning values for hashmap
<p>I saw a piece of java code using Hashmap as follows:</p> <pre><code>Map indata = new HashMap(12); //load data indata.put(“checking”, ((object) new Double(1.0))); indata.put(“PURPOSE”, ((object)"2”)); </code></pre> <p>What confuse me is the two useages of "put" method, in which we have <code>((object) new Double(1.0)) </code> and <code>(object)"2"</code>. What do <code>(object)</code> function here? Any differences between <code>((object) new Double(1.0)) </code> and <code>(object)"2"</code>?</p>
java
[1]
89,791
89,792
jquery fadeIn not working
<p>Can someone please tell me what I'm doing wrong:</p> <p>style:</p> <pre><code>.warning{border: 1px solid #F0AAAA; background:#FFBABA; color: #C90000;} </code></pre> <p>markup:</p> <pre><code> &lt;p class="warning"&gt;A successful authorization already exists. Further authorizations are not allowed at this time.&lt;/p&gt; </code></pre> <p>script:</p> <pre><code> $().ready(function () { alert($(".warning").html()); // WORKS $(".warning").fadeIn(4000); // DOESN'T WORK }); </code></pre>
jquery
[5]
3,666,299
3,666,300
Alternative of GetGlobalAsaxType in .NET 3.5?
<p>I am checking out a sample application source code and there is:</p> <pre><code>var assembly = BuildManager.GetGlobalAsaxType().BaseType.Assembly.GetName().Name; </code></pre> <p>But in .NET 3.5, there is no BuildManager.GetGlobalAsaxType(). Is there any alternative way to do so in .NET 3.5? </p>
asp.net
[9]
5,103,391
5,103,392
How to bring user further down the page using jQuery?
<p>When the user performs a certain action I want to bring them further down the page. Kind of like how an a-name link works. Except obviously it needs to happen without any additional parameters being added to the url or refreshing the page.</p> <p>So what would be the jQuery way of doing this:</p> <pre><code>&lt;a href="#person"&gt;Click Me&lt;/a&gt; &lt;a name='person'&gt;Tommy&lt;/a&gt; </code></pre> <p>EDIT</p> <p>a nice slide down effect to bring the user down the page would be nice too.</p>
jquery
[5]
1,653,906
1,653,907
Shifting or moving tab positions on Tab control in C#
<p>I am using tabcontrol in c# widows form app. My requirement is as shown in the image.</p> <p><img src="http://i.stack.imgur.com/iYYu0.png" alt="enter image description here"></p>
c#
[0]
3,605,534
3,605,535
Can an external Javascript file be called and executed depending on a conditional?
<p>I know that I can run an external Javascript file from within HTML with the following syntax:</p> <pre><code>&lt;script type="text/javascript" src="http://somesite.com/location/of/javascript.js"&gt; &lt;/script&gt; </code></pre> <p>This will result in <code>http://somesite.com/location/of/javascript.js</code> being run the moment the browser reads that line of the HTML.</p> <p>But is there a way I can run an external Javascript file from within Javascript? Something like:</p> <pre><code>if (x == 1) { run this! -&gt; http://somesite.com/location/of/javascript.js; } </code></pre> <p>Obviously that's not valid code. But I can't find any example of what might be the right way to do this (if it exists), because all the help text I find with Google searches tell me how to run Javascript from within HTML</p> <p>I know that I can include a Javascript file and then call functions within it. However, in this situation, I do not have any control over <code>http://somesite.com/location/of/javascript.js</code>, and it is designed to execute the moment it is called. I can't change how it works, so I need to figure out how to call it at the right time in the right way.</p> <p>Is there a way I can get it to be called and executed immediately depending on a conditional statement?</p>
javascript
[3]
3,952,672
3,952,673
How to get the date from a timeStamp long value?
<p>I tried to compare date and time of two timeStamp long values as follows. </p> <pre><code>Timestamp st1 = new Timestamp(1313045029); Timestamp st = new Timestamp(1313045568); System.out.println("Date:"+st.getDate()); System.out.println("Day:"+st.getDay()); System.out.println("Year:"+(st.getYear()+1900)); System.out.println("Month:"+(st.getMonth()+1)); System.out.println("Hours:"+st.getHours()); System.out.println("Minutes:"+st.getMinutes()); System.out.println("Seconds:"+st.getSeconds()); System.out.println("*********************************"); System.out.println("Date1:"+st1.getDate()); System.out.println("Day1:"+st1.getDay()); System.out.println("Year1:"+(st1.getYear()+1900)); System.out.println("Month1:"+(st1.getMonth()+1)); System.out.println("Hours1:"+st1.getHours()); System.out.println("Minutes1:"+st1.getMinutes()); System.out.println("Seconds1:"+st1.getSeconds()); </code></pre> <p>There should be some difference in time, but in the output there is difference at all? Please help. </p>
java
[1]
4,652,509
4,652,510
Enable Media Volume Slider in Android application
<p>Some Android programs trigger the "media volume" slider when the hardware volume up/down buttons are pressed. My application seems to set the ringer volume when the hardware buttons are pressed.</p> <p>How would I enable the media volume slider? </p> <p>I would hate for users to have to go into their settings to change the media volume when they use my application.</p>
android
[4]
5,518,022
5,518,023
Insert values in an associative array but only if have value
<p>I've this bucle:</p> <pre><code>foreach($jsonU as $j) { $jsonUId = $j-&gt;id; $jsonUName = $j-&gt;name; $jsonUDescription = $j-&gt;description; $jsonUDate = $j-&gt;date; $jsonUStatus = $j-&gt;status; $jsonUPicture = $j-&gt;picture; $jsonUncompleted[] = array('id'=&gt; $jsonUId, 'name'=&gt; $jsonUName, 'description' =&gt; $jsonUDescription, 'date' =&gt; $jsonUDate, 'status' =&gt; $jsonUStatus, 'picture' =&gt;$jsonUPicture); } </code></pre> <p>I need to insert a key in the array only if have value. For example, <code>$jsonUPictore</code> not always has a value and in that case I don't need to write that key.</p> <p>Some help?</p>
php
[2]
1,730,457
1,730,458
redirect to a new page once file upload is finished
<p>I have got the following php file for my file upload, how do I redirect to a new page once the file is finished upload, thanks in advance.</p> <pre><code>&lt;?php echo &lt;&lt;&lt;_END &lt;html&gt; &lt;title&gt;PHP Form Upload&lt;/title&gt;&lt;/head&gt;&lt;body&gt; &lt;form method = 'post' action='testupload.php' enctype='multipart/form-data'&gt; Select File: &lt;input type='file' name='filename' size='10' /&gt; &lt;input type='submit' value='Upload' /&gt; &lt;/form&gt; _END; if($_FILES) { $a = uniqid(); $saveto = $a.".jpg";; // $name = $_FILES['filename']['name']; move_uploaded_file($_FILES['filename']['tmp_name'], $saveto); $typeok = TRUE; switch($_FILES['filename']['type']) { case "image/gif": $src = imagecreatefromgif($saveto); break; case "image/jpeg": case "image/pjpeg": $src = imagecreatefromjpeg($saveto); break; case "image/png": $src = imagecreatefrompng($saveto); break; default: $typeok = FALSE; break; } echo "Upload image '$saveto'&lt;br/&gt;&lt;img src='$saveto' /&gt;"; } if ($_FILES["filename"]["size"] &gt; 2000) { echo "Error: file is too big" . $_FILES["file"]["error"] . "&lt;br /&gt;"; } echo"&lt;/body&gt;&lt;/html&gt;"; ?&gt; </code></pre>
php
[2]
282,981
282,982
Error exception must derive from BaseException even when it does (Python 2.7)
<p>What's wrong with the following code (under Python 2.7.1):</p> <pre><code>class TestFailed(BaseException): def __new__(self, m): self.message = m def __str__(self): return self.message try: raise TestFailed('Oops') except TestFailed as x: print x </code></pre> <p>When I run it, I get:</p> <pre><code>Traceback (most recent call last): File "x.py", line 9, in &lt;module&gt; raise TestFailed('Oops') TypeError: exceptions must be old-style classes or derived from BaseException, not NoneType </code></pre> <p>But it looks to me that <code>TestFailed</code> does derive from <code>BaseException</code>.</p>
python
[7]
100,941
100,942
Remove image and use CSS instead for data from database using PHP
<p>I have the PHP code as below:</p> <pre><code> &lt;?php for ($i = 1; $i &lt;= 5; $i++) { $checked = ($value['2.Capacity'] == $i) ? ' &lt;img src="img/tick.jpg" width="20px" /&gt;' : ''; echo '&lt;td&gt;'.$checked.$i.'&lt;/td&gt;'; } </code></pre> <p><strong>I need:</strong></p> <p>I want to remove the <code>&lt;img src="img/tick.jpg" width="20px" /&gt;</code> to put CSS style <code>Bold + underlined</code> I do not know how to fix this.</p> <p><strong>Note:</strong></p> <p>For the <code>$value['2.Capacity']</code> it's data from database, it integer value <code>1 2 3 4 5</code>.</p> <p>Anyone help me please,Thanks.</p>
php
[2]
4,857,892
4,857,893
How to cast a generic parameter?
<p>Here's what I am trying to write:</p> <pre><code>public void Foo&lt;T&gt;(T parameter) { otherObject.Bar&lt;T&gt;(parameter); } </code></pre> <p>The signature of the Bar() method is:</p> <pre><code>public void Bar&lt;T&gt;(T parameter) where T: class </code></pre> <p>So I get a compile error because the T in Foo's signature doesn't have the same constraint. Unfortunately I can't write:</p> <pre><code>public void Foo&lt;T&gt;(T parameter) where T: class { otherObject.Bar&lt;T&gt;(parameter); } </code></pre> <p>because Foo is implementing a method defined in an external interface. Question is:</p> <p>Can I somehow transpose the T within the method Foo before calling Bar. (Note, I can be sure that T always will be a class - I just need to get past the compiler).</p> <p>The only way I have found is using reflection but I wonder if there is a simpler trick I'm missing.</p>
c#
[0]
5,083,862
5,083,863
Back button and last activity
<p>My app chains some activities. </p> <p>if you press the back button, you go back through old activities then you suddenly quit the application !</p> <p>so I need to show a message like "do you really want to exit" if it's the last activity on stack</p> <p>I know how to override the back button but i can't figure how to know how many activity are in history</p> <pre><code>@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK &amp;&amp; event.getRepeatCount() == 0) { // Is it the last activity on stack ? // so show confirm dialog return true; } return super.onKeyDown(keyCode, event); } </code></pre> <p>Please help.</p>
android
[4]
1,284,857
1,284,858
Values changing when app turns from portrait mode to landscape mode in android
<p>I am working on android apps. My app should work both in portrait and landscape mode. I adjusted all the layouts by keeping all layout files in layout-lan folder. But now my issue is with functionality i.e when the app is changed to landscape mode the values of my parameters are changing and due to this I am getting crashes. i.e i kept a counter value but it is displaying wrong count value when turned to port-lan. Also the functionality is changing due to this. Please help me in this regard.</p>
android
[4]
1,269,664
1,269,665
reading from file and storing as integer
<p>i am trying to read from a file and store the data in three integers, red, green and blue the data in the file is set as:</p> <pre><code>255,0,0 0,255,0 0,0,255 0,255, 255 </code></pre> <p>i have tried may methods of doing this but i am having no success could anyone help here is a copy of the method so far:</p> <pre><code>private void readColoursFromFile() { int red = 128; int green = 128; int blue = 128; StringBuilder contents = new StringBuilder(); String filename = "colours.txt"; try { BufferedReader reader; reader = new BufferedReader(new FileReader(filename)); String str; while (( str = reader.readLine()) != null) { StringTokenizer tokenizer = new StringTokenizer(str, ","); String rcolour = tokenizer.nextToken(); String gcolour = tokenizer.nextToken(); String bcolour = tokenizer.nextToken(); Integer irColour = red; Integer igColour = green; Integer ibColour = blue; rcolour = Integer.toString(irColour); gcolour = Integer.toString(ibColour); bcolour = Integer.toString(igColour); contents.append(str); printColourRow(red, green, blue); } { reader.close(); } } catch (IOException e) { System.out.println("error"); e.printStackTrace(); } } </code></pre>
java
[1]
3,905,300
3,905,301
Nested if-statement in loop vs two separate loops
<p>Here is the source code:</p> <pre><code>public int indexOf(Object o) { if (o == null) { for (int i = 0; i &lt; size; i++) if (elementData[i]==null) return i; } else { for (int i = 0; i &lt; size; i++) if (o.equals(elementData[i])) return i; } } return -1; } </code></pre> <p>Why doesn't one this: have only one loop and the if-statement. </p> <pre><code>public int indexOf(Object o) { for (int i = 0; i &lt; size; i++){ if (o == null) { if (elementData[i]==null) return i; else { if (o.equals(elementData[i])) return i; } } return -1; } </code></pre> <p>The first snippet has to have two loops, but some say the above code performance is good. Why?</p>
java
[1]
2,557,669
2,557,670
Android write to file - can't find file
<p>I am a newbie in Android development. I try to write something to a file. I am using the code:</p> <pre><code>try { FileOutputStream fOut = openFileOutput( "out.txt", MODE_WORLD_READABLE); OutputStreamWriter osw = new OutputStreamWriter(fOut); osw.write("something"); osw.flush(); osw.close(); fOut.close(); } catch (MalformedURLException e) { Log.e("FILE WRITE ERROR", e.getMessage()); } catch (IOException e) { Log.e("FILE WRITE ERROR", e.getMessage()); } </code></pre> <p>Everything it's ok but I can't find the file in DDMS FIle Explorer. Could you help me and tell me where Android saves the file? It isn't in "/data/data/my_project_package". Thank you.</p>
android
[4]
4,570,377
4,570,378
Streaming Using Video View works fine but after playing some video Gives Dialog Can Not Play this video
<p>I am using Video View To stream Video.</p> <p>I am able to start video successfully But what happens is after playing some video I am getting Dialog Box saying Can not play this video.</p> <p>When I tried multiple times then I realized that It shows me dialog at random length of video played.</p> <p>I don't able to find why this is happening.</p>
android
[4]
2,668,607
2,668,608
Calling C++ function pointers from C libraries
<p>I have a class that only has static members.</p> <p>I would like to register one of its member functions (VerifyClean in the code below) to be called at exit, using the "atexit" library function.</p> <p>The <a href="http://yosefk.com/c++fqa/function.html#fqa-33.2" rel="nofollow">C++ FQA</a> says that i must specify extern "C" for the function i want to register this way, like in the following example.</p> <pre><code>class Example { public: static void Initialize(); static void DoDirtyStuff {++dirtLevel;} static void CleanUpStuff {--dirtLevel;} private: static void VerifyClean(); // DOESN'T COMPILE: extern "C" static void VerifyClean(); static int dirtLevel; } int Example::dirtLevel; extern "C" void Example::VerifyClean() // DO I NEED extern "C" HERE? { assert(dirtLevel == 0); } void Example::Initialize() { dirtLevel = 0; atexit(&amp;VerifyClean); } </code></pre> <p>Do i really have to use extern "C"?</p> <p>Does the answer change if i replace "atexit" with a non-library function (implemented in plain C)?</p> <p>If the function VerifyClean were public and i decided to call it directly from C++ code, would i get link errors or runtime crashes? I ask this because the declaration doesn't mention extern "C" at all, so regular C++ code might handle the function call incorrectly. This works OK on my MS Visual Studio 2005 system.</p>
c++
[6]
1,613,192
1,613,193
How to execute "del data.txt" using Process?
<p>The following trivial code is just an example that does not reflect my real scenario. I have tried it and it did not work. </p> <p>I want to delete <code>data.txt</code> using <code>Process</code> rather than using <code>File</code> class.</p> <pre><code>using System; using System.Diagnostics; namespace Tester { class Program { static void Main(string[] args) { Process p = new Process(); p.StartInfo.FileName = "cmd"; p.StartInfo.Arguments = "del data.txt"; p.StartInfo.UseShellExecute=false; p.EnableRaisingEvents = true; p.Exited += (sender, e) =&gt; { Console.WriteLine("Finished"); }; p.Start(); p.WaitForExit(); } } } </code></pre> <p>How to execute <code>del data.txt</code> using <code>Process</code>?</p>
c#
[0]
4,144,499
4,144,500
Selecting hidden field value in same div in jQuery
<p>This should be simple, not sure why I'm having issues. </p> <p>I've tried <code>$this.closest('.image_id').val()</code> but I keep getting <code>undefined</code>.</p> <p>Here's the jQuery I'm using:</p> <pre><code>$('#image_container').on('change', '[name="image-type"]', function() { $this = $(this); console.log($this.closest('.image_id').val()); }); </code></pre> <p>The HTML:</p> <pre><code>&lt;div id="image_library"&gt; &lt;div class="row-fluid library-row"&gt; &lt;div class="span3 library-file-name"&gt; file name &lt;/div&gt; &lt;div class="span1 library-image-size"&gt; file size &lt;/div&gt; &lt;div class="span4 library-actions"&gt; &lt;input type="hidden" class="image_id" name="image_id" value="1303"&gt; &lt;select name="image-type"&gt; &lt;option value="none"&gt;Not Set&lt;/option&gt; &lt;option value="thumbnail"&gt;Thumbnail&lt;/option&gt; &lt;option value="feature"&gt;Feature&lt;/option&gt; &lt;option value="gallery"&gt;Gallery&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
2,106,943
2,106,944
Uploading Files with Size and delete option in Javascript
<p>How can i upload files directly by selecting the files as an attachment and display it an email with a delete option and size like our outlook. Please share the Javascript Code.</p>
javascript
[3]
3,446,827
3,446,828
.blur() on every select element after selection
<p>I was wondering if there's a way, using jquery, to unfocus EVERY select element after a selection triggered ?</p> <p>Thanks.</p> <p><em>Note: I know how to do it for one element at a time, this question is for global behavior of select elements</em></p>
jquery
[5]
387,070
387,071
C# interview question
<p>In one of the interview, i got asked the following question but i am not sure what is that, Please help me to understand about the question</p> <p>Use C# to turn an 4th and 7th bits of a said byte myFlag in which write most bit is first bit.</p>
c#
[0]
3,083,183
3,083,184
detect power state change
<p>What is the best way to detect when Windows power state is changing?</p> <p>I need to preform some actions depending on wether the computer is going to Stanby/Hibernate/Shut Down</p> <p>Thanks Sp</p>
c#
[0]
5,264,367
5,264,368
Disable a particular application (like Youtube) using an Android Program code .
<p>I want to only disable an application (not delete it) using android code.</p> <p>Please provide me some sample code to block or disable application using android code.</p> <p>It will be very needful for me.</p> <p>Thanks in Advance.</p>
android
[4]
5,856,263
5,856,264
Convert .db to binary
<p>I'm trying to convert a .db file to binary so I can stream it across a web server. I'm pretty new to C#. I've gotten as far as looking at code snippets online but I'm not really sure if the code below puts me on the right track. How I can write the data once I read it? Does <code>BinaryReader</code> automatically open up and read the entire file so I can then just write it out in binary format?</p> <pre><code>class Program { static void Main(string[] args) { using (FileStream fs = new FileStream("output.bin", FileMode.Create)) { using (BinaryWriter bw = new BinaryWriter(fs)) { long totalBytes = new System.IO.FileInfo("input.db").Length; byte[] buffer = null; BinaryReader binReader = new BinaryReader(File.Open("input.db", FileMode.Open)); } } } } </code></pre> <p>Edit: Code to stream the database:</p> <pre><code>[WebGet(UriTemplate = "GetDatabase/{databaseName}")] public Stream GetDatabase(string databaseName) { string fileName = "\\\\computer\\" + databaseName + ".db"; if (File.Exists(fileName)) { FileStream stream = File.OpenRead(fileName); if (WebOperationContext.Current != null) { WebOperationContext.Current.OutgoingResponse.ContentType = "binary/.bin"; } return stream; } return null; } </code></pre> <p>When I call my server, I get nothing back. When I use this same type of method for a content-type of image/.png, it works fine.</p>
c#
[0]
1,202,109
1,202,110
what is a reason for which RTTI is considered as a bad design?
<p>what is a reason for which RTTI is considered as a bad design?<br/> Stroustrup has written in his book TC++PL that the most common case of usage RTTI technique is with switch instruction, when one want to decide what code should be executed basing on what is a "real" type of a passed object. There is given an example in which an object of shape class was passed to the function and different actions were executed depending on that whether a shape is circle, square, triangle, etc. He has written that such construction is a sign that one should replace the switch-case sequence by virtual functions.</p>
c++
[6]
448,782
448,783
How to use Switch case In the Java
<p>I am using Neatbeans 7.0 for Java programming. I have written a Switch case for selection of the program.</p> <pre><code>switch(menu) { case 1: { //stmt } default: { //stmt return; } } </code></pre> <p>I am getting compile time error at <code>switch(menu)</code></p> <pre><code>The Error is "strings in switch are not supported in -source 1.6 (use -source 7 or higher to enable strings in switch) </code></pre> <p>(Alt-Enter shows hints)" Can any one please help me on this.</p>
java
[1]
5,520,561
5,520,562
change string into var datatype in c#
<p>I am reading data from file like this</p> <pre><code>using (StreamReader r = new StreamReader("newfile.txt")) { string lines1; lines1 = r.ReadLine(); var lines = lines1; foreach (string line in lines) { var dictionary = new Dictionary&lt;String, Int32&gt;(); var records = line.Split(','); </code></pre> <p>How can i convert string data type to var data type? </p> <p>if i used this line</p> <pre><code> var lines = lines1; </code></pre> <p>then the error accur at</p> <pre><code> var records = line.Split(','); </code></pre>
c#
[0]
5,389,970
5,389,971
Get the width of an image specified by an url jquery
<p>I want to read out the width (orgWidth) of an image specified by an url within a for-loop, calculate its new width (calcWidth) for a height of 480px.</p> <pre><code>for (var i=1; i &lt;= item.length; i++) { url = document.images[i].rsc; orgWidth = some-fancy-thing-that-reads-the-width; orgHeight = some-fancy-thing-that-reads-the-height; factor = orgHeight / 480 // 1400 / 480 = 2.916 calcWidth = orgWidth / factor // 1000 / 2.916 = 342.935 document.images[i].width = calcWidth; } </code></pre> <p>Page I need it for: <a href="http://foto.hendrik-schicke.de/index.php/people" rel="nofollow">http://foto.hendrik-schicke.de/index.php/people</a></p>
jquery
[5]
303,417
303,418
filtering in c# using sql server as database
<p>filtering in c# using sql server as database</p> <p>for example choosing first what to filter in the combobox by choosing student number and in the textfield entering 1001 ...den only 1001 will appear in the datagrid...</p> <p>we are using ssql server</p>
c#
[0]
4,925,937
4,925,938
How can you restrict certain apps from launching on Android?
<p>I'm trying to build a sandboxed environment in which only certain apps are allowed to be launched.</p> <p>I had originally decided to try polling all running apps in the background to see which ones were running, then killing any that weren't on the whtielist. However, I discovered that you can only kill background processes, not active tasks.</p> <p>If this can be done, how? </p>
android
[4]
2,822,355
2,822,356
C preproccessor problem
<p>I have a program to find the reciprocal of a number but the main program is written in C and the <code>reciprocal</code> function is written in c++.Next I have a header file <code>reciprocal.hpp</code> that has some of the conditional compilation code that makes the <code>reciprocal</code> function an extern function.Can someone please explain me what is there in the <code>reciprocal.hpp</code> program.</p> <p><strong>main.c</strong></p> <pre><code>#include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; int main(int argc,char **argv) { int i; i = atoi(argv[1]); printf("\nThe reciprocal of %d is %f\n",i,reciprocal(i)); return 0; } </code></pre> <p><strong>reciprocal.cpp</strong></p> <pre><code>#include&lt;cassert&gt; #include "reciprocal.hpp" double reciprocal(int i) { assert( i != 0); return 1.0/i; } </code></pre> <p><strong>reciprocal.hpp</strong></p> <pre><code>#ifdef __cplusplus extern "C" { #endif extern double reciprocal(int i); #ifdef __cplusplus } #endif </code></pre> <p>I don't understand what is happening in <code>reciprocal.hpp</code>.Please help!!</p>
c++
[6]
5,533,979
5,533,980
line breaks on comments textareas
<p>A user post a comment on a forum using a textarea, he presses enter to format his text wich means line breaks, how can i convert those line breaks to html breaks when inserting its message on the database so the message is echoed with the line breaks formatting?</p> <p>cheers</p>
php
[2]
4,740,683
4,740,684
Fade DIV with cool animation
<p>I am fading a DIV slowly, </p> <pre><code>$(ele).fadeIn('slow'); </code></pre> <p>How can i create a very good animation along with the fadeIn to show real animation power of jquery</p>
jquery
[5]
4,398,775
4,398,776
Speech Recognition/Identification
<p>What am I up against if I want to do comparisons in voices? I have an audio source that I want to track who's talking based on their voice (voice pattern?) - are there any C# libraries to get me close?</p>
c#
[0]
638,675
638,676
Reading text file and removing specific characters
<p>After someone inputs a text file, I have to make it so it will read the text file that the user inputted.</p> <p>Using a switch statement, how do I make sure the first word and last word doesn't have a specific character?</p> <p>The first word should not have a single-quotation mark, double-quotation mark, a dollar sign, or a period.</p> <p>The last word should not have a single-quotation mark, double-quotation mark, semi-colon, colon, period, comma, hyphen, exclamation point, or question mark remove it.</p> <p>I am using hasNext in my while so that it prints each word on one line.</p>
java
[1]
1,997,177
1,997,178
How to create an array in javascript using attributes set in the request object?
<p>I need to creata an array in javascript, elements for the array should come from server side.</p> <p>For this what i did was, In servlet,</p> <pre><code>String[] valuesArray = {"val1","val2","val3"}; request.setAttribute("valuesArray",valuesArray); </code></pre> <p>In Jsp/javaScript: <code>var arrayObj = new Array(${'valuesArray'});</code></p> <p>but,this is not working.. Ultimately, arrayObj should contain {"val1","val2","val3"} as elements. Can someone please suggest where i have gone wrong or let me know how to handle this requirement? </p> <p>Thanks in advance.</p>
javascript
[3]
5,370,427
5,370,428
php image type, mozila and IE7
<p>i insert image in page and strangely I get a picture of the types.</p> <p>show type with: $_FILES['img']['type'].</p> <p>Result:</p> <pre><code>Firefox: image/jpeg IE7: 'image/pjpeg' Firefox: image/png IE7: image/x-png </code></pre> <p>Now i use this filter:</p> <pre><code>$type_filter = array('image/gif', 'image/jpeg', 'image/png', 'image/jpg', 'image/bmp', 'image/x-png', 'image/pjpeg'); </code></pre> <p>It is good, or something else is missing? Thanks</p>
php
[2]
2,372,833
2,372,834
showing images moving using java script
<p>i want to Create new page named “MySlidShow.htm”, and put link to in PhotoGallary page. The slide show page has four links (previous, Start SlideShow, End Slide Show, Next). When user put the mouse over an image show this image description and date taken below it and pause the slide show if it is running, and when the moves the mouse away hide the description and date and resume the slide show. (Use array to store images name, and another to store images description and date taken (you may use associative array). can any one show me how or write me the code</p>
javascript
[3]
5,201,399
5,201,400
how to give action to progress bar
<p>hi i am new to iphone. what i am doing is cretating a imageview and a progressview i create iboutlet for both imageview and progressview and take a timer after 4 min i will call imagepicker.All is well but the progressview is no action only display as idle i am writing code for that is <code>progressview.progress=0.0; [self.view addsubview.progrssview];</code> really i dont know how it solve pls help me .</p>
iphone
[8]
5,547,141
5,547,142
Recycled bitmap exception
<p>I'm getting this exception:</p> <p>Exception: java.lang.IllegalStateException: Can't copy a recycled bitmap</p> <p>My code is:</p> <pre><code> int width = bitmap.getWidth(); int height = bitmap.getHeight(); int newWidth; int newHeight; if (width &gt;= height) { newWidth = Math.min(width,1024); newHeight = (int) (((float)newWidth)*height/width); } else { newHeight = Math.min(height, 1024); newWidth = (int) (((float)newHeight)*width/height); } float scaleWidth = ((float)newWidth)/width; float scaleHeight = ((float)newHeight)/height; Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); switch (orientation) { case 3: matrix.postRotate(180); break; case 6: matrix.postRotate(90); break; case 8: matrix.postRotate(270); break; } Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); bitmap.recycle(); try { bitmap = resizedBitmap.copy(resizedBitmap.getConfig(), true); } catch (Exception e) { Log.v(TAG,"Exception: "+e); } </code></pre> <p>If the exception is telling me that I've recycled <em>resizedBitmap</em>, that is patently false! What am I doing wrong??</p>
android
[4]
4,410,191
4,410,192
Displaying the Length of Individual Sequences in File
<p>I have a file that contains two sequences. I have a program that could read all sequences, combine them together, and display the length of both sequences together. Now I want to display the length individually. The two sequences are separated by the symbol <code>&gt;</code>.</p> <p>Example:</p> <pre><code>SEQ1 &gt;ATGGGACTAGCAGT SEQ2 &gt;AGGATGATGAGTGA </code></pre> <p>Program:</p> <pre><code>#!usr/bin/python import re fh=open('clostp1.fa','r') count=0 content=fh.readlines() fh.close() seq='' patt=re.compile('&gt;(.*?)') for item in content: m=patt.match(item) if not m: s=item.replace('\n','') seq=seq+s seq=seq.replace('\s','') print seq print 'The length of the coding sequence of the bacillus' print len(seq) </code></pre>
python
[7]