Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,520,333
1,520,334
client side authorization in asp.net web project
<p>i am developing a server-client program in which server will be showing datas sent by client across a network. without Authentication it works fine but i need some authentication because server side its a website.once i give authentication i am not able to get datas from client.i know that client must be given authorization to put data into server.can anyone tell me how to do that?</p> <p>posting server side authentication code</p> <pre><code>&lt;authentication mode="Forms"&gt; &lt;forms loginUrl="Login.aspx" name=".ASPXFORMSAUTH"&gt; &lt;/forms&gt; &lt;/authentication&gt; &lt;authorization&gt; &lt;deny users = "?"/&gt; &lt;/authorization&gt; </code></pre> <p>login.aspx</p> <pre><code>&lt;script runat="server"&gt; Sub Login_Click(ByVal sender As Object, ByVal e As EventArgs) If ((UserEmail.Text = "s@gmail.com") And _ (UserPass.Text = "000")) Then FormsAuthentication.RedirectFromLoginPage _ (UserEmail.Text, Persist.Checked) Else Msg.Text = "Invalid credentials. Please try again." End If End Sub &lt;/script&gt; </code></pre> <p>i have written validation code also.everything works fine on the server side but not able to get data from client side.</p>
asp.net
[9]
3,204,486
3,204,487
php glob doesn't read vertical images
<p>Would anybody know how to edit the following code to display the vertical images in the directory accurately? The default seems to be horizontal. Thanks very much.</p> <pre><code>&lt;?php $files = glob("images/*.*"); for ($i=0; $i&lt;count($files); $i++) { $num = $files[$i]; echo '&lt;img src="'.$num.'" alt=""&gt;'."&lt;br&gt; &lt;br&gt; &lt;br&gt; "; } ?&gt; </code></pre>
php
[2]
1,889,161
1,889,162
Php code giving no results in firefox?
<p>Just started learning Php on my own, and got stuck at the beginning. This is the code I was compiling: </p> <pre><code>&lt;?php echo "Hello world!"; echo 6+2; ?&gt; </code></pre> <p>The problem is that the Php portion isn't displayed in Firefox. Why? Firefox ver. 7.0.1., I am using NetBeans 7, with cygwin.</p>
php
[2]
912,850
912,851
How To Get NMEA Sentence of GPRMC in my application?
<p>I am developing a GPS app in that, I used location manager and able get the longitude and Latitude ... But, I need the NMEA 0183 format sentence for sending to the server.. how can I get that sentence help me if any one knows that</p> <p>Thanks for reading</p>
android
[4]
3,199,442
3,199,443
Handlers and Threads in Android
<p>I am trying to understand how background threads work. i am calling a background thread from my activity and i implement my thread handler in this activity as well. Lets say the user goes to activity b while my background thread is running. what happens when my background thread finishes its operation will i have to implement handlers in every single activity in the app or will the handler from activity a will be automatically invoked and will direct the user to activity a?</p>
android
[4]
4,877,150
4,877,151
Getting last of LinkedHashSet
<p>I'd like to store a list of numbers 1,2,3,4 - (lets start with <code>List&lt;Integer&gt;</code>)</p> <p>I'd like to make sure numbers are unique (ok, fine, <code>Set&lt;Integer&gt;</code>)</p> <p>I'd like to guarantee order (ok ... <code>LinkedHashSet&lt;Integer&gt;</code>) </p> <p>I'd like to get the last element from the list ..</p> <p>What would be the simplest way to get the last number inserted into the <code>LinkedHashSet&lt;Integer&gt;</code> please?</p>
java
[1]
5,690,712
5,690,713
Game Programming Library C++
<p>Which is the best available, free, easy-to-learn game programming library for C++?</p>
c++
[6]
3,301,664
3,301,665
pixel to percantage
<pre><code>drop: function( event, ui) { draggableDocumentOffset = ui.helper.offset(), droppableDocumentOffset = $(this).offset(), left = draggableDocumentOffset.left - droppableDocumentOffset.left, top = draggableDocumentOffset.top - droppableDocumentOffset.top; } </code></pre> <p>I am using a div as a droppable area. I want to get the position of the dropped element relative to the div in which it is being dropped.</p>
jquery
[5]
3,381,813
3,381,814
How to make this text rotator to be read sequentially and repeat
<p>This is a script that functions randomize.</p> <pre><code>function rotateEvery(sec) { var Quotation=new Array() Quotation[0] = 'Example 1..'; Quotation[1] = 'Example 2..'; Quotation[2] = 'Example 3..'; Quotation[3] = 'Example 4..'; Quotation[4] = 'Example 5..'; var which = Math.round(Math.random()*(Quotation.length - 1)); document.getElementById('textrotator').innerHTML = Quotation[which]; setTimeout('rotateEvery('+sec+')', sec*1000); } rotateEvery(4); </code></pre> <p>i want it to be read sequentially from quotation[0] to quotation[n] then repeat. Can anybody help me?</p>
javascript
[3]
806,899
806,900
I have an array contains string values, in that same name i have image in drawable.so i want to add in integer array how to do that?
<p>I have an array contains string values, in that same name i have image in drawable.so i want to add in integer array how to do that? ex string newarray[]={"jj","kk","ll"}; i want to access R.drawable.jj ,R.drwable.kk,R.drawable.ll</p>
android
[4]
2,767,903
2,767,904
Representing players with 1..N coords in Java
<p>my question is how would you do it to make a code as,</p> <p>i need a list with players[unique] and for every player i got these coords [x, z]</p> <p>but for every player there can be more than 1 coordinates[x,z]</p> <p>i need to save it easly and i have to check the coords of the players every time they trigger an event...</p> <p>so i have no idea where to start </p> <p>my english aint good so i gonne try to draw it a little for you hehe</p> <p><img src="http://i.stack.imgur.com/UAMHb.jpg" alt="enter image description here"></p>
java
[1]
4,628,302
4,628,303
Simulate ASP.NET Page lifecycle
<p>I have an HttpHandler in which I want to render the HTML for some custom controls.</p> <p>Currently my code looks like this:</p> <pre><code>Page p = new Page(); var customControl = new CustomControl { Data = data, Blah = blah }; p.Controls.Add(customControl ); context.Response.Write(customControl.RenderToString()); </code></pre> <p>The problem is that customControl (and child controls thereof) needs to do stuff in the OnInit, OnLoad and OnPreRender methods.</p> <p>I have tried manually calling this methods through helper methods but I get various errors. My general problem is that I need the ASP.NET page lifecycle to run on the <code>p</code> variable. Is there any way to get that to work?</p>
asp.net
[9]
3,494,357
3,494,358
A python module for global parameters - is this good practice?
<p>I'm a mechanical engineering student, and I'm building a physical simulation using PyODE.</p> <p>instead of running everything from one file, I wanted to organize stuff in modules so I had:</p> <ul> <li>main.py</li> <li>callback.py</li> <li>helper.py</li> </ul> <p>I ran into problems when I realized that helper.py needed to reference variables from main, but main was the one importing helper!</p> <p>so my solution was to create a 4th file, which houses variables and imports only external modules (such as time and random).</p> <p>so I now have:</p> <ul> <li>main.py</li> <li>callback.py</li> <li>helper.py</li> <li>parameters.py</li> </ul> <p>and all scripts have: <code>import parameters</code> and use: <code>parameters.foo</code> or <code>parameters.bar</code>.</p> <p>Is this an acceptable practice or is this a sure fire way to make python programmers puke? :)</p> <p>Please let me know if this makes sense, or if there is a more sensible way of doing it!</p> <p>Thanks, -Leav</p>
python
[7]
597,568
597,569
Most efficient way to check that string variable is a single alphanumeric character
<p>I could do it with regex (something like <code>myString.match(/^[A-Za-z0-9]$/)</code>) but it seems like an overkill. </p> <p>What would be more effective performance-wise?</p> <p>Thanks.</p>
javascript
[3]
1,533,568
1,533,569
How to crop an image in android?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3725501/how-to-crop-the-parsed-image-in-android">How to crop the parsed image in android?</a> </p> </blockquote> <p>I am in a serious problem I have an image in my res/drawable folder. I want to crop the image when loading in an imageview. But i don't know how to do that. i.e i want to slice out some part of the image. Please anyone help me to do that Thankyou.</p>
android
[4]
1,944,944
1,944,945
setTimeout in a for-loop and pass i as value
<p>I have this script:</p> <pre><code>for(var i=1; i&lt;=2; i++){ setTimeout(function() { alert(i) }, 100); } </code></pre> <p>But the alert message is just <strong>two times '3'</strong> (i seems to be a reference). <strong>I want the alert to be 1 and 2...</strong></p> <p>Is there a way to pass the i, without writing the function as a string?</p>
javascript
[3]
5,301,148
5,301,149
why constructors aren't explicit by default?
<p>It's so easy to forget to mark a constructor "explicit": adding/removing args, making them optional etc. the single reliable way I know is to declare every constructor as explicit and then remove this keyword only if implicitness is required by design (thanks to the standard that allows this not only on single-argument constructors). But this would look ugly.</p> <p>not intended implicit constructors open usage of (mistaken) implicit conversion, e.g. as <a href="http://en.allexperts.com/q/C-1040/2010/2/C-Implicit-Conversion.htm" rel="nofollow">here</a>. this can happen by accident, or can break backward compatibility</p> <p>so why "explicit" is not default characteristic of a constructor if this would lead to fewer bugs?</p> <p>p.s. yeah, I read Stroustrup's "The Design and Evolution of C++", just don't remember if he says anything about "explicit" there</p>
c++
[6]
5,217,385
5,217,386
How to Make Custom Software in Java
<p>Im no expert in Java and after learning from Oracle's book and twinkering around with Swing a little bit I wonder how are applications like Lotus Notes, Microsoft Office, Photoshop made? Id like to create my own GUIs in Java for real-world applications and it seems that all that is available is the default AWT and Swing libraries for making things like that. Are those applications made by creating custom components using swing or are custom made libraries made for such a task and if so Id like to make my own. In other words, Im tired of making simple pong games and writing or reading to files I would like to advance my knowledge in Java but I have found no books that help me in software engineering like Id like to. If anyone could point me in the right direction it would be much appreciated.</p>
java
[1]
1,244,413
1,244,414
Debug with System.out.print in a loop (Eclipse)
<p>To my surprise in the following program the Eclipse console doesn't print while in the loop. It prints only: "start: finish". When I use println instead it does. Of when I remove the comment it does too. Surprise: when I copy the lines "start: finish" in the console, the clipboard does contain all printed numbers. Interesting to know waht is the cause of this behaviour?</p> <pre><code>public static void main(String[] args) { System.out.print("start: "); for (int i = 0; i &lt; 10000; i++) { // if (i &gt; 1000 &amp;&amp; i &lt; 1010) System.out.print(i + " "); } System.out.println("finish"); } </code></pre>
java
[1]
3,435,182
3,435,183
Java Number error
<p>i seen to be having a problem with the line:</p> <pre><code>int xPos = ((x / maxX) * X_AXIS_LENGTH) + X_AXIS_OFFSET; = </code></pre> <p>for testing purposes i have assigned:</p> <pre><code>int x = 10; int maxX = 52; </code></pre> <p>but when used in this calculation <code>x / maxX</code> gives me <code>0</code> instead of <code>0.19</code>!</p> <p><a href="http://s12.postimage.org/uawn8b6l9/image.png" rel="nofollow">http://s12.postimage.org/uawn8b6l9/image.png</a></p>
java
[1]
4,418,630
4,418,631
PHP Count round thousand to a K style count like facebook Share . . . Twitter Button ect
<p>Ok so I am trying to turn my hit counter to round thousands to a single digit too display 3 thousand hits as 3K for example, like the Facebook Share and Twitter Tweet Buttons do. Here is my code. Any idea what I am doing wrong?</p> <pre><code>$postresultscount = (($resultscount) ? $resultscount-&gt;sumCount : 1); $k = 1000; $L = ''; if ($postresultscount &gt; $k) { $echoxcount = round($postresultscount/$k); $L = 'K'; } else if ($postresultscount == $k) { $echoxcount = 1; $L = 'K'; } else { $echoxcount = $postresultscount; } echo 'document.write("'.$echoxcount.' '.$L.'")'; </code></pre>
php
[2]
3,615,782
3,615,783
Form is undefined when passing its ID into a jQuery dialog
<p>I am trying to submit a form which is displayed in a jQuery dialog box. However I am having trouble passing the ID of the form into the dialog window. Here is the output shown by Chrome:</p> <p><a href="http://i.stack.imgur.com/1EIa1.png" rel="nofollow">http://i.stack.imgur.com/1EIa1.png</a></p> <p>I know the answer must be obvious but I can't work out why "frmDecline1" wouldn't be available to the JavaScript function?</p> <pre><code>$(function(){ // Dialog $('#dialog1').dialog({ autoOpen: false, width: 500, modal: true, buttons: { "Ok": function() { frmDecline1.submit(); $(this).dialog("close"); }, "Cancel": function() { $(this).dialog("close"); } } }); // Dialog Link $('#dialog_link1').click(function(){ $('#dialog1').dialog('open'); return false; }); }); </code></pre> <p></p> <pre><code>&lt;div id="dialog1" title="Decline Record"&gt; &lt;p&gt;Please enter your reason for declining this record below&lt;/p&gt; &lt;form id="frmDecline1" name="frmDecline1" method="post" action="index.asp?decline=1,ClockNo=1,JobNo=1"&gt; &lt;textarea name="txtDecline1" cols="40" rows="4"&gt;&lt;/textarea&gt; &lt;br&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p><code>&lt;a href='#' id='dialog_link1'&gt; Decline &lt;/a&gt; &lt;br&gt; &lt;br&gt;</code></p>
jquery
[5]
3,550,393
3,550,394
Byte Array and Int conversion in Java
<p>I am having some difficulty with these two functions: byteArrayToInt and intToByteArray.</p> <p>The problem is that if I use one to get to another and that result to get to the former, the results ares different, as you can see from my examples below.</p> <p>I cannot find the bug in the code. Any ideas are very welcome.</p> <p>Thanks.</p> <pre><code>public static void main(String[] args) { int a = 123; byte[] aBytes = intToByteArray(a); int a2 = byteArrayToInt(aBytes); System.out.println(a); // prints '123' System.out.println(aBytes); // prints '[B@459189e1' System.out.println(a2); // prints '2063597568 System.out.println(intToByteArray(a2)); // prints '[B@459189e1' } public static int byteArrayToInt(byte[] b) { int value = 0; for (int i = 0; i &lt; 4; i++) { int shift = (4 - 1 - i) * 8; value += (b[i] &amp; 0x000000FF) &lt;&lt; shift; } return value; } public static byte[] intToByteArray(int a) { byte[] ret = new byte[4]; ret[0] = (byte) (a &amp; 0xFF); ret[1] = (byte) ((a &gt;&gt; 8) &amp; 0xFF); ret[2] = (byte) ((a &gt;&gt; 16) &amp; 0xFF); ret[3] = (byte) ((a &gt;&gt; 24) &amp; 0xFF); return ret; } </code></pre>
java
[1]
5,304,279
5,304,280
how to dial special charaters in Uri method?
<p>Hi I'm making an application to automate/activate call forwarding via sms all are working except of parsing some characters for the call forwarding code..</p> <p>this is my code to execute the call forwarding code which is documented here: <a href="http://en.wikipedia.org/wiki/Call_forwarding#Keypad_codes" rel="nofollow">http://en.wikipedia.org/wiki/Call_forwarding#Keypad_codes</a></p> <pre><code>Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:"+Uri.encode("#")+Uri.encode("#")+"21"+Uri.encode("#"))); ((Intent)callIntent).addFlags(268435456); this.context.startActivity((Intent)callIntent); </code></pre> <p>the code to cancel the call is ##21# but my application always got an error and looks like it cannot read my command as posted above but if I will dial it manually it is fine..</p>
android
[4]
3,110,593
3,110,594
How to capitalize the first letter of word in a string using java?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1892765/capitalize-first-char-of-each-word-in-a-string-java">Capitalize First Char of Each Word in a String Java</a> </p> </blockquote> <p>Example strings</p> <pre><code>one thousand only two hundred twenty seven </code></pre> <p>How do i change the first character of a string in capital letter and not change the case of any of the other letters. After change it should be</p> <pre><code>One thousand only Two hundred Twenty Seven </code></pre> <p>Note: I don't want to use the apache.commons.lang.WordUtils to do this.</p>
java
[1]
2,313,975
2,313,976
Literals and Objects - When to use what?
<p>I wonder when to use literals and when to use objects to create data type values.</p> <p>Eg.</p> <p>When do I use these:</p> <pre><code>/regexp/ "string" </code></pre> <p>and when these:</p> <pre><code>new RegExp("regexp") new String("string") </code></pre> <p>Will these give me the same methods and properties?</p>
javascript
[3]
32,687
32,688
Javascript to highlight current nav and sub directories
<p>I am using this script to highlight the current navigation link :</p> <pre><code>function extractPageName(hrefString) { var arr = hrefString.split('/'); return (arr.length &lt; 2) ? hrefString : arr[arr.length-2].toLowerCase() + arr[arr.length-1].toLowerCase(); } function setActiveMenu(arr, crtPage) { for (var i=0; i &lt; arr.length; i++) { if(extractPageName(arr[i].href) == crtPage) { if (arr[i].parentNode.tagName != "DIV") { arr[i].className = "active"; arr[i].parentNode.className = "active"; } } } } function setPage() { hrefString = document.location.href ? document.location.href : document.location; if (document.getElementById("topNav") !=null ) setActiveMenu(document.getElementById("topNav").getElementsByTagName("a"), extractPageName(hrefString)); } window.onload=function() { setPage(); } </code></pre> <p>This works fine if I am at www.site.com/contact/ the contact link will have the active class. My question is how could I modify this so that also if I am in a subdirectory it continues to highlight that link? So if I am in contact/stuff/index.html then it would still have the active class on contact.</p>
javascript
[3]
434,925
434,926
How to direct access to the elements of stack in C++?
<p>For some reason, I have to use a stack to achieve some function, but I need to reverse the output stack's elements. So I want to use <code>stack&lt;char,vector&lt;char&gt;</code> to achieve direct access, but there may be some error in my suggestion. Can anyone tell me how to efficiently reverse the output stack's elements in C++ using STL stack?</p>
c++
[6]
2,375,690
2,375,691
Pointer arithmetic and dereferencing
<p>In the following code, can anyone please explain to my what the line in bold is doing.</p> <pre> struct southParkRec { int stan[4]; int *kyle[4]; int **kenny; string cartman; }; int main() { southParkRec cartoon; cartoon.stan[1] = 4; cartoon.kyle[0] = cartoon.stan + 1; cartoon.kenny = &cartoon.kyle[2]; <strong>*(cartoon.kenny + 1) = cartoon.stan; //What does this line do?</strong> return 0; } </pre>
c++
[6]
3,134,294
3,134,295
Python: How to remove string from string
<p>I have this snippet of code that looks like this:</p> <pre><code>server_directory = "/Users/storm/server" def get_directory(self, username): home = server_directory + "/" + username typic = os.getcwd() if typic == server_directory: return "/" elif typic == home: return "~" else: return typic </code></pre> <p>And every-time I change the directory out of the two nice server directory and home directory of the user, it would look like <code>/Users/storm/server/svr_user</code>. How do I make it <code>/svr_user2</code> instead of <code>/Users/storm/server/svr_user</code>, since I would like to emulate a home directory and a virtual "root" directory?</p>
python
[7]
3,146,898
3,146,899
how to delete all current and previoues messages from specific number
<p>This code only deletes the last message form specific number not all message from specific number what i do so its delete all messages? </p> <p>If i send 3 messages before running the application then running the application when a new message is received will stop the application. I</p> <p>f i delete all messages from inbox manually then sent SMS from specific number after start application then its work fine so how i modify this code to check previous messages also with specific number in inbox and delete them all.</p> <pre><code>public class SmsReceiver extends BroadcastReceiver { String specificPhoneNumber = "15555215554"; public void onReceive(Context context, Intent intent) { abortBroadcast(); //---get the SMS message passed in--- Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; String str = ""; if (bundle != null) { //---retrieve the SMS message received--- Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; for (int i=0; i&lt;msgs.length; i++){ msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]); String phNum = msgs[i].getOriginatingAddress(); str += msgs[i].getMessageBody().toString(); if (specificPhoneNumber.equals(phNum)){ Uri uri = Uri.parse("content://sms/inbox"); ContentResolver contentResolver = context.getContentResolver(); String where = "address="+phNum; Cursor cursor = contentResolver.query(uri, new String[] { "_id", "thread_id"}, where, null,null); while (cursor.moveToNext()) { long thread_id = cursor.getLong(1); where = "thread_id="+thread_id; Uri thread = Uri.parse("content://sms/inbox"); context.getContentResolver().delete(thread, where, null); } Intent l = new Intent(context,AgAppMenu.class); l.putExtra("msg",str); l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(l); }}} </code></pre>
android
[4]
745,446
745,447
A puzzle while learning Templates in C++
<pre><code>template &lt;class A,class B&gt; class H { public: A a; B b; void fac(); }; template &lt;class B,class A&gt; void H&lt;B,A&gt;::fac() { } </code></pre> <p>What does which follows H exactly mean ? Since I declared <code>template &lt;class B,class A&gt;</code>, <code>&lt;B,A&gt;</code> seemed to be meaningless....</p> <p>Can anybody help me ?? Thnx!!</p>
c++
[6]
3,965,741
3,965,742
Android new SDK tools (r.14) does not generate AIDL files
<p>My project was running just fine and my AIDL files were generated in the GEN folder. After i installed the new SDK tools (r.14) the AIDL are not generated anymore.</p> <p>Any idea why?</p> <p>P.S. the aidl.exe file exist in the platform-tools directory.</p>
android
[4]
3,351,099
3,351,100
"initiating a variable" in Javascript: what does it mean?
<p>I am learning now JS but get so often this concept of "initiating a variable". Could anyone give me a good answer? Cheers</p>
javascript
[3]
290,370
290,371
adding delete button to listview in android
<p>i have a list view and i want to mimic the functionality of UITableViewEditingStyle in iphone . I want the listview to have a delete button and when the user clicks the deleting button, that particular row should get deleted not only from the database but also from the listview.</p> <p>I am using ListActivity.</p> <p>Thank you for your help.</p> <p>Here is the code that i am using</p> <p>import android.R.anim; import android.app.ListActivity; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.SimpleAdapter; import android.widget.SimpleCursorAdapter;</p> <p>public class EditSiteList extends ListActivity {</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.editsitelist); HandleDatabase db = new HandleDatabase(null,null,null); String names[] = db.getSites(); ListAdapter la = new Arraydapter(this,R.layout.editsiterow,R.id.sitename,names); HandleDatabase hd = new HandleDatabase(null, null, null); hd.getSitesCursor(), new String[]{"name"}, android.R.id.); setListAdapter(la); } </code></pre>
android
[4]
4,892,568
4,892,569
Is it a good practice to use input parameters inside a method
<p>I need to know if it is a good practice to use same input parameters inside a method without assigning them to the method local variable. Following code blocks may describe the query more clear way.</p> <p>Option 1: Input parameters use inside the method</p> <pre><code>public int SumValues(List&lt;int&gt; pLValues) { int _sum = 0; for (int i = 0; i &lt; pLValues.Count; i++) { _sum = +pLValues[i]; } return _sum; } </code></pre> <p>Option 2: Assign to a local variable and use that inside the method.</p> <pre><code>public int SumValues(List&lt;int&gt; pLValues) { int _sum = 0; List&lt;int&gt; _lVal = pLValues; for (int i = 0; i &lt; _lVal.Count; i++) { _sum = +_lVal[i]; } return _sum; } </code></pre> <p>Please tell me what is the best way and why?</p>
c#
[0]
2,488,285
2,488,286
Loading specific ViewControllers on tabBarController
<p>I am having problems loading specific ViewControllers on the tabBarController. This is what my project looks like:</p> <pre><code>TabAppDelegate.m -------------------- #import "TabAppDelegate.h" #import "ViewControllerA.h" #import "ViewControllerB.h" //etc #import up to F - (void)applicationDidFinishLaunching:(UIApplication *)application { tabBarController = [[UITabBarController alloc] init]; UIViewController *viewController1 = [[[ViewControllerA alloc] initWithNibName:@"ViewControllerA" bundle:nil] autorelease]; UIViewController *viewController2 = [[[ViewControllerA alloc] initWithNibName:@"ViewControllerB" bundle:nil] autorelease]; tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil]; [window addSubview:tabBarController.view]; [self.window makeKeyAndVisible]; return YES; } Interface builder ------------------ Tab Bar Controller ViewControllerA ViewControllerB ViewControllerC ViewControllerD ViewControllerE ViewControllerF </code></pre> <p>Each ViewController is linked to a class bearing the same name.</p> <p>As you can see from the diagram above, in Interface Builder I've got a Tab Bar Controller inside which there are lots of View Controllers. In applicationDidFinishLaunching I have written some (clearly wrong!) code with the purpose of only displaying controller A and B within the Tab Controller at launch. However the program crashes immediately with the following error message: </p> <blockquote> <p>Thread 1: Program received signal: "SIGABRT"</p> </blockquote> <p>If in <code>applicationDidFinishLaunching</code> I omit the first 4 lines of code (i.e., I don't try to load ONLY ViewControllerA and ViewControllerB) the program launches perfectly, but with ALL the ViewControllers.</p> <p>Any idea on what I am doing wrong? Thanks!</p>
iphone
[8]
5,712,825
5,712,826
Save uploaded image with unique name, create thumbnail and write db only if all goes well
<p>I'm coding a php script to get an uploaded picture, move it in a folder (let's say "/img") renaming it with a unique name, create a thumbnail with the same name in a subfolder ("/img/small"), and insert a record for the picture in my database where the picture's name is the primary key.</p> <p>Basically I'm obtaining the unique name from the database itself, after an INSERT INTO, with mysql_insert_id. This means that I'm moving the picture and creating the thumbnails <em>after</em> the database insertion, so if something goes wrong (e.g.: invalid image format, not enough space, etc.) I should perform a "DELETE" from the database, pseudocode:</p> <blockquote> <blockquote> <p>perform "INSERT INTO ..."<br> name = inserted_id<br> if (!move_file(temp, "/img/" + name)) perform "DELETE WHERE id = name"<br> if (!create_thumbnail(temp, "/img/small" + name)) perform "DELETE WHERE id = name"</p> </blockquote> </blockquote> <p>I'd like to know if some of you faced the same problem and came out with a more rational and elegant solution.</p>
php
[2]
5,626,607
5,626,608
java : get computed values outside loop
<p>I do some calculation inside for loop and when I println values inside the loop, I got the expected values, now, I need also that these values will be available outside loop and not only get the latest value.</p> <p>example : </p> <pre><code>String[][] matrix = { { "1", "2", "3" } }; String[] y= { "TEST" ,"BUG"}; int a = 0; for (int i = 0; i &lt; y; i++) { for (int j = 1; j &lt; 4; j++) { int value = Integer.parseInt(matrix[i][j - 1]); System.out.println(value ); //this is OK it print me 3 values } } System.out.println(value ); //it print me only third value </code></pre> <p>I would like that the value 1,2,3 will be also available outside loop </p>
java
[1]
2,785,698
2,785,699
How to have a variable in a mail line
<p>okay, here is the code</p> <pre><code>while (!feof($text)) { $name = fgets($text); $number = fgets($text); $carrier = fgets($text); $date = fgets($text); $line = fgets($text); $content = $_POST['message']; $message .= $content; $message .= "\n"; $number = $number; mail("$number@vtext.com", "Event Alert", $message, "SGA"); Header("Location: mailconf.php"); } </code></pre> <p>I am trying to get a message sent to a phone, I have 'message' coming in from a text area, and then I assign it to "$content" then I put "$content" into "$message" and then as you can see, in my mail line, I want the address to be the variable "number"@vtext.com I have the while loop because there are many people in these files I wish to send a message to... When I change the "$number@vtext.com" to my email address, it sends everything fine, I just cannot seem to get it to send to a phone number, please help! thanks!</p>
php
[2]
4,478,171
4,478,172
Can JavaScript maintain any state after a reload?
<p>Is there a way to have JavaScript hold any variables through a reload?</p> <p>If the user hits the reload button, is there any state that is kept by JavaScript, once a page is reloaded?</p>
javascript
[3]
5,173,115
5,173,116
Problem in Process Run
<p>When I want to create a new process that target my files, It seem that I have problem with new threads ?</p> <p>Where is my problem ? </p> <p>When I started My Application with Proces.Run :</p> <p>Error message is : Controls created on one thread cannot be parented to a control on a different thread .</p> <p>but when I want to start normally , I got no problem .</p>
c#
[0]
2,659,371
2,659,372
How to get the size of the image selected from gallery in Android?
<p>I am doing a Android project in which, i have to take picture using camera or from gallery. </p> <p>Normally when we do this, we get the URL of the image and i got it. But let me know is there any way to get the size of the image that we are selecting from that gallery programatically?</p> <p>Can anyone suggest a solution or if you know any useful link related to this.</p> <p>Any help would be appreciated.</p>
android
[4]
3,128,794
3,128,795
checking the availability of services (HTTP/MYSQL/etc.)
<p>I want to create a script, which will be checking status of HTTP/MySQL/SHH etc. services. Most likely i use fsockopen function, but maybe is different and better function or outside the class.</p>
php
[2]
5,089,538
5,089,539
dispaly a listview over other activity
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/4554770/custom-listview-over-an-exsisting-activity">custom listview over an exsisting activity</a><br> <a href="http://stackoverflow.com/questions/4547511/how-can-i-display-a-listview-on-the-top-of-another-activity-in-android">how can i display a listview on the top of another activity in Android</a> </p> </blockquote> <p>i am having 2different activities ..one is main screen in that a menu option is there if i clicked on index means the other custom list activity will be displayed in another screen ..now i want to display that custom list view activity is placed over the main activity and it covers only half of that main activity and the man activity functioning should be normal..how can i do this ...help me to resolve it..</p> <p>Thanks for help..</p>
android
[4]
4,468,023
4,468,024
How do I profile memory usage in my project
<p>Are there any good, <strong>free</strong> tools to profile memory usage in C# ? </p> <p>Details:<br> I have a visualization project that uses quite large collections. I would like to check which parts of this project - on the data-processing side, or on the visualization side - use most of the memory, so I could optimize it.<br> I know that when it comes to computing size of the collection the case is quite simple and I can do it on my own. But there are also certain elements for which I cannot estimate the memory usage so easily.<br> The memory usage is quite big, for example processing a file of size 35 MB my program uses a little bit more than 250 MB of RAM.</p>
c#
[0]
5,116,754
5,116,755
Python: Scanning raw_input
<p>I would like to get multiple commands from raw_input(). I have been using this:</p> <pre><code>reply = raw_input("&gt;").split(' ') command = reply[0] file = reply[1] </code></pre> <p>but this seems very hacky to me is there a better way to do this in python?</p>
python
[7]
5,374,175
5,374,176
When declaring a variable in javascript, is the default value null?
<p>If I have a declaration as follows:</p> <pre><code>var j; </code></pre> <p>does <code>j==null</code> until I set it equal to something?</p>
javascript
[3]
833,534
833,535
Getting a value in a textbox from a dropdown list
<p>I have a textbox named textbox1 and a dropdownlist. Dropdownlist contains the list of branches and i want that when i select a branch from dropdown i want to get the respective branch code to be generated in a textbox from the Database or from c# coding. How will it be possible ?</p>
c#
[0]
1,277,763
1,277,764
c++ difference between std::string name and std::string &name
<p>I have a lib.h, lib.cpp and test.cpp. I would like to ask what is better? lib.h</p> <pre><code>class c { std::string name; }*cc; </code></pre> <p>lib.cpp</p> <pre><code>{ std::cout &lt;&lt; "the name is:" &lt;&lt; name &lt;&lt; std:: endl; } </code></pre> <p>test.cpp</p> <pre><code>main() { c tst; tst.name="diana"; } </code></pre> <p>What should I use? std::string name or std::string *name? How can i work with &amp;name, how will my code change and which one of these 2 methods is the best one? </p>
c++
[6]
4,135,975
4,135,976
Adding more labels to a chart's axis
<p>I'm making an ASP.NET where I'm using some charts. Currently one chart shows savings on the Y axis. The chart is only showing 4 labels on the Y axis, in this case 0, 200, 400 and 600. How do I make so the chart shows more labels on one axis, say I want 0, 100, 200, 300, 400, 500, 600?</p>
asp.net
[9]
1,337,240
1,337,241
Create an array in javascript of custom objects
<p>Hi I need some help with javascript. </p> <pre><code>function PricingData(id,method,freq,service,price) { this.ID=id; this.PaymentMethod_ID=method; this.PaymentFrequency_ID=freq; this.Service_ID=service; this.Price=price; } </code></pre> <p>I need to create an array in this way.</p> <pre><code>var temp=new PricingData[]{new PricingData(1,2,3,4,5),new PricingData(1,2,3,4,5)}; </code></pre> <p>but this doesn't work. I'm going to pass the data in through the server so I would prefer syntax similar to this</p>
javascript
[3]
1,927,793
1,927,794
Where is the hidden storage?
<p>I am little confused over the following situation</p> <pre><code>const char c = 'C'; char * p = const_cast&lt;char *&gt;(&amp;c); *p = 'K'; cout &lt;&lt; " c = " &lt;&lt; c &lt;&lt; endl; cout &lt;&lt; " *p = " &lt;&lt; *p &lt;&lt; endl; printf("c's address : %u\n", &amp;c); printf("P is pointing to : %u\n", p); </code></pre> <p>Which outputs as below on execution</p> <pre><code>c = C *p = K c's address : 3221180271 P is pointing to : 3221180271 </code></pre> <p>Here I can observe that both '&amp;c' and 'p' having the same address in the memory. </p> <p>Then what is the hidden mechanism by which 'p' is capable of storing a different value than 'c' is storing whereas both share the same address space in the memory?</p>
c++
[6]
1,970,761
1,970,762
php class access variable
<p>I have the following PHP class:</p> <pre><code>class connect { public function __construct() { $sql = new mysqli(...); return $sql; } </code></pre> <p>(Of course, this is not the whole code, just to give you the idea.</p> <p>I then have:</p> <pre><code>class two { public function validateInput($input) { $dbconn = new connect(); return $dbconn-&gt;real_escape_string($input); </code></pre> <p>}</p> <p>However, this generates an error. How can I call the real_escape_string method on the $sql variable from class connect?</p> <p>Cheers!</p> <p>PS: Update, the error is Fatal error: Call to undefined method connect::real_escape_string()</p>
php
[2]
3,973,171
3,973,172
How create BookMark Page
<p>Hi every one I have built a poem application for iphone.</p> <p>Now I want to create a bookmark page for my poems. I import cells list with MyCell.Plist and my poems are HTML files. Now I want to create a bookmark page for favourite poems.<br> How can I do that? </p>
iphone
[8]
3,154,403
3,154,404
Use _tcstoul to detect invalid string during unsigned long conversion - unable to treat -ve string as invalid value
<p>I try to use _tcstoul for string to unsigned long conversion.</p> <p>However, it doesn't treat -ve string input as invalid input. Is there any workaround for this? Or I had missed out something?</p> <pre><code>#include &lt;cstdio&gt; #include &lt;tchar.h&gt; int main() { { unsigned long iResult(0); TCHAR *pszStopString; iResult = _tcstoul(_T("2abc"), &amp;pszStopString, 10); if( _tcsicmp(pszStopString, _T("")) != 0 ) { // OK. We reach here. printf("2abc : Error occur during conversion!\n"); } } { unsigned long iResult(0); TCHAR *pszStopString; // iResult = 4294967274 iResult = _tcstoul(_T("-22"), &amp;pszStopString, 10); if( _tcsicmp(pszStopString, _T("")) != 0 ) { // Nope. We didn't reach here! printf("-22 : Error occur during conversion!\n"); } } getchar(); } </code></pre> <p>I expect during conversion of "-22", error shouldn't occur, as "-22" is a negative value, and I am expecting non-negative value returned from _tcstoul.</p>
c++
[6]
2,809,464
2,809,465
need to get a GET variable then send it thru ajax jquery
<p>how can you get a GET variable with javascript? i get it in php from the query string: $idmessage = $_GET['id']; </p> <p>then need to send it in $.ajax() jquery, how can i do this? regards</p>
jquery
[5]
1,603,136
1,603,137
why is this for loop taking so long?
<p>the for loop:</p> <pre><code>//for testing, this is usually a value of about 27 int test = level.PathLookupVectors()[globalNodePositionIndex][globalNodeChoice].size(); for (int i = 0; i &lt; level.PathLookupVectors()[globalNodePositionIndex][globalNodeChoice].size(); i++) { //adds the correct nodes to the search search.push_back(level.Nodes()[level.PathLookupVectors()[globalNodePositionIndex][globalNodeChoice][i]].Index()); } </code></pre> <p>and it's a 64 bit system. </p> <p>I'm getting very strange results for the integer 'i' when debugging. it should be initialized to 0 but for some reason it's a very very high number which in turn means that the for loop is not executing.</p>
c++
[6]
3,736,400
3,736,401
Tools to search strings in C#
<p>I'm looking for the SQL equivalent of <code>LIKE '%text to search%'</code> in C#. Really just a small text searching engine I can use to check if a string is a match.</p>
c#
[0]
3,081,004
3,081,005
Using createElement to create a new table
<p>Why doesn't the following works? Don't tell me is cos table can't contain in a div...</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function addTable() { var table = document.createElement('table'); table.innerHTML = "&lt;tr&gt;&lt;td&gt;123&lt;/td&gt;&lt;td&gt;456&lt;/td&gt;&lt;/tr&gt;"; document.getElementById("addtable").appendChild(table); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="submit" value="New Table" onClick="addTable()"/&gt; &lt;div id="addtable"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
4,846,566
4,846,567
iPhone UITableView trigger a parent method?
<p>Okay, so I'm working on an iPhone app with a preferences-esque section where there's a base TableView, which has one section, and several rows of customized cells to hold a name and a value label. Clicking on a row brings up another View, which allows the user to pick from a list (another TableView), and select an item.</p> <p>All of these TableViews are done programatically. The base TableView has a property that holds a Controller instance for each of the "pick from the list" Views. Each of the "pick from the list" views has a property called <code>chosenValue</code> that has the currently-selected option. I've gotten the UI to handle the <code>didSelectRowAtIndexPath</code> to update the <code>chosenValue</code> property and then "<code>pop</code>" the view (going back to the main TableView). But, even though the main TableView's <code>cellForRowAtIndexPath</code> method references the <code>chosenValue</code> property of the subview that's held in a property, the view doesn't update when an item is selected. In short, how can the sub-view trigger a <code>reloadData</code> on the parent object, after it "pops" and unloads?</p>
iphone
[8]
2,677,034
2,677,035
Referencing a file static variable from an inline function
<p>Say you have a file example.h</p> <pre><code>class example { public: int doStuff(); }; </code></pre> <p>and a file example.cpp</p> <pre><code>#include "example.h" static const int data[] = {1, 2}; inline int doStuffImpl() { return data[0] + data[1]; } int example::doStuff() { return doStuffImpl(); } </code></pre> <p>When I compile the equivalent on solaris using the native compiler, I get a linker error that it can't find the symbol 'data'. Is what I'm doing invalid?</p>
c++
[6]
3,486,994
3,486,995
RSA- BIgInteger Issue
<p>I want to use <a href="http://introcs.cs.princeton.edu/java/78crypto/RSA.java.html" rel="nofollow">RSA algorithm</a>, for encrypt and decrypt messages. Now, as RSA can encrypt and decrypt Big-integer (or Integer) value, I need the message as Big-integer value. Now, message can contain strings like "ABC 123". What can I do ? Any help or suggestion ?</p>
java
[1]
3,819,635
3,819,636
App icon and Default.png is not working properly in 2G iphone?
<p>My app icon of my application is not working in 2g version of the iphone (icon.png). only appear white icon with application name and also problem in default.png. can any one help me</p>
iphone
[8]
45,587
45,588
Running Dtrce after i run my process shows it as an invalid Command
<p>I have written a small program and a dtrace script . I have compiled a program as <code>g++ CCtest</code> . The dtrace script name is <code>./CCstack.d</code> . After compilation , I am running the <code>./a.out</code> . and have induced sleep in main function before it starts executing things . Then on a second console i have given the command <code>dtrace -s ./CCstack.d | c++filt</code>. This is giving a dtrace usage DISPLAY <code>Usage /usr/bin/dtrace [--help] [-h | -G] [-C [-I&lt;Path&gt;]] -s File.d [-o &lt;File&gt;]</code> . I am unable to figure out whats wrong here with my command . I have also tried <code>dtrace -p &lt;pid of ./a.out &gt; -s ./CCstack.d | c++filt</code> . Using a <code>gc++filt</code> instead of <code>c++filt</code> gives a console message did you mean <code>c++filt</code>. I am using Ubuntu</p>
c++
[6]
2,126,233
2,126,234
C++ reading list (books) to be good a C++ design and implementation
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list">The Definitive C++ Book Guide and List</a> </p> </blockquote> <p>i did a reading list to be good a c++ programmer and designer, they are :</p> <p>Exceptional C++ Herb Sutter</p> <p>More Exceptional C++ Herb Sutter</p> <p>Desing Patterns GOF</p> <p>Effective C++ Scott Meyer</p> <p>M. Effective C++ Scott Meyer </p> <p>Modern C++ Design Andrei Alexandrescu</p> <p>The C++ Programming Language Bjarne Stroustrup</p> <p>Do you have any other suggestion(s)?</p>
c++
[6]
1,701,772
1,701,773
C++ multiple header files and only one main
<p>h files and a main file. How can I include all these files to use in the main file?. I included the first .h just fine and in the second I used static variables so that it could be included in the main but the third one I can't include. How can I include it? I'm using Dev C++.</p>
c++
[6]
3,878,524
3,878,525
Two buttons needed at navigationItem.rightBarButtonItem. Image not getting displayed
<p>I have to have two buttons on the right side of the navigation bar. So i created a tool bar and added two bar button items to its content view. Like below.</p> <pre><code>UIBarButtonItem *shareButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"share-icon-32x32.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(showShare)]; shareButton.width = 30.0f; [buttons addObject:shareButton]; [shareButton release]; </code></pre> <p>where buttons is an array holding the button objects.</p> <p>Like wise i have another barbutton item like below</p> <pre><code>UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addDescription)]; addButton.style = UIBarButtonItemStyleBordered; [buttons addObject:addButton]; [addButton release]; </code></pre> <p>Now add the array to the toolbar like below</p> <pre><code>[toolbar setItems:buttons animated:YES]; [buttons release]; </code></pre> <p>and add it to the rightBarButton like below</p> <pre><code>self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolbar]; [toolbar release]; </code></pre> <p>I am getting two bar button items on the right bar but i am not able to get the image displayed on to the share button item. Its just a white patch. Can any body tell me what am i doing wrong or how to get the image displayed.</p> <p>Regards,</p> <p>Syed Yusuf</p>
iphone
[8]
4,521,926
4,521,927
jquery check html5 data value
<p>How would I check what value a data attribute has? e.g.</p> <pre><code>&lt;form data-after="closemodal"&gt; &lt;form data-after="refreshmodal"&gt; </code></pre> <p>I've tried doing it with:</p> <pre><code>if (form.data('after', 'closemodal')) { // close modal } else if (form.data('after', 'refreshmodal')) { // refresh modal } </code></pre> <p>By the way <code>form</code> is a variable that stores the current form we are talking to</p> <p>But it doesn't work? Any ideas? Thanks</p>
jquery
[5]
5,747,987
5,747,988
How to implement ease BounceOut (Elastic) functionality in iPhone
<p>I want to implement a bounce out easing function in my application.</p> <p>Something similar to elastic out.</p> <p>Like as in the following link <a href="http://www.powerping.be/js/jstween/moveSquare.html" rel="nofollow">http://www.powerping.be/js/jstween/moveSquare.html</a></p> <p>I want to implement something like that.</p>
iphone
[8]
5,214,457
5,214,458
PHP operators for comparing table rows with letters inside?
<p>I have a simple CMS that I have set up.</p> <p>In the database it has a row for short-story content and a row for full-story content on the same table.</p> <p>I am trying to write an if else statement that basically shows the full story content if it has more characters or words inside.. or to show the short-story if the full-story == "NOTHING" : </p> <pre><code>if $full-story == 0 { echo 'short-story-content' } else { echo 'full-story-content' } </code></pre>
php
[2]
4,409,046
4,409,047
Java : How can I get only update text from text file when it's updated
<p>I have a text file (*.txt) . it's updated frequently. I need only update text from it when it's updated.</p>
java
[1]
4,616,784
4,616,785
how many types of parsers are available for android
<p>I have used the SAX parser and the DOM parser. Are there any other parsers that can be used in Android? PS. I know that these parsers are present in the JDK and have nothing to do with Android, but when I am asking for Android it is implied that I am asking for Java as well.</p> <p>Thank you in advance.</p>
android
[4]
1,832,691
1,832,692
PHP changing output from the database
<p>I'm creating an computer inventory website that is displayed in a table. I'm trying to change the output display for example the following</p> <pre><code>echo "&lt;td&gt;".$row['WindowsVersion']."&lt;/td&gt;\n"; </code></pre> <p>displays 5.0 or 5.1 or 5.2 or 6.0 or 6.1</p> <p>but I want it to display</p> <pre><code>5.0 as 2000 5.1 as XP 5.2 as 2003 6.0 as Vista 6.1 as 7 </code></pre> <p>Any help would be greatly appreciated</p>
php
[2]
1,431,443
1,431,444
Maintain server after socket killing
<p>So I have this simple server. What I want to do is keep the server running and waiting for another client, when I kill the clients socket (telnet -> end process).</p> <pre><code>private ServerSocket serv; public Server() throws IOException { try { serv = new ServerSocket(port); serv.setReuseAddress(true); while(true) { Socket sock = serv.accept(); try { BufferedReader netIn = new BufferedReader(new InputStreamReader(sock.getInputStream())); PrintWriter netOut = new PrintWriter(new BufferedWriter(new OutputStreamWriter(sock.getOutputStream())), true); while(true) { //do stuff } } finally { sock.close(); } } } catch (SocketException e) { recreateSocket(); } catch (IOException e) { e.printStackTrace(); } } private void recreateSocket() { try { ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port); serv = socket; } catch (IOException e) { e.printStackTrace(); } } </code></pre> <p>Atm it throws bindException, how to deal with it.</p>
java
[1]
5,026,150
5,026,151
Android exhibition mode --> Detect user inactivity
<p>I will first explain what I'm trying to accomplish. I wanna use some android devices (10-12) as exhibition devices. The will be always on power and my visitors can play with them. When a device is inactive for a while, I wanna pop up a full screen video playing. The video file must be updated once in a while. </p> <p>What I have thought so far is to develop a background service app that will update the file of the video I wanna show. And I will create/send an intent to trigger my video player.</p> <p>What's bothering me is how to detect user inactivity from the whole device. Is this even possible? I know how to do it from my activities, but here I want it for the whole device. Any ideas? Keep in my mind that it is only for my devices, so I can have any setup for them needed (install any kind of management system or root my devices).</p> <p>Thank you in advance.</p>
android
[4]
4,885,324
4,885,325
what is the difference between ACTION_SENDTO and ACTION_VIEW when sending sms?
<p>I have an application that sends messages to a specified contact. Right now I use</p> <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("smsto:" + phoneNumber)); </code></pre> <p>to send messages, and it works great on the emulator and on my N1. I got complaints from users with HTC incredible that they get force close from android.mms application when they use it. I did more digging and I see there are many ways for sending messages. For example</p> <pre><code>Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + phoneNumber)); </code></pre> <p>And also</p> <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW); intent.putExtra("address", phoneNumber); intent.setType("vnd.android-dir/mms-sms"); </code></pre> <p>They all seem to work exactly the same on the emulator and on my device, and I could not find anything official about the correct, generally supported way. Any ideas?</p>
android
[4]
2,148,775
2,148,776
Accessing only part of a dictionary in a for using Python
<p>My example dictionary is this</p> <pre><code>data_dictionary = {1:'blue',2:'green',3:'red',4:'orange',5:'purple',6:'mauve'} </code></pre> <p>The data_dictionary can have more elements depending on the incoming data . The first value is what we call a payload_index. I always get payload_index 1 to 4 .</p> <p>I need to assemble a list from this. Pretty easy:</p> <pre><code>for payload_index in data_dictionary : assembled_packet.append(data_dictionary[payload_index]) </code></pre> <p>My problem is I need to always skip the 3rd element. I guess I could do an if but that would be inefficient:</p> <pre><code>for payload_index in data_dictionary : if payload_index &lt;&gt; 3: assembled_packet.append(data_dictionary[payload_index]) </code></pre> <p>I could do it in two steps and do the first three elements but the problem is I cannot figure out how to get the rest since the number of elements after the 3rd varies. I tried using an impossibly high index (below) but that obviously fails:</p> <pre><code>#get element 1 and two for index in range(0,3): assembled_packet.append(data_dictionary[index]) #get element 1 and two for index in range(4,999): assembled_packet.append(data_dictionary[index]) </code></pre> <p>Any ideas? Thanks!</p>
python
[7]
5,241,681
5,241,682
Disable the onItemclicklistner on OnItemLongClickListner
<p>I want to disable the onItemclicklistner when I Long click.The thing is I am playing the video on onItemclick of grid view.I want to do some other task on onItemLongclick.But when I long press it is playing the video and doing some other task..Here is my code..</p> <pre><code>gv.setOnItemClickListener(new OnItemClickListener() { @SuppressWarnings("deprecation") public void onItemClick(AdapterView&lt;?&gt; parent, View v,final int position, long id) { Log.d(TAG, "got in onItemClick of Item "+position); System.gc(); Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; String[] cols = new String[]{ MediaStore.Video.VideoColumns._ID, MediaStore.Video.VideoColumns.DISPLAY_NAME, MediaStore.Video.VideoColumns.DATA}; Cursor c; c = managedQuery(uri, cols, null, null, MediaStore.Video.VideoColumns.DATE_TAKEN); c.moveToFirst(); int mPath = c.getColumnIndexOrThrow(MediaStore.Video.VideoColumns.DATA); c.moveToPosition(position); String filename = c.getString(mPath); Log.d(TAG, "video position is " + position+ " video path is " + filename); Intent intent = new Intent(Isabella_galleryActivity.this, ViewVideo.class); intent.setDataAndType(uri, "video/*"); intent.putExtra("videofilename", filename); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); gv.setOnItemLongClickListener(new OnItemLongClickListener() { //@Override public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View v, int position, long id) { Log.d(TAG, "got in onItemLongClick of Item "+position);// TODO Auto-generated method stub //del_image = (ImageView)findViewById(R.id.video_delet_image); //del_image.setVisibility(View.VISIBLE); //gv.setClickable(false); div.setVisibility(View.VISIBLE); div.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.w(TAG, "deleting the video"); } }); return false; } }); } </code></pre> <p>please help me..If any one knows the answer..Thanks in advance</p>
android
[4]
992,385
992,386
How to record audio/voice in background contineously in android?
<p>As I want to record audio in backgroung i use service..But I am not able to record the audio in service.</p> <p>I tried same code in Activity it works for me. but how to do audio recording in background when voice /speech is input that means audio recording should start if there is voice input and that should be in background...?</p>
android
[4]
1,892,381
1,892,382
Is the first operation supposed to be faster and if so then Why?
<p>Is the first opeartion faster than the second one ?</p> <pre><code> u+= (u &lt;&lt; 3) + (u &lt;&lt; 1) //first operation u+= u*10 //second operation </code></pre> <p>Basically both of them does the same thing that is <code>u= u+(10*u)</code> But i came to knew that first operation is faster than second . Does the cpu time when operation + different from * . <code>Is multiplication by 10 actually equivalent to 10 addition operations being performed ?</code></p>
c++
[6]
3,418,359
3,418,360
How to set the value for an HTML element from external javascript
<p>I'm using an external javascript file (eg:<code>myjs.js</code>) with function <code>setval()</code> to set the <code>innerText</code> property of a HTML lable.</p> <p>I have PHP page with <code>&lt;lable id="abc"&gt;&lt;/lable&gt;</code> and I have included <code>myjs.js</code> in <code>&lt;head&gt;</code> section. <code>myjs.js</code> is included in <code>&lt;head&gt;</code> section of one more PHP file and I'm calling <code>setval()</code> from this file, so when it runs it must set the <code>innerText</code> of lable in the first PHP file.</p> <p>Is it possible to achieve? Any suggestions are greatly appreciated. I hope I made question clear.</p> <p>Thanks</p>
javascript
[3]
5,151,836
5,151,837
Aborting Execution, If Filename is changed
<p>This was A Question Asked by my teacher. "How Would You Stop Your Script From Executing, IF Filenamed is renamed by User."</p> <p>I had sumthing this idea in my mind.</p> <pre><code>#consider the name of the script to be myscript.py import os signal = 0 while 1: if "myscript.py" not in os.listdir("."): signal = 1 else: if signal: break else: #do the requirements </code></pre> <p>But then He said, whatif, the user has a file named "myscript.py" already in the directory, and he changed the name of the script, the script would run well. And there I got stuck.</p> <p>I am using python2.7, OS: Windows, Allowed To use Any external Libraries if required, Any suggestions?</p>
python
[7]
5,752,352
5,752,353
Intent and string array
<p>I need pass a string array from AlarmReceiver.class to Notify.class but the string is always "null". Now, is a problem about intent within AlarmReceiver?</p> <pre><code>public class AlarmReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { [...] Intent notificationIntent = new Intent("com.example.myapp", null, context, Notify.class); notificationIntent.putExtra("notify", not1[x]); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); </code></pre> <p>Notify class:</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); Intent notificationIntent = getIntent(); String[] message = notificationIntent.getStringArrayExtra("notify"); Toast toast6=Toast.makeText(this,""+message,Toast.LENGTH_LONG); toast6.show(); </code></pre>
android
[4]
1,214,489
1,214,490
Javascript Namespace Help
<p>I have a pretty big Javascript script with loads of global variables &amp; functions in it. Then a piece of code that calls one function from this js file: myfunc();</p> <p>Ok, now I have cloned this script and modified some functionality, all function prototypes and variables are named the same in both scripts. So now I have two scripts loaded and one call to myfunc(), now we have a clash because there are loads of global variables with the same names and two myfunc()s.</p> <p>What I want to do is wrap this cloned script in a namespace, so that I can modify the original call to: clone.myfunc() which will call the new function, but I also want myfunc() to just refer to the original script. In other words I can't touch the original script (no permissions) and I want to be able to use both the clone and the original at runtime.</p> <p>This is the script im cloning: <a href="http://pastebin.com/6KR5T3Ah" rel="nofollow">http://pastebin.com/6KR5T3Ah</a></p> <p>Javascript namespaces seem quite tricky this seems a nice namespace method:</p> <pre><code>var namespace = { foo: function() { } bar: function() { } } ... namespace.foo(); } </code></pre> <p>However that requires using an object, and the script (as posted above) is humongous at nearly 4000 lines, too much to objectize I think?</p> <p>Anyone know a better solution to avoid namespace pollution, with one script I cant touch and one being a clone of that script. Just so I can call myfunc() and clone.myfunc() and all global variables will behave in their respected scope.</p> <p>It's either that, or I go through and modify everything to have unique names, which may take a lifetime</p> <p>This is a Mozilla addon if it helps context wise.</p> <p>Thanks.</p>
javascript
[3]
4,692,039
4,692,040
How do I exclude elements that have a "target" defined (for opening external links in new windows)?
<p>I'm not sure if this script is working properly. I do not want to overwrite existing targets. How can I adjust this to exclude links that already have a target defined?</p> <pre><code>$("a[@href^='http://']").not("[@href*='" + window.location.host + "']").attr('target','_blank'); </code></pre>
jquery
[5]
2,929,897
2,929,898
How to call overriden methods in all derived classes
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5644338/how-to-force-child-same-virtual-function-call-its-parent-virtual-function-first">How to force child same virtual function call its parent virtual function first</a> </p> </blockquote> <p>I have a class hierarchy where each derived class overrides a given virtual function and starts its implementation by calling the one in its parent class. The goal is to have each of the derived implementation to be executed, but I do not like the way I do it.</p> <p>For example, I have this class:</p> <pre><code>class base { public: void do_stuff() { do_something(); } virtual void do_something() { } }; </code></pre> <p>Then I derive this class on several levels:</p> <pre><code>class derived_10: public derived_9 // which inherit from derived_8 and so on until derived_0 // which inherit from base { public: virtual void do_something() { // this will also call derived_8::do_something() and so on // until base::do_something() derived_9::do_something(); // then, some stuff } }; </code></pre> <p>I'm looking for a solution that will make sure that all derived_x::do_something() will be called in sequence when base::do_stuff() is called, without having to expect the derived classes to do this themselves. Do you have an idea of the best way to get this behavior ?</p>
c++
[6]
3,548,594
3,548,595
link detection?
<p>I asked a question yesterday about a problem that Im having with a program that Im trying to build <a href="http://stackoverflow.com/questions/6331409/having-problems-passing-array-values">having problems passing array values </a>. </p> <p>the problem that I am having is that I have an array named $images() that for some bizarre reason wont accept values, however last night as was playing around with the program something very bizarre occurred.</p> <p>one of the links actually worked, even though the array was still somehow empty? this has led me to wonder if the pages somehow have a way of detecting if the links are being processed and somehow disable link downloading perhaps? </p> <p>obviously I cant confirm this, and is nothing more than a conspiracy at this point but is this even possible? thanks for your help guys! </p>
php
[2]
831,878
831,879
How can I retrieve a file from my app folder in android?
<p>I want to send the database file of my app via email. This makes my it easier to help in a error case. For that I need to retrieve the installation folder of my app. How can I achieve this so that i can send my db which is place here APP-FOLDER\databases\mydb.db</p> <p>Thanks</p>
android
[4]
5,587,324
5,587,325
How can i take section as a button and clicking that button should display no of rows for that section?
<p>For Ex:I have 5 Section each section should be displayed as Button where it also have button title to display by pressing that button it should display no. of rows for ex: 5 rows. it is different for every section.each functionality should be done by TableView Only so how it's possible?Please guide me on solving this problem.</p>
iphone
[8]
3,097,343
3,097,344
linkShare integration in iPhone
<p>I want to integrate linkShare affiliated link into the my iPhone application. </p> <p>I have already created the links for the applications which I want to sell from within my application using my linkShare account.</p> <p>But the only problem is how would I get the logo, name and description of those applications. Is there any kind of iTunes or other API available?</p> <p>Thanks in Advance.</p>
iphone
[8]
1,918,293
1,918,294
How to access the ID of an HTML element
<p>How to get the value from "id" instead of from "value" and show it on the page? Now I have <code>Holzart:3</code>, I want to have <code>Holzart:Lärche</code>.</p> <p>I have this function:</p> <pre><code>$(document).ready(function() { $("input[name='holzart']").click(function() { PobierzWartosc2(); }); }); function PobierzWartosc2() { $('#aus2').html(''); $("input[name='holzart']").each(function() { if (this.checked == true) { $('#aus2').append('Holzart:'+ $(this).val()) } }); } </code></pre> <p>and this HTML:</p> <pre><code>&lt;tr&gt;&lt;td&gt;&lt;label&gt; &lt;input type="radio" name="holzart" value="3" id="Lärche" &gt;Lärche&lt;/label&gt;&lt;/td&gt;&lt;/tr&gt; </code></pre>
jquery
[5]
1,662,263
1,662,264
making transperent background
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/54926/make-a-jpanel-not-draw-its-background-transparent">Make a JPanel not draw its background (Transparent)</a> </p> </blockquote> <p>i want to make my application background as transperent.how to do this?</p>
java
[1]
5,913,278
5,913,279
Jquery add percent sign to input box
<p>I'd like to have an input box that automatically adds a visible percent sign to the user when entering numbers (not just recognizes it as a percent when submitting). Thus, a user hits "2" and sees "2%"</p> <p>I'm assuming one could use Jquery to do this fairly easily, but I have no idea how! Any ideas?</p> <p>Thanks everyone.</p>
jquery
[5]
3,144,753
3,144,754
How to know which instruction taking the longest time to finish ? (to increase my program performance)
<p>I need to know how can I get every instruction's duration so I can maintain the code to increase the performance of my program .</p>
c#
[0]
2,785,180
2,785,181
Is there any reason to put code in the code behind rather than in the aspx file?
<p>Any time I need to write code I almost always put it in the code behind file. For some reason this has always seemed like the "right" way to write code.</p> <p>Based on most of the examples I see online, a lot of other people choose to write code this way too, but it seems like putting your code in the aspx file allows you to do all the same stuff as well as offering a few advantages. </p> <p>Top of the list being:</p> <ul> <li>Easier to make changes since no recompile.</li> <li>You have access to all code if you can't find the project in source control (this recently happened to me).</li> </ul> <p>Is there any benefit to having code in a code behind file? Is there any disadvantage to putting code in your aspx file?</p>
asp.net
[9]
3,058,561
3,058,562
I just started learning the syntax of c++. What now?
<p>I more or less know the syntax of C++, but when I start to write a program, I have nothing to write, I am blank. The thing is I knew the syntax of C as well and I didn't know how to write programs in that either. Though I could understand the written answers of almost anything.</p> <p>So, my question here is how do I start writing my own programs or how do I put my thoughts on any program using any programming language?</p>
c++
[6]
5,543,308
5,543,309
Fancybox gallery with image map
<p>I am trying to create a fancybox gallery using image maps. The html/iframes open but I can't get the gallery working.</p> <p>I tried:</p> <pre><code>&lt;area class="fancybox" data-fancybox-group="gallery" </code></pre> <p>and also tried:</p> <pre><code>&lt;area class="fancybox" rel="gallery" </code></pre> <p>However, the previous and next buttons are not appearing.</p> <p>Below is my javascript:</p> <pre><code> $('map &gt; area.fancybox').click(function(e) { e.preventDefault(); var url = $(this).attr('href'); $.fancybox({ 'href' : url, 'type' : 'iframe' }); }); </code></pre> <p>I noticed it does seem to work if I manually add my gallery as a group, but then I will have to do a bit of manipulation to get the gallery order working?</p> <pre><code>$('map &gt; area.fancybox').click(function(e) { e.preventDefault(); var url = $(this).attr('href'); console.log($(this).attr('rel')); $.fancybox([{ 'href' : url, 'type' : 'iframe' }, { 'href' : 'class.cfm', 'type' : 'iframe' }, { 'href' : 'explore.cfm', 'type' : 'iframe' }] ); }); </code></pre>
jquery
[5]
2,755,115
2,755,116
How do you create a link from data retrieved from the database
<p>I have products stored in a database. These items have ID, NAME, QUANTITY, and STOCK_NUMBER fields. I want to make an <code>href</code> for all of the data in the database:</p> <pre><code>$Result=mysql_query("SELECT * FROM Products"); while($row=mysql_fetch_array($Result)){ href ..... } </code></pre> <p>I want the result like this </p> <p><code>item_id=1&amp;name_1_tv&amp;quantity_1=2&amp;stock_number_1=1411 &amp;item_id=2&amp;name_2_mobile&amp;quantity_2=5&amp;stock_number_2=5894 &amp;item_id=3&amp;name_3_radio&amp;quantity_3=2&amp;stock_number_3=18541 &amp;item_id=4&amp;name_4_tv&amp;quantity_4=2&amp;stock_number_4=1025 &amp;item_id=5&amp;name_5_computer&amp;quantity_5=1&amp;stock_number_5=1455 &amp;item_id=6&amp;name_6_cd&amp;quantity_6=2&amp;stock_number_6=5888</code></p> <p>all these under the link</p>
php
[2]
4,290,450
4,290,451
Removing a string in javascript
<p>I have a URL say <a href="http://www.google.com/?v=as12&amp;&amp;src=test&amp;img=test" rel="nofollow">dummy URL</a></p> <pre><code>http://www.google.com/?v=as12&amp;&amp;src=test&amp;img=test </code></pre> <p>Now I want to remove the &amp;src=test&amp; part alone.I know we can use indexof but somehow I could not get the idea of getting the next ampersand(&amp;) and removing that part alone. Any help.The new URL should look like</p> <p><a href="http://www.google.com/?v=as12&amp;img=test" rel="nofollow">http://www.google.com/?v=as12&amp;img=test</a></p>
javascript
[3]