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 |
|---|---|---|---|---|---|
136,861 | 136,862 | jQuery slide, how to not slide at beginning or end? | <p>I have a jquery function which slides a certain div to the right or left when I click a button.</p>
<pre><code>$(function(){
$("#prev").click(function(){
$("#contentcont").animate({'left': '-=110'});
return false;
});
$("#next").click(function(){
$("#contentcont").animate({'left': '+=110'});
return false;
});
});
</code></pre>
<p>Everything works fine. But what can I do if I havent slided anything yet, I can just slide the whole thing to one side? Right now I can slide to both sides. But I just want to do that if I already slided at least one. Also the same for the end... how can I tell jquery to stop the sliding when I just reached the end?</p>
<p>Thanks in advance. I'm still not a jquery pro...</p>
| jquery | [5] |
4,208,624 | 4,208,625 | Android: Create an Activity initially hidden, process data while its hidden, then show it only after its ready | <p>I have a two activity application. One is a "HomePage". Another is a "DataPage" activity that just contains a webview. When the user clicks on a button on the HomePage, I show the DataPage and load the URL. The problem is the URL is a very slow loading page. I want to solve that problem by creating both activities when my app is open. The home page will be visible, the DataPage will be hidden. I will immediately start the WebView of the DataPage so that it loads in the background. Then when the user clicks on the button, I will reveal the DataPage, with most of its data already loaded.</p>
<p>I dont know how to create an activity in an initially hidden state. And then bring that activity into the front? Is there a way of doing that?</p>
| android | [4] |
5,105,792 | 5,105,793 | What's the difference between function(myVar) and (function)myVar? | <p><em>This is yet another one of those questions I'd like to be able to tag 'newbie'.</em></p>
<p>I'm going through the full tutorial at cplusplus.com, coding and compiling each example manually. Regularly, I stumble upon something that leaves me perplexed.</p>
<p>I am currently learning this section: <a href="http://www.cplusplus.com/doc/tutorial/structures/" rel="nofollow">http://www.cplusplus.com/doc/tutorial/structures/</a> . There are some subtleties that could easily be overlooked by only reading the tutorial. The advantage of typing everything by hand is that such details do stand out.</p>
<p>In the above page, there are two sample programs. One has this line: </p>
<pre><code>stringstream(mystr) >> yours.year;
</code></pre>
<p>The other one has this line: </p>
<pre><code>(stringstream) mystr >> pmovie->year;
</code></pre>
<p>What I don't understand is the difference (if any) between <code>function (myVar) = x;</code> and <code>(function) myVar = x;</code>.</p>
<p>I am not doing the whole tutorial in sequential order. I checked but didn't find this addressed anywhere, though I may have missed it.</p>
<ul>
<li>Is there a difference? </li>
<li>Is there a preferred way to do it one way rather than the other? </li>
</ul>
| c++ | [6] |
1,466,445 | 1,466,446 | cannot be resolved or is not a field | <p>i would like to ask how can i solve this problem ..</p>
<pre><code>public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
textOut =(TextView) findViewById(R.id.tvGetInput);
getInput = (EditText) findViewById(R.id.etInput);
Button ok = (Button) findViewById (R.id.bOk);
ok.setOnClickListener(new View.OnClickListener() {
</code></pre>
<p>(the tvGetInput, etInput ,bOk has the error)
it says "cannot be resolve or is not a field" </p>
| android | [4] |
1,362,264 | 1,362,265 | How to convert HTML to RTF in Java? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2091803/how-to-convert-html-to-rtf-in-java">How to convert HTML to RTF in Java?</a> </p>
</blockquote>
<p>(I'm looking for a open source library)</p>
| java | [1] |
1,876,903 | 1,876,904 | Getting appropriate hash index C++ | <p>I've tried everything. Even java's forumla: </p>
<p>java.lang.String.hashCode():</p>
<pre><code>s[0]*(31^(n-1)) + s[1]*(31^(n-2)) + ... + s[n-1]
</code></pre>
<p>I've interpretted this as a sum:
Although I am not quite sure what to do with the s[n-1];</p>
<pre><code>int hashmap::hashstr( const char*const str )
{
int result = 0;
int i = 0;
int j = 0;
int k = 0;
unsigned n = 0;
for ( ; str[n] != NULL; ++n ); // how many characters?
while ( j != n ) // no more characters
{
result += str[i] * ( 31 ^ ( n - k ) );
j++;
i++;
k++;
}
return result % maxSize;
}
</code></pre>
<p>where maxSize is the 10th element in my fixed array size of 11.</p>
<p>What am i doing wrong? SOME of my hash indicies are coming out wrong. Others, correctly. Why is this? So far everyones been like, "Who cares how it works!! Use a template!" Well, I want to understand this.. </p>
| c++ | [6] |
5,995,504 | 5,995,505 | AlertDialog.Builder How Can I Access the the 'PositiveButton'? | <p>I am using <code>AlertDialog.Builder</code> to create a dialog with a <code>EditText</code> and two buttons, <code>'OK'</code> and <code>'Cancel'</code>. I create the OK and Cancel buttons with <code>AlertDialog.Builder.setPositiveButton()</code> and <code>.setNegativeButton()</code> respectively. The purpose of the dialog is to request an I.P. address from the user.</p>
<p>Initially I want to have the OK button disabled and attach to the <code>EditText</code> an <code>OnKey listener</code> so that when the user types the onKey listener is called and I can check the current <code>EditText</code> value with a regular expression for a valid IP address. Should a valid IP address be entered I'd then want to enable the OK button, but as I use the <code>setPositiveButton()</code> I have no idea what the id of the button is. </p>
<p>Can I get the id of the OK button?</p>
| android | [4] |
1,893,161 | 1,893,162 | Bind DropDownList SelectedValue from Enum | <p>I have enum for Salutation like</p>
<pre><code>public enum SALUTATION
{
MR = 1,
MS = 2,
MRS = 3,
}
</code></pre>
<p>and in my <code>staff</code> class my <code>Salutation</code> property is like,</p>
<pre><code>public SALUTATION Salutation
{
get;
set;
}
</code></pre>
<p>here, while editing the staff profile am just binding the datas from the database. For salutation I just tried binding the salutation like</p>
<pre><code>ddlSalutation.SelectedValue = Enum.GetName(typeof(SALUTATION), staff.Salutation);
</code></pre>
<p>but it binds the selectedValue as <code>-1</code> always. how can I bind the exact value in the ddl selected item. can anyone help me here..</p>
<p>in the page load event am just binding the ddl source as</p>
<pre><code> Hashtable hashSalutation = Utilities.GetEnumList(typeof(SALUTATION));
ddlSalutation.DataSource = hashSalutation;
ddlSalutation.DataTextField = "value";
ddlSalutation.DataValueField = "key";
ddlSalutation.DataBind();
ddlSalutation.Items.Insert(0, new ListItem("Select Salutation", "-1"));
public Hashtable GetEnumList(Type enumeration)
{
string[] names = Enum.GetNames(enumeration);
Array values = Enum.GetValues(enumeration);
Hashtable ht = new Hashtable();
for (int i = 0; i < names.Length; i++)
{
ht.Add(Convert.ToInt32(values.GetValue(i)).ToString(), names[i]);
}
return ht;
}
</code></pre>
| c# | [0] |
5,544,271 | 5,544,272 | Android images, density, and screen pixels | <p>I am confused by Android documentation about this questions so I will ask them here:
I have HTC Desire mobile on this <a href="http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density" rel="nofollow">link</a> I see that it has pixels 480×800 and Density 252</p>
<ol>
<li>When I try to get Density like this getResources().getDisplayMetrics().densityDpi I get value 240 and not 252.</li>
<li>I have image with size 400x113 with Density 240(Pixels/Inch) And when I try to get size in program with getWidth and getHeight it said 600 and 170.</li>
<li>What size my image need to be for this phone HTC Desire and which Density it need to have.</li>
</ol>
<p>Thanks.</p>
| android | [4] |
2,399,508 | 2,399,509 | Clear or delete variable before declaring it again with javascript | <p>I am VERY NEW to javascript and am messing around with some math. I currently have:</p>
<pre><code><input disabled="disabled" type="text" id="backer-prediction-answer" width="100" value="" />
<FORM>
<INPUT type="button" value="Apply" name="button1" onclick="apply()">
</FORM>
<script>
var backerPrediction1 = document.getElementById("backer-prediction-1").value;
var backerPrediction2 = document.getElementById("backer-prediction-2").value;
var backerPrediction3 = document.getElementById("backer-prediction-3").value;
var backerPrediction4 = document.getElementById("backer-prediction-4").value;
function apply(){
var backers = parseInt(backerPrediction1,10) + parseInt(backerPrediction2,10);
document.getElementById("backer-prediction-answer").value = (backers);
}
</script>
</code></pre>
<p>I would like to be able to hit apply and have it recalculate. Do I need to delete the variable before declaring it again? If so, how do I do that?</p>
| javascript | [3] |
5,254,004 | 5,254,005 | isAlive problem..Help to understand how it works | <p>I get this error:</p>
<pre><code>"non-static method isAlive() cannot be referenced from a static context"
</code></pre>
<p>what's wrong with this code..please.</p>
<p>I'd like to detect if the thread is alive...
Any help in terms of code will be highly appreciated..thanks
max</p>
<blockquote>
<pre><code>class RecThread extends Thread {
public void run() {
recFile = new File("recorded_track.wav");
// Output file type
AudioFileFormat.Type fileType = null;
fileType = AudioFileFormat.Type.WAVE;
// if rcOn =1 thread is alive
int rcOn;
try {
// starts recording
targetDataLine.open(audioFormat);
targetDataLine.start();
AudioSystem.write(new AudioInputStream(targetDataLine),
fileType, recFile);
if (RecThread.isAlive() == true) {
rcOn =1;
}
else {
rcOn =0;
}
} catch (Exception e) {
showException(e);
}
// update actions
recAction.setEnabled(true);
stopRecAction.setEnabled(false);
}
}
</code></pre>
</blockquote>
| java | [1] |
640,394 | 640,395 | Python beginner, strange output problem | <p>I'm having a weird problem with the following piece of code.</p>
<pre><code>from math import sqrt
def Permute(array):
result1 = []
result2 = []
if len(array) <= 1:
return array
for subarray in Permute(array[1:]):
for i in range(len(array)):
temp1 = subarray[:i]+array[0]+subarray[i:]
temp2 = [0]
for num in range(len(array)-1):
temp2[0] += (sqrt(pow((temp1[num+1][1][0]-temp1[num][1][0]),2) + pow((temp1[num+1][1][1]-temp1[num][1][1]),2)))
result1.append(temp1+temp2)
return result1
a = [['A',[50,1]]]
b = [['B',[1,1]]]
c = [['C',[100,1]]]
array = [a,b,c]
result1 = Permute(array)
for i in range(len(result1)):
print (result1[i])
print (len(result1))
</code></pre>
<p>What it does is find all the permutations of the points abc and then returns them along with the sum of the distances between each ordered point. It does this; however, it also seems to report a strange additional value, 99. I figure that the 99 is coming from the computation of the distance between point a and c but I don't understand why it is appearing in the final output as it does.</p>
| python | [7] |
5,567,887 | 5,567,888 | Checkbox Issue with IE8 using jquery | <p>I have this code</p>
<pre><code> $('#Submit').click(function(event) {
var checked = $('.inputchbox'); ......IE8
var ids= checked.map(function() {
return $(this).val();
}).get().join(',');
alert(ids);
});
</code></pre>
<p>This Code return all the values which is there for Checkboxbox (.inputchbox is class for the checkbox)</p>
<p>but If I give somethign like this </p>
<pre><code>var checked = $('.inputchbox input:checkbox:checked');
or
var checked = $('.inputchbox input[type=checkbox]:checked');
or
var checked = $('.inputchbox input[name=chk]:checked');
or
var checked = $('.inputchbox').find('input[type=checkbox]:checked');
</code></pre>
<p>if i am giving like this nothing is working for me I am not getting the result in IE8?</p>
<pre><code> var checked = $('.inputchbox'); .....this is working but I am getting the checkboxes ids its doesnot checking wheather its checked or not..
</code></pre>
<p>I need to get only checked chekcbox id's </p>
<p>thanks</p>
| jquery | [5] |
1,338,868 | 1,338,869 | Question about inheritance | <pre><code>class B{
private:
void DoSomething();
}
class W{
private:
class D: public B{
}
D d;
}
</code></pre>
<p>Can I call private member function in base class of D in the scope of class W?</p>
| c++ | [6] |
861,172 | 861,173 | Include PHP file with parameter | <p>newbie in PHP here, sorry for troubling you.</p>
<p>I want to ask something, if I want to include a php page, can I use parameter to define the page which I'll be calling?</p>
<p>Let's say I have to include a title part in my template page. Every page has different title which will be represented as an image. So,</p>
<p>is it possible for me to call something <code><?php @include('title.php',<image title>); ?></code> inside my template.php?</p>
<p>so the include will return title page with specific image to represent the title.</p>
<p>thank you guys.</p>
| php | [2] |
3,600,726 | 3,600,727 | java.lang.NullPointerException with arrays | <p>Hey the names in the program are in portuguese but I think its understandable, if you have any doubt just ask and i'll translate.</p>
<p>So I'm getting a <code>NullPointerException</code> with these. The array Vector_Canais is initialized in the constructor:</p>
<pre><code>public Box(int capacidade) {
Time a = new Time();
Vector_Canais = new Canal[DEFAULT_SIZE];
}
public static void novoCanal() {
Scanner in = new Scanner(System.in);
Cnl = in.nextLine();
Vector_Canais[i] = new Canal(Cnl);
i++;
}
public static String listaCanais(int i) {
return (Vector_Canais[i].getCanal());
}
public static void listaCanais() {
for (int a = 0; a < 100; a++) {
if (Box.listaCanais(a) != null) {
System.out.println(Box.listaCanais(a));
}
}
</code></pre>
<p>i is initialized at 0.
Any ideas?</p>
| java | [1] |
4,690,584 | 4,690,585 | Passing anonymous functions as parameters for later use | <p>I'm having issues with a script that I made for use in HTML5.
Here is the function</p>
<pre><code>function loadImage(loc,after,para){
var img = new Image();
img.src = loc;
if(typeof(after) != "undefined" && typeof(para) != "undefined"){
img.onloadeddata = after(img,para);
}else if(typeof(after) != "undefined"){
img.onloadeddata = after(img);
}
return img;
}
</code></pre>
<p>and here is what is calling it</p>
<pre><code>window.globalFriends[i][2]=loadImage('http://graph.facebook.com/'+window.globalFriends[i][0]+'/picture', function (a){
updateLoaders();
loadingDrawPerson(a);});
</code></pre>
<p>What I'm trying to do is send a function as a parameter for it then to be called.
It kinda of works but it a weird way. For example; All the images do get loaded but the onloadeddata either fires the function way to early or the function is getting executed before it gets to the loadImage function.</p>
<p>What are your ideas on my malfunctioning script?</p>
<p>Thank-you for reading
Paul</p>
| javascript | [3] |
411,422 | 411,423 | How do I call a property from inside a javascript closure | <p>I have a javascript closure and inside the method <code>getresult()</code>. I want to call a property in the object <code>quo</code>. </p>
<pre><code>var quo = function (test) {
talk: function () {
return 'yes';
}
return {
getresult: function () {
return quo.talk();
}
}
}
var myQuo = quo('hi');
document.write(myQuo.getresult());
</code></pre>
<p>From inside <code>getresult()</code>, how can I call the property <code>talk</code>?</p>
| javascript | [3] |
220,969 | 220,970 | Toggle Text with jQuery | <p>I've found a a few articles here on this topic but none seem to answer exactly what I'm looking for.</p>
<p>Here is my current code:</p>
<pre><code> $(".email-slide").click(function(){
$("#panel").slideToggle("slow");
$(this)
.text("Close")
.toggleClass("active");
});
</code></pre>
<p>When I select the word "Email" which has the class "email-slide" the top panel slides down, and the word "Email" turns to white, and the word "Email" turns into the word "Close".</p>
<p>All good so far. But when clicking "Close" though the color and panel go back to normal, the word "Close" does not turn back into the word "Email". Instead of .text("Close") I tried .toggleText("class") but it seems that does not work. Is there something similar I could do it accomplish it by adding the least amount of code possible? Thank you!</p>
<p>UPDATE - I am able to accomplish it by using the following code, but was hoping that would be a more efficient/shorter way of doing it. If not, let me know. Thanks!</p>
<pre><code>$(".email-slide").click(function(){
$("#panel").slideToggle("slow");
$(this).toggleClass("active");
});
$(".email-slide").toggle(function (){
$(this).text("Close")
}, function(){
$(this).text("Email")
});
</code></pre>
| jquery | [5] |
192,927 | 192,928 | MPEG1 to MPEG4? | <p>How to convert thro objective-C the MPEG1 to MPEG4? Is there any application that does, so that i can add to my app and test?</p>
<p>Thanks.</p>
| iphone | [8] |
1,923,449 | 1,923,450 | Constructing a temp object and calling a method that returns a pointer - is it safe? | <p>My intution says it isn't, but the fact that everything is going on in the same line is a bit confusing. I wonder if the pointer is still valid when <code>cout</code> uses it.</p>
<pre><code>#include <iostream>
#include <string>
struct A {
A() : m_s("test"){ }
const char* c_str() { return m_s.c_str(); }
std::string m_s;
};
int main() {
std::cout << "abc " << A().c_str() << " def" << std::endl;
}
</code></pre>
| c++ | [6] |
5,671,252 | 5,671,253 | how can i show checked items of listview in next activicity in android? | <p>I am New to Android. My Requirement is to check an item of list view and i want show the selected items in next activity.</p>
<p>can anyone help me..</p>
<p>Thanks in advance </p>
| android | [4] |
1,928,802 | 1,928,803 | PHP, Pass object from one object to another object per reference, when classes are in different files | <p>I'm developing a Web App.<br>
Until now the backend was JBoss 6.1 Application Server (Java EE). </p>
<p>Now, with the same frontend, there should be another backend in PHP.<br>
As I like the structure of the Java Backend, I design a similar structure for the php backend.</p>
<p>EVERY request to the PHP backend goes to ONE entry, it's "facade.php", it is my front
controller. </p>
<p>The front controller (facade.php) handles the JSON input and other things and then there is a large switch statement. Every task (login, get event objects, ...) is transferred to another process class. </p>
<p>Snippet of "facade.php":</p>
<pre><code>switch ($procClass) {
case "lgi":
require_once("classes/Login.php");
$login = new Login();
$resultMap = $login->process($internalObj, $sessionObj);
break;
case "cst":
require_once("classes/Cases.php");
$cases = new Cases();
$resultMap = $cases->process($internalObj, $sessionObj);
break;
.
.
.
}
</code></pre>
<p>In the JBoss Java EE environment, when I am in an Stateless Session Bean and I do a local
look up to another Stateless Session Bean (different classes), the objects are handed
to the method of the other class BY REFERENCE.</p>
<p>Now I know that, in PHP, when you are in the same class and you pass one object to another method of the same class, the object is passed per reference (or more accurately the reference is passed by value).</p>
<p>But, as in the example above, if I pass the "sessionObj" object from facade.php to the instance of another class (cases), which is in another file, it seems that it is NOT possible to pass objects per reference.</p>
<p>Is my assumption correct? </p>
<p>Is there another way to pass per reference in this situation (from object to object when the classes in separate files)?</p>
| php | [2] |
918,526 | 918,527 | ImageView and set position | <p>I have imageView in activity. How I can set position this imageView in my activity. I know how I can do this in xml file but I want to do this in activity, because I have onTouch method where I get coordinates where I clicked and I want to draw this images in this coordinates.</p>
| android | [4] |
4,078,879 | 4,078,880 | Generte resource ID at runtime? | <p>I am writing a custom preference with a seek bar, so far it works, except for one problem the ID of my seek bar is defined in XML, so when I try to use 2 of my custom prefernces and then I update the Seek Bar I cannot distinguish between the two.</p>
<pre><code>SeekBar bar = (SeekBar)view.findViewById(R.id.PreferenceSeekBar);
</code></pre>
<p>Is there a way to generate a custom Resource ID at runtime?
Or perhaps another way to solve this? </p>
<p>Thanks,
Jason</p>
| android | [4] |
1,364,413 | 1,364,414 | script printing out first part of array twice | <p>I have a script that i wrote, but it prints the first part of the array twice. </p>
<p>The output that i get is the following: </p>
<p>2009_06_09_02_07_57_Phase2_04.jpg
2009_06_09_02_07_33_Phase2_03.jpg
2009_06_09_02_07_57_Phase2_04.jpg</p>
<p>The code is below:</p>
<pre><code> $currentPath = $path.'images/galleries/phase2/folder1/';
$dirNew = opendir($currentPath);
while ($file = readdir($dirNew)) {
if($file != "." && $file != ".." && $file != "Thumbs.db" && $file != "index.html" && $file != "index.php") {
$dirArray[] = $file;
$indexCount = count($dirArray);
sort($dirArray);
for($i=0; $i < $indexCount; $i++) {
print $dirArray[$i].'<br />';
/*echo '<br /><a href="'.$currentPath.$dirArray[$i].'" title="image 1" class="thickbox" rel="phase 2">
<img src="'.$currentPath.$dirArray[$i].'" width="75" height="75" border="0"></a><br /><br />
Click image <br />for slideshow';*/
}
}
}
closedir($dirNew);
}
</code></pre>
<p>Any pointers in the right direction will be welcome. </p>
<p>Thanks in Advance</p>
| php | [2] |
1,936,683 | 1,936,684 | how to write vb code for custom paging and custom sorting in sql and asp:repeater | <p>pl give vb code for custom paging and sorting in asp:repeater using stored procedure</p>
| asp.net | [9] |
1,683,185 | 1,683,186 | How to distinguish if given Context object is an Activity or a Service Context? | <p>I would like to know if my given Context object is from Activity, Service or Application. Or in other words if my code is executing in background or in foreground. (By foreground i mean Activity code and threads that have been created by Activity.)</p>
| android | [4] |
4,332,141 | 4,332,142 | Reading a file from a url and copying to another location with a url path | <p>In C#, is there a way to read a file from a url path and then creating a copy at the location of the url path? Most examples I've seen are able to read something from a url path, but copies it to the local machine.</p>
| c# | [0] |
1,086,716 | 1,086,717 | increase or decrease quantity form in mobile | <p>i am trying to make make a product quantity form.</p>
<p>which can increase or decrease quantity form by touching(tapping) button...</p>
<p>but its hard to make jquery script to me... can anyone help me plz ?</p>
<p>here is my html code</p>
<pre><code><span><input type="text" name="minus" class="minus"></span>
<span><input type="text" name="quantity" value="1" class="result"></span>
<span><input type="text" name="plus" class="plus"></span>
</code></pre>
| jquery | [5] |
2,744,651 | 2,744,652 | Match returning null in JavaScript | <pre><code>var regEx = new RegExp("/[0-9]/");
var test = 'TREE'
alert(test.match(regEx));
</code></pre>
<p>or</p>
<pre><code>var regEx = new RegExp("/[0-9]/");
var test = '1234'
alert(test.match(regEx));
</code></pre>
<p>Why do they return null?</p>
<p>Am i missing something here?</p>
<p>(Ok, the debate mentally drained me last night)</p>
| javascript | [3] |
4,991,821 | 4,991,822 | Email sending via Android Application | <p>I want to send email from my application without configuration email in android device.
can we do this?? we click a button and mail will automatically to the recipient.</p>
<p>I have used the following code. where we can give the sender name.
and can we send mail via android emulator.</p>
<p>Thanx.</p>
<pre><code> Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL , new String[]{"abc@example.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "Request For Quote");
intent.putExtra(Intent.EXTRA_TEXT , "Hi....");
try {
//startActivity(Intent.createChooser(intent, "Send mail..."));
startActivity(intent);
//Toast.makeText(SendingEmailActivity.this, "Mail Sent Successfully", Toast.LENGTH_SHORT).show();
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(DemoActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
</code></pre>
| android | [4] |
4,199,887 | 4,199,888 | python 2.7 Prototyping/forward reference | <p>I want to do something like this in Python. I took out what we are really doing and replaced it with this ridiculous example that will really never end. Please assume the calls from a<==>b are finite. Our code does have the logic to end the cycle.</p>
<p>I am worried that I will get an error for calling b in a before b is defined. However, I read that as long as I don't make a call that executes a before def b then I should have no problem. What is the real answer here? And what is python doing behind the scenes to make it not exit on line 2 (b())</p>
<pre><code>def a():
b()
def b():
a()
b()
</code></pre>
| python | [7] |
685,720 | 685,721 | Adding a comment in passworded zip makes it damaged | <p>iam using zip uploader
and this zip passworded
ok?
when upload it and download and extract it with the password it work good
but
when upload it and use<code>$zip->setArchiveComment();</code> to add comment in it
and download then trying to extract tell me the password incorrect
and that is happing in the server only
in the local host every thing is good</p>
| php | [2] |
2,265,099 | 2,265,100 | Conversion of a Char variable to an integer | <p>why is the integer equivalent of '8' is 56 in C sharp? I want to convert it to an integer 8 and not any other number.</p>
| c# | [0] |
5,129,840 | 5,129,841 | PNG transparency and touches in android | <p>I have a png, when I save it it is a square image, but inside the square png is a circle (sometimes its other shapes). How can I check when the user is over what is inside the png and a graphic rather than when a user is inside a png but is over transparency?</p>
| android | [4] |
5,015,814 | 5,015,815 | Sufficient Method for Testing Equality | <p>I want to implement a custom <code>equals()</code> method for a class I have, <code>Board</code>. The method compares the arrays of each board, defined as <code>private int[] board</code>, returning true if the arrays are equal and false if they are not. I know there are some "gotchas" in testing equality, so I was wondering if the following code was optimal and sufficient for truly testing the equality: </p>
<pre><code>public boolean equals(Object y) {
if (this.getClass() != y.getClass()) return false; //must be same class -- duh
Board that = (Board) y; //y cast as Board
int[] thisBoardCopy = this.getBoard(); //copy of current board
int[] thatBoardCopy = that.getBoard(); //copy of y's board
return Arrays.equals(thisBoardCopy, thatBoardCopy);
}
</code></pre>
| java | [1] |
2,827,915 | 2,827,916 | Call a common function before every onclick function | <p>Current Code</p>
<pre><code><a onclick="callMe1()">Click Me</a>
<a onclick="callMe2()">Click Me 2</a>
function callMe(){
//anything
}
function callMe2(){
//anything
}
</code></pre>
<p>and so on... I have hundreds of onclick event functions.</p>
<p>I want to add this function which should be called before any onclick event function.</p>
<pre><code>function callBeforeAnyOnClick(){
//This should be executed before callMe() and callMe2().
//once execution is complete, it should call a function as per onclick event,callMe() or callMe2().
}
</code></pre>
<p>Any solution? Will jquery bind work here?</p>
| jquery | [5] |
3,576,847 | 3,576,848 | Starting Activities in a looping chain | <p>I have three Activities, which are started in a chain. ActivityA starts ActivityB, which then starts ActivityC. I also have an Application object.</p>
<p>ActivityA starts ActivityB with (this snippet is actually in an anonymous class, so it needs <code>getApplicationContext()</code> instead of <code>this</code>).</p>
<pre><code>startActivity(new Intent(getApplicationContext(), ActivityB.class));
</code></pre>
<p>ActivityB starts ActivityC with</p>
<pre><code>startActivity(new Intent(this, ActivityC.class));
</code></pre>
<p>In ActivityC, if the user wants to go back to ActivityA, he will click a Button that invokes</p>
<pre><code>startActivity(new Intent(getApplication(), ActivityA.class));
</code></pre>
<p>My question is, is this the correct way to do this while avoiding memory leaks?</p>
| android | [4] |
5,627,923 | 5,627,924 | Linked list in Java - comparing two lists | <p>I need to create a recursive method in java which checks two Char lists.
If the second list includes all the chars in the first list at least once and in the same order it should return true, else it should return false.
for example:</p>
<p>List 1: "abbcd"(every char in a node), List 2: "abbcccddd"(every char in node) This should return true.</p>
<p>Example 2: "abbcd", List 2: "abcd" this should return false.</p>
<p>I have some ideas but can't reach a definite solution.
Ideas anyone?</p>
| java | [1] |
5,189,543 | 5,189,544 | how to upload large files via fileupload controller in asp.net | <p>I am using file upload controller for uploading documents.Here when I'm using files of size say 30mb I'm getting an error saying </p>
<blockquote>
<p>"The connection to the server was reset while the page was loading.".</p>
</blockquote>
<p>Its not even going to the upload button click event.</p>
<p>File upload controller working fine for files having smaller size.</p>
<p>I'm uinsg VS2005 and C#.</p>
| c# | [0] |
5,476,328 | 5,476,329 | onClick event is not working in safari browser but it working Fine in IE/FF/Chrome/Opera browser? | <p>Hello expert i got one issue and i need your help.</p>
<p>I am using javascript onClick event it's working good with IE/FF/Chrome browser but it not working for safari browser, I have wasted my 2 days on it but not able to resolve it so i need your help it too urgent for me.</p>
<p>The code which i am using are as follows:</p>
<pre><code>heartSelectHandler = {
clickCount : 0,
action : function(select)
{
heartSelectHandler.clickCount++;
if(heartSelectHandler.clickCount%2 == 0)
{
selectedValue = select.options[select.selectedIndex].value;
heartSelectHandler.check(selectedValue);
}
},
blur : function() // needed for proper behaviour
{
if(heartSelectHandler.clickCount%2 != 0)
{
heartSelectHandler.clickCount--;
}
},
check : function(value)
{
alert('Changed! -> ' + value);
}
}
<select onclick="javascript:heartSelectHandler.action(this);" onblur="javascript:heartSelectHandler.blur()" id="heart" data-role="none">
<?php for ($i = 20; $i <= 150; $i++): ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
</code></pre>
| javascript | [3] |
2,374,211 | 2,374,212 | Keypress events python please help looping sticky keys? | <p>I am wanting to loop the sticky keys to create the annoying "sticky keys" noise. (click shift key 5 times enter key once)
please can someone provide me with information on what i need to do, and or a short script? any help will be much appreciated.(for python)
would i need to insert the keys byte?</p>
| python | [7] |
1,571,914 | 1,571,915 | php 2d array ... store mysql results in 2d array | <p>I have a sql statement that returns a number of records each having 10 attributes. How can i get the data and put it into a 2D array. Currently Im doing this :</p>
<pre><code>while($row1 = mysql_fetch_array($result1))
{
echo $row1[0][1]; //There is an error here
}
</code></pre>
<p>Is $row1 a 2D array? (It should be because Im getting n*m results). If $row1 is a 2d array then shouldn't i be able to access $row[0][1]?</p>
| php | [2] |
5,816,289 | 5,816,290 | Third party controls and scripts | <p>Looking for a good resource to find asp.net controls and such. I don't mind purchasing them so open source is not my only consideration.</p>
<p>I have a social site that I want to build but I do not want to reinvent the wheel. Things like membership and user managment, banner ad managment, forums etc.. are common features in most any social site so i was hoping to purcahase that code.</p>
<p>I have considered DotNetNuke but this is a learning project and not every organization uses DNN so I figure I can learn things about ASP.Net dev by writng my own app that I would not by using DNN.</p>
| asp.net | [9] |
441,479 | 441,480 | SetConsoleTextAttribute : Foreground only | <p>I would like to change ONLY the foreground color text of my console application, not the background text color nor the console background color. In Other words: I want to keep previous colors like they are except the foreground text color.</p>
<p>Presently i use the code below but the background under the text change too.</p>
<pre><code>#include <windows.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
cout << "green?" << endl;
cin.ignore();
return 0;
}
</code></pre>
| c++ | [6] |
2,501,164 | 2,501,165 | Can someone please explain what this means Javascript | <p>What is it asking me to do? I am having trouble understanding what is actually needed here.... </p>
<blockquote>
<p>Write the function setImage(). It will take one argument, the slot index. It should do the following:</p>
<ul>
<li>Randomly choose the index of the array above. (This array is images)</li>
<li>Set the slot indexed by the argument to the be file name indexed by the random index
(Remember your testing for step 1. Instead of a string literal, you should use an element of the array images.).</li>
</ul>
</blockquote>
| javascript | [3] |
2,232,672 | 2,232,673 | How to Change Background When You Pass a Certain Point on Page using jQuery | <p>I have a sidebar and the various sections on a page. The sidebar floats left and the sections float right. I would like the sidebar color/background to change when it passes each section, so when it is on the first section it is red, second section blue and third section green. I have attached an example with the HTML/CSS. If someone could help me fill in the jQuery, that would be awesome.</p>
<p><a href="http://jsfiddle.net/fkYZp/" rel="nofollow">http://jsfiddle.net/fkYZp/</a></p>
| jquery | [5] |
5,096,619 | 5,096,620 | Android ACTION_SEARCH isn't working | <p>...</p>
<p>I need to implement search feature to my application via search dialog, but the standard way of doing that isn't working where the same code and activity work for SEARCH_LONG_PRESS but doesn't work for SEARCH. Here's my manifest file:</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.myapp"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="preferExternal">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Main"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.default_searchable"
android:value=".ObjectSearch" />
</activity>
<activity android:name=".ObjectSearch">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH_LONG_PRESS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
</application>
</manifest>
</code></pre>
| android | [4] |
2,836,722 | 2,836,723 | seekBar and refresh | <p>I've a seekBar and I can increase and decrease text size but I've a problem: when I change tha value by seekBar and press a button (x++) new TextSwitched is ok but if again I press I've old value (text decreased). Pressing again I've new value... Reading logs values doesn't change when I press button. Value changes only when use seekBar. Thanks for patience.</p>
<pre><code>seekBar1.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
if(seek<10)
{
seek=10;
seekBar1.setProgress(seek);
}
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
// TODO Auto-generated method stub
seek=progress;
TextView t = (TextView) mSwitcher.getChildAt(0);
t.setTextSize(seek);
Log.i("MyActivity", "MyClass.getView() — list " + seek);
SharedPreferences prefs = getSharedPreferences(PRIVATE_PREF, 0);
SharedPreferences.Editor editor = prefs.edit();
editor.putInt("seek", seek);
editor.putInt("progress", progress);
editor.commit();
</code></pre>
<p>Button:</p>
<pre><code>button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
x++;
mSwitcher.setText(""+prog[x]);
</code></pre>
<p>public View makeView() {
TextView t = new TextView(this);</p>
<pre><code>return t;
</code></pre>
| android | [4] |
5,438,312 | 5,438,313 | Wifi hotspot/ Teather connected users | <p>I wanna find the name of the users , who are all connected through my wifi hotspot in my android (non-rooted mobile).</p>
<p>I had tried to get the users ipAddress by using ping..But that giving me Exception
arp -a</p>
| android | [4] |
5,778,842 | 5,778,843 | Jquery: ajax post and encoding | <p>I am unable to understand why I can't get a correct ISO-8859-1 charstet from the server answer. Being this a work on legacy code, i hardly could change charset encoding on the pages.</p>
<p>I make use of the JQuery call</p>
<pre><code>$.post("server-side-code", {t:ctext, i:ioff, sid:sessionid}, function(data, status) { $('#chk').append(data); });
</code></pre>
<p>posting a textarea value created using javascript:</p>
<pre><code><form accept-charset='ISO-8859-1' method='post'>
<textarea cols='40' rows='8' id='commento'></textarea><br>
<input type='button' value='invia' id='submit'></form>
</code></pre>
<p>The server side script processing the request declares at its very top:</p>
<pre><code>text/html; charset=ISO-8859-1
</code></pre>
<p>so, honestly, I can't figure out what else I should declare, in terms of encoding. This notwithstanding, the accented characters "àèéìòù" bounce back as: "à èéìòù" when placing the server answer in an HTML element</p>
<p>The source is saved as ascii. Tryng to do this to have rudimentary Html encoding on the variable to be posted does not solve:</p>
<pre><code>ctext = escapeHTML(ctext);
function escapeHTML (str)
{
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
};
</code></pre>
<p>Some idea?</p>
<p>Thanks!</p>
| jquery | [5] |
3,826,185 | 3,826,186 | Java - specify the IP to run from | <p>I have a server with 2 IPs (example: 192.168.1.1 and 192.168.1.2) and a Java process that I want to run. The servers default IP is what it runs from if I start it, but I want the process to run from the secondary IP.</p>
<p>Is this possible <em>without</em> create virtual machines and running from inside those? </p>
| java | [1] |
1,924,845 | 1,924,846 | Error stating can't convert 'char' to 'string' | <pre><code>const char * path=@"C:\Documents and Settings\QI_3664\Desktop\senthur.prt";
</code></pre>
<p>this is the line which is giving the problem.</p>
<p>At first it reported that escape sequence is missing, later when I added the <code>@</code> symbol it started reporting that 'char' can't be converted to'string' </p>
<p>Pls someone help me in resolving this. Thanks in advance.</p>
<p>The same line works well in c++. I compiled both the programs in Visual Studio 2005.</p>
| c# | [0] |
3,422,857 | 3,422,858 | how to use foreach loop to edit textboxes | <pre><code>foreach(textbox t in this.controls)
{
t.text=" ";
}
</code></pre>
<p>I want to clear all the textboxes in my page at one time.</p>
<p>I am getting an error:</p>
<blockquote>
<p>Unable to cast object of type 'System.Web.UI.LiteralControl' to type
'System.Web.UI.WebControls.TextBox'.</p>
</blockquote>
| c# | [0] |
1,512,752 | 1,512,753 | In this code how to stop after found or not found string using python | <pre><code>import win32com.client
objSWbemServices = win32com.client.Dispatch(
"WbemScripting.SWbemLocator").ConnectServer(".","root\cimv2")
for item in objSWbemServices.ExecQuery(
"SELECT * FROM Win32_PnPEntity "):
found=False
for name in ('Caption','Capabilities '):
a = getattr(item, name, None)
if a is not None:
b=('%s,' %a)
if "Item" in b:
print "found"
found = True
else:
print "Not found"
break
</code></pre>
<p>I want only One time to display "found" else "not found"</p>
| python | [7] |
4,064,290 | 4,064,291 | frame-by-frame animation API compatibilty | <p>I am using the following code to set Frmae-by-frame animation :</p>
<pre><code> public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
final ImageView back = (ImageView) findViewById(R.id.splash_image);
back.setBackgroundResource(R.drawable.splash_animation);
AnimationDrawable frameAnimation = (AnimationDrawable) back.getBackground();
// Start the animation (looped playback by default).
frameAnimation.setExitFadeDuration(2000);
frameAnimation.start();
}
</code></pre>
<p>However, the <code>setExitFadeDuration</code> only works after API level 11. Is there an alternative to the code that I used to make the animation compatible with API 7 onwards</p>
| android | [4] |
5,564,203 | 5,564,204 | Java Iterators | <p>What is an external and internal iterator in Java ?</p>
| java | [1] |
3,297,885 | 3,297,886 | Text from the array isn't being read | <p>I am trying to create an IRC Bot, below is the code, however, when it runs, it will not detect "001" whatever I try, I'm running it on JRE6 and using JDK6. I'm developing it with Eclipse and using the debug feature to run it. I've tried with both "java.exe" and "javaw.exe". When running, debugex shows 001 is clearly there.</p>
<p>Here is my code:</p>
<pre><code>package bot;
import java.io.*;
import java.net.*;
public class Main {
static PrintWriter out = null;
@SuppressWarnings("unused")
public static void main(String[] args) {
Socket sock = null;
BufferedReader in = null;
try {
sock = new Socket("irc.jermc.co.cc",6667);
in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
out = new PrintWriter(sock.getOutputStream(), true);
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
boolean sentconnect = false;
while(sock.isConnected() == true){
if(sentconnect == false){
writeout("NICK GBot");
writeout("USER GBot GBot GBot :GBot");
sentconnect = true;
}
String data = "";
try {
data = in.readLine();
} catch (IOException e) {
e.printStackTrace();
}
data = data.trim();
if(data != ""){
System.out.println("[IN] " + data);
}
String[] ex;
ex = data.split(" ");
for(String debugex : ex){
//System.out.println("DEBUGEX: " + debugex);
}
if(ex[1] == "001"){
writeout("JOIN #minecraft");
}
try {
Thread.sleep((long) 0.5);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(ex[0] == "PING"){
writeout("PONG " + ex[1]);
}
}
}
private static void writeout(String msg) {
out.println(msg);
System.out.println("[OUT] " + msg);
}
}
</code></pre>
| java | [1] |
3,025,705 | 3,025,706 | IDE for CodeIgnitor framework | <p>i am going to use codeignitor php framework to develop web application. now i am confused about using IDE. I do not know which IDE is best suitable for codeingitor framework. is there any one who can help me in this regard.</p>
<p>thanks.</p>
| php | [2] |
4,572,189 | 4,572,190 | Javascript Src Path | <p>Hello I'm having some trouble with the following code within my Index.html file:</p>
<pre><code><SCRIPT LANGUAGE="JavaScript" SRC="clock.js"></SCRIPT>
</code></pre>
<p>This works when my <code>Index.html</code> file is in the same folder as <code>clock.js</code>. Both Index.html and clock.js are in my root folder.</p>
<p>But when my index.html is in these different directories clock.js does not load:</p>
<pre><code>/products/index.html
/products/details/index.html
</code></pre>
<p>What can I put as the 'SRC' so that it will always look for <code>clock.js</code> in the root folder?</p>
<p>Thanks in advance!!</p>
| javascript | [3] |
2,490,307 | 2,490,308 | hashset datatype | <p>How to declare a headset using double as datatype?</p>
<pre><code>public HashSet priceSet() {
Set<double> hSet = new HashSet<double>(); //<==== netbeans warn this line
for (Map.Entry<String, Tablet> entry : tableMap.entrySet()) {
hSet.add(entry.getValue());
}
return (HashSet) hSet;
}
</code></pre>
<p>what's the problems of this line?
Set hSet = new HashSet();</p>
| java | [1] |
5,060,402 | 5,060,403 | How to write DATA type in PHP select query | <p>I would like to execute query in PHP and retrive data from the table by SELECT. My problem is that I have to do it by the field which is DATE type and I don't know how to write it in SELECT
Thanks in Advance </p>
| php | [2] |
1,703,170 | 1,703,171 | Is it possible to display ASCII characters in Javascript's pop up confirm() or alert()? | <p>Is it possible to display characters like <code><</code>, <code>></code>, <code>'</code>, etc in Javascript's pop up <code>alert()</code> or <code>confirm()</code>?</p>
<p><code><</code> is automatically changed to <code>&lt;</code></p>
<p>etc. </p>
<p>The same still occurs if I change the symbols to their unicode like <code><</code> to <code>\u003c</code> etc. </p>
| javascript | [3] |
3,757,244 | 3,757,245 | What is the most efficient way to find the last digit of an int in C++ | <p>I want to try writing my own BigInt Class so I am wondering what would be the most efficient way to find the last digit of a number in C, especially for an input that would be an extremely large int.</p>
| c++ | [6] |
2,548,224 | 2,548,225 | Beginner: While loop not functioning properly, syntax errors, displays nothing | <p>I am working through some Looping exercises, While statements in particular. Here are the instructions:</p>
<blockquote>
<p>2.2) Modify the program so that it asks users whether they want to guess again each time. Use two variables, number for the number and answer for the answer to the question whether they want to continue guessing. The program stops if the user guesses the correct number or answers "no". (In other words, the program continues as long as a user has not answered "no" and has not guessed the correct number.)</p>
</blockquote>
<p>Here is my code:</p>
<pre><code>#!usr/bin/env python
#
#While statement
number = 24
while number != 24:
answer = raw_input("Guess my lucky number! Do you want to keep guessing?")
if number == 24:
print "You got it! That is great!"
elif answer == "no":
print "Thank you for playing."
else:
print "That is not the right answer! Try again."
</code></pre>
<p>When I run the module in IDLE, the end quote of That is great!" - becomes red and says invalid syntax. In terminal if I run $ python while.py nothing loads. I've tried writing this as Python 3 functions with print("") but it still does not run.</p>
<p>Thanks to anyone who can help with this.</p>
| python | [7] |
3,357,000 | 3,357,001 | What is a frozen icicle? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/919153/what-is-androids-icicle-parameter">What is android's icicle parameter?</a> </p>
</blockquote>
<p>I've seen the term "frozen icicle" used in several places in the Android API documentation, but nowhere have I ever seen it <i>explained</i>. What is a frozen icicle? I had at first thought that it meant the triangles used when selecting text, but now I wonder if it has something to do with saved instance state.</p>
| android | [4] |
2,000,609 | 2,000,610 | Getting Color Values C# | <p>I'm having trouble with this one problem. I'm trying to compare Color RGB in a list
and sort them by there RGB. I've thought about adding it to a dictionary but don't know exactly how to get the values of the colors once their added to the Dictionary. So how would can I get the RBG of color in a list to compare them with one another. Any help or advice and I will be grateful, thanks.</p>
| c# | [0] |
1,427,959 | 1,427,960 | Disable the 'save image' menu on iPhone with Javascript | <p>Have a photography site that I want to prevent image copying from. How can I disable the save image menu that pops up on an iPhone when you hold down your finger on an image?</p>
| iphone | [8] |
2,287,013 | 2,287,014 | How to fill the 'Application' column in LogCat (Android-14+) | <p>Starting from android sdk and Eclipse plugin 14 (Android 4.0), the LogCat view includes a column "Application". This column is empty when I write log messages, but contains the package name of my application when android system code is executed in the context of my application.</p>
<p>It would be neat to be able to filter by Application to get all relevant log output; but I cannot find any documentation on how to set this... any ideas?</p>
| android | [4] |
1,416,902 | 1,416,903 | which database to use | <p>I am developing an App in which I need to authenticate password, store user personal information and setting details / preferences. All these are user-mobile specific or rather App specific and are unique for each user,the password and settings info should not be lost once phone is switched off or user exits the App, which data storage rocedure is recommended for such App?</p>
| android | [4] |
719,831 | 719,832 | how can we call webservice through background service | <p>i am using a web service. i have to start that particular service at every 6 hrs interval, automatically . i want to perform this task with alarm manager. but i have no idea.</p>
| android | [4] |
2,731,902 | 2,731,903 | Class selector not working | <p>I'm doing z-index management by class .. so the active object gets the class topmost ..</p>
<pre><code>function topmost() {
$(".topmost").removeClass("topmost");
$("#thing").addClass("topmost");
}
</code></pre>
<p>This code doesn't seem to be working, and I can't fathom why ..</p>
<p>== EDIT ==</p>
<p>The problem is that <code>$(".topmost").removeClass("topmost");</code> is finding zero results when there are several on the page. I use this class selector often and have never had this issue. The class is being added by jQuery in the first place, but it should see it anyway. I look in my inspector and log the selection and it comes up with zero when I can see the at least 3 divs with the class. It is a function nested in an object, is that a problem? Can it scope out of the object and search the whole DOM?</p>
| jquery | [5] |
3,058,217 | 3,058,218 | Is it possible to change PHP error layout (i.e. orange box)? | <p>Is it possible to change the way PHP formats its error messages? I'm on PHP 5.3.5, using the default error output settings, and was hoping I could change the layout in some .ini or config file. The standard way PHP displays error message I find somewhat hard to read. </p>
<p>For clarity, I'm talking about errors that are displayed on my page. Also, I'm not talking about different types of errors. I'd just like to change the orange box and exclamation mark and the way the call stack is displayed. As the error is rendered in my browser, perhaps there's a template somewhere in the installation files that I could change?</p>
<p>I apologize to all orange-box disciples out there. </p>
| php | [2] |
710,146 | 710,147 | How to merge two arrays of objects | <p>A:</p>
<pre><code>Array (
[0] => gapiReportEntry Object (
[metrics:private] => Array (
[visits] => 1036
[pageviews] => 2046
[bounces] => 693
[entrances] => 1036
)
[dimensions:private] => Array (
[date] => 20110114
)
)
)
</code></pre>
<p>B:</p>
<pre><code>Array (
[0] => gapiReportEntry Object (
[metrics:private] => Array (
[goal1Completions] => 1
)
[dimensions:private] => Array (
[date] => 20110114
)
)
)
</code></pre>
<p>C:</p>
<pre><code>Array (
[0] => gapiReportEntry Object (
[metrics:private] => Array (
[visits] => 1036
[pageviews] => 2046
[bounces] => 693
[entrances] => 1036
[goal1Completions] => 1
)
[dimensions:private] => Array (
[date] => 20110114
)
)
)
</code></pre>
<p>I want to merge(A,B) and get C.</p>
| php | [2] |
3,766,538 | 3,766,539 | Setting focus on hidden textbox field using Javascript | <p>How can I set focus on hidden textbox element?</p>
<p>I tried using </p>
<pre><code>document.getElementById("textControl_fd_component_JSON_TASK_NStext64").focus;
</code></pre>
<p>But, this does not work here </p>
<pre><code>alert(document.activeElement.id); returns null.
</code></pre>
<p>When I made this field visible, above script worked fine. </p>
<p>Any guesses where I am getting it wrong?</p>
| javascript | [3] |
3,990,644 | 3,990,645 | Cannot set boolean values in LocalStorage? | <p>i noticed that i cannot set boolean values in <code>localStorage</code>?</p>
<pre><code>localStorage.setItem("item1", true);
alert(localStorage.getItem("item1") + " | " + (localStorage.getItem("item1") == true));
</code></pre>
<p>always alerts <code>true | false</code> when i try to test <code>localStorage.getItem("item1") == "true"</code> it alerts true ... so no way i can set an item in <code>localStorage</code> to true?</p>
<p>even if its a string, i thought only <code>===</code> will check the type? </p>
<p>so </p>
<pre><code>alert("true" == true); // shld be true?
</code></pre>
| javascript | [3] |
5,138,794 | 5,138,795 | Apply filter to business object | <p>Can someone help me how to filter data from business object?</p>
<p>Here is my sample code: </p>
<pre><code>var allemps = empService.GetAllEmployees();
IEnumerable<Emp> emps;
if (allemps.IsFreeOfErrors)
{
emps = allemps.Value.Contains("abc");
}
</code></pre>
<p>here <code>allemps.Value</code> is returning all employee data. But I want to filter <code>emps</code> whose name starts with "abc". How do I do this?</p>
| c# | [0] |
5,464,704 | 5,464,705 | How can one find Class of calling function in python? | <p>I am trying to determine the owning class of a calling function in python. For example, I have two classes, ClassA and ClassB. I want to know when classb_instance.call_class_a_method() is the caller of class_a.class_a_method() such that:</p>
<pre><code>class ClassA(object):
def class_a_method(self):
# Some unknown process would occur here to
# define caller.
if caller.__class__ == ClassB:
print 'ClassB is calling.'
else:
print 'ClassB is not calling.'
class ClassB(object):
def __init__(self):
self.class_a_instance = ClassA()
def call_class_a_method(self):
self.class_a_instance.class_a_method()
classa_instance = ClassA()
classa_instance.class_a_method()
classb_instance = ClassB()
classb_instance.call_class_a_method()
</code></pre>
<p>the output would be:</p>
<pre><code>'ClassB is not calling.'
'ClassB is calling.'
</code></pre>
<p>It seems as though <strong>inspect</strong> should be able to do this, but I cant puzzle out how.</p>
| python | [7] |
2,666,511 | 2,666,512 | I just need to override show() for the Toast class | <p>I just need to override the <code>show()</code> method for the <code>Toast</code> class. I created a class which extends <code>Toast</code> class, but then I create a toast message I get an exception the <code>setView(View view)</code> hasn't been called. But I don't want to create a custom <code>View</code> for the method but use the default one. </p>
<p>So, how is that possible to override the only <code>show()</code> method without creation of custom <code>View</code> for the <code>setView(View view)</code> method?</p>
<p>Here is what I do:</p>
<pre><code> MyOwnToast m = new MyOwnToast(getApplicationContext());
m.makeText(getApplicationContext(), "Bla bla bla", Toast.LENGTH_LONG);
m.show();
</code></pre>
<p>And my custom toast is here:</p>
<pre><code>public class MyOwnToast extends Toast {
public MyOwnToast(Context context) {
super(context);
}
@Override
public void show() {
super.show();
Log.i("Dev", "
}
</code></pre>
<p>Also it is stated on the <a href="http://developer.android.com/guide/topics/ui/notifiers/toasts.html#CustomToastView" rel="nofollow">dev site</a>:</p>
<blockquote>
<p>Note: Do not use the public constructor for a Toast unless you are
going to define the layout with setView(View). If you do not have a
custom layout to use, you must use makeText(Context, int, int) to
create the Toast.</p>
</blockquote>
<p>How I can override the <code>show()</code> method then?</p>
| android | [4] |
5,103,936 | 5,103,937 | How to access a variable state from before an ajax request in the call back function | <p>EG</p>
<pre><code>for(i in an_object){
$.getJSON("http//www...." + "?callback=?",'', function(data){
// do something using what the value of i from when the JSONP request was sent
// but i is always the last value in an_object because the loop
// has finished by the time the callback runs.
);
});
}
</code></pre>
| javascript | [3] |
3,672,665 | 3,672,666 | How can I balance the load of a UI across several processor cores? | <p>I am running a C# winform application that shows huge number of statistics and charts frequently. This application consist of multiple forms, each form has different output. When I open the task manager and check out the cpu usage, I find that only one core out of my eight cores is over loaded and the rest are doing nothing!
Is there a way, for example, to assign each number of forms to a core. I need to improve the perfomance. </p>
<p>What I am looking for is to multithread my winforms such that each form would have a different thread that is running on a different core. Is that possible ?</p>
<p>The bottleneck is happening from loading the data into the controls.</p>
| c# | [0] |
3,821,031 | 3,821,032 | Angry birds like Floating menu on Android | <p>Does anyone know how to make a floating menu like the ones in Angry Birds home screen? </p>
<p>Here is a picture showing the menu buttons in collapsed mode (gear, up buttons). On tapping these buttons, the actual menu would expand, showing two or more round buttons.</p>
<p><img src="http://i.stack.imgur.com/KAtcI.jpg" alt="alt text"></p>
<p>Any links, clues is much appreciated. </p>
| android | [4] |
5,689,373 | 5,689,374 | how to ensure only after service(started in alarmreceiver) finish its job the alarm should be called again | <p>I have a alarm receiver start a service for every 5 mins. In the service Iam synching my database with a server. if the server splits the packets and send. I need to send the request again with a session id. The problem is when i do that i want the alarmreciever to wait until the service finish its work. ie only when i get all the packets the next 5mins should be counted. my alarm receiver:</p>
<pre><code>public class OnBootReceiver extends BroadcastReceiver {
private static final int PERIOD = 60000; // 1 minute 300000 for 5 min
@Override
public void onReceive(Context context, Intent intent) {
AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
Intent i=new Intent(context, OnAlarmReceiver.class);
PendingIntent pi=PendingIntent.getBroadcast(context, 0,i, 0);
mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime()+60000,PERIOD,pi);
}
}
</code></pre>
<p>and my Appservice</p>
<pre><code>public class AppService extends WakefulIntentService {
public AppService() {
super("AppService");
}
@Override
protected void doWakefulWork(Intent intent) {
//connecting to server and getting data here.
Log.v(null, "wake up");
...
while (syncstaus.equals("more"){
// send request again
}
}
}
</code></pre>
<p>only after the loop finishes i want the alarm to start again. how can i do this. please throw some light on how this works</p>
<p>Thanks in advance</p>
| android | [4] |
3,151,176 | 3,151,177 | Partial Javascript Statements Logged To Server | <p>I have some code that generates URLs to be used in various places across a site (image src, link hrefs, etc). I am seeing lines in the access logs which show some of the <em>javascript code</em> that generates the URLs masquerading as a file request.</p>
<p>For example, "/this.getIconSrc()" is one that I'm seeing quite a bit. I can't figure out how or why this is occurring and I can't manage to reproduce it without actually entering "http://whateverthesiteis.com/this.getIconSrc()" into the location bar. In most cases, these functions are chained together to generate a URL but the whole function chain does not appear in the server logs, just part of it.</p>
<p>I've probably invested around 30 hours trying to figure out why this is happening but cannot. It doesn't appear to be a browser issue as I've tried in IE 6/7, FF 2/3, Opera, Safari 3, and the problem does not occur. Has anyone else experienced something similar and, if so, what was the solution?</p>
| javascript | [3] |
1,362,247 | 1,362,248 | sharedpreferences that don't change from activity to activity? | <p>If i set a sharedpreference in one activity, why does the other one has different preferences? context changed? (but i se use application context!)</p>
<p>Here is my code</p>
<pre><code>MyApp appState = ((MyApp)this.activity.getApplicationContext());
appState.setDittaSelezionata( (int) itemId);
</code></pre>
<p>....</p>
<pre><code>MyApp appState = ((MyApp)this.getApplicationContext());
int ditta_id_selezionata = appState.getIdSomething();
</code></pre>
<p>And</p>
<pre><code>public class MyApp extends Application implements Parcelable {
private SharedPreferences getSharedPrefs()
{
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
//SharedPreferences settings = this.getSharedPreferences(MyApp.PREFS_NAME, this.MODE_PRIVATE);
return settings;
}
public int getIdSomething() {
SharedPreferences settings = this.getSharedPrefs();
return settings.getInt("ditta_id_selezionata", 0);
}
public void setDittaSelezionata(final int ditta_selezionata) {
SharedPreferences settings = this.getSharedPrefs();
SharedPreferences.Editor editor = settings.edit();
editor.putInt("ditta_id_selezionata", ditta_selezionata);
// Commit the edits!
editor.commit();
}
</code></pre>
<p>...</p>
<p>How can i make global preferences that are shared among all activities android 3.2? is there something android provides or i have to code a save to file/open to file and add it for each activity onStop() / onCreate() ?</p>
| android | [4] |
2,569,004 | 2,569,005 | executing WIFIDirectDemo sample with multiple android emulators | <p>I want to try the sample Wifi Direct Demo </p>
<p><a href="http://developer.android.com/resources/samples/WiFiDirectDemo/index.html" rel="nofollow">http://developer.android.com/resources/samples/WiFiDirectDemo/index.html</a> on multiple android emulators, but I'm not able to activate the WIFI P2P on each emulator, so it's possible to do it or no ??</p>
<p>PS: I took a look about the port forwarding, but it's doesn't work since a WIFI connection is needed before.</p>
<p>Thank you so much</p>
| android | [4] |
1,030,614 | 1,030,615 | unable to read file from ftp in android? | <p>I am trying to read data from a file from ftp server. This piece of code works perfectly in java when i run from my desktop computer. I copied over the same code to android and i am getting an exception. The Exception is:</p>
<p>java.io.IOException: Unable to connect to server: Unable to retrieve file: 550</p>
<p>I have no idea why it is occurring when the same code is working perfecty in java.
The java code is:</p>
<pre><code>String s = "ftp://username:password@ftp.mysite.x10.mx:21/sg1996text.txt;type=i";
URL u;
String f="";
try {
u = new URL(s);
URLConnection uc=u.openConnection();
BufferedInputStream bis=new BufferedInputStream(uc.getInputStream()); //This is where exception i raised.
System.out.println("IS opened");
int i;
while((i=bis.read())!=-1)
f=f+(char)i;
System.out.println("File Read");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
</code></pre>
| android | [4] |
2,311,264 | 2,311,265 | How to get a function to execute | <p>I have a function and I want it to execute. Does anyone know how to do this?</p>
<pre><code>def a():
a = 'print'
print a
</code></pre>
| python | [7] |
5,392,553 | 5,392,554 | Testing android .apk file | <p>I am looking for an open source that can automate the test of any android application like phone app or phonebook on the Android device and give out a report on the PC.
Thank You </p>
| android | [4] |
5,885,765 | 5,885,766 | Is it possible to make use of the Android resource resolver on a self-created folder in the file system? | <p>I'd like the ability to "overwrite" the Android resources packaged within my apk by having the app periodically download a zipped file containing overrides that follow the same naming convention as the source does. For example, the zip might consist of the following paths:</p>
<pre><code>res/values/strings.json
res/values-land/strings.json
</code></pre>
<p>My code would parse those files and produce a Map> that would map the string resource id to a folder->value pair (or something along these lines). At this point I'm really only concerned with strings and images (maybe arrays), but not layouts, etc.</p>
<p>To the point: Is there any method available, that, given a list of folder names, would tell me which one the Android resolver would choose based on current state? I'm assuming this is difficult because the compiler breaks everything down to ids, but figured it was worth a shot. Any ideas?</p>
| android | [4] |
3,822,358 | 3,822,359 | innertext return all the child and self text. how do i except one child text | <p>I have an xml file</p>
<pre><code><first>
first1
<second>second1</second>
first2
<third>third1</third>
first3
</first>
</code></pre>
<p>I want to read self text for <code><first></code> and child text for <code><third></code> except the child <code><second></code></p>
<p>answer should be</p>
<pre><code>first1 first2 third1 first3
</code></pre>
<p>I tried:</p>
<pre><code>.select(descendant::first1[not(descendant::second)]
</code></pre>
<p>but it's not working. Need sug</p>
| c# | [0] |
245,917 | 245,918 | What is the disadvantage of Java not having real properties? | <p>So, it's said quite often it's a disadvantage of Java that it does not have properties like <a href="http://msdn.microsoft.com/en-us/library/x9fsa0sw%28VS.80%29.aspx" rel="nofollow">C#</a></p>
<p>What advantage, over the getXX/setXX java-bean style properties would we get if Java gets "native" support for properties ?</p>
| java | [1] |
4,720,953 | 4,720,954 | Check if a string contain Error 404 | <p>What's a simple method of checking if a string contain <code>error 404</code>?
The string was built from HttpGet. </p>
<p>Any help is appreciated.</p>
| java | [1] |
1,523,290 | 1,523,291 | What is the size of the parameter when the parameter is an array? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/967402/are-arrays-or-lists-passed-by-default-by-reference-in-c">Are arrays or lists passed by default by reference in c#?</a> </p>
</blockquote>
<p>On my machine a pointer is 32 bits, therefore a function that passes a class object will be passing 32 bits (the pointer that is the reference to the class object). I keep hearing contradictory things about arrays in c sharp, that they are reference types, and that they are passed by value. So could someone please tell me how many bits a function that passes an array of 5 floats will use in passing that array? Is it the size of a pointer, or 5 * 32 the size of 5 floats?</p>
| c# | [0] |
724,271 | 724,272 | Image not downloading in Android | <p>I have a bit of code that was working, but now isn't and I can't figure out why. I am trying to download an image from a URL, but nothing is being retrieved. I have the following code:</p>
<pre><code>URL u;
u = new URL("https://sites.google.com/site/mymoneymobilesite/rugbynut/leagues/league%20six%20nations.png");
URLConnection ucon = u.openConnection();
InputStream is = ucon.getInputStream();
Bitmap tmp_bmp = BitmapFactory.decodeStream(is);
</code></pre>
<p>Like I say, this was working months ago, but I've come to update some other code and found that it isn't anymore.</p>
<p>Can anyone help please?</p>
<p>UPDATE:
I have tried the code:</p>
<pre><code>InputStream iStream = (InputStream) u.getContent();
Drawable d = Drawable.createFromStream(iStream, "test");
</code></pre>
<p>but d is null. I use the same URL as above (the image is publicly available) and the application has no issues with connecting to the internet, as it is managing to download other data.</p>
<p>Any more ideas?</p>
| android | [4] |
1,231,883 | 1,231,884 | Force custom cursoradapter to not recycle views | <p>I'm using a listview with an adapter extending CursorAdapter.
The listitems contains a few TextViews which can contain arbitrary lengths of text.
The problem is now as the views (in the listview) are recycled, items might get alot higher than needed since a previous item in the view needed bigger space.</p>
<p>I guess that the solution is to somehow to not allow recycling, or just force set the size of the view upon it being bound. I've been trying a number of different solutions but I haven't found a way. Could someone please help me? ;)</p>
<pre><code> @Override
public View newView(Context context, Cursor c, ViewGroup parent)
{
settings = ctx.getSharedPreferences("myprefs", 0);
View v = inflater.inflate(R.layout.convoview_list_item, parent,false);
ctx2 = context;
parentGroup = parent;
return v;
}
@Override
public void bindView(View v, Context context, Cursor c)
{
//Adding text etc to my views from the cursor here.
}
</code></pre>
| android | [4] |
4,373,905 | 4,373,906 | condition in if statements | <p>can if condition contain strings?
for example</p>
<pre><code>string s="abs";
if(s) or if(s==null) or if(s.equals(""))
</code></pre>
<p>which among the above are correct?
Also write for integers..</p>
<pre><code>int value=5;
</code></pre>
<p>say </p>
<pre><code>if(value) then condition
</code></pre>
<p>is it correct?</p>
| java | [1] |
797,199 | 797,200 | How to combine initialization and assignment of dictionary in Python? | <p>I would like to figure out if any deal is selected twice or more.</p>
<p>The following example is stripped down for sake of readability. But in essence I thought the best solution would be using a dictionary, and whenever any deal-container (e.g. deal_pot_1) contains the same deal twice or more, I would capture it as an error.</p>
<p>The following code served me well, however by itself it throws an exception...</p>
<pre><code> if deal_pot_1:
duplicates[deal_pot_1.pk] += 1
if deal_pot_2:
duplicates[deal_pot_2.pk] += 1
if deal_pot_3:
duplicates[deal_pot_3.pk] += 1
</code></pre>
<p>...if I didn't initialize this before hand like the following.</p>
<pre><code> if deal_pot_1:
duplicates[deal_pot_1.pk] = 0
if deal_pot_2:
duplicates[deal_pot_2.pk] = 0
if deal_pot_3:
duplicates[deal_pot_3.pk] = 0
</code></pre>
<p>Is there anyway to simplify/combine this?</p>
| python | [7] |
5,248,549 | 5,248,550 | How can I get a resource by name based on a string variable? | <p>I want to do</p>
<pre><code>String childImg = "childIcon";
textView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.????, 0, 0, 0);
</code></pre>
<p>it's expecting an int but i have a string. how do i work around this?</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.