Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
2,468,738
2,468,739
Jquery returns NaN,any idea?
<p>HTML code: </p> <pre><code>&lt;form id="hostadd" action="addmoney.php?taskid=12" method="post" onSubmit="return false"&gt; &lt;input type="hidden" name="mode" value="" /&gt; current unit price:$ &lt;input id="unitprice" name="unitprice" type="text" size="5" maxlength="6" value= 0.50 /&gt;&amp;nbsp Shortfall:&lt;input id="shortfall" type="text" name="shortfall" size="4" maxlength="6" value=80 /&gt; &lt;input id="add_price" type="submit" value="Submit" onclick="Adjust()"/&gt;&lt;/form </code></pre> <p>Jquery code:</p> <pre><code> function Adjust(){ $totalprice=parseFloat($('unitprice').val())*parseInt($('shortfall').val()); alert($totalprice); }; </code></pre> <p>When I test</p> <pre><code>var unitPrice = $('#unitprice').val(); alert(unitPrice); var shortFall = $('#shortfall').val(); alert(shortFall); </code></pre> <p>I got two blank alerts.</p>
jquery
[5]
3,924,620
3,924,621
Strings between quotation marks in C++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7459939/what-do-single-quotes-do-in-c-when-used-on-multiple-characters">What do single quotes do in C++ when used on multiple characters?</a> </p> </blockquote> <p>The following code compiles in C++:</p> <pre><code>unsigned int x; x = 'abc'; </code></pre> <p>What does it mean? Is putting string between quotation marks legal? What does it do?</p>
c++
[6]
1,502,173
1,502,174
Right Justifying output stream in C++
<p>I'm working in C++. I'm given a 10 digit string (char array) that may or may not have 3 dashes in it (making it up to 13 characters). Is there a built in way with the stream to right justify it?</p> <p>How would I go about printing to the stream right justified? Is there a built in function/way to do this, or do I need to pad 3 spaces into the beginning of the character array?</p> <p>I'm dealing with ostream to be specific, not sure if that matters.</p>
c++
[6]
1,822,103
1,822,104
Reading label Id
<p>I'm having a table in which i'm creating a label dynamically.</p> <pre><code>'&lt;td&gt;' + '&lt;label for="Name" id = ' + value + '&gt;' + text + '&lt;/label&gt;&lt;/td&gt;' </code></pre> <p>I want to retrieve the id of the label and I`m doing the following which is not working: How can I get the Id of the label? </p> <pre><code>function ReadNames() { $('#Table tr').each(function() { NameID.push($(this).find('label').val()); }); } </code></pre>
jquery
[5]
5,689,927
5,689,928
Can't clear a .log file, "permission denied"
<p>I have a little problem. I have a skype resolver but my Debug file does get bigger and bigger.</p> <p>How can i clear this? I have this with PHP:</p> <pre><code> &lt;?php $fp = fopen("skype/debug-20130331-0951.log",'w+'); if(!$fp) echo 'not Open'; while(!feof($fp)) { fputs($fp,' ',999); } fclose($fp); ?&gt; </code></pre> <blockquote> <p>Warning: fopen(skype/debug-20130331-0951.log) [function.fopen]: <strong>failed to open stream: Permission denied</strong> in C:\xampplite\htdocs\clear.php on line 3</p> </blockquote> <p>How can i fix this?</p>
php
[2]
2,071,910
2,071,911
jQuery .html() does not work with hidden divs?
<p>function <code>.html()</code> works when the item is displayed. but when I add <code>style="display:none"</code>, then html() function returns nothing. Is there workaround of this problem? thanks?</p>
jquery
[5]
2,818,105
2,818,106
findViewById not working for an include?
<p>I have an include like:</p> <pre><code>&lt;include android:id="@+id/placeHolder" layout="@layout/test" /&gt; </code></pre> <p>The include layout looks like (test.xml):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/outer" ... &gt; &lt;ImageView android:id="@+id/inner" ... /&gt; &lt;/FrameLayout&gt; </code></pre> <p>I can't seem to find the inner ImageView with id="inner" at runtime:</p> <pre><code>ImageView iv = (ImageView)findViewById(R.id.inner); if (iv == null) { Log.e(TAG, "Not found!"); } </code></pre> <p>Should I be able to find it? It seems like since it's using an "include", the normal findViewById method does not work.</p> <p>---------- Update ----------------</p> <p>So I can find the id assigned to the include:</p> <pre><code>View view = findViewById(R.id.placeHolder); // ok </code></pre> <p>but I can't find any of its children by id like:</p> <pre><code>view.findViewById(R.id.outer); // nope view.findViewById(R.id.inner); // nope </code></pre> <p>same as the original if I try searching for them directly like:</p> <pre><code>findViewById(R.id.outer); // nope findViewById(R.id.inner); // nope </code></pre> <p>Do ids just get stripped off of elements at runtime maybe?</p> <p>Thanks</p>
android
[4]
5,727,584
5,727,585
Better Way to Code Hidden Div Toggle in JQuery?
<p>I've finally found a way to get this to work but the code it a bit long winded and I'm sure there is a better way of doing it. This is does what I want but I want to extend this to work on 10 or so divs and the code would be ridiculous if I used this method. I've tried playing around with the .each() method but it just leads to further frustration. If anyone could point me in the right direction I'd be much obliged. Here is a jFiddle of what I have so far: <a href="http://jsfiddle.net/QbsbD/47/" rel="nofollow">http://jsfiddle.net/QbsbD/47/</a></p> <pre><code>$(document).ready(function() { $('#btn1').click(function() { if ('#div2:visible') { $('#div2').hide('fast'); } if ('#div3:visible') { $('#div3').hide('fast'); } $('#div1').slideToggle("slow"); }); $('#btn2').click(function() { if ('#div1:visible') { $('#div1').hide('slow'); } if ('#div3:visible') { $('#div3').hide('slow'); } $('#div2').slideToggle("slow"); }); $('#btn3').click(function() { if ('#div1:visible') { $('#div1').slideUp('slow'); } if ('#div2:visible') { $('#div2').slideUp('slow'); } $('#div3').slideToggle("slow"); }); });​ </code></pre>
jquery
[5]
5,899,277
5,899,278
C++ -- which constructor of string is call when we use string(0)?
<p>Given the following code,</p> <pre><code>class A { public: A() : str(0) {} private: string str; }; </code></pre> <p>Based on this <a href="http://www.cplusplus.com/reference/string/string/string/" rel="nofollow">http://www.cplusplus.com/reference/string/string/string/</a></p> <pre><code>string ( ); string ( const string&amp; str ); string ( const string&amp; str, size_t pos, size_t n = npos ); string ( const char * s, size_t n ); string ( const char * s ); string ( size_t n, char c ); template&lt;class InputIterator&gt; string (InputIterator begin, InputIterator end); </code></pre> <p>I don't see which constructor of string is called when we use the 'str(0)'.</p> <p>Question> Can someone tell me which string constructor is used for 'str(0)'?</p>
c++
[6]
1,005,608
1,005,609
Weird JavaScript Code
<pre><code>for (var i=a.length-1;i&gt;0;i--) { if (i!=a.indexOf(a.charAt(i))) { a=a.substring(0,i)+a.substring(i+1); } } </code></pre> <p>I found this in a web app I'm auditing, it just baffles me why it's there. I can't seem to see a case where <code>i!=a.indexOf(a.charAt(i))</code> would be false.</p> <p>The value the pass to it is:</p> <pre><code>a = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; </code></pre> <p>There is no comment either //sigh</p>
javascript
[3]
2,073,417
2,073,418
Android custom SharedPreferences implementation to persist to database?
<p>I am attempting to use a custom implementation of the <code>SharedPreferences</code> interface to persist an application's preferences to a database (instead of the default XML). </p> <p>Why? I'd like to use the convenience of <code>PreferenceActivity</code> to construct the UI but this app will be used on multiple devices so the preferences a user sets need to persist across devices.</p> <p>So.. I've got the implementation written, but can't figure out how to associate a particular SharedPreference with a <code>PreferenceActivity</code>. I know that uses <code>getSharedPreferences()</code>, but how can I override that? Can i register my <code>SharedPreferences</code> somehow? I did not see anything in the API to do this.</p> <p>Or ... if I'm going about this all wrong please let me know. Thanks.</p>
android
[4]
4,687,338
4,687,339
Javascript returning strange value
<p>I was testing a function out to see what happens when it's parameters are <code>null</code> and decided to put an else statement with it. To my surprise, it did not log the parameters that I have passed, it's logging something else entirely. Maybe someone can shed some light on this, here's the code:</p> <pre><code>function testing(o) { if (!o) { return "Sorry, looks like you need to pass an argument.." } else { return o; } } console.log(testing(02034)); //logs 1052 </code></pre> <p>What's going on here?</p>
javascript
[3]
5,068,582
5,068,583
php display image
<p>I am not able to display image using this code. Could any one help me in correcting?</p> <pre><code>&lt;?php include("connect.php"); $sql="select * from profile where userid=3"; $row=mysql_query($sql); header("Content-type: image/jpeg"); echo $row['image']; ?&gt; </code></pre>
php
[2]
5,736,769
5,736,770
How can I differentiate an android Activity from a SubActivity programatically?
<p>How can I differentiate an android Activity from a SubActivity programatically? Is there any api for that?</p>
android
[4]
2,112,555
2,112,556
How do I get my generic class to require its parameters to extend/implement multiple classes?
<p>I'm looking for the correct syntax for the following:</p> <pre><code>public class Foobar&lt;K extends SomeJavaAPIClass and implements Cloneable&gt;{ </code></pre> <p>So that I can have Foobars of 'K', where K is a generic subclass of SomeJavaAPIClass and where K has it's own clone() method </p> <p>I've tried <code>&lt;K extends SomeJavaAPIClass, implements Cloneable&gt;</code> with no luck, along with other permutations</p>
java
[1]
1,494,595
1,494,596
Why cannot parse a DateTime?
<p>I'm trying to parse a DateTime which I read from a file, the format of the date is:</p> <p><code>19/10/2005 12:00:00 a.m.</code></p> <p>and the code I'm using is:</p> <pre><code>string Fecha = dbRow["FECHA"].ToString().Trim(); DateTime fechamov; if (!DateTime.TryParseExact(Fecha, "dd/MM/yyyy HH:mm:ss tt", CultureInfo.InvariantCulture, DateTimeStyles.None, out fechamov)) { fechamov = DateTime.Now; System.IO.File.AppendAllText(pathString, "Corregir nota: " + dbRow["NOTA"].ToString().Trim() + Environment.NewLine); } </code></pre> <p>but before I set the <code>DateTime.Now</code> it always gets the value <code>01/01/0001 12:00:00 a.m.</code></p> <p>I've been trying with different formats, but it just doesn't work, what am I doing wrong, any ideas?</p>
c#
[0]
2,314,092
2,314,093
Error while adding minutes to a js date object?
<pre><code>var d=ed; d.setMinutes(d.getMinutes() + 30); </code></pre> <p><code>ed</code> has my date,but this is giving me error like </p> <pre><code>Object doesn't support this property or method </code></pre> <p>wat might be the problem???</p>
javascript
[3]
5,386,520
5,386,521
Looking for stats on popularity of JavaScript libraries
<p>Does anyone know if there's a site that tracks the popularity of the big/various JavaScript libraries?</p>
javascript
[3]
1,702,998
1,702,999
Returning a memory locations of a five element array
<p>I was having issue when returning five strings of data from an array to a output .dat file. Just curious why would this happen am I referencing something somewhere wrong? I was using fstream to return the data to the .dat file and I can see the correct data passed(in the dropdown) when I use breakpoints. I had this happen before and this seems to be a basic concept that missing here somewhere. It seems it is returning the memory address of the element objects on the stack.</p>
c++
[6]
4,959,511
4,959,512
python and assigning variable values in if statements
<p>I'm somewhat of a beginner in python and I swear I got a very similar program to what I'm doing right now to work. But, for some reason, I can't make it work. I was able to pinpoint my problem and created a fake program to play around with it. Here is what the program:</p> <pre><code>global heading global heading2 global a heading=2 a=2 heading2=4 def function (): if a==2: heading=heading2 print 'yes' print heading function() print heading </code></pre> <p>This is what appears:</p> <pre><code>yes 4 2 </code></pre> <p>Why doesn't the heading variable heading keep the value 4? I tried putting return heading all over. Didn't work. I tried putting the variables in the parentheses of the function. Didn't work either... Do you know what I'm doing wrong?</p>
python
[7]
2,943,884
2,943,885
omit object type in the signature of an abstract method
<p>I have a Model abstract class and i want to have an abstract method to set the id of the model instances. I'd like for the implementation to define what object they would like to use for the id object though. In the following example the getId() works fine but i can't override the setId() method because the signatures aren't the same: setId(Object id) vs setId(Integer id). Can i accomplish this with the use of &lt; T > or &lt; E > or something else. I'm not familiar how to use those. </p> <pre><code>abstract class Model{ abstract public void setId(Object id); &lt;-- the problem abstract public Object getId(); } class SQLiteModel extends Model{ private Integer id; @Override public void setId(Integer id){ &lt;-- the problem this.id = id; } @Override public Integer getId(){ return id; } } </code></pre> <p>and what about multiple generics? </p> <pre><code>abstract class Model&lt;T&gt; { abstract public void setId(T id); abstract public T getId(); abstract public T getSomethingElse(); } class SQLiteModel extends Model&lt;Integer&gt; { private Integer id; @Override public void setId(Integer id) { this.id = id; } @Override public Integer getId() { return id; } @Override public String getSomethingElse(){ return "a string"; } } </code></pre>
java
[1]
1,481,109
1,481,110
Online php script runner
<p>I want to develop an online PHP script runner. I don't know how get started with it. Any basic ideas will be appreciated. Thanks.</p>
php
[2]
5,994,922
5,994,923
Creating a function in JS
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname">Javascript: var functionName = function() {} vs function functionName() {}</a> </p> </blockquote> <p>I am curious to which is best pratice when creating a function in js</p> <pre><code>function x() { ... } </code></pre> <p>OR</p> <pre><code>var x = function() { ... } </code></pre> <p>Is there a difference or are they the exact same thing. </p>
javascript
[3]
4,733,715
4,733,716
populate collection with each()
<p>I am trying to populate a collection using an each. I can get the element in one string, and I can get an alert to fire on each iteration. I just cant put the two together.</p> <p>Here is my list:</p> <p>4/27/2011 5:42:54 PM<br> 4/27/2011 5:43:00 PM<br> 4/27/2011 5:46:53 PM<br> 4/28/2011 2:10:40 PM </p> <p>Here is my code. </p> <pre><code>if (chosenTime &gt; 0) { var myDateClass = $('.exceptionDate') var i = 0 $(myDateClass).each(function () { var myDateClassVal = myDateClass[i].GetAttributeNode(outerText); //this currently gives an error //if I switch this to myDateClass.text(); // it returns the list in one string i++ }); </code></pre>
jquery
[5]
2,337,239
2,337,240
.sln file contains information in xml or in code (like vb)?
<p>I am reading <strong>Developing Web Applications with .net frame work 4.0</strong> book (70-515). In that I found one sentence that at page number 21 <strong>A solution file is an XML file that contains information...</strong> After I read this sentence I opened the .sln file in note pad. But strangely I didn't find any xml over there. It contains some code which is some what similar to VB code. Even I referred to <a href="http://msdn.microsoft.com/en-us/library/bb165951%28v=vs.80%29.aspx" rel="nofollow">Microsoft</a> link, there are no mentioning it is xml file. Is that sentence is wrong in that book? Please any one clarify me! </p>
asp.net
[9]
836,728
836,729
Can i change the Font size and Font Type of NavigationItem's Title?
<p>i have used This code: self.navigationItem.title=@"My Name is ABC"; i want to change the font size as well as font Type's also so how can i change both with this code?</p>
iphone
[8]
4,359,783
4,359,784
non-static variable cannot this be referenced from a static context error
<pre><code>public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter expression: "); String exp = input.nextLine().trim(); ExpressionTree exptree = new ExpressionTree1(); //new instance of ExpressionTree TreeNode root = new TreeNode(); root = exptree.parseOutsideExpression(exp); int evaluate = exptree.Compute(root); String answer = Integer.toString(evaluate); System.out.println("The evaluated expression is:" + answer); } class ExpressionTree{ </code></pre> <p>I've looked at several examples and I've noticed that a common answer is to create a new instance of your object within main() which I've done, but I still get the same error and I am unclear as to why. </p>
java
[1]
1,866,457
1,866,458
Is it possible to combine the functions easier?
<p>I need to combine some functions (modify 1st function), but I can't do it this way (it works, but is bad for me):</p> <pre><code>var a = function(){alert('a');}; var b = function(){alert('b');}; var c = a; a = function(){c(); b();}; a(); </code></pre> <p>Then I try to do this:</p> <pre><code>var a = function(){alert('a');}; var b = function(){alert('b');}; var rx = /^[\s\S]*\(([\s\S]*)\)\s*{([\s\S]*)}$/; concat = function(f1,f2) { var q = f1.toString().replace(rx,'$1|$2').split('|'); var w = f2.toString().replace(rx,'$1|$2').split('|'); return (q[0]!=='' &amp;&amp; w[0]!=='')? new Function(q[0]+','+w[0],q[1]+w[1]): (q[0]!=='')? new Function(q[0],q[1]+w[1]): new Function(w[0],q[1]+w[1]); }; a = concat(a,b); alert(a); </code></pre> <p>It works, but may be exist an easier way?</p>
javascript
[3]
1,326,672
1,326,673
PHP: direct call another PHP web applications without going through the usual HTTP call
<p>I have two PHP web applications. All of the apps are located on the same computer. Each application will run independently.</p> <p>Now, can I do a direct API call from one PHP app to another? I don't want to go through either the webservice, or the usual HTTP call that involves HTML response. I want to call app A from app B, using direct method call, as if those two apps are the same application.</p> <p>How to do this?</p>
php
[2]
4,605,470
4,605,471
Three20 framework in iphone sdk
<p>I want to know how to use the three20 frame work in my project,i want to create a image gallery for my app.Please give a correct method of adding three20 to my project.</p>
iphone
[8]
3,428,058
3,428,059
Fetching data from another website with php
<p>I need to fetch data from this web page <a href="http://www.cba.am/en/sitepages/default.aspx" rel="nofollow">central bank of armenia</a></p> <p>In my html form user must insert the price of his supply. He/she selects the currency (USD, EUR or AMD) and types its value. After that I need to convert inserted price to other two currencies and add them to my database. So how can I get USD and EUR exchange rates from the site given above using PHP and attach them to variables. </p>
php
[2]
1,820,814
1,820,815
How to reference 2 ArrayAdapters separately
<p>I've been working on understanding ArrayAdapters for the past 2 days, but can't seem to get them down entirely.</p> <p>The following code is functional as is.</p> <pre><code> private void initAdapter(ArrayList&lt;String&gt; aL) { for (String s : aL) { aL.add(s); } setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, aL) { @Override public View getView(int position, View convertView, ViewGroup parent) { View row; if (null == convertView) { row = mInflater.inflate(R.layout.list_item, null); } else { row = convertView; } TextView tv = (TextView) row.findViewById(android.R.id.text1); tv.setText(getItem(position)); return row; } }); } </code></pre> <p>I am trying to make it into a method where I can use ArrayAdapter on multiple Arrays and put them into separate ListViews. When I try modifying the method to </p> <pre><code>private void initAdapter(ArrayList&lt;String&gt; aL, ListView L) { </code></pre> <p>and</p> <pre><code>L.setAdapter(new ArrayAdapter&lt;String&gt;(this. R.layout.list_item, aL) { </code></pre> <p>I get an error at compile. Also, why is it that you don't have to specify a ListView for your first ArrayAdapter. Does it just automatically reference anything with the id 'list'?</p> <p>I am quite confused and stuck on this and would be very grateful for a well-explained answer.</p>
android
[4]
147,420
147,421
Get parent directory of parent directory
<p>I have a string relating to a location on a network and I need to get the directory that is 2 up from this location.</p> <p>The string could be in the format:</p> <pre><code>string networkDir = "\\\\networkLocation\\staff\\users\\username"; </code></pre> <p>In which case I would need the <code>staff</code> folder and could use the following logic:</p> <pre><code>string parentDir1 = Path.GetDirectoryName(networkDir); string parentDir2 = Path.GetPathRoot(Path.GetDirectoryName(networkDir)); </code></pre> <p>However, if the string is in the format:</p> <pre><code>string networkDir = "\\\\networkLocation\\users\\username"; </code></pre> <p>I would just need the <code>networkLocation</code> part and <code>parentDir2</code> returns null.</p> <p>How can I do this?</p> <p>Just to clarify: In the case that the root happens to be the directory 2 up from the given folder then this is what I need to return </p>
c#
[0]
1,586,026
1,586,027
How can I pass parameters to a module pattern to override default values [private properties] in JavaScript?
<p>I was reading this article <a href="http://www.klauskomenda.com/code/javascript-programming-patterns/#revealing" rel="nofollow">http://www.klauskomenda.com/code/javascript-programming-patterns/#revealing</a> and was wondering if I can pass parameters to override the private properties.</p> <pre><code>// revealing module pattern var anchorChange4 = function () { // this will be a private property var config = { colors: [ "#F63", "#CC0", "#CFF" ] } // this will be a public method var init = function () { var self = this; // assign reference to current object to "self" // get all links on the page var anchors = document.getElementsByTagName("a"); var size = anchors.length; for (var i = 0; i &lt; size; i++) { anchors[i].color = config.colors[i]; anchors[i].onclick = function () { self.changeColor(this, this.color); // this is bound to the anchor object return false; }; } } // this will be a public method var changeColor = function (linkObj, newColor) { linkObj.style.backgroundColor = newColor; } return { // declare which properties and methods are supposed to be public init: init, changeColor: changeColor } }(); anchorChange4.init(); </code></pre> <p>I'm trying to change the values of the Array colors, like passing different colors as parameters. I hope I'm making some sense.</p>
javascript
[3]
1,086,948
1,086,949
assign block of html with variable to another variable
<p>What i need is :</p> <pre><code>$myVar = '&lt;a class="thumbnail" href="$url"&gt;$text&lt;span&gt;&lt;img src="$url" /&gt;&lt;br /&gt;$text&lt;/span&gt;&lt;/a&gt;'; </code></pre> <p>This code does not work certainly. It does not return an error because I put single quote ''</p> <p>BUT the <code>$url</code> and <code>$text</code> won't be replaced by their values.</p> <p>I've tried <code>htmlspecialchar</code> and <code>Endofhtml</code> functions but also does not work. </p>
php
[2]
3,123,228
3,123,229
New iPhone Dev policy...how does Apple enforce this?
<p>Apple doesn't want anyone to create iPhone apps outside of the Xcode/Objective-C environment. How can they actually enforce this?</p> <p>If the non Xcode IDE, for example Unity, compiles to an iPhone executable, how will Apple know which dev environment you used to create the app? Can they have Xcode compile some sort of signature into the executable that no one knows about?</p>
iphone
[8]
4,157,471
4,157,472
Programatically Dial a Phone number and pass DTMF using the iPhone SDK
<p>How do you programatically do the following from the iPhone SDK</p> <p>1) Programatically Dial a Phone Number through the iPhone SDK</p> <p>2) Bypass the <strong>dial / cancel</strong> prompt that the iPhone brings up</p> <p>3) Send additional DTMF after the number is dialed just like how you would program pauses into a regular phone. </p> <p>I know you can make a tel:// call but the issue is that it brings up the dial / cancel prompt and after that it prevents any future DTMF from being sent.</p>
iphone
[8]
414,972
414,973
wait for webrequest to finish
<p>hi this function downloads an image from source and adds it to a zip file. the problem is sometimes the image comes out all messed up(1/3 is downloaded, the rest is empty space) as if the download isn't finish. how can i make sure the download is finished before i move on? thank you.</p> <p>edit: i have timeout there so it wouldnt wait indefinitely. should i just extend the timeout? or is there a better way?</p> <pre><code>public void addImage(string source, string destination) { if (isFinalized) return; try { WebRequest req = WebRequest.Create(source); req.Timeout = 5000; WebResponse resp = req.GetResponse(); BufferedStream reader = new BufferedStream(resp.GetResponseStream()); byte[] fileData = new byte[resp.ContentLength]; reader.Read(fileData, 0, fileData.Length); zip.AddEntry(destination, fileData); } catch (Exception exp) { } } </code></pre>
asp.net
[9]
3,610,946
3,610,947
Copy a property-decorated member to a new class
<p>I am trying to copy all the methods and attributes from a class to an instance of another class. Unfortunately I am having issues with properties. Here's an example:</p> <pre><code>class ToAdd(object): @property def foo(self): return 'foo!' class Base(object): pass b = Base() for item, val in ToAdd.__dict__.iteritems(): if not item.startswith('__'): setattr(b, item, val) </code></pre> <p>When calling <code>b.foo</code> I expect to get <code>'foo!'</code>, but instead it returns <code>&lt;property at 0x104a73d08&gt;</code>.</p> <p>Note that this is akin to a mixin, but I want it to work on instances instead of classes.</p>
python
[7]
1,694,366
1,694,367
Using python for software automation
<p>My biggest difficulty is finding a tool that I can develop test python.</p> <p>What could I use?</p>
python
[7]
2,801,016
2,801,017
Using a variable outside of function in Python
<p>A really simple question, and I'm sure I knew it but must have forgotten</p> <p>When running this code:</p> <pre><code>x = 0 def run_5(): print "5 minutes later" x += 5 print x, "minutes since start" run_5() print x </code></pre> <p>I get x isn't defined. How can I have x used in the function and effected outside of it?</p>
python
[7]
3,460,584
3,460,585
Android: Activity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView that was originally added here
<p>I am receiving the above error when launching my application in version 3.1 in my tablet</p> <p>It works fine from 2.1 to 2.3 on phones</p> <p>The code it complains about is as follows:</p> <pre><code>@Override protected void onCreate() { // Other logic here // .... showDialog(Constants.INTRODUCTION_DIALOG); } </code></pre> <p>What is the problem here? I see other related threads but I don't see one similar to my problem on launch.</p> <p>Thanks</p>
android
[4]
2,601,068
2,601,069
how to get text from edit text which is in scroll view?
<p>Hi am adding edit text field dynamically to the scroll view and then am adding a text into the edit text and then i want to get back data into string array...for that i wrote a following code please suggest me how to get the data from edit text..`for(int i=0;i <pre><code> value=(EditText)row.findViewById(R.id.EditText01); Button sayit=(Button)row.findViewById(R.id.sayit); Button sentence=(Button)row.findViewById(R.id.sentences); TextView positions=(TextView)row.findViewById(R.id.positions); TextView sentenc=(TextView)row.findViewById(R.id.sentence); positions.setText(String.valueOf(i)); sentenc.setText(String.valueOf(i)); sayit.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TextView t=(TextView)row.findViewById(R.id.positions); String s=t.getText().toString(); int j=Integer.parseInt(s); mTts.speak(field_wordsundvalue[j],TextToSpeech.QUEUE_FLUSH,null); } }); sentence.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { TextView t1=(TextView)row.findViewById(R.id.sentence); String s=t1.getText().toString(); int j=Integer.parseInt(s); mTts.speak(field_sentencesundvalue[j],TextToSpeech.QUEUE_FLUSH,null); } }); ll.addView(row); mylist.add(value); }` </code></pre>
android
[4]
2,087,070
2,087,071
Is it possible to run "pm create-user Name" command programmatically?
<p>I am able to create the multiple user profile on Jellybean using "pm create-user Name" terminal command on Emulator, but I want to know is there any way so I can run the same command programmatically. I don’t want to open the terminal. </p>
android
[4]
5,137,123
5,137,124
Write image in drawable using android 2.1
<p>I have a bitmap object. I want to overwrite a .png image under drawable folder with the bitmap object content. I need a sample code to do this. Thanks in advance</p>
android
[4]
3,903,124
3,903,125
Calling keyevent from mouse
<p>I need to emulate a key press with click on a link. The keyboard shortcut <kbd>CTRL</kbd>+<kbd>+</kbd> must be called with a click on a link, or a similar function.</p>
javascript
[3]
760,922
760,923
How do I make the first letter of a string uppercase?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1026069/capitalize-first-letter-of-string-in-javascript">Capitalize first letter of string in javascript</a> </p> </blockquote> <p>How do I make the first letter of a string uppercase?</p>
javascript
[3]
3,519,607
3,519,608
Display vertical pages for UITextView in UIScrollView
<p>How i can display vertical pages for <code>UITextView</code> in <code>UIScrollview</code></p> <pre><code>self.textView = [[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 410)]autorelease]; self.textView.textColor = [UIColor blackColor]; self.textView.font = [UIFont fontWithName:@"Georgia-Bold" size:14]; self.textView.textAlignment = UITextAlignmentCenter; //self.textView.backgroundColor = [UIColor colorWithHue:2.0/12 saturation:2.0 brightness:4.0/10 alpha:1.0]; self.textView.backgroundColor = [UIColor whiteColor]; self.textView.editable = NO; self.textView.delegate = self; self.textView.textAlignment = UITextAlignmentCenter; self.textView.layer.borderWidth = 1; self.textView.layer.borderColor = [[UIColor darkGrayColor] CGColor]; self.textView.layer.cornerRadius = 1; self.textView.textAlignment = UITextAlignmentCenter; self.textView.text = @"Juice fasting makes every other natural method work faster..............."; [self.view addSubview:self.textView]; scrollView.contentSize = CGSizeMake(textView.frame.size.width, textView.frame.size.height); scrollView.maximumZoomScale = 4.0; scrollView.minimumZoomScale = 0.75; scrollView.clipsToBounds = YES; scrollView.scrollEnabled = YES; scrollView.delegate = self; scrollView.indicatorStyle = UIScrollViewIndicatorStyleBlack; [self.scrollView addSubview:self.textView]; [button release]; [super viewDidLoad]; } </code></pre> <p>I have a long text in <code>UITextView</code>. How i can display this <code>UITextView</code> in vertical pages when user scrolls.</p> <p>Appreciate help.</p>
iphone
[8]
3,420,390
3,420,391
camera application with odd images
<p>I have created a camera app which once opens simply captures an image every x minutes and sends the images to a web server. All is working well but I have noticed on the web site some odd images coming through every now and again! Has anyone hae any ideas as to whats happening?<br><br><a href="http://i.stack.imgur.com/Mi15n.jpg" rel="nofollow">heres the odd image</a></p> <p>I thnk i have found the problem, i suspect that running the application through the emulator causes these images to be produced and sent to my website, this would make sense as the emulator has no way of taking images.</p>
android
[4]
5,934,244
5,934,245
How do I use preg replace to remove this?
<p>I have a string <code>$test='23487°';</code></p> <p>How can I remove all the instances of the little circle that appears in the string using preg replace? </p> <p>What to I enter for the regex to remove it?</p> <p>EDIT - as Pekka says, str_replace is better I am now using that. But the little circle is still not recognized by PHP...</p>
php
[2]
2,980,534
2,980,535
Should I use the ReSharper rules for naming?
<p>I have a fairly small and new MVC application I am working on. I just installed the Trial edition of ReSharper and its suggesting a few (many) name changes. </p> <p>In particular it's suggesting method name changes from <code>getStorageAccount</code> to <code>GetStorageAccount</code>, local variable name changes from <code>_questionTable</code> to <code>questionTable</code> and so on.</p> <p>I would like to my application to conform as much as possible. Do you suggest I spend an hour changing everything just so it's done the way ReSharper suggests. I have the time and now would be a good time to do it.</p>
c#
[0]
419,140
419,141
Clone of table header doesn't inherit width when table is bigger than the window
<p>I am using this script to make my table headers stick to the top of the page when scrolling through the table: <a href="http://cmcqueen1975.bitbucket.org/htmlFloatingTableHeader/tables.html" rel="nofollow">http://cmcqueen1975.bitbucket.org/htmlFloatingTableHeader/tables.html</a></p> <p>The problem is, when the table exceeds the window size, the table headers are still crammed in to 100% of the screen width. Then the headers don't line up with the cells they represent. This can be seen in this fiddle:</p> <p><a href="http://jsfiddle.net/UDNNr/" rel="nofollow">http://jsfiddle.net/UDNNr/</a></p>
jquery
[5]
2,702,975
2,702,976
how can i run this program when clicking the button in java?
<pre><code>import javax.swing.*; public class Client extends JPanel { public static void main( String[] args) { clients application; if (args.length == 0) application = new clients(""); else application = new clients(args[0]); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE ); } } </code></pre> <p>I have a java program which consists of swing buttons,When i click on a button i need this program to be executed.How to do?i have tried all possible cases.</p>
java
[1]
4,838,692
4,838,693
c# Exception handling
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5457967/c-exception-handling">c# Exception handling</a> </p> </blockquote> <p>Hi,</p> <p>Greetings!</p> <p>I am getting an error in my c# windows application as creation or updation fails system.exception only some times. i am adding my code below.Please give me some suggesion to get rid of this error.It works fine some times.</p> <pre><code>try { int itemId = TzThing.Set(xml, SessionDatabase, languageStr); } catch (Exception e) { responseString = "create/update item failed, reason:" + e.Message; TouchServer.Log(Logger.MessageType.Error, 0, "Item create/update operation failed. Reason:" + e.Message); } </code></pre> <p>Here set method is my insert or update operation.</p> <p>Thankyou regards jennie</p>
c#
[0]
5,148,100
5,148,101
Unit Testing-Method-ASP.NET-Help?
<p>Hi I have a simple method, where It takes a string as parameter <strong>(domainname//firstname.lastname)</strong> and takes out (<strong>domainname//</strong>) and returns string as just firstname.lastname.</p> <p>I need to unit test for the following case.</p> <ol> <li>check for single slash (domainname/firstname.lastname)</li> <li>Check for empty string</li> <li>Check for null value</li> <li>Check wheather the string contains // or not</li> </ol> <p>I wrote the following but it does not make any sense to me, coz this is completely wrong.</p> <pre><code>#region Checking for null value [TestMethod] public void CheckForNullValueTest() { string expected = ""; string source = @"domainname//hari.gillala"; string actual = Function.RemoveSlash(source); assert.Equal(expected, actual); } #endregion #region Checking for empty [TestMethod] public void CheckForEmptyValueTest() { string expected = string.empty; string source = @"domainname//hari.gillala"; string actual = Function.RemoveSlash(source); assert.Equal(expected, actual); } #endregion #region Checking for singleslash [TestMethod] public void CheckForEmptyValueTest() { string expected = @"domainname/hari.gillala"; string source = "domainname//hari.gillala"; string actual = Function.RemoveSlash(source); assert.Equal(expected, actual); } #endregion #region Checking for Doubleslash [TestMethod] public void CheckForEmptyValueTest() { string expected = @"domainname//hari.gillala"; string source = "domainname//hari.gillala"; string actual = Function.RemoveSlash(source); assert.Equal(expected, actual); } #endregion </code></pre> <p>I know I am completely wrong, but some can help me to understand, how to write, what are the mistakes. thanks for the patience</p> <p>Many Thanks Hari</p>
asp.net
[9]
5,603,505
5,603,506
truncate string with escaped forien charasters
<p>I have the following function to truncate text:</p> <pre><code> /** * Removes HTML tags, crops to 255 symbols * * @param string $unformatted */ public function formatShortDescr($unformatted) { if(strlen($unformatted)&lt;1) return; $long_text = strip_tags(trim($unformatted)); $max_length = 255; if(strlen($long_text) &gt; $max_length){ $short_text = (substr($long_text,0,$max_length)); } else { $short_text = $long_text; } return $short_text; } </code></pre> <p>E.g this: <code>&lt;p&gt;Victory har utvecklats f&amp;ouml;r att passa den &amp;auml;gare som beh&amp;ouml;ver en kompakt, ........</code> get converted into: <code>Victory har utvecklats f&amp;ouml;r att passa den &amp;a</code></p> <p>How can I set it to never cut a string half way through break the html entities? </p>
php
[2]
2,570,311
2,570,312
How to return an object of type "Object" without causing a type mismatch
<p>How can I return type <code>Object</code> from a method to an unknown type without causing a type mismatch?</p>
java
[1]
4,697,632
4,697,633
FourSqaure API PushConsole
<p>While I am trying to send test push i am getting below response</p> <p><strong>Push Response</strong> Push sent!</p> <p><strong>Response:</strong> Your Server returned: 500 Internal Server Error</p> <p>And my code to receive push notification is as below</p> <pre><code>namespace FourSquareService { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class FourSquare : System.Web.Services.WebService { [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string ReadFourSqurePush() { if (HttpContext.Current.Request != null) { return "Hello World"; } return string.Empty; } } } </code></pre> <p>Anybody can help me?</p>
asp.net
[9]
3,236,802
3,236,803
Android -- Layout ellipsize with right-aligned view
<p>How can I achieve this as Text1 gets longer?</p> <p>|[Text1] [Text2]<strong><em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>___</strong>|</p> <p>|[Text1 Text1 Text1] [Text2]<strong><em>_</em>___</strong>|</p> <p>|[Text1 Text1 Text1 Tex...][Text2]|</p> <p>Text2 should always be on the right of Text1, but when Text1 is too large, it is ellipsized and Text2 is right-aligned.</p>
android
[4]
4,519,238
4,519,239
jQuery: How to store data for non-existent elements?
<p>What is a good approach of storing data for dom elements that do not exist yet, but when created they obtain that data. </p>
jquery
[5]
1,090,097
1,090,098
Java Style / Best Practice - passing fields to methods vs accessing directly
<p>In Java, given the following class:</p> <pre><code>public class MyClass { private final Dependency dependency; public MyClass(Dependency dependency) { this.dependency = dependency; } public void doWork() { // validate dependency... } </code></pre> <p>The doWork method needs to invoke a method that uses <code>dependency</code>.</p> <p>Which of the following two variations is considered "best practice", and why?</p> <pre><code> // Access dependency directly void validateDependency() { this.dependency.something(); } // access dependency as passed to the method void validateDependency(Dependency dependency) { dependency.something(); } </code></pre> <p>I find myself favouring the latter, passing the dependency directly to the method, as it makes the method easier to test in isolation (albeit, marginally).</p> <p>However, I'm interested in the java convention / best practice here.</p>
java
[1]
2,155,128
2,155,129
How to solve all in one query?
<p>In my search module I am using SQLite database. Sometimes I'm searching more than two values. So I am using <code>AND</code> condition and sometimes searching only one value. These two cases I need to implement in a single query. Please help me.</p> <p>This is the query:</p> <pre><code>Cursor dbcur = myDB.rawQuery("select * from "+dbtable+" where Status='"+item+"'AND ball_court='"+ball+"'AND Tovendor='"+vendor+"'", null); </code></pre> <p>Sometimes I am searching <code>status</code> and <code>ball_court</code>, <code>tovendor</code> and sometimes I am searching <code>status</code> only. How to solve this problem?</p>
android
[4]
2,466,236
2,466,237
Executing parallel code on code::block
<p>how can I configure Code::block to execute parallel code for me using MPI</p>
c++
[6]
3,890,789
3,890,790
problem with a palindrome method
<p>Hi i am trying to write a palindrome method but am getting the wrong results</p> <pre><code>public static boolean isPalindrome(String input){ int b=input.length(); int []array=new int[b]; for(int i=0;i&lt;array.length;i++){ array[i]=Integer.parseInt(input);} for(int i=0;i&lt;(array.length)/2;i++){ if(!(array[i]==array[array.length-1-i])){ return false;} } return true; } } </code></pre>
java
[1]
774,110
774,111
C++ Selection for Array
<p>I'm trying to teach myself C++ through a book I picked up. One of the exercises is to get an user-inputted array of colours as string objects. Then they say to implement a selection sort on the user-inputted colours using relational operators. I have already started on what I think is the right track, but I have hit a road block and I am not sure what is wrong with it. It compiles, it just won't return the sorted vales (I think) Any assistance with what I have already would be greatly appreciated</p> <pre><code>void selectionSort(char [], int); int main() { const int SIZE = 80; char colour[SIZE]; cout &lt;&lt; "Enter the names of five kinds of fruit:" &lt;&lt; endl; cin.getline(colour, SIZE); cout &lt;&lt; colour &lt;&lt; endl; selectionSort(colour, SIZE); cout &lt;&lt; colour &lt;&lt; endl; return 0; } // SORT void selectionSort(char shade[], int size) { int startScan, minIndex, minValue; for (startScan = 0; startScan &lt; (size - 1); startScan++) { minIndex = startScan; minValue = shade[startScan]; for (int index = startScan + 1; index &lt; size; index++) { if (shade[index] &lt; minValue) { minValue = shade[index]; minIndex = index; } } shade[minIndex] = shade[startScan]; shade[startScan] = minValue; } cout &lt;&lt; shade[size] &lt;&lt; endl; } </code></pre>
c++
[6]
455,131
455,132
Using Simple HTML Dom Parser to Get hyphenated Attribute
<p>There is a similar question to this on StackOverflow. But, My question is a little different.</p> <p>I have selected the image with the required class whose image I want. Earlier, I used</p> <p><code>element-&gt;src</code> </p> <p>to get the value of src attribute, but now the site has replaced it with 'data-src'. </p> <p>I do not have the full contents of a tag, hence I can not use preg_replace. I Have the reqired element, I just want to be able to do something like</p> <p><code>$element-&gt;data-src</code></p> <p>I am trying to do this using PHP SIMPLE HTML DOM PARSER, but no luck yet.</p>
php
[2]
4,007,532
4,007,533
Reading a big file cost too much memory in Python 2.7
<p>I used .readline() to parse file line by line, because I need to find out the start position to extract data into a list, and the end point to pause extracting, then repeat until the end of file. My file to read is formatted like this:</p> <pre> blabla... useless.... ... /sign/ data block(e.g. 10 cols x 1000 rows) ... blank line /sign/ data block(e.g. 10 cols x 1000 rows) ... blank line ... EOF </pre> <p>let's call this file 'myfile' and my python snippet:</p> <pre><code>f=open('myfile','r') blocknum=0 #number the data block data=[] while True: # find the extract begnning while not f.readline().startswith('/sign/'):pass # creat multidimensional list to store data block data=append([]) blocknum +=1 line=f.readline() while line.strip(): # check if the line is a blank line, i.e the end of one block data[blocknum-1].append(["2.6E" %float(x) for x in line.split()]) line = f.readline() print "Read Block %d" %blocknum if not f.readline(): break </code></pre> <p>The running result was that read a 500M file consume almost 2GB RAM, I cannot figure it out, somebody help! Thanks very much!</p>
python
[7]
4,823,158
4,823,159
javascript get element by name
<p>Ok i have this little cute code as a expirement:</p> <pre><code>function validate() { var acc = document.getElementsByName('acc').value; var pass = document.getElementsByName('pass').value; alert (acc); } </code></pre> <p>and this html part</p> <pre><code>&lt;table border="0" cellpadding="2" cellspacing="0" valign="top"&gt; &lt;tr&gt; &lt;td class="td1"&gt;Account&lt;/td&gt; &lt;td class="td2"&gt;&lt;input type="text" name="acc" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="td1"&gt; &lt;td&gt;Password&lt;/td&gt; &lt;td class="td2"&gt;&lt;input type="password" name="pass" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div&gt;&lt;button onClick="validate()" class="cupid-greenx"&gt;Login now&lt;/button&gt;&lt;/div&gt; </code></pre> <p>yes its working, the alert box is showing but the problem is, the value of input("name:acc") is not showing as i specified that it must show whenever it gets the value of that input box instead it shows "undefined" on the alert box. thanks in advance.</p>
javascript
[3]
2,782,269
2,782,270
Android:Is it possible to communicate with input method without a normal textview like edittext?
<p>If I popup input method with togglesoftinput,my view's onCreateInputConnection was not called, and i can not communicate with input method.</p> <p>And then i try to attach the input method to my view:</p> <pre><code>public boolean showSoftInput(View view, int flags,ResultReceiver resultReceiver) { checkFocus(); synchronized (mH) { if (mServedView != view &amp;&amp; (mServedView == null || !mServedView.checkInputConnectionProxy(view))) { return false; } } ... </code></pre> <p>but it returns false</p> <p>How can I force onCreateInputConnection to be called?</p> <p>or </p> <p>How can I make mServedView == view ?</p>
android
[4]
1,662,794
1,662,795
How to make PHP header location redirect use PHP generated URL
<p>This is fairly simple but I cant work it out.</p> <p>I'm building a wordpress site, and I want a redirect on my 404 page using PHP instead of javascript.</p> <pre><code>&lt;?php header("Location: www.myblogurl.com"); ?&gt; </code></pre> <p>And I use this in my wordrpess websites to get the URL of my blog...</p> <pre><code>&lt;?php bloginfo('url'); ?&gt; </code></pre> <p><br /></p> <p>But I can't seem to merge the two PHP scripts together, please see my poor attempt below.</p> <pre><code>&lt;?php $location = bloginfo('url'); header( 'Location:' + $location ) ; ?&gt; </code></pre> <p>This seems to echo my website URL instead of redirecting.</p> <p>Can any help me please, thanks.</p>
php
[2]
2,282,747
2,282,748
Javascript - return false error
<p>I have a form validation function that loops through the form elements checking for empty fields - code below:</p> <pre><code>function formValidate(ourform){ var formelems = document.getElementById(ourform).elements; for (var i=0; i&lt;formelems.length; i++){ if(formelems[i].value == "") { alert("Empty Field(s). Please fill in all the fields."); return false; } } } </code></pre> <p>the problem is that my form does not return false if there's an empty field - it processes the form. I have solved this before but now i just cannot remember how.</p> <p>Thanks.</p>
javascript
[3]
2,372,379
2,372,380
save data for bookmark
<p>I need some suggestion on the right approach to use for saving some bookmark data for my book-like android app I am making. Is using ShardPreference object the best way or what are other alternativs? I just need to save the page number and title in the bookmark.</p>
android
[4]
2,759,383
2,759,384
shorter way of echoing a variable in php?
<p>In the last two days, ive run across code that has php echo'd variables displayed like this</p> <pre><code>&lt;?=$selected?&gt; </code></pre> <p>What exactly is going on and why? What is this called?</p>
php
[2]
1,228,733
1,228,734
Jquery json full calendar
<p>I need help getting Full Calendar working with the day view. I've got it working for Month and week but not for day. I'm getting data in a dynamic JSON feed from java.</p> <p>I am getting following JSON feed: <code>"title":"trftdtdt","start":"2011,12,15,21,0","end":"2011,12,15,21,30","allDay":"‌​false","eventNeed ":"ride","eventStatus":"helpNeeded"</code> </p> <p>This seems to work for everything except day view. What do I need to do to get this working for day view?</p>
jquery
[5]
898,649
898,650
How to set ExpandableListView child as not enabled
<p>Is there a way to set a child on an <a href="http://developer.android.com/reference/android/widget/ExpandableListView.html" rel="nofollow">ExpandableListView</a> as not enabled? I have a header in the children group and I don't want it to be highlighted when clicked. Not an actual header, just a child with a different layout.</p> <p>What I'm looking for is something like <a href="http://developer.android.com/reference/android/widget/ListAdapter.html#isEnabled%28int%29" rel="nofollow">ListAdapter#isEnabled()</a> but there is no such method in the ExpandableListAdapter class.</p>
android
[4]
3,738,578
3,738,579
attaching data to <td> elements
<p>I'm building a web interface to edit values in large tables (2600 x 2600). Because the table is so big, I only load a part of the table into the browser, and the user has the ability to see a small window of the table by specifying xmin, xmax, ymin and ymax values. What is the best way to attach x,y coordinates to each tag that I display to reflect that cell's actual coordinates in the big table? I've looked into jQuery.data() function but it's not obvious how to use it for this purpose.</p>
jquery
[5]
4,469,202
4,469,203
Why doesn't this generic interface stack work?
<p>I have a bunch of generic interfaces and classes</p> <pre><code>public interface IElement { // omited } class Element implements IElement { // omited } public interface IElementList&lt;E extends IElement&gt; extends Iterable { public Iterator&lt;E&gt; iterator(); } class ElementList implements IElementList&lt;Element&gt; { public Iterator&lt;Element&gt; iterator() { // omited } } public interface IElementListGroup&lt;E extends IElementList&lt;? extends IElement&gt;&gt; { public E getChosenElementList(); } class ElementListGroup implements IElementListGroup&lt;ElementList&gt; { public ElementList getChosenElementList() { // omited } } </code></pre> <p>And then a simple code</p> <pre><code>ElementListGroup group; for(Element e : group.getChosenElementList()) { // omited } </code></pre> <p>And the line with for keyword throwe a "cannot convert from element type Object to Element" compiler error.</p> <p>Thanks in advance.</p>
java
[1]
4,589,629
4,589,630
Refactoring in jQuery (following DRY principles)
<pre><code>$dltDiv.click(function(){ $seatdiv.css("background-color","#42de18"); $ticketRowDiv.hide(); price = price-15.50; $('#price h1').html('$'+price); }); $seatdiv.click(function(){ $seatdiv.css("background-color","#42de18"); $ticketRowDiv.hide(); price = price-15.50; $('#price h1').html('$'+price); }); </code></pre> <p>How could I make the same code in one function and be called seperately? Cheers.</p>
jquery
[5]
3,260,254
3,260,255
Assignment in conditionals
<p>I've seen a lot this kind of code recently :</p> <pre><code>if ($foo = $bar-&gt;getFoo()) { baz($foo); } </code></pre> <p>Is this considered good or bad practice ?</p> <p>For example, Netbeans IDE give a notice if you use this kind of code :</p> <blockquote> <p>Possible accidental assignment, assignments in conditions should be avoided</p> </blockquote> <p>What do you think ?</p>
php
[2]
1,523,232
1,523,233
Fatal error: Call to a member function diff() on a non-object when the object exists?
<p>Trying to get the difference between two DateTime objects. With the below code, I can echo out the <code>$endSub</code> variable and get a string like <code>2012-5-26T00:00:00-04:00</code> which is exactly what I need. However, I get the error in the title if I do not <code>exit()</code> the code on the <code>$interval =</code> line. Can anyone see a reason this would occur?</p> <pre><code>if ($todays_month &gt;= 6){ $endSub = new DateTime(($startYear+1).'-5-'.$startDay); }else{ $endSub = new DateTime($startYear.'-5-'.$startDay); } echo $endSub-&gt;format(DATE_RFC3339); exit(); $interval = $startSub-&gt;diff($endSub); </code></pre>
php
[2]
125,631
125,632
Setting camera intent to not add in EXIF data
<pre><code> Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //Using a File so it overwrites previous camera shot File pictureFile = new File(cameraImagePath); camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(pictureFile)); startActivityForResult(camera, TAKE_PICTURE); </code></pre> <p>I'm using this code to get a camera shot which is then uploaded to an imageboard. The problem is that on some phones GPS locations are recorded in the EXIF data and users are unknowingly revealing their locations. Is there some value I can add to the intent to tell the camera app not to record any EXIF data?</p> <p>(Using 1.6 API's also)</p>
android
[4]
5,205,693
5,205,694
Is this C++ code defining main or running main?
<p>I'm reading Stroustrup's Programming: Principles and Practice and came across this code:</p> <pre><code>int main() try { // our program return 0; //0 indicates success } catch (exception&amp; e) { cerr &lt;&lt; "error: " &lt;&lt;e.what() &lt;&lt;'\n'; keep_window_open(); return 1; // 1 indicates failure } catch (...) { cerr &lt;&lt; "Oops: Unknown exception!\n"; keep_window_open(); return 2; //2 indicates failure } </code></pre> <p>At first I thought that the first line called the main function (which contained the heart of the code and was written somewhere else). And then we are just trying to catch errors that might have occurred inside of main(). But if that's the case, why does it say "our program" in the try block? This makes me think that this code is defining main(). But if that's the case, then where are the bracket s? That is, why isn't it <code>int main() {</code> on the first line?</p>
c++
[6]
1,460,098
1,460,099
Can I open 2 cameras on android phone
<p>Is it possible for me to open both front and back Camera in my android application? Or I can either open front or back?</p> <p>Can I have 2 preview surface? one from front, one from back?</p> <p>Thank you.</p>
android
[4]
2,741,286
2,741,287
Change rawtext to a variable name?
<p>Is there a way I could possible change raw text to a variable name in a echo. For instance settings a variable <code>$number</code> to <code>number1</code>, and then when it echoes to use <code>$number1?</code> </p> <p>To clarify, say we have a variable named <code>$number = "number1";</code> in it, and when we echo <code>$number</code> , it echos a variable named <code>number1</code>, how would I change <code>number1</code> to a variable? Something like "echo "$"."$number";?</p>
php
[2]
4,651,187
4,651,188
JQuery select between
<p>I have a JQuery "collection" of li objects (result of applying .filter())...</p> <p>The collection is named <code>results</code> ... Because of javascript pagination i am trying to find an efficient way to make elements visible from index x up to index y... This test didnt work </p> <pre><code>results.find(":lt(5):gt(0)").show(); </code></pre> <p>Iam just trying to find a non loop method.</p>
jquery
[5]
1,974,049
1,974,050
native heap size increasing whenever application is launched
<p>Native heap size of my application keeps increasing and finally crashes. </p> <p>I have a couple of list views in my application and it is being populated from the database. In the lisview, there are images and I have soft references to the bitmap image that is being loaded into the listview.</p> <p>I also have option to view my application in different languages - English and Hindi.Whenever the user changes the language, I reload my application and this is increasing native heap size even though I have set FLAG_CLEAR_TOP and the activities are destroyed.I also set the locale when the language is changed.</p> <p>I have also made sure all the lists are cleared when activities are destroyed.</p>
android
[4]
506,502
506,503
Location of Android Phone via Sim card
<p>I want a offline location of android phone and want to save in local db, can i do via sim card? will i be able do with Network provide but without internet ? if yes find provide me the way to do in Android Any help will be appropriated thanks.</p>
android
[4]
2,117,102
2,117,103
How to be able to write to a textbox side-by-side names of the items which are find inside Listbox in C#?
<p>How to be able to write to a textbox side-by-side names of the items which are find inside Listbox in C#?</p> <p>Regards,</p>
c#
[0]
4,070,990
4,070,991
Search for file in directory with multiple directories
<p>Here's my goal. I want to be able to pass a parent directory and a filename to a method that searches for that specific file in the directory and any sub-directories. Below is the code I have been working with but can not get it to do exactly what I want. It will find the file I specify but will not return anything.</p> <pre><code>private static File findFile(File dir, String name) { String file = ""; File[] dirlist = dir.listFiles(); search: for(int i = 0; i &lt; dirlist.length; i++) { if(dirlist[i].isDirectory()) { findFile(dirlist[i], name); } else if(dirlist[i].getName().matches(name)) { file = dirlist[i].toString(); break search; } } return new File(file); } </code></pre> <p>I know that when the method finds a directory and calls itself it resets the file variable which is where I am storing the found file. So that is why I am getting a blank return. I am not sure how to accomplish this goal or if it's even possible.</p>
java
[1]
4,534,041
4,534,042
$_SESSION variable not updating every iteration
<p>So I have this piece of code that is executed each iteration. The iterations are not ordinary loops but part of a series of ajax request iterations. The first ajax request determines a filename that is assigned to e.g $_SESSION['filename'] and then this variable is pushed into and array etc. Now the problem occurs when i have multiple files being processed.</p> <p>It happens often that one of the filenames that is generated gets duplicated and inserted into the database which it should not.</p> <p>First callback function:</p> <pre><code> case 'upload': ... $_SESSION['upload_filename'] = random_filename($alphas).'.'.$fileExt; ... break; </code></pre> <p>second callback function:</p> <pre><code> case 'insert_db': array_push($someGlobalArray, $_SESSION['upload_filename']); insert($_SESSION['upload_filename']); break; </code></pre> <p>So as I said a new filename is generated properly like 70% of the time. I'm not sure why the old filename from the previous "iteration" lingers and $_SESSION['filename'] does not contain a new filename. I've tried unset the filename after insert() in the second callback function, but that causes a problem where no filename is available to be either pushed into the array or inserted into the database since what I think is that it gets unset before? I've also tried sleep(2) after the insert() and then unset but does not help.</p> <p>Here is more of the code: <a href="http://pastebin.com/g4fereQx" rel="nofollow">http://pastebin.com/g4fereQx</a></p>
php
[2]
195,006
195,007
List loop cannot be accessed
<p>I have a new list which have at least 5 objects. I am trying to copy the elements of the new list to the old one. The problem here is that loop never accessed.</p> <pre><code>foreach (JobPosition Position in JobPositionsListNew) { JobPositionsList.Add( new JobPosition( Position.SetGetPositionName, Position.SetGetMinimumDegree, Position.SetGetSalary)); } </code></pre>
c#
[0]
1,284,243
1,284,244
How do i calculate the height of toolbars, address bars and other navigation tools in pixels?
<p>Basically i need to know how many pixels the y axis is from the top left of the screen until i reach the actual web window. Does anyone have any ideas...?</p>
javascript
[3]
4,558,113
4,558,114
IOS 4.3 app not running in lower version
<p>Application created using 4.3 is not running in lower version.... Here am also set deployment target to lower version..</p> <p>Why its not running in lower version?</p> <p>Where should i learn functionality of all ios versions and also i want to know possibility of running 4.3 app in lower version.</p>
iphone
[8]
3,208,814
3,208,815
How to wake a phone without pressing power button
<p>Anybody know that how to wake a phone with any action but without pressing power button or any hard-key and in android programmatically..</p> <p>Thanks in advance</p>
android
[4]
962,082
962,083
strtotime - a second before midnight
<p>I attempted this:</p> <pre><code>$date_string = strtotime('6 Mar, 2011 23:59:59'); </code></pre> <p>But I think PHP can't interpret that for some reason as it returned empty. I tried this:</p> <pre><code>$date_string = strtotime('6 Mar, 2011 midnight'); </code></pre> <p>The above worked but I need it to be a second before midnight i.e. the last second of the day. How can I get strtotime to return this without changing the 6 Mar, 2011 part?</p>
php
[2]
1,041,052
1,041,053
if file exists php
<p>I use following code to delete old image from ftp...</p> <pre><code>unlink(getcwd() . '/images/' . $row['pic']); </code></pre> <p>But it throws errors in case there is not image, so i have tried using file_exists() but that didn't work too, so how can i check if there is an image before trying to delete. thanks.</p> <pre><code>if(file_exists(getcwd() . '/images/pics/' . $row['pic'])) { unlink(getcwd() . '/images/pics/' . $row['pic']); } </code></pre>
php
[2]
3,311,402
3,311,403
What is Convert.ToInt32 and Convert.Uint 16?
<p>I am a new developer with C#, which don't understand convert string to integer.</p> <p>What are</p> <ul> <li><code>Convert.ToInt16</code></li> <li><code>Convert.ToInt32</code></li> <li><code>Convert.ToInt64</code></li> <li><code>Convert.Uint16</code></li> <li><code>Convert.Uint32</code></li> <li><code>Convert.Uint64</code> </li> </ul> <p>What is the functionality and different of it? </p> <p>Can give me an example?</p>
c#
[0]
933,832
933,833
Get frequency count of elements in an array
<p>Hi I have a list of values. I want to get another list with the amount of times every values in that list occurs. This is fairly easy, but I also need to have the values which are not present in the original list, to be present in the frequency list, but then with value 0. For example:</p> <pre><code>I = [0,1,1,2,2,2,4,4,5,5,6,6,6,8,8,8] </code></pre> <p>What you expect:</p> <pre><code>freqI = [1,2,3,2,2,2,3,3] </code></pre> <p>What I need:</p> <pre><code>freqI = [1,2,3,0,2,2,3,0,3] </code></pre> <p>As you can see 3 and 7 are not present in <strong>I</strong>, though they are still accounted for in the frequency list. </p> <p>My initial try ended up giving me the first kind of solution (with the intermediate values):</p> <pre><code>d = {x:I.count(x) for x in I} sorted_x = sorted(d.iteritems(), key=operator.itemgetter(0)) </code></pre> <p>How can I get the frequency count (aka histogram) of my array, with the intermediate values present ?</p>
python
[7]
2,788,381
2,788,382
Installing Big Integer libraries for C++?
<p>I try to install <a href="https://mattmccutchen.net/bigint/" rel="nofollow">https://mattmccutchen.net/bigint/</a> and even when I include all the .hh files, using BigIntegers throws undefined reference errors.</p> <pre><code>[Linker error] undefined reference to `BigInteger::BigInteger(int)' [Linker error] undefined reference to BigInteger::divideWithRemainder(BigInteger const&amp;, BigInteger&amp;) </code></pre> <p>I am using DevCPP and don't want to switch from this (it's been a headache getting anything other than DevCPP working). I also tried GMP but that was needlessly confusing and I couldn't get that working either.</p> <p>When I tried compiling the <code>.cc</code> files that came with it, I get all the same linker errors. </p>
c++
[6]
1,689,270
1,689,271
ajax modal pop up not working in Firefox
<p>hi i have ajax modal pop up and it is working perfectly in IE but the same control is not working in firefox. below is my code</p> <p> &nbsp; </p>
asp.net
[9]