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 |
---|---|---|---|---|---|
2,214,224 | 2,214,225 |
I am moving selected data from one listbox to another but I am getting an error "Object reference not set to an instance of an object."
|
<pre><code> ListItem item = new ListItem();
item.Text = ListBox1.SelectedItem.Text;////(error occured here)
ListBox2.Items.Add(item.Text);
ListBox1.Items.Remove(item.Text);
string usrid = null;
string usridselect = "select user_id from user_membership where email_id ='" + ListBox1.SelectedItem.Text + "'";
SqlConnection sqcon = DBConnection.connectDB();
sqcon.Open();
SqlDataReader sqldr = DBConnection.SelectData(usridselect, sqcon);
if (sqldr.HasRows)
{
while (sqldr.Read())
{
usrid = sqldr[0].ToString();
}
}
sqldr.Close();
</code></pre>
|
c#
|
[0]
|
1,035,649 | 1,035,650 |
Cloning object in JAVA
|
<p>I can not understand the mechanism of cloning custom object. For example:</p>
<pre><code>public class Main{
public static void main(String [] args) {
Person person = new Person();
person.setFname("Bill");
person.setLname("Hook");
Person cloned = (Person)person.clone();
System.out.println(cloned.getFname() + " " + cloned.getLname());
}
}
class Person implements Cloneable{
private String fname;
private String lname;
public Object clone() {
Person person = new Person();
person.setFname(this.fname);
person.setLname(this.lname);
return person;
}
public void setFname(String fname) {
this.fname = fname;
}
public void setLname(String lname){
this.lname = lname;
}
public String getFname(){
return fname;
}
public String getLname() {
return lname;
}
}
</code></pre>
<p>This is example shows right way of cloning as a in the books write. But I can delete implements Cloneable in the class name definition and I receive the same result.</p>
<p>So I don't understand the proposing of Cloneable and why clone() method is defined in class Object? </p>
|
java
|
[1]
|
1,252,310 | 1,252,311 |
Minesweeper number of mines java
|
<p>Hi so I am almost done with this program that creates the class minesweeper game. It compiles and runs perfectly and the game shows up in the GUI client program, but one problem occurs.</p>
<p>When playing, sometimes the a 1 will appear when it has more than 1 adjacent mine, or a 0 when there is actually a mine in one of the eight squares surrounding it. Any help/suggestions are gladly appreciated!</p>
<pre><code>private void countAdjacentMines()
{
// TO DO: STUDENT CODE HERE
for (int i = 0; i < mineField.length; i++)
{
for (int j = 0; j < mineField.length; j++)
{
if (!(mineField[i][j].getIsMine()))
{
int count = 0;
for (int p = i -1; p <= i + 1; p++)
{
for (int q = j - 1; q < j + 1; q++)
{
if (0 <= p && p < mineField.length && 0 <= q && q < mineField.length)
{
if (mineField[p][q].getIsMine())
count++;
} // end if
} // end for
} // end for
mineField[i][j].setAdjacentMines(count);
} // end if
} // end for loop rows
} // end for loop columns
} // end countAdjacentMines
</code></pre>
|
java
|
[1]
|
4,986,818 | 4,986,819 |
PHP :: I am trying to print an 8x8 grid
|
<p>I am trying to print an 8x8 grid on php can anyone check this code is I am doing something wrong</p>
<pre><code> $row = 0;
$col = 0;
print "<form>";
while ($row <= 8){
print "<tr>";
$row++;
while ($col <= 8){
print "<td>";
print "<input type="checkbox" name="battle" value="ships">";
print "</td>";
$col++;
}
print "</tr>";
)
print "</form>";
</code></pre>
|
php
|
[2]
|
1,251,184 | 1,251,185 |
Confused about GridView and INamingContainer?
|
<p>I have a nested GridView. In order for me to find the nested GridView, I have to do a FindControl on the Parent GridView, but I was under the impression that you only need to do this if the parent control implements INamingContainer and according to this <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.aspx" rel="nofollow">link</a>, GridView does not implement from INamingContainer. Is there another reason?</p>
|
c#
|
[0]
|
5,827,410 | 5,827,411 |
groupsumClump Problem
|
<p>Im struggling to get the below problem right for a quite a while sometime.</p>
<p>Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given target, with this additional constraint: if there are numbers in the array that are adjacent and the identical value, they must either all be chosen, or none of them chosen. For example, with the array {1, 2, 2, 2, 5, 2}, either all three 2's in the middle must be chosen or not, all as a group. (one loop can be used to find the extent of the identical values). </p>
<pre><code> groupSumClump(0, {8, 2, 2, 1}, 9) → true
groupSumClump(0, {2, 4, 4, 8}, 14) → false
</code></pre>
<p>The code is at <a href="http://ideone.com/Udk5q" rel="nofollow">http://ideone.com/Udk5q</a></p>
<p>Failing test case scenarios:</p>
<pre><code> groupSumClump(0, {2, 4, 4, 8}, 14) → false -->NegativeArraySizeException
groupSumClump(0, {8, 2, 2, 1}, 9) → true false --> X
</code></pre>
<p>i have really tried my best to make it work but alas its failing always.
Please Need your help SO experts to resolve this problem
I will be highly obliged and thankful to you,if you can spare a few minutes to look into my problem as well and help me in acheieving the desired solution.</p>
|
java
|
[1]
|
3,618,544 | 3,618,545 |
Changing the value of "this"
|
<p>I have this function :</p>
<pre><code>Number.prototype.f=function()
{
this=2;//This is not working
}
var x=0;
x.f();
alert(a);//Here I want that x equal 2
</code></pre>
<p>And I want that x is 2 at the end!</p>
|
javascript
|
[3]
|
429,922 | 429,923 |
C#: Use of unassigned local variable, using a foreach and if
|
<p>I have this following code:<br>
I get the error, "Use of un-Assigned Local variable"
I'm sure this is dead simple, but im baffled.. </p>
<pre><code> public string return_Result(String[,] RssData, int marketId)
{
string result;
foreach (var item in RssData)
{
if (item.ToString() == marketId.ToString())
{
result = item.ToString();
}
else
{
result = "";
}
}
return result;
}
</code></pre>
|
c#
|
[0]
|
3,001,963 | 3,001,964 |
Simple jQuery syntax help, don't know where I've gone wrong
|
<p>I'm having trouble with a jQuery code at the moment, I know WHERE the problem lies, but I don't know what the problem is exactly. Probably very basic, but I'm new to this.</p>
<p>You can see a (non)working fiddle here: <a href="http://www.jsfiddle.net/CvZeQ/" rel="nofollow">http://www.jsfiddle.net/CvZeQ/</a></p>
<p>Basically I want to set different .click function based on whatever is selected (I have 5 image maps, each with a different #mapname, and want each to pertain to a different variable (answer1, answer2, answer3...) so as to store the selected 'answer' for each map.)</p>
<p>Here is the code I'm using for one of the maps:</p>
<pre><code> $(window).load(function(){
//Get cookies when page loaded
var useranswers=$.cookie('survery');
useranswers= JSON.parse (useranswers);
// do something with previous answers
//#shape functions
$('#shape area').hover(
function(e){
$('#'+ this.alt).addClass('hover');
},
function(e){
$('#'+ this.alt).removeClass('hover');
}
).click(
function(e){
$('img.selected-region').removeClass('selected-region');
},
function(e){
$('#'+ this.alt).addClass('selected-region');
},
function(e){
var answer1 = $(this).attr("class");
});
});
</code></pre>
<p>I know the problem lies somewhere with the .click function, but I'm not entirely sure what I've done wrong. Any help would be greatly appreciated.</p>
|
jquery
|
[5]
|
3,370,697 | 3,370,698 |
How to disable webview zoom out?
|
<p>I am loading javascript file in webview but If I double click a web view, it zooms out. Is there any way to disable that? </p>
<p>Thanks
Monali</p>
|
android
|
[4]
|
5,567,738 | 5,567,739 |
Python dictionary - binary search for a key?
|
<p>I want to write a container class that acts like a dictionary (actually derives from a dict), The keys for this structure will be dates.</p>
<p>When a key (i.e. date) is used to retrieve a value from the class, if the date does not exist then the next available date that preceeds the key is used to return the value.</p>
<p>The following data should help explain the concept further:</p>
<pre><code>Date (key) Value
2001/01/01 123
2001/01/02 42
2001/01/03 100
2001/01/04 314
2001/01/07 312
2001/01/09 321
</code></pre>
<p>If I try to fetch the value associated with key (date) '2001/01/05' I should get the value stored under the key 2001/01/04 since that key occurs before where the key '2001/01/05' would be if it existed in the dictionary.</p>
<p>In order to do this, I need to be able to do a search (ideally binary, rather than naively looping through every key in the dictionary). I have searched for bsearch dictionary key lookups in Python dictionaries - but have not found anything useful.</p>
<p>Anyway, I want to write a class like that encapsulates this behavior.</p>
<p>This is what I have so far (not much):</p>
<pre><code>#
class NearestNeighborDict(dict):
#
"""
#
a dictionary which returns value of nearest neighbor
if specified key not found
#
"""
def __init__(self, items={}):
dict.__init__(self, items)
def get_item(self, key):
# returns the item stored with the key (if key exists)
# else it returns the item stored with the key
</code></pre>
|
python
|
[7]
|
2,237,614 | 2,237,615 |
add and remove row from table using button
|
<p>I would like to have a table with 10 rows 5 of which are visible. Also 2 buttons - and + and if clicked a row is added or removed, same as the + image in the bbc.co.uk site. How would i accomplish this</p>
|
jquery
|
[5]
|
2,811,357 | 2,811,358 |
how to change values between loop
|
<p>I extracted the values of the array on the foreach loop, but I want when it retrieves a certain <code>'br_title'</code> changed href link to <code><a href="http://noorresults.moe.sa</code>..how to do that with simple code?..</p>
<pre><code> <ul class="riMenu">
<?php foreach ($last_branches as $last) { ?>
<li><a href="<?= base_url(); ?>branches/show/<?php if (!empty($last['br_id'])) echo $last['br_id'] ?>"> <?php if (!empty($last['br_title'])) echo $last['br_title'] ?></a></li>
<?php }; ?>
</ul>
</div>
</div><!-- Menu E
</code></pre>
|
php
|
[2]
|
2,323,067 | 2,323,068 |
writing code in button's click event in gridview
|
<p>i have added a button control in gridview and i want to redirect
to the another page on button's click event,
and also i want to access the values of selected row in a gridview and show that values on other page on button
click event which is inside the gridview,, can anybody plz help me out in this .</p>
|
asp.net
|
[9]
|
1,334,742 | 1,334,743 |
How to pass object between activities in android
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2736389/how-to-pass-object-from-one-activity-to-another-in-android">How to pass object from one activity to another in Android</a> </p>
</blockquote>
<p>While retrieving appSession I get a RunTimeException:</p>
<pre><code>appSession = (ApplicationSession)intent.getParcelableExtra("appSession");
</code></pre>
<p>I am creating a app in which at the launch of app I create an ApplicationSession class object. I want to pass this object to all activities upon launch. How do I achieve this?</p>
<pre><code>// app start
// contains data specific to app which I need to use across all activites.
ApplicationSession appSession = new ApplicationSession();
</code></pre>
<p>How to pass <code>appSession</code> to all activites?</p>
|
android
|
[4]
|
1,834,473 | 1,834,474 |
Incorrect line ending: found carriage return (\r) without corresponding newline (\n)
|
<p>I received error in my xml file. "Incorrect line ending: found carriage return (\r) without corresponding newline (\n).</p>
<pre><code><Button
android:id="@+id/btn_login"
android:layout_width="100dip"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/et_un"
android:layout_marginBottom="15dp"
android:layout_marginRight="22dp"
android:text="Login"
android:textColor="#AA0000"
android:textSize="10pt" />
</code></pre>
<p>How to solve it. can anyone help</p>
|
android
|
[4]
|
1,783,659 | 1,783,660 |
python -- trying to count the length of the words from a file with dictionaries
|
<p>SOLVED</p>
<pre><code>def myfunc(filename):
filename=open('hello.txt','r')
lines=filename.readlines()
filename.close()
lengths={}
for line in lines:
for punc in ".,;'!:&?":
line=line.replace(punc," ")
words=line.split()
for word in words:
length=len(word)
if length not in lengths:
lengths[length]=0
lengths[length]+=1
for length,counter in lengths.items():
print(length,counter)
filename.close()
</code></pre>
|
python
|
[7]
|
4,736,192 | 4,736,193 |
How to add the android application as a library to another android application?
|
<p>i create one simple apps.here i want use the one already create apps (name : mainLabProject) in my current apps.so i make the mainLabProject as library.goto <code>project explorer</code>->right click the <code>project Name</code>-> select <code>Properties</code>->select <code>android</code> then ->select <code>isLibrary</code> click <code>true</code> and create library.</p>
<p>After that i add this library in my current app (name UseLabProject).so follow the same path asa baove and after click <code>add</code> button and add mainLabProject as library in my current Apps.</p>
<p>also apply the permission in my current app`s maniFest file Like.</p>
<p><strong><code><uses-library android:name="info.main" android:required="true" /></code></strong></p>
<p>but when i run this apps this type error occur in conesole</p>
<pre><code>2012-07-21 12:18:05 - UseLabProject] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
[2012-07-21 12:18:05 - UseLabProject] Please check logcat output for more details.
[2012-07-21 12:18:05 - UseLabProject] Launch canceled!
</code></pre>
<p>and This type error in Logcat</p>
<pre><code>07-21 12:18:04.172: ERROR/PackageManager(63): Package info.use requires unavailable shared library info.main.MainLabProject; failing!
</code></pre>
<p>so now i how to solve this problem.</p>
<p>i remove the permission from manifest file then got this type exception</p>
<pre><code>07-21 12:56:23.885: E/AndroidRuntime(4663): java.lang.RuntimeException: Unable to start activity ComponentInfo{info.use/info.use.UseLabProject}: android.content.ActivityNotFoundException: Unable to find explicit activity class {info.use/info.main.MainLabProject}; have you declared this activity in your AndroidManifest.xml?
</code></pre>
|
android
|
[4]
|
2,172,747 | 2,172,748 |
How does System.Guid.NewGuid() generate unique values?
|
<p>How does <code>System.Guid.NewGuid()</code> know that the values it generates are unique, for example when i use in a loop?<br>
Does it internally store data somewhere? .</p>
|
asp.net
|
[9]
|
3,242,131 | 3,242,132 |
Why do we call null String?
|
<p>I like to know why do we call null string. Where Strings are objects in java and objects can not be null only references can be null.</p>
<p>Can anybody elaborate on it?</p>
|
java
|
[1]
|
3,637,616 | 3,637,617 |
How do I run a .py(GUI) file outside of IDLE in order to use sys.exit
|
<p>How do I run a .py file outside of IDLE in order to use sys.exit? I'm using command=sys.exit and seems to crash inside of tcl & tk when the button is pushed. The exit is working cause it returns SystemExit in the Shell. I've found that I need to run this outside the IDLE to have this work properly. Oh, I'm working from the book "Programming Python" tutorial. How do I run a .py(GUI) file outside of IDLE to see sys.exit work?</p>
<pre><code>import sys
from tkinter import *
widget = Button(None, text='Hello widget world', command=sys.exit)
widget.pack()
widget.mainloop()
</code></pre>
|
python
|
[7]
|
2,216,840 | 2,216,841 |
How to make Slide show for Apple iphone
|
<p>HI anyone Please let me know i need to Make a Slide show Application which can have 10 images and i need to keep all these Images in a Slide show manner </p>
|
iphone
|
[8]
|
1,931,499 | 1,931,500 |
Cannot copy assembly.Unable to add the dll to website
|
<p>Iam getting the error "Cannot copy assembly.Unable to add the dll to website. The process cannot access the file because it is being used by another process" while building the .net application.</p>
|
c#
|
[0]
|
2,916,113 | 2,916,114 |
Stop my app from being updated(auto-update is disabled)
|
<p>Consider that user has my app with version 1 and auto update option is disabled/off. I have an upgrade in the market for my app(say version 2).
User gets a notification saying, "updates available" and updates my app.
Now based on some requirement I need my app not be be upgraded to version 2.
Can this be done?</p>
|
android
|
[4]
|
3,576,888 | 3,576,889 |
Android: How to do the rest API authentication in android
|
<p>I want to call the secure rest api (Https) using the username and password.
The response from the api is JSON object.</p>
<p>How can i do that ?</p>
<p>Thank you.</p>
|
android
|
[4]
|
2,017,854 | 2,017,855 |
How to show a very long data in console window in C++?
|
<p>I have a data file that contains more than 500 rows, but I can only able to read around 400 rows in console window. How am I gonna solve this? </p>
<p>This is my c++ programming code to read the data file.</p>
<pre><code>int main ()
{
int a,b,c,d,e,f ;
string line;
ifstream infile;
infile.open ("test1.cp");
if (!infile)
cout<< "Error opening the file. \n";
else
{
while (!infile.eof())
{
getline(infile, line);
if (!(istringstream(line) >> a >> b >> c >> d >> e >> f))
continue;
cout << a << "\t" << b << "\t" << c << "\t" << d << "\t" << e <<"\t" << f << endl;
}
}
infile.close ();
getch ();
return 0;
}
</code></pre>
|
c++
|
[6]
|
2,693,947 | 2,693,948 |
javascript refresh popup from another popup
|
<pre><code>Window A opens window B
Window A opens window C
On Window C (after user action) I need Window B refreshed.
</code></pre>
<p>some more explanation:
yes. Window A is the main calendar. window B is opened manually and is smaller and shows stats about the calendar (window A)</p>
<p>When user clicks on a calendar event in window A then Window C opens. And when the user changes info on Window C then Window B (stats) needs to update.</p>
|
javascript
|
[3]
|
3,191,742 | 3,191,743 |
How to include library files while creating jar files
|
<p>How to include JOGL.jar and Gluegen-rt.jar in the java project? I have included these external jars in the eclipse, but when I try to create a Jar file of the project, the JAR file does not exceute. It says That JOGL.jar is missing. </p>
<p>How can I include these libraries? Any suggestions are welcome.</p>
|
java
|
[1]
|
701,098 | 701,099 |
Display all the week numbers between two dates in PHP
|
<p>Can anybody tell how to display all the week numbers that are covered between two dates in PHP.The dates may be of different year.</p>
<p>IF i am using start date as "2011-09-16" and end date as "2011-09-21" it will show me week 37 and 38.</p>
|
php
|
[2]
|
5,292,315 | 5,292,316 |
jquery: turn updating number into progress bar?
|
<p>so i have this div</p>
<pre><code><div id="progress">{2 digit number updates here}</div>
</code></pre>
<p>What's the best way to turn this into a progress bar?</p>
<p>something like this?</p>
<pre><code><div id="progress">
<div id="bar" style="width={2 digit number updates here}"></div>
</div>
</code></pre>
<p>would this be 'ok'?!!!</p>
|
jquery
|
[5]
|
2,548,241 | 2,548,242 |
Android: Create ListView in AsyncTask
|
<p>I'm creating <code>ListView</code> in <code>AsyncTask</code> inside <code>Fragment</code>. In <code>onActivityCreated</code> method i call <code>AsyncTask's execute()</code> method, but after <code>onPause()</code> when I resume activity, my list is empty. Should I call <code>execute()</code> method again in <code>onResume()</code>? Thank you.</p>
|
android
|
[4]
|
1,055,709 | 1,055,710 |
How to do <xor> in python e.g. enc_price = pad <xor> price
|
<p>I am new to crypto and I am trying to interpret the below code. Namely, what does <code><xor></code> mean?</p>
<p>I have a secret_key secret key. I also have a unique_id. I create pad using the below code. </p>
<pre><code>pad = hmac.new(secret_key, msg=unique_id, digestmod=hashlib.sha1).digest()
</code></pre>
<p>Once the pad is created, I have a price e.g. 1000. I am trying to follow this instruction which is pseudocode:</p>
<pre><code>enc_price = pad <xor> price
</code></pre>
<p>In Python, what is the code to implement <code>enc_price = pad <xor> price</code>? What is the logic behind doing this?</p>
<p>As a note, a complete description of what I want to do here here:
<a href="https://developers.google.com/ad-exchange/rtb/response-guide/decrypt-price" rel="nofollow">https://developers.google.com/ad-exchange/rtb/response-guide/decrypt-price</a></p>
<p><a href="https://developers.google.com/ad-exchange/rtb/response-guide/decrypt-price" rel="nofollow">developers.google.com/ad-exchange/rtb/response-guide/decrypt-price</a></p>
<p>Thanks</p>
|
python
|
[7]
|
2,335,828 | 2,335,829 |
MapView fails on a 2.3.3 android device
|
<p>I have a problem when my application is running on 2.3.3. It seems to crash immediately when trying to load the map. It works on all the emulator versions, and it works on a 2.2 device, but only crashes on the 2.3.3 device. Anyone know why this could happen? The exact log cat dump is </p>
<p>could not find class 'com.google.googlenav.map.TrafficService referenced from method com.google.android.maps.MapActivity.createMap</p>
|
android
|
[4]
|
2,314,685 | 2,314,686 |
How can i change language of my application
|
<p>In my application i have a option of language selection.</p>
<p>There is three language English German & Spanish. When I select an option, the entire application language should be changed.</p>
<p>Please help to solve my problem.</p>
|
android
|
[4]
|
5,106,097 | 5,106,098 |
Simple Java Error Code while compiling
|
<p>I am trying to run below code. It is giving me error</p>
<blockquote>
<p>The operator + is undefined for the argument type(s) String, void</p>
</blockquote>
<pre><code>public class CompStrings{
String s1=null;
String s2=null;
public void testMethod(){
s1 = new String("Hello");
s2 = new String("Hello");
String str3="abc";
String str4 ="abc";
/**
* ==
*/
if(str3==str4){
System.out.println("str3==str4 is true");
}else{
System.out.println("str3==str4 is false");
}
if(str3.equals(str4)){
System.out.println("str1.equals(str2) is true");
}else{
System.out.println("str1.equals(str2) is false");
}
System.out.println(s1.hashCode());
System.out.println(s2.hashCode());
System.out.println(s1 + " equals " + s2 + " -> " +
s1.equals(s2));
System.out.println(s1 + " == " + s2 + " -> " + (s1 == s2));
/*Integer i1 = new Integer(10);
Integer i2 = new Integer(10);
System.out.println(i1.hashCode());
System.out.println(i2.hashCode());
1)String s1="hello";
String s2="hello";
2)String s1 = new String("Hello");
String s2 = new String("Hello");
3)String s1="hello";
string s2=s1;
**/
}
public static void main(String argv[]){
CompStrings obj= new CompStrings();
// \System.out.println("Calling My Method"+ obj.testMethod());
System.out.println("Hashcode for emp1 = " + obj.testMethod());// Here it gives Error
}
public boolean equals(Object o){
String s = (String) o;
if (s1.equals(s) ){
return true;
}else{
return false;
}
}
public int hashCode(){
return s1.hashCode();
}
}
</code></pre>
|
java
|
[1]
|
5,072,648 | 5,072,649 |
Why are filename underscores better than hyphens
|
<p>From <a href="http://homepage.mac.com/s_lott/books/python/BuildingSkillsinPython.pdf" rel="nofollow">Building Skills in Python</a>:</p>
<p>"A file name like exercise_1.py is better than the name execise-1.py. We can run both programs equally well from the command line, but the name with the hyphen limits our ability to write larger and more sophisticated programs."</p>
<p>Why?</p>
|
python
|
[7]
|
4,679,485 | 4,679,486 |
PHP call static workaround for PHP 5.2
|
<p>Is there are way to get __callStatic, or similar, functionality in PHP 5.2?</p>
<p>I'm finishing a PHP Framework and need to use this functionality for a Database ORM class. So for example you can use the code below to get data from column 2 and column 4 of the database table i.e. by declaring methods dynamically according to what you want (like rails I guess).</p>
<pre><code>Class::find_by_col2_or_col4();
</code></pre>
<p>I have already done this in PHP 5.3 and it works perfectly, but I'm trying to do the same for those using PHP 5.2.</p>
<p>Or is there some other way to retrieve the name of the static method and arguments using PHP 5.2?</p>
<p>Thanks.</p>
|
php
|
[2]
|
2,932,528 | 2,932,529 |
pyschools topic 3 ex 9
|
<p>I have made already 3 posts today about pyschools.com exercises i hope that's not too much. Anyway, the exercise asks me to write a function to convert the time to 24 hour format.
Here's an example: >>> time24hr('12:34am') '0034hr'</p>
<p>My function, which works fine in my IDLE: </p>
<pre><code>def time24hr(tstr):
am_or_pm = tstr[-2:]
first_numbers = tstr[0:2]
last_numbers = tstr[3:5]
if am_or_pm == "am":
if first_numbers == '12':
first_in_am12 = '00'
return first_in_am12 + last_numbers + am_or_pm
else:
return first_numbers + last_numbers + am_or_pm
if am_or_pm == "pm":
if first_numbers == '12':
return first_numbers + last_numbers + am_or_pm
elif int(first_numbers) > 9:
ok = repr(int(first_numbers) + 12)
return ok + last_numbers + am_or_pm
elif int(first_numbers) <= 9:
ok = repr(int(tstr[1]) + 12)
return ok + last_numbers + am_or_pm
</code></pre>
<p>However, in the pyschools website, when i run the code, it gives me the following error :
ValueError: invalid literal for int() with base 10: '1:'
What does this mean ? </p>
|
python
|
[7]
|
546,042 | 546,043 |
Getting syntax error while using fopen and fread
|
<pre><code>$file = "status.txt";
$open = fopen($file, "r");
$size = filesize($file);
$count = fread($open, $size);
if($count == 1) {
header('Location: http://www.google.com/');
} else {
echo "Status is unavailable";
}
</code></pre>
<p>Hello, I am trying to read a text file.<br>
I get the error <code>Parse error: syntax error, unexpected T_STRING</code> while doing this.<br>
I am trying to read status.txt and if it has 1 it will redirect else it will say Status is unavailable.<br>
Any ideas?</p>
|
php
|
[2]
|
4,461,150 | 4,461,151 |
Not sure how to draw "poison dart"
|
<p>Sorry if the title is a little... vague. Anyway, I'm making a platformer using java and I've been trying to create a pressure plate triggered dispenser that shoots poisoned darts. The game is pretty much split up into a grid system, with each block being a spot on the grid. so far I've made it so that when the pressure plate is activated, it looks as if it's pressed down. I've also been able to draw it to the screen but it does not move or anything. This is the code I use to draw it to the screen:</p>
<pre><code>public void drawDart(Graphics g) {
if(Component.isPressed) {
for(int x = 0; x < block[0].length; x++) {
for (int y=0; y < block[0].length; y++) {
if(x == 91 && y == 35) {
block[x][y] = new Block(new Rectangle(x * Tile.tileSize, y * Tile.tileSize, Tile.tileSize, Tile.tileSize), Tile.poisonDart);
}
}
}
}
}
</code></pre>
<p>Unfortunately, with this code when I step on the pressure plate, the dart is drawn, but will not move. I've tried using x++ before but that doesn't move the dart at all.</p>
<p>Another problem is that I would like the dart to look like it's affected by gravity, which is hard to do when the game is split into a large grid system. Either way, what do you guys think?</p>
<p><em>Moderator edit (moved from OP comment):</em></p>
<pre><code>block[x][y] = new Block(new Rectangle(x * Tile.tileSize, y * Tile.tileSize,
Tile.tileSize, Tile.tileSize), Tile.poisonDart);
</code></pre>
|
java
|
[1]
|
3,922,456 | 3,922,457 |
how to disable browser refresh confirmation message [resend cancel] from javascript
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4327236/stop-browsers-asking-to-resend-form-data-on-refresh">Stop browsers asking to resend form data on refresh?</a> </p>
</blockquote>
<p>how to disable browser refresh confirmation message [resend cancel] from javascript .?</p>
|
javascript
|
[3]
|
530,388 | 530,389 |
what utilities can monitor media streaming from handset devices?
|
<p>Hi there I am looking for a utility that can monitor media streaming information while the media is being accessed via a handset device...does anyon</p>
|
android
|
[4]
|
4,431,751 | 4,431,752 |
programatically switching between jquery library and 3rd party library
|
<p>We are using a 3rd party java script library for functionalities like drag-drop, calender etc. Now are planning to move to jQuery for these controls & effects.</p>
<p>The 3rd party uses $(DOMElement) like jQuery to add the extension methods to the control(say converting a textbox to calender).
jQuery also uses the same syntax.</p>
<p>We are not completely replacing the 3rd party library with jQuery. So in some place $(element) should refer to the 3rd party library, while in some places in the same page, it should refer to jQuery. </p>
<p>Is there a way to programatically specify which which library the $(element) should refer.</p>
<p>Thanks in Advance..</p>
|
jquery
|
[5]
|
1,850,324 | 1,850,325 |
Python -- How do you view output that doesn't fit the screen?
|
<p>I should say I'm looking for a solution to the problem of <strong>viewing output that does not fit on your screen.</strong> For example, range(100) will show the last 30ish lines in your terminal of 30 height. </p>
<p>I am only looking to be nudged in the right direction and am curious how you guys have approached this problem. </p>
<p>What have you done when you run into a situation where you wish you could conveniently scroll through some large output? </p>
<h2>Best Answer</h2>
<p>Use the scrollback buffer on your terminal. </p>
<p>If you're using GNU Screen, it can be set with <code>defscrollback 1000</code> or any other number in <code>HOME/.screenrc</code>. </p>
<p>Use <code>Ctrl-a, [</code> to enter copy mode</p>
<pre><code>j - Move the cursor down by one line
k - Move the cursor up by one line
C-u - Scrolls a half page up.
C-b - Scrolls a full page up.
C-d - Scrolls a half page down.
C-f - Scrolls the full page down.
G - Moves to the specified line
</code></pre>
<p>The best part is <code>?</code> for reverse search, <code>/</code> for forward search while in copy mode. </p>
<p>Super convenient.</p>
<p>Thank you!</p>
<hr>
<h2>Original question:</h2>
<p>What is the python equivalent of the bash less command? </p>
<pre><code>LongString | less
</code></pre>
<p>Is there something like that for python? I find myself thinking I could use it fairly often but just move on and find some other solution. </p>
<p>By "long things" I mean anything that generates more output lines than my screen. 1000 print messages, a dictionary, a large string, range(1000), etc. </p>
<p>My googlefu has failed.</p>
|
python
|
[7]
|
3,507,961 | 3,507,962 |
Java HttpURLConnection
|
<p>What is the function or purpose of HttpURLConnection.setDoInput or HttpURLConnection.setDoOutput?</p>
|
java
|
[1]
|
5,367,956 | 5,367,957 |
UIViewController either leaks memory or crashes app if autoreleased
|
<p>I have this code in my app and it says memory leak at 'gvc'.</p>
<pre><code>GameViewController* gvc = [[GameViewController alloc] init];
[self.navigationController pushViewController:gvc animated:YES];
</code></pre>
<p>If i modify this code to autorelease view controller, it crashes my app after a while giving error 'Missed Method'</p>
<pre><code>GameViewController* gvc = [[[GameViewController alloc] init] autorelease];
[self.navigationController pushViewController:gvc animated:YES];
</code></pre>
<p>Is there something wrong with autorelease? How to resolve this memory leak?
Thanks in advance.</p>
|
iphone
|
[8]
|
1,805,713 | 1,805,714 |
iphone-uiview-background
|
<p>I am new to iPhone development. I have one XIB file, the login page (a form).</p>
<p>Now I want to set the <code>UIView</code> background image.</p>
<p>When I supply an image from Interface Builder then there is no effect, and when I set it from the code then also no effect.</p>
<pre><code>self.view.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:@"srk_ipad_Homepg.png"]];
</code></pre>
<p>I don't want to use a <code>UIImageView</code> because when I place an image, all my controls are hidden behind the <code>UIView</code>.</p>
|
iphone
|
[8]
|
2,057,688 | 2,057,689 |
parse name no spaces?
|
<p>When a user enters more than one space, my program doesn't properly print the user's name out. For example, if the user enters their first name followed by 2 spaces and then their last name, my program assumes those extra spaces are the middle name and prints the middle name as the spaces and the last name as the second string entered, even though only two strings were entered. How can I improve this issue so that the extra space a user may enter doesn't count as a middle or last name?</p>
<pre><code>public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Welcome to the name parser.\n");
System.out.print("Enter a name: ");
String name = sc.nextLine();
name = name.trim();
int startSpace = name.indexOf(" ");
int endSpace = name.indexOflast(" ");
String firstName = "";
String middleName = "";
String lastName = "";
if(startSpace >= 0)
{
firstName = name.substring(0, startSpace);
if(endSpace > startSpace)
{
middleName = name.substring(startSpace + 1, endSpace);
}
lastName = name.substring(endSpace + 1, name.length());
}
System.out.println("First Name: " + firstName);
System.out.println("Middle Name: " + middleName);
System.out.println("Last Name: " + lastName);
}
</code></pre>
<p>Output: joe mark</p>
<pre><code>First name: joe
Middle name: // This shouldn't print but because the user enter extra spaces after first name the spaces becomes the middle name.
Last name: mark
</code></pre>
|
java
|
[1]
|
2,492,547 | 2,492,548 |
pythonic way to map set of strings to integers
|
<p>Is there shorter way to do this?</p>
<pre><code>g_proptypes = {
'uint8' : 0
'sint8' : 1,
'uint16' : 2,
'sint16' : 3,
'uint32' : 4,
... # more strings
}
</code></pre>
<p>The dict is necessary as I'll have the string with me and need to find the corresponding integer. </p>
|
python
|
[7]
|
5,252,481 | 5,252,482 |
can i make fck editor dragable?
|
<p>i want make FCK editor drag able in my asp.net application.
drag FCK editor with mouse pointer movement.</p>
|
asp.net
|
[9]
|
4,891,621 | 4,891,622 |
Converting IF statements to simple statement - Which one is efficient?
|
<p>I hope everyone will enjoy reading this.</p>
<p>I have two IF statements below</p>
<pre><code>public int GetTax(Item item)
{
int tax=0;
if(item.Name.Equals("Book"))
{
tax = 10;
}
if(item.Imported)
{
tax += 5;
}
return tax;
}
</code></pre>
<p>I have converted above if condition to this.</p>
<pre><code>public int GetTax(Item item)
{
return 5 * ((int)item.Name.Equals("Book") * 2 + ((int)item.Imported));
}
</code></pre>
<p>Which one do you think efficient? and justify why?</p>
|
c#
|
[0]
|
5,070,691 | 5,070,692 |
Displaying same datagridview in different places (c#)?
|
<p>I'm working on a desktop application in C# (in Visual Studio 2010, framework 4.0). I have to display same (or slightly modified - without some columns) datagridview / table in different places. I'll get the data from querying different (local) files. I find it very consuming to make a new query for each table. Thus I thought about binding tables with query. But I don't know if it is the best way to do it. I don't know how "expensive" it is to bind data to gridview. Maybe it would be better to somehow show the same table, maybe put it in a panel an then display it properly (moving it to different positions/user controls according to the user's navigation).</p>
<p>These tables are not that big, but I'd need to display 4-5 of them in quite some locations and I don't want to waste memory with them because there are also some very large tables.</p>
<p>Any ideas?</p>
<p>Thank you for your time and answers.</p>
|
c#
|
[0]
|
3,283,315 | 3,283,316 |
Android - Load PDF / PDF Viewer
|
<p>I want to display pdf contents on webview. </p>
<p>Here is my code: </p>
<pre><code>WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("URL/Demo_PDF.pdf");
</code></pre>
<h2>Problem:</h2>
<p>When i am trying to run the application, at that time I am getting blank screen. </p>
<p>And also, if there is any PDF viewer then also suggest me !!</p>
<p>FYI, I have already set internet permission.</p>
|
android
|
[4]
|
3,377,909 | 3,377,910 |
PHP Get Current Filename After URL Rewrite
|
<p>I know <code>$_SERVER["REQUEST_URI"];</code> can be used to get the url of the current page, but this doesnt work if the URL is a htaccess URL rewrite.</p>
<p>How can I get the real (not rewritten) filename of the current php file?</p>
<p>For example I go to <a href="http://site.com/page/" rel="nofollow">http://site.com/page/</a> it rewrites and displays <a href="http://site.com/page.php" rel="nofollow">http://site.com/page.php</a> </p>
<p><code>$_SERVER["REQUEST_URI"];</code> will just give me the rewrite, I want the original.</p>
|
php
|
[2]
|
635,926 | 635,927 |
Understanding Cookies in PHP
|
<p>When the following code is run for the first time, it does not echo out the "var1" value but it does on browser refresh (f5), Why? As i understand when the browser sends the code to the server, setcookie() stores the cookie variable ("var1") to a client (browser) in a local file and puts the "var1" value available in global domain via $_COOKIE superglobal. </p>
<p>Since "var1" value is available immediately in $_COOKIE after the first server replies to browser's initial request, then why the "var1" is not echoed out. Is it that setcookie() stores "var1" value in client's browser on first request and only when the page is refreshed (2nd request) the browser sends back "var1" value to the server and then the server makes it available in the global domain via $_COOKIE function.</p>
<hr>
<h2> CODE</h2>
<pre><code><?php
setcookie("var1","5");
echo $_COOKIE['var1'];
?>
</code></pre>
<p>Kindly clear this for me. </p>
<p>Thanks
djain.</p>
|
php
|
[2]
|
5,439,032 | 5,439,033 |
Dynamic TableLayout with ID's?
|
<p>I have a working dynamic <code>TableLayout</code> that holds user data. Clicking an "Add Event" button brings up a <code>Dialog</code> that allows the user to enter data. When the <code>Dialog</code> is dismissed, the entered data appears as a new row in the table. </p>
<p>Now, however, I am having trouble allowing the user to EDIT a given row in the table. It seems I need dynamic ID's to give each <code>TableRow</code> in order to allow edits. Is this possible?</p>
|
android
|
[4]
|
286,329 | 286,330 |
Running default AVD for the lowest sdk
|
<p>My app's min sdk is 2.1 and max sdk - 4.1 , If i run it always starts the emulator for 4.0. Why doenst it run the emulator for the lowest sdk= 2.1 bcos if it works in 2.1 then works in all. How can I make it run the emulator for lowest/min sdk my app is set for.</p>
|
android
|
[4]
|
3,922,840 | 3,922,841 |
Huge data in C++ program during compile time
|
<p>I have around 30 XML files, which my C++ process (at run time) should parse and make some installation.</p>
<p>I felt, instead of using XML at runtime, why can't I write a script which will encode the XML files into my own structure and generate a C++ program which should be compiled and built?</p>
<p>What I mean is, my script should populate the encoded structure as a variable assignment in C++ program.</p>
<p>Something like</p>
<pre><code>class generatedCode
{
private:
unsigned char = ox11, ox22....
};
</code></pre>
<p>Then my C++ process will decode this and do installation instead of XML parsing.</p>
<p>My whole intention is the bring all the XML info by some means into C++ process memory.</p>
<p>Can someone please suggest, is this a good way? Do suggest any other ways of doing it?</p>
|
c++
|
[6]
|
611,159 | 611,160 |
is there a function to count multiple occurrences of different values in an array?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1317612/count-number-of-values-in-array-with-a-given-value">Count number of values in array with a given value</a> </p>
</blockquote>
<p>Let's say I've an array fruits:</p>
<pre><code>$fruits = array("apple", "apple", "apple", "banana", "banana", "strawberry");
</code></pre>
<p>I want to transform this array into an array count:</p>
<pre><code>$count = array("apple" => 3, "banana" => 2, "strawberry" => 1);
</code></pre>
<p>What would be the easiest way possible to archieve this?</p>
|
php
|
[2]
|
1,008,597 | 1,008,598 |
Capture one line of Serial Data from SerialPort Class
|
<p>I have a serial connection that gives me multiple lines of text continuously. I just want to capture one of those lines using the SerialPort method in C#. How would I go about capturing just one line of the output from the Serial Port? I know all of the COM port/baud rate/bit rate/parity settings.</p>
|
c#
|
[0]
|
4,794,840 | 4,794,841 |
How to check for " " using explode
|
<p>How do use explode to check for " ".</p>
<p>Thanks
Jean</p>
|
php
|
[2]
|
5,625,082 | 5,625,083 |
How to convert String Array to Double Array in one line
|
<p>I have a string array as:</p>
<pre><code>String[] guaranteedOutput = Arrays.copyOf(values, values.length,
String[].class);
</code></pre>
<p>All the String values are numbers. The data should be converted to a <code>Double[]</code>.</p>
<p><strong>Question</strong><br>
Is there a one line solution in Java to achieve this or we need to loop and convert each value to a Double? </p>
|
java
|
[1]
|
3,623,215 | 3,623,216 |
how the system apps are loading on booting process in android?
|
<p>My doubt is whether Zygote process will loads the system apps after booting process or System Server. What are things involved in loading system apps and market apps after booting.</p>
|
android
|
[4]
|
1,085,737 | 1,085,738 |
How to start a Service even if we force the application in Android.?
|
<p>I created an Activity and started a service in that activity.The service should run in the background even if we make the application to force close.Please help me to solve this problem.</p>
|
android
|
[4]
|
1,814,127 | 1,814,128 |
prints line number in both txtfile and list?
|
<p>i have this code which prints the line number in infile but also the linenumber in words what do i do to only print the line number of the txt file next to the words???</p>
<pre><code>d = {}
counter = 0
wrongwords = []
for line in infile:
infile = line.split()
wrongwords.extend(infile)
counter += 1
for word in infile:
if word not in d:
d[word] = [counter]
if word in d:
d[word].append(counter)
</code></pre>
<p>for stuff in wrongwords:
print(stuff, d[stuff])</p>
<p>the output is :</p>
<pre><code>hello [1, 2, 7, 9] # this is printing the linenumber of the txt file
hello [1] # this is printing the linenumber of the list words
hello [1]
what i want is:
hello [1, 2, 7, 9]
</code></pre>
|
python
|
[7]
|
1,504,127 | 1,504,128 |
How to show tabs At Bottom rather then at top?
|
<p>I m having following screen,
<img src="http://i.stack.imgur.com/vws10.png" alt="enter image description here"></p>
<p>I am using Following code to make Layout to show tabhost and tab widget</p>
<p><img src="http://i.stack.imgur.com/N57Lr.png" alt="enter image description here"></p>
<p>I want to place the tabs at bottom .
Please tell how to do this.</p>
|
android
|
[4]
|
2,809,058 | 2,809,059 |
Anyone tried to bulk upload device UDIDs to the iPhone dev portal?
|
<p>I'm trying to add 50 beta testers to my app through ad hoc. In the portal, it gives you an option to upload a file for UDIDS. What format should it be? Also, it mentioned that you are only limited to 100 devices per year and they cannot be changed. Does this mean once I added my beta testers, they cannot be changed forever, even for other apps?</p>
|
iphone
|
[8]
|
4,648,297 | 4,648,298 |
Reload div using jquery
|
<p>I have a problem: In my PHP page inside div there is a list of partner details are listed and when i add another partner through jquery i need to show that partner also into the above list ,if the addition is success we need to reload..</p>
<pre><code><?php for($i=0;$i<$partnerCount;$i++){ ?>
<tr>
<td><input type='checkbox' id='<?php echo $partnerData[$i]['PARTY_RELATIONSHIP_ID'];?>' name='party_relation[]'></td>
<td><?php echo $partnerData[$i]['partnerCode'];?></td>
<td><?php echo $partnerData[$i]['partnerName'];?></td>
<td><?php echo $partnerData[$i]['PARTY_ROLE_NAME'];?></td>
<td><?php echo $partnerData[$i]['phone'];?></td>
<td><?php echo $partnerData[$i]['address1'];?></td>
<td><?php echo $partnerData[$i]['address2'];?></td>
<td><?php echo $partnerData[$i]['city'];?></td>
<td><?php echo $partnerData[$i]['state'];?></td>
<td><?php echo $partnerData[$i]['zip'];?></td>
</tr>
<?php } ?>
</code></pre>
|
jquery
|
[5]
|
4,050,713 | 4,050,714 |
Do the class specific new delete operators have to be declared static
|
<p>Is it required in standard for class specific new, new[], delete, and delete[] to be static.
Can i make them non-static member operators. And why is it required for them to be static </p>
|
c++
|
[6]
|
2,526,525 | 2,526,526 |
what is the difference between os.open and os.fdopen in python
|
<p>I am really confused when to use <code>os.open</code> and when to use <code>os.fdopen</code></p>
<p>I was doing all my work with <code>os.open</code> and it worked without any problem but I am not able to understand under what conditions we need <code>file descriptors</code> and all other functions like <code>dup</code> and <code>fsync</code></p>
<p>Is the <code>file object</code> different from <code>file descriptor</code></p>
<p>i mean <code>f = os.open("file.txt",w)</code></p>
<p>Now is f the fileobject or its the filedescriptor?</p>
|
python
|
[7]
|
2,635,307 | 2,635,308 |
Java Port scanner
|
<pre><code>import java.net.Socket;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
String remote = "69.163.44.171";
int i = 0;
do {
try {
Socket s = new Socket(remote,i);
System.out.println("Server is listening on port " + i+ " of " + remote);
s.close();
} catch (IOException ex) {
System.out.println("Server is not listening on port " + i+ " of " + remote);
}
i++;
} while(i == 55000)
}
</code></pre>
<p>Output:</p>
<pre><code>Server is not listening on port 0 of 69.163.44.171
BUILD SUCCESSFUL (total time: 0 seconds)
</code></pre>
<p>i use while loop cause it is faster, now to the question why does it only scan one port? </p>
|
java
|
[1]
|
5,997,478 | 5,997,479 |
How to convert PictureDrawable into ScaleDrawble?
|
<p>I am trying to scale a picture drwable which I get from <a href="http://code.google.com/p/svg-android/" rel="nofollow">svg-android-library</a>. I can create the drawable but do not get how to scale it.</p>
<p>Here is the code I tried:</p>
<pre><code>Drawable drawable = svg.createPictureDrawable();
int size = 108;
Bitmap img = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(img);
//resize drawable here according to screen width
drawable = new ScaleDrawable(drawable, 0, size*2, size*2).getDrawable();
drawable.setBounds(0, 0, size*2, size*2);
drawable.draw(canvas);
</code></pre>
<p>Any suggestions?</p>
|
android
|
[4]
|
4,869,100 | 4,869,101 |
how to get the users id's on after select checkbox from fieldset using jquery
|
<p>I am using this code to select the checbox from fieldset:</p>
<pre><code>$("fieldset:has(input[type='checkbox'])")
</code></pre>
<p>its working fine on the fieldset I have studentid's I need to get the student id's which ever textbox is selected on the fieldset?</p>
<p>Can anybody help me out?</p>
<p>thanks</p>
|
jquery
|
[5]
|
5,145,897 | 5,145,898 |
How can I store values in a variable permanently even after restarting machine?
|
<p>I want to store values permanently in a variable. The same variable should be able to be edited and saved by user, and whatever it is I need the value of the variable from the last time I modified it, like a database. Please explain me with some examples! </p>
|
c#
|
[0]
|
5,538,844 | 5,538,845 |
Save dynamic div into SESSION
|
<p>Hello guys i have the following PHP script:</p>
<pre><code>if(isset($_POST['add_slider']))
{
echo '<div class="sliderz">';
$images = mysql_query("SELECT * FROM store");
while($row = mysql_fetch_assoc($images))
{
echo '<ul class="connectedSortable">';
echo '<li>';
echo "<img class='ui-state-default' src=".$row['image'].">";
echo '</li>';
echo '</ul>';
}
echo '</div>';
}
</code></pre>
<p>and the html looks like this:</p>
<pre><code><form action="admin.php" method="POST">
<input type="submit" value="Add new slider!" name='add_slider'>
</form>
</code></pre>
<p>How can i acciev the same thing but save it into $_SESSION :-?</p>
|
php
|
[2]
|
623,091 | 623,092 |
android how to find gesture overlay is fully filled
|
<p>I am learning android gesture overlay and I was struggled in implementing some logic. The logic I want to implement is,
I will show a gesture overlay like a square, The user started painting the gesture overlay with some color, I need to find if the overlay is <strong>fully 100% painted</strong>. If it was fully painted then i need to go for some other flow.Anybody please help how can we implement that logic... Many more thanks in advance.</p>
|
android
|
[4]
|
2,994,506 | 2,994,507 |
C# application not running on different machines
|
<p>I have a C# application that loads fine on my development machine but fails to even start on Win2008 machine.</p>
<p>Checked Frameworks and they match up, Net 4.0</p>
<p>I immediately suspected the problem was arising from references to specific files that I was reading from and sure enough, using some test code I narrowed it down to a single line.</p>
<pre><code>public static string[] salesArray = (File.ReadAllLines("sales.txt").ToArray());
</code></pre>
<p>If I comment out the above line, the test app starts, if I leave it in, it fails. Any ideas?</p>
<p>I am copying the Debug directory to the second machine (sales.txt) within it.</p>
<p>This is the entire code. The app does nothing but open a blank window.</p>
<pre><code>namespace testServer
{
public partial class Form1 : Form
{
public static string[] salesArray = (File.ReadAllLines("sales.txt").ToArray());
public Form1()
{
InitializeComponent();
}
}
}
</code></pre>
|
c#
|
[0]
|
5,229,780 | 5,229,781 |
Delete /data/data folder
|
<p>My application is a system application. What I need is to perform clean data for all other applications. As far as I know, data for all application store in /data/data. Is there any way to remove all folders/files in /data/data programatically?</p>
<p>I know how to do that from adb:</p>
<pre><code>adb shell
# rm -r /data/data
</code></pre>
<p>And this is how I'm trying to do it in the code:</p>
<pre><code>Process process;
try {
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("mount -o remount,rw -t rfs /dev/stl5 /data; \n");
os.writeBytes("rm -r /data/data; \n");
os.writeBytes("mount -o remount,ro -t rfs /dev/stl5 /data; \n");
return;
} catch (IOException e) {
e.printStackTrace();
}
</code></pre>
|
android
|
[4]
|
4,583,659 | 4,583,660 |
"Invalid argument supplied for foreach()" - What happens next?
|
<p>If "Invalid argument supplied for foreach()" is a "warning" in PHP and doesn't halt execution, where does the script execution continue from? After the foreach block? After the function? What happens next?</p>
|
php
|
[2]
|
5,565,261 | 5,565,262 |
How to pick file from /data/data/ path from a device
|
<p>I have created a file in the below path using my applcation.</p>
<p>/data/data/VisionEPODErrorLog/ErrorLog.txt</p>
<p>I am able to see the file using Eclipse DDMS->File Explore ->Data</p>
<p>But when I installed my applcation in the mob device I am not getting that path in the device.</p>
<p>I need to see the exact file in the device </p>
<p>Is there any third party applcation needed to access the path.If so whats that or is there any way else to get that file from the device.if anyone konws please let me konw </p>
|
android
|
[4]
|
336,413 | 336,414 |
Check an array have string?
|
<pre><code>setTimeout(function() {
abc[index].Factoid
}, 2000);
</code></pre>
<p>I set some string in this array.</p>
<p>How to check this array has string or has no string?</p>
|
javascript
|
[3]
|
1,994,696 | 1,994,697 |
How to add additional JavaScript code
|
<p>I'm developing a mobile site and the template I'm using is based off of Jquery Mobile.</p>
<p>In the header.php file, the template I am using is making calls to CDN javascript files:</p>
<pre><code><link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-
1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</code></pre>
<p>Since I'm basically pulling in the JavaScript from those URLS and it's not actually some .js file in a folder on my web server - how would I go about adding additional javascript code? Do I add it to my header.php? Get a special plugin that'll allow me to add additional javascript? The template doesn't give my any option to add additional code. So, not sure where the code would actually go...</p>
<p>Thanks in advance</p>
|
javascript
|
[3]
|
2,291,619 | 2,291,620 |
Custom content scroll box's scroll bar jumps on drag
|
<p>I created a custom content scroll box using HTML, CSS and JavaScript. When you try to drag the scrollbar it jumps to the left edge of the scrollbar. Any idea why am I missing something?</p>
<pre><code>var scrollbar = document.getElementById("scrollbar");
var barWidth = 300;
var scrollbarWidth = 40;
scrollbar.addEventListener("mousedown", function(e) {
window.addEventListener("mousemove", hScroll, null);
}, null)
window.addEventListener("mouseup", function(e) {
window.removeEventListener("mousemove", hScroll, null);
}, null);
function hScroll(e) {
var scroller_pos = e.clientX - offset;
if (scroller_pos <= 0) scroller_pos = 0;
else if (scroller_pos >= barWidth-scrollbarWidth) scroller_pos = barWidth-scrollbarWidth;
scrollbar.style.marginLeft = scroller_pos + "px";
}
</code></pre>
|
javascript
|
[3]
|
3,192,886 | 3,192,887 |
CSS doesn't affect new items on asp.net web form
|
<p>I have a web form with a CSS, I'm working on it with visual studio.</p>
<p>Yesterday I edited the CSS and it worked just fine, new fonts, positions, labels, everything works.</p>
<p>Today I decided to add a new label and dropdown box to my web form, and I did some styling for them in the same CSS. In the visual studio preview the CSS for the new items takes effect, but when I run the debug the new items are not affected by the CSS, but the old items are still working fine.</p>
|
asp.net
|
[9]
|
4,125,924 | 4,125,925 |
Change PHP GET with link?
|
<p>I'd like to create a link that changes a PHP <code>$_GET</code> variable. For example:</p>
<pre><code>URL: http://site.com/index&variable=hello&anothervariable=dontchangeme
<a href="variable=world">Click me</a>
(after click)
URL: http://site.com/index&variable=world&anothervariable=dontchangeme
</code></pre>
<p>I know you can do this to just change the page (<code>href="1.html"</code>), but I'd like to do the same thing while maintaining the GET variables that were already there.</p>
|
php
|
[2]
|
604,692 | 604,693 |
Multi-threading strategies? (Modifying a scene in a multi-threaded engine through an Editor)
|
<p>I'm trying to write an editor overtop a multi-threaded game engine. In theory, through the editor, the contents of the scene can be totally changed but I haven't been able to come up with a good way for the engine to cope with the changes. (ie delete an entity while the renderer was drawing it). Additionally, I'm hesitant to write code to manage locks at every instance I use an entity or resource that can be potentially deleted. I imagine there has to be a relatively more elegant solution.</p>
<p>Does anyone have any ideas or strategies I can start looking at?</p>
<p>Thanks!</p>
|
c++
|
[6]
|
5,731,781 | 5,731,782 |
Iterate Through Dynamic tags and populate using jquery
|
<p>I have this so far...</p>
<pre><code><script type="text/javascript">
$(document).ready(function () {
$('ul').addClass('navMenu');
$('li').addClass('todo').html("<span class='navItemHead'></span>");
$('span.navItemHead').wrap("<a href='/My/Website'></a>");
});
</script>
</code></pre>
<p>I have four names I want to put into the name tag Mary,Nick,Matt,Meg and 1,2,3,4 in the span tag, so the final html should read.....</p>
<pre><code> <li class="todo ">
<a href="/Register/Website"><span class="navItemHead">1</span>Mary</a>
</li>
<li class="todo ">
<a href="/Register/Website"><span class="navItemHead">2</span>Nick</a>
</li> ....etc
</code></pre>
|
jquery
|
[5]
|
5,421,043 | 5,421,044 |
Grid View checkbox view state
|
<p>iam using grid view in that 1st col is checboxes.and i want to maintain state..so iam using 2 functions </p>
<pre><code>private void RememberOldGridValues()
{
ArrayList oUserCheckedList = new ArrayList();
int index = -1;
foreach (GridViewRow row in gridViewResults.Rows)
{
if (((CheckBox)row.FindControl("chkSelect")).Checked)
{
index = row.RowIndex;
if (Session["CHECKED_ITEMS"] != null)
oUserCheckedList = (ArrayList)Session["CHECKED_ITEMS"];
if (oUserCheckedList.Count == 1)
{
oUserCheckedList.RemoveAt(0);
}
if (!oUserCheckedList.Contains(index))
oUserCheckedList.Add(index);
}
if (index >= 0)
break;
}
if (oUserCheckedList != null && oUserCheckedList.Count > 0)
Session["CHECKED_ITEMS"] = oUserCheckedList;
}
</code></pre>
<p>this is to rememeber checked values and other is repopulate vales which gets repopulated once u come back from other pages .. in this my adding index is 3 but when i retrive on main page coming form other pages to my suprise arraylist has count 1 but always point to 0 inderx so instaed my 5row.index it is shwoing me 0 row.index and be default selecte first checkbox.
this is code to repopulate values </p>
<pre><code>//to Repopulate Grid view Checkboxes
private void RePopulateGridValues()
{
ArrayList oUserCheckedList = (ArrayList)Session["CHECKED_ITEMS"];
if (oUserCheckedList != null && oUserCheckedList.Count > 0)
{
foreach (GridViewRow row in gridViewResults.Rows)
{
string str = oUserCheckedList[0].ToString();
int i = Convert.ToInt32(str);
if (row.RowIndex == i)
{
CheckBox myCheckBox = (CheckBox)row.FindControl("chkSelect");
myCheckBox.Checked = true;
}
}
}
</code></pre>
<p>any help will be appreciated.</p>
|
asp.net
|
[9]
|
3,890,506 | 3,890,507 |
replace space with dash javascript
|
<pre><code>var html = "<div>"+title+"<br/>";
document.write(title.replace(/ /g,"-"));
html+= '<p><a href="go.aspx?title=' + title + '">Details<\/a></p></div>';
</code></pre>
<p>hi all,i want to replace <strong>title</strong> space with dash</p>
|
javascript
|
[3]
|
5,336,857 | 5,336,858 |
How To add TextBoxes Data in asp.net using Onblur event
|
<p>I am creating a ASP.net web application where i need to add different text boxes data and save it in another text box .But using java Script and onblur event. How can we do please say in clear and understanding way because am new to It.
Thanks </p>
|
asp.net
|
[9]
|
5,241,650 | 5,241,651 |
create listview programmatically with no xml layout
|
<p>I found this example to create a custom listview:</p>
<pre><code>public class UsersListActivity extends ListActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] statesList = {"listItem 1", "listItem 2", "listItem 3"};
setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item,
statesList));
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(getApplicationContext(),
"You selected : "+((TextView) view).getText(), Toast.LENGTH_SHORT).show();
}
});
}
}
</code></pre>
<p>However, they are using a xml layout for each row. Is this good practice? What if I wanted to create my own layout programmatically and utilize it in the adapter? </p>
<p>I guess it would be easier just to use the xml layout, but it would be nice to know</p>
|
android
|
[4]
|
2,456,571 | 2,456,572 |
Odd HTML validation error
|
<p>I'm getting an odd HTML validation error from this piece of JavaScript any help appreciated, I think it may be causing a bug in the slider function that I'm working with...</p>
<pre><code><script type="text/javascript" charset="utf-8">
sfHover = function() {
var sfEls = document.getElementById("nav2").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
</script>
</code></pre>
<p>The errors are</p>
<blockquote>
<p>Error: character ";" not allowed in
attribute specification list</p>
</blockquote>
<p>and</p>
<blockquote>
<p>Error: element "sfEls.length"
undefined</p>
</blockquote>
<p>from the line</p>
<blockquote>
<p>for (var i=0; i
</blockquote>
<p>and </p>
<blockquote>
<p>Error: end tag for "sfEls.length"
omitted, but OMITTAG NO was specified</p>
</blockquote>
<p>from the closing script tag</p>
|
javascript
|
[3]
|
420,089 | 420,090 |
JavaScript String concatenation bug on Firefox 3.6
|
<p>This is my simple script: </p>
<pre><code><script>
$("#adv").ready(function(){
var x = 0;
setInterval(function(){
$("#adv").html('');
x++;
$('<img src="http://url/adv'+x+'.png?u=1&s=1&a='+x+'" />').appendTo('#adv');
if(x == 2) {
x = 0;
}
}, 20000);
});
</script>
</code></pre>
<p>Rotate image file every 20 seconds. Works perfectly but sometimes in server logs is see: </p>
<pre><code>GET /adv%2527+x+%2527.png 403 Mozilla/5.0%20(Macintosh;%20U;%20PPC%20Mac%20OS%20X%2010.4;%20en-US;%20rv:1.9.2.4)%20Gecko/20100611%20 *Firefox/3.6.4*
GET /adv%2527+x+%2527.png 403 Mozilla/5.0%20(Windows;%20U;%20Windows%20NT%206.1;%20pl;%20rv:1.9.2.23)%20Gecko/20110920%20Firefox/3.6.23
</code></pre>
<p>So script concatenate script with quotas: <strong>/adv%2527+x+%2527.png</strong>
And this is only for Firefox 3.6.x</p>
<p>I also tested this on my Firefox 3.6 latest version, but this never happend for me.</p>
<p>anyone has idea how i should concatenate string to avoid this problem ? </p>
|
javascript
|
[3]
|
5,455,868 | 5,455,869 |
run from a separate class
|
<p>So i need to run this class from a second class. How do I do that? Here's the code I want to run from a separate class: </p>
<pre><code>import java.util.*;
public class Numbers {
int min(int a, int b, int c, int d, int e) {
int min1 = Math.min(a, b);
int min2 = Math.min(c, d);
int min3 = Math.min(min1, min2);
int min4 = Math.min(min3, e);
return min4;
}
int max(int a, int b, int c, int d, int e) {
int max1 = Math.max(a, b);
int max2 = Math.max(c, d);
int max3 = Math.max(max1, max2);
int max4 = Math.max(max3, e);
return max4;
}
double avg(int a, int b, int c, int d, int e) {
double average = (a+b+c+d+e)/5;
return average;
}
double stddev(int a, int b, int c, int d, int e) {
double average = (a+b+c+d+e)/5;
double a1 = Math.pow((a-average),2);
double b1 = Math.pow((b-average),2);
double c1 = Math.pow((c-average),2);
double d1 = Math.pow((d-average),2);
double e1 = Math.pow((e-average),2);
double average2 = (a1+b1+c1+d1+e1)/5;
double x;
x = Math.sqrt(average2);
return x;
}
}
</code></pre>
|
java
|
[1]
|
22,659 | 22,660 |
JavaScript: unexpected token error
|
<p>I'm working on a codecademy.com lesson where I'm supposed to check if a number is a multiple of 3 or 5 (but not a multiple of 3 and 5), returning true or false depending on result of the test. The method should also return false if doesn't satisfy either of the conditions.</p>
<p>When I run the code it's telling me there's a syntax error: unexpected token. Can anyone see what I'm doing wrong? </p>
<pre><code>var FizzBuzzPlus = {
this.isFizzBuzzie = function(number){
if (number % 3 === 0 && number % 5 === 0){
return false;
}else if (number % 3 === 0 || number % 5 ===0){
return true;
}else{
return false;
}
};
};
</code></pre>
|
javascript
|
[3]
|
3,456,635 | 3,456,636 |
What is the contents of the Request[] collection
|
<p>When I access the Request object as a collection, where does it get it's data from?</p>
<p>For example I know</p>
<pre><code>Request["someKey"]
</code></pre>
<p>will return the value of either </p>
<pre><code>Request.QueryString["someKey"]
</code></pre>
<p>or</p>
<pre><code>Request.Form["someKey"]
</code></pre>
<p>depending on which is set. </p>
<p>Are any other collections searched (cookies, session)? </p>
<p>What happens is the key value pair exists in several of the collections?</p>
<p>I took a look in MSDN, but couldn't find much info.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/system.web.httpcontext.request" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.web.httpcontext.request</a></p>
<p>Thanks for the help!</p>
|
asp.net
|
[9]
|
922,858 | 922,859 |
put one image on the other one
|
<blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/1405871/php-how-to-draw-an-image-over-another-image">PHP: How to draw an image over another image?</a><br>
<a href="http://stackoverflow.com/questions/3003702/how-to-include-an-image-inside-another-image-in-php">How to include an image inside another image in PHP?</a> </p>
</blockquote>
<p>Hello<br>
How can I put one image on the other one with php?<br>
Thank`s for help</p>
|
php
|
[2]
|
5,947,066 | 5,947,067 |
unable to install Google Play License Library" and "Google Play Downloader Library"
|
<p>I have to install Google Play License Library" and "Google Play Downloader Library" packages i am following steps given at <a href="http://developer.android.com/guide/market/expansion-files.html#Preparing" rel="nofollow">Developer Guide</a>
but i am not able to find above packages in sdk-manager.</p>
<p>screen-shot is available <a href="http://www.dropbox.com/gallery/69822895/1/issues?h=284395" rel="nofollow">here</a> </p>
<p>i have tried the suggestions given in <a href="http://stackoverflow.com/questions/8294061/unable-to-install-google-api-in-android">this question</a>.
advice me what to do?</p>
|
android
|
[4]
|
5,619,589 | 5,619,590 |
getAncestorOfClass like method on Android for views
|
<p>Is there on Android a method like getAncestorOfClass of SwingUtilities to use on Views?</p>
<p>Something like:</p>
<pre><code>View parent = AndroidUtilities.getParentOfClass(childView, DesiredClass.class);
</code></pre>
|
android
|
[4]
|
856,006 | 856,007 |
Getting Email referrer address
|
<p>I have a requirement to know the referrer URL and i am using <code>$_SERVER['HTTP_REFERER']</code> it works fine for the websites which is referring to my site but it is not showing any url when the link has been clicked from any email inbox. </p>
|
php
|
[2]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.