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 |
---|---|---|---|---|---|
3,198,316 | 3,198,317 | What does this Javascript do? | <p>What is this line doing:</p>
<pre><code> var tfun = new Function("_", "at" , "with(_) {return (" + text + ");}" );
</code></pre>
<p>What is the <code>_</code>, <code>at</code>, and <code>with(_)</code>?</p>
<p>I've read this:
<a href="http://www.permadi.com/tutorial/jsFunc/index.html" rel="nofollow">http://www.permadi.com/tutorial/jsFunc/index.html</a></p>
<p>I understand that it's creating a new function object, but am still quite puzzled at what his is supposed to do.</p>
<p>Thanks.</p>
<p>Forgot to put the source:
<a href="http://kite.googlecode.com/svn/trunk/kite.js" rel="nofollow">http://kite.googlecode.com/svn/trunk/kite.js</a></p>
<p><a href="http://www.terrainformatica.com/2011/03/the-kite-template-engine-for-javascript/" rel="nofollow">http://www.terrainformatica.com/2011/03/the-kite-template-engine-for-javascript/</a></p>
| javascript | [3] |
4,197,896 | 4,197,897 | While clicking the view it automatically selects the first Radiobutton in android | <p>I have a view with <code>TextView</code> and <code>RadioButton</code>, if I click TextView first option in radio button gets selected automatically. I had also specified <code>android:focusableInTouchMode="false"</code> in layout and I'm using <code>Android 2.2.1</code> Versions. Any solution to this problem??</p>
<p>
</p>
| android | [4] |
1,882,730 | 1,882,731 | How to get info about all running activities in android? | <p>all</p>
<p>i am abserving one thing in android.</p>
<p>If any thing happened in frontend of android.</p>
<p>you get info by watching the log cat.</p>
<p>For example if u open camera,in logcat it display the camera event is opened.</p>
<p>like thet every thing you get by watching log cat.</p>
<p>ok fine, is there any another way to get all info?</p>
<p>if any one has solution,please help me </p>
<p>Thanks in advance.</p>
| android | [4] |
4,609,354 | 4,609,355 | how String object is allocate memory without having new keyword or constructor? | <p>In C# if we want to create a variable of type <code>string</code> we can use:</p>
<pre><code>string str="samplestring"; // this will allocate the space to hold the string
</code></pre>
<p>In C#, <code>string</code> is a class type, so if we want to create an object, normally we have to use the <code>new</code> keyword. So how is allocation happening without <code>new</code> or <code>constructors</code>?</p>
| c# | [0] |
3,411,504 | 3,411,505 | Android Threading | <p>Hey,
So im newish to android and Im lost because although my code uses AsyncTask for it's heavy lifting I am still getting a ANR error when I run my one class. So here is the relevant peices of my code:</p>
<pre><code>package com.cody.color;
import android.app.Activity;
import android.os.Bundle;
public class Play extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
System.out.println("about to start threader");
new GuiThreader().execute();
System.out.println("Threader finished");
setContentView(R.layout.colorboard_small);
}
}
package com.cody.color;
import android.os.AsyncTask;
public class GuiThreader extends AsyncTask<Void, Void, Void>{
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
System.out.println("threader moving");
GUIdriver game = new GUIdriver();
game.play();
return null;
}
}
</code></pre>
| android | [4] |
4,297,626 | 4,297,627 | How to send encoded Base64 image string to server using JSON object | <p>I am new in android . i have send image to server using Json format as a string.</p>
<p>so i have Encoded image string i.e base64 string.</p>
<pre><code> Json j = new JSonObject();
String Image_string = Base64.ToEncodedString(bytearray, Base64.Default);
j.put("image_file_content",Image_string);
</code></pre>
<p>But i am getting this error.
Please help me..wts wrong</p>
<p></p>
<p>400 Bad Request</p>
<p></p>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
<p></p>
| android | [4] |
4,444,405 | 4,444,406 | Is it possible to Improve this Jquery code? | <p>I am currently doing this:</p>
<pre><code>var currFilterList = "";
$('.prod-filters input[type=checkbox]:checked').each(function() {
currFilterList += $(this).attr('data-groupid')+',';
});
</code></pre>
<p>I was thinking it could be cool to do something like:</p>
<pre><code>var currFilterList = $(blahblah).each(function() { return += value; }
</code></pre>
<p>The other thing I wanted to do was to add an item to an array of JQUERY objects (which needed to be null initially, I tried merge, but doesn't work as its not an array of JQUERY objects, is there a way to do this?</p>
<pre><code>var myArrayOfJqueryObjects = [];
foreach(blah) {
$('.myItem').ADDTO(myArrayOfJqueryObjects );
}
</code></pre>
<p>Thanks alot for any replies :)!!!</p>
| jquery | [5] |
3,818,021 | 3,818,022 | PHP crashing on occasion - APC error? | <p>Any thoughts on this? We've had this happen twice recently. Basically, every page throws a fatal error, fixed by an apache restart. Here's what's in the log, repeated over and over.</p>
<p>[Tue Apr 13 15:18:12 2010] [error] [client 10.0.0.2] PHP Fatal error: Internal Zend error - Missing class information for in /www/sites/ep/vogoo/items.php on line 31<br>
[Tue Apr 13 15:18:12 2010] [error] [client 10.0.0.2] PHP Fatal error: Internal Zend error - Missing class information for in /www/sites/ep/vogoo/items.php on line 31<br>
[Tue Apr 13 15:18:13 2010] [error] [client 10.0.0.2] PHP Fatal error: Internal Zend error - Missing class information for in /www/sites/ep/vogoo/items.php on line 31</p>
<p>Looking around, this may be an issue with APC?
<a href="http://pecl.php.net/bugs/bug.php?id=16120&edit=1" rel="nofollow">http://pecl.php.net/bugs/bug.php?id=16120&edit=1</a>
(We're running 3.0.19, which shows as latest stable on pecl.)</p>
<p>Thoughts? I increased the amount of memory apc uses, but the problem just happened again.</p>
| php | [2] |
546,757 | 546,758 | What characters should be allowed in a URL and How do I make sure / get rid of unwanted characters? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4223980/the-ultimate-clean-secure-function">The ultimate clean/secure function</a> </p>
</blockquote>
<p>I am looking for some solution to make sure my $_GET incoming data only has what is needed and not some other dangerous characters, etc. How would be the best validation/sanitization of doing this? I assume REGEXP, could play some role here:</p>
<pre><code>if (isset($_GET['p'])) {
//validate //sanitize etc...
//call controller... or whatever.
}
</code></pre>
| php | [2] |
506,564 | 506,565 | Re-read what the method is suppose to be, do my code look about right? | <p>I just re-read what the method is supposed to do:</p>
<ul>
<li>Add the give Picture at the end and the method insert it at the position given by the "where" parameter value. Value should between 0 - nPictsInAlbum</li>
<li>When it is 0, the Picture is inserted at the beginning and the other Pictures are shifted right to make space for the Picture.</li>
<li>nPictsInAlbum add the given Picture at the end</li>
</ul>
<pre><code>public boolean addPicture(Picture thePicture, int where) {
int index = where;
while (index < nPictsInAlbum) {
pictArray[index - 1] = thePicture;
}
return true;
}
</code></pre>
| java | [1] |
3,631,623 | 3,631,624 | Get an instance of activity that starts another from intent | <p>Is there a way to get an instance of the activity that has called the currently running activity from the intent object that has been passed to it?
eg. if A has called B, I would like to retrieve A's instance from the intent in B's onCreate method.
As Activity is not Serializable i am not able to pass the instance in the extras bundle.
Any help on this would be great</p>
<p>Thanks.</p>
| android | [4] |
3,304,838 | 3,304,839 | How can I test whether this Javascript object has any properties? | <p>I have some code that adds properties to an object like this:</p>
<pre><code>var MyObject = new Object();
if (....) { MyObject.prop1 = .... ; }
if (....) { MyObject.prop2 = .... ; }
if (....) { MyObject.prop3 = .... ; }
</code></pre>
<p>After going through all these if statements, I want to test and see whether <code>MyObject</code> has properties. I don't want to test if it has <code>prop1 || prop2 || prop3</code> because there are 12 properties that can be added. </p>
<p>How do I test to see if it has at least one? I tried <code>if (MyObject)</code> but of course that doesn't work because that only tests the existence of the object. Is these something like a simple one-liner like <code>(MyArray.length)</code> for objects?</p>
| javascript | [3] |
5,389,075 | 5,389,076 | Showing val as html inside of a div in real time | <p>I'm using the following in order to have on screen display of each value of a checkbox that's selected with great results when it's displayed inside a textbox. I'd like to change it so that I can show a real time display in a div as html instead of a textbox.</p>
<p>A <a href="http://jsbin.com/ujuse" rel="nofollow">link to a working demo is here</a> and below is the script. I know it's probably a basic line or two but i'm still learning and new. thanks!</p>
<pre><code>function updateTextArea() {
var allVals = [];
$('#c_b :checked').each(function() {
allVals.push($(this).val());
});
$('#t').val(allVals)
}
$(function() {
$('#c_b input').click(updateTextArea);
updateTextArea();
});
</code></pre>
| jquery | [5] |
4,061,294 | 4,061,295 | JQuery throw if more than an element is returned by a selector | <p>In jQuery is there a way to throw/return no elements if jQuery selector returns more than one DOM element? I know you can wrap every call with a simple check, but I'd like to use an existing method if any.</p>
| jquery | [5] |
4,837,693 | 4,837,694 | Writing wrapper for 3 different classes which 3 different unordered_map and related functions of each class | <p>I have 3 different classes .Each having a different boost::unordered_map and associated functions .
In the Ist classs, unordered_map has key as long int and returns pointer to struct tm.
And i have function like <code>tm * Maketime(long int)</code> .</p>
<p>In the second class, map takes key as Struct tm and value as long int.For this i have provided hash function and equality operator.Also i have various functions in this class.</p>
<p>Third class, map takes key as string and value as long int.Also various functions in this class .</p>
<p>How do i wrap all three in one class?
I thought of template class but what about functions each with different return type and arguement?</p>
| c++ | [6] |
305,976 | 305,977 | jQuery search/replace all body text problems | <p>I am doing a complex language translation in <a href="http://en.wikipedia.org/wiki/JQuery" rel="nofollow">jQuery</a>. I am copying some of the methods used in the jQuery/Google translate, but using our own XML files for getting original English and translated languages.</p>
<p>I am able to easily read English and other language into an array.</p>
<p>But my problem is that some of these text phrases, that we are paying someone to have translated, are going to be inside other sentences inside many different pages.</p>
<p>I have been blasting away, trying different approaches, and still no real luck in finding a useable solution.</p>
<p>In past efforts, I have used the $('body').nodesContainingText() from jQuery-translate, to parse through each text node, then search for that text inside the English array, grab that position, and use that to get the translated version in the other language array.</p>
<p>And that works fine where there are separate text nodes, but still not even close to consistently working on partial replacing.</p>
<p>Seems the more I try to fix the problem, the less it works.</p>
<p>So what I'd really like is some guidance about what I am doing wrong?</p>
<p>Here is the code I am using, maybe this will help.</p>
<p><a href="http://crosenblum.pastebin.com/f6468aae8" rel="nofollow">http://crosenblum.pastebin.com/f6468aae8</a></p>
| jquery | [5] |
1,009,053 | 1,009,054 | Redirect The User After Login | <p>I have a page that only allow the user accessing the page after login. Say that this page is </p>
<blockquote>
<p><a href="http://www.example.com/secret/data/important.php?id=23&pin=2if24scrtw2323" rel="nofollow">http://www.example.com/secret/data/important.php?id=23&pin=2if24scrtw2323</a>.</p>
</blockquote>
<p>This is the scenario: When the user access the URL without login, the user will be redirected to login page. My login page URL:</p>
<blockquote>
<p><a href="http://www.example.com/login.php" rel="nofollow">http://www.example.com/login.php</a></p>
</blockquote>
<p>After successfully login, the user will be redirected again automatically to the page that he/she try access in advanced (in this case: > <a href="http://www.example.com/secret/data/important.php?id=23&pin=2if24scrtw2323" rel="nofollow">http://www.example.com/secret/data/important.php?id=23&pin=2if24scrtw2323</a>) Just like facebook.</p>
<p>What's idea behind it? Thx</p>
| php | [2] |
516,791 | 516,792 | c# previous week date | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/658353/calculate-previous-weeks-start-and-end-date">Calculate previous week's start and end date</a> </p>
</blockquote>
<p>I need to get the previous week start date in c#
for eg. today is Jan 9th.
previous week start date is Jan 1th.</p>
<p>I am using the following code</p>
<pre><code> DayOfWeek weekStart = DayOfWeek.Sunday;
DateTime startingDate = DateTime.Today;
while (startingDate.DayOfWeek != weekStart)
startingDate = startingDate.AddDays(-1);
DateTime previousWeekStart = startingDate.AddDays(-7);
</code></pre>
<p>Is this the best way in c#</p>
<p>Thanks</p>
| c# | [0] |
936,167 | 936,168 | Call a functor in Python | <p>Should be easy, but somehow I don't get it. I want to apply a given function. Background is copy a class and applying a given method on the newly created copy. </p>
<p><strong>Major Edit. Sorry for that.</strong></p>
<pre><code> import copy
class A:
def foo(self,funcName):
print 'foo'
funcName()
def Bar(self):
print 'Bar'
def copyApply(self,funcName):
cpy = copy.copy()
# apply funcName to cpy??
a = A()
func = a.Bar()
a.foo(func) # output 'Bar'
b = a.copyApply(foo) # new copy with applied foo
</code></pre>
| python | [7] |
3,070,935 | 3,070,936 | Element's Value is Null - I am not representing this correctly, I think | <p>Here's my code - I am getting an error in my firebug console that document.getElementById('deletebutton').value is null.</p>
<p>EDIT: To explain what I want - I want code to execute if one of two submit buttons is pressed - this is code to determine whether it was the delete button that was pressed (if not, it should have a null value) and it will execute certain code. Whenever I try to use this though, I keep getting the error message "'deletebutton' is null.</p>
<p>Here's the HTML:</p>
<pre><code><button type="submit" name="del" id="deletebutton" value="'.$org.'">Delete</button>
</code></pre>
<p>How do I account in my program for this? I set it to '', but I believe null would be a better option. Would I do:</p>
<pre><code>if (document.getElementById('deletebutton').value != null
</code></pre>
<p>?</p>
<p>Here's the actual code:</p>
<pre><code><script type="text/javascript">
//<![CDATA[
function formValidation() {
var ids = ["orgname", "cultpicklist", "catpicklist", "servpicklist"]
formValue = 1;
if (document.getElementById('deletebutton').value != '' && document.getElementById('orgname').value === "") {
formValue = 0;
}
else {
for (var i = 0, len = ids.length; i < len; i++) {
if (document.getElementById(ids[i]).value === "") {
formValue = 0;
break;
}
}
}
if (formValue == 1) {
return true;
} else if (formValue == 0) {
alert('Please fill out all required fields');
return false;
}
}
//]]>
</script>
</code></pre>
| javascript | [3] |
5,539,697 | 5,539,698 | PHP files not loading properly | <p>I have a PHP file consisting of the following structure:</p>
<pre><code><html>... headers, scripts & styling
... some html here
<?php
if($_GET['v'] == 1)
{
?>
... html code here ...
<?php
}
else
{
?>
... html code here ...
<?php
}
?>
</html>
</code></pre>
<p>Sometimes the file just loads half, for example if <code>v=1</code> what would load onto the screen (if I check with <code>View Source</code> also) is something like this: (relative to what I exampled above)</p>
<pre><code><html>... headers, scripts & styling
... some html here
... html cod
</code></pre>
<p>As you can see, the code just cuts off randomly. The is nothing obvious casing this such as a loop or anything. It happens in the middle of HTML code and not inside the <code><?php ?></code> tags.</p>
<p>It looks as if the server just decides to stop communicating right there-and-then for no reason. It also happens at a different and random place each time and sometimes loads perfectly fine.</p>
<p>It also only happens on my shared hosting account and not on my <code>localhost</code>.</p>
<p>Is there anything simples that might be causing this?
Did anyone experience this before?</p>
| php | [2] |
2,821,291 | 2,821,292 | Reverse iterate over a std::vector with forward iterators | <p>If I have a function which takes a <code>std::vector<T>::const_iterator</code> called begin and a <code>std::vector<T>::const_iterator</code> called end, is it possible for me to iterate over it in a backwards direction?</p>
<p><strong>UPDATE</strong></p>
<p>I can't change the function signature, which is like this:</p>
<pre><code>void func(Foo::const_iterator begin, Foo::const_iterator end)
{
...
}
</code></pre>
<p>and called with:</p>
<pre><code>func(foo.begin(), foo.end());
</code></pre>
<p>which I also can't change</p>
| c++ | [6] |
4,733,396 | 4,733,397 | How can i save captured image in SD card in Android? | <p>i am making an custom camera application so camera is open in activity view but i don't know how to save captured image in sdcard ?
i have used flowing code to open camera in activity view captured photo</p>
<pre><code>ublic class Camera_preview extends Activity implements SurfaceHolder.Callback,Camera.PictureCallback, OnClickListener {
Camera camera;
SurfaceView cameraView;
SurfaceHolder surfaceHolder;
Button Photo_btn;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.camera_layout);
Photo_btn =(Button)findViewById(R.id.camera_btn);
cameraView = (SurfaceView) this.findViewById(R.id.CameraView);
surfaceHolder = cameraView.getHolder();
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
surfaceHolder.addCallback(this);
actionBar.hide();
Photo_btn.setOnClickListener(this);
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder holder)
{
// TODO Auto-generated method stub
camera =Camera.open();
try
{
camera.setPreviewDisplay(holder);
}
catch (IOException exception)
{
camera.release();
}
camera.startPreview();
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
camera.stopPreview();
camera.release();
}
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
System.out.println("******data*********"+data);
camera.startPreview();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(v == Photo_btn)
{
camera.takePicture(null, null, this);
}
}
}
</code></pre>
<p>plz help</p>
| android | [4] |
3,842,273 | 3,842,274 | Panel Enabled property not propagated | <p>I am working on an ASP .Net web application in my company.<br>
The application contains a composite user control made up of a checkbox, several panels and other controls. </p>
<p>One panel contains severals child controls and especially a custom server control.<br>
The custom server control inherits from TextBox. </p>
<p>A handler is executed when the checkbox is checked or unchecked.<br>
A statement in the handler set the Enabled property of the panel to false.<br>
But the Enabled property of the custom server control is equal to true at PreRender.<br>
Why ?</p>
| asp.net | [9] |
5,795,736 | 5,795,737 | How do I run JavaScript in a console like environment? | <p>I'm trying to follow the the examples here</p>
<p><a href="http://eloquentjavascript.net/chapter2.html" rel="nofollow">http://eloquentjavascript.net/chapter2.html</a></p>
<p>and</p>
<pre><code>print('blah');
</code></pre>
<p>Keeps trying to send to a physical printer when run in a browser. I just want console output.</p>
| javascript | [3] |
2,768,373 | 2,768,374 | Loop through all inputs in a div with a certain class | <pre><code><script language="javascript" type="text/javascript" src="jquery-1.6.js"></script>
<script>
$('.disabledForm').each(function(i, div) {
alert('in here');
$(div).find('input').each(function(j, element){
$(element).attr('disabled','disabled');
});
});
</script>
<div id="divDisabled" class="disabledForm">
<label>Disabled Input 1&nbsp;<input type="text" id="disabledInput1" name="disabledInput1" /></label>
<br />
<label>Disabled Input 2&nbsp;<input type="text" id="disabledInput2" name="disabledInput2" /></label>
</div>
</code></pre>
<p>Never see the "in here" message and my Inputs never get disabled so I assume I'm doing something wrong. Can someone tell me what it is I'm not doing right?</p>
| jquery | [5] |
2,939,775 | 2,939,776 | Do browsers today really not hide javascript? | <p>(This is not a duplicate of <a href="http://stackoverflow.com/questions/822872/do-web-sites-really-need-to-cater-for-browsers-that-dont-have-javascript-enabled">this question</a>).</p>
<p>Are there any browsers today that, if they do not support javascript tags, fail to hide it? E.g., Firefox with adblock will not run javascript, but will not display it directly to the user.</p>
<p>This <a href="http://www.w3schools.com/js/js_howto.asp" rel="nofollow">w3school tutorial</a> claims you should hide javascript tags with comments, like this:</p>
<pre><code><script type="text/javascript">
<!--
document.getElementById("demo").innerHTML=Date();
//-->
</script>
</code></pre>
<p>otherwise these browsers will display the JS code. This seems a bit irrelevant today ... is it?</p>
| javascript | [3] |
1,975,886 | 1,975,887 | How to create a new variable from the contents of another variable in python? | <p>May it's very simple question, but I'm stuck here.
I have variable val as <code>val="mandy"</code>, now i want to create a list whose name is the content of val. i.e. "mandy". so how to define <code>mandy=[]</code> in python.
It's like "$$" equivalent of PHP.</p>
| python | [7] |
4,572,936 | 4,572,937 | Button click doesn't call function even when button attribute OnClick is set to that function | <p>I have an aspx page with two buttons, one of the buttons has an OnClick attribute to a function that should be run when clicked. When the other button is clicked there is an if statement checking if the page is a postback, if it is then I run some statements that need to be run when that button is clicked. That postback button works fine. However, the other button, when it's clicked the function it's supposed to call never executes, and the statements inside if (Page.IsPostBack) get executed instead. What can I do to fix this? Is there a way to make the button that calls a function not do a Post back?</p>
| asp.net | [9] |
3,834,229 | 3,834,230 | Delete row table using jQuery | <p>Suppose I have a table like this</p>
<pre><code>id name address action
--------------------------------------
s1 n1 a1 delete
s2 n2 a2 delete
</code></pre>
<p>Delete is a link for example <code><a href="http://localhost/student/delete/1"></code>. In the real case I delete the student using ajax. In order to simplify the code, I just alert the link and omit the ajax script. I just wanna know How to delete row from the html document using jquery.</p>
<pre><code>$(document).ready(function() {
$("a").click(function(event) {
alert("As you can see, the link no longer took you to jquery.com");
var href = $(this).attr('href');
alert(href);
event.preventDefault();
});
);
</code></pre>
<p>I want, After I alert the link the selected row will be remove automatically. Is there any suggestion how to implement this one ?</p>
| jquery | [5] |
4,906,902 | 4,906,903 | Looking for a simple example of informal protocols in Objective C, to understand how informal protocol works actually | <p>I am looking for a simple example, which shows how informal protocols works!</p>
| iphone | [8] |
1,045,926 | 1,045,927 | Run android application with instrumentation turned on | <p>I have created a customised version of android.app.Instrumentation and have modified my AndroidManifest.xml to use it. </p>
<p>However when I run the application from eclipse it does not seem to load my instrumentation object (am logging and settings global (I know horrible, just for now I swear!) variables that I later check)</p>
<p>I think I need to run it using adb and telling it to use instrumentation but I can't find the correct instructions for doing this (and I have read so much about instrumentation the last few days I am start to go nuts!)</p>
| android | [4] |
767,028 | 767,029 | Asp.net variables values | <p>I am using ASP.net in my project. </p>
<p>I Declare a Variable btn_clik, tot at the beginning of Class. </p>
<pre><code> public partial class Table : System.Web.UI.Page
{
public int btn_click = 1, tot = 0;
</code></pre>
<p>I have two button, Up And Down. When I click Up button btn_click variable want to decrease. And Down Button btn_click variable want to increase. </p>
<pre><code> protected void btnUp_Click(object sender, EventArgs e)
{
if (btn_click != 1) { btn_click--;}
}
protected void btnDown_Click(object sender, EventArgs e)
{
if (btn_click < tot) { btn_click++;}
}
</code></pre>
<p>But At the Page load,.. btn_click vale is 1; then I Click Down Button,.. btn_click value is 2. I repeat the Down Button Click,.. But btn_click value is still 2; I Check that with breakpoints. Each Time btn_click Variable is going to 1, At that time of Button Click.</p>
<p>What is the Mistake...</p>
| asp.net | [9] |
3,804,524 | 3,804,525 | How to handle 3D gmailQuote style design in my web application | <p>i am sending mails to otherdomains using my own server .in my domain the reply messesages design is looking good.</p>
<p>but when i got reply from gmails why design is not coming properly in my application. i debug my application in that i saw
<code><div class="3D gmailQuote"></code> when got reply from gmail.that style i didn't write in my app.but when i got reply from
gmails that style is coming .i think due to that in my app design of the reply message looking ugly.</p>
<p>How to acheive this?
Thanks in advance</p>
| asp.net | [9] |
1,175,853 | 1,175,854 | Checked exceptions and File.exists() in Java | <p>I have primarily a C# background (and am very much a newbie) so forgive me if my assumptions based on this are the problem.</p>
<p>Simply put, one of the features in a piece of software I'm working on (in Java) has the user input a file name. What I intend to do is have the program loop and append a string to the end of the file name from an array of possible append strings, to see if a file exists, and if it does, open it. I am guaranteed to have only ONE file of a given name, so breaking out of the loop on the first success isn't a bug (if the file name the user specifies is "foo" and the appendStrings array has "bar" and "baz" inside of it, I am guaranteed there will never be both a "foobar" and "foobaz" in the directory). What I eventually came up with was similar to this:</p>
<pre><code>public FileReader LocateFile(String fileName)
{
FileReader toReturn = null;
for(int i = 0; i < appendStrings.length; i++)
{
File locatedFile = new File(fileName + appendStrings[i]);
try
{
toReturn = new FileReader(locatedFile);
}
catch(FileNotFoundException ex)
{
continue;
}
}
//...handling in case I didn't find a file.
}
</code></pre>
<p>Great, it works just fine. Except for two problems:</p>
<ol>
<li>The compiler is upset with me that I'm declaring a variable (ex) that I'm not using. I suppose I could log the exception or something, but that seems ridiculous because this will happen often and I'd rather not fill my log file with excessive noise just to make the compiler happy.</li>
<li>I've read from countless sources that you don't use exceptions to control the flow of the program; you use them for <em>exceptional</em> circumstances.</li>
</ol>
<p>My question is: is there a way to please the compiler in this situation? I <em>have</em> to catch that FileNotFoundException, so using File.exists() won't really solve my problem. Am I doing things backwards, or is this just how Java rolls?</p>
| java | [1] |
3,733,779 | 3,733,780 | deleted NSHTTPCookie returns if app is terminated | <p>After using some code to delete all of the cookies:</p>
<pre><code>NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies]) {
[storage deleteCookie:cookie];
}
</code></pre>
<p>if you continue to use the app for a period of time, the cookies stay deleted. however, if you terminate the app immediately afterwards, the cookies will come back. sounds like some kind of cookie sync mechanism isn't kicking in fast enough, but the's no mention of it in the HTTPCookieStore docs.</p>
<p>How do you get a cookie to (reliably) stay deleted?</p>
| iphone | [8] |
5,028,112 | 5,028,113 | ajax jquery - track changes to table | <p>Im updating a particular table with ajax using jquery every 5 seconds. I wish to highlight in yellow, any row that has been freshly inserted or changed. How do I keep track of what has changed ? Can this be done in jquery ? (My backend is django/python)</p>
| jquery | [5] |
5,764,794 | 5,764,795 | What are alternatives for these controls in iPhone | <p><strong>What are alternatives for these controls in iPhone</strong> </p>
<ul>
<li>Radio Button</li>
<li>Check Box</li>
<li>Drop Down</li>
<li>x raise to Power y in UILabel</li>
<li>Hyperlink</li>
</ul>
<p>Suggestion and answers will be appreciated, thanks.</p>
| iphone | [8] |
1,566,543 | 1,566,544 | How to do Text Animations using Android SDK? | <p>So i have a code developed where when some button from the app is pressed it should get displayed in the Textview with some Animation(to add some fun). Is it possible to have text animations in Textview or should i use Canvas or SurfaceView for drawing this aplhabets with animation? </p>
<p>Any help in this regard with some code sample will be great. </p>
| android | [4] |
3,287,038 | 3,287,039 | How to print the string "\n" | <p>I want to print the actual following string: <code>\n</code> , but everything I tried just reads it in takes it as a new line operator.. how do I just print the following: <code>\n</code> ?</p>
| python | [7] |
4,742,030 | 4,742,031 | java program to retreive page source from google search automatically | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2085454/search-word-in-google-and-want-to-find-hits-of-each-word-using-java-program">search word in google and want to find hits of each word using java program</a> </p>
</blockquote>
<p>hi friends,
I want to write java program to retrieve page source from google search automatically. Its very urgent.Give any suggestions. </p>
| java | [1] |
5,782,768 | 5,782,769 | Problem with document.getElementById | <p>This works : </p>
<pre><code>
alert(document.getElementById("Container").nodeName);</code></pre>
<p>But this doesnt : </p>
<pre><code>
var CurParent = document.getElementById("Container");
alert(CurParent.nodeName);</code></pre>
<p>I am using IE7.
Why ? </p>
| javascript | [3] |
3,516,374 | 3,516,375 | Jquery creating option elements in a for loop? | <p>I have my <code>select</code> dropdown initially being created using <code>php</code> like so:</p>
<pre><code> <select id="cupcake-amt" name="amt">
<?php for($i=0; $i<50; $i++) : ?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php endfor; ?>
</select>
</code></pre>
<p>How would I create a jquery function that rebuilds the options to a different amount. So instead of 50 options I would want it 12 later. What's the best approach?</p>
| jquery | [5] |
3,070,926 | 3,070,927 | Getting text from a Listview | <p>I have a ListView that gets filled from a cursor (using rawQuery) that I need to get the text of the selected item from on click.</p>
<pre><code>protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Intent mViewChaptersIntent = new Intent(this, ViewWeb.class);
String s = ((TextView) l.getItemAtPosition(position)).getText().toString(); // Tried this, didn't work.
mViewChaptersIntent.putExtra("extension", s);
mViewChaptersIntent.putExtra("itmClicked", String.format("%d", id));
startActivity(mViewChaptersIntent);
}
</code></pre>
<p>But I'm not sure about the right way to do it. The getItemAtPosition that I've seen in other posts doesn't seem to work...</p>
| android | [4] |
4,842,106 | 4,842,107 | create a new object from existing object | <p>I have a method called xyz which returns an object.</p>
<pre><code>private XYZ xyz() {
return abc;
}
</code></pre>
<p>I want to use this method in 2 different places but I want to call the method only once.</p>
<p>I mean for the first time I am calling the method to get the object.</p>
<pre><code> XYZ aaa = xyz();
</code></pre>
<p>Here I have an object 'aaa'. And I want to use the same object in different place, but I can't use this object as this is private. So what I want to do is to create a new object called 'bbb' from 'aaa' without calling the method.
Just like bbb = aaa;
Please help me how to create a new object from existing object or create a duplicate object with different name.</p>
<p>Thanks in advance</p>
| java | [1] |
5,110,637 | 5,110,638 | C++ download html file or get file contents | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1129194/download-a-url-in-c">Download a URL in C++</a> </p>
</blockquote>
<p>I want to either download/save a HTML file contents located on a remote server to local folder.</p>
<p>I just need the function if there is any.</p>
| c++ | [6] |
2,675,334 | 2,675,335 | Android: How should I structure my Activity if I need to get an item and title from a remote db? | <p>I am curious what is the best way to design an activity that simply makes a remote call and gets an item_name and item_description and needs to display that to the screen.</p>
<p>I was thinking about doing a hack of a ListView, but it seems that it isn't really intended for that.</p>
<p>What I really need is to be able to update 2 fields with the data I get back from the db. What is the best way to do that?</p>
<p>Thanks!</p>
| android | [4] |
3,245,592 | 3,245,593 | Validation in android | <p>I need allow the user to Enter only number and period in android through code</p>
<p>please help me</p>
<pre><code> InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
System.out.println("source " + source);
System.out.println("dSta " + dstart);
System.out.println("dEnd " + dend);
System.out.println("Start " + start);
System.out.println("End " + end);
for (int i = 0; i < source.length(); i++) {
if (!Character.isDigit(source.charAt(i))) {
System.out.println("Character.isDigit(source.charAt(i)) " + Character.isDigit(source.charAt(i)));
return "";
}
/* if (!Character.isDefined('.')) {
return "";
} */
}
return null;
}
};
</code></pre>
| android | [4] |
3,662,216 | 3,662,217 | Using on instead of live to hide a div with a specific id on link click | <p>I am trying to hide a div with an id <code>#op-four</code> using <code>on</code> instead of <code>live</code></p>
<pre><code>$("#one").on("click", function() {
$("#op-four").hide();
});
</code></pre>
<p>fiddle <a href="http://jsfiddle.net/ythSA/" rel="nofollow">http://jsfiddle.net/ythSA/</a> but it wont work</p>
| jquery | [5] |
659,475 | 659,476 | About the Jquery Append Function | <p>Let's assume you have a table and the following Jquery code</p>
<pre><code>var rows = $('#ttable').find('tbody > tr').get();
$('#ttable tbody').append(rows[1]);
</code></pre>
<p>Right the rows object gets all the "tr". The second line, will append row[1] to the table body, so you should get it in the end of the table.</p>
<p>It works fine, but the original row disappear. WHY? This mean, the row don't duplicate, it just moves.
WHY? and How to fix that??</p>
| jquery | [5] |
2,618,447 | 2,618,448 | AM/PM in asp.net | <p>I need time with AM/PM format in asp.net MVC3 application and I am using the following statement:</p>
<pre><code>@Model.ReportDate.ToString("hh:mm tt")
</code></pre>
<p>but it is returning 6:45 instead of 6:45 PM. How to fix this ?</p>
| asp.net | [9] |
4,060,697 | 4,060,698 | Concatenate a string and a list | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/12633024/python-concatenate-string-list">Python concatenate string & list</a> </p>
</blockquote>
<p>Is it possible to concatenate a string and a list?</p>
<p>The following code causes the error: <code>TypeError: not enough arguments for format string</code></p>
<pre><code>t = ["a", "b", "c"]
s = "%s.%s.%s" % t
</code></pre>
| python | [7] |
2,501,167 | 2,501,168 | Would it be a bad idea to extend Context? Android | <p>Context: "This is an abstract class whose implementation is provided by the Android system"</p>
<p>I was thinking of deriving it to include some handy methods, but I'm not sure what to make of the above line. Any thoughts?</p>
| android | [4] |
2,655,829 | 2,655,830 | C++ : Aliases in function argument | <p>I have an issue with the use of aliases in function arguments. Here is my problem.</p>
<p>Let's consider this function definition</p>
<pre><code>void thisIsSparta(int& number){
...
}
</code></pre>
<p>at call time, it works perfectly well with the following code :</p>
<pre><code>int king = 1;
thisIsSparta(king);
</code></pre>
<p>but I have a mismatch error when I try this :</p>
<pre><code>thisIsSparta(1);
</code></pre>
<p>I can easily guess that the error occurs because there is simply no variable to alias, hence the error. However, I don't want the programmer to worry about using only one of the two approaches, this second function call should work as fine !</p>
<p>The only solution I see is to create another function with no alias argument, in addition to the first one :</p>
<pre><code>void thisIsSparta(int number){
}
</code></pre>
<p>But this would result in an awful code duplication, and I'm not a huge fan of this. </p>
<p>Furthermore, the program could decide to use this second definition instead of the former when I use a variable. I then loose the interest of the alias, whose purpose is to avoid variable copy.</p>
<p>Does anyone have a solution to my problem ? Indeed, this is a simplified example, in practice I have a generic type in argument for this function, and it could be arbitrarily big. This is why I'd like to use an alias to avoid copy.</p>
| c++ | [6] |
1,487,995 | 1,487,996 | C# Decimal for loop incremental .05 | <p>I'm trying to do a for loop that increments .05 that stops at max int.</p>
<pre><code>int maxValue = 1;
Decimal maxDec = Convert.ToDecimal(maxValue);
for (int i = 0; i < maxDec + 1; i+0.1M)
{
var val = i.ToString();
}
</code></pre>
<p>so i'm trying to get 0.05, 0.10 ect up to 1.</p>
| c# | [0] |
3,282,131 | 3,282,132 | Convert date format in PHP (without SQL) | <p>How to convert date from <code>yyyy:mm:dd</code> to <code>yyyy-m-dd</code> and <code>yyyy:mm:dd</code> (without leading zero for the month) to <code>yyyy-m-dd</code> (with leading zero to month)?</p>
| php | [2] |
2,535,587 | 2,535,588 | How can I get the value of the selected item in an unordered list with $_POST? | <p>How can I get the value of the selected item in an unordered list with $_POST? I just want to show the selected item on the next page.</p>
<pre><code><form id="categories" name="categories" action="register.php" method="post">
<ul class="list" name="categories">
<li><a href="#">Delivery</a></li>
<li><a href="#">House Chores</a></li>
<li><a href="#">Shopping</a></li>
</ul>
</form>
</code></pre>
| php | [2] |
3,491,897 | 3,491,898 | How to display data in tabular format in android? | <p>I am new to android,now i am working on some database sample programs.
Now i have a problem in displaying the data retrived from database in
a tabular format.If anyone know the answer please help me with the
source code.</p>
| android | [4] |
1,779,243 | 1,779,244 | Special characters in PHP ldap bind | <p>Hi I am using Ldap bind for login but on my ldap server some users have special characters in cn, The ldap bind is not working when a string(not password) have special characters I tried url encode, converted special characters to utf8 format but issue remains same.</p>
<p>Any Help is appreciated </p>
| php | [2] |
4,792,984 | 4,792,985 | Print object values in toString | <p>I wants to override toString() method to show name of user but Name is the inner class of User class so how can I print it.</p>
<pre><code>public class User
{
public static class Name
{
private String _first, _last;
public String getFirst() { return _first; }
public String getLast() { return _last; }
public void setFirst(String s) { _first = s; }
public void setLast(String s) { _last = s; }
}
private Name _name;
public Name getName() { return _name; }
public void setName(Name n) { _name = n; }
@Override
public String toString()
{
return "";//How to print first name and last name here
}
}
</code></pre>
| java | [1] |
4,767,270 | 4,767,271 | Variable assignment and functions - this should work right? | <p>I am trying to take a variable from <code>$_POST</code>, run <code>mysql_real_escape_string</code> and a custom function, <code>html2text</code> on it. This should work, right? Or do I need to separate it on separate lines?</p>
<pre><code>$orgname = mysql_real_escape_string(html2txt($orgname)) = $_POST['orgname'];
</code></pre>
| php | [2] |
2,452,392 | 2,452,393 | Is object[0] sort of a default key for an object in JavaScript? | <p>Here's a small JavaScript snippet:</p>
<pre><code> var re_words = /\w+/g;
var words;
while (words = re_words.exec(' here are a few (sic!) words ')) {
alert(words);
}
</code></pre>
<p>The loop alerts the words found in the input string, which is what I expected, because all the JavaScript tutorials tell me so.</p>
<p>Now, <strong>typeof(words)</strong> results in <strong>object</strong>.</p>
<p>Therefore, I would have expected <strong>alert(words)</strong> to give me <strong>object</strong>.</p>
<p>If I inspect the elements in words, I found them to be 0, "index" and "input". The element words[0] is the same as what is alerted with words.</p>
<p>So, the question is: is the element 0 sort of a default index for an Object in JavaScript which is returned if it is defined. </p>
<p>Or asked differently: why does <strong>alert(words)</strong> give the same effect as <strong>alert(words[0])</strong>? I would have expected alert(words) to give a "Object".</p>
| javascript | [3] |
20,522 | 20,523 | get website in python | <p>Can some one help me to do my homework?</p>
<p>I want to write the project in python.</p>
<p>Project: search for "Hello World" on bing.com
and get all the sites from all the result pages and save them into "site.txt"</p>
| python | [7] |
5,231,135 | 5,231,136 | Exception specification when overriding a virtual function? | <p>If a class inherits from another and overrides a virtual function, how must the exception-specification for the derived (overridden) function be related to the base function?</p>
<p>Is that is must be at least as restrictive? right? or others?</p>
| c++ | [6] |
530,571 | 530,572 | need some advices when making a streaming application | <p>I'm developing an app on android that can play videos streamed from a server (my PC) likes youtube. I'm new to this and I need some advices to get a right approach.
First, my app on android should have the ability to seek to a position that have been played. So, in the server side (my PC), what streaming server should I use?
Do I need to combine the streaming packets into a temporary file and play on this file in order to get seek-back?</p>
| android | [4] |
5,604,662 | 5,604,663 | how to iterate from a specific point in a sequence (Python) | <p><strong>[Edit]</strong></p>
<p>From the feedback/answers I have received, I gather there is some confusion regarding the original question. Consequently, I have reduced the problem to its most rudimentary form</p>
<p>Here are the relevant facts of the problem:</p>
<ol>
<li>I have a sorted sequence: <strong>S</strong></li>
<li>I have an item (denoted by <strong><em>i</em></strong>) that is GUARANTEED to be contained in <strong>S</strong></li>
<li>I want a <strong>find()</strong> algorithm that returns an iterator (<strong><em>iter</em></strong>) that points to <strong><em>i</em></strong></li>
<li>After obtaining the iterator, I want to be able to iterate FORWARD (BACKWARD?) over the elements in <strong><em>S</em></strong>, starting FROM (and including) <strong><em>i</em></strong></li>
</ol>
<p>For my fellow C++ programmers who can also program in Python, what I am asking for, is the equivalent of:</p>
<pre><code>const_iterator std::find (const key_type& x ) const;
</code></pre>
<p>The iterator returned can then be used to iterate the sequence. I am just trying to find (pun unintended), if there is a similar inbuilt algorithm in Python, to save me having to reinvent the wheel. </p>
| python | [7] |
1,803,795 | 1,803,796 | How to get properties of a class in an array | <p>I have a student class with the following structure:</p>
<pre><code> public sealed class Student
{
public string Name {get;set;}
public string RollNo {get;set;}
public string standard {get;set;}
public bool IsScholarshipped {get;set;}
public List<string> MobNumber {get;set;}
}
</code></pre>
<p>How can I get those properties of
Student
class in an array like</p>
<pre><code> arr[0]=Name;
arr[1]=RollNo;
.
.
.
arr[4]=MobNumber
</code></pre>
<p>And the types of these properties in separate array like</p>
<pre><code> arr2[0]=string;
arr2[1]=string;
.
.
.
arr2[4]=List<string> or IEnumerable
</code></pre>
<p>Please , explain it with chunk of code.</p>
| c# | [0] |
5,370,981 | 5,370,982 | How to install ndk in linux? | <p>Step1: I extracted Android NDK to a separate directory.
Step2: Created a directory called project in it.
Step3: Where should I create the application.mk file and what should it contents be?
And, then how do I proceed to build it?</p>
<p>Error I get is this:</p>
<pre><code>android-ndk-r7c/project$ .././build/tools/build-target-prebuilts.sh
ERROR: Please provide the path to the toolchain source tree. See --help
</code></pre>
| android | [4] |
2,596,804 | 2,596,805 | Manually add ":animated" selector to jQuery objects | <p>I have a function that animates dom elements with CSS3 if available. Now i often use the <code>:animeted</code> jQuery selector. How do i make my CSS3 Animated elements respond to <code>:animeted</code> selector also?</p>
<p>When a DOM Object is animated with jQuery it gets <code>"fxqueue":"inprogress"</code> in the Data object, so i was thinking i could manually add my elements using:</p>
<p><code>$("div").eq(0).data({"fxqueue": "inprogress"});</code></p>
<p>but</p>
<p><code>console.log( $("div:animated") )</code></p>
<p>does not select anything.</p>
| jquery | [5] |
1,335,902 | 1,335,903 | How to call method with parameter of type vector<int>::iterator& in C++? | <p>I have a method to find number in range of iterator like below. I want it has reference parameter and return reference of iterator.</p>
<pre><code>// find number in range of begin and end, if number found return reference of iterator, throw exception otherwise
vector<int>::iterator &find_int(vector<int>::iterator &begin, vector<int>::iterator &end, int &number)
{
for (; begin != end; ++begin)
{
if (*begin == number)
{
return begin;
}
}
throw "not found";
}
</code></pre>
<p>I want to call this method as following code but it can't compile.</p>
<pre><code>vector<int>::iterator i5 = find_int(vi1.begin(), vi1.end(), 5);
</code></pre>
<p>I want to know how can I call <code>find_int</code> method ?</p>
<p><strong>Update</strong>
Error message when compile the code</p>
<pre><code>C:\Windows\system32\cmd.exe /c g++ c:\cpp\ch9.cpp -o c:\cpp\ch9.exe
c:\cpp\ch9.cpp: In function 'int main()':
c:\cpp\ch9.cpp:41:63: error: invalid initialization of non-const reference of ty
pe 'std::vector<int>::iterator& {aka __gnu_cxx::__normal_iterator<int*, std::vec
tor<int> >&}' from an rvalue of type 'std::vector<int>::iterator {aka __gnu_cxx:
:__normal_iterator<int*, std::vector<int> >}'
c:\cpp\ch9.cpp:30:24: error: in passing argument 1 of 'std::vector<int>::iterato
r& find_int(std::vector<int>::iterator&, std::vector<int>::iterator&, int&)'
shell returned 1
Hit any key to close this window...
</code></pre>
| c++ | [6] |
4,774,409 | 4,774,410 | compare file with 20 other files to count the number of matches | <p>i have 20 files i want to compare it with master.txt file one by one if there are any match the program gives me the total number of matches between two files i try with the below code:</p>
<pre><code>using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
int found;
int count = 0;
string[] content = File.ReadAllLines(@"C:\master.txt");
string[] mastercontent = File.ReadAllLines(**ineed to pass more than filename** );
foreach (string con in content)
{
if (mastercontent.Contains(con))
{
found = 1;
count = count + found;
}
// else
// {
//Console.WriteLine("no match");
// }
Console.WriteLine(count);
}
}
}
}
</code></pre>
<p>i face problem with passing more than one file path to the File.ReadAllLines()</p>
| c# | [0] |
1,104,973 | 1,104,974 | How to handle objects with length of one and greater than one in a method without redunancy | <p>I'm writing my own JavaScript bind method (for practice) and am having trouble letting go of the need to handle single objects vs multiple objects differently in this method, solely because I need to loop through objects with a length greater than one. (see obj vs obj[i] below)</p>
<p><strong>Is there any way I can make this bind method less redundant feeling?</strong> (please assume using another library is out of the question.. thanks)</p>
<pre><code>var foo = (function () {
return {
bind: function (obj, type, handler, delegate) {
var delegate = delegate || false,
len = obj.length;
if (typeof obj == 'undefined') {
return false;
}
if (len > 1) {
for (var i = 0; i < len; i++) {
if (obj.addEventListener) {
obj[i].addEventListener(type, handler, delegate); // false: bubble (^). true: capture (v).
} else if (obj.attachEvent) {
obj[i].attachEvent('on' + type, handler);
} else {
obj[i]['on' + type] = handler;
}
}
} else {
if (obj.addEventListener) {
obj.addEventListener(type, handler, delegate); // false: bubble (^). true: capture (v).
} else if (obj.attachEvent) {
obj.attachEvent('on' + type, handler);
} else {
obj['on' + type] = handler;
}
}
}
}
})();
</code></pre>
| javascript | [3] |
3,970,631 | 3,970,632 | I don't know the meaning of one character in a Python code | <p>I wonder what is the signification of the ';' sign in the instructions</p>
<pre><code>if l&lt;p:
if t&gt;0:
if int(num)&gt;=int(lst):
</code></pre>
<p>in the code of this question:
<a href="http://stackoverflow.com/questions/4747666/optimizing-python-code">Optimizing python code</a></p>
<p>Maybe an error in the third instruction, ';=' instead of '!='</p>
<p>But I can't imagine the signification of the character in the two other lines.</p>
<p>Is there someone who can explain, please ?</p>
| python | [7] |
1,456,895 | 1,456,896 | Python sys.exit() help? | <p>I am working in Python and am trying to have a line of code execute and after it executes I am calling <code>sys.exit()</code> to have the script itself "exit." However, it seems that <code>sys.exit()</code> is executing before the line of code above it executes. Below is the code I am trying to implement:</p>
<pre><code>if something == True:
self.redirect('http://www.google.com/')
sys.exit()
</code></pre>
<p>The script is exiting before it is redirecting. I need the redirect to complete and then have sys.exit() execute. I CANNOT use the sleep command due to nature of the other code being implemented. Can anyone give me some help as how to fix/workaround this issue?</p>
| python | [7] |
346,079 | 346,080 | Largest and smallest number in an array | <p>This works perfectly...but when I use <code>foreach</code> instead of <code>for</code> this doesn't works. I can't understand <code>for</code> and <code>foreach</code> are same.</p>
<pre><code>namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int[] array = new int[10];
Console.WriteLine("enter the array elements to b sorted");
for(int i=0;i<10;i++)
{
array[i] = Convert.ToInt32(Console.ReadLine());
}
int smallest = array[0];
for(int i=0;i<10;i++)
{
if(array[i]<smallest)
{
smallest=array[i];
}
}
int largest = array[9];
for(int i=0;i<10;i++)
{
if (array[i] > largest)
{
largest = array[i];
}
}
Console.WriteLine("the smallest no is {0}", smallest);
Console.WriteLine("the largest no is {0}", largest);
Console.Read();
}
}
}
</code></pre>
| c# | [0] |
335,403 | 335,404 | Opening a .rtx file in the Java application environment? | <p>I have created a notepad application which is in a <code>jar</code> file, using Java.</p>
<p>Using this I created a text file and saved it with the file extension <code>.rtx</code>.</p>
<p>Now I want to right-click <code>file.rtx</code> in Windows, or any other platform, and in the popup I want to show my notepad application. If it is selected I want to open that file to show its contents in my notepad environment.</p>
<p>Alternatively, double-clicking the file should result in opening the file in my notepad environment.</p>
| java | [1] |
3,501,341 | 3,501,342 | HttpHandler for a specific port | <p>I have a web application built on ASP.NET MVC framework which requires a service payment module. For the given service payment provider, I have to create a module that listens to a specific port (different from 80) at a specific url. What is the best way to achieve this? Should I create a separate Http Server application which would listen to those connections? Is there a way to create an HttpHandler in the context of the main web application that would process the request for a given port?</p>
| asp.net | [9] |
1,776,728 | 1,776,729 | int? maxResults what does the ? means in this statement | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2699373/c-sharp-basic-question-what-is">C# - Basic question: What is ‘?’?</a> </p>
</blockquote>
<p>I have found this statement in a function arguments.</p>
<pre><code>public static SyndicationFeed GetDataFeed(...... int? maxResults)
</code></pre>
<p>what does that means?</p>
| c# | [0] |
4,536,078 | 4,536,079 | Limit the text field characters to 50 - cannot find function slice in Object 0 | <p>I am using this to limit the characters in the Text Field. </p>
<pre><code>textField.value = textField.value.slice(0,50);
textField.value = textField.value.replace(/[^0-9]+/, "");
</code></pre>
<p>I am getting an error, cannot find function slice in Object 0.</p>
| javascript | [3] |
5,379,889 | 5,379,890 | How to add a view programmatically to an xml layout in android? | <p>Hiiii there, I have an xml layout and when a button is clicked I need to add a TableLayout view to that xml layout. I know how to do this with simple stuff like text views but tables would seem to be a lot harder to define programmatically, Im not quite sure what inflating is but is that what I should be using? Thanks.</p>
| android | [4] |
5,735,967 | 5,735,968 | How does this program work | <p>This is my first C++ program. It prints the number of words in the input.</p>
<p>My first question, how does it go into the loop and add to the count? is it every time i type the space character? if so, how does it know I'm trying to count words?</p>
<pre><code>using namespace std;
int main() {
int count;
string s;
count = 0;
while (cin >> s)
count++;
cout << count << '\n';
return 0;
}
</code></pre>
<p>My second question. Can someone explain to me what namespace std means for a begineer?</p>
| c++ | [6] |
4,124,278 | 4,124,279 | Deck of Cards: How do I make it so I randomly draw a card only once? | <p>I am trying to simulate a deck of cards but I don't know how to make it so it randomly chooses a card but only once. I keep getting doubles of cards.</p>
<pre><code>#include <iostream>
#include <cstdlib> //for rand and srand
#include <cstdio>
#include <string>
using namespace std;
string suit[] = { "Diamonds", "Hearts", "Spades", "Clubs" };
string facevalue[] = { "Two", "Three", "Four", "Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Jack", "Queen", "King", "Ace" };
string getcard() {
string card;
int cardvalue = rand() % 13;
int cardsuit = rand() % 4;
card += facevalue[cardvalue];
card += " of ";
card += suit[cardsuit];
return card;
}
int main() {
int numberofcards = 52;
for (int i = 0; i < numberofcards; i++) {
cout << "You drew a " << getcard() << endl;
}
system("pause");
}
</code></pre>
<p>Any suggestions?</p>
| c++ | [6] |
3,518,638 | 3,518,639 | select all siblings with width of | <p>how can I select all siblings with the width of a defined value?</p>
<p>IE:</p>
<pre><code>$(this).siblings(all with width of 400px).dosomething();
</code></pre>
<p>thank you</p>
<p>d.</p>
| jquery | [5] |
1,642,375 | 1,642,376 | One generic event name or multiple descriptive event name | <p>Would you do:</p>
<pre><code>this.btSomeButton.Click += btSomeButton_OnClick;
private void btSomeButton_OnClick(object sender, EventArgs e)
{
this.DoFunc1();
this.DoFunc2();
}
</code></pre>
<p>Or:</p>
<pre><code>this.btSomeButton.Click += DoFunc1;
this.btSomeButton.Click += DoDunc2;
</code></pre>
<p>Are there any hidden implications for using the second method? Like, is it guaranteed that DoFunc2() will run after DoFunc1()?</p>
| c# | [0] |
243,811 | 243,812 | How to determine the max file upload limit in php | <p>How can the file upload size allowed by php settings be determined withing a php script?</p>
| php | [2] |
4,537,009 | 4,537,010 | DropDownList DataValue as object | <pre><code>DataTextField="Name"
DataValueField="ID_ListGroupParIzm"
</code></pre>
<p>???? DataValueField2="ID_Point"</p>
<p>is it real to load 2 values from sqlDataSource in one DropDown list ? Get structure object from sqlDataSource ?</p>
<p>I can see only one way - making a new table to combine ID_Point and ID_ListGroupParIzm to one ID but that's really weird.</p>
| asp.net | [9] |
2,840,094 | 2,840,095 | Excel sheet using pear | <p>I am Generating excel sheet using pear in PHP.My question is how can i set uniform height for my All rows in my worksheet...??Any idea.</p>
<p>Thanks in Advance.....</p>
| php | [2] |
1,738,840 | 1,738,841 | Build a string of HEX and strings. How? | <p>It turns out building the following string in python...</p>
<pre><code># global variables
cr = '\x0d' # segment terminator
lf = '\x0a' # data element separator
rs = '\x1e' # record separator
sp = '\x20' # white space
a = 'hello'
b = 'world'
output = a + rs + b
</code></pre>
<p>...is not the same as it may be in C#.</p>
<p>How do I accomplish the same in C#?</p>
| c# | [0] |
2,206,464 | 2,206,465 | How to conduct a good tech workshop | <p>I am currently trying to organize a small workshop for several people to generate interest in android. I intend to conduct a hands-on workshop, taking everyone through various components and features by building an app.</p>
<p>One way I can think to do this is to write an app before hand, share it with everyone and then try to develop in group the same code again, understanding the nuances. However, I am not sure how well that'll work out.</p>
<p>I am curious to hear other methodologies or ideas which will help me make this workshop fruitful and engaging for everyone.</p>
<p>I am guessing some of you have experience with similar stuff, can you please suggest what would be a good way to go about it?</p>
<p>PS - Using possibly irrelevant tags, as my reputation won't allow me to create new ones.</p>
| android | [4] |
4,578,798 | 4,578,799 | Regarding binding array to gridview | <p>Hi
I have created session array :</p>
<pre><code> int[] a = (int[])Session["values"];
</code></pre>
<p>Now i have to bind this value to my gridview. I have one column (boundfield in my gridview) in gridview.
I used code to bind array to gridview as follows, but its giving last value only as i want all the values to bind :</p>
<pre><code> for (int i = 0; i < a.Length; i++)
{
str = "select * from Quest_Info where Quest_id='" + a[i] + "' order by Quest_id";
SqlDataAdapter da2 = new SqlDataAdapter(str, sqlconn);
ds2 = new DataSet();
da2.Fill(ds2, "Result");
reviewgrid.DataSource = ds2;
reviewgrid.DataBind();
}
</code></pre>
<p>Which code will work for this?
Asp.net, c#
Thank You.</p>
| asp.net | [9] |
629,165 | 629,166 | jquery mask output | <p>I have a jquery masked textbox which has a mask:</p>
<pre><code>$("#txthtml").mask("99/99/9999");
</code></pre>
<p>When I check the output, it has the '/' in its value. Is there an easy way to get only what the user entered and nothing else? So if text box read <code>01/01/1990</code> I want <code>01011990</code> .</p>
<p>Same thing if I have a phone number mask, how can I get the user input only?</p>
| jquery | [5] |
4,182,522 | 4,182,523 | how to read a txt file containing matrix form of data into 2d array of same dimensions as in the file using java | <p>here is my code:</p>
<pre><code>import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class csvimport5 {
public static void main(String[] args) throws IOException {
double [][] data = new double [87][2];
File file = new File("buydata.txt");
int row = 0;
int col = 0;
BufferedReader bufRdr = new BufferedReader(new FileReader(file));
String line = null;
//read each line of text file
while((line = bufRdr.readLine()) != null && row < data.length)
{
StringTokenizer st = new StringTokenizer(line,",");
while (st.hasMoreTokens())
{
//get next token and store it in the array
data[row][col] = Double.parseDouble(st.nextToken());
col++;
}
col = 0;
row++;
}
System.out.println(" "+data[87][2]);
}
}
</code></pre>
<p>it shows error:-numberformatException :empty string </p>
<p>pls help me</p>
| java | [1] |
2,830,063 | 2,830,064 | PHP Remove URL from string | <p>If I have a string that contains a url (for examples sake, we'll call it $url) such as;</p>
<pre><code>$url = "Here is a funny site http://www.tunyurl.com/34934";
</code></pre>
<p>How do i remove the URL from the string?
Difficulty is, urls might also show up without the http://, such as ;</p>
<pre><code>$url = "Here is another funny site www.tinyurl.com/55555";
</code></pre>
<p>There is no HTML present. How would i start a search if http or www exists, then remove the text/numbers/symbols until the first space?</p>
| php | [2] |
2,739,558 | 2,739,559 | Problem in animation of UIImageView? | <p>i want to make an animation of UIImageView using CGAffineTransformScale and along with it animation that uiimageview should changing it origin also. so that i written following method,</p>
<p>-(void)imageDidMoving
{</p>
<pre><code>imageV = [[UIImageView alloc] init];
imageV.frame = CGRectMake(0, 0, 768, 1024);
imageV.contentMode = UIViewContentModeScaleToFill;
[self.view addSubview:imageV];
imageV.image = [UIImage imageNamed:@"image.png"];
imageV.autoresizingMask = UIViewAutoresizingFlexibleWidth || UIViewAutoresizingFlexibleHeight;
imageV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.1, 0.1);
[UIView beginAnimations:@"image animation" context:nil];
[UIView setAnimationDuration: 0.75];
imageV.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:.3];
imageV.transform = CGAffineTransformScale(CGAffineTransformIdentity,1.5, 1.5);
[UIView commitAnimations];
</code></pre>
<p>}</p>
<p>but it doesn't worked.
I am also using CGAffineTransformScale instead of ,</p>
<pre><code>CGRect frame2 = CGRectMake(70,70, 300, 600);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
imageView.frame = frame2;
[UIView commitAnimations];
</code></pre>
<p>but it also not working?</p>
<p>How i scaling and changing the origin of UIImageView without using NSTimer?</p>
| iphone | [8] |
4,966,244 | 4,966,245 | How to read the body of the message in the mail retrieve from gmail by using pop3 in c #? | <p>This is code:</p>
<pre><code>protected void Button9_Click(object sender, EventArgs e)
</code></pre>
<p>{
try
{
// create an instance of TcpClient</p>
<pre><code> TcpClient tcpclient = new TcpClient();
// HOST NAME POP SERVER and gmail uses port number 995 for POP
tcpclient.Connect("pop.gmail.com", 995);
// This is Secure Stream // opened the connection between client and POP Server
System.Net.Security.SslStream sslstream = new SslStream(tcpclient.GetStream());
// authenticate as client
sslstream.AuthenticateAsClient("pop.gmail.com");
//bool flag = sslstream.IsAuthenticated; // check flag
// Asssigned the writer to stream
System.IO.StreamWriter sw = new StreamWriter(sslstream);
// Assigned reader to stream
System.IO.StreamReader reader = new StreamReader(sslstream);
// refer POP rfc command, there very few around 6-9 command
sw.WriteLine("USER [email protected]");
// sent to server
sw.Flush(); sw.WriteLine("PASS your_gmail_password");
sw.Flush();
// RETR 1 will retrive your first email. it will read content of your first email
sw.WriteLine("RETR 1");
sw.Flush();
// close the connection
sw.WriteLine("Quit ");
sw.Flush(); string str = string.Empty;
string strTemp = string.Empty;
while ((strTemp = reader.ReadLine()) != null)
{
// find the . character in line
if (strTemp == ".")
{
break;
}
if (strTemp.IndexOf("-ERR") != -1)
{
break;
}
str += strTemp;
}
textbox1.text=str;
textbox1.text+="<BR>" + "Congratulation.. ....!!! You read your first gmail email ";
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
</code></pre>
<p>}</p>
<p>The message body is a bunch of what appears to be random characters. I know it's not just a bunch of random characters but some code that needs to be parsed and converted. How can I read content in "message body"?</p>
| c# | [0] |
322,534 | 322,535 | jQuery select parent a of an image | <p>I am trying to select the anchor tag and add a target attribute. When it is wrapped in a image with the class size-thumbnail. Anyone know why this wont work? </p>
<pre><code><a href="example"><img class="size-thumbnail" src="example"></a>
</code></pre>
<p>jquery</p>
<pre><code>$('.size-thumbnail:parent').attr('target','_blank');
</code></pre>
| jquery | [5] |
1,342,787 | 1,342,788 | how to disable form submit and check the form | <p>I have the following code. I need to see how many checkboxes have been checked in my form and if there are 4 or less submit the form and if there are more display an error and don't submit.</p>
<pre><code>function SetHiddenFieldValue()
{
var checks = document.getElementById('toppings').getElementsByTagName('input');
var toppings = new Array();
var randomNumber = Math.floor((Math.random() * 9000) + 100);
var totalChecked = 0;
var itemPrice = 5.99;
for (i = 0; i < checks.length; i++)
{
if (checks[i].checked)
{
toppings[i] = checks[i].value;
totalChecked += 1;
}
}
if (totalChecked > 4) {
alert("You can only choose up to Max of 4 Toppings");
} else {
itemPrice = itemPrice + (totalChecked * 0.99);
document.getElementById('my-item-name').value = toppings.join("\t");
document.getElementById('my-item-id').value = randomNumber;
document.getElementById('my-item-price').value = itemPrice;
}
</code></pre>
<p>And my form is:</p>
<pre><code><form id="pizza" name="pizza" method="post" action="" class="jcart" onsubmit="return SetHiddenFieldValue();">
<input type="hidden" name="my-item-id" id="my-item-id" value="" />
<input type="hidden" name="my-item-name" id="my-item-name" value="" />
<input type="hidden" name="my-item-price" id="my-item-price" value="" />
<input type="hidden" name="my-item-qty" value="1" />
<input type="submit" name="my-add-button" value=" add " />
</form>
</code></pre>
<p>any help would be appreciated.</p>
| javascript | [3] |
531,647 | 531,648 | How to restart the program? (Restart button in game) | <p>I am making a game and when you loose there is a <code>Play Again</code> button. I'd like to when you hit that have the game totally start over. It may seem like a basic question but it's within a class and it's not at the end of the program so it can't just be one big while to go back to the top. Any ideas?</p>
| java | [1] |
420,178 | 420,179 | Is there a reason why this.form.target='_top' does not work and target="_top" works when placed as a form attribute? | <p>Akin to the problem faced by the author at <a href="http://cfyves.com/2011/05/05/need-form-submission-to-break-out-of-an-iframe/" rel="nofollow">http://cfyves.com/2011/05/05/need-form-submission-to-break-out-of-an-iframe/</a>, I attempted to break out of a submitted iframe however it would only work if I include the <code>target</code> attribute in the form element. </p>
<p>Using <code>this.form.target</code> did not generate any errors but it did not break out of the iframe when the form was submitted. Is there a reason why this would be the case?</p>
| javascript | [3] |
1,270,614 | 1,270,615 | Remove what is after @ into an email? | <p>Let's say I have some email: <strong>[email protected]</strong>.</p>
<p>Firstly I would want to remove everything that is after <strong>@</strong>. </p>
<p>And last remove anything inside what's left from the previous action what matches the special characters allowed in an email address format ( anything like "_", "." or other special characters allowed ) and camile hump the first letter in the word or words if that's the case.</p>
<p>Is it possible and how would I do that ?</p>
| php | [2] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.