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,778,010 | 2,778,011 | simulation of static class in java | <p>What do you think of the following way to simulate a static class in java?
You can add non static methods but you wouldn't be able to call them.</p>
<pre><code> /**
* Utility class: this class contains only static methods and behaves as a static class.
*/
// ... prevent instantiation with abstract keyword
public abstract class Utilities
{
// ... prevent inheritance with private constructor
private Utilities() {}
// ... all your static methods here
public static Person convert(String foo) {...}
}
</code></pre>
| java | [1] |
5,191,626 | 5,191,627 | Help with retrieving answers from radio buttons | <pre><code>$host = 'localhost';
$user = 'root';
$pw = '';
$db = 'pmdb';
mysql_connect($host,$user,$pw);
mysql_select_db($db);
$result = mysql_query("SELECT * FROM Questions WHERE QuizID=1");
$num_rows = mysql_num_rows($result);
while($row = mysql_fetch_assoc($result))
{
$array[] = $row;
}
for($i=0; $i<=($num_rows-1); $i++)
{
$title = $array[$i]['Title'];
$ans1 = $array[$i]['Answer1'];
$ans2 = $array[$i]['Answer2'];
$ans3 = $array[$i]['Answer3'];
$ans4 = $array[$i]['Answer4'];
echo $title.'<br>';
echo '<form method="post">';
echo '<input type="radio" name="ans'.$i.'">'.$ans1.'<br>';
echo '<input type="radio" name="ans'.$i.'">'.$ans2.'<br>';
echo '<input type="radio" name="ans'.$i.'">'.$ans3.'<br>';
echo '<input type="radio" name="ans'.$i.'">'.$ans4.'<br>';
}
echo '<input type="submit" value="submit" id="submit">';
echo '</form>';
</code></pre>
<p>I manage to display the question followed by the corresponding choices and at the bottom a submit button. </p>
<p>How would I, on click of the submit button, get the values that the user have chosen for each question that was looped out from the database? <code>ans1</code>, <code>ans2</code>, etc.</p>
<p>This is necessary to compare their answer to the answer key and compute their score.</p>
<p>.help please! Thank you very much and More power!</p>
| php | [2] |
4,795,794 | 4,795,795 | How can I decode a URL with jQuery? | <p>How can I decode a URL using jQuery? My url is </p>
<blockquote>
<p>http%3A%2F%2Fdtzhqpwfdzscm.cloudfront.net%2F4ca06373624db.jpg</p>
</blockquote>
| jquery | [5] |
605,863 | 605,864 | Way to force image to reload from server | <p>I've seen all of the other posts on similar issues with setAttribute() in IE, but can't seem to get any of the workarounds to, er, work (specifically for the src attribute of an img element.</p>
<p>The example:</p>
<pre><code>function reloadCaptcha(sImgElementId) {
var oImgElement = document.getElementById(sImgElementId);
oImgElement.setAttribute('src', oImgElement.src);
return false;
}
</code></pre>
<p>And the img element:</p>
<pre><code><img id="nlc" name="nlc" src="/inc_captcha.asp" onClick="javascript:reloadCaptcha('nlc'); return false;" />
</code></pre>
<p>It just reloads the src. Works like a charm in Chrome and FF. Nada in IE.</p>
<p>How can I make this work in IE?</p>
| javascript | [3] |
4,932,727 | 4,932,728 | adb shell input events | <p>What is the basic difference between "adb shell input keyevent" and "adb shell sendevent " .Which one should I use for inputting a character and are the both keycodes same that we pass to both the commands?</p>
<p>Regards,
KVR</p>
| android | [4] |
2,335,483 | 2,335,484 | Create XML file in Local Memory | <p>I want to read XML data from the net and then store it in a XML file in android device's local memory.
How do i do that.
I have used following code for getting XML data:</p>
<pre><code>HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
String str = EntityUtils.toString(rp.getEntity());
}
</code></pre>
<p>I am getting the xml data as string. Now I want to dump it ina xml file.</p>
<p>Thanks</p>
| android | [4] |
3,246,897 | 3,246,898 | Drawing with a canvas over an ImageView | <p>I want to create an ImageView and then draw text on top of the ImageView. I also need to be able to modify the text periodically. Currently I've created a custom view that extends ImageView. Then I overwrite onDraw() and use it to draw the text. Only problem then is that when I use my custom ImageView it doesn't draw the image, just the text.</p>
<pre><code>public class BoardView extends ImageView
{
public BoardView(Context context)
{
super(context);
}
protected void onDraw(Canvas canvas)
{
Paint paint = new Paint();
setImageResource(R.drawable.board);
paint.setColor(Color.BLUE);
canvas.drawText(x.getName(), x.getX(), x.getY(), paint);
}
}
</code></pre>
| android | [4] |
1,790,276 | 1,790,277 | Create Text File in Memory and return it over ajax, possible? | <p>I can create a text file easily enough but I want to avoid having to keep the file on the server. </p>
<p>How can I create a text file in memory and return it over ajax so the file itself is returned and no file is kept on server? It doesn't need to be ajax but I want to avoid a postback if at all possible.</p>
| asp.net | [9] |
4,390,022 | 4,390,023 | cpp run function that before it is declared? | <p>I'm new to CPP, and I want to know how to run a function that isn't in its scope. I'm used to doing such things in javascript, and I get an error CPP when I try to do that. What I mean is the below:</p>
<pre><code>#include <iostream>
using namespace std;
int tic_h;
int tic_v;
void echo(string e_val){
cout << e_val;
}
void c_mes(){
echo("X|0|X\n");
echo("-----\n");
echo("X|0|X\n");
echo("-----\n");
echo("X|0|X\n");
s_v();
}
void s_v(){
echo("Please enter vertical coordinate: ");
cin >> tic_v;
if(tic_v<4&&tic_v>0){
c_mes();
}else{
s_v();
}
}
void s_h(){
echo("Please enter horizontal coordinate: ");
cin >> tic_h;
if(tic_h<4&&tic_h>0){
s_v();
}else{
s_h();
}
}
int main(){
s_h();
return 0;
}
</code></pre>
<p>I get this error:</p>
<blockquote>
<p>error: 'sv' was not declared in this scope on line 16</p>
</blockquote>
<p>How can I make it work?</p>
| c++ | [6] |
5,096,526 | 5,096,527 | Handling Multiple UITableViews and Insertion/Deletion of cells in those tables | <p>I have two table views in a single controller.One is grouped whose frame is (0,0,320,70), other one is plain whose frame is (0,70,320,300).In the grouped tableView, I am adding the cells dynamically and want this plain tableView to shift down, so that the grouped tableView is completely visible. In a similar way,when I remove cells dynamically from grouped tableView, I want the plain tableView to shift Up and adjust according to the new height of grouped tableView.</p>
<p>Help me out with this. Is there any apple provided sample to do such a thing ? </p>
| iphone | [8] |
3,408,921 | 3,408,922 | Weird JavaScript Code | <pre><code>for (var i=a.length-1;i>0;i--) {
if (i!=a.indexOf(a.charAt(i))) {
a=a.substring(0,i)+a.substring(i+1);
}
}
</code></pre>
<p>I found this in a web app I'm auditing, it just baffles me why it's there.
I can't seem to see a case where <code>i!=a.indexOf(a.charAt(i))</code> would be false.</p>
<p>The value the pass to it is:</p>
<pre><code>a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
</code></pre>
<p>There is no comment either //sigh</p>
| javascript | [3] |
454,254 | 454,255 | Javascript Bitwise Operators | <p>I'm trying to figure out some differences between C# and Javascript. Ok, take this code in Javascript:</p>
<pre><code>var j = 0x783a9b23;
var bt = ((16843134 ^ (16843134 - 1)) * j);
</code></pre>
<p>After executing this, "bt" will be 6051320169. </p>
<p>Now after doing this in C#:</p>
<pre><code>int j = 0x783a9b23;
int bt = ((16843134 ^ (16843134 - 1)) * j);
</code></pre>
<p>"bt" will be 1756352873. Certainly not the same. Any ideas why Javascript is not seeing how C# sees it?</p>
| javascript | [3] |
4,967,957 | 4,967,958 | How does the compiler know where control should return to after a function call? | <p>Consider the following functions:</p>
<pre><code>int main()
{
//statement(s);
func1();
//statement(s);
}
void func1()
{
//statement(s);
func2();
//statement(s);
}
void func2()
{
//statement(s);
}
</code></pre>
<p>How does the compiler know where to return to after the <code>func2</code> has performed all its operations? I know the control transfers to function <code>func1</code> (and exactly which statement), but <em>how</em> does <em>the compiler</em> knows it? What tells the compiler where to return to?</p>
| c++ | [6] |
2,390,721 | 2,390,722 | pass method as parameter using anonymous inner class | <p>There was an answer similar to this here:
<a href="http://stackoverflow.com/questions/4685563/how-to-pass-a-function-as-a-parameter-in-java">How to pass a function as a parameter in Java?</a></p>
<p>but the correct answer provided does not work. I have a class:</p>
<pre><code>public class randomClass {
2
3 public String name;
4 private int x;
5 private boolean y;
6
7 public randomClass(String name){
8 this.name = name;
9 setAttributes(1,true, "test");
10 System.out.println(x + "," + y);
11 }
...
21
22 public int xMethod(){
23 return 1;
24 }
25
26 public void passMethod(){
27 testMethod(new Callable<Integer>() {
28 public Integer call(){
29 return xMethod();
30 }
31 });
32 }
33
34 public void testMethod(Callable<Integer> myFunc){
35
36 }
</code></pre>
<p>inside function passMethod im trying to pass xMethod() into testMethod, but the error I get is:</p>
<pre><code>cannot find symbol
symbol : class Callable
</code></pre>
<p>and I'm not sure why.</p>
<p>Also, I tried using return type String for xMethod, can you pass a function with different return types then Integer?</p>
| java | [1] |
4,975,189 | 4,975,190 | Pythonic equivalent of this function? | <p>I have a function to port from another language, could you please help me make it "pythonic"?</p>
<p>Here the function ported in a "non-pythonic" way (this is a bit of an artificial example - every task is associated with a project or "None", we need a list of distinct projects, distinct meaning no duplication of the .identifier property, starting from a list of tasks):</p>
<pre><code>@staticmethod
def get_projects_of_tasks(task_list):
projects = []
project_identifiers_seen = {}
for task in task_list:
project = task.project
if project is None:
continue
project_identifier = project.identifier
if project_identifiers_seen.has_key(project_identifier):
continue
project_identifiers_seen[project_identifier] = True
projects.append(project)
return projects
</code></pre>
<p>I have specifically not even started to make it "pythonic" not to start off on the wrong foot (e.g. list comprehension with "if project.identifier is not None, filter() based on predicate that looks up the dictionary-based registry of identifiers, using set() to strip duplicates, etc.)</p>
<p>EDIT:</p>
<p>Based on the feedback, I have this:</p>
<pre><code>@staticmethod
def get_projects_of_tasks(task_list):
projects = []
project_identifiers_seen = set()
for task in task_list:
project = task.project
if project is None:
continue
project_identifier = project.identifier
if project_identifier in project_identifiers_seen:
continue
project_identifiers_seen.add(project_identifier)
projects.append(project)
return projects
</code></pre>
| python | [7] |
2,925,527 | 2,925,528 | Is there a javascript equivalent of python's __getattr__ method? | <p>In python you can define a object having <code>__getattr__(self,key)</code> method to handle all unknown attributes to be solvable in programmatic manner, but in javascript you can only define getters and setters for pre-defined attributes. Is there a generic way of getting the former thing done also in javascript?</p>
<p>Sample code would be smth like:</p>
<pre><code>function X() {};
X.prototype={
__getattr__:function(attrname) {
return "Value for attribute '"+attrname+"'";
}
}
x=new X()
alert(x.lskdjoau); // produces message: "Value of attribute 'lskdjoau'"
</code></pre>
<p>Key point is getting value of attribute programmatically depending on the name of the attribute. Pre-setting attribute does not help because during init there is no information what attributes might be requested.</p>
| javascript | [3] |
4,134,000 | 4,134,001 | Android - How can I programmatically add a VPN network | <p>The Settings on Android provides an option to add VPN manually.</p>
<p>Can this be done programmatically through some kind of an API?</p>
<p>I'm not looking for a way to connect to a VPN. I'm only concerned about configuring a VPN profile.</p>
| android | [4] |
3,598,489 | 3,598,490 | jQuery - Check a Input Field for a Word in a String | <p>I have users that are putting in links to youtube videos and we want to only enable the button if the string (URL) they enter contains the word, 'youtube'. Below is the code and I can't get it to work how I need it to. Thanks...</p>
<pre><code>var inputValue = $('#inputLink').val();
</code></pre>
<hr>
<pre><code>$('#submitBtn').attr("disabled", "disabled");
$('#inputLink').keyup(function(){
if (inputValue.toLowerCase().indexOf("youtube") >= 0) {
$('#submitBtn').removeAttr('disabled');
}
});
</code></pre>
| jquery | [5] |
3,512,724 | 3,512,725 | Correct javascript inheritance | <p>I've been reading a lot of articles about "inheritance" in javascript. Some of them uses <code>new</code> while others recommends <code>Object.Create</code>. The more I read, the more confused I get since it seems to exist an endless amount of variants to solve inheritance.</p>
<p>Can someone be kind to show me the most accepted way (or defacto standard if there is one)?</p>
<p>(I want to have an base object <code>Model</code> which I can extend <code>RestModel</code> or <code>LocalStorageModel</code>.)</p>
| javascript | [3] |
5,252,492 | 5,252,493 | javascript date and loop check | <p>Hey all, this is the code i have to check for a day thats equal to the list of days in the comma seperated list:</p>
<pre><code>for(var i = 0; i < daysHidden.length; i++){
if (daysHidden[i] == d.getDate());
{
alert(daysHidden[i] + '=' + d.getDate());
}
}
</code></pre>
<p>the daysHidden = 1 (its the only thing in the list April 1st is already gone and todays the 2nd so 1 is the only one in the list)</p>
<p>and d.getDate() has 1-30 (for april)</p>
<p>When i run the code, however, it keeps looping through the if code when it should only loop once (when it finds that 1=1</p>
<p>However, i keep getting the alert box that says:</p>
<p>1=1</p>
<p>1=2</p>
<p>1=3</p>
<p>etc.... 1=30</p>
<p>So i do not know what i am doing incorrect? I already tried putting them as strings:</p>
<pre><code> if (daysHidden[i].ToString == d.getDate().ToString);
</code></pre>
<p>But that doesnt seem to work.... Any help would be great :)</p>
<p>David</p>
| javascript | [3] |
4,377,621 | 4,377,622 | Or symbol for JavaScript object declaration | <p>I just started to read some JavaScript project. Most of the .js file to start with have an object declared as the following:</p>
<pre><code>window.Example || {
bleh: "123";
blah: "ref"
}
</code></pre>
<p>What does the <code>||</code> symbol do here?</p>
| javascript | [3] |
5,187,209 | 5,187,210 | Sqllite or shared preferences to persist the changes | <p>I have a scenario where upon clicking on a button, i need to show/hide an <code>listView</code>. I have a <code>Activity</code> which holds 12 <code>ListViews</code>, if the user hides 5 <code>listViews</code>, then for that entire session until he log's out of app, the acitvity should show only 5 <code>ListViews</code>.</p>
<p>In this situation how would i carry out the operation, should i save the checked value in a sqllite and read it each time when the user opens that activity or should i go with some other approach. How would it impact the performance of the <code>application</code>. </p>
| android | [4] |
4,798,667 | 4,798,668 | Aligning text to the right in the C++ console | <p>How do I format my console output so that it's aligned to the right in C++? </p>
| c++ | [6] |
3,667,711 | 3,667,712 | iphone security : Does the app screenshot get saved in cache even if backgrounding is removed? | <p>From what I have read , I understand that iOS takes a screenshot whenever the app goes into the background and stores it in the cache for transition purposes. My client has security issues, therefore I have removed backgrounding from my app to make sure that the screenshot is not taken.</p>
<p>Now, I have read in some places, that this is not enough, I also need to put some sort of "white screen" to cover up my content or make sure that all fields are set as empty in applicationWillTerminate. Is this required ? and if I have removed backgrounding where does the screenshot get stored on the file system ?</p>
<p>Regards,
Harikant Jammi</p>
| iphone | [8] |
2,442,743 | 2,442,744 | how to to scroll smoothly between divs without jquery | <p>i want to to scroll up and down a page with javascript smoothly. i have follow some code on this page-</p>
<p><a href="http://www.xfunda.com/index.php?view=article&id=55%3Ajavascript-page-scroll-scroll-a-web-page-from-bottom-to-top-smoothly&option=com_content&Itemid=75" rel="nofollow">http://www.xfunda.com/index.php?view=article&id=55%3Ajavascript-page-scroll-scroll-a-web-page-from-bottom-to-top-smoothly&option=com_content&Itemid=75</a></p>
<p>but this only goes up, im quite confused on hot to get to specific div's</p>
| javascript | [3] |
5,898,485 | 5,898,486 | Ontouch of two imageButtons at the same time | <p>I have two image-buttons on my layout I have to handle three cases
1.button 1 get touched
2. Button 2 get touched
3. button 1 and 2 both touched at the same time</p>
<p>In my OntouchListner I have cached the first two cases But how to catch the 3rd one ? please Help me... </p>
| android | [4] |
5,465,073 | 5,465,074 | Python Multiple inheritance | <p>I have 3 classes A,B and D as given below</p>
<pre><code>class A(object):
def test(self):
print "called A"
class B(object):
def test(self):
print "called B"
class D(A,B):
def test(self):
super(A,self).test()
inst_d=D()
inst_d.test()
----------------------------------------
Output:
called B
</code></pre>
<p>Question: In <code>D.test()</code>, I am calling <code>super(A,self).test()</code>. Why is only <code>B.test()</code> called even though the method <code>A.test()</code> also exists?</p>
| python | [7] |
5,916,076 | 5,916,077 | Add properties to an anonymous JavaScript type after defined? | <p>I know that in JavaScript you can add new properties to an existing type (like Date), but is it possible to add new properties to an anonymous type after it's been defined?</p>
<p>For example, say I have the following script:</p>
<pre><code>var employee = {
'Name': 'Scott',
'Age': 32,
'JavaScriptNewbie': true
};
</code></pre>
<p>Later on in my script I want to add a new property to this employee object (say, Salary). Is that possible?</p>
<p>TIA!</p>
| javascript | [3] |
323,290 | 323,291 | How do I access members in John Resig's class in ajax callbacks? | <p>I am using John resig's implementation class mentioned here: <a href="http://ejohn.org/blog/simple-javascript-inheritance/" rel="nofollow">http://ejohn.org/blog/simple-javascript-inheritance/</a></p>
<p>Now I have a function, which is actually a callback supplied to an ajax method. Now, how do I access the class members inside this function?</p>
<p><strong>---EDIT---</strong></p>
<p><strong>CASE I</strong></p>
<p>Suppose, here is the class I defined:</p>
<pre><code>var Person = Class.extend({
init: function(isDancing){
this.dancing = isDancing;
},
dance: function(){
return this.dancing;
}
});
</code></pre>
<p>And I use it like:</p>
<pre><code>var p = new Person(true);
$.ajax({url: url, success: p.dance});
</code></pre>
<p>Then, in the dance method, this.dancing wont work, because this wont point to the object p.</p>
<p><strong>CASE II:</strong></p>
<p>I am using knockoutjs (http://knockoutjs.com) for binding my UI to the objects. Suppose we have:</p>
<pre><code>var AppViewModel = Class.extend({
person: new Person()
});
</code></pre>
<p>and binding in html would be:</p>
<pre><code><button data-bind="click: person.dance">Dance</button>
</code></pre>
<p>in this case, the 'this' in dance would point to the object of AppViewModel, and not person.</p>
<p>The latter case is more important for me.</p>
| javascript | [3] |
734,779 | 734,780 | jquery selector | <p>I am having trouble getting my selector right here. What this function is suppose to do is</p>
<ol>
<li>Select the image and shift the opacity on hover</li>
<li>Select the anchor tag an slideUp on hover</li>
</ol>
<p>If you can help me get the anchor tag selected specific to the particular image that is being hovered over that would be great. I've tried many different ways but I'm not that great with syntax.
Thanks!</p>
<pre><code>$(document).ready(function() {
$('.workitem_photo > img').each(function() {
$(this).hover(function() {
$(this).stop().animate({ opacity: 0.8 }, 500);
$(this > '.workitem_projectdetails').show('500')
},
function() {
$(this).stop().animate({ opacity: 1.0 }, 500);
$(this > '.workitem_projectdetails').hide('500')
});
});
});
</code></pre>
<p>Here is the html:</p>
<pre><code><div class="workitem branding">
<div class="workitem_photo"><img src="<?php echo home_url( '/wp-content/themes/po/' ); ?>images/workitem/branding-1000ikc.gif" alt="1000 Islands Kayaking" /></div>
<div class="workitem_title">1000 Islands Kayaking Identity</div>
<div class="workitem_description">Brand development for a Kayak tour operator.</div>
<a class="workitem_projectdetails" href="#" style="display:none;">View Project Details</a>
</div>
</code></pre>
<p>Here is a working version <a href="http://www.patrickorr.ca" rel="nofollow">my test site</a></p>
| jquery | [5] |
4,659,680 | 4,659,681 | Why isn't this showing? | <p>Web Developer is showing my JavaScript as being valid, but if I run the page this does not work. I tried following the usage on jquery-color's site, but it kept returning property id missing everytime. I really wish when I took JavaScript in college that I had a better instructor. He flashed through jQuery and most of JavaScript as a whole without really teaching it.</p>
<p>Edit #1: I fixed the (this) error in the code, but still a no go.</p>
<p>Here is the code for the jQuery:</p>
<pre><code><script type="text/javascript">
jQuery("li.site-links").hover(function(){
jQuery(this).stop().animate({
backgroundColor: "#000000"
}, 1000 );
});
</script>
</code></pre>
<p>and site link: <a href="http://lab.nmjgraphics.com" rel="nofollow">http://lab.nmjgraphics.com</a></p>
| jquery | [5] |
583,072 | 583,073 | how loaders deliver new result when the content change | <p>from the <a href="http://developer.android.com/guide/topics/fundamentals/loaders.html" rel="nofollow">API</a> it says that one of the loaders characteristics is :</p>
<blockquote>
<p>They monitor the source of their data and deliver new results when the
content changes.</p>
</blockquote>
<p>i used a loader with cursors not ContentProvider , and i have a list that display the cursor when i make a delete or update to the table i load the cursor from the loader deos not deliver new result as they says , why that ? or i misunderstand something ? </p>
| android | [4] |
4,507,120 | 4,507,121 | Storing a pointer to an object created in a method | <p>Using C++:</p>
<p>I currently have a method in which if an event occurs an object is created, and a pointer to that object is stored in a vector of pointers to objects of that class. However, since objects are destroyed once the local scope ends, does this mean that the pointer I stored to the object in the vector is now null or undefined? If so, are there any general ways to get around this - I'm assuming the best way would be to allocate on the heap.</p>
<p>I ask this because when I try to access the vector and do operations on the contents I am getting odd behavior, and I'm not sure if this could be the cause or if it's something totally unrelated.</p>
| c++ | [6] |
5,929,323 | 5,929,324 | asp.net stored procedure problem | <p>Why this code don't work,when i want run this code vwd 2008 express show me this error message:Invalid object name 'answers'.</p>
<p>this is my ascx.cs code:</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data.SqlClient;
using System.Configuration;
public partial class odgl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
string connectionString =
@"SANATIZEDSTRING!!!!";
using (SqlConnection cn = new SqlConnection(connectionString))
{
using (SqlCommand dohvati = new SqlCommand("dbo.get_answers",cn)) {
dohvati.CommandType = CommandType.StoredProcedure;
SqlParameter izracun = new SqlParameter("@count", SqlDbType.Int);
izracun.Direction = ParameterDirection.Output;
dohvati.Parameters.Add(izracun);
cn.Open();
dohvati.ExecuteNonQuery();
int count = Int32.Parse(dohvati.Parameters["@count"].Value.ToString());
Response.Write(count.ToString());
cn.Close();
}
}
}
}
</code></pre>
<p>and this is my stored procedure
:</p>
<pre><code>set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[get_answers]
@ukupno int output
as
select @count= (SELECT COUNT(*) FROM answers)
go
</code></pre>
| asp.net | [9] |
673,150 | 673,151 | Why does "a + + b" work, but "a++b" doesn't? | <p>I was fiddling around with different things, like this</p>
<pre><code>var a = 1, b = 2;
alert(a + - + - + - + - + - + - + - + b); //alerts -1
</code></pre>
<p>and I could remove the spaces, and it would still work.</p>
<pre><code>a+-+-+-+-+-+-+-+b
</code></pre>
<p>Then I tried</p>
<pre><code>a + + b
</code></pre>
<p>It ran and evaluated to 3, but when I removed the spaces, (<code>a++b</code>) it wouldn't run, and it had a warning which read "Confusing plusses."</p>
<p>I can understand that in cases like</p>
<pre><code>a+++++b
</code></pre>
<p>which could be interpreted as any of the following</p>
<pre><code>(a++) + (++b)
(a++) + +(+b)
a + +(+(++b))
a + +(+(+(+b)))
</code></pre>
<p>that it would be confusing.</p>
<p>But in the case of</p>
<pre><code>a++b
</code></pre>
<p>the only valid way to interpret this, as far as I can tell, is</p>
<pre><code>a + +b
</code></pre>
<p>Why doesn't <code>a++b</code> work?</p>
| javascript | [3] |
825,498 | 825,499 | How should i understand built-in function bin(x)? | <blockquote>
<p><a href="http://docs.python.org/library/functions.html#bin" rel="nofollow"><strong><code>bin(x)</code></strong></a></p>
<p>Convert an integer number to a binary string. The result is a valid Python expression. If <code>x</code> is not a Python int object, it has to define an <code>__index__()</code> method that returns an integer.</p>
</blockquote>
<p>So if i want to get <code>bin</code> from <code>Cadilac</code> what should i do with this string and <code>__index__()</code> method? How to syntaticly proper compose them?</p>
| python | [7] |
448,943 | 448,944 | jquery two different date validation | <pre><code>var cin = $("#datepicker").val();
var cout = $("#datepicker2").val();
dateformat is : dateFormat: 'DD, d MM, yy'
</code></pre>
<p>how do i use jquery to check cin(checkin) date not past cout(checkout) date? which means, cout date cannot earlier then cin date</p>
| jquery | [5] |
2,964,663 | 2,964,664 | jquery ajax error when nothing wrong with http request | <p>I am using jquery to do ajax calls:</p>
<pre><code> // omitting the code for the options properties
var options = {
type: Type,
url: Url,
data: '{aString:"abc"}',
contentType: ContentType,
dataType: dataType,
//processdata: ProcessData,
success: function (msg) {
ServiceSucceeded(msg);
},
error: ServiceFailed
};
function ServiceFailed(result) {
alert('Service call failed: ' + result.status + '' + result.statusText);
}
$.ajax(options).done(function () {
alert("success: " + msg);
});
</code></pre>
<p>This call works in that the url defined in options is called. The endpoint is a wcf service which I host so I have verified it's called as expected.</p>
<p>I monitor the call with fiddler, and I see nothing wrong with the request or the response. The http response code is 200 OK.</p>
<p>But the function in done is not called. Instead ServiceFailed is run. Why is this? Why is done() not called, and why does jquery consi</p>
| jquery | [5] |
2,416,311 | 2,416,312 | get parent li text by jquery | <p>I need alert <strong>thisparenttext</strong> in following code by clicking on <strong>clickedlicontent</strong></p>
<pre><code><script>
$("#one").live("click",function(){
var partxt=$(this).parent().parent().text();
alert(partxt);
});
</script>
<ul>
<li>thisparenttext<ul><li id="one">clickedlicontent</li></ul></li>
<li>bb</li>
</ul>
</code></pre>
<p>In other word, I want take only the text of first parent of clicked li, not all its all html codes. </p>
| jquery | [5] |
5,883,788 | 5,883,789 | how to set the value of textarea with toolbar using javascript? | <p>I'm trying (from my firefox extension) to set the value of a textarea with toolbar which placed when creating a blog before posting it like in blogger or live-journal.</p>
<p>In simple textarea I can get or set the textarea value by:</p>
<pre><code>var myTextArea = gBrowser.contentDocument.getElementsByTagName("textarea")[0];
alert(myTextArea.value); // alerts the old value
myTextArea.value = "this is the new value of the textarea";
</code></pre>
<p>where there of course was only one textarea.</p>
<p>The problem is in textarea with toolbar.
I succeeded changing the value of the textarea i'm writing in right now even though it has toolbar, but in all other sites especially blog sites the element value is changed but the text in the page stays the same.</p>
<p>I thought maybe the textarea is CKEditor but I don't know it's name so I can't use:</p>
<pre><code>FCKeditorAPI.GetInstance('InstanceName').insertText("new value in textarea");
</code></pre>
<p>is the textarea in sites such as mentioned above is CKEditor? and more important - how do i set the it's value?</p>
<p>thanks!</p>
| javascript | [3] |
3,321,083 | 3,321,084 | Array name is not defined in python NameError | <p>I am a beginner in python and started to learn basics. I have a sample program here in python </p>
<pre><code>#Simple Program Python
tf=float(input("Enter total time of run in seconds "))
delt = float(input("Enter the time step of run "))
dx = float(input("Enter the value of dx "))
xf = float(input("Enter the total length of a channel "))
n =float(tf/delt)
#t =range[n]
from array import array
m = xf/dx
for i in range(0,int(n)) :
t[i]=i*tf/n
print("THe total time of run is %r " %tf)
print("seconds")
print("The time step is %r" %delt)
print("Number of steps is %r" %n)
print("The number of space step in X direction is %r " %m)
</code></pre>
<p>In the for loop, when I try to assing t[i], then it throws an error "NameError: name 't' is not defined". In some stackoverflow questions, there was suggestions to use </p>
<pre><code>from array import array
</code></pre>
<p>But I still get an error. I tried that solution from <a href="http://stackoverflow.com/questions/7098938/nameerror-name-array-is-not-defined-in-python">NameError: name 'array' is not defined in python</a>. PLease help to get rid of this error. </p>
<p>Thanks. </p>
<p>Jdbaba</p>
| python | [7] |
4,231,458 | 4,231,459 | Whats wrong with this header code? | <pre><code>$return_url = $_SERVER['REQUEST_URI'];
header("Location: /logout?msg=You must login to view that page&c=2&path=$return_url");
</code></pre>
<p>For some reason its taking me to <code>http://my.domain/login?msg=You%20must%20login%20to%20view%20that%20page&c=2</code></p>
<p>when it should take me to </p>
<p>to <code>http://my.domain/login?msg=You%20must%20login%20to%20view%20that%20page&c=2&path=/blogs/write</code></p>
<p>if i echo <code>$return_url</code> it returns the right path...</p>
<p>So i'm not sure whats up. Help?</p>
| php | [2] |
5,363,715 | 5,363,716 | Android unique id | <p>How do I get an unique ID from an Android phone?</p>
<p>Whenever I try to get the unique ID from the phone as a string it
always shows <em>android id</em> and no other unique hex values.</p>
<p>How do I
get that one?</p>
<p>This is the code I use to get the ID until now:</p>
<pre><code>String id=Settings.Secure.getString(contentResolver,Settings.Secure.ANDROID_ID);
Log.i("Android is is:",id);
</code></pre>
<p>the output which I get looks like this:</p>
<pre><code>Android id is: android id
</code></pre>
<p>I am using a Nexus One for testing.</p>
| android | [4] |
1,170,848 | 1,170,849 | Java two get() methods after each other | <p>I am trying to compare two int values with a method. </p>
<p>I have put two get methods after each other because the array[i] is a list of person objects and gethouse only gives the house object, the houseid is in another class. </p>
<p>I'm wondering if I can set up two get() methods after each other?</p>
<pre><code>public Person findperson( int houseId ){
for ( int i = 0; i < array.length; i++ ){
if ( array[ i ].gethouse().gethouseID() == houseId ){
return array[ i ];
}
}
return null;
}
</code></pre>
| java | [1] |
2,500,101 | 2,500,102 | function with multiple arguments **args | <p>I am learning python and this is from </p>
<pre><code>http://www.learnpython.org/page/MultipleFunctionArguments
</code></pre>
<p>They have an example code that does not work- I am wondering if it is just a typo or if it should not work at all.</p>
<pre><code>def bar(first, second, third, **options):
if options.get("action") == "sum":
print "The sum is: %d" % (first + second + third)
if options.get("return") == "first":
return first
result = bar(1, 2, 3, action = "sum", return = "first")
print "Result: %d" % result
</code></pre>
<p>Learnpython thinks the output should have been-</p>
<pre><code>The sum is: 6
Result: 1
</code></pre>
<p>The error i get is-</p>
<pre><code>Traceback (most recent call last):
File "/base/data/home/apps/s~learnpythonjail/1.354953192642593048/main.py", line 99, in post
exec(cmd, safe_globals)
File "<string>", line 9
result = bar(1, 2, 3, action = "sum", return = "first")
^
SyntaxError: invalid syntax
</code></pre>
<p>Is there a way to do what they are trying to do or is the example wrong? Sorry I did look at the python tutorial someone had answered but I don't understand how to fix this.</p>
| python | [7] |
2,933,073 | 2,933,074 | How to perform syncing in android? | <p>I am creating a networking website's Application in android.I want to know how can I perform syncing ie I want to store all user contacts on websites to my android phone.
user's details will come in XML format.</p>
<p>Please Guide me .. </p>
| android | [4] |
1,241,006 | 1,241,007 | Clarification of methods being called using a stoplight example | <p>The code below appears in my book in the chapter about Methods. I'm a little confused about a couple of things.</p>
<ol>
<li>Is my understanding correct when I believe that the <code>run()</code> method is calling the <code>createFilledCircle</code> method?</li>
<li>Is the <code>run()</code> method the receiver and the <code>createFilledCircle</code> the sender?</li>
<li>for the three <code>add(createFilledCircles...red,yellow and green);</code> how does the programmer know what information is permitted in the argument? Is the format of <code>(x location, y location, width of figure, height of figure)</code> being used in the <code>add(createFilledCircle)</code>? </li>
</ol>
<p><br/></p>
<pre><code>import acm.program.*;
import acm.graphics.*;
import java.awt.*;
public class StopLight extends ConsoleProgram {
public void run() {
double cy = getWidth() / 2 ;
double cx= getHeight() / 2;
double fx = cx - (FRAME_WIDTH / 2);
double fy = cy - (FRAME_HEIGHT /2 );
double dy = (FRAME_HEIGHT / 4 ) + (LAMP_RADIUS / 2);
GRect frame = new GRect (fx, fy, FRAME_WIDTH, FRAME_HEIGHT);
frame.setFilled(trye);
frame.setColor(Color.GRAY);
add(frame);
add(createFilledCircle(cx, cy-dy, LAMP_RADIUS, Color.RED));
add(createFilledCircle(cx, cy, LAMP_RADIUS, Color.YELLOW));
add(createFilledCircle(cx, cy + dy, LAMP_RADIUS, Color.GREEN));
}
private GOval createFilledCircle (double x, double y, double r, Color color) {
GOval circle = new GOval (x -r, y -r, 2 * r, 2 * y );
circle.setFilled(true);
circle.setColor(color);
return circle;
}
private static final double FRAME_WIDTH = 50;
private static final double FRAME_HEIGHT = 100;
private static final LAMP_RADIUS = 10;
}
</code></pre>
| java | [1] |
73,405 | 73,406 | Date Conversion in objective c? | <p>I have an array containing the String objects with this format 22/04/2011.My question is that how can I change this string into the <code>yyyy-mm-dd format</code>. I am using <code>NSDateFormatter</code> but it's not working. </p>
| iphone | [8] |
955,452 | 955,453 | Only one insertion happens for multiple insertions | <p>Below is my code.</p>
<pre><code><?php
$f3=require(dirname(__FILE__).'/../../lib/base.php');
$f3->set('AUTOLOAD',dirname(__FILE__).'/');
$db=new DB\Jig('../data/');
$importer = new Importer($db);
$importer->import();
<?php
/**
* Imports the data from the format that was provided
* @author pubudu
*
*/
class Importer
{
public function __construct($db)
{
$this->db = $db;
}
public function import()
{
$user =new DB\Jig\Mapper($this->db,'user');
$i = 0;
for($i =0; $i<100;$i++){
$user->load(array('@userID=?',$i));
$user->userID = $i;
$user->password = substr(md5(uniqid()), 0, 8);
$user->save();
$user->reset();
}
}
}
</code></pre>
<p>But the code results in only one insertion happening. After running the above code, my user file looks like</p>
<pre><code>{"511d834f45214":{"userID":99,"password":"31ba5884"}}
</code></pre>
<p>Can someone point to me where I'm going wrong?
From what I found out, after the first insertion, the <code>load</code> method returns the same entry. But I'm sending different <code>userID</code> s to fetch data.</p>
| php | [2] |
1,193,042 | 1,193,043 | how to check CD or DVD in DVD-RAM drive in java | <p>I wrote how to detect this drive,but not able to check whether it is a CD or DVD in DVD-RAM drive in java?</p>
| java | [1] |
1,463,677 | 1,463,678 | How to extract end of URL in Javascript? | <p>I have URLs in the form:</p>
<blockquote>
<p>serverName/app/image/thumbnail/2012/4/23/1335228884300/bb65efd50ade4b3591dcf7f4c693042b</p>
</blockquote>
<p>Where <code>serverName</code> is the domain name of the server.</p>
<p>I would like to write a JS function that accepts one of these URLs and returns the very last (right-most) forward-slash-delimited string. So if the URL above was passed into the function, it would return "<code>bb65efd50ade4b3591dcf7f4c693042b</code>";.</p>
<pre><code>function getImageDirectoryByFullURL(url) {
// ... Not sure how to define regexp to delimit on forward slashes,
// or how to start searching from end of string.
}
</code></pre>
| javascript | [3] |
5,567,550 | 5,567,551 | Printing Hindi characters as string in java results in error | <p>I print hindi characters as string in java and I'm getting an error. I save the java file in notepad uing UTF-8.</p>
<pre><code>public class MainClass {
public static void main(String args[]) throws Exception {
String s = "साहिलसाहिल";
System.out.print(s);
}
}
</code></pre>
<p>After compilation, I get 2 errors of illegal character. Why so?</p>
| java | [1] |
566,341 | 566,342 | Table like data structure in Java | <p>Forgive me if this question has been answered elsewhere, but I have searched long and hard and have not found an answer.</p>
<p>I am new to Java programming and I wish to create a simple table like data structure, that I can manipulate as required.</p>
<p>For example:</p>
<p>Name,Age,Hair_Colour
Bob,20,Black
John,25,Brown
Larry,30,Black</p>
<p>In powershell, I would just create a custom object, populate it and them append to an array. However, I'm struggling with coding it in Java.</p>
<p>I would appreciate any help that anyone can provide me with.</p>
<p>Thank you in advance.</p>
| java | [1] |
5,942,659 | 5,942,660 | use of jquery-latest | <p>I recently had some code I wrote a year ago fail because someone linked my code to </p>
<blockquote>
<p><a href="http://code.jquery.com/jquery-latest.js" rel="nofollow">http://code.jquery.com/jquery-latest.js</a></p>
</blockquote>
<p>In the latest version, jquery had deprecated/replaced a function.</p>
<p>Nice to have a dynamically updated version but my code isn't going to change, it's going to break. Is there any reason to use jquery-latest? </p>
| jquery | [5] |
4,644,048 | 4,644,049 | php script outputs itself | <p>after submitting a form my php script outputs its code.
sometimes not all of it.</p>
| php | [2] |
719,342 | 719,343 | About Tool Strip Status in C# | <p>I'm trying to change the text in the Tool Strip Status from one message to another message in 2 second. Why can't I do like below? </p>
<pre><code>toolStripStatusLabel1.Text = "Cool";
Thread.Sleep(2000);
toolStripStatusLabel1.Text = "Status: IP Address update complete";
</code></pre>
<p>I've tried it but it only display the second message. Why it doesn't display the first message while within the 2 second?</p>
| c# | [0] |
3,955,572 | 3,955,573 | How can jquery $ act as an object as well as a function in javascript? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8734115/how-can-jquery-behave-like-an-object-and-a-function">How can jQuery behave like an object and a function?</a> </p>
</blockquote>
<p>In jquery we can use $ as a function as well as a namespace. for example both of these use-cases are valid. </p>
<ol>
<li><code>$("div").html("<b>Wow!</b> Such excitement...");</code> </li>
<li><code>var trimmed = $.trim(someString);</code></li>
</ol>
<p>How can one identifier $ act as an <strong>object</strong> as well as a <strong>function</strong> at the same time? </p>
| javascript | [3] |
2,688,964 | 2,688,965 | Video creation from series of images? | <p>How to create the video from series of png images. Is it possible in android can any body suggest me to do that thanks in advance </p>
| android | [4] |
2,649,353 | 2,649,354 | Parse error: syntax error, unexpected T_STRING on line | <p>I'm getting the "Parse error: syntax error, unexpected T_STRING in" on the below, on the first line. Any idea why its happening?</p>
<pre><code>if( !is_numeric($bday_day) || !is_numeric($bday_month) || !is_numeric($bday_year) ){
$this->error[$this->errorCount] = REGISTRATION2error_age;
$this->errorCount++;
}
</code></pre>
| php | [2] |
1,771,534 | 1,771,535 | ASP.net custom error page | <p>im trying to implement a custom error page, what i want to be able to do is have a single generic error page which can display the error which occurred or other information (custom error message). when a error occurs on the website, the user should be directed to this page which shows the error message. </p>
<p>so for example if i had a page which was trying to update something to a database, but something went wrong, i should be redirected to the error page which will have some custom text like something like " there has been an error with bla bla bla ... please contact administrator".</p>
<p>hope this makes sense</p>
<p>thanks </p>
| asp.net | [9] |
4,492,867 | 4,492,868 | Javascript CR+LF will break string? | <p>When storing '\n\r' inside a string constant it will make the Javascript engine throw an error like "unterminated string" and so on.</p>
<p>How to solve this?</p>
<p>More info: basically I want to use Javascript to select text into a TEXTAREA HTML field and insert newlines. When trying to stuff those constants, I get an error.</p>
| javascript | [3] |
4,564,861 | 4,564,862 | mysql_assoc error - displaying fine | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/795746/warning-mysql-fetch-array-supplied-argument-is-not-a-valid-mysql-result">Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result</a> </p>
</blockquote>
<p>i have an error being drawn with this code:</p>
<pre><code><?php
include "config.inc.php";
mysql_query($addClient) or die(mysql_error());
$sth = mysql_query(
sprintf(
"SELECT c_id,p_id,p_title FROM projects WHERE c_id = %s",
mysql_real_escape_string($_GET['id'])
)
);
$projects = array();
while($r = mysql_fetch_array($sth)) {
$projects[] = array('id' => $r['p_id'], 'name' => $r['p_title']);
}
print json_encode($projects);
exit;
?>
</code></pre>
<p>I get this error:</p>
<blockquote>
<p><b>Warning</b>: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in <b>/home/content/g/a/t/gatts316/html/clients/inc/get-projects.php</b> on line <b>10</b><br /></p>
<p>[]</p>
</blockquote>
| php | [2] |
5,107,175 | 5,107,176 | What to do when the user hit the home key and the IPhone Application exit | <p>How do i handle the user pressing the home button at any time, while my app is still processing stuff with the server?</p>
<p>I have this problem both in ios3 & ios4 - i believe maybe the answers would be different because in ios4 it can last in the background.</p>
<p>how do you usually handle such events?
Thanks,
Itay</p>
| iphone | [8] |
6,020,851 | 6,020,852 | Does turning a list into a set, then back again, cause problems in Python? | <p>I'm turning a list into a set in Python, like so:</p>
<pre><code>request.session['vote_set'] = set(request.session['vote_set'])
</code></pre>
<p>So I can easily do a <code>if x in set</code> lookup and eliminate duplicates. Then, when I'm done, I reconvert it:</p>
<pre><code>request.session['vote_set'] = list(request.session['vote_set'])
</code></pre>
<p>Is there a better way to do this? Am I potentially doing something dangerous (or stupid)?</p>
| python | [7] |
1,353,749 | 1,353,750 | getting error as document is empty(size 0kb) when opening pdf file in micromax funbook | <p>Iam trying to Downloading pdf from server and displaying it as it is in android micromax funbook.</p>
<p>I am getting the error as document size is empty(0 KB).when open the pdf file...</p>
<p>I'm new to android suggest me the coding what i am using is correct or not for downloading</p>
<pre><code> public static void DownloadFile(String fileURL, File directory) {
try {
FileOutputStream f = new FileOutputStream(directory);
URL u = new URL(fileURL);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
InputStream in = c.getInputStream();
byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = in.read(buffer)) > 0) {
f.write(buffer, 0, len1);
}
f.close();
} catch (Exception e) {
e.printStackTrace();
}
}
</code></pre>
<p>and the code for showing pdf.</p>
<pre><code> public void showPdf() {
File file = new File(Environment.getExternalStorageDirectory()
+ "/pdf/Read.pdf");
PackageManager packageManager = getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType("application/pdf");
List list = packageManager.queryIntentActivities(testIntent,
PackageManager.MATCH_DEFAULT_ONLY);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(file);
intent.setDataAndType(uri, "application/pdf");
startActivity(intent);
}
</code></pre>
| android | [4] |
756,789 | 756,790 | Java, how to continue running while ServerSocket.accept() takes in clients? | <p>I am trying to make a multiplayer game where many calculations are done on the server with multiple clients. How could I have my server listen for new clients, while calculating for the game. Everything I have tried pauses the entire program while it runs ServerSocket.accept(). Is there any way around this? Thanks in advance.</p>
| java | [1] |
4,849,700 | 4,849,701 | Debugging .aspx in WAP | <p>In WAP, should you expect to get errors when debugging an .aspx during compile time? I'm not getting any errors when my .aspx has errors until runtime when using Web Application Projects. I never really thought about it, because I've always just used WAP. I'm asking the question for someone else and I don't see any information on an answer to this.</p>
<p>we do conditional rendering of custom controls so it's important for us to be able to debug errors during compile time in an .aspx page before it hits production.</p>
| asp.net | [9] |
3,401,141 | 3,401,142 | How can I show a pop-up after completing a task in the background? | <p>I want to show a pop-up message after completing my current task, which is running in the background. The pop-up message must be poped up on current activity.</p>
<p>How i can achieve this?</p>
| android | [4] |
2,939,354 | 2,939,355 | best book to learn fast javascript | <p>I want to learn javascript and implement it in my real work asap.</p>
<p>Can anybody suggest me best book or link? Currently I am lookins javascritp step by step book by Steve Suehring but it is taking a lot of time. and yes no w3schools link.</p>
<p>This will really help me.</p>
| javascript | [3] |
5,470,785 | 5,470,786 | Where clause in PHP doesn't work with variable | <p>I am learning PHP and have been trying to make this following work for some time but no luck. </p>
<pre><code>$sql = "SELECT * FROM add_employee WHERE employee_id='".$employee_id."'";
</code></pre>
<p>I am getting this following error:</p>
<pre><code>Notice: Undefined variable: employee_id in www/suman/payroll_process.php on line 12
</code></pre>
<p>I know the employee id I entered is in the database. When I hard coded employee_id='100', the query got a return. </p>
<p>How should I get the value in the variable and where should u this variable</p>
| php | [2] |
2,419,761 | 2,419,762 | jQuery Toggle Bug | <p>I use the following code to toggle some stuff on a page. The problem is that if a user clicks too fast then more than one panel will open and stay on the page. I'm guessing this is because I'm using <code>click()</code> rather than <code>toggle()</code> but in order to get the full control of the animation I opted for the click function. Is there a way to get around this? Thanks.</p>
<p>EDIT: Another bug I have found is that upon page load the first panel fades off and then back in again because of the <code>.filter(':first').click();</code> at the end of the code, but this is used to get the active state on the first panel. Any alternatives?</p>
<pre><code>jQuery(document).ready(function()
{
var tabContainers = $('div.feature > div');
tabContainers.hide().filter(':first').show();
$('div.feature ul.feature-nav li a').click(function ()
{
var ref = this;
tabContainers.filter(':visible').fadeOut(500, function()
{
tabContainers.filter(ref.hash).fadeIn(500);
});
$('div.feature ul.feature-nav li a').removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(':first').click();
});
</code></pre>
| jquery | [5] |
4,860,046 | 4,860,047 | Rendering and jaggering | <p>I have a html 5 canvas using the 2d context. I am able to get up to 120 frames per second, but the rendering can be jagged, where the animation just jumps. I would like to know any ideas what may be causing it, especially with such a high (but pointless) frame rate? What are known ways or smoothing out animation as well?</p>
<p>The only thing that does come to mind, is the actual drawing is not being accounted for. So while the updating and drawing functions can be run quickly, the painting onto the canvas is stacked later. Which would then imply that I am not geting a true frames per second.</p>
| javascript | [3] |
5,030,479 | 5,030,480 | ASP.NET Site slow until recycle | <p>I just recently move a site from IIS6 to IIS7 and are experiencing a lot of performance problems. </p>
<p>The site performance is really bad until I do a recycle on the Application Pool. What can this be a symptom of?</p>
<p>I recycle ever night but that seems not to be enough?</p>
<p>I'm not relying that much on Sessions. Use caching quite a lot.</p>
| asp.net | [9] |
534,330 | 534,331 | jquery doing two ajax calls under on function | <p>if have the following two scripts, when a button is clicked i wish for them both to be loaded, at the moment they are conflicting? any suggestions? the first needs to run before the second. I have tried calling two separate function but still i get a conflict </p>
<pre><code>function showUser3(str)
{
if (str=="")
{
document.getElementById("basketShow").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("basketShow").innerHTML=xmlhttp.responseText;
}
}
var Id = str;
var qty = $("#"+Id).find("#qty").val();
var productID = $("#"+Id).find("#productID").val();
var categoryID = $("#"+Id).find("#categoryID").val();
var priceID = $("#"+Id).find("#priceID").val();
var url = 'ajaxAddBasket.php?productID='+productID+'&categoryID='+categoryID+'&qty='+qty+'&priceID='+priceID+'&Id='+Id;
xmlhttp.open("GET",url,true);
xmlhttp.send();
if (str=="")
{
document.getElementById("ajaxPallet").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("ajaxPallet").innerHTML=xmlhttp.responseText;
}
}
var url = 'ajaxPallet.php';
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</code></pre>
| jquery | [5] |
523,699 | 523,700 | Optimal Code for initialization | <p>Which of the following code would be optimal for initializing array?</p>
<pre><code>char szCommand[2048] ={0}
</code></pre>
<hr>
<pre><code>char szCommand[2048];
memset(szCommand,0,2048);
</code></pre>
| c++ | [6] |
2,862,900 | 2,862,901 | How to pass this variable to this function? | <p>I have to pass <strong>aaa</strong> to <strong>ehi()</strong> function in the <strong>mitt</strong> parameter.</p>
<p><strong>aaa</strong> is an array of numbers like: 29837,127365,5645,12323,47656564,2312,4534,2343</p>
<p>This is the correct way that the <strong>ehi()</strong> works:</p>
<pre><code> function ehi(aaa) {
love({functionality: 'kiss',
mess: 'yuhuuuuuu',
mitt: '29837,127365,5645,12323,47656564,2312,4534,2343'
});
}
</code></pre>
<p>I need to substitute 29837,127365,5645,12323,47656564,2312,4534,2343 with aaa.</p>
<p>How can I do that ?</p>
| javascript | [3] |
2,011,249 | 2,011,250 | Diff between getExternalFilesDir and getExternalStorageDirectory() | <p>I understand that ExternalFiles is to be used on API 8 and up and getExternalStorageDirectory is for 7 and down. However I am a little confused between the use. For example I wanted to check that a folder that exists and previously you would use something like:</p>
<pre><code>File ChildFolder = new File(Environment.getExternalStorageDirectory() + "/ParentFolder/Child");
</code></pre>
<p>However every example I see says to use getExternalFilesDir (null), File.ext. Since I am above API 8 I want to use this method but how do I just check for a folder? I will check for a files existence at another point but for now just want to see if the folders exist??</p>
<p>TIA
JB</p>
| android | [4] |
1,292,944 | 1,292,945 | how to add three default images to wordpress? | <p>how to add three default images to wordpress <strong>custom background</strong>?</p>
<p><img src="http://i.stack.imgur.com/fNCQ4.jpg" alt="enter image description here"></p>
<p>now, i want to add three default images which can be selected one by the user.and it locates on the <strong>upload Image</strong> part.like this:</p>
<p>the default background image:</p>
<p><img src="http://i.stack.imgur.com/CMlwd.jpg" alt="enter image description here"></p>
<p>how do i do thank you.</p>
| php | [2] |
1,829,909 | 1,829,910 | Replacing image src with input hidden value using Jquery | <p>I have below input hidden with value ="/fr/images/findacourse_logo_tcm10-268.gif".</p>
<pre><code><input type="hidden" id="Qt_Email_Image" value="/fr/images/findacourse_logo_tcm10-268.gif"/>
</code></pre>
<p>I have another input image below with src = "/images/quote/Quote_Email_Button.JPG"</p>
<pre><code><tr>
<td>
</td>
<td colspan="2" class="">
<input type="image" border="0" alt="Email me this quote " src="/images/quote/Quote_Email_Button.JPG" id="Quote_btnEmail" name="Quote:btnEmail"/>
</td>
</tr>
</code></pre>
<p>Now I want at runtime the input image src gets replaced with above input hidden value and will show above image instead of image link in src. So that my above html becomes</p>
<pre><code><tr>
<td>
</td>
<td colspan="2" class="">
<input type="image" border="0" alt="Email me this quote " src="/fr/images/findacourse_logo_tcm10-268.gif" id="Quote_btnEmail" name="Quote:btnEmail"/>
</td>
</tr>
</code></pre>
<p>I want to use Jquery for above solution, please suggest!</p>
<p>Thanks.</p>
| jquery | [5] |
2,762,241 | 2,762,242 | jQuery SlideToggle on checkbox | <p>I currently have this working with a button. How do I switch display/hide to work with a Checkbox?</p>
<pre><code>$(document).ready(function(){
$(".slidingDiv").hide();
$(".show_hide").show();
$('.show_hide').click(function(){
$(".slidingDiv").slideToggle();
});
});
</code></pre>
| jquery | [5] |
3,114,179 | 3,114,180 | How do I read character by character from a text file and put it in a character array? | <p>I'm trying to read character by character from a text file until EOF, put them into a character array, so that I can manipulate it after. Compiled with g++ without errors, and when run, I'm prompted for the input file but then it just hangs. </p>
<pre><code>int main (int argc, char *argv[]) {
string filename;
ifstream infile;
char *cp, c[1024];
memset (c, 0, sizeof(c));
cp = c;
cout << "Enter file name: " << endl;
cin >> filename;
//open file
infile.open( filename.c_str() );
//if file can't open
if(!infile) {
cerr << "Error: file could not be opened" << endl;
exit(1);
}
while (!infile.eof()); {
infile.get(c, sizeof(infile));
// get character from file and store in array c[]
}
}//end main
</code></pre>
| c++ | [6] |
2,036,175 | 2,036,176 | php empty values | <p>I have a problem with my php script it is...</p>
<pre><code> Parse error: syntax error, unexpected T_LOGICAL_OR, expecting ')' in C:\wamp\www\register.php on line 34
</code></pre>
<p>I am a nube with !Empty so let me know if im doing something wrong.</p>
<pre><code>if (!empty($username or $email or $password or $repassword))
{
}
else
{
}
</code></pre>
<p>This is my code but something in the middle of the else and if statement </p>
<p>So what am i doing wrong?</p>
<p>My question is what am i doing wrong?
oh and </p>
<ul>
<li>$username </li>
<li>$email</li>
<li>$password</li>
<li>$repassword</li>
</ul>
<p>are all values </p>
<p>and yes this is a script to figure out if someone has filled in all of the textboxes in the form for a register script.</p>
| php | [2] |
1,134,578 | 1,134,579 | returned function result is confused in conditional statement | <p>I have a class that works with database in PHP. the Add function in this class is: </p>
<pre><code> function Add($post_id)
{
if(!is_numeric($post_id))
{
return 1181;
}
$query = "...";
$result = mysql_query($query, $this->link);
return $result;
}
</code></pre>
<p>I also have a page that gets a form data and passes them to this class. The page code is:</p>
<pre><code>$result = $obj->Add($post_id);
if($result == 1181)
{
echo 'invalid';
}
else if($result)
{
echo 'success';
}
else
{
echo 'error';
}
</code></pre>
<p>the returned value is 1 and the output must be 'success', but i get 'invalid' message. If i swap 'invalid' and 'success' conditional statements, everything works well, but i want to know that what's this problem for? </p>
| php | [2] |
5,512,804 | 5,512,805 | ImageView is being re-sized - why? | <p>I have the following image in my app: It's a 59x60 PNG. </p>
<p><img src="http://i.stack.imgur.com/SOEo4.png" alt="enter image description here"></p>
<p>I use it in the following layout:</p>
<pre><code><RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/headerContainer"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/menu_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/menu_bt_refresh"
android:layout_alignParentRight="true" />
</RelativeLayout>
</code></pre>
<p>When I run it in my Nexus One, the width of the ImageView is 89 pixels. Why?</p>
| android | [4] |
4,852,766 | 4,852,767 | detect power state change | <p>What is the best way to detect when Windows power state is changing?</p>
<p>I need to preform some actions depending on wether the computer is going to Stanby/Hibernate/Shut Down</p>
<p>Thanks
Sp</p>
| c# | [0] |
4,015,900 | 4,015,901 | How to Capture image from Camera Application in Android Programming? | <p>I am trying to implement Camera application in android,and i got some code from net to create a Live Camera through WebCam.Upto this no problem.Now i have to capture the images when click the button, and i displayed the captured images in the Dialog window.Without any exception the program is running but the captured image is not displayed,some default image is displayed.</p>
<p>My code is</p>
<pre><code>public void captureImage()
{
Camera.Parameters params = camera.getParameters();
camera.setParameters(params);
Camera.PictureCallback jpgCallback = new PictureCallback()
{
public void onPictureTaken(byte[] data, Camera camera)
{
try
{
Dialog d=new Dialog(c);
d.setContentView(0x7f030000);
BitmapFactory.Options opts = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length,opts);
TextView tv=(TextView)d.findViewById(0x7f050001);
ImageView i=(ImageView)d.findViewById(0x7f050000);
i.setImageBitmap(bitmap);
tv.setText("Hai"+data.length);
d.show();
}
catch(Exception e)
{
AlertDialog.Builder alert=new AlertDialog.Builder(c);
alert.setMessage("Exception1"+e.getMessage());
alert.create();
alert.show();
}
}
};
camera.takePicture(null, null, jpgCallback);
}
</code></pre>
<p>I have no idea from where this default image is coming,i don't how to slove this problem.Anyone knows about this please help me.Waiting for the Reply.....</p>
| android | [4] |
5,360,021 | 5,360,022 | How to remove \ from a string in c#? | <p>I want to remove <code>\</code> (backslash) from a string in C#. How can I do this ?</p>
<pre><code>string scrip
= "$(function () {$(\"[src='" + names[i, 0] + "']\"" + ").pinit();});";
</code></pre>
<p>I used <code>scrip..Replace(@"\", "") ;</code> but <code>\</code> is not replacing with empty string </p>
| c# | [0] |
4,857,013 | 4,857,014 | How can I access the contents of a form submission via Javascript? | <p>I have server side caching running on a website, and need to trigger functionality based on the submission of a form. How can I access the contents of a form submission via Javascript? Usually I would access these with PHP via $_POST.</p>
<p>I can't get the values via PHP because the page that is being served after the form submission is the cached page, and no PHP will be executed.</p>
<p>I am using jQuery.</p>
| javascript | [3] |
5,502,262 | 5,502,263 | Error making C++ functions virtual | <p>The error states:
<br>"error: virtual outside class definition"</p>
<p>Cpp members in question:</p>
<pre><code>virtual void Account::creditBalance(double plus)
{
if(plus > 0)
balance += plus;
else
cout << "Cannot credit negative.";
}
virtual void Account::debitBalance(double minus)
{
if(minus <= balance)
balance -= minus;
else
cout << "Debit amount exceeded account balance.";
}
</code></pre>
<p>The rest of the code is here (although I'm not sure it's necessary): <a href="http://pastebin.com/de5e9f77" rel="nofollow">http://pastebin.com/de5e9f77</a></p>
| c++ | [6] |
1,082,422 | 1,082,423 | Accessing sqlite db value between applications | <p>I have an sqlite db in one of my applications, and I need to get the value of a particular column in this database from another application.</p>
<p>Using Content providers to access this field is the only(and best?) approach, or are there other alternatives?</p>
<p>Any help is appreciated</p>
| android | [4] |
108,156 | 108,157 | Will everything work the same if I cut and paste my .cpp to the bottom of my .h? | <p>I have a <strong>very simple</strong> class and I'd like to consolidate it to a single .h file. Will everything work the same if I cut and paste the guts of my .cpp to the bottom of my .h?</p>
<p>In particular, there are static member variable initializations <code>int MyClass::myStaticVar = 0;</code> outside of any class definition at the top of the .cpp, and following that, there are static member function implementations <code>void MyClass::myStaticMethod() {...}</code>. Some <em>non-static</em> member functions are already being implemented in the .h, not the .cpp. So you can see there are some nuances here that I'd like to clarify.</p>
<hr>
<p><strong>Edit</strong> So far, what I'm getting is:</p>
<blockquote>
<p>This is naughty, but it will work if you only <code>#include</code> the .h once.
It breaks the convention and doesn't really work like a .h so it might
as well be named .doofus.</p>
</blockquote>
<p>Now, for example, look at the <a href="http://sourceforge.net/projects/reactivision/files/TUIO%201.0/TUIO-Clients%201.4/TUIO_CPP-1.4.zip/download" rel="nofollow">TUIO C++ bindings</a>. A lot of the classes consist of one .h file, no cpp (TuioPoint.h, TuioCursor.h, TuioObject.h, etc). I don't think this is so bad...</p>
| c++ | [6] |
475,584 | 475,585 | use span id value as a conditional javascript | <p>I have this span in the html body:</p>
<pre><code><span id="username_status"></span>
</code></pre>
<p>snippet of sql query:</p>
<pre><code>if($exist > 0)
{
echo 'Sorry, That username is Taken!'; //value in username_status
}
else{
echo 'Username available!'; //value in username_status
}
</code></pre>
<p>and i'm trying to use the query result to generate a form validation alert:</p>
<pre><code>var s1 = document.getElementById('username_status').innerHTML;
if (s1 === "Sorry, That username is Taken!")
{
alert("Please Change Your Username. It is already used.");
return false;
}
}
</code></pre>
<p>I've searched far and wide, but it looks i'm not getting anything. any help?</p>
| javascript | [3] |
4,818,899 | 4,818,900 | Mediascanner not working in 2.2 and above | <p>Can someone please tell me why the following works fine on 2.1 and not on 2.2 or 3.1? The final toast message even shows indicating MediaScanner completed.</p>
<pre><code> scanner = new MediaScannerConnection(this,
new MediaScannerConnection.MediaScannerConnectionClient () {
public void onMediaScannerConnected() {
Log.v("SCANNER"," CONNECTED: "+outputFile.getPath());
scanner.scanFile(outputFile.getPath(), null);
}
public void onScanCompleted(String path, Uri uri) {
if (path.equals(outputFile.getPath())) {
PhotoPager.this.runOnUiThread(new Runnable() {
public void run() {
Toast
.makeText(PhotoPager.this,
"Image has been saved",
Toast.LENGTH_SHORT)
.show();
}
});
}
scanner.disconnect();
}
}
);
</code></pre>
| android | [4] |
1,486,939 | 1,486,940 | How to write a PHP batch file that will execute a series of PHP files one after another? | <p>I know I can set up a cron for each of the individual PHP files, but is there a way for a cron to run one PHP file that calls a list of files in a specific order. For example, It should only call the second file if the first file has completed. </p>
| php | [2] |
3,519,542 | 3,519,543 | accessing a registry key throws an exception? | <p>I am trying to access a key in the following path in registry on widows 8:</p>
<blockquote>
<p>Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Run</p>
</blockquote>
<p>and I am using the folowing in code to do that:</p>
<pre><code>using (RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Default))
{
using (RegistryKey key = baseKey.OpenSubKey(startUpRegistryPath))
</code></pre>
<p>But this throws an exception:</p>
<blockquote>
<p>SecurityException: Requested registry access is not allowed.</p>
</blockquote>
<p>How do i gain write acccess to that path with C# code?</p>
<p>Thanks!</p>
| c# | [0] |
2,626,083 | 2,626,084 | OOP, assigment operator does not work | <p>This is from my code:</p>
<pre><code>struct R3
{
float x;
float y;
float z;
R3(float, float, float);
R3();
};
R3::R3(float a, float b, float c)
{
x = a;
y = b;
z = c;
}
R3::R3()
{
x = 0;
y = 0;
z = 0;
}
struct Bodies
{
int Mass;
float Dist[100];
R3 Place(float, float, float);
R3 Speed(float, float, float);
R3 Acc(float, float, float);
Bodies(int, R3, R3, R3);
};
Bodies::Bodies(int M, R3 XYZ, R3 V, R3 A)
{
Mass = M;
Place = XYZ;
Speed.x = V.x;
Speed.y = V.y;
Speed.z = V.z;
Acc.x = A.x;
Acc.y = A.y;
Acc.z = A.z;
}
</code></pre>
<p>My problem is, that for Place = XYZ;, it's showing the error "invalid use of member (did you forget the '&'?)"
and for Speed.x = V.x; "insufficient contextual information to determine type".</p>
<p>I'm quite new to OOP, and I don't see where the problem might be.</p>
<p>Could you please tell me why doesn't it work?</p>
<p>Thanks.</p>
| c++ | [6] |
1,977,179 | 1,977,180 | Storing 'struct' data to binary file | <p>I need to store a binary file with a 12 byte header composed of 4 fields. They are namely: sSamples (4-bytes integer), sSampPeriod (4-bytes integer), sSampSize (2-bytes integer), and finally sParmKind (2-bytes integer).
I'm using 'struct' to my variables to the desired fields. Now that I have them defined separately, how could I merge them all to store the '12 bytes header'?</p>
<pre><code>sSamples = struct.pack('i', nSamples) # 4-bytes integer
sSampPeriod = struct.pack('i', nSampPeriod) # 4-bytes integer
sSampSize = struct.pack('H', nSampSize) # 2-bytes integer / unsigned short
sParmKind = struct.pack('H', 9) # 2-bytes integer / unsigned short
</code></pre>
<p>In addition, I've a 'npVect' float array of dimensionality D (numpy.ndarray - float32). How could I store this vector in the same binary file, but after the header? </p>
| python | [7] |
2,495,368 | 2,495,369 | Where to find a python module, py4cs? | <p>I need the python moduel py4cs, but I cannot find it anywhere, it is not on pypi or anywhere else. Please Help. Thanks!</p>
| python | [7] |
1,432,052 | 1,432,053 | PHP Loop to search for string, execute if no match | <p>I am trying to search for multiple strings within a larger string and if none of them are a match, manipulate the original string. Here is the code:</p>
<pre><code>$searchthis = 'this is a string'
$arr = array('foo', 'bar');
foreach ($arr as &$value) {
if (strpos($searchthis, $value) !== false) {
break;
}
else{
$searchthis = $searchthis . ' addthis';
}
}
</code></pre>
<p>The problem is after searching the first string variable and not matching, the original searched string is manipulated before running the next test.</p>
<p>Any thoughts? Thanks in advance</p>
| php | [2] |
1,400,359 | 1,400,360 | Xoom avd - API 11 attach google map | <p>I have download avd "<strong>Xoom (Motorola Mobility Holding INC) - Api Level 11</strong>" for motorola tablet development and configure and integrate the Google map but "<strong>MapActivity</strong>" class required google API class. so i have copy <em>map.jar</em> file and add it as External library but not run.i know that there are google API available to perform map Operation but i need to continue with "<strong>Xoom (Motorola Mobility Holding INC) - Api Level 11</strong>" <strong><em>not</em></strong> google API so is there any alternet way by which i can integrate google map in this level.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.