Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
2,367,687 | 2,367,688 | Jquery .toggle() with first element open | <p>So I am using .toggle() to open and close a bunch of divs, but I made the first div open on page load. The problem lies where, if a user click on that div to toggle it closed, it takes two clicks, the first click seems to try to toggle it open again. How should I handle this?</p>
<pre><code>$(document).ready(function(){
$('.content_accrd').css({"height":"0px"});
$('.content_accrd:eq(0)').css({"height":"100px"});
$('.paneltop:eq(0)').css({"background-position":"0px -21px"})
$('.paneltop').toggle( function() {
$(this).css({"background-position":"0px -21px"})
.siblings('.content_accrd').animate({"height":"100px"}, 200)
}, function() {
$(this).css({"background-position":"0px 0px"})
.siblings('.content_accrd').animate({"height":"0px"}, 200);
})
})
</code></pre>
<p>markup:</p>
<pre><code> <div id="panel1" class="panel">
<h2 class="panel_title">Capad Clients</h2>
<div class="paneltop">
</div>
<div class="content_accrd">
<p>
text
</p>
</div>
</div>
<div id="panel1" class="panel">
<div class="paneltop">
</div>
<div class="content_accrd">
<p>
text
</p>
</div>
</div>
<div id="panel1" class="panel">
<div class="paneltop">
</div>
<div class="content_accrd">
<p>
text
</p>
</div>
</div>
</code></pre>
| jquery | [5] |
5,663,361 | 5,663,362 | How to bring Virtual Keyboard manually in android?While we clicking the edit text box,the keyboard want to display? | <p>While we clicking the edit text box,the keyboard want to display?
wat to do any suggestions</p>
<p>in customized view</p>
| android | [4] |
3,352,414 | 3,352,415 | UIScrollView always bounce upwards and does not show scroll bar in iphone | <p>This is probably simple but I do not seem to get it to work. I have a view and inside it I have a scroll view and inside it I have a view with some labels and a button. the height of the text inside the labels changes according to some condition so I need to scroll down to see it. But whenever I try to scroll down it bounce back up without giving me a chance to view the rest of the view.</p>
<p>Basically, I want when I scroll down, the view to remain down as it normally should. Besides I do not see the scroll bar at all when I'm scrolling.</p>
<p>I know I probably do not understand how scroll views work, so I'd appreciate any help to explain to me the behavior of scroll views.</p>
<p>P.S. I built my whole view in a nib file and this specific setup That I mentioned at the beginning is based on a suggestion from one question I read here.</p>
<p>Thanks, Mohsen</p>
| iphone | [8] |
1,863,188 | 1,863,189 | application of C++ | <p>everybody, I've just finished my course <code>Introduction to Systems Programming</code>, the last part of it was C++, I learned a lot of stuff, but all I used to write was some <code>console programs</code>, I want to begin to write something new on c++ (something with <code>graphic windows</code> or maybe <code>small game</code>) to improve my knowledge, from which point can I start and which books can You recommend, I found a lot materials but I don't want to waste my time for bad books, so need Your advice, thanks in advance</p>
| c++ | [6] |
5,390,885 | 5,390,886 | android delete specific contact programmatically | <p>Right now, this code is working
<code>ops.add(ContentProviderOperation .newDelete(ContactsContract.Data.CONTENT_URI) .withSelection(ContactsContract.Data.RAW_CONTACT_ID+"=?",new String[] {sid}).build());</code></p>
<p>However it creates unknown record and seems that its the deleted contact. Do I need something to make it work properly?</p>
| android | [4] |
5,879,125 | 5,879,126 | storing input from a seperate class | <p>I posted a question earlier for a homework assignment but I have a new question. I am new at this so I appreciate any help I can get and I'm not looking for code but more of an explanation of the steps I need to take to get to my answer.</p>
<p>I'm working on an address book. The user picks a menu 1, 2, or 3. I have a main class, a validation class, a class that declares set and get and a class that handles the IO functions.</p>
<p>I'm just learning classes so please be patient but basically I want to understand how to save the info if the user wants to enter a new person.
I have a setName and getName and a setPhoneNumber and getPhoneNumber in a class I also have the function to save everything written in the IO class that was provided. I don't understand what saves the information I guess is what I'm saying. Do I need to create a scanner for each line? or How do I send it to the right place?
Do I need to call the whole function that is in the IO class that handles the name and phone number? </p>
<pre><code> if(menuNumber == 2)
{
System.out.println("Enter name: ")
System.out.println("enter phone number: ")
}
</code></pre>
<p>Thank you in advance for any help. I'm taking classes online and so far java hasn't been an easy one. I want to understand it but I'm struggling through this book and my projects have a pretty quick turnaround so I want to learn it but I almost need to stop and ask for someone to break it down for me in english instead of staring at a diagram in a book.</p>
| java | [1] |
519,448 | 519,449 | Unable to switch on String in JRE7 | <p>I'm on jre7 and I still can't switch on Strings. I installed jdk7 update 1 and pointed Eclipse to it but still no luck. Any idea what I'm doing wrong? Thank you.</p>
<p>Here is a the code:</p>
<pre><code>String code = "something";
switch(code) {
case "xxx": dosomehting(); break;
default: dosomethingelse(); break;
}
</code></pre>
<p>The error I get:
Cannot switch on a value of type String. Only convertible int values or enum constants are permitted.</p>
| java | [1] |
4,651,060 | 4,651,061 | How do I get the current volume/amplitude in an Android MediaPlayer? | <p>I'm working on an app that will both record an audio file, and then have the option to play back that file once it's been recorded. The UI has an EQ component that animates relative to the current amplitude of the recording. I've got the animation working via the MediaRecorder.getMaxAmplitude() method, but can't find any means to do this with MediaPlayer. I know it must be possible since there are music visualization Live Wallpapers by default that perform this functionality but I can't see any way that it's pulling that information when combing through AOSP. Does anybody know how to make this work?</p>
| android | [4] |
2,205,862 | 2,205,863 | Lex/Yacc for C#? | <p>Actually, maybe not full-blown Lex/Yacc. I'm implementing a command-interpreter front-end to administer a webapp. I'm looking for something that'll take a grammar definition and turn it into a parser that directly invokes methods on my object. Similar to how ASP.NET MVC can figure out which controller method to invoke, and how to pony up the arguments.</p>
<p>So, if the user types "create foo" at my command-prompt, it should transparently call a method:</p>
<pre><code>private void Create(string id) { /* ... */ }
</code></pre>
<p>Oh, and if it could generate help text from (e.g.) attributes on those controller methods, that'd be awesome, too.</p>
| c# | [0] |
5,278,606 | 5,278,607 | How can I include a button in a Toast notification? | <p>First of all, I know this has been asked before: <a href="http://stackoverflow.com/questions/3308975/android-button-in-custom-toast">Android : Button in custom Toast</a>.
This is nearly an exact duplicate, but I think that it warrants a new question based on the fact that it's been used in apps, namely Gmail for ICS (it appears when you delete a message).</p>
<p>The linked question says that it's not possible to include a button in a <code>Toast</code> because <code>Toast</code>s cannot be focused. Is this wrong, outdated, or did Gmail find a way around it?</p>
| android | [4] |
4,106,622 | 4,106,623 | name 'newList' is not defined | <p>So I am making a python game and I am trying to implement a save/load system. I have the save part down however the load function that I made isn't working. When I assign cPickle.load to a new list it isn't registering.</p>
<pre><code>def save():
file = open('save.txt', 'wb')
cPickle.dump(GameState, file)
file.close()
def load():
inFile = open('save.txt', 'rb')
newList = cPickle.load(inFile)
inFile.close()
</code></pre>
<p>Please help, thanks!</p>
| python | [7] |
5,485,435 | 5,485,436 | What does this mean? (function (x,y)){...}){a,b); in JavaScript | <p>I saw a this function </p>
<pre><code>(function (x, y, data, lbl, dot) {
var timer, i = 0;
rect.hover(function () {
clearTimeout(leave_timer);
var side = "right";
if (x + frame.getBBox().width > width) {
side = "left";
}
var ppp = this.popup(x, y, label, side, 1);
//var ppp = r.popup(x, y, label, side, 1);
frame.show().stop().animate({path: ppp.path}, 200 * is_label_visible);
label[0].attr({text: data + " hit" + (data == 1 ? "" : "s")}).show().stop().animateWith(frame, {translation: [ppp.dx, ppp.dy]}, 200 * is_label_visible);
dot.attr("r", 6);
is_label_visible = true;
}, function () {
dot.attr("r", 4);
leave_timer = setTimeout(function () {
frame.hide();
label[0].hide();
is_label_visible = false;
}, 1);
});
})(x, y, data[i], labels[i], dot);
</code></pre>
<p>what is this? a function? why function definition in ()?</p>
| javascript | [3] |
831,381 | 831,382 | event.keycode v event.which | <p>Good Morning All,</p>
<p>I fell foul of a Fire Fox Keydown behaviour in that pressing the enter key (indeed any key) without having focus on a specific field will NOT trigger a keydown event it will only trigger a Keypress event. </p>
<p>This could be very confusing as the keydown and keyup event use javascripts keycodes whereas keypress uses ASCII codes. Fortunately 13 (enter/return) is common to both.</p>
<p>Is there any known reason why FF using keypress in this circumstance? what is the benefit?</p>
<p>Once this was established I.E 8 threw up a silly in that it does not permit preventDefault demanding instead returnValue = false the following snippet from another SO post has proved very useful:</p>
<pre><code>event.preventDefault ? event.preventDefault() : event.returnValue = false;
</code></pre>
<p>During the search to resolve these issues I have been consistently confused by event.keycode v event.which. Namely am I doing wrong using a switch statement similar to:-</p>
<pre><code>$("#class_Name").bind("keydown", function(event){
// do not test input if field controls used
switch(event.which){
case 13:
//enter key
event.preventDefault ? event.preventDefault() : event.returnValue = false;
break;
}
</code></pre>
<p>Is the following better, if so why?</p>
<pre><code>$("body").keypress(function(event){
// stop inadvertant form submission
if (event.keycode == "13"){
event.preventDefault ? event.preventDefault() : event.returnValue = false;
}
});
</code></pre>
<p>I would just like to know so that I know which is best to apply.</p>
<p>Many thanks.</p>
| jquery | [5] |
1,126,082 | 1,126,083 | Uploading video on server through POST | <p>I would like to know that how can I upload a video file on server using POST in android. Please, let me know the answer, if anyone knows about it?</p>
<p>Thanks</p>
| android | [4] |
5,636,823 | 5,636,824 | Suggest a library to get selector(s) of given element | <p>There are a lot of libraries that return elements by css/xpath selectors, but how can I get such selector by element? Maybe you know some library that does it? I know it is implemented in Selenium IDE, but the codebase is rather huge and I was unable to find where do they do it (and I think that I can not just use part of the selenium).</p>
<p>Sample use case - user selects element on html page, and we must get some sensible selector for it (that would preferably still return the same element when html changes).</p>
<p>For sure it's possible to write such a library, but if one already exists...</p>
| javascript | [3] |
1,527,854 | 1,527,855 | Method argument extends class implements interface | <p>I have the following Class and Interface :</p>
<pre><code>public class BasicObject{...}
public interface CodeObject{...}
</code></pre>
<p>I want to create a method in which the argument need to be of type BasicObject and implements CodeObject. I tried this code but it doesn't guarantee clazz to be a class that implements CodeObject.</p>
<pre><code>myMethod(Class<? extends BasicObject> clazz){...}
</code></pre>
<p>I want to do somethign like this but this code doesn't compile :</p>
<pre><code>myMethod(Class<? extends BasicObject implements CodeObject> clazz){...}
</code></pre>
| java | [1] |
4,552,761 | 4,552,762 | get the object property in another class | <p>i have a Emp class which have one property empName.i am setting this property in empCreate class.i want to get this property in Main class.</p>
<pre><code>public class Main {
public static void main(String[] args) {
// here i want to get empName which i set it in empCreate.java
}
}
</code></pre>
<p>how i can do this. please suggest.</p>
<hr>
<p>i have Emp.java: </p>
<pre><code>public class Emp {
private String empName;
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
}
</code></pre>
<p>and empCreate.java: </p>
<pre><code>public class empCreate {
public static void main(String args[]) {
Emp emp= new Emp();
emp.setEmpName("abc");
}
}
</code></pre>
<p>i want to get this property in Main.java which i set it in empCreate.java </p>
| java | [1] |
4,334,391 | 4,334,392 | abstracting this jQuery function | <p>Gotten a lot of great help here! The code here has been helped along by a few folks. Hopefully someone can help me take it to the next level.</p>
<p>Basically, I have code which will add a checkmark after a given period of time to a clicked item in the left navigation. There are going to be other links on the page which are going to trigger the same behavior for the corresponding left links. So for example there would be 10 links on the left, and 10 links on top that would each need to trigger a corresponding link on the left. I am trying to abstract this code so that I can activate it from a different source. To make it easier, it can be thought of as how to trigger this piece of code from a source outside of the navigation. Here's the code:</p>
<pre><code>$(function() {
var thetimeout=null;
$('#leftnav li a').click(function() {
$('#leftnav li').not('this').css('background-position','left bottom');
$(this).parent().css('background-position','left top');
if(thetimeout!=null) {
window.clearTimeout(thetimeout);
}
thetimeout=window.setTimeout($.proxy(function() {
$(this).parent().css('background-image','url(images/check.png)');
}, this)
,5000);
});
</code></pre>
<p>});</p>
<p>I have a working demo (with the top links not working) up <a href="http://www.jontakiff.com/checks" rel="nofollow">here.</a></p>
<p>Thanks for your time, I really appreciate it.</p>
| jquery | [5] |
2,377,204 | 2,377,205 | WAMPSERVER GD2 - doesn't support jpeg images? | <p>I have WAMPSERVER 2.0 installed on my localhost with php_gd2 extension enabled, however when I'm trying to save a jpeg image I get this exception:</p>
<pre><code>Your GD installation does not support JPG image types
</code></pre>
<p>How to enable JPG images?</p>
| php | [2] |
1,025,525 | 1,025,526 | Anyone tried to bulk upload device UDIDs to the iPhone dev portal? | <p>I'm trying to add 50 beta testers to my app through ad hoc. In the portal, it gives you an option to upload a file for UDIDS. What format should it be? Also, it mentioned that you are only limited to 100 devices per year and they cannot be changed. Does this mean once I added my beta testers, they cannot be changed forever, even for other apps?</p>
| iphone | [8] |
179,641 | 179,642 | What should the following code do and with explanations | <pre><code>class A {
public:
A() { }
~A() { cout << "A Destructor \n" ; }
};
class B :public A{
public:
B() { }
virtual ~B() { cout << "B Destructor \n" ; }
};
class C : public B {
public:
C() { }
~C() { cout << "C Destructor \n"; }
};
int main()
{
A *pointA = new A;
A *pointB = new B;
A *pointC = new C;
delete pointA;
delete pointB;
delete pointC;
}
</code></pre>
| c++ | [6] |
5,879,898 | 5,879,899 | How to use self.method() in class creation time? | <p>In some cases, I want to use instance method in class creation time.</p>
<p><strong>I just want to use self in permissions list..This is my question</strong></p>
<p>But it does not work. Is it some ways to solve the problem?</p>
<pre><code>class PermissionChecker(object):
# how to use self in class create time.
permissions = [self.is_superuser(), self.is_god()]
def is_superuser(self):
# use self.property just like self.name...
return True
def is_god(self):
return True
class Child(PermissionChecker):
permissions = PermissionChecker.permissions + [self.is_coder(),]
def is_coder(self):
return True
</code></pre>
| python | [7] |
5,845,392 | 5,845,393 | Access to path is denied when trying to moving a folder | <p>Trying to move a folder in C Drive to another location in C Drive.</p>
<p>However, it gives an error that "Access to the destination is denied".</p>
<p>I have created a "Temp" folder in C Drive. I am moving a folder into there.</p>
<p>It was working before and had just suddenly stopped working for some reason...</p>
<p>I dont think it is a permission problem, because I would first create the directory it needs to be moved into, and if it was a permission problem, it would have not let me create the directory in the first place?</p>
| c# | [0] |
1,922,643 | 1,922,644 | JSon Parsing error with double quotes | <p>I'm trying to parse the string "quotes":""living d life till i breathe my last"",
using json parser but its not parsing.I come to know the problem,its due to these double quotes "quotes":""living… in the string.</p>
<p>I have tried these things :</p>
<p>str_response = [str_response stringByReplacingOccurrencesOfString:@"\'" withString:@""];
str_response = [str_response stringByReplacingOccurrencesOfString:@"""" withString:@"""];
str_response =[str_response stringByReplacingOccurrencesOfString:@"\"" withString:@""];</p>
<p>But no success,nothing alb to replaces the double quotes with single quote
I want the result:
"quotes":"living d life till i breathe my last"</p>
<p>Thanks for the help</p>
| android | [4] |
3,065,912 | 3,065,913 | can i make auto complete to android's default searchbar? | <p>I'm trying to do an autocomplete for android's default search dialog but it doesn't seem to work. Is this impossible to do?</p>
| android | [4] |
707,202 | 707,203 | What changes would have to be made to JavaScript to make it compilable to binary? | <p>What changes would have to be made to JavaScript to make it compilable. I don't mean to make into executable that still relies on interpreter - I mean so that it compiles into binary in the way that C compiles.</p>
<p>I expect the prototypal inheritance might be an issue - but I don't know.</p>
<p>Also, I am pretty sure that <code>eval</code> would not be possible (or desired).</p>
<p>Is there anything out there that is trying to do something like this?</p>
<p>Is it technically achievable?</p>
<p>Could JavaScript (with some small modifications) be used as to create efficient programs?</p>
<hr>
<p><strong>EDIT</strong></p>
<p>I am specifically looking for something like what <code>RPython</code> is to Python - but for javascript.</p>
<p>It also appears that dynamic typing would be difficult/impossible for a compiled language as I want.</p>
| javascript | [3] |
4,429,054 | 4,429,055 | Php Syntax help for a noobie | <p>Im working on a noobie app to pull some dates from the database and then a year later send me an alert (with cron). So far im struggling a bit and am trying to make a page which does my maths which I can work on building up.</p>
<p>So far ive been debugging all day and reading tutorial after tutorial but am still getting errors. Very frustrating :)</p>
<p>My code looks like this....</p>
<pre><code><?php
$con = mysql_connect("localhost","root", "etc");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
$result = mysql_query('SELECT CheckDate FROM Data') or exit(mysql_error());
while ($row = mysql_fetch_array($result))
{
extract($row);
$validfromdate = CheckDate;
$alert=strtotime("+1 year", $validfromdate);
echo $alert;
?>
</code></pre>
| php | [2] |
3,807,272 | 3,807,273 | css stylesheets | <p>i need to implement two different stylesheets in a single master page. one style sheet is designed specifically for the project, and works fine. but when i add the second style sheet to it, which is used for some other project, all the web content forms look weird.
what is the best way of implementing those two stylesheets in the project?</p>
| asp.net | [9] |
4,543,006 | 4,543,007 | Does System.currentTimeInMillis represent UTC time? | <p>Does System.currentTimeInMillis represent UTC time or local system time ?</p>
| java | [1] |
1,987,629 | 1,987,630 | Why can === have some odd behavior in Javascript? | <p>I'm raising the question as seen from <a href="http://www.codecademy.com/courses/programming-intro/5#!/exercises/4" rel="nofollow">this Code Academy lesson</a>. Thanks in advance for your explanations.</p>
<p>Hope this is not repeated too often.</p>
<p>-------- Explanation from the lesson is added below ----------------</p>
<blockquote>
<p>You may have noticed we've used two types of equals thus far, the single equals (=) and the double or triple equals (==, ===). The single equals (=) assigns a variable, while the double and triple equals (==, ===) are used to check equivalence between values. Since == can have some odd behavior in JavaScript, it is almost always better to use ===.</p>
<p>Run this exercise to see what it does. It first sets the variable word to the string "this". Change the code so that word === "that" evaluates to true, and the console.log() command is run.</p>
</blockquote>
| javascript | [3] |
5,014,515 | 5,014,516 | jQuery character replacement call activated on click | <p>I have this jquery function to automatically replace sertain characters with others:</p>
<pre><code>jQuery(function() {
jQuery('.textarea').keyup(function() {
jQuery(this).val(jQuery(this).val().replace(/A/g, "5"));
jQuery(this).val(jQuery(this).val().replace(/Q/g, "3"));
});
});
</code></pre>
<p>I want to make this function optional and only activated if the user clicks on a button next the text-area input form.</p>
<p>I'm trying something like this:</p>
<pre><code>$("a").toggle(
function () {
jQuery(function() {
jQuery('.tifibox').keyup(function() {
jQuery(this).val(jQuery(this).val().replace(/A/g, "3"));
jQuery(this).val(jQuery(this).val().replace(/Q/g, "5"));
});
});
$(this).addClass("selected"); // button selected
},
function () {
$(this).removeClass("selected");
}
);
</code></pre>
<p>I have not tested this yet.. but is that correct? thanks</p>
| jquery | [5] |
4,641,785 | 4,641,786 | Javascript error - SXBB[id].resize is not a function | <p><a href="http://digital-diy.com/forum/" rel="nofollow">My forum</a> (based on phpbb3) has a Javascript error that I'd like to resolve. In FF and IE the following error occurs:</p>
<pre><code>Error: SXBB[id].resize is not a function
Source File: http://digital-diy.com/forum/classes/scripts/select_expand_bbcodes.js
Line: 197
</code></pre>
<p>The mod that uses this script is called "Syntax Highlighter 1.0.15". The developer is not sure why the error occurs, hopefully someone at stackoverflow can lend a hand?</p>
| javascript | [3] |
1,989,134 | 1,989,135 | How can I write my code to attempt a database action but continue executing code on failure? | <p>Simple question I guess, I want to use PHP to write an update to an existing row in my database, if it doesn't happen I want to log the failure but continue executing the code. While it would be nice to have records of failures to track down issues, that the update failed isn't that important to my user, nor will it affect the running of any other code; the query is simply for a 'cosmetic' but entirely unnecessary piece of information.</p>
<p>My database class's query function is set to die on failure, could I modify that or is there another way of doing it without altering my standard query code?</p>
| php | [2] |
3,411,586 | 3,411,587 | server side validation in asp.net? | <p>hi all as i know that asp.net provide server side validation control which has there own built-in logic, so i want to ask here can we extend built-in logic, i means suppose we use <strong>compare validator</strong> for comparing two file at this point it will validate according to there built-in logic, but i want to add some code for compare validator, is this possible.</p>
<p>According to my knowledge in asp.net every control treated as class which has data and code so according to inheritance or extend can we add some code in validation control ?</p>
| asp.net | [9] |
3,831,464 | 3,831,465 | Get list of dictionary elements ordered by dictionary key | <p>I have a dictionary <code>d</code> for which the keys are all strings. Now when I do:</p>
<pre><code>for key in d:
print(d[key])
</code></pre>
<p>I get the elements of <code>d</code> is some "random" order. How can I force the element of <code>d</code> to come out sorted by the lexicographical order?</p>
| python | [7] |
3,209,460 | 3,209,461 | Frame Calculator issue in C# | <p>Hello I am working a frame calculator in C# and right now it works just fine however when I use a of 100 or above it does not do it right, it gives the same answer 23.333. I need help getting it to work above 100, I am kinda new to C# as well. All it is suppose to do is take a number subtract 30 and then divide it by 3 to give you your frames.</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int inNum;
inNum = (int)numericUpDown1.Value; // using a numericupdown to get user input
double outNum;
outNum = (inNum - 30F) / 3F;
label4.Text = outNum.ToString("f3"); // using a label to display result to user
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}
</code></pre>
| c# | [0] |
1,773,956 | 1,773,957 | Basic Javascript validation | <p>This is a really simple problem. I had this working and then i must of changed something and now it doesn't work. Its just a peice of JS code checking for an empty string. Here is the code below. It's been driving me mad for 20 minutes trying to figure out what is wrong with this ridicliously simple code.</p>
<pre><code> <script type="text/javascript">
function validateForm(){
var email= document.getElementById('email').value;
if (email.length==''){
alert("please fill out email");}}
</script>
<form name="contact" method="post" action='ContactPHP.php'>
Your Email: <input name='email' type='text' /><br />
<input type="button" value="submit" onClick="validateForm()"/>
</form>
</code></pre>
| javascript | [3] |
4,879,368 | 4,879,369 | Get text bounds of space | <p>How to measure bounds of space in android?</p>
<p>I mean, the following:</p>
<pre><code>Rect bounds = new Rect();
paint.getTextBounds(String.valueOf(' '), 0, 1, bounds);
return bounds.width();
</code></pre>
<p>returns 0.</p>
| android | [4] |
1,411,365 | 1,411,366 | in c++ , how to use array as function input and output | <p>i want to create a function in c++ which contains two arrays as input and returns one array as output,</p>
<p>array function_name(array A, array B)</p>
| c++ | [6] |
4,072,406 | 4,072,407 | Whats the best way to parse a file in Java | <p>I have a text file with Tag - Value format data. I want to parse this file to form a Trie. What will be the best approach? </p>
<p>Sample of File: (String inside "" is a tag and '#' is used to comment the line.)</p>
<pre><code> #Hi, this is a sample file.
"abcd" = 12;
"abcde" = 16;
"http" = 32;
"sip" = 21;
</code></pre>
| java | [1] |
2,875,422 | 2,875,423 | Click count possible with javascript? | <p>Let's say, in website, I want to display the notice message block whenever people click any of the link at my website more than x number of times. Is that possible to count with javascript and display the notice message block ? And can we count the refresh times also ? Or can it be only done with server side language like php ? Please kindly suggest. Thank you.</p>
<p>With Regards,</p>
| javascript | [3] |
796,743 | 796,744 | Deprecated: Function eregi() is deprecated contact form | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6270004/how-can-i-convert-ereg-expressions-to-preg-in-php">How can I convert ereg expressions to preg in PHP?</a> </p>
</blockquote>
<p>I have a php contact form that I have used on a few different websites. I am trying to implement the same one on a new site, but I am getting the following message:</p>
<p>Deprecated: Function eregi() is deprecated in /home/content/58/10223058/html/contact-1.php on line 36</p>
<p>Here is line 36 from my code:</p>
<pre><code>if(!eregi($string_exp,$name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
</code></pre>
<p>I am sure there is an easy fix for this, but I am very new to PHP and do not know how to go about fixing this!</p>
<p>Any help would be greatly appreciated. Thankyou</p>
| php | [2] |
5,389,235 | 5,389,236 | C# set inherited class equal to base class | <p>if I have a parent class:</p>
<pre><code>public class ParentClass
{
public string ParentStr = string.empty;
}
</code></pre>
<p>and a child class:</p>
<pre><code>public class ChildClass : ParentClass
{
public string ChildStr = string.empty;
}
</code></pre>
<p>Say later in my code I have an instance of ParentClass</p>
<pre><code>ParentClass parentClass = New ParentClass() { ParentStr = "something" }
</code></pre>
<p>Is it possible to create an instance of the ChildClass from the ParentClass? Something to the effect of:</p>
<pre><code>ChildClass childClass = (ChildClass)parentClass
</code></pre>
| c# | [0] |
5,523,756 | 5,523,757 | Don't understand how variable I is getting assigned a value in a struct | <p>I have the following code:</p>
<pre><code>#include <iostream>
using namespace std;
struct S {
S(int i): I(i) { }
int & v () { return I; }
private :
int I;
};
S s1 (1);
int main() {
cout << s1.v() << "\n";
return 0;
}
</code></pre>
<p>And I get the output:</p>
<pre><code>1
</code></pre>
<p>I am confused as to how it is working. For example with <code>s1</code> it is calling the constructor <code>S(int i)</code> but how is it sub-classing <code>I</code> and calling its constructor when there is no <code>I</code> class and how is the private variable <code>I</code> getting assigned a number when there has been nothing assigned to it? Also, if <code>v()</code> returns <code>int&</code> (a reference therefore, I would think it would print out a memory location but it gives 1 consistently).</p>
<p>Sorry if this sounds stupid can't figure it out.</p>
| c++ | [6] |
846,795 | 846,796 | Can outdated programming software be harmful? | <p>I recently bought a book called "Killer Game Programming in Java" It's about 5 years old now and the programs run best with Java2SE and Java 2SE 1.4. Since these versions are old and not updated, could using these software versions be harmful. The link below says yes but I wanted a second opinion before I try to install. Also, I'm running on a Mac. If all else fails I'm gonna try to email the author.
<a href="http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase14-419411.html#7501-j2sdk-1.4.2-oth-JPR" rel="nofollow">http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase14-419411.html#7501-j2sdk-1.4.2-oth-JPR</a></p>
| java | [1] |
3,068,803 | 3,068,804 | Which assert to use? | <p>AFAIK, there are three common types of Asserts people use in Java viz.,</p>
<ul>
<li><a href="http://docs.oracle.com/javase/1.4.2/docs/guide/lang/assert.html" rel="nofollow">http://docs.oracle.com/javase/1.4.2/docs/guide/lang/assert.html</a></li>
<li><a href="http://static.springsource.org/spring/docs/1.2.x/api/org/springframework/util/Assert.html" rel="nofollow">http://static.springsource.org/spring/docs/1.2.x/api/org/springframework/util/Assert.html</a></li>
<li><a href="http://junit.sourceforge.net/javadoc/org/junit/Assert.html" rel="nofollow">http://junit.sourceforge.net/javadoc/org/junit/Assert.html</a></li>
</ul>
<p>Can you tell me the correct usage for each of the paradigm?</p>
| java | [1] |
4,669,764 | 4,669,765 | How to use BCEL in java programming? | <p>Is BCEL(Byte code Engineering Library) directly usable in normal java 1.6 or we need to download something for using it?
Or is this an in built library in java1.6? </p>
| java | [1] |
3,710,942 | 3,710,943 | Highlight row with jQuery | <p>I'd like to have a function that will highlight row of the table when a mouse rolls over it. I currently have a function that creates an alternate row color every other row and I would like to modify it rather than creating a separate function. Here's what I have:</p>
<pre><code>$(".tblRows tr:even").addClass("altColor");
</code></pre>
<p>where </p>
<pre><code>.altColor TD {
background-color:#f5f5f5
}
</code></pre>
<p>and my HTML is </p>
<pre><code><table class="tblRows">
...
</code></pre>
<p>I know there's a jQuery function hover() but I'm not sure how to incorporate it with what I've got. When hovered I'd like it to use class="hilite"</p>
<p>Is it possible?</p>
| jquery | [5] |
1,242,831 | 1,242,832 | Function returns undesired value | <p>This is my first time posting to this site, therefore I would appreciate all criticisms in a constructive manner. I am learning to write Object Oriented programming with C++ and decided to make a trivial simulation of an ATM machine that takes in user input and processes it (i.e makeDeposit, checkBalance, etc.).</p>
<p>My Problem: BankAccount method: makeDeposit end up changing the output of getBalance() to prefix with a zero:
for example: makeDeposit(10) will change getBalance() from 0 -> 010.</p>
<pre><code>`//BankAccout.h
#ifndef BANK_ACCOUNT_H
#define BANK_ACCOUNT_H
#include <string>
class BankAccount {
private:
float m_accountBalance;
public:
BankAccount ();
float getBalance();
/*Can I pass by value or would reference be necessary?*/
void makeDeposit(BankAccount&, int);
};
#endif`
//BankAccout.cpp
#include "BankAccount.h"
#include <iostream> //remove once done
using namespace std; //remove once done
BankAccount::BankAccount () {
m_accountBalance = 0;
}
float BankAccount::getBalance() {
return m_accountBalance;
}
//increment the object balance based on ammount
void BankAccount::makeDeposit(BankAccount &bao, int deposit_amount) {
bao.m_accountBalance += deposit_amount;
}
int main () {
BankAccount b1;
cout << b1.getBalance(); //returns 0
b1.makeDeposit (b1,1); //returns 01
cout << b1.getBalance();
//Ex.
//makeDepost(b2, 10);
//b2.getBalance(); will retrun 010
return 0;
}
</code></pre>
<p>Any tips would also be much appreciated as I am about to take the roughest Data Structures course with little experience with object oriented programming. </p>
<p>Also, could someone explain to me what subversion is and how it is used. </p>
| c++ | [6] |
2,791,308 | 2,791,309 | Where to define functors used by many derived classes? | <p>A common scenario in my code is that I got a <strong>functor</strong> that is used by many classes in a hierachy.</p>
<p>To make it accessible by all classes and stay DRY, I usually define it as a protected inner struct of my base class like that:</p>
<pre><code>class Base
{
protected:
struct CommonFunctor
{
bool operator()()
{
return true;
}
};
};
class DerivedA : public Base
{
void FooA()
{
bool test = CommonFunctor()();
}
};
class DerivedB : public Base
{
void FooB()
{
bool test = CommonFunctor()();
}
};
</code></pre>
<p>I don't like that solution because it clutters my base class with many small functors, that are internal only and even if they are not accessible to the public, they decrease readability of my base class.</p>
<p><strong>Do you know any other solutions for this scenario?</strong></p>
| c++ | [6] |
5,510,256 | 5,510,257 | Updating data from GridView | <p>I have a Gridview where I join two tables, bringing in the data to be displayed</p>
<p>table 1 sid, schedule, stime, splace, stourid</p>
<p>table 2 tourid, tourname</p>
<p>Basically they are joined stourid to tourid. That is so I can show the tourname in the grid.</p>
<p>Now I want to edit this GridView, what do I need to do, for instance, if the user edits the tourname, that it'll be saved to the database? I assume an Update statement is need, but how does it link to the GridView?</p>
<p>Whats the best and neatest method?</p>
<p>Regards,</p>
| asp.net | [9] |
5,975,834 | 5,975,835 | jQuery replaceAll() function | <p>I want to replace every link by an input box whose value is the URL of the link. I would like to use the jQuery replaceAll() function. The standard format is</p>
<pre><code>$(content).replaceAll(target);
</code></pre>
<p>My question is: how do you refer to the target object? In other words, in the following code, what should I replace <em>TheCurrentLink</em> with?</p>
<pre><code>$('<input>').attr('value', TheCurrentLink.href}).replaceAll($("a"));
</code></pre>
| jquery | [5] |
5,911,945 | 5,911,946 | content observer only invoked once then never again | <p>I am trying to observe sms messages with the following content observer. Unfortunately, it only picks up some occurrences. At first I thought it was a lifecycle issue, so I placed methods in the stop, start, resume, etc methods to make sure I always have an observer observing while my activity is in the forefront. Anyone have any ideas as to why it only picks up the first new message? After catching the first one, it doesn't pick up until I re-install application.</p>
<pre><code>private void registerContentObservers() {
ContentResolver cr = getContentResolver();
mSmsObserver = new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
Log.v(TAG, "onChange method");
}
@Override
public boolean deliverSelfNotifications() {
return true;
}
};
// cursor.registerContentObserver(mSmsObserver);
cr.registerContentObserver(Uri.parse("content://sms/inbox"), false, mSmsObserver);
}
private void unregisterContentObservers() {
ContentResolver cr = getContentResolver();
if (mSmsObserver != null) {
// just paranoia
cr.unregisterContentObserver(mSmsObserver);
mSmsObserver = null;
}
}
@Override
protected void onDestroy() {
Log.v(TAG, "onDestroy()");
unregisterContentObservers();
super.onDestroy();
}
@Override
protected void onStart() {
Log.v(TAG, "onStart()");
registerContentObservers();
super.onStart();
}
@Override
protected void onStop() {
Log.v(TAG, "onStop()");
unregisterContentObservers();
super.onStop();
}
@Override
protected void onResume() {
Log.v(TAG, "onResume()");
registerContentObservers();
super.onResume();
}
@Override
protected void onPause() {
Log.v(TAG, "onPause()");
super.onPause();
}
</code></pre>
| android | [4] |
2,671,603 | 2,671,604 | Why's PHP complaining about my register_shutdown_function()? | <p>I try to register a shutdown function to log an fatal error. Nice stuff, if it would work for my class...</p>
<p>Inside a method I do this:</p>
<pre><code>register_shutdown_function(array($this, 'handleFatalError'));
</code></pre>
<p>handleFatalError is not static, and it's public:</p>
<pre><code>public function handleFatalErrors() {
if(is_null($e = error_get_last()) === false) {
//mail('your.email@example.com', 'Error from auto_prepend', print_r($e, true));
}
}
</code></pre>
<p>PHP says:</p>
<blockquote>
<p>Warning: register_shutdown_function()
[function.register-shutdown-function]:
Invalid shutdown callback
'ErrorManager::handleFatalError'
passed in ...</p>
</blockquote>
<p>Why's that an invalid callback?</p>
| php | [2] |
2,558,481 | 2,558,482 | Creating an array of other objects in javascript? | <p>Is something like this possible:</p>
<pre><code>function FooClass()
{
var barsArray=new Array();
var index=0;
function addBar()
{
barsArray[index]=new BarClass(index);
}
}
function BarClass()
{
var myIndex;
function BarClass(index)
{
myIndex=index;
}
}
</code></pre>
| javascript | [3] |
1,262,079 | 1,262,080 | convert number of seconds since 1970 to DateTime for a specific time zone? | <p>I want to convert seconds since 1970 to datetime for a specific time zone.</p>
<p>I have the time in milisecond and the timezone for a server.
I am getting these values by calling an API. I want to know the year,month, day of that time zone.</p>
<p>int milisecond = 12347586484;
zone = "GMT +8.00";</p>
<p>How can I do that?</p>
<p>Thanks,
Syd</p>
<p>Edit: Will I get the right date if I use gmtime()?</p>
<pre><code>timeinmilisecond + 8*360000;
struct tm *jobCreationtm;
time_t t = (time_t)(timeinmilisecond);
jobCreationtm = gmtime(&t);
</code></pre>
<p>Note: I dont want to use third party dlls.</p>
| c++ | [6] |
1,601,478 | 1,601,479 | why we use code-behind approch in asp.net? | <p>i want to know that why we use code behid approch. if there is some advantage then plese share to me ? as we know that there is two methode for writing server side code for
aspx.file </p>
<ul>
<li>code-behind approch in which we usually we seprate our server code aspx.cs file from aspx file </li>
<li>we can directly write server side code in aspx page by writing //server side codebefore html tag ?</li>
</ul>
<p>so i wnat to know that is ther any authentic reasion which provide advatage in code-behind approch.</p>
| asp.net | [9] |
5,758,612 | 5,758,613 | How can I get the MCC and MNC on an iPhone | <p>As per the subject - is there an API to get the MCC/MNC on iPhone OS 2.1 or above?</p>
| iphone | [8] |
4,829,924 | 4,829,925 | Pixel dimension | <pre><code>class Program
{
static void Main(string[] args)
{
Bitmap aBitmap = new Bitmap(@"c:\bitmap.bmp");
Image aImage = (Image)aBitmap;
Bitmap newBitmap = new Bitmap(aImage, new Size(100, 100));
newBitmap.Save(@"C:\newbitmap.bmp");
}
}
</code></pre>
<p>what will be the pixel dimension of each <code>pixel</code> if the size of the bitmap is <code>100X100</code>?
How the pixel dimension can be calculated?</p>
| c# | [0] |
5,380,350 | 5,380,351 | Better way of printing a mm:ss.ms stop watch string? | <p>I want to show a formatted string with minutes, seconds, and only one character of milliseconds. This is what I put together (mostly from other posts around here):</p>
<pre><code>public static final String getTimeDurationAsString(long milliseconds) {
int millis = (int) (milliseconds % 1000);
int seconds = (int) (milliseconds / 1000) % 60;
int minutes = (int) ((milliseconds / (1000*60)) % 60);
int hours = (int) ((milliseconds / (1000*60*60)) % 24);
StringBuilder sb = new StringBuilder();
if (hours > 0) {
sb.append(String.format("%02d", hours));
sb.append(":");
}
sb.append(String.format("%02d", minutes));
sb.append(":");
sb.append(String.format("%02d", seconds));
sb.append(".");
sb.append(String.format("%03d", millis).substring(0, 1));
return sb.toString();
}
</code></pre>
<p>So I will hide the hours position if the duration didn't exceed 59.9 minutes (which will usually be the case). I did a pretty bad substring() for the milliseconds position just to grab the first digit. Is there a better way to do the above? I'd like strings like:</p>
<pre><code>00:14.9
00:05.1
00:05.2
33:20:4
etc
</code></pre>
<p>I have to generate this string repeatedly for a game I'm making (the above rendered every frame) so afraid it's doing a lot of unnecessary work?</p>
<p>Thanks!</p>
| java | [1] |
3,769,760 | 3,769,761 | Time difference between unix timestamps | <p>I have to try and work out if a unix timestamp is between 21 days and 49 days from the current date. Can anyone help me to work this out? Thanks!</p>
| php | [2] |
4,352,178 | 4,352,179 | [python]: Where to find some great python code to study? | <p>I want study some real project code to improve my python coding.
Is there any great source ?</p>
| python | [7] |
3,059,046 | 3,059,047 | iphone target might include its own product | <p>After adding image resource into app (and may be some step I do not remember about) xcode reports with message: this target might contain its own product</p>
<p>Do you have any ideas how to solve this?</p>
<p>thank you</p>
| iphone | [8] |
113,188 | 113,189 | How to get value from the UIDatePicker? | <p>When i change the value in uIDatePicker at time no event is call.I want to gate change value from the UIDatePicker/</p>
| iphone | [8] |
5,952,456 | 5,952,457 | Should I use prepared statements for static values? | <p>Say on each pageload I want to grab the score of one particular use, <code>SELECT score FROM users WHERE id = 6</code>. None of those variables will ever change, and I'm not including POST/GET data into it.</p>
<p>Should I still use prepared statements? Or can I just use the <code>query</code> function?</p>
| php | [2] |
210,557 | 210,558 | Is stackoverflow using jQuery? | <p>I am a web developer, quite impressed with stackoverflow UI. there are lot of transitions, fade- ins and outs when buttons are clicked.. Is it using jQuery ? could you give me a sample jQuery code ?</p>
| jquery | [5] |
5,890,336 | 5,890,337 | Automatic page refresh even we navigate to another page | <p>i have a problem in page navigating. please help me to solve out.</p>
<p>in one asp.net page forexample Page1.aspx i have dropdown when we select an item in dropdown that would display in a label. Then we navigate to another page from page1.aspx to page2.aspx by clicking linkbutton in page1.aspx. Again if i come to page1.aspx that previously selected value of dropdown should appear in label.</p>
<p>please help me.</p>
| asp.net | [9] |
2,826,656 | 2,826,657 | How to color table rows on the basis of column 'value' or 'text' in javascript? | <p>I am having column name as 'Status'. If status is 'Pass' i need to show that row in green color. If 'fail' then red. How to do it in javascript? </p>
<pre><code>for (i=0; i < rows.length; i++) {
var value = rows[i].getElementsByTagName("td")[0].firstChild.nodeValue;
if (value == 'Pass') {
rows[i].style.backgroundColor = "red";
}
}
</code></pre>
<p>I tried this but it is not supported by browser. Kindly help. Thanks.</p>
| javascript | [3] |
3,887,477 | 3,887,478 | Creating a table in a canvas on Android | <p>Would anyone know how to create a table in android on a custom view. Code</p>
<pre><code>public void draw(Canvas canvas)
{
// TODO Auto-generated method stub
Rect rect = new Rect(4,4,canvas.getWidth(),canvas.getHeight()/5);
RectF rectF = new RectF(rect);
Paint t=new Paint();
t.setColor(Color.BLUE);
canvas.drawRoundRect(rectF, 10, 10, t);
t.setColor(Color.WHITE);
t.setStyle(Style.FILL);
t.setTextSize(30);
t.setStyle(Paint.Style.FILL);
t.setAntiAlias(true);
canvas.drawText("HOO",rectF.left,rectF.centerY(),t );
super.draw(canvas);
}
</code></pre>
<p>I want to be able to create a table where i can fill in specific information below this rectangle. Does anyone know how to achieve it.</p>
| android | [4] |
2,993,166 | 2,993,167 | jQuery: execute method from string | <p>Is there a way to call methods by their name in jQuery? For example:</p>
<pre><code>var condition = true;
$('div').execute(condition ? 'show':'hide');
</code></pre>
| jquery | [5] |
5,630,151 | 5,630,152 | jQuery within "Load" problem | <p>I'm having trouble getting jQuery to load inside a file that has been imported using jQuery <strong>load</strong>.</p>
<p>Here is the code I'm using to get the external page:</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$("#changeLinks a").click(function() {
$("#changeMe").fadeIn("slow").load($(this).attr('href'));
return false;
});
});
</script>
</code></pre>
<p>Aimed at a simple div (#changeMe).</p>
<p>I've heard about possibly using "<strong>live</strong>" but I don't have any experience with that function so I'm confused.</p>
<p>Any help would be great.</p>
| jquery | [5] |
4,144,068 | 4,144,069 | How to pass value from Page 1 to Page 2? [php] | <p>I'm kinda new to PHP and I want to pass the value from the <em>select</em> from a form in Page 1 to Page 2. Mind helping me? Thank you!</p>
| php | [2] |
3,469,681 | 3,469,682 | Adding a line break as separator | <p>I have a function that uses comma as separator in breaking name/email pairs from a long string. I would like to modify this function to be able to detect if instead of a comma a line break is used. Here's the function that needs to be modified:</p>
<pre><code>$str = '"Fname Lname" <abc@email.com>, abc@gmail.com';
$pairs = explode( ",", $str );
foreach( $pairs as $pair ) {
if( strpos($pair, '<') ) {
$output = explode( "<", $pair );
$output['0'] = trim( str_replace( "\"", "", $output['0'] ) );
$output['1'] = trim( rtrim( $output['1'], ">" ) );
} else {
$output = array();
$output['0'] = '';
$output['1'] = $pair;
}
print_r($output); // Save it to database here
}
</code></pre>
<p>I found a post suggesting using a file() fnction but I am not sure how to combine those two together.</p>
<pre><code>$str = '"Fname Lname" <abc@email.com>, abc@gmail.com';
$pairs = file($str, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
</code></pre>
| php | [2] |
809,070 | 809,071 | Android basic question | <p>I am new to Android.
can anyone tell me about Android that how can we run sample application on eclipse in android.while i run emulator opens but nothing is displayed on the screen.
Even HelloWorld Application is also not runnning. </p>
<p>My setup appears to be correct, I verified again.</p>
| android | [4] |
4,318,514 | 4,318,515 | question about filtering a dictionary using a list in python | <p>with the following dictionary and array:</p>
<pre>
a = { 'a':[1,2,3,4,5], 'b':[1,2,3], 'c':[1,2,3,4,5] }
b = ['a','c']
</pre>
<p>I would like to filter a into a new dictionary to only have the key-values in the array b so i end up with:</p>
<pre>
c = {'a': [1, 2, 3, 4, 5], 'c': [1, 2, 3, 4, 5]}
</pre>
<p>So.. the obvious way to do this for me was the following:</p>
<pre>
(1) dict(map( lambda x:(x,a[x]), b))
</pre>
<p>Searching for different ways to do it I also see this:</p>
<pre>
(2) dict( (x, a[x]) for x in b)
</pre>
<p>I don't fully have my head around (2) but before I dive too deep into what is going on is there an advantage to using (2) over (1)? Or better yet is there a better way to do this?</p>
| python | [7] |
4,296,832 | 4,296,833 | How can i generate random DNS names of Hosts in java | <p>this could be of the form:</p>
<p>aaa1.bbb2.ccc3.ddd4</p>
<p>Maybe taking a cue from <a href="http://www.dnsjava.org/download/" rel="nofollow">http://www.dnsjava.org/download/</a>
and first generating individual strings aaaa1 , bbb2 etc and then using join()</p>
<p>or</p>
<pre><code>String validCharacters = $('a', 'z').join() + $('A', 'Z').join();
String randomString(int length) {
return $(validCharacters).shuffle().slice(length).toString();
}
@Test
public void buildFiveRandomStrings() {
for (int i : $(5)) {
System.out.println(randomString(12));
}
}
</code></pre>
| java | [1] |
323,735 | 323,736 | Declaring Anonymous Inner class | <pre><code>rb.addActionListener(new ActionEvent(ae) {
public void actionPerformed(ActionEvent ae) {
nowCall(ae);
}
});
</code></pre>
<p><strong>Another way</strong></p>
<pre><code>Thread th=new Thread(Runnable r) {
public void run() {
// do something
}
};
// notice the ending of above 2 snippets
</code></pre>
<p>I am really confused seeing these two.It seems there is no exact pattern to declare an anonymous inner class.</p>
<p><em>please explain the syntax for anonymous inner class.</em></p>
| java | [1] |
1,889,514 | 1,889,515 | PHP - User registration | <p>I'ld like to create a very basic PHP based web app. The question is how to create the whole user registration, login, validation, profile stuff that every basic app needs?</p>
<p>Are there any good frameworks or is stuff like that usually build from scratch?</p>
<p>Thanks for your tips.
Michael</p>
| php | [2] |
2,831,176 | 2,831,177 | Android: random images changed when device is rotated to landscape mode | <p>I build an app which shows 3 random images from an SQLite database. But when I rotate my device to landscape mode, the random images are changed.
I dont want that acruallyy, what I want is the 3 random images stay still either on potrait or landscape mode.</p>
<p>Can anybody provide me a solution?</p>
<p>Thank you very much.</p>
| android | [4] |
490,746 | 490,747 | Final attribute initialized AFTER the object instantiation | <p>Well, I've a final property but I don't want to initialize it when I create my object because I can't. So I tried to not initialize it in my constructor but using a setter, I guessed it would have been something like a only-one-time usable setter, but I've this error :</p>
<blockquote>
<p>Test.java:27: error: cannot assign a value to final variable foo</p>
<pre><code> this.foo = new String(foo);
</code></pre>
</blockquote>
<p>Here is a short code I used to test this :</p>
<pre><code>class Test {
private final String foo;
public static void main(String[] args) {
Test test = new Test();
test.setFoo("gygygy");
System.out.println(test.getFoo());
}
public Test() {
System.out.println("Constructor");
}
public String getFoo() {
return foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
}
</code></pre>
<p>So I assume the constructor implicitly makes something like this.foo = new String(); or this.foo = null; and I think I can't modify this behavior, but how can I have an equivalent to what I wanna do ? I think in something like :</p>
<pre><code>private String foo;
/* ... */
public void setFoo(String foo) {
if( !(this.foo.isInitialized()) )
this.foo = foo;
}
</code></pre>
<p>but the Object.isInitialized() method obviously doesn't exist, and I can't find an equivalent x)</p>
<p>So here's my question in a few words : How can I do ? I want a <em>final attribute</em> that is <em>not initialized at the instantiation of the object</em>.</p>
<p>Thanks !</p>
| java | [1] |
2,611,406 | 2,611,407 | No compilation error on Runtime Exceptions. why? | <p>In the Below example if RuntimeException is replaced with some other exception then compiler throws the compilation error. But for Runtime Exception's it is not throwing anything. Why? Please explain.</p>
<pre><code>class A {
public void process() {
System.out.print("A,");
}
}
class B extends A {
public void process() throws RuntimeException {
System.out.print("B,");
throw new RuntimeException();
}
public static void main(String[] args) {
A a = new B();
a.process();
}
}
</code></pre>
| java | [1] |
5,219,221 | 5,219,222 | android action bar | <p>I have just started working with action bar.Can anyone give me the example of tabbed action bar with menus.
That will be more helpful to me while starting working with action bar.Thanks a lot in advance.</p>
| android | [4] |
2,240,414 | 2,240,415 | Animation doesn't stop when handler is called | <p>I have a system which works like this:
- I start a spinner animation in my view when a network request is fired.
- When the request finishes (within a AsyncTask) the Animation is stopped.</p>
<p>This works fine except when the display turns off because of lack of user action. This code won't work in this situation:</p>
<pre><code>imgVwSpinner.post(new Runnable() {
@Override
public void run() {
imgVwSpinner.clearAnimation();
imgVwSpinner.setImageResource(R.drawable.refresh);
}
});
</code></pre>
<p>Is there a workaround to ensure the animation is cleared?</p>
| android | [4] |
2,043,101 | 2,043,102 | Which is faster: $("li").last() or $("li:last-child")? | <p>In jQuery, which is faster to execute: <code>$("li").last()</code> or <code>$("li:last-child")</code> ?</p>
| jquery | [5] |
3,109,495 | 3,109,496 | C# Javascript iframe resize | <p>How do you auto resise an iframe after you've added content to a div in the code behind. I'm called </p>
<pre><code>function resizeIframe() {
parent.document.getElementById('iframe2').style.height = document.getElementById('events_calendar').offsetHeight;
}
</code></pre>
<p>but i'm about 20 px short. BAsically i've got a calendar that renders whats on on a certain day. this can be n number of lines. after i've popuplated that div in C# code behind I'm call resizeIframe() and not getting anywhere. i've tired style.height, clientheight etc.</p>
<p>Thanks
Frames</p>
| javascript | [3] |
2,475,934 | 2,475,935 | Why won't my timer increment the number? | <p>I recently learned javascript. I was experimenting with it. Now, I tried to make a simple timer. Here is the code:</p>
<pre><code><html>
<head>
<script type="text/javascript">
function start(obj)
{
var t = setTimeout("increment(obj)", 1000);
}
function increment(obj)
{
obj.innerHTML = parseInt(obj.innerHTML) + 1;
start(obj);
}
</script>
</head>
<body>
<p onclick="start(this)">0</p>
</body>
</html>
</code></pre>
<p>The contents of the <code><p></p></code> should be incremented by 1 every second. Does anyone know why this doesn't work?</p>
| javascript | [3] |
870,664 | 870,665 | Play Google (Android store) Statistics | <p>I'm guessing that these stats I can see in my Developer Console are not in realtime. Does anybody know what time they update them at?</p>
<p>My statistics are low, at the moment its only showing 11th of march to the 12th. Does this mean that I haven't had any downloads on the 13th or 14th or that it has not updated yet? </p>
<p>13th and 14th are not visible on the graph at all the line stops at the 12th. Does this mean it just hasn't updated yet?</p>
| android | [4] |
573,076 | 573,077 | is it a php bug? (about extends) | <pre><code>class A extends B {}
class B extends C{}
class C {}
</code></pre>
<p>result</p>
<pre><code>PHP Fatal error: class 'B' not found ...
</code></pre>
<p>if the order is like this</p>
<pre><code>class A extends B {}
class C {}
class B extends C{}
</code></pre>
<p>everything is ok.</p>
<hr>
<p>PS: if I remove class C {}</p>
<pre><code>class A extends B {}
class B extends C{}
</code></pre>
<p>php tells me class 'B' is not found, why?</p>
<p>php version 5.3.4</p>
| php | [2] |
3,831,458 | 3,831,459 | A question related to UITextfield | <ol>
<li>I have code that dynamically load 10 different textfields in viewdidload method</li>
<li>now if i click on any UITextfield and then autorotate device then my cursor should directly
come to that UITextfield when device rotates from portrait to landscape mode</li>
<li>second case is that if i click on any UITextfield and then i click on return and then if i rotate my device from portrait to landscape mode then also it works as 1 st case</li>
</ol>
<p>How to do this thing by code<br>
any guidance helps me a lot<br>
I'm stuck here</p>
| iphone | [8] |
3,427,478 | 3,427,479 | Asp.net Variable is not working on the page | <p>I have the following code:</p>
<pre><code><tr id="test" runat="server">
<td align="<%=myalignment%>">
</code></pre>
<p>I set myalignment = "center", however, when the page is rendered, it doesn't grab the variable. It just shows exactly how it is above. I wanted to programatically change certain TDs to "center" or "left" and I thought this would work. Any ideas?</p>
<p>If tr doesn't have runat="server", then it works fine...</p>
| asp.net | [9] |
5,848,568 | 5,848,569 | iPhone: Is it possible to put a link in Push-Notifications? | <p>Is it possible to put a link in Push-Notifications message? I wish to send video link as notification. </p>
| iphone | [8] |
4,060,328 | 4,060,329 | Removing elements from an object with changing indexes | <p>I am having trouble deleting rules from the stylesheet object due to ever changing indexes.</p>
<p>I have this function:</p>
<pre><code>function delete_styles(delete_array){
console.log(delete_array); // ["0,0", "0,1", "0,2", "0,6", "0,7", "0,8", "0,9", "0,10", "0,14", "0,15", "0,16"]
for(var i in delete_array){
var pair = delete_array[i].split(',');
var p1 = parseInt(pair[0]);
var p2 = parseInt(pair[1]);
document.styleSheets[p1].deleteRule(p2);
}
}
</code></pre>
<p>However, as soon as I delete <code>(0,0)</code>, the index <code>(0,1)</code> is invalid because it becomes <code>(0,0)</code>!</p>
<p>I can't just use a counter and take a way an incrementing amount each time because there may be larger gaps in the CSS rules.</p>
<p>Any help on the logic here?</p>
| javascript | [3] |
3,180,624 | 3,180,625 | javascript string assignment by index number quirk | <pre><code>a="12345"
a[2]=3
a[2]='9'
console.log(a) //=> "12345"
</code></pre>
<p>What is going on?? This quirk caused me 1 hour painful debugging. How to avoid this in a sensible way?</p>
| javascript | [3] |
4,301,574 | 4,301,575 | submit inside submit | <p>I admit its not very clear title. But I did not know how else to name what I am trying to do.</p>
<p>I have index.htm. this page pulls data from index.asp?Process=ViewRequests with the following code.</p>
<pre><code> $(function Requests() {
$.ajax({
type: 'GET',
url: 'content/requests/index.cs.asp?Process=ViewRequests',
success: function(data) {
$("#requests").html(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#requests").html('.');
}
});
});
</code></pre>
<p>Then, in this new pulled data set, I have a few forms. All forms have REQUESTFORM as ID and submit buttons' name is respond. What I need it needs to perform; once user clicks on either of these forms, clicked form should send its data to index.asp?Process=RespondRequests and print its response.</p>
<pre><code> $("[name='respond']").click(function() {
$.ajax({
type: "POST",
data: $("#REQUESTFORM").serialize(),
url: "content/requests/index.cs.asp?Process=RespondRequests",
success: function(output) {
$('#REQUESTFORM').html(output)
},
error: function(output) {
$('#REQUESTFORM').html(output);
}
});
});
</code></pre>
<p>Is this even possible?</p>
| jquery | [5] |
2,382,722 | 2,382,723 | Tuple conversion to a string | <p>I have the following list:</p>
<pre><code>[('Steve Buscemi', 'Mr. Pink'), ('Chris Penn', 'Nice Guy Eddie'), ...]
</code></pre>
<p>I need to convert it to a string in the following format:</p>
<pre><code>"(Steve Buscemi, Mr. Pink), (Chris Penn, Nice Guy Eddit), ..."
</code></pre>
<p>I tried doing </p>
<pre><code>str = ', '.join(item for item in items)
</code></pre>
<p>but run into the following error:</p>
<pre><code>TypeError: sequence item 0: expected string, tuple found
</code></pre>
<p>How would I do the above formatting?</p>
| python | [7] |
2,296,388 | 2,296,389 | Android - How to get TimeZone Value from milliseconds | <p>In Android how to get TimeZone value(GMT+8.00) from milliseconds long value.</p>
<p>Thanks</p>
| android | [4] |
4,561,888 | 4,561,889 | adding links into javascript | <p>I was trying to add links into javascript but could not do it. Loober is checking an input box. According to the focus, i wanted to change the links that appear on the page. changeME is default.</p>
<pre><code> <script type = "text/javascript">
var check = document.getElementById("loober");
var testElement = document.getElementById("changeMe");
var text = "bbb";
var text2 = "aaa";
check.onfocus= function()
{
testElement.innerHTML = text.link("index.php");
}
check.onblur = function()
{
testElement.innerHTML = text2.link("home.php");
}
</script>
</code></pre>
<p>Thanks</p>
| javascript | [3] |
4,041,892 | 4,041,893 | setting delegate of a custom class | <p>i am working in creating a custom class which is subclass of UIWebview. But its delegate functions are not being called. How should i set delegate for this class. I know this is a basic question but it will be really good if some one could answer it. Thanks in advance.</p>
<p>My Code:</p>
<p>.h file</p>
<pre><code>@interface PollackWebView : UIWebView<UIWebViewDelegate> {
}
-(id)initWebview:(CGRect)frame;
@end
</code></pre>
<p>.m file:</p>
<pre><code>@implementation PollackWebView
-(id)initWebview:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
}
return self;
}
-(void)SetMyDelegate {
self.delegate = self;
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@"shouldStartLoadWithRequest");
if ( navigationType == UIWebViewNavigationTypeLinkClicked ) {
// do something with [request URL]
return NO;
}
return TRUE;
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
NSLog(@"webViewDidStartLoad");
}
</code></pre>
| iphone | [8] |
5,840,569 | 5,840,570 | What does the C++ compiler error "looks like a function definition, but there is no parameter list;" mean? | <pre><code>#include <iostream>
#include <fstream>
using namespace std;
int main
{
int num1, num2;
ifstream infile;
ostream outfile;
infile.open("input.dat");
outfile.open("output.dat");
infile >> num 1 >> num 2;
outfile << "Sum = " << num1 + num2 << endl;
infile.close()
outfile.close()
return 0;
}
</code></pre>
<p>This is what I did and when I compile it, I got this error that said</p>
<pre><code>error C2470: 'main' : looks like a function definition, but there is no
parameter list; skipping apparent body
</code></pre>
<p>Please don't hate me :( I am new at this computer science....</p>
| c++ | [6] |
158,589 | 158,590 | Series of views or series of activity? | <p>I've made my first android app :-) There's only one activity, and, on events, I modify the root view of the unique activity. My GUI is a series of views inside an unique activity.</p>
<p>Perhaps it's best to do one activity with only one root view, and, when I want to show another view, create and launch another activity, with only one general view ?</p>
<p>If so, how to do that ?</p>
<p>Thanks.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.