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 |
|---|---|---|---|---|---|
361,217 | 361,218 | QFlags python alternative | <p>In PyQt4, what is the alternative for:</p>
<pre><code>class TestClass
{
public:
enum Option {
OptionA = 0x0, // 0x000000
OptionB = 0x1, // 0x000001
OptionC = 0x2, // 0x000010
OptionD = 0x4, // 0x000100
OptionE = 0x8, // 0x001000
OptionE = 0x10 // 0x010000
// ... some more options with value which is a power of two
};
Q_DECLARE_FLAGS(Options, Option)
};
Q_DECLARE_OPERATORS_FOR_FLAGS(TestClass::Options)
</code></pre>
<p>How do I convert this block to python?</p>
| python | [7] |
2,389,119 | 2,389,120 | Nested type as function argument | <p>I have the following template class:</p>
<pre><code>
template<class T>
class C
{
typedef C_traits<T> traits;
typedef typename traits::some_type type;
//...
// use 'traits' and 'type' a lot
//...
};
</code></pre>
<p>where <code>C_traits</code> is a template struct that has a typedef for <code>some_type</code> that is different for each specialization of the type <code>X</code>. I am trying to write a function that receives a reference to a variable of <code>type</code> as defined above, i.e.:</p>
<pre><code>
template<class T>
//void f(const C_traits<T>::some_type& c) <-- this does not work either
void f(const C<T>::type& c)
{
//...
}
</code></pre>
<p>I'm getting an "expected unqualified-id before '&' token" error on the line where f is defined. I think I understand why I am getting this error, but I'd like to know if there is any way to accomplish what I'm trying to do here.</p>
<p>Put another way, I'd like to do something like this:</p>
<pre><code>
template<class T>
void f(typename const C<T>::type& c)
{
//...
}
</code></pre>
<p>which is not allowed. Any thoughs?</p>
| c++ | [6] |
1,056,666 | 1,056,667 | How to erase duplicate element in vector, efficiently | <p>I have</p>
<pre><code> vector<string> data ; // I hold some usernames in it
</code></pre>
<p>In that vector, I have duplicate element(s), so I want erase this/these element(s).Are there any algorithm or library function to erase duplicate element(s)?</p>
<pre><code>ex :
In data;
abba, abraham, edie, Abba, edie
After operation;
abba, abraham, edie, Abba
</code></pre>
| c++ | [6] |
923,734 | 923,735 | How do I alert users of an Android app when new data is posted to a remote server? | <p>I am developing an Android application for an already existing website. When ever a user enters some data into the website (like a forum post), all the other users should be alerted about that post. Is it possible?</p>
<p>I think this is possible with triggers. Am I correct? </p>
| android | [4] |
4,486,949 | 4,486,950 | When i develop my codes under Sun JDK and run my codes in Oracle JRockit JVM, am i using libraries from JRockit? | <p>When i develop my codes under Sun Standard JDK, and run my codes in Oracle JRockit JVM, am i using the implementation of the <code>String</code> class provided by Hotspot VM or JRockit VM?</p>
| java | [1] |
3,864,845 | 3,864,846 | Can I overwrite a constructor in javascript? | <p>I just learned that I <a href="http://stackoverflow.com/questions/13383345/how-do-i-access-this-javascript-property">can overwrite a method</a> in a Javascript class, as shown below, but what about the actual constructor?</p>
<p>If possible, how do I do it without instantiating the class?</p>
<pre><code>var UserModel = (function() {
var User;
User = function() {}; // <- I want to overwrite this whilst keeping below methods
User.prototype.isValid = function() {};
return User;
})();
</code></pre>
| javascript | [3] |
2,698,481 | 2,698,482 | How many ASP.NET developers program using pure OO? | <p>How many ASP.NET developers program using OO (e.g. using get, set)?</p>
<p>6 years ago I developed and maintained a .Net 1.1 Intranet application that had no get/set.</p>
<p>So how about today? Worth trying the pure OO route?</p>
<p>Thanks,</p>
<p>TDG</p>
| asp.net | [9] |
1,070,637 | 1,070,638 | Tuple conversion to a string | <p>I have the following list:</p>
<pre><code>[('Steve Buscemi', 'Mr. Pink'), ('Chris Penn', 'Nice Guy Eddie'), ...]
</code></pre>
<p>I need to convert it to a string in the following format:</p>
<pre><code>"(Steve Buscemi, Mr. Pink), (Chris Penn, Nice Guy Eddit), ..."
</code></pre>
<p>I tried doing </p>
<pre><code>str = ', '.join(item for item in items)
</code></pre>
<p>but run into the following error:</p>
<pre><code>TypeError: sequence item 0: expected string, tuple found
</code></pre>
<p>How would I do the above formatting?</p>
| python | [7] |
3,070,244 | 3,070,245 | Can I run arbitrary javascript code in the javascript:void() function using the browser's address bar? | <p>I was wondering if I could run a block of code(which includes for loops and if statements) in a javascript:void() function through the URL box.</p>
| javascript | [3] |
4,786,902 | 4,786,903 | Custom Web Control in ASP.NET | <p>I want to create a custom web control with properties like Color, Text , border width.I am currently working on aproject where we are adding the custom control on the page from the drop down list and at the same time provide the user yo modify the custom control property.I just need an example to know how to create such control.</p>
| asp.net | [9] |
6,015,719 | 6,015,720 | make static buttons dynamic | <p>I have added 10 custom buttons using interface on view. Now I want to make visible that no of buttons only whenever user put value. e.g If user put 5 then on button click 5 buttons get visible. Can it be possible? If anyone know please give me the solution.</p>
<p>Thanks alot.</p>
| iphone | [8] |
1,431,965 | 1,431,966 | how to prevent client to access public function of base class | <pre><code>//cls_a is defined by system framework, so we cannot change its definition
public class cls_a {
public void method_a();
}
//I add a new cls_b implemenation and would like to
//add a new method_a(int) function
//and prevent client side to access cls_a.method_a()
public class cls_b extends cls_a {
public void method_a(int a) {
//do something for a
method_a();
}
}
//client side
cls_b b = new cls_b();
b.method_a(2); //it's okay
b.method_a(); //should give something error when compiling code
</code></pre>
<p>I would like to design <code>cls_b</code> so that the Java compiler will give an error when client side calls <code>b.method_a()</code>. Anyone knows how to do it in Java?</p>
| java | [1] |
5,557,288 | 5,557,289 | Javascript: which 'time processing' function is faster? | <p>I just created two versions of a function that can be used to process the date and time and return it to different HTML elements. These elements will be displayed a phone lockscreen. The function is called every second, to make sure it jumps to the next minute in time.</p>
<ul>
<li>v.1 works at once: it processes every time unit (sec., min. day, month etc.) each second.</li>
<li>v.2 works step by step: if the numbers of second is at any time "0" process the minutes. Then, if minutes is "0" process the hours etc.</li>
</ul>
<p>I'd expected v.2 to be faster, but according to a test I did here: <a href="http://jsperf.com/timecalccompare" rel="nofollow">http://jsperf.com/timecalccompare</a> it's about 90% slower! <em>Is</em> it really slower or is the test unreliable?</p>
| javascript | [3] |
2,411,401 | 2,411,402 | Halting Execution of a program in C# | <p>In C++, I used to write a function that stops the execution of the program by the amount of the float parameter passed to it, there's the function:</p>
<pre><code>void wait(float sec){
clock_t endwait = clock() + sec * CLOCKS_PER_SEC; // CLOCK_PER_SEC == 1000
while(clock() < endwait);
}
</code></pre>
<p>is there an equivalent built in method in C# like that ?
if not, how can i write one like that in C# ?</p>
<p>Thnx in advance .. :)</p>
| c# | [0] |
4,403,788 | 4,403,789 | Prevent Default Jquery | <p>I'm trying to prevent the enter button when pressed on an input field that is within form tags to submit and and refresh the page. Instead I want to load an AJAX file. Now I know if I got rid of the form tags then this would work and I wouldn't even need the <code>e.preventDefault();</code> tags. What am I missing here? Code is below.</p>
<pre><code>$('#input_field').bind('keyup', function(e) {
if(e.keyCode==13){
e.preventDefault();
$('#insert_ajax_file').load('load_file.php');
}
</code></pre>
| jquery | [5] |
5,469,749 | 5,469,750 | String input, parsing, split | <p>I need to write a program that makes a user to type string date (ex. 10/21) once, and convert that string into integers. I suppose splitting is necessary before parsing?</p>
<pre><code>import java.util.Scanner;
public class ConvertDates {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Please input a date (mm/dd): ");
String k = input.next();
k = String.split("/");
int mm = Integer.parseInt(k);
int dd = Integer.parseInt(k);
</code></pre>
| java | [1] |
2,147,246 | 2,147,247 | how can i fix this application? (begginer) | <p>Hello im new to android development and im trying to follow the instructions in this book..<a href="http://amzn.to/4nck80" rel="nofollow">http://amzn.to/4nck80</a> and i just cant get it to work!</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" ></LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is my first android application!" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="And this is a clickable button!" />
</Button>LinearLayout>
</code></pre>
<p>im getting the Error The markup in the document following the root element must be well-formed. by the first Textview
and a warning Unexpected text found in layout file: "LinearLayout>" by LinearLayout></p>
<p>Thanks in advance!!</p>
| android | [4] |
612,847 | 612,848 | $(this) vs this in jQuery | <p>What is the difference between <code>$(this)</code> and <code>this</code> in jQuery ? Here are two different usage :</p>
<pre><code> $(document).ready(function() {
$("#orderedlist").find("li").each(function(i) {
$(this).append( " BAM! " + i );
});
});
$(document).ready(function() {
// use this to reset several forms at once
$("#reset").click(function() {
$("form").each(function() {
this.reset();
});
});
});
</code></pre>
| jquery | [5] |
2,001,127 | 2,001,128 | get collection of elements | <p>how to get a collection of elements?</p>
<pre><code>var tst = this.tbl_list.find('col');
alert('length = '+tst.length);
for(var key in tst){
alert(tst[key][0].tagName);
}
</code></pre>
<p>this alerts <code>length = 7</code> (which is the correct count), but each element is <code>undefined</code>!?</p>
| jquery | [5] |
3,071,604 | 3,071,605 | delete td and change cell data | <p>I have table with many rows. Each row is identified in UI with some ordered number such as 1, 2, 3 etc. This ordered number is also shown in UI.</p>
<p>When a row is deleted, the order should be changed dynamically</p>
<p>If second row is deleted. Then the other rows should be ordered again in sequence as 1, 2, 3 etc.</p>
<p>How can I do this?</p>
| jquery | [5] |
2,924,927 | 2,924,928 | In Java, how do I override the class type of a variable in an inherited class? | <p>In Java, how do I override the class type of a variable in an inherited class? For example:</p>
<pre><code>class Parent {
protected Object results;
public Object getResults() { ... }
}
class Child extends parent {
public void operation() {
... need to work on results as a HashMap
... results.put(resultKey, resultValue);
... I know it is possible to cast to HashMap everytime, but is there a better way?
}
public HashMap getResults() {
return results;
}
</code></pre>
| java | [1] |
5,553,210 | 5,553,211 | eric5 autocomplete | <p>I've installed Eric5 for python dev. with my portage on gentoo. I can't get any autocomplete in it!</p>
<pre><code>#!/usr/bin/python3
import os
os. #<-I've pressed ctrl+space many times but don't get a menu :(
</code></pre>
<p>Also installed assistant and rope plug-in, but it didn't helped. Configured eric to search completions in API files.</p>
| python | [7] |
915,430 | 915,431 | How to make soft keyboard enter button say “Search” in 3.2? | <p>all</p>
<p>I tried to use EditText's attribute </p>
<pre><code>android:imeOptions="actionSearch"
</code></pre>
<p>combined with </p>
<pre><code>android:inputType="text"
</code></pre>
<p>or with </p>
<pre><code>android:singleLine="true"
</code></pre>
<p>but have no luck.</p>
<p>Also i tried to set attributes from code:</p>
<pre><code>EditText edt = (EditText) findViewById(R.id.editText1);
edt.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
edt.setInputType(InputType.TYPE_CLASS_TEXT);
</code></pre>
<p>Problem present at Motorola Xoom with stock keyboard (firmware version 3.2) and at all emulators</p>
| android | [4] |
2,327,560 | 2,327,561 | PHP Include DB Conn - Password not accessible | <p>I have a strange include file problem. I'm hoping its a simple fix due to being a 2-day-old, PHP noob.</p>
<p>I'm simply trying to include DB credentials in to my parent script, like this:</p>
<p><strong>db-conn.php</strong></p>
<pre><code><?php
$dbUsername = "xxx";
$dbPassword = "xxx";
$dbHostname = "localhost";
?>
</code></pre>
<p><strong>parent.php</strong></p>
<pre><code><?php
include("c:/inetpub/vhosts/mydomain.net/php-private/db-conn.php");
//echo $dbPassword;
//echo $dbUsername;
$dbHandle = mysql_connect($dbHostname, $dbUsername, $dbPassword) or die("Unable to load page content due to a connection fault.");
unset ($dbHostname, $dbUsername, $dbPassword);
echo "Connected to MySQL<br><br>";
?>
</code></pre>
<p>But I'm getting this error:</p>
<p><strong>Access denied for user 'xxx'@'localhost' (using password: NO)</strong></p>
<p>What is strange about this (for me) is that I can echo the username and hostname successfully but I cannot echo the password, it's empty. Yet if I go to my include file, copy the password from 'dbPassword' and paste it inline on my parent page, it works. This proves my password is correct, the username and hostname ARE included, I just can't access my password variable!</p>
<p>Can somebody pleeeease put me straight here. I've already pulled my hair out tonight with open_basedir and permissions for this include file!! <em>_</em></p>
<p>*<em>UPDATE - *</em></p>
<p>Problem solved, please see my answer below.</p>
| php | [2] |
1,257,172 | 1,257,173 | listing exceptions programmatically - Python | <p>Is there any way to programmatically determine which exceptions an object or method might raise?</p>
<p>Like <code>dir(obj)</code> lists available methods, I'm looking for the equivalent <code>dir_exceptions(obj)</code>.</p>
<p>As far as I know, the only way to achieve this would be to parse the source.</p>
| python | [7] |
2,819,831 | 2,819,832 | custom button images not applying | <p>Hi im applying custom images to button on different states, for which i create an xml file in appliication drawable folder in which i define states of button and images like this </p>
<p>Btn_enter_cutom.xml</p>
<pre><code><item android:drawable="@drawable/btn_enter" />
<item
android:state_pressed="true"
android:drawable="@drawable/btn_enter_pressed" />
</code></pre>
<p>and assign this xml file to background attribute of the button.
button's default image is btn_enter.png but when this button presses i want to apply btn_enter_presses.png,but when i pressed the button nothing will happens,is there any problem with the xml file please help me in this regards.thanks</p>
| android | [4] |
5,224,610 | 5,224,611 | question about opening a new activity from notification from current activity | <p>My current activity is MyActivity( used to display the data on the list ) and I am getting a new notification. What I am expecting is the data on the list will be refresh when clicking on the notification but It does work that way....There is also a picture of a issue. Any ideas are welcome. Thanks</p>
| android | [4] |
1,466,211 | 1,466,212 | Searching a List of Lists - Python | <p>Basically I have converted a tab delimited txt file into a list containing a bunch of lists for each book (title, author, publisher, etc) and I have figured out how to search for something using indexes, but how can I make it so it searches and returns anything that matches even partially.</p>
<pre><code>import csv
import itertools
list_of_books = list(csv.reader(open('bestsellers.txt','rb'), delimiter='\t'))
search = 'Tom Clancy'
for sublist in list_of_books:
if sublist[1] == search:
print sublist
</code></pre>
<p>EG. So instead of having to search 'Tom Clancy' someone could enter 'clancy' and still get all the Tom Clancy novels.</p>
<p>Thanks.</p>
| python | [7] |
2,188,396 | 2,188,397 | How to query sqlite database from array in android | <p>I am using the following, where <code>AuthorName</code> column value i want to find on the basis of <code>AuthorID</code>. <code>catid</code> is an array that contains <code>AuthorID</code> </p>
<pre><code>public Cursor Authorname(String[] catid) {
myDataBase.rawQuery("SELECT AuthorName FROM AUTHOR_NAME WHERE AuthorID = ?",catid);
}
</code></pre>
<p>but it return <code>IllegalArgumentException</code>. Can anybody help me to short out this. Thanks in advance.</p>
| android | [4] |
1,093,781 | 1,093,782 | Add div to another div, then make some actions and then remove added div. How? | <pre><code>$div = $('<div>Here is my div!</div>');
$('#bar').append($div.html());
//do some actions
$div.remove();
</code></pre>
<p>But appended div isn't removed?</p>
<p>How can I do it?</p>
| jquery | [5] |
3,661,408 | 3,661,409 | Java JPane Option Window Problems | <p>This last program we did, stupid simple, was to just use a jpane and graphics to draw 3 non primative shapes but I need a way so that a message (JOptionPane) shows up AFTER the JPane is closed> if you have it after in the code, they both go at the same time</p>
| java | [1] |
4,892,701 | 4,892,702 | How to build a function on the fly in java? | <p>I'm parsing a text file that is being mapped to some java code like such:</p>
<pre><code>public void eval(Node arg)
{
if(arg.data.equals("rand"))
{
moveRandomly();
}
else if(arg.data.equals("home"))
{
goHome();
}
else if(arg.data.equals("iffood"))
{
ifFoodHere(arg.left, arg.right);
}//snip..
</code></pre>
<p>This is going to need to be re-evaluated about a thousand times and I'd rather not have to traverse the whole thing every time. Is there any way to make this traversal once and then have it be a function that is called every other time?</p>
| java | [1] |
1,101,120 | 1,101,121 | Find a class instance by given field object | <p>Is it possible to find a object instance using a public static method which expects a field object as parameter? </p>
<p>Thats what I search:</p>
<pre><code>public class Foo {
private Bar myObject;
public static Foo get(Bar bar) {
// return an instance of Foo which has stored a
// reference to bar inside myObject or null if not found
}
}
</code></pre>
<p>I hope, you understand my concern. Google did not help, I just guess that there could be a solution using Java Reflection. Thanks a lot for help.</p>
| java | [1] |
906,728 | 906,729 | How and where to register an email account to be used for sending emails from an app to the owner of the device? | <p>I have written an (android) app which can send emails to the user of the device. The user's gmail account is read from the device, and is used both as the email's sender and receiver address. The emails are currently sent via the gmail smtp server, via an email account registered by me (with a name corresponding to the name of the app). The App programmatically logs into my account, with the proper password, and sends the email to the user's account. It worked for a short time. Then gmail seemed to react on the fact that this email account was being logged into from various parts of the world (i.e. from my App used by various/different customers), and they suspected that the account was being hijacked. And they forced me to change the password. So this setup no longer seems to be working.</p>
<p>So my question is:
HOW can this be achieved?
Using another email account to send the emails through?
HOW? WHERE?
Or is there another way to use the gmail smtp server for this purpose?</p>
<p>Regards, Terje</p>
| android | [4] |
1,842,411 | 1,842,412 | Array initialization error | <p>I am doing java programming practice from a website. I have to display this out put using arrays.</p>
<pre><code>Enter the number of students: 3
Enter the grade for student 1: 55
Enter the grade for student 2: 108
Invalid grade, try again...
Enter the grade for student 2: 56
Enter the grade for student 3: 57
The average is 56.0
</code></pre>
<p>This is my source code so far, it is raising error <code>The local variable grades may not have been initialized</code>. How do I recover this? I have to make this program using arrays.</p>
<pre><code>package array;
import java.util.Scanner;
public class GradesAverage {
public static void main(String[] args) {
int numStudents = 0;
int[] grades;
Scanner in = new Scanner(System.in);
System.out.print("Enter number of students : ");
numStudents = Integer.parseInt(in.next());
for (int i = 0; i < numStudents; i++) {
System.out.print("Enter grade of student "+i+" :");
grades[i] = Integer.parseInt(in.next());
}
}
}
</code></pre>
| java | [1] |
393,160 | 393,161 | Improving __init__ where args are assigned directly to members | <p>I'm finding myself writing a lot of classes with constructors like this:</p>
<pre><code>class MyClass(object):
def __init__(self, foo, bar, foobar=1, anotherfoo=None):
self.foo = foo
self.bar = bar
self.foobar = foobar
self.anotherfoo = anotherfoo
</code></pre>
<p>Is this a bad code smell? Does Python offer a more elegant way of handling this?</p>
<p>My classes and even some of the constructors are more than just what I've shown, but I usually have a list of args passed to the constructor which just end up being assigned to similarly named members. I made some of the arguments optional to point out the problem with doing something like:</p>
<pre><code>class MyClass(object):
def __init__(self, arg_dict):
self.__dict__ = arg_dict
</code></pre>
| python | [7] |
3,989,719 | 3,989,720 | how to change the value of user.identity.name | <p>I think this is a very fundamental question - but i am not sure how to do it.</p>
<p>I am trying to test an application with different user login ID's (because these users have different roles).The application uses the login information of the system user and has no login of its own. The <code>user.identity.name</code> is used to get the value. However I would like to override this value to test for different user logins. How can I do this? </p>
| asp.net | [9] |
1,056,507 | 1,056,508 | setting location.href does not work from a <a> click | <p>This is code I took over from a colleague who left:</p>
<pre><code><input type="text" class="value" placeholder="0"></span><br>
<a href="/model/act/id/'.$model->id.'" class="act act-a" url="/model/act/id/'.$model->id.'">Act Now</a>
<script>
$('.act-a').click(function(){
if(parseInt($('.value').val())>0){
//window.location.href = window.location.origin + $(this).attr('url') + '?r=' + parseInt($('.value').val());
window.location.replace("www.google.com");
return true;
}
return false;
});
</script>
</code></pre>
<p>When I click on the link, I never get redirected to www.google.com. Originally what I want is to execute the commented code, but setting www.google.com to debug, I think to realize that my redirection is being ignored, and instead the original href from the is used! </p>
<p>How can I set window.location.href when a link has been clicked, adding a GET parameter?</p>
| javascript | [3] |
4,989,030 | 4,989,031 | Difference between Utility and Helper classes | <p>Aren't utility classes really the same concept as helpers? I mean utility methods don't extend an existing class such as helpers but the two types of methods really could be referred to as "Helpers" in either case.</p>
| c# | [0] |
14,507 | 14,508 | C# Dynamic Method Call on Generic Functions | <p>I have the following two functions:</p>
<pre><code>public class MyClass
{
public void Save<TObject>(TObject object) where TObject : class
{
}
public void Save<TObject>(TObject object, String strValue) where TObject : class
{
}
}
</code></pre>
<p>I want to be able to dynamically call the first save function similar to the following:</p>
<pre><code>public void DoSomething<T>(String strMethod) where T : class
{
T myObject = Activator.CreateInstance<T>();
MyClass.GetType().GetMethod(strMethod, new Type[] { typeof(T) }).MakeGenericMethod(typeof(T)).Invoke(null, new[] { myObject });
}
</code></pre>
<p>Unfortunately, when I do this, it is unable to match the first save function. If I remove the <code>new Type[] { typeof(T) }</code> I am stuck with an ambiguity issue. What am I missing?</p>
| c# | [0] |
413,323 | 413,324 | Adding the results to an arraylist | <p>I am facing some difficulties while assigning the values in an array list. My code is :</p>
<pre><code>while (answer.hasMore()) {
SearchResult rslt = (SearchResult)answer.next();
Attributes attrs = rslt.getAttributes();
System.out.println();
if (attrs.get("department") != null && attrs.get("telephonenumber") != null) {
System.out.println(attrs.get("department") + " " + attrs.get("name") + " " +
attrs.get("Description") + " " + attrs.get("mail") + " " +
attrs.get("telephonenumber")+
attrs.get("samaccountname") + attrs.get("samaccountname") );
}
</code></pre>
<p>I want to assign the values of <code>attrs.get("department") + attrs.get("description")+ attrs.get("name")+attrs.get("mail")</code> each one to an array list.</p>
<p>I tried to define at the beginning:</p>
<pre><code>String[] name = new String[100];
</code></pre>
<p>and in the while loop i tried to read the name attribute, I tried to do:</p>
<pre><code>name = attrs.get("name");
</code></pre>
<p>But it did not work. Can anyone help.</p>
| java | [1] |
3,970,057 | 3,970,058 | Android App Class Not Found Error | <p>I developed an Android project in the package:<code>com.anand.eprint</code>. </p>
<p>The package contains <code>ePrintActivity.java</code> and <code>GmailSender.java</code>. The <code>ePrintActivity</code> calls <code>GmailSender</code> internally. This is working successfully. </p>
<p>I exported the project, taken backup and formated the system.
Now I installed new OS, eclipse and android environment. </p>
<p>Imported the same Android project into eclipse. </p>
<p>Now I am trying to install and run in <code>Emulators/Android</code> Phones. </p>
<p>I am getting error: <code>ClassNotFoundError:GmailSender</code>. </p>
<p>Please anyone help me ?</p>
| android | [4] |
2,293,875 | 2,293,876 | typical memory usage of an iphone app | <p>According to Instruments 'Net Bytes' of my app are never more than 2MB yet sometimes I receive memory warning and the app crashes because some views on the stack are unloaded by force.</p>
<p>I'd like to know what is the typical memory footprint where system would not send you memory warning and unload the views ?</p>
<p>I have so far tried this on OS 3.1.2 on iphone 3GS and 3G and with 3G giving warning almost 80% of the time I test the app on it.</p>
| iphone | [8] |
5,672,586 | 5,672,587 | variable variables | <p>how do i create variable variables inside a for loop?</p>
<p>this is the loop: </p>
<pre><code>for ( $counter = 1; $counter <= $aantalZitjesBestellen; $counter ++) {
}
</code></pre>
<p>inside this loop i would like to create a variable $seat for each time it passes but it has to incrementlike so. first time it passes it should be <code>$seat1 = $_POST['seat'+$aantalZitjesBestellen]</code>, next time it passes: <code>$seat2 = $_POST['seat'+$aantalZitjesBestellen]</code> and so on.</p>
<p>so at the end it should be:</p>
<pre><code>$seat1 = $_POST['seat1'];
$seat2 = $_POST['seat2'];
</code></pre>
<p>and so on.</p>
<p>so the variable and the content of the $_POST should be dynamic.</p>
| php | [2] |
1,273,068 | 1,273,069 | I need a uDIG tutorials | <p>Do you know any good tutorials - how to create plug-ins to uDIG application?</p>
| java | [1] |
286,813 | 286,814 | parent.history.back(); is not supported in firefox | <p>parent.history.back(); is not supported in firefox, i am using asp.net ajax history.</p>
| asp.net | [9] |
2,467,531 | 2,467,532 | Unexpected token ( error | <p>hello can anyone help me debug little error that my eyes seem to be skipping. error is: unexpected ( error. Are my array syntex correct?</p>
<pre><code>function SourceClusting()
{
// grabbing count
var table = document.getElementById('OSDataCount');
var counter= table.rows[1].children[0].innerHTML
// putting all variable into arrays
var latitude()
var longitude()
var i
var marker =[];
// placing values into arrays
for (i=1;i == counter;i++)
{
longitude[i]=table.rows[i].children[6].innerHTML;
latitude[i]=table.rows[i].children[5].innerHTML;
marker[i]=new GMarker(new GLatLng(longitude[i],latitude[i]));
}
var markerCluster = new MarkerClusterer(map, marker);
}
</code></pre>
<p>cheers</p>
| javascript | [3] |
5,477,369 | 5,477,370 | how to disable editing in a textbox and how to set default value of text box is eql to session variable | <p>I am editing a page and there i am asking again username and password for confirmation..
I want to pick username from session variable</p>
<pre><code>$_SESSION['employee']['password']=$row['Password'];
</code></pre>
<p>and want that username displayed there(i am setting username box value=session username variable) but not for editing only password is asked with value blank..</p>
<p>HOw i disable editing of any textbox like when we choose settings in orkut ...</p>
<p>I am trying this thing</p>
<pre><code><td><b><i>Username</i></b></td>
<td><input type="text" id="username" value="<?php $_SESSION['employee']['password'] ?>"></td>
</tr>
</code></pre>
<p>But by doing this my username textbox again coming blank.It is not filled with username i think the syntex i am using wrong...</p>
<pre><code>value="<?php $_SESSION['employee']['password'] ?>"
</code></pre>
<p>How i can correct it..</p>
| php | [2] |
1,671,220 | 1,671,221 | Which is better in implementing click listener? | <p>Which is a good practice in implementing click listener and why? Or is there a better way other than the two? Thanks.</p>
<p>First :</p>
<pre><code> sampleButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
// do something
}
});
</code></pre>
<p>Second : implement OnClickListener then override onClick method?</p>
| android | [4] |
3,992,839 | 3,992,840 | Assigning a value to a object's property/variable in a callback | <pre><code>var obj1={
var1:"val1",
init:function(){
this.var1="val2";
var self=this;
setTimeout(function(){self.var1="val3"},1);
setTimeout(function(){obj1.var1="val3"},1);
}
}
obj1.init();
console.log(obj1.var1);
console.log(obj1);
</code></pre>
<p>How to set/assign a value to var1 in the setTimeout callback. Assigning val3 does not have an effect and as seen in the screenshot we have two properties mentioned as var1 now. 1 is var1=val2 and other is var1=val3 , but this.var1 always returns val2 not val3</p>
<p><img src="http://i.stack.imgur.com/NXYdh.jpg" alt="enter image description here"></p>
| javascript | [3] |
2,555,260 | 2,555,261 | Error Writing a Copy constructor in C++ | <p>I am trying to write a copy constructor for a class but I get these two error messages, which I cannot decipher. Can somebody please tell me what I am doing incorrect?</p>
<pre><code>class Critter
{
public:
Critter(){}
explicit Critter(int hungerLevelParam):hungerLevel(hungerLevelParam){}
int GetHungerLevel(){return hungerLevel;}
// Copy Constructors
explicit Critter(const Critter& rhs);
const Critter& operator=(const Critter& rhs);
private:
int hungerLevel;
};
Critter::Critter(const Critter& rhs)
{
*this = rhs;
}
const Critter& Critter::operator=(const Critter& rhs)
{
if(this != &rhs)
{
this->hungerLevel = rhs.GetHungerLevel(); // ERROR: object has type qualifier not compatible with member function
}
return *this;
}
int _tmain(int argc, _TCHAR* argv[])
{
Critter aCritter2(10);
Critter aCritter3 = aCritter2; // ERROR : No suitable copy constructor
Critter aCritter4(aCritter3);
return 0;
}
</code></pre>
| c++ | [6] |
4,481,595 | 4,481,596 | Issue with custom jQuery selectbox - keyboard navigation | <p>I have issues with customized select box, i've done customization with this solution for example:
- <a href="http://info.wsisiz.edu.pl/~suszynsk/jQuery/demos/jquery-selectbox/" rel="nofollow">http://info.wsisiz.edu.pl/~suszynsk/jQuery/demos/jquery-selectbox/</a></p>
<p>I've tryed many others aswell... It's always same result. Issues remains, which is I can't type in a letter for example "T" for Texas, but instead scroll all the way down in order to select Texas.</p>
<p>Anyone perhaps familiar with this issue, is this a bug or is it just how it works?</p>
<p>I've checked all similair questions, but found no right answer or solution.</p>
| jquery | [5] |
1,297,705 | 1,297,706 | Issue with JQuery Each function | <p>I have a jquery function to hide email ids on the webpage to avoid spambots.
I am trying to replace all the span tags with class 'mailme' to valid email ids with the help of this function. The code was working for 1 span tag but since its changed to multiple spans with the help of each method, its not working.</p>
<p>Html</p>
<pre><code><span class="mailme">myemail at mydomain dot com</span>
</code></pre>
<p>jQuery</p>
<pre><code>$('span.mailme').each(function(){
var spt = "#" + $(this).attr("id");
var at = / at /;
var dot = / dot /g;
var addr = $(spt).text().replace(at,"@").replace(dot,".");
$(spt).after('<a href="mailto:'+addr+'" title="Send an email">'+ addr +'</a>')
.hover(function(){window.status="Send a letter!";}, function(){window.status="";});
$(spt).remove();
});
</code></pre>
| jquery | [5] |
2,411,178 | 2,411,179 | Is this the right way to connect to a socket? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/563153/socket-create-vs-fsockopen-php">socket_create vs. fsockopen php</a> </p>
</blockquote>
<p>Is this the right way to connect to a socket in PHP.</p>
<pre><code><?php
$fp = fsockopen($ipaddress,$port, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
}
else{
echo "Socket connected";
}
echo fread($fp, 100);
?>
</code></pre>
<p>If yes, then what is the difference between this approach and the approach specified here:
<a href="http://www.devshed.com/c/a/PHP/Socket-Programming-With-PHP/" rel="nofollow">http://www.devshed.com/c/a/PHP/Socket-Programming-With-PHP/</a>
Thanks</p>
| php | [2] |
2,720,700 | 2,720,701 | Splitting a string using a single delimeter | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/236129/splitting-a-string-in-c">Splitting a string in C++</a> </p>
</blockquote>
<p>I'm trying to split a single string object with a delimeter into separate strings and then output individual strings.</p>
<p>e.g The input string is firstname,lastname-age-occupation-telephone</p>
<p>The '-' character is the delimeter and I need to output them separately using the string class functions only.</p>
<p>What would be the best way to do this? I'm having a hard time understanding .find . substr and similar functions.</p>
<p>Thanks!</p>
| c++ | [6] |
3,341,774 | 3,341,775 | manifest file not containing an attribute | <p>Thanks for your answers. I'm still having a fault saying manifest file does not contain a file/object attribute, after I had created my jar file for my application. I'm doubting maybe I didn't know what exactly the main-class represent in a manifest file while writing the code. please illustrate taking an example from the HelloWorld .</p>
<p>Thanks</p>
| java | [1] |
616,368 | 616,369 | Arkanoid in C#, help needed | <p>I have searched on web, but dint find any tips how to do it. IDE to be used in Microsoft Visual Studio. What project type must I choose to make Arkanoid game?</p>
| c# | [0] |
1,767,734 | 1,767,735 | how can i send the data with the help of BeginSendTo function in UDP | <p>Actually i am quite new in UDP programming so i am not understanding how to use the BeginSendTo function....i have made a socket initiated all the relevant which is needed to make an connection then i used a array name buffer where i want to store my data..</p>
<p>Here is the sample of my code :-</p>
<pre><code>public partial class Form1 : Form
{
byte[] buffer = new byte[10];
IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 1235);
Socket newsocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
IPEndPoint sen = new IPEndPoint(IPAddress.Loopback, 5001);
newsocket.Bind(endpoint);
EndPoint tmp = (EndPoint)sen;
protected void SendCallback(IAsyncResult ar)
{
try
{
Socket socket = (Socket)ar.AsyncState;
for (int i = 0; i < 6; i++)
{
buffer[i] = (Byte)uLC.getADC(i); // this is the function i am storing the values in to buffer array
}
}
catch (Exception err)
{
MessageBox.Show(err.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Interval = 2000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
newsocket.BeginSendTo(buffer, 0, 7, SocketFlags.None, tmp, new AsyncCallback(SendCallback),newsocket);
}
</code></pre>
<p>I am not able to send the data..</p>
| c# | [0] |
4,735,730 | 4,735,731 | Need to post JSONObject to PHP server through parameter | <p>From past couple of hour I was trying to send JSONObject to a PHP server. I need to send this object through a parameter.</p>
<p>Some what like this:</p>
<pre><code>message={"name":"Firstname","email":"test@test.com"}
</code></pre>
<p>here message is my parameter name.</p>
<p>Yes I am using HttpClient for posting my request. As I have mentioned that I need to send a post request to the server attaching a JSONObject to a parameter, I am using the following methods:</p>
<p>Supose my exact URL is like <a href="http://www.example.com/" rel="nofollow">http://www.example.com/</a> then I need to append deviceID, date and message type with the URl so as to make it look like <a href="http://www.example.com/deviceID/date/140" rel="nofollow">http://www.example.com/deviceID/date/140</a> then to this URL I need to send a post request which is a JSONObject attaching it to a parameter named message.</p>
<p>For this I am doing:</p>
<pre><code>String url = "http ://www.example.com/deviceID/date/140";
JSONObject j = new JSONObject();
j.put("name", "Firstname");
j.put("email", "test@test.com");
HttpClient httpclient = new DefaultHttpClient();
HttpPost request = new HttpPost(url);
BasicHttpParams params = new BasicHttpParams();
params.setParameter("message",j.toString());
request.setParams(params);
HttpResponse response = httpclient.execute(request);
</code></pre>
<p>If I pass this way, the server returns a JSONObject error message saying <code>"error":"name not found"</code> -- what am I doing wrong?</p>
| android | [4] |
1,738,334 | 1,738,335 | To change the character to string | <p>Have to change the character "^" to "255E"</p>
<pre><code>String s_ysymbol = c1.getString(c1.getColumnIndex(DBConstants.YSYMBOL));
</code></pre>
<p>in this ysymbol starting charecter will be ^ have to change it to 255E and then have to do further process..
I tried the replace method</p>
<pre><code>s_ysymbol.replace("^","255E");
</code></pre>
<p>but it not changing.. can anybody provide solution..</p>
| java | [1] |
115,354 | 115,355 | Can i do the effect shown in this page using jquery? | <p>Please look at this page:</p>
<p><a href="http://www.nike.com/nikeos/p/nikegolf/en_US/" rel="nofollow">http://www.nike.com/nikeos/p/nikegolf/en_US/</a></p>
<p>In the slide number 2, there is a midpanel that does a growing effect onmouse over.Some panels step aside at the same time or simply grows over another. As you can see, the background changes, the box grows as well as its content. I think that is flash, but, is there a way to obtian the same results using jquery? I have certain jquery experience but i dont wich function would be usefull to combine to get those results</p>
<p>Thanks</p>
| jquery | [5] |
4,626,455 | 4,626,456 | formatting double precision values in C# | <p>Say I have a <code>double</code> variable initialized as </p>
<pre><code>double dValue = 5.156365
</code></pre>
<p>I would like to show this in a textbox as 5.16 i.e only two decimal places.</p>
<p>How should I format? </p>
<p>Is <code>textbox.Text = dValue.ToString("F2", Culture.....)</code> correct? When I tried it did give me the correct result. However, if <code>dValue = 5</code> then I would like only 5 to be shown and not 5.00.</p>
<p>How could I achieve this in C#?</p>
| c# | [0] |
5,542,448 | 5,542,449 | Java Array Bulk Flush on Disk | <p>I have two arrays (int and long) which contains millions of entries. Until now, I am doing it using DataOutputStream and using a long buffer thus disk I/O costs gets low (nio is also more or less same as I have huge buffer, so I/O access cost low) specifically, using </p>
<pre><code>DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("abc.txt"),1024*1024*100));
for(int i = 0 ; i < 220000000 ; i++){
long l = longarray[i];
dos.writeLong(l);
}
</code></pre>
<p>But it takes several seconds (more than 5 minutes) to do that. Actually, what I want to bulk flush (some sort of main memory to disk memory map). For that, I found a nice approach in <a href="http://www.cs.berkeley.edu/~bonachea/java/dist/doc/html/ti/io/BulkDataInputStream.html" rel="nofollow">here</a> and <a href="http://www.cs.berkeley.edu/~bonachea/java/dist/doc/html/ti/io/BulkDataOutputStream.html" rel="nofollow">here</a>. However, can't understand how to use that in my javac. Can anybody help me about that or any other way to do that nicely ?</p>
| java | [1] |
1,923,590 | 1,923,591 | Best way of writing an expression in an if construct | <p>I have a question about something that I found among PHP best practises book that I read.</p>
<p>What is the best way to do the following test?</p>
<pre><code>if("value" == $variable){}
</code></pre>
<p>and</p>
<pre><code>if($variable == "value"){}
</code></pre>
| php | [2] |
739,520 | 739,521 | Python .replace() Error | <p>In Python, I open a text file and read it line-by-line, and strip() the line before evaluating it.
When I evaluate the line, I have an if statement to check if the line is "random", and then puts a random number into a variable called genRandom. I have another line in my code that looks like this:</p>
<pre>thisLine.replace("genRANDOM",genRandom) #Replace genRANDOM with the random number</pre>
<p>On every line, it seems to work ok. In the input text file, I have a line that looks like this:</p>
<pre>-genRANDOM</pre>
<p>Whenever my script evaluates that line, I get this error:</p>
<pre><code>Traceback (most recent call last):
File "D:\Mass Storage\pythonscripts\TurnByTurn\execute.py", line 37, in <module>
thisLine.replace("genRANDOM",genRandom) #Replace genRANDOM with the random number
TypeError: expected a character buffer object
</code></pre>
<p>How can I fix this? Thanks in advance!</p>
| python | [7] |
2,164,883 | 2,164,884 | Getting location on first boot FC also and random FC's on some devices | <p>I am getting the current location with the following code but this is causing FC if there is no last known location. Also some devices like Motorola atrix crash if they open this activity.</p>
<pre><code>locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000L, 500.0f, this);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f, this);
Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
double lat = location.getLatitude();
double lng = location.getLongitude();
</code></pre>
<p>Is there a better way of getting the current location with out crashing my app?</p>
| android | [4] |
4,703,895 | 4,703,896 | Why is the name of the variable declared twice on the same line? | <p>I have created the following function..</p>
<pre><code>function test(){
var el = el = document.body;
};
test();
</code></pre>
<p>Here what does the repeated <code>el</code> represent? is they return the same value? Can anybody explain this in short? Thanks in advance.</p>
| javascript | [3] |
1,311,950 | 1,311,951 | Call to undefined function using encoding in PHP | <p>i am getting <code>Call to undefined function basr64_encode()</code> Error of PHP is there some Library Missing ??? or any extension ? </p>
| php | [2] |
4,386,287 | 4,386,288 | Not getting the response after adding debug proxy | <p>I have an android application where i connect to server and get the data to be rendered. To show the maps I added '<strong>-http-proxy IP:port -debug-proxy</strong>' to 'Additional emulator command line options' in eclipse . Since i have added this I am unable to recieve the response properly.
I am using HTTP connection to connect to server and get the response. I am using following code :</p>
<pre><code> HttpResponse response = httpclient.execute(httppost);
Log.v("Response",""+response.toString());
responseBody = EntityUtils.toString(response.getEntity());
Log.v("ResponseBody",""+responseBody);
</code></pre>
<p>First Log statement is getting executed but second Log statement is not getting executed.</p>
<p>I am getting following in the console:</p>
<p>sent closed=0 data=0 n=0 ret=0</p>
<p>connection reset by peer (receive)</p>
<p>body completed by close (13908 bytes)</p>
<p>I am not getting complete response and connection is getting lost.</p>
<p>Everything is working fine fine if i remove '-http-proxy IP:port -debug-proxy' . But then i cant show map.</p>
<p>Pls help.. Thanks</p>
| android | [4] |
2,700,413 | 2,700,414 | How to make all combinations of the elements in an array? | <p>I have a list. It contains x lists, each with y elements.
I want to pair each element with all the other elements, just once, (a,b = b,a)</p>
<p>EDIT: this has been criticized as being too vague.So I'll describe the history.
My function produces random equations and using genetic techniques, mutates and crossbreeds them, selecting for fitness.
After a number of iterations, it returns a list of 12 objects, sorted by fitness of their 'equation' attribute.
Using the 'parallel python' module to run this function 8 times, a list containing 8 lists of 12 objects (each with an equation attribute) each is returned.
Now, within each list, the 12 objects have already been cross-bread with each other.
I want to cross-breed each object in a list with all the other objects in all the other lists, but not with the objects within it's own list with which it has already been cross-bread. (whew!)</p>
| python | [7] |
5,920,970 | 5,920,971 | Android mainfest file | <p>my application contain some default intent and user defined ,i want my application to start always from the beaning when user resuming the application after pressing the home button</p>
| android | [4] |
4,353,737 | 4,353,738 | How to properly cancel pending alarms | <p>I can't seem to find an answer to this, but what is the criteria for passing in a matching <code>PendingIntent</code> to be removed from an alarm? It it based on the just the name like com.blah.package.myclass or do the <code>Extra</code>s matter?</p>
<p>For example, I'm doing something like this and all alarms fire the same intent:</p>
<pre><code> public void setAlarm(Context context, long nextAlarmMillis) {
Intent intent = new Intent(context, AlarmReceiver.class);
intent.putExtra("alarm", this);
PendingIntent sender = PendingIntent.getBroadcast(context, 1234 /* unused */, intent, PendingIntent.FLAG_UPDATE_CURRENT);
// Get the AlarmManager service
AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
am.cancel(sender);
am.set(AlarmManager.RTC_WAKEUP, nextAlarmMillis, sender);
}
</code></pre>
<p>What happens is that the <code>Alarm</code> class can be altered, etc and passed in as an <code>Extra</code>. I am canceling the previous alarm, but I'm not sure if it's doing anything or if any left over alarms will remain.</p>
<p>Anyone know for sure?</p>
| android | [4] |
4,003,208 | 4,003,209 | Is it always OK to not explicitly initialize a value if you would only be setting it to its default value? | <p>Resharper just prompted me on this line of code:</p>
<pre><code>private static bool shouldWriteToDatabase = false;
</code></pre>
<p>indicating that I should not say " = false" because bools, apparently, <a href="http://msdn.microsoft.com/en-us/library/83fhsxwc.aspx">default to false in C#</a>. I've been programming in C# for over a year and a half and never knew that. I guess it just slipped through the cracks, but this leaves me wondering what's good practice.</p>
<p>Do I work on the assumption that default values are understood by all? This would result in cleaner code, but invites ambiguity if another programmer isn't aware of the default value.</p>
| c# | [0] |
5,703,162 | 5,703,163 | Problems with mousewheel in jQuery | <p>I have the following code in the head-section:</p>
<pre><code><script type='text/javascript' src='/js/jquery.mousewheel.min.js'></script>
jQuery(function($) {
$('#box').bind('mousewheel', function(event, delta) {
var dir = delta > 0 ? 'Up' : 'Down',
vel = Math.abs(delta);
alert(dir + ' at a velocity of ' + vel);
return false;
});
});
</code></pre>
<p>In firefox 5 nothing happens at all. In Chrome 13 and IE 9 I get "Down at a velocity of NaN", no matter at which direction I scroll.</p>
<p>How can I fix this? What I want to do is to check if the user is scorlliing upwards, or if he´s scrolling downwards.</p>
<p>Thanks for your help!</p>
| jquery | [5] |
5,990,052 | 5,990,053 | setTimeout scope issue | <p>I have a setTimeout defined inside of a function that controls the player's respawn (i am creating a game):</p>
<pre><code>var player = {
...
death:(function() {
this.alive = false;
Console.log("death!");
var timer3 = setTimeout((function() {
this.alive = true;
Console.log("alive!");
}),3000);
}),
...
}
</code></pre>
<p>When it executes, I read in the console, "death!" and 3 seconds later "alive!". However, <code>alive</code> is never really set back to true, because if i write <code>player.alive</code> in the console, it returns <code>false</code>. How come i can see "alive!" but the variable is never set back to true?</p>
| javascript | [3] |
1,027,882 | 1,027,883 | How do I generate test data for my Python script? | <p>A equation takes values in the following form :</p>
<pre><code> x = [0x02,0x00] # which is later internally converted to in the called function to 0x300
y = [0x01, 0xFF]
z = [0x01, 0x0F]
</code></pre>
<p>How do I generate a series of test values for this function ?
for instance I want to send a 100 odd values from a for loop </p>
<pre><code>for i in range(0,300):
# where a,b are derived for a range
x = [a,b]
</code></pre>
<p>My question was a bit unclear so please let my clarify.
what I wanted to ask how I can do <code>x =[a,b]</code> generate different values for <code>a,b</code> </p>
| python | [7] |
3,367,634 | 3,367,635 | create a listener that will listen to an external push server | <p>is there any build-in mechanism in Android, which could create a service or app that actully listens to some server from the out side.. something that will "Wake up" the phone and makes him receaving a message from an outside server (i am asking this coz most of the appz are working the way aroound, when the phone sending requests to an outside server to recieve data)</p>
<p>is it possible any how ?</p>
<p>thanks.</p>
| android | [4] |
2,876,932 | 2,876,933 | Replacing an element in an object array | <p>I want to replace the entire object in an array.</p>
<p><a href="http://jsfiddle.net/CWSbJ/" rel="nofollow">http://jsfiddle.net/CWSbJ/</a></p>
<pre><code>var array = [ {name: "name1" }, { name: "name2" } ];
var element = array[0];
element = {name: "name3"};
alert(array[0].name);
</code></pre>
<p>In this piece of code I would expect the output name3, why can't I replace an entire object in an array like this? And what is the good way to do this?</p>
| javascript | [3] |
258,533 | 258,534 | Step through wordpress code | <p>I was wondering if anybody knew how to setup step through code for Wordpress. I have tried <a href="http://xdebug.org/index.php" rel="nofollow">xdebug</a> but had no luck setting it up on my VPS. I managed to get it working on my localhost at one stage but it didn't track WP too well in conjunction with NetBeans. It either tried to load my page without the core WP files or lost track of what was going on before I could navigate to the page I wanted to debug.</p>
<p>To config my xdebug install I followed all the instructions on <a href="http://xdebug.org/find-binary.php" rel="nofollow">http://xdebug.org/find-binary.php</a> but NetBeans could not talk to my remote testing server.</p>
<p>For those interested here is the <code>phpinfo()</code> output post xdebug install: <a href="http://pastebin.com/dFgndG42" rel="nofollow">pastebin</a></p>
<p><em>tried to make this community wiki as I feel it's appropriate but the checkbox turned up absent</em></p>
| php | [2] |
4,733,252 | 4,733,253 | JQuery unbinding a specific handler | <p>Given the code below, how can you get <code>unbind('click', h)</code> to work?</p>
<p>It doesn't currently work. I could make <code>h</code> a global variable but I don't know how to "set this up" given the <code>msg</code> variable is set within the function.</p>
<p>??</p>
<pre><code>function x(open) {
var msg = "blah";
var h = function (e) {
e.preventDefault();
showDialog(msg);
};
if (open === true) {
but.unbind('click');
link.unbind('click');
} else {
but.click(h);
link.click(h);
}
}
</code></pre>
| jquery | [5] |
1,374,442 | 1,374,443 | Multiple value to UIPicker View | <p>I have a UI picker view to store child details, i got the value through a web service.I was added child name to picker view , now it shows all childs.</p>
<p>I also have one more value child id to store in the picker view, when a user select a child i need to get the id of the corresponding child.How i add multiple values to same row a pickerview.</p>
<p>Thanks,
Companion</p>
| iphone | [8] |
1,948,490 | 1,948,491 | Break multiple lines in a text file into a list of lists | <p>I am working with a text file ex:</p>
<pre><code>blahblahblahblahblahblahblah
blahblahblahblahblahblahblah
start
important1a important1b
important2a important2b
end
blahblahblahblahblahblahblah
</code></pre>
<p>What I want is to get an output like</p>
<pre><code>["'important1a', 'important1b'", "'important2a', 'important2b'"]
</code></pre>
<p>Where each important line is split into individual elements, but they are grouped together by line in one list.</p>
<p>I have gotten close with this:</p>
<pre><code>import shlex
useful = []
with open('test.txt', 'r') as myfile:
for line in myfile:
if "start" in line:
break
for line in myfile:
if "end" in line:
break
useful.append(line)
data = "".join(useful)
split_data = shlex.split(data)
print split_data
</code></pre>
<p>This outputs:</p>
<pre><code>['important1a', 'important1b', 'important2a', 'important2b']
</code></pre>
<p>There is no distinction between lines.</p>
<p>How can I modify this to distinguish each line? Thanks!</p>
| python | [7] |
1,401,366 | 1,401,367 | Valid value formats for android:padding? | <p>When writing xml files, I know following is working:</p>
<pre><code>android:padding="20px"
</code></pre>
<p>Are there other valid value formats available for <code>padding</code>? e.g.</p>
<pre><code>android:padding="10px 20px 10px 20px"
</code></pre>
| android | [4] |
379,488 | 379,489 | File uploading in asp.net? | <p>In web application [asp.net], when i am trying to upload a .doc file which is having 6 mb size, when i click ok button it is giving one empty tab in browser, where as when i upload small size .doc it is uploading, why it is like this, can you help me.</p>
| asp.net | [9] |
4,015,140 | 4,015,141 | Machine that can turn phone 90 degrees every few seconds? | <p>I want to detect memory leaks in my Android application. Some leaks could be detected while rotating the phone physically so that the activities are constantly recreated.</p>
<p>I'm looking of some sort of physical device that could turn the phone 90 degrees every X seconds. I could build something using lego Mindstorm (that would actually be very cool), but I'm looking for something cheaper.</p>
<p>I also thought of using a clock, but I couldn't find one that has a clock second hand strong enough. Futhermore if the phone rotate 360 degrees after some time the USB cable would become too twisted. I think a device that goes back and forth between horizontal and vertical would be perfect.</p>
<p>My dream testing machine would also allow me to plug a USB cable so that I can run the Monkey tool while constantly rotating the phone.</p>
| android | [4] |
5,601,559 | 5,601,560 | How do you simulate the press of a home button through terminal on a jailbroken iPhone? | <p>For iphone simulator , We can use AppleScript and can simulate the press of a home button through terminal. But for iphone, How do we can simulate the same?</p>
| iphone | [8] |
5,736,828 | 5,736,829 | Create Items via ECMA Script / JavaScript with SP.JS (CSOM) | <p>Im trying to create Items via ECMA Script & the client sided object model (CSOM).</p>
<p>Unfortunately I couldnt find an answer yet, can you tell me how to create it?
I want to translate this function to the CSOM world :</p>
<pre><code> function Create_Hyperlink(address, description, comment) {
var URL = address + " , " + description;
$().SPServices({
operation: "UpdateListItems",
listName: "Hyperlinks",
batchCmd: "New",
valuepairs: [["URL", URL], ["Comment", comment]],
completefunc: function (xData, Status) {
alert("Created");
}
});
}
</code></pre>
<p>Thanks for your replies :))</p>
| javascript | [3] |
3,590,637 | 3,590,638 | How to Add recurring events programatically? | <p>i am developing an application for adding events to calendar. i am using following code to insert recurring event but it force closes the application with an error "java.lang.IllegalArgumentException: DTEND and DURATION cannot both be null for an event."</p>
<p>code:</p>
<pre><code> ContentValues event = new ContentValues();
event.put("calendar_id", 1);
event.put("title", "Event Title");
event.put("description", "Event Desc");
event.put("eventLocation", "Event Location");
event.put("dtstart", Long.parseLong("1315432844000"));
event.put("rrule", "FREQ=WEEKLY;WKST=SU;BYDAY=WE");
event.put("allDay", 1); // 0 for false, 1 for true
event.put("eventStatus", 1);
event.put("hasAlarm", 1); // 0 for false, 1 for true
Uri url = getContentResolver().insert(eventsUri, event);
</code></pre>
<p>Thanks in Advance </p>
| android | [4] |
787,513 | 787,514 | Retry Task Framework | <p>I have a number of situations where I need to retry a task n-times if it fails (sometimes with some form of back-off-before-retry logic). Generally, if an exception is thrown, the task should be retried up to the max-retry count.</p>
<p>I can easily write something to do this fairly generically, but not wanting to re-invent the wheel I was wondering if anyone can recommend any frameworks for this. The only thing I have been able to find is: <a href="http://ant.apache.org/manual/Tasks/retry.html">Ant Retry</a> but I don't want to use Ant tasks directly in my application.</p>
<p>Thanks</p>
| java | [1] |
827,043 | 827,044 | How do you display data from two tables that are connected via an id? | <p>I have two tables with the following:</p>
<pre><code>table 1
sid, schedule, stime, splace, stourid
table 2
tourid, tourname
</code></pre>
<p>I want to display the <code>table 1</code> in a GridView, but with field <code>stourid</code> I want <code>tourname</code> from <code>table 2</code> to be displayed instead of <code>stourid</code>. How can I do this?</p>
| asp.net | [9] |
4,678,690 | 4,678,691 | Import program in other folders with Python | <p>I want to import a Python program from 2 different folders:</p>
<ul>
<li><code>Prog1</code> from the path <code>/home/francis/docs/folder1/</code></li>
<li><code>Prog2</code> from the path <code>/home/francis/docs/folder2/</code></li>
</ul>
<p>How do I import these two Programs in my main program situated in <code>/home/francis/docs/folder3/</code>?</p>
| python | [7] |
115,137 | 115,138 | One assembly spanning multiple files | <p>I know that 1 namespace can span multiple assemblies and also that 1 assembly can contain multiple namespaces.</p>
<p>However, what foxes me is how can one Assembly span multiple files. Is it done by simply creating the multiple assemblies with the same name in separate directories? Is that all there is to it?</p>
| c# | [0] |
2,099,205 | 2,099,206 | Make URL as an anchor tag in JavaScript? | <p>I am getting an URL as a input which I want to assign it to an anchor tag.</p>
<p>Suppose the URL is </p>
<pre><code>var url = "http://www.google.com";
</code></pre>
<p>I want to put this url like this</p>
<pre><code><a href="http://www.google.com">http://www.google.com</a>
</code></pre>
| javascript | [3] |
2,443,469 | 2,443,470 | Update Gridview on treeview node checked | <p>I need to update or filter the records in gridview, when I check a node in treeview <strong>without postback.</strong>
I tried placing the gridview in update panel and registered ASYNCPOSTBACKTRIGGER for treeviews NODECHECKCHANGED event, but still the postback occurs.</p>
<p>How can I solve this or any other approach? please help</p>
| asp.net | [9] |
4,941,696 | 4,941,697 | What is the use of a web.config file in asp.net? | <p>What is the use of a web.config file in asp.net?</p>
| asp.net | [9] |
1,522,874 | 1,522,875 | how to split a string with ',' | <p>I have an array of some parameters like:</p>
<pre><code>arr=['abc','xyz','how are you, I am good'];
</code></pre>
<p>I want a result like:</p>
<ol>
<li>abc</li>
<li>xyz</li>
<li>how are you, I am good </li>
</ol>
<p>Using javascript only.</p>
<p>I am explaining again something was wrong in last question.
Here is the scenario.</p>
<p>I have 6 string varables having some special charecters.</p>
<p>I assigned these 6 strings to an array like this:</p>
<pre><code>arr=[str1,str2,str3.....);
</code></pre>
<p>After that I am doing:</p>
<pre><code>arr=escape(arr);
</code></pre>
<p>Because some string variable have special charecters.</p>
<p>After that I am reviving this <code>arr</code> into other function like this.</p>
<pre><code>var newarr=unescape(arr);
</code></pre>
<p>Now I want to get all six variables from this new <code>arr</code>, how can I do this?</p>
<p>Currently I am using the split function like. </p>
<pre><code>split(',');
</code></pre>
<p>But the problem is in this some variables have, inside so it splits twice
I don't want that.</p>
| javascript | [3] |
2,537,122 | 2,537,123 | C# as a very first language? | <p>Is it possible to learn C# as your first computer language without any knowledge of the other three languages it combines? </p>
<p>I learned objective-c without knowing c first, but assuming I know nothing of C# or any other language is it possible to learn as a first language? </p>
| c# | [0] |
2,569,388 | 2,569,389 | SMS listener, best way? | <p>I need to make application that will catch EVERY SINGLE SMS that phone receives, and forward that SMS to email adress. So, i'm wondering how to perform that - should I make that as service or as application? User should open the application only once, and forget that it's running on his phone.
I really don't know how to manage this because I'm not experienced Java programmer, </p>
<p>If i make that as Service I assume that it would need to be running always, so it could 'listen' for incoming SMS's. (it doesn't help if it turns on periodically because than it's possible to miss some messages while being turned off). And i'm not sure if that's even possible?</p>
<p>If i make that as Application, could I achieve that effect through this way:
when default SMS application receives message, phone also notifies my app and so wake it up, and than my app cathes sms and do the job?</p>
| android | [4] |
5,903,960 | 5,903,961 | php inverted comma in a variable | <p>I am trying to assign a string to a variable like that</p>
<p><code>$start "<?xml version="1.0" encoding="utf-8"?>"</code></p>
<p>Its giving me error
PHP Parse error: syntax error, unexpected T_DNUMBER</p>
<p>I think its because I am inserting " between and also ?
How to solve this ?</p>
| php | [2] |
2,836,774 | 2,836,775 | Android: safe way to hide navigation spinner in ActionBar? | <p>I would like to show a spinner in my ActionBar, using <code>ActionBar.NAVIGATION_MODE_LIST</code>, but I would like it to hide/show based on some application context. I have found that I can remove it from the ActionBar with <code>getActionBar().setNavigationMode(-1)</code>, however I don't know if this is a good idea.</p>
<p>Any feedback on if this is safe or if there is a safer alternative?</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.