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 |
|---|---|---|---|---|---|
5,553,627 | 5,553,628 | Calling a Class function from within a class in Javascript, Jquery | <p>This is what I am trying to do and it isn't working, Error it is showing is : this.run is not a function. on the line ( this.xId = window.setInterval( 'this.run()', 2500 ); )</p>
<pre><code>function(){
this.run = function(){
DO SOMETHING;
}
this.xId = window.setInterval( 'this.run()', 2500 );
}
</code></pre>
<p>What could be the reason ?</p>
| javascript | [3] |
1,966,323 | 1,966,324 | jQuery function equal to href=# | <p>Is there a jquery function that can make you go to #name, like you can if you make a link to href="#name", so I could on document ready directly go to #name</p>
| jquery | [5] |
1,328,047 | 1,328,048 | How fast c++ file is fulfilled? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/673523/how-to-measure-execution-time-of-command-in-windows-command-line">How to measure execution time of command in windows command line?</a> </p>
</blockquote>
<p>is there a program which counts how fast .exe file is fulfilled? For example, if I must write c++ that takes one number from input file, multiply it with 2 and outputs in output file. And if I start c++ program, I can't tell how fast it is completed, cause for me it seems like 0.1 sec - blinking window. So is there any chance telling exactly time of it?</p>
| c++ | [6] |
4,774,935 | 4,774,936 | How do you show a preview image when allowing file uploads in ASP.NET? | <p>Here is the functionality I want:</p>
<p>User selects an image from their machine, hits an Upload button (or better yet the following fires on the onchange event of the file input), and is able to see a preview of the image they are about to upload.</p>
<p>Here is the current workflow I am using, but it seems suboptimal:</p>
<p>I have an image control, a file input control and a submit button control. When the submit button is clicked, the codebehind handles the OnClick event and loads the image from the file input element. It then stores it into a temporary folder on the web server and sets the image control's ImageUrl to point to it.</p>
<p>This works, but results in me having to do a lot of janitorial duty in cleaning up these temporary images. Is there a cleaner workflow for doing this?</p>
| asp.net | [9] |
4,561,767 | 4,561,768 | Image displayed at Gallery not to be centred | <p>I am using Gallery class for displaying images.
With the default implementation , the first image occupies the centre of the screen .
If the first image(centre image) is scrolled towards the left of the screen , then the second image(next image) occupies the centre of the screen.</p>
<p>My requirement is that for the very first time , the first image should be displayed 20 dip from the left margin. I'll keep some spacing (60 dip) between the first & the second image.</p>
<p>I wanted to know , whether this is possible or not.</p>
<p>Kindly provide your inputs/sample code.</p>
<p>Thanks in advance.</p>
<p>Warm Regards,</p>
<p>CB</p>
| android | [4] |
1,744,871 | 1,744,872 | c# - DataSet and DataGridView | <p>I have made a basic program to add values to a dataSet and display it to a dataGridView:</p>
<pre><code>public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DataTable table1 = new DataTable("People");
table1.Columns.Add("id");
table1.Columns.Add("Name");
table1.Columns.Add("Age");
table1.Rows.Add(1, "Jack", 18);
table1.Rows.Add(2, "Tim", 18);
DataSet set = new DataSet("SetPeople");
set.Tables.Add(table1);
dataGridView1.DataSource = set;
dataGridView1.Update();
}
}
</code></pre>
<p>When I try it out nothing seems to happen. The dataGridView remains blank. Any idea where I am going wrong?</p>
| c# | [0] |
2,511,522 | 2,511,523 | how to draw an image above an Transparent image using CoreGraphics | <p>I want to daw an image on an transparent image using coreGraphics can any tell me with the couple of line of code?</p>
| iphone | [8] |
4,755,109 | 4,755,110 | Video chat feature | <p>I searched a lot and didn't find the answer of my question.
I want to add to my android app video chat feature.
I am writing app for version 2.2 and latest.
Can I provide this feature or not and if I can,please write some link of code
which I need.</p>
<p>And also, I have read <a href="http://coenraets.org/blog/2010/07/video-chat-for-android-in-30-lines-of-code/" rel="nofollow">this</a> tutorial and I want to know is this real working app and if yes how can I merge this to my native app code?</p>
| android | [4] |
4,051,214 | 4,051,215 | Javascript function on submit button - Wait for it to complete | <p>I want to trigger a function when the submit button is pressed on the form and wait for the javascript function to complete, then continue the form submission. I dont want the form to submit before the javascript function has completed.**</p>
<p>This is what I have at the moment:
<a href="http://jsfiddle.net/njDvn/68/" rel="nofollow">http://jsfiddle.net/njDvn/68/</a></p>
<pre><code>function autosuggest() {
var input = document.getElementById('location');
var options = {
types: [],
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
}
<!-- Get lat / long -->
function getLatLng() {
var geocoder = new google.maps.Geocoder();
var address = document.getElementById('location').value;
geocoder.geocode({
'address': address
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latLng = results[0].geometry.location;
$('#lat').val(results[0].geometry.location.lat());
$('#lng').val(results[0].geometry.location.lng());
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
<!-- Load it -->
window.onload = autosuggest;
</code></pre>
| javascript | [3] |
2,235,097 | 2,235,098 | List to IEnumerable with parent and child class | <p>Given the following classes:</p>
<pre><code>public class ContentItem : IEquatable<ContentItem>
{
...
}
</code></pre>
<p>and</p>
<pre><code>public class Widget : ContentItem, IWidget
{
...
}
</code></pre>
<p>why I can't do this:</p>
<pre><code>List<Widget> widgets = _repository.GetItems(widgetType);
</code></pre>
<p>where</p>
<p><code>_repository.GetItems(widgetType)</code> returns <code>IEnumerable<ContentItem></code>?</p>
<p>Essentially I already have a repository implementation which works on <code>ContentItem</code> class and I would like to use that same repository also for working with <code>Widget</code> class basically because Widget has the same base properties and only introduces few new ones that just hold some information (they come from <code>IWidget</code> interface) and don't have any impact on how repository should handle the class). I don't want to make another repository class just to replace all occurences of <code>ContentItem</code> with <code>Widget</code>.</p>
<p>Should I make my changes by explicitly specifing casts or changing my repository (or repository interface, which I also have)? If possible, I would like to avoid various constructs such as AsEnumerable(), ToList() or explicit casts.</p>
| c# | [0] |
5,527,085 | 5,527,086 | Is there a encryption api's available to encrypt log file while using Microsoft Enterprise Library 3.1 | <p>How to encrypt a string message while it is being logged into the log file using Logger.Write(...) in Microsoft Enterprise Library 3.1. Are there any inbuilt API's in Microsoft Enterprise Library which does encryption? </p>
| c# | [0] |
2,810,712 | 2,810,713 | How to stop a program in Idle, python 3.2 | <p>I made a program in Idle that says:</p>
<pre><code>for trial in range(3):
if input('Password:') == 'password':
break
else:
# didn't find password after 3 attempts
**I need a stop program here**
print ("Welcome in")
</code></pre>
<p>Remember, this is in Idle, so I need program for Idle, not CMD. I also am using Python 3.2, if that helps.</p>
| python | [7] |
1,675,248 | 1,675,249 | How to send multidimensional array from JavaScript to PHP in query string | <p>I am using following code </p>
<p>window.location.assign("index.php?module=pengu_dispatch&action=cover_letter&value="+list);</p>
<p>Here I want to send multidimensional array in query string to the PHP file.</p>
<p>Using JSON stringify function I converted array into string and send but on PHP side after decoding I am not getting the complete array.</p>
<p>Please let me know what I could be doing wrong</p>
| javascript | [3] |
3,290,301 | 3,290,302 | jquery .each and rails | <p>I'm trying to translate this script to jQuery. See rails casts <a href="http://railscasts.com/episodes/88-dynamic-select-menus" rel="nofollow">#88</a></p>
<pre><code>var colors = new Array();
<%= for color in @colors %>
colors.push(new Array(<%= colot.product_id %>, '<%= color.name %>', <%= color.id %>));
<% end %>
function productSelected() {
product_id = $('order_items_attributes_0_product_id').val();
options = $('item_color_id').options;
colors.each(function(color) {
if (color[0] == product_id) {
options[options.length] = new Option(color[1], color[2]);
}
});
if (options.length == 1) {
$('color_field').hide();
} else {
$('color_field').show();
}
}
$(document).ready(function() {
productSelected();
$('order_items_attributes_0_product_id').change(productSelected);
});
</code></pre>
<p>Firebug says </p>
<pre><code>TypeError: 'undefined' is not a function (evaluating 'colors.each(function(color) {
if (color[0] == product_id) {
options[options.length] = new Option(color[1], color[2]);
}
})')
</code></pre>
<p>Also the ruby code is no longer allowed in 3.1.1 js files (under assets)? It also complains about <code>SyntaxError: Unexpected token '<'</code></p>
| jquery | [5] |
4,497,535 | 4,497,536 | C# - calculate if a date is six months older | <p>I am trying to calculate if the given specified date is at least six months old. I am doing this:</p>
<pre><code>if(DateTime.Now.AddMonths(-6)>date)
{
//Do something
}
</code></pre>
<p>Is this correct?</p>
<p>Some people say that this approach is wrong and will not give accurate results. Is the above is correct?</p>
| c# | [0] |
3,237,004 | 3,237,005 | Get child class properties in parent constructor | <pre><code>class A
{
public string PropA {set; get;}
public A()
{
var props = this.GetType().GetProperties(BindingFlags.Public);
}
}
class B : A
{
public string PropB {set; get;}
}
var b = new B();
</code></pre>
<p>When <code>A</code> constructor is called, variable <code>props</code> contains only <code>PropA</code>. It's possible to get all properties (<code>PropA</code> and <code>PropB</code>)?</p>
| c# | [0] |
3,441,456 | 3,441,457 | Proper Way To Display A Default Image When Replacement Image Is Missing in PHP | <p>I have the following code that is used to load user images from a database when their information is displayed.</p>
<p>I was attempting to write it in a way in which it would check if the user already has an image tied to their user id in the database and if so, would leave the image alone and if not, would display a "missing.jpg"/default user image.</p>
<p>I've tried the following, but right now it seems the code is overwriting existing images and replacing them with the missing.jpg image and I don't know why.</p>
<p>I'd appreciate somebody taking a look and showing me why that is.</p>
<pre><code> //Images
$thisScript = $_SERVER["SCRIPT_FILENAME"];
$dirName = dirname($thisScript);
$relative_path = "images/headshots/".$this->id.".jpg";
$missing_path = "images/headshots/missing.jpg";
$full_path = $dirName . "/" . $relative_path;
//if(file_exists($relative_path))
//if(file_exists($_FILES['uploadedfile']['name']))
if(basename( $_FILES['uploadedfile']['name']) != '' /*and (file_exists($_FILES['uploadedfile']['name']))*/)
{
$this->process_headshot_file($relative_path, $full_path);
}
else
{
//$this->process_headshot_file($missing_path, $full_path);
$query = "UPDATE hraps SET headshot_filename = '".$_SESSION['missing_headshot_image']."' WHERE id = ".$this->id;
$result = mydb::cxn()->query($query);
}
</code></pre>
<p>Thank you in advance for your help.</p>
| php | [2] |
4,330,667 | 4,330,668 | Can't get Dialog hosting a WebView to layout properly | <p>I'm trying to host a webview on a dialog, without a titlebar, but I'm getting odd layout results. Example test:</p>
<pre><code>@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager wm = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
LinearLayout ll = new LinearLayout(getContext());
ll.setOrientation(LinearLayout.VERTICAL);
ll.setLayoutParams(new LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT));
ll.setMinimumWidth(display.getWidth() - 10);
ll.setMinimumHeight(display.getHeight() - 10);
WebView wv = new WebView(getContext());
wv.setLayoutParams(new LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT));
wv.getSettings().setJavaScriptEnabled(true);
ll.addView(mWebView);
setContentView(ll, new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.FILL_PARENT));
}
</code></pre>
<p>the dialog is inflated at startup, but the webview is not visible. If I rotate the device, it becomes visible, and fills the whole parent layout as requested.</p>
<p>What is the right way to do this? I simply want a dialog which occupies most of the device screen, and has a WebView on it which fills the entire space.</p>
<p>Thanks</p>
| android | [4] |
1,753,036 | 1,753,037 | Why this Jquery function does not display me an alert box? | <p>I observed when I put the ready event the function works but as I remove it It does not..</p>
<p>Works.</p>
<pre><code><script type="text/javascript">
$(document).ready( function() {
$('.clicky').click( function() {
alert("TEst10");
$(this).addClass('clicked');
alert("TEst10");
setTimeout( function() {
$(this).removeClass('clicked');
}, 1000 );
});
});
</script>
</code></pre>
<p>Not work</p>
<pre><code><script type="text/javascript">
$('.clicky').click( function() {
alert("TEst10");
$(this).addClass('clicked');
alert("TEst10");
setTimeout( function() {
$(this).removeClass('clicked');
}, 1000 );
});
</script>
</code></pre>
<p>Why the second one does not work?</p>
| jquery | [5] |
2,110,978 | 2,110,979 | Building an app across different Android platforms? | <p>I see a whole bunch of platforms / SDKs, everything from 1.x to 4.x.</p>
<p>Does this mean I have to build my app separately for all different versions?</p>
<p>My goal is to wrap my HTML5 web app and make it available as a native app in app stores.</p>
| android | [4] |
2,800,105 | 2,800,106 | Android open source project fork – missing references | <p>I want to fork an Android project (a normal application) from the <a href="http://android.git.kernel.org/" rel="nofollow">official repository</a>. After I clone the project and import it into Eclipse, I still have loads of different missing references to some other projects that prevent me from even looking at the layout ressources (as it tells me to fix the Java errors first).</p>
<p>Is there a way to fix those references, without using <em>repo</em> or cloning the whole repository (with all its projects)? After all I’m only interested in a single standard application there.</p>
| android | [4] |
563,615 | 563,616 | Android: change textview settings (setTextColor) in listview-row layout | <p>Little complicated title, but i don't know how to tell in different way =D.</p>
<p>I have 1 activity and 2 layout xml files.<br>
in 1st .xml i have listview and in 2nd .xml i have items, which representing row in listview. it looks like in this tutorial: <a href="http://ykyuen.wordpress.com/2010/01/03/android-simple-listview-using-simpleadapter/" rel="nofollow">http://ykyuen.wordpress.com/2010/01/03/android-simple-listview-using-simpleadapter/</a> </p>
<p>my question is: how can i programmatically change textviews settings in 2nd .xml (in tutorial grid_item.xml)<br>
if i call <code>text1.setTextColor(Color.RED);</code> , it throws me exception java.lang.NullPointerException</p>
| android | [4] |
83,138 | 83,139 | How to format string to money | <p>I have a string like <code>000000000100</code>, which I would like to convert to 1.00 and vice versa.</p>
<p>Leading zero will be remove, last two digit is the decimal.</p>
<p>I give more example :</p>
<pre><code>000000001000 <=> 10.00
000000001005 <=> 10.05
000000331150 <=> 3311.50
</code></pre>
<p>Below is the code I am trying, it is giving me result without decimal :</p>
<pre><code>amtf = string.Format("{0:0.00}", amt.TrimStart(new char[] {'0'}));
</code></pre>
<p>Thank you.</p>
| c# | [0] |
3,749,154 | 3,749,155 | how read xml file from res folder | <p>I want to load data from an XML file and assign that data to variables in my Android app.</p>
<p>After doing some research on the various XML parsers available to Android, I figure the best parser method to use would be SAX.</p>
<p>I've read through a bunch of posts about reading XML from Android however I can't find one that uses a local file in the 'res' folder. </p>
<p>All the tutorials I've found are loading the XML file via a URL. </p>
<p>Is there a way to load the XML from the res folder?</p>
<p>Thanks</p>
| android | [4] |
3,496,458 | 3,496,459 | class construct,but now allocate memory | <pre><code>template <class _T1>
inline void constructInPlace(_T1 *_Ptr)
{
new (static_cast<void*>(_Ptr)) _T1();
}
</code></pre>
<p>I have known the place new about c++, I can't understand the above syntax!</p>
| c++ | [6] |
4,891,143 | 4,891,144 | xammp problem because can't be run | <p>here I have a problem with my xammp to run Apache, there is no problem to me to run mysql, I already done this before and don't have any problem, but this time Apache can't be run..anybody know?</p>
| php | [2] |
4,416,783 | 4,416,784 | java project problem | <p>I have a java project. I can run it through command prompt but can not able to run through Eclipse or NetBeans. When I run it, the error come main class is not found.</p>
<p>What can i do ?</p>
| java | [1] |
3,869,558 | 3,869,559 | How to delete a particular word in paragraph using PHP? | <p>I have a paragraph which contains several instances of the word "manish". I want to remove those lines which contain the word "manish", without altering the remaining lines.</p>
| php | [2] |
3,255,148 | 3,255,149 | JavaScript floating point sum issue | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/588004/is-javascripts-math-broken">Is JavaScript's Math broken?</a> </p>
</blockquote>
<p>Why JS show 25.1+61.7+13.2 = 100.00000000000001 ? Its fixed if you just change the position of the number like 13.2+25.1+61.7 = 100. Can anyone explain this.</p>
| javascript | [3] |
2,043,078 | 2,043,079 | How the construction function runs when call static function in Java | <p>I want a class to check if an input is valid, and all the valid input is record in a text file.</p>
<p>So in construction, it read in the text file and put all valid inputs into a HashSet. Then I have <code>static</code> function to receive an input and check if the input is in the HashSet.</p>
<p>Code structure is like following:</p>
<pre><code>public class Validator {
HashSet validInputs;
public Validator() {
//read in
}
public static boolean validate(String in) {
//check and return
}
}
</code></pre>
<p>Then in other class, I need to use <code>Validator</code> class to validate strings. Code is like:</p>
<pre><code>...
String a = XXX;
boolean valid = Validator.validate(a);
...
</code></pre>
<p>I haven't tested the code, but I have two questions:</p>
<ol>
<li>Does it work? Is the valid input text file read in?</li>
<li>When will the class read in the text file?</li>
<li>Will <code>Validator</code> read the text file every time I call the function <code>validate()</code>?</li>
</ol>
| java | [1] |
274,795 | 274,796 | Extending a provided class | <p>I have extended a class like so:</p>
<pre><code>public class CormantRadDock : Telerik.Web.UI.RadDock
{
public enum Charts { LineChart, PieChart, BarChart };
public Charts ChartType { get; set; }
public bool LegendEnabled { get; set; }
public string ChartName { get; set; }
public CormantRadDock() : base()
{
}
}
</code></pre>
<p>I am now trying to adjust some code elsewhere to accommodate this update.</p>
<p>The old code was this:</p>
<pre><code>List<RadDock> docks = new List<RadDock>(dockLayout.RegisteredDocks);
</code></pre>
<p>where RegisteredDocks is of type <code>"System.Collections.ObjectModel.ReadOnlyCollection<RadDock>"</code></p>
<p>I do not understand why this is not possible:</p>
<pre><code>List<CormantRadDock> docks = new List<CormantRadDock>(dockLayout.RegisteredDocks);
</code></pre>
<p>I receive the errors: </p>
<p>The best overloaded method match for 'System.Collections.Generic.List.List(System.Collections.Generic.IEnumerable)' has some invalid arguments.</p>
<p>Argument 1: cannot convert from 'System.Collections.ObjectModel.ReadOnlyCollection' to 'System.Collections.Generic.IEnumerable' </p>
<p>Could someone please explain why this is occurring and a best possible solution?</p>
| c# | [0] |
1,029,977 | 1,029,978 | image from gallery to image in bytes.. also data in bytes.. for facebook upload in android | <p>I got code to upload picture and video to Face Book..
But i don't know how to convert image from gallery to image in bytes.. also data in bytes.. Any one can help me???? </p>
<pre><code>*Upload picture,
Bundle params = new Bundle();
params.putByteArray("picture", <image in bytes>);
params.putString("message", "Have fun");
mAsyncRunner.request("me/photos", params, "POST", new SampleUploadListener());*
this is code for upload images...
*Upload video,
Bundle params = new Bundle();
param.putString("filename", <dataName>);
param.putByteArray("video", <data in bytes>);
mAsyncRunner.request("me/videos", param, "POST", new SampleUploadListener());**
this is code for upload images...
Any one know how code for my question please post.....
</code></pre>
<p>thanks in advance</p>
| android | [4] |
1,538,138 | 1,538,139 | How to get Registration ID from C2DM Servers? | <p>I am very new to Android. I developed my project in android. Now I would like to add notification for my application. So I planned to use C2DM. I register to C2DM and i have received a mail. but i not yet receive registration ID from gmail. How can i receive from gmail registration. What i wil do? Any body pls help me. Thanks in advance.</p>
| android | [4] |
1,915,933 | 1,915,934 | Zoom some portion of UIImage to fill the entire screen iPhone | <p>What I want to do is to zoom some portion of the image into the entire screen.</p>
<p>To accomplish that I have a UIImage on UIImageView, which in turn is a subview of UIScrollView. However if I use zoomToRect and specify the rect of the image portion I want to zoom, the portion is zoomed until one of its bounds reached the screen bounds and does not fill the entire screen. </p>
<p>Can someone suggest how can I accomplish what I want?</p>
| iphone | [8] |
572,453 | 572,454 | I keep getting this error no match for 'operator==' in 'temp2 == temp3' | <pre><code>#include<iostream>
#include<cctype>
#include<string>
#include<cstdlib>
#include"Palindrome.h"
using namespace std;
struct Node
{
string pharse;
Node* next;
};
int main()
{
Stack S1;
Queue Q1;
string word;
int length;
cout << "Do you know what a Palindrome is?\n";
cout << "It is a word that is the same spelling backwards and forward\n";
cout << "Enter in a word ";
getline(cin, word);
//cout.flush();
length = word.length();
string NewWord1[length];
string NewWord2[length];
for(int c =0; c < length; c++)
{
NewWord1[c] = word[c];
NewWord2[c] = word[c];
}
for(int c =0; c < length; c++)
{
cout << NewWord1[c];
cout << endl;
cout << NewWord2[c];
cout << endl;
}
cout << "end";
S1.push(NewWord1, length);
Q1.enqueue(NewWord2, length);
Node temp2 = S1.pop();
Node temp3 = Q1.dequeue();
if(temp2 == temp3)
cout << "They are palindrome.";
else
cout << "They are not palindrome.";
/*S1.pop();*/
return 0;
}
void Stack :: push(string NewWord1[], int size)
{
//cout << NewWord1[0];
if(!isFull())
{
for(int i = 0; i < size; i++)
{
Node *temp = new Node;
temp -> pharse = NewWord1[i];
temp -> next = head1;
head1 = temp;
}
}
}
</code></pre>
<p>// pop and enqueue return a Node which is my structure.</p>
| c++ | [6] |
478,979 | 478,980 | python __getattr__ and __name__ | <p>I'm using "new style" classes in Python 2.6 and am having trouble with __getattr__ in a subclass.</p>
<p>If the subclass implements like such...</p>
<pre><code>def __getattr__(self, name):
if self.__folderDict.has_key(name):
if name == 'created':
return doSomethingSpecial(self.__folderDict[name])
return self.__folderDict[name]
else:
raise AttributeError()
</code></pre>
<p>It's not clear to me why my attribute exception gets thrown for a reference to __name__ ?</p>
<p>My understand is that __getattr__ should not even get called and that __name__ should be fullfilled by __getattribute__ since I'm using new style?</p>
<p>Here's a more complete example...</p>
<pre><code>class Base(object):
@staticmethod
def printMsg(msg, var):
print msg + str(var)
return
def printName(self):
Base.printMsg('#', self.__name__)
return
class Derived(Base):
def __getattr__(self, name):
if self.__testDict.has_key(name):
return self.__testDict[name]
else:
raise AttributeError()
__testDict = {'userid': 4098}
d = Derived()
print d.userid
d.printName()
</code></pre>
<p>The result is...</p>
<pre><code>4098
Traceback (most recent call last):
File "D:/.../Scratch/scratch01.py", line 24, in <module>
d.printName()
File "D:/.../Scratch/scratch01.py", line 17, in __getattr__
raise AttributeError()
AttributeError
</code></pre>
| python | [7] |
5,473,774 | 5,473,775 | Which java class file will be called if same class is packed in two jar files? | <p>i am working on opensource project . As of of now i have dont any customization in any class. So using all the jars files provided by opensource project. My question is if i modify one java file ,compile it and pack it new jar file with same folder structure , will there be any issue at start up of server or run time? If not which class file will be called(default file or my customize java class file) ?</p>
| java | [1] |
1,060,028 | 1,060,029 | Set Title in Tab childs | <p>How can I change a title from tab child?
I tried a simple setTitle(...) but it won't work.</p>
<p>(from the parent tab activity, it does, however...)</p>
<p>thanks,
Ori</p>
| android | [4] |
1,908,096 | 1,908,097 | jQuery while loop to generate list | <p>Hi I am trying to get a list from 1-100 without typing in each line. I know it is a while loop but I've never had to use a while loop...thanks.</p>
<pre><code> <ul>
<li>9.99</li>
...
<li>9.01</li>
</ul>
</code></pre>
<p>I kick myself in advance...</p>
| jquery | [5] |
1,544,182 | 1,544,183 | Aligning items from 2 lists(simple python) | <p>I was wondering how I could align every item in one list, to the corresponding index in the second list. Here is my code so far:</p>
<pre><code>letters=['a','ab','abc','abcd','abcde','abcdef','abcdefg','abcdefgh','abcdefghi','abcdefghij']
numbers=[1,2,3,4,5,6,7,8,9,10]
for x in range(len(letters)):
print letters[x]+"----------",numbers[x]
</code></pre>
<p>This is the output I get:</p>
<pre><code>a---------- 1
ab---------- 2
abc---------- 3
abcd---------- 4
abcde---------- 5
abcdef---------- 6
abcdefg---------- 7
abcdefgh---------- 8
abcdefghi---------- 9
abcdefghij---------- 10
</code></pre>
<p>This is the output I want:</p>
<pre><code>a---------- 1
ab--------- 2
abc-------- 3
abcd------- 4
abcde------ 5
abcdef----- 6
abcdefg---- 7
abcdefgh--- 8
abcdefghi-- 9
abcdefghij- 10
</code></pre>
| python | [7] |
1,503,965 | 1,503,966 | Parsing MHTML File using C# | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/100358/looking-for-c-html-parser">Looking for C# HTML parser</a> </p>
</blockquote>
<p>Hi Everyone,</p>
<p>I'm using CDO object's createMHTMLBody to download and save the webcontent as MHTML file.
I want to extract content from that MHTML file using C#. How can i do that.
Please Help me.</p>
| c# | [0] |
4,390,525 | 4,390,526 | Can I make the Jquery slideViewer autoplay? | <p>Any thoughts on making the slideViewr plugin from (2007-2009 Gian Carlo Mingati | design and development for interactive media) autoplay?</p>
<p>I tried upgrading to the slideViewerPro, but did not like the thumbnails and other stuff.</p>
<p>Thanks.</p>
| jquery | [5] |
929,790 | 929,791 | C#: Filtering listbox having List<String> as datasource | <p>I have a listbox that has a List assigned as datasource:</p>
<pre><code>List<String> files = new List<String>();
files.Add("test");
files.Add("test2");
ListBox1.DataSource = files;
</code></pre>
<p>Now the listbox shows me both entries of the List.</p>
<p>Is there a way to implement an easy filtering mechanism using a textbox?
So if i enter "2" into the textbox just the "test2" entry should be shown anymore.</p>
<p>Any suggestions?</p>
| c# | [0] |
1,317,950 | 1,317,951 | Problems reading text file data in Java | <p>I have this code:</p>
<pre><code> BufferedReader br =new BufferedReader(new FileReader("userdetails.txt"));
String str;
ArrayList<String> stringList = new ArrayList<String>();
while ((str=br.readLine())!=null){
String datavalue [] = str.split(",");
String category = datavalue[0];
String value = datavalue[1];
stringList.add(category);
stringList.add(value);
}
br.close();
</code></pre>
<p>it works when the variables category and value do not have a comma(,),however the values in the variable value does contain commas.Is there a way that I can split the index of the without using comma?</p>
| java | [1] |
2,078,053 | 2,078,054 | Jquery: plugin to handle clicks on elements? | <p>are there any good plugins to handle clicks based on the element clicked ?</p>
<p>for example, if link is clicked display a box with options. if form is clicked display a box with different options. </p>
<p>or any pattern suggestion would be useful.</p>
| jquery | [5] |
6,032,605 | 6,032,606 | Add a canvas - Android | <p>I dynamically create a canvas with:</p>
<pre><code>Canvas canvas = new Canvas();
</code></pre>
<p>But how can I add it to my LinearLayout?</p>
<pre><code>LinearLayout ll = new LinearLayout(this);
</code></pre>
| android | [4] |
3,515,257 | 3,515,258 | Android how to get name of contact from phone book | <p>i have a listview where i get phone numbers from phone book in Array, i want to compare these numbers with phone book and get name of contact.</p>
<p>please help me with a code example.</p>
<p>thank you</p>
| android | [4] |
4,008,985 | 4,008,986 | how to generate an dynamic array | <p>I am a PHP Developer please help me ,i have problem to generate a dynamic menu to fetch data from database and store result in the dynamic array.</p>
| php | [2] |
5,810,044 | 5,810,045 | image in layout is different from image loaded in emulator | <p>My problem is as follows: </p>
<p>I have a layout called layoutscreen.xml . On this layout I have various buttons. To add a resource I went to imagebutton which took me to the resource screen and then added a particular image in this case basic.png. I got this off my hard drive and I noticed the image had not rescaled properly. I then went too drawable-hdpi and replaced basic.png that had been shrunk with a new copy off my hard drive. </p>
<p>Therefore showing the full sized image. I then went to background and changed it to the resource of the new image. It displayed fine. The problem was when I ran the emulator the old basic.png was still there after the replacement. </p>
<p>What is the best practice to add an image to a button?</p>
| android | [4] |
209,064 | 209,065 | Arabic Font Break | <p>I am working on an Arabic App. I am wondering that my S3 is showing Arabic text correctly. But when I see the text in Emulator it is breaking. Any reason why?</p>
| android | [4] |
251,145 | 251,146 | How can i seperate Headers, classes and main functions in C++? | <p>Please help me in separating the classes, headers and main() in the following program. I tried my best but there is problem.</p>
<pre><code>#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;
class player
{
public:
string name;
string type;
void getdata()
{
cout<<"Enter the name of the Player : "<<endl;
cin>>name;
cout<<"Enter the Game he play : "<<endl;
cin>>type;
}
void display()
{
cout<<"The name of the Player is : "<<name<<endl;
cout<<"The game he will play is : "<<type<<endl;
}
};
int main()
{
player sachin;
sachin.getdata();
sachin.display();
system("pause");
return(0);
}
</code></pre>
| c++ | [6] |
749,347 | 749,348 | Find a file in python | <p>I have a file that may be in a different place on each user's machine. Is there a way to implement a search for the file? A way that I can pass the file's name and the directory tree to search in?</p>
| python | [7] |
2,576,505 | 2,576,506 | Understanding the basics of multidimensional arrays | <p>I am new to using multidimensional arrays with php, I have tried to stay away from them because they confused me, but now the time has come that I put them to good use. I have been trying to understand how they work and I am just not getting it. </p>
<p>What I am trying to do is populate results based on a string compare function, once I find some match to an 'item name', I would like the first slot to contain the 'item name', then I would like to increment the priority slot by 1.</p>
<p>So when when I'm all done populating my array, it is going to have a variety of different company names, each with their respective priority...</p>
<p>I am having trouble understanding how to declare and manipulate the following array:</p>
<pre><code>$matches = array(
'name'=>array('somename'),
'priority'=>array($priority_level++)
);
</code></pre>
| php | [2] |
5,549,242 | 5,549,243 | Code for sending email in C++ | <p>Hi guys,</p>
<p>i know there are external libraries out there like jwsmtp and vmime or poco which help you send email in c++. However i am having trouble configuring them and linking them. Therefore i would like to know if anyone has the source code for sending an email in c++(windows 7 os) through my gmail account.</p>
| c++ | [6] |
2,958,381 | 2,958,382 | Javascript/CSS drop downs not working | <p>I am trying to add css dropdowns to the navigation menu. But it is not working. I would like to know what is causing the problem. Your help is highly appreciated. Here is the link:<br />
<a href="http://www.pinhmct.org/tmp/index.html" rel="nofollow">Drop downs to navigation bar</a></p>
| javascript | [3] |
353,400 | 353,401 | jquery checkbox problem | <p>Im having a problem with a piece of jquery code. Every time this piece of code is executed, it disables all the links in my page :( if i click on a link on a page... it doesn't to nothing.</p>
<pre><code>// listen to every click on a checkbox
$('input[type="checkbox"].status').bind('click', function(e){
e.stopPropagation();
// if the checkbox is checked
if($(this).is(':checked'))
{
// increase counter
statusCounter++;
return;
}
// if the checkbox is unchecked
if($(this).is(':not(:checked'))
{
// decrease counter
statusCounter--;
return;
}
</code></pre>
<p>Any help? thanks</p>
| jquery | [5] |
3,550,984 | 3,550,985 | Javascript- document/window has focus? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/497094/how-do-i-find-out-which-javascript-element-has-focus">How do I find out which Javascript element has focus?</a> </p>
</blockquote>
<p>Is it possible to check in Javascript whether the current window has focus?</p>
| javascript | [3] |
2,400,070 | 2,400,071 | Block the user to see the result page when not login | <p>I'm using web application, struts and hibernate are the technologies used in that application. When user login, it traverse from login page to result page. My question is, how do i prevent the user when not login, user should not allow to see the result page using the url of the result page directly. i.e means hitting the result page url in browser.
For e.g:
login page url --> //localhost:8080/Log/login.action</p>
<p>result page url --> //localhost:8080/Log/details.action</p>
<p>Appreciate your help.</p>
| java | [1] |
1,589,627 | 1,589,628 | how to create a PDF file uing javascript in IE | <p>I want to create a PDF file based on users' query result (in html table).
What is the best javascript/lib I can use for IE?
I found jsPDF but it does not support IE. </p>
| javascript | [3] |
4,820,964 | 4,820,965 | Uploading and downloading via ftp with iPhone SDK | <p>Could anybody explain to me the process of uploading to and downloading form and ftp server with the iPhone SDK. If you could just point me in the right direction (e.g. documentation etc.). How difficult is a task like this?</p>
<p>Thanks in advance.</p>
| iphone | [8] |
1,796,531 | 1,796,532 | Is it possible to output video of my iPhone application running on a device? | <p>I am working on an app for a client where he will be showing it in a board from to a group of directors for a serious presentation. Because the iPhone is so small, it wouldn't make sense to have him demo the app on the actual device because no one would see anything. </p>
<p>Is it possible to have the screen output on a computer or tv so that everyone in the room can see what is going on?</p>
| iphone | [8] |
4,410,469 | 4,410,470 | Get Row ID when click on link in cell | <p>Lets say I want to get the ID of a row when I click on a span in a cell as below</p>
<pre><code><tr id="theRowID">
<td><span class="getRowID">get this rows ID</span></td>
</tr>
</code></pre>
<p>Would this be accurate?</p>
<pre><code>$(".getRowID").click(function(){
$(this).closest('tr').attr("id");
});
</code></pre>
| jquery | [5] |
3,543,674 | 3,543,675 | shared library binding only to library not to process | <p>i have the following problem with shared librarys</p>
<p>create a shared libraray</p>
<pre><code>class A
{
static int callCount;
A() { callCount++; }
}
int A:callCount = 0;
class Main
{
Main()
{
A a1();
A a2();
}
}
</code></pre>
<p>now create an process which is loading this shared libraray more times and i would like have the callCount belongs only to the shared library not to the whole process</p>
<pre><code>dlopen("shared.so", RTLD_LAZY);
// after some code i can construct Main()
// and now i will open the shared object again
dlopen("shared.so", RTLD_LAZY);
// now if i construct Main from the new library i want to have a new
// initialized callCount eq 0 but its 2
</code></pre>
<p>how can i solve this problem</p>
| c++ | [6] |
1,027,661 | 1,027,662 | Load HTML data into WebView, referencing local images? | <p>If I'm loading a WebView with an HTML document directly (no web server) using WebView.loadData() is there a way for that document to reference local images? If so where do I place them, and how do I reference them?</p>
<p>Or alternatively is there a way to easily encode and embed bitmaps into the HTML document?</p>
<p>I need to display local HTML documents that include images and I'd like to avoid setting up a remote server to serve the resources.</p>
| android | [4] |
2,161,137 | 2,161,138 | How to use FileObserver for System files [Android] | <p>I wan to monitor changes in android system file<br>
<code>"/sys/class/net/eth0/operstate"</code> for monitoring ethernet state.</p>
<p>I have written an File Observer class but i am not getting any events in
<code>public void onEvent(int event, String path)</code> call back function. </p>
<p>Do we need any special type of permissions for observing android system files?<br>
Do i need to run my APK as root.</p>
<p>Thanks.</p>
| android | [4] |
5,016,472 | 5,016,473 | How to get the id of an element with its index using jquery? | <p>Using <code>.index()</code> we can get the position or index of an element. Now i want to know that
can we get the element's <code>id</code> using its index ?</p>
<p>An Example,</p>
<pre><code><ul id="unOrderedList">
<li id="gears"><a class="links" href="#">Click here!</a></li>
<li id="tyres"><a class="links" href="#">Click here!</a></li>
<li id="rear"><a class="links" href="#">Click here!</a></li>
<li id="mirror"><a class="links" href="#">Click here!</a></li>
<li id="charger"><a class="links" href="#">Click here!</a></li>
<li id="port"><a class="links" href="#">Click here!</a></li>
<li id="list"><a class="links" href="#">Click here!</a></li>
</ul>
</code></pre>
<p>For the above mark up, if i want to know 4th <code><li></code> id means, how shall it do it with jquery?</p>
<p>Thanks in Advance!</p>
| jquery | [5] |
3,923,639 | 3,923,640 | importing modules from packages in python, such a basic issue I guess I can't even find the answer anyhwere | <p>So my first python program, I downloaded the macholib package from PYPI, then unzipped it and ran installed the setup.py using python install, now I'm trying to run a program where I first import the macholib, then when I try to access methods like Macho, it gives me an error saying macholib module has no attributes called Macho.
My understanding is macholib is a package and not a module or something, hence I cant use the contents of the package.
Please answer, I've wasted too much time on such a simple newbie issue.
running a mac with the latest version of python.</p>
<p>Code:</p>
<pre><code>import sys
import macholib
MachO(DivXInstaller.dmg)
</code></pre>
<p>I tried macholib.MachO(DivXInstaller.dmg) and macholib.MachO.MachO(DivXInstaller.dmg)</p>
<pre><code>Error for python test.py
Traceback (most recent call last):
File "test.py", line 3, in <module>
MachO(DivXInstaller.dmg)
NameError: name 'MachO' is not defined
</code></pre>
| python | [7] |
2,432,559 | 2,432,560 | Refresh parent page upon closing child with JavaScript | <p>I have the following function being called on the child page pop-up from the main page. The function:</p>
<pre><code>function getBenefitEdit(bfn_benefit, bfn_benefit_id, bfn_std_max_days, bfn_std_pcy_wait_days){
document.forms[0].std_benefit_nm_policy_chg.value = bfn_benefit;
document.forms[0].std_benefit_id_policy_chg.value = bfn_benefit_id;
document.forms[0].std_max_days_policy_chg.value = bfn_std_max_days;
document.forms[0].std_pcy_wait_days_policy_chg.value = bfn_std_pcy_wait_days;
document.forms[0].action = "nwrGetBenefitSTD.do";
document.forms[0].submit();
window.opener.location.href = window.opener.location.href;
window.close();
}
</code></pre>
<p>I'm trying to get the new page to update the parent page, then refresh the parent page upon closing it. Unfortunately, while this works in FireFox, it fails in IE. Any suggestions?</p>
| javascript | [3] |
1,695,741 | 1,695,742 | how to set ignore case sensitive in this line? | <p>how to set case sensitive in string contain? this is my code below which compare string how do i set ignore case sencitive in this line?? my application check if string contain"LOGIN" in string recieve how do i add ignorecase sensitive so eighter string contain "login" or "LOGIN" its start application??</p>
<pre><code> public void onReceive(Context context, Intent intent)
{
abortBroadcast();
//---get the SMS message passed in---a
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String str = "";
if (bundle != null)
{
//---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i=0; i<msgs.length; i++){
msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);
String phNum = msgs[i].getOriginatingAddress();
str += msgs[i].getMessageBody().toString();
if (specificPhoneNumber.equals(phNum))
{
Uri uri = Uri.parse("content://sms/inbox");
ContentResolver contentResolver = context.getContentResolver();
String where = "address="+phNum;
Cursor cursor = contentResolver.query(uri, new String[] { "_id",
"thread_id"}, where, null,
null);
while (cursor.moveToNext()) {
long thread_id = cursor.getLong(1);
where = "thread_id="+thread_id;
Uri thread = Uri.parse("content://sms/inbox");
context.getContentResolver().delete(thread, where, null);
}
if (str.contains("LOGIN"))
{
Intent l = new Intent(context,AgAppMenu.class);
l.putExtra("msg",str);
l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(l);
}
</code></pre>
| android | [4] |
335,871 | 335,872 | Javascript two equals | <p>Trying to deepen my knowledge of JS, can someone tell me what this does/is please?</p>
<pre><code>jQuery = $ = this.jQuery;
</code></pre>
<p>What exactly does two equal signs do here?</p>
| javascript | [3] |
2,253,248 | 2,253,249 | Java code to find balance no of days in a financial year | <p>How to find the balance number of days in the current financial year in java. For eg balance days upto march 31.</p>
<pre><code>if(Integer.parseInt(currentmonth)<4){
currentyears=Integer.parseInt(currentyear)-1;
finMonth=Integer.parseInt(currentmonth)+9;
remainMonth=12-finMonth;
}else{
currentyears=Integer.parseInt(currentyear);
finMonth=Integer.parseInt(currentmonth)-3;
remainMonth=12-finMonth;
}
</code></pre>
<p>This is my code for finding the financial year. My Problem is to find the remaining days in the financial year.</p>
| java | [1] |
1,711,732 | 1,711,733 | ImageView rotating continuously | <p>I've used an ImageView in my compass app which rotates when sensor value changes. The problem is when device reaches between 173 to 186 degree angle my ImageView start rotating continuously from 0-360 degree angle. This particular problem started after I added a piece of code to decrease rotation speed of ImageView before this app was running perfectly fine.</p>
<p>A method added to decrease rotation speed</p>
<pre><code>protected float[] lowPass( float[] input, float[] output ) {
if ( output == null ) return input;
for ( int i=0; i<input.length; i++ ) {
output[i] = output[i] + ALPHA * (input[i] - output[i]);
}
return output;
}
</code></pre>
<p>Sensor Event Listener from where the method is called</p>
<pre><code>private SensorEventListener mySensorEventListener = new SensorEventListener() {
.
.
.
public void onSensorChanged(SensorEvent event) {
.
.
.
SensorManager.getOrientation(rotationMatrix, orientationValues);
accelVals = lowPass( orientationValues, accelVals );
azimuth = (int) Math.toDegrees(accelVals[0]);
azimuth = (azimuth +360)%360;
allowRotating=true;
dialer.post(new RotateRunnable(azimuth));
.
.
.
}
};
</code></pre>
<p>Will be glad If any one can help me out</p>
| android | [4] |
1,112,318 | 1,112,319 | How to implement push email notifactions for my SBS app in android | <p>I am new to the developement of SBS app in android. I wanted to know the requirements for implemeting push notifications on the app side.</p>
<p>Suppose if i am using jive services for my SBS. What are the things which are required to implement push notifications?</p>
| android | [4] |
3,770,361 | 3,770,362 | How to enforce API calls are coming from authorized site | <p>What is it that I need to do (what request parameter) do I need to check to make sure that someone calling my API is indeed the domain associated with that key, and that they key isn't being used on multiple domains? </p>
| php | [2] |
5,756,820 | 5,756,821 | Joomla index redirect | <p>I want to redirect the index.php to index.html. But in the index.html user has 2 options, 1. to go to a specific section (or) 2. go to actual index.php i.e. our actual site is running with index.php, but we want to highlight a section, so first we want the user to come to index.html & go to mainsite if he wants to.</p>
<p>How can I do this? I have tried htaccess, but it is giving an infinite loop.</p>
| php | [2] |
5,799,214 | 5,799,215 | Random text and counter for pairs of letters | <p>I am using this which is successful in creating a counter for letters relative to the previous pair. </p>
<pre><code>def pairwise(iterable):
it = iter(iterable)
last = next(it) + next(it)
for curr in it:
yield last, curr
last = last[1]+curr
valid = set('abcdefghijklmnopqrstuvwxyz ')
def valid_pair((last, curr)):
return last[0] in valid and last[1] in valid and curr in valid
def make_markov(text):
markov = defaultdict(Counter)
lowercased = (c.lower() for c in text)
for p, q in ifilter(valid_pair, pairwise(lowercased)):
markov[p][q] += 1
return markov
</code></pre>
<p>But i would now like to generate random text with each letter depending on the counter for the previous pair. Here is the code used when a letter only depends on the previous letter. </p>
<pre><code>def genrandom(model, n):
curr = choice(list(model))
for i in xrange(n):
yield curr
if curr not in model:
curr = choice(list(model))
d = model[curr]
target = randrange(sum(d.values()))
cumulative = 0
for curr, cnt in d.items():
cumulative += cnt
if cumulative > target:
break
</code></pre>
<p>I am having trouble adapting it to this second configuration, the output isn't consistent with what i would expect. Thanks!</p>
| python | [7] |
3,828,558 | 3,828,559 | How to send HTTP POST Request with xml body and xml header In Java? | <p>How to send HTTP POST Request with xml body and xml header In Java?</p>
| java | [1] |
5,611,361 | 5,611,362 | How to access data which is stored in server via UI? | <p>I am developing an android application. In that application I have to access the data from the server into my cell using User Interface. I dont know much about How to save data in server and How to access in my cell.</p>
<p>If any body knows then help me. or give me some links to study about that.</p>
<p>Thanks in advance...</p>
| android | [4] |
3,907,667 | 3,907,668 | Exit Button on App? App Still Running? | <p>I have a question about the exit button. I have read several posts on here about use of an exit button/back button. Also the blog: <a href="http://blog.radioactiveyak.com/2010/05/when-to-include-exit-button-in-android.html" rel="nofollow">http://blog.radioactiveyak.com/2010/05/when-to-include-exit-button-in-android.html</a>, which clears discourages the use of an exit button.</p>
<p>Here is my question. I have an app that is very small; however it pulls data from the webservice/MySql database online. It is supposed to only pull data on first open. Or, if the user selects update data from a menu. I do not have an exit button in the app, However I thought that if the user would back completely out of the app, this would be the same as an EXIT. </p>
<p>After backing out of the app, I can still see the app in Setting>Applications>Running Services. It says "1 process and 1 service". In Manage Applicaions, it says that the app has been running for 36 hours.
Is this okay? I do not want users to think my app is using their battery.
On a separate note, I do not see an additional updating (pull from webservice) after backing out. But if I install the app on my galaxy Tablet 10.1 running Android 3.1, I do see an occasional update from the webservice. </p>
<p>Anyone have some advice for me?</p>
| android | [4] |
90,550 | 90,551 | Detecting when user has dismissed the soft keyboard | <p>I have an EditText widget in my view. When the user selects the EditText widget, I display some instructions and the soft keyboard appears.</p>
<p>I use an OnEditorActionListener to detect when the user has completed text entry and I dismiss the keyboard, hide the instructions and perform some action.</p>
<p>My problem is when the user dismisses the keyboard by pressing the BACK key. The OS dismisses the keyboard, but my instructions (which I need to hide) are still visible.</p>
<p>I've tried overriding OnKeyDown, but that doesn't seem to get called when the BACK button is used to dismiss the keyboard.</p>
<p>I've tried setting an OnKeyListener on the EditText widget, but that doesn't seem to get called either.</p>
<p>How can I detect when the soft keyboard is being dismissed?</p>
| android | [4] |
3,316,213 | 3,316,214 | Header already.... when header() is used...PHP | <p>When I use <code>header( 'Location: <a href="http://www.yoursite.com/new" rel="nofollow">http://www.yoursite.com/new</a>_page.html' ) ;</code> which is a PHP redirection of page, it says header already passed at line....</p>
<p>The landing page as <code><? include('header.php'); ?></code></p>
<p>How can I over come this error message?</p>
<p>Appreciate assistance.</p>
<p>Thanks
Jean</p>
| php | [2] |
2,971,382 | 2,971,383 | Auto-type conversion in JavaScript | <p>The following all expressions in JavaScript are far obvious.</p>
<pre><code>var x = 10 + 10;
</code></pre>
<p>The value of <code>x</code> is <code>20</code>.</p>
<pre><code>x = 10 + '10';
</code></pre>
<p>The value of <code>x</code> in this case is <code>1010</code> because the <code>+</code> operator is overloaded. If any of the operands is of type string, string concatenation is made and if all the operands are numbers, addition is performed.</p>
<pre><code>x = 10 - 10;
x = 10 - '10';
</code></pre>
<p>In both of these cases, the value of <code>x</code> will be <code>0</code> because the <code>-</code> operator is not overloaded in that way and all operands are converted to numbers, if they are not before the actual subtraction is performed (you may clarify, if anyway I'm wrong).</p>
<hr>
<p>What happens in the following expression.</p>
<pre><code>x = '100' - -'150';
</code></pre>
<p>The value of <code>x</code> is <code>250</code>. Which also appears to be obvious but this expression somewhat appears to be the equivalent to the following expression.</p>
<pre><code>x = '100' +'150';
</code></pre>
<p>If it had been the case then these two strings would have been concatenated and assigned <code>100150</code> to <code>x</code>. So why is addition performed in this case?</p>
<hr>
<p><strong>EDIT :</strong></p>
<p><code>+'10' + 5</code> returns <code>15</code> and <code>'a' + + 'b'</code> returns <code>aNaN</code>. Does anyone know why?</p>
| javascript | [3] |
2,126,248 | 2,126,249 | Monitor/logging who signs into the asp.netapp? | <p>I want to have a log file keep rows of who logs in and timestamp. is there a place to do this? And what sort of code is needed?</p>
| asp.net | [9] |
5,864,630 | 5,864,631 | Iphone: what type of APDU will use for contactless stickers | <p>Here i am using MYMax sticker. how can i communicate with contactless sticker in iphone.
please help me this one
Thanks in advance</p>
| iphone | [8] |
5,156,891 | 5,156,892 | GlobIterator prepends / slash to local filenames | <p>So I was trying to use <a href="http://php.net/GlobIterator" rel="nofollow"><code>GlobIterator</code></a> for unifying some file parameter handling. (Using the Iterator for symmetry with the also used <a href="http://php.net/RecursiveDirectoryIterator" rel="nofollow"><code>RecursiveDirectoryIterator</code></a> for other list params.)</p>
<p>But it has a peculiarity with filespecs for the current directory:</p>
<pre><code> $dir = new GlobIterator("*.php");
</code></pre>
<p>That prepends <code>/</code> slashes to keys and <code>FileObject</code> entry names.</p>
<pre><code> [pathName:SplFileInfo:private] => /index.php
[fileName:SplFileInfo:private] => /index.php
</code></pre>
<p>Which makes utilizing it as filename iterator less useful. </p>
<p>So <code>GlobIterator</code> is not merely a 1:1 <a href="http://php.net/glob" rel="nofollow"><code>glob()</code></a> replacement wrapped in an Iterator as the manual suggests. <strong>(1)</strong> But why does the <code>/</code> get prepended anyway? <strong>(2)</strong> And which flag does disable this rewrite? <a href="http://php.net/FilesystemIterator" rel="nofollow"><code>FilesystemIterator::CURRENT_AS_FILEINFO</code></a> was my first assumption, but didn't help, neither <code>::KEY_AS_PATHNAME</code>. Are there other flags? (terse manual and all)</p>
| php | [2] |
1,053,156 | 1,053,157 | substring javascript not working at all | <p>is there any reason why this wouldn't be working? </p>
<pre><code> var caseString = "sliderInput";
var theString = caseString.substring(1, 2);
</code></pre>
<p>I put it through the Firebug debugger in Firefox and it is giving me the error:
"invalid assignment left-hand side."</p>
<p>*<em>*</em> here is my exact code</p>
<pre><code> var elements = new Array();
elements = document.getElementsByTagName("Input");
var allSliderInputs = new Array();
var sliderParams = new Array();
var first, last, inc, style;
for (var i=0; i < elements.length ; i++){
var c = elements[i].className; //works fine here
var t = c.substring(0, 2); //when it hits this line it says "invalid assignment left-hand side"
}
</code></pre>
| javascript | [3] |
2,817,091 | 2,817,092 | Define a function with a prototype chain | <p>Suppose I have an object <code>X</code> defined as</p>
<pre><code>var X = function () {};
X.prototype.doSomething = function () {};
X.prototype.doSomethingElse = function () {};
</code></pre>
<p>Is it possible to construct a <strong>function</strong> <code>f</code> so that <code>f instanceof X</code>?
Note that I must also be able to do <code>f()</code> without a <code>TypeError</code>.</p>
<hr>
<p>In Mozilla, I can do exactly what I want with <code>__proto__</code>:</p>
<pre><code>var f = function () {};
f.__proto__ = new X;
</code></pre>
<p>However, that is (1) nonstandard and (2) deprecated. <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/Proto" rel="nofollow">MDN's page for <code>__proto__</code></a> suggests using <code>Object.getPrototypeOf</code> instead, but what I'm really looking for is an <code>Object.setPrototypeOf</code> (which doesn't exist, though the idea is brought up in <a href="https://bugs.ecmascript.org/show_bug.cgi?id=264" rel="nofollow">this bug report</a>).</p>
<p>A cheap approximation to what I want is</p>
<pre><code>var f = function () {};
jQuery.extend(f, new X);
</code></pre>
<p>Unfortunately, this does not make <code>f instanceof X</code> true (nor would I
expect it to!).</p>
| javascript | [3] |
3,311,387 | 3,311,388 | Number & Decimal Validations using Jquery | <p>I need to implement following validations.Please suggest any jQuery plugin for this.</p>
<h2>Case -1</h2>
<p>Numeric
Number Range : (0-9999)
Non Negative
Non Decimal</p>
<h2>Case -2</h2>
<p>Numeric
Number Range : (0-99.99)
Non Negative
Decimal with more than 2 digits after decimal is not allowed</p>
<h2>Case -3</h2>
<p>Numeric
Number Range : (0-99999)
Non Negative
Decimal @ first position or last position</p>
| jquery | [5] |
1,745,041 | 1,745,042 | how to display the pictures using javascript (jQuery) onto html webpage? | <p>so i have javaScript file with variable of image1 = pic1.jpg and variable of image 2 = {'pic2.jpg', 'pic3.jpg}</p>
<p>how do i just these variables to display the images horizontally with spaces in between them?</p>
| jquery | [5] |
3,176,984 | 3,176,985 | Should I perform a 301 redirect in Global.asax or on my 404 error page | <p>I'm about to replace a current e-commerce site with a brand new site. Before, a URL to a product was like this: www.example.com/ProductDetails.aspx?ProductID=123</p>
<p>Now it is like this: www.example.com/en-us/product/123/The-greatest-product-in-the-world</p>
<p>My question is: Should the 301 permanent redirect be done in the Application_BeginRequest event of Global.asax or in the Page_Load of my 404 error page? Isn't too late to make a 301 when the 404 loads?</p>
| asp.net | [9] |
1,714,208 | 1,714,209 | How to set UITextField setInputView to UIPickerView - iphone OS:3.1.2 | <p>I have created a UITextField along with UIPickerView programmatically and set the input view
of the text field to picker view but when i upload this test application to the iphone test device with iPhone OS: 3.1.2 it crashes on [textfield setInputView:picker] execution, however the same test application works fine if uploaded on iphone test device with iphone OS: 4.1. Please let me know how could i make it work on iphone OS:3.1.2 </p>
<p>Thanks</p>
<pre><code>UIPickerView* picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0.0f, 480.0f, 320.0f, 270.0f)];
picker.delegate = self;
[TestViewController addSubview:picker];
UITextField* textfield = [[UITextField alloc] initWithFrame:CGRectMake(145.0f, 97.0f, 155.0f, 29.0f)];
textfield.delegate = self;
[textfield setInputView:picker]; // Crashes on execution
[TestViewController addSubview:textfield];
</code></pre>
| iphone | [8] |
262,616 | 262,617 | check if a function is not false and use it's value without calling it again | <p>Hi i would like to know if there's a good way to check if a function return something and have a fallback if it return false. </p>
<pre><code>function setPage(hash){
for(k = 0; k<magazine.pages.length ; k++ )
{
if( magazine.pages[k][2] == hash )
{
return k;
break;
}
}
return false;
};
var actualPage = ( !hash ? 0 : setPage(hash.replace('#', '')) ? setPage(hash.replace('#', '')) : 0 )} );
</code></pre>
<p>I'd like to avoid the setPage() function to be called twice while i can't store it's value before as i want it to be called only if hash is true. Is it possible to do it whithout sacrifiing the short syntax ?</p>
| javascript | [3] |
5,799,704 | 5,799,705 | Designing a iPhone application | <p>I am into designing a new iPhone application. My application is will contain almost all iPhone SDK concepts including core data, server integration, location services. Is there any design decisions I should keep in mind?
My plan was to go by designing a controller class for each iPhone app screen and also any utility classes to be used. Any guidance will be really appreciated.</p>
| iphone | [8] |
2,261,106 | 2,261,107 | Block connections to specific host | <p>How to block network connection to specific host? Without root. Can I get a one of device network connections (by host or ip) which is now active and block it?</p>
| android | [4] |
2,984,343 | 2,984,344 | Best way to find max and min of two values | <p>I have a function that is passed two values and then iterates over the range of those values. The values can be passed in any order, so I need to find which one is the lowest first. I had the function written like this:</p>
<pre><code>def myFunc(x, y):
if x > y:
min_val, max_val = y, x
else:
min_val, max_val = x, y
for i in range(min_val, max_val):
...
</code></pre>
<p>But to save some screen space, I ended up changing it to:</p>
<pre><code>def myFunc(x, y):
min_val, max_val = sorted([x, y])
for i in range(min_val, max_val):
...
</code></pre>
<p>How bad is this? Is there a better way that's still one line?</p>
| python | [7] |
2,428,895 | 2,428,896 | Pointer array question | <pre><code>int test[3] = {1,2,3};
cout<<test[3]<<endl;
// this will get a error
</code></pre>
<p>but </p>
<pre><code>int test[3] = {1,2,3};
int (*A)[3];
A = &test;
cout<<test[3]<<(*A)[3]<<endl;
// this will print -858993460 withiout any errors
</code></pre>
<p>So could anyone tell me why? i am really confused by that.</p>
<p>in the first case why it is not outofboundary error but an undefined error?
and why the second case will not get a error? i used to think they are the same...</p>
<p>actually i did know the array start from 0, i am confused by why the first got an error but the second won't????</p>
| c++ | [6] |
1,422,562 | 1,422,563 | Python:how to replace string by index | <p>I am writing a program like unix tr, which can replace string of input.
My strategy is to find all indexes of source strings at first, and then replace them by target strings. I don't know how to replace string by index, so I just use the slice.
However, if the length of target string doesn't equal to the source string, this program will be wrong. I want to know what's the way to replace string by index.</p>
<pre><code>def tr(srcstr,dststr,string):
indexes = list(find_all(string,srcstr)) #find all src indexes as list
for index in indexes:
string = string[:index]+dststr+string[index+len(srcstr):]
print string
</code></pre>
<p>tr('aa','mm','aabbccaa')<br>
the result of this will be right: mmbbccmm<br>
but if tr('aa','ooo','aabbccaa'), the output will be wrong: </p>
<p>ooobbcoooa</p>
| python | [7] |
3,922,206 | 3,922,207 | Problem in displaying Bitmaps on canvas | <p>I am have some bitmaps which i want to display serially one after another but my code displays only last bitmap.Can anybody tell me why is it happening?
here is the code</p>
<p>class Panel extends SurfaceView implements SurfaceHolder.Callback {</p>
<pre><code> private boolean _run = false;
public Panel(Context context) {
super(context);
getHolder().addCallback(this);
_run = true;
}
@Override
public void onDraw(Canvas canvas) {
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
Log.i("Read","surfaceChanged is called");
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
Log.i("Read","surfaceCreated is called");
while (_run ) {
display();
}
}
public void display() {
Canvas c;
c = null;
try {
c = getHolder().lockCanvas(null);
synchronized (getHolder()) {
onPreviewFrame();
invalidate();
c.drawColor(Color.BLACK);
c.drawBitmap(bmp, 10, 10, null);
//panel.surfaceDestroyed(panel.getHolder());
}
} finally {
if (c != null) {
getHolder().unlockCanvasAndPost(c);
}
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
Log.i("Read","surfaceDestroyed is called");
_run = false;
}
}
</code></pre>
| android | [4] |
3,465,257 | 3,465,258 | Android - Layout change from database | <p>I have a project about quiz . I want to get data from database to create question . When user click next button , it go to next question (fetch from database).It has many question so can't create activity for each question . What type of layout should I use and How would I do that ?
Thank for helping .. </p>
| android | [4] |
442,327 | 442,328 | Android Specific file title | <p>I have faced with one problem: I tried to put video files with spanish titles(i.e. Puente Hacia <strong>Atrás</strong>) in assets folder and to do a listview to present titles of my videos. But when i try to get assets, convert it to list and get list length than I got 0 result. If I remove this specific spanish char everything is OK(video title is displayed in listview and video can be played). So, that is possible to do that such a title like this will be definable by app? I thought that app works in UTF-8 encoding type.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.