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 |
---|---|---|---|---|---|
896,178 | 896,179 | how to write a program in C++ which receives 10 numbers from input and checks whether these numbers are in ascending order or not? | <p>I am a newbie. And I want to do this program without using array and only with 3 variables. Looking forward for your help. I stuck up here:</p>
<pre><code>#include<iostream>
#include <math.h>
using namespace std;
int main()
{
float a,b,c;
cout << "Please Enter the numbers: " << endl;
for(float k=0; k<=9; k++)
{
cout << "Enter number " << k+1 << " : ";
cin >> c
}
}
</code></pre>
<p>I am not getting the part how to take the values in a & b and compare them with each other. Please let me know if I am heading towards wrong direction.
looking forward for the help.</p>
<p>Thanks in advance.</p>
<p>Regard,
Sam</p>
| c++ | [6] |
252,193 | 252,194 | Dalvik Debug Monitor not showing my phone | <p>I have downloaded and installed the SDK. But my phone is not getting shown in the Dalvik Debug monitor.</p>
<p>Please help me, what is going wrong? I have killed the server. And restarted. But adb devices is not listing my device. I know while development in eclipse, I cant get my application running on my phone rather on emulator.</p>
<p><img src="http://i.stack.imgur.com/ZgwE1.png" alt="enter image description here"></p>
<p>I executed these commands too:</p>
<pre><code>E:\programs\Android\android-sdk-windows\platform-tools>adb kill-server
E:\programs\Android\android-sdk-windows\platform-tools>adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
E:\programs\Android\android-sdk-windows\platform-tools>
</code></pre>
<p>PS: I re-installed my SDK. Previously I was having a <a href="http://stackoverflow.com/questions/6462851/my-android-phone-not-showing-up-in-dalvik-debug-monitor">problem</a> when my phone was offline. But that was resolved. I followed the same steps. But no success. </p>
<p>Thanks in advance.</p>
| android | [4] |
4,488,546 | 4,488,547 | How to remove all the view along with rootView from UINavigationController in iPhone | <p>I have an UIView added in the main window with a controller. On clik of a button on this view I want to load a UINavigationController which will migrate to multiple views pushing them one by one on stack. Now what I want to do is when user reaches at the end of views, in the last view I have a done button. ON clik of this button I want to move back to my first screen unloading the NavigationController from the memory.</p>
<p>What is the best way to do it since popToRootViewController takes you to the first screen of UINavigationController which is my second screen.</p>
| iphone | [8] |
4,892,109 | 4,892,110 | How to get the PHP Version? | <p>Is there a way to check the version of PHP that executed a particular script from within that script? So for example, the following snippet</p>
<pre><code>$version = way_to_get_version();
print $version;
</code></pre>
<p>would print 5.3.0 on one machine, and 5.3.1 on another machine.</p>
| php | [2] |
5,797,068 | 5,797,069 | how to create a xml file and write in android and put into raw folder | <p>can anybody tell how to create a xml file and write in android and where to put the file for aceess again is it possible to put into raw folder ?</p>
| android | [4] |
3,527,334 | 3,527,335 | passing blocks around in javascript without lengthy function syntax | <p>In my testing code, I'm getting a lot of things that look like this:</p>
<pre><code>test.truth(function(){return myTest.isDef('')});
</code></pre>
<p>Where a majority of the line there is just the function boilerplate. Is there a way to reduce that, so that I can have a syntax more like:</p>
<pre><code>test.truth { myTest.isDef('') }
</code></pre>
<p>as one would do in Scala?</p>
<p>Of course, ideally this is highly browser compatible.</p>
| javascript | [3] |
1,888,976 | 1,888,977 | How to center align text in a tab bar in Android | <p>I want to put only text in tab bar, no image... I want to center text in a tab bar, horizontally and vertically. Exactly in the center.</p>
| android | [4] |
3,517,929 | 3,517,930 | IE8 Slide Toggle Issue | <p>Im having some trouble with jQuery's slideToggle function in IE8 for some reason the DIV its opening closes immediately after its opened </p>
<p>heres the code im using</p>
<pre><code>$("h3 a").click(function(){
id = $(this).attr("href");
$(id).slideToggle("slow");
});
</code></pre>
<p>and the HTML</p>
<pre><code><h3><a href="#promo-materials">Graphic and Pormotional Materials</a></h3>
<div id="promo-materials" class="center gallery">
<a href="images/portfolio/bistro.png" rel="facebox">
<img src="images/portfolio/thumbs/bistro.png" alt="" />
</a>
<a href="images/portfolio/direct-savings.png" rel="facebox">
<img src="images/portfolio/thumbs/direct-savings.png" alt="" />
</a>
</div>
</code></pre>
<p>Here is a link to the functional page it works in all other browsers including IE7</p>
<p>I forgot to post it:</p>
<p><a href="http://bestprintideas.com" rel="nofollow">http://bestprintideas.com</a></p>
<p>I currently have it triggering Compatiblity Mode since I had to get to work today.</p>
| jquery | [5] |
1,281,252 | 1,281,253 | How to use HelloGallery Widget | <p>I am running the <a href="http://developer.android.com/resources/tutorials/views/hello-gallery.html" rel="nofollow">HelloGallery example</a> for Android (using the XML layout file below), and I am now wondering how I would use it in my app. </p>
<p>It is referred to as a "layout widget". Is this different than an "app widget"?<br>
I am having trouble finding resources for adding this to my app, since when I search for "layout widget" I get references to widgets that float around on the home screen, and not using them within apps. </p>
<p>How would this be done?</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</code></pre>
| android | [4] |
4,573,471 | 4,573,472 | Soap query database | <p>I write a opration on java soap service to query the database and then show the data I have searched on client jsp page. However, I can't show it, the variable "rs" cannot change, I don't know why? could someone help me to find the troboule?
This is the opration i create on soap service:</p>
<pre><code> @WebMethod(operationName = "query")
public String query(@WebParam(name = "parameter") String parameter) {
ResultSet rs;
try {
Connection con = data1.getConnection();
Statement statement = con.createStatement();
String QueryString;
QueryString = "SELECT * from stud where name= parameter";
rs = statement.executeQuery(QueryString);
while (rs.next()) {
System.out.println(rs.getInt(1) + " " + rs.getString(2) + "\n");
}
} catch (Exception ex) {
System.out.println("Unable to connect to batabase.");//TODO write your implementation code here:
}
//TODO write your implementation code here:
return null;
}
</code></pre>
| java | [1] |
877,083 | 877,084 | problem in coding | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3794856/sorting-in-arrays">Sorting in arrays</a> </p>
</blockquote>
<pre><code>int A[5]={1,5,3,2,4};
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
if(A[j]>A[j+1])
{
int t=A[j];
A[j]=A[j+1];
A[j+1]=t;
}
}
}
for(i=0;i<5;i++)
cout<<A[i];
</code></pre>
<p>The desired output must be 1,2,3,4,5
but my output is 0,1,2,3,4.
What's the problem in my code?</p>
| c++ | [6] |
3,420,043 | 3,420,044 | jquery search GET anchor | <p>I need help getting hash search <em>bookmarkable</em>
So far I've got if I search something, it shows up <a href="http://site.com/" rel="nofollow">http://site.com/</a><strong>#searchedThing</strong>
but when I refresh or copy and paste the link to address bar, it wont show up that thing.</p>
<p><strong>index:</strong>
</p>
<pre><code><input type="text" id="media">
<input type="submit" id="media-search" value="Search">
<div id="media-list"></div>
<script src="js/search.js"></script>
</code></pre>
<p><strong>search.js</strong></p>
<pre><code>$('input#media-search').on('click', function() {
var media = $('input#media').val();
if ($.trim(media) != '') {
$.post('search.php', {media: media}, function(data) {
$('div#media-list').html(data);
location.hash = "#search=" + media;
});
}
});
</code></pre>
<p><strong>search.php</strong></p>
<pre><code>if (isset($_POST['media']) === true && empty($_POST['media']) === false) {
require 'connect.php';
$query = $db->prepare("SELECT `media`.`id`,
`media`.`title`
FROM `media`
WHERE `media`.`title`
LIKE :search
");
$query->bindValue(':search', '%' . $_POST['media'] . '%', PDO::PARAM_STR);
$query->execute();
if($query->rowCount() == 0) {
echo 'File';
}
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
echo "<li><a href='#" . $row['id'] . "' name='" . $row['id'] . "'>" . $row['title'] . "</a></li>";
}
}
</code></pre>
| jquery | [5] |
960,213 | 960,214 | programatically off the sound on tapping mute button on iphone | <p>Can anyone tell how to progmatically Disable the sound when mute button of iphone pressed while playing audio file.
i'm using streamer for audio</p>
<p>Thanks in advance....</p>
| iphone | [8] |
5,838,392 | 5,838,393 | How to add multiple textbox controls using a loop and change ID | <pre><code><%
for(int i = 0 ; i < 10 ; i++) {
%>
<asp:CheckBox ID="CheckBox<%=i %>" runat="server" />
<%
}
%>
</code></pre>
<p>But this code is not working
How can I add multiple controls using loops by this method?</p>
| asp.net | [9] |
3,159,393 | 3,159,394 | Can we multiply two bytes directly by using * operator directly | <p>I need to perform the following operation on a byte <code> (2*x*x)+x </code> where x is a single byte. Can i perform that operation directly as we will do for int. If no how can we perform above operation.</p>
| java | [1] |
5,243,802 | 5,243,803 | android, Samsung 10.1, drawable image resizes | <p>I'm developing an app for Samsung 10.1.
Pictures are stored in drawable-hdpi folder.</p>
<p>when I use ImageView to show the picture, the image is somehow resized.
for example, 1280x60 size image is shown as a 853x43 image.</p>
<p>Any idea why the image is resized and how to prevent resizing?</p>
| android | [4] |
203,296 | 203,297 | How to navigate from one screen to another screen automatically? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1979524/android-splashscreen">Android SplashScreen</a> </p>
</blockquote>
<p>I am new to android application development.</p>
<p>I developed one android application using android sdk. i install .apk file in samsung tab,and it is working properly.</p>
<p>But my requirement is before my application home page launching i have to display my company logo in one screen and my application title in another screen each 5sec after that my application home page have to display automatically.</p>
<p>please help me go forward.</p>
| android | [4] |
2,209,151 | 2,209,152 | Determining the presence of a file with JavaScript? | <p>I have folder/file tree generated by JavaScript where the folder and files each have checkbox inputs with paths associated with them, like:</p>
<pre><code>/var/www/site/user/folder7/ or
/var/www/site/user/folder7/file.txt or
/var/www/site/user/folder7/file.? (? being any file extension)
</code></pre>
<p>In the case of these paths I need only</p>
<pre><code>/var/www/site/user/folder7
</code></pre>
<p>I know that normally to remove file names one would use something like:</p>
<pre><code>var full_path = node.context.nextElementSibling.value;
var folder_target_path = full_path.substring(0, full_path.lastIndexOf("/"));
</code></pre>
<p>However this return either:</p>
<pre><code>/var/www/site/user/folder7 or
/var/www/site/user
</code></pre>
<p>I could use the lastIndexOf() method if I could use some regex to find .? and then up to the last '/'; however I am fairly new to javascript and have never used regex in it. </p>
<p>Could you suggest an effecient way to get only the folder and not the file path in all cases?</p>
<p>Regards,
Steve</p>
| javascript | [3] |
4,424,520 | 4,424,521 | Rectifying JScript runtime error | <p>When i am running the application,i got an error as follows:</p>
<p>Microsoft JScript runtime error:Sys.ArgumentTypeException:Object of type 'Sys._Application' cannot be converted to type 'Sys._Application'.Parameter name:instance</p>
| asp.net | [9] |
1,806,285 | 1,806,286 | Android: What is android.R.id.content used for? | <p>Anybody could explain the meaning of "android.R.id.content" ?</p>
<p>How is it being used ?</p>
<p><a href="http://developer.android.com">http://developer.android.com</a> does not have any explanation.</p>
<p>public static final int content
Since: API Level 1</p>
<p>Constant Value: 16908290 (0x01020002)</p>
| android | [4] |
400,378 | 400,379 | C# Return private objects | <p>Are there any guidelines to return an object of a class? I have a class which has a List and a method which do something with the list and returns that list:</p>
<pre><code>public class Foo
{
private List<Bar> _myList = new List<Bar>();
public List<Bar> DoSomething()
{
// Add items to the list
return _myList;
}
}
</code></pre>
<p>I don't think this is a good way to return the list, because now the calling method can modify the list and thus the list in the object Foo is updated. This can lead to unexpected and unwanted behaviour.</p>
<p>How do you handle this kind of situations? Do you make a copy of the object (in this case the list) and return that object, or.. ? Are there any best practices or tricks?</p>
| c# | [0] |
5,558,901 | 5,558,902 | How can I extract specified information from a webpage by php? | <p>Is there any algorithm to extract specified information from a webpage by php?For example,I want to extract weather information in a webpage.But the position of the weather information is always chaning.How to do this?</p>
| php | [2] |
4,831,107 | 4,831,108 | How to create dialer style filter box in android custom title bar? | <p>Hello Guys can you help me for creating a TextView in title bar so that if we type
'a' in that TextView than all entries in the ListView starting with 'a' only will get displayed.</p>
<p>The TextView will be something of type filterBox in Contact list.</p>
<p>Thanks in advance.</p>
| android | [4] |
2,348,916 | 2,348,917 | android:layout_gravity="center_horizontal" in Java code | <p>I have added a Button to a view in java code. Basically I want to add the xml</p>
<pre><code>android:layout_gravity="center_horizontal"
</code></pre>
<p>to the Button but do this in Java code, how is this done?</p>
| android | [4] |
3,100,818 | 3,100,819 | Java chat client connecting to server | <p>I have created a chat server that works with telnet. Now, I am trying to write my own client. I need to be able to get an IP address from the user and a port number. I am trying to pass those variables through the ChatClient(). However, when I compile the following code, I receive the following error message: </p>
<pre><code>ChatClient.java:24: cannot find symbol
symbol : variable ip
location: class ChatClient
new ChatClient(ip,port);
^
ChatClient.java:24: cannot find symbol
symbol : variable port
location: class ChatClient
new ChatClient(ip,port);
^
2 errors
</code></pre>
<p><strong>ChatClient.java</strong></p>
<pre><code>public class ChatClient {
PrintWriter output;
BufferedReader input;
Socket client;
public ChatClient(int ip, int port) throws Exception {
String line;
input = new BufferedReader( new InputStreamReader( client.getInputStream()) ) ;
output = new PrintWriter(client.getOutputStream(),true);
output.println("Enter an ip address: ");
line = input.readLine();
output.println("Enter a port number: ");
line = input.readLine();
}
public static void main(String ... args) {
try {
new ChatClient(ip,port);
} catch(Exception ex) {
out.println( "Error --> " + ex.getMessage());
}
} // end of main
}
</code></pre>
| java | [1] |
3,840,209 | 3,840,210 | Get list of dictionary elements ordered by dictionary key | <p>I have a dictionary <code>d</code> for which the keys are all strings. Now when I do:</p>
<pre><code>for key in d:
print(d[key])
</code></pre>
<p>I get the elements of <code>d</code> is some "random" order. How can I force the element of <code>d</code> to come out sorted by the lexicographical order?</p>
| python | [7] |
3,337,943 | 3,337,944 | Click a button and it should load the content into the main content area | <p>I have create 3 buttons on the left menu for "Cars," "Music," and "Games"
When the user clicks one, it should load the appropriate contents into a DIV
in the main content area. Each button should replace the contents of anything
previously displayed in the div. I created my buttons, but I do not know how to
load the content into the main content div or how to replace the previous content.
Can you help please?</p>
| javascript | [3] |
3,992,514 | 3,992,515 | Sorting nested JSON array | <p>I'm attempting to sort this JSON object:</p>
<pre><code>JSONObject = {
"command": [{
"geobox": [...],
"jobName": "...",
"keywords": ["..."],
"users": ["..."]
}, {
"geobox": [...],
"jobName": "...",
"keywords": ["...", "..."],
"users": ["...", "...", "..."]
}],
"type": "..."
}
</code></pre>
<p>It has "command" which is an array of nested json objects and "type" which I don't really care about. I want it to sort the array of nested json objects in "command" in alphabetical order based on the jobName value.
I tried something like this but it didn't work.</p>
<pre><code>JSONObject.command.sort(function (a, b) {
return JSONObject.command[a].jobName - JSONObject.command[b].jobName
});
</code></pre>
| javascript | [3] |
2,657,508 | 2,657,509 | using regular expressions to highlight links in a text | <p>hi i am trying to highlight links in a text using RegEx ,For this I tried with match() method and replace() method,
but i didn't get it.plz any one can help me.</p>
<p></p>
<pre><code><head runat="server">
<title></title>
<script type="text/javascript" >
function findReplace() {
var srcString = document.getElementById('new').innerHTML;
var pattern = new RegExp("<[^<]+</a>", 'ig');
var newString = srcString.match(pattern);
for (var i = 0; i < newString.length; i++) {
var replaced = srcString.replace(pattern, '<div style="background-color: yellow; display: inline; font-weight: bold;"> ' + newString[i] + ' </div>')
document.getElementById('new').innerHTML = replaced
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type='button' id='btn'value='Match' onclick="findReplace()" />
<div id='new'>
Finally we have succeeded! <a href='#'>Remember</a> that if you just want to replace one word,
you should use a string or normal regular expression as your searchFor parameter. However,
if you want to replace <a href='#'>google</a> be sure to write a <a href='#'>regularexpression</a> and append a little g at the end!
</div>
</form>
</body>
</html>
</code></pre>
| javascript | [3] |
4,930,100 | 4,930,101 | Android custom codec or encrypt media file? | <p>I want to create an application which permits to the user to download media files and play them, but only with my application. So first of all I thought that encrypting files will be a good solution, but it takes to much. Now I'm thinking to create a custom codec for my media files. I didn't work until now with codecs so how complicated is to make one for Android? Can be made in java or only in C and used via JNI? Also can you recomand me some useful books for understanding how are codecs created?</p>
<p>Thanks in advance!</p>
| android | [4] |
5,999,854 | 5,999,855 | Calling onLocationChanged() function on Android | <p>I am using <code>locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);</code> in Android. </p>
<p>If I set minimum time = 120000 and distance = 10000, if user moves 11000 meter in 60000 millisecond, then location changed function will execute or not?</p>
<p>I want to know then when the <code>onLocationChanged()</code> function is called.</p>
<p>Maybe something like:</p>
<ul>
<li>If time = 120000 and distance = 10000 then execute (...)</li>
</ul>
<p>or:</p>
<ul>
<li>or time = 120000 or distance = 10000 then execute (...)</li>
</ul>
| android | [4] |
437,165 | 437,166 | breadcrumb does not display title of the nav in Php | <p>I recently started learning php and I'm not being able to understand why my code does not get the parent value <strong>("Clients")</strong> when I click on the sublink UX/UI.</p>
<p>$sel_subject is the Titles on the Navbar and $sel_page is the subpage titles
When I click on the Title it shows up on the breadcrumb but when I click on the subpages the Title are blank, having issue with the following code.</p>
<pre><code> **$output_sub_nav .= "<li> {$sel_subject[ 'menu_name' ]}</li>" ;**
</code></pre>
<p><strong>Navbar Image:</strong>
<img src="http://i.stack.imgur.com/3VFpT.png" alt="nav bar"></p>
<p><strong>My Code below:</strong></p>
<pre><code>function breadcrumbs ( $sel_subject ,$sel_page , $sel_rnav )
{
$output_sub_nav = "<ul class =\"breadcrumbs\">" ;
$output_sub_nav .= "<li><a href =\"index.php\">HOME</a></li>" ;
if ( ! is_null ( $sel_subject ) )
{
$output_sub_nav .= "<li> {$sel_subject[ 'menu_name' ]}</li>" ;
}
elseif ( ! is_null ( $sel_page ) )
{
**$output_sub_nav .= "<li> {$sel_subject[ 'menu_name' ]}</li>" ;**
$output_sub_nav .= "<li> {$sel_page[ 'menu_name' ]}</li>" ;
}
elseif ( ! is_null ( $sel_rnav ) )
{
$output_sub_nav .= "<li> {$sel_rnav[ 'menu_name' ]}</li>" ;
}
$output_sub_nav .= "</ul>" ;
return $output_sub_nav ;
}
</code></pre>
| php | [2] |
4,017,316 | 4,017,317 | jQuery UI sortable - allow dropping to parent | <p>How can I make it so a jQuery UI sortable that allows dragging between different lists, will also accept being dropped on a parent?</p>
<p>See <a href="http://jsbin.com/odupi5/4" rel="nofollow">this example on JSBin</a>, where there are 3 lists, one of them empty. When dragging any list item, and dropping it on the <code><div></code> elements that wrap the lists (green), I want that item to go to the end of the contained <code><ul></code> (red). The sortable's <code>update</code> function needs to be called automatically as well. How?</p>
<pre><code>$('.sortable').sortable(
{
accept: '.sortable li',
connectWith: '.sortable,.container',
update: function () { alert('done with the moving'); }
});
</code></pre>
<p>My attempt (doesn't work) is to make the containing <code><div></code> a droppable target, as follows:</p>
<pre><code>$('.container').droppable(
{
accept: '.sortable li',
drop: function(event, ui)
{
ui.draggable.appendTo($(this).find('ul'));
}
});
</code></pre>
| jquery | [5] |
3,029,965 | 3,029,966 | changing the color of titleFor Header in section | <p>-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
hi
i am very new in objective c.......................through this method we can get the title for header section .but how to change the color of that string??can we do that........if any one knows that please tell me.</p>
<p>Regards </p>
| iphone | [8] |
2,834,836 | 2,834,837 | How do I check if a process is running from c++ code? | <p>I'm writing a C++ app that will communicate with another process via boost::interprocess, however I need to check if the other process is actually running first - as the other process is responsible for creating the inter-process shared memory. How do I check if the other process is running ?</p>
<p>folks, I'm specifically required to check other processes</p>
| c++ | [6] |
5,471,396 | 5,471,397 | Input String was not in correct format in asp.net | <p>We've been facing an issue while saving our page. It throws "Input String was not in correct format". After trying so many time, we found there was no problem with the code, but with the "Cache (Temporary Internet File"). After Cache was cleared, it saved without any error. Does anyone knew the reason behind it?</p>
| asp.net | [9] |
379,565 | 379,566 | Maximum size of Stream/Bitmap in WallpaperManager | <p>I'm trying to set a resource/stream as Wallpaper in Android. I use the WallpaperManager class and its methods setResource/setStream to do this. I normally scale the images using BitmapFactory.Options before I set them as wallpaper. But this time I wanted to try the full image without any scaling. So I tried to set an image with a resoultion of 5005 x 3274 as wallpaper, without any scaling. And to my surprise, the avd's wallpaper changed to the default stock wallpaper. No exception and no error logs. Below is the code I use. </p>
<p>So is there any limit for the size of wallpaper that can be set? I cannot find any information about maximum image size in WallpaperManager docs. Any help would be appreciated.</p>
<pre><code>public void onBtnClick(View view) {
Thread t = new Thread(new Runnable() {
public void run(){
try{
mgr.setResource(R.drawable.wallpaper);
mHandler.post(new Runnable() {
public void run(){
Toast.makeText(MainActivity.this, R.string.toast_success, Toast.LENGTH_SHORT).show();
}
});
} catch(Exception ioe) {
Log.w("WallpaperManager", ioe.getMessage());
}
}
}
}
</code></pre>
| android | [4] |
3,714,458 | 3,714,459 | what compiler does internally for initializing a variable and assigning a variable while constructing object? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/926752/why-should-i-prefer-to-use-member-initialization-list">Why should I prefer to use member initialization list?</a> </p>
</blockquote>
<p>Class A has a member variable i. i can be initialized or assigned during object creation.</p>
<p>A) Initialise</p>
<pre><code> class A {
int i;
public:
A(int _i) : i(_i){}
}
</code></pre>
<p>B) assign</p>
<pre><code>class A {
int i;
public:
A(int _i) : { i = _i}
}
</code></pre>
<p>My question is what is the basic difference between these 2 approach?</p>
| c++ | [6] |
5,749,398 | 5,749,399 | javascript removechild | <p>I am trying to delete a hidden element. I have tried the following codes but it always returns the parent as undefined.</p>
<p>attempt one</p>
<pre><code>var timeLeft = document.getElementById("time");
timeLeft.document.removeChild(timeLeft);
</code></pre>
<p>attempt two</p>
<pre><code>var timeLeftBody, timeLeft;
timeLeftBody = document.getElementsByTagName("body")[0];
timeLeft = document.getElementById("time");
timeLeft.timeLeftBody.removeChild(timeLeft);
</code></pre>
| javascript | [3] |
3,504,313 | 3,504,314 | Why python does not allow hyphens | <p>I have always wondered why can't we use hyphens in between function names and variable names in python</p>
<p>Having tried functional programming languages like Lisp and Clojure, where hyphens are allowed. Why python doesn't do that.</p>
<pre><code># This won't work -- SyntaxError
def is-even(num):
return num % 2
# This will work
def is_even(num):
return num % 2
</code></pre>
<p>I am sure Sir Guido must have done this because of some reasons. I googled but couldn't manage to find the answer. Can anyone please throw some light on this?</p>
| python | [7] |
529,369 | 529,370 | jQuery popup div fades out after fading in | <p>I have a DIV element right at the beginning of my HTML code</p>
<pre><code><div id="popup"></div>
</code></pre>
<p>Its CSS <code>display</code> property is set to <code>none</code> initially. Now when I click on specific HTML elements, the following happens:</p>
<pre><code>$('#popup-opener-button').click(function() {
$('#popup').fadeIn();
});
</code></pre>
<p>This works like charm. Now I'd like this DIV to disappear whenever I click anywhere on the screen, except when clicking on the DIV itself. I thought this would do it:</p>
<pre><code>$('#popup').siblings().click(function() {
$('#popup').fadeOut();
});
</code></pre>
<p>but as the SPAN I'm clicking on to fade in my popup div is actually the child of #popup's sibling, it instantly fades out right after fading in. Is there a way not to do this?</p>
| jquery | [5] |
2,450,292 | 2,450,293 | function returning released objects | <p>I have made a custom singleton class with an nsmutabledictionary as a property.I set and retrieve values in this class through two methods </p>
<pre><code>-(void)setObject:(id)object forKey:(NSString*)key
{
if(!object||object==nil)
{
return;
}
[self.dict setObject:[object retain] forKey:key];
}
</code></pre>
<p>and objectForKey</p>
<pre><code>-(id)objectForKey:(NSString*)key
{
id obj=[self.dict objectForKey:key];
return obj;
}
</code></pre>
<p>The reason i do this is that while i save and retrieving values from nsuserdefaults in iterative methods(10000 loops or higher) the code is much slower.Hence i built a class mimicing the functionality of nsuserdefaults . The problem is that sometimes the values returned from this class is already released.As a result the code crashes ,Is there any further validations we can make so that this class returns only non released objects</p>
| iphone | [8] |
4,960,253 | 4,960,254 | android Messagebox | <p>android Messagebox doesn't show because of <strong>finish</strong> call, how to make this function wait for ok and then close</p>
<pre><code>public void msbox(String str,String str2)
{
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setMessage(str2);
dlgAlert.setTitle(str);
dlgAlert.setPositiveButton("OK", null);
dlgAlert.setCancelable(true);
dlgAlert.create().show();
finish();
}
</code></pre>
<p>should be like this</p>
<pre><code>public void msbox(String str,String str2)
{
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setTitle(str);
dlgAlert.setMessage(str2);
dlgAlert.setPositiveButton("OK",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
finish();
}
});
dlgAlert.setCancelable(true);
dlgAlert.create().show();
}
</code></pre>
| android | [4] |
2,102,136 | 2,102,137 | Is there any way to get cookie response quickly? | <p>I have written a simple code in page <strong>test_cookie.php</strong> to work with cookies.</p>
<pre><code>if(isset($_GET['data'])) {
setcookie('test_cookie', $_GET['data'], time()+60*60*24*30);
}
echo 'Cookie name is: ' . $_COOKIE['test_cookie'];
</code></pre>
<p>Now once cookie is set to something, and I set the value to something else (using $_GET), then the content value doesn't change quickly. I have to refresh it again, if a new value comes.</p>
<p>Here is a picture example:</p>
<p><img src="http://i.stack.imgur.com/bSLc0.png" alt="Cookie Problem"></p>
| php | [2] |
4,076,075 | 4,076,076 | Issue With Request.Form.Get | <p>I have a dropdown list which is autopostback enabled.it contains several values.On selected_Index change event of dropdown i'm loading a gridview and it works fine.I have a Button called clearall which is supposed to change the dropdown list index to 0 and reset the gridview but when i click on the Button it will change the dropdown Index to 0 but does not reset the gridview.gridview display data of previous dropdown list selection.when i click on the button for the second time gridview is reset.</p>
<p>i'm using</p>
<pre><code>dRev = Request.Form.Get("ctl00$ContentPlaceHolder2$pnlSearchL2$i0$ddlDRevision");
</code></pre>
<p>to get the dropdownlist value and reset the gridview.looks like Request.Form.Get gets the old value on first button click.how can i solve this?</p>
| asp.net | [9] |
5,328,395 | 5,328,396 | How to handle objects with length of one and greater than one in a method without redunancy | <p>I'm writing my own JavaScript bind method (for practice) and am having trouble letting go of the need to handle single objects vs multiple objects differently in this method, solely because I need to loop through objects with a length greater than one. (see obj vs obj[i] below)</p>
<p><strong>Is there any way I can make this bind method less redundant feeling?</strong> (please assume using another library is out of the question.. thanks)</p>
<pre><code>var foo = (function () {
return {
bind: function (obj, type, handler, delegate) {
var delegate = delegate || false,
len = obj.length;
if (typeof obj == 'undefined') {
return false;
}
if (len > 1) {
for (var i = 0; i < len; i++) {
if (obj.addEventListener) {
obj[i].addEventListener(type, handler, delegate); // false: bubble (^). true: capture (v).
} else if (obj.attachEvent) {
obj[i].attachEvent('on' + type, handler);
} else {
obj[i]['on' + type] = handler;
}
}
} else {
if (obj.addEventListener) {
obj.addEventListener(type, handler, delegate); // false: bubble (^). true: capture (v).
} else if (obj.attachEvent) {
obj.attachEvent('on' + type, handler);
} else {
obj['on' + type] = handler;
}
}
}
}
})();
</code></pre>
| javascript | [3] |
409,275 | 409,276 | Android EditText | <p>in my custom listview that Contain an image and EditText ,and in EditText i can comment the photo ,i can give text comment max length of 50 ,when i lost the focus in EditText i want to rearrange the text in EditText in following format</p>
<p>EG: suppose comment contain 40 char and user can at a time directly view only 20 char,then if i lost the focus text should be rearranged that at the end there should be 3 dot</p>
<p>Original Comment i wirte:eg-> eeeeeeeeeeeeeeeeeeeeeeeeeee
after i lost focus it should shown as-> eeeeeeeee...</p>
<p>it's importent that the nothing happens to original text because these text i want to send to server, and i directly take these values,and if am replace the text by new this type of text this will create problem, also when i gain focus i need to see full text also. </p>
<p>NB: i set android:singleline=true</p>
| android | [4] |
4,380,350 | 4,380,351 | Notifiy the user in a Thread | <p>Hy!!</p>
<p>Code:</p>
<pre><code>final ProgressDialog pd = ProgressDialog.show(Main.this,"","Loading. Please wait...", true);
pd.show();
Thread t = new Thread() {
public void run(){
result = GetData("link", nameValuePairs);
pd.dismiss();
if(result.contains("Logged IN"))
{
user=etuser.getText().toString();
}
else
{
fail();
}
}
};
t.start();
</code></pre>
<p>Fail Function:</p>
<pre><code>public void fail ()
{
final TextView tverror = new TextView(this);
tverror.setText("FAIL");
linear_l.addView(tverror);
}
</code></pre>
<p>Error: It isn't possible to add a view during the run in the thread.</p>
<p>Is there any workaround?</p>
| android | [4] |
5,683,417 | 5,683,418 | How to Download an image from FTP using FTPClient? | <p>I m using this code and try to download an png pic from server .this is code</p>
<pre><code>import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.imageio.ImageIO;
import org.apache.commons.net.ftp.FTPClient;
public class NetTest {
public static void main(String[] args){
FTPClient client = new FTPClient( );
OutputStream outStream;
try {
client.connect( "server" );
client.login("[email protected]", "pass");
String remoteFile = "Pages/page0001.png";
outStream = new FileOutputStream( "C:\\asd.png" );
client.retrieveFile(remoteFile, outStream);
} catch(IOException ioe) {
ioe.printStackTrace();
System.out.println( "Error communicating with FTP server." );
} finally {
try {
client.disconnect( );
} catch (IOException e) {
System.out.println( "Problem disconnecting from FTP server" );
}
}
}
}
</code></pre>
<p>this code gives me no error but when i open the image it shows me invalid image .</p>
| java | [1] |
2,386,822 | 2,386,823 | php update password or save defualt if it is blank | <p>Can someone point me out how can I save the default password if it is blank?
Its an update issue. Im making an update page when the user update their profile.
Its a long profile info. I did not post it all here coz my only problem is the password field.
Even if it is leave as blank it still updating the field on the database.I use md5 for encryption. Below is the code. Please just add the code, your code. Thank you.</p>
<p>The id is=1 because im just testing it. Ill only have one data in the userstest table.</p>
<pre><code> $desire= $_POST['desired'];//username field
$password = md5(trim(mysql_prep($_POST['password'])));//password field
$passconfirm = md5(trim(mysql_prep($_POST['confirmpassword']))); //confirmpasswor field
$sql = mysql_query("UPDATE userstest SET username = '$desire',password='$password',confirmpassword='$passconfirm' WHERE id=1");
if(mysql_affected_rows()==1){
echo "Update Successfull";
}else{
echo "Update Failed" . mysql_error();
}
</code></pre>
| php | [2] |
923,484 | 923,485 | What are some of the more obscure parts of C++? | <p>I've read quite a few beginner's books on C++, and a little beyond that, but what are some of the more obscure aspects of C++, or where can I find information/tutorials on these?</p>
| c++ | [6] |
1,601,588 | 1,601,589 | In UIActionSheet UITextView disable copy, select, select all, define functionality | <p>In <strong>UIActionSheet</strong> used <strong>UITextView</strong> in that <strong>Copy, Cut, Select, Select All</strong> functionality shows. I don't require this functionality. Please tell me how to disable this functionality in <strong>UIActionsheet UITextView</strong>.</p>
<p>I used </p>
<pre><code>self.textView.userInteractionEnabled = NO;
</code></pre>
<p>but then it disables scrolling functionality which i require. So please help me out here.</p>
| iphone | [8] |
1,319,197 | 1,319,198 | get word document | <p>I have a directory which have a few word documents (.doc) files. I want to get each one from that directory and put them into a list so I can open them. How do I loop through to get them and once I get them how do I open them. </p>
| c# | [0] |
4,015,349 | 4,015,350 | Getting caller identification in Android | <p>I am making an application which can call the name of the person who is calling.</p>
<p>I work with a TTS library, but I am not able to get the caller identification. Where can I get it?</p>
| android | [4] |
739,802 | 739,803 | Is it possible to to declare variables within a condition? | <p>This is how I would do a while loop:</p>
<pre><code>boolean more = true;
while (more)
{
// do something
if (someTest())
{
more = false;
}
}
</code></pre>
<p>That's pretty standard. I'm curious to know if there's a way of doing something similar to the code below in Java: (I think I've seen something like it in C)</p>
<pre><code>// The code below doesn't compile (obviously)
while (boolean more = true)
{
// do something
if (someTest())
{
more = false;
}
}
</code></pre>
<p>I only ask this because currently I don't like the way I'm defining the variable used in the condition (in this case: "more") <em>outside</em> the scope of the loop, even though it's only relevant <em>inside</em> the loop. There's no point it being left hanging around after the loop has finished.</p>
<hr>
<p><strong>* * Update * *</strong></p>
<p>An idea came to me following a visit to the Porcaline Chamber of Secrets:</p>
<pre><code>for (boolean more=true; more; more=someTest())
{
// do something
}
</code></pre>
<p>It's not perfect; It's abusing the for loop and I can't think of a way to execute the loop <em>at least once</em>, but it's close... Is there a way to make sure the loop is performed 1+ times?</p>
| java | [1] |
3,006,748 | 3,006,749 | when motorola milestone will get android 2.2? | <p>when motorola milestone will get android 2.2?</p>
| android | [4] |
2,121,364 | 2,121,365 | Covariant return type in Java | <p>The following code uses the concept of method overriding in Java.</p>
<pre><code>package pkg;
import java.util.ArrayList;
import java.util.List;
abstract class SuperClass
{
abstract public List<String>getList();
}
final class SubClass extends SuperClass
{
private List<String>list=null;
@Override
public ArrayList<String> getList()
{
list=new ArrayList<String>();
list.add("A");
list.add("B");
return (ArrayList<String>) list;
}
}
final public class Main
{
public static void main(String[] args)
{
SuperClass s=new SubClass();
List<String>list=s.getList();
for(String str:list)
{
System.out.println(str);
}
}
}
</code></pre>
<p>By convention, method overriding uses the same signature (with return type) in both super class and subclass. In the above code, the return type of the <code>getList()</code> method in the <code>SuperClass</code> is <code>List</code> and in its subclass the return type is <code>ArrayList</code>. How does method overriding work here?</p>
<p>By the way, it's obvious that <code>ArrayList</code> is an implementation of the <code>List</code> interface but how does the compiler treat the return type here while overriding the <code>getList()</code> method?</p>
<p>Should I believe something like this... <em>The return type of the overridden method is allowed to be a subtype of the overridden method's return type.</em></p>
| java | [1] |
1,963,906 | 1,963,907 | How to delete end of a string in python | <p>I have a string looks like this</p>
<pre><code>urse/project/kb/use.js
</code></pre>
<p>from this string i need to get</p>
<pre><code>urse/project/kb/
</code></pre>
<p><code>use.js</code> the name will always change except <code>.js</code>.</p>
<p>Or delete the string till the first <code>/</code> from the end?</p>
| python | [7] |
490,894 | 490,895 | button click check? | <p>I WANT to find out if a there is a way
to check if a group of buttons are being clicked
for exp. if i have nine buttons and i want to check
to see if any of the nine is clicked like </p>
<pre><code>if(button1.text ==""
button2.text ==""
button3.text==""
button4.text==""
button5.text=="" )
</code></pre>
<p>so instead of checking each Individual click we can have it check
nomatter what button is clicked????</p>
| c# | [0] |
3,063,276 | 3,063,277 | can we get the list of all open urls in browser from java script | <p>Is it possible to get urls of all the tabs open in the browser from java script...Is it any browser dependent thing ?</p>
| javascript | [3] |
3,032,613 | 3,032,614 | Sharing an object between activities | <p>I have a Weather app with four Activities. The main/launcher activity is 'invisible' using...</p>
<p>android:theme="@android:style/Theme.Translucent.NoTitleBar"`</p>
<p>...and is simply used to do a few checks (whether this is a new install, whether a network connection is available etc) before firing off one of the other Activities. The other Activities are UI-oriented - two simply display weather data pulled from a website and the third to provide a location 'picker' so the user can choose which area to show the weather for.</p>
<p>However, all four activities make use of a WeatherHelper object which basically does everything from checking for available SD card storage to maintaining preferences and pulling/formatting website pages.</p>
<p>So, my question(s)...what is the best way to have one instance of WeatherHelper which can be used by multiple activities and where/how are best to create it in my case?</p>
<p>I've been an OO programmer for a lot of years but I'm very new to Android and the design concepts - I've read a lot on the Android Developers site over the past weeks but I've stalled trying to decide on this.</p>
<p>Any ideas gratefully received.</p>
| android | [4] |
490,936 | 490,937 | Loop through database rows and create a single array | <p>I have nooby PHP question that I can't figure out!</p>
<p>I loop through rows from my database:</p>
<pre><code> $data = array();
while($row = sqlsrv_fetch_array($queryResult, SQLSRV_FETCH_ASSOC)){
$data[] = $row;
}
</code></pre>
<p><code>$data</code> now contains an array within an array how can I have it so that its still just a single array?</p>
<p>Thanks all</p>
| php | [2] |
1,410,932 | 1,410,933 | getting java.lang.ClassFormatError if i use SMTP code | <p>I am trying to send a mail by SMTP from my code in java.
The problem occuring is quite unique and i am not sure if any of you guys have faced the same kind of issue.
I have already a bunch of existing code which runs fine without any error when i run if from Maven without the code for the SMTP in it.
But the moment i integrate the code to send mail by SMTP in it i start getting wierd exceptions and the jar file execution from Maven fails.
Below is the error</p>
<pre><code>Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/mail/Message
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
</code></pre>
<p>I searched the net also but could not get any proper solution as to why this wierd exception is occuring againa and again.
Can you please provide your comments on the sam as i have been stuck with this issue for a very long time now.</p>
| java | [1] |
1,469,557 | 1,469,558 | Jquery, Extract child text | <p>Here is html code, </p>
<pre><code><li class="comment-content">
Target String!!!
<span class="comment-time">2011-07-13 17:08:39</span>
<a title="comment" class="bottoml cof-comment" href="#">comment</a>
<a title="modify" class="bottoml cof-comment" href="#">modify</a>&nbsp;&nbsp;
<a title="delete" class="bottoml cof-comment" href="#">delete</a></li>
</li>
</code></pre>
<p>I can get comment-content's text using jquery like this,</p>
<pre><code>$(".comment-content").text();
</code></pre>
<p>the result is : </p>
<pre><code>Target String!!! 2011-07-13 17:08:39 comment modify delete
</code></pre>
<p>my question, can I get the string "Target String!!!" only using jquery?
without sub tag's text, direct child text only I mean.</p>
| jquery | [5] |
445,107 | 445,108 | create and save a webite url's snapshot using PHP and any third party service | <p>I want to capture the website screenshot to be saved in my server and displayed in my application.</p>
<p>Presently we were using some API from <a href="http://counter3.goingup.com/thumboo/" rel="nofollow">http://counter3.goingup.com/thumboo/</a> using the code below :</p>
<pre><code>$result = @file_get_contents("http://counter3.goingup.com/thumboo/image.php?i=20c41926583c26fe2297d7aae847e76c|||".$website_url."|||80x50");
@file_put_contents("asset/screenshot/".$file_name,$result);
</code></pre>
<p>Sinced last week it was generating and saving screenshots properly , but since this week , it's generating an <strong>invalid image</strong> . </p>
<p>Also , as the error is suppressed , it is saving the file , but it's actually a corrupted file</p>
<p>Please suggest how to achieve this . Is there any other free service that I can use alongwith PHP</p>
| php | [2] |
5,525,566 | 5,525,567 | Does somebody know some FAQ websites based on phpMyFAQ? | <p>Does somebody know some FAQ websites based on phpMyFAQ ? </p>
<p>Thanks
Joseph</p>
| php | [2] |
796,527 | 796,528 | UnknownHostException again! | <p>I posted one question previously and all of them answered that there is some problem with DNS but i changed my DNS to many addressed and now i have the most reliable, google DNS :-</p>
<pre><code>8.8.8.8
</code></pre>
<p>Still i get the same UnknownHostException. What can be the problem? This is my code :-</p>
<pre><code> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse("http://rss.news.yahoo.com/rss/india");
</code></pre>
<p>Infact if i pass address as something very common like :- <a href="http://google.com" rel="nofollow">http://google.com</a> i still get the same error. Please help me :(. I have my submissions tomorrow.</p>
<p>Thanks in advance :)</p>
<p><strong>EDIT</strong> : If i type the same address in my mozilla, it works great. So, i am sure that there is no DNS problem.</p>
<p><strong>2nd EDIT</strong> :- I found this link <a href="http://www.ehow.com/how_4747553_fix-unknownhostexception-java-applications-ubuntu.html" rel="nofollow">http://www.ehow.com/how_4747553_fix-unknownhostexception-java-applications-ubuntu.html</a></p>
<p>But when i run the command </p>
<pre><code>sudo apt-get install lib32nss-mdns
</code></pre>
<p>i get package not found.</p>
<p>Somebody even mentioned :-</p>
<pre><code>-Djava.net.preferIPv4Stack=true
</code></pre>
<p>But where do i write this statement of Djava?</p>
<p>I am using Netbeans 6.8 to run my web application</p>
| java | [1] |
5,283,501 | 5,283,502 | Better way to bind event in jquery | <p>I have a page where I have many controls and then I have a div element and have 10 asp buttons in that div element.</p>
<p>I want to bind mousehover event to only those buttons which are inside the div element.</p>
<p>Currently i m doing it like:</p>
<pre><code><script src="jquery-1.6.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#MangoPager_btn1").hover(mousehoverfunction);
$("#MangoPager_btn2").hover(mousehoverfunction);
$("#MangoPager_btn3").hover(mousehoverfunction);
$("#MangoPager_btn4").hover(mousehoverfunction);
$("#MangoPager_btn5").hover(mousehoverfunction);
$("#MangoPager_btn6").hover(mousehoverfunction);
$("#MangoPager_btn7").hover(mousehoverfunction);
$("#MangoPager_btn8").hover(mousehoverfunction);
$("#MangoPager_btn9").hover(mousehoverfunction);
$("#MangoPager_btn10").hover(mousehoverfunction);
});
</script>
</code></pre>
<p>Is there any way in jquery so that i can declare a list of button ids something like <code>[MangoPager_btn10,MangoPager_btn2,MangoPager_btn3]</code> so that i don't have to do that for every single button id.</p>
<p>I tried with <code>input</code> type but then it's applying the function for all input type objects not for buttons which are in the <code>div</code> elemet.</p>
<p>Any other bettrer way to do it in jquery ....
I </p>
| jquery | [5] |
5,460,733 | 5,460,734 | How to get a response to HTTPClient from a Servlet which is called from the HTTPClient? | <p>I am able to successfully post to a servlet using HttpClient. However i need a boolean parameter back to the HttpClient from the servlet and am not sure how to do the same. </p>
<p>Earleir i was using the common-httpclient-3.1.jar.However then i was made aware of the version upgrade of httpclient to 4.0 which assists in the Response handling from HttpResponse. Now I am using httpclient.4.0.3, httpcore-4.1 and httpmime-4.1.1. The code being tried by me is as below for the HttpClient.</p>
<pre><code>HttpClient client = new DefaultHttpClient();
HttpPost method = new HttpPost("http://localhost:9090/drools-guvnor/KeystoneServlet");
HttpEntity entity = method.getEntity();
List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
nvps.add(new BasicNameValuePair("directory", directory));
nvps.add(new BasicNameValuePair("username", username));
nvps.add(new BasicNameValuePair("password", password));
method.setEntity(new UrlEncodedFormEntity(nvps));
ResponseHandler responseHandler = new BasicResponseHandler();
HttpResponse response = client.execute(method, responseHandler);
System.out.println("responseBody: "+responseHandler.handleResponse(response));
</code></pre>
<p>In the KeyStoneServlet i am able to successfully get the parameters directory, username and password. Further using these parameter am doing a further processing and am able to retrieve a boolean parameter which i want back as a response to the HttpClient. However i do not know how can i do the same. The responseBody SOP above comes blank and doesnt show me anything.</p>
<p>Any assistance on the same will be highly appreciated.</p>
| java | [1] |
623,875 | 623,876 | Python String to List object | <p>I have this String (representing a JSON value):</p>
<pre><code>BABEL_JSON = "{
'BD': u'Bangladesh',
'WF': u'Wallis y Futuna',
'BF': u'Burkina Faso'
}"
</code></pre>
<p>and I need to transform into a List object like this:</p>
<pre><code>BABEL_LIST = [
("BD", u"Bangladesh"),
("WF", u"Wallis y Futuna"),
("BF", u"Burkina Faso")
]
</code></pre>
<p>What is the best way? to begin I tried with:</p>
<pre><code>import json
BABEL_LIST = json.loads(str(BABEL_JSON))
</code></pre>
<p>but I have this error:</p>
<pre><code>TypeError: 'NoneType' object is not callable
</code></pre>
| python | [7] |
3,702,890 | 3,702,891 | Can anyone give me the source code to get Horizontal Slide with the next page also visible as a background of the current page | <p>Can anyone give me the source code to get Horizontal Slide with the next page also visible as a background of the current page and with 2 or more xmls, each xml should be given with a different page integrated in the MainActivity..i am getting the Horizontal Scroll with ViewPager but unable to display the 1st page with the 2nd page at the right edge of the screen to show that there is next page available, and in the 2nd page we need to show the 1st page at left corner and 3rd page at right corner of the 2nd page .. please help me out with this..</p>
| android | [4] |
2,854,738 | 2,854,739 | getting strange results from framerate code in java | <p>I'm trying to keep my game at 60fps, but I'm getting strange results from my code like "2-8000 fps" Why isn't this staying at 60?</p>
<pre><code>public void run(boolean fullscreen) {
this.fullscreen = fullscreen;
try {
long lastFrame = 0;
long frames = 0;
init();
while (!done) {
frames++;
long startTime = System.nanoTime() / 1000000;
try
{
System.out.println("framerate: " + ((System.nanoTime() / 1000000 - startTime) / frames ) );
// 123456: 6 zeros => 16ms
long nsToSleep = 17000000 - (System.nanoTime() - lastFrame);
System.out.println("ns: " + nsToSleep);
lastFrame = System.nanoTime();
if(nsToSleep > 0)
{
System.out.println("ns2: " + (nsToSleep/1000));
System.out.println("ns3: " + (nsToSleep%1000));
Thread.sleep(nsToSleep/17000000, (int)(nsToSleep % 1000));
}
else
{
Thread.yield(); // Only necessary if you want to guarantee that
// the thread yields the CPU between every frame
}
}
catch(Exception e){
e.printStackTrace();
}
mainloop();
render();
Display.update();
}
cleanup();
}
catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
</code></pre>
| java | [1] |
5,630,201 | 5,630,202 | JavaScript and getElementById for multiple elements with the same ID | <p>How can I get a collection of elements by specifying their <code>id</code> attribute? I want to get the name of all the tags which has same <code>id</code> in the html.</p>
<p>I want to use ONLY <code>getElementById()</code> to get an array of elements. How can I do this?</p>
| javascript | [3] |
4,964,924 | 4,964,925 | files in folder in listview | <p>I want to make a listview of files in folder,but it doesn't work. What's wrong with this code?</p>
<pre><code>DialogResult wczytywanie_z_folderu = new DialogResult();
wczytywanie_z_folderu = folderBrowserDialog1.ShowDialog();
string[] pliki_w_folderze = Directory.GetFiles(folderBrowserDialog1.SelectedPath);
if (wczytywanie_z_folderu == DialogResult.OK)
{
List<string> lista = new List<string>();
lista = pliki_w_folderze.ToList();
int dl_listy = lista.Count;
int dlugosc = pliki_w_folderze.Length;
for (int i = 0; i == dlugosc; i = i + 1)
{
string alfabet = "abcdefghijklmnopqrstuwvxyz";
char[] litery = alfabet.ToCharArray();
Random r = new Random();
string temp = "";
for (int j = 0; j < 1; j++)
{
int random_letter = r.Next(litery.Length);
temp += litery[random_letter].ToString();
ListViewItem str = new ListViewItem(temp);
str.Text = lista[i];
listView1.Items.Add(str);
}
}
</code></pre>
| c# | [0] |
2,120,275 | 2,120,276 | How can I pass "this" into setTimeout callback? | <p><a href="http://jsfiddle.net/mnbayazit/M2W6Z/" rel="nofollow">fiddle</a></p>
<p><strong>code:</strong></p>
<pre><code><button onclick="this.disabled=true; setTimeout(function(){this.disabled=false;},500);">click</button>
</code></pre>
<p><code>this</code> seems to refer to the window rather than the button. How can I pass the button object in so that I can re-enable it?</p>
<p>I'm aware of workarounds... I could give the button an ID and then grab it again, but I'm interested to know if I can somehow pass <code>this</code> in.</p>
| javascript | [3] |
3,337,431 | 3,337,432 | how to close db connections in except clause | <p>originally, I didn't have a main() function. I just had a whole bunch of code in:</p>
<pre><code>if __name__ == '__main__':
</code></pre>
<p>I'm trying to refactor the code a bit so that it's a little cleaner and does come clean up in case the code raises an exception. So, now my code looks like this:</p>
<pre><code>if __name__ == '__main__':
try:
main()
except :
print "Unexpected error:", sys.exc_info()[0]
engine.close()
db.close()
</code></pre>
<p>the problem is, engine and db are both created inside of main(), so I don't really have a reference to them. Is there a way to handle the exception in this way, or do I have to make it more granular within the main() function?</p>
<p>edit:
<a href="http://effbot.org/zone/python-with-statement.htm" rel="nofollow">very helpful article about with statements</a></p>
| python | [7] |
1,692,712 | 1,692,713 | send information through a url from desktop based application | <p>i have to pass some information to a weburl and get a response in return from it.</p>
<p>This has to be done on a button click of a desktop based application made in c#.</p>
| c# | [0] |
3,103,094 | 3,103,095 | How to generate an alphanumeric incrementing id in PHP? | <p>I have system in PHP in which I have to insert a Number which has to like </p>
<pre><code>PO_ACC_00001,PO_ACC_00002,PO_ACC_00003.PO_ACC_00004 and so on
</code></pre>
<p>this will be inserted in Database for further reference also "PO and ACC" are dynamic prefix they could different as per requirement</p>
<p>Now my main concern is how can is increment the series 00001 and mantain the 5 digit series in the number?</p>
| php | [2] |
5,348,240 | 5,348,241 | Specify context of imported method | <p>I have two files. In the first there is a dictionary ready for export:</p>
<pre><code>__all__ = ['container']
def show_name(self):
myFunction()
print self.name
container = {
'show_name': show_name
}
</code></pre>
<p>In the second file I import <code>myFunction</code> and I define the class <code>Person</code>:</p>
<pre><code>from myModule import myFunction
class Person:
def __init__(self):
self.name = 'Bob'
self.show_name = types.MethodType(container['show_name'], self)
person = Person()
</code></pre>
<p>The problem is that when I call <code>person.show_name()</code> I get the error:</p>
<blockquote>
<p>NameError: global name 'myFunction' is not defined</p>
</blockquote>
<p>How can I have <code>Person.show_name</code> access the same functions <code>Person</code> does? </p>
| python | [7] |
5,572,324 | 5,572,325 | How to understand the following c++ code? | <pre><code>inpfile>>ch;
if(ch<16) outfile<<"0×0"<<std::hex<<setprecision(2)<<(int)ch<<" ";
</code></pre>
<p>what does <code>std::hex<<setprecision(2)</code> mean?</p>
| c++ | [6] |
1,659,551 | 1,659,552 | creating an ajax application | <p>I have several pages of my web application done. They all use the same master page so they all all look very similar, except of course for the content. It's technically possible to put a larger update panel and have all the pages in one big update panel so that instead of jumping from page to page, the user always stays on the same page and the links trigger __doPostback call-backs to update with the appropriate panel.</p>
<p>What could be the problem(s) with building my site like this? </p>
| asp.net | [9] |
5,974,866 | 5,974,867 | altering variable inside print/echo? | <p>cant you?</p>
<p>Instead of</p>
<pre><code>$next_page = $pageNumber + 1;
print '<a href="'.$url.'/page/'.$next_page.'">Next &raquo;</a>';
</code></pre>
<p>i would like to write it like this</p>
<pre><code>print '<a href="'.$url.'/page/'.$pageNumber+1.'">Next &raquo;</a>';
</code></pre>
<p>the last one gives my parse error. why?</p>
| php | [2] |
5,537,884 | 5,537,885 | sliding panels using jquery | <p>What is the best way to have a panel to slide down when a button is clicked? I need the panel to be movable. Are there any jquery plugins to achieve the same?</p>
<p>Thanks</p>
| jquery | [5] |
2,896,778 | 2,896,779 | View for scrollable, zoomable, clickable image? | <p>I need to show an image which is actually a map with coloured areas, also I need to be able to:
1. zoom in and out using two fingers
2. scroll the image as it is bigger than screen
3. clicks on the image, get clicked area pixel value(color), so that I know which area the user clicks </p>
<p>I searched many hours, tried many approaches:
1. Write a class that extends View, and display a Bitmap, I found a thread in the forum about it, but there is no zoom, and the scroll is not natural.
2. Use a WebView to display HTML file that contains the image, so there is zoom and scroll functionalities, however, I cannot control the limit of zoom in/out, also, when the user clicks, I'm not sure if I can get the position on the image map by adding scrollX, scrollY with touchX, touchY. As the image may be scaled up/down, also, there may be paddings that WebView adds to its content. </p>
<p>This really drives me crazy, can anyone help? </p>
| android | [4] |
5,694,785 | 5,694,786 | ButtonDown and ButtonUp events for Android screen buttons? | <p>Is there a way to get an onButtonDown or onButtonUp event for a soft button (i.e. not a physical hardware button, but a button on the screen)? I have a button on the screen that I want the user to hold down for X seconds. To do this I need to capture the buttonDown and buttonUp events separately.</p>
<p>Thanks,</p>
<p>Bret</p>
| android | [4] |
666,485 | 666,486 | Allow only numbers to be typed in a textbox | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/995183/how-to-allow-only-numeric-0-9-in-html-inputbox-using-jquery">How to allow only numeric (0-9) in HTML inputbox using jQuery?</a> </p>
</blockquote>
<p>How to allow only numbers to be written in this textbox ?</p>
<pre><code><input type="text" class="textfield" value="" id="extra7" name="extra7">
</code></pre>
| javascript | [3] |
3,886,779 | 3,886,780 | difference among "Density-compatibility" and "Size-compatibility" android | <p>Can someone explaing the difference among "Density-compatibility" and "Size-compatibility" please?</p>
<p>Thanks</p>
| android | [4] |
123,823 | 123,824 | How to close window in firefox using javascript? | <p>I am using top.window.close() to close the parent window but it is not working in Mozilla firefox.Please suggest alternatives.
The above code is working fine for IE6.</p>
| javascript | [3] |
2,955,328 | 2,955,329 | I have a problem with the following Java code | <pre><code>public class b {
public static void main(String[] args) {
byte b = 1;
long l = 127;
// b = b + l; // 1 if I try this then it does not compile
b += l; // 2 if I try this then it does compile
System.out.println(b);
}
}
</code></pre>
<p>I am using this code but I have problem:
I don't understand why <code>b=b+l;</code> is not compiling but if I write <code>b+=l;</code> then it compiles and runs.</p>
<p>Please explain why this happens.</p>
| java | [1] |
4,055,202 | 4,055,203 | PHP switch function doesn't recognize "less than 0" | <pre><code>$bytes = 0;
switch($bytes){
case $bytes == 0:
echo 'Equal to 0.';
break;
case $bytes < 0:
echo 'Less than 0.';
break;
}
</code></pre>
<p>This outputs "Less than 0."</p>
<p>Why?</p>
| php | [2] |
4,549,296 | 4,549,297 | Getting an object to work with array_walk_recursive in PHP | <p>I have an object that implements <code>IteratorAggregate</code> and <code>ArrayAccess</code>, which internally contains an array that will be generated when it is accessed.</p>
<p>I want to use <code>array_walk_recursive</code> on this object, but it does not seem to work. It seems that this is either impossible due to the implementation of <code>array_walk_recursive</code> or I just need to add an interface to my object. What am I missing?</p>
| php | [2] |
314,816 | 314,817 | Get value selected from drop down list in where clause using php code | <p>My code is like this:</p>
<pre><code>$zone = $_POST['zone'];
$state = $_POST['state'];
$sql = "Select zone_id from tbl_zone where zone_name = $zone";
$query = mysql_query($sql);
</code></pre>
<p>I am selecting zone name which is fetched from database and listed in drop down list.
Now i want to get id of zone name to store in other table.</p>
<p>In where clause zone_name is blank.
What changes should be done in above code?</p>
<p>Thanks in advance..</p>
| php | [2] |
2,903,278 | 2,903,279 | Python Path import problems | <p>I added a folder to my PYTHONPATH where I can put all of my Django Apps. I print sys.path, and everything looks good, the folder I want is there. However, when I go to import a module, it tells me that there's no module by that name. All the site-packages modules work fine. In all of my Django apps, there's an "<strong>__<em>init</em>__</strong>.py" like there's supposed to be. I heard that if those are created on windows there can be problems, but I couldn't dig up much more than that.</p>
| python | [7] |
3,943,790 | 3,943,791 | How to determine if a home screen shortcut exists? | <p>Is there a way to determine whether a particular home screen shortcut
exists? </p>
<p>My application installs a shortcut on the home screen at device
startup time under certain conditions and I don't want duplicate
shortcuts to appear. I also don't want Toast messages appearing saying
"Shortcut created" or "Shortcut already exists" every single time the
device boots. I've found an undocumented Intent Extra called
EXTRA_SHORTCUT_DUPLICATE which will prevent duplicate shortcuts from
being installed but the Launcher still displays the "Shortcut already
exists" Toast message. I'd rather not rely on this undocumented
Intent Extra if there is a supported technique for this.</p>
| android | [4] |
1,077,882 | 1,077,883 | How to make un clickable App Icon on Action Bar like YouTube App in android | <p>How to make un-clickable App Icon on Action Bar like YouTube App in android </p>
| android | [4] |
2,204,629 | 2,204,630 | inserting multiple row at time in sqlite | <p>I just created a method to insert into the database. But it still showing the same result. i,e unit1 only. the code is as follows
DbAdapter.java</p>
<pre><code>private static final String DATABASE_NAME="bible1";
private static final String DATABASE_TABLE="test1";
private static final int DATABASE_VERSION=1;
public static final String KEY_ID="_id";
public static final String UNITS="units";
public static final String CHAPTERS="chapters";
private static final String CREATE_DATABASE="create table test1 (_id integer primary key autoincrement, units text not null, chapters text not null);";
private static SQLiteHelper sqLiteHelper;
private static SQLiteDatabase sqLiteDatabase;
private Context context;
//constructor
public DbAdapter(Context c){
context = c;
}
private static class SQLiteHelper extends SQLiteOpenHelper{
public SQLiteHelper(Context context){
super(context,DATABASE_NAME,null,DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
// TODO Auto-generated method stub
db.execSQL(CREATE_DATABASE);
MakeUnits();
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
}
}
public DbAdapter open() throws SQLException{
try{
sqLiteHelper = new SQLiteHelper(context);
sqLiteDatabase = sqLiteHelper.getWritableDatabase();
}catch(NullPointerException ne){
Log.e("Database", "error in creating the table");
}
return this;
}
public void close(){
sqLiteHelper.close();
}
public static void MakeUnits()
{
createUnits("unit1","chapter1");
createUnits("unit2","chapter2");
}
public Cursor fetchAllNotes(){
return sqLiteDatabase.query(DATABASE_TABLE, new String[]{KEY_ID,UNITS,CHAPTERS}, null, null, null, null, null);
}
public static long createUnits(String units,String chapters){
ContentValues content= new ContentValues();
content.put(UNITS, units);
content.put(CHAPTERS, chapters);
return sqLiteDatabase.insert(DATABASE_NAME, null, content);
}
</code></pre>
<p>So What to do now? I think the method I created is correct.</p>
| android | [4] |
5,280,037 | 5,280,038 | how to make text field in tableview in iphone | <p>i want to know how to make text field in tableview in iphone.</p>
| iphone | [8] |
2,276,953 | 2,276,954 | jquery disable mouseover while waiting on callback | <p>I have a mouseover effect using jquerys animate. The effect makes a div grow in length by * 2 on mouseover and shrink back on mouseleave. This works fine apart from if you move the mouse in and out really quickly - the effect doesnt have time to catch up and so the div just keeps growing.</p>
<p>Is there anyway to disable any further events from firing on an element until the callback is reached?</p>
| jquery | [5] |
3,551,412 | 3,551,413 | why use an 'apply' function in this situation? | <p>in Chrome's console,</p>
<pre><code>> $$
bound: function ()
{
return document.querySelectorAll.apply(document, arguments)
}
</code></pre>
<p>why is this code like this?
what's difference with </p>
<pre><code> return document.querySelectorAll(arguments)
</code></pre>
<p>?</p>
| javascript | [3] |
5,126,400 | 5,126,401 | reading bytes from binary file to long int | <p>I have two question :</p>
<ul>
<li><p>I have a data on binary file. I want read first 8 bytes to signed long int by using read function but I could not . Do you know how can I do that ? </p></li>
<li><p>How can directly read a block of data to string ?
Can I read like as shown in
ex : </p>
<pre><code> ifstream is;
is.open ("test.txt", ios::binary );
string str ;
is. read ( str.c_str, 40 ) ; // 40 bytes should be read
</code></pre></li>
</ul>
| c++ | [6] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.