Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
3,302,027
3,302,028
Exam sample: why is this variable in C++ producing such an output?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points">Undefined Behavior and Sequence Points</a> </p> </blockquote> <p>Working out the below code by hand:</p> <pre><code>#include &lt;stdio.h&gt; int func (int a, int b) { static int c = 1; return a + b * (c *= -1); } int main () { int a = 2, b = 3; int c = func(a, b); a *= a++; b *= ++b; printf("%d %d %d %d\n", a, b, c, func(a, b)); } </code></pre> <p>I calculate the variables in <code>printf()</code> to be as follows:</p> <pre><code>a = 5, b = 16, c = -1, func(a, b) = -11 </code></pre> <p>however my compiler tells me the last value is in fact 21.</p> <p>Output:</p> <pre><code>a = 5, b = 16, c = -1, func(a, b) = 21n </code></pre> <p>I'd calculate my value as <code>(16*-1) + 5</code></p> <p>Can anyone tell me where I have gone wrong?</p>
c++
[6]
3,462,753
3,462,754
Build a road network out of shapefile coordinates
<p>I want to build a road network from the ESRI shapefiles. I am able to read the data from the .shp files but unable to proceed any further with building the road network out of the shapefile coordinates and display it on the screen. I am not that expirienced in Java. I would appreciate any kind of suggestions on how should i proceed now.</p>
java
[1]
5,442,878
5,442,879
toggle using pure javascript
<pre><code>&lt;script&gt; function toggleMenu() { var thisMenu = document.getElementById(id).getElementsByTagName('ul')[0]; if( thisMenu.style.display == 'block' ) { thisMenu.style.display = 'none'; } else { thisMenu.style.display = 'block'; } return thisMenu; } &lt;li class="NavLinks test2" id="menuIteam"&gt; &lt;a onclick="toggleMenu('menuIteam');"&gt;Tutorial&lt;/a&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://www.google.com"&gt;google&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.yahoo.com"&gt;yahoo&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/script&gt; </code></pre> <p><em><strong></em>**</strong><em>description</em><strong><em>*</em>**<em>*</em>**<em>*</em>*</strong></p> <p>onClick on Tutorial hide's the submenu iteams but if i click on Tutorial and hover over submenu iteams and hovers out the iteam list iteam are not hiding. Please let me know if my code needs to modify. Thank you in andvance.</p>
javascript
[3]
3,749,484
3,749,485
Android wireless display
<p>I'm a fairly new android programmer and I've been having a rummage online about displaying an android screen over the network. I know it is possible to mirror the display using apps such as MirrorOp Sender. What I'm looking for is the android device to display one thing on the android device itself and something completely different on a screen elsewhere. So far my search results haven't gotten me very far. </p> <p>So really what I want to know is, are there currently apps out there that can do this and are there any libraries out there that I could use to help me implement this? I have a few ideas on how I would go about implementing this but there is no point in me writing something from scratch if it has already been done.</p>
android
[4]
2,730,078
2,730,079
Trying to integrate Javascript range slider into my website but not sure where to start
<p>I am trying to build a little test shell for my website using Javascript. What I have at the moment is a normal website. PHP/HTML with an SQL backend.</p> <p>What I'd like is a simple Javascript feature whereby the user has a single slider object and can use this object to set the upper and lower limit on a number of variables, which will be determined by a drop down box just underneath the slider.</p> <p>Aside from this, I'd just like a number of checkboxes which dictate which products are displayed (i.e if I'd like food but not drink, the food checkbox would be ticked!).</p> <p>I'm not expecting anyone on SO to do this for me, of course, but I would like to find some specific areas I could go to learn how to do this, and google is failing me in this regard. I will then begin working/editing this post to show my code/ask for help.</p> <p>Can anyone help please?</p>
javascript
[3]
2,394,137
2,394,138
Is it possible to pass an "unnamed" variable to a function?
<p>Let's say there is the following function:</p> <pre><code>void SetTheSize(const SIZE *size) { ... } </code></pre> <p>Is there any way to call that function without specifying the SIZE variable? e.g.,</p> <pre><code>SetTheSize((const SIZE*)&amp;{10, 10}); </code></pre> <p><strong>edit:</strong> I should had mentioned that the SIZE is a struct, without SIZE(int, int) constructor.</p>
c++
[6]
4,053,109
4,053,110
How to set up Navigation Controller -> Root View in code (iPhone SDK)
<p>I need the ability to bypass the default RootViewController you get when you pick a navigation controller project type in XCode. I need this because I want to go down a different path depending on whether the app has been configured (sign up/login screens if not). Could someone point me to an example where in the AppDelegate the NavigationController is hooked to another controller (in this case SignupController) via code?</p> <p>Here is what I have, but it doesn't let me change the title. And in the MainWindow.xib, it's still tied into the default RootViewController. </p> <pre><code>(void)applicationDidFinishLaunching:(UIApplication *)application { [[UIApplication sharedApplication] // if no config, load up the SignupController SignupController* signupController = [[SignupController alloc] initWithNibName:@"SignupController" bundle:nil]; [window addSubview:[navigationController view]]; [window makeKeyAndVisible]; </code></pre>
iphone
[8]
5,647,333
5,647,334
Unwanted carriage return when getting input from terminal
<p>I've just started learning Java and have come across a little quirk I'm not sure how to solve. It's the same as <a href="http://stackoverflow.com/questions/1123869/eliminating-the-new-line-when-using-bufferedreader-method-to-get-user-input-using">this</a> question but the solution there doesn't work here. The problem there was thought to be the result of something to do with Netbeans, and compiling the code form the command line may solve the problem, but I <strong>am</strong> compiling and running from the command line.</p> <p>Basically, when I run the following code (snipped for brevity)</p> <pre><code> System.out.println("Number: "); line = in.readLine(); </code></pre> <p>I get the following output:</p> <pre><code>Number: //Input cursor is found here </code></pre> <p>I'm running the code using the Gnome Terminal that ships with Ubuntu. Does anyone know what's causing this?</p>
java
[1]
4,765,403
4,765,404
How to display only those columns in the gridview according to which dropdownlist the user selects
<p>For example i have three dropdownlists and the the user selects Say Name and PIN dropdownlist i want results that match the two to be displayed not any other what should I do?</p> <p>Please help! :/</p> <p><strong>EDIT:</strong></p> <p>What i want to do is based on what dropdown list the user makes the selection from i want to display only those columns in the gridview on the next page and two fields name and pin corresponding to those rows will always be displayed ... if i try permutaion combinations i would have to make 81 sql queries. What should I do?</p>
asp.net
[9]
4,642,360
4,642,361
How to save a state of a variable in android app and use it
<p>I have an android app which was built on eclipse. What i am currently doing is going through set of question in xml file randomly to ask. Xml file looks like this:</p> <pre><code>&lt;item&gt; &lt;ques&gt;&lt;/ques&gt; &lt;option1&gt;&lt;/option1&gt; &lt;option2&gt;&lt;/option2&gt; &lt;option3&gt;&lt;/option3&gt; &lt;ans&gt;&lt;/ans&gt; &lt;level&gt;1&lt;/level&gt; &lt;/item&gt; &lt;item&gt; &lt;ques&gt;&lt;/ques&gt; &lt;option1&gt;&lt;/option1&gt; &lt;option2&gt;&lt;/option2&gt; &lt;option3&gt;&lt;/option3&gt; &lt;ans&gt;&lt;/ans&gt; &lt;level&gt;1&lt;/level&gt; &lt;/item&gt; &lt;item&gt; &lt;ques&gt;&lt;/ques&gt; &lt;option1&gt;&lt;/option1&gt; &lt;option2&gt;&lt;/option2&gt; &lt;option3&gt;&lt;/option3&gt; &lt;ans&gt;&lt;/ans&gt; &lt;level&gt;2&lt;/level&gt; &lt;/item&gt; </code></pre> <p>so on.... </p> <p>Right now i am selecting question from level one randomly. Like there are 50 question in level 1 and 50 in level 2. I want to select question in order now. Like start from the top to bottom. Like if user A logs in plays the game he is being asked question a and b from level 1. Then he closes the game and logs back again so he should see c and d now.</p> <p>My problem is how can this state be saved in android? Is there a easy way to do this?</p>
android
[4]
321,752
321,753
jquery or php detect external site length
<p>This might be pushing the limits here.</p> <p>I iframe some external websites into one of my own websites. </p> <pre><code>&lt;iframe style="margin-top:20px;width:99%;height:600px;" src="http://www.website.com/"&gt;&lt;/iframe&gt; </code></pre> <p>This works just fine and dandy. However, sometimes the sites are much longer than 600px. Which is not to be unexpected.</p> <p>Is there a way to detect the height, or some method of length detection that I could work with? </p> <p>I don't expect this is possible, but I thought I'd ask.</p>
jquery
[5]
264,961
264,962
display data in tree structure using php
<p>I want to display data in tree strucure using php. The data should be read from xml file. The root direcory information will be in 1st file(ex level0.xml).the sub directories of root will be in level1.xml file and so on.I need to get the values from these file and display in tree structure. When i click the directory it should read the next level file &amp; display its sub directories and files. How can i do this? Is there any other approach or language to display?</p>
php
[2]
1,344,793
1,344,794
String array to notepad
<p>I have a string array in C# and I intend to copy it in a notepad so that each row would be located in a line. What should I do?</p>
c#
[0]
5,326,274
5,326,275
Use of google voice to translate voice to text
<p>is there any API or anything else that will help me out in translating voice to text using google voice for that in android phone.</p>
android
[4]
166,738
166,739
Javascript - Masking a password on a JS alert box
<p>I have the following</p> <pre><code>var validate=prompt("Enter your PIN","Enter your PIN"); </code></pre> <p>This works fine except it shows the password when typing it.</p> <p>Is there any way to mask the password being entered?</p> <p>Cheers,</p>
javascript
[3]
4,715,997
4,715,998
PHP 'global variable'
<p>I am creating a game in PHP, and am having a problem with global variables. Depending on which button is pressed in my HTML page, a corresponding PHP script is run and a function is called depening on the <code>isset</code> function.</p> <p>My question is this: I want to keep a score variable, and I would like to have access to this variable in the future after multiple <code>post</code> statements have been issued.</p> <p>I have tried using the <code>global</code> keyword but this does not seem to do what I am expecting.</p> <p>Can I please have some help with this?</p>
php
[2]
4,466,544
4,466,545
How to check if an array has an element at the specified index?
<p>I know there is array_key_exists() but after reading the documentation I'm not really sure if it fits for this case:</p> <p>I have an $array and an $index. Now I want to access the $array, but don't know if it has an index matching $index. I'm not talking about an associative array, but an plain boring normal numerically indexed array.</p> <p>Is there an safe way to figure out if I would really access an $array element with the given $index (which is an integer!)?</p> <p>PHP may not care if I access an array with an index out of bounds and maybe just returns NULL or so, but I don't want to even attempt to code dirty, so I <em>want</em> to check if the array has the key, or not ;-)</p>
php
[2]
1,454,046
1,454,047
Color slider puzzle
<p>I was going through the iPhone samples available <a href="http://hoangtuanonline.com/mad/iPhone%20documents/books/object-c%20books%3B%20iphone%20books/Iphone%20Books/Iphone%20DevCenter%20&amp;%20GL%20Specs/iPhone%20Sample%20apps.pdf" rel="nofollow">here</a>.</p> <p>There is one sample code named <strong><em>Color Slider Puzzle</em></strong>, but the link to the download is not working.</p> <p>Does anyone have a working download link to this sample code?</p>
iphone
[8]
4,197,047
4,197,048
C++ XML-RPC Calling
<p>I haven't seen any documentation for calling XML-RPC by inputing certain strings and get respone of some strings in c++ by connecting to an XML API. This is a documentation provided by the server. I can't figure out how to do this</p> <pre><code> A client can interact with a Pandorabot by POST'ing to: http://www.pandorabots.com/pandora/talk-xml The form variables the client needs to POST are: botid - see H.1 above. input - what you want said to the bot. custid - an ID to track the conversation with a particular customer. This variable is optional. If you don't send a value Pandorabots will return a custid attribute value in the &lt;result&gt; element of the returned XML. Use this in subsequent POST's to continue a conversation. This will give a text/xml response. For example: &lt;result status="0" botid="c49b63239e34d1d5" custid="d2228e2eee12d255"&gt; &lt;input&gt;hello&lt;/input&gt; &lt;that&gt;Hi there!&lt;/that&gt; &lt;/result&gt; The &lt;input&gt; and &lt;that&gt; elements are named after the corresponding AIML elements for bot input and last response. If there is an error, status will be non-zero and there will be a human readable &lt;message&gt; element included describing the error. For example: &lt;result status="1" custid="d2228e2eee12d255"&gt; &lt;input&gt;hello&lt;/input&gt; &lt;message&gt;Missing botid&lt;/message&gt; &lt;/result&gt; </code></pre>
c++
[6]
4,117,104
4,117,105
Best star rating solution for PHP
<p>I'm wondering what the best and most efficient way to write up the following PHP code would be?</p> <pre><code> if ($av == 1) echo '/images/1-star.png'; if ($av &gt; 1 &amp;&amp; &lt; 2) echo '/images/1-half-star.png'; if ($av == 2) echo '/images/2-star.png'; if ($av &gt; 2 &amp;&amp; &lt; 3) echo '/images/2-half-star.png'; </code></pre> <p>Following this same pattern up to 5 stars.</p>
php
[2]
1,867,866
1,867,867
Generate a random string with a specific bit size in java
<p>How do i do that? Can't seems to find a way. Securerandom doesn't seems to allow me to specify bit size anywhere</p>
java
[1]
3,549,304
3,549,305
Detect fieldset on mouse click JQUERY
<p>i'm trying to add a single condition to the following Javascript that will stop the IF statement below eveluating to TRUE when user clicks inside a fieldset on the page.</p> <p>I have tried allsorts but i'm guessing, I just tried adding " &amp;&amp; !(e.target.isFieldSet))" but no joy. I've tried searching the web, anyone any ideas?</p> <pre><code>$(function() { $('tr').live('click', function(e) { //if not clicking an anchor tag or imag then assume user wants to go to details page if ((!$(e.target).is('a')) &amp;&amp; (!$(e.target).is('img')) &amp;&amp; (!$(e.target).is('th')) &amp;&amp; !(e.target.isTextEdit)) { window.location = $("#AbsolutePath").val() + 'Waste.mvc/Details/' + $(this).attr('rowid'); } }); }); </code></pre>
jquery
[5]
4,054,964
4,054,965
Uncheck Succeeding Radio Buttons upon clicking a radio button
<p>I'm building a conditional logic survey.</p> <p>I want to uncheck all the radio buttons present after the radio button I just click - even those belonging to other radio groups. In short - empty the form the point at which I click but keep the rest of the earlier part of the form intact.</p> <p>Is there any way to do this with jQuery? Something automatic and fast?</p>
jquery
[5]
1,631,653
1,631,654
ListBox problem in ASP.NET
<p>May be it's the same question i have i asked before but the issue is the same and i didn't find any resolution so i have to write it again with the expectation that it would be solved this time. My question is i am using two list boxes and one list box is populated by putting the list the list item tag in listBox1 on aspx page and i want to implement functionality like add and remove between two list boxes i mean removing an item from listBox1 should be added to second and removing an item from second should be added to first. While i tried my own but the problem is that on post back it come to same condition. I have implemented the add remove functionality by using the jQuery but the problem is that on post back it come to same condition so i want a good solution for this ow should i implement this so that on post back it retain it's value please ris me off from this issue. I found some solutions for this on Google that i should make some other class which will extend ListBox base class but i couldn't understand that and how should i code for that so please explain me that code if possible.</p>
asp.net
[9]
2,081,707
2,081,708
Using Python to convert color formats?
<p>I'm working on a Python tool to convert image data into these color formats:</p> <ul> <li>RGB565</li> <li>RGBA5551</li> <li>RGBA4444.</li> </ul> <p>What's the simplest way to achieve this?</p> <p>I've used the <a href="http://www.pythonware.com/products/pil/" rel="nofollow">Python Imaging Library (PIL)</a> frequently. So I know how to load an image and obtain each pixel value in RGBA8888 format. And I know how to write all the conversion code manually from that point.</p> <p>Is there an easier way? Perhaps some type of 'formatter' plugin for PIL?</p> <p>Does PIL already support some of the formats I'm targeting? I can't ever figure out which formats PIL really supports without digging though all of the source code.</p> <p>Or is there a better library than PIL to accomplish this in Python?</p> <p>Any tips would be appreciated. Thanks!</p>
python
[7]
1,841,480
1,841,481
can not load my image into a bitmap class in android
<p>hi i have a problem with a bitmap and a picture located here:</p> <pre><code>file:///mnt/sdcard/Android/data/com.dev.app/files/Pictures/20120924-092226.jpg </code></pre> <p>so i have a string with this url (the the file exists!)</p> <p>now i need to get a bitmap, so i do:</p> <pre><code>String str = "file:///mnt/sdcard/Android/data/com.dev.app/files/Pictures/20120924-092226.jpg"; Bitmap b = BitmapFactory.decodeFile(str); </code></pre> <p><strong>but b is always null. and i dont know why.</strong></p> <p><strong>EDIT</strong>: i create the file before with a code like this:</p> <pre><code>String filename = DateFormat.format("yyyyMMdd-hhmmss",Calendar.getInstance().getTime()) + ".jpg"; Uri imageUri = helper.createImageDestinationUri(null, filename); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, requestCode); </code></pre>
android
[4]
4,307,588
4,307,589
Dynamically Remove Elements Jquery .click not Firing
<p>I am writing a script to dynamically create and remove elements, adding the elements works fine. But the #removeText function is not firing, I assume something because it was created after the page had finished loading or something. How can I get the #removeText click function to work if it has been dynamically created? </p> <pre><code>var i = 0; $('#addText').on('click', function() { var div = $("#addText").closest('div').attr('id'); $("&lt;p&gt;&lt;input type=\"text\" id=\"text" + i + "\" placeholder=\"Type something…\"&gt;&lt;a href=\"#\" id=\"removeText\"&gt;Remove&lt;/a&gt;&lt;/p&gt;").appendTo('#' + div); }); $('#removeText').on('click', function() { console.log(1); }); </code></pre>
jquery
[5]
3,775,708
3,775,709
Javascript : add string to iframe with window.opener form popup
<p>I use this code for add string to element of parent windows form popup :</p> <pre><code>window.opener.document.getElementById('myid').innerHTML += 'string'; </code></pre> <p>Now I want to add string to element of iframe form popup.Both of iframe and parent is in the same domain. I try this code but not work:</p> <pre><code>parent.myframename.window.opener.document.getElementById('iframeelementid').innerHTML += 'string'; </code></pre> <p>What is wrong? Is there any way to do this?</p> <p>Thanks for any help.</p> <p><em><strong></em>* UPDATE <em>*</em></strong> </p> <p>This is my complete code. Main page:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function myPopup() { window.open( "pop.htm", "myWindow", "status = 1, height = 180px, width = 330px) } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;textarea id="input"&gt;&lt;iframe src="frame.html" name="myframe"&gt;&lt;/iframe&gt; &lt;/textarea&gt; &lt;a href="" onclick="myPopup()"&gt;Popup&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and pop.htm:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script&gt; function insert() { parent.myframe.window.opener.document.getElementById('inframe').innerHTML += 'asasasas'; window.close(); return false; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="button" id="insert" onclick="insert()" value="insert" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and iframe.html:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;span id="inframe"&gt;&lt;/span&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
5,600,105
5,600,106
How do I open a website in browser through JAVA without having the browser open a new tab
<p><strong>Introduction</strong></p> <p>I am making a proxy server in java. Whenever the user enters an unknown host (URL) in the browser, the proxy server handles <code>UnknownHostException</code> by executing the code below:</p> <pre><code>try { Process p=Runtime.getRuntime().exec("cmd /c start http://www.mysite.com/unknownhosterror.htm"); } catch(IOException io) { System.out.println("Error"); } </code></pre> <p>What these lines of code do is to display an html file containing "This page could not be displayed." whenever the user entered a non-existing URL.</p> <p><strong>Problem</strong></p> <p>The code above opens a new tab and displays the content of www.mysite.com/unknownhosterror.htm. What I want is to redirect to it. </p> <p>For example, I wrote www.nosuchsite.com in the URL bar. Suppose there is no such site, it will automatically redirect to www.mysite.com/unknownhosterror.htm and display "This page could not be displayed.".</p> <p>How can I do this?</p> <p><em>EDIT</em> NOTE: I do not use <code>Servlet</code>. </p>
java
[1]
3,342,600
3,342,601
What is the difference between new Object and new Object() in JavaScript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3034941/new-myobject-vs-new-myobject">new MyObject(); vs new MyObject;</a> </p> </blockquote> <p>In some articles I seen following statement to create new object in JavaScript:</p> <pre><code>var myObject = new Object; </code></pre> <p>and at some sites:</p> <pre><code>var myObject = new Object(); </code></pre> <p>In there is any difference between two statements or one is just shorthand?</p>
javascript
[3]
4,278,983
4,278,984
Replace method doesn't work
<p>I want to replace the smart quotes like <code>‘</code>, <code>’</code>, <code>“</code> and <code>”</code> to regular quotes. Also, I wanted to replace the <code>©</code>, <code>®</code> and <code>™</code>. I used the following code. But it doesn't help. Kindly help me to resolve this issue.</p> <pre><code>str.replace(/[“”]/g, '"'); str.replace(/[‘’]/g, "'"); </code></pre>
javascript
[3]
4,184,432
4,184,433
Populating ComboBox and CheckedListBox from Database, C#
<p>Ok, as the title says, I'm trying to populate a combobox from a database, then change the contents of the checkedlistbox based on the change in the combobox. The problem here is, I'm about as lost as I could be. I decided to go with an access database (db1.mdb, in the same dir as the exe). The primary data table Table1 has the names of the items that should go in the combobox (item1, item2, item3). Then, I have separate tables for each value(tableitem1, tableitem2, tableitem3), and the listbox will be using these one at a time, listing the "Item Name" fields, of which there are varying amounts in each table. After checking off the options in the checkedlistbox, I need to grab the values from the other columns in that table "value1 and value2" from the database table associated with the checked list box. I've been programming for about 5 years, but have never needed to manipulate a database before, so I'm totally lost.</p>
c#
[0]
2,567,048
2,567,049
Inner FutureTask in Java
<p>I try to implement an inner method in order to execute the following code in a new thread</p> <pre><code>MyPojo result = null; final MyPojo result2 = result; FutureTask&lt;MyPojo&gt; runnableTask = new FutureTask&lt;MyPojo&gt;( new Runnable() { BindJSON&lt;MyPojo&gt; binding; // Make the URL at which the product list is found String sourceURLString = "http://www.....ca/files/{CAT_ID}.json"; @Override public void run() { sourceURLString = sourceURLString.replace("{CAT_ID}", catId); binding = new BindJSON&lt;MyPojo&gt;(); result2 = binding.downloadData(sourceURLString, MyPojo.class); } }, result2); runnableTask.run(); </code></pre> <p>So, now I take an error which says: The final local variable result2 cannot be assigned, since it is defined in an enclosing type. I take a look at this answer: <a href="http://stackoverflow.com/questions/5997953/cannot-refer-to-a-non-final-variable-i-inside-an-inner-class-defined-in-a-differ">Cannot refer to a non-final variable i inside an inner class defined in a different method</a> but it didn't work for me. What should I do to make this work?</p>
java
[1]
5,858,878
5,858,879
How come when I use htmlentities() on my wamp server it works well, but has weird characters on someone else's server?
<p>I'm pulling an XML feed that doesn't specify the encoding. I can't change this on the feed. When I use htmlentities(), it gives me a proper output for certain characters on my WAMP server, but when I upload it to another server, it seems like the encoding is incorrect for certain characters, like open and close double quotes (not just " but the one that looks like 66 and 99)</p>
php
[2]
5,633,173
5,633,174
Most elegant way to modify Python list elements inplace
<p>I have a 2D list that looks like this:</p> <pre><code>table = [['donkey', '2', '1', '0'], ['goat', '5', '3', '2']] </code></pre> <p>I want to change the last three elements to integers, but the code below feels very ugly:</p> <pre><code>for row in table: for i in range(len(row)-1): row[i+1] = int(row[i+1]) </code></pre> <p>But I'd rather have something that looks like:</p> <pre><code>for row in table: for col in row[1:]: col = int(col) </code></pre> <p>I think there should be a way to write the code above, but the slice creates an iterator/new list that's separate from the original, so the references don't carry over. </p> <p>Is there some way to get a more Pythonic solution?</p>
python
[7]
2,296,961
2,296,962
how to get respected person details saved in arrays from selected value in table view
<p>i am having 3 arrays with info regarding peoples.</p> <p>one array is with name,second array with email,third array with phone number.</p> <p>eg:{jon,Willems...},{jon@example.com,Willems@example.com...},{123456,123456,...} </p> <p>I need to display agent names in table.</p> <p>when ever i selects people name in table i need to retrieve that particular person email and phone number.</p> <p>how can i done,can any one please post some code or tutorial.</p> <p>Thank u in advance.</p>
iphone
[8]
2,099,199
2,099,200
splitting one program into several smaller and their binding in python?
<p>i want to make from one big program 5 smaller programs:main and program1,program2,program3 and program4.programs1,2,3,4 should use variables from main program and return some new variables,and main program should use(or call) programs1,2,3,4... can i bind these programs using functions,modules or something else and how? i'm new in Python and any help will be usefull</p>
python
[7]
4,667,317
4,667,318
mvaayoo api issue for sending messages from a website
<p>i am using mvaayoo api for sending the messages from my website.</p> <p>i have read the documentation and do the same even then i am not able to send the messages.</p> <p>i am using this sample code</p> <pre><code>string strUrl = "http://api.mVaayoo.com/mvaayooapi/MessageCompose?user= Username:Password&amp;senderID=mVaayoo&amp;receipientno=919849558211&amp;msgtxt=This is a test from mVaayoo API&amp;state=4"; WebRequest request = HttpWebRequest.Create(strUrl); HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(); Stream s = (Stream)response.GetResponseStream(); StreamReader readStream = new StreamReader( s ); string dataString = readStream.ReadToEnd(); response.Close(); s.Close(); readStream.Close(); </code></pre> <p>Help me please</p> <p>Thanks, Rajbir</p>
asp.net
[9]
5,565,086
5,565,087
find all items in list object
<p>I would like to interrogate all new emails (one by one) and find the contents of them so that I can use the contents for another application. </p> <p>My first step was interpreting the return values from a search done via the search attr of an IMAP4 object. I'm trying to figure out what data is in a list that I have returned to me.<br> How can I examine the object tree via print? Or, better yet, how can I get the contents of the email in a string?</p> <p>For ex., I am returned the following via print: <code>unseen email content: ['3 4']</code> from a variable named "response". If I run <code>print response.__class__.__name__</code>, I get "list" returned.</p> <p>I know that there is other data in "3", and "4", I just don't know what. </p> <p>update: Specifically, this is the return of a call to an IMAP4obj.search(None, '(UNSEEN)')</p>
python
[7]
5,494,298
5,494,299
Deleting Original Line from the output file
<p>I want to remove <code>tempstring</code> lines from the output.txt file </p> <pre><code>File.Copy(words, Npath); StreamReader temp = new StreamReader(Npath, Encoding.UTF8); string tempstring = temp.ReadToEnd(); string[] temp3 = tempstring.Split(','); temp.Close(); StreamWriter sW = File.AppendText(Npath); string remove = tempstring.Replace(tempstring," "); foreach (string item in temp3) { string str = item.TrimStart().TrimEnd(); string newStr = "&lt;addr-line&gt;" + str + "&lt;/addr-line&gt;"; sW.WriteLine(newStr); } sW.Close(); </code></pre> <p>The output .txt file shows </p> <blockquote> <blockquote> <p><strong>Marko Kostic, Faculty of Technical Sciences, University of Novi Sad, Trg D. Obradovica 6, 21125 Novi Sad, Serbia</strong></p> </blockquote> </blockquote> <pre><code>&lt;addr-line&gt;Marko Kostic&lt;/addr-line&gt; &lt;addr-line&gt;Faculty of Technical Sciences&lt;/addr-line&gt; &lt;addr-line&gt;University of Novi Sad&lt;/addr-line&gt; &lt;addr-line&gt;Trg D. Obradovica 6&lt;/addr-line&gt; &lt;addr-line&gt;21125 Novi Sad&lt;/addr-line&gt; &lt;addr-line&gt;Serbia&lt;/addr-line&gt; </code></pre> <p>I want to remove the Bold Paragraph, which in code is <code>tempstring</code> from the output file</p> <p>Any suggestions?</p>
c#
[0]
127,891
127,892
Difference between Array adapter and Cursor Adapter in Android
<p>What is the difference between Array adapter and Cursor Adapter in Android?</p>
android
[4]
612,721
612,722
c# paint grid cells and return the certain grid painted
<p>I'm making a program to interface with my 128*64 LCD i bought for my atmega8.</p> <p>The idea is thati want to make a grid( like the one on the lcd) and then paint certain cells of the grid( single colored) and retreive the cells painted. </p> <p>In x;y system... Like 1;1 2;3 </p> <p>So i could then later send the painted(activated) cells to my atmega8 lcd. a picture of the idea is here, but i need to reteive the cells painted <a href="http://stackoverflow.com/questions/12710390/drawing-a-grid-on-a-picturebox">Drawing a grid on a PictureBox</a></p> <p>Anyone got an idea how to do this?- Can i use Gridview for this and return the cells activated(painted) ?</p>
c#
[0]
3,372,439
3,372,440
C# List all Folders on a SQL reporting server using ReportingServices
<p>I'm just trying to get a list of all the folders that resides on a sql server running reporting services. I'm using the web service ReportingServices</p>
c#
[0]
105,021
105,022
What's the point of os.error?
<p>Why does Python's <code>os</code> module contain <a href="http://docs.python.org/library/os.html#os.error"><code>error</code>, an alias for <code>OSError</code></a>?</p> <p>Is there a reason to ever spell it <code>os.error</code>? <code>OSError</code> certainly seems more consistent with all the other built-in exceptions.</p> <p>I hoped <code>os.py</code> would shed some light, but it uses <code>error</code> sometimes and <code>OSError</code> others.</p> <p>It seems goofy to have an extra name for one of the exceptions, yet it survives into Python 3.0. What am I missing?</p>
python
[7]
665,998
665,999
Cannot save video to specific folder
<p>I am trying to save video to specific folder like </p> <pre><code>Intent captureVideoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); File videosFolder = new File(Environment.getExternalStorageDirectory(), "Videos"); if (!videosFolder.exists()) { videosFolder.mkdirs(); // &lt;---- } String sfx = getNextName(ConstantData.RESPONSE_TYPE_VIDEO); videoUri = Uri.fromFile(new File(videosFolder, sfx)); captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT,videoUri); captureVideoIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(captureVideoIntent,1277); </code></pre> <p>videoUri is fine, folder Videos is created and on result when I try to read file like </p> <pre><code>InputStream inputStream = this.getContentResolver().openInputStream(videoUri); ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(8 * 8192); .... </code></pre> <p>I am getting exception FileNotFound, what is true, there is Videos folder but there is no saved video inside. Does anybody know what is problem and why I cannot save video to specific folder ? Video has extension .3gp and folder is always empty.</p>
android
[4]
841,151
841,152
Is there any way I can find how many objects are instanciated from stack and how many objects from Heap. I dont wish to have the restrictions of scoping in objects from Stack
<p>Is there any way I can find how many objects are instanciated from stack and how many objects from Heap. I dont wish to have the restrictions of scoping in objects from Stack.</p> <p>If i use a static counter in constructor and destructor, it will be called in both the cases(object from stack and heap). One way is to exploit the idea are objects from stack are scoped and destructor is called when they go out of scope but i want a better solution so as to know the number of objects at any point of time.</p>
c++
[6]
5,210,954
5,210,955
Embedding a Resource in C#
<p>I'm using the AxShockwaveFlash object to load an extern .SWF file into my C# application. The AxShockwaveFlash takes in a URL for the movie to load. To load a local file, I can use a file:/// url string, which works fine.</p> <p>However, I'd really prefer that the SWF be embedded in the compiled executable, but the the AxShockwaveFlash object requires the string url to load.</p> <p>Does anyone have any good ideas on how this can be achieved, short of writing the file to a location on the computer when the executable is run?</p> <p>Thanks.</p>
c#
[0]
4,439,778
4,439,779
Is there a browser plugin or method to find which php template an item is coming from?
<p>Is there a browser plugin or method to find which php template an item is coming from?</p>
php
[2]
5,724,941
5,724,942
Fastest Way to Round to the Nearest 5/100ths
<p>I have numbers that I want to go from:</p> <pre><code>1.215145156155 =&gt; 1.2 1.368161685161 =&gt; 1.35 1.578414616868 =&gt; 1.6 </code></pre> <p>(*Note: the hundredths place should not be marked if it is zero.)</p> <p>What's the <strong><em>fastest</em></strong> way to do this?</p> <p>This is what I have right now, and it is not fast enough:</p> <pre><code>def rounder(v): v = str(round(float(v),2)) if len(v) == 3: v = v + str(0) d0 = int(v[0])#ones d1 = int(v[2])#tenths d2 = int(v[3])#hundredths if d2 &lt;= 4: return str(d0)+'.'+str(d1) elif 4 &lt; d2 &lt; 7: return str(d0)+'.'+str(d1)+str(5) elif d2 &gt;= 7: if d1 != 9: return str(d0)+'.'+str(d1+1) if d1 == 9: return str(d0+1)+'.'+str(0) </code></pre>
python
[7]
225,126
225,127
getting parent index with jquery
<p>I know there is another question with an answer to my question, however one solution that was said to be newer does not work for me.</p> <p>so I have something like: </p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;div class="thumb"&gt;&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div class="thumb"&gt;&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div class="thumb"&gt;&lt;/div&gt;&lt;/li&gt; &lt;/ul&gt; $("ul li div.thumb").live("click",function(){ alert($(this).parent().index()); }); </code></pre> <p>I want to retrieve the index of the li, however the solution is not working for me.</p> <p>EDIT:</p> <p>Ok my actual code has children within div.thumb:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;div class="thumb"&gt;&lt;div class="inner"&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div class="thumb"&gt;&lt;div class="inner"&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/li&gt; &lt;li&gt;&lt;div class="thumb"&gt;&lt;div class="inner"&gt;3&lt;/div&gt;&lt;/div&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I didn't think it would matter since div thumb is being clicked. I'm getting -1 for any .thumb clicked ​</p>
jquery
[5]
5,336,595
5,336,596
Programming language detection in PHP
<p>I need to detect which programming language is used in a code snippet, there is any library to do this?</p> <p>I already read this <a href="http://stackoverflow.com/questions/475033/detecting-programming-language-from-a-snippe">http://stackoverflow.com/questions/475033/detecting-programming-language-from-a-snippe</a>, but I rather use a tested and working library.</p>
php
[2]
5,901,320
5,901,321
Android device specific camera path in android
<p>I created a sample app, in my app i capture a photo and save it in a specific folder. The app runs successfully on the emulator with target 2.3.3, but when installing it on a mobile the image gets stored in the default folder in <code>/mnt/sdcard.DCIN/100ANDRO/sample.jpg</code>. Please tell me how can I overcome this issue.</p>
android
[4]
4,689,287
4,689,288
c++ how to deal with method returning either NULL or std::string?
<p>I am a bit stuck with some code. I have to use the return type of the method <code>getToto()</code> which usually returns a <code>std::string</code>, but in one case it returns <code>false</code> (It is part of a library I have to use, I cannot modify it). I understand that is equivalent to a null pointer. But I cannot find a proper way to catch it!</p> <p><strong>Test.cpp</strong></p> <pre class="lang-cpp prettyprint-override"><code>static std::string getToto(){ char buffer[1024]; if ( CTX_Get_Env(buffer, "Toto", 1024) ) return false; return buffer; } </code></pre> <p>If I try</p> <pre class="lang-cpp prettyprint-override"><code>const char* returned = Test::getToto().c_str(); if (returned==NULL){ std::cout&lt;&lt; "null pointer"&lt;&lt;std::endl; } </code></pre> <p>I get an error whilst running</p> <blockquote> <p>terminate called after throwing an instance of 'std::logic_error'</p> <p>what(): basic_string::_S_construct NULL not valid</p> </blockquote> <p>Sorry, I have a rather low level in C++.</p>
c++
[6]
221,405
221,406
PHP Loop Over ONLY Different Arrays
<p>I have a single array with several of the same values. And I only want to loop over DIFFERENT values. How could I go about doing this?</p> <p>Example</p> <pre><code>166-01 001;09;UO; 166-01 001;09;UO; 166-01 001;09;UO; 166-01 001;09;UO; 166-01 001;09;UO; 166-01 001;09;UO; 166-01 001;09;UO;_86 166-01 001;09;UO;_86 166-01 001;09;UO;_86 166-01 001;09;UO;_86 166-01 001;09;UO;_86 166-01 001;09;UO;_86_97 166-01 001;09;UO;_86_97 166-01 001;09;UO;_86_97 166-01 001;09;UO;_86_97_108 166-01 001;09;UO;_86_97_108 166-01 001;09;UO;_86_97_108_119 166-01 001;09;UO;_86_97_108_119 </code></pre> <p>I have that in a single array, but I only want to loop for the different ones. So it would loop once for nothing, then once for _86, then once for _86_97, then once for _86_97_108, and then once for _86-97_108_119. So only loop for different key values, </p> <p>or would there be a way to count the number of different keys?</p>
php
[2]
605,545
605,546
Find out the new element in EditText View
<p>I want to execute one method wheneer i enter number in EditText view.But i did not change the focus of EditText.I am stay in the same EditText when i enter a new number automatically i eant to execute one function.Now my question is how we find that event that means enter a new number in EditText </p>
android
[4]
4,617,802
4,617,803
Optimizing php conditionals
<p>I have something like this:</p> <pre><code>&lt;?php $fix1 = XXXXXXX //Integer. Problem isn't here. Extracted automatically $iffix1 = range(9000000,8000000); $iffix2 = range(7999999,7888888); ... //There're more iffix[XX]s, up to $iffix60 if($fix1 = in_array($iffix1)) { $var1 = 1; } elseif($fix2 = in_array($iffix2)){ $var2 = 2; } .... //I have 60 more elseifs as well $result = $var1 * $fix1; echo $result; ?&gt; </code></pre> <p>The script is more complicated than that, but the question question only concerns this bit, Obviously, I get a low-memory error.</p> <p>How can I fix this?</p>
php
[2]
4,366,231
4,366,232
Load gallery at with particuler image position
<p>I have a list of images in grid view.I want to display a gallery of all this on click event of any image in grid view.I wanted to display selected image in gallery first when its load.I have position of all this images. Any help will be highly appreciated.</p>
android
[4]
5,581,918
5,581,919
Horizontal line padding
<p>I'm trying to add a horizontal line between two EditText widgets, but strangely the line has no padding at the bottom, so it appears "glued" to the widget that is below it.</p> <p>This is my code (in the layout.xml, inside a LinearLayout with vertical orientation):</p> <pre><code> &lt;EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:capitalize="sentences" android:singleLine="true" android:maxLength="30" /&gt; &lt;View android:background="#FF00FF00" android:layout_width="fill_parent" android:layout_height="1dip" /&gt; &lt;EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="10dp" android:scrollbars="vertical" android:capitalize="none" android:autoLink="all" android:maxLines="8" /&gt; </code></pre> <p>And this is how it looks like:</p> <p><img src="http://i.stack.imgur.com/Ceg4D.png" alt="enter image description here"></p> <p>I'd like to add some padding below the line. I tried with android:paddingBottom in the View widget, and with android:paddingTop in the below EditText widget, but the result is the same (it's ignored).</p>
android
[4]
1,895,464
1,895,465
Overriding a property
<p>I'm trying to override a property in my program. Here is basically what I'm trying to do : </p> <pre><code>class A { public int test = 7; } class B : A { public int test = 8; } class Program { static void Main(string[] args) { A test1 = new A(); A test2 = new B(); Console.WriteLine(test1.test); Console.WriteLine(test2.test); } } </code></pre> <p>This displays 7 in both case when I'd like it to display 8 in the 2nd case....</p> <p>I've tried virtual and override as well as new (public new int test = 8;) But it doesn't seem to work</p> <p>And yes I know I should use private and getters. I just want to know if it's possible ?</p> <p><strong>Edit :</strong> I'm not a native C# programmer so forgive me if i mix the terms (such as field and propertys)!</p>
c#
[0]
3,023,148
3,023,149
iPhone app pricing model question?
<p>I have heard there has been some studies of the apple app store for the iphone. It was a comparison between having a free application supported by ad vs a .99 cent application. .99 cents seems to be the sweet spot for a lot of the smaller applications. Anyone know where those studies were done? Are people having better success with .99 cents or the free ad supported applications?</p>
iphone
[8]
5,972,365
5,972,366
$_SERVER['PHP_SELF'] intermittently returning two leading forward slashes
<p>Why would $_SERVER['PHP_SELF'] return a filename in one instance as /test/foo.bar and another instance (executed from the same php script) as //test/foo.bar (with double leading forward slashes)?</p> <p>form.php sends $_GET to login.php. login.php redirects to</p> <pre><code>header ('Location: test/foo.bar') </code></pre> <p>foo.bar includes: </p> <pre><code>$page = filter_var($_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING); </code></pre> <p>(<em>Additionally, I cannot replicate it on demand.</em> )</p>
php
[2]
5,954,309
5,954,310
Is there any Android flickr open source application?
<p>I am looking for flickr open source android 3.2 application for my learing purpose. If it is there somewhere, please help me out.</p>
android
[4]
3,468,083
3,468,084
remove <br> from specific div
<p>I need to remove break from a specific <code>div</code>, i know how to remove all breaks with</p> <p><code>$('br').remove();​</code></p> <p>But I need to keep some breaks elsewhere on the page , </p> <p>How would I remove the breaks from a <code>div</code> with the id "grape1" and "grape12" but leave all others intact?</p>
jquery
[5]
5,930,306
5,930,307
How to design good looking Web Application
<p>I am a java developer and I am on my way to create a professionally good looking web application, one which has jquery, and fancy menus, well organized css, html etc. I have little knowledge of CSS, html, javascript and other web <strong>designing</strong> languages. </p> <p>Please let me know how developers create such kind of websites that have good look and feel.</p> <p>I dont want to use GWT/Wicket/or any other java framework. Just the traditional html and javascript as they are way faster than java based web UI frameworks.</p> <p>Also let me know if there is any IDE to easily design the website. I use eclipse. can it be done on eclipse.</p>
java
[1]
75,819
75,820
Message shown when adding a homescreen shortcut.
<p>When creating a homescreen shortcut through my application, I see a dialogue come up on the bottom of the screen that says something like "shortcut .... created", "shortcut .... already exist", or "shortcut ... deleted". Is there a way to disable this dialogue/message?</p>
android
[4]
1,789,036
1,789,037
Cannot import google io source code 2011
<p>I am new to android development . I'm trying to download and run the iosched 2011 source code for HoneyComb. And, I looked in most of the forums, and not been able to understand what to do . So, if anyone of u guys could give a step by step process for downloading and running on eclipse locally , I would be very greatful.</p>
android
[4]
2,952,379
2,952,380
HTC Chacha showing landscape although portrait is set in the manifest file
<p>I was developing an app today and I set the orientation for the all the activities to <code>portrait</code> in the manifest file.Now when I deployed the app on my <code>Xperia U</code> mobile it was working fine . But when I deployed it in my friends <code>htc Chacha</code> it was showing the layout not in portrait.Instead the layout was shown in <code>landscape</code>.</p> <p>Why this is happening?</p>
android
[4]
5,657,103
5,657,104
Grouping an array of similar words
<p>I have an array with a bunch of words. E.g:</p> <pre><code>array( developer,develop,development,design,designer,designing ) </code></pre> <p>I want to be able to group these words together with their similar words so I'd get something like this:</p> <pre><code>array( array( develop, developer, development ), array( design, designer, designing ), ); </code></pre> <p>What would be the best way to do this in PHP?</p>
php
[2]
5,113,794
5,113,795
Does the PHP mail function return true if email is incorrect
<p>I am making a system that will be used to collecting a larger of data from users. I know some will be spam! I just want to know if the mail function returns false if the email is not correct? </p> <p>Say I have. </p> <pre><code> &lt;?php $to = "fake@fake.com"; $header = "From: {$to}"; $subject = "Hi!"; $body = "Hi,\n\nHow are you?"; if (mail($to, $subject, $body, $header)) { echo("&lt;p&gt;Message successfully sent!&lt;/p&gt;"); } else { echo("&lt;p&gt;Message delivery failed...&lt;/p&gt;"); } ?&gt; </code></pre> <p>Which message will be printed if the email is not correct?</p> <p>If it does return false I want a "flag" to be stored with it in that database so the admins can review it and delete it. </p>
php
[2]
4,823,514
4,823,515
Paper View effect iPhone
<p>I would like to create a turn up page view with button under the view like the first image of this app: <a href="http://itunes.apple.com/us/app/ihandy-translator-pro/id402422247?mt=8" rel="nofollow">http://itunes.apple.com/us/app/ihandy-translator-pro/id402422247?mt=8</a></p> <p>How can I do this "page peek" view, it works so if I press in the bottom right of the yellow pad is raised and the button are displayed. How can I do that? And how is this method of view called?</p>
iphone
[8]
4,648,886
4,648,887
Parse JSON string
<p>I have a hard-coded JSON string.</p> <pre><code>var test = "JSON STRING HERE"; </code></pre> <p>I am using jQuery. I know there is a function like getJSON, but that makes an AJAX call. I want it to parse the hardcoded string so that I can use <code>$.each(test, function(a,b){}))</code></p> <p>Thank you for your time.</p>
jquery
[5]
2,683,819
2,683,820
How to find duplicate elements in array using for loop in python like c/c++?
<p>i have a list with duplicate elements:</p> <p>In python:</p> <pre><code> list_a=[1,2,3,5,6,7,5,2] tmp=[] for i in list_a: if tmp.__contains__(i): print i else: tmp.append(i) </code></pre> <p>i have used the above code to found the duplicate elements in the list_a. i dont want to remove the elements form list.</p> <p>But i want to use for loop here: Normally C/C++ we use like this i guess:</p> <pre><code> for (int i=0;i&lt;=list_a.length;i++) for (int j=i+1;j&lt;=list_a.length;j++) if (list_a[i]==list_a[j]) print list_a[i] </code></pre> <p>how do we use like this in Python ?</p> <pre><code>for i in list_a: for j in list_a[1:]: .... </code></pre> <p>i tried the above code .But it gets solution wrong.i dont know how to increase the value for j.pls help... </p>
python
[7]
4,217,093
4,217,094
why does not eclips know cout and cin in my code?
<p>I am new in c++, I want to write my program with eclips but it does not know cout and cin however I add include This is my code:</p> <pre><code>class READY { public: READY(); virtual ~READY(); #include &lt;iostream.h&gt; int main (){ cout&lt;&lt;"hello"; } }; #endif /* READY_H_ */ </code></pre>
c++
[6]
5,924,715
5,924,716
Python 2.7: How to check if a deque is empty?
<p>Is try-catch the only method to do that?</p>
python
[7]
4,228,996
4,228,997
Toggle not working in IE
<p>I am using this code on my site:</p> <pre><code>var panel = $('.couch-hide'); var originalPos = panel.css("right"); panel.toggle(function() {$(this).animate({right:0},1000, 'easeOutBounce');},function(){$(this).animate({right:originalPos},1000);} ); </code></pre> <p>In FF it works flawlessly, but in IE, it doesn't pop out on click. Also, since im using the CSS right it shows the horizontal scrollbars but in FF it doesn't. Any ideas on what I can do to fix this issue?</p>
jquery
[5]
908,066
908,067
Switching Tabs with previous tab
<p>I am created tabhost with 4 tabs named previous, solotalk, mytalk, edit. after pressing solotalk, mytalk,edit, then then i am press previous it should come back edit, mytalk, solotalk, here i am using intent for calling solotalk mytalk and edit</p>
android
[4]
976,309
976,310
convert '1' to '0001' in JavaScript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2686855/is-there-a-javascript-function-that-can-pad-a-string-to-get-to-a-determined-lengt">Is there a JavaScript function that can pad a string to get to a determined length?</a> </p> </blockquote> <p>How can I convert convert '1' to '0001' in JavaScript without using any 3rd party libraries. I have done this in php using spritf: <code>$time = sprintf('%04.0f',$time_arr[$i]);</code></p>
javascript
[3]
5,748,542
5,748,543
List Slicing python
<p>I have a list like </p> <pre><code>myl = ['A','B','C','D','E','F'] #length always even </code></pre> <p>Now my desired output is <code>'AB','CD','EF'</code></p> <p>I tried</p> <pre><code>&gt;&gt;&gt; myl = ['A','B','C','D','E','F'] &gt;&gt;&gt; even_pos = myl[::2] &gt;&gt;&gt; odd_pos = myl[::-2] &gt;&gt;&gt; odd_pos.reverse() &gt;&gt;&gt; newlist = zip(even_pos,odd_pos) &gt;&gt;&gt; for x in newlist: ... print "".join(list(x)) ... ... AB CD EF &gt;&gt;&gt; </code></pre> <p>I don't like this way because I think this is too much.</p> <p>So, is there any better way to achieve my output.</p>
python
[7]
3,756,808
3,756,809
How to terminate a console mode app from a BackGroundWorker
<p>I am creating one BackgroundWorker and inside its DoWork function I have the following code: </p> <pre><code> foreach (string newFilepath in newFilesPath) { if (!File.Exists(encryptedFilePath)) { encryptedFiles.Add(encryptedFilePath); Helper.SendErrorMail(null, "Could not find encrypted file.", encryptedFilePath); Application.Exit(); } else { Helper.Count_DataFeeds++; File.Delete(newFilepath); } } </code></pre> <p>As per this code I should see only one mail because the Application exists, however I am seeing 8 mails(for each file it is iterating). Why application is not quitting ? I want to kill the application at once.</p> <p>It is a console application.</p>
c#
[0]
3,724,286
3,724,287
Reading from a URL and storing in an ArrayList in JAVA
<p>I'm trying to read from the URL below which appears to work but when I try to store it in the ArrayList it gives me an error. Any ideas on whats causing the error?</p> <pre><code>public abstract class ItemList implements ItemListInterface{ private static String inputLine; private static ArrayList&lt;String&gt; wordArray; public static void main(String[] args) throws Exception { URL wordList = new URL("http://dl.dropbox.com/u/18678304/2011/BSc2/phrases.txt"); BufferedReader in = new BufferedReader( new InputStreamReader( wordList.openStream())); while ((inputLine = in.readLine()) != null){ System.out.println(inputLine); wordArray.add(inputLine); } in.close(); } } </code></pre>
java
[1]
255,440
255,441
PHP not stripping slashes when echoing
<p>I'm hoping someone can clear this up for me. I have been reading a book on best practices when it comes to form validation and that if the user enter a wrong value return the form back to them with the data they entered with warning/error messages. </p> <p>What I want to do is say a user enters the below into a text box: </p> <pre><code>hello " there </code></pre> <p>I want to return the above in the text box. Now when I use the below code it adds a slash. </p> <pre><code>&lt;input name="name" id="name" type="text" class="formbox" &lt;? php if ($missing || $errors) { echo 'value="' . htmlentities($name) . '"'; } ?&gt; &gt; </code></pre> <p>What I considered doing is this:</p> <pre><code>&lt;input name="name" id="name" type="text" class="formbox" &lt;? php if ($missing || $errors) { $name = stripslashes($name); echo 'value="' . htmlentities($name) . '"'; } ?&gt; &gt; </code></pre> <p>While the above works it seems inefficient. If I use just 'stripslashes' then anything after the " is removed. Currently the form is just checking its self in the sense that when the user clicks submit the form reloads and an IF statement catches any posts which then checks to see if there are any missing fields.</p> <p>I hope this all makes sense as I have been unable to find a best solution on SO and Google.</p> <p>Many thanks for any help in advance :) </p>
php
[2]
1,045,397
1,045,398
type synonyms in c#?
<p>i hope i missed this in the docs. is there a way to declare a type synonym in c#? thanks konstantin</p>
c#
[0]
3,769,451
3,769,452
jQuery accordion-like menu with text replace
<p>I want to indicate a menu's expandability/collapsibility with a 'plus' sign. I want to replace the plus sign with a minus when the item has been expanded.</p> <p>The only issue at the moment is returning the minus back to a plus when I click on another item. </p> <p>Any suggestions? </p> <p>Fiddle: <a href="http://jsfiddle.net/saltcod/Lg9Mn/" rel="nofollow">http://jsfiddle.net/saltcod/Lg9Mn/</a></p>
jquery
[5]
1,570,309
1,570,310
Conversion to Dalvik format failed with error 1 Solution?
<p>I was programming an application for android, after i added a tab layout to the program an error showed up to:</p> <blockquote> <p>Conversion to Dalvik format failed with error 1</p> </blockquote> <p>I have tried cleaning the project and looking at all the other solution to the problem on this website. Has someone also found some obscure solution to this error?</p>
android
[4]
5,805,228
5,805,229
What is default jvm error log location?
<p>If an error log location isn't specified when executing <code>java -cp ../blah someplace/somejar.jar</code> where would the jvm error log be written to?</p>
java
[1]
652,969
652,970
Collect all method args in an Object[] array
<p>I'm looking at collecting all the method parameters of generic methods in an Object[] array for logging purposes. I'm aware that this is better achieved using aspects, but am disallowed from using it and am looking for a pure reflection based approach if possible</p> <p>To clarify, Assuming a method call</p> <pre><code>class A { foo(int a, Object b){ } } </code></pre> <p>Given an object instance of A, is it possible within the 'foo' method to dynamically determine the arguments that were passed? I cant seem to find any API in java.lang.reflect or annotations to determine this.</p> <p><strong>EDIT</strong>: I currently use the implementation below for logging. However it's tedious to collect all method params in an array before calling it and was wondering if this could be inferred somehow. I'm looking for any suggestion/library other than aspects </p> <pre><code>private static final ConcurrentMap&lt;Class, Method[]&gt; METHODS = new ConcurrentHashMap&lt;Class, Method[]&gt;(); protected void log(Class clazz, String methodName, Object[] args) { Method[] methods = METHODS.get(clazz); if (methods==null){ methods = clazz.getDeclaredMethods(); METHODS.put(clazz, methods); } for(Method method:methods){ if (method.getName().equals(methodName)){ StringBuilder builder = new StringBuilder(methodName + '('); int i=0; for (Class type:method.getParameterTypes()){ builder.append(type.getSimpleName()) .append(" [") .append(args[i++]) .append("] ,"); } String str = StringUtils.removeEnd(builder.toString(), ",") + ")"; LoggerFactory.getLogger(clazz).info(str); } } } </code></pre>
java
[1]
3,533,416
3,533,417
PHP - Select a unique mysql line without while
<p>I want to select only unique values with php/mysql. </p> <p>I can do it with many line, but I forget how to do it without while... :)</p> <p>Thanks a lot.</p> <p>Here is the code that I want to do without while.</p> <pre><code>$request_1m = "SELECT date1, date2 from mytable"; $result_1m = mysql_query($request_1m,$db); while($row = mysql_fetch_array($result_1m)) { /* Get the data from the query result */ $date1_1m = $row["date1"]; $date2_1m = $row["date2"]; } </code></pre>
php
[2]
5,501,132
5,501,133
JAVA Multiple Operations when defining a variable
<p>In Java is it possible to have multiple operations on a variable definition?</p> <p>For example</p> <pre><code>double myLocalVariable = (myLocalVar2 + myLocalVar3 * myLocalVar4); </code></pre> <p>Thanks for the help!</p> <p>CJ</p>
java
[1]
3,888,185
3,888,186
Multiple BroadcastReceivers that handle the BOOT_COMPLETED action?
<p>Is it possible to have multiple BroadcastReceivers that run on BOOT_COMPLETED in a single app?</p>
android
[4]
920,869
920,870
C++ Array Member of Constant Length (Initialisation of)
<p>I have a class that contains an array. I want this array to be set at the length of a constant:</p> <pre><code>// Entities.h class Entities { private: const int maxLimit; int objects[maxLimit]; int currentUsage; public: Entities(); bool addObject(int identifier); void showStructure(); }; </code></pre> <p>The main problem I'm having is with the constructor. I thought:</p> <pre><code>// Entities.cpp Entities::Entities() : maxLimit(50) { currentUsage = 0; cout &lt;&lt; "Entities constructed with max of 50" &lt;&lt; endl; } </code></pre> <p>would have been sufficient...but not so. I don't know if I can use the initialiser list for array initialisation.</p> <p>How can I initialise the 'objects' array using the 'maxLimit' const? I'm relatively new to classes in C++ but I have experience with Java. I'm mainly testing out this phenomenon of 'constness'.</p> <p>Cheers.</p>
c++
[6]
4,452,102
4,452,103
Jquery changing .live to .on,
<p>I am trying to change all my <code>.live()</code> to <code>.on()</code> as the prior is now deprecated.</p> <p>I am struggling to understand how it works though. Before I used this code and it worked fine...</p> <pre><code>$('#lightBoxClose').live('click', function() { $('#lightBox').fadeOut(); }); </code></pre> <p>So I tried changing it to,</p> <pre><code>$('#lightBoxClose').on('click', function() { $('#lightBox').fadeOut(); }); </code></pre> <p>But it doesn't work can anyone please explain what I am supposed to be doing thanks.</p>
jquery
[5]
3,275,552
3,275,553
Reading a pdf file using bufferedreader and writing to a bytearrayoutputstream
<p>How do I read a PDF file and write it in a <code>ByteArrayOutputStream</code>?</p> <pre><code> /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package javaapplication1; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import net.sf.json.JSONObject; import org.apache.commons.codec.binary.Base64; public class NewClass2 { public static void main(String[] args) { try { File pdfFile = new File("C:\\Users\\311001\\Documents\\NetBeansProjects\\JavaApplication1\\src\\javaapplication1\\image\\test_01.pdf"); FileInputStream input = new FileInputStream(pdfFile); ByteArrayOutputStream output = new ByteArrayOutputStream(); byte[] buffer = new byte[65536]; int l; while ((l = input.read(buffer)) &gt; 0) { output.write(buffer, 0, l); } input.close(); byte[] pdfBytes = output.toByteArray(); String pdfInString = new String(Base64.encodeBase64(pdfBytes)); JSONObject json1 = new JSONObject(); json1.put("command", pdfInString); System.out.println(json1); } catch (Exception e) { } } } </code></pre>
java
[1]
3,824,468
3,824,469
Expand/collapse group nodes in ExpandableListView based on passed Cursor values?
<p>I've got a ExpandableListView widget that is populated using an adapter based on the SimpleCursorTreeAdapter as shown below. I I query my SQL database for the ListView's group titles as well as a boolean value to whether the group should be expanded or collapsed (which is returned in a Cursor). I then feed this Cursor to my adapter and the list is populated and displayed.</p> <p>The only thing I can't do, is have the group nodes in the ListView be expanded or collapsed based on the boolean value in the supplied Cursor. I want to have this happen when the activity containing this ExpandableListView widget is initally created, loaded, and displayed.</p> <p>Is there a way to have my adapter take the boolean values supplied in the Cursor object and use them to expand or collapse these group nodes?</p> <pre><code>public class MyExpandableListAdapter extends SimpleCursorTreeAdapter { public MyExpandableListAdapter (Cursor cursor, Context context, int groupLayout, int childLayout, String[] groupFrom, int[] groupTo, String[]childrenFrom,int[]childrenTo) { super(context,cursor,groupLayout,groupFrom,groupTo,childLayout,childrenFrom,childrenTo); } @Override protected Cursor getChildrenCursor(Cursor groupCursor) { String strCategory = groupCursor.getString(groupCursor.getColumnIndex("strCategory")); Cursor cur = mainActivity.mDbHelper.getCardTitlesForCategory(strCategory); return cur; } } </code></pre> <p>Thanks for your suggestions and advice.</p>
android
[4]
4,945,832
4,945,833
file weight and how many lines in text file - how ? (C#)
<p>how to measure any file weight ?</p> <p>and how to know how many rows in text file ?</p> <p>thank's in advance</p>
c#
[0]
1,709,518
1,709,519
Wiping data on an actual phone
<p>Ok, usually I use the emulator so I have just to check the "wipe-data" entry and that's it. If I'm using a phone how could I do that? Is there a way to have a "developer profile" on my phone so I don't lose my personal data?</p> <p>I'm using my personal phone so....</p>
android
[4]
5,622,667
5,622,668
View to hold three image and when scroll change the screen in android
<p>i am new to android and stuck and thinking how the task can be done.</p> <p><strong>The task is...</strong></p> <p>The view or horizontal scroll view will have three image so user can move them left to right and right to left vice versa.and on change of the image it will load some image to the screen.</p> <p><strong>the loading of image i will explain.</strong></p> <p>if the first image is focused or in the center that image will showed in the screen and the other remain two image will be blur or not so clear. i am displaying some image in order to get the clear picture of the question.</p> <p>Image below:</p> <p><img src="http://i.stack.imgur.com/Chhp2.png" alt="in place of number image will come"></p> <p>so how that can be done in android is there some view component is there to directly add the image in the place of number. thanks for any reply</p>
android
[4]
3,600,603
3,600,604
Restrict Postback on button client click event
<p>I am having an asp button in Update panel and a update progress attached with update panel. I want restrict page postback on on button's client click event.</p>
asp.net
[9]
5,645,400
5,645,401
C# loops through 24 hours every 30 minutes
<p>I am wondering how I would loop through a datetime or any type of variable to go from 12:00AM to 11:59PM every 30 Mins?</p> <p>So I need a variable that shows times in 12HR format (01:00PM, 09:00AM) and everytime I loop through it, to add 30 mins to the time? I then need to use this value in a string.</p> <p>The time needs to start at 10:00AM</p>
c#
[0]
5,851,009
5,851,010
Reading request content from Java socket InputStream, always hangs after header
<p>I am trying to use core Java to read HTTP request data from an inputstream, using the following code:</p> <pre><code>BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); </code></pre> <p>I receive the header fine, but then the client just hangs forever because the server never finds "EOF" of the request. How do I handle this? I've seen this question asked quite a bit, and most solutions involve something like the above, however it's not working for me. I've tried using both curl and a web browser as the client, just sending a get request</p> <p>Thanks for any ideas </p>
java
[1]
3,926,113
3,926,114
Possible to make a self contained web part that uses jQuery?
<p>Basically I would like to create a WebPart that uses jQuery but I don't want to have to add jQuery to my masterpages (or anywhere else) manually. I would like to have one WSP that I could email to someone, have them install only that, and having a working WebPart that uses jQuery.</p> <p>Is this possible?</p>
jquery
[5]