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,404,703 | 2,404,704 | setTimout help | <p>I have a small piece of javascript that I would like to use but need a delay before it's activated.</p>
<pre><code>function sglClick(url) {
window.setTimeout('location.href="http://'"+url",1500);
}
</code></pre>
<p>This is not working and I'm really stuck here. Wish I knew a bit more javascript. Can someone please help?</p>
<p>Thanks</p>
<p><hr /></p>
<p>Here is what I now have</p>
<pre><code>function send(){
}
function sglClick(url) {
// window.location.href="http://"+url;
setTimeout(function send() { location.href = "http://" + url; },1500);
}
</code></pre>
| javascript | [3] |
2,705,574 | 2,705,575 | JDBC error with PreparedStatement | <p>I'm trying to write a small function that gets an id u (integer), and returns the number of friends u have with distance <=3 (the friends information is stored in the table <strong>Likes</strong>: Likes(uid1, uid2) means: uid1 likes uid2).<br>
I wrote this simple query: </p>
<pre><code> String likesDistance =
"SELECT uid2 " + //DISTANCE = 1
"FROM Likes " +
"WHERE uid1 = ? " +
"UNION " +
"SELECT L2.uid2 " + //DISTANCE = 2
"FROM Likes L1, Likes L2 " +
"WHERE L1.uid1 = ? and L1.uid2 = L2.uid1 " +
"UNION "+
"SELECT L3.uid2 " + //DISTANCE = 3
"FROM Likes L1, Likes L2 , Likes L3 " +
"WHERE L1.uid1 = ? and L1.uid2 = L2.uid1 and L2.uid2 = L3.uid1 ";
</code></pre>
<p>Then, I do the following: </p>
<pre><code> PreparedStatement pstmt2 = con.prepareStatement(likesDistance);
pstmt1.setInt(1, u);
pstmt1.setInt(2, u);
System.out.println("2");
pstmt1.setInt(3, u);
System.out.println("3");
pstmt1.setInt(4, u);
pstmt1.setInt(5, u);
</code></pre>
<p>Where u, as mention before, is an integer passed to the function.<br>
All this code is within a 'try' block. When I try to run it, it prints the first printout ("2"), but not the second one ("3"), and I get the following exception message:<br>
<strong>The column index is out of range: 3, number of columns: 2.</strong> </p>
<p>Why is it like this, and how can I change it to work as I want? </p>
<p>Thanks a lot.</p>
| java | [1] |
3,128,766 | 3,128,767 | Exception raise in Python 3.3 | <p>I have this example in book, but it does not work in my python 3.3</p>
<pre><code>x = 'item found'
def search():
raise x or return
try:
search()
except x:
print('exception')
else:
print('no exception')
</code></pre>
<p>Could any one tell me why?</p>
| python | [7] |
1,315,374 | 1,315,375 | how to play animated gif file in android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3163706/is-it-possible-to-play-gif-format-in-android">Is it possible to play GIF format in Android?</a> </p>
</blockquote>
<p>can anyone please tell me how i show animated .gif file in android.</p>
<p>thanks in adv..</p>
| android | [4] |
4,651,813 | 4,651,814 | Jquery Hover image and Alt text - execution order? | <p>I've a very simple jQuery script to change an image and display the alt text when a thumbnail is hovered over.</p>
<p>Both image and Alt text display in the same div. The code works but the text displays before the image changes and so briefly resizes the div for long alt text:</p>
<pre><code>$("#thumbwrapper li img").hover(function(){
$('#main_img').attr('src',$(this).attr('src').replace('thumb/', ''));
$("#desc").html( $(this).attr("alt") );
});
</code></pre>
<p>I need to order these two so the IMAGE changes 1st and then the alt text. I'm guessing I need to nest a second function but don't know how.
This is my guess of nesting function() but it just breaks the alt text changing:</p>
<pre><code>$("#thumbwrapper li img").hover(function(){
$('#main_img').attr('src',$(this).attr('src').replace('thumb/', ''),function(){
$("#desc").html( $(this).attr("alt") );
});
});
</code></pre>
| jquery | [5] |
3,567,431 | 3,567,432 | Class Emulation - Module Pattern vs. Function Objects | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3790909/javascript-module-pattern-vs-constructor-prototype-pattern">Javascript: Module Pattern vs Constructor/Prototype pattern?</a> </p>
</blockquote>
<p>I want to use class emulation in javaScript. This is a preference.</p>
<p>I've been using the module pattern but am considering using just a simple function object as I can create public and private member variables and functions.</p>
<p><a href="http://jsfiddle.net/chrisallenaaker/Dqg28/" rel="nofollow">Here</a> is an example of a function-object emulating a class:</p>
<pre><code>var input = document.getElementById('input');
var output = document.getElementById('output');
function test()
{
var private_var = 'private_var';
var private_func = function(){ return 'private_func';};
var my = {};
my.public_var = 'public_var';
my.public_func = function(){ return 'public_func';};
return my;
}
var object_test = new test();
alert( '| ' + object_test.public_var);
alert( '| ' + object_test.private_var);
alert( '| ' + object_test.public_func() );
alert( '| ' + object_test.private_func() );
</code></pre>
<p><a href="http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth" rel="nofollow">Here</a> is an example of a the module pattern emulating a class.</p>
<p>What are the primary differences? Besides the ability to make implied global explicit, are there any?</p>
| javascript | [3] |
3,521,790 | 3,521,791 | is possible to overload a main method? | <p>is possible to overload a main method? If yes from which method the jvm will start executing?</p>
| java | [1] |
4,622,716 | 4,622,717 | jquery start animation when timer runs out | <p>I am trying to run some code that will start a particular animation when my timer stops, but I am stuck on trying to get it started.</p>
<p>Code:</p>
<pre><code>if($('#popup_msg').length) {
var timer = 0;
$('#popup_msg').bind({
mouseenter: function() {
timer = 0;
console.log(timer);
},
mouseleave: function(){
timer += 100;
console.log(timer);
}
});
timer += 100;
console.log(timer);
if(timer == 5000) {
$('#popup_msg').delay(5000).slideUp();
}
}
</code></pre>
<p>Thanks in advance for the help!</p>
| jquery | [5] |
3,052,210 | 3,052,211 | javascript function object and this | <p>What's difference of this in the following two cases?</p>
<p>Case 1</p>
<pre><code>var Person = function() { this.name="Allen Kim" }
Person.name; //undefined
</code></pre>
<p>Case 2</p>
<pre><code>var Person = function() { this.name="Allen Kim" }
var me = new Person();
me.name // Allen Kim
</code></pre>
<p>Just wanted to understand how this scope works on both cases.</p>
| javascript | [3] |
3,690,140 | 3,690,141 | What physical characteristics would be suited for android's OS to run smoothly? | <p>Do you think a smartphone with this characteristics will be able to stand android OS?
- 100 MB Storage
- -64 MB RAM
- Processor PNX-4910</p>
<p>////Edit--_</p>
<p>old version/ stable version??</p>
| android | [4] |
4,389,099 | 4,389,100 | how to store an input into an array? C++ | <pre><code>int b;
int array[12];
cout << "Enter binary number: ";
cin >> b;
</code></pre>
<p>(for example: b will be 10100)</p>
<p>** How to store b(10100) into an array so that it'll be [1][0][1][0][0] **</p>
<pre><code>cout << array[0] << endl;
</code></pre>
<p>** output should be 1 **</p>
<pre><code>cout << array[1] << endl;
</code></pre>
<p>** output should be 0 **</p>
<p>Please help thank you.</p>
| c++ | [6] |
2,413,051 | 2,413,052 | jQuery missing ; before statement | <p>I have a problem with jQuery, my code looks ok, but I'm getting an error, which sounds like this:</p>
<blockquote>
<p>missing ; before statement
[Break on this error] }elseif($('.v_gallery li:first').hasClass('s')){\n</p>
</blockquote>
<p>And my code looks like this:</p>
<blockquote>
<p>_gallery_pag : function() {<br />
$('#top_pag a').live('click',function() { var _type = $(this).attr('rel');</p>
<pre><code> switch(_type)
{
case '1':
if($('.v_gallery li:last').hasClass('s'))
{
$('.v_gallery li:first').find('a').click();
}elseif($('.v_gallery li:first').hasClass('s')){
alert('You can\'t go back!You are at the first page!');
}
break;
}
return false;
});
}
</code></pre>
</blockquote>
<p>I know, probably I miss spell checked something...because I don't see any problems.</p>
<p>10x guys</p>
| jquery | [5] |
1,440,407 | 1,440,408 | LinearLayout and GestureDetector | <p>I'm trying to figure out, if it's possible to use GestureDetector for LinearLayout or just ScrollEvent?</p>
<p>Any Examples?</p>
<p>Thank you,</p>
<p>Mur</p>
| android | [4] |
4,969,207 | 4,969,208 | Android ListView tolerance | <p>I have list items that have a HorizontalScrollView in each of them. Hence, I should be able to swipe up and down the list and also swipe through the list item horizontally. (e.g. Pulse News App).</p>
<p>What I'm encountering is that, whenever I scroll the HorizontalScrollView, the ListView also gets scrolled by tiny bit but giving out annoying disturbances in terms of User Experience.</p>
<p>So, I was actually thinking to subclass ListView and implement my own ListView widget. However, I don't know which method to override so that I could increase X tolerance and stop the listview from giving these unwanted flickering. </p>
| android | [4] |
4,916,872 | 4,916,873 | StackoverFlowException in C# | <p>I am writing a code for setting the property in C# and getting an exception. </p>
<pre><code>public class person
{
public string name
{
set
{
name = value;
}
get
{
return name;
}
}
public static void Main()
{
person p = new person();
p.name = "Bilal";
Console.WriteLine(p.name);
}
}
</code></pre>
| c# | [0] |
34,205 | 34,206 | add function to an array in php | <p>I'm having trouble declaring an array in conjunction to a function. Here is my code, what am I doing wrong? </p>
<pre><code>private function array_list(){
return array('1'=>'one', '2'=>'two');
}
private $arrays= array(
'a'=>array('type'=>'1', 'list'=>$this->array_list())
);
</code></pre>
<p>Getting unexpected T_VARIABLE error when I run this code.</p>
| php | [2] |
4,179,955 | 4,179,956 | non-static variable x cannot be referenced from a static context | <p>Excuse my ignorance. I'm a beginner:</p>
<p>Why is the following code giving me the following compiling error?
[line: 16] non-static variable x cannot be referenced from a static context</p>
<pre><code>public class average{
int [] numbers = {2,3,4,5,6};
double x = averageMark(numbers);
public static double averageMark(int [] numbers){
int sum = 0;
double average = 0.000;
for (int i = 0; i < numbers.length; i++){
sum = numbers [i] + sum;
average = sum/numbers.length;
}
return average;
}
public static void main (String [] args){
System.out.println(x);
}
}
</code></pre>
| java | [1] |
4,418,636 | 4,418,637 | Is it possible to Serialize or Create a System.Web.UI.Page item? | <p>I have a method that takes a System.Web.UI.Page as an input and returns some application specific details (what "type" of page it is, if certain items are in the query string, etc...). To run a unit test on this I was trying to create a System.Web.UI.Page item (in the code I am able to just send this.Page).</p>
<p>First Attempt: Serialization - I tried to serialize the page to a file and then deserialize to create the standard test page. Received many errors about not being able to serialize a Page. Is there anyway to write that object to a file?</p>
<p>Second Attempt: new Page() - I tried to just create the page and set the items I was interested in, but all the items I'm interested in appear to be read-only (no setter). Is there some way to create a System.Web.UI.Page programatically?</p>
| asp.net | [9] |
2,146,538 | 2,146,539 | using variable extracted from selector | <p>I am trying to use list elements to toggle between corresponding panels, I also want to do this using variables, just so I can orient myself with their use better. Here is my html and code below. I am tring to extract the i from the the "icon" id clicked, and use that i to open a corresponding "panel" id, with the attached i afterward. Any help would be appreciated! thanks!</p>
<p>html</p>
<pre><code><div id="icon0" class="icon">
<a href=""><img src="Images/film_icon.png"/></a>
</div>
<div id="icon1" class="icon">
<a href=""><img src="Images/film_icon.png"/></a>
</div>
<div id="icon2" class="icon">
<a href=""><img src="Images/film_icon.png"/></a>
</div>
<div id="icon3" class="icon">
<a href=""><img src="Images/film_icon.png"/></a>
</div>
</code></pre>
<p>html panels:</p>
<pre><code><div id="panel0" class="panel">0000</div>
<div id="panel1" class="panel">1111</div>
<div id="panel2" class="panel">2222</div>
<div id="panel3" class="panel">3333</div>
</code></pre>
<p>Jquery</p>
<pre><code>for(var i=0; i<4; i++){
$('#icon'+i).click( function() {
$('#panel'+i).fadeOut(400);
return false;
</code></pre>
| jquery | [5] |
5,907,628 | 5,907,629 | Conditional compilation is turned off | <p>I get a javascript error:</p>
<p>Conditional compilation is turned off</p>
<p>I found this link to fix : <a href="http://msdn.microsoft.com/en-us/library/5y5529x3(VS.90).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/5y5529x3(VS.90).aspx</a>
But after adding this field </p>
<p>/*@cc_on @*/</p>
<p>I get new, another javascript error:</p>
<p>Expected ')'</p>
<p>How to fix it? Thanks</p>
| javascript | [3] |
32,927 | 32,928 | compare one column to another in csv file in Python | <p>Hi i want to compare column a of a csv file with column b of the same csv file as follows:</p>
<pre><code>column a:
8,67,55,32,44,70,9,10,79,21
column b:
22, 45, 6, 22, 3, 22, 6, 7,22,5
</code></pre>
<p>i want the user to enter a number lets say: '8' usin rawinput command. Then search number corresponding to 8 in other coulmn(b). This should give 22. once 22 is obtained i want all other numbers of column(a) that correspond to the numbr 22 in column b to be listed/displayed. pls help me over how to go about this?</p>
| python | [7] |
5,034,336 | 5,034,337 | Regarding designing a program of file check | <p>I am working on application which creates a folder in C: itself named abc and inside abc folder there
is a serialized file named fg.ser, but the issue is that due to some technical reason
that file named fg.ser got deleted .</p>
<p>Now I have taken the fg.ser file inside an another seprate folder named backup inside C: drive and placed the
fg.ser jar file inside the backup folder.</p>
<p>I want to create a java program which will check in 2 minutes if there is a file fg.ser is present in
folder abc then it would not do anything but if the file fg.ser is not present inside folder abc then it
will pick the file fg.ser from back up folder and will put in folder named abc .</p>
<p>Please advise. Any help would be appreciated please help</p>
| java | [1] |
3,854,883 | 3,854,884 | how to get value member of combobox which is created using foreach loop | <p>how to get value member of combobox which is created using foreach loop? it does not show the value member.</p>
<p>my code is like this</p>
<pre><code> DataSet dsLoadWorkHourId = new DataSet();
dsLoadWorkHourId = Workhour.LoadWorkId();
foreach (DataRow row in dsLoadWorkHourId.Tables[0].Rows)
{
cmbWorkHourId.Items.Add(row["SHIFT"].ToString());
}
</code></pre>
| c# | [0] |
166,326 | 166,327 | onActivityResult in ActivityGroup | <p>I am invoking gallery from Child Activity and getting the path of selected image in parent ActivityGroup's onActivityResult method but i want to display selected image in an ImageView of Child Activity. How to do this?</p>
| android | [4] |
4,143,247 | 4,143,248 | Show thumbnail image in div on click / hover | <p>Simply want to show the .thumbimage within the .fullsizeimage on click or hover - unfortunately no luck with the .attr function.</p>
<p><a href="http://jsfiddle.net/CUZBa/" rel="nofollow">http://jsfiddle.net/CUZBa/</a> - Fiddle just in case!</p>
<pre><code> <div class="row">
<div class="fullsizeimage">
<img src="https://www.houseplans.com/img/980e/461-2p1-2520_plan-detail.jpg" />
</div>
<div class="thumbimage"><a href="#"><img src="https://www.houseplans.com/img/85cd/461-2e-2520_plan-detail.jpg" width="100" height="100"></a></div>
<div class="thumbimage"><a href="#"><img src="https://www.houseplans.com/img/872d/461-2alt1-2520_plan-detail.jpg" width="100" height="100"></a></div>
<div class="thumbimage"><a href="#"><img src="https://www.houseplans.com/img/230e/461-2alt2-2520_plan-detail.jpg" width="100" height="100"></a></div>
</div>
<script src="" type="text/javascript">
$('.thumbimage a').on('click hover',function(){
$('.fullsizeimage img').attr('src',$(this).attr('src'));
});
</script>
</code></pre>
| jquery | [5] |
3,445,677 | 3,445,678 | getting value using explode | <p>I am trying to parse following string...</p>
<pre><code>IN.Tags.Share({"count":180,"url":"http://domain.org"}
</code></pre>
<p>is my following approach correct to get the value of count?</p>
<pre><code>$str = 'IN.Tags.Share({"count":180,"url":"http://domain.org"}';
$data = explode(':', $str);
$val = explode(',', $data[1]);
return $val[0];
</code></pre>
<p>Or is there any better way to handling this type of strings? I think it could be done using regex as well.</p>
<p>thanks.</p>
| php | [2] |
4,980,571 | 4,980,572 | PHP - Calling function inside another class -> function | <p>I'm trying to do this: </p>
<pre><code>class database {
function editProvider($post)
{
$sql = "UPDATE tbl SET ";
foreach($post as $key => $val):
if($key != "providerId")
{
$val = formValidate($val);
$sqlE[] = "`$key`='$val'";
}
endforeach;
$sqlE = implode(",", $sqlE);
$where = ' WHERE `id` = \''.$post['id'].'\'';
$sql = $sql . $sqlE . $where;
$query = mysql_query($sql);
if($query){
return true;
}
}
//
}//end class
</code></pre>
<p>And then use this function <strong>* INSIDE of another class *</strong>: </p>
<pre><code>function formValidate($string){
$string = trim($string);
$string = mysql_real_escape_string($string);
return $string;
}
//
</code></pre>
<p>.. on $val. Why doesn't this work? if I write in a field of the form, it's not escaping anything at all. How can that be? </p>
<p><strong>* UPDATE *</strong>
handler.php:</p>
<pre><code>if(isset($_GET['do'])){
if($_GET['do'] == "addLogin")
{
$addLogin = $db->addLogin($_POST);
}
if($_GET['do'] == "addProvider")
{
$addProvider = $db->addProvider($_POST);
}
if($_GET['do'] == "editProfile")
{
$editProfile = $db->editProfile($_POST);
}
if($_GET['do'] == "editProvider")
{
$editProvider = $db->editProvider($_POST);
}
}
//end if isset get do
</code></pre>
<p>** The editProvider function works fine except for this :-) ** </p>
| php | [2] |
5,013,505 | 5,013,506 | How do I put multiple pages under one domain? | <p>So, i have a few app pages that i would like to put under urls like this</p>
<p>constants.heroku.com/physics/planck</p>
<p>constants.heroku.com/physics/e</p>
<p>constants.heroku.com/physics/standardgravitation</p>
<p>My app.py for the plancks constant app looks like this.</p>
<pre><code>import os
from flask import Flask
app = Flask('plancksconstant')
app = Flask(__name__.split('.')[0])
@app.route('/physics/planck')
def hello():
return '6.626068E-34'
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
</code></pre>
<p>the url for this app is <a href="http://nameless-sands-2295.herokuapp.com/physics/planck" rel="nofollow">http://nameless-sands-2295.herokuapp.com/physics/planck</a>. I got the end part working correctly (/physics/planck) but the beginning of the url is still the name of the app (nameless-sands-2295). How do I change that to be "constants" instead of the name of the app?</p>
<p>solved it!!!!
just did this</p>
<pre><code>import os
from flask import Flask
app = Flask('plancksconstant')
app = Flask(__name__.split('.')[0])
@app.route('/physics/planck')
def hello():
return '6.626068E-34'
@app.route('/physics/standardgravity')
def hello():
return '9.8'
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
</code></pre>
| python | [7] |
1,981,488 | 1,981,489 | merge all the elements in a list python | <p>I have a list of string like:</p>
<pre><code>s = [("abc","bcd","cde"),("123","3r4","32f")]
</code></pre>
<p>Now I want to convert this to the following:</p>
<pre><code>output = ["abcbcdcde","1233r432f"]
</code></pre>
<p>What is the pythonic way to do this?
THanks</p>
| python | [7] |
399,438 | 399,439 | How To get click count on UIButton | <p>I got button i need to get count..value </p>
<p>if i click 5 time button..</p>
<p>the count will be 5.</p>
| iphone | [8] |
3,794,839 | 3,794,840 | PHP, Pass object from one object to another object per reference, when classes are in different files | <p>I'm developing a Web App.<br>
Until now the backend was JBoss 6.1 Application Server (Java EE). </p>
<p>Now, with the same frontend, there should be another backend in PHP.<br>
As I like the structure of the Java Backend, I design a similar structure for the php backend.</p>
<p>EVERY request to the PHP backend goes to ONE entry, it's "facade.php", it is my front
controller. </p>
<p>The front controller (facade.php) handles the JSON input and other things and then there is a large switch statement. Every task (login, get event objects, ...) is transferred to another process class. </p>
<p>Snippet of "facade.php":</p>
<pre><code>switch ($procClass) {
case "lgi":
require_once("classes/Login.php");
$login = new Login();
$resultMap = $login->process($internalObj, $sessionObj);
break;
case "cst":
require_once("classes/Cases.php");
$cases = new Cases();
$resultMap = $cases->process($internalObj, $sessionObj);
break;
.
.
.
}
</code></pre>
<p>In the JBoss Java EE environment, when I am in an Stateless Session Bean and I do a local
look up to another Stateless Session Bean (different classes), the objects are handed
to the method of the other class BY REFERENCE.</p>
<p>Now I know that, in PHP, when you are in the same class and you pass one object to another method of the same class, the object is passed per reference (or more accurately the reference is passed by value).</p>
<p>But, as in the example above, if I pass the "sessionObj" object from facade.php to the instance of another class (cases), which is in another file, it seems that it is NOT possible to pass objects per reference.</p>
<p>Is my assumption correct? </p>
<p>Is there another way to pass per reference in this situation (from object to object when the classes in separate files)?</p>
| php | [2] |
2,376,269 | 2,376,270 | Trying to write to a file and force download with php | <p>Im using the following code to present a file for download. The file saves on the server correctly with the data, and prompts for download, but the downloaded file is empty. The new file is in the same directory as this script.</p>
<pre><code><?php
if(strlen($_POST['name'])<1){
echo "error: you must enter a filename<br><a href=data.php>back</a>";
exit();
}
$name = $_POST['name'];
$data = file_get_contents("temp.php");
$fh = fopen("$name", 'w') or die("can't open file");
fwrite($fh, $data);
fclose($fh);
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Length: ". filesize("$name").";");
header("Content-Disposition: attachment; filename=$name");
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");
?>
</code></pre>
| php | [2] |
1,075,528 | 1,075,529 | Microsoft JScript runtime error about ASPxUploadControl | <p>I am using ASPxUploadControl to add document. At first, it was working fine, but now I set its visibility to false, because of some reason. It gives me this error:
Microsoft JScript runtime error: 'myUploadControl' is undefined</p>
| asp.net | [9] |
1,118,017 | 1,118,018 | How do i format the error log message in log file using PHP | <p>Suppose I want to display the sql error in log file which has been created by me. For example ,error log file called "myerror.log "</p>
<p>Now i am using the following code to print my message in log file , " error_log(mysql_error(), 3, "tmp/myerror.log"); ".
So Every time when message is printed in myerror.log file with same line, Here i want to print the message one after another.</p>
<p>Kindly help me
Thanks
Dinesh Kumar Manoharan</p>
| php | [2] |
619,661 | 619,662 | x motif UI automation using Python | <p>I have this UI application implemented in x motif. This application contains certain forms with buttons to store the profile. Now the goal is to create a Python script, that can fill in those forms, say, Name, age, etc and then to simulate the confirm button in order to save the form. </p>
| python | [7] |
4,656,949 | 4,656,950 | Preferred Equals() Method Implementation | <p>This is a question about how to implement the equals method when I need to find instance of the object in a List given a value that one of the instances my have in their member.</p>
<p>I have an object where I've implemented equals:</p>
<pre><code>class User {
private String id;
public User(id) {
this.id = id;
}
public boolean equals(Object obj) {
if (!(obj instanceof User)) {
return false;
}
return ((User)obj).id.equals(this.id);
}
}
</code></pre>
<p>Now if I want to find something in the List I would do something like this:</p>
<pre><code>public function userExists(String id) {
List<Users> users = getAllUsers();
return users.contains(new User(id));
}
</code></pre>
<p>But perhaps this might be a better implementation?</p>
<pre><code>class User {
private String id;
public boolean equals(Object obj) {
if (!(obj instanceof User)) {
return false;
}
if (obj instanceof String) {
return ((String)obj).equals(this.id);
}
return ((User)obj).id.equals(this.id);
}
}
</code></pre>
<p>With this instead:</p>
<pre><code>public function userExists(String id) {
List<Users> users = getAllUsers();
return users.contains(id);
}
</code></pre>
| java | [1] |
6,006,610 | 6,006,611 | Jquery Tools Slideshow and tabs question | <p>I have created the following example to illustrate a problem I have with a jquery tools slideshow. I want the list of headlines at the bottom to highlight as I scroll over the navigation dots below the content pane.</p>
<p><a href="http://testing.lukem.co.uk/slider/slideshow.htm" rel="nofollow">http://testing.lukem.co.uk/slider/slideshow.htm</a></p>
<p>It's a while since I've done any javascript or jquery so any pointers gratefully received!</p>
<p>I think I may be able to acheive it using the API and / or the tab index.</p>
<p>Many thanks,</p>
| jquery | [5] |
4,516,234 | 4,516,235 | assigning text to a textarea | <p>How can I do this in textarea</p>
<pre><code>$(this).text() = $(this).text().substring(0, 20);
</code></pre>
| jquery | [5] |
4,188,416 | 4,188,417 | Combining Jquery filter with selector | <p>I am trying to use a selector to filter on all input type.</p>
<p><code>var allInputTextboxes = $('input[type=text]');<br>
var filteredList = allInputTextboxes.filter('Id$=' + endWithId);</code></p>
<p>I am not getting any result back. Is this doable?</p>
<p>Thanks...</p>
| jquery | [5] |
2,667,375 | 2,667,376 | Read a simple text file | <p>Hi everyone I am trying to read the date from a file in android. I am using Eclipse and the program is compiling and running, just it is not printing the context of the txt file. Here is my load method</p>
<pre><code> private String load(String filename) {
try {
// Log.v("Home", " in the load method");
Log.d("Home", " in the load method");
final FileInputStream fis = openFileInput(filename);
// final InputStream fis = getResources().openRawResource(R.raw.pages);
final BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
reader.close();
fis.close();
return sb.toString();
} catch (Exception ex) {
return "No entry exists for this file";
}
}
</code></pre>
<p>and in the oncreate i just access it</p>
<pre><code>String fileName = "pages.txt";
load(fileName);
</code></pre>
<p>pages.txt is in the res/raw directory. I tried to read the file with both </p>
<pre><code>final FileInputStream fis = openFileInput(filename);
// final InputStream fis = getResources().openRawResource(R.raw.pages);
</code></pre>
<p>but It is not printing the context.</p>
<p>I added in the onCreate method </p>
<pre><code>Log.d("File", load(fileName));
</code></pre>
<p>but is returning the catch statement <code>No entry exists for this file.</code></p>
<p>Thanks</p>
| android | [4] |
5,214,942 | 5,214,943 | Passing a function pointer by reference | <p>Hi I am trying to learn some function pointers in C/C++ and I was trying to write the following C++ code with gcc on Ubuntu. </p>
<p>This code should execute the multiply or or the add function depending on the
preprocessor flag -DADD or -DMULTIPLY provided during compilation</p>
<pre><code>#include <iostream>
#include <iomanip>
//Adds two numbers
int add(int a, int b)
{
return a+b;
}
//Multiplies two numbers
int multiply(int a, int b)
{
return a*b;
}
//Function to set the correct function to be executed.
//All functions here should have the same signature.
void functionsetter( void (*ptr2fun)(int,int) )
{
#ifdef ADD
ptr2fun = add;
#endif
#ifdef MULTIPLY
ptr2fun = multiply
#endif
}
int main(int argc, char *argv[])
{
int a = 5;
int b = 6;
void (*foo)(int,int);
functionsetter(foo);
return 0;
}
</code></pre>
<p>I cannot figure out how to pass the function pointer <code>foo</code> to the <code>function-setter</code> function by reference. Can someone help me out on this.I am sure the declaration of </p>
<p><code>functionsetter</code> is wrong in the code, Please let me know how to fix it.</p>
<p>I am trying to compile this with <code>g++ -O2 -g -Wall -DADD main.cpp -o main</code></p>
<p>Note: I want to use such preprocessor flags and function pointers in some other-code elsewhere.
Please let me know if such a thing is a good idea / practice.</p>
| c++ | [6] |
5,674,228 | 5,674,229 | jQuery beginner - referencing HTML object passed into JS function | <p>It seems like there should be a better way to code this:</p>
<p>HTML snippet:</p>
<pre><code><label onclick="addstuff(this)" id="label_id">Hello</label>
</code></pre>
<p>JS/jQuery snippet:</p>
<pre><code>function addstuff(field){
$('#'+field.id).before('<div>Just a random element being added…</div>');
}
</code></pre>
<p>I dislike that I am referencing my field in the Javascript by $('#'+field.id) when the field is already being passed in. It seems like there should be another way to reference field in jQuery using the field object that is passed in, which in my mind should be more efficient, but I'm not having any luck figuring it out. Any advice is greatly appreciated.</p>
| jquery | [5] |
5,300,636 | 5,300,637 | Make an X using drawLine | <p>How can I draw an x using the drawline method?</p>
<pre><code>g.drawLine(getX(), getY(), getX()+getWidth(), getY()+ getHeight());
</code></pre>
<p>I am assumming I would have to flip this. How?</p>
| java | [1] |
799,047 | 799,048 | is it possible to set variables that are global only within a function? | <p>That is variables that are visible to anonymous functions iside a main function. I ask because array_walk_recursive allow for only one additional parameter, it would be nice to be able to reach some vars from anonymous functions without relying on constant compact and extract</p>
| php | [2] |
1,749,961 | 1,749,962 | Moving Div and Content into Another Div | <p>I have tried to move my div and its contents to another div using such things as:</p>
<pre><code><script>
document.getElementById('#header').appendChild(
document.getElementById('#live')
);
</script>
</code></pre>
<p>and</p>
<pre><code><script>
$("#header").append($("#live"))
);
</script>
</code></pre>
<p>but i cant move the div the best i have done is move some text about.</p>
<p>Help.</p>
| javascript | [3] |
3,975,156 | 3,975,157 | how to use SSH in different platforms? | <p>I am using QT libraries in my C++ applications, I would like to know if there is a multiplatform library to use SSH without portability problems.</p>
<p>I need a ssh client to connect to my server and send files.</p>
| c++ | [6] |
245,815 | 245,816 | not implementing all of the methods of interface. is it possible? | <p>Is there any way to not implement all of the methods of an interface in the class? I tried to find the answer to this question on Google but could not find one.</p>
| java | [1] |
5,786,242 | 5,786,243 | How should this instanceof condition look like? | <p>I have a list of nodes. This nodes are a data class I defined by myself. Each node has a data field of the type Object. Now I want to find the node in a list of nodes that has the parameter object in the data field. I wrote this method, because I wanted to first compare if the two objects (the parameter and the object in the data field) are of the same type:</p>
<pre><code>public Node getnNodeByData(Object obj) {
for (Node node : nodes) {
if (node.getData() instanceof obj.getClass()) {
}
}
}
</code></pre>
<p>Unfortunately this condition does not work:</p>
<pre><code>Incompatible operand types boolean and Class<capture#1-of ? extends Graph>
</code></pre>
<p>I don't really know why this is a problem. How can I make this working?</p>
| java | [1] |
3,347,941 | 3,347,942 | Is there an easy way to store a reference to an arbitrary instance variable in an array? | <p>I want to store instance variable references of aribrary objects in an array, so that I can iterate over the array and set these instance variables.</p>
<p>Would I have to provide their memory addresses to the array? like </p>
<pre><code>[arr addObject:&anIvar];
</code></pre>
<p>?</p>
| iphone | [8] |
5,411,617 | 5,411,618 | How to get drawable from a button? | <p>Since on button, we can use android:drawableLeft to set the drawable on the left of a button. Is there way to get this drawable programmatically?</p>
<pre><code><Button android:id="@+id/detail_refresh_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="@string/refresh"
android:gravity="center"
android:drawableLeft="@drawable/progress"
/>
</code></pre>
<p>Is there any way to get the drawable "progress" in Java code?</p>
| android | [4] |
1,090,081 | 1,090,082 | How to use native ASP page with asp.net 2.0 | <p>I have migrated a web site from asp.net 1.1 with native asp pages that I have not modified.
But running them generated an error, unable to run them.
I have added a buildProviders and httpHandlers for asp, but after that the web does not compile anymore, too many errors. since it was working before, what is the trick to do so in minimal changes.
Any ideas?</p>
| asp.net | [9] |
2,193,706 | 2,193,707 | Android available memory in device at the time of downloading? | <p>How to check the available memory in android when user is downloading the media into the sdCard</p>
| android | [4] |
5,287,816 | 5,287,817 | Can i use activities for all my layouts for any application? | <p>I am beginner in android application development.
If i am using n number of layouts in my project and i need to change layouts with the user interaction.
Should i use different activities for different layouts or can i use setContentView to switch layouts.
Which one will be effecient?</p>
| android | [4] |
3,152,021 | 3,152,022 | Parse error: syntax error, unexpected $end in file on line 5 | <pre><code><?php
print_r($_FILES);
$new_image_name = "namethisimage.jpg";
move_uploaded_file($_FILES["file"]["tmp_name"], "C:\Program Files\wamp\www\workspace\DiaryApp\upload\".$new_image_name);
?>
</code></pre>
<p>Please help me out with the error I am new to php</p>
| php | [2] |
2,139,498 | 2,139,499 | Making the input read integer conversions and be totalled into an equation | <p>I have this code that takes a users input number and put it into an equation in the end. However, I keep getting an error/exception when compiling;
"Error: variable convertToNumL might not have been initialized." I understand what the error is saying, however, I don't know how to debug this. </p>
<p>This is what I know, the try/catch block is somehow preventing the variable convertToNum (which is derived from the .readLine () method). Can anyone show me how to work around this? </p>
<p>Much appreciated.</p>
<p>Part of my code:</p>
<pre><code> if (realNumber2)
{
//Question 4: Height
while (realNumber2 = true) {
System.out.println ("3) Please enter the height of the triangle face.");
try
{
stringTriangleHeight = myInput.readLine ();
convertToNumH = Double.parseDouble (stringTriangleHeight);
Integer.parseInt (stringTriangleHeight);
System.out.println ("Your triangle height is " + stringTriangleHeight + " " + Units + ".");
realNumber3 = true;
break;
}
catch (Exception e)
{
System.out.println ("That was either a smart remark, a negative number or jibberish.");
realNumber3 = true;
}
}
while (realNumber3) {
total1 = convertToNumL * convertToNumW; //base area, length x width
total2 = convertToNumL * convertToNumH / 2; //triangle area using sidelength 'length', base x height / 2
total3 = convertToNumW * convertToNumH / 2; //triangle area using sidelength 'width , base x height / 2
</code></pre>
| java | [1] |
1,986,650 | 1,986,651 | How best to extract xml tags in java without using xml-specific tools? | <p>The specification requires to validate a simplified xml syntax, primarily the order of tags with a stack. While the use of standard classes is allowed, I don't think xml-specific tools would be. Should I use string.split or tokenizer or something else? The goal is to extract text within <>, push if no leading /, else try to pop.</p>
| java | [1] |
411,433 | 411,434 | Python: super and __init__() vs __init__( self ) | <p><strong>A:</strong> </p>
<pre><code>super( BasicElement, self ).__init__()
</code></pre>
<p><strong>B:</strong></p>
<pre><code>super( BasicElement, self ).__init__( self )
</code></pre>
<p>What is the difference between A and B? Most examples that I run across use A, but I am running into an issue where A is not calling the parent __init__ function, but B is. Why might this be? Which should be used and in which cases?</p>
| python | [7] |
4,083,093 | 4,083,094 | How to implement generator in C++? | <p>I want to know how to implement a generator , like python , in C++?
In python, it can use keyword "yield" to do so.
But how to do it in C++?</p>
| c++ | [6] |
1,873,511 | 1,873,512 | ArgumentNullException was unhandled | <p>This is a part of a code that will saved image to database</p>
<pre><code>Bitmap TempImage = new Bitmap(@cwd + "\\Final.jpg", true);
pictureBox.Image = new Bitmap(TempImage);//pictureBox.Image = Image.FromFile(imgName[0]);
TempImage.Dispose();
string name = textBox1.Text + ".jpg";
MemoryStream mstr = new MemoryStream();
pictureBox.Image.Save(mstr, pictureBox.Image.RawFormat);
byte[] arrImage = mstr.GetBuffer();
</code></pre>
<p>then the program halts at <code>pictureBox.Image.Save(mstr, pictureBox.Image.RawFormat);</code> saying <code>ArgumentNullException was unhandled, Value cannot be null.
Parameter name: encoder</code></p>
<p>what would be wrong?</p>
| c# | [0] |
4,195,052 | 4,195,053 | Manage Our employee mobiles | <p>In our Organization we have 200 Android O.S mobiles for our customer support people.All employees are tracked using GPS.I had developed the tracking application that will send Location of mobiles for every 1 minute to my server.It is working well,but i want several extra features</p>
<ol>
<li>I want to install my tracking application using another application
on mobile with out user interaction.</li>
<li>I want to restrict the user not to delete the application</li>
<li>I want to restrict the user not to change settings(Location ,Date
time .. e.t.c)</li>
</ol>
<p>How can i achieve these.Please tell me what the different ways to do this?Without these restrictions my entire project will be failed.We already spent so much on this project.Please help me.</p>
| android | [4] |
3,508,348 | 3,508,349 | weird javascript problem with comparing | <p>i have this little piece in a function and the comparison is only working when I have the alert box before the check.</p>
<p>If I remove it, it will say it's always equal with 2 or higher... but when I have the alert box there, and it shows me they are not equal yet it works.</p>
<p>WHY? thanks</p>
<p>[edit: added the whole function, el_id is the div which is pressed and it has 2 attributes as you can see, but they dont cause the problem]</p>
<pre><code> function PostAnswer(el_id) {
var a = $("#"+el_id).attr("answer");
var u = $("#"+el_id).attr("player");
// mark question as answered
players_have_answered = players_have_answered + 1;
if (a == game_questions[current_question][5]) {
// CORRECT
current_question = current_question + 1;
// stop the clock and reset
stop_clock();
alert('Player '+u+' is correct!');
} else {
// WRONG!
$("#lbl_u" + u + "_q").html("<span class='sub'>Wrong answer!</span>");
}
alert(u + " player pressed: " + players_have_answered + " vs " + player_count);
if (player_count == players_have_answered) {
// stop the clock and reset
stop_clock();
alert('No player correct!');
}
}
</code></pre>
| javascript | [3] |
4,552,803 | 4,552,804 | C# syntax ?? in control statement | <p>Hi I have some code here which I dont understand</p>
<pre><code> public ObservableCollection<Packet> Items
{
get
{
this.items = this.items ?? this.LoadItems();
return this.items;
}
}
</code></pre>
<p>What does the ?? means?</p>
| c# | [0] |
5,200,647 | 5,200,648 | Android - memory leaks, what am I doing wrong? | <p>I have activity A, which launches activity B via an intent. Activity A has no references to Activity B, there are also no references to Activity B in the Application singleton I am using.</p>
<p>When I create Activity B, several thousand objects are created. That's okay, it's an activity with a very populated ListView with lots of images.</p>
<p>But, when I press the back button and return to Activity A, only about a dozen of the several thousand objects are released. onDestroy() is also called for the activity. I'm using DDMS to view the heap info, and am pressing 'Cause GC' several times to force it to free memory. </p>
<p>I've done the same test on other apps (that use list views too) and 100% of their objects are destroyed on pressing the back button then 'Cause GC', so it's certainly not a bug.</p>
<p>Any advice please? :-) I've read the material in the android docs about leaking contexts, but that's not helpful since i'm not referencing the activity (or anything in it) being destroyed elsewhere. Also, I have many other activities which work the same way, and don't release all memory on destroy. I must be missing something obvious?</p>
<p>Edit: I just realized i'm using AsyncTasks which have references to the activity (either passed as arg into doInBackground() or accessible via outerClass.this. Could they be hanging around in the thread pool, even after onPostExecute() ?</p>
<p>Edit: It leaks even if I go back before running any asynctasks :-( </p>
<p>Edit: No leak before running asynctasks if I remove admob code, but still leaks in the activites which do use asynctasks.. so asynctask is still a good candidate :-)</p>
| android | [4] |
4,488,674 | 4,488,675 | Have a class always return true for method exists | <p>I have a class that I would like to return true when method_exists() etc is called on it so that I can process it via __call().</p>
<p>I stumbled upon this link that talks about the removal of the behavior and __call()
<a href="https://bugs.php.net/bug.php?id=32429" rel="nofollow">https://bugs.php.net/bug.php?id=32429</a></p>
<p>Hopefully that makes sense. Thanks.</p>
<p>This is for a comment that I was not clear enough.</p>
<pre><code>class MyClass {
public function __call($method, $args) {
if($method === 'something') {
// do something
}
}
}
</code></pre>
<p>Then somewhere else there is</p>
<pre><code>$my_class = new MyClass();
if(method_exists($my_class, 'something')) {
// do something
// But does not because method exists returns false
// I would like it to return true if possible
}
</code></pre>
<p>Is there something complicated about that I'm not understanding?</p>
| php | [2] |
2,433,161 | 2,433,162 | Why do I need to prefix params with out or ref? | <p>If I'm calling a method that uses a out or ref parameter why do you need to mark the parameters with out or ref when calling the method? i.e.</p>
<pre><code>DateTime.TryParse(myDate, out dateLogged)
</code></pre>
<p>I had thought this was something to reduce ambiguity when operator overloading but if I create two methods like so:</p>
<pre><code>void DoStuff(int x, out int y)
{
y = x + 1;
}
void DoStuff(int x, ref int y)
{
y = x + 1;
}
</code></pre>
<p>Then Visual Studio reports "Cannot define overloaded method 'DoStuff' because it differs from another method only on ref and out", so I couldn't do that anyway. </p>
<p><strong>EDIT:</strong> </p>
<p>After a bit more research it seems that I would need to specify out or ref when calling a method if it there were two overloaded methods declared like this:</p>
<pre><code> void DoStuff(int x, out int y)
void DoStuff(int x, int y)
</code></pre>
| c# | [0] |
1,422,590 | 1,422,591 | How to get the content of all spans that have the email attribute with JavaScript | <p>I want to find all spans in a document that have the "email" attribute and then for each email address i'll check with my server if the email is approved and inject to the span
content an img with a "yes" or a "no". I don't need the implementation of the PHP side, only JavaScript.</p>
<p>So say "newsletter@zend.com" is approved in my db and the HTML code is:</p>
<pre><code><span dir="ltr"><span class="yP" email="newsletter@zend.com">Zend Technologies</span></span>
</code></pre>
<p>Then the JavaScript will change the HTML to:</p>
<pre><code><span dir="ltr"><span class="yP" email="newsletter@zend.com"><img src="yes.gif" />Zend Technologies</span></span>
</code></pre>
<p>I need someone to guide me to the right direction on how to approach this.</p>
<p>Note: i don't want to use jQuery.</p>
| javascript | [3] |
1,306,634 | 1,306,635 | Set Item postition in ActionBar | <p>I have this layout that add <strong>1 or more items</strong> into the ActionBar</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/item_test"
android:showAsAction="always|withText"
android:title="SearchIcon"/>
</menu>
</code></pre>
<p>And then I will add another item dynamically into the ActionBar from another Fragment or Activity</p>
<pre><code>MenuItem populateItem = menu.add("My New Item - Reload Icon");
</code></pre>
<p>But I want the item that I just added to <strong>stay in front</strong> of the items I had before, like the picture:</p>
<p><img src="http://i.stack.imgur.com/TKsgv.png" alt="enter image description here"></p>
<p>If I add it like I did, the icons will be shown as the last picture, how can I get the alignment like in the second picture? </p>
| android | [4] |
1,699,378 | 1,699,379 | how to get only the text of an element without getting the inline element using jquery? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6487777/getting-text-within-element-excluding-decendants">Getting text within element excluding decendants</a> </p>
</blockquote>
<p>how to get only the text of an element without getting the inline element using jQuery?</p>
<p>I have the following problem:</p>
<pre><code><p><strong>Test 1</strong> this is test 1 results</p>
</code></pre>
<p>How do I capture only "this is test 1 results" into an array using jQuery? I attempted this but it's not working:</p>
<pre><code>var TextResults = $("strong").parent("p").text();
var arrayTestResults = TextResults.split(" ");
</code></pre>
| jquery | [5] |
4,353,920 | 4,353,921 | Why I do not get first row if am using mysqli_fetch_assoc on first and mysqli_fetch_array second time? | <p>I am populating database column names for sorting my query in a sidebar list using <code>mysqli_fetch_assoc()</code> and that page is included on result page where I am using <code>mysqli_fetch_array()</code> to populate the table rows, now what the funny thing was on the result page I was getting only 3 rows where my database was having 4 rows, 1 row less, I was debugging entire code and I came accross that I am using <code>mysqli_fetch_assoc()</code> and <code>mysqli_fetch_array()</code> for same query, so if I removed <code>mysqli_fetch_assoc()</code> it used to return me 4 rows, but why is this so? I didn't got a bit</p>
<p>I thought I'll populate a comma separated names of table in my database and will explode later but after some internet research I came across this <code>mysqli_data_seek($fetch_results, 0);</code> and it solved my issue, but why I was getting 1 row less and after using <code>mysqli_data_seek($fetch_results, 0);</code> it returned me all rows that is 4 instead of 3? Can anyone explain me?</p>
<blockquote>
<p>P.S Am using excessive eval as I am developing customized systems, but
this is not the issue here, it's secure :)</p>
</blockquote>
| php | [2] |
5,756,335 | 5,756,336 | How to create a iPhone Settings-like view | <p>I want to create a view similar to the iPhone's Settings app. </p>
<p>Is this view using a UITableView or what? Are the items created programmatically or is it possible to do this in Interface Builder?</p>
| iphone | [8] |
5,008,209 | 5,008,210 | replacing a word in a string based on the content of the file in Python | <p>I have a text file with the following line - <code>a boy is drinking water</code>. say i call this file A.txt</p>
<p>My objective is to replace the word <code>water</code> with anything the user gives as input in A.txt.
and retaining the other stuff intact.
If A.txt is changed to <code>a boy is drinking juice</code> and is passed A.txt as parameter to the Python script, I want the output to be <code>a boy is drinking juice</code>. </p>
<p>How can we replace only that particular letter in a string.</p>
<p>thanks in advance for helping.</p>
| python | [7] |
1,535,584 | 1,535,585 | How can I use a ttf file for a button's text? | <p>How can I use a ttf file for a button's text?</p>
| android | [4] |
5,783,423 | 5,783,424 | What part of dereferencing NULL pointers causes undesired behavior? | <p>I am curious as to what part of the dereferencing a NULL ptr causes undesired behavior. Example:</p>
<pre><code>// #1
someObj * a;
a = NULL;
(*a).somefunc(); // crash, dereferenced a null ptr and called one of its function
// same as a->somefunc();
// #2
someObj * b;
anotherObj * c;
b = NULL;
c->anotherfunc(*b); // dereferenced the ptr, but didn't call one of it's functions
</code></pre>
<p>Here we see in #2 that I didn't actually try to access data or a function out of b, so would this still cause undesired behavior if *b just resolves to NULL and we're passing NULL into anotherfunc() ?</p>
| c++ | [6] |
4,292,901 | 4,292,902 | How can I place an background image to a the left upper corner of TextView in android | <p>Can you please tell me how can I place an background image to a the left upper corner of TextView in android? I would like the image not to be scaled by android.</p>
<p>I have tried </p>
<p>Resources res = getResources();
setCompoundDrawables(res.getDrawable(R.drawable.icon48x48_1), null, null, null);</p>
<p>Nothing is shown.</p>
<p>And I have tried
setBackground(R.drawable.icon48x48_1); </p>
<p>But it stretches the image.</p>
<p>Thank you for any help.</p>
| android | [4] |
5,337,610 | 5,337,611 | How can I capture output and show it at the same time with Python? | <p>I have a pretty long running job, which runs for several minutes and then gets restarted. The task outputs various information which I capture like this:</p>
<pre><code>output = subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate()
</code></pre>
<p>The thing is, I will only get the entire output at a time. I would like to show output as the program is sending it to stdout, while still pushing it back in a buffer ( I need to check the output for the presence of some strings ). In Ruby I would do it like this:</p>
<pre><code>IO.popen(cmd) do |io|
io.each_line do |line|
puts line
buffer << line
end
end
</code></pre>
| python | [7] |
4,580,090 | 4,580,091 | Service that broadcasts different message types | <p>I want to make a service that I can register to. The service will broadcast messages of different "types" and each application can register itself to recieve messages of different type.</p>
<p><strong>For example:</strong></p>
<p>I want to write a servive that reads the twitter messages of some user and broadcasts to the systems the tags.
Then a consumer can register to recieve only messages of tag "foo", and recieve the tweet message.
Another consumer can register to recieve only messages of tag "bar", and recieve the tweet message.</p>
<p>Lets assume I know how to build a service. My first idea is to just broadcast a something, and then filtering it in the apps. But I am not happy about this solution. I know there are some android services that work similar to what I want, but I found no reference on the web on how to implement this.</p>
<hr>
<p>Some RTFM I have done is:</p>
<ul>
<li><a href="http://groups.google.com/group/android-developers/browse_thread/thread/e1863d2822b22a33/90873ef925cd2aad" rel="nofollow">http://groups.google.com/group/android-developers/browse_thread/thread/e1863d2822b22a33/90873ef925cd2aad</a></li>
<li><a href="http://www.vogella.de/articles/AndroidServices/article.html" rel="nofollow">http://www.vogella.de/articles/AndroidServices/article.html</a></li>
<li><a href="http://stackoverflow.com/questions/3998650/what-is-the-simplest-way-to-send-message-from-local-service-to-activity">What is the simplest way to send message from local service to activity</a></li>
<li><a href="http://stackoverflow.com/questions/2463175/how-to-have-android-service-communicate-with-activity">How to have Android Service communicate with Activity</a> -> not good for me, as this question is about a single process, and I need the service talking to several different processes </li>
</ul>
<p>The main problem, is that most of the docs on the internet are about me calling the service, and not the service calling me.</p>
| android | [4] |
1,172,693 | 1,172,694 | How to implement app usage statistics | <p>I need to implement something to know wich apps is most used on a android device. I mean I need something just like this: <a href="http://pt.appbrain.com/app/appusage/com.smartappers.appusage" rel="nofollow">http://pt.appbrain.com/app/appusage/com.smartappers.appusage</a>
wich have a list of apps and the time that each one has been used.</p>
<p>I'm doing an app for a company and I need the usage statistics of the devices of employees.</p>
<p>Thx everyone !</p>
| android | [4] |
3,697,869 | 3,697,870 | Can someone give me an overview of ASP.net and how it's different from technologies such as php? | <p>I've been doing the html and css for a site, sending it off to a guy to implement in a web server. I get a call from the designer freaking out about the progress, saying the clients aren't happy. He wants me to personally integrate my css with what's on the site. The site is done in ASP.net, time is short, and I'm a little in over my head. I have an understanding of how php works, but have never worked extensively with it.<br>
Looking at the stuff on the ftp, I can't even find equivalent of the index.html file (I know that when I go to the site itself, there is nothing after the base url, i.e., www.site.com/ brings me to the homepage.)</p>
<p>Can anyone give me a few tips or links as to what I am to do with this, or where to even being navigating this site? </p>
<p>EDIT: It's -not- a .Net Web Application, from the looks of it. </p>
| asp.net | [9] |
3,782,584 | 3,782,585 | FLAG_ACTIVITY_CLEAR_TOP in Android | <p>Can somebody explain me in a really simple way what does <code>FLAG_ACTIVITY_CLEAR_TOP</code>mean? I know there were a lot of questions about it, but none of the answers satesfied me. Can somebody also give an example where this flag is useful? Thanks.</p>
| android | [4] |
2,811,323 | 2,811,324 | What is the correct code to store the text that extracted from each function into variable? | <p>I know this is not a right code, howvwer i wanna ask how can I achieve the idea behind using the right coding?</p>
<p>I intend to store into variable all the text inside each list item</p>
<pre><code>var date = $('.selector1 ul li')each().text()
var time = $('.selector2 ul li')each().text()
$(selector3).html("<td>date</td><td>time</td>");
</code></pre>
<p>Yes im trying to transform it into table</p>
| jquery | [5] |
3,663,357 | 3,663,358 | PHP what is the best way to handle a variable that may not be set? | <p>I have a foreach loop, that will loop through an array, but the array may not exist depending on the logic of this particular application.</p>
<p>My question relates to I guess best practices, for example, is it ok to do this:</p>
<pre><code>if (isset($array))
{
foreach($array as $something)
{
//do something
}
}
</code></pre>
<p>It seems messy to me, but in this instance if I dont do it, it errors on the foreach. should I pass an empty array?? I haven't posted specific code because its a general question about handling variables that may or may not be set. </p>
| php | [2] |
614,907 | 614,908 | how to parse data using ASIHttp request? | <p>I am using webservices.I am sending request from the iphone and fetch the data.I am using http request.But i want to use ASIhttprequest so how it possible?</p>
| iphone | [8] |
3,019,886 | 3,019,887 | Handling Duplicate objects in Javascript | <p>I have a javascript method which handles removing from one select box to another.
The code runs as follows :</p>
<pre><code> function moveAllOptions(formName, selectId1, selectId2) {
var sourceSelect = eval("document." + formName + "." + selectId1);
var destSelect = eval("document." + formName + "." + selectId2);
for (var i = 0; i < sourceSelect.length; i++) {
var optionText = sourceSelect.options[i].text;
var optionValue = sourceSelect.options[i].value;
for (var j = 0; j < destSelect.length; j++) {
if (destSelect.options[j].value == optionValue) {
destSelect.options[j].value = null;
}
}
}
}
</code></pre>
<p>But I found a problem like when it encounters duplicate values it is not deleting all the values .For eg: in the view source I have</p>
<pre><code>value="139">Customer Service<
value="231">Customer Service<
value="231">Customer Service<
value="231">Customer Service<
value="231">Customer Service<
</code></pre>
<p>In this case it removes only two objects from my left hand box.
Is there any way to remove duplicate objects also.One way I could think is create an two array objects(Two Dimensional), pass all the values in left hand side to one array then iterate to another array and finally pass again to normal options.</p>
| javascript | [3] |
3,083,277 | 3,083,278 | How to show google map on web page in asp.net? | <p>I want to show a google map on the aspx page.
How to do that?</p>
<p>Also I want to show that it on some update panel of ajax control. Can update panel have the property that it refreshes in every 1 minute?</p>
<p>Thanks & Regards,
Girish</p>
| asp.net | [9] |
4,019,918 | 4,019,919 | Updating tabs after changes | <p>i was wondering what state the actual tabs are after the onCreate state, the onCreate state runs when the tab is launched for the first time, when i select another tab and return back to the previously launched tab, in what state is it in ?</p>
| android | [4] |
5,984,578 | 5,984,579 | Adding a title to a displaced image rollover | <p>I have a simple image gallery (main images plus 4 thumbnails which on rollover trigger the main image swap) which needs to be extended to include a caption. The image swap function works as planned but I can't figure out how to 'tweak' the JS to allow the inclusion of a caption. Ideally I'd like to be able to add a title to the thumbnail and have it display beneath the main image.</p>
<pre><code><div class="contact">
<h1>Heading</h1>
<div id="gallery">
<ul>
<li><img src="images/thumbs/img_cart1.jpg" alt="" /></li>
<li><img src="images/thumbs/img_cart2.jpg" alt="" /></li>
<li><img src="images/thumbs/img_cart3.jpg" alt="" /></li>
<li><img src="images/thumbs/img_cart4.jpg" alt="" /></li>
</ul>
<img src="images/img_cart1.jpg" alt="" id="main-img" />
</div>
<script type="text/JavaScript">
// prepare the form when the DOM is ready
$(document).ready(function() {
$("#gallery li img").hover(function(){
$('#main-img').attr('src',$(this).attr('src').replace('thumbs/', ''));
});
var imgSwap = [];
$("#gallery li img").each(function(){
imgUrl = this.src.replace('thumbs/', '');
imgSwap.push(imgUrl);
});
$(imgSwap).preload();
});
$.fn.preload = function() {
this.each(function(){
$('<img/>')[0].src = this;
});
}
</script>
</code></pre>
<p>Any help would be greatfully received.</p>
<p>Thanks,
@rrfive</p>
| javascript | [3] |
3,870,717 | 3,870,718 | online money transaction.. php code | <p>I want to create a site which includes online money transaction. Site is done but online money transaction remains unsolved. well,, I dont have any idea how to implement it. can any one help me..</p>
<p>My requirement is to give access to my site 5 days for free... after that the user has to do the payment. paypal is about to stop ptheir service in india. so I would like to use some other service like paypal.</p>
<p>My site has been done in php. So any one pls help me or direct me to some links where I can find more relevant infomation about this.</p>
<p>Thank you..</p>
| php | [2] |
1,884,100 | 1,884,101 | Android In app walkthrough | <p><br/>How to create in-app step by step instructions?<br/>
<a href="http://i.stack.imgur.com/ROF16.png" rel="nofollow">Like this</a> (<a href="http://www.youtube.com/watch?v=9ZZQrm07s4A&feature=player_detailpage#t=222s" rel="nofollow">first boot android ics</a>, new google play app etc)
<br/>Is it a part of public android sdk? </p>
| android | [4] |
2,532,573 | 2,532,574 | When linking to JQuery script is it OK to use the one on the JQuery website? | <p>Hey there I've just been looking at using JQuery on my website I am developing.. A quick question; Am I able to just link to their script file? e.g.: </p>
<pre><code><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
</code></pre>
<p>or do I need to upload my own copy to a server?</p>
<p>Thanks in advance.</p>
| jquery | [5] |
3,157,722 | 3,157,723 | Determining the favicon file (.ico extension) on the client side? | <p>I know this is possible because this is how bookmarklets work for social bookmarking sites like delicious.</p>
<p>1.) Google has an API that will pull it for you but it only works about 80% of the time.</p>
<p>2.) Checking the default location host.com/favicon.ico does not work very often, maybe 50%.</p>
<p>The links I'm looking for look like this:</p>
<pre><code><link href="/static/27009/images/favicon.ico>
<link rel="shortcut icon" href="/static/favicon.ico" />
</code></pre>
<p>One idea was to load the site into a <code>visibility:none</code> iframe and pull the info. out, by searching the text for xxxx.ico.</p>
<p>Or if it is possible to access the iframe dom and just grab it that way.</p>
<p>How do I pull the favicon location client side?</p>
| javascript | [3] |
2,948,198 | 2,948,199 | How do i communicate between a dll and an exe? | <p>i have a dll which has to get some values from the running exe. So Can i do this by WCF? i.e whenever request is sent from dll to the service that in turn should request running exe and give the result.The dll which i am referring is a COM dll used in EXcel. Can it be done?</p>
| c# | [0] |
1,591,643 | 1,591,644 | Using java to count occurrences of letters in string | <p>Recently I did a problem where I found whether a character could be found in a string. I was wondering how to use Java to count the occurrence of EVERY letter in a string and then print it alphabetically? So for example, if the string is "alabama" then the function will return "a:4, b:1, l:1, m:1"</p>
| java | [1] |
2,815,436 | 2,815,437 | How to generate a Uniq Number C# | <p>I want to generate a Uniq Number something like TMP-0001354, TMP will be always same only number will get change, which should not be get duplicate in table.</p>
<p>I want to a exp. code which should be in c#, I'll call that function at the time of inserting the record in table. SQL server database I am using</p>
<p>I am trying this I don't know will it work fine or not.</p>
<pre><code> private string RandomNumberGenerator()
{
int maxSize = 8;
int minSize = 5;
char[] chars = new char[62];
string a;
a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
chars = a.ToCharArray();
int size = maxSize;
byte[] data = new byte[1];
RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
crypto.GetNonZeroBytes(data);
size = maxSize;
data = new byte[size];
crypto.GetNonZeroBytes(data);
StringBuilder result = new StringBuilder(size);
foreach (byte b in data)
{ result.Append(chars[b % (chars.Length - 1)]); }
return result.ToString();
}
</code></pre>
<p>Some one please help me.</p>
| c# | [0] |
872,169 | 872,170 | check the if DOM has class name attached to it | <p>I want to check if a Dom has class value attached to it.. Since that DOM will be assigned a random class value dynamically, I will not know the class name specifically, so is it possible to check if it has a class element attached to irrespective of its class name.</p>
| jquery | [5] |
2,824,859 | 2,824,860 | javascript function for php in_array() like non numeric Index | <p>i want a function for javascript like in_array in PHP to look for the special characters in an array. if that special character is in the array it returns true.</p>
| javascript | [3] |
5,209,261 | 5,209,262 | Anyone know why I can’t use kAudioFormatFlagIsFloat instead of kAudioFormatFlagIsSignedInteger for an AudioStreamBasicDescription? | <p>Why does this work?</p>
<pre><code>- (void)setupAudioFormat:(AudioStreamBasicDescription*)format
{
format->mSampleRate = 44100;
format->mFormatID = kAudioFormatLinearPCM;
format->mFramesPerPacket = 1;
format->mChannelsPerFrame = 1;
format->mBytesPerFrame = 2;
format->mBytesPerPacket = 2;
format->mBitsPerChannel = 32;
format->mReserved = 0;
format->mFormatFlags = kLinearPCMFormatFlagIsBigEndian |
kLinearPCMFormatFlagIsSignedInteger |
kLinearPCMFormatFlagIsPacked;
}
</code></pre>
<p>but when I change the mFormatFlag it doesn't and I get a kAudioFileUnsupportedDataFormatError.</p>
<pre><code>format->mFormatFlags = kAudioFormatFlagIsFloat |
kLinearPCMFormatFlagIsBigEndian |
kAudioFormatFlagIsPacked;
</code></pre>
<p>I am recieving the error when calling...</p>
<pre><code>OSStatus status = AudioQueueNewInput(&recordState.dataFormat,
AudioInputCallback,
self,
CFRunLoopGetCurrent(),
kCFRunLoopCommonModes,
0,
&recordState.queue);
</code></pre>
<p>I am sure the problem lies in the format flags as the error only happens when I try to use the float flag, any ideas how to get around it?</p>
<p>Many thanks.</p>
| iphone | [8] |
870,843 | 870,844 | How to run a service in sleep mode in Android | <p>I wrote an android service, which search for GPS every 5 minutes. I have used a timer inside the service. But this timer is not running when the phone is in the sleep mode.</p>
<p>Can't I run a service when the phone is in sleep mode?
How can I over come this problem? pls help me.</p>
<p>Thanks in Advance</p>
| android | [4] |
5,777,800 | 5,777,801 | In php what is more efficient n-1 < x OR n <= x | <p>What is more efficient</p>
<pre><code>if ($n-1 < $x)
</code></pre>
<p>or</p>
<pre><code>if ($n <= $x)
</code></pre>
<p>Anyone know?</p>
| php | [2] |
5,347,710 | 5,347,711 | How to make a view which covers whe whole screen, including the status bar? | <p>I want to make an overlay which is partially transparent, and covers the entire screen including the status bar. I've seen that the folks at tapbots do exactly that. So it must be possible somehow. Status bar should still be visible!</p>
| iphone | [8] |
5,261,447 | 5,261,448 | very interesting use of return keyword in php | <p>as we know, <strong>return</strong> keyword will RETURN some value and exit current function. Mean, that this one used only inside some functions.</p>
<p><b>BUT,</b> I saw some php-dev's use return keyword outside functions, even in index.php file (in root of web server). What is that mean???? By the way, maybe it's logical to require some file inside function, but this style isnt mine.</p>
| php | [2] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.