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
3,629,298
3,629,299
not able to get contentsize.height value in viewwillappear for uitableview
<p>i have created uitable(tblPartySizeSummary) view programmatically.i am calling contentsize.height in viewwillappear.i am getting 0 for content size.height.i am trying to fix scroll if content size is less or equal to table view height i have called all delegates and datasource method properly. my code is as below :</p> <pre><code>tblPartySizeSummary=[[UITableView alloc] initWithFrame:CGRectMake(0,155, 320,212) style:UITableViewStylePlain]; tblPartySizeSummary.tag=2; tblPartySizeSummary.backgroundColor=[UIColor clearColor]; tblPartySizeSummary.rowHeight=40; CGFloat f; f=[self tableViewHeight]; //tblPartySizeSummary.scrollEnabled=YES; tblPartySizeSummary.delegate=self; tblPartySizeSummary.dataSource=self; tblPartySizeSummary.separatorColor=[UIColor lightGrayColor]; [self.view addSubview:tblPartySizeSummary]; NSLog(@"Content size height is %@",[tblPartySizeSummary contentSize].height); if(tblPartySizeSummary.contentSize.height &lt; tblPartySizeSummary.frame.size.height) { tblPartySizeSummary.scrollEnabled=NO; } else { tblPartySizeSummary.scrollEnabled=YES; } </code></pre> <p>where should i call tblPartySizeSummary.contentSize.height? any suggestion ? thanks?</p>
iphone
[8]
2,130,930
2,130,931
Unpack positional arguments from data structure in Python
<p>given:</p> <pre><code>def psum(a,b,c): return a**b+c </code></pre> <p>and <code>x = [1,2]</code> and <code>y = 3</code> how can I do <code>psum(*x,3)</code> --> an equivalent.</p> <p>I do not want to do <code>x[0], x[1]</code> because a function returns <code>x</code> and calling it twice would be inefficient. Could one do <code>z = function(a)</code>. where <code>z = x</code>. and then do <code>z[0]</code>, <code>z[1]</code>.</p> <p>But I'm wondering if one can do this otherwise and use positional arguments in such a way.</p> <p>Also, <em>without</em> using a wrapper.</p> <p>Edit: One cannot use names because I didn't implement the function and the function writers did not use named arguments :/</p>
python
[7]
3,731,135
3,731,136
Delay displaying a fixed bar, but hide it instantly
<p>I currently have the following code which delays showing a fixed bar after a certain point.</p> <p>The code hides the fixed bar if you scroll up to the top, but automatically shows the bar after 2 seconds, even though the scroll point is below 70, so it should be hidden all together.</p> <pre><code> $(window).scroll(function() { if($(window).scrollTop() &gt; 70) { $('#mini-header').delay(2000).show(0); } else if($(window).scrollTop() &lt; 70) { $('#mini-header').hide(); } }); </code></pre> <p>A <a href="http://jsfiddle.net/fKqMN/" rel="nofollow">jsFiddle</a> shows the behaivor.</p>
jquery
[5]
3,657,548
3,657,549
What's wrong with my sub-classed AVAudioPlayer?
<p>I sub-classed AVAudioPlayer like so:</p> <pre><code>#import &lt;AVFoundation/AVFoundation.h&gt; @interface AudioPlayer : AVAudioPlayer { // irrelevant objects... } -(void) myMethod; @end </code></pre> <p>I also placed myMethod in the implementation. In another class, I instantiate the sub-class (not AVAudioPlayer) and import the header.</p> <p>When I attempt to call myMethod, I get the error:</p> <p>[AVAudioPlayer myMethod]: unrecognized selector sent to instance</p> <p>I'm certain I created an AudioPlayer class, not AVAudioPlayer, so what gives?</p>
iphone
[8]
5,375,509
5,375,510
Get Text Element
<p>I am a beginner. I am trying to pop up an alert box with the text contents of a <code>&lt;div&gt;</code>, but am getting <code>null</code>.</p> <p>Javascript: </p> <pre><code>alert(document.getElementById("ticker").value); </code></pre> <p>HTML</p> <pre><code>&lt;asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"&gt; &lt;script src="Tick.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"&gt; &lt;div id="ticker"&gt; Sample &lt;/div&gt; &lt;/asp:Content &gt; </code></pre> <p>What am I doing wrong?</p>
javascript
[3]
4,377,112
4,377,113
Is there are way to combine "is" and "as" in C#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/7113347/c-assignment-in-an-if-statement">C# - Assignment in an if statement</a> </p> </blockquote> <p>I find my myself doing the following multiple time</p> <pre><code>if (e.row.FindControl("myLiteral") is Literal) { (e.row.FindControl("myLiteral") as Literal).Text = "textData"; } </code></pre> <p>Is there way to replace the "if" part and simplify the setter:</p> <pre><code>(e.row.FindControl("myLiteral") &lt;some operator that combines is and as&gt; .text = "textData"; </code></pre> <p>EDIT: I should have mentioned this before- I want to remove the 'if' entirely.<br> "some operator " should do this internally and set the ".text" only if e.row.FindControl is a literal</p>
c#
[0]
3,197,704
3,197,705
Cannot compute Count for a data source that does not implement ICollection
<p><code>enter code here</code>hi. i am trying to implment custom paging in datalist control . and i am using Pagedatasource to schive this one PagedDataSource objPage = new PagedDataSource();</p> <pre><code>try { datatable ds= (datatable)viewstate["dtimages"] objPage.AllowPaging = true; //Assigning the datasource to the 'objPage' object. objPage.DataSource = ds.Dataset.Tables["Gallery"].ToString(); //Setting the Pagesize objPage.PageSize = 8; dlGallery.DataSource = objPage; dlGallery.DataKeyField = "Image_ID"; **dlGallery.DataBind();// getting error** } catch(Exception ex) { throw ex; } </code></pre> <p>Cannot compute Count for a data source that does not implement ICollection.</p> <p>why is this happening does any one can help me out thank you </p>
asp.net
[9]
4,221,563
4,221,564
Calling a php function with the help of a button or a click
<p>I have created a class named as "member" and inside the class I have a function named update(). Now I want to call this function when the user clicks 'UPDATE' button.<br> I know I can do this by simply creating an "UPDATE.php" file. </p> <p>MY QUESTION IS :-</p> <p>Can I call the "update() function" directly without creating an extra file? I have already created an object of the same class. I just want to call the update function when the user clicks on update button.</p>
php
[2]
5,634,580
5,634,581
Android refresh button
<p>Hai, I am developing an application in Android. In that there is a refresh button. If I click that button, the page needs to be reloaded like when execution begins. Is there any built in method in Android for getting this?</p> <p>Thanks in Advance</p>
android
[4]
4,986,298
4,986,299
subverting adblock detection?
<p>Several questions concern how to detect adblock use, but I couldn't find any that explained how to <strong>subvert</strong> detection?</p> <p><img src="http://i.stack.imgur.com/z0o6P.png" alt="enter image description here"></p>
javascript
[3]
4,143,975
4,143,976
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]
1,941,483
1,941,484
Android Licensing Service - LicenseChecker always times out
<p>I'm implementing the licensing service in one of my apps. I have set the test response to LICENSED. Anyway it always invokes the dontAllow() function. Locat sais:</p> <pre><code>08-17 23:44:53.956: INFO/LicenseChecker(479): Binding to licensing service. 08-17 23:44:54.556: INFO/LicenseChecker(479): Calling checkLicense on service for de.goddchen.android.xy 08-17 23:45:04.567: INFO/LicenseChecker(479): Check timed out. </code></pre> <p>So, what am I doing wrong? I'm using a 2.2 API emulator and I configured my publisher google account on it. Any ideas?</p>
android
[4]
2,772,823
2,772,824
missing } after property list
<p>I know this is something easy but I just can't see it. Can anyone tell me why I am getting the error "missing } after property list" for the following code:</p> <pre><code>var $newCandleDialog = $('&lt;div&gt;&lt;/div&gt;') .load('/prodash/dash_access.php?urlInit=candles/getCanStatus.php','it='+newData) .dialog({ autoOpen: false, title: 'Active Mode: New Candles!', modal: true, buttons: { "Load new candles": function() { $("#canHint").load('/prodash/dash_access.php?urlInit=candles/getcandles.php','q=0&amp;show=05&amp;strength=00'); $( this ).dialog( "close" ); } Cancel: function() { $( this ).dialog( "close" ); } } }); </code></pre> <p>Firebug starts the error with the "Cancel: function" line.</p> <p>Thank you in advance!</p>
jquery
[5]
5,528,219
5,528,220
Javascript: How convert array of objects to object with sorted unique arrays?
<p>Have data that has this kind of structure:</p> <pre><code>$input = [ { animal: 'cat', name: 'Rocky', value: 1 }, { animal: 'cat', name: 'Spot', value: 2 }, { animal: 'dog', name: 'Spot', value: 3 } ]; </code></pre> <p>Need fastest possible method for converting to this format:</p> <pre><code>$output = { animal: [ 'cat', 'dog' ], name: [ 'Rocky', 'Spot' ], value: [ 1, 2, 3 ] }; </code></pre> <p>The output should have keys equal to each of the keys in each object from the input. And the output values should be arrays with the sorted unique values. I found a few ways to do it using nested loops, but slower than I would like. With 30,000 elements to the input array with 8 keys for each of the objects, the best I have been able to do is 300ms in Chrome. Would like to get down to 100ms. Is there any faster method using a map or reduce?</p>
javascript
[3]
513,559
513,560
Writing to file across activities in append mode in android
<p>i have an application which has some set of actvities say 5.</p> <p>But now i want to write to common file among all activities .<strong>Does the data written to file in one activity shall reflect in the other activity so that offset of the file is shared</strong>?</p> <p>i have a problem here i may need to switch between activities many times,so an activity may gets instantiated and destroyed so many times. so if i open the same file again and again in oninit method of each activity is that going to create problem for me.</p> <p>please tell me some effective ways to accomplish this task.</p>
android
[4]
815,366
815,367
Auto generate serial no in gridview
<p>I want to generate serial no in gridview asp.net. Can you please help me how i do it. Thnx in advance</p>
asp.net
[9]
1,876,259
1,876,260
How do I do an AcceptAsync of a socket with a timeout?
<p>Here is what I have now:</p> <pre><code>Socket myNewSocket = currentSocket.Accept(); </code></pre> <p>Here is what I want:</p> <pre><code>Socket myNewSocket = AcceptWithTimeout(currentSocket, timeoutInMilliseconds) </code></pre>
c#
[0]
1,536,690
1,536,691
How to get Control back from NSOperationQueue
<p>Can you please tell me How can I get Control back from NSOperationQueue</p> <p>Following is my real question which I asked earlier:</p> <p>Hi friends , I made an app which plays the song on clicking on the image of artist.(see image attached). Each artist image is implemented on button and on clicking this button, a function is being called which first downloads and then plays the song. I passed this method(function) in a thread but problem is that every time when I click on the image of artist(button) new threads starts running and then multiple songs gets started playing concurrently. How can I use "NSOperation and NSOperationQueue" so that only one song will run at a time . Please help.</p> <p><img src="http://i.stack.imgur.com/suCLn.png" alt="alt text"> Thanks in advance</p> <p>Now I am able to play song by adding them in queue but when songs starts playing i m not able to do anything on my Screen until song is finished or I scroll the table. </p>
iphone
[8]
1,928,314
1,928,315
How do I do a deep copy of a 2d array in Java?
<p>I just got bit by using .clone() on my 2d boolean array, thinking that this was a deep copy.</p> <p>How can I perform a deep copy of my boolean[][] array?</p> <p>Should I loop through it and do a series of System.arraycopy's?</p>
java
[1]
527,180
527,181
jquery 'invalid expression' using selector on a tablecell
<p>Hi can someone tell me what i'm doing wrong in this jquery statement. I have a 'row' object which contains any number of tablecells, and i'm looking only for the cells that contain a textbox or text area.</p> <p>This statement works fine:</p> <pre><code>var $textCells = jQuery('td:has(textarea)', row); </code></pre> <p>but i need to include 'text', inputs, and this is where is blows up:</p> <pre><code>var $textCells = jQuery('td:has(textarea,input[@type=text])', row); </code></pre> <p>I get an 'Unrecognized expression error'. Can someone set me straight? Thanks</p>
jquery
[5]
1,782,993
1,782,994
How can I set a string with parenthesis and other items to a variable in PHP?
<p>I am trying to test some of these code here <a href="http://ha.ckers.org/xss.html" rel="nofollow">http://ha.ckers.org/xss.html</a> on my code. To do so I need to set the codes on that page into a PHP variable, I am having trouble though. </p> <p>For example this code below is incorrect just for setting it to a variable because of the "code" and 'code' the <strong>'"</strong> is what I am talking about. How can I set code from that page or below into a PHP variable for testing? </p> <pre><code>$string = '&lt;IMG SRC=\"javascript:alert('XSS');\"&gt;&lt;b&gt;hello&lt;/b&gt; hiii'; </code></pre>
php
[2]
4,522,287
4,522,288
Can't install AIR on Galaxy Android device
<p>I'm doing some AIR for Android development but when I try and launch my app I am told I need to install Adobe AIR. After being taken to the Google Play site I get the message that "Your device isn't compatible with this version."</p> <p>I updated my OS to Android 4.04 but I still get this message. How can I get Adobe AIR installed?</p>
android
[4]
509,911
509,912
Address of &this instantiated class?
<p>My goal is to write a function that returns the address of the instantiated class from which it is called. </p> <p>My initial guess was </p> <p>return &amp;this</p> <p>But this does not yield any good results.</p> <p>Any and all suggestions are much appreciated! Thanks!</p>
c++
[6]
4,212,978
4,212,979
Reusing Android Lock Pattern
<p>I am writing a application and it should be protected with a password. Instead of building a new one, Is it possible to use the Android's Pattern lock screen from application with different patterns?</p>
android
[4]
5,564,642
5,564,643
What does it mean to flush file contents in Python?
<p>I am trying to teach myself Python by reading documentation. I am trying to understand what it means to flush a file buffer. According to documentation, "file.flush" does the following.</p> <pre><code>Flush the internal buffer, like stdio‘s fflush(). This may be a no-op on some file-like objects. </code></pre> <p>I don't know what "internal buffer" and "no-op" mean, but I think it says that <code>flush</code> writes data from some buffer to a file.</p> <p>Hence, I ran this file toggling the pound sign in the line in the middle.</p> <pre><code>with open("myFile.txt", "w+") as file: file.write("foo") file.write("bar") # file.flush() file.write("baz") file.write("quux") </code></pre> <p>However, I seem to get the same <code>myFile.txt</code> with and without the call to <code>file.flush()</code>. What effect does <code>file.flush()</code> have?</p>
python
[7]
1,050,136
1,050,137
javascript function override
<p>Is it possible to completely override the function callwithargs that accepts some arguments with another new function callwithargs with no arguments?</p> <pre><code>function callwithargs(a, b, c){ if(arg.length){ do this }else{ do something else } } function callwithargs(){ do a new thing } </code></pre>
javascript
[3]
3,769,810
3,769,811
Python Lists: How can I search for another element or duplicate item in a list
<p>I have a list say <code>p = [1,2,3,4,2]</code> Is there any way of returning bool value <code>True</code> if it contains a duplicate using only find, indexing, slicing, len() etc methods and not dict, tuple etc.</p> <p>I used this code: </p> <pre><code>for e in p: duplicate = p.find(e, e+1) if duplicate in p: return True </code></pre>
python
[7]
81,968
81,969
What is uintptr_t data type
<p>What is uintptr_t and what it can be used for?</p>
c++
[6]
2,317,335
2,317,336
take the value from onitemselect in autocompletetextview
<p>amount is not being set to EditText, only stores in another external variable. </p> <pre><code>productAtoComplete.setOnItemClickListener(new OnItemClickListener(){ public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id){ amount.setText(map.get((String) parent.getItemAtPosition(position))); } }); </code></pre>
android
[4]
716,541
716,542
typeof a === 'undefined'
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4725603/variable-undefined-vs-typeof-variable-undefined">variable === undefined vs. typeof variable === “undefined”</a> </p> </blockquote> <p>Assuming that <code>undefined</code> has not been tampered with, are the following equivalent?</p> <pre><code>typeof a === 'undefined' </code></pre> <p>and </p> <pre><code>a === undefined </code></pre> <p>?</p> <p>[The reason I ask is because the author of <a href="https://raw.github.com/guillaumepotier/Parsley.js/master/parsley.js" rel="nofollow">Parsley.js</a> seems to love writing <code>'undefined' !== typeof someExpression</code>.]</p>
javascript
[3]
703,525
703,526
how to make a variable local
<p>I made this recursive method that calculates the longest path in a binary tree. the path its store in an arralist and then returned. however, i had to declare the array list variable global. is it possible to make this method but his the array list variable being local.</p> <pre><code>public static &lt;T&gt; ArrayList&lt;T&gt; longestPath(BinaryNode&lt;T&gt; root){ //ArrayList path = new ArrayList(); if(root == null) return null; if(height(root.left) &gt; height(root.right)){ path.add(root.element); longestPath(root.left); }else{ path.add(root.element); longestPath(root.right); } return path; } </code></pre> <p>The reason i had to make it global is because its a recursive program and every time it call itself it will create a new array list object variable with difference address if you know what i mean.</p>
java
[1]
2,506,200
2,506,201
Error in the python script
<p>I have this simple python script where <code>myvar1</code> is accessible in <code>generate()</code> function but not in <code>copy()</code> function. Need help figuring out the error:</p> <pre><code>#!/usr/bin/python import os, time def Test(tcid,descr,iterations,filsz): def setup(): print "entering set up\n" global myvar1, myvar2 myvar1 = 1.0 myvar2 = os.getcwd() def generate(): print "entering generate\n" print "in generate", myvar1, myvar2 def copy(): print "in copy", myvar1, myvar2 myvar1 += 5.0 setup() generate() for loopcount in range(5): loopcount = loopcount + 1 copy() if __name__ == "__main__": Test('test','simple test',2,10) </code></pre> <p>Error:</p> <p>Traceback (most recent call last): File "./pyerror.py", line 35, in Test('test','simple test',2,10) File "./pyerror.py", line 30, in Test copy() File "./pyerror.py", line 20, in copy print "in copy", myvar1, myvar2 UnboundLocalError: local variable 'myvar1' referenced before assignment</p>
python
[7]
732,401
732,402
Python: How to test multiple values inside an if [multiple values] in list:
<p>I've returned a list of href values from a HTML document. I want to go though every link within this list and test to see if they contain any of the values within my <code>IMAGE_FORMAT</code> tuple.</p> <pre><code>IMAGE_FORMAT = ( '.png', '.jpg', '.jpeg', '.gif', ) </code></pre> <p>At present I am simply testing for <code>'.jpg'</code> e.g <code>if '.jpg' in link.get('href'):</code> </p> <p>I'd like to extend this code to something along the lines of <code>if [any value inside IMAGEFORMAT] in link.get('href'):</code> </p> <p>What would be the most efficient or cleanest way or doing so?</p>
python
[7]
484,154
484,155
C#: Multi element list? (Like a list of records): How best to do it?
<p>I like lists, because they are very easy to use and manage. However, I have a need for a list of multiple elements, like records.</p> <p>I am new to C#, and appreciate all assistance! (Stackoverflow rocks!)</p> <p>Consider this straightforward, working example of a single element list, it works great:</p> <pre><code>public static List&lt;string&gt; GetCities() { List&lt;string&gt; cities = new List&lt;string&gt;(); cities.Add("Istanbul"); cities.Add("Athens"); cities.Add("Sofia"); return cities; } </code></pre> <p>If I want the list to have two properties for each record, how would I do it? (As an array?)</p> <p>E.g. what is the real code for this pseudo code?:</p> <pre><code>public static List&lt;string[2]&gt; GetCities() { List&lt;string&gt; cities = new List&lt;string&gt;(); cities.Name,Country.Add("Istanbul","Turkey"); cities.Name,Country.Add("Athens","Greece"); cities.Name,Country.Add("Sofia","Bulgaria"); return cities; } </code></pre> <p>Thank you!</p>
c#
[0]
5,535,288
5,535,289
Configuring frequency of notifications for requesting location updates
<p>I'm trying to resolve a small problem:</p> <pre><code>mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 120000, 0, mLocationListener); </code></pre> <p>So I assumed that mLocationListener should wait for 2 mainutes before calling it's onLocationChanged method. However, the method is called right after I send geo fix updates to emulator, every time I do it. Did I misunderstand the android developers guide, and do I have to to use timers or anything similar for organizing update rate I need?</p>
android
[4]
3,295,839
3,295,840
How to espace when calling jquery append?
<p>I append the following html:</p> <pre><code>&lt;span sytle="color:#000000" /&gt; </code></pre> <p>The color value is stored in a variable:</p> <p>var my_color = "#000000";</p> <p>var a = $("#a");</p> <p>Below is what I have tried:</p> <pre><code>a.append('&lt;span style="color: ' + my_color + '"&lt;/span&gt;'); </code></pre> <p>Is this correct?</p>
jquery
[5]
187,604
187,605
PHP - Unexpected behaviour using == (equal) and === (identical)
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1117967/what-does-mean">What does “===” mean?</a> </p> </blockquote> <p>I had the following in my code:</p> <pre><code>$mixed = array(); $mixed[0] = "It's a zero!"; $mixed['word'] = "It's a word!"; foreach ($mixed as $key =&gt; $value) { if ($key == 'word') { echo $value.'&lt;br /&gt;'; } } </code></pre> <p>The above would for some reason print both "It's a zero!" and "It's a word!". I was expecting it to print only "It's a word!". Why is that?? I feel like I am missing something important. When I was using <code>===</code> in the if statement, it worked as expected, in other words it printed only "It's a word!". I know there's a difference between the equal and identical operators, but the first example is not equal is it?</p>
php
[2]
1,559,872
1,559,873
Android: Reordering Lists like playlists in the media player
<p>I need to implement reordering of ListView rows like in media player. I found a lot of solutions, but most of them is hard to implement and they are 2 years old. Is there any fresh ideas and examples how to implement that ?</p> <p>P.S: I should support API 10</p>
android
[4]
1,188,656
1,188,657
C++ and Windows , CRT
<p>I am developing application application using C++ VS 2008. Now I need to either install respective MSM or install redist on customer machine to get this working.</p> <p>Is there any way in which I can just copy those CRT dlls and get the application running.</p> <p>Private assembly option seems to be complicate.</p>
c++
[6]
5,318,906
5,318,907
Is there a raw file size limit for android?
<p>Can someone tell me if it is possible to put an archive file with a size greater than 1 mb in res/raw and at runtime copy it to sdcard and decompress it?</p>
android
[4]
1,048,711
1,048,712
get method for a readonly member in C#
<p>I have a class definition in which a readonly member is defined.</p> <pre><code>private readonly Dictionary&lt;string, string&gt; map = new Dictionary&lt;string, string&gt;(); </code></pre> <p>Now in order to test my design, I want to access this member outside its class definition. I was thinking of providing a <code>get</code> method but unable to write an error free syntax.</p> <p>Is it possible to assign value to a member(using <code>new</code>) and still able to define its <code>get</code> method?</p> <p>PS: I am new to C# language.</p> <p><strong>EDIT:</strong> I have not written the code, its just a statement I have copied from an already written module. I have made some design changes in the module and want to test it with minimal changes possible in the code, so for that I was looking to get the readonly access of this member outside the class.</p>
c#
[0]
5,713,203
5,713,204
Two way sync adapter in Android
<p>I have gone through a number of links and after spending a huge amount of time over this, someone can please let me know the simplest approach to implement the Sync Adapter in Android which is 2 way. I mean the changes made on the remote database get reflected on the Android Device and the changes from the device should get updated on the server too.</p> <p>Also, how to edit the contacts from the default contacts app editor??</p> <p>Would like to give thanks in advance as it will prove to be a great help if someone answers my question.</p>
android
[4]
2,866,642
2,866,643
How do I edit a properties file without trashing the rest of it
<p><strong>Example.properties</strong></p> <pre><code>user=somePerson env=linux file=mpg </code></pre> <p><strong>properties.java class</strong></p> <pre><code>propertiestTest.java { Properties props = new Properties(); props.setProperty("user", "GodIsUser"); final File propsFile = new File(someDir/Example.properties"); props.store(new FileOutputStream(propsFile), ""); } </code></pre> <p><strong>reseult of Example.properties</strong></p> <pre><code>user=GodIsUser </code></pre> <p>and all other entries are deleted</p>
java
[1]
3,374,134
3,374,135
How to sync android phones to a database in the same network?
<p>I want to create an app for android phones and I'd like to know if is it possible or how it should be done this:</p> <p>In a wifi area with a pc that acts as server, the android phones with this app (connected to the same ap) should be capable to access to a database that reside on the pc (previously having done an authentication). And then, get all the information needed from the database. </p> <p>Rather than being continuously asking for requests to the server, it could download and make a copy to the phone just everytime the application starts and log in to the server (this db to copy should not be much large). </p> <p>As well, the phones could send messages to the server and get responses based on the requests asked.</p> <p>What should be done on the server side? what database or databases should fit better for each case?, what protocol is the best for this job...</p> <p>I'm totally noob on this and i need all the help you can give.</p>
android
[4]
4,661,696
4,661,697
Java library to convert source to code model
<p>Is there a java library that converts source code into some kind of a code model? Preferably a <code>javax.lang.model.element.TypeElement</code>?</p>
java
[1]
4,905,512
4,905,513
How to add a group of integers
<p>Can some one tell me how to do this and explain it to me: Write a program that reads a text file that contains groups of integers that start with the word “next”. For each group, the program computes and writes out the sum of integers in that group. There may be any number of groups.</p> <p>I'm not asking you to do my home work, I need some one to explain it. I got stuck with the scanner</p>
java
[1]
5,034,065
5,034,066
Other ways to use jQuery(html, [ownerdocument | props])?
<p>With jquery, besides using the <code>$(selector)</code> syntax, <a href="http://api.jquery.com/jQuery/#jQuery2" rel="nofollow">there is also</a> a syntax that is shown for usage as <code>$("&lt;p&gt;someHTML&lt;/p&gt;")</code>. Now, the only samples of this usage I can find are with <code>appendTo</code>. </p> <p>I'm sure there are other great uses of this feature, but I can't seem to find any documentation on it, or examples of implementation.</p> <p>It doesn't seem like I can run .find() over it however, but perhaps I set something up incorrectly in my trying it out.</p>
jquery
[5]
5,634,521
5,634,522
Scrolling is not smooth in Android, and gets stuck in the middle
<p>I'm using the following code for displaying in list... it scrolls but not in a smooth way; like on the iPhone.</p> <pre><code>this.ListAdapter = new IndMessageAdapter(this, R.layout.individualmessage_list, IndividualMessage.CombinedMessages); setListAdapter(this.ListAdapter); </code></pre>
android
[4]
707,959
707,960
Where is the location of the System class in Java?
<p>Actually we are getting the values from <code>System</code> class by using the <code>System.getProperty("keyValue")</code> method. Is this values varied from one application to another application. I mean, is the <code>System</code> class varied from one application to another application?</p> <p>What is the location of the <code>System</code> class?</p>
java
[1]
941,704
941,705
jQuery: checking slideToggle visibility not working?
<p>I am trying to use slide toggle to show a sign in form and if they click outside of the box, I want that form to slide up.</p> <p>I have everything running fine however my check for visibility isn't working and thus clicking outside the form container is not working. Can you spot why?</p> <pre><code>var loginForm = jQuery("#login .login-form"); jQuery("#login a").click(function(e) { e.preventDefault(); loginForm.slideToggle(); }); // below check isn't working why? if (jQuery(loginForm).is(":visible")) { jQuery("body").click(function() { jQuery(loginForm).slideUp(); }); } </code></pre>
jquery
[5]
435,005
435,006
comparing strings with comparison operators php
<p>I'm comparing strings with comparison operators. </p> <p>I needs some short of explanations for the below two comparisons and their result.</p> <pre><code>if('ai' &gt; 'i') { echo 'Yes'; } else { echo 'No'; } output: No </code></pre> <p>Why?</p> <pre><code>if('ia' &gt; 'i') { echo 'Yes'; } else { echo 'No'; } Output: Yes </code></pre> <p>Again, Why?</p> <p>May be I forgot some basics, but I really need some explanation of these comparison examples.</p>
php
[2]
3,801,262
3,801,263
Sorting multi-dimensional array based on value of specific key in array
<p>I have an array which is something like this:</p> <pre><code> $array[] = array( "name" =&gt; "sample", "image" =&gt; "sample.jpg", "header" =&gt; "sampleDelights", "intro_copy" =&gt; "" ); $array[] = array( "name" =&gt; "lwmag", "image" =&gt; "lwmag.jpg", "header" =&gt; "LW Mag", "intro_copy" =&gt; "" ); </code></pre> <p>I want to sort this array based on the alphabetical order from the key "header" with PHP. I have tried usort and searched for built in functions but cannot find one (or looking past it). Is this possible with a single php function?</p>
php
[2]
5,465,786
5,465,787
the jquery post method is not working?
<p>here is the code</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script type="text/javascript" src="jquery-1.3.2.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $('document').ready(function(){ $('#submit').click(function(){ var username=$('#user').val(); $.post('http://localhost:8080/verify/comment.php',{user:username},function(return_data){ alert(return_data); }); }); }); &lt;/script&gt; Username:&lt;input type="text" id="user"/&gt; &lt;input type="button" id="submit" value="submit"/&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>comment.php</p> <pre><code> &lt;?php echo 'welcome'; ?&gt; </code></pre> <p>it displays an empty alert message.. i cant get the value "welcome" in alert message........ any suggestion.......</p>
jquery
[5]
705,365
705,366
php - add commas in the array
<p>i have following array, and i have tried to add comma with the following code but i am not getting values its shows "array" only..</p> <p><strong>Array Value</strong></p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; 144 [category_id] =&gt; 144 ) [1] =&gt; Array ( [0] =&gt; 98 [category_id] =&gt; 98 ) [2] =&gt; Array ( [0] =&gt; 146 [category_id] =&gt; 146 ) [3] =&gt; Array ( [0] =&gt; 142 [category_id] =&gt; 142 ) ) </code></pre> <p><strong>Tried code to display values with commas</strong></p> <pre><code>$comma_separated = implode(",", $result_array); echo $comma_separated; </code></pre> <p><strong>output i am getting</strong></p> <pre><code>Array,Array,Array,Array </code></pre> <p>please check what i am getting wrong</p>
php
[2]
5,910,053
5,910,054
Start Android on external power
<p>We're making a small app for Android. Thus it would be vital for us that the Android phone would start when it's attached on external power source. Is there any way to turn on your phone when the phone is getting more electricity, without any human actions?</p> <p>Yours</p> <p>-Heikki</p>
android
[4]
474,958
474,959
Index based string matches in python
<p>I have two lists</p> <pre><code>list1 = ['this', 'is', 'the', 'right', 'string'] list2 = ['this', 'is', 'right'] </code></pre> <p>After comparison I need to find out another list include only</p> <pre><code>list3 = ['this', 'is'] </code></pre> <p>I have tried it up using intersection, I know it is not the proper solution in my case.</p> <pre><code>&gt;&gt;&gt; list(set(list1) &amp; set(list2)) ['this', 'is', 'right'] </code></pre> <p>It is not the index based comparison. </p> <p>I need to find the index based comparison. I mean, first compare first words in list1 and list2, if it is match, then take next words in each list then compare that words and so on. If it is not match, then return the matched words only. Anybody can help me??</p>
python
[7]
587,890
587,891
How can I execute C++ code on a webserver?
<p>Do hosting providers allow you to execute C++ code on their web-servers? I have a C++ algorithm that is used for converting file types and I want users to be able to upload their files to my website to get put through my algorithm. So far I haven't worked out how to execute C++ code on a webhost though? I can execute scripts and .Net assemblies and that's about all I can find. The algorithm is not platform dependent so it can be compiled to .exe or a.out. It's no big deal for me to rewrite the algorithm in C# or php (if I really have to ) but it would take quite a while so if prefer to keep it in C++. </p>
c++
[6]
1,768,648
1,768,649
Convert.ToString behaves differently for "NULL object" and "NULL string"
<p>I have foo (<code>object</code>) and foo2 (<code>string</code>) in a C# console application. The Code 2 throws exception while Code 1 works fine.</p> <p>Can you please explain why it is behaving so (with MSDN reference)?</p> <p>// Code 1</p> <pre><code> object foo = null; string test = Convert.ToString(foo).Substring(0, Convert.ToString(foo).Length &gt;= 5 ? 5 : Convert.ToString(foo).Length); </code></pre> <p>// Code 2</p> <pre><code> string foo2 = null; string test2 = Convert.ToString(foo2).Substring(0, Convert.ToString(foo2).Length &gt;= 5 ? 5 : Convert.ToString(foo2).Length); </code></pre>
c#
[0]
5,474,150
5,474,151
Problem with RelativeLayout when using "fill_parent"
<p>I have a Layout (using TableLayout, etc...) which works well. It seems like this: <a href="http://i.stack.imgur.com/jLFhA.png" rel="nofollow">http://i.stack.imgur.com/jLFhA.png</a></p> <p>I would like to rewrite it using one RelativeLayout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="6dip"&gt; &lt;TextView android:id="@+id/textViewTopicTitle" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Title" android:background="#880000"&gt;&lt;/TextView&gt; &lt;TextView android:id="@+id/textViewSolution" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/textViewTopicTitle" android:text="Description...." android:background="#008800"&gt;&lt;/TextView&gt; &lt;Button android:text="Start" android:id="@+id/buttonTopic" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/textViewSolution" android:layout_below="@id/textViewTopicTitle" android:layout_marginRight="6dip"&gt; &lt;/Button&gt; &lt;/RelativeLayout&gt; </code></pre> <p>It's not correct because the green TextView not fill as many space as possible.</p> <p>So I change: android:id="@+id/textViewSolution" android:layout_width="<strong>fill_parent</strong>"</p> <p>But in this case the button is missing!</p> <p><a href="http://i.stack.imgur.com/ugzeq.png" rel="nofollow">http://i.stack.imgur.com/ugzeq.png</a></p> <p><strong>My question is: is that possible to create such a layout using only RelativeLayout?</strong></p>
android
[4]
5,370,998
5,370,999
How to destroy an activity in Android?
<p>While the application is running, I press the HOME button to close the application. When I start the application again, it resumes on the page displayed prior to clicking on HOME. I want the application to start with the initial display instead. I have used finish() to finish the activity but it is not working. Any suggestions?</p>
android
[4]
3,677,337
3,677,338
Can't get this function to work
<p>I'm trying to build a hangman game using instructions from codecademy, but I'm having a hard time following alone. In the guessLetter function below, I've added two lines of code following the instructions they gave me</p> <p>This</p> <pre><code>shown = alterAt(checkLetter,letter,shown); ///this is mine </code></pre> <p>and this</p> <pre><code>checkLetter = indexOf(letter, checkLetter +1); </code></pre> <p>However, I can't get the tests to pass. I'd be grateful if you could assist.</p> <pre><code>// Skip to guessLetter(). You shouldn't need to touch this function. function alterAt ( n, c, originalString ) { return originalString.substr(0,n) + c + originalString.substr(n+1,originalString.length); } function guessLetter( letter, shown, answer ) { var checkLetter = -1; // This variable will hold the indexOf() checkLetter = answer.indexOf(letter); // Single Argument Version starting at 0 while ( checkLetter &gt;= 0 ) { // Replace the letter in shown with alterAt() and then store in shown. shown = alterAt(checkLetter,letter,shown); ///this is mine // Use indexOf() again and store in checkLetter checkLetter = indexOf(letter, checkLetter +1); ///this is mine } // Return our string, modified or not return shown; } </code></pre> <p><strong>Update</strong></p> <p>If the guess is correct, it's supposed to return shown modified by the guess. For example, if the word is tree and the player guesses 'e', it should return '__ee.' Here's a fiddle I can't get to work using the word 'whatever': <a href="http://jsfiddle.net/mjmitche/YAPWm/2/" rel="nofollow">http://jsfiddle.net/mjmitche/YAPWm/2/</a></p>
javascript
[3]
5,721,715
5,721,716
session variable for username
<p>Hey I am creating a forum where users can login and post ocmments in a forum, I want the username as a session variable so I can get it when they post a comment and insert the username in the db and also to display a hello user message.</p> <p>Below is my login code:</p> <pre><code>protected void Button1_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); localhost.Service1 myws = new localhost.Service1(); ds = myws.GetUsers(); foreach (DataRow row in ds.Tables[0].Rows) if (txtusername.Text == System.Convert.ToString(row["username"]) &amp;&amp; txtpassword.Text == System.Convert.ToString(row["password"])) { System.Web.Security.FormsAuthentication.RedirectFromLoginPage(txtusername.Text, false); } else Label3.Text = "Invalid Username/Password"; } </code></pre> <p>Do I declare the session variable here?</p> <p>Like:</p> <pre><code>Session["username"] = "username"; </code></pre> <p>Also not sure what to type to get the value username from the db</p> <p>Thanks</p>
asp.net
[9]
5,897,720
5,897,721
What is Javascript collision?
<p>Any best practices around it?</p>
javascript
[3]
121,788
121,789
Using underscore (_) as a PHP function name
<p>According to <a href="http://php.net/manual/en/functions.user-defined.php" rel="nofollow">http://php.net/manual/en/functions.user-defined.php</a>, I should be able to use an underscore (_) as a function name:</p> <blockquote> <p>Function names follow the same rules as other labels in PHP. A valid function name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*.</p> </blockquote> <p>However, the following kills my program without causing any errors:</p> <pre><code>error_reporting(E_ALL); echo('start'); function _($x){return ($x)?htmlspecialchars($x):'nbsp;';} echo('end'); </code></pre> <p>I am using PHP Version 5.3.18. What don't I understand?</p>
php
[2]
1,805,340
1,805,341
Python 3-compatibe HTML to text converter preserving basic structure under permissive licence?
<p>I am looking for a relatively simple HTML to text converter which displays links and works on strings.</p> <p>So far I have tried</p> <ul> <li>lynx but performance is too bad,</li> <li>html2text which gives weird and verbose markdown output and is under GPLv3 which is too restrictive for my (BSD-licensed) project,</li> <li><a href="http://effbot.org/librarybook/formatter-example-3.py" rel="nofollow">http://effbot.org/librarybook/formatter-example-3.py</a> using htmllib.HTMLParser with formatter.AbstractFormatter and a custom writer, however htmllib.HTMLParser is drpeceated and has been removed from Python 3.</li> </ul> <p>So is there any simple, performant, Python 3-compatible HTML to text converter under a permissive license such as MIT/BSD/Apache and the like?</p> <p><strong>Edit:</strong> I dont just need something to strip HTML-Tags but also to preserve the basic structure of the HTML, that is output that somewhat resembles that of Lynx.</p>
python
[7]
4,302,673
4,302,674
How to use zip() for 2D lists
<p>How can I use <code>zip()</code> for a number of 2D lists, analogous to <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.dstack.html" rel="nofollow">numpy.dstack()</a>? My 2D arrays have different types (string, float), so I don't want to use <code>dstack()</code>.</p>
python
[7]
741,775
741,776
How to recognise logged in user?
<p>I just made the registration form for my website, however I have zero knowledge on how to remember the user is logged in through the session. I think I could simply store his IP on a Table on my database when authenticated and remove it when he logs out.</p> <p>Is there anything wrong about this approach? If there is what should I do instead of it?</p>
php
[2]
901,355
901,356
How to group dynamically generated content based on similar content
<p>I have a dynamically generated page with varying number of items (div.item). Each item has an inner div with class "date". The items are ordered by ascending order from the DB based on the date value. Since this page content taken from the DB there may be 10 items with the same date, then the next 3 will share a date, then the next X may share another date, and so on.</p> <p>Based on the content of div.date I want to wrap all items with similar dates in a div.group. I would have preferred doing this direct on the PHP code, but I've inherited a large messy project with no documentation and this option is only temporary. The current simplified structure is below:</p> <pre><code>&lt;div class="item"&gt; &lt;div class="date"&gt;04-06-2012&lt;/div&gt; &lt;div class="other-content"&gt;Other Content&lt;/div&gt; &lt;/div&gt; &lt;div class="item"&gt; // To be grouped with above &lt;div class="date"&gt;04-06-2012&lt;/div&gt; &lt;div class="other-content"&gt;Other Content&lt;/div&gt; &lt;/div&gt; ... &lt;div class="item"&gt; // In it's own group &lt;div class="date"&gt;08-06-2012&lt;/div&gt; &lt;div class="other-content"&gt;Other Content&lt;/div&gt; &lt;/div&gt; ... </code></pre> <p>Thanks</p>
jquery
[5]
4,699,895
4,699,896
Android Text to speech
<p>I want to use TTS (Text to Speech) in my android application.how can i use texttospeech Engine and one more is it support Japanese language? please help me on this.</p> <p>Regards Thilag.</p>
android
[4]
5,407,419
5,407,420
How to retrieve MP3 file duration(secs) in android sdk <10
<p>I have stored set of MP3 files in my sd card. Now I want to retrieve its duration in seconds. I went through few links and I was able to find solution only from SDK version 10 using the <code>MediaMetadataRetriever</code> class. But my requirement is for SDk version 7. Is there any way to find out the duration of mp3 files. I am sorry if this is a repeated question here. </p> <p>I know that using MediaPlayer's <code>getDuration()</code> solves this issue. But I don't want to use this.</p> <p>Any help is much appreciated. </p>
android
[4]
4,064,054
4,064,055
How to check whether a page has been updated without downloading the entire webpage?
<p>How to check whether a page has been updated without downloading the entire webpage in Php? Whether I need to look in at the header?</p>
php
[2]
2,524,646
2,524,647
count element in array?
<p>I have an Array like this (when I <code>print_r</code>). How can I sum all elements in this Array? In this example, the sum is 0+1=1</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; 0 ) [1] =&gt; Array ( [0] =&gt; 1 ) ) </code></pre>
php
[2]
538,448
538,449
iPhone SDK: How to make 3hg app iPad Compatable?
<p>From Apple Review Guidelines</p> <p><a href="https://developer.apple.com/appstore/resources/approval/guidelines.html" rel="nofollow">https://developer.apple.com/appstore/resources/approval/guidelines.html</a></p> <p>iPhone apps must also run on iPad without modification, at iPhone resolution, and at 2X iPhone 3GS resolution</p> <p>I tried running my app on the iPad simulator. I thought it would be centered in the iPad screen but it was instead in the upper left hand corner. The size that of an iPhone app. Is that typical.</p> <p>My questions:</p> <p>a.) Why would the main view be located in the upper left hand corner? b.) Is there anything special I need to do to an iPhone app to make it pass the above rule. At this time, we are not ready to release an iPad version.</p> <p>Thanks in advance.</p>
iphone
[8]
648,389
648,390
Convert an array of dates into a date range
<p>I have an array of dates: from and to 's. i.e:</p> <pre><code>array( [0] =&gt; array('from' =&gt; '19-01-2000' 'to' =&gt; '20-01-2000') [1] =&gt; array('from' =&gt; '20-01-2000' 'to' =&gt; '21-01-2000') [2] =&gt; array('from' =&gt; '21-01-2000' 'to' =&gt; '22-01-2000') [3] =&gt; array('from' =&gt; '23-01-2000' 'to' =&gt; '24-01-2000') [4] =&gt; array('from' =&gt; '24-01-2000' 'to' =&gt; '25-01-2000') ) </code></pre> <p>I am trying to find a way to convert create a new array which will only have the date ranges, i.e:</p> <pre><code>array( [0] =&gt; array('from' =&gt; '19-01-2000' 'to' =&gt; '22-01-2000') [1] =&gt; array('from' =&gt; '23-01-2000' 'to' =&gt; '25-01-2000') ) </code></pre> <p>Any suggestions?</p>
php
[2]
5,075,591
5,075,592
Set the minlength property Jquery
<p>How to set the minlength property of a input element using jqeury. Its required like that because it will vary.. Is there a jquery api to do that?</p>
jquery
[5]
3,485,547
3,485,548
read local pdf through webview
<p>I am doing one application to read pdf from sdcard through webview. I used the following code.</p> <pre><code> webview = (WebView) findViewById(R.id.webview); webview.getSettings().setJavaScriptEnabled(true); webview.setWebViewClient(new HelloWebViewClient()); File file = new File(Environment.getExternalStorageDirectory() + "/MotoronAug.pdf"); Uri uri = Uri.fromFile(file); webview.loadUrl(uri.toString()); </code></pre> <p>but i got a blank page. But when i give a web address </p> <pre><code>webview.loadUrl("http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.google.com%2Farchive%2Fbigtable-osdi06.pdf"); </code></pre> <p>I can read it from webview what is the problem in my code?...I have MotoronAug.pdf file in my sdcard.Help me friends</p>
android
[4]
3,860,644
3,860,645
Jquery Find - Visible only
<p>I want to check if the div contains a children with class "error" but with the condition that the error class display is not equal to none. (Meaning error class must be visible.</p> <p>How can change my code below:</p> <pre><code> $(".related_field").each(function(){ var $widthAdj = $(this).find(".autoDiv"); if($(this).find(".error").length == 0){ //MUST BE VISIBLE "ERROR" CLASS ONLY $widthAdj.css("height","48px"); } else { $widthAdj.css("height","63px"); } }); </code></pre>
jquery
[5]
645,567
645,568
a for loop that won't pass beyond the first item in python
<p>I have this simple average function and when its run with a test data, will show the length of the data, but when calculating the actual average just won't go beyond the first item in the sequence. I need help in finding what I am doing wrong here. Thanks in advance for taking the time to answer if you do.</p> <pre><code>def avg(seq): total = 0 for i in seq: total+=i average = total/len(seq) return (float(average)) test_data = (12,89,90) print(len(test_data)) print(avg(test_data)) </code></pre>
python
[7]
126,983
126,984
method local innerclasses accessing the local variables of the method
<p>Hi I was going through the SCJP book about the innerclasses, and found this statement, it goes something like this.</p> <blockquote> <p>A method local class can only refer to the local variables which are marked <code>final</code></p> </blockquote> <p>and in the explanation the reason specified is about the scope and lifetime of the local class object and the local variables on the heap, but I am unable to understand that. Am I missing anything here about <code>final</code>?? </p>
java
[1]
859,147
859,148
Does PHP's DateTime class escape date from SQL injection
<p>Usually, I use PDO's prepared statements, type casting to (int), or PDO::quote() to prevent SQL injection. For this application, I need to modify the date using PHP before adding it to the query. Do I need to take extra steps to prevent SQL injection, or am I safe? Thanks</p> <pre><code>$date = new DateTime($_GET['suspect_user_provided_date']); $date-&gt;add(new DateInterval('P1D')); $sql='SELECT * FROM table WHERE date&lt;"'.$date-&gt;format('Y-m-d').'"'; </code></pre>
php
[2]
5,161,748
5,161,749
jQuery animate element reveal - bottom to top
<p>I'm trying to animate a horizontal lists appearance. It's a top navigation bar.</p> <p>The following works pretty well, but it animates in from the top (of, I assume, the ul) to the bottom. </p> <p>How would animate bottom, up? </p> <pre><code>$("#topnavigation li").css({height:'0'}); // 'hide' it first $("#topnavigation li", this).stop().animate({height:'23px'},{queue:false,duration:1000}); </code></pre>
jquery
[5]
1,387,002
1,387,003
Php substr and trim
<p>I want to read the last line of a block of text , e.g:</p> <blockquote> <p>250-SIZE 31457280</p> <p>250-AUTH LOGIN CRAM-MD5</p> <p>250 OK</p> </blockquote> <p>Here is my current code - it reads the first line only:</p> <pre><code>if (substr(trim($res), 0, 3) != "250") { </code></pre> <p>Giving an output of </p> <blockquote> <p>250-SIZE 31457280</p> </blockquote> <p>I want to get the last </p> <blockquote> <p>250 OK</p> </blockquote> <p>(there are no blank lines in between it's my copy paste problem ). Any idea?</p>
php
[2]
1,205,494
1,205,495
Iphone page curl effect
<p>I am using this code for Page curl effect ....Its work fine in simulator and device... But its not (setType:@"pageCurl") apple documented api , this caused it to be rejected by the iPhone Developer Program during the App Store review process: </p> <pre><code>animation = [CATransition animation]; [animation setDelegate:self]; [animation setDuration:1.0f]; animation.startProgress = 0.5; animation.endProgress = 1; [animation setTimingFunction:UIViewAnimationCurveEaseInOut]; [animation setType:@"pageCurl"]; [animation setSubtype:@"fromRight"]; [animation setRemovedOnCompletion:NO]; [animation setFillMode: @"extended"]; [animation setRemovedOnCompletion: NO]; [[imageView layer] addAnimation:animation forKey:@"pageFlipAnimation"]; </code></pre> <p>So i changed and using like this </p> <pre><code>[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; [UIView setAnimationDelegate:self]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationCurve:UIViewAnimationCurveLinear]; [UIView setAnimationWillStartSelector:@selector(transitionWillStart:finished:context:)]; [UIView setAnimationDidStopSelector:@selector(transitionDidStop:finished:context:)]; // other animation properties [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:imageView cache:YES]; // set view properties [UIView commitAnimations]; </code></pre> <p>In this above code i want to stop the page curl effect at midway.. But i cant stop it in midway like map applications in ipod... Is this any fix for this? or Is there any apple documented methods used for page curl effect in ipod touch?</p> <p>I am searching lot. but didnt get any answer ? can anyone help me? Thanks in advance..plz </p>
iphone
[8]
860,002
860,003
Problem with comparing the results from a two-dimensional array!
<p>I'm developing a slot machine game. The player insert amount of money and makes a bet to play. And the goal of the game is to obtain as many rows, columns, and diagonals as possible of the same symbol. In the above example, obtained a profit when the upper and lower line have equal symbols, partly 2x lines. Depending on the number of rows with the same symbol the user gets paid as the profit system follows:</p> <ul> <li>A series provides 2 * bet</li> <li>Two lines giving 3 * bet</li> <li>Three rows giving 4 * bet</li> <li>Four rows gives 5 * bet</li> <li>Five lines gives 7 * bet</li> <li>Fully playing field gives 10 * bet</li> </ul> <p>I dont know how to solve this problem with the paying? What code can I use? Should I use a for-loop? I'm new with c++ so I'm having trouble with this. I' been spending a lot of hours on this game and I just can't solve it. Please help me! Here's a small part of my code for now: I just want to compare the results. </p> <pre><code> srand(time(0)); char game[3][3] = {{'O','X','A'}, {'X','A','X'}, {'A','O','O'}}; for (int i = 0; i &lt; 3; ++i) { int r = rand() % 3; cout &lt;&lt; " " &lt;&lt;game[r][0] &lt;&lt; " | " &lt;&lt; game[r][1] &lt;&lt; " | " &lt;&lt; game[r][2] &lt;&lt; "\n"; cout &lt;&lt; "___|___|___\n"; } //......compare the result of the random symbols. ???? </code></pre>
c++
[6]
3,513,196
3,513,197
How to check a variable is a real object or just a reference to an object
<p>Considering:</p> <pre><code>A = {}; A.test = 123; B = A; C = {}; for (key in A) C[key] = A[key]; // a crude clone. </code></pre> <p>In this example, B is a reference to A, C is a deep-copy of A.</p> <p>I know I can check them by <code>A === B</code> and <code>A === C</code></p> <p>But if I don't have an <code>A</code>, can I distinguish "B" and "C" without knowing "A" ?</p>
javascript
[3]
5,477,113
5,477,114
Questions on string.xml and size of the icon
<p>In string.xml,</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string name="app_name"&gt;nameofmyapp&lt;/string&gt; &lt;/resources&gt; </code></pre> <p>I wanna change the text size how do I do that..also I want to increase the size of my icon which appears on my phone.. I tried google's <a href="http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-notification.html#source.type=text&amp;source.space.trim=1&amp;source.space.pad=0.2&amp;source.text.text=Correct!&amp;source.text.font=Helvetica&amp;shape=square&amp;name=example" rel="nofollow">http://android-ui-utils.googlecode.com/hg/asset-studio/dist/icons-notification.html#source.type=text&amp;source.space.trim=1&amp;source.space.pad=0.2&amp;source.text.text=Correct!&amp;source.text.font=Helvetica&amp;shape=square&amp;name=example</a> Didn't work! any suggestions? #newbie #thanks</p>
android
[4]
4,516,128
4,516,129
How to handle the phone call while running the application in iphone
<p>I am doing with a paint application. while drawing any picture if I got any phone call, the application is getting quit and reopens immediately after end of the call. But my requirement is I should able to draw the picture while I am in incoming call.</p> <p>Any one can Please help me out</p>
iphone
[8]
1,033,948
1,033,949
read an string line by line using c++
<p>I have a <code>string</code> with multiple line and I need to read it line by line. Please show me how to do it with a small example.</p> <p>Ex: I have a string <code>string h;</code></p> <p>h will be:</p> <pre><code>Hello there. How are you today? I am fine, thank you. </code></pre> <p>I need to extract <code>Hello there.</code>, <code>How are you today?</code>, and <code>I am fine, thank you.</code> somehow.</p>
c++
[6]
3,418,935
3,418,936
BootupReceiver in Android 3.1
<p>I want to know if there are any changes in boot up event in Android 3.1+, I do not recieve it in 3.1 whereas on android 2.2 it works fine</p>
android
[4]
3,461,748
3,461,749
Question about method call and creating a new object within an object
<p>I'm a Java virgin. How do you read: </p> <pre><code> (current.getPlayer() ).getID() &lt; p.getID() ) </code></pre> <p>Are 2 mthod calls happening at once?</p> <p>I also have a seperate question. If you are creating a new object within a new object such as </p> <pre><code> Playernode nd=new Playernode(new Player(p)); </code></pre> <p>which is perfectly legal, isn't the first object of Player class which doesn't seem to have a direct object reference in danger of garbage collection off the heap?</p>
java
[1]
89,794
89,795
how to download html table to excel format in php
<p>i am displaying mysql data in html table.</p> <p>How can i download it in msexcel format by using php. I am using pagination also. The download should be complete table.</p>
php
[2]
2,975,192
2,975,193
how can i extract 2 values from a text string?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/401756/parsing-json-using-json-net">Parsing JSON using Json.net</a> </p> </blockquote> <p>I want to pull two values from this test string and save then as their own strings, the values I want our the first and second values in the following piece of text, the values for distance and duration, they are 178331, and 7761. The string I want to pull them from is as follows.</p> <pre><code>{ "destination_addresses" : [ "1508-1520 38th Ave, Oakland, CA 94601, USA" ], "origin_addresses" : [ "800-828 Mountain Ranch Rd, San Andreas, CA 95249, USA" ], "rows" : [ { "elements" : [ { "distance" : { "text" : "111 mi", "value" : 178331 }, "duration" : { "text" : "2 hours 9 mins", "value" : 7761 }, "status" : "OK" } ] } ], "status" : "OK" } </code></pre>
c#
[0]
5,918,706
5,918,707
When to use static initial block in JAVA?
<p>Can anyone please explain me in which scenario we use static initial block? thanks in advance.</p>
java
[1]
1,274,304
1,274,305
Sorted collections: How do i get (extended) slices right?
<p>How can I resolve this?</p> <pre><code>&gt;&gt;&gt; class unslice: ... def __getitem__(self, item): print type(item), ":", item ... &gt;&gt;&gt; u = unslice() &gt;&gt;&gt; u[1,2] # using an extended slice &lt;type 'tuple'&gt; : (1, 2) &gt;&gt;&gt; t = (1, 2) &gt;&gt;&gt; u[t] # or passing a plain tuple &lt;type 'tuple'&gt; : (1, 2) </code></pre> <p>Rational: </p> <p>I'm currently overengineering a sorted associative collection with the ability to return ranges of items. It is quite likely that I will want to store tuples of small integers (or even more pathologically wierd values like Ellipsis) in the collection (as keys), and will need some kind of sane way of differentiating extended slices from plain keys</p> <p>In the one-dimensional case, it's sort of a non-issue. I can't think of any real reason I would want to collect values of type <code>slice</code>, especially since <code>xrange</code> values are functionally similar and more recognizable to pythonistas (in my judgement). All other extended slice constructs are tuples of <code>slice</code>, <code>Ellipsis</code> or plain-old python values</p> <p>No other type of extended slice seems to be in common use for any kind of collection except multidimensional arrays as in NumPy.</p> <p>I do need to support n-dimensional axes, similar to oct-trees or GiS indices. </p>
python
[7]
3,653,298
3,653,299
JAVA - find element in linked list
<p>I need to solve this problem:</p> <p>Write a method <code>find()</code> that takes an instance of <code>Stack</code> and a <code>String</code> <code>key</code> as arguments and returns <code>true</code> if some node in the list has <code>key</code> as its <code>item</code> field, <code>false</code> otherwise. Test your function in a test client. This test client may be the main function in the class <code>Stack</code>.</p> <p>In Java, this is what I've got so far:</p> <pre><code>public class Stack&lt;Item&gt; { private Node first; private class Node { Item item; Node next; } public boolean isEmpty() { return ( first == null ); } public void push( Item item ) { Node oldfirst = first; first = new Node(); first.item = item; first.next = oldfirst; } public Item pop() { Item item = first.item; first = first.next; return item; } public static void main( String[] args ) { Stack&lt;String&gt; collection = new Stack&lt;String&gt;(); String key = "be"; collection.find( key ); while( !StdIn.isEmpty() ) { String item = StdIn.readString(); if( !item.equals("-") ) collection.push( item ); else StdOut.print( collection.pop() + " " ); } } public void find( String key ) { for( Node x = first; x != null; x = x.next ) { if( x.item == key ) StdOut.println( x.item ); } } } </code></pre>
java
[1]
812,382
812,383
PHP further process result of ImagePNG() without saving to disk?
<p>Is there a way to process created image (using <code>ImagePNG()</code> from GD library) in memory <em>so to speak</em> without need to save temporary file to disk? What I am trying to achieve is basically to POST created image and would like to avoid any need to create temporary files, if possible. PHP would just output response of that POST from server.</p> <p>Thanks</p>
php
[2]
3,676,705
3,676,706
How to wrap texts in UITableviewcell on iPhone?
<p>How to wrap texts in UITableViewcell on iPhone?</p>
iphone
[8]
1,842,646
1,842,647
PHP page views counter and google bot question
<p>I have a simple php page views counter and was wondering how can I stop spiders and bots as being counted as views specifically google bot?</p>
php
[2]
3,222,596
3,222,597
how do I create my own custom ToString() format
<p>I would like to specify the format of the tostring format, but I am not sure of the best way to handle this.</p> <p>for example if I hand the following specifiers</p> <p>EE = equipment</p> <p>ED = equipment description</p> <p>EI = equipment Id</p> <p>so that if I used the tostring as such:</p> <pre><code>.ToString("EE-EI (ED)") </code></pre> <p>the output might be:</p> <pre><code> "CAT994-61 (Front end loader)" </code></pre> <p>would the best way be to search for the substrings and do a token replacement?</p> <p>does any one have an example of doing this?</p> <p>Thanks</p> <p>So Far....</p> <pre><code>public class Equipment { string _EquipIntID; public string EquipIntID { get { return _EquipIntID; } } string _EquipID; public string EquipID { get { return _EquipID; } } string _EquipDescription; public string EquipDescription { get { return _EquipDescription; } } string _CategoryID; public string CategoryID { get { return _CategoryID; } } string _Notes; public string Notes { get { return _Notes; } } string _DepartID; public string DepartID { get { return _DepartID; } } public Equipment(string equipIntId, string equipId, string equipDescription, string categoryId, string notes, string departmentId) { _EquipIntID = equipIntId; _EquipID = equipId; _EquipDescription = equipDescription; _CategoryID = categoryId; _Notes = notes; _DepartID = departmentId; } public string ToString(string format) { string output = format; output = output.Replace("EE", _EquipID); output = output.Replace("ED", _EquipDescription); output = output.Replace("DI", _DepartID); return output; } public override string ToString() { return _EquipID; } } </code></pre> <p>the above works nicely</p>
c#
[0]
2,551,874
2,551,875
Adding settings to android app
<p>This is definitely a noob question. I've followed the instructions here <a href="http://developer.android.com/guide/topics/ui/settings.html#Activity" rel="nofollow">http://developer.android.com/guide/topics/ui/settings.html#Activity</a> and when I click on settings, nothing happens.</p> <p>Here's what I have in MainActivity.java:</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); PreferenceManager.setDefaultValues(this, R.xml.preferences, false); } </code></pre> <p>Then I have a new java file called PrefsActivity.java </p> <pre><code>public class PrefsActivity extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); } } </code></pre> <p>Then I have res/xml/preferences.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;CheckBoxPreference android:key="face_up" android:title="@string/face_up" android:summary="@string/face_up_desc" android:defaultValue="false" /&gt; &lt;/PreferenceScreen&gt; </code></pre> <p>I am trying to make it compatible with minsdk 7 if possible. What am I missing?</p>
android
[4]