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,077,446 | 5,077,447 | How to receive the command output as it is happening in Python? | <p>I have Linux command that is running in Python.</p>
<pre><code>roc = subprocess.Popen(['sshpass', '-p', password, 'rsync', '-avz', '--info=progress2', hostname, '/home/zurelsoft/test'],
stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
print roc
</code></pre>
<p>This print the command processing only when it finishes execution. But, I want the output of the command as it is happening and stops when the command is fully executed. How it can be done?</p>
| python | [7] |
4,489,471 | 4,489,472 | Javascript match array | <p>Is there a way to match multiple arrays and delete similar strings.</p>
<pre><code>array1 = ["apple", "cherry", "strawberry"];
array2 = ["vanilla", "chocolate", "strawberry"];
</code></pre>
| javascript | [3] |
1,934,160 | 1,934,161 | Python re function | <p>I've been racking my brain as how to do the following:</p>
<p>If I have a sting of data such as <code>"003 HELLO, banana apple,xyz 004 HELLI, pear peach,lmn"</code>
I have a whole document full of rows like this which need splitting into:</p>
<pre><code>003 HELLO, banana apple,xyz
004 HELLI, pear peach,lmn
</code></pre>
<p>To me the logical thing to do would be to split the line after the word following the second comma as this is a pattern that runs all the way through. </p>
<p>Surely there has to be a way to do this with the re function. </p>
<p>Any idea how to do this?</p>
<p>Many thanks everyone</p>
| python | [7] |
1,029,941 | 1,029,942 | Is it possible to hide console C# application from Task Manager? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/187983/how-do-i-hide-a-process-in-task-manager-in-c">How do I hide a process in Task Manager in C#?</a> </p>
</blockquote>
<p>Hi</p>
<p>Is it possible to hide console C# application from Task Manager ?</p>
<p>thanks in advance</p>
| c# | [0] |
3,361,217 | 3,361,218 | How to resolve java.lang.nullpointer exception in android test project? | <p>In Eclipse i am doing to create a Android Test Project in the below way. But I am getting always java.lang.NullpointerException.</p>
<p>Procedure. No Previous project is there on the eclipse.</p>
<p>Select New --> Project --> Android -->Android Test Project.</p>
<p>It is asking project name. I am giving test. Then it is asking android version. I am selecting android 2.2 now i am selecting ok. i am getting "java.lang.NullpointerException"</p>
<p>How to resolve this?</p>
| android | [4] |
1,157,682 | 1,157,683 | Ask confirmation to user (through jQuery) before ajax post >> strange behaviour | <p>I have a strange behaviour in my ajax posting. First, I display an anchor link with the class 'remove-link'. From this link, I get the target URL in the variable removeLinkObj. Next, I show a jquery ui dialog to ask the user to confirm. Then I do the ajax call with the url removeLinkObj. </p>
<p>The problem is that in STEP1 the link is (for example) ../../43 and in STEP2 the link is ../../42. So it is the previous value! Why is the value not the right one? I don't know if I'm clear?</p>
<p>The aim of my code is to ask confirmation to the user (through a jquery ui dialog) before posting.</p>
<pre><code>$().ready(function () {
var removeLinkObj;
$('.remove-link').click(function () {
// STEP1
removeLinkObj = $(this); //for future use
$('#confirm-remove').dialog('open');
return false; // prevents the default behaviour
});
$('#confirm-remove').dialog({
autoOpen: false, width: 500, resizable: false, modal: true,
buttons: {
"Continue": function () {
// STEP2
$.ajax({
type: "Delete",
url: removeLinkObj[0].href,
cache: false,
success: function (data) {
alert(data.TransportedMaterialId);
$("#" + data.TransportedMaterialId).remove();
}
});
$(this).dialog("close");
},
"Cancel": function () {
alert('User clicked Cancel');
$(this).dialog("close");
}
}
});
})
</code></pre>
<p>And in my html:</p>
<pre><code><a href="aa/bb/44" class="remove-link">Delete</a>
</code></pre>
<p>Thank you anyway.</p>
| jquery | [5] |
3,201,942 | 3,201,943 | Help with "incompatible types" error in Java | <p>I can't figure out why it won't compile. And how do I make the error a string?</p>
<pre><code>public class UserID {
private String firstName;
private String lastName;
private String userId;
private String password;
public UserID(String first, String last) {
Random generator = new Random();
firstName = first;
lastName = last;
userId = first.substring(0, 3) + last.substring(0, 3)
+ generator.nextInt(1) + (generator.nextInt(7) + 3)
+ generator.nextInt(10);
password = generator.nextInt(10) + generator.nextInt(10)
+ generator.nextInt(10) + generator.nextInt(10)
+ generator.nextInt(10) + generator.nextInt(10);
}
}
</code></pre>
<p>Error Message:</p>
<pre><code>UserID.java:36: error: incompatible types
+ generator.nextInt(10);
^
required: String
found: int
</code></pre>
| java | [1] |
1,377,420 | 1,377,421 | how to access activity button on dialog | <p>I have an activity having 5 buttons. I called a custom dialog from button clicking on this activity. A list of dialog is opened and i am selecting an item and get back to that activity. Here I want to hide 3 buttons when I am returning from dialog. I can't restart activity from dialog.Anyone is there who helps Me?
Thanks in advance</p>
| android | [4] |
4,958,227 | 4,958,228 | C# coding exercises | <p>Hallo there</p>
<p>Am currently busy with C# and would like a little more practice.
Was hoping there might be a good link where I can do just that, preferably with answers to practice questions as a way of gaining confidence.
I have a whole lot of pseudo code exercises and it only explores program flow, not really the use of delegates, interfaces, structs, classes inheritance etc. </p>
<p>Kind regards
Arian</p>
| c# | [0] |
3,725,477 | 3,725,478 | how to change a selections options based on another select option selected? | <p>here is my html.</p>
<pre><code><select id="type">
<option value="item1">item1</option>
<option value="item2">item2</option>
<option value="item3">item3</option>
</select>
<select id="size">
<option value="">-- select one -- </option>
</select>
</code></pre>
<p>here is the jquery i tried but was unsuccessful.</p>
<pre><code>$(document).ready(function() {
if( $("#type").val("item1"))
{
$("#size").html("<option value='test'>test</option><option value="test2">test2</option>);
}
elseif( $("#type").val("item2"))
{
$("#size").html("<option value='anothertest1'>anothertest1</option>");
}
});
</code></pre>
<p>basically what i'm trying to do is if an option is selected in #type then the size select is populated with options associated to it. how can i do this?</p>
<p>thanks</p>
| jquery | [5] |
585,015 | 585,016 | how to get next day of current date in a MonthDisplayHelper in android? | <p>i have a monthdisplayhelper to display the month, i want to select days between two date. i.e.,if i selected 2nd July and 9th July, all the dates(3rd to 8th) in between these dates must be selected or highlighted.</p>
| android | [4] |
1,432,399 | 1,432,400 | PHP Overloading similar to sprintf()? | <p>How do you write a function in PHP that can accept an <em>unlimited</em> number of arguments similar to sprintf?</p>
<pre><code>sprintf("one:%s",$one);
sprintf("one:%s two:%s",$one,$two);
...
</code></pre>
| php | [2] |
2,507,541 | 2,507,542 | match 2 Images in c# | <p>How to Compare 2 images which are of different size</p>
| c# | [0] |
2,213,153 | 2,213,154 | Split a string at a natural break | <p>While rendering a title (using reportlab), I would like to split it between two lines if it is longer than 45 characters. So far I have this:</p>
<pre><code>if len(Title) < 45:
drawString(200, 695, Title)
else:
drawString(200, 705, Title[:45])
drawString(200, 685, Title[45:])
</code></pre>
<p>The problem with this is that I only want to split the title at a natural break, such as where a space occurs. How do I go about accomplishing this?</p>
| python | [7] |
4,576,260 | 4,576,261 | ListView rounded Selector | <p>I have create a listView with rounded cornered background. Now while i select the first item in the listview, the selector shape was not top rounded rect. Likewise while i select the last item in listview, the selector shape was not bottom rounded rect. If i apply rounded rect to the selector all listview item selection will be rounded rect shape. So that i want the selector shape to be matched with the listview's rounded rect background.</p>
<p>Please help me to solve this issue.</p>
| android | [4] |
5,897,399 | 5,897,400 | Member-Function Pointers With Default Arguments | <p>I am trying to create a pointer to a member function which has default arguments. When I call through this function pointer, I do not want to specify an argument for the defaulted argument. This is disallowed according to the standard, but I have never before found anything that the standard disallowed that I could not do in some other conformant way. So far, I have not found a way to do this.</p>
<p>Here is code illustrating the problem I'm trying to solve:</p>
<pre><code>class MyObj
{
public:
int foo(const char* val) { return 1; }
int bar(int val = 42) { return 2; }
};
int main()
{
MyObj o;
typedef int(MyObj::*fooptr)(const char*);
fooptr fp = &MyObj::foo;
int r1 = (o.*fp)("Hello, foo.");
typedef int(MyObj::*barptr)(int);
barptr bp1 = &MyObj::bar;
int r2 = (o.*bp1)(); // <-- ERROR: too few arguments for call
typedef int (MyObj::*barptr2)();
barptr2 bp2 = &MyObj::bar; // <-- ERROR: Can't convert from int(MyObj::*)(int) to int(MyObj::*)(void)
int r3 = (o.*bp2)();
return 0;
}
</code></pre>
<p>Any ideas on how to do this <em>in conformant C++</em> if I do not want to specify any values for the defaulted arguments?</p>
<p>EDIT: To clarify the restrictions a bit. I do not want to specify any default arguments either in the call or in any typedef. For example, I do not want to do this:</p>
<pre><code>typedef int(MyObj::*barptr)(int = 5);
</code></pre>
<p>...nor do I want to do this:</p>
<pre><code>typedef int(MyObj::*barptr)(int);
...
(o.barptr)(5);
</code></pre>
| c++ | [6] |
5,503,312 | 5,503,313 | Need help in Javascript + IFrame | <p>I have 2 function one in iframe and another one out of iframe.</p>
<p>I want to call outer function from inner[iframe] function. </p>
<p>Can anyone help me?</p>
| javascript | [3] |
4,513,096 | 4,513,097 | Python oop question | <p>How do I call method <code>.get_item(Example1()).do_something()</code> in class <code>Base</code> from inside the class <code>Example2</code>?</p>
<pre><code>class Base:
items = []
def add_item(self, item):
self.items.append(item)
def get_item(self, item):
return self.items[0]
class Item:
pass
class Example1(Item):
def do_something(self):
print('do_something()')
class Example2(Item):
def __init__(self):
'''
How call this method .get_item(Example1()).do_something() ?
'''
if __name__ == '__main__':
base = Base()
base.add_item(Example1())
base.add_item(Example2())
</code></pre>
| python | [7] |
4,880,744 | 4,880,745 | How to make activity appear in "Choose file" dialog? | <p>Example: when you click a button to upload an image, you get the dialog to choose a file. Then you can select an app you want to choose it. How can I make my app appear in that dialog?</p>
<p><img src="http://i.stack.imgur.com/6hHRyl.png" alt=""></p>
| android | [4] |
4,793,363 | 4,793,364 | PHP SQL server query problems | <p>Im using php with mssql function (Xampp). Im trying to do a so-called progress bar for my user to see the process running behind. So, from a form, i send it to two php pages. one is the processing page and another one is the progress bar (popup window) page.</p>
<p>The processing page work fine, insert, update the database. but the problem is another page, which is the progress bar page keep on hang after refresh. </p>
<p>If i run both page using different browser (firefox and chrome), the progress bar working fine, but if both running in the same browser (eg: im using firefox4), the progress bar script will halt and error of 'Maximum execution time of 60 seconds exceeded' appear</p>
<p>fyi, both page use the same database and same table..</p>
<p>many2 thanks in advance.... </p>
| php | [2] |
4,411,809 | 4,411,810 | What are the meanings of Navegation Type & Hierarchical in eclipse android project | <p>I am creating a new project, but when I come on the "New Blank Activity" Screen, I found a selection list named as "Navigation Type" and immediately below this there is "![Hierarchical][1] Parent" text field. can any one tell me what is the purpose and how I will fill these fields.</p>
<p>Thanks in advance....</p>
<p>Rizwan</p>
| android | [4] |
3,418,910 | 3,418,911 | not able to retrieve old session variable values in php | <p>Hi i am new to PHP.I am having "item.php" page and "cart.php" page. In item.php 3 checkboxes are available. if i click on one checkbox from item.php the value is sent to to cart.php page. however if i go back and select another checkbox the old value is not retained. Only the new value is getting printed.
I am storing the retrieved checkbox value in a session variable in cart.php but still not able to retrieve the old values selected. Can anybody help me out? Thanks in advance</p>
| php | [2] |
3,996,930 | 3,996,931 | Javascript: check if the url is changed or not? | <p>My url format is like : </p>
<pre><code>http://domain.in/home
http://domain.in/books/notes
http://domain.in/books/notes/copy
</code></pre>
<p>I've called a javascript function on window.load to check if the url has changed or not.</p>
<p>If the url has been changed then code is executed else it will return and checks again after 5 sec.</p>
<p>My code is :</p>
<pre><code>window.onload = function(){
setInterval(function(){
page_open();
}, 5000);
};
function page_open(){
var pages=unescape(location.href);
pages=pages.substr( pages.lastIndexOf("studysquare.in/") + 15 );
// gives book if url is http://studysquare.in/book
//alert("pages"+pages+"\n\n recent"+recent);
if (pages==recent) { return; }
recent=pages;
alert("Reached down now the code will execute.");
}
</code></pre>
<p>The problem now is : when the url is like :</p>
<pre><code>http://domain.in/book
</code></pre>
<p>Single level deep, then everything works fine. But when the url is like</p>
<pre><code>http://domain.in/book/copy or http://domain.in/book/copy/notes
</code></pre>
<p>Then nothing works.....
Any help to check 3 level deep url change in javascript every 5 sec ? :)</p>
<p>Hi sorry I forgot to tell that... I've .htaccess file which doesnt allow to navigate the page when any length url after the <code>domain.in/</code> is written.... that means only single page remains open and not affected by the url change...</p>
| javascript | [3] |
4,207,245 | 4,207,246 | Access to hyperlink in a pdf(iPhone)? | <p>I am working on a small app, which can open a pdf. My question is, if it is possible to access a hyperlink from a pdf? Because when am trying to click on hyperlink nothing is happening and it's not redirecting me to the link. I tried searching a lot but didn't got any luck on this. Am expecting a quick response as my work is getting delayed because of this issue. If it's possible then what would be the approach? Right now am using UIWebView to open the pdf. Any sample app or code will be of great help.</p>
<p>Thanks for your time .</p>
| iphone | [8] |
1,928,011 | 1,928,012 | Accessing Image Path | <p>I want to get the Path a image of the photo albums from the iPhone device. and also i need the extension of that image with their name.</p>
| iphone | [8] |
3,942,326 | 3,942,327 | why does python's list.append evaluate to false? | <p>Is there a reason being <code>list.append</code> evaluating to false? Or is it just the C convention of returning 0 when successful that comes into play?</p>
<pre><code>>>> u=[]
>>> not u.append(6)
True
</code></pre>
| python | [7] |
5,175,892 | 5,175,893 | How to add a method to a javascript object? | <p>I have my js constructor:</p>
<pre><code>Function myobj(){
This.type = "triangle";
}
</code></pre>
<p>How do I add a method to it like:</p>
<pre><code>Triangle.mymethod();
</code></pre>
| javascript | [3] |
1,890,727 | 1,890,728 | C# Using an ID to create an object in a constructor | <p>I want to create an Employee object using the constructor;</p>
<p>public Employee(int _employeeId)</p>
<p>In the body I want to read an employee from the database.
However I cannot get away with;</p>
<pre><code>using (SHPContainerEntities db = new SHPContainerEntities())
{
this = db.Employee.Where(x =>x.EmployeeId == _employeeId).SingleOrDefault() as Employee;
}
</code></pre>
<p>Because "this" is readonly.
So how do I do this?</p>
| c# | [0] |
3,308,631 | 3,308,632 | Can I emulate a click of an element by html value of it? | <p>I have this code :</p>
<pre><code><ul>
<li>Start</li>
<li>Hello my</li>
<li>name is</li>
<li>Marco</li>
</ul>
</code></pre>
<p>and I'd like to emulate che "click" of the <code><li></code> with html "Hello my", for example, without "cycle all items" and check the <code>.html()</code>. </p>
<p>So a sort of selector by html value. Is it exist in jQuery?</p>
| jquery | [5] |
1,180,716 | 1,180,717 | How to get the file type in PHP | <p>I have a <code>.doc</code> file and I renamed named it to give it a <code>.jpg</code> extension. When I process the renamed file with my function it accepts the file as having a <code>.jpg</code> although the file is not really a JPEG. What's the best way to find the actual file type? Here is my current code:</p>
<pre><code>function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
</code></pre>
<p>What's the best way to check the file's type without depending on the extension?</p>
| php | [2] |
5,665,378 | 5,665,379 | Getting events as Json through Facebook API in Java | <p>Right now I use a URL object to work with a FacebookModel object:</p>
<pre><code>public ImageIcon getIconImage(String id) throws IOException {
String url = "http://graph.facebook.com/" + id + "/picture" ;
URL pic = new URL(url);
ImageIcon icon = new ImageIcon(pic);
return icon;
}
</code></pre>
<p>I use (for image Icons) :</p>
<pre><code>public void actionPerformed(ActionEvent arg0) {
try {
center.setIcon(model.getIconImage(display.getText()));
} catch (IOException ex) {
Logger.getLogger(SubmitAction.class.getName()).log(Level.SEVERE, null, ex);
}
}
</code></pre>
<p>How can I get user's events in the same way.</p>
<p>Thanks.</p>
| java | [1] |
150,746 | 150,747 | Getting month in a string format | <p>I want to show the date in format 22-Apr-2012.
I am using this code:</p>
<pre><code> SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
sdf.applyPattern("dd MMM yyyy");
Date x = new Date(time.year,time.month,time.monthday);
System.out.println(sdf.format(x));
</code></pre>
<p>But i am getting o/p as:
22 apr 3912.
I want to know why it is showing 3912 in place of 2012.</p>
| android | [4] |
2,793,591 | 2,793,592 | Create jquery item from string without actually inserting into DOM? | <p>Is it possible to create a jquery object that I can perform jquery functions on from just a string representation?</p>
<p>I.e.</p>
<pre><code>var item = '<div>hello</div>';
???
alert(item.html());
</code></pre>
<p>I think I could do it by adding it to the DOM using <code>append()</code>, then reselecting it, but i dont really want to do that as it seems horribly ineffcient.</p>
<p>EDIT: Thanks for all the replies</p>
| jquery | [5] |
5,195,775 | 5,195,776 | FormView not updating with control events | <p>Time for my daily ASP.NET question.</p>
<p>One of my pages shows all of our customer information from a customer table. I want the user to choose whether to see all customer records, or select a specific record from a list. So, my webpage has two radio buttons (show all customers, show specific customer), a listbox (full of customer names), and a formview control. The problem I'm having is getting the formview to update when I change modes via radio buttons or listbox selection (see code below).</p>
<p>Can anyone provide me with some pointers on how to do what I'm trying to do?</p>
<pre><code>protected void Page_Load(object sender, EventArgs e)
{
UpdatePage ();
}
protected void RadioButtonShowAll_CheckedChanged(object sender, EventArgs e)
{
}
protected void RadioButtonShowSelected_CheckedChanged(object sender, EventArgs e)
{
}
protected void DropDownListCustomers_SelectedIndexChanged(object sender, EventArgs e)
{
RadioButtonShowSelected.Checked = true;
UpdatePage ();
}
protected void UpdatePage ()
{
if (RadioButtonShowAll.Checked)
SqlDataSource1.SelectCommand = "SELECT * FROM [Customer] ORDER BY [Company]";
else
SqlDataSource1.SelectCommand = "SELECT * FROM [Customer] WHERE ([CustomerID] = @CustomerID) ORDER BY [Company]";
FormView1.DataBind();
}
</code></pre>
| asp.net | [9] |
5,875,120 | 5,875,121 | Is it possible to do something *after* something has finished in Javascript? | <p>I have a simple login page and I am trying to disable the username field, password field, and the submit button while I am authenticating, reenable them after if the password/username or both are wrong or simply login otherwise.</p>
<p>I am doing that using the following code:</p>
<pre><code> // get the field values
var usernameField = document.getElementById("username");
var passwordField = document.getElementById("password");
var submit = document.getElementById("submit");
usernameField.disabled = "disabled";
passwordField.disabled = "disabled";
submit.disabled = "disabled";
// Authentication code
</code></pre>
<p>and I want everything to be disabled before the authentication code starts. For now, what it does is that when I click on the submit button, it remains "stuck" for few seconds then either logs in or simply produces the error. But it never disables anything (I made sure this is not a css problem).</p>
<p>Let me know if more info is needed.</p>
| javascript | [3] |
994,341 | 994,342 | How can I put this JavaScript into WordPress? | <p>I've got a client who is using WordPress and WooCommerce. </p>
<p>I'm trying to add a button to a file. I can get the button to show up, both in the front end editor, and in the template files. But I can't get it to function, nothing happens on hover or on click. No matter which theme I try. </p>
<p>I assume it's the way WordPress handles JavaScript, but I'm not 100% sure. What the button is supposed to do is when clicked on a pop up from myregistry.com appears and the user can then add a product to the registry. </p>
<p>I don't know very much JavaScript yet, I have used a little jQuery but mostly in the form of plugin's, with some minor changes here and there.</p>
<p>So, how could I get this to work inside of Wordpress?</p>
<p>Any help or tips would be great.</p>
<pre><code> <!-- Start AddToMyRegistry Button Tag -->
`<script id='scriptMyRegistryWebWidgetButtonScript' type='text/javascript'>`
`document.write("<img id='ImgAddToMyRegistryButton' src='http://images.myregistry.com/Images/MyRegistry/WebWidgetImages/netSol/742.jpeg' onmouseover='ImgAddToMyRegistryButton_onmouseover(this);' onmouseout='ImgAddToMyRegistryButton_onmouseout(this);' style='border-width: 0px; cursor: pointer;' onclick='CreateAddToMyRegistryWidget();' />");
function ImgAddToMyRegistryButton_onmouseover(elementParam)
{elementParam.src = 'http://images.myregistry.com/Images/MyRegistry/WebWidgetImages/netSol/742.jpeg';}
function ImgAddToMyRegistryButton_onmouseout(elementParam)
{elementParam.src = 'http://images.myregistry.com/Images/MyRegistry/WebWidgetImages/netSol/742.jpeg';}`
`</script>`
`<!-- End AddToMyRegistry Button Tag -->`
</code></pre>
| javascript | [3] |
3,878,703 | 3,878,704 | Python parse arguments from command line | <p>I have a question regarding passing arguments in Python.for Ex: in the script i am expecting arguments like</p>
<pre><code>1.python run.py -create vairbale1 -reference variable2 many more variables
2.python run.py -get -list variable many more variable
</code></pre>
<p>How can i enfore this in the script using optparse or getopt and if the arguments are invalid The i need to print Invalid arguments</p>
<pre><code> from optparse import OptionParser
parser = OptionParser()
</code></pre>
| python | [7] |
4,054,218 | 4,054,219 | Is it possible to change UIBarButtonItem title and style in runtime? | <p>In one project, I hope to change UIBarButtonItem and style in runtime</p>
<p>editBarItemButton links to a UIBarButtonItem which original status are</p>
<p>style:UIBarButtonItemStyleBordered
title:Edit</p>
<p>if I press the bar item button, it will execute the codes below:</p>
<pre><code>[editBarItemButton setStyle: UIBarButtonItemStyleDone];
[editTarBarItemButton setTitle:@"Done" ];
</code></pre>
<p>but neither the style nor title has changed.</p>
<p>Welcome any comment</p>
<p>Thanks
interdev</p>
| iphone | [8] |
1,281,440 | 1,281,441 | How to get MenuItems from Different Android application | <p>I have called "Contacts" app's EditContactActivity from MyApplication. I want to get Contextmenuitems ie ( "Send sms" , "call" , "Edit" , etc ) as menus. So i can use this menu in my application.</p>
| android | [4] |
249,069 | 249,070 | How do i go about removing 51365 from a string? | <p>Just wondering if you can help me out with something. I have a string with a series of numbers like 58498, 53980, 84578. Always 5 numbers in the series. Whats the best way to go about removing these?</p>
| php | [2] |
3,868,010 | 3,868,011 | QuickActions like the Twitter app | <p>I want to add <strong><em>Pattern 6: QuickActions</em></strong> from <a href="http://android-developers.blogspot.com/2010/05/twitter-for-android-closer-look-at.html" rel="nofollow">android's blog</a> to my app.</p>
<p>Any code snippet?</p>
<p>Anyone try to do it already? </p>
<p>Should this work on android 1.5?</p>
| android | [4] |
1,569,921 | 1,569,922 | Storing Settings for C#? | <p>I have looked at the other posts, but this question is different than them.</p>
<p>I want to store 3 values of data (Type, String, String), how would I be able to do this?</p>
<p>An example of it would be: String, "lol", "lol2".</p>
<p>I've tried both the resource settings and settings settings, but neither work. They both say the name can't be doubled.</p>
<p>This is for a Windows Form</p>
<p>Any help would be appreciated thanks.</p>
<p>And I HAVE to HAVE it in this order. Because when someone selects the method "String" from the drop-down list I have, it shows everything that has the type of String including "lol". And then lol2 should be put in a textbox after selecting the 'lol" string.</p>
| c# | [0] |
4,963,576 | 4,963,577 | How do I make my program beep in a loop? | <p>I need help with some code, what i want it to do is be able to make the computer 'beep' using the alert function ie: \a but I don't know how to implement it so that the user can choose how many times it beeps while using a switch statement, All help will genuinely be thanked.</p>
<pre><code>#include <iostream>
using namespace std;
int main()
{
int x;
int y;
cout << "Do you want to make your computer beep" << endl;
cin >> x;
if (x == 'y' || x == 'Y')
{
cout << "How many beeps do you want" << endl;
switch (y)
{
// This is the part i'm stuck on!!!
}
}
cin.ignore();
cin.get();
return 0;
}
</code></pre>
| c++ | [6] |
4,884,447 | 4,884,448 | how to replace the character? | <pre><code> $a="dir=desc&order=position&"
</code></pre>
<p>i want to replace <code>=</code> to <code>-</code>, <code>&</code> to <code>-</code>.</p>
<p>i using the following code:</p>
<pre><code> $a = str_replace('&','-',$a);
$a = str_replace('=','-',$a);
</code></pre>
<p>it now turns to <code>dir-desc-order-position-</code>. but i want to get <code>dir-desc-order-position</code>. namely, the last character replace with null <code>""</code>.</p>
| php | [2] |
1,028,126 | 1,028,127 | how to avoid camera landscape mode in android? | <p>HI</p>
<p>I am New To android, my problem is when iam capturing image programetically the camera is opening in landscape mode..Than How to Avoid it?</p>
<p>Can anyone help me</p>
<p>Thanks in advance</p>
| android | [4] |
1,619,605 | 1,619,606 | How to use mmap in python when the whole file is too big | <p>I have a python script which read a file line by line and look if each line matches a regular expression.</p>
<p>I would like to improve the performance of that script by using memory map the file before I search. I have looked into mmap example: <a href="http://docs.python.org/2/library/mmap.html" rel="nofollow">http://docs.python.org/2/library/mmap.html</a></p>
<p>My question is how can I mmap a file when it is too big (15GB) for the memory of my machine (4GB)</p>
<p>I read the file like this:</p>
<pre><code>fi = open(log_file, 'r', buffering=10*1024*1024)
for line in fi:
//do somemthong
fi.close()
</code></pre>
<p>Since I set the buffer to 10MB, in terms of performance, is it the same as I mmap 10MB of file?</p>
<p>Thank you.</p>
| python | [7] |
4,590,548 | 4,590,549 | How to view records made by a customer | <p>Sorry for my ambiguous question on the last post on this. I am developing an eCommerce website for my assignment. What I want to achieve is that when a customer logs in to his account he should be able to see his account with all the items he purchased. I am using table orders for keeping all orders. I do not get any errors. I only get the table headings I created.</p>
<p>The query i am using is :</p>
<pre><code>$result = mysql_query("SELECT orderID, cust_firstname, cust_lastname,
cust_address, cust_phone, cust_country from orders
where cust_firstname =" .$_SESSION['user_name']);
</code></pre>
<p>Please help</p>
<p>Thank you</p>
| php | [2] |
1,029,356 | 1,029,357 | overflow content of the page web is hidden | <p>I am currently developing a web browser, and I had a problem for which I can not find any solution:
When I load a web page in my webview directly from the internet it is displayed normally in the emulator
But when I go through our proxy server to load it, the overflow content of the page web is hidden, and the scrollbars are not displayed ...
tks a lot</p>
| android | [4] |
4,068,495 | 4,068,496 | Need advice new AsyncTask recursive calling | <p>I need advice is this solution acceptable and not cause overflow, I update data which read with AsyncTask, after AsyncTask finished I need to update again and again. Is this solution acceptable and safe</p>
<pre><code>private class DownloadFilesTask extends AsyncTask<URL,Integer,com.ring_view.www.json.System> {
@Override
protected com.ring_view.www.json.System doInBackground(URL... params) {
int count = params.length;
URL temp=params[0];
System system=null;
try {
system = Communicator.getSystem(temp);
} catch (LoggingConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONParsingErrorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return system;
}
protected void onProgressUpdate(Integer... progress) {
//setProgressPercent(progress[0]);
}
protected void onPostExecute(com.ring_view.www.json.System result) {
txtWorkAllowedValue.setText(result.work_allowed);
try {
new DownloadFilesTask().execute(new URL("http://test/status-system.json"));
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
</code></pre>
<p>I first time call new DownloadFilesTask().execute(new URL("http://test/status-system.json")); in OvCreate method and it works fine in emulator. Is this safe or there is some more elegant solution ?</p>
| android | [4] |
4,048,308 | 4,048,309 | Wanted to execute Php code for some particular seconds | <p>I wanted to execute a bunch of code for 5 seconds and if it has not finished executing within the specificed time frame I need to execute another piece of code..</p>
<p>Whether it's possible?</p>
<p>Ex..
There are two functions A and B</p>
<p>If A takes more than 30 seconds to execute the control should pass on to B</p>
| php | [2] |
198,465 | 198,466 | uint vs int in C# | <p>I have observed for a while that C# programmers tend to use int everywhere, and rarely resort to uint. But I have never discovered a satisfactory answer as to why.</p>
<p>If interoperability is your goal, uint shouldn't appear in public APIs because not all CLI languages support unsigned integers. But that doesn't explain why int is so prevalent, even in internal classes. I suspect this is the reason uint is used sparingly in the BCL.</p>
<p>In C++, if you have an integer for which negative values make no sense, you choose an unsigned integer.</p>
<p>This clearly signifies that negative numbers are not allowed or expected, and the compiler will do some checking for you. I also suspect in the case of array indices, that the JIT can easily drop the lower bounds check.</p>
<p>However, when mixing int and unit types, extra care and casts will be needed.</p>
<p>Should uint be used more? Why?</p>
| c# | [0] |
5,995,884 | 5,995,885 | ListView Navigation | <p>I have a basic question. On the main screen there is a listview which should navigate to another listview. It is like selecting a category then a sub-category. For each subcategory view, should I create new activity or can I pass the position value from first listview to create the appropriate just once and can navigate back again ? </p>
| android | [4] |
5,559,385 | 5,559,386 | How can I use a passed parameter in a JavaScript function? | <p>Forgive the <em>complete</em> newbie question here - I <em>know</em> this is really basic stuff, but for the life of me I can't figure it out. Javascript is relatively new to me, and this is the first time I've had to do this particular thing.</p>
<p>So, I'm trying to use a Modal to open an iframe - the page itself will have links to several modals, all of which need to be passed a different value. Rather than hardcode each of these, I'm trying to set it up in such a way that one function can be used and the links can pass the values as required.</p>
<p>The code I currently have successfully opens the modal, but a 404 error is inside it - plus the modal title shows + title + - so I guess I'm referencing it wrong (probably in the function?).</p>
<p>Heres what I've got, pointers in the right direction would be appreciated!</p>
<pre><code>function openIframe(title,url){
$.modal({
title: '+title+',
url: '+url+',
useIframe: true,
width: 600,
height: 400
});
}
</code></pre>
<p>.. and the link:</p>
<pre><code><a href="#" onclick="openIframe('Process Voucher','a_processvoucher.cfm')">Add</a>
</code></pre>
| javascript | [3] |
1,114,519 | 1,114,520 | Blocking light on a tiled level | <p>I'm making a tiled(tiles size is 16px) level scrolling game in Java.
Right now I'm dealing with the lighting system.
I calculated the light gradient(as shown on the picture) with this code for each light(yellow blocks and tiles):</p>
<pre><code>visMap = new int[level.getWidth() * level.getHeight()];
int lighted = 0;
for (int x = 0; x < level.getWidth(); x++) {
for (int y = 0; y < level.getHeight(); y++) {
double xd = (this.x >> 4) - x;
double yd = (this.y >> 4) - y;
double distance = Math.sqrt(xd * xd + yd * yd);
double p = power * 1.0;
double bright = p - distance;
visMap[x + y * level.getWidth()] = (int) (bright * power);
}
}
</code></pre>
<p>And now I'm trying to make the block somehow block the light(like in real life).
Is there a good method for this?
Thank's in advance,
Zaplik</p>
<p>The Picture: <a href="http://i.imgur.com/f0n5x.png" rel="nofollow">click</a></p>
| java | [1] |
4,297,713 | 4,297,714 | How to make Active a View inside Multiview in Clientside Javascript in Asp.net | <p>I have three views inside a Multiview
How to activate one by one view means I Just want to change the Active View Index of the Multiview using javascript in ClientSide How can i do this?</p>
| asp.net | [9] |
5,153,179 | 5,153,180 | how to add no days to date object not calendar object | <p>I have an Date object..now i want to add no of days to that date object..
so how that can be done..Actually using Calender object that can be done i know..
but in my case i haven't used calender object..instead only used date object..</p>
<p>For Example suppose i have an date object</p>
<pre><code>Date dtStartDate=o.getStartDate();
int x=28;
</code></pre>
<p>now what i want is to add 28 to this date object,means if the dtStartDate is 1 july 2011
then after adding 28,dtStartDate will be 29 july 2011.
please suggest me..</p>
<p>thanks in advance</p>
| android | [4] |
1,336,767 | 1,336,768 | jquery live search | <p>How i can i check the value of an input field continuously after it has been focused once ? (with jquery).I'm looking to make a live search and completely remove the submit button on my form. </p>
| jquery | [5] |
3,966,749 | 3,966,750 | How to get the android xml view element id attribute in java code | <p>Suppose I have an xml definition for a button with id as "@+id/send_button"</p>
<p>How I can get this id attribute value in Java code? I tried getXXX methods on AttributeSet class but doesnt provide any value which has "send_button" in it. </p>
<p>Edit1:</p>
<p>Let me make it a little bit more clear.</p>
<p>I am creating a custom View component and I want to know whats the id value that the user of this component provided in xml file.</p>
<p>Edit2:</p>
<p>I'm not using custom attributes due to a particular reason but using </p>
<pre><code><mycomponent
android:id="@+id/my_id"/>
</code></pre>
<p>Edit 3:</p>
<p>There is a getIdAttribute() method on AttributeSet but it just doesnt work. Anyone know any reason?</p>
| android | [4] |
1,800,381 | 1,800,382 | random text string | <p>I am fooling around with this function that says if you leave this text box blank than print the error code. if its not blank that print one of the text strings. The error code is working but I cannot get it to print any of the text strings. I think the problem is somewhere in returning the random selection to the html doc, I am not sure how to syntax this.
When you click the button it executes the function</p>
<pre><code>function button() {
var a = "Punf";
var b = "Relcken";
var c = "Checks in the mail";
var d = "Thae said";
var e = "Drorself";
var f = "Thertions";
var g = "Don stupid";
var err = "You think you are smarter than this website? Your not!"
if (document.getElementById('ask').value == "") {
document.getElementById('answer').innerHTML = err;
}
if (document.getElementById('ask').value == !"") {
var qoute = (a, b, c, d, e, f, g);
var maxQuote = quote.length;
var randQuote = Math.floor(Math.random() * maxQuote);
return quote(randQuote);
document.getElementById('answer').innerHTML = a;
}
}
</code></pre>
<p>I have got it down to here but I am still having issues and I am not sure why, Thanks for pointing out my rookie mistakes I need to take a step back and look at it with fresh eyes more.</p>
<pre><code>if (document.getElementById('ask').value == ""){
document.getElementById('answer').innerHTML = err;
}
var quote = [a,b,c,d,e,f,g];
var maxQuote = quote.length;
var randQuote = Math.floor(Math.random()*maxQuote);
document.getElementById('answer').value = quote[randQuote];
}
</code></pre>
| javascript | [3] |
5,625,754 | 5,625,755 | Getting nth-child of a variable full of li tags | <p>I've got a variable, let's call it $listObjects. The data of it is as followed....</p>
<pre><code><li>Data Here 1</li>
<li>Data Here 2</li>
<li>Data Here 3</li>
<li>Data Here 4</li>
</code></pre>
<p>I have tried every way I can think of, and can't find out how to get the nth-child of the list tags. Is this possible? I basically want to use nth-child(3n) on the $listObjects variable.</p>
<p>If the method above isn't possible, the $listObjects variable is being populated like so...</p>
<pre><code>var $listObjects = $data.find('li[data-type=' + $filterType + ']');
</code></pre>
<p>Would it be possible to add the nth-child(3n) to that line?</p>
| jquery | [5] |
4,738,913 | 4,738,914 | How can i display a UIAlertview On bottom portion of iphone? | <p>usually the UIAlertview appear at middle of iphone screen but i want to display it bottom of iphone.
How can i do that?</p>
| iphone | [8] |
4,174,720 | 4,174,721 | Republishing web methods in CXF | <p>I am using JAX-WS webservices using Apache CXF framework.And I am using eclipse indigo as IDE.If I publish some methods from a class,it works fine.I can create client and invoke these published web-methods.But,after that if I try to publish another web-method from that particular class from eclipse,it can not be published.Is there any work around??How can I publish more methods?</p>
| java | [1] |
5,012,694 | 5,012,695 | Why does retreiving html from inside a NOSCRIPT return htmlentities? | <p>Considering the code:</p>
<pre><code><noscript><div>FOO</div></noscript>
</code></pre>
<p>Running</p>
<pre><code>$('noscript').html();
</code></pre>
<p>returns <code>&lt;div&gt;FOO&lt;/div&gt;</code></p>
<p>but running</p>
<pre><code>$('noscript').text();
</code></pre>
<p>returns the raw html.</p>
<p>This is the opposite of what I was expecting. Is there an explanation for this?</p>
| jquery | [5] |
5,572,653 | 5,572,654 | C++: Program converting postfix to evaluation | <p>How can I convert the char in the array into an integer?</p>
<p>Ignore lines 5-100 it is just my stack.
<a href="http://ideone.com/KQytD" rel="nofollow">http://ideone.com/KQytD</a> </p>
<p>Scroll down output #2 worked properly but output #3 did not. Some how when I pushed the value back into the stack and when I popped it it had the +'43' because of the ASCII and I cannot seem to get it into a regular integer value so I can do these operations easily.</p>
<p>line 116 puts input into char postfix. NOTE: input must be in postfix notation line 117 puts the single integer value into final after it has run through the function.</p>
<p>convertPostfixToEvaluation works as such: I scroll through each index of postfix until I read in '=' then I output the total/sum. The first if statement pushed the operands (0-9) into a stack. The second if statement if it reads in an operator then it attempts to do the operation as such in lines 134-158. After the if statements I increase the index value by 1 so it can scan the entire array.</p>
<p>The issue lies within the switch where I try adding,subtracting,multiply, or dividing more than 3 operands. so the 3rd one i believe is still has the value (+43 because of the ASCII).</p>
<p>My outputs(on the bottom of my program) show what the awkwardness is.</p>
<p>The cut to the chase issue. Issue converting char to int the second time around.</p>
| c++ | [6] |
1,600,898 | 1,600,899 | JavaScript: How to pass an anonymous function as a function parameter? | <p>I would like to write a function that accepts an anonymous function as a parameter. For example:</p>
<pre><code>run('param1', function(){
alert('execute this');
});
function run(param1, callback) {
//now execute the callback parameter as a function
}
</code></pre>
<p>How can I achieve something like this?</p>
| javascript | [3] |
3,715,235 | 3,715,236 | I want to fetch contacts stored in Phone but getting problem | <p>i am using following code in order to fetch contacts from Phone
i am getting names but not number , help me to find out other fields of contacts.</p>
<pre><code>public class DialActivity extends Activity {
private ListView mContactList;
public String[] fields;
public Cursor cursor;
public boolean mShowInvisible;
public Uri uri;
public String[] projection;
public String[] selectionArgs;
public String selection;
public String sortOrder;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mContactList = (ListView) findViewById(R.id.ListView01);
// Populate the contact list
populateContactList();
}
/**
* Populate the contact list based on account currently selected in the account spinner.
*/
private void populateContactList() {
// Build adapter with contact entries
Cursor cursor = getContacts();
String[] fields = new String[] {
ContactsContract.Data.DISPLAY_NAME
};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.listrow, cursor,
fields, new int[] {R.id.TextView01});
mContactList.setAdapter(adapter);
}
/**
* Obtains the contact list for the currently selected account.
*
* @return A cursor for for accessing the contact list.
*/
private Cursor getContacts()
{
// Run query
Uri uri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME
};
String selection = ContactsContract.Contacts.IN_VISIBLE_GROUP + " = '" +
(mShowInvisible ? "0" : "1") + "'";
String[] selectionArgs = null;
String sortOrder = ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC";
return managedQuery(uri, projection, selection, selectionArgs, sortOrder);
}
</code></pre>
<p>}</p>
<p>In the above code i am using a custom ListRow layout and showing the contact name in each row, but want to populate a list which has names and corresponding number so that i can make a call on those number by clicking on that listItem. I know how to make call but i am not having the numbers.</p>
| android | [4] |
719,852 | 719,853 | "Uncaught ReferenceError: jquery is not defined" - but it is | <p>I've ready some similar questions and have verified that jquery is the first script included...</p>
<pre><code>// this test confirms that jquery is defined
if (typeof jQuery == 'undefined') {
alert('jquery not defined');
}
// (this is being alerted)
else { alert( 'jquery is defined'); }
// this is what I want to achieve (to begin with)
jquery("#free-signup").css( 'display', 'none' );
</code></pre>
<p>and jquery does seem to be defined... what am I doing wrong?!</p>
| jquery | [5] |
5,454,833 | 5,454,834 | scrollView delegates not working (scrollViewDidEndDecelerating) | <p>I am building a sort of slide show where the user slides through the images himself via a scrollView with paging enabled. i have a view controller for portrait and a view controller for landscape. The portrait view controller works fine with the "scrollViewDidEndDecelerating" function but i did the same exact thing on the landscape view controller and it does not respond.</p>
<pre><code>- (void)viewDidLoad {
[super viewDidLoad];
imageNamesArray = [[NSMutableArray alloc] initWithCapacity:LNumImages];
int x = 0;
for(x=0; x<LNumImages;x++) {
[imageNamesArray insertObject: [NSString stringWithFormat:@"kr_Page_%d.png",x+1] atIndex:x];
}
LScrollView.delegate = self;
LScrollView.pagingEnabled = YES;
LScrollView.showsHorizontalScrollIndicator = YES;
LScrollView.contentSize = CGSizeMake(LScrollWidth * LNumImages, LScrollHeight);
[self initImages:0];
}
- (void)LScrollViewDidEndDecelerating:(UIScrollView *)LScrollView {
NSLog(@"stopped");
//does not get called
//[self arangeImages];
}
</code></pre>
| iphone | [8] |
5,250,707 | 5,250,708 | how to get value? | <p>How to get current selected value of a dropdown which is inside div?
divid is divcontent
and dropdownid is country </p>
<p>code follows</p>
<pre><code><form id="frm1">
</code></pre>
<p></p>
<p>both dropdowns are ajax-generated based on some conditions. </p>
<p>Thanks in advance</p>
| jquery | [5] |
4,106,566 | 4,106,567 | to check the combination of pressed buttons | <p>I have 4 buttons (a1, a2, b1, b2). They can combinate: a1-b1; a1-b2; a2-b1; a2-b2.It means that "a1" and "a2" cann't be chosen together. So after clicking "a1" I need to block "a2".And depends on what 2 buttons were pressed, it will be differenet actions.I tried something like this</p>
<pre><code>if(a1.isPressed()|| b1.isPressed()){
a2.setClickable(false);
b2.setClickable(false);}
</code></pre>
<p>but it didn't work.</p>
<h1>Update:</h1>
<p>I tried to add boolean variable a1Boolean = false;
boolean a2Boolean = false;
And after each click `a1.setOnClickListener(new View.OnClickListener() {</p>
<pre><code> @Override
public void onClick(View v) {
a1Boolean = true;`
</code></pre>
<p>And then to check in the method </p>
<p><code>private boolean geta1_b1() {
if (a1Boolean || b1Boolean) {
a2.setClickable(false);
b2.setClickable(false);
}
return true;
}</code></p>
<p>but when I call this method before all these clicks, of corse, it didn't work, because I didn't press any buttons yet. Any ideas how to find a right decision?</p>
| android | [4] |
1,728,904 | 1,728,905 | In C# a method for turning something like C:\mydir\another\again\..\..\ into C:\mydir | <p>Is there a C# function to translate ..\s in a path so you can get the final path?</p>
| c# | [0] |
1,401,744 | 1,401,745 | how to refresh the datagridview when new rows has been added | <p>hi i am a student of c# and working in winform i have a problem here to refresh the datagridview with new values i have a mainform in which i have a datagridview the data in the datagridview is filled up with the code</p>
<p>i have a second form which is invoked from a button on the main form as <code>showdialog</code>and the main form is running behind and there is one more button on the second form which is submit button. there are some controls on the second form from then the data is inserted into the database table, the table which is connected to the datagridview of main form so i want when the form second is opened and data is filled then when submit button is pressed so after <code>this.hide();</code> when the main form is visible then the submitted data should be in the datagridview
i have searched and found that changing the datasource would result in the datagridview to refresh with new data so i tried this</p>
<pre><code>MAINSOFTWARE ms = new MAINSOFTWARE();
ms.dataGridView1.DataSource = null;
ms.dataGridView1.DataSource = ms.bindingSource1;
this.Hide();
</code></pre>
<p>but it is not refreshing the gridview with new submitted data so now is there any way to refresh?</p>
| c# | [0] |
392,383 | 392,384 | Get the instance name of this | <p>Is this possible!!?!?!?!?</p>
<p>I'm trying to make a set of classes that model a number of different types of things. Properties of these things change over time, and I want my code to be easy to maintain, so I want to do something like the following:</p>
<pre><code>public class Cat
{
public string CatName { get; set; }
public Cat()
{
this.CatName = MAGICSTUFF.GetInstanceName(this);
}
}
</code></pre>
<p>Somewhere else, when I want to get at those cats, I want to be able to say:</p>
<pre><code>[TestMethod]
public void test_awesome_cats()
{
Cat Tiger = new Cat();
Assert.IsTrue(Tiger.CatName.Equals("Tiger"));
}
</code></pre>
<p>So, I'm trying to map my naming convention into object properties. The part I can't figure out is the MAGICSTUFF.GetInstanceName. Is that a thing?</p>
<p>I suspect this is impossible, so if that's the case hopefully somebody can give me some other ideas on clever ways to use convention for this type of scenario. I've been thinking of using attributes for the Cat class for a while, but I like this was a lot better if its possible.</p>
| c# | [0] |
1,539,540 | 1,539,541 | ASP.NET Error with session key strings | <p>Hey I am trying to convert the following code to VB.NET from this webpage</p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/cc163730.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/magazine/cc163730.aspx</a></p>
<p>And have a method converted as such</p>
<pre><code>' Get the order from the session on demand
Private Shared Function GetOrderFromSession(ByVal i As Integer) As ShoppingCartOrder
Dim session As HttpSessionState = HttpContext.Current.Session
Dim ID As Integer = 0
Dim quantity As Integer = 0
' note: For simplicity session key strings are dynamically
' created——for performance reasons they should be precreated.
ID = CInt(session(ShoppingCartItemIDKeyBase + i))
quantity = CInt(session(ShoppingCartOrderQuantityKeyBase + i))
Dim item As ShoppingCartItem = ShoppingCartItem.GetItem(ID)
Return New ShoppingCartOrder(item, quantity)
End Function
</code></pre>
<p>But getting the error around the lines</p>
<pre><code> ID = CInt(session(ShoppingCartItemIDKeyBase + i))
quantity = CInt(session(ShoppingCartOrderQuantityKeyBase + i))
</code></pre>
<p>Error 1 Overload resolution failed because no accessible 'Item' can be called without a narrowing conversion:
'Public Default Property Item(index As Integer) As Object': Argument matching parameter 'index' narrows from 'Double' to 'Integer'.
'Public Default Property Item(name As String) As Object': Argument matching parameter 'name' narrows from 'Double' to 'String'. </p>
| asp.net | [9] |
3,057,716 | 3,057,717 | what is the difference between webservice and webapplication? | <p>can you please tell me what is the difference between webservice and webapplication.</p>
| asp.net | [9] |
447,432 | 447,433 | How to run my Intent if file exists | <p>I want to run my Intent if the file exists, otherwise show a message that the file is not found. This is my code</p>
<pre><code>if (!file.exists())
{
Toast.makeText(MyActivity.this, " the file not found",Toast.LENGTH_LONG).show();
}
{
Intent intent = new Intent(getApplicationContext(),BooksActivity.class );
startActivity(intent);
}
</code></pre>
| android | [4] |
1,238,015 | 1,238,016 | $(this) vs this in jQuery | <p>What is the difference between <code>$(this)</code> and <code>this</code> in jQuery ? Here are two different usage :</p>
<pre><code> $(document).ready(function() {
$("#orderedlist").find("li").each(function(i) {
$(this).append( " BAM! " + i );
});
});
$(document).ready(function() {
// use this to reset several forms at once
$("#reset").click(function() {
$("form").each(function() {
this.reset();
});
});
});
</code></pre>
| jquery | [5] |
960,407 | 960,408 | How to check if a file exist on an external server | <p>How to check if a file exist on an External Server? I have a url "http://logs.com/logs/log.csv" and I have an script on another server to check if this file exists. I tried </p>
<pre><code>$handle = fopen("http://logs.com/logs/log.csv","r");
if($handle === true){
return true;
}else{
return false;
}
</code></pre>
<p>and</p>
<pre><code>if(file_exists("http://logs.com/logs/log.csv")){
return true;
}else{
return false;
}
</code></pre>
<p>These methos just do not work</p>
| php | [2] |
2,491,725 | 2,491,726 | const keyword scope in Javascript | <pre><code>1. >>> const a = 2
2. >>> var a = 3
3. >>> a = 4
4. >>> a // print 2
</code></pre>
<p>Why the operation line 3 is allowed? const seems more "global" than without any keyword...</p>
| javascript | [3] |
4,431,247 | 4,431,248 | How can I add a Javaagent to a JVM without stopping the JVM? | <p>I wish to profile a Java application without stopping the application. Can I add a Javaagent somehow while the application is running?</p>
| java | [1] |
547,248 | 547,249 | How to position a div to stay above footer on a specific page through jQuery? | <p>I have a 2 columns page layout and I want to add a div to stay just above the footer on a specific page.</p>
<p>How can this be done through jQuery?</p>
<p>Thanks!
Vic</p>
| jquery | [5] |
1,246,218 | 1,246,219 | new Number() / Is there a better way to cast? | <p>This is for the code below which I got from <a href="http://www.javascriptkit.com/javatutors/navigator.shtml" rel="nofollow">here</a>. I'm trying to make it a bit more robust by running it through <a href="http://www.jshint.com" rel="nofollow">jshint</a> which reports that you should not use new Number().</p>
<pre><code>else if ( /Firefox[\/\s](\d+\.\d+)/.test( navigator.userAgent ) ) {
name = 'Firefox ';
version = new Number( RegExp.$1 );
if( version < 10 ) {
f_value = [ name, version ];
document.body.innerHTML = 'You are Running - ' + f_value[0] + ' ' + f_value[1] + message;
return false;
}
}
</code></pre>
| javascript | [3] |
1,897,693 | 1,897,694 | JavaScript DEBUG Issue | <p>I am trying to debug this piece of code:</p>
<pre><code> $(document).track(
{
'module' : 'Omniture',
'event' : 'instant',
'args' :
{
'linkTrackVars' : 'products,events,eVar31,eVar32,eVar33,eVar34,eVar35,eVar36,eVar37',
'linkTrackEvents' : '',
'linkType' : 'o',
'linkName' : 'Click'
'svalues' : {
'products' : ';OFFERID1[,;OFFERID2]',
'events' : 'Add',
'eVar31' : id,
'eVar32' : family,
'eVar33' : c_id,
'eVar34' : r_id,
'eVar35' : inetwork,
'eVar36' : customer,
'eVar37' : tag
},
},
'defer' : '0';
},
);
</code></pre>
<p>I am getting following error messages:</p>
<pre><code> missing } after property list
'svalues' : {\n
</code></pre>
<p>Any clue. </p>
| javascript | [3] |
4,940,967 | 4,940,968 | Begginer in java | <p>Given the following</p>
<pre><code>public class WaitTest {
public static void main(String[] args) {
System.out.print("1 ");
synchronized (args) {
System.out.print("2 ");
try {
args.wait();
} catch (InterruptedException e) {
}
}
System.out.print("3 ");
}
}
</code></pre>
<p>What is the result of trying to compile and run this program?</p>
<ol>
<li>It fails to compile because the IllegalMonitorStateException of wait() is not dealt with inline 7.</li>
<li>1 2 3 </li>
<li>1 3</li>
<li>1 2</li>
<li>At runtime, it throws an IllegalMonitorStateException when trying to wait.</li>
<li>It will fail to compile because it has to be synchronized on the this object.</li>
</ol>
<p>According me the answer should be 1,2,3 line no. 11 should get printed but the answer for this question is D why </p>
| java | [1] |
3,524,656 | 3,524,657 | java.io.FileNotFoundException: in.txt, (The system cannot find the file specified) | <p>I'm getting the following error</p>
<pre><code>java.io.FileNotFoundException: in.txt, (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at FileTest.main(FileTest.java:50)
</code></pre>
<p>Yet Im certain that I have created a in.txt file under the src, bin, and root directory. I also tried specifying the full directory in my main parameters, but still not working. Why isn't Eclipse picking it up?</p>
<pre><code>import java.io.*;
public class FileTest {
public static void main(String[] args) {
try {
String inFileName = args[0];
String outFileName = args[1];
BufferedReader ins = new BufferedReader(new FileReader(inFileName));
BufferedReader con = new BufferedReader(new InputStreamReader(System.in));
PrintWriter outs = new PrintWriter(new FileWriter(outFileName));
String first = ins.readLine(); // read from file
while (first != null) {
System.out.print("Type in a word to follow " + first + ":");
String second = con.readLine(); // read from console
// append and write
outs.println(first + ", " + second);
first = ins.readLine(); // read from file
}
ins.close();
outs.close();
} catch (IOException ex) {
ex.printStackTrace(System.err);
System.exit(1);
}
}
}
</code></pre>
| java | [1] |
3,090,562 | 3,090,563 | Is it possible to emulate Android phone on Android tablet? | <p>I have a tablet with mdpi screen (xlarge). Is it possible to emulate some other screen configurations on it? I have layouts for middle-size screens and I want to see how they will look like without using emulator (it causes a lot of pain for my PC).</p>
<p>For example, I've seen something like that on iPad (when its running iPhone apps)</p>
| android | [4] |
2,043,764 | 2,043,765 | Updating Dictionaries in Python | <p>I'm reading per line a file and creating new entries for my dictionary:</p>
<p>Suppose that the first line after parsing and splitting will have an entry like this:</p>
<pre><code>dict = {"A":{"B":1}, "G":{"P":2}}....
</code></pre>
<p>then I continue to line 2 and say there is an arbitrary lines to read:</p>
<p>And both keys "A", and "G" appeared again along with them are another entries of values:</p>
<p>Suppose the Second line contained:</p>
<pre><code>dict = {"A":{"H":10}, "G":{"L":5}}....
</code></pre>
<p>Now my question is that, whenever my program reads from a file instead of resetting the information stored for an existing key, like "A", "G". I would like to do have this instead:</p>
<pre><code>dict = {"A":{"B":1,"H":10}, "G":{"P":2,"L":5}}
</code></pre>
<p>then it should keep on updating whenever it says an existing key in the dictionary or make a new entry otherwise</p>
| python | [7] |
1,362,244 | 1,362,245 | FileNotFoundException while unzipping a file | <p>I have this code that's supposed to unzipp a file.</p>
<pre><code>public class dec extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toast.makeText(this, "hello, starting to unZipp!", 15500).show();
String location = Environment.getExternalStorageDirectory() + "/unzipped/";
/////////////////////////////////////////////////////////////////////
try {
ZipInputStream zin = new ZipInputStream(getAssets().open("totalkeys.zip"));
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
Log.v("Decompress", "My UNZIPPING: " + ze.getName());
if(ze.isDirectory()) {
dirChecker(ze.getName());
} else {
FileOutputStream fout = new FileOutputStream(location + ze.getName());
for (int c = zin.read(); c != -1; c = zin.read()) {
fout.write(c);
}
zin.closeEntry();
fout.close();
}
}
zin.close();
} catch(Exception e) {
Log.v("Decompress", "My ERROR: "+e.toString());
/// throws My ERROR: java.io.FileNotFoundException: /mnt/sdcard/unzipped/Eng_blue/altlayout.txt (No such file or directory)
/// and dies.
}
}
////////////////////////////////////////////////////
private void dirChecker(String dir) {
String location = Environment.getExternalStorageDirectory() + "/unzipped/";
File f = new File(location + dir);
if(!f.isDirectory()) {
f.mkdirs();
}
////////////////////////////////////////////////////
finish();
}
}
</code></pre>
<p>Yet it only throws "ava.io.FileNotFoundException: /mnt/sdcard/unzipped/Eng_blue/altlayout.txt" which is the name of the first file and dies.</p>
<p>I thought that dirChecker() method would create this folders on the flow... any ideas how to fix that?</p>
<p>Thanks!</p>
| android | [4] |
1,309,527 | 1,309,528 | Animation for different for Alphabets? | <p>I am preparing Alphabet App.I want prepare animations for app.I prepared some animations thought xml files .Suppose animation for "A" it takes three animation xml files.</p>
<pre><code>Is there any way to implement for animation..?
</code></pre>
<p>is there any chance image move according to coordinate ?</p>
<p>In the case of "B" how to prepared carve shape animation through xml or java.Please help me. </p>
| android | [4] |
567,453 | 567,454 | jquery to check for empty field | <p>How can i use jquery to check for the empty input field / to check if the field contains a specified string? </p>
<p>I understand that valid8(); does something similar. Any working example?</p>
| jquery | [5] |
4,939,595 | 4,939,596 | C# Action syntax | <p>I have two methods like this:</p>
<pre><code>public void ExecuteA()
{
Write();
// A specific work
Clear();
}
public void ExecuteB()
{
Write();
// B specific work
Clear();
}
</code></pre>
<p>I want to extract the Write() and Clear() methods to a new method (Action) to have something like this:</p>
<pre><code>public ASpecificWork()
{
// do A work
}
public BSpecificWork()
{
// do B work
}
Execute(BSpecificWork);
Execute(ASpecificWork);
</code></pre>
<p>The Write() and Clear() will be defined in Execute() just one time.
What's the right syntax to do so?</p>
| c# | [0] |
656,916 | 656,917 | How to install apk file on the Xperia Android mobile | <p>I want to test my build on my device. Please provide some tool/information regarding installation of application on device ? </p>
<p>thanks and regards,</p>
| android | [4] |
3,005,870 | 3,005,871 | Matrix pattern generation | <h2><strong>Hello</strong></h2>
<p>I am working on java and I have to generate all the possible patterns(combinations) of M-by-N matrices such that in the same row there should not be more than a single 1, Same column may contain more than a single 1, Taking an example of 3*3 matrix, matrices generated should look like:</p>
<pre><code>1 0 0
1 0 0
1 0 0
0 1 0
1 0 0
1 0 0
0 0 1
1 0 0
1 0 0
1 0 0
0 1 0
1 0 0
1 0 0
0 0 1
1 0 0
1 0 0
1 0 0
0 1 0
1 0 0
1 0 0
0 0 1
0 1 0
0 1 0
0 1 0
1 0 0
0 1 0
0 1 0
0 0 1
0 1 0
0 1 0
0 1 0
1 0 0
0 1 0
0 1 0
0 0 1
0 1 0
</code></pre>
<p>..... and so on.</p>
<p>As I have already said that progrom should be flexible that can generate all such possible patterns for any value of M and N.</p>
<p>Please help me..</p>
<p>Thanks! </p>
| java | [1] |
4,149,524 | 4,149,525 | how do I generate unique ids for different component created at runtime as R.java create unique for all calsses | <p>I have to impliment the same logic to generate unique ids in my project for different component created at runtime as R.java does. Some one can help me</p>
| android | [4] |
4,386,543 | 4,386,544 | code for please wait the values are loading statement is appearing when we move from one intent to another intent | <p>I am move from one intent to another intent,the another intent collects the data from our own data base so,it takes so much time for appearing .In that idle time I want to display a animation like progerss dialogue etc.pleae give me the suggestions</p>
| android | [4] |
678,748 | 678,749 | Play voice for incoming call in android | <p>Is there any way by chance to play voice for incoming call. I can able to attempt incoming call, with in that audio stream I should play voice. Is there anything to do with sdk coding?</p>
| android | [4] |
4,828,145 | 4,828,146 | jQuery: Pass anchor element to function when clicked | <p>So.. This one should be simple. I have an anchor element. When it is clicked, I want to call a function that will delete it's parent element. Essentially, it is a link to remove the parent.</p>
<p>How would I accomplish this? I have tried using the following, which is not working:</p>
<pre><code><div>
<a href='javascript:removeParent()'>Remove</a>
</div>
<script>
function removeParent() {
$( this ).parent().remove()
}
</script>
</code></pre>
<p>Can anyone help me out?</p>
<p>I'm trying to accomplish this because it is a form that can have multiple attributes... So you can add more attributes and thus need a way to remove them.</p>
<p>Cheers!</p>
| jquery | [5] |
4,951,238 | 4,951,239 | Modify the hover jquery function | <p>Consider the following:
There is a panel (let it be a div element) who's height is controlled using the hover function. The only css property that is animated is height. Both of the animations (on mouse over height+=500px; on mouse out height-=500px) have duration of 10 seconds.
Can u imagine this: douring the period of those 20 seconds, you can 'accidentally' roll the mouse in and out at least 10 times.</p>
<p>What jquery does is it remembers all that happened (with the mouse) and chains a looong list of unnecessary animations.</p>
<p>I need u guys to help me prevent this.</p>
| jquery | [5] |
1,792,237 | 1,792,238 | How can I find path to given file? | <p>I have a file, for example "something.exe" and I want to find path to this file<br>
How can I do this in python?</p>
| python | [7] |
428,954 | 428,955 | Set of Iphone sample photos | <p>Does anyone know where I can get a set of sample photos taken with an Iphone. I would like to have about 1000 of these. I am running some tests on image compression algorithms. </p>
<p>Cheers</p>
| iphone | [8] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.