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,128,946 | 3,128,947 | calles and handsfree | <p>is there any way to be notified when a person calls or I call or when I removed hand free from socket ?
I want to make a music player and I need to stop it when a person calls or user removed hand free from socket , how to detect this situation .</p>
| android | [4] |
164,021 | 164,022 | Change Contextual ActionBar Close button icon on just one action mode | <p>I have an activity with 2 different action modes (one for copy/paste, and one for editing some text with an EditText). Is it possible to use <em>different</em> custom icons for each action mode?</p>
<p>I know about this style:</p>
<pre><code><item name="android:actionModeCloseButtonStyle">@style/MyCloseButton</item>
</code></pre>
<p>But how can I apply that to one of two action modes of the same activity?</p>
<p>EDIT: More generically, is it possible to use 2 styles for two CABs on the same activity?</p>
| android | [4] |
751,638 | 751,639 | 0 multiplied by 3 equals to 0. 2 multiplied by 6 equals to 12. 4 multiplied by 9 equals to 36. | <pre><code>0 multiplied by 3 equals to 0.
2 multiplied by 6 equals to 12.
4 multiplied by 9 equals to 36.
6 multiplied by 12 equals to 72.
8 multiplied by 15 equals to 120.
10 multiplied by 18 equals to 180.
</code></pre>
<p>can you help me translate into PHP loop</p>
| php | [2] |
5,343,280 | 5,343,281 | Editing Python Program | <pre><code>Message = input("Enter a message: ")
vowels=Message.count('a')+ Message.count('i')+Message.count('e')+Message.count('u')+Message.count('o')
print ('There are ',vowels,' vowels.')
</code></pre>
<p>How would I edit the function to include the function "Vowels(text)" and still work the same? thanks.</p>
| python | [7] |
2,550,963 | 2,550,964 | Issue while redirecting to same page in sitemap | <p>I entered all details of pages in xml.but one page sitemap not coming as i mean.</p>
<pre><code><?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<!--<siteMapNode url="~/EmployeePortal/Index.aspx" title="Home" description="Home" >-->
<siteMapNode url="~/User/UserApplications.aspx" title="Applications" description="Applications">
<siteMapNode url="~/User/TicketDashboard.aspx" title="Ticketing Dashboard" description="Ticketing Dashboard" >
<siteMapNode url="~/User/Ticket_Details.aspx" title="Ticket Details" description="Ticket Details" />
<siteMapNode url="~/User/NewTicket.aspx" title="Create Ticket" description="Create Ticket"/>
<siteMapNode url="~/User/My_Tickets.aspx" title="My Tickets" description="My Tickets">
<siteMapNode url="~/User/Ticket_Details.aspx?page=1" title="Ticket Details" description="Ticket Details" />
</siteMapNode>
</siteMapNode>
</siteMapNode>
</siteMap>
</code></pre>
<p>here its appearing as
applications>ticketing dashbaord>ticket details
but i want sitemap as
applications>ticketing dashbaord>my tickets>ticket details
why its not coming by my code
Thanks in advance
Amrutha</p>
| asp.net | [9] |
1,909,944 | 1,909,945 | Java—how can I dynamically reference an object's property? | <p>In javascript, I can do this:</p>
<pre><code>function MyObject(obj) {
for (var property in obj) {
this[property] = obj[property];
}
}
</code></pre>
<p>Can I do anything close in Java?</p>
<pre><code>class MyObject {
String myProperty;
public MyObject(HashMap<String, String> props) {
// for each key in props where the key is also the name of
// a property in MyObject, can I assign the value to this.[key]?
}
}
</code></pre>
| java | [1] |
5,011,863 | 5,011,864 | update table using Label.Text | <p>A simple update operation is throwing an error like "incorrect syntax near '('". My code is below.</p>
<pre><code> protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
con.Open();
string insCmd = "update Reg set (DateOfBirth,Experience)=@DateOfBirth,@Experience where UserName='"+Label3.Text+"'";
SqlCommand insertUser = new SqlCommand(insCmd, con);
insertUser.Parameters.AddWithValue("@Experience",TextBoxex.Text);
insertUser.Parameters.AddWithValue("@DateOfBirth",TextBoxdob.Text);
try
{
insertUser.ExecuteNonQuery();
con.Close();
Response.Redirect("Admin.aspx");
}
</code></pre>
| asp.net | [9] |
4,981,802 | 4,981,803 | calling parent class method from child class object in java | <p>I have a parent class which have a method, in child class i have override that parent class method . In a third class i make a object of child and by using that object i want call method of parent class.Is it possible to call that parent class method ? If yes then how?</p>
<p>Please reply </p>
| java | [1] |
5,362,838 | 5,362,839 | Any way to create a Object that extends Array? | <p>I have created a lexer in javascript, and where im now using an array to describe a range of items, i now see the use of having my own Range object so i can properly distinguish an "array" and a "range array" in such a way that it reads nicely.</p>
<p>So is there any way i can create a hugely cross browser compatible sublcass of the Array object?</p>
<p>Or would a better/simpler approach just using array as is, and for "range arrays" i just tag the array with a property of my own choosing?</p>
<p>something like:</p>
<pre><code>var myRange = [1,2,3];
myrange.isRangeObj = true;
//i would then use if(myRange.isRangeObj) to do specific range operations.
//However i still think myRange instanceof Range reads better
</code></pre>
| javascript | [3] |
4,071,846 | 4,071,847 | A FileSet package/class wanted for Java | <p>Can anyone suggest a FileSet package/class in Java. By FileSet I mean a collection of files and directories together with regex-powered inclusion and exclusion rules (similar to Apache Ant). Thanks.</p>
| java | [1] |
407,691 | 407,692 | Java Error: Should be declared in a file named | <p>I'm fairly new to Java and trying to figure out how to solve the following error:</p>
<h2>Error reads</h2>
<pre><code>CalculatorWithMemory.java:1: class Calculator is public, should be declared
in a file named Calculator.java
public class Calculator
</code></pre>
<p>So my thought was that this means that I have to save 2 different .java files. However, this being for a class, I only have a provided text block to type my solution into so I cannot save these as .java files. Any thoughts on a solution would be great.</p>
<p>Thanks in advance!</p>
<p>To Provide all the information. I'm trying to solve for the following.</p>
<h2>Question</h2>
<p>The superclass Calculator contains:</p>
<ul>
<li>a (protected) double instance variable, accumulator, that contains the current value of the calculator.</li>
</ul>
<p>write a subclass, CalculatorWithMemory, that contains:</p>
<ul>
<li>a double instance variable, memory, initialized to 0</li>
<li>a method, save, that assigns the value of accumulator to memory</li>
<li>a method, recall, that assigns the value of memory to accumulator</li>
<li>a method, clearMemory, that assigns zero to memory</li>
<li>a method, getMemory, that returns the value stored in memory</li>
</ul>
| java | [1] |
1,321,646 | 1,321,647 | couldn't pass value from textbox to select input | <p>In my code, I have following lines to get the value from textbox input and set one of options as selected in select input according to this value.</p>
<pre><code>var category_name = jQuery('.categoryNameTextbox').val();
//alert(category_name);
jQuery('.categoryDropdown').val(category_name);
</code></pre>
<p>I can get "category_name" successfully, but I couldn't set the option in select input. However, if I use the following line to test, i can set "rent" as selected option in select input perfectly.</p>
<pre><code>jQuery('.categoryDropdown').val("rent");
</code></pre>
<p>Anyone knows what is going on here? Thank you in advance.</p>
<p>Here is my code. My purpose is set selected option in dropdown list according to the value in the textbox</p>
<pre><code><select class="categoryDropdown"><option value="">Select</option><option value="buy">Buy</option><option value="sell">Sell</option><option value="rent">Rent</option></select><div style="display: none;"><input type="text" class="categoryNameTextbox" value="rent"></div>
</code></pre>
| jquery | [5] |
2,065,794 | 2,065,795 | Php don't print if line begins with | <p>I have the below code which prints out lines of text as long as the lines aren't empty:</p>
<pre><code>$textChunk = wordwrap($value, 35, "\n");
foreach(explode("\n", $textChunk) as $textLine)
{
if ($textLine!=='')
{
$page->drawText(strip_tags(ltrim($textLine)), 75, $line, 'UTF-8');
$line -=14;
}
}
</code></pre>
<p>I would like to edit it so that it also doesn't print the line if it begins with 'T:'</p>
<p>Any ideas?</p>
| php | [2] |
5,438,836 | 5,438,837 | socket gets destroyed every time I rotate the phone | <p>I'm working with sockets but every time a rotate the phone to the horizontal position my socket get destroyed as the activity is recreated. I guess this is because I destroy the socket in the onStop() function. </p>
<p>Until now I'm using:</p>
<pre><code>@Override
protected
void onSaveInstanceState( Bundle data ) {
data.putInt( "Phase", 3 );
}
</code></pre>
<p>to store some integers but I don't know how to store a socket and even if I would, that wouldn't avoid the socket from being destroyed upon changing phone orientation.</p>
<p>Any ideas?</p>
| android | [4] |
2,011,358 | 2,011,359 | Returning switch capable value based on String | <p>Not sure how I'm going to attack this.</p>
<p>Basically what I have is input of varying length, one or multiple times, that will cause an action. It being from typed input, file etc.</p>
<p>I have no idea on by what and how to tackle this. Would it be best to have a function returning an <code>int</code> that correspond to an <code>public static final int FOO = 1;</code>, an <code>enum</code>, an other way?</p>
<p>What I have as of now is a series of if statements as in:</p>
<pre><code>if (str.equals("foo") || str.equals("F")) {
blah;
} else if (str.equals("beach")) {
more blah;
}
</code></pre>
<p>Is this good as any, or is there a better way? Have had a peek at <code>enum</code> but seems like that is more to it then in e.g. C. This is probably wrong, but would it be something in the direction of this?</p>
<pre><code>class Mother
{
HappyCamping() {
switch (ValInput(str)) {
case FOO: do fo; break;
case BAR: do bar; break;
case BAZ: do fo bar: break
...
}
private enum ValInput(String str)
{
FOO("foo"), BAR("bar"), BAZ("baz");
private int value;
private ValInput(String str) {
if (str.equals("blah"))
this.value = 1;
...
}
}
}
</code></pre>
<p>Point being having a cleaner approach and separate out the "parsing" from the main routine. What would be a good way here?</p>
| java | [1] |
1,556,095 | 1,556,096 | If anchor is clicked php | <p>I'm trying to echo information on a page after and anchor has been clicked</p>
<pre><code><a id="anchor">Information</a>
<?php
if(?){
echo 'INFORMATION';
}
?>
</code></pre>
| php | [2] |
856,470 | 856,471 | How to get value of a <input> by clicking another <input> in same <tr> different <td> | <pre><code><tr class="item-row" id="itemsRow">
<td></td>
<td><input class="tInput" id="invoiceNo" readonly/> </td>
<td><input class="tInput" id="clientId" readonly /> </td>
<td><input class="tInput" id="issueDate" readonly/></td>
<td><inpu class="tInput" id="netTotal" readonly /> </td>
<td><input class="tInput" id="amountDue" readonly /> </td>
<td><input class="tInput" id="status" readonly /> </td>
</tr>
</code></pre>
<p>Im trying to get value of 'input id=invoiceNo' when I click to 'input id=status' using following code</p>
<pre><code>var invno = $(this).closest('tr td:nth-child(2) input').val();
alert(invno);
</code></pre>
<p>It alerts 'undefined'</p>
<p>so how to solve this?</p>
| jquery | [5] |
5,542,066 | 5,542,067 | Python Odd number maker | <p>python function <code>nthOddDigits</code>, which takes a positive integer x and returns the nth number that only has odd digits 1,3,5,7,9,11, 13, 15, 17, 19, 31 etc. <code>nthOddDigits(0)</code>returns 1, etc. </p>
<pre><code>def nthOddDigits(x):
if x % 2 == 0:
return x + 1
else:
return x;`
</code></pre>
<p>This returns odd numbers if inputted number is even. However, it doesn't check if all the digits are odd. example <code>nthOddDigits(20)</code> returns 21 which is odd but all the digits aren't odd. Thanks!</p>
| python | [7] |
5,264,403 | 5,264,404 | jQuery remove larger scope? | <p>If I have an element nested as:</p>
<pre><code><ul>
<li><img src="/blah.jpg" class="removeme" /></li>
<li><img src="/ole.jpg" class="keepme" /></li>
</ul>
</code></pre>
<p>How do I go about removing the entire list containing the img class that has <code>removeme</code>?
I've been able to get to</p>
<p>alert($(containername).children('ul').children('li').children().hasClass("removeme"))</p>
<p>returns true but I can't seem to remove the entire <code><li></li></code> (and <strong>not</strong> only the img).</p>
<p>Thanks in advance!</p>
| jquery | [5] |
2,315,448 | 2,315,449 | best php method of getting images from a url and saving? | <p>I want to allow users to put in am img url instead of uploading an image, the image would then go through my thumbnailing class.</p>
<p>Is file_put_contents the best method?</p>
| php | [2] |
249,027 | 249,028 | JQuery tab and JScrollPane combination is not working properly | <p>I'm using a jQuery tab and inside the I've used a jScroll Pane, tab code is below</p>
<pre><code>$(function(){$('.tabs').each(function(){var currentTab, ul=$(this);$(this).find('a').each(function(i){
var a=$(this).bind('click',
function(){
if(currentTab){
ul.find('a.active').removeClass('active');
$(currentTab).hide();
}
currentTab=$(this).addClass('active').attr('href');
$(currentTab).show().jScrollPane();
return false;
}
);
$(a.attr('href')).hide();});});});</script>
</code></pre>
<p>but initially my first tab is not showing, but the first tab should show initially. <strong>Can any body solve this?</strong></p>
| jquery | [5] |
6,288 | 6,289 | MediaLauncher on emulator(virtual device) | <p>Is it possible to play and record speech on android emulator? or it must require physical device?</p>
| android | [4] |
1,798,393 | 1,798,394 | Swap image src if screen width <= 699 | <p>I have two images "image-big.jpg" and "image-small.jpg" I want to via javascript detect if screen width <= 699 and change the SRC of my image with class="imageswap" from image-big.jpg to image-small.jpg.</p>
<p>So basically if they are on a portable device it will display the smaller image.</p>
<p>I am novice at best with javascsript and any help is gratefully appreciated!</p>
| javascript | [3] |
3,135,482 | 3,135,483 | referencing class variable to a local variable | <p>why do some people make a new reference in method to a field variable?</p>
<pre><code>public class Foo {
int mFoo[] = {1, 2, 3};
void method() {
int foo[] = mFoo; // WHY not just use mFoo?
print(foo[0]); // WHY not just use mFoo?
}
}
</code></pre>
| java | [1] |
4,650,676 | 4,650,677 | Spritesheet vs map of individual sprites, Android performance | <p>Currently I have all of my sprites as individual images, 186 bitmaps in all but not all of them are used in each level. So, when a level is loading, only the sprites needed for that level are loaded into a hashmap (typically about 40-80). When scrolling over my tilemap, I simply reference these bitmaps in the hashmap to draw on the canvas</p>
<p>Initially this seemed like the simplest approach so it's what I went with. That said, is there any reason to consider using sprite sheets instead? If so, what would the advantages be? Using sprite sheets seems to be very popular from what I have gathered on the internet, but i'm not sure why, or why it would be better than what I am currently doing.</p>
<p>Thanks for any thoughts</p>
| android | [4] |
57,573 | 57,574 | Java Tree Debugging | <p>I am trying to implement a method to count all nodes of a tree from the root down. Basically I count the root then add the length of each of the roots child lists. </p>
<pre><code> public int size()
{
int count = 1; //count the root node
for (int i = 0; i < root.getChildren().size(); i++){
count += (root.getChildren().get(i)).length() + 1;
}
return count;
}
</code></pre>
<p>This is the solved solution.</p>
| java | [1] |
3,148,832 | 3,148,833 | Add HTML in ItemTemplate from a code behind | <p>I have a repeater control that lists 10 records from a database.
What I want to do is to divide that 10 records in two columns, and I don't know how to do that.<br>
The problem is that I can't use <%# if (Container.ItemIndex == 0) %>.<br>
I tried to use ItemDataBound to manipulate the data, but I don't know how to make repeater control to display generated data back to the browser.</p>
<p>Any help or idea will do.<br>
Hope you understood what I was going to say.<br>
Thanks.</p>
| asp.net | [9] |
4,913,568 | 4,913,569 | How to redirect to the another activity when progress dialog dismiss in android | <p>i am new in android development and i have one problem with redirect the activity when the progress dialog dismiss.</p>
<p>I am creating application with help of progress dialog box.i want to redirect the activity when the progress bar dismiss at that time i want to redirect another activity.i search many but i cant get the proper ways.</p>
<p>so please provide me any example,or any sample code so that i can get my requirement. </p>
| android | [4] |
980,162 | 980,163 | JavaScript onkeyup camelcase vs lowercase | <p>I do not seem to find what version of a "onkeyup" is correct:</p>
<p>camelcase: <strong>onKeyUp</strong></p>
<p>or </p>
<p>lowercase: <strong>onkeyup</strong></p>
<p>[UPDATE] <a href="http://www.w3.org/TR/html4/intro/sgmltut.html" rel="nofollow">http://www.w3.org/TR/html4/intro/sgmltut.html</a> mentions: </p>
<p>"Attribute names are always case-insensitive."</p>
| javascript | [3] |
2,532,057 | 2,532,058 | preg_replace all spaces | <p>I'm trying to replace all spaces with underscores and the following is not working:</p>
<pre><code>$id = "aa aa";
echo $id;
preg_replace('/\s+/', '_', $id);
echo $id;
</code></pre>
<p>prints</p>
<pre><code>aa aaaa aa
</code></pre>
| php | [2] |
5,801,332 | 5,801,333 | C# - Filesystemwatcher to enable Timer | <p><strong>Hello All,</strong> </p>
<p>//Pleas i have a simple Problem. I need, when Filesystemwatcher sees the File -after fsw start the Timer for Closing Application (Application will be Closed after 2 second, when is file created)// </p>
<p><strong>Thank you user "Never Quit" *</strong></p>
<p>Finaly i Have this "easy" Code :-) </p>
<pre><code> public partial class Form1 : Form
{
System.Timers.Timer casovac = new System.Timers.Timer();
int totalSeconds = 0;
public Form1()
{
InitializeComponent();
casovac.Interval = 1000;
casovac.Elapsed += new System.Timers.ElapsedEventHandler(cas_elapsed);
}
void cas_elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
totalSeconds++;
if (totalSeconds == 3)
{
casovac.Stop();
Application.Exit();
}
}
private void Form1_Load(object sender, EventArgs e)
{
FileSystemWatcher fsw = new FileSystemWatcher();
fsw.Path = Application.StartupPath + "\\OUT\\";
fsw.Filter = "file.exe";
fsw.IncludeSubdirectories = true;
fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
fsw.Changed += new FileSystemEventHandler(fsw_changed);
fsw.Created += new FileSystemEventHandler(fsw_changed);
fsw.EnableRaisingEvents = true;
}
private void fsw_changed(object source, FileSystemEventArgs e)
{
casovac.Start();
}
}
</code></pre>
<p>}</p>
<p>But Thank you All ;-)</p>
| c# | [0] |
3,019,899 | 3,019,900 | String difference with new additions and deletions | <p>I want to find the difference between two strings in java. The difference should be close to any file comparison tools. I have used longest common subsequence algorithm but still it is not pointing the exact expected difference. Any help with this regard will be much appreciated.</p>
| java | [1] |
2,644,389 | 2,644,390 | Distributing a prize evenly within a lottery system | <p>Whats the best way to distribute a number evenly across "three people?" for instance let's say I have 300 of something each person gets 100 but then if I have 2 of something then the first two people get 1 while the third person is out of luck. What would be the quickest way to do this? Sometimes that 300 number will be as high as 2,000,000 and I'm not really sure if a for() loop is the best solution for this?</p>
| php | [2] |
4,848,179 | 4,848,180 | How to declare an array of different data types | <p>I am working on arrays in java and I have got a question.
I know that an array in java is a collection of similar data types, as shown below</p>
<pre><code>int[] x = new int[]{1,2,3};
</code></pre>
<p>Above declaration can be read as an Integer array which is a collection of integer types.</p>
<p>Consider this</p>
<pre><code>Object[] x = new Object[]{1,2,3,"srk"};
</code></pre>
<p>Here, can I say that above is an array which is a collection of dis-similar data types.
Or<br>
It's an Object array of similar data types i.e.., objects. </p>
<p>I am muddled and skeptical about this.
In java, is it possible to create an array or any sort of collection which can hold different data types?</p>
| java | [1] |
3,731,867 | 3,731,868 | Can't get js-model to work with localStorage or at all | <p>I am using Sammy and js-model on a small project and can't get js-model to actually work.</p>
<p>Here is my js-model model:</p>
<pre><code>var Color = Model('color', function(){
this.persistence = Model.localStorage;
});
</code></pre>
<p>Here is a route from the app that adds a new entry to the Color model. It doesn't seem to save the color entry to localStorage. When the route changes back to #/colors, there are no entries in the Color model.</p>
<pre><code>this.get('#/colors/add', function(){
var color_name = prompt('Color Name');
var color_hex = prompt('Color Hex');
var color = new Color();
color.attr('color_name', color_name);
color.attr('color_hex', color_hex);
color.save();
this.redirect('#/colors');
});
</code></pre>
<p>and finally, here is the #/colors route:</p>
<pre><code>this.get('#/colors', function(){
var context = {};
context.colors = Color.all();
load_template('assets/templates/pages/swatch.template', context, function(template, data){
$el.html(template(data));
});
});
</code></pre>
<p>Any advice? I am using the latest version of Chrome BTW.</p>
| javascript | [3] |
3,052,076 | 3,052,077 | what is difference between platform-tools and Sdk tools? | <p>I can't get the difference between Android platform-tools and and Android SDK tools.
can any one give my a brief?</p>
| android | [4] |
3,182,437 | 3,182,438 | php assigning by reference,passing by reference | <p>I understand there is <em>assigning by reference</em> (<code>$b = &$a</code>) and <em>passing a variable by reference</em> <code>function foo( &$var )</code></p>
<p>I don't understand how this works: <code>return($var & 1) & return(!($var & 1))</code> ? I saw this fragment <a href="http://www.php.net/manual/en/function.array-filter.php" rel="nofollow">here</a>.</p>
<pre><code><?php
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}
function even($var)
{
// returns whether the input integer is even
return(!($var & 1));
}
$array1 = array(1, 2, 3, 4, 5);
$array2 = array(6, 7, 8, 9, 10, 11, 12);
print_r(array_filter($array1, "odd"));
// Array ( [0] => 1 [2] => 3 [4] => 5 ) //1,3,5 ..odd
echo "<br>";
print_r(array_filter($array2, "even"));
//Array ( [0] => 6 [2] => 8 [4] => 10 [6] => 12 ) 6,8,10,12...even
// I tested with these variables
echo "<br><br>";
$var=22;
echo(odd($var)); //prints 0
var_dump(odd($var)); //int 0
$var=11;
echo (even($var)); //prints nothing
var_dump(even($var));//boolean false
?>
</code></pre>
| php | [2] |
2,112,531 | 2,112,532 | How to add class .selected dynamically to selected element here? | <p>In this example . By clicking on thumbnail , big images is getting changed. I want to add border to selected thumbnail.</p>
<p>see example here <a href="http://jsfiddle.net/Qhdaz/2/" rel="nofollow">http://jsfiddle.net/Qhdaz/2/</a></p>
<p>HTML</p>
<pre><code><div id="big-image">
<img src="http://lorempixel.com/400/200/sports/1/">
<img src="http://lorempixel.com/400/200/fashion/1/">
<img src="http://lorempixel.com/400/200/city/1/">
</div>
<div class="small-images">
<img src="http://lorempixel.com/100/50/sports/1/">
<img src="http://lorempixel.com/100/50/fashion/1/">
<img src="http://lorempixel.com/100/50/city/1/">
</div>
</code></pre>
<p>CSS</p>
<pre><code>.small-images a, .big-images a {display:inline-block}
.small-images a.selected {border:1px solid red}
</code></pre>
<p>Current jQuery code</p>
<pre><code>$(function(){
$("#big-image img:eq(0)").nextAll().hide();
$(".small-images img").click(function(e){
var index = $(this).index();
$("#big-image img").eq(index).show().siblings().hide();
});
});
</code></pre>
| jquery | [5] |
1,367,871 | 1,367,872 | Should I test if an element exist before doing anything to it? | <p>Let's say I had the following HTML and Javascript. Here, there is only 1 div on the page, but at any given time, there could be a total of 2 divs (dynamically inserted). </p>
<p>In jQuery, should you first test to see if an element exists before doing anything to it, especially if you know there's a chance it might not be present? </p>
<p>Should I test it with <code>if (('#div2).length > 0)</code>? </p>
<p>Or should I just let jQuery figure it out? I know if doesn't exist, jQuery is smart enough to know the element isn't there, so it won't do anything to it nor would it throw an error. But is it better to first test to see if it exist? Best practice maybe or is there a performance difference?</p>
<p><strong>HTML:</strong></p>
<pre><code><div id="div1"></div>
</code></pre>
<p><strong>Javascript:</strong></p>
<pre><code>$('#div1').text('Hello World!');
/*
Should I first test and see if this div exists?
With if (('#div2').length > 0)
Or leave it as is and let jQuery handle it
*/
$('#div2').text('Should I have first tested to see if this div existed?');
</code></pre>
| jquery | [5] |
519,663 | 519,664 | How is fragment advantage over using instead of view in android | <p>can anybody tell how is fragment advantage over using instead of view in android </p>
<p>Thanks</p>
| android | [4] |
5,857,342 | 5,857,343 | Windows Service speed | <p>I have a issue regarding two timers in Windows Service
The second TimerLimit is never executed.
I have set up two timers because i need one to check to parse some email and i need it to do constantly while second one just if something happens after having reading emails. I have an impression they are in conflict.
Is it possible because the first timer is too fast ?
any suggestion to solve this issue ?
Thank you in advance </p>
<pre><code> protected override void OnStart(string[] args)
{
stop = false;
ParseEmail.DeleteFiles();
timer = new Timer(200);
timer.Elapsed += new ElapsedEventHandler(ExecuteService);
timer.Enabled = true;
timerLimit = new Timer(20000);
timerLimit.Elapsed += new ElapsedEventHandler(ExecuteServiceLimit);
timerLimit.Enabled = true;
}
protected override void OnStop()
{
stop = true;
}
private void ExecuteService(object source, ElapsedEventArgs e)
{
if (stop)
{
return;
}
try
{
if (ParseEmail.isNotUse)
{
ParseEmail.isNotUse = false;
ParseEmail.ParseValues();
}
}
catch (Exception exp)
{
ParseEmail.isNotUse = true;
Console.WriteLine("Exception: {0}", exp.ToString());
}
}
private void ExecuteServiceLimit(object source, ElapsedEventArgs e)
{
if (stop)
{
return;
}
try
{
ParseEmail.CheckLimitOrders();
}
catch (Exception exp)
{
Console.WriteLine("Exception: {0}", exp.ToString());
}
}
}
</code></pre>
<p>}</p>
| c# | [0] |
989,796 | 989,797 | PHP script not echo'ing logs in real time - Was working on my other server | <p>I wasn't sure how to title this thread, sorry.</p>
<p>I have a script that processes some logs and I <code>echo</code> a lot of debug information as the process goes. Since moving to the new server, it seems that the script hangs for 30 odd seconds, then spits out all the logging, then hangs again for 30 odd seconds and the process continues.</p>
<p>This is really odd behavior and I don't know where to start. Its like it isn't processing the file line by line but in blocks ...</p>
<p>PHP version is 5.1.6 on a CentOS running plesk. (My old CP was CPanel)</p>
<p>Any ideas?</p>
<p>EDIT: Simple example of my issue - Running this code:</p>
<pre><code>for ($i=0; $i<100; $i++) {
echo "test $i";
sleep(1);
}
</code></pre>
<p>the script will hang for 100 seconds, then print out all the "test 1" ect. Sleep is required in my main script and on the other server just echoed the values in turn.</p>
<p>EDIT2: Have tried setting output_buffering = 0 and implicit_flush = On and didn't help.</p>
| php | [2] |
2,317,581 | 2,317,582 | Java library to convert source to code model | <p>Is there a java library that converts source code into some kind of a code model? Preferably a <code>javax.lang.model.element.TypeElement</code>?</p>
| java | [1] |
4,040,219 | 4,040,220 | Get headers sent in urllib2 http request | <p>I know how to get the headers RECEIVED</p>
<pre><code>resp = urllib2.urlopen('http://www.google.com')
print resp.info()
</code></pre>
<p>But how do you access the headers SENT to 'http://www.google.com' ?</p>
<p>I usually use wireshark to analyze and see what is actually being sent, but I'd like to have access to this information in my script.</p>
| python | [7] |
5,888,760 | 5,888,761 | The "is" keyword: there a difference in these methods? | <p>Not really sure about the <code>is</code> keyword, but I <em>think</em> these two are the same. Can anyone confirm this?</p>
<pre><code>public bool Equals(Object obj)
{
if (obj == null) return false;
MyType t = (MyType)obj;
if (t == null) return false;
return true;
}
</code></pre>
<p>and the other is...</p>
<pre><code>public bool Equals(Object obj)
{
return obj is MyType;
}
</code></pre>
| c# | [0] |
3,173,300 | 3,173,301 | How do you shift the tab positions dynamically with jQuery Accordian? | <p>In Accordion jQuery functionality, how do you shift the tab positions dynamically using left, right, top and bottom without using UI plugin?</p>
<p>Example: There is a drop down with four values these are 1.top 2.bottom 3.left and 4.right</p>
<pre><code>If i click on top - Tabs should display top to bottom direction
If i click on bottom - Tabs should display bottom to top direction
If i click on left - Tabs should display left to right direction
If i click on left - Tabs should display right to left direction
</code></pre>
| jquery | [5] |
3,648,607 | 3,648,608 | C# Textbox to listbox | <p>I have a listbox being populated from textbox entry.</p>
<pre><code>{
textBox2.Text.Replace("\r\n", "\r");
listBox1.Items.Add(textBox2.Text);
}
</code></pre>
<p>Whats happening is the textbox is being populated in a single column format, when it moves over to the listbox the \r\n gets changed to the black squares and does populate the same as it looked in the textbox.</p>
| c# | [0] |
866,265 | 866,266 | What is the proper way to initiate a JavaScript function on load in a CMS? | <p>I need to call a function on page load. Typically this would be handled with a body onload call, however I'm in a CMS that reuses the body tag on multiple pages. I only need the script to run on a single page. Is there a next-best-location to initiate an onload function?</p>
<p></p>
| javascript | [3] |
573,242 | 573,243 | Open activity from shuffled list view | <p>So basically I want this list view to be shuffled so it is always random. But each one needs to open up its own activity and be constant no matter where it is in the list view (so I'm pretty sure I can't use position.) So I tried using the (TextView) view).getText() and it isn't reading it as it does in the Toast. Any ideas?</p>
<pre><code>public class Bands extends ListActivity{
int numBands;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ArrayList<String> bands = new ArrayList<String>();
bands.add(new String("Band0"));
bands.add(new String("Band1"));
bands.add(new String("Band2"));
Collections.shuffle(bands);
setListAdapter(new ArrayAdapter<String>(this, R.layout.item_list, bands));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// When clicked, show a toast with the TextView text
Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
Toast.LENGTH_SHORT).show();
if( ((TextView) view).getText() == "Band0"){
Intent i = new Intent(Bands.this, Audio.class);
i.putExtra("Band", 0);
startActivity(i);
}
}
});
}
</code></pre>
<p>}</p>
<p>Anyone know a way to read the number order the shuffle creates? Cause that could be a way if someone knows how. Thanks and any help is appreciated.</p>
| android | [4] |
4,524,726 | 4,524,727 | creating multiple divs with javascript | <p>how can i create a div and show it with jquery and also how to create multiple divs with multiple ids and show it in series...........</p>
<p>i want to create multiple div popups one after antoher and want to show if user has any notifications one after other</p>
| jquery | [5] |
5,118,686 | 5,118,687 | Is it possible to force 3G on Iphone without jailbreaking? | <p>I've heard mixed results regarding forcing the iPhone to 3G operation only (so that it doesn't switch between 3G and Edge).. this is supposed to improve call consistency (read: fewer dropped calls - which i seem to have a lot of problems with).</p>
<ol>
<li>does anyone know how to do this without jailbreaking?</li>
<li>otherwise, any tips on getting better reception/reducing dropped calls?</li>
</ol>
| iphone | [8] |
5,880,189 | 5,880,190 | Android layout about multiple support screens | <p>i have attached some images using margin and padding. i have done this on samsung galaxy but
on motorola mile stone, the images are disturbed.</p>
<p>i have already used <code><support_screens></code> in manifest... but it is not working</p>
| android | [4] |
3,675,197 | 3,675,198 | Receive input in specific time | <p>I'm writing a testing system and i all i want to do is to count how many seconds had user spent on this question. i.e. i print question(standard System.out.println), then wait 5 seconds and if within these 5 seconds user answered(through standard input), i want to keep this value.
If user hasnt provided an answer in 5 seconds, it must skip this question and continue.
The problem is - im reading user answers via Scanner object, and something like in.nextInt() is uncontrollable, i suppose.</p>
<p>How can i solve this problem? Here is fragment of my code without that functionality, can you give me some hints what to add?</p>
<pre><code> public void start() {
questions.prepareQuestions(numQuestions);
Scanner in=new Scanner(System.in);
boolean playerIsRight=false,botIsRight=false;
int playerScore=0,botScore=0;
for (int i = 0; i < numQuestions; i++) {
questions.askQuestion(i);
System.out.print("Your answer(number): ");
playerIsRight=questions.checkAnswer(i,in.nextInt()-1); //in.nextInt() contains the answer
botIsRight=botAnswersCorrectly(i + 1);
if(playerIsRight){ playerScore++; System.out.println("Correct!");}
else System.out.println("Incorrect!");
if(botIsRight) botScore++;
System.out.print("\n");
}
if(botScore>playerScore) System.out.println("Machine won! Hail to the almighty transistors!");
else if(playerScore>botScore) System.out.println("Human won! Hail to the power of nature!");
else System.out.println("Tie. No one ever wins. No one finally loses.");
}
</code></pre>
| java | [1] |
1,042,311 | 1,042,312 | enter "finish" state when not calling finish() causing BadTokenException | <p>I have a very weird behaviour, which I cant find its cause.
the last thing I do on onCreate() is to call a certain method.
in that method i use<br>
<strong>progressDialog = ProgressDialog.show(this, null, "Registering with Moish'd! server", true, false);</strong>.<br>
on the first run i get BadTokenException: Unable to add window on the <em>progressDialog</em> line.
the second run it passes it.<br>
I read in forums that if the activity is in the middle of "finish" process than it might cause such an excetion.<br>
after a long debugging tests, i tried asking for isFinishing(). something odd accoured - before calling the method, <strong>isFinishing() returns false</strong>.in the first line of the method I ask again and now <strong>isFinishing() returns true</strong>.
how can it be ?!? in the last line before entering a method its not "finishing" and in the first line of the method its suddenly "finishing", when NOTHING is happening in between (certainly not calling finish()). anyone ?!?</p>
| android | [4] |
5,337,006 | 5,337,007 | TypeError: argument of type 'NoneType' is not iterable in python | <p>I am trying to get the VM size of a running process and using the following simple script. Here initially I am trying to get the reference of that process. But getting the error as -- </p>
<pre><code>if "DomainManager" in c:
TypeError: argument of type 'NoneType' is not iterable
</code></pre>
<hr>
<pre><code>import wmi
computer = wmi.WMI ()
for process in computer.Win32_Process ():
c = process.CommandLine
if "DomainManager" in c:
print c
</code></pre>
<p>Would you please let me know the reason.</p>
<p>Thanks,
Rag</p>
| python | [7] |
4,992,289 | 4,992,290 | Calling functions from main() in c++ | <p>I came across a program with 10 header and 10 source files. I read in my text book that the functions are called from main. But how can I pass data to so many functions from main()?</p>
| c++ | [6] |
3,219,852 | 3,219,853 | sessions in asp.net? | <p>i am developing a videos website in that one fo the web page where videos are playing where i place the option sending mail to friends where link of the video will go. Problem is the videos play on videoid which is in session. so when i send mail that is link how can i send videoid which is in session how can i send session["videoid"]. can u help me thank you</p>
| asp.net | [9] |
467,970 | 467,971 | android-toolbox showcase crashing | <p>I'm an android developer. I just imported latest zip for Android toolbox, and tried to run the showcase:
When the app runs I get the following error. I am on Android 4.03 </p>
<pre><code>8-02 14:19:25.534: E/AndroidRuntime(32732): java.lang.NoClassDefFoundError: com.bugsense.trace.BugSenseHandler
08-02 14:19:25.534: E/AndroidRuntime(32732): at de.viktorreiser.androidtoolbox.showcase.AndroidToolboxShowcaseActivity.onCreate(AndroidToolboxShowcaseActivity.java:68)
</code></pre>
| android | [4] |
2,831,279 | 2,831,280 | How to add PayPal library Code with my iPhone application? | <p>How to add PayPal library Code with my iPhone application? </p>
| iphone | [8] |
1,038,081 | 1,038,082 | What is the relationship between Enum and Enumeration, if any | <p>I wonder what is a formal connection if any between <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Enumeration.html" rel="nofollow">Enumeration interface</a> in Java and an <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html" rel="nofollow">Enum construct</a>?</p>
| java | [1] |
3,456,416 | 3,456,417 | Store Bitmap from imageview to SD | <p>i am trying to save a bitmap that is displayed on an imageview. what i understand is that i need to </p>
<ol>
<li>convert bitmap to stream.</li>
<li>write that stream to a file on the sd card.</li>
</ol>
<p>here is what i have done </p>
<pre><code>try {
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(path, "name.png");
FileOutputStream out = null;
if (file.exists()) {
// do something awesome
} else {
out = new FileOutputStream(file);
currentimage.compress(Bitmap.CompressFormat.PNG, 100, out);
}
out.close();
} catch (Exception e) {
e.printStackTrace();
}
</code></pre>
<p>I am trying to change the file name saved i understand it will go in the FileOutputStream but not quite sure </p>
| android | [4] |
1,455,017 | 1,455,018 | What is the hash tag used for in JavaScript? | <p>I'm not talking about in the URL. I know what that does. I'm talking about how it's used in actual code.</p>
<p>After trying to assign it as a variable, I realized that it's reserved, but I don't know what for.</p>
| javascript | [3] |
5,450,798 | 5,450,799 | 'setInterval' vs 'setTimeout' | <p>What is the main difference between </p>
<p><strong><a href="https://developer.mozilla.org/En/window.setInterval">setInterval</a></strong></p>
<p>and </p>
<p><strong><a href="https://developer.mozilla.org/en/window.setTimeout">setTimeout</a></strong></p>
<p>in JavaScript? </p>
| javascript | [3] |
4,034,318 | 4,034,319 | Differences between static class and instance class with private constructor | <p>Although a static class has only one instance and can't be instantiated, a class with a private constructor can't be instantiated (as the constructor can't be seen), so every time you call this class, this is the same one instance?</p>
<p>Factory classes always follow the last convention (instance class with private constructor). Why is this?</p>
<p>Thanks</p>
| c# | [0] |
2,467,447 | 2,467,448 | Use JavaScript to load an xml file while form authentication expired | <p>I am using javascript to load an xml file in my .aspx file. This xml file is accessible only to authenticated users. When a user's form authentication ticket expires, the instead of the intended xml, my Login.aspx is loaded. I want to redirect the user to the Login.aspx.</p>
<p>I have no clue what is the best way to handle this. The load function is from a 3rd part javascript and it does not return any data or status. I am thinking to add some code in Application_EndRequest method, but don't know whether this is a good idea. I also don't know how to redirect to Login.aspx in between the request/response cycle.</p>
| asp.net | [9] |
132,115 | 132,116 | How to find programatically that hard keyboard is popped out in android device | <p>I am an android developer. I am developing one application for a samsung device which supports hard keyboard. In this application, I have to change the orientation of my application only when hard keyboard is popped out as well as Editview is focused.</p>
<p>Can anyone please help me to find the solution of it.</p>
<p>Thanks in advance.</p>
| android | [4] |
2,411,161 | 2,411,162 | Can not remove my activity from the Stack | <p>I know this has been asked. I browsed and tried whatever I have found but for some reason, it is not working for me.</p>
<p>my code is as follow</p>
<pre><code>runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(LoginActivity.this, HomepageActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
</code></pre>
<p>I can not use</p>
<p>android:noHistory="true"</p>
<p>as my activity in some circumstances has to stay on the stack.</p>
<p>So, i have the following behaviour. I log in into my app with the LoginActivity, then it goes to the HomepageActivity, but if I press the Back bottom, the LoginActivity pops back again, which I do not want.</p>
<p>Any idea how I could fix this.</p>
| android | [4] |
957,956 | 957,957 | simple instantiations of python classes | <p>Can you please explain why 'hello world' isn't returned below? What do I need to modify for it to be expressed properly when called? Thanks.</p>
<pre><code>>>> class MyClass:
... i=12345
... def f(self):
... return 'hello world'
...
>>> x=MyClass()
>>> x.i
12345
>>> x.f
<bound method MyClass.f of <__main__.MyClass instance at 0x060100F8>>
</code></pre>
| python | [7] |
5,764,965 | 5,764,966 | a JS closure query | <p>I am a C++ ( Qt ) developer and know JS a bit. I am not able to understand a part of below code. Can you please help me with this?</p>
<pre><code>function augment(withFn) {
var name, fn;
for (name in window) {
fn = window[name];
if (typeof fn === 'function') {
// **Not able to understand below code.**
window[name] = (function(name, fn) {
var args = arguments;
return function() {
withFn.apply(this, args);
fn.apply(this, arguments);
}
})(name, fn);
// **In above code I understood everything else except this last line.
// Why whole function is in circular bracket? Why it ends with (name, fn);
// What is the meaning of this?
}
}
}
augment(function(name, fn) {
console.log("calling " + name);
});
</code></pre>
| javascript | [3] |
1,971,933 | 1,971,934 | simulation of static class in java | <p>What do you think of the following way to simulate a static class in java?
You can add non static methods but you wouldn't be able to call them.</p>
<pre><code> /**
* Utility class: this class contains only static methods and behaves as a static class.
*/
// ... prevent instantiation with abstract keyword
public abstract class Utilities
{
// ... prevent inheritance with private constructor
private Utilities() {}
// ... all your static methods here
public static Person convert(String foo) {...}
}
</code></pre>
| java | [1] |
3,304,873 | 3,304,874 | Using insertBefore with the result of $.get | <p>Im trying to make this work with jQuery</p>
<pre><code>var ng = $.get('/static/views/ng.html');
$('#myHeader').insertBefore(ng);
</code></pre>
<p>the ng.html contains this</p>
<pre><code><div id="ng">
<div class="c all"></div>
<div class="f all"></div>
<div class="p all"></div>
</div>
</code></pre>
<p>It doesn't trow any error or so, I figure that it is the $.get that doesn't return a correct object but don't know how to continue.</p>
<p>Any ideas?</p>
<p>Thanks</p>
| jquery | [5] |
3,103,618 | 3,103,619 | C++ behaviour when const | <p>Here's a basic struct (I hope)</p>
<pre><code>struct SomeType {
float a;
float b;
float c;
float d;
SomeType(float, float, float, float);
};
</code></pre>
<p>And source</p>
<pre><code>SomeType::SomeType(float na, float nb, float nc, float nd) : a(na), b(nb), c(nc), d(nd) {}
</code></pre>
<p>The I have a class</p>
<pre><code>struct SomeClass {
static const SomeType v;
SomeClass();
};
</code></pre>
<p>When I then initialise it</p>
<pre><code>const SomeType SomeClass::v(0,0,0,0);
</code></pre>
<p>My vales become inf or nan or -nan. Anyone seen this before, or know how to fix it?</p>
<p>Edit: Fixed type</p>
<p>Edit: This is quite close to my original example. I multiple classes with similar structure to SomeClass.</p>
| c++ | [6] |
669,730 | 669,731 | How do I make an "automatic updater" for my desktop java application? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/305461/automatic-updates-of-java-desktop-application">“Automatic updates” of java (desktop) application</a> </p>
</blockquote>
<p>Nowadays it's common for applications to check online if there is a more recent version of the application, and download that.</p>
<p>But how does one create such a solution for a java desktop application? </p>
<p>Where do I begin? How does it work?</p>
| java | [1] |
2,134,287 | 2,134,288 | g++ installation error? | <p>i have tried the following command but i am asked to enter the offical amd64 dvd.</p>
<p>the command i entered is</p>
<pre><code> sudo apt-get install build-essential
</code></pre>
<p>and this is the program i want to run</p>
<pre><code>#include <iostream>
using namespace std;
int main()
{
bool a = ( 10 > 5);
bool b = ( 3*3 = 12):
if( a && b)
{
cout << "One of them evaluates to false"<<endl;
}
}
</code></pre>
| c++ | [6] |
4,790,320 | 4,790,321 | Recording playback and mic on IPhone | <p>In iPhone SDK 4.3 I would like to record what is being played out through speaker via Remote IO and also record the mic input. I was wondering if the best way is to record each separately to a different channel in an audio file. If so which apis allow me to do this and what audio format should I use. I was planning on using ExtAudioFileWrite to do the actual writing to the file.</p>
<p>Thanks</p>
| iphone | [8] |
1,516,196 | 1,516,197 | How do I stop a Python function from modifying its inputs? | <p>I've asked almost this just before now, but the fix doesn't work for x = [[]], which I'm guessing is because it is a nested list, which is what I will be working with.</p>
<pre><code>def myfunc(w):
y = w[:]
y[0].append('What do I need to do to get this to work here?')
y[0].append('When I search for the manual, I get pointed to python.org, but I can\'t find the answer there.')
return y
x = [[]]
z = myfunc(x)
print(x)
</code></pre>
| python | [7] |
2,852,248 | 2,852,249 | xml/rss file creater | <pre><code><channel>
<title>Company</title>
<link>http://www.ndroid360.com/companypms/index.php/main_con</link>
<description>Companypms - By Keyur Modi </description>
<language>en-us</language>
<image>
<title>Company</title>
<url>http://www.ndroid360.com/companypms/public/admin/dashboard/images/keyur.jpg</url>
<link>http://www.ndroid360.com/companypms/index.php/main_con</link>
<width>90</width>
<height>36</height>
</image>
<item>
<title>Project Add</title>
<link>http://www.ndroid360.com/companypms/index.php/main_con</link>
<description>
OK, modi sarkar
</description>
</item>
<item>
<title>A Post Title</title>
<guid isPermaLink="true">http://www.mydomain.com/file-location/</guid>
<link>http://www.ndroid360.com/companypms/index.php/main_con</link>
<pubDate>Wed, 30 Apr 2009 23:00:00 +1100</pubDate>
<description><![CDATA[ <p>This is a brief summary of the post, so tempting that noone will be able to resist clicking through.</p> ]]></description>
</item>
</channel>
</code></pre>
<p>I want to put an image after second <code><item></item></code>-tag. What can I do?</p>
| php | [2] |
3,661,133 | 3,661,134 | OnTouchListener on Activity never calls | <p>I used this code, but when i click on activity at runtime, it never hits in OnTouch() method. Can someone guide me what i am doing wrong? Should i need to setcontentview of this activity? Actually i want the coordinates of activity where user touch during execution.</p>
<pre><code>public class TouchTestAppActivity extends Activity implements OnTouchListener
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//setContentView(R.layout.touch);
}
@Override
public boolean onTouch(View arg0, MotionEvent arg1)
{
// TODO Auto-generated method stub
String test = "hello";
}
}
</code></pre>
| android | [4] |
2,819,290 | 2,819,291 | How to ensure all async function return before doing callback | <p>I have this code:</p>
<pre><code>var submitOrder = function (event) {
var ids = $('.selected').map(function () { return $(this).data('id'); }).get();
getURLS(ids, function(res) {
console.log(res);
});
};
var getURLS = function (ids, callback) {
var users = new Object();
var num = ids.length - 1;
var retif = function(){
console.log('hitting with ' + num);
if (num == 0){
callback(users);
} else {
num--;
}
}
for(id in ids) {
var query = FB.Data.query('SELECT src_big FROM photo WHERE pid in (SELECT cover_pid FROM album WHERE owner=\'' + ids[id] + '\' AND type=\'profile\')');
query.wait(function (rows) {
users[ids[id]] = rows[0].src_big;
retif();
});
}
}
</code></pre>
<p>However, when I examine the console logs in my browser, I see the correct number of API calls made, but only one result is in the Object.</p>
<p>Is there some "better" way that I can write this that would ensure a correct output?</p>
| javascript | [3] |
353,583 | 353,584 | Binding DataGrid with dataset and set columns width | <p>I have DataGrid, this datagrid has a binding with a dataset</p>
<pre><code><asp:DataGrid runat="server" ID="myGrid">
<Columns>
<asp:BoundColumn DataField="MyField1" HeaderText="MyField1"></asp:BoundColumn>
<asp:BoundColumn DataField="MyField2" HeaderText="MyField2"></asp:BoundColumn>
</Columns>
</asp:DataGrid>
myGrid.DataSource = GetMyDataset();
myGrid.DataBind();
</code></pre>
<p>That's work but I see has column all the fields of my dataset + the 2 columns defined.
I'd like see only the columns.</p>
<p>And how set the column width % ?</p>
<p>Any idea ?</p>
<p>Thanks,</p>
| asp.net | [9] |
4,999,121 | 4,999,122 | Is it possible to change document type with JavaScript without page reload? | <p>If I wanted to render whole page again with JavaScript, I would have to possibly change document type without page reloading. Is it possible to change document type with JavaScript or is only realistic choice to reload page and render new document type on server side?</p>
| javascript | [3] |
4,361,689 | 4,361,690 | How do I declare a dynamic array with std::auto_ptr? | <p>I am trying to declare a dynamic int array like below.</p>
<pre><code>int n;
int *pInt = new int[n];
</code></pre>
<p>Can I do this with std::auto_ptr?</p>
<pre><code>I tried something like:
std::auto_ptr<int> pInt(new int[n]);
</code></pre>
<p>But it doesn't compile. </p>
<p>I'm wondering if I could declare a dynamic array with auto_ptr instruct and how. Thanks!</p>
| c++ | [6] |
2,489,308 | 2,489,309 | java : How to deal with an array of values received in this case? | <p>I am working on a Third Party API where, if one symbol is given we will make the request this way as </p>
<pre><code>KIMapi = new KIMapi(symbol);
KIMapi .setType(KIMapi .TIME );
ArrayList list = KIMapi .getData();
Iterator itr = list.iterator();
while(itr.hasNext())
{
system.out.println(itr.next());
// Process it
}
</code></pre>
<p>Now my query is that I may receive an array of Symbols as shown below:</p>
<pre><code>String symbol[] = {"BBW","MAruthi", "S" , "G" };
for (int i = 0;i < symbol.length;i++ )
{
KIMapi = new KIMapi (symbol[i]);
// Do i need to keep all the above code shown above inside this for loop ?
}
</code></pre>
<p>Any guidance will help.</p>
| java | [1] |
3,395,649 | 3,395,650 | python's print function not exactly an ordinary function? | <p>Environment: python 2.x</p>
<p>If <code>print</code> is a built-in function, why does it <strong>not</strong> behave like other functions ? What is so special about <code>print</code> ?</p>
<pre><code>-----------start session--------------
>>> ord 'a'
Exception : invalid syntax
>>> ord('a')
97
>>> print 'a'
a
>>> print('a')
a
>>> ord
<built-in function ord>
>>> print
-----------finish session--------------
</code></pre>
| python | [7] |
5,233,011 | 5,233,012 | Mutating a list while looping | <p>I am trying to loop through a list and mutate the list I'm working on by making a copy. I am getting the following error but am unsure how to fix:</p>
<pre><code> 52 def match_jugglers(list_of_jugglers):
53 while len(list_of_jugglers) > 0:
---> 54 jugglers = list_of_jugglers[:]
55 for juggler in jugglers:
56 for preference in juggler.preferences:
TypeError: sequence index must be integer, not 'slice'
</code></pre>
<p>Any suggestions? Thanks in advance.</p>
<p>UPDATE 1: list_of_jugglers is a deque(), sorry should have mentioned that.
UPDATE 2: Um, so I'm an idiot in thinking I could slice a deque() and make a copy -- was still thinking list in my head (thus the original description). </p>
| python | [7] |
5,666,228 | 5,666,229 | How to hit the URLs automatically and put the received response into a csv file? | <p>I've an .csv file which contains hundreds of URLs. I've to write a PHP script which will read the file then loop through all the URLs.
In the loop each URL should automatically hit(like we type the URL in browser's address bar and press enter button), the response received after hitting the URL has to be written into a new .csv or .txt file in the following way:</p>
<pre><code> Request URL, Response received
</code></pre>
<p>At the end of loop each request URL and its respective response should be written to a .txt or .csv file. The response is surely going to be in the csv format in one liner. So no validation is required while writing the response to the file.
I did lot of search on google on it, but couldn't get the useful solution. Could anyone help me to solve this issue?
Thanks in Advance.</p>
| php | [2] |
5,234,606 | 5,234,607 | passing parameters from one php to multiple php | <p>.I have three php pages:</p>
<p>page1.php
page2.php
page3.php</p>
<p>on page1.php i have this code:</p>
<pre><code><form id="try" method="post" action="page2.php">
Batch: <input id="batch" name="batch" type="text"/><br />
Dept: <input id="dept" name="dept" type="text"><br />
<input type="submit" />
</form>
</code></pre>
<p>on page2.php i am able to use the values inserted on page1.php by simply calling them using <code>$_POST['batch']; and $_POST['dept'];</code></p>
<p>but what i want to do next is to pass the values of batch and dept from page2.php to page3.php. or maybe from page1.php to page2.php since i think it's just the same.</p>
<p>.Help pls! Thanks in adv</p>
<p>@kjy112 - i'm confused, since i am using </p>
<pre><code><form method="post">
</code></pre>
<p>should i be starting my session on page2.php by using the following:</p>
<pre><code>session_start();
$_SESSION['batch'] = $_POST['batch'];
$_SESSION['dept'] = $_POST['dept'];
</code></pre>
<p>and then use</p>
<pre><code>session_start();
$batch = $_SESSION['batch'];
</code></pre>
<p>to use it on page3.php?</p>
| php | [2] |
4,100,321 | 4,100,322 | Changing the upload limit in php | <p>I am developing a CMS where the clients will need to upload files larger than 2mb - up to 10mb at least. I have changed the details in the php.ini file and I cannot see anywhere else that the problem might be. Any help?</p>
<p>Cheers</p>
| php | [2] |
4,556,363 | 4,556,364 | Copy to clipboard in Javascript having hidden input field | <p>I have a span which shows the name of the user like this and a hidden input box which contains username of the user. The input box sits right below the span on UI and has visibility hidden</p>
<pre><code><span> My Name </span>
<input type = "text" class = "hidden" value = "MyUserName">
</code></pre>
<p>What I want is when the user clicks on the visible span and presses Ctrl + C, I want the value of the input box to get copied on the clipboard. (MyUserName in this case). Is there any way I can do this in Javascript? </p>
| javascript | [3] |
4,354,186 | 4,354,187 | Where does class, object, reference variable get stored in java. IN heap or stack? Where is heap or stack located? | <p>I understand that variables of a method are stored in stack and class variables are stored in heap. Then where does the class, objects we create get stored in java</p>
| java | [1] |
3,625,252 | 3,625,253 | How to upload image on Twitter | <p>I want to upload image on Twitter.</p>
<p>please any one help me how we upload image on Twitter.
Please explain or provide code.</p>
<p>Thanks Rockydilse</p>
| iphone | [8] |
2,567,264 | 2,567,265 | iPhone: UIAlertView overlap | <p>Every 10 min I synchronize my app with server, and when something wrong with server, I show UIAlertView. </p>
<pre><code> NSString *alertTitle = @"Sync failed";
NSString *alertMessage = @"Something wrong with server"
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:alertTitle
message:alertMessage
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", @"OK button title")
otherButtonTitles:nil];
[alertView show];
[alertView release];
</code></pre>
<p>If to shoot down server and do not touch phone, in hour there will be 6 Alert Dialogs, and I supposed to close 6 AlertDialogs. How to fix that ? Can AlertView check if its already shown to user or something like that ? Thanks...</p>
| iphone | [8] |
1,522,283 | 1,522,284 | customize elfinder file manager | <p>I am using elfinder file manager in one of my project. I am developing my project in PHP. I am new with using this file manager.</p>
<p>Now, I want to execute an SQL query when file will be uploaded and want to put track of each file uploaded with each user separately. So I am not getting that how to customize this thing.</p>
<p>For Example, I am a user and I have registered. Each user has their separate account and they can upload their files there in his/her account.</p>
<p>Now, suppose I am user and uploading 1 image in my account. So when I am uploading my file. I want to insert that file name, size and all other details with user_id in my database table. So I can manage track of each user uploaded files.</p>
<p>Please any one can help me here for this?</p>
<p>Thanks in ADVANCE</p>
| php | [2] |
2,441,346 | 2,441,347 | C# Check The Width and Height of a Image | <p>I am able to display the picture in the picture box without checking the file size by the following code.</p>
<pre><code> private void button3_Click_1(object sender, EventArgs e)
{
try
{
//Getting The Image From The System
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
Bitmap img = new Bitmap(open.FileName);
pictureBox2.Image = img;
}
}
catch (Exception)
{
throw new ApplicationException("Failed loading image");
}
}
</code></pre>
<p>I want to check the image size for example whether it is 2MB or 4MB before displaying in the picture box.A also want to check the width and height of the image.Thanks in advance</p>
| c# | [0] |
2,945,441 | 2,945,442 | why does creating a local type vector fail | <pre><code>#include <iostream>
#include <vector>
int main()
{
class Int {
public:
Int(int _i) : i(i) {}
private:
int i;
};
std::vector<Int> VI;
}
</code></pre>
<p>I try to compile the above code and got the following error message:</p>
<pre><code>foo.cc: In function 'int main()':
foo.cc:13: error: 'main()::Int' uses local type 'main()::Int'
foo.cc:13: error: trying to instantiate 'template<class _Alloc> class std::allocator'
foo.cc:13: error: template argument 2 is invalid
foo.cc:13: error: invalid type in declaration before ';' token
</code></pre>
<p>Could anyone of you tell me why I can't do things like this in C++? Thanks in advance.</p>
| c++ | [6] |
2,470,462 | 2,470,463 | How to kill all running applications in android? | <p>I want to kill all running applications in android .so for this task , i implemented following code. But it is not working .App still remains in running.</p>
<pre><code>ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
for (RunningAppProcessInfo service : manager.getRunningAppProcesses()) {
Log.i("process name " , service.processName);
android.os.Process.killProcess(service.pid);
}
</code></pre>
<p>So where does i make mistake in code ?
Is there any help ?</p>
| android | [4] |
5,833,821 | 5,833,822 | replace text information | <p>I would like to replace text information in my (#loader) div. I am using two functions show_info() and replace_info().</p>
<pre><code>$('#measure_submit').click(function(){
show_info("Sending params ...");
get_data();
});
function get_data(){
$.ajax({
url: '/controller/view',
data : { ... },
type: 'POST',
typedata: 'text',
success: function(data){
hide_info();
},
beforeSend : function(data) {
replace_info("Loading data ...");
}
});
function show_info(string){
$('#loader').text(string);
$('#info_box').fadeIn(2000);
}
function replace_info(string){
$('#loader').fadeOut(2000);
$('#loader').text(string);
$('#loader').fadeIn(2000);
}
</code></pre>
<p>But I am able to see only the text "Loading data ...". The "Sending params ..." is totally skipped even if there is fadeOut(2000).</p>
<p>I was even trying setTimeout(replace_info("Loading data ..."),4000); but no LUCK.</p>
<p>Anyone knows where is the trouble?
Any help is much appreacited.</p>
<p>Thanks Peter</p>
| jquery | [5] |
4,721,916 | 4,721,917 | RelativeLayout margins inside a ListView are not displayed | <p>I'm currently using a ListView that I fill with a custom adapter with RelativeLayout's. The problem is that the margins are not displayed for the RelativeLayout. </p>
<p>Here is my relative layout declaration : </p>
<pre><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ArticleSnippet"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="6dip"
android:layout_marginTop="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:background="@drawable/background_snippet" >
...
</RelativeLayout>
</code></pre>
<p>The ListView declaration : </p>
<pre><code><ListView
android:id="@+id/ArticleSnippets"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:divider="#fff"
android:dividerHeight="0sp">
</ListView>
</code></pre>
<p>Is there anything special to do to make the margin active inside a ListView ? </p>
<p>Thanks in advance for any help,</p>
<p>Lint (Dusariez JF) </p>
| android | [4] |
4,431,154 | 4,431,155 | Data post differ from Firefox-IE | <p>I'm using jquery to send the code in some <code><pre></code> tags of <a href="http://www.felicepollano.com" rel="nofollow">my blog</a> to an handler, that will replace these with a proper pastebin.com frame containing the formatted code.</p>
<p>I'm using an MD5 hash to map the code chunk to the pastebin corresponding translation in order to have just one paste bin for each code snippet.</p>
<p>Problem is that the string posted seems to change a little between IE and firefox, so I don't have an exactly MD5 codification. For some reason problem appear only on the production server.</p>
<p>The jquery code is this:</p>
<pre><code>$(function() {
$.each($('pre'), function(i, e) {
if (e.lang != '') {
$.ajax({
url: 'pastebin.ashx',
context: $(this),
data: {
data: $(this).text(),
lang: e.lang
},
success: function(t) {
if (t.indexOf('*error*') != 0) {
var h = Math.floor($(this).height() * 1.62) + "px";
$(this).replaceWith("<iframe src='http://pastebin.com/embed_iframe.php?i=" + t + "' style='border:none;width:100%;height:" + h + "'></iframe>")
}
}
});
}
});
});
</code></pre>
<p>Is there some reason the posted data can change from different browsers ?
<strong>EDIT</strong></p>
<p>The problem does not happen with all the IE, same version 9.0.8112.16421 works on a machine, and not with another! I suppose the difference must be in the $(this).text(). Failing version seems to contain the text without carriage returns.</p>
| jquery | [5] |
3,335,186 | 3,335,187 | Jquery switch through color instead of fade | <p>how can i have jquery switch between the array below on an elements font color?</p>
<pre><code>colors1 = ["ffffff", "eeeeff", "ddddff", "ccccff", "bbbbff", "aaaaff", "9999ff", "8888ff", "7777ff", "6666ff", "5555ff", "4444ff", "3333ff", "2222ff", "1111ff", "0000ff"]
</code></pre>
<p>Basically what I'd like to do is have an element fade in and out using this array of colors. I tried using jQuery's animate (animate({opacity:1}, { queue: false, duration: 1500 })), but since we use IE at work 100% of the time, the opacity animation looks very poor in IE6/7. It looks really junky trough the animation and so does fadeIn and fadeOut. I dont have issues with filter as i know to remove it once the animation or fade is complete. I believe the new animation api removes filter as well automatically.</p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.