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
5,838,475
5,838,476
Apply jQuery function to one element and *NOT* its descendants
<p>I want to add certain classes to the various levels of my websites nav header. So I'll have something in the end like</p> <pre><code>$('#navCol &gt; ul &gt; li &gt; ul &gt; li &gt; ul').addClass('lvl2'); // Each ‘li &gt; ul’ past the first ‘ul’ indicates another sub-level. </code></pre> <p>to add the <code>lvl2</code> class to the second level, etc. Having said that, not only does it apply said class to the second level, it also adds it to the other <code>ul</code>s beneath it. Is there a way to specify that I only want to include the element and not its descendants.</p>
jquery
[5]
3,551,113
3,551,114
Handling large strings in Android (OutOfMemeryError)
<p>I am currently working on an Android application and has encountered an OutOfMemoryError on a Motorola Defy. </p> <p>The place where the error occurs, is where I convert a 5MP image to a Base64 encoded string which subsequently is sent to a web service contained in a SOAP document. </p> <p>I am aware, that both the actual encoding of the image, and using SOAP both are overheads - and would prefer myself to eliminate those - but that is not possible right now. </p> <p>My question goes more on how to handle the large strings, being not to much into Java and Memory handling I need a little assistance. </p> <p>The code is approx like this: </p> <pre><code>String soapMessage = registration.createSoapRequest(); //In this method a StringBuilder is used to build the message, and returns it //as new String(soap.toString(); //At this point I have to objects in memory using approx 6 and 9 MB each. //I would expect it to be the StringBuilder and the string soapMessage. //But I can't figure out how to GC the StringBuilder - which I don't need to use //any more. //Declaring the entity to post StringEntity entity = new StringEntity(soapMessage, HTTP.UTF_8); //By declaring the entity, I receive my OutOfMemoryException, due to having //the 6-7 MB string now replicated 3 times - giving 21 MB alone. entity.setContentType("text/xml"); //Creating client HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://MYSERVER/services/registration.svc"); post.setHeader("Content-Type","text/xml; charset=utf-8"); post.setHeader("SOAPAction", "http://tempuri.org/IRegistration/PostRegistration"); post.setEntity(entity); BasicHttpResponse response = (BasicHttpResponse)client.execute(post); </code></pre> <p>The obvious Memory issue here seems to make me able to only hold one instance of the string in memory. </p> <p>How would I do this?</p> <p>I hope somebody can help me through this as I feel stuck in Java Memory handling.</p> <p>Best regards /Anders</p>
android
[4]
2,967,942
2,967,943
Difference between calling function and referencing function?
<p>Look at the following code:</p> <pre><code>window.onload = someFunction; </code></pre> <p>Many times I see the use of this kind of code and even I use the same. But, there are still few things unclear. </p> <ol> <li>The above is a call to <code>someFunction</code> as soon as the page loads, right. But, aren't we supposed to call a function with brackets <code>()</code>?</li> <li>From my understanding, we are just assigning <code>someFunction</code> to <code>window.onload</code>, therefore can we or shouldn't we call <code>window.onload()</code>;</li> <li>Are there such cases, when <code>functionName()</code> and <code>functionName</code> becames interchangeable. Because at many places, and in various API, I have seen calling the function without brackets.</li> </ol>
javascript
[3]
3,128,175
3,128,176
uiview in navigation
<p>I am working with a navigation application. I have a homeViewController with two views(accept, service). When I click on a button in serviceView it should go to acceptView. I should have back button in navigation bar which takes me be back to serviceView from acceptView. When I am trying to use [self navigationController pushViewController, it only accepts viewcontroller but not view. Can any one please tell the alternative. Please help me.</p> <p>Thanks in advance</p>
iphone
[8]
860,381
860,382
issue in deleting when we have more than 1 file
<p>i have 10 files. i want to delete them but the condition here is as i delete file 1 to file 5 .let say in file6 i got an exception then in that case i should restore all the files deleted</p> <p>i should delete the files only if there is no exception occured in any of the file when we try to delete</p> <p>something like rollback transcation what we do in DB. is there any properties in file we can achive this concept</p> <p>anyhelp would be great thank you </p>
asp.net
[9]
2,621,115
2,621,116
Confusions about Wordpress get_the_title function
<p>The function:</p> <pre><code> /** * Retrieve post title. * * If the post is protected and the visitor is not an admin, then "Protected" * will be displayed before the post title. If the post is private, then * "Private" will be located before the post title. * * @since 0.71 * * @param int $id Optional. Post ID. * @return string */ function get_the_title( $id = 0 ) { $post = &amp;get_post($id); $title = isset($post-&gt;post_title) ? $post-&gt;post_title : ''; $id = isset($post-&gt;ID) ? $post-&gt;ID : (int) $id; if ( !is_admin() ) { if ( !empty($post-&gt;post_password) ) { $protected_title_format = apply_filters('protected_title_format', __('Protected: %s')); $title = sprintf($protected_title_format, $title); } else if ( isset($post-&gt;post_status) &amp;&amp; 'private' == $post-&gt;post_status ) { $private_title_format = apply_filters('private_title_format', __('Private: %s')); $title = sprintf($private_title_format, $title); } } return apply_filters( 'the_title', $title, $id ); } </code></pre> <p>I don't understand what the parameter <code>__('Protected: %s')</code> means in a particular line of code below. What kind of parameter is it?</p> <pre><code>$protected_title_format = apply_filters('protected_title_format', __('Protected: %s')); </code></pre>
php
[2]
2,093,261
2,093,262
SMS Manager for Dual Sim Phones?
<p>I am working with SMS Manager for sending sms in android.The code i am using is as below:</p> <pre><code>private void sendSms(String Phnno, String Message) { if (Utils.checkSIM(MyActivity.this)) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(Phnno, null, Message, null, null); Utils.showMessage(MyActivity.this,"","Thank You for your interest,please check your inbox for the results."); } else { showErrorMessage(MyActivity.this, "SIM Error!", "Please insert SIM"); } } </code></pre> <p>This code works for me perfectly on single sim phones but when i check this in dual sim phones i am getting following warning and SMS never sends.</p> <pre><code>01-11 15:56:13.664: W/sendTextMessage(6656): use single sim interface to sendTextMessage by double sim interface </code></pre> <p>Please suggest how i can achieve it on my dual sim phone.Thanks in Advance.</p>
android
[4]
3,590,714
3,590,715
How to create an immutable class
<p>I want to make the class below immutable. Can anyone provide a simple example of creating an immutable class in java?</p> <pre><code>class Emp implements Comparable { String name,job; int salary; public Emp(String n,String j,int sal) { name=n; job=j; salary=sal; } public void display() { System.out.println(name+"\t"+job+"\t"+salary); } public boolean equals(Object o) { // use a shortcut comparison for slightly better performance; not really required if (this == o) { return true; } // make sure o can be cast to this class if (o == null || o.getClass() != getClass()) { // cannot cast return false; } // can now safely cast Emp p=(Emp)o; return this.name.equals(p.name)&amp;&amp;this.job.equals(p.job) &amp;&amp;this.salary==p.salary; } public int hashCode() { return name.hashCode()+job.hashCode()+salary; } public int compareTo(Object o) { Emp e=(Emp)o; return this.name.compareTo(e.name); //return this.job.compareTo(e.job); // return this.salary-e.salary; } } </code></pre>
java
[1]
482,952
482,953
Draw a curve in iPhone?
<p>I am developing a game app in which a curve(Bezier) is required on the basis of theta provided by user and this will be in animated format. But i am not aware of openGL. Then how can i do it programatically?</p>
iphone
[8]
3,746,251
3,746,252
Is it normal for android emulator to load more that 7+ minutes?
<p>I tried to run android emulator with Google API 14 and Google API 3 the effect is the same - it loading more than 7+ minutes and seems to be stuck at displaying android logo. But whole this time my CPU is loaded with emulator process. Is it normal? Removing all avd api and reinstalling - will solve the problem?</p> <p>I can not get it completely loaded. Maybe something wrong while I updated it in Eclipse?</p>
android
[4]
5,298,633
5,298,634
A case where named constants are not needed over magic numbers
<p>Obviously the point of using named constants over magic numbers is for code clarity and for not having to go through code changing numbers throughout.</p> <p>However, what do you do if you just have a number used just once in a function? Say you have a short member function that uses an object's velocity (which we'll say won't change) to calculate its motion, but this is the only function that uses that velocity. Would you...</p> <p>A) Give the class a named static constant to use</p> <p>B) Put a named constant in the function</p> <p>C) Use the magic number but comment it</p> <p>D) Other...</p> <p>I am kind of leaning towards using a magic number and commenting it if the number is ONLY BEING USED ONCE, but I'd like to hear others' thoughts.</p> <p>Edit: Does putting a named constant in a function called many times and assigning to it have performance implications? If it does I guess the best approach would be to put the constant in a namespace or make it a class variable, etc.</p>
c++
[6]
2,641,642
2,641,643
Jquery- recognize the object being acquired?
<p>Lets say I have this assignment : </p> <pre><code>$("myObj").val('1') </code></pre> <p>now lets say I want to add to <code>1</code> the existsing value , so : </p> <pre><code>$("myObj").val($("myObj").val()+'1') </code></pre> <p><em>p.s. , I dont want any outside variable to remember the value</em></p> <p>Is there any way to get the object being acquired ? something like : </p> <p><img src="http://i.stack.imgur.com/30ITj.jpg" alt="enter image description here"></p>
jquery
[5]
2,907,141
2,907,142
how to draw candlestick charts in iphone?
<p>i am new to Quertz,How can I draw candle charts in IPhone? Does anybody has any examples with a nice interface for IOS?</p>
iphone
[8]
2,034,044
2,034,045
str_get_html and simply html dom
<p>way after str_replace function $img is empty and secont $img->find('img') function show error:</p> <pre><code>Fatal error: Cannot use object of type simple_html_dom as array in D:\wamp\www\test.php on line 7 &lt;?php require_once('simple_html_dom.php'); $img_html = str_get_html('hhtml tekst html tekst &lt;img src = "img.png" /&gt; ad sad'); foreach($img_html-&gt;find('img') as $element) $img[] = $element-&gt;src . '&lt;br&gt;'; $img_html = str_replace($img[0], 'n-'.$img[0], $img_html); foreach($img_html-&gt;find('img') as $element2) echo $element2-&gt;src . '&lt;br&gt;'; ?&gt; </code></pre>
php
[2]
835,151
835,152
What's a suitable return type for this Java method?
<p>we are implementing a system with Strategy pattern. </p> <p>Some callers to a specific methods require a Hashmap of data while in some case it would be a user-defined DTO. Some need both.</p> <p>How do we decide which return type to use, instead of an Arraylist containing Hashmap and DTO ? Is there anything more approporiate? </p> <p>Example:</p> <p>Some caller needs only 2 strings and prefers a Hashmap.</p> <p>Some other caller to the same API needs 12 values which are suited to put in a DTO. 1st caller does not need all the elements in the DTO.</p> <p>3rd caller needs all 14 values and hence both structures.</p>
java
[1]
4,073,994
4,073,995
jquery if div not id
<p>i want to cut the price off to all input value in all divs, except only one <code>div sale_wrap</code>. how to make exception with jquery?</p> <pre><code>&lt;div id="one_wrap"&gt; &lt;input type="checkbox" name="1" value=""&gt; &lt;input type="checkbox" name="1" value=""&gt; &lt;/div&gt; &lt;div id="two_wrap"&gt; &lt;input type="checkbox" name="2" value=""&gt; &lt;input type="checkbox" name="2"" value=""&gt; &lt;/div&gt; &lt;div id="sale_wrap"&gt; &lt;input type="checkbox" name="3" value=""&gt; &lt;/div&gt; </code></pre> <p>jquery:</p> <pre><code>if($("div").attr("id") != "sale_wrap") { t_balance; } else { var sale = t_balance*((100-window.discount_p)/100); t_balance = sale; } </code></pre>
jquery
[5]
1,759,798
1,759,799
java regular expression showing middle results
<p>How do you show all the matches?For example I have one String "Hello world and how are you a". Here I have to get all the positions where letter 'a' resides.For that I wrote one sample java program. But here only start() and end() methods are available for matcher. How do I get the middle results? Please explain me..</p> <pre><code>import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexTestStrings { public static void main( String args[] ){ String line = "Hello world and how are you a"; String pattern = "[a]"; Pattern r = Pattern.compile(pattern); Matcher m = r.matcher(line); if (m.find( )) { System.out.println(m.start()); System.out.println(m.end()); } else { System.out.println("No result foud"); } } } </code></pre>
java
[1]
1,342,374
1,342,375
two values in one field
<p>I've this simple form, when the price is set to <code>120</code> $:</p> <pre><code> &lt;input type="checkbox" name="addon[book]" value="120" /&gt; book &lt;input type="checkbox" name="addon[plane]" value="420" /&gt; Plane </code></pre> <p>Could I send two values (USD &amp; €) with thr form?</p> <p><strong>EDIT:</strong> <br /></p> <p>I added <code>name="addon[book]"</code> because I'll display the <code>name</code> too</p> <p><strong>EDIT 2:</strong><br /></p> <p>PHP:</p> <pre> foreach($addon as $name => $value) { echo 'your addons: '.$name; } $total = array_sum(array_map("intval", $_POST["addon"])); echo 'the total '.$total.' $'; </pre>
php
[2]
2,148,688
2,148,689
How Writing XMl file usning XMLStreamWriter in android
<p>i want create XML file here is my following code </p> <pre><code>String fileName = "jasstech.xml"; XMLOutputFactory xof = XMLOutputFactory.newInstance(); XMLStreamWriter xtw = null;** try { xtw = xof.createXMLStreamWriter(new FileOutputStream(fileName), "UTF-8"); xtw.writeStartDocument("UTF-8", "1.0"); xtw.writeStartElement("root"); xtw.writeComment("This is an attempt to create an XML file with StAX"); xtw.writeStartElement("foo"); xtw.writeAttribute("order", "1"); xtw.writeStartElement("meuh"); xtw.writeAttribute("active", "true"); xtw.writeCharacters("The cows are flying high this Spring"); xtw.writeEndElement(); xtw.writeEndElement(); xtw.writeStartElement("bar"); xtw.writeAttribute("order", "2"); xtw.writeStartElement("tcho"); xtw.writeAttribute("kola", "K"); xtw.writeCharacters("Content of tcho tag"); xtw.writeEndElement(); xtw.writeEndElement(); xtw.writeEndElement(); xtw.writeEndDocument(); } catch (XMLStreamException e) { e.printStackTrace(); } catch (IOException ie) { ie.printStackTrace(); } </code></pre> <p>The above Same Code is Working Fine in JAVA project But In Android Project gives following Error </p> <pre><code>03-03 07:48:40.778: ERROR/AndroidRuntime(719): Uncaught handler: thread main exiting due to uncaught exception 03-03 07:48:40.788: ERROR/AndroidRuntime(719): com.kochar.xml.stream.FactoryConfigurationError: Provider com.ctc.wstx.stax.WstxOutputFactory not found 03-03 07:48:40.788: ERROR/AndroidRuntime(719): at com.kochar.xml.stream.XMLOutputFactory.newInstance(XMLOutputFactory.java:23) </code></pre>
android
[4]
5,904,884
5,904,885
How to get the inner html value
<pre><code>&lt;span style="color: red"&gt; advertising cctv/bust&lt;/span&gt; &lt;span style="color: red"&gt;a&lt;/span&gt;tion </code></pre> <p>how to get the value from this text</p> <p>I used replace function but it removing only once and it ignoring second one </p> <p>how can i do this one</p>
javascript
[3]
4,746,964
4,746,965
How to change DataField of BoundField
<p>When using the <code>asp:boundfield</code>, can I call a C# function that return a string which corresponds to the column name instead of writing the column itself?</p> <pre><code> &lt;asp:BoundField DataField="Notes" HeaderText="Notes"/&gt; </code></pre> <p>Instead of having <code>DataField="Notes"</code>, I want to have <code>DataField=FUNCTION_NAME</code>.</p> <p>I tried using the following but it didn't work:</p> <pre><code>DataField=&lt;% FUNCTION_NAME %&gt; </code></pre>
asp.net
[9]
3,081,422
3,081,423
Return two widgets from a getView methord
<p>I am working in an android application and I want to implement a Gallery. And on my getView method now I return a Image View. In this method I want to return a button and an Image View. How can I do this.</p> <p>Thanks in advance</p> <p>This is ma code :</p> <pre><code>ImageView imageView = new ImageView(mContext); imageView.setImageResource(mImageIds[position]); imageView.setLayoutParams(new Gallery.LayoutParams(150, 180)); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setBackgroundResource(mGalleryItemBackground); return imageView; </code></pre>
android
[4]
2,545,713
2,545,714
Issue with sending form in jquery
<p>I am working on a function that lets people log in to their accounts and the form should be sent without reloading the page. The problem is, with my current code the form values are not sent for some reason. What is wrong with my code?</p> <p><strong>Jquery</strong></p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $('#form form').submit(function(){ $("#form :input").attr("disabled", true); $.post('0_0.php', $(this).serialize(), function(data){ $('#message').html(data); $("#message").fadeIn(500); $("#form :input").attr("disabled", false); }); return false; }); }); &lt;/script&gt; </code></pre> <p><strong>html</strong></p> <pre><code>&lt;div id="form"&gt;&lt;form&gt; &lt;table&gt;&lt;tr&gt; &lt;td&gt;&lt;input type="text" value="" class="input 1" placeholder="E-post" name="email" id="i" /&gt;&lt;/td&gt;&lt;td&gt; &lt;input type="password" name="pass" placeholder="Lösenord" class="input" value="" id="p" /&gt;&lt;/td&gt;&lt;td&gt; &lt;input type="submit" value="Logga in" class="button" name="submit" /&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" id="checkbox-1-4" name="remember" class="regular-checkbox" /&gt;&lt;label for="checkbox-1-4"&gt;&lt;/label&gt; &lt;/td&gt;&lt;td&gt;&lt;a class="link" style="margin:0; font-size:11px;" href="forgot_password.php"&gt;Glömt lösenordet?&lt;/a&gt; &lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/form&gt;&lt;/div&gt; </code></pre>
jquery
[5]
2,846,159
2,846,160
If statement variable returning empty
<p>this is a test code i wrote to get a value set for $rectype to insert into a table. problem I'm having is $rectype is returning 0 or empty. the files do exist since I perform a similar is_file check to start the process that leads up to this section of the coding</p> <pre><code>$dirchk1 = "/temp/files/" . $data[0] . ".doc"; // exist $dirchk2 = "/temp/files/" . $data[1] . ".doc"; // exist $file_1 = (is_file($dirchk1)); $file_2 = (is_file($dirchk2)); if ($file_1) { $rectype == ($file_2 ? '3' : '1'); } echo $rectype . "\n"; </code></pre>
php
[2]
5,680,006
5,680,007
How to avoid ANR occured in android?
<p>I am making an application in Android 1.6, there is an 'Application Not Responding' (ANR) error occuring - please suggest how to handle it in activity? </p> <p>I did only calling of web services according to condition and used a timer which runs and calls a particular webservice. One webservice fetches users who show on a gridview, when we click on the gridview seldom ANR occured but not each time.</p>
android
[4]
4,810,990
4,810,991
Android:Running an application continously in background even if user closes the application
<p>I am new to android and I was trying out an app as "Scheduled messaging". Scenario: Suppose you want to send some message to your friend at 6PM. Then you can just make an entry and message will be sent automatically at that time. But now where I am stuck up is that the application must run always even if user tries to close it because else message wont be sent. Can anyone please give me a small demo for this. thanks!!!</p>
android
[4]
4,922,694
4,922,695
Structs data type in php?
<p>Can anyone give me example for structs data type in php ? How come there is something like structs in php all of a sudden ?</p>
php
[2]
4,905,496
4,905,497
How to get YEAR of previous month using date()
<p>I want to get the year of the previous month.</p> <p>For example in <code>July 2012</code> I want result <code>2012</code>. But in <code>January 2013</code> I want result <code>2012</code> and in <code>Feb 2013</code> I want result <code>2013</code></p> <p>I have searched and found this <a href="http://stackoverflow.com/questions/5489502">How to get previous month and year relative to today, using strtotime and date?</a> It uses <code>date_create</code> function (i.e. DateTime Class). But I want a solution without using it. i.e. by using simple <code>date()</code> function</p>
php
[2]
3,433,029
3,433,030
Simple C++ code (what's wrong here?)
<p>Noob to C++.</p> <p>I'm trying to get user input (Last Name, First Name Middle Name), change part of it (Middle Name to Middle Initial) and then rearrange it (First Middle Initial Last).</p> <p>Where am I messing up in my code? </p> <p>--Thanks for ANY help you can offer!</p> <p>...</p> <pre><code>#include &lt;iostream&gt; using std::cout; using std::cin; #include &lt;string&gt; using std::string; int main() { string myString, last, first, middle; cout &lt;&lt; "Enter your name: Last, First Middle"; cin &gt;&gt; last &gt;&gt; first &gt;&gt; middle; char comma, space1, space2; comma = myString.find_first_of(','); space1 = myString.find_first_of(' '); space2 = myString.find_last_of(' '); last = myString.substr (0, comma); // user input last name first = myString.substr (space1+1, -1); // user input first name middle = myString.substr (space2+1, -1); // user input middle name middle.insert (0, space2+1); // inserts middle initial in front of middle name middle.erase (1, -1); // deletes full middle name, leaving only middle initial myString = first + ' ' + middle + ' ' + last; // return 0; } </code></pre>
c++
[6]
3,552,616
3,552,617
How can I lookup for the MX records corresponding to a particular domain name in iPhone application?
<p>E.g. I have a address say: mycompany.com &amp; there are MX records for this address as: server1.mycompany.com server2.mycompany.com server2.mycompany.com</p> <p>Now,there's a web serivce which is hosted on all 3 of above servers for redundancy or fallback. So,before calling the web service from my iPhone app,I want to do lookup for mycompany.com for MX records &amp; invoke the web service on one of the 3 servers returned by MX records. Which API/Class or framework of iPhone I need to use? Is it possible with CFHost?</p>
iphone
[8]
541,625
541,626
How to sort list of date object?
<p>How to sort list of date object ? For example I have unsorted list of date objects. How to get max/min value from this list ?</p>
python
[7]
2,314,894
2,314,895
Console.ReadKey(false) in C# something fishy about it
<p>i am trying to make a simple application in C# in which every character I type is displayed in a console window. Here is my code : </p> <pre><code>class Program { static void Main(string[] args) { while (true) { System.ConsoleKeyInfo input; input = Console.ReadKey(false); String d = input.ToString(); char c = d[0]; Console.WriteLine(c); } } } </code></pre> <p>The problem is that the characters are not displayed correctly, and to be more precise, every character is followed by an 'S'. For example i type 'a' and i get 'aS' instead of 'a'. Any solutions? Thnx in advance!</p>
c#
[0]
1,269,926
1,269,927
How to add 2 or more views to one scrollView that relate with Page controll?
<p>I'm new to iphone development. I used <code>UIPageControl</code> and <code>UIScrollView</code> where I wanted to add 2 or more views into a single <code>UIScrollView</code>. I have 2 pages of Page controls. Please give me an example or link for implementing this.</p> <p>Thanks in advance. </p>
iphone
[8]
2,404,341
2,404,342
Notification when app not used for more than certain period
<p>Is there a way to send a notification to the user that app has been downloaded but a certain task from the app is not yet complete even after certain period - say a month. One way is a background service which should come alive every month in this case, check the app state (in sharedprefs) and then send a notification. Is there some other easier way in Android without writing custom service. </p>
android
[4]
3,084,147
3,084,148
What are the Default Access Modifiers in C#?
<p>What is the default access modifier for classes, methods, members, constructors, delegates and interfaces?</p>
c#
[0]
2,475,603
2,475,604
jquery sortable connected lists and selectable together?
<p>I have 2 lists and I am using the sortable feature - works great. But I also need to be able to select multiple items and drag those to the connected list as well. I have 100's of items in a given list and dragging 1 at a time is a bit painful.</p> <p>Has anyone achieved this?</p>
jquery
[5]
2,363,462
2,363,463
Is it Possible to create an entire application using just dynamic parts of C#?
<p>I am feeling rather impish about this, so please don't think I would seriously try this as I know from bitter experience the strengths of a static type checking system.</p> <p>But, as for a concept, would it be possible to basically do C# in a completely dynamic way, throwing the static type checker to one side and saying "pah, you're so old fashioned!".</p> <p>I have recently had great experience of IronPython and F#, but I feel truly at home in a C based language.</p> <p>How far can one take C# on the road to dynamics? I recently wrote an XML to ExpandoObject parser and that was great, it felt like javascript prototyping. </p> <p>How optimised is the dynamic stuff, is it as quick as some of the real Dynamic programming language environments out there such as NodeJs and CPython?</p>
c#
[0]
579,142
579,143
What is cause of java.lang.ExceptionInInitializer error?
<p>What causes this type of exception?</p> <pre><code>&gt; java.lang.ExceptionInInitializerError  at &gt; java.lang.Class.newInstanceImpl(Native Method)  at &gt; java.lang.Class.newInstance(Class.java:1409)  at &gt; android.app.Instrumentation.newApplication(Instrumentation.java:957) &gt;  at &gt; android.app.Instrumentation.newApplication(Instrumentation.java:942) &gt;  at android.app.LoadedApk.makeApplication(LoadedApk.java:471)  at &gt; android.app.ActivityThread.handleBindApplication(ActivityThread.java:3264) &gt;  at android.app.ActivityThread.access$2200(ActivityThread.java:117) &gt;  at &gt; android.app.ActivityThread$H.handleMessage(ActivityThread.java:973) &gt;  at android.os.Handler.dispatchMessage(Handler.java:99)  at &gt; android.os.Looper.loop(Looper.java:130)  at &gt; android.app.ActivityThread.main(ActivityThread.java:3687)  at &gt; java.lang.reflect.Method.invokeNative(Native Method)  at &gt; java.lang.reflect.Method.invoke(Method.java:507)  at &gt; com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) &gt;  at com.android.internal.os.Zygo… </code></pre>
android
[4]
5,391,697
5,391,698
Combing Two jQuery Objects To Make One Custom Context for Efficient Selectors
<p>I have some common elements that are in a #footer and #header divs respectively. In order to make the selectors faster, I'd like to make a custom jquery object.</p> <p>A combination of #footer and #header. Something like:</p> <pre><code>var someCustomContext = $("#footer") + $("#header"); var betterQuickerSelector = $(".buttonClass", someCustomContext); </code></pre> <p>Is this possible?</p> <p>Thanks SO!</p>
jquery
[5]
3,904,890
3,904,891
C# polling to monitor folder
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/13918550/c-sharp-to-loop-through-folder-until-it-finds-the-correct-files">C# to loop through folder until it finds the correct files</a> </p> </blockquote> <p>Is it possible to use c# polling to monitor a folder for "required" files? I am running a batch file which requires certain files to be in the folder. If the files are not there and batch job cancels automatically. I am just wondering if I can use ploling to monitor the folder and once they are available I would like the batch file to continue. Thanks</p>
c#
[0]
4,587,071
4,587,072
What happens during a file upload?
<p>I upload a file to my server (Server A) using a PHP script. With this same PHP script I again upload using CURL from my site to another server (Server B) using what was just uploaded like this:</p> <pre><code>$file = $_FILES['file']['tmp_name']; </code></pre> <p>My question is this: Does this script wait for the file to be completely uploaded to Server A before continuing to upload to Server B?</p> <p>If not, how do I get the script to wait for everything to upload to me then continue to upload to Server B without the script ending its execution?</p>
php
[2]
2,127,815
2,127,816
How to change single char from string in JavaScript
<p>I have a variable which contains the following string</p> <pre><code>placeholder = "&lt;strong&gt;Total Damage:&lt;/strong&gt; $70,000.00" </code></pre> <p>Now, I am trying to replace Dollor sign($) with pound sign(£). Any idea how this can be done?</p> <p><strong>[Edit]</strong></p> <p>I don't know javascript, still trying to learn. now the solution seems so simple, I feel embarrassed now. Sorry for bothering everyone with such silly question :(</p>
javascript
[3]
4,556,195
4,556,196
Problems with background on UITableViewCell iPhone
<p>I the following code in my class. When I launch my app on the simulator it works. However when launcing the app on an actual device(iPhone 1g, 3.1.3) it does not work. Any ideas?</p> <p>(it's for making gradient background)</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MainScreenCellID = @"MainScreenCellID"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MainScreenCellID]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MainScreenCellID] autorelease]; } cell.textLabel.text = [[[self.controllers objectAtIndex:[indexPath row]] navigationItem] title]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; UIImageView *bgimage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell_bg.png"]]; cell.backgroundView = bgimage; [bgimage release]; for (UIView *view in cell.contentView.subviews) { view.backgroundColor = [UIColor clearColor]; } return cell; } </code></pre> <p><img src="http://i.stack.imgur.com/wOESd.png" alt="temp"></p> <p>(Black fields is added because the app is not done yet.)</p> <p>EDIT:</p> <p>I can add that on the UITableViewCell which this method work on I have made my own subclasses, but where I am using the UITableViewDefaultStyle it does not work.</p>
iphone
[8]
2,450,927
2,450,928
reject if file name contains non english character
<p>am trying to upload file which file name contains only in english character with symbol or number ,my problem is if my file name contains <strong>english with chinese character</strong> then i need to validate it and need to show alert message that file name should'nt be in non english character</p> <p>can anybody send me this code</p>
javascript
[3]
4,917,893
4,917,894
Dashboard implementation for android app
<p>I need to create a dashboard for my android app. Is there any open-source dashboard implementation for android apps which I can use. If not then is there a or a tutorial about creating it.</p> <p>Note: I have only been able to find obsolete tutorials on the internet. </p>
android
[4]
1,332,129
1,332,130
Project conversion from ISO 8859-1 to UTF-8
<p>I coded a php project under ISO 8859-1, and for some technical reasons I want to encode the project under UTF-8. what is a better way to do it? I am afraid of loosing special characters like french accents and so on. thanks for you advice. </p>
php
[2]
5,479,870
5,479,871
how to extract web text in android like rss to display it on android GUI?
<p>how to extract some criteria from this page <a href="http://www.zigwheels.com/api/zigtvApi.php?method=data&amp;module=News&amp;section=News" rel="nofollow">http://www.zigwheels.com/api/zigtvApi.php?method=data&amp;module=News&amp;section=News</a></p> <p>and filter this ( content_id , thumbnail, summary , headline , image) to display them as rss feeds in my android GUI</p>
android
[4]
2,500,108
2,500,109
javascript where to put the var statement
<p>I have a function that looks like this:</p> <pre><code>function SomeFunction() { var SomeVar; if (SomeCondition) { SomeVar = 4; } } </code></pre> <p>This is equivalent to:</p> <pre><code>function SomeFunction() { if (SomeCondition) { var SomeVar = 4; } } </code></pre> <p>Does using the var statement only if the condition is true make a difference or not, is there any best practice or <strong>performance implications</strong> concerning this?</p> <p>Thanks.</p> <p><strong>Edit: yes, I am aware that there's no block scope, just function scope.</strong></p>
javascript
[3]
5,658,060
5,658,061
What's wrong with this code?
<p>When I write <code>cout&lt;&lt; Read("filepath")</code>I get strange set of identical characters. Code is below:</p> <pre><code>char* Read(std::string FilePath) { char* Buffer; ifstream F_S(FilePath); while (! F_S.eof()) { F_S.getline(Buffer,100); return Buffer; } } </code></pre>
c++
[6]
480,845
480,846
process argument with spaces
<p>hi i need to have argument that contain spaces.</p> <p>in this case <code>/SASE Lab Tools</code> is the subject. Under normal command line:</p> <p><code>sslist -R -H -h sinsscm01.ds.net "/SASE Lab Tools"</code></p> <p>how do i make that happen? Here is my code:</p> <pre><code>static void Main(string[] args) { System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "sslist.exe"; p.StartInfo.Arguments = "-R -H -h sinsscm01.ds.net /SASE Lab Tools"; } </code></pre>
c#
[0]
5,352,399
5,352,400
running background thread in android throughout the application
<p>hi i am new to android. can anybody help me to solve this. i want to run a background thread which will request to the server response in some time gaps. this threads have to be run in background through out the application. if any one know how do this in android please let me know.i hope you understood my problem .thanks in advance</p>
android
[4]
4,286,885
4,286,886
C# -Priority based delegates and chaining in delegates possible? or Windows Work Flow?
<p>Whenever i feel hungry i will publish i am hungry.This will be notified to the service providers say (<b>MealsService,FruitService,JuiceService </b>).(These service providers know what to serve).</p> <p>But the serving priority is the concern. Priority here means my first choice is <b> MealsService </b> when there are enough meal is available my need is end with MealsService.To verify the enough meal is availabe the <b> MealsService </b> raises the event "updateMeTheStockStatus" to the <b> "MealsServiceStockUpdateListener" </b> .</p> <p>The <b> "MealsServiceStockUpdateListener" </b> will only reply back to <b> "MealsService" </b>. No other Service providers (<b> FruitService,JuiceService </b> ) will be notified by the <b> "MealsServiceStockUpdateListener" </b>.If there is no sufficient stock then only the <b>MealsService</b> passes notification to the <b> JuiceService </b> (as it is the second priority).As usual it checks the stock.If stock is not sufficient it passes message to <b>FruitService</b>,so the flow continues like this.</p> <p><hr/></p> <ol> <li> How can i technically implement this? </li> <li> Any implemention like priority based delagates and delegate chaining make sense ? </li> </ol> <p>(Somebody! Please reframe it for good readability ).</p> <p>Update : In this model there is no direct communication between "StackUpdateListener" and "me".Only The "Service Providers" will communicate me.</p>
c#
[0]
1,208,475
1,208,476
Will ajax work in dot.net framework 2.0?
<p>I have vs2005.Now I installed 2008 also in my machine(both are there).Previouly when I was opening my vs 2005 solution file,there was no ajax control. Now it shows me ajax control in it.(but solution file show vs2005).Will it cause any error in future?</p>
asp.net
[9]
5,722,005
5,722,006
Global keylogger in Java
<p>I'm writing an application that monitors the person’s mouse and keyboard. If they have not used the keyboard or mouse for 1 minute, it will pop up a message that says “You have not used the mouse or keyboard for 1 minute” along with an OK button.</p> <p>How do I do this in Java?</p>
java
[1]
777,363
777,364
How do I hide a adjacent div when I mouseout of a menu item, using JQuery?
<p>I was wondering how I could reverse the click triggered in this function on 'mouseout' of 'a.menu-arrow'? See code below:</p> <pre><code>$(".menu-arrow").hover(function() { $.data(this, "timer", setTimeout($.proxy(function() { $(this).click(); }, this), 500)); }, function() { clearTimeout($.data(this, "timer")); }); </code></pre> <p>What happens is after 0.5 of a second of hovering over a.menu-arrow...a click is triggered showing a adjacent div containing the submenu. This is how the HTML is structured unfortunately.</p> <p>Any help would be greatly aprreciated. </p> <p>Sorry I'm a novice at JavaScript &amp; JQuery</p>
jquery
[5]
4,014,445
4,014,446
How to check whether an enum variable is assigned with a single enum value?
<p>I would like to restrict the user to use any of the enumvalue.if the user tries to assign more than two values,i have to throw an error.</p> <pre><code>public enum Fruits { Apple, Orange, Grapes } Publiv Fruits Fruits { get { return m_fruits; } set { m_fruits=value; } Fruits=Fruits.Apple&amp;Fruits.Grapes;//I need to avoid such type of assignment </code></pre> <p>Can anyone say how to check this type of validation.</p> <p>Thanks, Lokesh</p>
c#
[0]
3,580,126
3,580,127
How do I get the value after decimal?
<p>Example -> 4.11 I need to get 11 which is the value after decimal</p> <p>How do i get that in C#?</p>
c#
[0]
1,868,428
1,868,429
std streams to write to void* and back
<p>How can I get fstream to write to a void pointer?</p> <p>Basically I've used MapFileView and got a void pointer from it for shared memory.</p> <p>I've use copymemory to copy a bunch of data back and forth between two separate applications.</p> <p>Now instead, I want to use the std library to read in a struct via &lt;&lt; overload and write it to my mapped memory (Local\MyMemMap, invalid_handle), then read it back via >> overload. It's not a physical file that you can see.</p> <p>Basically I want to redirect ifstream and ofstream to my void* if possible. Otherwise, what other std streams would allow me to use my pointer and the operator overloads?</p> <p>I only know of istream, osstream.</p>
c++
[6]
5,381,447
5,381,448
Content Assist not working as expected on Eclipse
<p>These are the specs:</p> <ul> <li>OS: Windows 7 Professional x86</li> <li>IDE: Eclipse Juno 4.2 (for Java Developers)</li> <li>ADT: Version 20</li> <li>SDK: 7</li> </ul> <p>I'm creating an XML layout, and after dragging a ImageView to a FrameLayout, it all works as expected.</p> <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:android1="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;ImageView android1:id="@+id/imageView1" android1:layout_width="wrap_content" android1:layout_height="wrap_content" android1:src="@drawable/logo_splashcreen" /&gt; &lt;/FrameLayout&gt; </code></pre> <p>What I noticed, is that it is using <code>android1</code> instead of <code>android</code>.</p> <p>If I try to add a new parameter to the ImageView, via the <code>Ctrl+Space</code> it throws me the <img src="http://i.imgur.com/uQHA3.png" alt=""> error.</p> <p>Is it normal? Never happened to me before...</p>
android
[4]
2,240,099
2,240,100
jquery: inner: outerHeight
<p>That I got no idea how. I need a function that the window height or the monitor configuration is larger than 1200, put a div position top = 1000px and else put in another position top = 800px</p>
jquery
[5]
16,134
16,135
C#:SerialPort: read and write buffer size
<p>I am writing a program to send and receive data via a serial port with C#.</p> <p>Although I have read this reference: <a href="http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.readbuffersize.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.readbuffersize.aspx</a>, I am not quite clear if I change the values of the buffer for reading and writing:</p> <pre><code>serialPort.ReadBufferSize = 1; // or 1024 ? serialPort.WriteBufferSize = 1;// or 1024 ? </code></pre> <p>The values (1 or 1024) should be better to be smaller or bigger?</p> <p>Thanks in advance.</p>
c#
[0]
204,007
204,008
How can I 'shine' a png on the iPhone in the same way that the app launcher does?
<p>I want to show users what their square flat .png image will look like when converted to a normal 'shined' icon by the app launcher.</p> <p>e.g. round corners and glassy effect.</p> <p>Thanks</p>
iphone
[8]
262,465
262,466
jQuery Basic Plugin - Loading from another page
<p>I am very inexperienced with jQuery plugins, and only mildly experienced in jQuery itself.</p> <p>I am trying to create a jQuery plugin that allows me to fill a <code>div</code> with content from another page with GET variables in the URL depending on the parameters that are passed to it.</p> <p>Eg <code>$('#mydiv').getstuff(1,2,3)</code> would load it with code from <code>engine.php?a=1&amp;b=2&amp;c=3</code>.</p> <p>Here is my code so far - I know there are problems with the way it takes in parameters but other than that I can't figure out why it's not working.</p> <pre><code>&lt;script type="text/javasctipt" src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; (function($){ $.fn.extend({ //pass the options variable to the function bookmark: function(options) { var defaults = { number: 5, order: 1, user: '', }; var options = $.extend(defaults, options); return this.each(function() { var o = options; var obj = $(this); var container = $("div", obj); $("div", obj).load("thing.php?number="+o.number+"&amp;order="+o.order+"&amp;user="+o.user); }); } }); })(jQuery); $(document).ready(function() { $('#thing').bookmark(1,2,3); }); &lt;/script&gt; &lt;div id="thing"&gt;&lt;/div&gt; </code></pre>
jquery
[5]
4,653,077
4,653,078
Suggestion for API design about stream
<p>Need to design an API method whihc take OutputStream as a parameter. </p> <p>Is it a good practice to close the stream inside the API method or let the caller close it?</p> <pre><code>test(OutputStream os) { os.close() //??? } </code></pre>
java
[1]
2,874,335
2,874,336
Converting double[][] in to float[][]
<p>I was wondering if there is a way of converting a double [][] in to a float[][] in Java? I currently have a for loop in my code that does this and am looking for a better and cleaner way.</p> <p>Any ideas would be appreciated, Thanks,</p>
java
[1]
2,612,698
2,612,699
how can i send sms programmatically in iphone
<p>I need to send sms programmatically.</p> <p>I found sending programmatically email in google,But did n't found clear info regarding sending sms programmatically.</p> <p>Can any one pls post some sample code.</p> <p>Thank u in advance.</p>
iphone
[8]
1,323,014
1,323,015
How to put '<' and '>' inside a linkbutton's text property (asp.net)?
<p>How to put '&lt;' and '>' inside a linkbutton's text property (asp.net)? I tried <code>&lt;asp:LinkButton runat="server" ID="lbEdit" Text="&amp;lt;edit settings&amp;gt;"&gt;&lt;/asp:LinkButton&gt;</code> but then the link doesn't show up.</p>
asp.net
[9]
1,986,647
1,986,648
c# FindSumSubset(decimal, ArrayList<decimal>)' has some invalid arguments
<pre><code>ArrayList&lt;decimal&gt; FindSumSubset(decimal sum, ArrayList&lt;decimal&gt; list) { for (int i = 0; i &lt; list.Length; i++) { decimal value = list[i]; if (sum - value == 0.0m) { return new ArrayList().Add(value); } else { var subset = FindSumSubset(sum - value, list.GetRange(i + 1, list.Length -i); if (subset != null) { return subset.Add(value); } } } return null; } </code></pre> <p>i am trying to call the above function like this:</p> <pre><code>ArrayList numbers = new ArrayList(); numbers.Add(210); numbers.Add(188.83); numbers.Add(67.93); numbers.Add(125.92); numbers.Add(35.92); numbers.Add(19.16); ArrayList listresult = new ArrayList(); listresult = FindSumSubset(9075.12m, numbers); </code></pre> <p>i am getting two errors:</p> <pre><code>Error 2 The best overloaded method match for 'WindowsFormsApplication2.Form1.FindSumSubset(decimal, ArrayList&lt;decimal&gt;)' has some invalid arguments </code></pre> <p>and</p> <pre><code>Error 2 Argument '2': cannot convert from 'System.Collections.ArrayList' to 'ArrayList&lt;decimal&gt;' </code></pre> <p>can someone tell me what i am diong wrong?</p>
c#
[0]
3,400,616
3,400,617
Jquery and CSS style
<p>If I want to add an CSS style for a field in a table that has the value that is equal to the current time or greater than the current time but it is less than the value of the next field, how can I do this using Jquery?</p> <p>The sample of table looks like this:</p> <pre><code> ----------------------- field | current time ----------------------- 1 | 05:25 2 | 07:30 3 | 09:18 4 | 10:13 5 | 12:44 </code></pre> <p>If the current time is 09:50 the field No.4 should have a different background color (If the current time is 05:30 then the field No. 2 , ...)</p> <p>Thanks for all suggestions.</p>
jquery
[5]
3,902,767
3,902,768
Permutation Id..? C++
<p>I am using permutation to generate a string (using each of its character) into "helloworld!", however it took...176791 to get to "helloworld!" Is there a ways so I can just input: 176791 to quickly permutate to "helloworld!"?</p> <pre><code> ... 176790. helloworl!d 176791. helloworld! </code></pre> <p>My code:</p> <pre><code>#include &lt;windows.h&gt; #include &lt;string&gt; #include &lt;iostream&gt; #include &lt;algorithm&gt; int main( void ) { ::UINT64 Count = 0; std::string SomeString = "eohldo!lwrl"; do { Count ++; std::cout &lt;&lt; Count &lt;&lt; ". " &lt;&lt; SomeString &lt;&lt; std::endl; if( SomeString == "helloworld!" ) break; } while( std::next_permutation( SomeString.begin( ), SomeString.end( ) ) ); ::getchar( ); return( 0 ); }; </code></pre>
c++
[6]
2,470,194
2,470,195
checking of constructor parameter
<pre><code>class item { int i; public: item(int no) { } }; </code></pre> <p>I want to check the constructor parameter. If it is found to hold a negative value, then object creation should be stopped.</p> <p>Exceptions can not be used here as the targeted system does not support exceptions.</p>
c++
[6]
3,038,855
3,038,856
Looking for a simpler way to check if multiple properties & methods in an object are undefined
<p>Consider the following code:</p> <pre><code> if(eform[funcName] !== undefined){ if(eform[funcName].init !== undefined){ //finally do something } } </code></pre> <p>I'm first checking to see if the <code>eform</code> object has the property specified by the variable <code>funcName</code>. If it does, then I need to check whether that property has an <code>init</code> method.</p> <p>Is there any way to combine these into a single <code>if</code> statement? Or perhaps something even more elegant than that?</p>
javascript
[3]
377,154
377,155
TypeError: 'float' object has no attribute '__getitem__'
<p>This code is a beginning attempt at reading a csv file into a couple of lists. I'm getting the error below, and I can't see why the float isn't being returned. Thanks for your help!</p> <pre><code> File "main.py", line 32, in &lt;module&gt; LR.openfile('djia_temp.csv') File "main.py", line 9, in openfile self.xs = self.tempDiff(dataAvgandtemp) File "main.py", line 18, in tempDiff tdArray.append([vector[0]-vector[1]]) TypeError: 'float' object has no attribute '__getitem__' </code></pre> <p>Code:</p> <pre><code>from processFile import processFile import numpy as np class processFile: @staticmethod def wholeFile(f): fileArray = [] for line in f: fileArray.append(line.strip()) return fileArray @staticmethod def liner(rows, columns, delimiter): vectors = [] for row in rows: vector = [] tok = row.split(delimiter) for num in columns: vectors.append(float(tok[num])) return vectors class linRegmain: def openfile(self, file): f = open(file) a = processFile.wholeFile(f)[1:] dataAvgandtemp = processFile.liner(a, [2,3], ";") self.xs = self.tempDiff(dataAvgandtemp) self.ys = processFile.liner(a,[1], ";") print self.xs print self.ys def tempDiff(self, vectors): tdArray = [] for vector in vectors: tdArray.append([vector[0]-vector[1]]) return tdArray if __name__ == '__main__': LR = linRegmain() LR.openfile('djia_temp.csv') </code></pre>
python
[7]
857,721
857,722
Create a flattened representation of an class based on its MRO
<p>How would I create a flattened representation of a class that is composed of multiple base classes/mixins. Is there a library for doing such a thing? For example:</p> <pre class="lang-py prettyprint-override"><code>class Foo(object): def a(self): return class Bar(object): def b(self): return class Baz(Foo, Bar): pass </code></pre> <p>I want to be able to create a text representation of the flattened class that would look like this:</p> <pre class="lang-py prettyprint-override"><code>class Baz(object): def a(self): return def b(self): return </code></pre> <p>The idea would be to create a text editor plugin (ST2 in my case) to allow the user to right-click on a class name and select an option to have a tab open with the flattened class displayed for reference.</p> <p>Of course the tool would need to be smart enough to treat super calls as basically includes.</p>
python
[7]
2,537,044
2,537,045
How to limit the number of entries in a java List?
<p>I know how to limit size in Map (<a href="http://stackoverflow.com/questions/422181/how-do-i-limit-the-number-of-entries-in-a-java-hashtable">like this</a>,using LinkedHashMap.removeEldestEntry method does exactly that)</p> <p>I want to know how to limit size in a List,what is a best way to implement?</p> <p>thanks for help :)</p>
java
[1]
2,823,707
2,823,708
javascript: lightweight lightbox script
<p>i'm looking for a lightweight javascript for displaying images the way lightbox does. it should be small + simple, no jquery/mootools plugin, no animations.</p> <p>i just should be able to display an image when clicking on its thumbnail.</p> <p>thanks</p>
javascript
[3]
2,633,941
2,633,942
Onselectedindexchanged is firing
<p>In grid row command event I am calling a <code>.ascx</code> page as a popup.</p> <p>In the popup I have one button, on clicking the button, I'm calling one more popup.</p> <p>Under the second popup I have four dropdown controls, in the dropdown controls I'm filtering and filling the data one after another.</p> <p>The problem here is, if I filter the third dropdown, the second dropdown field data is getting reset(Onselectedindexchanged is firing).</p>
asp.net
[9]
5,381,452
5,381,453
How to catch touch event of an dialog when it is clicked outside
<p>Actually i have <code>Dialog</code> in my activity, what i want is suppose the dialog is open, then on Touch of outside dialog i want to dismiss the dialog and at the same time i want to call a function which do some update in my activity.</p> <p>Initially i used <code>MyDialog.setCanceledOnTouchOutside(true);</code> But these will only dismiss and in my case, at the same time i want to call some functions whenever user click outside of dialog. So what should i do, I know that if i can extend the <code>Dialog</code> class and override its <code>onTouchEvent</code> method then it will be solved but in my case my class already extends Activity class and in java we can't extend more then one class..</p> <p>So what will be the best solution for that. Please help me to solve this out</p>
android
[4]
112,621
112,622
What is ecmascript?
<p>In Visual Studio when I am setting my script type to JavaScript this comes up as an option in intellisense.</p> <p>A quick Google search came up with lame results, leading me to believe this isn't terribly popular to use.</p> <ul> <li>What is it? </li> <li>Does anyone use it? <code>(&lt;script type="text/ecmascript"&gt;)</code></li> <li>Why?</li> </ul>
javascript
[3]
3,981,922
3,981,923
Sharing Android code (Is there really no way to do this?)
<p>I have a particular collection of code along with some XML files that I need to share with every application I will make. </p> <p>At the moment I can't because as far as I am aware there is no way to do this. This seems like a massive oversight by the development team.</p> <p>If the code needs changing, I have to change it in every app that I create - and will create in the future.</p> <p>Are there any ways to share code in android yet?</p> <p>I am using Eclipse for development.</p>
android
[4]
2,447,098
2,447,099
Mapping Settings pages to Keys
<pre><code>startActivity(new Intent(Settings.ACTION_SETTINGS)); </code></pre> <p>Above code is used to call a setting through Intent</p> <p>i need to map that intent in Combination of key..</p> <p>for example </p> <p>i need to call settings intent by pressing a+s+d</p>
android
[4]
2,222,435
2,222,436
Android Location Listener (or Android Events in general)
<p>I have a general question about LocationListener in Android. Perhaps this is about Android or Java events in general, but not sure. </p> <p>There seems to be a million ways to set up a LocationListener, and they all seem pretty ugly (mainly because of lack of reusability). Here is an example from android found <a href="http://developer.android.com/guide/topics/location/obtaining-user-location.html" rel="nofollow">here</a>:</p> <pre><code>// Acquire a reference to the system Location Manager LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); // Define a listener that responds to location updates LocationListener locationListener = new LocationListener() { public void onLocationChanged(Location location) { // Called when a new location is found by the network location provider. makeUseOfNewLocation(location); } public void onStatusChanged(String provider, int status, Bundle extras) {} public void onProviderEnabled(String provider) {} public void onProviderDisabled(String provider) {} }; // Register the listener with the Location Manager to receive location updates locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener); </code></pre> <p>This works, but, I'm really surprised that this is a standard way of writing OOP code...</p> <p>What I would really like to see is a simple a <em>reusable</em> way to implement LocationListener. Anybody know of a simple tutorial on how this could be done? My goal would be to be able to implement this easily any Activities that need to be updated with gps information... perhaps a Service? Thanks!</p>
android
[4]
3,352,166
3,352,167
change value when python is in infinite loop
<p>Can this be done in python? Start by print an infinite loop and changing values in between loops.</p> <pre><code>x = 5 while ( true ): print x x = 3 # regain control of the interpreter and set to new value </code></pre> <p>expected output:</p> <pre><code>5 5 5 ...... 3 3 3 </code></pre>
python
[7]
2,926,194
2,926,195
Can not increment global variable from function in python
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them">Using global variables in a function other than the one that created them</a> </p> </blockquote> <p>Hello Guys! I have the following script:</p> <pre><code>COUNT = 0 def increment(): COUNT = COUNT+1 increment() print COUNT </code></pre> <p>I just want to increment global variable COUNT, but this gives me the following error:</p> <pre><code>Traceback (most recent call last): File "test.py", line 6, in &lt;module&gt; increment() File "test.py", line 4, in increment COUNT = COUNT+1 UnboundLocalError: local variable 'COUNT' referenced before assignment </code></pre> <p>Can anyone explain me why it is so?</p>
python
[7]
369,104
369,105
SHMultiFileProperties with c++
<p>Seen an example of using SHMultiFileProperties on the site with c# but I'm really having trouble using it with unmanaged c++. I am a beginner so i would appreciate any help or maybe a small example.</p>
c++
[6]
3,544,584
3,544,585
jQuery watch div
<p>Is there any way to watch, if the content within a div changes?</p> <p>Let's say I have:</p> <pre><code>&lt;div id="hello"&gt;&lt;p&gt;Some content here&lt;/p&gt;&lt;/div&gt; </code></pre> <p>Which at some point 5 seconds later changes to:</p> <pre><code>&lt;div id="hello"&gt;&lt;ul&gt;&lt;li&gt;This is totally different!&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt; </code></pre> <p>How can I be notified of this via a callback or something else? I can in most cases get the javascript that's doing the inserting, to tell me. But I wanted to know if it was possible. </p>
jquery
[5]
3,772,714
3,772,715
How detect and handle if object is used as l-value or as r-value?
<p>I have a container class called <code>Properties</code>. I want to add to it <code>operator[](const std::string &amp; name)</code> which will return property with specified name.</p> <p>Now lets consider that there is no property with specified name. In this case I wan't to add new <code>Property</code> with specified name to my <code>Properties</code> if it is used as l-value and throw exception otherwise.</p> <pre><code>Properties pts; pts.add("name1", val1); pts.add("name2", val2); pts["name1"] = val3; //OK pts["name3"] = val1; //OK creating new Property with value = val1 cout &lt;&lt; pts["name4"]; //Ooops can't find Property with name = "name4", so throwing an exception </code></pre> <p>Is this possible in C++? How can I write such <code>operator[]</code>?</p>
c++
[6]
2,564,011
2,564,012
Button disappears when ListView size is increased
<p>I am trying to create an activity with a ListView on top and a Button underneath it. But when the size of the ListView is increased the Button disappears and moves down. Any suggestions? I am using TableLayout with each row containing ListView and Button. -Thanks</p>
android
[4]
2,047,431
2,047,432
DateTime How To
<p>When creating a class what is the syntax to define a public property for that class as a DateTime type rather than string?</p>
c#
[0]
402,484
402,485
Using POST for all functions in REST protocol
<p>Is it wrong to use POST for everything in REST? I know POST is for updating and creating but what if I use it for SELECTS and DELETS as well? What I basically need is a web service that can do CRUD operations to a database. Im using PHP. Also, what if I use query strings to do the POST request instead of using JSON or XML?</p>
php
[2]
1,073,966
1,073,967
How to take a screenshot from the camera view?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8996611/ios-capture-screenshot-of-camera-controller">iOS Capture &ldquo;screenshot&rdquo; of camera controller</a> </p> </blockquote> <p>I'm trying to take a screenshot when the camera of the iphone is running, I want to do this because my goal is to take a lot of screenshot and send them to a server with POST methods to simulate a streaming.<br> I tried a lot of methods but every time I get a blank image.</p> <p>I'm french so I'm sorry if my english is bad, and thank you in advance for the help.</p>
iphone
[8]
1,089,930
1,089,931
PHP - Checking for return false;
<p>Just a quick question - and I'm sure really basic!</p> <p>I have the following code:</p> <pre><code>function checkThings($foo, $bar) { ... if ($valid) { return $results; } else { return false; } } </code></pre> <p>On the other end of this I am currently doing</p> <pre><code>$check = checkThings($foo, $bar); if ($check === false) { echo "Error"; } else { echo $check; } </code></pre> <p>Is writing the following the same?</p> <pre><code>$check = checkThings($foo, $bar); if (!$check) { echo "Error"; } else { echo $check; } </code></pre> <p>Which method is the preferred method if both are correct?</p> <p>Thanks :)</p>
php
[2]
3,175,027
3,175,028
Dynamic instance creation without generics
<p>I would like to understand why the following doesn't work:</p> <pre><code>public class HelloClass { private class MyClass { public MyClass() { System.out.println ("Oh heck this is me!"); } } public Object newInstance (Object o) { try { // java.lang.InstantiationException here return o.getClass().newInstance(); } catch (Exception e) { e.printStackTrace(System.out); return null; } } public void run() { MyClass m = new MyClass(); Object o = newInstance(m); } public static void main(String[] args) { HelloClass hd = new HelloClass(); hd.run(); } } </code></pre> <p>I know of the correct way to achieve this via declaring the newInstance argument as Class&lt;T&gt;, but would like to understand why it cannot be done like the above.</p> <p>UPD: Here is the exception I'm getting:</p> <pre><code>java.lang.InstantiationException: HelloClass$MyClass at java.lang.Class.newInstance0(Class.java:340) at java.lang.Class.newInstance(Class.java:308) at HelloClass.newInstance(HelloClass.java:14) at HelloClass.run(HelloClass.java:24) at HelloClass.main(HelloClass.java:30) </code></pre>
java
[1]
3,671,705
3,671,706
what is the 'decimal.getcontext().copy()' mean
<pre><code>import decimal # Decimals a=decimal.getcontext().copy() print a </code></pre> <p>thanks.</p> <p>what is the useful of a.</p>
python
[7]
1,586,386
1,586,387
What's the Meaning and use of window.lol&&lol() in the google homepage?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2894550/blank-space-on-google-home-page">blank space on google home page</a> </p> </blockquote> <p>What's the Meaning and use of window.lol&amp;&amp;lol() in the google homepage? AND Where is the source code of lol&amp;&amp;lol?</p> <pre><code>&lt;a href="/search?q=Pierre+de+Fermat&amp;amp;ct=pierre_de_fermat-2011-hp&amp;amp;oi=ddle&amp;amp;hl=en"&gt; &lt;img ... onload="window.lol&amp;&amp;lol()"/&gt; &lt;/a&gt; </code></pre>
javascript
[3]
5,032,827
5,032,828
Android Emulator's launch options don't work in Eclipse plugin?
<p>I need to change the emulator's default time zone. It worked in command line with -timezone option. But when I tried it in eclipse android's launch options. it didn't work. I set it in Window->preferences->android->launch->default emulator options. Am I setting it in a wrong place?</p>
android
[4]
4,305,486
4,305,487
java : Unparseable date Exception
<p>I have this value,</p> <blockquote> <p>2011-11-19T00:00:00.000-03:00</p> </blockquote> <p>which needs to be converted and set it in this format </p> <blockquote> <p>yyyyMMdd</p> </blockquote> <p>I tried this way </p> <pre><code>import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class ParsedDate { public static void main(String args[]) throws ParseException { DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US); String s1 = "2011-11-19T00:00:00.000-03:00"; Date d = sdf.parse(s1); String s2 = (new SimpleDateFormat("yyyyMMdd")).format(d); System.out.println(s2); } } </code></pre> <p>But it is giving me </p> <p><strong>Exception in thread "main" java.text.ParseException: Unparseable date: "2011-11-19T00:00:00.000-03:00"</strong></p> <p>Could anybody please help me? </p>
java
[1]
4,477,810
4,477,811
Android - how to reset a TextView
<p>I set an original TextView value like this:</p> <pre><code>TextView problemName = (TextView) findViewById(R.id.some_variable); </code></pre> <p>But at some point I need to reset it to something new. I don't see a function like setText() or anything like that. How is the displayed text supposed to be reset?</p> <p>Thanks!</p>
android
[4]
5,737,945
5,737,946
jquery to disable form elements
<p>Scenario is that I have written a function for auto refresh on form element and I want onclick event on login button to disable the auto refresh function. </p> <p>I'm not able to get disable the autorefresh and the page still refreshes. </p> <p>My code is:</p> <pre><code>$('#form').ready(function () { //Increment the idle time counter every minute. var idleInterval = setInterval("timerIncrement()", 15000); // 1 minute //Zero the idle timer on mouse movement. $(this).mousemove(function (e) { idleTime = 0; }); $(this).keypress(function (e){ idleTime = 0; }); }); function timerIncrement() { idleTime = idleTime + 1; if (idleTime &gt; 2) { // 20 minutes window.location.reload(); } } $('#login').ready(function () { alert("working promptly"); //Zero the idle timer on mouse movement. $(this).click(function (e) { alert("Hi In click !"); $('#form').attr("disabled","true"); }); }); </code></pre>
jquery
[5]
4,353,890
4,353,891
JQuery - Sliding
<p>I saw <a href="http://www.mindthree.com/" rel="nofollow">this website</a> in this when we click the next or previous buttons it slides different webpages. I want the same effect but I could not find the way to do it. Can you post the answer with HTML, CSS and JQuery or Javascript code.</p>
jquery
[5]