Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
5,686,817 | 5,686,818 | what is PATH in $_SERVER? | <p>What is PATH defined in $_SERVER?</p>
<p>I didn't see PATH defined in PHP.net manual. It says PATH_TRANSLATED and PATH_INFO only.</p>
<p>I got following detail in print_r($_SERVER).</p>
<pre><code>[PATH] => /sbin:/usr/sbin:/bin:/usr/bin
</code></pre>
| php | [2] |
2,708,351 | 2,708,352 | How do I write a response to a readline I've written | <p>I need to write a readline, which is "Hello Dad, are you alive today?." Then he wants to be able to write "yes" or "no" and get a log entry that says "Dad:yes:8/1/2012" when he types "yes." </p>
<p>So far I have the Readline set up, but I don't know what the name of the next thing I have to do is. Now, I don't need the answer but I'm a little lost with all of the terms and things. If you get what I'm trying to say and you want to help please let me what the name of the next thing I have to do.</p>
| c# | [0] |
4,641,255 | 4,641,256 | One liner to check if element is in the list | <p>I have been working on and off with Java/Python. Now in this situation I want to check if the element is in the list and do stuff...</p>
<p>Python says:</p>
<pre><code>if "a" in ["a", "b", "c"]:
print "It's there!"
</code></pre>
<p>Does java provide any one liner for this rather than creating ArrayList / Set or similar data structure in steps and adding elements to it?</p>
<p>Thanks </p>
| java | [1] |
3,689,660 | 3,689,661 | Array mapping in php | <p>I having two arrays say,</p>
<pre><code>$array1 = array("code" => "E0089",
"desc" => "some description");
$array2 = array("code" => "Code",
"desc" => "Description");
</code></pre>
<p>resultant array should be,</p>
<pre><code>$result = array("Code" => "E0089",
"Description" => "some description");
</code></pre>
<p>In short, I want to map two arrays and create third array.</p>
| php | [2] |
4,221,957 | 4,221,958 | What does this C# syntax mean? | <p>I'm looking at the source code for the MvcContrib Grid and see the class declared as:</p>
<pre><code>public class Grid<T> : IGrid<T> where T : class
</code></pre>
<p>What does the <code>where T : class</code> bit do?</p>
| c# | [0] |
2,568,552 | 2,568,553 | How can I make span’s text into hyperlink and it should execute a function | <p>I have a span (id=”OverdueReportsCount”). How can I make span’s text into hyperlink and it should execute a function (CountReports)?
Thanks</p>
| jquery | [5] |
347,959 | 347,960 | Will Dictionary<TKey, TValue> use TKey.Equals and TKey.GetHashCode? | <p>I have implemented a Dictionary as follows:</p>
<pre><code>Dictionary<ErrorHashKey, ErrorRow> dictionary;
</code></pre>
<p>I have defined <code>Equals()</code> and <code>GetHashCode()</code> in the <code>ErrorHashKey</code> class. I am currently writing up some documentation for the project, and came accross this from the <a href="http://msdn.microsoft.com/en-us/library/ms132151%28v=vs.90%29.aspx" rel="nofollow">IEqualityComparer Interface doc</a>:</p>
<blockquote>
<p>Dictionary requires an equality implementation to
determine whether keys are equal. You can specify an implementation of
the IEqualityComparer generic interface by using a constructor that
accepts a comparer parameter; if you do not specify an implementation,
the default generic equality comparer EqualityComparer.Default is
used. If type TKey implements the System.IEquatable generic
interface, the default equality comparer uses that implementation.</p>
</blockquote>
<p>I am not doing anything that the documentation specifies (or at least I don't think I am). I do not pass a comparer in the constructor parameter nor do I create an <code>EqualityComparer.Default</code> comparer.</p>
<p>Is the <code>System.IEquatable<T> generic interface</code> automatically implemented in every class created? Should I be defining an implementation of <code>IEqualityComparer<T></code>?</p>
| c# | [0] |
2,507,348 | 2,507,349 | NullPointerException for DataOutputStream | <p>I am getting a NullPointerException for DataOutputStream. What could be the causes for this?</p>
| java | [1] |
3,682,905 | 3,682,906 | iPhone Screen Orientation Support | <p>We have an app where ipad supports all the orientation and iphone views are set for portrait where few views in iphone do support landscape. Iam not sure this acceptable with Apple rejection criteria</p>
<p>Please guide me.</p>
| iphone | [8] |
1,015,200 | 1,015,201 | Is it possible to have a member pointer to an array in a struct? | <p>Is it possible to have a member pointer to an array in a struct? I would like to do something like below:</p>
<pre><code>struct A
{
int array[10];
int sizeOfArray;
};
template<int size>
class B
{
public:
B(int (A::*arrayLocation)[size],
int A::*arraySize):
memberArray(arrayLocation),
memberArraySize(arraySize))
{
}
void setValue(A* pobj1)
{
for(int i = 0; i < pobj1->*memberArraySize; i++)
{
(pobj1->*memberArray)[i] = 1;
}
}
private:
int (A::*memberArray)[size];
int A::*arraySize;
};
int main()
{
A obj2;
B<10> obj1(&A::array, &A::sizeOfArray);
obj1.setValue(&obj2);
}
</code></pre>
| c++ | [6] |
2,231,611 | 2,231,612 | Under what circumstances might not be viewstate persisted? | <p>I have a page and a user control inside it. </p>
<p>I assign a value to viewstate in the control and do </p>
<pre><code>Server.Transfer(Request.Url.AbsolutePath);
</code></pre>
<p>but when I check the value on control's Page_Load() event the assigned value doesn't exists (viewstate is empty, has not keys).</p>
<p>Why might this happened?</p>
| asp.net | [9] |
4,738,190 | 4,738,191 | Not Able to set title and Navigate to the next view by clicking on corresponding row in uitableview | <p>i tried to understand the uitable view and implemented it and able to populate data into row from a nsArray.I have make a NextViewController consisting of a dynamic lable which will receive inpur/text from the SimpleTable class.For ex,
in simple table view class i have rows with content as(see code please):</p>
<pre><code>**My SimpleViewController.m**
#import "SimpleTableViewController.h"
#import "NextViewController.h"
@implementation SimpleTableViewController
- (void)viewDidLoad {
arryData = [[NSArray alloc] initWithObjects:@"iPhone",@"iPod",@"MacBook",@"MacBook Pro",nil];
self.title = @"Simple Table Exmaple";/**/NOT ABLE TO SET TITLE.WHY?????Please guide how to use NSlog here**
[super viewDidLoad];
}
***//And on selection of any row i want to navigate to next view controller class***
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NextViewController *nextController = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil];
[self.navigationController pushViewController:nextController animated:YES];
[nextController changeProductText:[arryData objectAtIndex:indexPath.row]];
}
@end
**My NextViewController.h**
@interface NextViewController : UIViewController {
IBOutlet UILabel *lblProductTxt;
}
- (IBAction) changeProductText:(NSString *)str;
@end
**my NextViewController.m**
//posted only important part of code where i feel may be an issue
- (IBAction) changeProductText:(NSString *)str{
lblProductTxt.text = str;
} @end
</code></pre>
<p>I have check IB properly and the connections are proper.Please help me.Not getting where i am wrong?</p>
| iphone | [8] |
3,566,236 | 3,566,237 | When debugging why does visual studio say median is an unassigned variable? -Answered | <p>So, I am trying to make a console program that analyzes data(well kind of). The problem is when I go to print the median it tells me it is unassigned(well the debugger says this actually). What did I do wrong?
using System;</p>
<pre><code>using System;
class midpointFormula
{
static void Main()
{
double min, max, range, median, quartile1, quartile3, internalQuartileRange, IQR15;
int dataPoints, dataPoints1, count, count1;
double[] dataSet;
bool isEven;
count = 0;
Console.WriteLine("This program allows you to find several diffrent values from the data");
Console.Write("Please enter the amount of data points you would like to use: ");
dataPoints = int.Parse(Console.ReadLine());
dataPoints1 = dataPoints - 1;
dataSet = new double[dataPoints];
#region Enter Data
while (count < dataPoints)
{
count1 = count + 1;
Console.Write("Please enter the {0} datapoint: ", count1);
dataSet[count] = double.Parse(Console.ReadLine());
++count;
}
#endregion
min = dataSet[0];
max = dataSet[dataSet.Length - 1];
range = max - min;
#region Even Check
if (dataPoints % 2 == 0)
{
isEven = true;
}
else
{
isEven = false;
}
#endregion
if (isEven == true)
{
int medianPoint;
medianPoint = (dataPoints / 2) - 1;
median = dataSet[medianPoint];
}
else
#region Output
Console.WriteLine("Minimum is : {0}", min);
Console.WriteLine("Maximum is : {0}", max);
Console.WriteLine("Range is : {0}", range);
Console.WriteLine("Median is : {0}", median);
#endregion
Console.ReadKey();
}
</code></pre>
<p>}</p>
<p>Note: Yes, I know if there is an uneven amount of datapoints it will not calculate the data points, I am still working on that.</p>
| c# | [0] |
3,765,462 | 3,765,463 | How can I get all of icons in APK | <p>We can use PackageManager to load the icon of applications, and show them in Home activity.
If the apk had more than one icons,in different res folder. They are always in
drawable-ldpi,
drawable-hdpi,
drawable-mdpi, or any else...
They may be not the same.
How can I get them all</p>
| android | [4] |
4,548,539 | 4,548,540 | ASP.NET resolve symbol dataset in App_Code folder | <p>I have a project where some datasets with table adapters are stored in the App_Code folder in VS 2010. I am unable to get access to the table adapters from code behind. I tried following <a href="http://weblogs.asp.net/scottgu/archive/2006/01/15/435498.aspx" rel="nofollow">this</a> guide that was written for VS 2005, however, VS 2010 says it cannot resolve symbol. Is there any additional namespaces I need to add for VS 2010 to resolve the symbol?</p>
<p>My code is similar to the following, but with the correct names of the dataset and table adapter.</p>
<p>var tableAdapter = new NorthwindTableAdapters.SuppliersTableAdapter();</p>
| asp.net | [9] |
2,949,201 | 2,949,202 | Override usb or power cable connection sound in android device | <p>Is there any way to override the default sound that is made when an usb cable or power cable is connected to an android device ?
I am looking for a way to replace that default system sound with one of my own or even disable the sound completely. I did some digging into the android developer reference and found that the intent "android.intent.action.ACTION_POWER_CONNECTED" can be used in a broadcast receiver to handle the power connected state of the device. But I cannot abort that broadcast (in case I donot want to play the default sound) as it is a non-ordered broadcast.
Is there any other way out around this ?</p>
<p>Any help is appreciated.</p>
<p>Thanks.</p>
| android | [4] |
5,951,372 | 5,951,373 | Pass a $_GET variable to Dompdf | <p>How i pass a $_get variable to dompdf,See my code</p>
<pre><code><?php // test.php
include('dompdf/dompdf_config.inc.php');
ob_start();
require_once('pdf.php');//contain html with php variables
$pdf_html = ob_get_contents();
ob_end_clean();
$dompdf = new DOMPDF();
$dompdf->load_html($pdf_html);
$dompdf->render(); // Parse the html,
$dompdf->stream('file.pdf');
?>
</code></pre>
<p>In my pdf.php page i have a $id=$_GET['id']; that takes id from test.php and generates result base on the id from mysql result</p>
| php | [2] |
1,462,967 | 1,462,968 | URL Parameters with brackets | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4543500/php-form-input-field-names-containing-square-brackets-like-fieldindex">PHP: form input field names containing square brackets like field[index]</a> </p>
</blockquote>
<p>I just saw a URL parameter with brackets in it, does anyone know what could be the reason for using brackets? </p>
<p><code>www.website.com?request[product]=Digital+Printing</code></p>
<p>Thanks</p>
| php | [2] |
1,195,483 | 1,195,484 | php redirect after form success | <p>Total noob here, be gentle.
Using php script to allow people to add their email to a mailing list. When it successfully writes the email to the .txt doc it displays a success message on a white page. I want it to redirect to a page I've designed to look like the rest of the site. I've read elsewhere that I need to use the header function, but I can't figure out where to put it since the preceding portion of my code contains outputs. I'd appreciate any guidance. Thanks.
I think this is the relevant code: </p>
<pre><code>// Write to file if email doesn't already exist
if ($emailexists != "yes") {
// Write to the list and give success message
fwrite($fh, "$_POST[email]\n");
$msg = "Your e-mail address $EmailFix was successfully added to the list!";
}
// Close the list
fclose($fh);
}
</code></pre>
<p>Then this:</p>
<pre><code>// Show success message if there was one and end script, and no errors were encountered
} elseif (isset($msg)) {
echo "<b>" . $msg . "</b>\n";
echo "</body>\n";
echo "</html>\n";
exit;
}
</code></pre>
| php | [2] |
354,144 | 354,145 | How to create a summary of my code | <p>I want to automatically create some sort of report of my code(java).
Example:
I have something like:</p>
<pre><code>public classe qwerty{
//CODE
/*
* Converts ...
* @param s
* -string...
*/
public static int mult(string s)
{
//CODE
}
}
</code></pre>
<p>And I want to create something that looks like this:</p>
<pre><code>...............................
public static int mult(string s)
Converts ...
Paramters:
s (String): string...
Returns (int)
.................................
ETC
</code></pre>
<p>Is there any tool for that??</p>
| java | [1] |
2,881,004 | 2,881,005 | Jquery difference between searching 'children' and 'find' | <p>When is one preferred over the other when searching for nested DIvs?</p>
| jquery | [5] |
5,284,188 | 5,284,189 | Is setting the value of Server.ScriptTimeout enough to prevent page timeouts? | <p>On an administrative page with a long running process we're setting the following:</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
this.Server.ScriptTimeout = 300;
//other code
}
</code></pre>
<p>Is this enough that should prevent that page from timing out as it does what it needs to? I have no control over the process and how long it runs but we've found that 5 minutes is more than enough time, yet we're still getting intermittent errors of:</p>
<pre><code>System.Web.HttpException: Request timed out.
</code></pre>
<p>We've tried upping the value to 600 with really no difference and in any testing we've done we can never get the actual process to run for that long. Is there elsewhere that we need to be setting timeout values that won't affect the entire application and only the specific page we need the longer timeout value on? </p>
| asp.net | [9] |
2,101,882 | 2,101,883 | JS, return something friendly than undefined | <p>I'm creating a dictionary object in javascript (eg associate array)</p>
<pre><code>var myobj = {
"a" : "Some string",
"b" : "Some string else"
}
</code></pre>
<p>if I access myobj.a, it will return "Some string"
but if I access something not in the list myobj.c it return undefined.
Is there any way to set object getter to return something like: "Key not available"
Can we use prototype...
Thanks for any help</p>
| javascript | [3] |
2,670,247 | 2,670,248 | how to open a file by user input in python | <p>I am (trying) to write a tool that will open a file based on user input.
I want to eventually write the results of the script into a file and store it into the same directory as the input file.</p>
<p>I currently have this</p>
<pre><code>from Bio import SeqIO
import os, glob
var = raw_input("what is the path to the file (you can drag and drop):")
fname=var.rsplit("/")[-1]
fpath = "/".join(var.rsplit("/")[:-1])
os.chdir(fpath)
#print os.getcwd()
#print fname
#for files in glob.glob("*"):
# print files
with open(fname, "rU") as f:
for line in f:
print line
</code></pre>
<p>I do not understand why I cannot open the file. Both the "os.getcwd" and the "glob.glob" part show that I successfully moved to the users directory. In addition, the file is in the correct folder. However, I cannot open the file...
any suggestions would be appreciated </p>
| python | [7] |
365,045 | 365,046 | getting 24 hours difference in android | <p>I want to call an activity which downloads the data if the data has not been downloaded in last 24 hours.But I have no idea how to do this.Can some one help me out?</p>
| android | [4] |
6,741 | 6,742 | call php function every 10mins for 1hour | <p>got this code that should check if url is available and also give me ping:</p>
<pre><code><?php
function test ($url){
$starttime = microtime(true);
$valid = @fsockopen($url, 80, $errno, $errstr, 30);
$stoptime = microtime(true);
echo (round(($stoptime-$starttime)*1000)).' ms.';
if (!$valid) {
echo "Status - Failure";
} else {
echo "Status - Success";
}
}
test('google.com');
?>
</code></pre>
<p>How do i make it so this function would be called every lets say 10minues for 1hour (6times in total) ?</p>
| php | [2] |
2,939,403 | 2,939,404 | set width in percentage using jquery | <p>How can i set width of div in percentage using jquery?</p>
| jquery | [5] |
2,103,171 | 2,103,172 | Need to get/display properties from a variable | <p>I have searched but perhaps just don't understand and need an actual person to help explain. I have a script that generates the following variable:</p>
<pre><code>var trackerResult = {
"sessionId": "16zA06FJt5sp",
"customerId": "16zA06FJt5so",
"contact": {
"firstName": "Bilbo",
"lastName": "Baggins",
"email": "bbshireguy@gmail.com"
},
"orders": [{
"orderId": "16zA06FJt5ss",
"number": 11512,
"items": [{
"price": 97,
"productId": "16zA06FJt3of",
"productName": "Main"
}]
}, {
"orderId": "16zA06FJt5sw",
"number": 11513,
"items": [{
"price": 49,
"productId": "16zA06FJt3op",
"productName": "Upsell"
}]
}],
"demoMode": "1"
};
</code></pre>
<p>I need to be able to simply display the productName and the price. If what the script generated were a bit more simple I could do it, but as I understand what I am looking at there is properties that are technically a child of a child?</p>
<p>Thank you in advance.</p>
| javascript | [3] |
4,694,190 | 4,694,191 | how to display Trademark symbol in php? | <p>I got a trouble regrading of I cannot display trademark symbol?
what happen of my code ? </p>
<p>I had test this 2 code in the below, but still failed?</p>
<pre><code>$textmsg = htmlspecialchars($textmsg);
file_put_contents($textpath, $textmsg);
preg_replace("™", "â„¢Â", $textmsg);
file_put_contents($textpath, $textmsg);
</code></pre>
| php | [2] |
5,658,772 | 5,658,773 | How to write a configurable Java variable creation | <p>A new java component that is suppose to send along a list of pre-define variable to external party. User will then able to define which variable (a fixed set of variable) they want to send via a xml property file</p>
<p>Problem is: The pre-define variable is inside a class, and have business logic together with it, which i can't change or tap into (part of external api). eg as follow:</p>
<pre><code>public class DataColumn implement java.io.Serializable{
public static final String _actionID = "ActionID";
public static final String _actionName = "ActionName";
public static final String _actionDesc = "ActionDescription";
public static final DataColumn ActionDesc = new DataColumn (_actionDesc);
public static final DataColumn ActionID = new DataColumn (_actionID);
public static final DataColumn ActionName = new DataColumn (_actionName);
....and about 100 other variale more
protected WebMediaReportColumn(java.lang.String value) {
_value_ = value;
_table_.put(_value_,this);
}
}
</code></pre>
<p>user will define in the xml file like following:</p>
<pre><code><interface>
<fields isRequired="true">
<field>ActionID</field>
<field>ActionName</field>
<field>ActionDescription</field>
</fields>
</interface>
</code></pre>
<p>In order to set which variable to send across, the code looks like following:</p>
<pre><code>interface.setColumns(new DataColumn[] {
DataColumn.ActionID, DataColumn.ActionName, DataColumn.ActionDesc
}
);
</code></pre>
<p>Question is: how best to write a program that can base on what the user define in a property file, and create the Datacolumn[] Array accordingly? <strong>Without</strong> using If else block which is too long and hard to maintain.</p>
| java | [1] |
2,872,202 | 2,872,203 | Error with JavaScript Constructors Under Various Formats | <p>I have an issue with code in the following format:</p>
<pre><code>Test = {
baseConstructor: function( a, b ) {
this.a = a;
this.b = b;
},
object: new Test.baseConstructor( x, y )
};
</code></pre>
<p>I get an error saying that this.baseConstructor is not a constructor. So what would I do in this case? I know I could reformat it without using the Test = {} style but is there a way to do it in this format.</p>
| javascript | [3] |
886,813 | 886,814 | Asp.net jquery and alert with click anywhere on page | <p>I have an asp.net 4.0 page with a listbox, textbox and a ajax tabcontainer. On one of the tabs of the tab container there is a usercontrol. When I enter “edit mode” (by the user clicking an asp:button called Edit) in the usercontrol on that tab, I would like to display an alert when the user tries to click or nav by tabbing anywhere outside of that user control. E.g. “You must save your changes first…”</p>
<p>Is there a way with jquery that I could setup just one function that say traps the click on another tab or any control outside of that usercontrol?</p>
<p>I have my usercontrol so it can send an event to the parent when it enters “edit mode”.</p>
<p>Oh yeah, I also have update panels in the mix.</p>
| jquery | [5] |
2,958,445 | 2,958,446 | Debug android application | <p>I am developing an Android application where I get the following exception while writing to the database:</p>
<pre><code>An exception occurred: android.database.sqlite.SQLiteException
</code></pre>
<p>But it doest say anything else(not even the stack trace). </p>
<p>In general I find it very difficult to debug android SDK exceptions.</p>
<p>Any suggestions/tips on how to debug while developing android applications?</p>
<ul>
<li>I am using Eclipse to develop the application. </li>
</ul>
| android | [4] |
4,823,484 | 4,823,485 | Pagination error scrollview | <p>I ahve a view controller that holds 4 images ,i implement the pagination for these images this is my code</p>
<pre><code>- (void)viewDidLoad {
[super viewDidLoad];
[imageViewObj setImage:[UIImage imageNamed:@"hand1@2x"]];
NSTimer *ImgChangeTimer = [NSTimer scheduledTimerWithTimeInterval:2.0
target:self
selector:@selector(changeImage)
userInfo:nil
repeats:YES];
pageControlBeingUsed = NO;
NSArray *colors = [NSArray arrayWithObjects:[UIImage imageNamed:@"help3@2x"], [UIImage imageNamed:@"help4@2x"], [UIImage imageNamed:@"help2@2x"],[UIImage imageNamed:@"help1@2x"] ,nil];
for (int i = 0; i < colors.count; i++) {
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width *i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
UIImageView*subview = [[UIView alloc] initWithFrame:frame];
UIImage *imggg = [colors objectAtIndex:i];
[subview setBackgroundColor:[UIColor colorWithPatternImage:imggg]];
[self.scrollView addSubview:subview];
[self.scrollView addSubview:imageViewObj];
[subview release];
}
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * colors.count, self.scrollView.frame.size.height);
self.pageControl.currentPage = 0;
self.pageControl.numberOfPages = colors.count;
</code></pre>
<p>my need is i want to put a close button in the last image ,or the close button is hidden for first three-images and will unhidden when the user paging the last image.is there any way to do this?.
Thanks in advance.
EDIT</p>
<pre><code>if (self.pageControl.currentPage == 0) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"df" message:@"okkkk" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
</code></pre>
<p>i put this in viewdidlod and i get the alertview</p>
<p>but when i put "4" instead of "0" i didnt get the alertview</p>
| iphone | [8] |
877,872 | 877,873 | windows based iphone SDK needed | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/928656/iphone-sdk-on-windows-alternative-solutions">Iphone SDK on Windows (alternative solutions)</a> </p>
</blockquote>
<p>Hello,</p>
<p>From where can i get windows SDK kit of iPhone development in free ? I am new on iPhone development and i want to start it.
Thanks </p>
| iphone | [8] |
539,054 | 539,055 | jquery ajax returning true but not display proper message? | <p>I have the following code</p>
<pre><code>$(document).ready(function(){
// class exists
if($('.delete').length) {
// add click handler
$('.delete').click(function(){
// ask for confirmation
var result = confirm('Are you sure you want to delete this?');
var vid = $(this).attr('id');
var row = $(this).parents('tr');
// do ajax request
if(result) {
$.ajax({
type:"POST",
url:"delete_joke.php",
data:{id:vid,garbage:'FG9g543hfh'},
dataType: "json",
success:function(response){
// hide table row on success
if(response == "true") {
row.fadeOut();
$('#errors').show();
$('#errors').html( '<div class="message green"> Successfully deleted!<img src="http://puppetweb.ca/play/views/admin/gfx/icon-close.gif" alt="Close this item" /> </div>' ).show();
}else{
$('#errors').show();
$('#errors').html( '<div class="message red"> Error deleting. <img src="http://puppetweb.ca/play/views/admin/gfx/icon-close.gif" alt="Close this item" /> </div>' ).show();
}
}
});
}
return false;
});
}
});
</code></pre>
<p>And it works up until the part where I want to show the success, I have the php script print "true" on success and "false" on error, and if I do alert(response) it shows the word true. But it is displaying the Error deleting on success and Error deleting on error?</p>
<p>Any help?</p>
| jquery | [5] |
5,943,067 | 5,943,068 | Android TextView formating | <p>I am trying to implement a TextView that is serving as a header for a ListView. I want to format it so that I have basically a title centered on the first line and then additional information on the lines following. How can I format the text/string to create this kind of formatting? </p>
<p>Thanks,
Rob</p>
| android | [4] |
5,897,174 | 5,897,175 | iPhone:Add & Delete Row in UITableview with editing mode | <p>What I want to do is:</p>
<ol>
<li><p>Setting editing mode on NavigationBar in UITableView adds an <code>edit</code> button on the left side of the UINavigationBar. When I click this button, I'd like an <code>add</code> button to appear on the right side of the NavigationBar.</p></li>
<li><p>When I click on the <code>add</code> button, add a row to the NSMutableArray and update the table.</p></li>
</ol>
<p>So please give me ideas, code, or links to develop this functionality.</p>
| iphone | [8] |
5,541,973 | 5,541,974 | Check for invalid characters in a php string | <p>How can i check to see if a php string contains only 0-9 , and |? so it would accept <code>158,147|157,541|145,157</code> but not <code>125 ,148|126,4</code></p>
| php | [2] |
1,873,254 | 1,873,255 | python datetime localization | <p>What do I need to do (modules to load, locale methods to invoke, etc.) so that when I call:</p>
<pre><code>datetime.date(2009,1,16).strftime("%A %Y-%b-%d")
</code></pre>
<p>instead of getting:</p>
<pre><code>Out[20]: 'Friday 2009-Jan-16'
</code></pre>
<p>i get spanish/french/german/... output</p>
<pre><code>Out[20]: 'Viernes 2009-Ene-16'
</code></pre>
<p>without having to change my whole operating system's locale (i.e. just use python calls to dynamically set the locale and keep the changes scoped within my app)</p>
<p>Thanks.</p>
<p></p>
| python | [7] |
3,752,021 | 3,752,022 | C++ multidimensional array operator | <p>it is possible to overload somehow operator for multidimensional array?</p>
<p>Something like:</p>
<pre><code>class A {
...
int& operator[][] (const int x, const int y);
...
}
</code></pre>
<p>thanks in advance</p>
| c++ | [6] |
875,541 | 875,542 | Python TypeError: unsupported operand type(s) for *: 'Vector2' and 'int' | <p>I am trying to create a Vector2 class.
When I try to type</p>
<pre><code>vec1 = Vector2()
vec2 = vec1 * 5
</code></pre>
<p>it gives me the error:</p>
<pre><code>TypeError: unsupported operand type(s) for *: 'Vector2' and 'int'
</code></pre>
<p>Is there something wrong with my operator overloading?</p>
<pre><code>class Vector2(object):
def __init__(self, x = 0.0, y = 0.0):
self.X = x
self.Y = y
def __add__(self, other):
if isinstance(other, Vector2):
new_vec = Vector2()
new_vec.X = self.X + other.X
new_vec.Y = self.X + other.Y
return new_vec
else:
raise TypeError("value must be a vector.")
def __radd__(self, other):
return self.__add__(other)
def __sub__(self, other):
new_vec = Vector2()
new_vec.X = self.X - other.X
new_vec.Y = self.Y - other.Y
def __mull__(self, value):
new_vec = Vector2()
new_vec.X = self.X * value
new_vec.Y = self.Y * value
return new_vec
def __rmull__(self, value):
return self.__mull__(value)
def __div__(self, value):
new_vec = Vector2()
new_vec.X = self.X / value
new_vec.Y = self.Y / value
return new_vec
def dot(vector1, vector2):
return ((vector1.X * vector2.X) + (vector1.Y + vector2.Y))
</code></pre>
| python | [7] |
2,025,389 | 2,025,390 | determine height and width of dynamic html element by jquery | <p>suppose i have one js variable and my html data is stored into it like</p>
<pre><code>var data = '<div id="tst">here will be my othere html</div>'
</code></pre>
<p>in this case can i determine that what would be height & width of div tst using jquery?</p>
<p>one guy give me solution like</p>
<pre><code>var $test = $(data).appendTo('body');
var size;
window.setTimeout(function(){
size = {
height: $test.height(),
width: $test.width()
};
$test.remove();
});
</code></pre>
<p>but the above code looks bit complicated. if anyone know easy solution then please give me a sample code to do so. thanks</p>
| jquery | [5] |
3,596,623 | 3,596,624 | How can I add information values(or strings)of handle from Messagebox to List box in C#? | <p>my program follows;</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
namespace WindowsFormsApplication9
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
abc();
}
[DllImport("user32.dll", SetLastError = true)]static extern IntPtr
FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]public static extern int
EnumChildWindows(IntPtr hwnd, EnumChildCallback Proc, int lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
public delegate bool EnumChildCallback(IntPtr hwnd, ref IntPtr lParam);
public static void abc ()
{
IntPtr pHndl = FindWindow("notepad", null);
EnumChildWindows(pHndl, EnumChildProc, 0);
}
public static bool EnumChildProc(IntPtr hwndChild, ref IntPtr lParam)
{
try
{
const int nChar = 256;
StringBuilder ss = new StringBuilder(nChar);
string veri = "Handle: " + hwndChild.ToString() + "::" + GetWindowText(FindWindow("notepad", null), ss, 256);
MessageBox.Show(veri);
}
catch (Exception ex)
{
MessageBox.Show("Hata Olustu: " + ex.Message);
}
return true;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
</code></pre>
| c# | [0] |
1,894,452 | 1,894,453 | replacing div tag | <p>I have the following code,</p>
<pre><code><div id=1 class="mydiv"> <span>some data</span></div>
<div id="q-1">data</div>
<div id=2 class="mydiv"> <span>some data</span></div>
<div id="q-2">data</div>
<div id=3 class="mydiv"> <span>some data</span></div>
<div id="q-3">data</div>
<div id=4 class="mydiv"> <span>some data</span></div>
<div id="q-4">data</div>
<div id=5 class="mydiv"> <span>some data</span></div>
<div id="q-5">data</div>
</code></pre>
<p>I need to exchange a div of a given ID with the one after it, <strong>with the same class</strong>.</p>
| jquery | [5] |
3,934,656 | 3,934,657 | How to parse a locally stored XML file in iPhone? | <p>How to parse a locally stored XML file in iPhone?</p>
<p>please help me with this using code snippets</p>
| iphone | [8] |
303,250 | 303,251 | problem in toString() method for number to String conversion | <p>why in two below javascript commands output is 10 as integer</p>
<pre><code> var iNum1 = 10;
var fNum2 = 10.0;
alert(iNum1.toString()); //outputs “10”
alert(fNum2.toString()); //outputs “10”
</code></pre>
<p>while fNum2 var is a float ???</p>
| javascript | [3] |
3,570,055 | 3,570,056 | how to make the parent window blank during the onload? | <p>When i type the URL in the browser the login.jsp gets evaluated and a child window(with diasabled toolbar ) is opened and the parent window gets closed.</p>
<p>wat i want is when i type the url in the browser and click go i dont want to display any information of login.jsp page to be dispalyed in the parent window.. i want only in the child window......</p>
<p>i dont have any idea of using another jsp...</p>
<p>can someone help me wit the code or ideas.... </p>
<p>the code i hav written is pasted below.</p>
<p><strong>Login.js file</strong></p>
<pre><code>function focus(){
window.onload=ifocus();
document.LoginFB.strUserid.value="";
document.LoginFB.strPassword.value="";
document.LoginFB.strUserid.focus();
}
function ifocus(){
if(!window.opener){
window.opener='top';
window.close();
window.open('http://localhost:8080/jsp/Login.jsp','tr','width=1250,height=700,toolbar=no,location=no,directories=no,status=no,menubar=no,hbar=yes,scrollbars=yes,copyhistory=no,scrolling=yes, resizable=yes');
}else{
return;
}
</code></pre>
<p><strong>Login.jsp</strong></p>
<pre><code><body onload=javascript:focus()>
</code></pre>
| javascript | [3] |
5,167,214 | 5,167,215 | How to call other constructors from a constructor in c#? | <p>I have a constructor like:</p>
<pre><code>public Blah(string a, string b)
{
}
public Blah(string a, string b, string c)
{
this.a =a;
this.b =b;
this.c =c;
}
</code></pre>
<p>How can I call the 2nd constructor from the 1st one?</p>
<p>like:</p>
<pre><code>public Blah(string a, string b)
{
Blah(a,b, "");
}
</code></pre>
| c# | [0] |
1,326,215 | 1,326,216 | html parser in java | <blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/26638/what-html-parsing-libraries-do-you-recommend-in-java">What HTML parsing libraries do you recommend in Java</a><br>
<a href="http://stackoverflow.com/questions/1873475/need-a-good-html-parser-on-php">Need a good HTML parser on php</a><br>
<a href="http://stackoverflow.com/questions/3152138/what-are-the-pros-and-cons-of-the-leading-java-html-parsers">What are the pros and cons of the leading Java HTML parsers?</a> </p>
</blockquote>
<p>Hello,
I have used <a href="http://simplehtmldom.sourceforge.net/" rel="nofollow">http://simplehtmldom.sourceforge.net/</a> for parsing html in php and is there is any thing similar to that....</p>
| java | [1] |
5,481,837 | 5,481,838 | Using Javascript to ONLY hide a link/txt/div | <p>I have a site with a Javascript image viewer to enlarge my pics.</p>
<p>Therefore if you browse with JS enabled you dont have to see the link
to another page witch shows the pics enlarged.</p>
<p>if JS is disabled you wont see my function to enlarge pics with javascript, but
will see my link to the enlarged page.</p>
<p>I need a code to just hide the link. i keep finding TOGGLE switches. </p>
| javascript | [3] |
3,242,398 | 3,242,399 | webview and youtube video | <p>Sorry for my english. Here's my problem.
I have an html file in which there are some youtube videos. I load this file in a webview. When the activity with the webview starts, I would see the videos thumbnails and
I would click on them to watch them in the mediaplayer of the smartphone or in the browser. </p>
<p>Videos are embed in the html file with tag:</p>
<ul>
<li><p>object => I can see the thumbnail, but if I click on it, it doesn't open the video</p></li>
<li><p>iframe => I can see the thumbnail, if I click on it, the video starts but:
- if I click on pause and then on play, the audio restarts but not the video
- I can't watch the video on full screen</p></li>
<li>video => I can see the thumbnail, but if I click on it, It appears a grey square like if a plugin lacks</li>
</ul>
<p>Could anyone help me? Thanks.</p>
| android | [4] |
5,516,323 | 5,516,324 | Inserting item into map, which holds 2 more map | <p>I am trying to insert an item, into a map, which holds two other map.</p>
<pre><code>map< map<int, int> , map<int, int> > GC;
map<int, int> A;
A.insert(pair<int,int>(1,1));
map<int, int>:: iterator p1 = A.begin();
map<int, int> B;
B.insert(pair<int,int>(2,3));
map<int, int>:: iterator p2 = B.begin();
GC.insert( pair< map<int,int>, map<int,int> > (*p1, *p2) );
</code></pre>
<p>Well, as presumed its not working.</p>
<p>How to do it?</p>
<p><strong>EDIT:</strong><br>
It gives the following error:</p>
<blockquote>
<p>E:\CB\test.cpp|20|error: no matching function for call to <code>'std::pair<std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int> > >, std::map<int, int, std::less<int>, std::allocator<std::pair<const int, int> > > >::pair(std::pair<const int, int>&, std::pair<const int, int>&)'</code></p>
</blockquote>
| c++ | [6] |
3,292,007 | 3,292,008 | Dot dotdot dotdotdot as loading in JS? | <p><br>
I wanna create some loading dots, like this:<br>
<br>
At 0000 miliseconds the span content is: .<br>
At 0100 miliseconds the span content is: ..<br>
At 0200 miliseconds the span content is: ...<br></p>
<p>And that is replying itself...<br>
<br>
That creates a nice waiting script. But what is the best / easiest way to make that in JS?</p>
| javascript | [3] |
5,542,513 | 5,542,514 | Why is this javascript getting permission denied? | <blockquote>
<pre><code>Permission denied for <http://example.com> to get property
</code></pre>
<p>HTMLDocument.body from
<a href="http://www.example.com" rel="nofollow">http://www.example.com</a>.</p>
</blockquote>
<pre><code>var c = parseFloat(cf.contentDocument.body.offsetHeight) + 30;
</code></pre>
| javascript | [3] |
5,227,170 | 5,227,171 | SeekBarPreferences are changing but not visually | <p>I've been trying to work this out for 2 days now and I have absolutely no idea how to fix it.</p>
<p>Essentially, I have a service that listens for changes in a ListView (via a BroadcastReceiver) and updates several SeekBarPreferences accordingly via editor.putInt("SeekBarPreference", value).commit();. Now everything works as it should and it returns the correct values BUT it wont change the seekbarpreferences visually. If I restart the service (press back and then click on the relevant option) they change to the correct positions. Or even if I rotate the device they change.
I guess my question is; Is there any way to manually "refresh" the 'look' of the preferences?</p>
<p>Thanks!</p>
<p>(I know there are similar questions on here, but none of them really have a solution)</p>
| android | [4] |
3,735,958 | 3,735,959 | how to transfer all data from database to texbox in C# windows application? | <p>im using access database for my C# application as database,and i create 1 database and 1 windows form application in c#, and there are some textboxes,is it possible inserting all data from database into textboxes by using "SELECT "statement??????how can i do??i need help..</p>
| c# | [0] |
5,485,193 | 5,485,194 | Custom Data-bound control help | <p>I have never done this before and am very beginner in this one, so please treat me that way and help me. Obviously this is a complex topic for me at this stage.</p>
<p>I need to develop a custom data-bound control which will contain, few text-boxes, drop-down lists, labels, and other standard web-server controls. And, I want to be able to load this control from a web page on button click. When the user enters any data to any of its child controls, i should be able to save, and also retrieve when the data-bound control is loaded again. Also, the data in the child control should retain their value on postback.</p>
<p>Can someone help me getting into building this? What approach should i follow? Any books or artilces matching my requirement will be really helpful which i can read and help me develop this. </p>
| asp.net | [9] |
4,672,339 | 4,672,340 | Android-Huge amount of data inside a folder of assets | <p>I am currently having certain folders likes /images ,/pdf inside assets folder which has large data.I am working on copying these files to my internal /data/data path.There is a utility class in commons.io called FileUtils which allows me to copy the directory as such.</p>
<p>But my biggest question is ,how I make a File object out of folder inside assets so that I can put in FileUtils.copyDirectory(src,dest).Copying files recursively from assets gives me problems.Please suggest.</p>
| android | [4] |
2,458,008 | 2,458,009 | GLSurfaceView in LinearLayout Follow Up Question | <p>Please see this question I asked a few days ago: <a href="http://stackoverflow.com/questions/5980933/glsurfaceview-in-linearlayout">GLSurfaceView in LinearLayout</a></p>
<p>The answer that was given worked very well... but I would like to know if there is a more detailed explanation on why this works?</p>
<p>From my comments, "Working with other view types, and looking at the examples provided for LinearLayout, using wrap_content should work AFAIK. Can you provide any documentation links or further explanation?"</p>
<p>"Is the issue with the GLSurfaceView wanting too much space initially when wrap_content is used?"</p>
| android | [4] |
1,734,921 | 1,734,922 | Is new ObservableCollection<object>(ObjEnumerable.ToList()) same as Foreach and add? | <p>Is there any performance difference between the following two snippets?</p>
<h1>1</h1>
<pre><code>IEnumerable<object> enumerable = ...
var observableCollection = new ObservableCollection<object>(enumerable.ToList());
</code></pre>
<h1>2</h1>
<pre><code>IEnumerable<object> enumerable = ...
var observableCollection = new ObservableCollection<object>();
foreach (object o in enumerable)
{
observableCollection.Add(o);
}
</code></pre>
| c# | [0] |
2,568,348 | 2,568,349 | Making image clickable in gridview imagefield | <p>Hello i have an image field in a griedview as this:</p>
<pre><code><asp:ImageField DataImageUrlField="PictureID"
DataImageUrlFormatString="~/UploadedImages/{0}.jpg" HeaderText="Image"
ReadOnly="True">
<ControlStyle Width="100px" />
</asp:ImageField>
</code></pre>
<p>I want when user click on any of the images, it should take them to another page UploadedImage.aspx, displaying the clicked image in full size.
Can someone help me accomplish that?</p>
| asp.net | [9] |
5,023,695 | 5,023,696 | trying use of mouseover and mouseout in jquery | <p>i show <strong>ul</strong>,(it shows my submenu) like floowing code , i have problem with hiding <strong>ul</strong>, while i move mouse over ul(into menu) , it hides, and i cound not use of mouseout event correctly</p>
<p>how could i hide ul, just when mouseout of "ul li"</p>
<pre><code>$("ul li").mouseover(function() {
$(this).find('ul').show();
}).mouseout(function(){
$(this).find('ul').hide();
});
</code></pre>
| jquery | [5] |
2,493,004 | 2,493,005 | showing image on top of running phone | <p>how is it possible to show an image ontop of a running activity while still being able to control the background?
in case some ppl say it is not possible, check this app out:
<a href="https://play.google.com/store/apps/details?id=com.myboyfriendisageek.stickit&hl=en" rel="nofollow">https://play.google.com/store/apps/details?id=com.myboyfriendisageek.stickit&hl=en</a></p>
<p>is there a way to open a transparent activity but still being able to control the previous activity?
ive also tried using a toast, but that is capped by a timer, and i have not been able to find a way to control it.</p>
| android | [4] |
5,686,470 | 5,686,471 | dynamic global value replacement in javascript | <pre><code><html>
<body>
<script type="text/javascript">
var str="Welcome to Microsoft! ";
var val="Microsoft!";
document.write(str.replace('/'+val'+/gi', "W3Schools"));
</script>
</body>
</html>
</code></pre>
<p>this is not working, how to use val dynamically ?</p>
| javascript | [3] |
4,437,920 | 4,437,921 | jQuery :not selector | <p>I am interesting which method is faster: <code>:not</code> selector or <code>not()</code> method.
For example in such query:</p>
<pre><code>$(this).find(':input').not(':input[type=button], :input[type=submit], :input[type=reset]').each(function() { ... });
</code></pre>
<p>Thank you</p>
| jquery | [5] |
3,212,732 | 3,212,733 | When should I overload new/delete in C++ | <p>I have learned something about overloading new/delete in 《C++ Primer》.But I am very curious :as the default new/delete is so good,When should I overload them?</p>
| c++ | [6] |
2,858,120 | 2,858,121 | how do I destroy Params GET or POST when I input to another Form? | <pre><code><form id="form3" name="form3" method="get" action="">
<tr>
<td align="left" ><input name="page" type="text" id="page" size="5" value="<?php echo $pageNumView; ?>"/></td>
</tr>
</form>
<form id="form4" name="form4" method="post" action="">
<tr>
<td width="84%"><input name="iddetails" type="text" id="iddetails" size="20" value="<?php echo $rows['product_id']; ?>"/> </td>
</tr>
</form>
</code></pre>
<p>I have 2-Forms. I wanted to delete <code>$_GET['page']</code> in Form3 whenever I input on 'iddetails' in form4.
I tried using <code>unset($_GET['page']);</code> i can see it working using a debugger trace & deleted the params 'page'.
But when I tried using Form4 Input again, <code>$_GET['page']</code> is still there and was not totally deleted.
So how do I delete the Params 'Page' in form3 if I input at 'iddetails' form4? </p>
<p>I have read about this POST-REDIRECT-GET solution.</p>
| php | [2] |
4,242,503 | 4,242,504 | How to connect the iphone to Itunes? | <p>Iam trying to get the device id of my iphone.For that iam connecting iphone to MAc pc using datacable.But in itunes doesnt recognize my iphone.This iphone was bought in america and unlocked in india.i think this was the problem.If this is not a problem then please tell me the solution for that one.please sir.Apps are completed but testing is not completed because this is the problem.Please sir</p>
| iphone | [8] |
2,184,341 | 2,184,342 | how to know the coordinates of image when touch | <p>How to get image coordinates at mouse hover position.</p>
<p>Please let me know </p>
<p>Thank you</p>
| android | [4] |
2,096,596 | 2,096,597 | PHP Subscriptions - Preventing Sharing | <p>Have a client who is looking at developing a site where clients get access by subscriptions.</p>
<p>Obviously the biggest concern is people sharing their login details.</p>
<p>Are there any good techniques which can be deployed to help prevent this or at least reduce it.</p>
<p>Obviously only allowing single session per user logged in so it would kick other people off if they were logged in.</p>
<p>Any other good ideas ?</p>
<p>Thank if you can advise.</p>
| php | [2] |
690,007 | 690,008 | Anybody used UIScrollViewDelegate as following: | <p>I have used UIScrollView in that UIButtons, i wanted to stop scroll of scrollview.
Suppose there are 3 buttons,
If i press 1st button then all buttons will scroll
,and 1st button will move to center then 2nd and 3rd.</p>
<p>As i press 2nd then 2nd button will move to center , INDEX MUST BE SAME (1,2,3) Only x-coordinate will change.</p>
<p>Anyone , Please Help me..</p>
<p>Thank you In Advance....</p>
| iphone | [8] |
2,020,034 | 2,020,035 | Verify a web element can be interracted with | <p>I am writing automated test scripts for a project I am working on, using webdriver. During one of my scripts a "wheel of hope appears" on the page while a payment is being processed. All other elements are displayed on the page but the spinning wheel always takes focus. Hence I can't click/interact with any elements on the page.</p>
<p>In general before clicking on an element I verify that it is on the page. My problem is
that the element is on the page but I am unable to click on it due to the wheel taking focus. Is there a way to verify that an element can have focus/be the active element? Otherwise I am stuck using explicit waits as my wait for jquery implicit wait doesn't seem to work. </p>
<p>All ideas welcome.</p>
<p>Thanks,
James</p>
<p>My one thought is to use jquery to focus on the element, and then to only start the next action once the element has been focused on. Does anyone know if this would have limitations?</p>
<p>I tried to use the following to focus the element then verify focus: </p>
<pre><code>arguments[0].focus();
if(document.activeElement==arguments[0]){
return true;
}
else{
return false
}
</code></pre>
<p>(where arguments[0] is the webelement behind the wheel of hope I want to click on). Unfortunately it returns true while the wheel is still spinning and taking away focus...</p>
| javascript | [3] |
479,596 | 479,597 | use of equals() method in comparator interface? | <p><code>equals()</code> method is available to all java collection classes from the <code>Object</code> class. This method is also declared in <code>Comparator</code> interface, so what is the purpose of declaring this method in Comparator? in which case is it used and how?</p>
| java | [1] |
4,431,020 | 4,431,021 | List.remove removes odd elements | <p>It might be something obvious but not able to rationalise the output of this snippet.
Reference: <a href="https://github.com/marhan/effective-java-examples/blob/master/src/main/java/org/effectivejava/examples/chapter07/item41/SetList.java" rel="nofollow">this</a></p>
<pre><code>public class Sample {
public static void main(String[] args) {
Set<Integer> set = new TreeSet<Integer>();
List<Integer> list = new ArrayList<Integer>();
for (int i = -3; i < 3; i++) {
set.add(i);
list.add(i);
}
System.out.println("After adding elements:");
System.out.println(set + " " + list);
for (int i = 0; i < 3; i++) {
set.remove(i);
list.remove(i);
}
System.out.println("After removing elements:");
System.out.println(set + " " + list);
}
}
</code></pre>
<p>output:</p>
<p>After adding elements:</p>
<p>[-3, -2, -1, 0, 1, 2] [-3, -2, -1, 0, 1, 2]</p>
<p>After removing elements:</p>
<p>[-3, -2, -1] [-2, 0, 2]</p>
<p>I am expecting:</p>
<p>After removing elements:</p>
<p>[-3, -2, -1] [0, 1, 2] </p>
<p>i.e. list.remove(i) should actually remove 1st ,2nd and 3rd item in the list. fair enough ?</p>
| java | [1] |
1,720,307 | 1,720,308 | ideal way of handling multiple return values in methods in java | <p>I know there are ways to return multiple results and break them up but this feels.. messy.</p>
<p>For practice I'm doing a quadratic equation solver. Obviously there are going to be cases when there are multiple return values needed. I'm just wondering what's the preferred way of handling a case like this-- I'm not so much looking for workarounds (returning a string and breaking it into two, etc) as I am for some sort of general "best practice" for clean/well styled code</p>
| java | [1] |
4,752,661 | 4,752,662 | How to access Assets Subfolder of installed applications in android | <p>I am accessing the assets folder of installed applications from my application. I am able to access the assets folder of every installed application but it returns me with some folder & some files. If it returns me only files then there is no problem I am able to access those files but how could I come to know that is this the file or folder which is I am accessing?</p>
| android | [4] |
1,362,318 | 1,362,319 | Finding DropDownList index by text | <p>I have a populated DropDownList. How do I find the index whose Text value is "x"?</p>
| asp.net | [9] |
4,136,150 | 4,136,151 | Playing a WAV File Multiple Times | <p>I need to have the same short wav file (1 second) play each time the user presses a single button. I have the following code that works for about 30 clicks and then the app "Force closes" on the device. I think what is going on is that new instances of media player are being created and then the instances build up (approx 30 clicks) and the app crashes. So I then added the "release" instance in the hope that on button-click the wav would play and then the mediaplayer would be released. However, it doesnt work that way. With the mp.release() no sound is played possibly becaue the medaiplayer gets released too soon for the user to hear the sound?</p>
<p>Anyone have a good tip to help me getting this to work? Thank you all so much.</p>
<p>Button button2 = (Button) findViewById(R.id.button10);
button2.setOnClickListener(new View.OnClickListener() {</p>
<pre><code> public void onClick(View v) {
// Perform action on click
MediaPlayer mp = MediaPlayer.create(getApplicationContext(), R.raw.clicker);
mp.start();
mp.release();
</code></pre>
| android | [4] |
5,309,593 | 5,309,594 | How to transfer a value of a var from 1 func to another? | <p>I have 3 functions:</p>
<pre><code>public int ok_join(string gr)
{
...................
string gash = Regex.Match(response, @"gash:""(?<id>[^""]+)""").Groups["id"].Value;
string groupId = Regex.Match(response, @"state:""smd=(?<id>[^""]+)""").Groups["id"].Value;
......................
}
public bool ok_post(string gr)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.site.ru/" + gash + "&stoud=" + groupId + "&");
.........................
}
public void go()
{
while (true)
{
........
int h = ok_join(gr);
if (h == 0)
ok_post(gr);
.............
}
}
</code></pre>
<p>How to send a value of gash and groupid from function ok_join to ok_post?</p>
| c# | [0] |
5,340,480 | 5,340,481 | Jquery detecting clicked element id | <p>I'm trying to use the same function to slide up and down a text area. using jquery's slidetoggle.</p>
<p>How can I make javascript detect the clicked element in order to know which box to expand.</p>
<p>Here is what I have</p>
<pre><code>function slidedown(id){
$(id+'text').slideToggle(500);
}
</code></pre>
<p>that is my function</p>
<p>in my html I have this </p>
<pre><code><a id="reroof" href="javascript:slidedown(this)">reroof</a>
</code></pre>
<p>the section i want to expand is called rerooftext</p>
<p>however when I check the value of id.id I says undefined.</p>
<p>Any ideas?</p>
| javascript | [3] |
815,554 | 815,555 | jQuery syntax error? Css and Animate in 'if' and 'else' statements | <p>Edit - Ive changed my code:</p>
<p>This works fine:</p>
<pre><code>$(".image-div").click(function () {
if ($(this).css('z-index') == 1)
$(this).css('z-index','2');
else
$(this).css('z-index','1');
});
</code></pre>
<p>And this also works:</p>
<pre><code> $(".image-div").click(function () {
if ($(this).css('z-index') == 1)
$(this).animate({
width: '500px'
}, 5000, function() {
// Animation complete.
});
else
$(this).animate({
width: '250px'
}, 5000, function() {
// Animation complete.
});
});
</code></pre>
<p>But this doesn't do anything: </p>
<pre><code> $(".image-div").click(function () {
if ($(this).css('z-index') == 1)
$(this).css('z-index','2');
$(this).animate({
width: '500px'
}, 5000, function() {
// Animation complete.
});
else
$(this).css('z-index','1');
$(this).animate({
width: '250px'
}, 5000, function() {
// Animation complete.
});
});
</code></pre>
<p>Thanks</p>
| jquery | [5] |
3,650,239 | 3,650,240 | Calling function on opener window | <p>The child lost its parent!!</p>
<p>I have a parent window, when somebody clicks on an image a JS popup opens and displays the photo and its information.</p>
<p>To close the popup/child window, and to flash an element on my parent/opener window, I have been using this function:</p>
<pre><code>function closeWindow() {
var currentID = document.getElementById('currentID').value;
window.opener.flashElement(currentID);
window.close();
}
</code></pre>
<p>My problem is this doesn't work if my users navigate away from the page that the popup originally opened. For example, in the popup window, there are next and previous buttons to scroll through the individual photos in that set of results, which reloads the page with a new querystring value.</p>
<p>If my user scrolls (reloads page) less than 7 times it's okay but if they scroll more than that, the <code>window.opener</code> function does not work, and because of that, the <code>window.close</code> function doesn't either!</p>
<p>I could probably rebuild the page so the data comes via an AJAX call, rather than reloading the page, but that's a lot of work I could do without.</p>
<p>Any ideas?</p>
| javascript | [3] |
4,900,550 | 4,900,551 | making this pythonic | <p>How can I make the following snipped of code "pythonic"</p>
<pre><code> tag_list = []
for d in docs:
tags = d["tags"]
for tag in tags:
if tag not in tag_list:
tag_list.append(tag)
</code></pre>
| python | [7] |
4,969,975 | 4,969,976 | How to add list together | <p>I'm trying to figure out a question and I'm getting confused. Basically I have a list and it's supposed to represent a bank statement. I'm trying to add the list together so the negative numbers, which is supposed to represent withdrawl, is added together and the positive numbers are added together to represent the deposits. So far I got </p>
<pre><code>def statement(l):
deposit = 0
withdrawl = 0
for a in l:
a = sum(l)
for b in l:
if b == -b:
b = sum(b)
return [a,-b]
</code></pre>
<p>but when I do <code>statement([30.95,-15.67,45.56,-55.00,43.78])</code>
it returns <code>[49.620000000000005, -43.78]</code>
when it is supposed to return <code>[120.29,-70.67]</code> can someone help?</p>
<p>Thanks!</p>
| python | [7] |
2,963,723 | 2,963,724 | Android Tabs Layout | <p>I have an Tab Activity with 4 tabs.
Each of tab is showing me the list view.
Suppose i m on 4th tab and dragged the list view to the last position and after that i click on 3rd tab and again when i go to 4th tab it is not refreshing and showing me the last visible screen. Actually i want to show the list view again from 1st element.</p>
<p>is tabs refresh automatically or we need to do it programmatic??</p>
<p>pls help me..</p>
| android | [4] |
5,263,363 | 5,263,364 | How to share class files between visual c# express and web dev express? | <p>What if I want to make an application which supports both winform and webform, how do I setup the project files in visual studio or vstudio express ?</p>
| c# | [0] |
466,473 | 466,474 | Formatting text received via api | <p>I get text via api and sometimes the text can be like so:</p>
<pre><code>hello
world!
How are you?
</code></pre>
<p>But I do need the text to be like this:</p>
<pre><code>hello world! How are you?
</code></pre>
<p>How to do that?</p>
| php | [2] |
240,863 | 240,864 | How can i get the printer's network path (\\COMPUTER\PRINTERNAME) | <p>How can i get the printer's network path (\COMPUTER\PRINTERNAME) from default printer window c++.</p>
| c++ | [6] |
5,630,569 | 5,630,570 | Google Checkout Merchant account in In_App billing? | <p>What is the importance or usage of 'Google Checkout Merchant account' in android in-App purchase ? Thanks in advance </p>
| android | [4] |
4,438,185 | 4,438,186 | Extend doesn't seem to work in jquery plugin | <p>I'm creating a basic jquery plugin but the extend doesn't seem to work..</p>
<p>I'm calling the plugin in below manner</p>
<pre><code> $('#ccontainer').slide("/json/service.json",6000,700,'true','true','right','800px');
</code></pre>
<h2>Plugin</h2>
<pre><code>(function($) {
$.fn.slide = function(settings) {
var options = {
service : '',
slideAnimationTime : 5000,
slideSpeed : 800,
onHoverPause : 'true',
autoSlide : 'true',
direction : 'right',
width : ''
};
$.extend(options , settings);
console.log(options.slideSpeed); //doesn't show up new settings as 700 in above case but instead shows old value 800
}
</code></pre>
| jquery | [5] |
1,305,545 | 1,305,546 | Object.ReferenceEquals never hit | <p>Can anyone tell me why the following condition does not hit?</p>
<pre><code>List<DateTime> timestamps = new List<DateTime>();
timestamps.Add(DateTime.Parse("8/5/2011 4:34:43 AM"));
timestamps.Add(DateTime.Parse("8/5/2011 4:35:43 AM"));
foreach(DateTime x in timestamps)
{
if (Object.ReferenceEquals(x, timestamps.First()))
{
// Never hit
Console.WriteLine("hello");
}
}
</code></pre>
| c# | [0] |
4,742,884 | 4,742,885 | drop down list changed | <p>in my application I need to check if a drop down list has changed or not. can you please let me know how I should write it? </p>
<pre><code>if (document.form.dropdownlist.???)
</code></pre>
<p>I don't know what to write instead of ????</p>
| javascript | [3] |
4,101,250 | 4,101,251 | Calling a function from within another function? | <p>I want to use a function from another class within a new function which I will call from main. I am trying to do this as below, but get an error: </p>
<blockquote>
<p>Error The name 'Class1' does not exist in the current context.</p>
</blockquote>
<p>Actually, in my code I use different names, but its just to illustrate the structure and to make it easier to read for you.</p>
<pre><code>public class Class1
{
public static int[] Function1()
{
// code to return value
}
}
public class Class2
{
public static int Function2()
{
int[] Variable = Class1.Function1();
//other code using function1 value
}
}
</code></pre>
| c# | [0] |
5,308,083 | 5,308,084 | Javascript to get entire contents of frame | <p>I want to have a script rewrite a simple text-file opened up as the source of a frame -- one that lacks any html. I tried <code>frames[1].document.innerHTML</code> but without success. I even tried <code>.outerHTML</code> and got nothing. Can I either (a) get from the frame the entire contents of the frame to manipulate using the script and then <code>.write()</code> back the result to the frame? Or (b) add <code><html></code> and <code><div></code> tags, wrapping the document so I can get the inner html and then manipulate that? Any help appreciated.</p>
| javascript | [3] |
246,583 | 246,584 | How to add TableRow dynamically to the TableLayout | <p>I need to add <code>TableRow</code> which consists of several different <code>Views</code> dynamically to the <code>TableLayout</code> but have this <code>TableRow</code>'s inflated from my <code>layout.xml</code>. Please advice how to do this.</p>
| android | [4] |
5,291,142 | 5,291,143 | Android export give a "Conversion to Dalvik format failed error1" | <p>When i try to export my android project i'm getting the following eclipse error message "Conversion to Dalvik format failed error1""</p>
<p>i try the following steps but no luck..</p>
<p>01.Project » Clean
02.add the following to eclipse.ini -Xms128m /-Xmx512m
03.Restarting Eclipse with the -clean option</p>
<p>Export Steps:
Right click on project->export->android under that select the "export android application"</p>
<p>regards,
Sam</p>
| android | [4] |
3,497,900 | 3,497,901 | How can I quickly encode and then compress a short string containing numbers in c# | <p>I have strings that look like this:</p>
<pre><code>000101456890
348324000433
888000033380
</code></pre>
<p>They are strings that are all the same length and they contain only numbers. </p>
<p>I would like to find a way to encode and then ompress (reduce the length) of the strings. The compression algoithm would need to just compress down to ASCII characters as these will be used as web page links. </p>
<p>So for example:</p>
<pre><code>www.stackoverflow.com/000101456890 goes to www.stackoverflow.com/aJks
</code></pre>
<p>Is there some way I could do this, some method that would do the job of compressing quickly. </p>
<p>Thanks,</p>
| c# | [0] |
3,352,961 | 3,352,962 | Find a link whose href matches | <p>I have a link like:</p>
<p><code><a href="#slide1">Slide 1</a></code></p>
<p>And I want to find it like so:</p>
<p><code>$('ul.dots li a').attr('href').is('#' + id).parents('li').toggleClass('selected');</code></p>
<p>the id variable would be something like: <code>#slide1</code> including the hash. However it does not work... Any ideas on how best to do this? I also tried: <code>$('ul.dots li a[href=#' + id + ']').parents('li').toggleClass('selected');</code> but doesn't work either...</p>
<p>Can anyone help. Thanks</p>
| jquery | [5] |
2,276,546 | 2,276,547 | Access array element from function call in php | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1769020/how-to-avoid-temporary-variables-in-php-when-using-an-array-returned-from-a-func">How to avoid temporary variables in PHP when using an array returned from a function</a> </p>
</blockquote>
<pre><code>function array_test()
{
return array(0, 1, 2);
}
echo array_test()[0];
</code></pre>
<p>Can anyone explain why this code doesn't work?</p>
| php | [2] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.