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 |
|---|---|---|---|---|---|
1,918,477 | 1,918,478 | Handling orientation changes yourself | <p>From the documentation regarding the <code>android:configChanges='orientation'</code> attribute of the activity tag in the manifest:</p>
<blockquote>
<p>Note: Using this attribute should be avoided and used only as a last-resort. Please read Handling Runtime Changes for more information about how to properly handle a restart due to a configuration change.</p>
</blockquote>
<p>Why does it say this? </p>
<p>In the case of threads and networking requests via a service API library, a request could be made with a reference to the original Activity, and then an orientation change could occur, leaving the thread pointing to the old Activity.</p>
<p>While this can be fixed, it's tedious and ugly compared to just handling the configuration changes yourself.</p>
<p>Why should it be avoided?</p>
<p>Edit: I guess I should also ask: would this be an acceptable reason for doing the orientation configuration changes yourself?</p>
| android | [4] |
5,164,921 | 5,164,922 | Is there a master UI element that controls all subviews? | <p>If you have a seperate UIViewcontroller for each screen, along with its own NIB file, what is the master UI control that is controlling which viewcontroller to fire up and when?</p>
<p>Is this the job of the Controller and there is no master UI object that manages this?</p>
<p>I am very new, so maybe I need to understand things from the ground up, any links would be appreciated!</p>
| iphone | [8] |
5,916,377 | 5,916,378 | Change one character in a string in python? | <p>What is the easiest way in python to replace a character in a string like: </p>
<pre><code>text = "abcdefg";
text[1] = "Z";
^
</code></pre>
| python | [7] |
3,503,448 | 3,503,449 | Reference and datatype checking, are these the same? | <p>I have a simple function in my library that checks the validity of an object reference (object here meaning, a reference to a created HTML element, mostly DIV's). It looks like this:</p>
<pre><code>function varIsValidRef(aRef) {
return ( !(aRef == null || aRef == undefined) && typeof(aRef) == "object");
}
</code></pre>
<p>While experimenting i found that this has the same effect:</p>
<pre><code>function varIsValidRef(aRef) {
return (aRef) && typeof(aRef) == "object";
}
</code></pre>
<p>I understand there are some controversies regarding the short hand () test? While testing against various datatypes (null, undefined, integer, float, string, array) i could find no difference in the final outcome. The function seem to work as expected.</p>
<p>Is it safe to say that these two versions does the exact same thing?</p>
| javascript | [3] |
5,674,133 | 5,674,134 | Cannot call derived class method in a function that takes base class as parameter | <p>I have the following problem:</p>
<pre><code>class A {
void f() {}
}
class B extends A {
void g() {}
}
class C extends A {
void h() {}
}
void foo(A temp)
{
temp.g();
}
</code></pre>
<p>I want my foo() function to take a base class parameter, so I can work with B & C. But inside the funciton I have a call to a derived class method, so of course I get an error.<br>
I also tried this inside the foo function:</p>
<pre><code>if(temp instanceof B)
{
B somevar = (B)temp;
}
else if( temp instanceof C)
{
C someVar = (C)temp;
}
someVar.g();
</code></pre>
<p>But still I have a compile errors that it doesnt know who someVar is. How could I make this to work ? </p>
<p>Thanks.</p>
| java | [1] |
3,804,057 | 3,804,058 | Data appears in the simulator but not in the device | <p>I have developed a simple To-Do application with a simple database.problem is that my database only shows data in the simulator.when I load it to the phone,it doesn't show up the data.the console shows an error message saying "My table doesn't exists".hope someone can help me coz it's critical....</p>
<p>Thanks.</p>
| iphone | [8] |
611,852 | 611,853 | anonymous functions javascript, how to access source code? | <p>I got some JS Code that gets inside a random Anonymous js function.
I want that code (for example <code>alert('hello')</code> ) to dump/alert
the entire script block/object which it was injected into. </p>
<p>kinda like document.body.innerHTML but for the anonymous function block </p>
<p>result should be like :</p>
<pre><code>Function()({ somecode; MyAlert(...) } )()
</code></pre>
<p>or</p>
<pre><code>Try { some code; mycode; } catch(e) { }
</code></pre>
| javascript | [3] |
3,947,150 | 3,947,151 | Is there a way to move row to the selected row in UITableView | <p>I hope to know if there is a way to move row to the selected row in UITableView.</p>
<p>for example, row are:</p>
<p>1
2
3
4
5
6
7
8</p>
<p>only 3 rows are visible,</p>
<p>I hope to move row directly to 7</p>
<p>Welcome any comment</p>
<p>Thanks</p>
<p>interdev</p>
| iphone | [8] |
509,352 | 509,353 | android, is there something like "while key down"? | <p>I want my clickable ImageView to change its image while it is being pressed and return back to its original image when it is no longer being pressed. What do you think might be the best way for that?</p>
<p>Thanks!</p>
| android | [4] |
1,341,927 | 1,341,928 | Recursive function taking ages to run | <p>I profiled my code and found that my program spent roughly 85% of the time executing this particular recursive function. The function aims to calculate the probability of reaching a set of states in a markov chain, given an initial position (x,y). </p>
<pre><code>private static boolean condition(int n){
int i = 0;
while ( n >= i){
if( n == i*4 || n == (i*4 - 1))
return true;
i++;
}
return false;
}
public static double recursiveVal(int x, int y, double A, double B){
if(x> 6 && (x- 2 >= y)){ return 1;}
if(y> 6 && (y- 2 >= x)){ return 0;}
if(x> 5 && y> 5 && x== y){ return (A*(1-B) / (1 -(A*B) - ((1-A)*(1-B))));}
if(condition(x+ y)){
return (recursiveVal(x+1, y,A,B)*A + recursiveVal(x, y+1,A,B)*(1-A));
}
else{
return (recursiveVal(x+1, y,A,B)*(1-B) + recursiveVal(x,y+1,A,B)*B);
}
}
</code></pre>
<p>I was once told that 99% of recursive functions could be replaced by a while loop. I'm having trouble doing this though. Does anyone know how I could improve the execution time or rewrite this as a iterative loop?</p>
<p>Thanks</p>
| java | [1] |
1,412,953 | 1,412,954 | int64_t conversion to 'long double' issue | <p>The following code produces the shown output and I'm confused ... I'm using Intel compiler version 2013 beta update 2 <code>/opt/intel/composer_xe_2013.0.030/bin/intel64/icpc</code>:</p>
<pre><code>// all good
int64_t fops_count1 = 719508467815;
long double fops_count2 = boost::static_cast<long double>(fops_count1);
printf("%" PRIu64 "\n", fops_count1); // OK outputs 719508467815
printf("%Le\n", fops_count2); // OK outputs 7.195085e+11
// bad! why this?
int64_t fops_count1 = 18446743496931269238;
long double fops_count2 = boost::static_cast<long double>(fops_count1);
printf("%" PRIu64 "\n", fops_count1); // OK outputs 18446743496931269238
printf("%Le\n", fops_count2); // FAIL outputs -5.767783e+11 <<<<<<<<<<<<<<<<< WHY?
</code></pre>
| c++ | [6] |
3,643,174 | 3,643,175 | how can I make the mouse to position at clicked position of the imageview.? | <p>While I drag an <code>uiimageview</code>, the center is positioned at clickpoint..I am using the following code</p>
<pre>
imageView.center=[[touches anyObject] locationInView:self.view];
</pre>
<p>so the mouse jumps to image center even I drag at the corner.</p>
<p>How can I make the mouse to position at clicked position of the imageview.??? </p>
<p>Thanx in advance</p>
| iphone | [8] |
2,257,395 | 2,257,396 | Ignoring unhandled exception for deprecated comment error in mcrypt.ini | <p>I made a web application that is hosted on a external server, now i'm getting the following error:</p>
<pre><code>Unhandled Exception
Message:
Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1
Location:
Unknown on line 0
</code></pre>
<p>I know that it's an easy fix to just change the # to ; in mcrypt.ini but the hosting service doesn't want to change the file and the only thing that they want to do is upgrade the server which they say that I have to pay for...</p>
<p>Is there a way in my web app that i can ignore errors like this?</p>
<p>I tried error_reporting(0); but this does not seem to work.</p>
| php | [2] |
5,860,017 | 5,860,018 | jQuery dependencies | <p>I have the following code:</p>
<pre><code>function drawDimensions(divid) {
// This function gets a JSON file, loops through the JSON code using $.each and fills the divid with parsed JSON content
}
</code></pre>
<p>On the other hand, I have 2 functions that allows me to toggle the menu and submenus by using <code>$.toggle()</code>.</p>
<p>What should I be loading under <code>$(document).ready(function() { });</code>?</p>
<p>At the moment, I'm loading the drawDimensions <strong>and</strong> the toggle functions under it, but the toggle does not work. Do I need to load them in a certain order within the document ready function? Does it matter?</p>
<p><strong>Note</strong>: toggle functions work if I disable the drawDimensions and simply attach the output html to the code.</p>
| jquery | [5] |
1,491,247 | 1,491,248 | python find index of of item in list | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8115015/python-two-lists-finding-index-value">Python two lists finding index value</a> </p>
</blockquote>
<pre><code>listEx = ['cat *(Select: "Standard")*', 'dog', 'cow', 'turtle *(Select: "Standard")*', 'onion', 'carrot *(select: "Standard")*']
listEx2 = ['house', 'farm', 'cottage', 'cat', 'turtle', 'computer', 'carrot']
for i in listEx2:
for j in ListEx:
if i in j:
print listEx.index(listEx2[i] in listEx[j])
</code></pre>
<p>Here is what I am attempting to do. For the items in <code>listEx2</code>, I want to find the index of the item in <code>listEx</code>, where the item in <code>listEx2</code> was found in <code>listEx</code>. I would like the script to print out the index of the item in <code>listEx</code> with the name.</p>
<p>Thanks!</p>
| python | [7] |
150,471 | 150,472 | How to call a static method of a class using method name and class name | <p>Starting with a class like this:</p>
<pre><code>class FooClass(object):
@staticmethod
def static_method(x):
print x
</code></pre>
<p>normally, I would call the static method of the class with:</p>
<pre><code>FooClass.static_method('bar')
</code></pre>
<p>Is it possible to invoke this static method having just the class name and the method name? </p>
<pre><code>class_name = 'FooClass'
method_name = 'static_method'
</code></pre>
| python | [7] |
2,612,944 | 2,612,945 | Python: how can I get rid of the second element of each sublist? | <p>I have a list of sublists, such as:</p>
<p>[[501, 4], [501, 4], [501, 4], [501, 4]]</p>
<p>How can I get rid of the second element for each sublist ? (i.e. 4)</p>
<p>[501, 501, 501, 501]</p>
<p>Should I iterate the list or is there a faster way ?
thanks</p>
| python | [7] |
906,362 | 906,363 | Parsing url from xml file? | <p>I have a xml file having the tags like</p>
<pre><code><link>
<linkto>http://www.ezstream.com/broadcasts/index.cfm?fuseaction=usrbrd&broadcasterid=57468</linkto>
<image>report_button</image>
<alt>Report a Problem</alt>
<target></target>
</link>
</code></pre>
<p><code><linkto></code> tag have the url. But because of the "&" symbol in the url thats completely crashing the page. I tried using like </p>
<p>amp; next to the & symbol but this doesn't give the correct url. PLease help me </p>
<p>Thanks </p>
| asp.net | [9] |
431,477 | 431,478 | Corrupt file when using Java to download file | <p>This problem seems to happen inconsistently. We are using a java applet to download a file from our site, which we store temporarily on the client's machine. </p>
<p>Here is the code that we are using to save the file:</p>
<pre><code>URL targetUrl = new URL(urlForFile);
InputStream content = (InputStream)targetUrl.getContent();
BufferedInputStream buffered = new BufferedInputStream(content);
File savedFile = File.createTempFile("temp",".dat");
FileOutputStream fos = new FileOutputStream(savedFile);
int letter;
while((letter = buffered.read()) != -1)
fos.write(letter);
fos.close();
</code></pre>
<p>Later, I try to access that file by using:</p>
<pre><code>ObjectInputStream keyInStream = new ObjectInputStream(new FileInputStream(savedFile));
</code></pre>
<p>Most of the time it works without a problem, but every once in a while we get the error:</p>
<pre><code>java.io.StreamCorruptedException: invalid stream header: 0D0A0D0A
</code></pre>
<p>which makes me believe that it isn't saving the file correctly.</p>
| java | [1] |
145,809 | 145,810 | Identifying market and non market apps on android device | <p>I want to filter market and non market applications installed on android device.How can I do this...</p>
<p>Thanks,
Prateek</p>
| android | [4] |
363,914 | 363,915 | iPhone, how do I draw a simple line graph from an array of prices and dates? | <p>I'm looking for some very simple to develop line graph library. However, all the examples seem quite complicated. I have a database with two main fields, date and value.</p>
<p>Can anyone point me at or provide me with an example of code which will do just that ?</p>
| iphone | [8] |
3,825,943 | 3,825,944 | Hide folder with photos on sd card | <p>I save pictures to my application on sd card. When I go to gallery I can see that pictures. How I can save pictures which I use in application on sd card but they must be invisible in gallery from phone.</p>
| android | [4] |
3,340,005 | 3,340,006 | How to make variable in method global? | <p>For example I have a method like this. If you see the String 'tablenumber' I want to be able to use it in a later function such as a onclick button so I can send the contents of it to a different activity. But if I use this variable outside the method it's not recognised. How do I go about this.</p>
<pre><code>{
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
String tablenumber = (String) arg0.getSelectedItem();
}
public void onNothingSelected(AdapterView<?> arg0) {
}
});
</code></pre>
| android | [4] |
5,980,105 | 5,980,106 | jQuery navigation: call only one function at a time? | <p>I have 3 buttons each calling a function that animates the different content into view. If the user is quick they can click 2 buttons, this messes with the animation temporary. How can I call only one function at a time?</p>
<p>The display is set to inline-block from none to make the content visible, the means when 2 animations are playing they align next to each other.</p>
<p>Here is my code for one of the functions, the 2nd is identical except the element ID's correspond with what I need moved. Each button calls one of these functions.</p>
<pre><code>function mepage(){
var ele = document.getElementById("btn2");
var ele = document.getElementById("btn3");
var mecont = document.getElementById("mecontent");
if ($(ele).is(':visible'))
{
$("#btn2,#btn3").slideUp(1000, function() {
$("#mecontent").fadeIn(800).css("display","inline-block");
});
}
else {
$("#mecontent").fadeOut(800, function() {
$("#mecontent").css("display","none");
if(ele.style.display == "none"){
$("#btn2,#btn3").slideDown(1000);
}});
}
}
</code></pre>
| jquery | [5] |
5,356,092 | 5,356,093 | Setting a nibble of a 32-bit integer to a certain value | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/14427737/setting-the-nibble-for-an-int-java">Setting the nibble for an int - java</a> </p>
</blockquote>
<p>I am stuck on how to replace a 4-bit value to a certain position of an original 32-bit integer. All help is greatly appreciated!</p>
<pre><code>/**
* Set a 4-bit nibble in an int.
*
* Ints are made of eight bytes, numbered like so:
* 7777 6666 5555 4444 3333 2222 1111 0000
*
* For a graphical representation of this:
* 1 1 1 1 1 1
* 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |Nibble3|Nibble2|Nibble1|Nibble0|
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Examples:
* setNibble(0xAAA5, 0x1, 0); // => 0xAAA1
* setNibble(0x56B2, 0xF, 3); // => 0xF6B2
*
* @param num The int that will be modified.
* @param nibble The nibble to insert into the integer.
* @param which Selects which nibble to modify - 0 for least-significant nibble.
*
* @return The modified int.
*/
public static int setNibble(int num, int nibble, int which)
{
int shifted = (nibble << (which<<2));
int temp = (num & shifted);
//this is the part I am stuck on, how can I replace the original
// which location with the nibble that I want? Thank you!
return temp;
}
</code></pre>
| java | [1] |
3,055,415 | 3,055,416 | convert unsigned int *' to 'unsigned int *& | <p>I have a function which gets 'unsigned int *& argument
The parameter I want to transfer in my code is located in the <code>std::vector<unsigned int> data</code>
So,what I do is : I transfer the following parameter &data[0]
But get the compilation error:</p>
<pre><code>unsigned int *' to 'unsigned int *&
</code></pre>
<p>What can be a work around?
Thanks,</p>
| c++ | [6] |
2,852,803 | 2,852,804 | Find and copy FORM tag | <p>I need to find a form tag within an element and copy it. I feel I'm close but not quite there yet. He's what I've got so far:</p>
<p><strong>JS</strong></p>
<pre><code>if ($('#myElement').find('form').length > 0) {
var myFormTag= $('#myElement').find('form').html();
}
</code></pre>
<p><strong>HTML</strong></p>
<pre><code><div id="myElement">
<h1>
blah
</h1>
<form action="blah.php" method="post">
<table>
<tr>
<td>
<select>
<option>option
</select>
</td>
<td>
<input type="text">
</td>
</tr>
</table>
</form>
</div>
</code></pre>
<p>I just need to return the opening tag:</p>
<pre><code><form action="blah.php" method="post">
</code></pre>
| jquery | [5] |
5,302,142 | 5,302,143 | search for a string | <p>I want to search in large piece of texts for different strings and if the match found for each string it return me a special string (not the matched string).</p>
<p>there are almost 150 different string I want to search them in the thousand text files.
I write this code </p>
<pre><code>foreach($countries as $cont)
{
if(stripos($text,$cont))
{
$country=$cont;
</code></pre>
<p>and here is a few line of countries.php (I include this file) :</p>
<pre><code>$countries['AD'] = 'Andorra';
$countries['AE'] = 'United Arab Emirates';
$countries['AF'] = 'Afghanistan';
$countries['AG'] = 'Antigua And Barbuda';
$countries['AI'] = 'Anguilla';
$countries['AL'] = 'Albania';
</code></pre>
<p>For example I want to print 'Arabian' when it was a match for 'United Arab Emirates'...</p>
| php | [2] |
5,371,426 | 5,371,427 | Speed up .net assembly load time during development | <p>I am working on a large (100s of assemblies) asp.net application and during development it can take a couple of minutes for the first page to load after a recompile. </p>
<p>I am told that much of the delay comes from JITing the assemblies and that this delay is proportional to the number (but not the size) of assemblies. I have not yet measured this. </p>
<p>We are working on architectural changes to improve the situation (combine assemblies, decouple applications) but I was wondering if there are any quick hit fixes that I can get by, for example, changing IIS settings in development or combining DLLs post-build.</p>
<p>We are using .net 3.5.</p>
<p>Any suggestions for me?</p>
| asp.net | [9] |
2,130,840 | 2,130,841 | Is there a way to monitor and record which applications have started recently? | <p>I would like to know which applications the user has started within the last, say, 24hours. Is this possible?</p>
| android | [4] |
1,511,076 | 1,511,077 | How to calculate when current pay period ends? | <p>I want to know how to calculate the last date of this pay period?</p>
<p>I know that the pay is bi-weekly and the first period started on 01/09/2012.
so far here what i have done </p>
<pre><code> DateTime d = new DateTime();
d = Convert.ToDateTime("01/09/2012");
while (d <= Convert.ToDateTime("01/06/2013")) {
PayPeriod.Items.Add(new ListItem(d.ToString("MM/dd/yyyy"), d.ToString("MM/dd/yyyy")));
d = d.Date.AddDays(14);
}
</code></pre>
<p>And this work perfect, but it work perfect because I have manually put the ending of the current pay period "01/06/2013".</p>
<p>My question is how can I automatically figure out the last date of the current pay period?</p>
| c# | [0] |
1,639,279 | 1,639,280 | Send image over socket in iPhone | <p>How can i send image over socket in iPhone. I tried with string the code i used is as follows, now i need to send image over socket. </p>
<pre><code>CFWriteStreamRef writeStream = NULL;
CFStringRef host = CFSTR("192.168.1.211");
UInt32 port = 8001;
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, host, port, NULL, &writeStream);
CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
if(!CFWriteStreamOpen(writeStream)) {
NSLog(@"Error Opening Socket");
}
else{
UInt8 buf[] = "Abc";
int bytesWritten = CFWriteStreamWrite(writeStream, buf, strlen((char*)buf));
NSLog(@"Written: %d", bytesWritten);
if (bytesWritten < 0) {
CFStreamError error = CFWriteStreamGetError(writeStream);
}
}
</code></pre>
<p>Regards,</p>
| iphone | [8] |
1,989,452 | 1,989,453 | How to append new content to td | <p>I have a <code><td></code> that currently has some content in it. I would like to append some new data to the end of the current content.
My <code><td></code> has an id of <code>#imglist</code></p>
<p>Thanks for any help.</p>
| jquery | [5] |
2,151,519 | 2,151,520 | WAP push messages in android | <p>Anybody know which permission is used for receiving the WAP push messages in android ?
and please let me know its description also.</p>
<p>Regards,
Parvathi</p>
| android | [4] |
1,230,783 | 1,230,784 | Using declaration for a class member shall be a member declaration (C++2003) | <p>Paragraph 7.3.3. of C++2003 standard states that</p>
<blockquote>
<p>Using declaration for a class member shall be a member declaration.</p>
</blockquote>
<p>This means that the following gives a syntax error:</p>
<pre><code>struct S1
{
static int var1;
};
using S1::var1;
</code></pre>
<p>While the following compiles fine:</p>
<pre><code>namespace N2
{
int var2;
}
using N2::var2;
</code></pre>
<p>Does anybody know the rationale (if any) behind that?</p>
<p>Even more, the standard gives explicit example with static data member of the struct and tells that it should cause syntax error. MS C++ gives this error:</p>
<blockquote>
<p>cpptest1.cxx(9) : error C2885: 'S1::var1': not a valid using-declaration at non-class scope</p>
</blockquote>
<p>It is still not clear why this should be banned.</p>
| c++ | [6] |
1,764,423 | 1,764,424 | Searching for a parser or engine that can separate cities, country, product types and options from a query | <p>I have a need for a search engine that can parse a string into multiple sub-query (if that make sense).</p>
<p>Similar to those search engine where you can type <code>Casino in Las vegas</code> and it will retrieve the Casinos in Las Vegas.</p>
<p>I have to make a search engine that parse sentence like <code>B&B in Quebec with folding bed and breakfast</code> into</p>
<pre><code>{
type: { "B&B" },
location: { "Quebec" },
option: { "folding bed", "breakfast" }
}
</code></pre>
<p>So before I try to invent the wheel, I'd like to know if something like that exists in either open-source or commercial.</p>
| c# | [0] |
4,106,459 | 4,106,460 | jQuery Div Slider With Thumbnail Nav | <p>I'm looking for a slider that has a thumbnail nav, but the thumbnail nav also needs to be on a slider to accommodate a large number of items.</p>
<p>Can anyone point me to a site that may have a demo.</p>
| jquery | [5] |
3,175,976 | 3,175,977 | Do PHP printer functions work on a live server? | <p>I used printer functions in PHP to print data. It works on my local development server (localhost),
but it is not working in a live environment.
Is it possible to use the PHP printer functions on a live web server?</p>
| php | [2] |
3,554,580 | 3,554,581 | How to close parent activity within child activity? | <p>How do I close a parent activity from a child activity?</p>
| android | [4] |
4,131,280 | 4,131,281 | StringWithFormat min width | <p>I know that this is possible, but can't seem to find it. I need to format a string (using stringWithFormat) with 3 0's when the value is <100.</p>
<p>So my integer i = 5, the string should be @"005", but I can't remember or find the format specifier to make this happen.</p>
<p>Hopefully this is low hanging fruit.</p>
<p>Thanks!</p>
| iphone | [8] |
50,151 | 50,152 | android: iTelephony | <p>I am working on Android 2.2/2.3 and need to use some of the api's provided by iTelephony. </p>
<p>I have tried few ways to access some of the hidden APIs but it doesn't work. </p>
<p>Please let me know if anyone has attempt successfully or any suggestions are welcome.</p>
<blockquote>
<p>Exception encountered: WARN/System.err(827): java.lang.NoSuchMethodException: getActiveCallsCount</p>
</blockquote>
<p>Eg. <code>getActiveCallsCount(); getHoldCallsCount(); getCallTime() etc...</code></p>
<p>Here is my sample code :</p>
<pre><code>private void getActiveCallCounts() {
try {
Class serviceManagerClass = Class.forName("android.os.ServiceManager");
Method getServiceMethod = serviceManagerClass.getMethod("getService", String.class);
Object phoneService = getServiceMethod.invoke(null, "phone");
Class ITelephonyClass = Class.forName("com.android.internal.telephony.ITelephony");
Class ITelephonyStubClass = null;
for (Class clazz : ITelephonyClass.getDeclaredClasses()) {
if (clazz.getSimpleName().equals("Stub")) {
ITelephonyStubClass = clazz;
break;
}
}
if (ITelephonyStubClass != null) {
Class IBinderClass = Class.forName("android.os.IBinder");
Method asInterfaceMethod = ITelephonyStubClass.getDeclaredMethod("asInterface", IBinderClass);
Object iTelephony = asInterfaceMethod.invoke(null, phoneService);
if (iTelephony != null) {
Method getActiveCallsCountMethod = iTelephony.getClass().getMethod("getActiveCallsCount");
Integer output= getActiveCallsCountMethod.invoke(iTelephony);
System.out.println("got call count.. " + output.intValue());
} else {
Log.w("TTT", "Telephony service is null, can't call "
+ "getActiveCallsCount");
}
} else {
Log.d("TTT", "Unable to locate ITelephony.Stub class!");
}
} catch (Exception ex) {
ex.printStackTrace();
Log.e("TTT", "Failed to get active call count due to Exception!" + ex.getMessage());
}
}
</code></pre>
| android | [4] |
1,053,081 | 1,053,082 | Using subprocess to log print statements of a command | <p>I am running a Transporter command, which prints a log of what is happening to the prompt. </p>
<p>How would I re-direct all the print statements to a separate file called <code>transporter_log.txt</code> in the same folder as the script is running from? Something like - </p>
<pre><code>log_file = open(PATH, 'w')
subprocess.call(shlex.split("/usr/local//iTMSTransporter -m verify...")
log_file.write(...)
</code></pre>
| python | [7] |
4,271,532 | 4,271,533 | Modify inline image inline style with PHP Simple HTML DOM Parse | <p>I have an image with source that looks like</p>
<p><code><img alt="" src="./userfiles/images/Water%20lilies(1).jpg" style="width:800px;height:600px;" /></code></p>
<p>I'd like to find out if the width is greater than 750px if yes the need to change the style="width: xxx" to be style="width: 750px;"</p>
<p>Is this possible with the Simple DOM?</p>
<p>All i can do now it to set the width of the image which doesnt seem to work because the style overwrites it</p>
<p><code>foreach($content->find('img') as $element) {
$element->width = '750';
}</code></p>
| php | [2] |
201,061 | 201,062 | Get a text block from a url | <p>forexample, I have this url:</p>
<p><code>http://adstorage.jamba.net/storage/view/325/0/fa/Fairytale.mp3</code></p>
<p>How can I use PHP code so that it returns <code>Fairytale</code>. all the things before <code>Fairytale</code> and after that <code>.mp3</code> should be removed.</p>
<p>the idetifier are <code>/</code> and <code>.mp3</code> only the <code>file name</code> should be returned.</p>
| php | [2] |
1,574,092 | 1,574,093 | Problem Exporting DataGrid to Excel | <p>I first got an error usign the code below, explaining that "DataGridLinkButton' must be placed inside a form tag with runat=server."</p>
<p>Now I've tried setting AllowSorting to false, as well as removing the sort expression from each column, with the same error. Then I tried creating a new, plain, DataGrid, with the same data source, but now I get a blank page and FF doesn't recognise the content type properly any more. Please help.</p>
<pre><code>Response.Clear();
base.Response.Buffer = true;
base.Response.ContentType = "application/vnd.ms-excel";
base.Response.AddHeader("Content-Disposition", "attachment;filename=file.xls");
base.Response.Charset = "";
this.EnableViewState = false;
StringWriter writer = new StringWriter();
HtmlTextWriter writer2 = new HtmlTextWriter(writer);
this.lblExport.RenderControl(writer2);
base.Response.Write(writer.ToString());
</code></pre>
| asp.net | [9] |
4,426,622 | 4,426,623 | Reading PayWave (ISO14443-B format) track information through Android 2.3.3 NFC | <p>I'm trying to <strong>Read Track data for Payment cards</strong> (<em>PayWave, PayPass</em>). As per my understanding they follow <strong><em>ISO 14443 B</em></strong>.
With new NFC API,</p>
<ol>
<li>i can connect with IsoDep format without any exception thrown</li>
<li>call getHiLayerResponse() - returns nothing :(. Now what?</li>
</ol>
<p>Later i tried to call transceive() method, but all in vain (i don't know the <strong>APDU</strong> commands). </p>
<p><strong>Can someone help me how to read/get track details of PayWave or PayPass cards (payment cards)?</strong></p>
<pre><code>if ( NfcAdapter.ACTION_TAG_DISCOVERED.equals(action) ) {
Parcelable nfcTag = intent.getParcelableExtra("android.nfc.extra.TAG");
Tag t = (Tag)nfcTag;
IsoDep myTag = IsoDep.get(t);
String s1 = null, s2 = null;
byte[] b1 = myTag.getHiLayerResponse(); //b1 is not null, but length == 0
if( b1 != null && b1.length > 0 )
s1 = new String(b1);
byte[] b2 = myTag.getHistoricalBytes(); //returns nothing coz its NfcB
if(b2 != null && b2.length > 0)
s2 = new String(b2);
if( !myTag.isConnected() )
{
myTag.connect();
String sData = "0xBB"; // got this magic value from web
byte []data = sData.getBytes();
result = myTag.transceive(data);
if(result != null && result.length > 0)
{
s3 = new String(result); // value of s3 will be "m"
}
}
}
</code></pre>
<p><strong>Any help will be great, please shed some light... Thanks in Advance</strong></p>
| android | [4] |
1,594,036 | 1,594,037 | Best method for intersecting a time list with a time range list | <p>Basically what I have is this:</p>
<pre><code>secondData = [["8:33:00", 5], ["8:33:01", 3], ...] # and so forth
minuteData = [["8:33:00", 6], ["8:34:00", 5], ...] # and so forth
</code></pre>
<p>Now pretend like the time is an actual datetime object</p>
<p>What I want to do is find the most efficient method for iterating through the minute data and getting all the contained second data for that minute. e.g. if I have "8:34:00" I want "8:34.00".."8:34:59". Is there an easy way to make a list filter for this or something?</p>
<p>I should note that the lists are arranged in order of time, however there might be missing second data. I might only have 33 data points for the minute 9:58 for example.</p>
| python | [7] |
5,421,329 | 5,421,330 | How do you properly setup pyssh (PYTHON) | <p>I'm trying to test out pyssh, but I'm having trouble importing it.
I'm new to python so I'm not sure how to get this thing to import properly.</p>
<p>What do I have to do before I can import pyssh 0.3 into my code?</p>
| python | [7] |
1,745,469 | 1,745,470 | How to change the TabHost back ground color | <p>I am doing android application using Tab Host. I want to change the background color instead of giving default color from android operating system. i google this issue i got some solution and i made coding.</p>
<pre><code> for (i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) {
mTabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.LTGRAY);
}
mTabHost.getTabWidget().getChildAt(mTabHost.getCurrentTab()).setBackgroundColor(Color.parseColor("#000000"));
</code></pre>
<p>In this code the first tab getting change of color whenever i click the another(ie next tab) Tab the color will not change. if anyone have idea of this particular issue, ple guide me. </p>
| android | [4] |
5,872,972 | 5,872,973 | iphone iframe question | <p>is it possible to add an iframe to an iphone web page. I tried adding a standard iframe with height and width 100% however when i use them to display them in the simulator from the local files i cant scroll even after setting scrolling to auto. IS this a limitation of the simulator or am i making a mistake somewhere. im using this code</p>
<pre><code> <iframe src ="http://moodle.acs.gr" width="100%" height="90%" scrolling="auto">
</code></pre>
<p>iframes.</p>
<p></p>
| iphone | [8] |
4,288,911 | 4,288,912 | HTML and ASP Button Conflict on IE | <p>I got a problem using two types of button on IE.
For this test i created a ASP.NET webpage in Visual Studio and added the code below inside Default.aspx</p>
<pre><code> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<form action="#" method="post">
<input type="submit" name="test" value="Test!" class="button" title="Subscribe" />
</form>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
Hello <asp:Label ID="l1" runat="server" Text=""></asp:Label>
</asp:Content>
</code></pre>
<p>The problem happens when i try to use the asp:button. It won´t work (no postback).</p>
| asp.net | [9] |
1,139,142 | 1,139,143 | datepicker opens after ajax call on second click? how to open it on first click? | <p>before ajax call I write the code for date picker is:</p>
<pre><code><script type="text/javascript">
$(function() {
$("#birthdate").focus(function() {
$(this).datepicker().datepicker( "show" )
});
});
$(function() {
$("#joindate").focus(function() {
$(this).datepicker().datepicker( "show" )
});
});
</script>
</code></pre>
<p>this function called after onfocus event: </p>
<pre><code><tr>
<td align="left">
<input type="text" id="birthdate" name="birthdate" onfocus="$('#birthdate').datepicker({changeMonth: true,changeYear: true,dateFormat: 'dd/mm/yy',defaultDate: '-20y -1m -247d',yearRange: '-50:+0'});" tabindex="14" style="width:300px; " value="<? if($get_emp!='0')echo $employee_birth; ?>" /><span style="color:#F00;">*</span></td>
<td>
<input type="text" name="joindate" id="joindate" onfocus="$('#joindate').datepicker({changeMonth: true,changeYear: true,dateFormat: 'dd/mm/yy',defaultDate: '-3y -1m -247d',yearRange: '-50:+0'});" tabindex="15" style="width:300px; " value="<? if($get_emp!='0')echo $employee_join; ?>"/><span style="color:#F00;">*</span>
</td>
</tr>
</code></pre>
<p>after ajax call I call the same code but it not opens on first click , however it opens on second click?
please help me to sort out this problem.......................... </p>
| php | [2] |
3,002,995 | 3,002,996 | What's the difference between XElement and XDocument? | <p>What is the difference between <code>XElement</code> and <code>XDocument</code> and when do you use each?</p>
| c# | [0] |
819,515 | 819,516 | download the files in resources of xcode project | <p>I have a project which includes aprox 100 images and 101 files. which creates the application size 85MB on itunes. users can't download that much huge application.</p>
<p><strong>Is there any way to download the sound files in resources of xcode project instead of adding all the files in project and then upload it to itunes?</strong></p>
<p>Thanks guys.
Best Regards,
Naveed Butt</p>
| iphone | [8] |
3,244,168 | 3,244,169 | How do I get "I" to increment inside a .click function | <pre><code>$('#x').click(function() {
var i=1;
$('#y').prepend('<div id='+i+'>x'+i+'</div>');
i++;
});
</code></pre>
<p>I want the i to increment, now for some reason it is not. I will agree this is a silly question.</p>
| javascript | [3] |
1,965,213 | 1,965,214 | Check for duplicate key name instances in php array | <p>How would I best go about finding duplicate key names in an array in PHP?
I'm trying to validate a POST array, and realized that I need to make sure that there aren't any duplicate key names.</p>
| php | [2] |
4,252,139 | 4,252,140 | fire fox stuck on transferring data from server | <p>I'm opening new tab by click on button in the home page , and building the new tab from copying some Elements from the home page,on loading event,i do all my work , also I'm changing image src on load event by filling it from the server , i don't know why fire fox stuck on status of "Transferring data from server",can any one help me in this problem?</p>
<p>this is piece of my code:</p>
<pre><code>window.onload = function () {
document.getElementById('demo_tab_info').innerHTML=opener.document.getElementById('demo_tab_ifo').innerHTML;
if(document.getElementById("Have_Patient__Photo_image" ).value =='true')
{
document.getElementById("pat_<%=Pat_Acct%>_pic_area").innerHTML="<img name='pat_<%=Pat_Acct%>_pic_image' id='pat_<%=Pat_Acct%>_pic_image' src='' onload=\"Fix_Dimensions('pat_<%=Pat_Acct%>_pic')\"/>";
var Image_Element_Name = 'pat_<%=Pat_Acct%>_pic_image';
var Image = document.getElementById(Image_Element_Name);
Image.src='/jspapps/apps/file_uploader/view_image.jsp?table=pat_dri_images&db=admin&im_type=pat_pic&pat_acc=<%=Pat_Acct%>&ts='+(new Date()).getTime();
}
}
</code></pre>
| javascript | [3] |
5,381,645 | 5,381,646 | How to set up HTMLTestRunner in Python Script | <p>Anyone with similar problem?</p>
<p>HTMLTestRunner.py is in C:\Python27 folder. </p>
<p>In my script I have:</p>
<pre><code>import unittest, time, re, sys
sys.path.append("C:\\Python27")
from Python27 import HTMLTestRunner.py
</code></pre>
<p>Error getting:
Unresolved import</p>
<p>Description Resource Path Location Type
Encountered "." at line 9, column 36. Was expecting one of: ... ";" ... "," ... "as" ... ";" ... </p>
| python | [7] |
4,352,615 | 4,352,616 | EBICS file creation and validation with PHP | <p>i'm currently trying to create and then submit an EBICS formatted file on my bank account.</p>
<p>The file sounds good, but the bank rejects it without any error code.</p>
<p>Has anyone already done this kind of dev and could help on this?</p>
<p>Thanks!</p>
| php | [2] |
2,213,554 | 2,213,555 | How to convert date into US formatting in PHP? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2487921/php-convert-date-format-yyyy-mm-dd-dd-mm-yyyy-not-in-sql">PHP: convert date format yyyy-mm-dd => dd-mm-yyyy [NOT IN SQL]</a> </p>
</blockquote>
<p>Hope everyone is having a great holiday.</p>
<p>I have a date in this format: <code>23-12-2011</code> and would like to reverse it into US format <code>2011-12-23</code>.</p>
<p>Does anyone know how I can do this in PHP? Is there any function for breaking strings up?</p>
| php | [2] |
960,425 | 960,426 | When will ofstream::open fail? | <p>I am trying out try, catch, throw statements in C++ for file handling, and I have written a dummy code to catch all errors. My question is in order to check if I have got these right, I need an error to occur. Now I can easily check <code>infile.fail()</code> by simply not creating a file of the required name in the directory. But how will I be able to check the same for <code>outfile.fail()</code> (<code>outfile</code> is <code>ofstream</code> where as <code>infile</code> is <code>ifstream</code>). In which case, will the value for <code>outfile.fail()</code> be true?</p>
<p>sample code [from comments on unapersson's answer, simplified to make issue clearer -zack]:</p>
<pre><code>#include <fstream>
using std::ofstream;
int main()
{
ofstream outfile;
outfile.open("test.txt");
if (outfile.fail())
// do something......
else
// do something else.....
return 0;
}
</code></pre>
| c++ | [6] |
6,010,936 | 6,010,937 | Javascript 'new' Keyword | <p><code>'Javascript: The Good Parts'</code> provides this example regarding the "Constructor Invocation Pattern" (page 29-30).</p>
<pre><code>var Quo = function (string) {
this.status = string;
};
Quo.prototype.get_status = function() {
return this.status;
};
var myQuo = new Quo("confused");
document.writeln(myQuo.get_status()); // returns confused
</code></pre>
<p>The section ends with, <code>"Use of this style of constructor functions is not recommended. We will see better alternatives in the next chapter."</code></p>
<p>What's the point of the example and strong recommendation against using this pattern?</p>
<p>Thanks.</p>
| javascript | [3] |
2,585,850 | 2,585,851 | iPhone - ignoring the second touch on an area | <p>I have a view that the users are allowed to finger paint. The code is working perfectly if the area is touched with one finger. For example: I touch it with one finger and move the finger. Then, a line is drawn as I move the first finger. If I touch with a second finger the same view, the line that was being drawn by the first finger stops. </p>
<p>I would like to ignore any touch beyond the first, i.e., to track the first touch but ignore all others to the same view.</p>
<p>I am using touchesBegan/moved/ended.</p>
<p>I have used this to detect the touches</p>
<pre><code>UITouch *touch = [[event allTouches] anyObject];
lastPoint = [touch locationInView:myView];
</code></pre>
<p>I have also tried this </p>
<pre><code>lastPoint = [[touches anyObject] locationInView:myView];
</code></pre>
<p>but nothing changed. </p>
<p>How do I do that - track the first touch and ignore any subsequent touch to a view?</p>
<p>thanks.</p>
<p>NOTE: the view is NOT adjusted to detect multiple touches.</p>
| iphone | [8] |
1,556,339 | 1,556,340 | date difference function | <p>can any body can teach me how to use the date difference function? using asp.net? please...</p>
| asp.net | [9] |
5,135,140 | 5,135,141 | Android: How to make, buttons and checkbox inside each box in a grid? | <p>I need a grid view, and inside each box, in the grid, I need to insert buttons and check box.
What are my options?
--> I could not insert buttons + checkboxes by using gridView
--> I tried drawing in canvas, got the grid, but couldnot insert buttons...
Any suggestions??</p>
<p>Thanks in Advance!</p>
| android | [4] |
1,892,285 | 1,892,286 | How does the content of a Hashtable affect its size in memory? | <p>If I have Hashtable A that has 5 million keys mapped to 5 million unique values, and I have Hashtable B that has 5 million keys mapped to 20 unique values, then approximately how much more memory would Hashtable A use compared to Hashtable B?</p>
<p>All of the keys and values are Strings that are approximately 20-50 characters in length.</p>
<p>My initial guess is that Hashtable A would take up roughly double the space as Hashtable B, but if you include the mappings then Hashtable B would use:</p>
<p>(5 million keys + 5 million mappings + 20 values) / (5 million keys + 5 million mappings + 5 million values) = .66</p>
<p>66.6% of the memory Hashtable A uses. However I don't know if a mapping would use as much space as a key or value if the keys and values are Strings.</p>
<p>Comments?</p>
| java | [1] |
2,061,343 | 2,061,344 | How to save the XML From Webservice | <p>I am developing an application in which I am getting a XML file from web service.I am parsing xml from this and showing data in table view. Now I need to save the xml.And i want to show the data when there is no internet connection also. How can I save an XML file coming from web service??? and load it when there is no internet connection.
I can save the xml if the url has name in that,like "www.xyz/asd.xml" but in webservice we dont have xml name like that,so how to save?????
PLEASE HELP ME IN THIS.THANKS IN ADVANCE</p>
<pre><code>NSString *link = [[NSString alloc] initWithString://webservice link
XMLParser *parser = [[XMLParser alloc] init];
[parser ParsewithURL:link];
</code></pre>
| iphone | [8] |
1,408,462 | 1,408,463 | Getting a count of list items in a list via ECMAScript | <p>I have a SharePoint 2010 web site with a master page that has a counter on it. I'm trying to update that counter using the ECMAScript. The code I have falls nicely into the success method - but I cannot find the right call to get a count. I have tried length, length(), count & count(). Does anybody have any suggestions? I have the code working, but only by enumerating through the results of the list and incrementing a count.</p>
<p>This is what I have so far, as an example:-</p>
<pre><code><script type="text/javascript">
var clientContext = null;
var web = null;
ExecuteOrDelayUntilScriptLoaded(Initialize, "sp.js");
function Initialize()
{
clientContext = new SP.ClientContext.get_current();
web = clientContext.get_web();
var list = web.get_lists().getByTitle("Absences");
var camlQuery = new SP.CamlQuery();
var q = "<Where><Eq><FieldRef Name='StatusID' /><Value Type='Integer'>1</Value></Eq></Where>";
camlQuery.set_viewXml(q);
this.listItems = list.getItems(camlQuery);
clientContext.load(listItems, 'Include(Id)');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onListItemsLoadSuccess),
Function.createDelegate(this, this.onQueryFailed));
}
function onListItemsLoadSuccess(sender, args) {
var count = 0;
var listEnumerator = this.listItems.getEnumerator();
//iterate though all of the items
while (listEnumerator.moveNext()) {
count = count + 1;
}
$('#spnNumberOfAbsences').text(count);
}
function onQueryFailed(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
</code></pre>
| javascript | [3] |
3,699,903 | 3,699,904 | IIS stop responding for a single page sometimes not alway | <p>I have a web application that works fine in all of its pages but I have a page that the IIS stop responding when I request it --> load forever in FF and from my iPad safari said that the web server stop responding.</p>
<p>When I reset IIS it works fine for a while and then i face the same problem again.</p>
<p>I do nothing critical nor complicated in this page load it is all about http request and it works fine in local host very fine also!!</p>
<p>Any suggestions?</p>
| asp.net | [9] |
671,810 | 671,811 | Android on incoming call change the name on screen | <p>I'am trying to make an application that when someone calls me, and lets I see 000-111-222-333 on the screen (thats the number of who ever is calling me) I will change the number to lets say "God".</p>
<p>I'am using a pre-made example that i found on the net and was woundering if you can guide me to complete the code.</p>
<p>Heres what i'v got so far:</p>
<p>public class ServiceReceiver extends BroadcastReceiver {</p>
<pre><code>@Override
public void onReceive(Context context, Intent intent) {
MyPhoneStateListener phoneListener=new MyPhoneStateListener(context);
TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(phoneListener,PhoneStateListener.LISTEN_CALL_STATE);
}
</code></pre>
<p>}</p>
<p>And the second class:</p>
<p>public class MyPhoneStateListener extends PhoneStateListener {</p>
<pre><code>Context con;
public MyPhoneStateListener(Context context)
{
con = context;
}
public void onCallStateChanged(int state,String incomingNumber){
switch(state)
{
case TelephonyManager.CALL_STATE_IDLE:
Log.d("DEBUG", "IDLE");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d("DEBUG", "OFFHOOK");
break;
case TelephonyManager.CALL_STATE_RINGING:
}
}
</code></pre>
<p>}</p>
<p>What i want to do is instead of the LOG func, create a function that will change the number on the screen.</p>
<p>I'm lost.</p>
<p>Please help!</p>
| android | [4] |
771,309 | 771,310 | How is this illegal | <pre><code>a) int i[] = new int[2]{1,2};
b) int[] i = new int[]{1,2,3}{4,5,6};
</code></pre>
<p>I know we cannot give size of an array at declaration . But in statement(a) we are giving size in initialization . Then how is statement (a) illegal and statement (b) is legal in java</p>
| java | [1] |
1,552,641 | 1,552,642 | python how to delete strings after a keyword | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/549130/delete-chars-in-python">Delete Chars in Python</a> </p>
</blockquote>
<p>I want to know how to delete strings after a keyword in python</p>
<p>I will get lines in a txt file</p>
<p>What method could I use to do this. </p>
<p>For example: </p>
<p>"I have a book to read." </p>
<p>I want to delete all words after "book". </p>
| python | [7] |
1,487,261 | 1,487,262 | Invalid Postback occurring? | <p>I keep getting this error:</p>
<blockquote>
<p>Invalid postback or callback argument. Event validation is enabled
using in configuration or <%@
Page EnableEventValidation="true" %> in a page. For security
purposes, this feature verifies that arguments to postback or callback
events originate from the server control that originally rendered
them. If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation.</p>
</blockquote>
<p>I have registered the ClientScriptMagner.Regis.... but still nothing.</p>
<p>I have dropdownlist's in a control and when my form is submitted, this happens.</p>
<p>How do I fix this?</p>
| asp.net | [9] |
653,202 | 653,203 | Refresh a div that is displayed with php | <p>i want to refresh a page in php(which is executing the sql statements) to p refreshed every 10 seconds. I load the page in a div like:</p>
<pre><code><div id="test"> <?php echo showPage() ?></div>
</code></pre>
<p>So how can i just refresh this duv that will make the data fetch by the sql refresh..</p>
<p>thank you</p>
| php | [2] |
5,783,452 | 5,783,453 | How can I launch a python script on windows? | <p>I have run a few using batch jobs, but, I am wondering what would be the most appropriate? Maybe using time.strftime?</p>
| python | [7] |
3,000,380 | 3,000,381 | Gridview property in asp.net? | <p>i have a doubt in grid view. In Data list we have a property call RepeatDirection (horizontal or vertical). is there any property in gridview control displaying the data in horizontal.</p>
| asp.net | [9] |
2,913,638 | 2,913,639 | Why this Factorial function returning zero for large numbers | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1384160/calculating-factorial-of-large-numbers-in-c">Calculating factorial of large numbers in C</a> </p>
</blockquote>
<p>Firstly, I am new to C++. I have tried below program to calculate factorial of any number. </p>
<pre><code>#include <iostream>
using namespace std;
unsigned long factorial(unsigned long n){
return n <= 1 ? 1 : n * factorial(n-1);
}
int main()
{
cout << "Enter any Number to calculate factorial." <<endl;
unsigned long n;
cin >> n ;
cout << factorial(n) ;
}
</code></pre>
<p>If i give small numbers like 5,3,20 it returns me exact value. But if I give numbers like 34 etc.. It is returning me zero. I assume that it is exceeding the limit range. Please help me on this to return exact result whatever the number I enter.</p>
| c++ | [6] |
2,362,491 | 2,362,492 | filter_var php question | <p>I am making a quick little email script for a contact form and these variable aren't being set(<code>$firstName</code> and <code>$lastName</code>).</p>
<pre><code>$firstName = filter_var($_POST['firstName'], FILTER_SANITIZE_STRING);
$lastName = filter_var($_POST['lastName'], FILTER_SANITIZE_STRING);
</code></pre>
<p>Note I am a beginner at php</p>
| php | [2] |
5,503,611 | 5,503,612 | c++ overloading the [] operator without a class | <p>I have created a structure:</p>
<pre><code>struct a{
int a1;
int a2;
int a3;
};
</code></pre>
<p>Is there any way to create a function where <code>a[1]</code> will give access to <code>a1</code> in the same way that I'll be able through an array?</p>
<p>Edit, I have pasted the part that I actually do:</p>
<pre><code>struct lipid{
particle mainPart;
bead * head;
bead * body;
bead * tail;
vec direction;
bead * operator[](int index){
switch(index){
case 0: return head;
case 1: return body;
case 2: return tail;
default: return body;
}
}
};
</code></pre>
<p>bead and particle are another struct I have created. It works... thanks</p>
| c++ | [6] |
5,218,182 | 5,218,183 | Canvas.drawBitmap drawing the image with a yellow tint | <p>I am trying to draw the 'Y' component as greyscale from the image I get from the Camera via onPreviewFrame.</p>
<p>I am using the version of Canvas.drawBitmap that takes an array of 'colors' as a parameter. The Android docs don't mention what format the Color is in, so I'm assuming ARGB 8888.</p>
<p>I do get an image showing up, but it is showing up with an odd Yellow tint.</p>
<p>Here is my code below:</p>
<pre><code> public void onPreviewFrame(byte[] bytes, Camera camera) {
Canvas canvas = null;
try {
synchronized(mSurfaceHolder) {
canvas = mSurfaceHolder.lockCanvas();
Size size = camera.getParameters().getPreviewSize();
int width = size.width;
int height = size.height;
if (mHeight * mWidth != height * width)
{
mColors = new int[width * height];
mHeight = height;
mWidth = width;
Log.i(TAG, "prewviw size = " + width + " x " + height);
}
for (int x = 0; x < width; x ++) {
for (int y = 0; y < height; y++) {
int yval = bytes[x + y * width];
mColors[x + y * width] = (0xFF << 24) | (yval << 16) | (yval << 8) | yval;
}
}
canvas.drawBitmap(mColors, 0, width, 0.f, 0.f, width, height, false, null);
}
}
finally {
if (canvas != null) {
mSurfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
</code></pre>
<p>I've also tried using another version of Canvas.drawBitmap that takes a Bitmap as a parameter. I constructed the Bitmap in a similar way from the same array and I told it to use ARGB explicitly. But it still ended up being tinted Yellow!</p>
<p>What am I doing wrong here?</p>
| android | [4] |
4,464,102 | 4,464,103 | Is there a way to specify different bundle display names for different iOS devices in a universal app? | <p>I'm guessing no, but would love to be wrong. I would like to use a bundle display name for my universal app that shows great on the iPad and iPhone 4, but is too long (has ellipses) on older iPhone models. I'd like to specify the full bundle display name on the former two platforms, and then specify a shorter name on older iPhone models. Is there any way to do this?</p>
| iphone | [8] |
2,681,263 | 2,681,264 | compression with huffman | <p>I have a project that should compress and decompress the text files in Java. I understand the Huffman algorithm, but I don't know how to code the whole project. Who can help me?</p>
| java | [1] |
126,019 | 126,020 | Is it possible to call a non activity class from a BroadcastReceiver, If yes how we can do? | <p>I have one BroadcastReceiver,it notify when phone state is changed, at that time i wan't to get a data from <code>CallLog.Calls</code>(this reside in my non activity class) and save it to my SQLite database.But now i facing a problem when calling a class.<br>
Since i am new to android, any help or idea will be appreciated.</p>
<p>Thanks in advance</p>
| android | [4] |
2,126,371 | 2,126,372 | Can you detect/redirect a back button press through javascript? | <p>I'm trying to detect and change browser behavior if a user clicks on the back button.</p>
<p>Is this even possible through Javascript?</p>
| javascript | [3] |
4,482,535 | 4,482,536 | Javascript, escape is not a function - from firefox? | <p>I'm quite puzzled by this one, getting this error from firefox.</p>
<pre><code>escape is not a function
</code></pre>
<p><img src="http://i.stack.imgur.com/EOknY.png" alt="enter image description here">
Looking at the W3C page, it says it is supported as I thought.</p>
<p>I tried <code>escapeURI</code> instead and this produced the same error.</p>
<p>Any suggestions ?</p>
| javascript | [3] |
2,437,972 | 2,437,973 | Hide div based on option value | <p>How can I change this to hide all divs that match option values EXCEPT the first div?</p>
<p>What I have so far does the job of hiding all divs before a selection is made however I need to have the first div showing before the user makes a choice.</p>
<p><a href="http://jsfiddle.net/infatti/fj63g/" rel="nofollow">http://jsfiddle.net/infatti/fj63g/</a></p>
<pre><code>$('.dd-show-hide').find('option').each(function(){
$('#' + this.value).hide();
});
$('.dd-show-hide').change(function(){
$(this).find('option').each(function(){
$('#' + this.value).hide();
});
$('#' + this.value).show();
});
<select class="dd-show-hide">
<option>Choose</option>
<option value="div1">Show Div 1</option>
<option value="div2">Show Div 2</option>
<option value="div3">Show Div 3</option>
</select>
<div id="div1" class="drop-down-show-hide">div 1</div>
<div id="div2" class="drop-down-show-hide">div 2</div>
<div id="div3" class="drop-down-show-hide">div 3</div>
</code></pre>
| jquery | [5] |
5,302,425 | 5,302,426 | Select input from current row? | <p>I've got a table with rows and a button to add rows to the table. I increment the id's of the input fields using this code:</p>
<pre><code>$("#add_row_e").click(function() {
var row = $("#expenses tbody > tr:last"),
newRow = row.clone(true);
newRow.find("input").each(function() {
var num = +(this.id.match(/\d+$/) || [0])[0] + 1;
this.id = this.id.replace(/\d+$/, "") + num;
this.name = this.id;
});
newRow.insertAfter(row);
return false;
});
</code></pre>
<p>I then multiply the 2 inputs and output them to a div using this:</p>
<pre><code>$('.multiplier').on('keyup', function() {
$('#results').html("&pound;" + parseInt($('#E_NONM').val()) * parseInt($('#E_CCNM').val()));
});
</code></pre>
<p>Is there any way I can get this to work for each new row that I add? I'd imagine it'd have to look at the id's in the row and use that to multiply, however I don't know how to do this.</p>
<p>Also, how do I get the above to output to a input box not a div?</p>
| jquery | [5] |
3,879,075 | 3,879,076 | Delimiter on php.ini include path | <p>I am currently installing a subversion protocol within a business, some of the users develop in Windows on local Wamp servers, and others use local Lamp servers. The main site runs on a linux server. </p>
<p>The issue I have is setting up the include paths within the php.ini file. As some of the live files change this setting on the fly, this is becoming a pain.</p>
<p>The windows machines require a semi colon delimiter in the include paths, and the linux machines require a colon.</p>
<p>Is there any way to change the configuration of the windows machines to use a colon as the include path delimiters?</p>
| php | [2] |
2,093,802 | 2,093,803 | content provider able to do that? [android] | <p>device A is user has Application I.</p>
<p>device B is user has Application I too.</p>
<p>device C is admin and will update the Application I data.</p>
<p>i am using sqlite and content provider to share data among them. Am i getting correct or wrong direction?</p>
<p>If wrong, please suggest me the correct way to implement it. Thanks</p>
| android | [4] |
2,577,432 | 2,577,433 | How do I set characters in a Python string? | <p>I have a function that decrements a whole number parameter represented by a string. For instance, if I pass in the string "100", it should return "99."</p>
<pre><code>def dec(s):
i = len(s) - 1
myString = ""
while (i >= 0):
if s[i] == '0':
s[i] = '9'
i -= 1
else:
s[i] = chr(int(s[i]) - 1)
break
return s
</code></pre>
<p>However, Python issues this error.</p>
<pre><code>s[i] = '9'
TypeError: 'str' object does not support item assignment
</code></pre>
<p>I am assuming that <code>s[i]</code> cannot be treated as an lvalue. What is a solution around this?</p>
| python | [7] |
2,948,912 | 2,948,913 | Android UI for multiple devices | <p>Is there a way to ensure that my Android UI will display as expected across different phones ?</p>
| android | [4] |
1,343,446 | 1,343,447 | Validation Result Practies. Boolean or Count? | <p>Over a few years, I have have written a few validation classes and have always wonder what people thinks is the best way of handling them.</p>
<p>I've seen and done each of the following and am curious to your know opinions and why.</p>
<p><strong>Scenario 1, Message Counting</strong></p>
<pre><code>class ValidationClass1
{
public List<string> ValidationMessage { get; set; }
public void Validate(x)
{
// pseudo-code
if (!rule_logic1)
{
ValidationMessage.Add("Error in logic 1");
}
if (!rule_logic2)
{
ValidationMessage.Add("Error in logic 2");
}
}
}
</code></pre>
<p><strong>Scenario 2, Returning an Object or Tuple</strong></p>
<pre><code>class ValidationClass
{
public Tuple<bool, List<string>> Validate(x)
{
List<string> ValidationMessage = new List<string>();
bool passed = true;
// pseudo-code
if (!rule_logic1)
{
ValidationMessage.Add("Error in logic 1");
passed = false;
}
if (!rule_logic2)
{
ValidationMessage.Add("Error in logic 2");
passed = false;
}
return new Tuple<bool, List<string>>(passed, ValidationMessage);
}
}
</code></pre>
<p>In Scenario 1, the ValidationMessage list could be the return type as well. Regardless, calling code would have to check the count property of the list to see if the data passed or not. If it was only a singular rule, the returning string length would need to be checked via string.IsNullOrEmpty(x).</p>
<p>In Scenario 2, a custom object or tuple would be the return type so that the calling code would have to have knowledge of the returning code and evaluate a boolean property to see if it passed and then the validation messages.</p>
<p>So, in your opinion, which way do you prefer or if you have a different preference, I'd be curious to hear that as well.</p>
<p>Thanks</p>
| c# | [0] |
1,334,948 | 1,334,949 | How to execute system commands (linux/bsd) using Java | <p>I am attempting to be cheap and execute a local system command ('uname -a') in Java. I am looking to grab the output from uname and store it in a String. What is the best way of doing this? Current code:</p>
<pre><code>public class lame
{
public static void main(String args[])
{
try
{
Process p=Runtime.getRuntime().exec("uname -a");
p.waitFor();
BufferedReader reader=new BufferedReader(new InputStreamReader(p.getInputStream()));
String line=reader.readLine();
while(line!=null)
{
System.out.println(line);
line=reader.readLine();
}
}
catch(IOException e1) {}
catch(InterruptedException e2) {}
System.out.println("finished.");
}
}
</code></pre>
| java | [1] |
3,075,529 | 3,075,530 | Change screen preferences | <p>I have a business requirement, and after lot of googling came to a point that android (as compared to iPhone) would be the platform to go for</p>
<p>I have a requirement wherein lets say an App 'X' that comes built-in with OS (firmware) needs to be replaced with some App 'Y'.</p>
<p>Of course, i understand that there would be something that i would need to change at firmware level (correct me), and of course i have no idea how to do that</p>
<p>So, is such a kind of thing even possible ?</p>
<p>Any links where i could look for more.</p>
<p>Yogurt</p>
| android | [4] |
4,479,174 | 4,479,175 | Emulating a toggle button with JQuery and CSS | <p>I have a number of elements with the same class like this:</p>
<pre><code><html>
<head><title>example</title>
<script type="text/javascript" src="jquery.js">
</head>
<body>
<ul>
<li class="togglebutton">elem1</li>
<li class="togglebutton">elem2</li>
<li class="togglebutton selected">elem3</li>
<li class="togglebutton">elem4</li>
</ul>
$(document).ready(function(){
});
</body>
</html>
</code></pre>
<p>The selected element has a different color from the other elements. When a user clicks on ANOTHER element, I want that element to have the selected class - and all other elements should no longer have the selected class. In other words, only one element can be selected at any time.</p>
<p>I think I have worked out the logic, but I am not sure how to implement it using jQuery.</p>
<p>basically my approach would be:</p>
<p>(When an item is selected):</p>
<ol>
<li>Select all items using selector "ul > li.togglebutton"</li>
<li>remove class 'selected' from all of the items fetched in step 1</li>
<li>add class 'selected' to the current element that was clicked on.</li>
</ol>
<p>Is this logic correct, or is there a better way of going about it?</p>
<p>Also, how may I implement the above logic (assuming there is no better alternative), using jQuery?</p>
| jquery | [5] |
5,627,241 | 5,627,242 | App not loading images right??? | <p>I load the camera and take a picture, then set the picture taken into an imageview; however, the app always does the last image taken, not the current one. </p>
<p>So, if I open the app and take a picture, the image view is black. Close app, reopen and take another picture, the image view is now the first picture taken. </p>
<p>???</p>
<pre><code>Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File file = new File(Environment.getExternalStorageDirectory(), "image.jpg");
System.out.println((Environment.getExternalStorageDirectory() + "/image.jpg"));
outputFileUri = Uri.fromFile(file);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
setContentView(R.layout.image_process);
bmp = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/image.jpg");
image = (ImageView) findViewById(R.id.imageView1);
image.setImageBitmap(bmp);
</code></pre>
| android | [4] |
3,500,684 | 3,500,685 | The method getWindow().setBackgroundDrawableResource(int resid) doesn't work outside of onCreate() | <p>Here is a short sketch of my application</p>
<pre><code>...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
... //at this place, getWindow().setBackgroundDrawableResource(int resid)
//would work perfectly
mainView();
}
void mainView() {
setContentView(R.layout.main);
...
if (...) {
getWindow().setBackgroundDrawableResource(R.drawable.anyDrawable);
}
...
}
</code></pre>
<p>But in mainView() that method doesn't effect anything. And no Exception is thrown out.</p>
<p>main.xml already defines a background image, but start.xml doesn't do it. Could this cause my problem?</p>
<p>Or can I change the background image in another way?</p>
| android | [4] |
5,487,655 | 5,487,656 | variable used withing multiple selector | <p>ok, yet another jquery selector nightmare for me ! i've read about 20 questions with similar topic, but I couldnt find one with my problem ... sorry if it did exist ( probably does somewhere ) its seems pointlessly easy but somehow I cant get it to work.</p>
<p>I have a list of img, and when you click on one, I get hold of its 2nd class. Once I have this second class, i want to hide or show other element who have that class</p>
<p>heres some code to clarify : </p>
<pre><code><ul id="thumbail_list">
<li class="image fantome"><img src="images/fantome.png"/></li>
<ul>
</code></pre>
<p>lets say I click on my fantome image I want that somewhere else a paragraph with class texte and fantome which is hidden by default become visible.</p>
<pre><code>$('#thumbail_list li').click(function() {
var Chosenclass = $(this).attr('class').split(' ')[1];
var texte = '.text .' + Chosenclass ;
var image = '.image .' + Chosenclass ;
$('.image').fadeIn('slow', function(){
$(image).fadeOut('slow', function(){
$(texte).fadeIn('slow');
});
});
}
</code></pre>
<p>but I cant get this to work, console doesnt show me any error, and I,ve put alert everywhere and it always show me what I want ... but the invisible text wont show.</p>
| jquery | [5] |
5,314,520 | 5,314,521 | Python "classobj" error | <p>I have this code and I couldn't run it because i get this error:
"TypeError: 'classobj' object is not subscriptable"
and here is my code:</p>
<pre><code>import cgi
import customerlib
form=cgi.FieldStorage
history = customerlib.find(form["f_name"].value,form["l_name"].value)
print "Content-type: text/html"
print
print """<html>
<head>
<title>Purchase history</title>
</head>
<body>
<h1>Purchase History</h1>"""
print "<p>you have a purchase history of:"
for i in history: "</p>"
print""" <body>
</html>"""
</code></pre>
<p>I have the customerlib file beside this file. Any idea how to fix it?</p>
| python | [7] |
251,692 | 251,693 | Retreiving/Printing execution context | <p>EDIT: This question has been solved with help from apphacker and ConcernedOfTunbridgeWells. I have updated the code to reflect the solution I will be using.</p>
<p>I am currently writing a swarm intelligence simulator and looking to give the user an easy way to debug their algorithms. Among other outputs, I feel it would be beneficial to give the user a printout of the execution context at the beginning of each step in the algorithm.</p>
<p>The following code achieves what I was needing.</p>
<pre><code>import inspect
def print_current_execution_context():
frame=inspect.currentframe().f_back #get caller frame
print frame.f_locals #print locals of caller
class TheClass(object):
def __init__(self,val):
self.val=val
def thefunction(self,a,b):
c=a+b
print_current_execution_context()
C=TheClass(2)
C.thefunction(1,2)
</code></pre>
<p>This gives the expected output of:</p>
<pre><code>{'a': 1, 'c': 3, 'b': 2, 'self': <__main__.TheClass object at 0xb7d2214c>}
</code></pre>
<p>Thank you to apphacker and ConcernedOfTunbridgeWells who pointed me towards this answer</p>
| python | [7] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.