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,650,510
2,650,511
How to create Admin part for asp.net website?
<p>What are the steps to create a admin part for asp.net website. and how to add everything to website from admin panel.</p>
asp.net
[9]
4,058,853
4,058,854
Generic Delegate with the type provided on invoke or function add
<p>What I am going after is to be able to do something like this</p> <pre><code>public class Class1 { public delegate CollsionType ValidateDelegate&lt; T &gt;(PlayerState&lt;T&gt; state, Vector2 position, CollsionType boundary); public static ValidateDelegate ValidateMove; public void AnotherFunction&lt; T &gt;(PlayerState&lt; T &gt; state) { //option1 ValidateDelegate.Invoke&lt;T&gt;(state,SomeParameter,SomeParamter2) } } public class Class2&lt;TypeIWant&gt; { public void SomeFunction { //option2 Class1.ValidateMove = new ValidateDelegate&lt;TypeIWant&gt;(functionThatHasCorrectSigniture) } } </code></pre> <p>The trick here is I do not know the type T when the delegate is created in Class1. I only know T when a function is added to the delegate or when the delegate is invoked. </p>
c#
[0]
989,439
989,440
With checkbox selecting particular record
<p>I have an inflated list with text and checkbox.If checkbox 3 is checked when app relaunches the inflated list should start from the checked text. Can something like this be done?</p>
android
[4]
194,156
194,157
jquery animate function and mimic the visuallightbox like effect
<p>EXAMPLE: <a href="http://visuallightbox.com/lightbox-photo-software-sticky-notes-demo.html" rel="nofollow">http://visuallightbox.com/lightbox-photo-software-sticky-notes-demo.html</a> and click on any image to see how original image is showing.</p> <p>I want to create the same effect with code instead of using a library. The code that I'm using right now causes a similar effect, but it's not very smooth like visuallightbox.</p> <p>Here is the code:</p> <pre><code>&lt;ul&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;li&gt;thumb&lt;/li&gt; &lt;/ul&gt; &lt;div id="transition"&gt;&lt;div&gt;zoom effect&lt;div&gt;&lt;/div&gt; $('ul li').click(function(e){ var $t = $('#transition'), to = $(this).offset(), td = $(document); $t.children('div').css({width:100,height:100}); $t.css({ top: to.top + 50, left: to.left + 50, display: 'block' }).animate({ top: td.height()/2, left: td.width()/2 }, 600, function(){ $(this).animate({ top: '-=75', left: '-=50' }, 600); $(this).children('div').animate({ width:250, height:200 }, 600, function(){ // open dialog here }); }); }); $('#transition').click(function(e){ $(this).hide(); }); </code></pre> <p>How would I change this to get the desired effect?</p> <p>fiddle: <a href="http://jsfiddle.net/HDmff/" rel="nofollow">http://jsfiddle.net/HDmff/</a> </p>
jquery
[5]
2,319,055
2,319,056
jQuery error arise in a slider
<p>i have to do a slider of image and content in my site and i use a jQuery plugin for that slider , but there is a error raised .</p> <p>jQuery("#one").ContentSlider is not a function</p> <p>and my code for that</p> <pre><code> jQuery(function() { jQuery('#one').ContentSlider({ width : '900px', height : '400px', speed : 800, easing : 'easeInOutBack' }); }); jQuery(function() { jQuery('#two').ContentSlider({ width : '600px', height : '266px', speed : 400, easing : 'easeOutQuad', textResize : true }); }); </code></pre> <p>i don't know what is problem with the error.</p>
jquery
[5]
3,455,849
3,455,850
Basic PHP Script
<p>I'm trying to make a script to do the following:</p> <pre><code>http://mydomain.com/script.php?name=bob </code></pre> <p>That link would output to a blank page with text</p> <pre><code>Hi bob </code></pre> <p>Anyone know what the contents of script.php should be?</p>
php
[2]
2,851,865
2,851,866
Python dictionary to store socket objects
<p>Can we store socket objects in a Python dictionary. I want to create a socket, store socket object, do some stuff and then read from the socket(search from dictionary to get socketobject).</p>
python
[7]
1,354,387
1,354,388
would remove a key from Dictionary in foreach cause a problem? or should I better to construct a new Dictionary?
<p>for example:</p> <p>1.</p> <pre><code> foreach (var item in myDic) { if (item.value == 42) myDic.remove(item.key); } </code></pre> <p>would the iterator works properly no matter how the statements in the inner brackets could possibly affect <code>myDic</code>?</p> <p>2.</p> <pre><code> var newDic = myDic.where(x=&gt;x.value!=42).ToDictionary(x=&gt;x.key,x=&gt;x.value); </code></pre> <p>Is 2nd approach a good practice? functional programming and immutable?</p>
c#
[0]
4,851,201
4,851,202
Print empty line?
<p>I am following a beginners tutorial on Python, there is a small exercise where I have to add an extra function call and print a line between verses, this works fine if I print an empty line in between function calls but if I add an empty print line to the end of my <code>happyBirthday()</code> I get an indent error, without the added print line all works fine though, any suggestions as to why? Thanks in advance.</p> <p>Here is the code:</p> <pre><code>def happyBirthday(person): print("Happy Birthday to you!") print("Happy Birthday to you!") print("Happy Birthday, dear " + person + ".") print("Happy Birthday to you!") print("\n") #error line happyBirthday('Emily') happyBirthday('Andre') happyBirthday('Maria') </code></pre>
python
[7]
303,560
303,561
How to change the "Date" and "Time" of the mobile phone using "J2ME"?
<p> Im developing a mobile application using "J2me" for a configuration "CLDC-MIDP2.0". </p> <p> In my mobile application,im need to make the user should able to adjust the "Date" and "Time" settings of mobile. </p> <p> Here im using "DateField" to get the date from the user,but i cannot set or change the mobile phone's "Date" and "Time". </p> <p> So please help me.How to change the "Date" and "Time" of the mobile phone using "J2ME".Here im using "Nokia c2-00" mobile is for testing.It is "S40" device. </p> <p> Ideas of all are welcome. </p>
java
[1]
4,377,101
4,377,102
Push out advert effect with jquery
<p>I would like to make an advertisement to my site. Previously i seen a solution when user visit a site, the advert will push out the hole page from right to left. Is it possible to make it work with jquery?</p> <p>thanks</p>
jquery
[5]
5,122,230
5,122,231
Enter key triggering button click - but I don't want it to
<p>Have a real head-scratcher here: I have a page with several controls on it, and a ASP:Button or two. When I'm in a control, and hit the Enter key, it acts like I clicked the submit button, which I don't actually want to do at this point in time.</p> <p>The button is not in a ASP:Panel with a DefaultButton set, it has no OnClientClick attribute, I can see no JavaScript that watches for the Enter key... Why is it firing?</p> <p>If I create a standard .ASPX page and put a text box and a button on it, run it and hit the enter key, the button is ignored, e.g. the click event doesn't fire. This is the behaviour I expect, but am not getting.</p> <p>In short, what else could cause a button to think it's the default button for the page?</p> <p>Thank you,</p> <p>Mike K.</p>
asp.net
[9]
5,637,390
5,637,391
data filtering in gridview using jquery
<p>i have done the data filteration in gridview as like </p> <p><a href="http://tomcoote.co.uk/wp-content/CodeBank/Demos/columnFilters/demo.html" rel="nofollow">http://tomcoote.co.uk/wp-content/CodeBank/Demos/columnFilters/demo.html</a><br> on this page. But my requirement is some different from it. I Have a textbox outside the gridview i want to filter data according to this. please help me as soon as possible.</p> <p>Thanks In advance.</p>
jquery
[5]
3,391,328
3,391,329
how to copy a file between 2 computers on the network in python
<p>I am trying to move a log file from a computer, where an operation is performed, to another computer, that will get the log file and process it, returning a document with the result of the analysis.</p> <p>I am using Python for the job, but I am open to other options (I have to run this copy via console on OSX, due the fact that most of my work is done in shell scripting; so cannot use any visual solution; anything that can be launched via a script would work too); any suggestion is more than welcome since I do not really have a favorite way to do this (just trying the less problematic....I do not need any security encryption since both of the computers are on my internal network, no communication with the outside is performed).</p> <p>Hope that someone can point me to the right solution, thanks in advance.</p>
python
[7]
1,940,387
1,940,388
2How to get the current MavenSession or MavenExecutionRequest from a Plexus Component
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3736576/how-to-get-the-current-mavensession-or-mavenexecutionrequest-from-a-plexus-compo">How to get the current MavenSession or MavenExecutionRequest from a Plexus Component</a> </p> </blockquote> <p>created a Plexus component to house common logic for several Mojos I want to create. I have been able to pass information like localRepository and project from the Mojo (and test cases).</p> <p>I was wondering if there is a way to get the MavenSession or MavenExecutionRequest from within the component without having to pass them as parameters from a Mojo. I know my component will be running from a Maven Mojo.</p>
php
[2]
788,851
788,852
C# hide, background, processinfo
<p>I have this code:</p> <pre><code>ProcessStartInfo PSI = new ProcessStartInfo("cmd.exe"); PSI.CreateNoWindow = true; PSI.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; PSI.RedirectStandardInput = true; PSI.RedirectStandardOutput = true; PSI.RedirectStandardError = true; PSI.UseShellExecute = true; Process p = Process.Start(PSI); </code></pre> <p>problem is, when I build it, the command prompt still appears. How can I hide it?Thanks!</p>
c#
[0]
2,954,196
2,954,197
Approval of iPhone app with UIWebView subclass
<p>Apple does say in the documentation about the fact that they do not want us to subclass UIWebview. After reading a lot of posts, I think it is the internals of the Webview that makes it complicated and it may be the reason apple has said so.</p> <p>Iam looking to subclass this. Is there anyone who has faced this problem before?</p>
iphone
[8]
3,917,930
3,917,931
What does Class<something> mean in Java?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/6607550/what-does-angle-brackets-mean-in-java">What does &lt;&gt; (angle brackets) mean in Java?</a> </p> </blockquote> <p>i am reading about AsyncTask in Android and i have this example code:</p> <pre><code>private class DownloadFilesTask extends AsyncTask&lt;URL, Integer, Long&gt; { protected Long doInBackground(URL... urls) { int count = urls.length; long totalSize = 0; for (int i = 0; i &lt; count; i++) { totalSize += Downloader.downloadFile(urls[i]); publishProgress((int) ((i / (float) count) * 100)); } return totalSize; } protected void onProgressUpdate(Integer... progress) { setProgressPercent(progress[0]); } protected void onPostExecute(Long result) { showDialog("Downloaded " + result + " bytes"); } } </code></pre> <p>And it is supposed to be called whit:</p> <pre><code> new DownloadFilesTask().execute(url1, url2, url3); </code></pre> <p>I cant understand what means, i have seen them in some other classes like String&lt;> but i dont know what is the purpose of them. Hope you can explain me :)</p> <p>Thanks you :)</p> <p>PD: yes i am pretty new in Java :)</p>
java
[1]
4,706,575
4,706,576
can we assign a integer value to a reference variable?
<p>It is not possible to assign an integer value to a reference variable directly, say like:</p> <pre><code>int &amp;x=10; //not possible </code></pre> <p>Is there any other way we can modify this statement to make it possible?</p> <p>But not like this:</p> <pre><code>int a=10;int &amp;x=a; </code></pre> <p>This works fine. But I want some other way or modify a little bit my expression and make it work!</p>
c++
[6]
3,606,547
3,606,548
How to Display a progress bar that displays over the fade screen overlapping the previous activity
<p>I am trying to make an activity. I have made some controls in that activity.Suppose if I click on some control(e.g Button) ,then a fade screen display that overlaps the previous activity and over the fade screen there is a progress bar .when the progress bar is 100% completed ,then the fade screens disappers and the next activity displays.</p> <p>Now my question is ,How can i make a fade screen that displays over(overlaps) the previous activity and the fade screen also contains the progress bar.</p>
android
[4]
5,287,935
5,287,936
What are the benefits are programming in C over C++
<blockquote> <p><strong>Possible Duplicates:</strong><br /> <a href="http://stackoverflow.com/questions/632474/c-over-c">C over C++</a><br /> <a href="http://stackoverflow.com/questions/497786/why-would-anybody-use-c-over-c">Why would anybody use C over C++?</a><br /> <a href="http://stackoverflow.com/questions/482574/whats-the-advantage-of-using-c-over-c-or-is-there-one">What&#8217;s the advantage of using C over C++ or is there one?</a> </p> </blockquote> <p>I have seen some open source projects that are done in C and I am curious to know if there is something to be gained using C or if it is just a personal preference.</p>
c++
[6]
4,978,753
4,978,754
What is the best way to fill Combo box?
<p>I have 3 form's in my project</p> <p>When I open form 3, I fill Combo box with data (from DataBase)</p> <p>it take's time...... </p> <p>How I can fill this Combo box only one time when the program is open ? </p> <p>(in the first form - form1)</p> <p>thank's in advance</p>
c#
[0]
6,016,758
6,016,759
how do I write a `is_a_last_of_b(a, b)` to check whether `a` is the last child of `b`
<pre><code>a = $('div:first'); b = $('div'); </code></pre> <p><code>b</code> may contain multiple DOM elements.</p> <p>But <code>a</code> only contains 1 element.</p> <p>How do I know if <code>a</code> is the last element of <code>b</code>?</p> <p>I tried <code>a == $('div:last')</code>,but it's wrong after my test.</p> <p>And if <code>a</code> is an element of <code>b</code>, how do I get the sibling of <code>a</code> within <code>b</code>?</p> <p><strong>Clarify</strong></p> <p>the problem is how I can write a <code>is_a_last_of_b(a, b)</code> to check whether <code>a</code> is the last child of <code>b</code>.</p> <p>And if <code>a</code> is a direct child of <code>b</code>,how to write <code>next_sibling(a)</code> to return the next sibling of <code>a</code>(only one)?</p>
jquery
[5]
1,555,051
1,555,052
json parser problem in iphone
<p><a href="http://www.bidapene.com/system/Mobile/json_newdata.php?data=" rel="nofollow">http://www.bidapene.com/system/Mobile/json_newdata.php?data=</a>{"action":"login","mailID":"abc@gmail","pass":"admin"}</p> <p>how to parse above url in json</p>
iphone
[8]
5,077,284
5,077,285
How can I tell if a date is before a certain time in Java?
<p>For example given a java.util.Date how could I test if the time was before 12.30 PM that day?</p>
java
[1]
2,665,008
2,665,009
What effect does FireBug, Inspection Tools etc. Have on the window?
<p>I have a rather bizarre issue. I'm modifying the jQuery BookBlock plugin;</p> <p><a href="http://tympanus.net/codrops/2012/09/03/bookblock-a-content-flip-plugin/" rel="nofollow">http://tympanus.net/codrops/2012/09/03/bookblock-a-content-flip-plugin/</a></p> <p>To work with a full-screen page flip effect &amp; a sidebar. I've come to a brick-wall so to speak with is made more annoying by the following behaviour.</p> <p>On window load my sidebar slides in &amp; the page-flip effect gets knocked off centre. Strangely, opening and then closing any kind of 'Inspection Tools' in all browsers seems to reset a variable somewhere and re-centers my animation.</p> <p>So with that in mind here's my question, what effect does opening inspection tools or similar have on a window, and how can I replicate this within my jQuery?</p>
jquery
[5]
3,245,888
3,245,889
How to match current location coordinates with coordinates saved in database
<p>I have a database with coordinates of different places. Whenever a user comes to the place saved in database, a window should pop up reminding the user of coming to that place.</p> <p>For that I continuously need to check the current location coordinates with the coordinates saved in database. And when a match is found, the popup window should displayed.</p> <p>I can use CoreLocationManager to get current location. But how do I implement this code?</p>
iphone
[8]
3,147,703
3,147,704
Pass the image id to a function and show/hide();
<p>I've four images with IDs img01, img02, img03, img04.</p> <p>Another four images are added to an array to show that they are related to each image mentioned above, like IDs hover01, hover02, hover03, hover04.</p> <p>How to write a common function to show the hover image related to each? That is, each time when the mouse is over an image, an argument should be passed to a function to show. </p> <p>Hope that makes sense.</p>
jquery
[5]
4,170,821
4,170,822
How do you interpret jQuery(document).ready()?
<p>So <code>jQuery()</code> is is a function and document is an object which is used as a parameter of the <code>jQuery()</code> function. </p> <p>I suppose, the <code>jQuery(document)</code> function then return an object, which has a ready() method? Is it correct? What kind of object does <code>jQuery(document)</code> return then?</p>
jquery
[5]
4,921,097
4,921,098
how to validate first the 2 file name, before comparing the content?
<p>this code is used to compare the content of 2 text files, but i need to validate first, that the names of those 2 file is not same.</p> <p>can you help me to fix this code?</p> <pre><code> import java.io.*; import java.util.*; public class compare { public static void main(String args[]) throws IOException { try{ FileInputStream file1 = new FileInputStream(args[0]); FileInputStream file2 = new FileInputStream(args[1]); if(args.length != 2) throw (new RuntimeException("Usage : java compare &lt;filetoread&gt; &lt;filetoread&gt;")); if(args[0]==args[1]){ System.out.print("File name is identical"); } else { while (true) { int a = file1.read(); int b = file2.read(); if (a!=b) { System.out.print("File do not match"); break; } else{ System.out.print("Files match"); break; } } } } catch(FileNotFoundException e){ System.out.print("File tidak ada"); } catch(IOException e){ System.out.print("IO Error"); } } } </code></pre>
java
[1]
2,792,570
2,792,571
How to push top table rows to the bottom - HTML and JavaScript
<p>I want to push certain rows to bottom of table, how can it be achieved in plain JavaScript?</p> <p>In the table below, I want to push the 1st and 2nd rows to bottom:</p> <pre><code>&lt;table&gt; &lt;tr&gt;&lt;td&gt;ABCD&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;XYZ&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;adfs&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;asd&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;asdasd&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre>
javascript
[3]
5,277,992
5,277,993
Android Localization
<p>the following code is for changing app locale into spainish its working fine in some device ,but in some devices it enalrging(zooming)the views in the app. can any one give the solution?</p> <pre><code>Configuration config = getResources().getConfiguration(); Locale locale = new Locale("es", "es_ES"); // change this to a different Locale than your device config.locale = locale; Locale.setDefault(locale); getBaseContext().getResources().updateConfiguration(config, getResources().getDisplayMetrics()); Log.i("onSelected..", Locale.getDefault().getCountry()); startActivity(new Intent(getApplicationContext(), HomePage.class)); finish(); </code></pre>
android
[4]
3,498,669
3,498,670
How to get the letters of a string after a certain character
<p>I have some code that returns the file type (audio/mp3 or audio/wma etc) The user can download the file and i need to name the file test.mp3 or test.wma as appropriate. so i would like a string that returns the letters after the / Thanks</p>
php
[2]
1,683,586
1,683,587
Need to ask user if he wants to try again (Python)
<pre><code>#Ask the user what option he wants mode = input("Would you like to count Vowel's or Consonant's ? (Vowel or Consonant): ") mode = mode.strip() mode = mode.lower() # Tell the user the input he entered wasn't valid while mode != 'consonant' and mode != 'vowel': mode = input("That's not correct. Would you like to count Vowel's or Consonant's ? (Vowel or Consonant): ") #get the word from the user word = input("Please enter your Word: ") vowel_count = 0 consonant_count = 0 for letter in word: if letter in 'aeiouAEIOU': vowel_count += 1 for letter in word: if letter in 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ': consonant_count += 1 if mode == "consonant": print(word,"contains", consonant_count, "consonant's") if mode == "vowel": print(word,"contains", vowel_count, "vowel's") </code></pre> <ol> <li><p>Program Starts and asks the user whether they want to count vowels or consonants, this is stored as a "mode". If user provides input other than "consonant" or "vowel", program interprets this as an error and re-asks for input.</p></li> <li><p>Program asks for a word.</p></li> <li><p>Depending on mode, number of consonants or vowels are calculated and reported to the user.</p></li> <li><p>Program asks if another word is available. If so, steps 2 through 4 are repeated, otherwise continue to step 5.</p></li> <li><p>Depending on mode, average vowels per word or average consonants per word are reported to the user.</p></li> </ol> <p>Im stuck on step 4 i don't know how to ask the other for another word and repeat the same process</p>
python
[7]
5,197,749
5,197,750
. notaion vs. [] notation | Inserting into a Text Object
<p>I kind of move between dot notation and bracket notation on the line of code noted below. <code>JavaScript - The Good Parts</code> suggests using dot notation by default.</p> <p>How can I update this code to use the dot notation. Note that form_elements contains form input names as keys which are valid JavaScript identifiers ( they use alphanumeric characters only ).</p> <p>According to <code>JavaScript - The Good Parts</code> this means they can be used with the dot notation.</p> <pre><code>Su.text = function (form_elements) { this.text_object = {}; var key; for (key in form_elements) { //*u if (form_elements.hasOwnProperty(key)) { this.text_object[form_elements[key].name] = form_elements[key].value; // this line } } return this; }; </code></pre>
javascript
[3]
545,928
545,929
3D rotation while object being translated
<p>I've been playing with Android animation framework and I found the following 3D rotation sample code: </p> <p><a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Transition3d.html" rel="nofollow">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Transition3d.html</a></p> <p><a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Rotate3dAnimation.html" rel="nofollow">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Rotate3dAnimation.html</a></p> <p>It does pretty much what I want but I want the ImageView to rotate while it's being translated from point A to point B and the it should rotate along it's own center(which is moving) instead of the center of the container of screen. </p> <p>Does anyone know how to do that? </p> <p>-Rachel </p>
android
[4]
2,840,421
2,840,422
Show/Hide divs with same class - jquery
<p>I have 1 div that will contain 3-5 divs with the same class. Below the div is an anchor. I would like for when this anchor is clicked it will hide the first div and then show the second. Another click would show the next and so on. I have set display:none on all divs but the first so only one is currently showing. I just can't figure out how to hide the first and then show the second, then third, then next when clicking the anchor.</p> <pre><code>&lt;div class="container-div"&gt; &lt;div class="inner-div"&gt;...&lt;/div&gt; &lt;div class="inner-div" style="display:none;"&gt;...&lt;/div&gt; &lt;div class="inner-div" style="display:none;"&gt;...&lt;/div&gt; &lt;a href="#" class="more"&gt;More&lt;/a&gt; &lt;/div&gt; </code></pre> <p>So when the more anchor is clicked it would show one inner-div one at a time. Any suggestions or ideas would be greatly appreciated. Also, I would like to use jquery to accomplish this.</p>
jquery
[5]
7,744
7,745
When i create new project in android?
<p>When i create new project in android, i found each and every time error sign on project name just like picture, that could not run? So is that any solution to remove this error? <img src="http://i.stack.imgur.com/6XgKU.jpg" alt="error when creating new project"></p> <p><img src="http://i.stack.imgur.com/5biR7.jpg" alt="enter image description here"> default.properties file seems like this, which is message from error log.</p>
android
[4]
1,143,206
1,143,207
How to get exactly "Unknown Sources" application list on Android?
<p>How to get exactly "Unknown Sources" <strong>application list</strong> on Android? what is flag to used? If it is not this method,what are others method? and How to programmically?</p> <pre><code> PackageManager pm = this.getPackageManager(); final List&lt;PackageInfo&gt; appinstalled = pm .getInstalledPackages(what is flag??); // </code></pre> <p>Sorry for my bad English. Thank you.</p>
android
[4]
2,013,740
2,013,741
Android Broadcast onReceive method not called from service
<p>I have a service that sends an sms. I have a broadcast receiver that is registered to notify me when the sms has been sent or not sent. The problem now is in the emulator (froyo), everything works fine when an sms is sent and when it isn't. However on my phone (galaxy S i9000, darky rom 9.3), and on my friends HTC with cyanogenmod 7, the service sends the sms but there are no notifications, if i switch my phone to airplane mode and run the app, i received notifications telling me that the messages weren't sent (which is expected). On investigating, I realised that the onReceive method of my broadcast isn't called at all when the sms is sent. In logcat i also realised that in the emulator the smsmager sends the message, on my phone, the SMSDispatcher sends the message and SMSDispatcher is an internal android class that isn't part of the public api so i cant access it. Any ideas?</p>
android
[4]
3,463,768
3,463,769
javascript regexp for validating url without http in the beginning
<p>I want to validate a javascript string using regexp for URL.</p> <p>I don't wan't to force http:// in the beginning.</p> <p>What is the correct regexp, since I have the next one to include http:</p> <pre><code>var pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&amp;%@!\-\/]))?/; </code></pre>
javascript
[3]
2,227,340
2,227,341
How to find location within list?
<p>I suspect this is a basic question(but I tried to google and search SO with no luck). </p> <p>I have a list: <code>[1, 2,3,4]</code></p> <p>and I want to know where in the list the value of 3 is..but without using a for loop to go through the entire list. Is that possible? I'm already going through a very large list and want to minimize the number of loops through the entire list. </p> <p>Is this possible?</p>
python
[7]
3,062,577
3,062,578
how do i take a screenshot of an android layout?
<p>my question is how do I take a screenshot using the built in screen capture. Any hints or sample code would be greatly appreciated.</p>
android
[4]
4,728,697
4,728,698
Code Contract C# ensure value is in array
<p>This is most likely very simple but I can't seem to figure it out:)</p> <p>I have 2 arrays of int. I want to make sure one value is in both arrays using code contracts in some form. If the value is not both arrays I don't want to continue</p> <p>Can this be done? I was thinking of something like this but can't seem to get it to work</p> <pre><code>Contract.Requires(g[variable ] == y[variable]) </code></pre> <p>The value must be in the same posion in both arrays</p> <p>This is what I have now</p> <pre><code> private static int FirstCut(int[] g, int[] h) { int x = 0; Contract.Requires(g.Length &gt; 0); Contract.Requires(g.Length == h.Length); //skal være lige lange while (g[x] != h[x]) { x++; } return x; } </code></pre> <p>Regards </p> <p>Birger</p>
c#
[0]
3,852,442
3,852,443
How do I wait for "animated scroll to id" to complete before focusing on first form field?
<p>So, I have a link at the bottom of website. When it is clicked, it scrolls to a form at the top of the page with the animated style. And as it arrives at top of page, it focuses on the first field in form.</p> <p>Currently, this is my code:</p> <pre><code>$(document).ready(function() { $('#goto-show-form').click(function() { $('html, body').animate({scrollTop: $("#show-form").offset().top}, '500'); $('#first-field').focus(); return false; }); }); </code></pre> <p>What happens is it begins scrolling, then focuses to form field while still in process of scrolling, then returns to last position in scrolling process and continues scrolling up. Instead of being smooth, you can see it cuts back and forth.</p> <p>How can I tell jquery to wait until scrolling is complete before focusing to the form field?</p> <p>Here is the website: <a href="http://bit.ly/dfjvmT" rel="nofollow">http://bit.ly/dfjvmT</a> (The link that starts scroll is "Send us your resume" at the bottom.)</p> <p>Thanks.</p>
jquery
[5]
384,754
384,755
JQuery ~ How to keep moving the object when keydown
<p>In JQuery ~ I hope to make a simple character moving, Stop > Left || right.</p> <p>This script make #moveCharacter turn left walk 10px <strong>once</strong>.</p> <p>How can I <em>keydown</em> keep turn left <strong>walking</strong>,when <em>keyup</em> stop walking (like a character)??</p> <pre><code>// Left moving $(document).keydown(function(e){ if (e.keyCode == 37) { $("#moveCharacter").animate({marginLeft: "-=10px"}, {queue:false}); return false; } }); </code></pre> <p>2.I try to change keypress() but it has not work.....what wrong?</p> <pre><code>var xTriggered = 0; $(document).keypress(function(e){ xTriggered++; if (e.which == '37') { $("#moveCharacter").animate({marginLeft: "-="+xTriggered+"px"}, {queue:false}); return false; } }); </code></pre>
jquery
[5]
637,793
637,794
Writing reusable code
<p>I find myself constantly having to change and adapt old code back and forth repeatedly for different purposes, but occasionally to implement the same purpose it had two versions ago.</p> <p>One example of this is a function which deals with prime numbers. Sometimes what I need from it is a list of n primes. Sometimes what I need is the nth prime. Maybe I'll come across a third need from the function down the road.</p> <p>Any way I do it though I have to do the same processes but just return different values. I thought there must be a better way to do this than just constantly changing the same code. The possible alternatives I have come up with are:</p> <ol> <li><p>Return a tuple or a list, but this seems kind of messy since there will be all kinds of data types within including lists of thousands of items.</p></li> <li><p>Use input statements to direct the code, though I would rather just have it do everything for me when I click run.</p></li> <li><p>Figure out how to utilize class features to return class properties and access them where I need them. This seems to be the cleanest solution to me, but I am not sure since I am still new to this.</p></li> <li><p>Just make five versions of every reusable function.</p></li> </ol> <p>I don't want to be a bad programmer, so which choice is the correct choice? Or maybe there is something I could do which I have not thought of.</p>
python
[7]
1,713,870
1,713,871
jQuery replace multiple elements using class
<p>I want to replace all the <code>spans</code> with a <code>div</code>. When I run this code only one element gets replaced. How to change this code so that the script affects all the <code>spans</code>?</p> <p><em>I have tried to use clone(), but it didn't work.</em></p> <pre><code>$flexBox = $("&lt;div&gt;&lt;/div&gt;"); $(".overlayBox").replaceWith($flexBox); &lt;span class="overlayBox"&gt;&lt;/span&gt; &lt;span class="overlayBox"&gt;&lt;/span&gt; &lt;span class="overlayBox"&gt;&lt;/span&gt; </code></pre>
jquery
[5]
955,599
955,600
regular expression for date in any format in javascript?
<p>regular expression for date in any format in javascript</p> <p>The format includes: dd/mm/yyyy or mm/dd/yyyy or yyyy/dd/mm or dd-yy-mmmm or ddmmyyyy like so on.....</p> <p>can any one help please??</p>
javascript
[3]
2,317,901
2,317,902
How to inegrate paypal with iphone?
<p>I am trying to integrate paypal with iphone n i m getting the error related to .o files of mobile payment library..want to know the complete procedure for integating paypal with iphone..and i m trying dis coding for paypal </p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; [PayPal initializeWithAppID:@"APP-80W284485P519543T" forEnvironment:ENV_SANDBOX]; } -(IBAction)payPal:(id)sender { PayPal *payObject=[PayPal getInstance]; PayPalPayment *obj=[[PayPalPayment alloc]init]; obj.recipient=@"[email protected]"; obj.paymentCurrency=@"USD"; obj.description=@"Teddy Bear"; obj.merchantName=@"Priyanka"; obj.subTotal = [NSDecimalNumber decimalNumberWithString:@"10"]; [payObject checkoutWithPayment:obj]; } </code></pre>
iphone
[8]
2,375,354
2,375,355
pass three dropdown selected values as a parameters via Ajax to controller
<p>in jquery three dropdownlists values passing as parameters via ajax in button click event<br> but the value we store dropdownvalue cant we use out of the change function? </p> <pre><code> $("#rooms").change(function () { var searchRooms = $("#rooms").val(); }); </code></pre> <p>like this i need three varaibles(dropdownvalues) in button click event<br> i have three dropdownlists in view. i have selected one value from one dropdownlist using above code. now i need to select three values from three different dropdown lists.so if i use the above code to select one value from one dropdown then that value will be stored in searchRooms varaible.now i need to use(pass) the varaible to controller.if i close the change function i cant use the varaible value. am i correct? so i need to pass three dropdown list values to controller that to in button click event </p> <blockquote> <p>another issue,declaring as global variable.</p> </blockquote> <pre><code> $(#"btn").click(function(){ var searchRooms; var searchAdults; var searchChildren; $("#rooms").change(function () { searchRooms = $("#rooms").val(); }); $("#adults").change(function () { searchAdults = $("#adults").val(); }); $("#searchChildren").change(function () { searchChildren = $("#children").val(); }); $.ajax({ i need pass the above three variable values to controller here }); }); </code></pre> <blockquote> <p>in this after change function what will be the value of variable searchRooms?<br> in alert i am getting the value is undefined means,there is no value for searchRooms?<br> how can i pass that variable to controller? </p> </blockquote>
jquery
[5]
4,747,862
4,747,863
Problems with replacing text in a text file
<p>I have the following scenarion.</p> <p>Everytime my page loads I create a file. Now my file has two tags within. {theme}{/theme} and {layout}{/layout}, now everytime I choose a certain layout or theme it should replace the tags with {layout}layout{/layout} and {theme}theme{/theme}</p> <p>My issue is that after I run the following code</p> <pre><code>if(!file_exists($_SESSION['file'])){ $fh = fopen($_SESSION['file'],"w"); fwrite($fh,"{theme}{/theme}\n"); fwrite($fh,"{layout}{/layout}"); fclose($fh); } $handle = fopen($_SESSION['file'],'r+'); if ($_REQUEST[theme]) { $theme = ($_REQUEST[theme]); //Replacing the theme bracket in the cache file for rememberence while($line=fgets($handle)){ $line = preg_replace("/{theme}.*{\/theme}/","{theme}".$theme."{/theme}",$line); fwrite($handle, $line); } } </code></pre> <p>My output looks as follows </p> <pre><code>{theme}{/theme} {theme}green{/theme} </code></pre> <p>And it needs to look like this</p> <pre><code>{theme}green{/theme} {layout}layout1{/layout} </code></pre>
php
[2]
5,762,767
5,762,768
IComparable Implementation
<p>i have written the following code</p> <pre><code> class Program { static void Main(string[] args) { Circle c1 = new Circle(5); Circle c2 = new Circle(10); Console.WriteLine(c1.Area().ToString()); if (c1&gt;c2) { } } } public class Circle:System.IComparable&lt;Circle&gt;,IComparable { public int radius { get;private set; } public double Area() { return Math.PI * radius * radius; } public Circle(int radius) { this.radius = radius; } public int CompareTo(Circle c) { if (c.Area() == this.Area()) return 0; if (c.Area() &gt; this.Area()) return 1; return -1; } public int CompareTo(Object c) { if (((Circle)c).Area() == this.Area()) return 0; if (((Circle)c).Area() &gt; this.Area()) return 1; return -1; } } </code></pre> <p>However it the error Error 1 Operator '>' cannot be applied to operands of type 'ConsoleApplication1.Circle' and 'ConsoleApplication1.Circle' </p> <p>i have implemented both the methods and could not figure the error</p>
c#
[0]
1,731,296
1,731,297
iphone programming adivce
<p>Hello I was wondering if there are any methods that would allow me to interact with the iphone users. What I mean is like UIALERTVIEW of some sorts that will popup and update them with a status. But I don't want to have a fixed status, but one I can change anytime I want, like say if there is a day off, I want to provide a status over the air and when the user opens the app it will show the new message.</p> <p>Is this even possible? If there are any other alternatives please list them</p>
iphone
[8]
3,686,752
3,686,753
What does '>' do in jQuery find?
<p>I'm trying to decipher the following line of code</p> <pre><code>.find('&gt; li ul:visible') </code></pre> <p>And I cannot figure out what '>' achieves. I'm having trouble searching the documentation</p>
jquery
[5]
4,015,324
4,015,325
why is this java initialization giving error?
<p>I am trying to initialise the array C in the loop, but it gives error :<br> C is array of class ipdata and I have declared it and trying to initialise it inside the loop. </p> <pre><code>import java.io.*; import java.util.*; public class cluster_anlysis { class ipdata{ float a,b; int cluster; ipdata() { a=0; } } public float modc(float a){ if(a&lt;0.0) a=-a; return a; } public static void main(String[] args) { cluster_anlysis obj=new cluster_anlysis(); ipdata C[] = new ipdata[50]; float mean1,mean2,mean3; int i,j,n1=0,n2=0,n3=0,flag=0; float ina=0.0f; float inb=0.0f; //BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); Scanner scan =new Scanner(System.in); System.out.println("pls enter no of data: "); Integer no = scan.nextInt(); System.out.println("\nnow enter the x and y values"); for(i=0;i&lt;no;i++) { ina=scan.nextFloat(); inb=scan.nextFloat(); System.out.println(ina); C[i]= new ipdata(); // this line is giving error C[i].a=ina; C[i].b=inb; C[i].cluster=0; } } } </code></pre> <p>What could be the problem ? it says : No enclosing instance of type cluster_anlysis is accessible. Must qualify the allocation with an enclosing instance of type cluster_anlysis (e.g. x.new A() where x is an instance of cluster_anlysis).</p>
java
[1]
2,964,599
2,964,600
replacing quote in php
<p>I want to replace <code>“</code> and <code>”</code> characters with the caharacter <code>"</code> in php . I have written as follow but it doesn't change. How can I do this ?</p> <pre><code>$temp=str_replace("”","\"",$temp); $temp=str_replace("“","\"",$temp); </code></pre>
php
[2]
1,469,756
1,469,757
Java Method Pass-by-Value Issue
<p>When I call my <code>bar(Map map)</code> method from my current <code>foo(...)</code> method, I run into the following behavior where bar() says that map is empty.</p> <pre><code>private void foo() { Map map = new Map(); // pseudocode // add (key, value)'s to map printMap(map); // prints key and values Map newMap = bar(map); ... System.out.println(newMap.size()); // returns 0 } // end foo(); private Map bar(Map map) { printMap(map); // return empty ... } </code></pre> <p><strong>EDIT</strong>: Could it have been this print method's <code>it.remove()</code>call ? When I removed this call, I no longer had a problem.</p> <pre><code>private void printMap(Map mp) { Iterator it = mp.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry)it.next(); logger.info(pairs.getKey() + " = " + pairs.getValue()); it.remove(); // avoids a ConcurrentModificationException } } </code></pre>
java
[1]
5,951,913
5,951,914
PDFTextStripper gives "Object reference not set to an instance of an object" exception
<p>I am using <code>PDFTextStripper</code> class and for some .pdf files i am able to get proper text but some .pdf files its throwing the exception: <code>"Object reference not set to an instance of an object"</code></p> <p>Here is my code:</p> <pre><code>PDDocument doc = PDDocument.load(path); PDFTextStripper stripper = new PDFTextStripper(); string result = stripper.getText(doc); </code></pre> <p>Note: I have checked that .pdf file is not a image .pdf file(like scanned docs..) its a text .pdf file.</p> <p>How to solve this ?</p>
c#
[0]
5,309,029
5,309,030
iPhone - pushed view blocked by invisible toolbar (?)
<p>I have this UINavigationControl that has its toolbar visible and is showing the RootViewController. Then I push a new viewController into the screen but I like the toolbar to be invisible, while this other viewController is being shown.</p> <p>Then, to show the viewController and hide the toolbar of the UINavigationControl I do this:</p> <pre><code>self.navigationController.toolbar.hidden = YES; UIViewController *newVC = [[UIViewController alloc] init]; [self.navigationController pushViewController:newVC animated:YES]; </code></pre> <p>The problem is that any touch on this new view controller in the are correspondent where the toolbar was visible on the last view controller is not detected.</p> <p>As you know, the toolbar sits on a rectangle at the bottom of the screen, has the screen width and 44 pixels high (if I am not wrong). So, the new pushed view controller responds to touch on its full view are except those on this rectangle.</p> <p>See the following picture. I have 3 buttons. Buttons 1 and 2 will respond to touches, but not button 3, because it is inside the area where the toolbar of the other view was...</p> <p>And more than that, if I paint the background color of the new view with red, for example, the whole screen will be red, except for that bottom rectangle that will be white (and white is not the color of the previous view). I have checked and the view has 320 x 480...</p> <p><img src="http://i.stack.imgur.com/5S72u.png" alt="enter image description here"></p> <p>any clues? thanks.</p>
iphone
[8]
5,476,916
5,476,917
How do you install your app on your iphone?
<p>I have a developer account, I provisioned a profile etc.</p> <p>If I plug my iphone into my mac, when I build, will it automatically install the app on my phone also?</p>
iphone
[8]
790,119
790,120
Add prefix to mobile number in php before sending it to database
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/11786411/please-help-me-validate-mobile-no-in-php-form">Please help me VALIDATE Mobile no in php form</a> </p> </blockquote> <p>I got mobile number to validate but I am stuck at the prefix part.</p> <pre><code>if(empty($_POST['mobileno'])) // phone number is not empty { $error[] = 'Please enter mobile number'; } else { if(preg_match('/^\d{10}$/',$_POST['mobileno'])) // phone number is valid { $mobile = $_POST['mobileno']; // your other code here } else // phone number is not valid { $error[] = 'Phone number invalid !'; } } $prefix = 0; $pmobile = $prefix . $mobile; </code></pre> <p>This is what I am trying to do for prefix. Is this right as I cant add the value 0 before the number.</p>
php
[2]
2,021,333
2,021,334
BackgroundWorker progressBar - Problem implementing ReportProgress when loop occurs in another class
<p>Hi I am trying to integrate a background worker with a progress bar but cannot get it right.</p> <p>I am processing some files and all the processing is done in an external class.</p> <p>My difficulty is that the looping is inside this class,where usually I do the talking to the backgroundworker.</p> <p>The good thing is that when processing a file,an event is fired whenever each file has completed processing.</p> <p>This is my code any suggestions how could this be achieved</p> <pre><code> BackgroundWorker _bw = new BackgroundWorker private void RunLongProcess() { _bw.WorkerReportsProgress = true; _bw.WorkerSupportsCancellation = true; _bw.DoWork += DoWork; _bw.ProgressChanged += ProgressChanged; _bw.RunWorkerCompleted += RunWorkerCompleted; _bw.RunWorkerAsync();//start the process if (_bw.IsBusy) _bw.CancelAsync(); } static void DoWork (object sender, DoWorkEventArgs e) { var files=GetFiles(); int fileCount=files.Count; //usually I do a loop here but all the processing is done inside this class so var fileProcessor=new FileProcesser(); fileProcessor.ProcessFiles(files); } private void OnFileProcessCompleted(object sender, FileEventArgs e) { //Event Fired when a file has been processed //How do I update progressBar.Problem cross threading here. //What do I do here????? _bw.ReportProgress(e.FileProcessedCount, e); } ProgressChanged (object sender, ProgressChangedEventArgs e) { // Update the UI labelProgress.Text = e.UserState; progressBar.Value = e.ProgressPercentage; } private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Cancelled) // Console.WriteLine("You canceled!"); else if (e.Error != null) //Console.WriteLine("Worker exception: " + e.Error.ToString()); else // Console.WriteLine("Complete: " + e.Result); } </code></pre>
c#
[0]
2,258,112
2,258,113
splitting arrays
<p>How do I partition an array into four sub arrays in Java?</p>
java
[1]
2,531,899
2,531,900
I am a programming student and haveing problems writing a program for guessing random numbers just don't know where to get started
<p>program chooses the number to be guessed by selecting an int at random in the range 1-100. The program then displays the following ext in a label:</p> <pre><code>I have a number between 1 and 100 -- can you guess my number? Please enter your first guess. </code></pre> <p>A TextBox should be used to input the guess. As each guess is input, the background color should change to red or blue. Red indicates that the user is getting "warmer", blue that the user is getting "colder". A label should display either "Too High" or "Too Low", to help the user zero in on the correct answer. When the user guesses the correct answer, display "Correct!" in a message box, change the Form's background color to green and disable the TextBox. A TextBox (like other controls) can be disabled by setting the control's Enabled property to False. Provide a Button that allows the user to play the game again. When the button is clicked, generate a new random number, change the background to the default color and enable the TextBox.</p>
asp.net
[9]
5,178,329
5,178,330
How can i get current running context in android
<p>I am trying to get current running context in android, I tried to use:</p> <pre><code>&lt;application android:name="com.xyz.MyApplication"&gt; &lt;/application&gt; public class MyApplication extends Application { private static Context context; public void onCreate() { super.onCreate(); MyApplication.context = getApplicationContext(); } public static Context getAppContext() { return MyApplication.context; } } </code></pre> <p>when i try use MyApplication.getAppContext() in Alertbuilder they give this error </p> <p>AndroidRuntime(14421): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application</p>
android
[4]
1,155,557
1,155,558
Parser error: Could not load type 'Default'
<p>I have built an application in ASP.NET 3.5 framework and it is working fine on localhost but when i am uploading it on my server the page gives an error on loading "Parser Error Message: Could not load type 'Default'." &lt;%@ Page Language="C#" AutoEventWireup="true" Debug="true" CodeFile="Default.aspx.cs" Inherits="Default" %> so what should i do?</p>
asp.net
[9]
3,136,098
3,136,099
How to check if android device has access to internet?
<p>I am using following method to check if device has access to internet.<br> In this code i am trying to ping/request to <code>www.google.com</code> </p> <pre><code>try { HttpGet request = new HttpGet(new URI(WEB_SIT_TO_PING)); HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 500); HttpConnectionParams.setSoTimeout(httpParameters, 500); HttpClient httpClient = new DefaultHttpClient(httpParameters); HttpResponse response = httpClient.execute(request); int status = response.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_OK) { result = true; } } catch(Exception e) { e.printStackTrace(); result = false; } </code></pre> <p>Above code works but, when my activity gets launched it displays one blank black screen for 1-2 seconds and then it displays the main screen of the activity. </p> <p>I am doing this check in the <code>onCreate</code> of the activity.<br> Is there another why of doing this check. </p> <p>UPDATE:<br> I don't want to check if Network is connected or not, I want to check if Device has Access to Internet. It may be the case that Device has Network connection but that network connection does not have Internet Access. </p> <p>Thanks.</p>
android
[4]
1,490,579
1,490,580
C# Load/Unload plugins
<p>Is there anyway to have ClassLibrary plugins which can be loaded/unloaded. The only way I have found is using an AppDomain but that defeats the purpose as the plugin cannot use the hosts API.</p>
c#
[0]
5,406,166
5,406,167
Typecast an object to generic
<p>I am developing an application where i need to send an object to another class and back to calling class. My code is....</p> <pre><code>class Generic{ public static byte[] SerializeObject(Object o) { byte[] buffer = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos; `enter code here`try { oos = new ObjectOutputStream(baos); oos.writeObject(o); oos.close(); buffer = baos.toByteArray(); } catch (IOException e) { e.printStackTrace(); } return buffer; } public static HelloWorld DeSerializeObject(byte[] buf) { HelloWorld d2 = null; try { ObjectInputStream ois = new ObjectInputStream( new ByteArrayInputStream(buf)); d2 = (HelloWorld) ois.readObject(); ois.close(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace(); } return d2; } } </code></pre> <p>And i am calling this methods from a different activity like</p> <pre><code>HelloWorld helloworld=Generic.DeSerializeObject(bytearray); </code></pre> <p>Now i want to write a generic method to send this object and typecast in this method generically.Is there any method to achieve genericity in JAVA?</p>
android
[4]
2,098,040
2,098,041
how does CLR run beginXXX in a thread pool thread?
<p>I try to figure out how CLR put asynchronous operations BeginXXX into thread pool's queue. and which ThreadPool's API is called. But I did not find anything when I pokeed aroud BeginRead() in System.IO.Stream<br> and BeginExecuteReader() in System.Data.Sqlclient.SqlCommand by Reflector 6.</p>
c#
[0]
2,184,496
2,184,497
creating multidimensional array from single array
<p>i have a html form in which i use array like this (name="courts[]"). when it send data to php file i use foreeach loop to create multidimensional array for inserting records in mysql. In php file i write foreeach loop to iterate like this</p> <pre><code> $data = array(); $i = 0; foreach ($court_name as $result) { $data[] = array( 'court_name' =&gt; $result[0] ); $i++; } </code></pre> <p>it display result this </p> <pre><code> Array ( [0] =&gt; Array ( [court_name] =&gt; P ) [1] =&gt; Array ( [court_name] =&gt; S ) ) </code></pre> <p>instead of this</p> <pre><code> Array ( [0] =&gt; Array ( [court_name] =&gt; Punjab ) [1] =&gt; Array ( [court_name] =&gt; Sindh ) ) </code></pre>
php
[2]
65,321
65,322
How to avoid undefined index
<p>How can you easily avoid getting this error/notice in PHP?</p> <pre><code>Notice: Undefined index: test in /var/www/page.php on line 21 </code></pre> <p>The code:</p> <pre><code>$table = 'test'; $preset = array(); method($preset[$table]); </code></pre> <p>The array <code>$preset</code> exists but not with the specified index</p>
php
[2]
5,427,480
5,427,481
How do I know when one is done entering cin with \n? (loop)
<p>From Australian voting problem:</p> <p>A bot will keep putting information and it can reach 1000 lines. Example of what he'll enter:</p> <pre><code>"1 2 3 2 1 3 2 3 1 1 2 3 3 1 2 " </code></pre> <p>How do I know when he has finished entering information? There is an extra \n at the end and that's my only guess on where to go. cin doesn't seem to detect \n, but getchar() apparently does. It will however get the \n even after the first line of course, and getting it to work has become rather difficult. How do I accomplish this?</p>
c++
[6]
5,061,847
5,061,848
Third party JavaScript - good idea to use try catch?
<p>I am developing a third party JavaScript widget that will be included by users on their applications/blogs. I have good tests around the library, but I am afraid that if despite that if some syntax error sneaks through and cause the other scripts on the user's application to stop loading. </p> <p>So - to prevent this from happening, is it a good idea to surround my entire widget code in a try/catch like this?</p> <pre><code>try { // my library } catch(e) { // notify me about the error } </code></pre>
javascript
[3]
4,182,833
4,182,834
Phone not recognized in android debugger
<p>I am trying to run the android debugger on my phone, but the console as well as eclipse plugin reports a ??? in place of the device name. The attached phone is a sony ericsson xperia mini, running android 2.3 and the computer is running on ubuntu 10.10 . I have enabled the usb debugging option on the phone.</p>
android
[4]
1,829,644
1,829,645
How to bind the lifetime of a shared resource object to the union of its users' lifetimes?
<p>I have a number of GUI widgets that all make use of the same shared timer object. I would like to have the first GUI object that comes into existence create the timer instance and later have the last remaining gui object take care of destroying the timer.</p> <p>Is there an idiomatic C++ solution for this kind of problem?</p> <h3>Update</h3> <p><a href="http://ideone.com/UMLvt" rel="nofollow">Here is an attempt at a more generic solution.</a></p>
c++
[6]
3,067,665
3,067,666
JQuery Animation fails randomly
<p>I tried to implement jQuery Animation in my site, but randomly after seconds, minutes or hours, the animation throws an error: "Invalid property value" Line 154 Char 4889 jquery-ui-1.7.2-custom.js.</p> <p>Here is my Code:</p> <pre><code> $(idTimer).animate({backgroundColor: '#aa0000', color: '#ffffff'}, 1000); $(idPrice).animate({backgroundColor: '#aa0000', color: '#ffffff'}, 1000); $(idTimer).animate({backgroundColor: '#ffffff', color: '#f67802'}, 1000); $(idPrice).animate({backgroundColor: '#ffffff', color: '#000000'}, 1000); </code></pre> <p>Of course the IDs are correctly set. When the animation hangs up, no animation will be done anymore for this ID, so it's very mysterious. Please help, its urgent.</p> <p>Here is the failing code, beginning char 4889:</p> <pre><code>h.elem.style[f]="rgb("+[Math.max(Math.min(parseInt((h.pos*(h.end[0]-h.start[0]))+h.start[0],10),255),0),Math.max(Math.min(parseInt((h.pos*(h.end[1]-h.start[1]))+h.start[1],10),255),0),Math.max(Math.min(parseInt((h.pos*(h.end[2]-h.start[2]))+h.start[2],10),255),0)].join(",")+")"}}); </code></pre>
jquery
[5]
5,484,516
5,484,517
Using PHP, how do I echo a line from a text file that starts with a specific value?
<p>Lets say the text file " data1.txt" contains: </p> <pre><code>56715||Jim||Green||19 5678||Sara||Red||92 53676||Mark||Orange||6 56787||Mike||Purple||123 56479||Sammy||Yellow||645 56580||Martha||Blue||952 ect... . . </code></pre> <p>I would like to echo only the line beginning with "5678||". "5678" is the exact $refVal or reference value. The line should display like this:</p> <pre><code>My name is: $nameVar My color is: $colorVar My number is: $numVar </code></pre> <p>Thanks...</p>
php
[2]
4,233,256
4,233,257
Get string data from encoded bytes
<p>I have an array of bytes that has come from a barcode reader (connected via a COM port) reading an ID Card. When I convert these, I can read <em>some</em> of the data, for example:</p> <blockquote> <p>Name, Surname, City </p> </blockquote> <p>etc, but if some of the data has some characters like 'Ë' or 'Ç', or some characters that are used in our language [ed: OP is in Pristina, Kosovo], I get '?'. How can I get these characters through decoding?</p>
c#
[0]
5,270,439
5,270,440
what's an expression and expression statement in c++?
<p>I've read usually statements in c++ ends with a semicon; so that might help explain what an expression statement would be. but then what would you call an expression by giving an example?</p> <p>In this case, are both just statements or expression statements or expressions?</p> <pre><code>int x; x = 0; </code></pre>
c++
[6]
5,808,218
5,808,219
Two buttons needed at navigationItem.rightBarButtonItem. Image not getting displayed
<p>I have to have two buttons on the right side of the navigation bar. So i created a tool bar and added two bar button items to its content view. Like below.</p> <pre><code>UIBarButtonItem *shareButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"share-icon-32x32.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(showShare)]; shareButton.width = 30.0f; [buttons addObject:shareButton]; [shareButton release]; </code></pre> <p>where buttons is an array holding the button objects.</p> <p>Like wise i have another barbutton item like below</p> <pre><code>UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addDescription)]; addButton.style = UIBarButtonItemStyleBordered; [buttons addObject:addButton]; [addButton release]; </code></pre> <p>Now add the array to the toolbar like below</p> <pre><code>[toolbar setItems:buttons animated:YES]; [buttons release]; </code></pre> <p>and add it to the rightBarButton like below</p> <pre><code>self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolbar]; [toolbar release]; </code></pre> <p>I am getting two bar button items on the right bar but i am not able to get the image displayed on to the share button item. Its just a white patch. Can any body tell me what am i doing wrong or how to get the image displayed.</p> <p>Regards,</p> <p>Syed Yusuf</p>
iphone
[8]
5,232,667
5,232,668
Hangman in Python - Consonant Guessing Coding
<p><strong>The Question</strong></p> <pre><code>guess_letter: (str, str) -&gt; str </code></pre> <p>The first parameter is the unguessed consonants and the second is the difficulty level. Return the consonant to be guessed next by the computer player. If level is EASY, the consonant to guess is randomly selected. If level is HARD, the consonant to guess the first consonant in PRIORITY_CONSONANTS that occurs in the first parameter.</p> <pre><code>PRIORITY_CONSONANTS = 'tnrslhdcmpfgybwvkqxjz' EASY = 'E' HARD = 'H' </code></pre> <p>Overall this project will create a functional Hangman game, this is one component of it which I have to code myself.</p> <p>I don't know how to write this I made a small construct that I wanted to work around. But I honestly don't understand what to write.</p> <p>I want that when the difficulty level is hard it to select the first consonant in priority consonants that appears in the parameter unguessed consonants and when it is easy I want any random consonant to appear</p> <pre><code>guess_letters(unguessed_consonants, difficulty_level): if difficulty_level == EASY: if difficulty_level ==HARD: </code></pre>
python
[7]
1,823,629
1,823,630
Runtime error- Program terminated
<p>My program terminates for some reason. Its a rock-paper-scisors simulation. The termination takes place when I enter something in the first nextLine. If anybody could please help.</p> <p><pre><code></p> import java.util.*; import java.math.*; public class RockPapperScissors { /** * @param args */ public static void main(String[] args) { Scanner in=new Scanner(System.in); String comp, user; comp=getComp(); System.out.println("Enter rock, paper, or scissors"); user=in.nextLine(); winner(comp, user); } public static String getComp(){ Random rand=new Random(); String answer; int ran=rand.nextInt(3); if(ran==1) answer="rock"; else if(ran==2) answer="paper"; else answer="scissors"; return answer;} public static void winner(String com, String use){ if(com=="rock" &amp;&amp; use=="rock") System.out.println("Its a tie"); else if(com=="rock" &amp;&amp; use=="paper") System.out.println("You win!"); else if(com=="rock" &amp;&amp; use=="scissors") System.out.println("Computer wins, you FAIL"); else if(com=="paper" &amp;&amp; use=="rock") System.out.println("Computer wins, you FAIL"); else if(com=="paper" &amp;&amp; use=="paper") System.out.println("Its a tie"); else if(com=="paper" &amp;&amp; use=="Scissors") System.out.println("You win!"); else if(com=="scissors" &amp;&amp; use=="rock") System.out.println("You win"); else if(com=="scissors" &amp;&amp; use=="paper") System.out.println("Computer wins, you FAIL"); else if(com=="scissors" &amp;&amp; use=="scissors") System.out.println("Its a tie");} } </code></pre>
java
[1]
4,336,168
4,336,169
How to have custom dialog on preference activity?
<p>I have a preference page where there is a check box preference for enable login password. When the user check it, it should have a dialog pop out and inside there will be <strong>2 edit text</strong> fields for password.</p> <p>I have done some readings and it seems like using a custom dialog will be the right choice. But the problem is that there is no onCreateDialog() method for the preference activity to override, how do I solve this problem? Some example codes will be nice. Thanks!</p>
android
[4]
332,889
332,890
operator overloading error C++
<p>I have a inline operator overloading in cpp file. My understanding is the inline function should also put in the header file with the body of function. </p> <p>but when i do that. the error come out which is redefinition of "operator ==" </p> <p>could you explain why is the error like that. and also, could anyone explain what sorts of content should keep in the header file.? </p> <pre><code>inline bool operator ==(Duration&amp; d1, Duration&amp; d2) { return d1.getSecond() == d2.getSecond(); } </code></pre>
c++
[6]
5,165,276
5,165,277
reading a line from a file and splitting it - python
<p>I have a file with just 1 line of data ( close to 3 MB ) I need to split it into smaller lines and write the output to a new file.</p> <p>for eg :</p> <blockquote> <p>sample.txt - file 434D012000100009362D00000000069E0F0007000000DA434D01030010010003008000000000000000000000009C434D01200010000 .... and so on</p> </blockquote> <p>I want to split the whole line into smaller lines each of 23 bytes each. ie how do i get to write a python script to tell break after so many characters</p> <p>Thanks.</p>
python
[7]
2,746,579
2,746,580
Convert "['a','b','c']" to ['a','b','c'] : Javascript
<p>Which would be best way to do these things?</p> <p><strong>Note:</strong> My array contains complex values means comma separated or object values in side string array &amp; Arrays string quoted in <strong>double</strong> quotes and elements are in <strong>single</strong> quotes.</p> <p><strong>EX.</strong> <code>str = "['sam', 'admin', '1062', 'Sam', 'True', '$$global_permissions#1062:manage_replenishment,purchase_order,reprint_invoice#1008', '[email protected]', '9920580', 'en', '358', '{\"Sales-tax-details\":\"brand,category,supplierNo\",\"invoice-logs\":\"invoiceNo,eventDateTime,event\"}']"</code></p> <p>Here i played with <code>JSON.parse</code>, </p> <pre><code>JSON.parse(str); Uncaught SyntaxError: Unexpected token ' // this error i got on console </code></pre> <p>Then i tried,</p> <pre><code>JSON.parse(str.replace(/'/g, '"')) Uncaught SyntaxError: Unexpected token S // this error i got on console </code></pre> <p>One more thing i wanted to explore here as, if <code>str</code> contains following elements,</p> <p><code>str = "['sam', 'admin', '1062', 'Sam', 'True', '$$global_permissions#1062:manage_replenishment,purchase_order,reprint_invoice#1008', '[email protected]', '9920580', 'en', '358', '{}']"</code></p> <p>for this <code>str</code> i tried,</p> <pre><code>JSON.parse(str.replace(/'/g, '"')) </code></pre> <p>Its working fine here,</p> <p>Regards.</p>
javascript
[3]
5,967,993
5,967,994
Frontend creation using C++
<p>I have data generation code written in C++. Is it possible to create a frontend using C# and pass values to the data generation code written in C++?</p> <p>I'm using <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio#Visual_Studio_2010" rel="nofollow">Visual Studio 2010</a>.</p>
c++
[6]
4,061,499
4,061,500
Action bar sherlock error - Android
<p>I've created an Action Bar Sherlock library project, I've added that library to my project.</p> <p>I get the error:</p> <pre><code>R cannot be resolved to a variable </code></pre> <p>Im using min sdk 7, target sdk 15.</p> <p>I've cleaned the project and all of my projects in eclipse.</p> <p>I've restarted eclipse.</p> <p>Any ideas?</p>
android
[4]
5,197,008
5,197,009
remove table without id using jquery
<p>I have the following dynamically generated table on a page along with other tables on the page. I need to remove this table which does not have an id.There is one of two ways that I can think of to target the table for removal since these never change.</p> <p>By the class="matching_results_text" or by the text "You are here"</p> <p>Just do not know how to do it.</p> <p>I tried $("table").remove(":contains('You are here:')"); but that didn't work right.</p> <pre><code>&lt;table width="100%" border="0" cellspacing="0" cellpadding="5"&gt; &lt;tr&gt; &lt;td&gt; &lt;b&gt;You are here: &lt;a href="http://www.test.com"&gt;Home&lt;/a&gt; &amp;gt; &lt;a href="http://www.test.com/Ignition-Controls-s/30.htm" title="Ignition Controls"&gt;Ignition Controls&lt;/a&gt;&lt;/b&gt; &lt;div class="matching_results_text"&gt;We found 10 results matching your criteria.&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
jquery
[5]
5,127,159
5,127,160
Run external program concurrently
<p>I want to be able to run an external program concurrently with my Java code, i.e. I want to start the program, then return control to the calling method while keeping the external program running at the same time. The Java code will then keep generating input and send it to the external program and receive output back. </p> <p>I don't want to keep loading the external program as it has very high overhead. What is the best way to accomplish this? Thanks!</p>
java
[1]
4,344,715
4,344,716
What is Best Way to Input Decimal Numbers with iPhone SDK?
<p>So after finally learning how to store user input into a variable, I am realizing it is rather difficult to have the user input numbers with decimals. The Number KeyPad doesn't allow a decimal part, and if I use Numbers &amp; Punctuation it looks a bit weird.</p> <p>So do I have to use a number Picker to smoothly allow users to input numbers? OR should I just use the Numbers &amp; Punctuation since I was able to learn how to store that input (almost)?</p> <p>Any help would be greatly appreciated. </p>
iphone
[8]
2,238,530
2,238,531
how to give top to bottom animation android
<p>i am able to give bottom to top animation when i go to next activity but now when i pressed back i am using same code for giving animation from top to bottom animation but it always goes to bottom to top so my question is how to give animation from top to bottom when i pressed back button on android device.. my code for giving animation is below</p> <p>use when go from one activity to other using intent..</p> <pre><code> overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); </code></pre> <p>and xml is: slide_in_up.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromYDelta="100%p" android:toYDelta="0%p" android:duration="@android:integer/config_longAnimTime"/&gt; </code></pre> <p>and slide_out_up.xml is </p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromYDelta="0%p" android:toYDelta="-100%p" android:duration="@android:integer/config_longAnimTime"/&gt; </code></pre>
android
[4]
1,636,594
1,636,595
How upload file in remote machine (LAN) using Flajaxian FileUploader
<p>really it's a crucial point for me, my quastion is : </p> <p>How upload file in remote machine (LAN) using Flajaxian FileUploader.</p> <p>Env : C# , ASP.NET , VS .NET 2005</p> <p>please help</p> <p>Best regards</p>
asp.net
[9]
1,627,144
1,627,145
How static local POD constants are initialized? Lazily or not?
<p>POD means primitive data type without constructor and destructor.</p> <p>I am curious, how compilers handle lazy initialization of POD static local variables. What is the implication of lazy initialization if the function are meant to be run inside tight loops in multithreaded applications? These are the possible choices. Which one is better?</p> <pre><code>void foo_1() { static const int v[4] = {1, 2, 3, 4}; } void foo_2() { const int v[4] = {1, 2, 3, 4}; } </code></pre> <p>How about this? No lazy initialization, but slightly clumsy syntax?</p> <pre><code>struct Bar { static const int v[4]; void foo_3() { // do something } }; const int My::v[4] = {1, 2, 3, 4}; </code></pre>
c++
[6]
2,977,748
2,977,749
Incrementing characters being read
<p>I am trying to decode an input file that looks something like this: </p> <pre><code>abbaabbbbaababbaabababaabababaabbababaabababababababa... </code></pre> <p>and compare it to a makeshift mapping I have made using two arrays</p> <pre><code>int secretNumber[10]; string coding[10]; coding[0]="abb"; coding[1]="aabbbba"; coding[2]="abab"; ... </code></pre> <p>I am not sure how I can start off by reading the first character which is 'a' then check if it's in the coding array. If it is print out the secretCoding and move the next character b. Else if it's not in the array then add the next character to the first in a string and check to see if "ab" is in the array and if that isn't either add the next character which makes "abb" and so on.</p> <p>Something like this:</p> <pre><code>while (!(readFile.eof()) ){ for(int i=0; i&lt;10; i++){ if(stringOfChars==coding[i]){ cout &lt;&lt; secretNumber[i] &lt;&lt;endl; //Now increment to next char } else{ //combine the current string with the next character } } } </code></pre> <p><strong>Question:</strong> How do I go about reading in a character if its a match move to next character if not combine current character and the next character until there's a match. </p>
c++
[6]
2,822,800
2,822,801
Set current list item as selected in jQuery
<p>I have a list of items; the number of items in the list is different each time:</p> <blockquote> <pre><code>&lt;li id='item1'&gt;number_1&lt;li&gt; &lt;li id='item2'&gt;number_2&lt;li&gt; … &lt;li id='itemn'&gt;number_n&lt;li&gt; </code></pre> </blockquote> <p>When a user choose an item. I want to set the item as selected. In my code. I can get the id of each item. my problem is I cannot set the item as selected; for example. if I get item2. I want to the item become as </p> <blockquote> <pre><code>&lt;li id='item2' class="selected" &gt;number_2&lt;li&gt; </code></pre> <p>Since the id is a variable in mycode. I tried lots of ways to do that in my jquery script. like:</p> <pre><code>$("#id").addClass('selected'); // doesn't work; $("li" id).addClass('selected'); // doesn't work; $("#" id).addClass('selected'); // doesn't work; $($this. id).addClass('selected'); // doesn't work; </code></pre> </blockquote> <p>I searched on the web, maybe this is too simple probem, I didn't find similar questions and answers. Can anybody please help me out. thank you! </p>
jquery
[5]
1,889,839
1,889,840
Search by substring on strings which map to id
<p>What would be the best way to implement search by substring on Strings(around 5000 entity names in application) which map to entityId. </p> <p>I want to implement it so that I could put searched suggestions to the user as he types in one or more characters.For e.g I would want to be able to suggest all entities starting with his queried substring as he does the search.</p> <p>Looking forward to store them in the application scope itself to avoid frequent retrievals from DB.</p>
java
[1]
2,939,537
2,939,538
Difference between PrintWriter.printf and PrintWriter.format methods
<p>Is there any difference between the Java <code>PrintWriter</code> methods <code>printf</code> and <code>format</code>?</p> <p>The doc says <code>printf</code> is a convenience method but if it behaves exactly as <code>format</code>, so I don't understand what's convenient about it.</p>
java
[1]