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,172,898 | 3,172,899 | Store values into an array Android | <p>In android development, is it possible to store values into an array. I want to store id's into an array. Any help is appreciated</p>
| android | [4] |
1,255,618 | 1,255,619 | How to append file after string? php | <p>Ok lets say I have a File called File.txt and it contains </p>
<pre><code>Hello
World
!!!!!
</code></pre>
<p>Ok now I have it so they may Post something to add to the string But it has ot be right under the string "Hello". How would I go about doing that ? </p>
| php | [2] |
4,243,978 | 4,243,979 | Android emulator Output | <p>when i am trying to run my android application at that time
" <code>The application has stopped unexpactadly,Please try again</code>" and force to close application.
it comes every time.
can anyone try to solve this issue?
thanks</p>
| android | [4] |
1,779,155 | 1,779,156 | Android Activity | <p>if i create static button in one activity and use in another activity it shows error as </p>
<pre><code>/*********************************
01-12 19:57:17.030: DEBUG/PhoneWindow(21860):
couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@2f5671b8 has no id.
*************************************/
</code></pre>
<p>my code is ::</p>
<pre><code>public static LoginButton bttn;
findViewById(R.id.login).setOnClickListener(new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
bttn = (LoginButton)findViewById(R.id.login);
startActivity(new Intent(Account.this,Example.class));
}
});
</code></pre>
<p>In 2nd activity i use this static button as</p>
<pre><code>Account.bttn.init(this, mFacebook);
</code></pre>
| android | [4] |
4,301,578 | 4,301,579 | DateTime constructor throws error when the values are OK | <p>This line:</p>
<pre><code>new DateTime(2000, 11, 31, 10, 0, 0)
</code></pre>
<p>throws error: Year, Month, and Day parameters describe an un-representable DateTime.</p>
<p>Why is this happening?</p>
| c# | [0] |
1,948,025 | 1,948,026 | Celcius to Fahrenheit | <p>I can convert from fahrenheit to celcius, but not the other way around. I have attached the code below. Hopefully it's enough to see what is going on.</p>
<pre><code> public void actionPerformed(ActionEvent arg0) {
double temps = 0, temp1 = 0;
String instrings;
instrings = temp.getText();
if(instrings.equals(""))
{
instrings = "0";
temp.setText("0");
}
temps = Double.parseDouble(instrings);
instrings = temp.getText();
if(instrings.equals(""))
{
instrings = "0";
temp.setText("0");
}
temp1 = Double.parseDouble(instrings);
if(arg0.getActionCommand().equals("C")){
temps = (( temps * 9)/5+32);
DecimalFormat formatters = new DecimalFormat("#,###,###.###");
results.setText(""+formatters.format(temps));
}
else if(arg0.getActionCommand().equals("F"));
{
temp1 = (((temps - 32)/9)*5);
DecimalFormat formatters = new DecimalFormat("#,###,###.###");
results.setText(""+formatters.format(temp1));
}
}
</code></pre>
| java | [1] |
3,123,682 | 3,123,683 | Showing Pop up screens using JQuery Dialogue | <pre><code><html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<%
String str ="Ravi";
%>
<script>
function changeIt(_src)
{
$("#dialog").dialog();
}
</script>
</head>
<body >
<img onclick="changeIt(this)" src='Cham/ravi.jpg' name='myimage' height ="100" width="100" />
<div id="dialog" title="Dialog Title">
The Name is <%=str%>
<img src='Cham/ravi.jpg' name='myimage' height ="1000" width="1000" />
</div>
</body>
</html>
</code></pre>
<p>Hi , </p>
<p>On page start up , On a AJAX call , I have some images present in a folder , i will fetch those paths and will show them on UI Page .</p>
<p>Now On click of that Image on the UI Page , i am trying to display a Jquery dialogue BOX which must include some data from Database related to that Image details and as well as that Image ( which was clicked ) in bigger size . (Basically a POP UP)</p>
<p>when i include the Image also in the dialogue div , it looks awkward as the Image is loaded at the Page loading only . </p>
<p>If this is not a better approach for showing POP ups on a rich web site
as you people being UI Experts , could you please advice me what would be the best approach ?? I am not sure if Light box suits for my requirement , please suggest me . Thanks in advance </p>
| jquery | [5] |
3,369,836 | 3,369,837 | ImageView setClickable(true) ... setPressed(true) not staying pressed | <p>I've got an <code>ImageView</code> which I'm setting to <code>setImageResource(R.drawable.someStateListDrawable)</code>. Everything works fine, when it's clicked, it shows the pressed state. However, I've made it so that it <code>onClick</code>, the <code>ImageView</code> is set to "<code>setPressed(true)</code>" so that it will remain in the pressed state. But for some reason, its not... Any ideas?</p>
| android | [4] |
5,429,503 | 5,429,504 | Update Table or drop and recreate? | <p>Hii i have a table in which i have to insert values is only one row..so when the values are updated should i update it or drop it and recreate?SQlite Android</p>
| android | [4] |
2,721,773 | 2,721,774 | Find if a number is a possible sum of two or more numbers in a given set - python | <p>The office supply store sells your favorite types of pens in packages of 5, 8 or 24 pens. Thus, it is possible, for example, to buy exactly 13 pens (with one package of 5 and a second package of 8), but it is not possible to buy exactly 11 pens, since no non-negative integer combination of 5's, 8's and 24's add up to 11. To determine if it is possible to buy exactly n pens, one has to find non-negative integer values of a, b, and c such that</p>
<p>5a + 8b + 24c = n</p>
<p>Write a function, called numPens that takes one argument, n, and returns True if it is possible to buy a combination of 5, 8 and 24 pack units such that the total number of pens equals exactly n, and otherwise returns False.</p>
<p>Note: it was a question that came up in a mid sem exams, that was last month. i was unable to solve it but am still looking for the solution. any help will be accepted. the code in python or an algorithm to solve it. thanks</p>
| python | [7] |
3,381,741 | 3,381,742 | What exactly is a JavaScript pragma? | <p>When you want a JavaScript file (or function) to be parsed in "strict mode" you can put..</p>
<pre><code>"use strict";
</code></pre>
<p>..in the top of your JavaScript file (or function).</p>
<p>This "use strict"; is a so-called "pragma".</p>
<p>My question: <strong>what exactly is a pragma?</strong>
The closest thing I can think of is a "directive".</p>
| javascript | [3] |
4,991,863 | 4,991,864 | In JavaScript is there a difference between referencing an object's variable name vs. using `this` when declaring new key:value pairs of the object? | <p>In JavaScript is there a difference between referencing a object's variable name vs. using <code>this</code> when declaring new key:value pairs of the object?</p>
<pre><code> var foo = {
bar: function() {
foo.qux = 'value';
}
};
alert(foo.qux); // undefined
foo.bar();
alert(foo.qux); // 'value'
var foo = {
bar: function() {
this.qux = 'value';
}
};
alert(foo.qux); // undefined
foo.bar();
alert(foo.qux); // value
</code></pre>
<p>Also: <a href="http://jsbin.com/emayub/9/edit" rel="nofollow">http://jsbin.com/emayub/9/edit</a></p>
| javascript | [3] |
5,693,901 | 5,693,902 | 'this' is undefined in jQuery custom method | <p>I have a method that I want to take some action depending on the 'checked' status of a checkbox. The 'click' event works as expected, but the 'myFunction' call in the foreach loop does not:</p>
<pre><code>$(document).ready(function(){
$('#TreeView1 :checkbox')
.click(HandleCheckbox); // Works fine
// Go through the entire Category treeview to
// see if there are any checkboxes that are already
// checked.
$.fn.myFunction = HandleCheckbox;
$(":checked:checkbox").each(function(index) {
// In the HandleCheckbox 'this' is undefined.
$(this).myFunction();
});
});
function HandleCheckbox() {
alert(this.name + '=' + this.checked);
}
</code></pre>
<p>In the above code, when the '.click' method fires, 'this' is defined, as expected. When I call 'muFunction' in the foreach loop, 'this' is undefined in the 'HandleCheckbox' function.</p>
<p>I am still learning the jQuery ropes, so if there is a 'better' or easier way of doing this, please let me know.</p>
<p>Thanks.</p>
| jquery | [5] |
4,797,341 | 4,797,342 | Android Rest Service Engine | <p>Is there any kind of rest engine service.</p>
<p>In general having REST web service and android app that will fetch from it and make some data processing and have it displayed is something that fits to common pattern.</p>
<p>It would be natural to have service that could be queried over content provider or similar and retrieve data. Service would have some kind of definitions of data that it will fetch.</p>
<p>Anyone knows of something like that?</p>
| android | [4] |
4,548,960 | 4,548,961 | How to provide multilanguage support for an Android Application | <p><br>
I want to develop an Android application in which I will display a menu for language selection, in which the user can select a languge . My application is supposed to be done for English and Arabic language. How to develop an application in a language other than english in Android. What are the steps I need to follow to develop an application in Arabic Language in Android. Can anyone help me in solving this issue?</p>
<p>Thanks in Advance,</p>
| android | [4] |
1,219,145 | 1,219,146 | how to convert hour minute and pm/m to strtotime | <p>I have a time value <code>04:30</code> <code>(h:mts am/pm)</code> pm. I want to convert this to strtotime </p>
<p>Also I need to convert back from strtotime to this format <code>(h:mits am/pm)</code></p>
<p>Thanks</p>
| php | [2] |
2,034,830 | 2,034,831 | How to escape string in .aspx | <p>I'm trying to get this string to work, I can't escape it correctly or I'm using the wrong syntax " vs '</p>
<pre><code><a href="<%#string.Format("{0}?ItemRemove=true&iID={1}", Page, <%#Container.DataItem.Id )%>">...</a>
</code></pre>
| asp.net | [9] |
4,817,321 | 4,817,322 | C# - sorting Dictionary | <p>I have a Dictionary and I want to sort it by Person, could anyone write me how to do it? Yeah, I tried to find it in the internet, but without success :((</p>
<p>Class subject has 3 parametres - name (string), family_name (string), age (int).</p>
<p>And I want to sort it by for example family_name, if same then by age and finally by name (if also age is same) - could anyone write me the code how to do it?? Thanks a lot for your help ;-)</p>
| c# | [0] |
4,904,738 | 4,904,739 | How to find top most Activity for a Task? | <p>I have an app where I'm running a timer event in the background checking for inactivity. When a certain amount of time has passed, I want to call the finish() method for whatever activity is currently top most for my app (task). Note, that my app can be in the background so I can't just use the top most active activity on the device. My problem, is finding the top most activity for my task, and then calling the finish() method for that activity. Below is a snippet of my Runnable timer that I'm using. The "activity" variable in my snippet is the thing that I can't seem to find.</p>
<pre><code>mUpdateTimeTask = new Runnable()
{
public void run()
{
// - for every 10 seconds, this runnable task will check the inactivity time and will exit this app
// if the time allocated is exceeded
long longNowTime = System.currentTimeMillis()/1000;
if ( longNowTime-globalVariables.longLastActivityTime >= globalVariables.intLockoutDuration )
{
// - first, we'll stop the lockout timer from running
mHandler.removeCallbacks(mUpdateTimeTask);
// - call the finish() method to close the top most activity for this task (app)
activity.finish();
}
mHandler.postDelayed(this,mIntInterval);
}
};
</code></pre>
<p>Can anyone offer some suggestions to how I can get the Activity object for my top most activity and call the finish() method to close it?</p>
<p>Thanks.</p>
| android | [4] |
4,938,103 | 4,938,104 | How to convert Object array to a Custom Class array? | <p>I have </p>
<pre><code>public class ABSInfo
{
public decimal CodeCoveragePercentage { get; set; }
public TestInfo TestInformation { get; set; }
}
</code></pre>
<p>And I have an Object array say "SourceType" </p>
<pre><code>public object[] SourceType { get; set; }
</code></pre>
<p>I want to convert the Object Array (SoiurceType) to ABSInfo[].</p>
<p>I am trying as </p>
<pre><code>ABSInfo[] absInfo = Array.ConvertAll(SourceType, x => (ABSInfo)x);
</code></pre>
<p>but error</p>
<p><strong>Unable to cast object of type 'WindowsFormsApplication1.TestInfo' to type 'WindowsFormsApplication1.ABSInfo'.</strong></p>
<p>how to do the conversion?</p>
<p><strong>Edited:</strong></p>
<pre><code>public class TestInfo
{
public int RunID { get; set; }
public TestRunStatus Status { get; set; }
public string Description { get; set; }
public int TotalTestCases { get; set; }
public int TotalTestCasesPassed { get; set; }
public int TotalTestCasesFailed { get; set; }
public int TotalTestCasesInconclusive { get; set; }
public string ReportTo { get; set; }
public string Modules { get; set; }
public string CodeStream { get; set; }
public int RetryCount { get; set; }
public bool IsCodeCoverageRequired { get; set; }
public FrameWorkVersion FrameworkVersion { get; set; }
public string TimeTaken { get; set; }
public int ProcessID { get; set; }
public int GroupID { get; set; }
public string GroupName { get; set; }
}
</code></pre>
| c# | [0] |
1,269,259 | 1,269,260 | Issue with javascript inheritance using function prototype | <p>I want to use inheritance concept in js, so what i did is</p>
<pre><code>function myGarage(x) {
var _x = x;
Object.defineProperty(this, "BenZ", {
get: function () {
return _x;
},
set: function (value) {
_x = value;
},
enumerable: true,
configurable: true
});
}
myGarage.prototype = new MyCar();
function MyCar() {
var _x =0;
Object.defineProperty(this, "Audi", {
get: function () {
return _x;
},
set: function (value) {
_x = value;
},
enumerable: true,
configurable: true
});
}
</code></pre>
<p>After this i created there instance for <code>myGarage</code>.</p>
<pre><code> var g1 = new myGarage(true);
var g2 = new myGarage(false);
var g3 = new myGarage("null");
</code></pre>
<p>The problem here is when i set <code>g1.Audi = 10;</code> all other instance of <code>myGarage</code>'s Audi will hold the sample value </p>
<p>(eg)</p>
<pre><code> g1.Audi = 10;
var a = g2.Audi // a is 10
var b = g3.Audi; // b is 10
</code></pre>
<p>but i set the value to g1.</p>
<p>what i need is other instance must hold the default value or undefined</p>
| javascript | [3] |
2,292,866 | 2,292,867 | Jquery Templeate, droping last item off in the each | <p>Currently I am using jquery templating with some json data, I have a couple images that I am getting and I would like to drop the last image that I am getting from my json data. Right now I have this coded ( this only a snippet of the spot I am having the problem at):</p>
<pre><code> <div class="altViews">
<ul class="clearfix">
{{each(i,addImage) AdditionalImages}}
<li class="altImage">
<img src="http://images.url.com/images/products/${addImage}" alt="${Name}" id="${addImage}"/>
</li>
{{/each}}
</ul>
</div>
</code></pre>
<p>SO the main help I need is to be able to drop the last li, I just dont know how to use my index to do that.</p>
| jquery | [5] |
4,246,721 | 4,246,722 | How to empty a line in file and write it back to the original position? | <p>I'm able to read a string from a file but I'm having trouble deleting or emptying that string.
Thanks you for helping and have a great day.</p>
<pre><code>#include <iostream>
#include <fstream>
#include <map>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main() {
map<string, string> Data; // map of words and their frequencies
string key; // input buffer for words.
fstream File;
string description;
string query;
int count=0;
int i=0;
File.open("J://Customers.txt");
while (!File.eof()) {
getline(File,key,'\t');
getline(File,description,'\n');
Data[key] = description;
}
File.close();
cout << endl;
for ( count=0; count < 3; count++) {
cout << "Type in your search query.";
cin >> query;
string token[11];
istringstream iss(Data[query]);
while ( getline(iss, token[i], '\t') ) {
token[0] = query;
cout << token[i] << endl;
i++;
}
}
system("pause");
}//end main
</code></pre>
| c++ | [6] |
602,539 | 602,540 | How to set always default value for first record in list view in aspx page? | <p>I have an aspx page that uses a simple form to perform a search and the results are presented in a listview.</p>
<p>I have added a radio button to one of the columns and have set the value to be the records FlightNo. set always default value for first record in list view.</p>
<p>What I need to do is allow the user to select the row they require from the list view by selecting the radio button.</p>
| asp.net | [9] |
2,291,849 | 2,291,850 | "alert" is not defined when running www.jshint.com | <p>I fixed this by simply adding <code>var alert;</code> However, is this what I should be doing to get the pesky error message to go away? Here is the fix. Here is the fail on <a href="http://www.jshint.com/reports/71017" rel="nofollow">www.jshint.com</a>.</p>
<p>I'm trying to learn from the error it throws..not necessarily make them go away.</p>
<pre><code>(function () {
"use strict";
var alert; // added this in to fix
function initialize_page()
{
alert ("hi");
}
addEventListener('load', initialize_page);
})();
</code></pre>
| javascript | [3] |
4,702,606 | 4,702,607 | audio engine on iPhone | <p>I want to develop a voip application for iPhone. Could you let me know how can I achieve a good voice quality? How should I start with developing a good audio engine for iPhone?</p>
<p>Thanks.</p>
| iphone | [8] |
5,760,321 | 5,760,322 | GridView, replace text by image in column if columns text contains %text% | <p>i have a page with gridview tables that returns the following columns from an SQL DB</p>
<blockquote>
<p>Device | Message |</p>
<hr>
<p>Server1 | This error is ping failure from server1</p>
<p>Server2 | This error is DFS Backlog failure from server2
to server5</p>
</blockquote>
<p>Is there a way that i can replace the message for a picture?</p>
<p>I want to look in the column and if error message text contains %ping% then show ping.png image and if error message contains %DFS% replace text to dfs.png image</p>
<p>Can someone point me in the right direction?</p>
<p>Thanks</p>
| asp.net | [9] |
5,973,357 | 5,973,358 | What is wrong with this simple jQuery code? | <p>This is a simple jQuery code, what I want to do is hide <code>#bling</code>, but it does not</p>
<pre><code><script language="javascript">
$("document").ready(function() {
$('#bling').hide();
});
</script>
<div id="bling" style="background-color:#FFFF66; width:100px; height:100px;"></div>
</code></pre>
<p>Thanks
Dave</p>
| jquery | [5] |
6,002,181 | 6,002,182 | Generate Seqence of Numbers from ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789 | <p>I need to use > ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789 , to generate n number of combinations for primary key.
like for possible of single digit(A,B,...Z,1,2...9), and like via two digit (A1,A2..A9,1A..9A..ZA..Z9) and 3(AA1,A1A) ....</p>
<p>Please Suggest me is better than GUID with 12Chars?</p>
<p><strong>Thanks</strong><br>
Vinoth Xavier</p>
| c# | [0] |
2,306,866 | 2,306,867 | Reference Javascript object from string | <p>Given data similar to:</p>
<pre><code>var data = [{id: 12345,
name:'my products',
items:[{
size: 'XXL',
sku: 'awe2345',
prices:[{type: 'rrp',prices: 10.99},
{type: 'sell_price', price: 9.99},
{type:'dealer', price:4.50}
]
},{
size: 'XL',
sku: 'awe2346',
prices:[{type: 'rep', prices: 10.99},
{type: 'sell_price', price: 9.99},
{type:'dealer', price:4.50}
]
}
]
}]
}]
</code></pre>
<p>is there a way to evaluate a string representation of an element in the data object? for example: "data[0].items[0].prices[0].rrp" ...without using eval()?</p>
| javascript | [3] |
3,494,012 | 3,494,013 | NameError: name 'reload' is not defined | <p>I'm using python 3.2.2. When I write a simple program, I meet the problem.</p>
<pre><code>>>> reload(recommendations)
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
reload(recommendations)
NameError: name 'reload' is not defined
</code></pre>
<p>How should I do it?</p>
| python | [7] |
2,593,409 | 2,593,410 | c# syntax help What 's coming after the constructor? | <pre><code>public Butler(IWeapon weapon): this(weapon, new Communicate())
{}
</code></pre>
<p>What does this(weapon, new Communicate()) mean?</p>
| c# | [0] |
5,189,267 | 5,189,268 | 'base' as a function parameter name in C# | <p>I am currently following Microsoft's Naming Guidelines, and so using camelCase in function parameter naming. Now suppose I would like to use the signature</p>
<pre><code>public string WriteNumberInBase (int number, int base)
</code></pre>
<p>in some method and the compiler is complaining about the parameter name just because 'base' is a reserved keyword... Is there any way I can get 'base' to be accepted as a parameter name?</p>
| c# | [0] |
3,362,859 | 3,362,860 | Importing a user subclass in PHP | <p>I've coded a small PHP engine which includes some abstract classes. The user of the engine must implement subclasses of these abstract classes, and supply their subclasses to the engine. The engine has to be able to create and manipulate instances of these subclasses, so the user can't just create an instance and pass it to the engine.</p>
<p>So I need a way for the user to pass their subclasses to the engine. One obvious way would be to force the user to give these subclasses a specific name and put them in a specific directory, but that just seems inelegant somehow. Knowing that PHP could store classes in variables, what I tried first was to store the classes in constants, so I had a file with a few <code>define</code>s that user would fill in with the names and paths of their subclasses. That didn't work - it would seem PHP cannot store classes in constants, only variables.</p>
<p>So now I'm trying the same approach, but with variables instead of constants. There's a file, <code>UserIncludes.lib.php</code>, in which the user is required to set two variables to the names of their subclasses. Then those variables are used to call those subclasses throughout the engine's code. I'm not sure this is a good system, particularly because of the need to import the variables into every function that needs them using the <code>global</code> keyword, increasing the clerical and mental load on the engine.</p>
<p>So what are best practices for doing this sort of thing in PHP? It seems like it must be a fairly common task.</p>
| php | [2] |
3,975,647 | 3,975,648 | Concurrency Testing For A Web Service Using Python | <p>I have a web service that is required to handle significant concurrent utilization and volume and I need to test it. Since the service is fairly specialized, it does not lend itself well to a typical testing framework. The test would need to simulate multiple clients concurrently posting to a URL, parsing the resulting Http response, checking that a database has been appropriately updated and making sure certain emails have been correctly sent/received. </p>
<p>The current opinion at my company is that I should write this framework using Python. I have never used Python with multiple threads before and as I was doing my research I came across the Global Interpreter Lock which seems to be the basis of most of Python's concurrency handling. It seems to me that the GIL would prevent Python from being able to achieve true concurrency even on a multi-processor machine. Is this true? Does this scenario change if I use a compiler to compile Python to native code? Am I just barking up the wrong tree entirely and is Python the wrong tool for this job?</p>
| python | [7] |
2,658,031 | 2,658,032 | Jquery select only neighbor | <p>I've got:</p>
<pre><code><div class="row even">
<div class="more">more</div>
<div class="body">Some additional text</div>
</div>
<div class="row odd">
<div class="more">more</div>
<div class="body">Anoteher text</div>
</div>
</code></pre>
<p>And I want to toggle div with "body" class when "more" div is clicked but only in their common row class.</p>
<pre><code>$('.more').click(function() {
$('.body').toggle();
});
</code></pre>
<p>But it toggle all div with "body" class.</p>
| jquery | [5] |
1,618,101 | 1,618,102 | Javascript inheritance & Apply | <p>I have been looking into design patterns in Javascript and found <a href="http://tcorral.github.com/Design-Patterns-in-Javascript/Template/withoutHook/index.html" rel="nofollow">http://tcorral.github.com/Design-Patterns-in-Javascript/Template/withoutHook/index.html</a> to be a great source.</p>
<p>Can anyonne explain the significance of using <strong><em>ParentClass.apply(this)</em></strong></p>
<pre><code>var CaffeineBeverage = function(){
};
var Coffee = function(){
CaffeineBeverage.apply(this);
};
Coffee.prototype = new CaffeineBeverage();
</code></pre>
<p>PS: I tried commenting the CaffeineBeverage.apply(this), but no effect was there. Here is a link to jsfiddle <a href="http://jsfiddle.net/pramodpv/8XqW9/" rel="nofollow">http://jsfiddle.net/pramodpv/8XqW9/</a></p>
| javascript | [3] |
5,213,314 | 5,213,315 | What does "(void)!ptr" do? | <p>I see it when I read pugixml source code and I really don't know why it's there.</p>
<pre><code>void foo(void* ptr) {
(void)!ptr; // What does this line do?
}
</code></pre>
| c++ | [6] |
2,528,951 | 2,528,952 | How to pickle a empty file? | <p>I want to pickle a file that sometime's is empty. Right now its empty, but my idea is that its going to grow over time.</p>
<p>How do i check if a file is "pickable" since it seems that you can not pickle a empty file?</p>
| python | [7] |
2,055,917 | 2,055,918 | which function is there in android for the following java function--statement = database.createStatement(sqlStatement);? | <pre><code>public void execute(String sqlStatement) throws DBException {
Statement statement;
try {
statement = database.createStatement(sqlStatement);
statement.prepare();
statement.execute();
statement.close();
} catch (DatabaseException databaseException) {
throw new DBException(Class.class.getName(), "execute", databaseException.getMessage());
}
}
</code></pre>
<p>This is the function in java that i have to implement in android. In android how can i use the createstatement(), statement.prepare() and statement.execute() functions?</p>
| android | [4] |
4,970,991 | 4,970,992 | how to read .ics file and add data to Google Calendar in android? | <p>I have the calendar.ics file. I have to read that file from my application and transfer the data in to Google calendar in android. I am new to android. I need some help to do this.Can anyone help me to do this? </p>
| android | [4] |
2,021,861 | 2,021,862 | Android SherlockFragmentActivity - Tab | <p>I use SherlockFragmentActivity and I have:</p>
<pre><code>public class TestActivity extends SherlockFragmentActivity {
private static enum Tab {
Test1("test1", TestOneFragment.class),
Test2("test2", TestTwoFragment.class),
private final String title;
private final Class<? extends Fragment> clazz;
private Tab(String title, Class<? extends Fragment> clazz) {
this.title = title;
this.clazz = clazz;
}
private String getTitle() {
return title;
}
private Class<? extends Fragment> getFragmentClass() {
return clazz;
}
}
</code></pre>
<p>It works fine ,because I have Test1 and Test2 in the same "package".</p>
<p>How add external "package" class ? When I import com.bla.blaa.BlaActivity;
I use this like this:</p>
<pre><code> private static enum Tab {
Blabla("Blabla", BlaActivity.class),
Test1("test1", TestOneFragment.class),
Test2("test2", TestTwoFragment.class);
</code></pre>
<p>I have error: </p>
<pre><code>The constructor TestActivity.Tab(String, Class<BlaActivity>) is
undefined
</code></pre>
| android | [4] |
1,481,298 | 1,481,299 | Textarea onKeyChange not working? | <p>I'm attempting to write a very basic script using javascript. What I want to do is be able to detect whenever a textarea is modified, and then make some changes to other elements.</p>
<p>This is my jsfiddle: <a href="http://jsfiddle.net/QDRHT/1/" rel="nofollow">http://jsfiddle.net/QDRHT/1/</a></p>
<p>I'm attempting to detect whenever a new character is entered into the textarea, then modify the background color of a nearby div. However, it's not working at all, and I can't tell why (I'm new to Javascript, although I did make sure to validate my HTML and CSS, and run the javascript through JSLint).</p>
<p>If it matters, I'm running this in IE 9.</p>
| javascript | [3] |
565,273 | 565,274 | jQuery hide element, load Ajax in it, and then show element | <p>I am trying to hide an element, then replace its contents while it's hidden with an ajax <code>load()</code>, and as a callback, I would like to show that element again. Unfortunately, after the request completes, the callback is kind of ignored: the element is not shown again.</p>
<p>Here's my code, hope I was clear in my problem:</p>
<pre><code>//element is visible
$("#play").hide();//element becomes hidden
$("#play").load("page", function(data){
$("#play").show();//element should be visible again, but it isn't
});
</code></pre>
| jquery | [5] |
5,472,793 | 5,472,794 | Repeating while loop, until cancel | <pre><code>countries={'TW':'Taiwan','JP':'Japan','AUS':'Australia'}
def add_country():
while True:
new_short=raw_input('Country Name in short:')
new_full=raw_input('Country Name in full:')
countries[new_short]=new_full
answer=raw_input('want to add more?')
if answer in ('yes'):
return True
if answer in ('no'):
return False
print countries
add_country()
</code></pre>
<p>I just started learning Python. Above code isn't correct, can somebody fix it for me? Basically I just want to repeat the loop once if answer is yes, or break out of the loop if answer is no. The return True/False doesn't go back to the while loop?</p>
| python | [7] |
4,820,536 | 4,820,537 | difference between view and widget | <p>Well this is my simple question. What is the difference between a view and a widget ? </p>
<p>Thank you very much</p>
| android | [4] |
3,206,840 | 3,206,841 | Sort array of objects by object param, then sort those by another param alphabetically | <p>So, I have an array of objects that I want to sort like so:</p>
<pre><code>Array
(
[463] => stdClass Object
(
[name] => Organic 12
[total_weight] => 5
)
[340] => stdClass Object
(
[name] => Organic 12b
[total_weight] => 5
)
[340] => stdClass Object
(
[name] => Organic 12c
[total_weight] => 5
)
[532] => stdClass Object
(
[name] => Alpha 10
[total_weight] => 4
)
[203] => stdClass Object
(
[name] => General 5
[total_weight] => 3
)
</code></pre>
<p>)</p>
<p>Where the total_weight of all objects is sorted highest to lowest, then within those sorts, the objects are sorted alphabetically by name. I successfully can sort them by total_weight with php's usort, but can't figure out how to sub-sort the result. Using usort only, there's no consistency in the sorted results so one object's name might appear above another's in one result, but not in another. </p>
<p>I'm thinking perhaps array_multisort might be the answer, but I can't seem to figure it out. </p>
| php | [2] |
4,953,585 | 4,953,586 | Call a function after specific time period | <p>I have one function written in javascript.
How can i call this function after specific time interval.Say after each one minute.</p>
<pre><code>function FetchData() {
}
</code></pre>
| javascript | [3] |
4,482,576 | 4,482,577 | How can I replace a space in a string with an underscore in C#? | <p>I have strings such as:</p>
<pre><code>var abc = "Menu Link";
</code></pre>
<p>Is there a simple way I can change the space to an underscore?</p>
| c# | [0] |
6,021,580 | 6,021,581 | how to select input from the drives | <p>i have to write the code using simple java.i have to copy one source file to the destination file.the problem is that the user have to select the source and destination from any drives available.how to call the available drives in the java .no need of buttons
thank you.</p>
| java | [1] |
4,568,441 | 4,568,442 | Jquery - How list id elements contained from a div | <p>If I have a div like this:</p>
<pre><code><div id="box">
<div class="but" id="1">Text 1</div>
<div class="but" id="2">Text 2</div>
</div>
</code></pre>
<p>How can I create an array of all IDs of the <code>.but</code> elements contained in the <code>#box</code> div?</p>
<p>In the example will be <code>[1, 2]</code>.</p>
| jquery | [5] |
5,630,515 | 5,630,516 | Android Virtual KeyboardListener | <p>I have an <code>EditText</code> which when some text entered the virtual keyboard appears and when I press enter I can't get focus in my second <code>EditText</code>, but some times it works.</p>
<p>Anybody please help.</p>
<pre><code>edittext.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER)// key code for virtual keyboard next
{
System.out.println("Event catched>>>>>>>>>>>>>>");
edittext.requestFocus();
}
return false;
}
});
</code></pre>
| android | [4] |
3,085,206 | 3,085,207 | How to remove default input text | <p>I have:</p>
<pre><code><input type="text" id="nome" value="Nome..." />
</code></pre>
<p>I have to remove it, <strong>one time</strong>....when the focus will be on the input text.</p>
<p>I have to use jquery...</p>
<p>Thank you</p>
| jquery | [5] |
5,409,367 | 5,409,368 | C# - Inconsistent math operation result on 32-bit and 64-bit | <p>Consider the following code:</p>
<pre><code>double v1 = double.MaxValue;
double r = Math.Sqrt(v1 * v1);
</code></pre>
<p>r = double.MaxValue on 32-bit machine
r = Infinity on 64-bit machine</p>
<p>We develop on 32-bit machine and thus unaware of the problem until notified by customer. Why such inconsistency happens? How to prevent this from happening?</p>
| c# | [0] |
3,465,497 | 3,465,498 | Why my Image Quality is not good while sending it to server in My Android App? | <p>This is my code to send Image on Server . my image is going to server but not in good quality. </p>
<pre><code>photo = (Bitmap) data.getExtras().get("data");
image_from_camera.setImageBitmap(photo);
if(photo != null)
{
ByteArrayOutputStream stream = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 50, stream);
//Here if I increase the size of quality like up to
//photo.compress(Bitmap.CompressFormat.JPEG, 100, stream);
//then i am getting BAD REQUEST ERROR i.e request exceeds size limit.
byte[] byte_arr = stream.toByteArray();
image_string_chore_detail = Base64.encodeToString(byte_arr,Base64.DEFAULT);
System.out.println(
"IMAGE STRING IN CHORE DETAILS:: "+image_string_chore_detail);
}
</code></pre>
<p>So please help me what to do....</p>
| android | [4] |
1,897,615 | 1,897,616 | list out image extension support in android | <p>I would like to know that which <code>extension</code> of image are supported in android?
can you give me list of <code>image extension</code> support by android</p>
<p>Thanks
nik</p>
| android | [4] |
4,127,626 | 4,127,627 | Android Email Application: Open a Message directly | <p>By looking at the link
<a href="http://stackoverflow.com/questions/2001254/downloading-sent-mails-from-yahoo-gmail-and-hotmail">http://stackoverflow.com/questions/2001254/downloading-sent-mails-from-yahoo-gmail-and-hotmail</a>
is it possible to invoke or call Gmail and open a message programmatically</p>
| android | [4] |
841,357 | 841,358 | Does calling .Last() on an IList iterate the entire list? | <p>Does the <code>.Last()</code> extension method take into account if it's called on an <code>IList</code>? I'm just wondering if there's a significant performance difference between these:</p>
<pre><code>IList<int> numbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int lastNumber1 = numbers.Last();
int lastNumber2 = numbers[numbers.Count-1];
</code></pre>
<p>Intuition tells me that the first alternative is O(n) but the second is O(1). Is <code>.Last()</code> "smart" enough to try casting it to an <code>IList</code>?</p>
| c# | [0] |
739,718 | 739,719 | Java - write obenglobish method | <p>I have problem writing some method ... so if some1 can help, i would really appreciate it. Thank you.</p>
<p><strong>Task:</strong>
- read word
- turn it in "obenglobish" - that means that you must add "OB" before vowel ...
for example: english will become --> OBenglOBish ...
<strong>exception</strong>: two vowel in the row && -e is the last char in the word.</p>
<p>This is what i wrote, no matter on exceptions:</p>
<pre><code> import acm.program.*;
public class ObenGlobishX extends ConsoleProgram {
public void run() {
println("OBENGLOBISH");
while (true) {
String word = readLine("Enter a word: ");
if (word.equals("")) break;
println(word + " --> " + obenglobish(word));
}
}
private String obenglobish (String word) {
String result = "";
for (int i = 0; i < word.length(); i++) {
char c = word.charAt(i);
if (isEnglishVowel(c)) result = result + "ob" + c;
else result += c;
}
return result;
}
private boolean isEnglishVowel(char x) {
if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u') return true;
return false;
}
}
</code></pre>
<p>It works for word like English and Rot (robot), but for word gooiest it doesn't work - two oo's ... need to find out how to modify method to get correct results ... that means:
gooiest -> gobooiest
amaze -> obamobaze
etc.</p>
<p>THX</p>
| java | [1] |
3,394,124 | 3,394,125 | Line terminators | <p>What are difference between:</p>
<ul>
<li><code>\r\n</code> - Line feed followed by carriage return.</li>
<li><code>\n</code> - Line feed.</li>
<li><code>\r</code> - Carriage Return.</li>
</ul>
| c++ | [6] |
1,239,936 | 1,239,937 | ASP.Net machinekey, validationkey, and decryptionkey - key lengths | <p>What are the default key lengths that are generated when leaving the ValidationKey and DecryptionKey at their defaults? For example:</p>
<pre><code><machineKey decryptionKey="AutoGenerate,IsolateApps" validationKey="AutoGenerate,IsolateApps" ... />
</code></pre>
<p>I have not been able to find this documented anywhere on MSDN.
I would like to generate a static machine key and keep it in line with the defaults.</p>
| asp.net | [9] |
2,225,857 | 2,225,858 | favicon Problem | <p>How can i get favicon image from its websire url using xcode....</p>
<p>Is there any special api for this?</p>
<p>Can anyone help me?..... Thanks in advance..</p>
| iphone | [8] |
5,048,924 | 5,048,925 | add images to toolbar | <p>i have 5 UIbarButton items in a toolbar,
how can i set images on each barbutton,
i tried through IB, but it not coming up, how can i do it ptogrammatically?
one of bar button looks like this</p>
<p>aBar = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"a.png"]style:UIBarButtonItemStylePlain target:self action:@selector(aMethod)];</p>
<p>i already conencted all barbuttons ion IB.</p>
<p>regards</p>
| iphone | [8] |
4,927,907 | 4,927,908 | Why this convert into object | <p>Instead of string it is object</p>
<pre><code>String.prototype.foo = function () { return this; };
typeof "hello".foo() // object ???
"hello".foo().toString(); //hello
</code></pre>
<p>it should return string instead i guess. </p>
| javascript | [3] |
5,351,902 | 5,351,903 | Showing notification in broadcast receiver | <p>HI,
I am in a situation that I need to display notification when call arrives. For this I am using broadcast receiver. Code is below</p>
<pre><code>public class MyPhoneStateListener extends PhoneStateListener {
public Context context;
@Override
public void onCallStateChanged(int state, String incomingNumber) {
// TODO Auto-generated method stub
super.onCallStateChanged(state, incomingNumber);
switch(state){
case TelephonyManager.CALL_STATE_IDLE:
NotificationManager notifier = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
//Get the icon for the notification
int icon = R.drawable.icon;
Notification notification = new Notification(icon,"Simple Notification",System.currentTimeMillis());
//Setup the Intent to open this Activity when clicked
Intent toLaunch = new Intent(context, main.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, toLaunch, 0);
//Set the Notification Info
notification.setLatestEventInfo(context, "Hi!!", "This is a simple notification", contentIntent);
//Setting Notification Flags
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.FLAG_INSISTENT;
// notification.sound = Uri.withAppendedPath(Audio.Media.INTERNAL_CONTENT_URI, "6");
//Send the notification
notifier.notify(0x007, notification);
Log.d("CALL", "IDLE");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d("DEBUG", "OFFHOOK");
break;
case TelephonyManager.CALL_STATE_RINGING:
Log.d("DEBUG", "RINGING");
break;
}
}
}
</code></pre>
<p>Now problem is that sound for the notification is not playing but notification is being displayed correctly. Can anyone shed light on it please why notification sound is not being played?</p>
| android | [4] |
5,909,110 | 5,909,111 | clearing a link with javascript only works for the first link | <p>Found a bit of javascript that clears the link to current page. So far so good. It worked until there were more than one link.</p>
<pre><code>/*
CLCP v2.1 Clear Links to Current Page
Jonathan Snook
This code is offered unto the public domain
http://www.snook.ca/jonathan/
*/
window.onload = clearCurrentLink;
setTimeout("clearCurrentLink()",50);
function clearCurrentLink(){
var a = document.getElementsByTagName("A");
for(var i=0;i<a.length;i++)
if(a[i].href == window.location.href.split("#")[0])
removeNode(a[i]);
}
function removeNode(n){
if(n.hasChildNodes())
for(var i=0;i<n.childNodes.length;i++)
n.parentNode.insertBefore(n.childNodes[i].cloneNode(true),n);
n.parentNode.removeChild(n);
}
</code></pre>
<p>Thing is I can't figure out why it only clears the first link it finds.</p>
<p>I'm generating pages through node / expresss / jade / stylus. Any other ides on how to eliminate links to the current page? </p>
<p>Thanks!</p>
| javascript | [3] |
456,496 | 456,497 | Extract filenames from fileInfos | <p>I have <code>FileInfo[]</code> fileInfos
I want to populate
<code>string[]</code> filesNames and <code>List<string></code> fileNamesList using LINQ expression, how should I do it?</p>
| c# | [0] |
957,879 | 957,880 | Delegate Methods | <p>I am having the parentViewController dismiss the modal view because I want it to reload the UIPicker on the parentViewController. The code is really quite simple:</p>
<pre><code>-(void)didDismissFormsView {
NSUserDefaults *profiles = [NSUserDefaults standardUserDefaults];
NSArray *array = [[NSArray alloc]initWithObjects:[profiles stringForKey:@"name1"],[profiles stringForKey:@"name2"],[profiles stringForKey:@"name3"],nil];
self.profileData = array;
[array release];
[self dismissModalViewControllerAnimated:YES];
</code></pre>
<p>}</p>
<p>..and I know that the method is being called correctly from the modal view because I commented out the last line (dismissModal....) and it wouldnt let me dismiss the view.</p>
<p>However, the UIPicker is not updating!!! If I reload the app then the UIPicker is updated because I am using that same code in the viewDidLoad method. Why wouldnt the exact same code be reloading it when that delegate method is called? </p>
| iphone | [8] |
4,835,398 | 4,835,399 | UILabel display problem | <p><img src="http://i.stack.imgur.com/5vtAp.png" alt="enter image description here"></p>
<p>In the above figure it shows...</p>
<p>I need to display complete data in UILabel.</p>
<p>This is an alignment problem with UILabel</p>
<pre><code>UILabel *lable=[[UILabel alloc]init];
lable.frame=CGRectMake(350, 25, 50, 50);
[lable setTextColor:[UIColor whiteColor]];
[lable setBackgroundColor:[UIColor clearColor]];
[lable setText:@"Leveraged Commentary & Data"];
</code></pre>
<p>I need to display completed setText on lable @"Leveraged Commentary & Data";</p>
<p>Please help me out.</p>
<p>Thanks in advance</p>
| iphone | [8] |
167,713 | 167,714 | How do you bulk move files and directories with PHP | <p>I have a site with many files and directories. The directories are several levels deep. The problem is that they are in the wrong directory. They are in <code>/www/upload/site/</code> and everything should be moved to <code>/www/</code>. Is there a short script to move everything two directories up?</p>
<p>Thank you.</p>
| php | [2] |
1,002,775 | 1,002,776 | Forwarding __getitem__ to getattr | <p>Can someone explain what is happening here?</p>
<pre><code>class Test(object):
__getitem__ = getattr
t = Test()
t['foo']
</code></pre>
<p>gives error (in Python 2.7 and 3.1):</p>
<pre><code>TypeError: getattr expected at least 2 arguments, got 1
</code></pre>
<p>whereas:</p>
<pre><code>def f(*params):
print params # or print(params) in 3.1
class Test(object):
__getitem__ = f
</code></pre>
<p>prints the two parameters I'd expect.</p>
| python | [7] |
3,374,935 | 3,374,936 | really really simple javascript question | <p>I'm trying to use this plugin <a href="http://www.cssnewbie.com/example/equal-heights/plugin.html" rel="nofollow">http://www.cssnewbie.com/example/equal-heights/plugin.html</a> but haven't used much javascript before. It says:</p>
<pre><code>Load the jQuery library in your document’s head. - no probs
Load the equalHeights plugin the same way. - fine, I can do that
</code></pre>
<p>But then it says:
In order for the function to be able to calculate heights accurately, you’ll need to make sure it waits until the page is done loading before running. So wrap the function call (just like you should most all of your jQuery functions) in a $(docment).ready() function, like so:</p>
<pre><code>$(document).ready(function() {
$(".columns").equalHeights(100,300);
});
</code></pre>
<p>Now I'm not sure where I put this exactly. In another javascript file I included before that piece of code (or similar) was in the included javascript file already.</p>
<p>Can I just stick that function in the jsfile? or does it need to happen somewhere on the page?</p>
| javascript | [3] |
3,538,926 | 3,538,927 | Run specific method of the class defined by string | <p>I have this sample code</p>
<pre><code>class aaa:
@staticmethod
def method(self):
pass
@staticmethod
def method2(self):
pass
command = 'method'
</code></pre>
<p>Now I would like to run method of the class aaa defined by command string. How could I do this? Thank you very much.</p>
| python | [7] |
3,028,896 | 3,028,897 | Method Resolution Order (MRO) in new style Python classes | <p>In the book "Python in a Nutshell" (2nd Edition) there is an example which uses<br>
old style classes to demonstrate how methods are resolved in classic resolution order and<br>
how is it different with the new order. </p>
<p>I tried the same example by rewriting the example in new style but the result is<br>
no different than what was obtained with old style classes. The python version<br>
I am using to run the example is <strong>2.5.2.</strong> Below is the example: </p>
<pre><code>class Base1(object):
def amethod(self): print "Base1"
class Base2(Base1):
pass
class Base3(object):
def amethod(self): print "Base3"
class Derived(Base2,Base3):
pass
instance = Derived()
instance.amethod()
print Derived.__mro__
</code></pre>
<p>The call <code>instance.amethod()</code> prints <strong><code>Base1</code></strong>, but as per my understanding of the MRO<br>
with new style of classes the output should have been <strong><code>Base3</code></strong>. The<br>
call <code>Derived.__mro__</code> prints: </p>
<pre><code>(<class '__main__.Derived'>, <class '__main__.Base2'>, <class '__main__.Base1'>, <class '__main__.Base3'>, <type 'object'>)
</code></pre>
<p>I am not sure if my understanding of MRO with new style classes is incorrect or<br>
that I am doing a silly mistake which I am not able to detect. Please help me<br>
in better understanding of MRO. </p>
| python | [7] |
5,559,017 | 5,559,018 | smooth scrolling not working | <p>im trying to scroll the window when a certain divs are clicked,the problem i have got is it works perfectly in safari but in IE 6 and above there seems to be flickering.The screen also flickers when you try clicking in the scroll area of the window !! I cant figure out what the problem is.Could some one help please?</p>
<p>Jquery Code :</p>
<pre><code> $("div.trigger").click(function(){
$('html, body').animate({
scrollTop: $(this).next(".toggle_container").offset().top
}, 2000);
});
</code></pre>
| jquery | [5] |
4,792,313 | 4,792,314 | use tinymce with fancybox | <p>How to use <strong>tinymce with fancybox</strong>? I have used tinyMCE on my page and also need to open it in fancybox using same page but it is not wokring in <strong>firefox, safari and chrome</strong> but working fine with <strong>IE</strong>.</p>
| jquery | [5] |
4,980,459 | 4,980,460 | Start coding in Java with NetBeans | <p>There is a lot of information about Java around, but I don't understand how to setup everything.</p>
<p>I have a Mac. I heard the JDK comes with Macs. But is it the latest? How do I check that? Is it the J2SE or J2EE?</p>
<p>I want to create a web app. I installed NetBeans. When I choose create project there is a list of Java options. There is Java/Java EE/Java FX/Java Web. Which one should i choose? and afterwards, what is what? What is War?</p>
<p>I want to find a good tutorial/ebook explaining all these Java terms and how to setup Java/Java Server(Glassfish/Tomcat) on a Mac and with NetBeans to code a web app? A good one!</p>
| java | [1] |
2,395,747 | 2,395,748 | Global try-catch for a service | <p>I found a solution for a global try-catch in an activity. (<a href="http://stackoverflow.com/questions/4427515/using-global-exception-handling-on-android">here</a>) Can I do something similar with a service?</p>
| android | [4] |
4,888,291 | 4,888,292 | Simple account system | <p>I have been working on this small accounting thing, having some problems with the withdrawal section. I need help.</p>
<pre><code>public class Account {
private double balance;
public Account (double initialBalance){
if(initialBalance > 0){
balance = initialBalance;
}
}
public double getDeposit(){
return balance;
}
public void credit (double amount){
balance += amount;
}
public double withdraw(double amount2){
//double amount1;
//double with;
if (balance > initialBalance){
balance - amount2;
}
</code></pre>
| java | [1] |
172,390 | 172,391 | Call function in document.ready | <p>Can I call function in document.ready(function(){ }) by using "onclick" event...?</p>
<pre><code> document.ready(function(){
function MyFunction()
{
alert("Hello");
}
});
<a href="#" onclick="javascript:MyFunction()"></a>
</code></pre>
| jquery | [5] |
5,327,865 | 5,327,866 | Extended call-syntax: Passing parameters | <p>I have a function that looks like this:</p>
<pre><code>def getColumn(self, name, type, **args):
</code></pre>
<p>Now I would like to have a function</p>
<pre><code>def getColumns(self, columns)
</code></pre>
<p>where I can pass a tuple that contains a tuple, where each entry in that tuple represents the
arguments to be passed go getColumn. However, I'd like not to have to use named parameters for the name and type.</p>
<p>So I'd like not to have to use it like this:</p>
<pre><code>def getColumns(self, columns):
columns = [self.getColumn(**data) for data in columns]
column_data = ( {'name' : 'myName', 'type' : 'myType', 'other' : 'myOther'},
{'name' : 'myName2', 'type' : 'myType2', 'other' : 'myOther2'})
</code></pre>
<p>How do I get rid of the <code>'name':</code> and <code>'type':</code>?</p>
| python | [7] |
5,097,132 | 5,097,133 | PHP Show Google Analytics | <p>I use the fololowing code for all links going outisde my website:</p>
<pre><code>if ($_GET["url"])
{
$urll = base64_decode($_GET["url"]);
header("Location: ".$urll);
exit();
}
</code></pre>
<p>How can I show the Google Analytic's tracking code before the user is redirected so the page is tracked?</p>
<p>Could I just use a print statement?</p>
<p>Thanks.</p>
| php | [2] |
4,030,989 | 4,030,990 | Sorting of table | <p>I have looked at many sorting solutions for jQuery but haven't found what I'm looking for yet.</p>
<p>I am trying to sort a table which has rows and columns that need to be sorted: <a href="http://jsfiddle.net/rvezE/" rel="nofollow">http://jsfiddle.net/rvezE/</a></p>
<pre><code><table>
<tr>
<td>3</td>
<td>5</td>
<td>7</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>4</td>
</tr>
<tr>
<td>3</td>
<td>8</td>
<td>9</td>
</tr>
</table>
</code></pre>
<p>I need the table to be sorted from left to right, top to bottom. But all plugins I found so far can only sort by row.</p>
<p>I have tried a few simple solution by taking all the TD's out, sorting them and re-adding them, but for a large amount (around 100) the performance is terrible, it needs to be quite snappy for tablets too.</p>
<p>Anyone came across something like this?</p>
| jquery | [5] |
1,027,069 | 1,027,070 | adding 30 minutes to time using javascript - not working | <p>need some help with adding extra time to current time</p>
<pre><code>currentTime= new Date();
var hours2 = currentTime.getHours() + 4;
var minutes2 = currentTime.setMinutes(currentTime.getMinutes() + 30);
</code></pre>
<p>however it outputs as: 15:1455880112692PM and does not seem to be adding 4.5 hours? anyone have any ideas on this?</p>
| javascript | [3] |
1,605,395 | 1,605,396 | PHP foreach iterate twice instead of once | <p>I have a question regarding the foreach function in php:</p>
<p>At the moment I have:</p>
<pre><code><html>
<body>
<?php
$x=array("one","two","three", "four", "five", "six", "seven", "eight");
foreach ($x as $value)
{
echo $value . "<br />";
}
?>
</code></pre>
<p>
</p>
<p>Which outputs:</p>
<pre><code>one
two
three
four
five
six
seven
eight
</code></pre>
<p>But how do I make a foreach loop iterate twice instead of once so that I get:</p>
<pre><code>two
four
six
eight
</code></pre>
<p>Is this even possible? Or is it better to just use a for loop instead?</p>
<p>Any help will be appreciated, thank you.</p>
| php | [2] |
588,139 | 588,140 | Implementing horizontal and vertical scroll at a time in a custom list view | <p>I am developing a custom list view and putting data using a custom adapter.Normally the list scrolls vertically and it is working fine. But I need to show some more data in each row and need to scroll the list view horizontally also.
So, my query would be is it possible to club both horizontal and vertical scroll in a custom list view ?</p>
<p>Please help.</p>
<p>Regards,
Prithwish</p>
| android | [4] |
3,298,100 | 3,298,101 | date picker with current date in android | <p>I am using date picker but i have some problems with date and time picker. I need date picker dialog should appears with current date value. Similarly Time picker should appears with current time value. How to do this, please any body help.</p>
<p>Thnks. </p>
| android | [4] |
4,184,540 | 4,184,541 | How to get email from pop.gmail.com using c#? | <p>i want to read email from pop.gmail.com using console application.</p>
<pre><code>Pop3 client = new Pop3();
client.Connect("pop.gmail.com",995);
client.Login("xyz@searce.com", "12345");
//client.IsAuthenticated = true;
// get message list
Pop3MessageCollection list = client.GetMessageList();
if (list.Count == 0)
{
Console.WriteLine("There are no messages in the mailbox.");
}
else
{
// download the first message
MailMessage message = client.GetMailMessage(list[0].SequenceNumber);
}
client.Disconnect();
}
</code></pre>
<p>i got error server has closed the connection.
i have already disable firewall and antivirus.</p>
<p>plz help me.</p>
| c# | [0] |
4,104,520 | 4,104,521 | What is a good strategy for safely reading values out of a PHP array? | <p>I'm trying to read values from $_SESSION which may or may not be set, while avoiding undefined index warnings. I'm used to Python dicts, which have a <code>d.get('key','default')</code> method, which returns a default parameter if not found. I've resorted to this:</p>
<pre><code>function array_get($a, $key, $default=NULL)
{
if (isset($a) and isset($a[$key]))
return $a[$key];
else
return $default;
}
$foo = array_get($_SESSION, 'foo');
if (!$foo) {
// Do some foo initialization
}
</code></pre>
<p>Is there a better way to implement this strategy?</p>
| php | [2] |
5,691,828 | 5,691,829 | jquery - how could prevent clicked link when I move links with drag&drop? | <p>I allow move (drag&drop) some elements which contains inside link (<code>a</code>), After user drop it, it redirects browser to <code>href</code> of moved element. How could I allow to click that element and drag&drop its also?
I use <a href="http://dragsort.codeplex.com/" rel="nofollow">http://dragsort.codeplex.com/</a> plugin.</p>
| jquery | [5] |
641,448 | 641,449 | Is it possible to have a Conditional Compilation for ASP.NET comment? | <p>I'd like to do something like this</p>
<pre><code><# if ANYPREPROCESSORCONSTANT #>
<%--
<# endif #>
</code></pre>
<p>Is it possible (I want to put an asp.net COMMENT conditionally, I don't want to call a method conditionaly) ?</p>
<p>Update: seems impossible finally nobody could give any right answer :)</p>
| asp.net | [9] |
270,940 | 270,941 | Target child with jQuery | <p>I have the following code:</p>
<pre><code><div class="topLevel">
<span class="misc pointDown"></span>
<span class="misc"></span>
<span class="b">item</span>
</div>
</code></pre>
<p>When I click on the topLevel I need to replace "pointDown" with "pointUp". I think I have difficulty targeting the right element.</p>
<pre><code>$(".topLevel").live('click', function() {
$(this).next("span").removeClass("pointDown").addClass("pointUp");
});
</code></pre>
| jquery | [5] |
2,867,309 | 2,867,310 | Identical Javascript code works in separate file | <p>So I was beating my head against a wall, again and again, trying to find the error in my complex code. Finally, with nothing else to do, I copied and pasted the code into another file and called it code2.js and linked my hmtl file to this code. Suddenly, it works. Any ideas? It wasn't even the entire code went from broken to fixed, it was the new edit I was making went from broken to fixed. I know I was continuously saving the file, this was not the issue.</p>
<p>For background I use cpanel content managing system. Perhaps it's a bug in this?</p>
<p>Anyone seen anything like this?</p>
| javascript | [3] |
3,889,484 | 3,889,485 | c#.net function | <pre><code>namespace csfunction
{
class Program
{
static void Main(string[] args)
{
public int AddNumbers(int number1, int number2)
{
int result = AddNumbers(10, 5);
Console.WriteLine(result);
}
}
}
}
</code></pre>
<p>is my code...am getting error like.....Error Type or namespace definition, or end-of-file expected<br>
..hw can i over come this error</p>
| c# | [0] |
5,013,544 | 5,013,545 | Invalid Uri failure when trying to install an apk file programmatically | <p>I am trying to install apk files I store in the assets of my app (that will be moved to a external URL in the future). The app is for rooted devices and has the superuser granted permission. I am developing the app for devices that we own so we don't care about security at all, in case you wonder. </p>
<p>I get this error:</p>
<pre><code>05-14 09:27:18.205: E/(24879): pkg: file:///android_asset/myfile.apk
05-14 09:27:18.205: E/(24879): Failure [INSTALL_FAILED_INVALID_URI] (0)
</code></pre>
<p>every time I try this. What am I doing wrong? Thank you very much.</p>
<pre><code>private void install() throws IOException {
AssetManager assetManager = getAssets();
String[] files = null;
try {
files = assetManager.list("");
} catch (IOException e) {
Log.e("tag", "Failed to get asset file list.", e);
}
for(String filename : files) {
if (filename.endsWith(".apk")){
InputStream in = null;
try {
in = assetManager.open(filename);
Uri myuri = Uri.parse("file:///android_asset/" + filename);
String commands[]={"pm install " + myuri};
executeAsRoot(commands);
} catch(IOException e) {
Log.e("tag", "Failed to copy asset file: " + filename, e);
}
}
}
}
</code></pre>
| android | [4] |
4,095,552 | 4,095,553 | Conversion from string "31/03/2012" to type 'Date' is not valid | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/7945310/conversion-from-string-31-03-2012-to-type-date-is-not-valid">Conversion from string “31/03/2012” to type 'Date' is not valid</a> </p>
</blockquote>
<p>I tried Data.Parse and Convert.todatetime but now it says that
String was not recognized as a valid DateTime. I also configured .NetGlobalozation and setUI Culture to "English (United States) (en-US)" with the default "Invariant Language (Invariant Country)" but no use. What am i missing ?? The stack trace is as follows..</p>
<blockquote>
<p>[FormatException: String was not recognized as a valid DateTime.]<br>
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles) +2845862 System.DateTime.Parse(String s) +25
ProwessWebApp.Finyr.SSCreate_Click(Object sender, EventArgs e) in
E:\DevVB2008\ProwessWebApp\ProwessWebApp\ProwessWebApp\Finyr.aspx.vb:130
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111<br>
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +110<br>
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +10<br>
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +13<br>
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1565</p>
</blockquote>
<p>Can u plz tell me what to do ??
Dev..</p>
| asp.net | [9] |
6,012,930 | 6,012,931 | why int type value is not boxed as Integer | <pre><code>public class Test {
static void test(Integer x) {
System.out.println("Integer");
}
static void test(long x) {
System.out.println("long");
}
static void test(Byte x) {
System.out.println("byte");
}
static void test(Short x) {
System.out.println("short");
}
public static void main(String[] args) {
int i = 5;
test(i);
}
}
</code></pre>
<p>The output value is "long". </p>
<p>Can only tells me why it is not "Integer" since in Java, int value should be auto-boxed. </p>
| java | [1] |
2,404,767 | 2,404,768 | Working scrolling anchors | <p>Hi guys ive been trying to get smooth scrolling working on my anchors for ages but can never get it right.</p>
<p>Ive tried ifxscrollto plugin and it just flat out won't work for me and a few others.... anyone got suggestions?</p>
<p>PS: I want a script that automatically grabs named anchors.</p>
| jquery | [5] |
4,459,780 | 4,459,781 | jquery shake on mouse over? | <p>is it possible to shake a table row if mouse over? and if so how? =)</p>
<p>I have done it before when calling a div, but I havent as yet use the mouse over function, any help appreciated</p>
<p>Thanks =)</p>
| jquery | [5] |
5,944,710 | 5,944,711 | What does the b'' sentinel mean in Python iter()? | <p>Let's say I have a process that returns a bunch of lines, which I want to iterate through:</p>
<pre><code>import subprocess
myCmd = ['foo', '--bar', '--baz']
myProcess = subprocess.Popen(myCmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for myLine in iter(myProcess.stdout.readline, b''):
print myLine
</code></pre>
<p>What does the sentinel argument to <a href="http://docs.python.org/2/library/functions.html#iter" rel="nofollow"><code>iter()</code></a> do in this example, where I pass it the value <code>b''</code>? I think I understand <code>''</code> by itself — I stop iterating on an empty line — but I don't know what <code>b''</code> means. </p>
| python | [7] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.