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 |
|---|---|---|---|---|---|
4,674,397 | 4,674,398 | jQuery height() problem | <p>How do we go about accessing a height for a Gridview? The Gridview has a CSS attribute called height that is set to 800px, but I haven't been able to access anything with height()</p>
<p>$('ctl00_MainContent_grdPersonResults').height() = null </p>
<p>Any ideas?</p>
| jquery | [5] |
1,018,015 | 1,018,016 | Tool that detects duplicate javascript function names in a web page? | <p><strong>Background</strong></p>
<p>We have a web application in which several developers have written several .js files that manipulate the DOM and the problem of duplicate function names has crept into our application.</p>
<p><strong>Question</strong></p>
<p>Can anyone recommend a tool that will warn us when we accidentally write a web page with two javascript functions with the same name? </p>
<p><strong>Example</strong></p>
<p><em>HTML page</em></p>
<pre><code><script language="JavaScript" src="test.js" type="text/javascript"></script>
<script>function foo() {alert('bar');}</script>
</code></pre>
<p><em>test.js</em></p>
<pre><code>function foo() {alert('foo');}
</code></pre>
<p>Since foo() is declared twice in the page, apparently only the one that takes precedence is loaded. </p>
<p>The tools I've used seem to ignore this. Firebug only shows the loaded function. Netbeans will show both functions in navigator (without a warning), but only looks at one file at a time (ie, I can't point it at the HTML file and see it and the .js at the same time.) and web developer extensions allows me to look at everything at once, but no errors or warnings. Firefox's error console also throws no warning or error. Neither does IE.</p>
<p>Thanks!</p>
| javascript | [3] |
2,620,213 | 2,620,214 | Please explain Date object type conversion | <p>I just found a strange behaviour in SpiderMonkey and V8 javascript engines. Suggest finding an explanation would be a good school for everyone</p>
<p>The strange working code:</p>
<pre><code> var x = (new Date()).setHours(24, 0, 0, 0);
typeof x; // "number"
</code></pre>
<p>The working-as-expected code:</p>
<pre><code>var x = new Date();
x.setHours(24, 0, 0, 0);
typeof x; // "object"
x instanceof Date; // true
</code></pre>
<p>If we find the reason we'll understand how JavaScript works better</p>
| javascript | [3] |
3,347,826 | 3,347,827 | PHP installation on windows | <p>I want to install php in my system.For this
I have downloaded the php-5.3.5.tar.bz2 (zip file).
Now from this installation help link
<a href="http://www.php.net/manual/en/install.windows.installer.msi.php" rel="nofollow">http://www.php.net/manual/en/install.windows.installer.msi.php</a>
It is saying "Run the MSI installer and follow the instructions provided by the installation wizard. "</p>
<p>But i am not getting from where I can get MSI installer?</p>
| php | [2] |
6,000,513 | 6,000,514 | shouldOverrideUrlLoading is not working | <p>In my application, <strong>shouldOverrideUrlLoading</strong>() is not called on 4.0.3 version. I have tested it on 2.2 and 4.0.1 and they all are working fine.
Device name is <strong>HTC verizon</strong>.</p>
<p>My intent is to provide custom activities for mailto: and tel: links present in the page. Any ideas on how I can make this work if shouldOverrideUrlLoading() is never hit?</p>
<p>Please suggest</p>
| android | [4] |
3,380,001 | 3,380,002 | Method executing differently when same arguments are passed | <p>Same arguments passed on the same method for the same object. It usually will display true, which is what I expect. But... sometimes it displays false. About 2-3 out of 100 times. What is wrong with this method that would be causing this behavior?</p>
<p>year, month, and day are instance variables containing "2012", "4", "1" respectively.</p>
<pre><code>public boolean isInDateRange(String startDate, String endDate)
{
if(startDate == null || endDate == null){
return false;
}
Calendar today = Calendar.getInstance();
today.set(Integer.valueOf(year), Integer.valueOf(month), Integer.valueOf(day));
Calendar start = Calendar.getInstance();
//subtract 1 from the month parameter because java.util.Calendar's months
//go from 0 to 11 instead of 1 to 12.
start.set(Integer.valueOf(startDate.substring(0, 4)), Integer.valueOf(startDate.substring(5, 7)) - 1, Integer.valueOf(startDate.substring(8, 10)));
Calendar end = Calendar.getInstance();
end.set(Integer.valueOf(endDate.substring(0, 4)), (Integer.valueOf(endDate.substring(5, 7))) -1 , Integer.valueOf(endDate.substring(8, 10)));
return today.compareTo(start) >= 0 && today.compareTo(end) <= 0;
}
</code></pre>
<p>And here is what I am passing to it</p>
<pre><code>calendarDetails.getTuesday().isInDateRange("2012-05-01 00:00:00", "2012-05-01 00:00:00")
</code></pre>
| java | [1] |
3,008,377 | 3,008,378 | Why are conditional statements not working in this example? | <p>I'm a bit perplexed with this code. <code>$this->product</code> is an Object with 12 vars. The var_dump indicates that <code>$key</code> is a string.</p>
<pre><code>foreach ($this->product as $key => $val) {
if (($key !== "id") || ($key !== "weight")) {
var_dump($key);
} else {
print_r("Success" . $key);
}
}
</code></pre>
<p>Despite "id" and "weight" being present as var names and represented as strings within <code>$key</code> they are not caught with this conditional. Does anyone have any ideas?</p>
| php | [2] |
5,788,593 | 5,788,594 | Which is fine language for asp.net - C# or VB | <p>im going to digg asp.net deeply.To begin,i want to know which language has more features and advantages over the asp.net whether c# or VB.</p>
| asp.net | [9] |
2,431,958 | 2,431,959 | Convert aspx content to pdf | <p>I am using iTextSharp for convert aspx content to pdf . But facing problem for https site where page is secured and can't don lad as pdf. and geting error like
"Internet explorer was not able to open this internet site. The requested site </p>
<p>is either unavailable or cannot be found . Please try again later"</p>
| asp.net | [9] |
2,808,074 | 2,808,075 | jQuery calls twice a function | <p>When i click the .kontrahent div i want to use another jquery function to load xml document and append it to #info div, but when i click it get's called twice, i have no idea why it's not working. I have checked delegate,live,click and on methods.</p>
<p>jQuery code:</p>
<pre><code>$("#dane").on('click',".kontrahent",function(){
console.log($(this));
var konh_id = $(this).data("konhid");
show_info(konh_id);
$('#info').show();
});
</code></pre>
<p>Html code</p>
<pre><code><div class="row">
<div id="dane" class="span6">
<div class="kontrahent">
</div>
<div class="kontrahent">
</div>
<div class="kontrahent">
</div>
</div>
<div id="info" class="span8">TESTOWE INFORMACJE O KLIENCIE</div>
</div>
</code></pre>
<p>Then in console i have twice the selection</p>
| jquery | [5] |
1,584,483 | 1,584,484 | Sql Writer refuses to start | <p>I've got Visual Studio 2012 installed on Windows 7 64 bit machine. I am trying to install SQL Server express local DB amd get an error when the installer tries to start services. Here is the exact error message :</p>
<pre><code>Service "SQL Server VSS Writer failed to start. Verify you have sufficient privileges to start system services.
</code></pre>
<p>I am logged on to the machine as administrator. I have verified that the writter in Services is running and it is set to Auto.</p>
<p>I have no SQL Server installed on this machine as far as I know.</p>
<p>Im stumped. Anyone have any ideas? </p>
<p>Also when I try to start SQL Writer in Services I get the following error:</p>
<pre><code>Windows could not start the SQL Server VSS Writer service on local computer.
Error 1053: The server did not respond to the start or control request in a timely fashion.
</code></pre>
| asp.net | [9] |
5,221,143 | 5,221,144 | Confusion with Forms authentication and visual studio default asp.net site | <p>I've created new web application. Vs generated login, register and similar pages.
In web.config it put authentication type "Forms". I expected that all request would be redirected to Login page. And yet I can easily navigate to Home and About pages. </p>
<p>Why is that? How to make unauthenticated user to be redirected to Login page? I wonder if I add new pages, will they have same behaviour as just showing themselves to anybody?</p>
| asp.net | [9] |
4,006,664 | 4,006,665 | Extend MapActivity and another class: avoid multiple inheritance | <p>I would have a class hierarchy like in photo.</p>
<p>Usually in this case it's usefull pattern Decorator in Java, but with MapActivity is not possible, how can i do?</p>
<p><img src="http://dl.dropbox.com/u/278026/View.png" alt="Valid XHTML"></p>
| android | [4] |
2,420,548 | 2,420,549 | JavaScript Events like onclick and onload | <p>How to display the below using javascript 1.Display password in text form and after displaying when we click on reset button it should be asteriked
2.when we click on password textbox it should be blank</p>
| javascript | [3] |
2,414,001 | 2,414,002 | Using reference as template type | <p>In the following example, <code>Foo</code> is not doing what is intended, but I can't figure out why this is allowed to compile.</p>
<pre><code>#include <string>
#include <iostream>
typedef std::string& T;
T Foo(int & i)
{
return T(i);
}
int main()
{
int a = 1;
std::string & s = Foo(a);
}
</code></pre>
<p>I discovered this with templates, but the <code>typedef</code> shows that its unrelated to templates. Needless to say, <code>s</code> is not a valid string here. I would think that constructing the value in the return of <code>Foo</code> would produce a compile error.</p>
<p>What am I missing here?</p>
| c++ | [6] |
2,761,088 | 2,761,089 | Singleton Class in JavaScript | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1479319/simplest-cleanest-way-to-implement-singleton-in-javascript">Simplest/Cleanest way to implement singleton in JavaScript?</a> </p>
</blockquote>
<ol>
<li>What is the use of Singleton class?</li>
<li>Can anyone give me a scenario where
Singleton class be applied?<code>{ If i
am developing an Mobile App using
JavaScript, what could be my
Singleton Class here }</code></li>
<li>Any examples on how to create
Singleton Class in JavaScript.</li>
</ol>
| javascript | [3] |
2,193,231 | 2,193,232 | Linked list of different classes - in a maintanable way? | <p>Yo people,</p>
<p>My problem is, I have to find a way to easily maintain the next situation:
I have a linked list of different classes. I use void pointers, every class has "int type" as its first member.</p>
<p>Now when I want to call a class member function, I have to do this:
- Read the int, so I know the type of the class.
- I call a generic function with the type information, and also the "function" information to know which class member function to call.</p>
<p>So its basically a switch case in a switch case like this:</p>
<pre><code>void command(void *&pointer, int type, int function)
{
switch (type)
{
case 1:
switch (function)
{
case 1:
reinterpret_cast<myClass *>(pointer)->doSomething();
}
}
}
</code></pre>
<p>I do not even know what to do when a function, like "doSomething()" will need some arguments.</p>
<p>And it is a total mess anyway. I am sure there is a better way than this, but do not know what is it.</p>
<p>Anyone care to enlighten me?</p>
| c++ | [6] |
5,671,804 | 5,671,805 | delete specific entries | <p>I'm creating a jquery script that could create new form fields, i can create them but how can i delete the specific entries (referenced by class name class="inimene_'+count+'")</p>
<pre><code><script>
var count = 0;
function add(){
count ++;
var code = '<div class="inimene_'+count+'"><p>Eesnimi: <input type="text" id="eesnimi_'+count+'" /></br>Perenimi: <input type="text" id="perenimi_'+count+'" /></br>Pilet: <select><option selected>Vali pileti liik</option><option value="100.00 Kr">Täiskasvanu</option><option value="25.00 Kr">Õpilane 5-12kl</option><option value="3">Laps kuni 4kl</option></select>Summa: <input type="text" id="summa_'+count+'" /> Linn/Maakond <input type="text" id="linn_'+count+'" /> Rivi: <input type="checkbox" id="rivi_'+count+'" /><input type="button" id="kustuta" onclick="delete()" value="Kustuta" /></p></div>'
$('#container').append(code)
$('#val').val(count)
}
function delete(){
$('.inimene:last').remove();
}
$(document).ready(function(){
$('.add').click(add)
});
</script>
</code></pre>
| jquery | [5] |
4,406,107 | 4,406,108 | Is this a variant of the Module pattern? | <p>What is this pattern called? Is this a variant of the Module pattern? I remember there's disadvantage to this pattern and it's related to memory usage. </p>
<pre><code>var module = function() {
this.Alert = function() {
alert("I'm a public");
}
function iamPrivate() {
alert("not callable because I'm private");
}
}
var inst = new module();
inst.Alert();
</code></pre>
| javascript | [3] |
4,505,491 | 4,505,492 | How do I run javascript examples from sites like stackoverflow? | <p>What needs to be added inorder to run an example like what is found on here: <a href="http://stackoverflow.com/questions/3103962/converting-html-string-into-dom-elements">Converting HTML string into DOM elements?</a> in a basic HTML document?</p>
<p>Specifically I'm referring to the code:</p>
<pre><code>var xmlString = "<div id='foo'><a href='#'>Link</a><span></span></div>"
, parser = new DOMParser()
, doc = parser.parseFromString(xmlString, "text/xml");
doc.firstChild // => <div id="foo">...
doc.firstChild.firstChild // => <a href="#">...
</code></pre>
<p>I have tried:</p>
<pre><code><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
var xmlString = "<div id='foo'><a href='#'>Link</a><span></span></div>"
, parser = new DOMParser()
, doc = parser.parseFromString(xmlString, "text/xml");
doc.firstChild;
doc.firstChild.firstChild;
</script>
</body>
</html>
</code></pre>
<p>As a beginner to javascript, a complete html copy and paste solution would be good to see how precisely it fits in.</p>
| javascript | [3] |
1,651,817 | 1,651,818 | How to use viewGroup in android | <p>How to use viewGroup in android</p>
| android | [4] |
1,281,718 | 1,281,719 | Each time I view a php page on localhost, it downloads the page | <p>I have altered the httpd.conf file good to my knowledge by adding index.php in the directory index, </p>
<pre><code>LoadModule php5_module "d:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
PHPIniDir "d:/php"
</code></pre>
<p>But any .php file I load, it downloads it.</p>
<p>Any help would be appreciated.</p>
<p>Thanks
Jean</p>
| php | [2] |
2,996,788 | 2,996,789 | Measuring smooth scrolling performance | <p>Is there any way to measure scroll performance in an iPhone app, e.g. updates per second? I'm trying various techniques to improve the scrolling performance but it's sometimes hard to judge if they're actually having an effect.</p>
| iphone | [8] |
3,830,560 | 3,830,561 | How do I show only current selected image and hide it if not select? | <p>Here an example <a href="http://jsfiddle.net/6GdW6/" rel="nofollow">http://jsfiddle.net/6GdW6/</a></p>
<pre><code>$(".thumbnail").live("click", function() {
$(".fullimage").hide();
var i = $("<img />").attr("src", this.href).load(function() {
$(".fullimage").attr("src", i.attr("src")).addClass("selected");
$(".fullimage").fadeIn();
});
return false;
});
</code></pre>
<ol>
<li>How to show first image by default if no click?</li>
<li>How to add <code>selected</code> class only on active link?</li>
</ol>
<p>I want to keep current <code>html</code> format.</p>
| jquery | [5] |
5,816,272 | 5,816,273 | Android pptx to image convert | <p>Can anyone please help me how to show pptx file in android or how to convert pptx to image?I am tried with apache POI but i can't run it in android.Please help me with code.</p>
| android | [4] |
4,816,708 | 4,816,709 | Java search a text file | <p>I have made a phone bill system takes input of phone number called, date of the call and call length. it the saves it in to a text file. what i have not been able to do is search the text file for the phone number.</p>
<p><a href="http://pastie.org/3691596" rel="nofollow">My coding</a></p>
| java | [1] |
3,456,170 | 3,456,171 | How do I fix the error Incompatible pointer types sending 'NSString _strong' to parameter of type 'UIViewController*'? in Xcode | <p>Can anyone help me fix this error? Here is everything in the ViewController.m file. I've tried fixing it and searching online but nothing is helping. I already declared the GameScreenViewController, but now when I click the play button it goes to a black screen instead of a different screen I made. In the All Output it says 2012-06-05 12:54:52.652 parkour[4705:f803] Application tried to push a nil view controller on target </p>
<pre><code>-(IBAction)switchScreens:(id)sender{
UINavigationController *navigationController = [[UINavigationController alloc]
**initWithRootViewController:GameScreenViewController];**
[self presentViewController:navigationController animated:YES completion: nil];
}
@end
</code></pre>
| iphone | [8] |
5,663,992 | 5,663,993 | jQuery.noConflict and how to use it | <p>i try to use <code>jQuery.noConflict()</code> but in window.load function i get a "$ is not a function" error.</p>
<p>my code:</p>
<pre><code>jQuery.noConflict();
jQuery(document).ready(function($) {
/** Dropdown Menu **/
$('ul.tabs li:has(ul)').bind("click", function() {
$(this).find('ul').show('normal');
//event.stopPropagation();
});
$('ul.tabs li').bind("mouseleave", function() {
$(this).find('ul').hide('normal');
//event.stopPropagation();
});
});
jQuery(window).load(function($) {
$('#container').fadeIn('normal');
});
</code></pre>
<p>if i use jQuery instead of '$' it works fine, but is it possible to continue use the '$'?<br>
anyone knows/understand what is wrong with this?<br>
thanks!</p>
| jquery | [5] |
2,759,389 | 2,759,390 | Adding dot between two characters in java string | <p>I have a string :</p>
<pre><code>String x = "10";
</code></pre>
<p>i want to print it like this
1.0</p>
<p>I want to add "." between numbers </p>
<p>how??</p>
| java | [1] |
1,438,201 | 1,438,202 | Subtracting from div height in jQuery | <p>today I have a quick question. Here is my function:</p>
<pre><code>function checkheight() {
var heightofdiv = $('#checkforheight').height();
$("#centeredbackground").css("min-height",heightofdiv);
}
</code></pre>
<p>My problem is that I want to get my variable, heightofdiv, and then subtract the answer by 42 pixels. So really, I want heightofdiv to be equal to the height of checkforheight minus 42 pixels. If this is even possible, help would be greatly appreciated. Thanks!</p>
| jquery | [5] |
1,210,299 | 1,210,300 | How to add Icon in Android Application ? | <p>I have seen in android native Email application that it updates the icon by showing how many new mails are there ?
Is it a service that updates the icon or is it a process who does it ?
Can someone tell me which file does this change ?</p>
| android | [4] |
4,294,351 | 4,294,352 | Annotating C# code in arbitrary levels without obfuscating the code too much? | <p>I'm looking for the best way to do the following in C#.</p>
<p>Say I have a certain set of instructions:</p>
<pre><code>int a = 1;
int b = 2;
if (a==b) {return;}
...
</code></pre>
<p>I need to get some information per instruction or sets of instructions. So I annotate the code, roughly as follows:</p>
<pre><code>Console.WriteLine("a");
int a = 1;
Console.WriteLine("a");
int b = 2;
Console.WriteLine("if");
if (a==b) {
Console.WriteLine("ret");
return;}
...
</code></pre>
<p>Now suppose I need to have much more complete information about each instruction, actually several classes with some methods, and I want to even pass some information to those classes. Annotating the code like that certainly obfuscates the code to a point where it's practically unreadable. Imagine lots of prints in-between instructions, for instance.</p>
<p>My question, finally, is: is there a way (would <code>[Attributes]</code> help here?) to annotate code with arbitrary levels of complexity of the annotations, without cluttering it? I can imagine something like attributes, which would look like </p>
<pre><code>[Class.variable("a")]
int a = 1;
[Class.variable("a")]
int b = 2;
[Class.instruction("if")]
if (a==b) {
[Class.instruction("ret")]
return;}
...
</code></pre>
<p>while each class does a lot of stuff? If the above example with atts work, could someone give me an example of how it would work "for real" and not in pseudocode?</p>
<p>Thanks very much.</p>
| c# | [0] |
2,706,195 | 2,706,196 | jQuery event "looping" | <p>I´m trying to code a tooltip (Yes I know, I have my reasons to avoid plugins in this case) in jQuery.</p>
<p>Whe I show the tooltip and leave the mouse in the same place the show and hide repeats forever. It´s like the element triggers the hover event again and again and again.</p>
<p>I try unbind for the event but it does not work neither.</p>
<pre><code>$("td.with-tooltip").mouseover( function() {
var offset = $(this).offset();
var baseX = offset.left;
var baseY = offset.top;
var inputWidth = $(this).width();
var baseX = baseX + 50;
var baseY = baseY - $(".desc").height();
$(".desc div").html($(this).attr("title"));
$(".desc").css({"position":"absolute", "left": baseX, "top": baseY }).fadeIn();
$(this).unbind("mouseover");
}).mouseleave( function() {
$(".desc").fadeOut();
});
</code></pre>
<p>What can I do?</p>
<p>thanks.</p>
<p>I solved with this code, thanks for everybody, really.</p>
<p><code><pre>
var t;
var xOffset;
var yOffset;</p>
<pre><code>$("td.with-tooltip").hover(function(e){
t = $(this).attr("title");
$(this).attr("title", "");
$(".desc div").text(t);
xOffset = $(".desc").height() + 30;
yOffset = -20;
$(".desc").css("position","absolute")
.css("botton",(e.pageY + xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px").fadeIn("fast");
},
function(){
$(this).attr("title", t);
$(".desc").fadeOut("fast");
});
$("td.with-tooltip").mousemove(function(e){
$(".desc")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
</code></pre>
<p></pre></code></p>
| jquery | [5] |
1,765,064 | 1,765,065 | Can't execute python scripts, permission denied? | <p>I'm trying to compile a project using "appcelerator" (crossplatform dev for iphone/android). Just evaluating it. It seems to run some python scripts to do the build, but can't get it to work (and not getting anywhere on the help forums there). Seems like a permissions error, but I can't figure it out. Thought I'd try here in case this is a familiar thing in python:</p>
<pre><code>Exception occured while building project:
Traceback (most recent call last):
File "/Library/Application Support/Titanium/mobilesdk/osx/1.8.2/android/builder.py", line 2089, in <module>
s.build_and_run(True, avd_id, device_args=device_args)
File "/Library/Application Support/Titanium/mobilesdk/osx/1.8.2/android/builder.py", line 1934, in build_and_run
run_result = run.run(dex_args, warning_regex=r'warning: ')
File "/Library/Application Support/Titanium/mobilesdk/osx/1.8.2/android/run.py", line 36, in run
process = subprocess.Popen(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 595, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1106, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
</code></pre>
<p>I've set the permissions for "run.py" and "builder.py" to 777. The "subprocess.py" file also is 777. I'm still getting the permission denied error. Is there something obvious I'm missing here? I'm an admin user, on os 10.6. </p>
<p>Thanks</p>
| python | [7] |
3,604,295 | 3,604,296 | Best synchronisation strategy | <p>I have a simple app which is writing to an xml file on every button click. Once this is done, I read the Xml file soon after (as in, a couple of lines below with no methods to be stepped in to in between).</p>
<p>When the app runs for the first time, the xml file is written to/read from fine, but if I press the button again I get a "File is in use by another process". I am doing the whole flush, close, dispose thing with my streams and intend on using ProcessMon to check what process is holding the file.</p>
<p>Programatically, what is the best strategy to avoid this problem?</p>
<p>Thanks</p>
| c# | [0] |
3,190,057 | 3,190,058 | "Couldn't get connection factory client"API Key is fine | <p>Ok this has been making me crazy. I get the following crash (Couldn't get connection factory client), but my Maps API key is fine. </p>
<p>This line causes the crash</p>
<pre><code> mapView.getProjection().toPixels(point, somePoint);
</code></pre>
<p>But if I omit the toPixels part it runs fine, but does not do what I want it to do(display an image on a map).</p>
<p>Any guidance? This seems like a different issue than the API key issue and I am testing on a device running Android 2.2, if that it matters. </p>
| android | [4] |
3,699,909 | 3,699,910 | Android: Make parent selector trigger when selecting child | <p>I have a LinearLayout with some other LinearLayouts inside. The children layouts have a background selector set. I need to change the color of the parent layout as well when a children is pressed. I have set a background selector as well for the parent, but it only triggers when clicking outside of any children.</p>
<p>How can I avoid this?</p>
<p>Thanks!</p>
| android | [4] |
5,772,903 | 5,772,904 | eclipse - stuck with chinese in android virtual device | <p>When I run my android emulator in eclipse, all my keyboard characters gets translated to chinese when I try to write text. Why is this?</p>
<p>Thanks</p>
| android | [4] |
3,589,412 | 3,589,413 | Find all image links and add a class to it | <p>If I have a bunch of links to an image like this:</p>
<pre><code><a href="foo.png">foo.png</a> <a href="foo.jpg">foo.jpg</a> <a href="foo.gif">foo.gif</a>
</code></pre>
<p>How would I find it all with js and then add a class?</p>
<p>This is what I was thinking but that didn't work:</p>
<pre><code>$('a[href*=.png]').addClass('image-link');
$('a[href*=.jpg]').addClass('image-link');
$('a[href*=.gif]').addClass('image-link');
</code></pre>
<p>UPDATE: There was a typo in my js. The above works.</p>
| jquery | [5] |
824,093 | 824,094 | Equalizer in android implement | <p>i need to improve in sound. i have build an app in which i record from MediaRecoder class.i got success in recording but when i play it, i got loud vocal sound.i found that <a href="http://developer.android.com/reference/android/media/audiofx/Equalizer.html" rel="nofollow"><strong>Equalizer</strong></a> class is smart help for me. so i have try to implement it. but i found that it required <code>API Level 9</code>. and i want to record in 2.2(Level 8) so what i do for lower version so i can easily use in <code>level 8</code></p>
<p>is there any alternet solution for it</p>
| android | [4] |
25,027 | 25,028 | NOTHING as String in PHP | <p>How I can show <code>'NOTHING'</code> as string?</p>
<p>I need it to be displayed instead of showing empty string value as results.</p>
<pre><code>else if ($colorByChance == 5)
{
$color='NOTHING';
}
</code></pre>
| php | [2] |
2,097,069 | 2,097,070 | Append a word to ID attribute when it is hidden and remove it when toggle to show | <ol>
<li>I have two input fields that need to hide when first visit. </li>
<li>There will be a button to toggle it to show the fields so it could be edited.</li>
<li>The appending word (i.e. _temp) with the id is just to change the id name so that it doesn't save over again if it's not necessary. When the fields are showing the append word (_temp) needs to be removed.
(i.e. (<strong>Original Id Name</strong>: payment_gateway_login) (<strong>Append Id Name</strong>: payment_gateway_login_temp), when fields are showing remove append id name so it should be back to original: payment_gateway_login, the same should follow with id="payment_gateway_password".</li>
<li>Below is as far as I can get. Any help would be greatly appreciated.</li>
</ol>
<p>HTML:</p>
<pre><code><ul>
<li class="show-hide-container hide" style="display: list-item; ">
<ol>
<li class="password input required stringish" id="payment_gateway_login_input">
<input id="payment_gateway_login" name="payment_gateway[login]" type="password">
</li>
<li class="password input required stringish" id="payment_gateway_password_input">
<input id="payment_gateway_password" name="payment_gateway[password]" type="password">
</li>
</ol>
</li>
<li class="clearfix edit-login-pass"> <a href="#" class="btn" id="show_hide">Edit Login &amp; Password</a>
</li>
</ul>
</code></pre>
<p></p>
<p>JQUERY:</p>
<pre><code>$("input#payment_gateway_login").attr("id", "payment_gateway_login" + "_temp");
$("input#payment_gateway_password").attr("id", "payment_gateway_password" + "_temp");
$("#show_hide").live("click", function(event) {
return $("li.show-hide-container").toggle("show");
});
</code></pre>
<p></p>
| jquery | [5] |
298,017 | 298,018 | regular expression for spaces and words | <p>have the following text file:</p>
<pre><code><div>
<asp:HyperLinkField HeaderText="Hello World of Regular Expression" />
</div>
</code></pre>
<p>How do i get what's between the double quotes for any word and spaces?</p>
<p><strong>Updated:</strong></p>
<pre><code>//This one gets me close but doesn't get me strings with spaces in them
var match = Regex.Match(tokens[1], @"HeaderText=\""(\w+)\""");
//This was suggested below. It shows correct match count but values are just empty strings
var match = Regex.Match(tokens[1], @"HeaderText=""[^""]+""|[\w]+");
if (match.Success)
{
yield return new KeyValuePair<string, string>(
file, match.Groups[1].Value //This is empty for 2nd scenario
);
}
</code></pre>
| c# | [0] |
563,076 | 563,077 | How can I display different phrases depending on the time of day with javascript? | <p>For example, if it's between 8 and 1 pm, it would say "good morning", if it's 1:01-6:00 pm, it would say "good afternoon" and if it's between 6:01-11:59, it would say "good evening"</p>
<p>How do I go about doing that using javascript/jquery?</p>
| javascript | [3] |
3,480,005 | 3,480,006 | How to start ringing with default ringtone? | <p>I need to start ringing with default system ringtone. Which must be a datasource for MediaPlayer ?</p>
| android | [4] |
3,594,794 | 3,594,795 | Save output of $_SERVER to file | <p>I use this :</p>
<pre><code><?php
foreach($_SERVER as $key => $value){
echo "<b>$key:</b> $value<br>\n";
}
?>
</code></pre>
<p>Which outputs in browser. Is there anyway to redirect output to file and hide it from the browser page ?</p>
| php | [2] |
5,023,672 | 5,023,673 | Java 2D game camera without scrolling the world | <p>I've just finished a month long project of building a very complex map / world editor for a 2D tile rpg type game. Now I'm at the point where I'd like to actually play the game and am in the process of creating the runtime implementation of the game using the maps, characters, and other things that were generated through the map editor. I know almost exactly what I am doing, aside from the camera. I cannot think of a way to make the camera work in a way similar to games like zelda(gameboy) (where the camera is fixed on the character) without scrolling the (x,y) values of every sprite and tile in my game everytime the player moves. I've looked into some game engines but I'm not convinced that is what I need, though I'm very willing to be wrong on that assumption. The entire game is done with images, there are no rendered shapes, which leads me to believe that I do not need to mess around with openGL to make the camera work as desired. Could anyone suggest a way to implement a camera without using openGL? I'm not against using openGL but I'd rather not learn it if I dont need to as I am crunched for time already with other projects. Thank you for the suggestions.</p>
| java | [1] |
4,643,075 | 4,643,076 | erase all data from txt file - php | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4297570/how-do-i-purge-the-contents-of-a-text-file-in-php">How do i purge the contents of a text file in php</a> </p>
</blockquote>
<p>Hi..</p>
<p>How can I erase all the data stored (make blank) in my text file <code>myfile.txt</code> using php??</p>
| php | [2] |
41,198 | 41,199 | please tell me what is exception in this code | <pre><code>NSString *qry=@"UPDATE TABLE USERBASIC SET F_NAME='%@',M_NAME='%@',L_NAME='%@' WHERE REGISTRATIONID='%@'";
NSString *updtQuery=[[NSString alloc] stringWithFormat:qry,fname.text,mname.text,lname.text,userInformationId];
NSLog(@"try UPDATE %@:",updtQuery);
</code></pre>
<p>this gives invalid argument exception.. :(</p>
| iphone | [8] |
1,648,135 | 1,648,136 | English and/or Finnish text validation | <p>Is there an easy-to-use python module that'd do english or finnish text validation?</p>
<p>It'd be ok if I could just check the words exist in user-defined dictionary and possibly checking that the grammar is somewhat okay.</p>
<p>I am planning to implement a fancy validation for a directory contents I did while ago back. This involves some simple stuff like checking that the config scripts won't crash and does it all well. It's all quite easy otherwise.</p>
<p>For the validator I should just be able to input whole files or strings of unicode text.</p>
| python | [7] |
383,473 | 383,474 | How to install pymorph on windows? | <p>I am very new to python so sorry if this is a trivial question. I am developing on windows and I want to install the following library <a href="http://pypi.python.org/pypi/pymorph" rel="nofollow">pymorph</a></p>
<p>I know it can be installed on linux but how to install it on windows enviroment ?</p>
<p>Thanks</p>
| python | [7] |
75,382 | 75,383 | Why does java have new? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/433591/why-do-c-and-java-bother-with-the-new-operator">Why do C# and Java bother with the “new” operator?</a> </p>
</blockquote>
<p>Why does java have the new keyword? To create an object of type <code>A</code>, I have to type <code>A a = new A()</code>.</p>
<p>Java doesn't have stack allocation, so why couldn't that just be simplified to <code>A a = A()</code>?</p>
| java | [1] |
5,494,488 | 5,494,489 | Object gets stored in session, but while retrieving it is null | <p>On page load I am populating my own object, storing in session & it is getting stored,
When I am debugging i can see that object is stored in session, But When I am reading that session variable.. it is null,</p>
<p>Surprizingly I am able to use other session variables,</p>
<p>Howerver I am able to get the session variable when my sessionstate = "InProc"... and I get it null when sessionstate='StateServer' or sessionstate='SQLServer'</p>
<p>I've kept session TimeOut="20",
On the page I've added EnableSessionState="True"</p>
<p>Please help,
- Prashant C</p>
| c# | [0] |
1,583,470 | 1,583,471 | How to use a class as the base, but hide the class type publically? | <p>I am currently just exposing the properties through a generic interface e.g.</p>
<pre><code>public interface IBaseClass
{
int ID { get; set; }
}
internal class MyBaseClass : IBaseClass
{
public MyBaseClass() { }
public int ID { get; set; }
}
public class MyExposedClass : IBaseClass
{
private MyBaseClass _base = new MyBaseClass();
public int ID
{
get { return _base.ID; }
set { _base.ID = value; }
}
}
</code></pre>
<p>Then in my main application I can do:</p>
<pre><code>IBaseClass c = new MyExposedClass();
c.ID = 12345;
</code></pre>
<p>But can't do:</p>
<pre><code>MyBaseClass b = new MyBaseClass();
</code></pre>
<p>This is my desired behaviour. </p>
<p>However, I was just wondering if this is the correct approach? Or if there was a better way?</p>
| c# | [0] |
6,023,198 | 6,023,199 | (accelerated C++) chapter managing memory | <p>I am going through accelerated C++ and I am stuck in exercise 10.3 and I have literally no clue how to even start. I would like to mention here that its not homework exercise and I am reading it just to gain confidence in C++ . The question is shown below .</p>
<blockquote>
<p>Rewrite the median function from §8.1.1/140 so that we can call it
with either a vector or a built-in array. The function should allow
containers of any arithmetic type.</p>
</blockquote>
<p>The code for above question is given below</p>
<pre><code>template <class T>
T median( vector<T> v)
{
typedef typename vector<T>::size_type vec_sz;
vec_sz size = v.size();
if( size == 0 )
{
throw domain_error(" median of an empty vector");
}
sort( v.begin(), v.end() );
vec_sz mid = size /2;
return size%2 == 0 ? ( v[mid]+v[mid+1])/2 : v[mid] ;
}
</code></pre>
<p>I have no clue what to do next. Any help or criticism will be beneficial to me.
Thanks and regards</p>
| c++ | [6] |
5,078,161 | 5,078,162 | Should hardcoded data in a function be static? | <p>When I have hardcoded data in a function I could just initialize the variable normally:</p>
<pre><code>function check_country() {
$countries = array(
'aa',
'ab',
'ae',
...
);
}
</code></pre>
<p>Will PHP just make <code>$countries</code> <em>point</em> to the literal data in memory or will it <em>copy over</em> all the initialization data to a new ZVAL or whatever?</p>
<p>If it does the latter that would be basically equivalent to this, wouldn't it?</p>
<pre><code>function check_country() {
$countries = array();
$countries[] = 'aa';
$countries[] = 'ab';
$countries[] = 'ae';
}
</code></pre>
<p>An alternative would be to make the variable static and initialize it like this:</p>
<pre><code>function check_country() {
static $countries;
if (!isset($countries))
{
$countries = array(
'aa',
'ab',
'ae',
...
);
}
}
</code></pre>
<p>Is this technique a) faster and does it b) require twice the memory?</p>
| php | [2] |
1,505,012 | 1,505,013 | How to remove text input when button is clicked | <p>I have a jquery function below when when an upload has been completed, it will store the name of the file in a string and it's id in a text input. Now at bottom of function, if the user clicks on the <code>deletevideofile</code> button, then it is able to remove the file name which is fine but my question is how can I remove the text input? I can't seem to get the text input to be removed.</p>
<p>Below is code:</p>
<pre><code>function stopVideoUpload(success, videoID, videofilename){
var result = '';
videocounter++;
if (success == 1){
result = '<span class="videomsg'+videocounter+'">The file was uploaded successfully</span>';
$('.listVideo').eq(window.lastUploadVideoIndex).append('<input type="text" name="vidid" value="' + videoID + '" />');
$('.listVideo').eq(window.lastUploadVideoIndex).append('<div>' + htmlEncode(videofilename) + '<button type="button" class="deletefilevideo" video_file_name="' + videofilename + '">Remove</button><br/><hr/></div>'); }
var _videocounter = videocounter;
$('.listVideo').eq(window.lastUploadVideoIndex).find(".deletefilevideo").on("click", function(event) {
var video_file_name = $(this).attr('video_file_name');
jQuery.ajax("deletevideo.php?videofilename=" + video_file_name)
.done(function(data) {
$(".videomsg" + _videocounter).html(data);
});
$(this).parent().remove();
});
return true;
}
</code></pre>
| jquery | [5] |
2,112,880 | 2,112,881 | How to update system clipboard when Toolkit.getDefaultToolkit().getSystemSelection() returns null. | <p>The following code:</p>
<pre><code>Toolkit.getDefaultToolkit().getSystemSelection().setContents(
new StringSelection(a), null);
</code></pre>
<p>returns <code>null</code> because it is not supported on my Computer. But, I am wondering how I set my Computers selection if it does not support this. There has to be another way obviously. But how?</p>
| java | [1] |
3,674,975 | 3,674,976 | Reminder application | <p>I am developing a reminder application. I am generating notifications using notification manager class, when the timeline crosses.But if my cell phone is switched off ,I am unable to see these notifications. Not even when i switch it on again.</p>
<p>Even if i switch it off and switch on again, i think the pending intents are destroyed and no notification is generated.</p>
<p>How do i get it when the phone is switched on again ?</p>
| android | [4] |
5,540,158 | 5,540,159 | Why i need versioning in my IPhone apps? | <p>I don't understand, why i need versioning in my IPhone apps.Could anyone explain. </p>
| iphone | [8] |
1,034,954 | 1,034,955 | mediaplayer dies android | <p>i have a little problem with the media player class. I have a button, and by pressing it a sound will be played. The thing is that there is some delay between when i press the button and when the sound is played, and if i press it too many times the media player dies, and then no sound is played at all and i get the following errors: </p>
<pre><code>ERROR/MediaPlayer(3960): error (-19, 0)
ERROR/AudioTrack(3931): AudioFlinger could not create track, status: -12
ERROR/AudioSink(3931): Unable to create audio track
</code></pre>
<p>Here's the code:</p>
<pre><code>Button b = (Button)findViewById(R.id.button);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
AssetFileDescriptor afd;
try {
afd = getAssets().openFd("bassdrum6.mp3");
player = new MediaPlayer();
player.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(),afd.getLength());
player.prepare();
player.start();
} catch (IOException e) {
e.printStackTrace();
}
}
});
</code></pre>
<p>I don't know what's wrong here. I need some help.</p>
<p>Thanks in advance.</p>
| android | [4] |
5,850,139 | 5,850,140 | Override the arity of a function | <p>I would like to make a generic function wrapper that (for example) prints the called function and its arguments.</p>
<p>Doing so is easy through the <code>arguments</code> quasi-array and simple calls. For example:</p>
<pre><code>function wrap(target, method) {
return function() {
console.log(Array.prototype.slice.call(arguments).join(', '));
return method.apply(target, arguments);
}
}
</code></pre>
<p>However, this way of doing of course completely loses the arity of the called function (if you didn't know, one can obtain the arity (number of arguments) of a JavaScript function through its <code>length</code> property).</p>
<p>Is there any way to dynamically create a wrapper function that would copy the arguments of the wrapped function to itself?</p>
<hr>
<p>I've thought about creating a new <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function" rel="nofollow">Function object</a>, but I don't see any way to statically extract the arguments list, since the <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/arguments" rel="nofollow"><code>arguments</code> property</a> is deprecated.</p>
| javascript | [3] |
4,110,560 | 4,110,561 | Custom date sort in jquery datatable | <p>I am using jquery datatable and my html table's one of the column contains dates.</p>
<p>So how can we write custom date sort function? It is by default sorting as String.</p>
| jquery | [5] |
4,307,470 | 4,307,471 | How to make Local Notification in android? | <pre><code>public class ChildLock extends Activity implements OnClickListener
{
ProgressDialog dialog;
int increment;
int maximum ;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button startbtn = (Button) findViewById(R.id.startbtn);
startbtn.setOnClickListener(this);
}
@Override
public void onClick(View arg0)
{
EditText et = (EditText) findViewById(R.id.increment);
// convert the text value to a integer
increment = Integer.parseInt(et.getText().toString());
dialog = new ProgressDialog(this);
dialog.setCancelable(true);
dialog.setMessage("Loading...");
// set the progress to be horizontal
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
// reset the bar to the default value of 0
dialog.setProgress(0);
// get the maximum value
EditText max = (EditText) findViewById(R.id.maximum);
// convert the text value to a integer
maximum = Integer.parseInt(max.getText().toString());
// set the maximum value
dialog.setMax(maximum);
// display the progressbar
dialog.show();
// create a thread for updating the progress bar
Thread background = new Thread (new Runnable() {
public void run()
{
try
{
while(dialog.getProgress()<= dialog.getMax())
{
// wait 500ms between each update
Thread.sleep(500);
// active the update handler
progressHandler.sendMessage(progressHandler.obtainMessage());
}
}
catch (java.lang.InterruptedException e)
{
// if something fails do something smart
}
}
});
background.start();
}
// handler for the background updating
Handler progressHandler = new Handler()
{
public void handleMessage(Message msg)
{
if(dialog.getProgress()== dialog.getMax())
{
Intent i = new Intent(ChildLock.this, notifi.class);
startActivity(i);
}
dialog.incrementProgressBy(increment);
}
};
}
</code></pre>
| android | [4] |
2,855,622 | 2,855,623 | How to preserve scroll position in an ExpandableListView | <p>in my app I have a class derived from ExpandableListActivity.
When I scroll the contents, and then change phone orientation or edit an item and then go back to the list, the original list position is not preserved.
I have tried two solutions, similar to those I have recently successfully used with ListActivity-derived classes.</p>
<p>Solution 1:</p>
<pre><code>protected void onRestoreInstanceState(Bundle state) {
super.onRestoreInstanceState(state);
mListState = state.getParcelable(LIST_STATE);
}
protected void onResume() {
super.onResume();
loadData();
if (mListState != null)
getExpandableListView().onRestoreInstanceState(mListState);
}
protected void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
mListState = getExpandableListView().onSaveInstanceState();
state.putParcelable(LIST_STATE, mListState);
}
</code></pre>
<p>Solution 2:</p>
<pre><code>protected void onRestoreInstanceState(Bundle state) {
super.onRestoreInstanceState(state);
mListPosition = state.getInt(LIST_STATE);
}
protected void onResume() {
super.onResume();
loadData();
getExpandableListView().setSelection(mListPosition);
}
protected void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
mListPosition = getExpandableListView().getFirstVisiblePosition();
state.putInt(LIST_STATE, mListPosition);
}
</code></pre>
<p>Neither solution works. I have also tried to combine the two solutions, and this works when I edit an item and go back to the list, but it does NOT work when I change the phone orientation</p>
<p>Anyone can suggest a good way to achieve my goal?</p>
| android | [4] |
3,733,354 | 3,733,355 | Attach a pan gesture recognizer an image | <p>Could someone guide in what I need to do? I need to attach a pan gesture recognizer to an image which rotate clockwise and anticlockwise as we move.</p>
<p>Thanks</p>
| iphone | [8] |
3,265,778 | 3,265,779 | Is it possible for an app to alter the Android home screen? | <p>I'm a web developer. I have an idea for an Android app, but before I dive in and start learning, could someone please answer the following:</p>
<p>Is it possible for a regular app (installed from the Market)...</p>
<ul>
<li>to add/remove icons (of <strong>other</strong> apps) to/from the home screen? </li>
<li>to rearrange icons on the home screen?</li>
<li>to change the home screen's wallpaper?</li>
</ul>
<p>To clarify: I don't want to replace the home screen application itself (I believe this is only possible on rooted phones?); I just want to programmatically customise the stock home screen. I know the user can do this themselves, but can an app do it?</p>
<p>If possible, please link to documentation of the relevant APIs.</p>
| android | [4] |
1,698,825 | 1,698,826 | How to create lazy loading in Horizontal scrollview | <p>My application loads 10 image-thumbnails from server and set them into horizontal scrollview. When I swipe it to the last image, I would like to add lazy-loading element in the back of my horizontal scrollview and download next 10 more image in the background process.</p>
<p>My problem is -----> How I know the last image in horizontal scrollview shows on the screen?</p>
<p>I think the horizontal scrollview is so different from listview, because the listview uses adapter to control inside elements.</p>
<p>Thanks you so much</p>
| android | [4] |
4,102,513 | 4,102,514 | How can I send an Android app that I'm developing to someone over e-mail? | <p>This is my first Android app. I need to email what I have so far to someone for testing.</p>
<p>How should I do it?</p>
| android | [4] |
3,029,481 | 3,029,482 | Jquery IsNumeric with a not condition | <p>I am using Jquery to check to see if something isNumeric.
How do I check to see if it is not numeric?</p>
<pre><code> if (IsNumeric($('#Amount').val())) { .....
</code></pre>
<p>I put a ! before IsNumeric but that did not work.</p>
| jquery | [5] |
5,003,015 | 5,003,016 | PhP issue, downloading rather than displaying | <p>I followed much of <a href="https://help.ubuntu.com/community/ApacheMySQLPHP" rel="nofollow">this</a> how-to and got my test.php working fine but then in my public_html folder I added two folders and created a second site, I edited the document for both files in the same way as I did when it was just one site in home/magpie/public_html but the path seems to only lead to the folder from the first site </p>
<pre><code> gedit /etc/apache2/sites-available/mysite
</code></pre>
| php | [2] |
4,931,633 | 4,931,634 | loop through several vectors | <p>I had trouble searching for potential duplicates because I'm not sure what the correct terminology is.</p>
<p>If I have many vectors which are already created, how can I loop through them? To make things simple, suppose I have three vectors of strings named <code>"vec_one"</code>, <code>"vec_two"</code>, <code>"vec_three"</code>.</p>
<p>I want to do something like:</p>
<pre><code>for i in ("vec_one", "vec_two", "vec_three") {
for (vector<string>::const_iterator iter = i.begin(); iter != i.end(); ++iter) {
//do something with the elements ***and I need to access "i"***, that is, the vector name.
}
}
</code></pre>
<p>This would be the same as writing three different for loops, but would be more readable and in fact I have more than three in my non-simple application.</p>
<p>Note that because I need to access the vector name (see the comment), I can't just merge them all together and then run one loop.</p>
| c++ | [6] |
3,850,425 | 3,850,426 | concatenation operator (+) vs concat() | <p>For String concatenation we can use either <code>concat()</code> or concat operator <code>(+)</code></p>
<p>I have tried the following performance test and found <code>concat()</code> is faster and memory efficient way for String concatenation. If concat() is better than operator then when to use concatenation operator <code>(+)</code></p>
<p><strong>String concatenation compression</strong> for 100000 times</p>
<pre><code>String str = null;
//------------Using Concatenation operator-------------
long time1 = System.currentTimeMillis();
long freeMemory1 = Runtime.getRuntime().freeMemory();
for(int i=0; i<100000; i++){
str = "Hi";
str = str+" Bye";
}
long time2 = System.currentTimeMillis();
long freeMemory2 = Runtime.getRuntime().freeMemory();
long timetaken1 = time2-time1;
long memoryTaken1 = freeMemory1 - freeMemory2;
System.out.println("Concat operator :"+"Time taken =" +timetaken1+" Memory Consumed ="+memoryTaken1);
//------------Using Concat method-------------
long time3 = System.currentTimeMillis();
long freeMemory3 = Runtime.getRuntime().freeMemory();
for(int j=0; j<100000; j++){
str = "Hi";
str = str.concat(" Bye");
}
long time4 = System.currentTimeMillis();
long freeMemory4 = Runtime.getRuntime().freeMemory();
long timetaken2 = time4-time3;
long memoryTaken2 = freeMemory3 - freeMemory4;
System.out.println("Concat method :"+"Time taken =" +timetaken2+" Memory Consumed ="+memoryTaken2);
</code></pre>
<p><strong>Result</strong> </p>
<pre><code>Concat operator :Time taken =31 Memory Consumed =2259096
Concat method :Time taken =16 Memory Consumed =299592
</code></pre>
| java | [1] |
3,171,713 | 3,171,714 | android contactcontract row size | <p>Is there a maximum size for a complete row in the Android contractcontracts database? If so does anyone know what it is or where I can find it? I am wondering if the fields are dynamic in some way or fixed to a definite limit. </p>
| android | [4] |
5,344,321 | 5,344,322 | Function to get certain amount of lines from a file? | <p>Was just wondering if there is anything that exists to retrieve a certain amount of lines from a file or should I just go ahead & make an array of it with <code>file</code> & then loop through it until I get the required data?</p>
<p>All I'm trying to do is get the first 11 lines of data from a file (or less if there aren't 11).</p>
<p>Thank You!</p>
| php | [2] |
2,827,765 | 2,827,766 | rfind and << crashing program | <p>I have a problem that has a few programmers pulling their hair. The language is C/C++. Consider the code below...assume <em>request</em> is a valid C++ string.</p>
<pre><code>string outMsg;
string trans_str = ("</TRANSACTION>");
int32_t position;
//Assign outMsg and find "</TRANSACTION>"
outMsg.assign(request);
position = outMsg.rfind(trans_str);
</code></pre>
<p>The program crashes on the rfind(trans_str). The program also crashes when find(...) and replace(...) is used. It seems it has trouble with most C++ methods. The program also crashes on lines like the following....</p>
<pre><code>cout << "This is a string " << variable << "and this is the end"; //this is an example
</code></pre>
<p>The program usually crashes on the third "<<" and would only print the following output in this example:</p>
<p>"This is a string {variable} " CRASH.</p>
<p>A lot of weird things going on here.</p>
<p>"string" (in angle brackets) is included.</p>
<p>Thank you!</p>
| c++ | [6] |
71,815 | 71,816 | Is there any way to check timer is runned at defined period? | <p>i developed an application which sends birthday wishes on facebook wall, but when i am calling someone at same time that i set for sending wishes, then wishes failed to post on facebook wall.
I used Alarm Manager first.
But i want to use timer class and in that timer class i want to check that message is posted to wall or not at defined time or if not then i want to reschedule the timer class to send post.
i have this code for timer class </p>
<pre><code> private final Timer clockTimer;
private class Task extends TimerTask {
public void run() {
timerHandler.sendEmptyMessage(0);
}
}
private final Handler timerHandler = new Handler() {
public void handleMessage (Message msg) {
// runs in context of the main thread
timerSignal();
}
};
private List<SystemTimerListener> clockListener = new ArrayList<SystemTimerListener>();
public SystemTimerAndroid() {
clockTimer = new Timer();
clockTimer.schedule(new Task(), 1000, 1000);
}
private void timerSignal() {
for(SystemTimerListener listener : clockListener)
listener.onSystemTimeSignal();
}
public void killTimer() {
clockTimer.cancel();
}
@Override
public void addListener(SystemTimerListener listener) {
clockListener.add(listener);
}
</code></pre>
<p>this code is repeating after every second so i want to check if it runned for first time then stop the timer and reschedule for next day and so on...
Please help me. </p>
| android | [4] |
652,519 | 652,520 | Difference between objectAtIndex and [0] | <p>What is the difference between using the following: </p>
<pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dir = [paths objectAtIndex:0];
NSString *dir2 = paths[0]; // this throws incompatible type exception
</code></pre>
| iphone | [8] |
3,801,839 | 3,801,840 | confirm() on window.onbeforeunload | <p>I want to show a confirmation dialog if the user wants to leave the page with unsaved form data. What I have is:</p>
<pre><code>window.onbeforeunload = function() {
if (not_saved) if (confirm('Changes will not be saved')) return true;
return false;
}
</code></pre>
<p>But no matter what the user clicks, the result is the same - the stupid hardcoded dialog box that asks them whether they want to leave the page or stay on page. What I want to ask them is whether they want to stay or leave, and if they want to stay nothing happens, if they want to leave, they leave. Is this even possible? I can see how browsers want to limit what websites can do about keeping the users on the page, but I think I've seen some websites (Google Docs I think) having nice civilized dialog boxes.</p>
| javascript | [3] |
207,866 | 207,867 | PHP - get image from byte array | <p>I am trying to create a back-end for my mobile application. I am sending an image's contents as a byte array in the HTTP request's body (output stream) I want to read this stream of bytes in the PHP script and get back an image.</p>
<p>Can someone please tell me how I can do that?</p>
<p>Thanks.</p>
| php | [2] |
3,441,202 | 3,441,203 | jquery: most efficient way to get and store the ids of 100+ td items? | <p>Ok so I have about six of these calendars on page, so thats around 180 td items (1 for each date):</p>
<p><img src="http://i44.tinypic.com/eiwphl.jpg" alt="http://i44.tinypic.com/eiwphl.jpg"></p>
<p>each td has an id that is equal to that day's timestamp.
the dates I want are the red ones (class of <code>.booked</code>).</p>
<p>So i need the fastest way to 'serialize' the ids for <code>td.booked</code> items, any ideas?</p>
| jquery | [5] |
818,001 | 818,002 | _addFunctionCall method in Javascript | <p>Is there any method in JS named <code>_addFunctionCall</code> ? I came across following line in a legacy application.<br>
Method defination: </p>
<pre><code>i2b2.ONT.ajax._addFunctionCall( "GetNameInfo",
"{{{URL}}}getNameInfo",
i2b2.ONT.cfg.msgs.GetNameInfo,
null,
i2b2.ONT.cfg.parsers.ExtractConcepts);
</code></pre>
<p>Method call: </p>
<pre><code>var results = i2b2.ONT.ajax.GetNameInfo("ONT:FindBy", searchOptions);
</code></pre>
<p>My another question is <code>GetNameInfo</code> method call contains only two parameters while it seems that method defination contains more than two parameters.So how things work here ? </p>
<p>~Ajinkya. </p>
| javascript | [3] |
3,684,221 | 3,684,222 | similar functionality like uitableview in iphone to in android? | <p>can anybody please give me example of using similar functionality like uitableview in iphone to in android?</p>
| android | [4] |
3,782,181 | 3,782,182 | function's return type's need | <p>//we all always specify the return type of a function because it is in the syntax.....but can anyone tell me what basic objective is served by us by specifying the function's return type..........means why did the syntax have to be made like this.....it could be that we could just return the value..</p>
| c++ | [6] |
4,320,497 | 4,320,498 | Is it possible for a running python program to overwrite itself? | <p>Is it possible for a python script to open its own source file and overwrite it?</p>
<p>The idea was to have a very simple and very dirty way for a python script to download an update of itself so that the next time it is run it would be an updated version.</p>
| python | [7] |
4,139,348 | 4,139,349 | php email. how does it know to populate certain fields | <p>so im learning php (begginer if you cant tell) and, im currently pushin/pulling data from the db to a page so that it can then populate other parts of the page and when "send" is hit, it puts it all together and sends right...</p>
<p>my question is, </p>
<p>i know to set for example:</p>
<pre><code>$to = 'email@gmail.com';
$subject = 'test from my email php script';
$email = $_POST['email'];
$name = $_POST['fname'];
$lastname = $_POST['lname'];
$mssg = $_POST['mssg'];
</code></pre>
<p>but how does php or the mail app on the server know which field goes where since these are
self made variables???</p>
<p>so for example if i say:</p>
<pre><code>mail($to, $subject, $name, $lastname, $mssg);
</code></pre>
<p>how does it know to put say "subject" in the emails subject area and not all together in the mesage field etc?</p>
<p>i have a few pages open but none explain the WHY or better et, the HOW</p>
<p>thanks in advance.</p>
| php | [2] |
2,324,970 | 2,324,971 | Replacing image src with input hidden value using Jquery | <p>I have below input hidden with value ="/fr/images/findacourse_logo_tcm10-268.gif".</p>
<pre><code><input type="hidden" id="Qt_Email_Image" value="/fr/images/findacourse_logo_tcm10-268.gif"/>
</code></pre>
<p>I have another input image below with src = "/images/quote/Quote_Email_Button.JPG"</p>
<pre><code><tr>
<td>
</td>
<td colspan="2" class="">
<input type="image" border="0" alt="Email me this quote " src="/images/quote/Quote_Email_Button.JPG" id="Quote_btnEmail" name="Quote:btnEmail"/>
</td>
</tr>
</code></pre>
<p>Now I want at runtime the input image src gets replaced with above input hidden value and will show above image instead of image link in src. So that my above html becomes</p>
<pre><code><tr>
<td>
</td>
<td colspan="2" class="">
<input type="image" border="0" alt="Email me this quote " src="/fr/images/findacourse_logo_tcm10-268.gif" id="Quote_btnEmail" name="Quote:btnEmail"/>
</td>
</tr>
</code></pre>
<p>I want to use Jquery for above solution, please suggest!</p>
<p>Thanks.</p>
| jquery | [5] |
1,611,034 | 1,611,035 | Is there a way to appendTo head? | <p>I'm working with a platform that doesn't allow me to edit the source code. Is there a way to insert a line in the head element dynamically? Maybe something like below...</p>
<pre><code>$("<link href='http://fonts.googleapis.com/css?family=News+Cycle' rel='stylesheet'>").appendTo("head")
</code></pre>
| jquery | [5] |
1,391,127 | 1,391,128 | How to include a module dependency as a part of py2exe script | <p>I got a windows installer my_script.exe (generated out of my_script.py using py2exe) which is dependent on "PyDes" module,</p>
<p>when I execute my_script.exe it throws an error saying ,</p>
<p>Import error : pyDes module</p>
<p>How to include the pyDes module as a dependency to my_script.py</p>
<p>I am using py2exe to create windows installer.</p>
<p>python setup.py py2exe</p>
| python | [7] |
2,470,495 | 2,470,496 | What does plus equals (+=) do in Python? | <p>My friend sent me the following Python code to demonstrate what she thinks is wrong with Python. At the moment, I have to agree with her. All of the experienced programmers I've shown this to are equally confused. Can anyone tell me what is going on? </p>
<pre><code>class foo:
bar = []
def __init__(self,x):
self.bar += [x]
class foo2:
bar = []
def __init__(self,x):
self.bar = self.bar + [x]
f = foo(1)
g = foo(2)
print f.bar
print g.bar
f.bar += [3]
print f.bar
print g.bar
f.bar = f.bar + [4]
print f.bar
print g.bar
f = foo2(1)
g = foo2(2)
print f.bar
print g.bar
</code></pre>
<p><strong>OUTPUT</strong></p>
<pre><code>[1, 2]
[1, 2]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3, 4]
[1, 2, 3]
[1]
[2]
</code></pre>
<p>foo += bar seems to affect every instance of the class, whereas foo = foo + bar seems to behave in the way I would expect things to behave. </p>
<p>I've tried googling this, but I'm not sure what the '+=' operator is officially called, so haven't been able to find anything.</p>
| python | [7] |
1,461,655 | 1,461,656 | Script disable in text boxes | <p>How can I prevent a script from executing in text boxes, by using jQuery?</p>
<p>Here is my complete problem:</p>
<p>I want to send a message to someone using jQuery; if I entered a script tags like <code>a</code>, <code>href</code>, <code>script</code>, etc. they are not appearing in the other's message. How can I prevent this?</p>
| jquery | [5] |
385,970 | 385,971 | why is there no value for variable in this jquery code? | <pre><code> var ret = { valid: true, message: "" };
var prtime = $(".ptime").val();
var ctime = $(".ctime").val();
if ($(prtime).length == 0 || $(ctime).length == 0) {
ret = { valid: false, message: "" };
}
$(prtime).length
</code></pre>
<p>when I run this I get 0 even I when fill some words in prtime , and when I do
<code>$(".ptime").val()</code>.length then it shows me the length.</p>
<p>what are have I done wrong with that code</p>
| jquery | [5] |
1,974,214 | 1,974,215 | How do I encode an HTTP link... something very easily with javascript? | <pre><code><a onclick="go_url(ENCODED-URL);return false;">go to this url</a>
</code></pre>
| javascript | [3] |
184,247 | 184,248 | how to use a recorder / player objects | <p>I'm trying to put objects in a document. dat and then they can be read Does anyone know where is wrong?
The problem I have is that it is able to read the files you keep, I am not sure you save it, but if I find the file in the folders ...</p>
<p>I'm working with objets like:</p>
<pre><code>public class Person {
public int Id;
public String Name;
public boolean Show;
public Persona(
int identificator,
String newName,
boolean ShoworNot
){
this.Id = identificator;
this.Name = newName;
this.Show = ShoworNot;
}
Thanks
my code:
public void WriteFile
try {
FileOutputStream file = new FileOutputStream("try.dat");
ObjectOutputStream exit = new ObjectOutputStream(file);
Iterator ite2 = people.iterator();
while(ite2.hasNext()){
Person person2 = (Person)ite2.next();
exit.writeObject(person2);
exit.close();
}
System.out.println("It's works");
}
catch (IOException e){
System.out.println("Problems with the file.");
}
}
}
}
}
public void ReadFile(){
try {
FileInputStream file2 = new FileInputStream("try.dat");
ObjectInputStream entry = new ObjectInputStream(file2);
entry.readObject();
String data = (String)entry.readObject();
entry.close();
System.out.println(data);
}
catch (FileNotFoundException e) {
System.out.println("It can't open the file document");
}
catch (IOException e) {
System.out.println("Problems with the file");
}
catch (Exception e) {
System.out.println("Error reading the file");
}
}
</code></pre>
| java | [1] |
2,778,801 | 2,778,802 | The ConnectionString property has not been initialized | <p>My connection string is placed in web.config as follows.</p>
<pre><code><connectionStrings>
<add name="empcon" connectionString="Persist Security Info=False;User ID=sa;Password=abc;Initial Catalog=db5pmto8pm;Data Source=SOWMYA-3BBF60D0\SOWMYA" />
</connectionStrings>
</code></pre>
<p>and the code of program is...</p>
<pre><code>public partial class empoperations : System.Web.UI.Page
{
string constr = null;
protected void Page_Load(object sender, EventArgs e)
{
ConfigurationManager.ConnectionStrings["empcon"].ToString();
if (!this.IsPostBack)
{
fillemps();
}
}
public void fillemps()
{
dlstemps.Items.Clear();
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["empcon"].ConnectionString);
con.ConnectionString = constr;
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "select * from emp";
cmd.Connection = con;
SqlDataReader reader;
try
{
con.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
ListItem lt = new ListItem();
lt.Text = reader["ename"].ToString();
lt.Value = reader["empno"].ToString();
dlstemps.Items.Add(lt);
}
reader.Close();
}
catch (Exception er)
{
lblerror.Text = er.Message;
}
finally
{
con.Close();
}
</code></pre>
<p>i am totally new to programing....</p>
<p>i am able to run this application with er.message in label control as "the connection string property has not been initialized"</p>
<p>i need to retrieve the list of names of employees from the emp table in database into the dropdownlist and show them to the user...</p>
<p>can any one please fix it...</p>
| asp.net | [9] |
1,525,503 | 1,525,504 | Audio library for C++ for audio plugins? | <p>I am interested in creating audio plugins like a compressor or synthesizer VST plugin for example. Though I do want to start with something as simple as a distortion plugin. </p>
<p>And I thought I will use C++ for it. </p>
<p>I am wondering which audio library would be a good fit for this case? </p>
<p>My inspirations are the Sonalksis compressor and Reason's Mälstrom for example. </p>
| c++ | [6] |
3,517,086 | 3,517,087 | How I can cancel the AsyncTask during invocation? | <p>I am implementing a function which performs some backend database task. I have used Asynctask for that but If the backend task is in process and I close the activity, I want to cancel the AsyncTask too. How I can do tat?</p>
| android | [4] |
2,438,454 | 2,438,455 | file access peek ahead | <p>I need to read a file, line by line and I need to peek into 'the next line' so first I read the file into a list and then I cycle throught the list... somehow this seems rude, building the list could be become expensive.</p>
<pre><code>for line in open(filename, 'r'):
lines.append(line[:-1])
for cn in range(0, len(lines)):
line = lines[cn]
nextline = lines[cn+1] # actual code checks for this eof overflow
</code></pre>
<p>there must be a better way to iterate over the lines but I don't know how to peek ahead</p>
| python | [7] |
179,218 | 179,219 | jquery validation plugin minLength override in invalidHandler | <p>Is it possible to override the default minlength error message in the callback invalidHandler ?</p>
<p>Say by default the error message for minlength would be <em>Please enter at least {0} characters</em>. Can this be overriden with the inclusion of the form element say <strong>{element} - Please enter at least {0} characters</strong>. validator.numberOfInvalids() is able to capture this error but am not able to figure out how to override the error message of the corresponding error.</p>
<p>Any help in this context is really appreciated, Thanks.</p>
| jquery | [5] |
5,815,149 | 5,815,150 | Default.png no longer exists | <p>I've searched for the answer to this question but I can't seem to find it, and logically this process makes no sense to me...</p>
<p>I added a default.png to my app and I didn't like the fact that it didn't show long enough, so I removed it and was going to add a splash screen instead.</p>
<p>The problem is that the default.png still shows on load. I've completely removed it from the Xcode project and from the computer.</p>
<p>I've deleted the installed app from the simulator, and rebuilt the project but it still shows up. I've even exited Xcode and relaunched. Does this value get saved anywhere that I'm missing? How do I get rid of this image?</p>
<p>Any help will be appreciated.</p>
<p>Thank you in advance,
BWC</p>
| iphone | [8] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.