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
100,118
100,119
How to initialize anonymous inner class in Java
<p>is there any way to initialize anonymous inner class in Java? For example:</p> <pre><code>new AbstractAction() { actionPerformed(ActionEvent event) { ... } } </code></pre> <p>Is there any way to use for example putValue method somewhere in the class declaration?</p> <p>Thank you for help.</p>
java
[1]
4,355,337
4,355,338
jQuery: this random selector is rather predictable
<p>In this fiddle <a href="http://jsfiddle.net/SySRb/40/" rel="nofollow">http://jsfiddle.net/SySRb/40/</a>, I created an array with two elements, #f-ONE and #ONE. There is a function that, when the "start" box is clicked, selects one of the two elements randomly, and, depending on which is chosen, displays either a yellow or reddish box. </p> <p>However, in actual fact, it is always the yellow box that is selected, so something is not working.</p> <p>However, the exact same code that selects things randomly works in other contexts (see <a href="http://jsfiddle.net/urfXq/96/" rel="nofollow">http://jsfiddle.net/urfXq/96/</a> ), so I don't know what the problem is... </p>
jquery
[5]
3,112,110
3,112,111
C++ array of classes
<p>I working on a game but I have a problem with the initialization of the level. (feld is just field in german)</p> <pre><code>class level{ private: feld spielfeld[10][10]; public: /* other stuff */ void init_feld(); }; void level::init_feld() { for(int i=0;i!=10;i++){ for(int n=0;n!=10;n++){ spielfeld[i][n] = new feld(land, i, n); } } } </code></pre> <p>The Error:</p> <p>Error: no match for »operator=« in »((level*)this)->level::spielfeld[i][n] = (operator new(24u), (, ((feld*))))« /home/nick/stratego/feld.h:18:11: </p> <p>Remark: candidate is: feld&amp; feld::operator=(const feld&amp;) Process terminated with status 1 (0 minutes, 0 seconds) 2 errors, 0 warnings</p>
c++
[6]
5,485,779
5,485,780
A valid signing identity matching this profile could not be found in your keychain
<p>I am able to test my app on my device using the development profile/certficates...</p> <p>In the same way, I have created distribution profile/certicates for my app....</p> <p>But when I try to upload my app to iTunes , it says "Application failed codesign verification"</p> <p>Also in the Organizer, it says "A valid signing identity matching this profile could not be found in your keychain"</p> <p>i have tried everything that is listed here by other users...But not sure what the issue is...Please help me.</p>
iphone
[8]
4,963,396
4,963,397
How to apply a function to a collection of elements
<p>Consider I have an array of elements out of which I want to create a new 'iterable' which on every <em>next</em> applies a custom 'transformation'. What's the proper way of doing it under python 2.x?</p> <p>For people familiar with Java, the equivalent is Iterables#transform from google's collections framework.</p> <p>Ok as for a dummy example (coming from Java)</p> <pre><code>Iterable&lt;Foo&gt; foos = Iterables.transform(strings, new Function&lt;String, Foo&gt;() { public Foo apply(String string) { return new Foo(string); } }); //use foos below </code></pre>
python
[7]
1,062,744
1,062,745
Assemble a URL with jQuery
<p>I have a base url,</p> <pre><code>var url = "/example/url/here" </code></pre> <p>and an object</p> <pre><code>var data = {"id": 1, "do": "some action"} </code></pre> <p>and I want to assemble a url with these to items in a similar fashion to how the $.get works, only I just want the url. Any ideas or do I have to loop through the object and assemble the url myself? </p>
jquery
[5]
3,501,802
3,501,803
ByteBuffer as static final fields within classes
<p>I have certain values for columns that are frequently required to be stored in DB. Previously, I had been caching those values as <code>static final byte[]</code> class fields but unfortunately <code>byte[]</code> doesnt allow for easier equality comparasions(to check if another byte array elements are just the same as this one) thus I am thinking of using <code>static final ByteBuffer</code> class fields as that would allow me for easier equality comparisions <em>(my DB anyway requires to convert all values to ByteBuffer for writes)</em>.</p> <p>Now since I am new to ByteBuffer usage, I just wanted to ask if there are any issues with a few (&lt;100) <code>static final ByteBuffer</code> fields within my classes each containing a byte[] of length 2?</p>
java
[1]
5,050,345
5,050,346
Properties backing field - What is it good for?
<p>On one hand, I know that the advisable usage of Properties is to have a backing field, like in the following example:</p> <pre><code> private int m_Capacity; public int Capacity { get { return m_Capacity &gt; 0 ? m_Capacity : -666; } set { m_Capacity = value; } } </code></pre> <p>On the other hand, what benefit do I get from using the above example over discarding the field and using only the property for all purposes, like in the following example:</p> <pre><code> public int Capacity { get { return Capacity &gt; 0 ? Capacity : -666; } set { Capacity = value; } } </code></pre> <p>What is good about using a backing field for regular (non-auto-implemented) properties? </p>
c#
[0]
4,980,884
4,980,885
Opening a previous form when one is closed
<p>First of all, I am a newcomer to C# and programming in general. I've searched pretty thoroughly, but I can only find instances where someone wants to open another form and hide the one that the button was pressed on.</p> <p>In this instance, I'm having issues with my program continuously running when I press the (X) on any form other than the main "Form1".The form-to-form navigation works fine. i.e.: clicking a button hides the main window and opens the appropriate form, and the "back" button on that form hides itself and shows (I guess another instance) of the previous "main" form. --I could probably use some guidance in that, too. lol </p> <p>I wouldn't mind if it closed the entire application if the X was pressed, but I need to have the "X" present on all windows and all windows need to exit the entire app if the X is pressed. Any suggestions? </p> <p>Thanks in advance,</p> <p>Code:</p> <p><strong>Form1:</strong></p> <pre><code> public partial class Form1 : Form { public Form1() { InitializeComponent(); } public void btnTransaction_Click(object sender, EventArgs e) { Transaction transactionForm = new Transaction(); Form mainForm = this; transactionForm.Show(); mainForm.Hide(); } } </code></pre> <p><strong>Transaction Form:</strong></p> <pre><code> public partial class Transaction : Form { public Transaction() { InitializeComponent(); } private void button4_Click(object sender, EventArgs e) { Form1 mainForm = new Form1(); //not sure if I'm doing this right.. this.Hide(); //I don't know how to "reuse" the original Form1 mainForm.Show(); } } </code></pre>
c#
[0]
4,284,052
4,284,053
how to set bubble images to background of textview in android programatically?
<pre><code>msgList = (ListView)findViewById(R.id.msgList); receivedMessages = new ArrayAdapter&lt;String&gt;(this, R.layout.message); msgList.setAdapter(receivedMessages); msg = (EditText)findViewById(R.id.msg); msg.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_UP) &amp;&amp; (keyCode == KeyEvent.KEYCODE_ENTER)) { postMessage(); return true; } return false; } }); private void postMessage() { String theNewMessage = msg.getText().toString(); try{ myThread.sendMessage(theNewMessage); }catch(Exception e){ Log.e(TAG,"Cannot send message"+e.getMessage()); } receivedMessages.add(theNewMessage+":Me"); msg.setText(""); //receivedMessages.getContext().getString(sendmsg); } </code></pre> <p>I want to set background bubble image to string result means theNewmessage. Where I get the my result.bubble image get automatic size according to its character size length.</p>
android
[4]
4,855,372
4,855,373
Problem with $_POST
<p>This wont work. All the fields are correct etc and I have a db connection.</p> <p>To the problem</p> <p>I use this script to insert a post into the db:</p> <pre><code>&lt;?php if (isset($_POST['msg'])) { $title = mysql_real_escape_string($_POST['title']); $msg = mysql_real_escape_string($_POST['msg']); // kolla efter tomma fält if (empty($title) || empty($msg)) { $reg_error[] = 1; } if (!isset($reg_error)) { mysql_query("INSERT INTO messages (title, message, date, user_id) VALUES('$title', '$msg', '".time()."', '2')"); header('location: /'); exit; } } ?&gt; </code></pre> <p><b>The Form:</b></p> <pre><code>&lt;form action="post_msg.php" method="post"&gt; &lt;b&gt;Title:&lt;/b&gt; &lt;input type="text" name="title" size="40" /&gt; &lt;b&gt;Message:&lt;/b&gt; &lt;textarea rows="15" cols="75" name="msg"&gt;&lt;/textarea&gt; &lt;input type="submit" value="Post Message" /&gt; &lt;/form&gt; </code></pre> <p></p> <p>Worked fine the other day. Not today. No errors. The "post stuff" shows up in the url. I thought it only did when using $_GET which i dont. <code>http://localhost/post_msg.php?title=fdsg&amp;msg=sdfg</code></p> <p>i dont get any errors the page just reloads</p> <p>messages db</p> <pre><code>CREATE TABLE IF NOT EXISTS `messages` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(140) COLLATE utf8_unicode_ci DEFAULT NULL, `message` text COLLATE utf8_unicode_ci `date` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), FULLTEXT KEY `title` (`title`,`message`) </code></pre>
php
[2]
3,438,487
3,438,488
Is there any reason why lVals = [1, 08, 2011] throws an exception?
<p>I have discovered one thing that makes me crazy. If i specify the following list:</p> <pre><code>lVals = [1, 01, 2011] </code></pre> <p>than no any errors will be displayed, and the same will be if i use 02,03,04,05,06,07, but in case i specify second item in list as 08 or 09 i am getting the following exception:</p> <pre><code>&gt;&gt;&gt; a = [26, 08, 2011] File "&lt;stdin&gt;", line 1 a = [26, 08, 2011] ^ SyntaxError: invalid token </code></pre> <p>Also the same behavior appears when i put these numbers(08,09) at the any location within list([08,10,2011]) and etc, even if i try to assign 08 to a single int variable i get the same exception. </p> <p>Is there any reason why this happens?</p>
python
[7]
4,743,303
4,743,304
TextView , Text is grayed out
<p>Text in the textView seems like it is grayed out. </p> <p>I want so set the text color as when you click textView then It seems in black color as it is enabled.</p>
android
[4]
813,020
813,021
C++ cout fresh array gibberish
<p>When I "cout" an empty array, I get gibberish. Why?</p> <pre><code>int main() { char test[10]; cout &lt;&lt; test; return 0; } </code></pre> <p>...returns some unicode blather. An easy answer I'm sure.</p>
c++
[6]
1,577,729
1,577,730
I want to integrate a map other than google map into an android app
<p>I want to integrate a map other than google map into an android app</p>
android
[4]
2,226,577
2,226,578
Nested Classes Adapter Pattern?
<p>I have a static class <code>Manager</code> it should adapt between two tiers of logic would it be a bad practice to devide functionalitlies by nesting static classes inside it? I have about two dozen diffrent subjects to manage with 2 -3 functions each. and would like to avoid creating 2 dozen classes for this</p> <p>I mean use this:</p> <pre><code>static class Manager { static class Type1 { static void Method1(); static void Method2(); static void Method3(); } static class Type2 { static void Method4(); static void Method5(); static void Method6(); } static class Type3 { static void Method7(); static void Method8(); static void Method9(); } } </code></pre> <p>instead of:</p> <pre><code>static class Manager { static void Method1(); static void Method2(); static void Method3(); static void Method4(); static void Method5(); static void Method6(); static void Method7(); static void Method8(); static void Method9(); } </code></pre> <p>something like namespaces, but inside a class.</p>
c#
[0]
5,297,820
5,297,821
what does 'this' refer to in Javascript functions
<p>I understand the general idea behind the <code>this</code> keyword but I'm having trouble figuring out what it actually refers to in practice. For example, in both these example exercises, I guessed the wrong number. </p> <p>for question1, I said that the alert would be '5', because it is referring to the this.x outside the anonymous function in the function. </p> <p>In question2, I thought the alert would be 5 because this line</p> <pre><code>var alertX = o.alertX; </code></pre> <p>would bind the value 5 for property x inside the variable o to the new variable 'alertX' which becomes the function call in the next line: alertX();</p> <p>Can you explain why I'm wrong? </p> <pre><code>var question1 = function() { this.x = 5; (function() { var x = 3; this.x = x; })(); alert(this.x); }; var answer1 = 3; var question2 = function() { this.x = 9; var o = { 'x':5, 'alertX':function() { alert(this.x); } }; var alertX = o.alertX; alertX(); } var answer2 = 9; </code></pre>
javascript
[3]
5,241,041
5,241,042
simple python connect 4 game. why doesnt this test work?
<p>Everything about this code seems to work perfectly, except the tests for diagonal wins. The tests for vertical and horizontal wins seem to be exactly the same concept, and they work perfectly. </p> <p>The comments should mostly explain it, but the test should basically iterate through the board and check for x's in the bottom left hand corner (the only place that a right facing diagonal can start). it then goes up and to the right one space four times to check for a four in a row.</p> <p>Here is the function in question.</p> <pre><code>#for diagonal #not working! WHYYYY def winnertest3(): for i in range(3): for e in range(4): print i,e if board[i][e]=='X' and board[i+1][e+1]=='X' and board[i+2][e+2]=='X' and board[i+3][e+3]=='X': print "X wins!!!!" return 'over' return 'on' </code></pre> <p><a href="http://github.com/keevie/Computer-Science/blob/master//board1.py" rel="nofollow">http://github.com/keevie/Computer-Science/blob/master//board1.py</a></p>
python
[7]
1,845,874
1,845,875
Return filename from path
<p>What did I do wrong here?</p> <p>call</p> <pre><code>printf(filename(exename)); </code></pre> <p>my function should return filename</p> <pre><code>const char* filename(const string&amp; str) { const char* path; size_t found; found=str.find_last_of("/\\"); path = (str.substr(found+1)).c_str(); cout &lt;&lt; str.substr(found+1); // ------------&gt; is name ok printf("\n\n"); printf(path); // ------------&gt; is name not ok random numbers printf("\n\n"); return path; // ------------&gt; is not ok random numbers } </code></pre>
c++
[6]
5,172,531
5,172,532
Syncing between Mac OS X and iPhone
<p>Is there any progress made in this area since this post in 2008? </p> <p><a href="http://stackoverflow.com/questions/185673/how-do-i-sync-application-data-between-an-iphone-and-another-computer">http://stackoverflow.com/questions/185673/how-do-i-sync-application-data-between-an-iphone-and-another-computer</a></p>
iphone
[8]
2,805,406
2,805,407
How to see pushed images to sd card in emulator
<p>I create an emulator with 2000MB SD Card size and push files to it as you can see in image but i can't see these image files in gallery application in emulator. how can i see the images in gallery application? link of file to see my emulator and files that pushed to it!<br> <a href="http://up98.org/upload/server1/01/z/1ghux6w1nyojs4pmeqi2.png" rel="nofollow">emulator image</a></p>
android
[4]
1,764,901
1,764,902
Scrollable Canvas or surfaceview
<p>I want to create an application, wherein users can create a design on canvas with bitmaps and lines on it, but i want it to be scrollable i.e. my canvas should be larger than the screen size. I am using sufaceview and using canvas on it. But i have trouble having making it scrollable, what shold be my approach 1) make surfaceview scrollbale using someoffset (i read one tutorial with scrollable map with cells)2) use two canvas (not sure how it works) 3) use scrollview as parent view of sufaceivew (?) Or 4) something else.</p>
android
[4]
2,778,254
2,778,255
Android fingerpaint canvas color
<p>I'm messing about with Fingerpaint.java in the SDK <a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html" rel="nofollow">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html</a></p> <p>I've made a few adjustments to where I can save the bitmap and reopen to edit it later. Got that all working. Only issue is the canvas color on the saved copy is black rather than the color I set it too which means the canvas color when I go into edit is also black. I load my saved bitmap as such: The rest of the file is more or less the same as the one in the SDK. I'm just trying to figure out how I can get my canvas back to the desired color as when I first created it.</p> <pre><code> public MyView(Context c) { super(c); Bundle extras = getIntent().getExtras(); imageURI = extras.getString(Intent.EXTRA_SUBJECT); mBitmap = BitmapFactory.decodeFile(imageURI); Drawable d = new BitmapDrawable(mBitmap); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); d.setBounds(0, 0, width, height); d.draw(canvas); mBitmap = bitmap; mCanvas = canvas; mPath = new Path(); mBitmapPaint = new Paint(Paint.DITHER_FLAG); } </code></pre>
android
[4]
4,211,149
4,211,150
Error While Calling Activity from Service
<p>i have written this code of service class for calling the activity from the service..but it not works.....please help me.......</p> <pre><code>public class MyService extends Service { private static final String TAG = "MyService"; MediaPlayer player; Uri u1 ; @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { Intent intent = null; int startId = 0; super.onStart(intent, startId); Toast.makeText(this, "My Service Created", Toast.LENGTH_LONG).show(); Log.d(TAG, "onCreate"); //Intent i=new Intent(MyService.this,CustomDialogExample.class); //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //startActivity(i); } //player = MediaPlayer.create(this, u1.parse("http://marakana.com/static/tut/braincandy.m4a")); // player.setLooping(false); // Set looping // player.setLooping(false); // Set looping // @Override public void onDestroy() { Toast.makeText(this, "My Service Stopped", Toast.LENGTH_LONG).show(); Log.d(TAG, "onDestroy"); player.stop(); } @Override public void onStart(Intent intent, int startid) { Intent i=new Intent().setClass(MyService.this,CustomDialogExample.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show(); Log.d(TAG, "onStart"); //player.start(); } } </code></pre>
android
[4]
1,402,871
1,402,872
How to get URL for application's document directory iPhone
<p>This code is a part of Core Data. The URLsForDirectory....method does not run on iOS &lt; 4 so I need to know some other methods/objects to call. I would also appriciate documentation for future reference. Thank you</p> <pre><code>/** Returns the URL to the application's Documents directory. */ - (NSURL *)applicationDocumentsDirectory { return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; } </code></pre> <hr> <p>EDIT, problem solved. Updated post with answer.</p> <pre><code>/** Returns the URL to the application's Documents directory. */ - (NSURL *)applicationDocumentsDirectory { NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentPath = [searchPaths lastObject]; return [NSURL fileURLWithPath:documentPath]; } </code></pre>
iphone
[8]
2,021,635
2,021,636
Python: Convert list of ints to one number?
<p>I have a list of integers that I would like to convert to one number like:</p> <pre><code>numList = [1,2,3] num = magic(numList) print num, type(num) &gt;&gt;&gt; 123, &lt;type 'int'&gt; </code></pre> <p>What is the best way to implement the <i>magic</i> function?</p> <p>Thanks for your help.</p> <p><b>EDIT</b> <br> I did find <a href="http://bytes.com/groups/python/722951-int-str-list-elements">this</a>, but it seems like there has to be a better way.</p> <p><b>EDIT 2</b> <br> Let's give some credit to <a href="http://stackoverflow.com/questions/489999/python-convert-list-of-ints-to-one-number#490020">Triptych</a> and <a href="http://stackoverflow.com/questions/489999/python-convert-list-of-ints-to-one-number#490031">cdleary</a> for their great answers! Thanks guys.</p>
python
[7]
5,902,635
5,902,636
Count exact number of charaters in a string in java
<p>I have a string of names where all the different names are seperated by the same character (#) e.g. tom#will#robert#</p> <p>I want to be able to count the number of names by counting the number of times that # appears, How would i go about doing this?</p>
java
[1]
1,078,962
1,078,963
Capitalize words in string
<p>What is the best approach to capitalize words in a string?</p>
javascript
[3]
1,611,767
1,611,768
C#|Start Remote Desktop as a Process + Put text in the textbox
<p>well, the title of this qustions is abit stupid, but i will expline it very very simple. </p> <p>in my code, i am strating a remote deskop.exe </p> <p>like this:</p> <pre><code>Process rtc; rtc = Process.Start(@"C:\Windows\System32\mstsc.exe"); </code></pre> <p>now, the thing is. when the remote deskop comes up(its work) i will like to know how can i put a name in the textbox on the connction.</p> <p>so when the remote will be up, the conntion name will be there, or a ip. </p> <p>is it even posibale?</p>
c#
[0]
268,309
268,310
How does an ASP.NET session expire when the browser is closed?
<p>As in the title, I wonder how a session expires when the client's browser is closed?</p>
asp.net
[9]
1,388,846
1,388,847
If else difference
<p>Is there any difference between the below statements:</p> <pre><code> Object value = null; if(value == null) { } else if(value instanceof Long) { } </code></pre> <p>vs</p> <pre><code> Object value = null; if(isNotEmpty(value)) { } else { } public boolean isNotEmpty(Object obj) { if(obj != null &amp;&amp; obj instanceof Long &amp;&amp; obj &gt;0){ return true; } return false; } </code></pre>
java
[1]
5,871,324
5,871,325
Detect if an android app is running on background
<p>I want to check if my app is running on a background mode.</p> <p>The problem is that i have many activities(list activities, map activities etc.). Initially I have tried in the life cycle's resume and pause(or the <code>onUserLeaveHint</code>) methods to set a static boolean as true or false and work with this way. But this obviously can't work because when I move from one activity to another, the previous one get paused. </p> <p>Also, I've read here on stackoverflow that the <code>getRunningTasks()</code> should be used only for debugging purposes. I did a huge research but I can't find a solution. All I want to do is to be able to detect if a the app is running on a background. Can anyone propose me a way, or express any thought on how can I do that?</p>
android
[4]
2,899,342
2,899,343
Checking if image does exists using javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3381663/check-if-image-exists-with-given-url-using-jquery">Check if image exists with given url using jquery</a><br> <a href="http://stackoverflow.com/questions/5678899/change-image-source-if-file-exists">Change image source if file exists</a> </p> </blockquote> <p>I am throwing the value of an image path from a textbox into boxvalue and want to validate if the image exist using javascript. </p> <pre><code> var boxvalue = $('#UrlQueueBox').val(); </code></pre> <p>I browsed stackoverflow and found the below to get the image width/height, but don't want to use this.</p> <pre><code>var img = document.getElementById('imageid'); </code></pre> <p>How can an I validate if it is really an image from the image path?</p>
javascript
[3]
2,715,902
2,715,903
Accessing secure websites via App
<p>If my app provides a link to a secure website eg a booking system that uses https etc, then are the user's credit card and password details secure in this case ie are the card and password details encrypted when being sent from the mobile phone ? Also do you need the permssion of the website owner to incorporate such a link into your app. I would have thought the anser is no as it is a publically available website, but I just wanted to make sure. Thanks very much Rh</p>
android
[4]
871,675
871,676
fetching from DB and store them in a new array PHP
<p>I am fetching data from my DB and they look like this:</p> <pre><code>[{"0":"1","key-1":"1","1":"1","key-2":"1","2":"1","key-3":"1","3":"1","key-4":"1"}] </code></pre> <p>where the key-1 are the name of the column. (I only have one entry so).</p> <p>I want to extract only the column values and save them into a new array that will output like this:</p> <pre><code>{"key-1":"1","key-2":"1","key-3":"1","key-4":"1"} </code></pre> <p>I want it to look exactly like this and not : <code>[{"key-1":"1","key-2":"1","key-3":"1","key-4":"1"}]</code> </p> <p>I tried this:</p> <pre><code>$cart["key-1"]=$output["key-1"]; </code></pre> <p>where $output is the outcome of the DB that shown first (the one with []).</p> <p>and the $cart is the new array I want.</p> <p>Both are declared as:</p> <pre><code>$cart=array(); $output=array(); </code></pre> <p>and <code>$output[]=$row</code> where row is the result of the DB fetch. How to do it?</p>
php
[2]
3,336,010
3,336,011
C#: Detecting which application has focus
<p>I'm looking to create a C# application that changes content according to which application currently has focus. So if the user is using Firefox, my app would know that. Same for Chrome, Visual Studio, TweetDeck etc.</p> <p>Is this possible, and if so - how would I go about achieving it?</p> <p>I have a feeling I'm asking for to much - but it's worth a try.</p> <p>Many thanks in advance.</p>
c#
[0]
2,385,355
2,385,356
JavaScript, innerHTML not being recognised by javascript
<p>I have the following code for my website:-</p> <pre><code>function HCreateWindow(top,left,width,height,zindex,parent) { var handle = Math.floor(Math.random()*10000000000); if(parent==null) { document.write("&lt;div id=\"HWINDOW" + handle + "\"style=\"top: " + top + "px; left: " + left + "px;width: " + width + "px;height: " + height + "px; border: 1px solid black;z-index: " +zindex +"\" class=\"drag\"&gt;&lt;/div&gt;"); } else { document.getElementById("HWINDOW" + parent).innerHTML += "&lt;div id=\"HWINDOW" + handle + "\"style=\"top: " + top + "px; left: " + left + "px;width: " + width + "px;height: " + height + "px; border: 1px solid black;z-index: " +zindex +"\" class=\"drag\"&gt;&lt;/div&gt;"; } return handle; } </code></pre> <p>It turns out that the innerHTML causes internet explorer 8 to say that innerHTML is null or not an object. Thinking that this may be a bug with IE I updated to IE9. Still have the same problem. However, if I add the line before the 'if':-</p> <pre><code>document.write(parent); </code></pre> <p>it works, as if innerHTML is recognised. Got no idea how the two commands are related. The only thing is that I do not want to display the contents of 'parent', as this would make the web page untidy. Any clues?</p>
javascript
[3]
1,866,852
1,866,853
soap.wsdl_cache_enabled
<p>I want to set value of <strong>soap.wsdl_cache_enabled</strong> = <strong>0</strong> in php.ini, but do not get any option in ini. How to change it ?</p> <p>I have a wordpress plugin which gets data form a webservice, I have deleted the wsdl file but it is working, is it taking from cache?</p>
php
[2]
1,863,763
1,863,764
core java programming issues
<p>(a) There is a student class which contains name field(String) and id(String) it has no default constructor. however, it has a parameterized constructor, taking two Strings as an argument to supply value to those feilds.</p> <p>(b) it has a non static inner class name mark which contains fields cgpa(float) and sgpa(float). it has only one parameterized constructor to supply value to cgpa and sgpa.</p> <p>(c) the main() method resides in a different class named Demo. Create an array of student class and store the data there.</p> <pre><code>class Student{ String name; String id; public Student(String n,String d){ name=n; id=d; } class mark{ float cgpa; float sgpa; public mark(float g,float p){ cgpa=g; sgpa=p; } } } public class main{ public static void main(String[]args){ Student s[]=new Student[2]; s[0]=new Student("vivek","433"); // how to use non static argument of constructor in Student class array System.out.println("THe name is "+s[0].name+" and the id is "+s[0].id); } } </code></pre> <p>there is problem create array of class and store the argument in array</p>
java
[1]
4,382,249
4,382,250
In C#, can you make a windows form application start as a service?
<p>I have a GUI C# Windows form program that I would like to start as a service when the computer starts and perhaps have an icon in the system tray that when clicked maximizes the program. Is this possible without major rework?</p> <p>Thanks</p>
c#
[0]
1,837,843
1,837,844
How to adjust position of textLabel, detailTextLabel and switch in tableview?
<p>I have textLabel, detailTextLabel, UISwitch in tableview cell. I want to adjust y position of them. How can I do that? I already adjusted height of cell.</p> <pre><code>UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectMake(200, 10, 50, 30); cell.accessoryView = switchView; </code></pre> <p>Above code doesn't work for switch. It always shows at the same position.</p>
iphone
[8]
581,346
581,347
Show multiple RoutePaths from same GeoPoint in Android
<p>I wanted to show two Route Paths from same GeoPoint means from A-B and A-C.<br/><br/> Route1 contains GeoPoints from A-B and Route2 contains GeoPoints from A-C. Please help me.</p>
android
[4]
2,057,232
2,057,233
the import android could not be resolved
<p>I opened a project that I had not opened in a while in Eclipse today. I was unable to compile due to some (inexplicable) errors.</p> <pre><code>import android.app.Activity; import android.os.Bundle; import android.view.animation.AnimationUtils; import android.widget.ImageView; import android.view.animation.Animation; import android.content.Intent; </code></pre> <p>produces the following error:</p> <blockquote> <p>the import android could not be resolved</p> </blockquote> <p>What can I do to resolve this problem?</p>
android
[4]
5,465,348
5,465,349
How to convert "do-some-stuff" to lower camel-case "doSomeStuff" in the most neatful way?
<p>How to convert <code>"do-some-stuff"</code> to lower camel-case <code>"doSomeStuff"</code> in the most neatful way in Java?</p>
java
[1]
2,197,803
2,197,804
Piping popen stderr and stdout
<p>I want to call scripts from a directory (they are executable shell scripts) via python.</p> <p>so far so good: </p> <pre><code> for script in sorted(os.listdir(initdir), reverse=reverse): if script.endswith('.*~') or script == 'README': continue if os.access(script, os.X_OK): try: execute = os.path.abspath(script) sp.Popen((execute, 'stop' if reverse else 'start'), stdin=None, stderr=sp.PIPE, stdout=sp.stderr, shell=True).communicate() except: raise </code></pre> <p>Now what i Want is: lets say i have a bash script with a start functiont. from which I call </p> <blockquote> <p>echo "Something"</p> </blockquote> <p>Now I want to see that echo on sys.stdout and the exit Code. I believe you do this with .communicate() but mine doesn't work the way i thought it would.</p> <p>What am I doing wrong?</p> <p>Any help is much appreciated</p>
python
[7]
3,712,292
3,712,293
Jquery element replace problem
<p>First I'm not sure this is the place to ask this question if not please direct it to its proper place. </p> <p>The problem I am having is that I can get the first click function to work and have the html element change but I can't get the second click function to work and have the element change back. I was wondering how can I fix this problem?</p> <p>Here is the code.</p> <pre><code>$(document).ready(function() { $('.arrow').click(function(){ $(this).closest('li').find('ol:first').fadeToggle('fast', 'linear'); $(this).html('&lt;span class="arrow-alt"&gt;&amp;#8595;&lt;/span&gt;'); }); $('.arrow-alt').click(function(){ $(this).closest('li').find('ol:first').fadeToggle('fast', 'linear'); $(this).html('&lt;span class="arrow"&gt;&amp;#8594;&lt;/span&gt;'); }); }); </code></pre>
jquery
[5]
4,610,717
4,610,718
Displaying the Length of Individual Sequences in File
<p>I have a file that contains two sequences. I have a program that could read all sequences, combine them together, and display the length of both sequences together. Now I want to display the length individually. The two sequences are separated by the symbol <code>&gt;</code>.</p> <p>Example:</p> <pre><code>SEQ1 &gt;ATGGGACTAGCAGT SEQ2 &gt;AGGATGATGAGTGA </code></pre> <p>Program:</p> <pre><code>#!usr/bin/python import re fh=open('clostp1.fa','r') count=0 content=fh.readlines() fh.close() seq='' patt=re.compile('&gt;(.*?)') for item in content: m=patt.match(item) if not m: s=item.replace('\n','') seq=seq+s seq=seq.replace('\s','') print seq print 'The length of the coding sequence of the bacillus' print len(seq) </code></pre>
python
[7]
5,037,568
5,037,569
virtual methods
<p>if i have a class named <code>"Parent"</code> for example. he has a method named <code>"Print".</code> the class <code>"Kid"</code> is derived, it has a method named <code>"Print"</code>, but a new one.</p> <pre><code>new public void Print; </code></pre> <p>Let's create an object:</p> <pre><code>Parent p = new Kid(); </code></pre> <p>If i'll use the method Print with this object's pointer the metohd will be the father's("Parent") method, not the "Kid".</p> <p>but when I'm using a virtual method, the method will be the Kid's not the parent.(if the Print was virtual, the print in the "Kid" overrides the method")</p> <p>why? </p>
c#
[0]
313,593
313,594
How to write an IF else statement without 'else'
<p>I can't use <code>else</code> in my script; how can I implement an <code>if else</code> statement without using <code>else</code>?</p> <p>I'm trying to resize a div:</p> <pre><code>function hideTable(){ var table = document.getElementById('PDemo'); if(table.style.width == "50%") table.style.width = "150px"; if(table.style.width == "150px") table.style.width = "50%"; } </code></pre> <p>This script doesn't work because as soon as the first <code>if</code> statement is executed, the condition for the second <code>if</code> statement becomes true, so that executes too, thus nothing changes.</p> <p>P.S. This isn't a homework. The software I am using only allows 1-line statements.</p>
javascript
[3]
5,598,254
5,598,255
jquery.ui-min.js conflicts with ui.core.js on draggable()
<p>Am using jquery-1.3.2.min.js, jquery.colorbox.js, jquery-ui.min.js, ui.core.js, ui.tabs.js, jquery.accordion.js, jquery.BubblePopup.js, ....etc in my projects.</p> <p>I need to drag and drop jquery colorbox popup window. I am using jquery.ui-min.js draggable() function. Error comes on calling error console</p> <blockquote> <p>"c[l][k] is not a constructor" </p> </blockquote> <p>in jQuery UI 1.7.2.</p> <pre><code>jQuery(document).ready(function($){ jQuery("#colorbox").draggable(); }); </code></pre> <p>But remove only ui.core.js js file working fine. But I need ui.core.js file for some other purpose.</p> <p>Please give me the solution for that. How to use both jquery.ui-min.js and ui.core.js on calling draggable().</p> <p>Note: Am worked test purpose with four js files jquery.1.2.3-min.js, jquery.colorbox-min.js, jquery.ui.min.js and ui.core.js and also I used </p> <pre><code>JQuery.noConflict(); </code></pre> <p>No use. Still error comes..</p>
jquery
[5]
255,826
255,827
What is the difference between a static variable and a dynamic variable in java/oops?
<p>please some1 tell me the difference between a 'static variable' and a 'dynamic variable' in oops or in java. Also their usage if possible.</p>
java
[1]
925,338
925,339
jQuery Hover over image problem
<p>I have a script: see fiddle <a href="http://jsfiddle.net/patrioticcow/ERTWT/" rel="nofollow">http://jsfiddle.net/patrioticcow/ERTWT/</a> . When i hover over image a black div slides down. What i want it to be able to click on that div and do something. Right now if i hover over the black div the animation goes crazy :)</p> <pre><code>&lt;div class="profile-img-edit"&gt;Change Profile Picture&lt;/div&gt; &lt;img class="profile-img" src="http://download.exploretalent.com/media014/0000145198/0000145198_PM_1298338078.jpg"&gt; $('.profile-img').hoverIntent(function() { $('.profile-img-edit').slideDown(); }, function() { $('.profile-img-edit').slideUp("fast"); }); </code></pre> <p>i can use <code>hover</code> instead of <code>hoverIntent</code> but is not so reliable .</p> <p>thanks</p>
jquery
[5]
3,071,034
3,071,035
String.trim() returning false for same referenced object
<p>Why is this <strong>false</strong>?</p> <pre><code>String str1 = new String("Java "); String str2 = str1; System.out.println(str1.trim()==str2.trim()); //false </code></pre> <p>Initially <code>str2</code> was referencing <code>str1</code> object. So, comparing with == will return true for <code>str1==str2</code></p> <p>Then why is this <strong>false</strong> with <code>.trim()</code> method?</p> <p>Even it returns false for literals (without new keyword)</p> <pre><code>String str1 = "Java "; //this is now without new keyword String str2 = str1; System.out.println(str1.trim()==str2.trim()); </code></pre> <p>Note: I know how to use <code>.equals</code> method. But want to know <code>==</code> behavior especially in case of .trim() with above given two example.</p>
java
[1]
495,522
495,523
Display a list of results with numbers in ASP.NET
<p>I have a common problem in an ASP.NET web form. I'm just surprised that I haven't found a common solution :)</p> <p>I have a list of results being returned from a SQL Server database. I want to show those results in my web page with number to the left of them. For instance, my result set may look like the following:</p> <pre><code>New York | NY Chicago | IL Los Angeles | CA </code></pre> <p>In my web page, I would like to show them as:</p> <pre><code>1. New York, NY 2. Chicago, IL 3. Los Angeles, CA </code></pre> <p>I was surprised that I can't find a way to make the numbers automatically appear. Am i doing something wrong? If not, what is the recommended approach?</p> <p>Thanks</p>
asp.net
[9]
3,040,491
3,040,492
how to pass parameters through soap header in java
<p>how to pass parameters through soap header in java </p>
java
[1]
4,816,887
4,816,888
Display image based on combobox value on same page
<p>How to display a image depends on the value selected in the combo box and image is to display in the same page near to the combo box... Thanks in advance...</p>
javascript
[3]
2,439,754
2,439,755
Get File Name without path using WindowAPICodePack's commonOpenFileDialog
<p>When using the Windows API Code Pack's <code>CommonOpenFileDialog</code>, how do you retrieve the <code>filename</code> of a <code>file</code> (such as <code>mydoc.text</code>) without getting the path information?</p>
c#
[0]
4,401,981
4,401,982
Cpp Variable/Structure to store 128-bit data
<p>I need some variable/struct to store 32hex number or 128-bit number in an STL container. Do you have any suggestion for me ?</p>
c++
[6]
5,547,764
5,547,765
Next UIView is not being shown when row is selected
<p>my next View is not displayed &amp; in that i use imageview &amp; scrollview. My code look like this</p> <pre><code>-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { VolunteerPhotoDetail *volunteerPhotoDetail = [[VolunteerPhotoDetail alloc]initWithNibName:@"VolunteerPhotoDetail" bundle:nil]; volunteerPhotoDetail.indexRow = indexPath.row; [self.navigationController pushViewController:volunteerPhotoDetail animated:YES]; NSLog(@" self.navigationController 0x%x", self.navigationController); [volunteerPhotoDetail release]; } </code></pre> <p>nslog display value of the selg.navigationController but view is not displayed I check all the IB conncetion properly so please give me answer </p>
iphone
[8]
2,713,414
2,713,415
C++ Linking release built library with my debug build
<p>I've downloaded a 3rd party library, and built the .lib file in 'release' mode. After adding the lib to my project, if i run my project in release mode, it's fine. But if i run my project in debug mode, i get an error:</p> <pre><code>_iterator_debug_level value '0' doesn't match value '2; </code></pre> <p>I could rebuild the library in debug mode, but I don't think I'll need to be debugging the library itself? And I've downloaded prebuilt 3rd party libraries before which only come with a release build (i assume?) that link fine whether my project is in debug or release. I'm wondering how that is done.</p>
c++
[6]
1,846,830
1,846,831
Python lib to make nice command line scripts with options etc
<p>I remember coming reading about a python module/lib that helped make nice command line scripts that takes in options.</p> <p>My python script (1 file) does many things, and currently I comment out/uncomment the function I want run in my <strong>main</strong> section.</p> <p>I was hoping someone knows the lib I'm talking about that would help me organize the various functions and call them when I run the .py script.</p>
python
[7]
4,821,325
4,821,326
nivo slider pause on last slide
<p>Client has 5 sliders that will switch over at random times, but pause for two or three seconds when the last one has changed over. There are only 2 images per "slider"</p> <p>I figured I would use nivo slider as it looked promising.</p> <p>I have set up the different divs and sizing for each slider and got positioning right, but I'm not sure what i'm doing with the Jquery.</p> <p>I've tried other effects that people have posted up on here, but no help. one example...</p> <pre><code>$(window).load(function(){ $('#slider').nivoSlider({ animSpeed: 500, pauseTime: 4000, effect : 'fade', directionNav : false, controlNav: false, }); jQuery('#slider').data('nivoslider').stop(); setTimeout("jQuery(#slider').data('nivoslider').start()",5000); }); </code></pre> <p>This is how I'm thinking it should work.</p> <p>slider1 - switch after .5 seconds (pause) slider 4 - switch after .75 seconds (pause) slider 3 - switch after 1 second (pause) slider 2 - switch after 1.25 seconds (pause) slider 5 - switch after 1.5 seconds (pause) They all start random switch again after 2 or 3 second pause.</p> <p>Sorry if this is long, hope somebody can help</p> <p>Thanks</p> <p>Vic</p>
jquery
[5]
3,190,391
3,190,392
Null-Pointer by findViewById
<p>I have in my onCreate-Method a lot of findViewById. Some of them are parameter for objects I make in the onCreate-Method. Now I tried to make the findViewById-call in the Constructor of my Objects but i get a Null-Pointer. How do I get these findViewByIds in my Object?</p>
android
[4]
4,819,974
4,819,975
onDestroy method not exist in receiver. What is alternative?
<p>I am using a <code>Service</code> and I dynamically register a receiver like</p> <pre><code>private BroadcastReceiver yourCallReceiver; yourCallReceiver = new CallReceiver(); // Registers the receiver so that your service will listen for broadcasts registerReceiver(yourCallReceiver, theCallFilter); </code></pre> <p>and unregister like</p> <pre><code>@Override public void onDestroy() { super.onDestroy(); // Do not forget to unregister the receiver!!! unregisterReceiver(yourCallReceiver); } </code></pre> <p>but i am having problems that i need to shutdown some work whene i unregister receiver, but receiver does not have <code>onDestroy</code> method. How can i do this? how can i stop some third party work when unregister receiver in service? is this even possible?</p>
android
[4]
3,950,976
3,950,977
Android Redrawing an image to new position when the screen is touched
<p>I am trying to write a small android app that redraws an image everytime the screen is touched.</p> <p>I expected the image to be redrawn to the new <code>x,y</code> coordinates provided by <code>event.getX()</code> and <code>event.getY()</code> when I override the <code>onTouch(Event)</code> method in an activity.</p> <p>Can anyone help?</p>
android
[4]
3,383,029
3,383,030
javascript form validation suddenly stops working
<p>in my code i called a javascript function onsubmit of a form and inside the function making validation to my fields by using formname.fieldname.value and it works fine but suddenly it doesn't work display me an error "formname is not defined".</p> <p>Thanks in advance </p>
javascript
[3]
2,529,464
2,529,465
C# List All Permutation
<p>I have a problem.I developed a program with Apriori Algorithm.In Apriori Algorithm,I must take permutation values.For This</p> <pre><code>foreach (String s1 in array1) { foreach (String s2 in array2) { String result = s1 + " " + s2 + " " + s3; //Processing } } </code></pre> <p>I coding something.But this code only taking binary permutation.I must take binary,triple,four,quintet permutations with Automatically. Do u have idea for this?</p>
c#
[0]
283,560
283,561
Is this a bug in PHP?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4750781/php-array-behaving-strangely-with-key-value-07-08">php array behaving strangely with key value 07 &amp; 08</a> </p> </blockquote> <p>I've found something weird in PHP, if I use numeric arrays the 8th array gets ignored, here when I put 'Cherry' into $fruit[08], php seams to step over it.</p> <p>What's going on ? Is this a bug or something else.</p> <pre><code>&lt;pre&gt; &lt;?php $fruit[01] = "Apples"; $fruit[02] = "Pears"; $fruit[03] = "Bananas"; $fruit[04] = "Grape"; $fruit[05] = "Orange"; $fruit[06] = "Peach"; $fruit[07] = "Lemon"; $fruit[08] = "Cherry"; $fruit[09] = "Mango"; print_r($fruit); ?&gt; &lt;/pre&gt; </code></pre> <p>Output:</p> <pre><code>Array ( [1] =&gt; Apples [2] =&gt; Pears [3] =&gt; Bananas [4] =&gt; Grape [5] =&gt; Orange [6] =&gt; Peach [7] =&gt; Lemon [0] =&gt; Mango ) </code></pre>
php
[2]
3,811,734
3,811,735
Android: How to resume an App from a Notification?
<p>I am trying to program my notification to RESUME my app, instead of simply starting a new instance of my app... I am basically looking for it to do the same thing as when the Home button is long-pressed and the app is resumed from there.</p> <p>Here is what I am currently doing:</p> <pre><code>void notifyme(String string){ String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); int icon = R.drawable.notification_icon; // icon from resources CharSequence tickerText = string + " Program Running..."; // ticker-text long when = System.currentTimeMillis(); // notification time Context context = getApplicationContext(); // application Context CharSequence contentTitle = *********; // expanded message title CharSequence contentText = string + " Program Running..."; // expanded message text Intent notificationIntent = new Intent(this, Main.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); // the next two lines initialize the Notification, using the configurations above Notification notification = new Notification(icon, tickerText, when); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); final int HELLO_ID = 1; mNotificationManager.notify(HELLO_ID, notification); } </code></pre> <p>I am guessing that the new Intent line is where the problem lies... any help would be appreciated!</p>
android
[4]
436,668
436,669
Get selected text with format using javascript
<p>Basically, I want style of selected text. Suppose, I have a full text "Hello world to sample application" placed in div. Then I made a word "Hello" in bold. I want to retrieve style of word "Hello" word and not of whole div. There is one method "getCommandValue" method available but not working with Firefox. "getComputedStyle" method gives style of the object and not of selected text in div. Please suggest. It's urgent. Thanks a lot.</p>
javascript
[3]
4,695,403
4,695,404
How to pass a dymamic array of strings pointers from C++ to a C function
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7048888/stdvectorstdstring-to-char-array">std::vector&lt;std::string&gt; to char* array</a> </p> </blockquote> <p>I have to call a c function that accepts an array of string pointers. Example</p> <pre><code>void cFunction(char* cities[], int count) { for(int i = 0; i &lt; count; ++i ) { printf("%s\n", cities[i]); } } </code></pre> <p>Assume that function is in some third party libabry; it cannot be changed<br> I can declare a static array and call the function like this<br></p> <pre><code>char* placesA[] = {"Teakettle Junction", "Assawoman Bay", "Land O' Lakes", "Ion", "Rabbit Hask" }; cFunction(placesA, 5); </code></pre> <p><br> That works. But my data is dynamic i.e. the size of the array changes many times at runtime<br> So I tried this<br></p> <pre><code>std::vector&lt;std::string&gt; placesB(placesA, placesA + 5); cFunction(&amp;placesB[0], 5); // this won't work because std::string != char*[] </code></pre> <p><br> Tried this <br></p> <pre><code>std::vector&lt;char*&gt; placesC; cFunction(&amp;placesC[0], 5); </code></pre> <p>I find <code>placesC</code> awkward to populate at the sametime avoid memory leaks<br> I am looking for a solution that is both efficient ( as little string copying as possible and preferably uses STL and or Boost )</p>
c++
[6]
807,623
807,624
Handling the different results from parsedatetime
<p>I'm trying to learn python after spending the last 15 or so years working only in Perl and only occasionally.</p> <p>I can't understand how to handle the two different kinds of results from the parse method of Calendar.parse() from parsedatetime</p> <p>Given this script:</p> <pre><code>#!/usr/bin/python import parsedatetime.parsedatetime as pdt import parsedatetime.parsedatetime_consts as pdc import sys import os # create an instance of Constants class so we can override some of the defaults c = pdc.Constants() # create an instance of the Calendar class and pass in our Constants # object instead of letting it create a default p = pdt.Calendar(c) while True: reply = raw_input('Enter text:') if reply == 'stop': break else: result = p.parse(reply) print result print </code></pre> <p>And this sample run:</p> <blockquote> <p>Enter text:tomorrow<br> (time.struct_time(tm_year=2009, tm_mon=11, tm_mday=28, tm_hour=9, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=332, tm_isdst=-1), 1) </p> <p>Enter text:11/28<br> ((2009, 11, 28, 14, 42, 55, 4, 331, 0), 1) </p> </blockquote> <p>I can't figure out how to get the output such that I can consisently use result like so:</p> <pre><code>print result[0].tm_mon, result[0].tm_mday </code></pre> <p>That won't work in the case where the input is "11/28" because the output is just a tuple and not a struct_time. </p> <p>Probably a simple thing.. but not for this newbie. From my perspective the output of Calendar.parse() is unpredictable and hard to use. Any help appreciated. Tia.</p>
python
[7]
3,963,878
3,963,879
change column header in JTable if i know column position
<p>Can i change column header in Jtable tab from "Name" to "Surname" if i know column position? I want to change column name in second or first tab, not last one.</p> <p>with this code i can change only culumn header in last tab. i have 4 tabs.</p> <pre><code>JTableHeader th = table.getTableHeader(); TableColumnModel tcm = th.getColumnModel(); TableColumn tc = tcm.getColumn(0); tc.setHeaderValue( "???" ); th.repaint(); </code></pre>
java
[1]
5,498,336
5,498,337
Error function routine
<p>Pls what is the best approach considering (performance, security etc.) to implement an error function. Something in the line of ..</p> <pre><code>function trap_errors($error_code, $parametrs...) { $error_code = array =&gt; ('1001 = Error description1', '1002 = Error description2',..etc. ) } </code></pre> <p>I dont know if the above makes sense. Any pointers?..</p>
php
[2]
5,504,066
5,504,067
Testing when an UIImage background color has changed
<p>I have a student working on a project where he has a UIImage where he is able to draw a line on the screen. We want to know if you have any idea if he goes back and forth filling the entire screen with lines is there a way to test that every pixel has been covered with the line color? For example if the background is grey and the pen color is blue if he goes back and forth enough the screen will begin to turn blue. We want to test what areas are blue and what areas are still grey. </p> <hr> <p>The following segment of code will draw a line on the screen. If I run a loop the whole screen will eventually be filled with lines,criss crossed back and forth, and the screen will have the color of the line pen color.</p> <pre><code>UIGraphicsBeginImageContext(self.view.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0); // sets width of pen CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 0.0, 0.0, 1.0, 1.0); // controls color CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y); CGContextStrokePath(UIGraphicsGetCurrentContext()); drawImage.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); </code></pre>
iphone
[8]
1,975,975
1,975,976
from elements in a line to key and values
<p>I have a file with lines like this:</p> <pre><code>no.3 normal yes 54 0,543 12 </code></pre> <p>And I should end up with <code>("normal", yes, 54, 0.543, 12)</code> when I <code>print info(no.3)</code></p> <p>I have started by splitting up in lines. But now I'm not sure what to do?</p> <p>As I can see, I need to use the first element as key, and the remaining as value. But I'm not sure where to start?</p>
python
[7]
806,131
806,132
UIViewController Release in iphone
<p>I am Using 5 pages in my project.. Here i can navigate pages 1 to 5 one by one using presentModelViewController.. How to release in between pages such as 2,3,4 when i navigate from page 5 to page 1.. </p> <p>Thanks..</p>
iphone
[8]
3,015,674
3,015,675
How do we prevent default actions in JavaScript?
<p>What is the cross-browser method? I need to prevent any default action on an image, so that neither dragging nor anything else will fire on a default bases.</p>
javascript
[3]
5,262,401
5,262,402
converting web page scraper from python 2 to python 3
<p>I've a python 2 script to scrape data from a reddit thread, but I've currently got python 3 installed.</p> <p>I've no python knowledge, but have googled that the (initial?) problem is urllib2.</p> <p>Would this be easy to convert to python 3, or would it be better to install python 2?</p> <p>Code here:</p> <pre><code>import urllib2 import json # grab data raw_data = urllib2.urlopen('http://www.reddit.com/r/books/comments/cy3gy/what_books_are_you_reading_right_now/.json').read() thread_data = json.loads(raw_data)[1] toplevel_comments = thread_data['data']['children'] # extract books, upvotes and downvotes votes = dict() for book in toplevel_comments: try: book_name = book['data']['body'] book_upvotes = book['data']['ups'] book_downvotes = book['data']['downs'] votes[book_name] = (book_upvotes, book_downvotes) except KeyError: break # create a dictionary sorted by upvotes votes_by_up = reversed(sorted(votes.items(), key = lambda t: t[1][0])) # print for item in votes_by_up: book_name, votes = item book_upvotes, book_downvotes = votes print(book_name + ' -- ' + str(book_upvotes) + ' upvotes, ' + str(book_downvotes) + ' downvotes') </code></pre>
python
[7]
3,798,151
3,798,152
Python os.getcwd paths
<p>I'm using os.listdir() to get all the files from a directory and dump them out to a txt file. I'm going to use the txt file to import into access to generate hyperlinks. The problem I'm having is getting the correct path. So when the script is ran it uses whatever directory you are in. Here is an example. Right now it half works, it create links.txt, but there is nothing in the text file.</p> <pre><code>myDirectory = os.listdir("links") f.open("links.txt", "w") f.writelines([os.getcwd %s % (f) for f in myDirectory]) </code></pre>
python
[7]
373,563
373,564
How can I select all elements without a given class in jQuery?
<p>Given the following:</p> <pre><code>&lt;ul id="list"&gt; &lt;li&gt;Item 1&lt;/li&gt; &lt;li class="active"&gt;Item 2&lt;/li&gt; &lt;li&gt;Item 3&lt;/li&gt; &lt;li&gt;Item 4&lt;/li&gt; &lt;li&gt;Item 5&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>How can I select all but Item 2, AKA something like:</p> <pre><code>$("ul#list li!active") </code></pre>
jquery
[5]
5,895,695
5,895,696
ColorTranslator.ToHtml() return string issue
<p>I need hexadecimal string of color so I am using ColorTranslator.ToHtml() property which returns string hex of Color.</p> <p>if I choose a random color it returns "#FFF0B6" etc. However, if I choose a system-defined color for example Color.Black it returns "Black" in string.</p> <p>I need hexadecimal color codes in string whether they are defined in system or not. Any suggestions?</p>
c#
[0]
3,337,267
3,337,268
Using an Android Long-Button press to increment/decrement counter
<p>I want to be able to press a button on my program and hold it down (without releasing) to increment a variable. Problem I am having right now is when I conduct the long button press it only runs once, until I release and press again. </p> <p>First I want to find out if there is a way to do this without having to use the OnTouchListener, and just using the OnLongClick. Is there a way to check the value of the button? For example.. buttondown=true; Conduct a whileloop to increment until the button is released.</p> <p>Second, I don't want the updates to be delayed, because the incremented value is being drawn as the user holds down the button.</p> <p>Basically I am doing something like this:</p> <pre><code>btn_resume.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { ..code.. return true; } }); </code></pre>
android
[4]
5,546,552
5,546,553
How do I make a menu that does not require the user to press [enter] to make a selection?
<p>I've got a menu in Python. That part was easy. I'm using <code>raw_input()</code> to get the selection from the user. </p> <p>The problem is that <code>raw_input</code> (and input) require the user to press Enter after they make a selection. Is there any way to make the program act immediately upon a keystroke? Here's what I've got so far:</p> <pre><code>import sys print """Menu 1) Say Foo 2) Say Bar""" answer = raw_input("Make a selection&gt; ") if "1" in answer: print "foo" elif "2" in answer: print "bar" </code></pre> <p>It would be great to have something like</p> <pre><code>print menu while lastKey = "": lastKey = check_for_recent_keystrokes() if "1" in lastKey: #do stuff... </code></pre>
python
[7]
304,891
304,892
C# catch control's change event from its container
<p>In my project I have a settings form. Where if any changes happen I have to notify user about it if he wants to leave that page without saving his changes. At this time I am doing this by catching every control change event. I am sure there is a better way - like catching the change event from its container. Is it possible?</p>
c#
[0]
383,508
383,509
c# how to get the row number from a datatable
<p>i am looping through every row in a datatable:</p> <pre><code>foreach (DataRow row in dt.Rows) {} </code></pre> <p>i would like to get the index of the current row within the dt datatable. for example:</p> <pre><code>int index = dt.Rows[current row number] </code></pre> <p>how do i do this?</p>
c#
[0]
2,412,074
2,412,075
Reading text files in c++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/10888391/link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-invalid-or-c">LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt after installing VS2012 release preview</a> </p> </blockquote> <p>I am trying to read a text file in c++ visual studio 2010 through a windows32 console app. When using the fstream to try to read the text file I get the lnk 1123 error which says the conversion to COFF failed and that the file is either invalid or corrupt. I know the file is just a simple text file with a list of numbers. Is there a fix for this?</p>
c++
[6]
1,930,485
1,930,486
httpClient doesn't retry the request
<p>I'm using the spring android rest template 1.0.0.M2 version, I need to set the request time out and the retry attempt. I did it in following way.</p> <pre><code>//Time out httpComponentsClientHttpRequestFactory.setReadTimeout(5000); restTemplate.setRequestFactory(httpComponentsClientHttpRequestFactory); //set the reattempt client.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(retryCount, false)); </code></pre> <p>Problem is when read time out occurs it's not retry the request again. Can some one help me on this.</p> <p>Thanks Sam.</p>
android
[4]
850,324
850,325
Clearing Input Fields with JavaScript
<p>I've been looking at this for the last few hours, and can't really achieve what I'm looking for. I currently have the following two inputs:</p> <pre><code>&lt;input type="text" id="username" value="USERNAME" onfocus="inputFocused(this)" onblur="inputBlurred(this)" /&gt; &lt;input type="password" id="password" value="PASSWORD" onfocus="inputFocused(this)" onblur="inputBlurred(this)" /&gt; </code></pre> <p>Initially, the inputs text is grey, and I have the following JavaScript functions onfocus and onblur:</p> <pre><code>var defaultInput = ""; function inputFocused(obj){ defaultInput = obj.value; obj.value = ""; obj.style.color = "#000"; } function inputBlurred(obj){ if(obj.value == ""){ obj.style.color = "#AAA"; obj.value = defaultInput; } } </code></pre> <p>I'm trying to devise a way so that once I start typing into a field, leave the field, then return, it will not clear the input again (since it will then contain something the user typed in it). I've thought of achieving this with some kind of variable that I can alternate between 1 and 0 depending on the state, but that seemed sloppy. Any insight for this JS novice is greatly appreciated.</p>
javascript
[3]
346,669
346,670
Efficient in Java strings
<p>This sentences are equals <code>myString != null</code>, <code>myString.length() &gt; 0</code> and <code>! myString.equals("")</code> ? Wich is the most efficient? (Java 1.4)</p>
java
[1]
2,327,155
2,327,156
I am not able show another controller using presentModalViewController:
<p>Please see the code</p> <pre><code> -(IBAction)startGame{ NSLog(@"Button is pressed"); CharadesAppDelegate *del=(CharadesAppDelegate*)[[UIApplication sharedApplication]delegate]; [del setAllTeams:teamDict]; [del setScore:selectedScroll]; Playing *p=[[Playing alloc]init]; [self presentModalViewController:p animated:YES]; } </code></pre> <p>I want to present Playing controller which only contains following line</p> <pre><code> - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]]; </code></pre> <p>} but unfortunately I am not able to switch to another controller nothing happens when I press the button , please help</p>
iphone
[8]
2,479,725
2,479,726
code how to make an external authentication with gmail account android
<p>I am developing an application where I have an initial login. I want the user to access my app through her gmail account. </p> <p>Can someone help me with some code or tutorial? I don't quite understand the documentation from google...</p>
android
[4]
5,946,302
5,946,303
Convert Textbox Text to Date while text changing
<p>What I want is when user input text in textbox in normal way, text change to date format. for example when user are entering 20110110 text change to 2011/01/10 </p>
c#
[0]
137,254
137,255
iPhone App Development - Audio Queue Recording
<p>I am currently working on an App which needs to get some data from the microphone. I have read through some resources on the Internet and believe that Audio Queue is a good library to do it.</p> <p>I only need to get an array which stores the microphone input data, and do not need to play it back.</p> <p>Can anyone kindly give some hints on that? Greatly appreciated if a simple sample/essential code fragments can be given.</p>
iphone
[8]
3,788,411
3,788,412
How to manipulate Android classes
<p>New to Android. Trying to find docs that show what Android classes expect to elicit changes. For example, to make a keyboard always visible, I could find some info searching Google, but not directly in the docs of the SDK. Is there a source for more comprehensive docs on how Android works not just from the individual class level, but how it boots up and what to do to make small tweaks for an app.</p>
android
[4]
3,118,620
3,118,621
Hiding and showing groups of elements
<p>I have a page where all items of class 'div_title_item' are initially hidden. Base on some paginator logic I would then like to show some of them.</p> <pre><code>// initially $(".div_title_item").hide(); // this works fine </code></pre> <p>Now the showing part. I tried below but it didn't work.</p> <pre><code>// on some event for example var collection = $(".div_title_item"); collection[0].show(); collection[1].show(); // etc... </code></pre> <p>Nothing is shown.</p>
jquery
[5]
3,649,345
3,649,346
white space allowed as part of file path?
<p>My question is kinda related to <a href="http://stackoverflow.com/questions/5365780/android-asset-not-working-on-honeycomb">android_asset not working on Honeycomb?</a></p> <p>Is it allowed to have spaces in the file path name of an html page located in the assets folder?</p> <p>For ex: Is the following legal?</p> <pre><code>mWebView = (WebView) findViewById(R.id.webView1); mWebView.loadUrl("file:///android_asset/Help File/helpfile.html"); </code></pre> <p>Is there any other solution other than renaming the "Help File" directory to have no spaces in it?</p> <p>TIA.</p>
android
[4]
689,390
689,391
php address request
<p>i have this request method:</p> <pre><code>if (!$_REQUEST['0']) { echo "Address missing..."; die(); } else { code code etc. } </code></pre> <p>And address is: <a href="http://localhost/api.php?0=" rel="nofollow">http://localhost/api.php?0=</a><em>address</em></p> <p>If I open: <code>api.php?0=0</code> I should get another error which says address doesn't correct. But I get <code>Address missing</code>... In my opinion something wrong with:</p> <pre><code>if (!$_REQUEST['0']) </code></pre> <p>Any ideas?</p>
php
[2]
1,267,055
1,267,056
Install icons from android asset studio
<p>I need to install tab icons from Android asset studio. The downloaded zip contains a res folder with another folders: drawable, drawable-hdpi, etc. I've copied the files from the res/drawable in the downloaded zip, into the res/drawable folder and I've done the same with hdpi, ldpi and mdpi.</p> <p>Then I used the code:</p> <pre><code> firstTabSpec.setIndicator("tabname",getResources().getDrawable(R.drawable.ic_tab_myicon)); </code></pre> <p>But the app does not run because there is no icon. My icon does not appear in the list, however, does appear ic_menu_camera and others android icons. </p> <p>The code works fine with other icons like “ic_menu_camera”.</p> <p>Could someone help me?</p> <p>Thank you!</p>
android
[4]
1,134,413
1,134,414
UIScrollView landscape problems
<p>I'm playing around with the page control sample code.</p> <p>I changed the code to start the app in landscape, the app opened in the simulator but the app was still in portrait mode in a horizontal simulator.</p> <p>I then put the following code into the PhoneContentController.m file and the MyViewController.m file and changed the MyView.xib view to landscape.</p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientationUIIn terfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape(interfaceOrienta tion); } </code></pre> <p>Now what happens is the app starts in landscape mode with the first image displaying correctly. The problem now is the other images are showing on their sides and the scrollview is scrolling vertically instead of horizontally.</p> <p>How can I get this to scroll horizontally in landscape mode with all the images also in landscape mode?</p>
iphone
[8]