Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
4,529,327
4,529,328
Unhalted error by system call
<p>I am new to C#, and I am trying to call 'cls' command using the following:</p> <pre><code>Process.Start("cls"); </code></pre> <p>When i execute this line the program halts. If I switch 'cls', lets say to 'notepad' the progam works properly. Why is that?</p> <p>Thanks, Sun</p>
c#
[0]
5,362,704
5,362,705
Eight queens in Java in recursion
<p>This is my Java code for eight queens. I don't know why it place same results for eight times. In this code, diagonal is not included.</p> <pre><code>import java.util.*; class eightTeight { Set&lt;Integer&gt; s = new HashSet&lt;Integer&gt;(); public void print() { if (s.size() &lt; 8) { for (int i = 0; i &lt; 8; i++) { if (!s.contains(i)) { s.add(i); print(); } } } System.out.println(s); return; } } </code></pre> <p>It seems that once return runs, the s still keeps the data. Appreciated to any help.</p>
java
[1]
4,388,267
4,388,268
Windows Batch File to run PHP file
<p>I have PHP script that fetches information from a backend server and saves into a database.</p> <p>I am using wamp server and mysql. Now how do I make this run periodically (every 1 hour) without user interaction? I thought of using Windows Batch file. Is there any other way?</p> <p>How do I execute a PHP file in Windows Batch file?</p> <p>Thanks In Advance</p>
php
[2]
3,749,840
3,749,841
Show/Hide div using jquery - Not working
<p>I am using this function to show/hide a div. </p> <p>But this is not working. </p> <p>It's working only for hide and not working for show. And i need to show and hide the fields in slow style.</p> <p>How can this be done?</p> <p>what was my mistake here...</p> <pre><code>$(document).ready(function(){ $("#field-reviewers-items").hide(); $('#edit-field-openforreview-value-1').click(function(){ $("#field-reviewers-items").show(); }); $('#edit-field-openforreview-value-1').click(function(){ $("#field-reviewers-items").hide(); }); }); </code></pre>
jquery
[5]
417,486
417,487
IE8 not processing Flickr feed
<p>I've got a Flickr Image feed running on here:</p> <p><a href="http://rational-animal.co.uk/lewis" rel="nofollow">http://rational-animal.co.uk/lewis</a> -- but when I have a look at it in IE8, it refuses to load the Flickr feed. Any reason why this would be the case?</p> <p>Thanks! </p>
javascript
[3]
5,464,724
5,464,725
How to restart a guess number game
<p>I am using python 2.7.1</p> <p>I would like to be able to restart the game based on user input, so would get the option of restarting, instead of just exit the game and open again. Can someone help me figure out??Thanks</p> <pre><code>import random the_number = random.randrange(10)+1 tries = 0 valid = False while valid == False: guess = raw_input("\nTake a guess: ") tries += 1 if guess.isdigit(): guess = int(guess) if guess &gt;= 1 and guess &lt;= 10: if guess &lt; the_number: print "Your guessed too low" elif guess &gt; the_number: print "Your guessed too high" elif tries &lt;= 3 and guess == the_number: print "\n\t\tCongratulations!" print "You only took",tries,"tries!" break else: print "\nYou guessed it! The number was", the_number,"\n" print "you took",tries,"tries!" break else: print "Sorry, only between number 1 to 10" else: print "Error,enter a numeric guess" print "Only between number 1 to 10" if tries == 3 and guess != the_number: print "\nYou didn't guess the number in 3 tries, but you still can continue" continue while tries &gt; 3 and guess != the_number: q = raw_input("\nGive up??\t(yes/no)") q = q.lower() if (q != "yes") and (q != "no"): print "Only yes or no" continue if q != "no": print "The number is", the_number valid = True break else: break </code></pre>
python
[7]
950,153
950,154
Easy: Addclass removeClass hasClass issue?
<p>I have some buttons in a container div that need to toggle active but only 1 active button at a time. </p> <p>EDIT:</p> <p>html is: div container of .filter(btn, btn, btn, etc) there are 3 containers of buttons. The third container has a button with an id of: #filter1-none</p> <p>The code below works to have only 1 button active per group. </p> <p>Additionally, how would I remove active only from the button with an ID of #filter1-none ONLY if any of the other buttons are active?</p> <pre><code>$('.filter .btn').click(function () { $(this).addClass('active').siblings('.active').removeClass('active'); }); </code></pre>
jquery
[5]
5,481,538
5,481,539
php increment numerical value variable by even or odd numbers
<p>Im iterating through two lists dumping data into their own single array, but i need to merge the 2 arrays in numerical order into a single array.</p> <p>Im using a counter (<code>foreach and $i++</code>) to name the keys in the proper order, but both operations leave me with arrays named with numbers 0-10.</p> <p>How can i make a counter that will increment by only even or only odd numbers so i can merge the two lists after the fact and retain a proper numerical order?</p> <p>ie, have the first loop name things 0-2-4-6-8-10, and the second loop count 1-3-5-7-9</p>
php
[2]
5,411,053
5,411,054
Voice Recognizer not present
<p>I try this code</p> <pre><code>PackageManager pm = getPackageManager(); List activities = pm.queryIntentActivities( new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0); if (activities.size() != 0) { speakButton.setOnClickListener(this); } else { speakButton.setEnabled(false); speakButton.setText("Recognizer not present"); } </code></pre> <p>But the result it's Recognizer not present should i add any software to actice this service??</p>
android
[4]
1,238,721
1,238,722
Selecting Edit on row returns wrong row after sorting
<p>I am currently setting my GridView AllowSorting = true. The sorting works fine, but when I click on the edit button for a specific row after sorting, the wrong row gets returned. It edits the row that was previously in the position of the current row before sorting.</p> <p>Here is my code in the Sorting event.</p> <pre><code>string sortExpression = e.SortExpression; string direction = string.Empty; if (SortDirection == SortDirection.Ascending) { SortDirection = SortDirection.Descending; direction = " DESC"; } else { SortDirection = SortDirection.Ascending; direction = " ASC"; } DataTable table = Session["WebUserDT"] as DataTable; table.DefaultView.Sort = sortExpression + direction; grdWebUser.DataSource = table; grdWebUser.DataBind(); </code></pre> <p>Any idea how to solve this? </p>
asp.net
[9]
3,161,731
3,161,732
When is a Custom Content Provider called for?
<p>I have seen custom content providers for sqLite in apps, but thats about it. When should a Custom Content provider be built?</p>
android
[4]
4,862,636
4,862,637
select div with class unless it has ancestor of another class
<p>Asked this question ten minutes ago, but realized that I used the term parent instead of ancestor. I'm looking for something that refers to a class that has a particular ancestor.</p> <p>How can I select all inputs that do not have an parent of a particular class?</p> <p>Here I just want to get the inputs that do not have a parent with the class not-parent</p> <pre><code>$(document).ready(function() { $("div:not(.not-ancestor) &gt; input[type='text']").css('color', '#FF1200'); });​ </code></pre> <p><a href="http://jsfiddle.net/MFtv3/3/" rel="nofollow">http://jsfiddle.net/MFtv3/3/</a></p> <p>Thanks!</p>
jquery
[5]
2,315,713
2,315,714
Using arrays in a class
<p>Why can I do:</p> <pre><code>public class ThisTest { int[] anArray = new int[10]; public int[] getArr(){ anArray[0] = 100; anArray[1] = 200; return anArray; } } </code></pre> <p>But not:</p> <pre><code>public class ThisTest { int[] anArray = new int[10]; anArray[0] = 100; anArray[1] = 200; } </code></pre>
java
[1]
4,060,815
4,060,816
how can i retrieve text from textview
<p>I have a text view with 3 lines of data.</p> <p>eg: abcde efghi jklmn</p> <p>Now i need to retrieve the middle line text(efghi).</p> <p>These 3 lines are unwrap text.</p> <p>How can i can any one please help me.</p> <p>Thank u in advance.</p>
iphone
[8]
1,613,419
1,613,420
jquery: if children with specific class?
<p>i wonder how i can determine if a ul has MORE than 2 children and if there are two children with two specific classes inside this ul …</p> <pre><code>if($(this).children().length &gt; 2 &amp;&amp; $(this).children('.section-title, .active')) { $(this).append('&lt;li class="dots"&gt;&amp;hellip;&lt;/li&gt;'); } </code></pre> <p>???</p>
jquery
[5]
3,874,055
3,874,056
Separate test cases across multiple files in google test
<p>I'm new in google test C++ framework. It's quite easy to use but I'm wondering how to separate the cases into multiple test files. What is the best way?</p> <p>Include the .cpp files directly is an option. Using a header seems that does nothing...</p> <p>Any help is welcome</p>
c++
[6]
4,227,353
4,227,354
Programmatically switch to developer mode in Android
<p>I want to create a tool that allows to switch to developer mode on Android devices with an Android version less than 4.2. I want to create an apk to activate and deactivate the developer mode. Is this possible? How?</p>
android
[4]
2,391,372
2,391,373
Tax form on iPhone Developer, non-us live in Us
<p>I am a International student studying in US. and I am not a US citizen. iTunes Connect assume me as a US citizen just because my address is in US. The only form I can chose is W9 form, which is only suitable for US citizen.</p> <p>Does anyone know how to solve it? I know W8-Ben form is the right form for me, but I have no idea how do I submit online to Apple. I try to select contact us and there is no email or phone information to ask. </p> <p>Thanks!</p>
iphone
[8]
3,702,495
3,702,496
Java Web Start Not Launching Problem
<p>I've just install New OS windows 7 64bit, After installed java. </p> <p>I couldn't launch any Java Web Start application from my browser (by downloading and launching a *.jnlp file). When I try to launch an app, the loading cursor spinning for 10-20 seconds then nothing happen. I am getting frustrated with this issue!</p> <p>Does any one know how can i fix it ?</p>
java
[1]
5,356,389
5,356,390
grep prefix python strings
<p>I'm having problems using findall in python. </p> <p>I have a text such as:</p> <p><code>the name of 33e4853h45y45 is one of the 33e445a64b65 and we want all the 33e5c44598e46 to be matched</code></p> <p>So i'm trying to find all occurrences of of those alphanumeric strings in the text. the thing is I know they all have the "33e" prefix.</p> <p>Right now, I have <code>strings = re.findall(r"(33e+)+", stdout_value)</code> but it doesn't work. I want to be able to return <code>33e445a64b65, 33e5c44598e46</code></p>
python
[7]
2,441,695
2,441,696
Return to my separated activity by launcher
<p>Apologize for my poor english first.</p> <p>I have an activity separated from my process which taskAffinity was set to ="", let us call it X, and the main activity is A.</p> <p>The question is, when I operate like this:</p> <p>1.A -> HOME -> (something triggered) -> show X</p> <p>If I finish X, it will return to HOME, thats what I want.</p> <p>But if I act like this:</p> <p>2.A -> (something triggered) -> show X -> HOME</p> <p>I want to return to X by clicking the apk icon, not to A.</p> <p>How to make it?_?</p> <p>If I didn't set X to be separate, it will return to A in case 1. If I set X taskAffinity="", then it won't return to X in case 2.</p> <p>anybody know what I am talking about >_&lt; ?</p>
android
[4]
3,503,455
3,503,456
Alphabetic scrolling like in Contact App
<p>Does anyone know where I can find the source on how to implement the alphabetic scroll bar exactly like the one in the ICS contacts app.</p> <p>I would like the same look and feel, i.e. the triangular shaped window. I have seen lots of similar examples but none of them look like Google's implementation.</p> <p>Thanks</p> <p>i.e. something like this: <a href="http://stackoverflow.com/questions/5122749/create-easy-alphabetical-scrolling-in-listview">Create easy alphabetical scrolling in ListView?</a></p> <p>But I would like Google's version.</p>
android
[4]
1,900,128
1,900,129
Shared information between some Android activities
<p>I am new in Android and I'm developing my first app. Right now I have been able to implement some activities that work on their own and share information through intents, bundles, etc.</p> <p>The problem is that a have a list that I manipulate in several activities and I don't want to pass it each time I change my activity. What I want is to have the same list for all the activities so if I change it in Activity1 I'm also changing it in Activity4. </p> <p>I don't know what would be the best approach to do this. Can anyone guide me a little bit? </p>
android
[4]
2,964,634
2,964,635
How to upload pdf file in asp.net
<p>When I upload pdf file using my asp.net web app, I get that is Error 101 (net::ERR_CONNECTION_RESET): Unknown error.</p>
asp.net
[9]
2,818,464
2,818,465
Python store client address?
<p>Below is my simple server code.</p> <p>I want to store/print the addresses of any client's sending data.</p> <p>For example the output should be:</p> <pre><code>Connection from ('127.0.0.1', 61334) foo from ('127.0.0.1', 61334) Connection from ('127.0.0.1', 61335) bar from ('127.0.0.1', 61335) baz from ('127.0.0.1', 61334) qux from ('127.0.0.1', 61335) </code></pre> <p>Someone told me to use dict but I don't know how?</p> <pre><code>import select import socket server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server_socket.bind(('', 8888)) server_socket.listen(5) print "Listening on port 8888" read_list = [server_socket] while True: readable, writable, errored = select.select(read_list, [], []) for s in readable: if s is server_socket: client_socket, address = server_socket.accept() read_list.append(client_socket) print "Connection from", address else: data = s.recv(1024) if data: s.send(data) else: s.close() read_list.remove(s) </code></pre>
python
[7]
3,912,931
3,912,932
How create class errors?
<p>I create service and I need create class MyErrors (not exception)</p> <p>My web method returned or data or error, example response "<code>#45#Not valid login or password.</code>"</p> <p><code>#</code> - is a flag that says an error has occurred <code>45</code> - code error.</p> <p>example use error class:</p> <pre><code>int returnValue = ExistLogin(login); if (returnValue==0) { return Registaration(login, name, password); } else if(returnValue==1) { return Errors.LOGIN_ALREADY_EXISTS.ToString(); } else return Errors.ConvertToString(returnValue); </code></pre> <p>Errors.LOGIN_ALREADY_EXISTS - return number <code>&lt;-1</code></p> <p>Errors.LOGIN_ALREADY_EXISTS - return string <code>#-1#Error bla bla bla</code></p> <p>how best to create a class?</p>
java
[1]
3,731,372
3,731,373
Connect GPS device to android app through bluetooth
<p>Im creating an application to read data from a bluetooth GPS receiver through bluetooth just Like GPSInfo android app. Im able to list the paired devices but while connecting to the device the application crashes.Can any one help with some code please.</p> <p>Thank you.</p>
android
[4]
3,918,589
3,918,590
how to use local variable in other functions
<p>This is my code:</p> <pre><code>var shuffle = function(x) { var deck = []; deck.push(x); return deck; }; var Placemat = function() { var card1 = deck.shift(); var card2 = deck.shift(); } </code></pre> <p>By returning deck in <code>shuffle()</code> like this, can I use it in <code>Placemat()</code>? If not, how can I do it?</p>
javascript
[3]
3,112,404
3,112,405
Sending Message From Android Emulator
<p>I am developing an android messaging application. I want to send sms to url from android emulator. Is it possible? Can anyone help me?</p> <p>Thanks in advance, Tushar</p>
android
[4]
4,362,140
4,362,141
AccountManager adds account but does not show up under Accounts in Settings
<p>I have created a custom account type by following the SimpleSyncAdapter example provided by android. I am able to add accounts with the Account Manager, and on some phones (tested on Galaxy S3, Galaxy Nexus, HTC Desire HD), I do see my account under Accounts and Sync in Settings. To add an account, I am doing the following:</p> <pre><code>boolean added = mAccountManager.addAccountExplicitly(account, password, null); </code></pre> <p>However, on the Galaxy Note 2 and the Motorola Xoom, even though this returns true, the account does not appear under Accounts and Sync.</p> <p>Has anyone seen this issue before?</p>
android
[4]
3,513,194
3,513,195
would it ever make sense to modify a reference to a const char* passed in as a parameter to a method?
<p>Say I have something along the lines of:</p> <pre><code>int main() { const char* someString = "Hello"; MyClass myClass; myClass.modifySomeString(someString); return 0; } </code></pre> <p>And two possible method signatures for <code>modifySomeString</code>:</p> <p><strong>case A</strong> <code>void MyClass::modifySomeString(const char* inBuffer)</code></p> <p>This seems straight-out pointless since I'd be getting a value so whatever I do with inBuffer does not affect the original someString in <code>main()</code>, right?</p> <p><strong>case B</strong> <code>void MyClass::modifySomeString(const char*&amp; inBuffer)</code></p> <p>Here, I have a reference to the pointer so potentially I could actually modify the original "string" in main() (and probably should call the parameter inOutBuffer for clarity...). But besides the fact that I could cast to remove the const and modify the actual parameter inside my method... wouldn't this be just a bad thing to do? </p> <p>I mean:</p> <ol> <li>someString was declared const in main to start with, so trying to pass it to a method for it to modify it is nonsensical</li> <li>inside the method, if I'm stating the parameter is const too, again it just seems wrong to then try and go around its const to modify it affecting someString in main.</li> </ol> <p>Am I right about my observations on both cases A and B? Or is there a reason where it might be reasonable to pass a const string to a method and expect the method to still modify the original?</p> <p>Personally, I think if I'm passing a const to the method, the method should instead have an out parameter where I get a new string without changing the original one. Something like:</p> <pre><code>void MyClass::modifySomeString(const char* inBuffer, char*&amp; outBuffer) </code></pre> <p>But I'm interested in suggestions or someone explaining why it's perfectly fine to modify the const parameter.</p>
c++
[6]
90,922
90,923
jquery how can i collect matching elements?
<p>if any one give me a suggession to collect matching elements using each?</p> <p>this is i tried:</p> <pre><code>&lt;ul&gt; &lt;li class='options'&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li class='options'&gt;&lt;/li&gt; &lt;li&gt;&lt;/li&gt; &lt;li class='options'&gt;&lt;/li&gt; &lt;li class='options'&gt;&lt;/li&gt; &lt;/ul&gt;​ var x = $(); x = (function(){ $.each($('li.options','ul'), function(i,e){ return e; }) })() console.log(x)//i am getting undefined. </code></pre> <p><a href="http://jsfiddle.net/scDhx/" rel="nofollow">here is the jsfiddle</a></p> <p>how can i collect the matching elements?</p>
jquery
[5]
2,413,364
2,413,365
C# Windows Services Alternative
<p>Could anyone please tell me whether there is any alternative to Windows Services? The reason for my question is that I find windows services hard to test as it requires it be installed first.</p> <p>Thank you.</p>
c#
[0]
484,497
484,498
PHP If statements not working
<p>This is my code: </p> <pre><code> if ($username == "" || $pass == "" || $emailad==""|| $fname=="") { $msg = "Not all fields were entered"; }else { if(uniqueUser($username,$emailad)) { $msg="The username or email already exists"; }else { insertIntoDB($fname,$emailad,$username,$pass); $msg="The user has been inserted"; } } echo $msg; </code></pre> <p>this will be used to insert a new user into my db. However my problem is if I am to add a non existing user into it, the program will tell me that the username already exists BUT it will insert the new account if its not in the database. Therefore the program works fine in terms of insertion depending upon if the user exists in the database or not. The problem is the message display for me because I will never know if the user is already in the database or not since no matter how I rewrite this piece of code, a non existent user insertion will result in the wrong message being displayed. This is because the code will run the if statements, insert the new user....and run again displaying the message that it already exists. Could anybody explain why this happens?</p> <p>Unique user function:</p> <pre><code>function uniqueUser($usern,$eml) { $query = "SELECT S.username,S.email FROM tbl_user S WHERE S.username='$usern' OR S.email='$eml'"; return mysql_num_rows(queryMysql($query)); } </code></pre>
php
[2]
5,131,805
5,131,806
Adding + and - sign while show/hide div
<p>I use the following jQuery to show/hide a div. I need to add a '+' and '-' symbol to it. Someone please tell me how to add it</p> <pre><code>function toggleWidgets() { $('#secondary h3.widget-title').addClass('plus'); $('#secondary h3.widget-title').click(function() { $(this).toggleClass('plus').toggleClass('minus').next().toggle(180); }); } $(document).ready(function() { toggleWidgets(); }); </code></pre> <p>Here is the HTML</p> <pre><code>&lt;div id="secondary" class="widget-area" role="complementary"&gt; &lt;aside id="welt_last_tweets-2" class="widget widget_welt_last_tweets"&gt; &lt;h3 class="widget-title"&gt;&lt;/h3&gt; &lt;div id="welt-welt_last_tweets-2" class="welt-tweet-wrapper"&gt; &lt;/div&gt; &lt;/aside&gt; &lt;/div&gt; </code></pre>
jquery
[5]
2,696,170
2,696,171
How to pass argument in function?
<p>i have function like this.</p> <pre><code>function load($name, $arg1, $arg2, $arg3, $arg4){ $this-&gt;$name = new $name($arg1, $arg2, $arg3, $arg4); } </code></pre> <p>the <code>load()</code> method will load some class and set it as class <code>property</code> and the infinite arguments, depend in the class they assigned.</p> <p>another example if i only set method <code>$this-&gt;load</code> with 3 argument, the this what will happen in the process</p> <pre><code>function load($name, $arg1, $arg2){ $this-&gt;$name = new $name($arg1, $arg2); } </code></pre> <p>it is possible do something like that?</p>
php
[2]
1,799,826
1,799,827
Impersonation using absolute path
<p>I am trying to access a file using impersonation. Everything works fine when the file folder is shared. However when the folder is not shared and try to access the file using absolute path, it does not work. </p> <p>It works: \\folder\test.txt</p> <p>It does not work: \\nt9999\d$\folder\test.txt</p> <p>Thanks for your help.</p>
c#
[0]
796,299
796,300
Read SHOUTcast's 7.html with Java
<p>Alright, I'm at my wit's end. I've been trying for ~hours~ to read the following url in to a Java string and I can't for the life of me do it. I've tried about a bajillion different methods (that all work for other web pages!) I've found online and I'm about to lose my mind! Please help me get the contents of this web page in to a Java string~ :(</p> <p><a href="http://molestia.ponify.me:8062/7.html" rel="nofollow">http://molestia.ponify.me:8062/7.html</a></p> <p><strong>ANSWER:</strong></p> <pre><code>URL url = new URL("http://molestia.ponify.me:8062/7.html"); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0"); // This bugger right here saved the day! Reader r = new InputStreamReader(con.getInputStream()); StringBuilder buf = new StringBuilder(); while (true) { int ch = r.read(); if (ch &lt; 0) break; buf.append((char) ch); } String str = buf.toString(); Log.d("HTML", str); </code></pre>
java
[1]
5,560,437
5,560,438
how to start android application from my application but the application should not be visible to others
<p>supposing that i have created an application "MyApp" and it contains a button.When this button is clicked it should start another application say"App".this application "App" should not be available in any other part of the phone. please help me with this. thank you.</p>
android
[4]
5,701,326
5,701,327
jQuery function on $('p')[0]
<p>I tried the script</p> <pre><code>$('p')[0].innerHTML = 'hi'; </code></pre> <p>and it worked<br> but for slideUp/Down it does not works :(</p>
jquery
[5]
5,389,962
5,389,963
Need help using UIImagePNGRepresentation
<p>I'm trying to save a UIImageView image to a png file, and then use that file as a GLTexture. I'm having trouble with this, when I try to run my code in the simulator, XCode says it succeeded, but the simulator crashes with no error messages. Can someone help me with this? Here is my code:</p> <pre><code>NSString *dataFilePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Picture.png"]; NSData *imageData = UIImagePNGRepresentation(imageView.image); [imageData writeToFile:dataFilePath atomically:YES]; // Load image into texture loadTexture("Picture.png", &amp;Input, &amp;renderer); </code></pre>
iphone
[8]
878,426
878,427
c# game have multiple icons resolution?
<p>How can I make my games developed in c# having multiple icons? (same picture with different resolutions), so, after installing it, and going to start-->games, and change your view, the resolution will be adapted to the right size. Thx in advanced</p>
c#
[0]
1,960,962
1,960,963
How can i set different action commands while implementing an action listener?
<pre><code>import javax.swing.*; import java.awt.*; import java.awt.event.*; class Menu extends JFrame implements ActionListener{ // Create the components and global variables JButton newGameButton = new JButton("New Game"); JButton instructionGameButton = new JButton("Instructions"); JButton exitButton = new JButton("Exit"); JLabel mylabel = new JLabel("Welcome to Blackjack"); public Menu() { // Create the window super("ThreeButtons"); setSize(300,100); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); //Creating the container for the components and set the layout Container content = getContentPane(); FlowLayout layout = new FlowLayout(); content.setLayout(layout); //Adding the event listener newGameButton.addActionListener(this); instructionGameButton.addActionListener(this); exitButton.addActionListener(this); //Adding of components content.add(mylabel); content.add(newGameButton); content.add(instructionGameButton); content.add(exitButton); setContentPane(content); } //Add the event handler public void actionPerformed(ActionEvent event) { if (event.getActionCommand()=="New Game") new lol4(); if (event.getActionCommand()=="Instructions") //new Instructions(); if (event.getActionCommand()=="Quit ?") System.exit(0); } public static void main (String[] args) { //Create an instance of my class new Menu(); } } </code></pre> <p>Exit does not seem to work</p>
java
[1]
2,705,873
2,705,874
jQuery: Input value lost on keyup?
<p>I have a simple form which I would like to submit (i.e fire ajax) when the user presses enter (return) on an input field. If I press the submit button the event fires fine, but when using keyup to fire the exact same function the value of the input field is blank. I tried passing the value of the input field (from the keyup function) using <strong>$(this).val()</strong>, but the passed param was still blank. </p> <p><strong>Update II:</strong> The problem only occours on initial load. After hitting refresh the events fire as intended. Tested in Chrome and FF.</p> <p><a href="http://jsfiddle.net/R5QsC/1/" rel="nofollow">http://jsfiddle.net/R5QsC/1/</a></p> <pre><code>// Value of #pin is blank in getKeyAjax() $('#pin').keyup(function(e) { if (e.keyCode == 13) { console.log('DEBUG: Keypress detected (13)') getKeyAjax(); } }); // Value of #pin is correct in getKeyAjax() $('#btnPwdCreate').click(function() { getKeyAjax(); }); function getKeyAjax() { console.log('DEBUG: Starting ... getKeyAjax()'); var txtPin = $('#pin').val(); console.log('DEBUG: Value of txtPin: ' + txtPin); . . . } </code></pre>
jquery
[5]
4,961,392
4,961,393
good C# interview questions book
<p>Please suggest me a good C# interview questions book</p>
c#
[0]
4,316,289
4,316,290
take path of script as an argument python
<p>I have this python script which sits in </p> <pre class="lang-none prettyprint-override"><code>/some/folder/foo.py </code></pre> <p>So if I am in <code>/some/folder</code> and do </p> <pre><code>python foo.py </code></pre> <p>the script runs great. Now I want to take this path <code>/some/folder</code> as an argument, so that I can run this script when in different folder.</p> <p>something like if I am in <code>/a/different/folder</code> and from this folder I want to execute </p> <pre><code>foo.py </code></pre> <p>How do i do this? Thanks</p>
python
[7]
1,712,384
1,712,385
ADB needs reset always
<p>Whenever I run my emulator for the first time, it shows up but doesnt start my app and I find no device in DDMS view UNTIL I reset the ADB. It happens always FOR THE FIRST TIME. But after I reset the ADB it works from then on.</p>
android
[4]
1,516,632
1,516,633
What is a more efficient way in Python to return list elements which are not in a second list?
<p>Is there a faster way to do this in python?</p> <pre><code>[f for f in list_1 if not f in list_2] </code></pre> <p>list_1 and list_2 both consist of about 120.000 strings. It takes about 4 minutes to generate the new list.</p>
python
[7]
1,294,326
1,294,327
how to concisely create a temporary file that is a copy of another file in python
<p>I know that it is possible to create a temporary file, and write the data of the file I wish to copy to it. I was just wondering if there was a function like:</p> <pre><code>create_temporary_copy(file_path) </code></pre>
python
[7]
930,340
930,341
How can I cache a dynamic page to a flat file in PHP?
<p>I am trying to roll a caching system to reduce the load on the database.</p> <p>I want to be able to compare timestamps of the last updated time the flat file was updated to make sure it's not too long ago that the file was last updated.</p> <p>Here's the code: <pre><code>$cache_file = $_GET[ 'page_id' ] . '.html'; function cache() { // Here i want to get the timestamp of the file that was previously cached, // if it exists. // If the file doesn't exist, create it. // If it does exist, check last modified time, if it's too long ago, then overwrite // the file. $ob = ob_get_contents(); file_put_contents( $cache_file, $ob ); } function loadFromCache( $page_id ) { $file_name = $page_id . '.html'; if( ! file_exists( $file_name ) ) { return false; } readfile( $file_name ); return true; } </code></pre> <p>Thank you.</p>
php
[2]
1,289,269
1,289,270
Python - Extract multiple lists from a list of lists by index
<p>Is there an efficient way to loop through a list of lists and extract the 1st element of each list into another list, 2nd elements into another one, etc. Such as:</p> <pre><code>x = [[1, 2, 3], [4, 5, 6] , [7, 8, 9]] y1 = [i[0] for i in x] y2 = [i[1] for i in x] </code></pre> <p>Is there a way to extract y1 and y2 in a single list comprehension?</p>
python
[7]
1,906,301
1,906,302
Unable to GET data from ajax (get)
<p>I have a little problem with my code ...</p> <p>I have a page named "listeclients.php" which have several clients with id's etc. I just made a little button in order to send some data to a page named "actionclient.php", which just has to display the parameters I send to it. The actionclient.php consists in this :</p> <pre><code>&lt;?php echo "test = "; echo $_GET['test']; echo $_GET['test2']; ?&gt; </code></pre> <p>(It's just a test page).</p> <p>And here's my jQuery script :</p> <pre><code>$( "div.modif_dialog").click(function(e4) { $( "#editer" ).dialog("open"); var monUrl4 = 'actionclient.php?action=modifier&amp;id='; var url_final4 = monUrl4+pos4; $.ajax({ type: "GET", url: url_final4, data: { test: "TEST", test2: pos4}, success: function(){ alert (pos4); } }); $('#editer').load(monUrl4, function(response4, status4) { $('#test_dialog2').html(response4); }); e4.preventDefault(); }); </code></pre> <p>My alert with alert(pos4) works great, and the variables are all correct.</p> <p>The actionclient.php (url_final4) is well loaded in my dialogbox, but it always just print : "test = "</p> <p>Any clue ? (I did exactly the same code with a POST method in an another page and it works great... I don't understand.)</p> <p>Thanks !</p>
jquery
[5]
67,008
67,009
Place view to right of other view and vertically centered relatively to this view using RelativeLayout
<p>I was wondering if there is a way for placing a view to the right side of another view and centering it vertically on the second views height. In know this can be done using a LinearLayout, but for other reasons the 2 views must be part of the same RelativeLayout. </p> <p>Thanks a lot</p>
android
[4]
3,007,938
3,007,939
Jquery drag drop bug in IE9
<p>I’m working on a JQuery "Nettuts drag and drop" from <a href="http://nettuts.s3.amazonaws.com/127_iNETTUTS/demo/index.html" rel="nofollow">iNETTUTS demo</a>.</p> <p>Which I have downloaded from <a href="http://www.1stwebdesigner.com/freebies/drag-drop-jquery-plugins/" rel="nofollow">webdesigner.com</a>.</p> <p>The demo works excellently in all the browsers except IE9. If anyone has a solution, I would appreciate it. Thanks in advance.</p>
jquery
[5]
54,195
54,196
Is there any alternative of window.showModalDialog & window.open
<p>I want to use popup window in my Project with customize flavor like address bar don't display return value, customize close button finally it will be look like :</p> <p><img src="http://i.stack.imgur.com/eepNH.jpg" alt="enter image description here"></p>
javascript
[3]
222,927
222,928
How to launch two java program in the same time through another one?
<p>i'm a beginner and i try to code very simple java programs and here i have two java programs.</p> <p>the first program for selecting recent files from a folder.</p> <p>the second program for concatenating these recents files.</p> <p>what i want is to create a third java program that -will launch the first program. -then wait for 10s -launch the second java program.</p> <p>i want to keep separately the first and second program.</p> <p>because i want to use them for a further application.</p> <p>is it that possible? Do i have to use Process method like if i want to launch notepad.exe through java? or else?</p> <p>Thank you</p>
java
[1]
2,885,285
2,885,286
How to develop an iPhone application
<p>I want to develop an ebook application for iPhone. I'm new to iPhone developement, so don't have much idea about how to proceed. What I know is, I need the following:-</p> <ul> <li>iPhone SDK</li> <li>Intel Mac running mac OS X</li> <li>Xcode (?)</li> </ul> <p>Please indicate is that correct and how I can proceed to build an ebook application. Thanks.</p>
iphone
[8]
3,097,673
3,097,674
Calling webservice from javascript on android
<p>How to call a webservice from javascript on android? </p> <p>My html file is in <code>assest/www</code> folder.</p>
android
[4]
4,918,645
4,918,646
Adding a library/JAR to an Eclipse Android project
<p>This is a two-part question about adding a third-party library (JAR) to an Android project in Eclipse.</p> <p>The first part of the question is, when I try to add a third-party JAR (library) to my Android project I first get the problem of</p> <blockquote> <p>Error parsing XML: unbound prefix</p> </blockquote> <p>because I'm trying to use a class from that JAR (and need the prefix somehow defined). What's going on?</p> <p>Second, (after fixing that--the answer is given below), my application doesn't work on Android and I discover via the debugger (LogCat) that the class I'm attempting to consume doesn't exist.</p> <blockquote> <p>Caused by: java.lang.ClassNotFoundException: com.github.droidfu.widgets.WebImageView...</p> </blockquote> <p>Why, when I get no compilation or linker error in Eclipse, does it have this problem on the emulator?</p> <p>These two questions are rhetorical for I'm going to answer them myself below. Other posts in this forum creep up to the problem and elsewhere there is discussion, but I feel that I can be more explicitly helpful for the next guy to come along.</p>
android
[4]
2,868,489
2,868,490
how do I load a file into the python console?
<p>I have some lines of python code that I'm continuously copying/pasting into the python console. Is there a 'load' command or something I can run? e.g. "load file.py"</p>
python
[7]
4,399,420
4,399,421
Store information about a directory
<p>Other than the foldername, is there a way to get/set information about a directory to the actual folder itself? </p> <p>I want to set a directory priority so folders are displayed in a certain order by assigning a number to each. </p>
php
[2]
3,958,394
3,958,395
How to search & replace in Python?
<p>How can I add a character "-" to a string such as 'ABC-D1234', so it becomes 'ABC-D-1234'? Also, how can I add a character after the first 2 number, ie from 'ABC-D1234' to 'ABC-D12-34' Many thanks.</p>
python
[7]
1,939,307
1,939,308
How to get attribute from a <link tag in pure javascript?
<pre><code>&lt;link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.blogger.com/rsd.g?blogID=7487871339000666216" /&gt; </code></pre> <p>How can I get the href attribute of this link tag without using any javascript library?</p> <p>Right now I'm using the code below to achieve this but I want to know whether there is a simpler solution.</p> <pre><code>var links = document.getElementsByTagName("link"); for (i in links){ var title = links[i].getAttribute("title"); if ( title == "RSD"){ var href = links[i].getAttribute("href"); break; } } </code></pre>
javascript
[3]
448,959
448,960
Now I have duplicate emails lists name
<p>I have a TXT file with a list of emails Now I have duplicate emails lists name Example:</p> <pre><code>[email protected] [email protected] [email protected] [email protected] [email protected] </code></pre> <p>I want to show me only once every mail</p> <p>And the result:</p> <pre><code>[email protected] [email protected] [email protected] </code></pre> <p>This code that I would love to get help:</p> <pre><code>&lt;? Php $ Username = $ argv [1]; $ File = file_get_contents (". / Emailist.txt"); $ Ex = explode ("\ r \ n", $ file); for ($ i = 0; $ i &lt;count ($ ex); $ i + +) { echo $ ex [$ i]; } ?&gt; </code></pre> <p>tanks1</p>
php
[2]
746,434
746,435
Why does Java not permit the use of headers as in C++
<p>I have a question that I did not find an answer for except the following answer that does not meet my requirements:</p> <blockquote> <p>"Because James Gosling didn't want to"</p> </blockquote> <p>I know that Java can have interfaces (only pure virtual functions, no attributes), but it is not the exact same thing as class definitions.</p>
java
[1]
3,911,958
3,911,959
implementing an SDK on android
<p>I have some kind of voice related algorithm and I want android apps to be able to use it. I want multiple apps to be able to use it at the same time (it doesn't have to support multiple clients calling at once, but it does have to support multiple clients loading the library). What is the best way to implement it? I read a little about bound services but I am not sure it fits. I can't extend the Binder class since I need multiple app support, and I don't want to use a Messenger since it only provides asynchronous access and I need synchronous access (I want to return an object from the call). One other thing I don't understand is how to deliver my SDK. Should it be a library? an application?</p> <p>Thanks.</p>
android
[4]
500,005
500,006
Sending SMS using free gateway
<p>I just wanted to develop one web application which allows users to send an SMS to any mobile free of charge . I searched on the net and found many codes and articles and through those articles i came to know that for that kind of application, i required either of the following things:</p> <ol> <li>Web service (Third party web services that are free but not working or not delivering the sms)</li> <li>GSM Modem ( I don't have any idea about this)</li> <li>SMS Gateway ( I don't have any idea about plz suggest me a idea</li> </ol>
c#
[0]
3,980,787
3,980,788
need to extend two classes somehow
<p>I am creating an app which has a dashboard layout as its home screen and each icon opens a seperate activity.</p> <p>I have an abstract class called DashboardActivity which has methoda such as what to do when the home button in the title bar is pressed etc. </p> <p>I then have various classes such as 'hotels' which will display a list of hotels. This class extends DashboardActivity but I also need it to extend ListActivity because it will be a list but I know that this can't be done.</p> <p>What workaround can I use to overcome this problem? Thanks</p>
android
[4]
5,606,519
5,606,520
Copy data from an SD card to a raw file
<p>How might I copy data from an SD card to a raw file?</p>
android
[4]
4,632,167
4,632,168
No resource found that matches given name in main.xml
<p>This is really starting to drive me crazy.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id+/textview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="@string/hello"/&gt; </code></pre> <p>Produces the following error message: "<code>Error: no resource found that matches the given name (at 'id' with value '@id+/textview')</code>.</p> <p>This is copy and pasted from the Android hello world <a href="http://developer.android.com/resources/tutorials/hello-world.html" rel="nofollow">example</a>.</p>
android
[4]
184,683
184,684
Is it possible to use an ArrayAdapter (no subclassing) with a custom View to display data?
<p>Often, a simple of ArrayAdapter does what I want and during early development I will provide the android.R.simple_list_item_1 for the view id required by the ArrayAdapter constructor. Is it possible to provide a customized view which is based on the android.R.simple_list_item_1 to the ArrayAdapter constructor?</p> <p>I do not fully understand Android's 'include' functionality, but what I would like to do is something like:</p> <ul> <li>Define a new TextView based on customizing the android.R.simple_list_item_1. (I have no idea what the valid syntax would be)</li> </ul> <p>e.g.</p> <pre><code>&lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/MyTextView" android:textSize="20dip"&gt; &lt;include android.R.simple_list_item_1/&gt; &lt;/TextView&gt; </code></pre> <ul> <li><p>Reference my customized TextView. I assume that something like this would go into my layout directory. Then in my code I would do something like:</p> <pre><code>LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.id.MyTextView, null); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, view.getId(), myArrayOfData); </code></pre></li> </ul> <p>Is this possible and if it is, what is the appropriate syntax to accomplish what I want?</p>
android
[4]
4,490,100
4,490,101
Positing user current location
<p>first i would love to thank you for help me,i am develop the android application that contain 3 activities one of them is map.i am using google maps</p> <p>what i want : 1- when the user open the activity (map) it shows the user her location not the coordinate 2- the user also can be able to positing(pining) any place by using pin and my app must store the coordinates for this pin in variable so i can use it later. PlEASE HELP ME</p>
android
[4]
3,431,431
3,431,432
C++ exceptions catch clause
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1654150/scope-of-exception-object-in-c">Scope of exception object in C++</a> </p> </blockquote> <p>I have the following catch clauses:</p> <pre><code>catch(Widget w); catch(Widget&amp; w); void passAndThrowWidget() { Widget localWidget; throw localWidget; } </code></pre> <p>If we catch Widget object by value, compiler will make copy so when we throw exception, localWidget goes out of scope, and we don't see any issues.</p> <p>If we catch widget object byreference, according to reference concept, "w" points to same local Widget instead of copy. But i have seen most of the exceptions are caught by references in C++. My question how this works as "localWidget" goes out of scope when exception is thrown and catch by referense points to object which is destroyed.</p> <p>Thanks!</p>
c++
[6]
1,983,869
1,983,870
Autorelease and release function
<p>what's the difference beetween Autorelease and release function. ??can u give me example of autorelease function.</p>
iphone
[8]
60,181
60,182
Integrate auriotouch
<p>I need to integrate <code>aurioTouch</code> in another app. I have put all of his classes in my app, I have also changed is <code>didFinishLaunching</code> function to a normal void function, and removed <code>UIApplicationDelegate</code> tag from the header file. In my app, I put this code:</p> <pre><code>aurioTouchAppDelegate *soundRecord = (aurioTouchAppDelegate *)[[UIApplication sharedApplication] delegate]; [soundRecord startRecord]; </code></pre> <p>I have also change the file in my app where this code is, to a mm file.</p> <p>When I run this, I get this error:</p> <pre><code>2011-06-27 12:57:20.269 HomeSense[14996:40b] -[HomeSenseAppDelegate startRecord]: unrecognized selector sent to instance 0x5846a30 2011-06-27 12:57:20.271 HomeSense[14996:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[HomeSenseAppDelegate startRecord]: unrecognized selector sent to instance 0x5846a30' </code></pre>
iphone
[8]
2,408,447
2,408,448
setup two php versions in a one machine
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://serverfault.com/questions/103798/linux-one-apache-two-php-versions-possible">linux: one apache two php versions. possible?!</a> </p> </blockquote> <p>I was asked in an interview.</p> <p>How can we set up two different php version ex:php v 5.0 and php v 5.3 in a single machine?</p> <p>Is it possible to do it with apache?</p> <p>Thank</p>
php
[2]
1,125,688
1,125,689
jQuery load doesn't work as I expected
<pre><code>$(".content") .load("content/intro.html #bt") .hide() .fadeIn(2000) .delay(2000) .fadeOut(2000) .load("content/intro.html #ofm") .fadeIn(2000) .fadeOut(2000) .load("content/main.html") .fadeIn(800); </code></pre> <p>I would expect that jQuery first load content (<code>intro.html #bt</code> etc.) but it will actually load <code>main.html</code> and than will do everything other on the list. In this case three times fade in an out. What is workaround? </p>
jquery
[5]
1,393,110
1,393,111
Error in PHP file uploader
<p>Now, i am getting another problem.... i am trying to upload file with this code :-</p> <pre><code>&lt;form action="up.php" method="post"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="200000" /&gt; Choose a file to upload: &lt;input name="uploadedfile" type="file" /&gt;&lt;br /&gt; &lt;input type="submit" name="submit" value="Upload!"/&gt; &lt;/form&gt; </code></pre> <p>Here is the up.php:-</p> <pre><code>if(!isset($_FILES["uploadedfile"])) die("Hacking attempt"); </code></pre> <p>In the above code, it says Hacking attempt... why isnt it having the file??</p>
php
[2]
5,544,840
5,544,841
How to handle back navigation on notification - android
<p>I have a notification list on my application.when i click one notification item it will move to some page.when i click back button on emulator.,my application will be crashed.How to recover this probs.</p>
android
[4]
1,129,596
1,129,597
Regular Expression: Not all matches are printed when using System.out.println(m.matches());
<p>I execute the following code:</p> <pre><code>public static void test() { Pattern p = Pattern.compile("BIP[0-9]{4}E"); Matcher m = p.matcher("BIP1111EgjgjgjhgjhgjgjgjgjhgjBIP1234EfghfhfghfghfghBIP5555E"); System.out.println(m.matches()); while(m.find()) { System.out.println(m.group()); } </code></pre> <p>}</p> <p>What i cannot explain is when the code is executed with <strong>System.out.println(m.matches());</strong> the matches printed are: <strong>BIP1234E</strong> and <strong>BIP5555E</strong>. but when <strong>System.out.println(m.matches());</strong> is removed from code the matche <strong>BIP1111E</strong> is also printed.</p> <p>Can someone please explain how that's possible ? Thnx a lot for your help.</p>
java
[1]
2,396,031
2,396,032
Make a read only property writable in the derived class
<p>What I want to achieve is the following : I have a property declared in the BaseClass. If this property is accessed via the base class' pointer, only the getter should be available but if the derived class pointer is used I want to be able to get and set the property. So the intellisense should not even show a setter for the base pointer.</p> <pre><code>public class BaseClass { public virtual int MyProperty { get { return 1; } set {;}//This would show the setter in Intellisense } } public class DerivedClass : BaseClass { int intValue; public override int MyProperty { set { intValue = value;} } } </code></pre> <p><strong>A realistic example</strong>:<br> Consider a situation where you have a Parent and Child class derived from the Person class. Imagine a property -RestrictionLevel, where both can read it but only the parent can set the value. Is there a better way to design this situation?</p>
c#
[0]
3,538,759
3,538,760
How to add data/functions to all instances of a javascript object created by a constructor?
<p>How can I add data/functions to all instances of a javascript object created by a constructor so that all instances have the same reference and not a copy of it?</p> <p>Basically implementing the equivalent of a static method in C#.</p> <p>For example, given the following code which creates a Widget class.</p> <pre><code>(function() { var Widget = function() { }; Widget.prototype.init = function(data) { this.data = data; }; this.Widget = Widget; }).call(this); var instance1 = new Widget(); instance1.init('inst1'); var instance2 = new Widget(); instance2.init('inst2'); alert(instance1.data); // inst1 alert(instance2.data); // inst2 </code></pre> <p>In the above case each instance has it's own copy of the data property. However I want to add a function that sets data for all current and future instances.</p> <p>My current solution is to add a function to the constructor function object, not to it's prototype. See below for example. Is there any pitfalls to this and is there a better way?</p> <pre><code>(function() { var Widget = function() { }; Widget.prototype.init = function(data) { this.data = data; }; Widget.addStaticData = function(data) { this.staticData = data; }; Widget.prototype.getStaticData = function() { return Widget.staticData; }; this.Widget = Widget; }).call(this); var instance1 = new Widget(); instance1.init('inst1'); Widget.addStaticData('static'); var instance2 = new Widget(); instance2.init('inst2'); alert(instance1.data); // inst1 alert(instance2.data); // inst2 alert(instance1.getStaticData()); // static alert(instance2.getStaticData()); // static </code></pre>
javascript
[3]
5,175,105
5,175,106
multiple json objects in jquery $.post
<p>I wanted to know if it was possible to send multiple json objects to a php file in jquery, kind of like this:</p> <pre><code>$.post('convert.php', [{name: 'John', font: 'arial', size: '12'},{name: 'Smith', font: 'verdana', size: '14'}]); </code></pre>
jquery
[5]
4,545,243
4,545,244
How to stop the notification Audio?
<p>Iam doing one application in that i used the notification and assign the sound name.And my requirment is when the notification occur i touch the screen and stop the notification sound.SO for this how to develope the code.please guide me .</p>
iphone
[8]
1,780,985
1,780,986
java.io.IOException: error=2, No such file or directory
<p>I am trying to run a java program from another java program using Runtime.getrunTime().exec</p> <p>Code :</p> <pre><code>String java_home = System.getenv("JAVA_HOME"); String[] command = {""+java_home+"/bin/java -cp -cp /sc/sug/p-lib/* Tdesigner -cd /pr -in ing.rsp -out /scratch/sug/ng.pla -ad -stopO "}; try { proc = Runtime.getRuntime().exec(command); proc.waitFor(); int exitCode = proc.exitValue(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } </code></pre> <p>It gives me following error:</p> <pre><code> java.io.IOException: Cannot run program "/net/sl/sc/jdk6/bin/java -cp /sc/sug/p-lib/* Tdesigner -cd /pr -in ing.rsp -out /scratch/sug/ng.pla -ad -stopOnError ": java.io.IOException: error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:460) at java.lang.Runtime.exec(Runtime.java:593) at java.lang.Runtime.exec(Runtime.java:466) </code></pre> <p>Can anyone help me to solve the issue. is it that i need to add individual jar files with -cp rather than setting the directory.</p>
java
[1]
3,126,829
3,126,830
How do String objects work (like immutable objects)?
<p>I have these two situations:</p> <pre><code>String s = "aa"; s = s + " aa"; System.out.println(s); //...... </code></pre> <p>that work fine! It prints <b>aa aa</b>. But there is a problem:</p> <pre><code>String s = "aa"; this.addStringToStatement(s, " aa"); System.out.println(s); //... private void addStringToStatement(String statement, Object value) { statement += value; } </code></pre> <p>It prints: <b>aa</b>. What is the reason?? Thanks!</p>
java
[1]
5,892,429
5,892,430
Calendar Month and Displaying 4th Day in Red in PHP (Loop, Date, HTML Display Font Red)
<p>I'm trying to do a simple loop of the days in the month of that year. So I'm using a for loop in PHP. I assigned a date April 2013, $date = mktime(0, 0, 0, 4, 1, 2013). I also determined the numbers of days in that month, $days = date("t", $date). And then I did the loop using for loop so that for ($i = 1; $i &lt;= $d1; $i++) it'll display all the days in the month of April 2013, which is 30 days (output: 1, 2, 3, <strong>4</strong>, 5....30). I'd like to display this in HTML so that it'll look like a calendar month of April 2013 (which I can figure out later). However, I think I have this "writer's block" per se (or programming block so on). I want to display the so that when $i = 4, displays separately with a red color indicating that it is a special day. This is my main thing I'm stuck with. My code is as follows:</p> <pre><code>$date = mktime(0, 0, 0, 4, 1, 2013); $days = date("t", $date); for ($i = 1; $i &lt;= $days; $i++) { echo $i; } // except when $i = 4, echoes it as red/bold </code></pre> <p>Any ideas? Thanks in advance.</p>
php
[2]
3,258,831
3,258,832
How to preserve the last appliaction state in android when returning back from the Web Browser in android
<p>I am stuck with severe issue, I have an develop application in which iam redirect to the MAP browser showing the Route between Two cities , now when i press the back button on the Device my previous data are lost and i get unusual result.</p> <p>How to solve the application preserving previous state</p>
android
[4]
294,826
294,827
Scaling android app to different screen sizes
<p>So I'm working on scaling my application to different screen sizes. Right now Its optimized for a 10.1 inch screen but I'm working to get it to run on the kindle fire which has a 7 inch screen. I'm only using relative layouts. As of now my background scales perfectly but the image buttons ontop of the background don't scale and I was wondering if there was a reason for this. Also I use margins to adjust the positions of my buttons, is this okay for scaling sizes?</p>
android
[4]
5,151,614
5,151,615
Record audio in Android
<p>How to put on pause? I have not found such a function. There are other ways?</p>
android
[4]
820,196
820,197
overwrite java class in jar
<p>I have class called org.jbpm.task.Comment in my jbpm.jar.</p> <p>However, this it's a CR1 version and there is a bug in the class that I would like my application to overwrite.</p> <p>Is it fine just to have a class in my project under com.jbpm.task called Comment and everywhere even in other jars it will refer to mine?</p>
java
[1]
1,249,813
1,249,814
Java test specific property of an object using Collection.contains()
<p>In Java how to test if a Collection of objects contains an object depending on one of its properties.</p> <p>For example I would like to test if <code>Collection&lt;myObjects&gt;</code> contains an instance of myObjects which has myObjects.name = "myName".</p>
java
[1]
2,691,682
2,691,683
How to execute commands using java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4916918/java-execute-a-command-with-a-space-in-the-pathname">Java execute a command with a space in the pathname</a> </p> </blockquote> <p>I am having following command </p> <p><code>i_view32.exe C:\*.bmp /import_pal=C:\default.pal /convert=D:\temp\*.bmp</code> Which when i run through command prompt works fine. I am trying to run the same command with the help of java.</p> <pre><code> Process p = Runtime.getRuntime().exec(System.getenv("ProgramFiles")+"\\IrfanView\\i_view32.exe c:\\*.bmp /import_pal= 1.pal /convert=d:\\temp\\*.bmp"); </code></pre> <p>But i am not able to get Output in <code>d:\\temp\\</code> Folder. Can any one suggest me where i am wrong.</p> <p>Thanks in Advance..</p> <p>Is there any other way to give <code>"/"</code> as i am using slash <code>/import_pal=</code></p>
java
[1]
3,944,631
3,944,632
How to read passive RFID cards using Android?
<p>I am working on Android application (Droid Incredible).</p> <p>I am planning to read passive RFID tags using Android phone but I found that there is no slot for Android to connect to RFID reader.</p> <p>After some research, I found out that I will have to get RFID reader which can send RF data over bluetooth to Android. But I am not sure which company manufactures it or what will be cost of such RFID reader.</p> <p>Is there any one who can help me or throw some light on this issue? </p> <p>Thanks Siddhesh</p>
android
[4]
5,091,690
5,091,691
'class X' has no member 'Y'
<p>This error is inexplicably occurring. Here is the code and output:</p> <p>timer.cpp: </p> <pre><code>#include "timer.h" #include "SDL.h" #include "SDL_timer.h" void cTimer::recordCurrentTime() { this->previous_t = this->current_t; this->current_t = SDL_GetTicks(); }</code></pre> <p>timer.h: </p> <pre><code>#include "SDL.h" #include "SDL_timer.h" class cTimer { private: int previous_t; int current_t; float delta_time; float accumulated_time; int frame_counter; public: void recordCurrentTime(); float getDelta(); void incrementAccumulator(); void decrementAccumulator(); bool isAccumulatorReady(); void incrementFrameCounter(); void resetFrameCounter(); int getFPS(); };</code></pre> <p>Compiler errors: </p> <pre>make g++ -Wall -I/usr/local/include/SDL -c timer.cpp timer.cpp: In member function ‘void cTimer::recordCurrentTime()’: timer.cpp:6: error: ‘class cTimer’ has no member named ‘previous_t’ timer.cpp:6: error: ‘class cTimer’ has no member named ‘current_t’ timer.cpp:7: error: ‘class cTimer’ has no member named ‘current_t’ make: *** [timer.o] Error 1</pre> <p>Compiler errors after removing the #include "timer.h"</p> <pre> g++ -Wall -I/usr/local/include/SDL -c ctimer.cpp ctimer.cpp:4: error: ‘cTimer’ has not been declared ctimer.cpp: In function ‘void recordCurrentTime()’: ctimer.cpp:5: error: invalid use of ‘this’ in non-member function ctimer.cpp:5: error: invalid use of ‘this’ in non-member function ctimer.cpp:6: error: invalid use of ‘this’ in non-member function make: *** [ctimer.o] Error 1 </pre>
c++
[6]
3,046,742
3,046,743
Fastest way to read numerical values from text file in C++ (double in this case)
<p>Currently, my code is simply this:</p> <pre><code>void ReadFile(double Cst[][1000], char* FileName, int height) FILE* ifp; double value; int nRead = 0; int mRead = 0; //open the file, check if successful ifp = fopen( FileName, "r" ); if (ifp==NULL){ ... } for (nRead = 0; nRead &lt; height; nRead++){ for (mRead = 0; mRead &lt; 1000; mRead++){ fscanf(ifp, "%le",&amp;value); Cst[nRead][mRead]=value; } } fclose(ifp); </code></pre> <p>What can I change to make it the fastest possible?</p>
c++
[6]
5,917,428
5,917,429
How can I make stop watch in Android?
<p>I am need stop watch like widget in android.Currently I am using Android chronometer,it is not fulfilling my requirements as when I am stopping the chronometer its stops in UI but but it continues to tick in background.</p>
android
[4]
5,282,016
5,282,017
How to load image in textview?
<p>I want to display image in textview,is it possible?anybody knows,please give sample code for me.. Thanks All</p>
android
[4]
1,246,687
1,246,688
Using an intent to start new activity from ListActivity
<p>my ListActivity has a button on the bottom that I want to use to fire up a new activity using an intent. When I tried saying <code>Intent intent = new Intent(this, OtherActivity.class)</code> I'm getting an error that the constructor is undefined. FWIW, the other activity extends MapActivity. Not sure if that matters...</p> <p>What do I need to do to get this to work?</p>
android
[4]
795,471
795,472
Quick Debug about reading words
<p>I have this code and I receive an error when I run the program. Am I doing something wrong with this?</p> <pre><code>import java.io.*; import java.util.*; public class countLines { public static void main(String[] args) throws Exception { int count = 0; int word = 0; File f = new File("file.txt"); Scanner input = new Scanner(f); while(input.hasNext()){ String words = input.next(); word++; } while (input.hasNextLine()) { input.nextLine(); count++; } input.close(); System.out.println("Number of Line: " + count); System.out.println("This file has " + word + " words."); } } </code></pre>
java
[1]