Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
2,797,414
2,797,415
problems saving & opening a BitMap file
<p>In this code I'm trying to:</p> <ol> <li>get a bitmap from an ImageView</li> <li>save it as "er.png"</li> <li>then load it and assign it to another ImageView</li> </ol> <p>here's my code... but it keeps firing the exception that it can't write... any ideas what might be causing it? Maybe it needs some permissions?</p> <pre><code>////// GET FROM IV ///////////////////////////////////// ImageView iv = (ImageView)findViewById(R.id.ivDon); Drawable draw = iv.getBackground(); Bitmap bm = ((BitmapDrawable)draw).getBitmap(); Bitmap bmHue = Hue(bm,180); //////////////////////////// SAVE /////////// Bitmap bbicon = bmHue; String extStorageDirectory = Environment.getExternalStorageDirectory().toString(); OutputStream outStream = null; File file = new File(extStorageDirectory, "er.PNG"); try { outStream = new FileOutputStream(file); bbicon.compress(Bitmap.CompressFormat.PNG, 100, outStream); outStream.flush(); outStream.close(); } catch(Exception e) {Toast.makeText(this, "error writing :/", 5000).show();} // &lt;- this exception fires. ///////////////////////////// LOAD ////////////// java.io.FileInputStream in = null; try { in = openFileInput("er.PNG"); } catch (FileNotFoundException e) {Toast.makeText(this, "error reading :/", 5000).show();} ////////////////////////////// ASSIGN /////////////// ImageView iv1 = (ImageView)findViewById(R.id.iv01); iv1.setImageBitmap(BitmapFactory.decodeStream(in)); </code></pre> <p>Thanks!</p>
android
[4]
2,399,580
2,399,581
C# calculate accurate age
<p>anyone know how to get the age based on a date(birthdate)</p> <p>im thinking of something like this</p> <pre><code>string age = DateTime.Now.GetAccurateAge(); </code></pre> <p>and the output will be some thing like 20Years 5Months 20Days</p>
c#
[0]
3,173,187
3,173,188
Anonymous class definition based on interface... maybe?
<p>I saw this Java snippet in the book <em>Spring in Action</em>, but I'm not familiar with the language construct.</p> <pre><code>new RowMapper() { public Object mapRow() throws SQLException, DataAccessException { Motorist motorist = new Motorist(); motorist.setId(rs.getInt(1)); motorist.setEmail(rs.getString(2)); motorist.setPassword(rs.getString(3)); motorist.setFirstName(rs.getString(4)); motorist.setLastName(rs.getString(5)); return motorist; } } </code></pre> <p>According the <a href="http://static.springsource.org/spring/docs/1.2.x/api/org/springframework/jdbc/core/RowMapper.html" rel="nofollow">Spring documentation</a>, RowMapper is an interface. It looks to me like an anonymous class definition based on the RowMapper interface. The <code>new</code> keyword is a little confusing, making me wonder if this also creates one instance of the anonymous class. I would guess yes, because if the class has no name, how will you ever create an instance <em>after</em> the line that defines it?</p> <p>Can anyone confirm my guesses that:</p> <ul> <li>this is an anonymous class definition based on the RowMapper interface, and</li> <li>it creates a single instance of that class?</li> </ul> <p>Thanks in advance.</p>
java
[1]
149,518
149,519
Looking for free online webservice for getting zipcode(/postalcode) from lat, long?
<p>I am Looking for free online webservice for getting zipcode(/postalcode) from lat, long ?</p> <p>There is one : </p> <p><a href="http://ws.geonames.org/findNearbyPostalCodesxml?formatted=true&amp;lat=latValue&amp;lng=longValue" rel="nofollow">http://ws.geonames.org/findNearbyPostalCodesxml?formatted=true&amp;lat=latValue&amp;lng=longValue</a></p> <p>but its not working.....!</p> <p>Do you know other than this...?</p> <p>Thanks</p>
iphone
[8]
1,926,450
1,926,451
Jquery last selector solution
<p>I have created this <a href="http://jsfiddle.net/9dF22/" rel="nofollow">Fiddle</a> with this code:</p> <p>This is my problem I want to make same behavior by selecting <b>last</b> li (fifth) tag but <b>not</b> the <b>fourth</b> like in this example ,but I don't know how to accomplish that:( </p> <p>I hope that someone can help me with this...THX!!</p> <pre><code>$(document).ready(function() { $("button").click(function() { $('.active').removeClass('active').next('li').addClass('active') if ($('ul li:last').hasClass('active')) { $('ul li:last').removeClass('active') $('ul li:first').addClass('active') } }); }); </code></pre>
jquery
[5]
904,751
904,752
I'm using Unicode value '✔' to display a tick mark in Row of Table,now I need to display’ ✔’
<p>I'm using Unicode value '✔' to display a tick mark in Row of Table,now I need to display’ ✔’ Dynamically whenever I am click on one upload button in my thckbox,through ajax request</p>
javascript
[3]
3,654,104
3,654,105
How to get android:layout_gravity="bottom" to work in LinearLayout
<p>I am trying to have 1 image on the top of my LinearLayout and 1 at the bottom on the LinearLayout.</p> <p>But after all the things I tried, I can only get 1 image layout below another. I want 1 align to the top, 1 align to the bottom.</p> <pre><code>&lt;LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="@drawable/bg1" android:layout_gravity="top" /&gt; &lt;ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:background="@drawable/bg2" android:layout_gravity="bottom" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>I have tried using RelativeLayout (in the main container) with layout_alignParentBottom (in my second image), but that does not solve my problem either. </p> <p>Thank you for any idea.</p>
android
[4]
4,577,370
4,577,371
Getting a more accurate CGRectContainsPoint result
<p>I'm new to posting on this forum but can't tell you how many times reading it has helped me out. Currently I'm working on a game for the iPhone it has a grid of UIImageViews that are contained within a subview of my gameboardViewController. I build the grid on ViewDidLoad. Ok so far. Now I am using touchesBegan to figure out which one of the UIImageViews was touched, which kind-of works. I say kind-of because CGRectContainsPoint seems to give a false result, meaning the top row of this grid is thought by that function to be outside of my subview rect.</p> <pre><code>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event { UITouch *touch = [touches anyObject]; CGPoint currentLocation = [[touches anyObject] locationInView:self.gridView]; CGRect gridRect = self.gridView.frame; // Since I have an overlay I want to ignore touches when this subview is visible. if(self.readyScreen.hidden) { /* restrict the touches to only the subview gridView so any stray touches should be ignored.*/ if(CGRectContainsPoint(gridRect,currentLocation) ) { UIImageView *theTile = (UIImageView *)touch.view; [self gridItemTouched:theTile]; } } </code></pre> <p>}</p> <p>For some reason it isn't accurate enough to see that the top row of 50 x 50 UIImageViews are within the subview.</p> <p>Any suggestions?</p>
iphone
[8]
4,664,763
4,664,764
Detect Double tap in UIScrollView
<p>How can I detect double tap in UIScrollview?</p> <p>I tried:</p> <pre><code>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; if (touch.tapCount == 2) { // some operations here } } </code></pre> <p>But this is not detecting double tap in UIScrollView, is there any other way to detect double tap?</p> <p>Regards</p>
iphone
[8]
484,967
484,968
Service and view
<p>Can i get a view by calling findIdBy(R.id.x) in a Service? thanks</p>
android
[4]
1,001,456
1,001,457
null pointer exception on list.add
<p>I've been working on this one error for a few hours so I thought I'd pick the brains of some pros. </p> <p>I am getting a null pointer exception at the modelData.add(i, es) method. I know from debugging that es isn't null. I'm really confused, thanks.</p> <pre><code>public class EventTableModel extends AbstractTableModel { //private int rowCount = 0; protected List&lt;EventSeat&gt; modelData; private static final int COLUMN_COUNT = 3; private Event e; Event j = GUIpos.m; int i = 1; public EventTableModel(Event e) { this.e = e; try { System.out.println(modelData); for (EventSeat es : e.getEventSeats()) { modelData.add(i, es); i++; } } catch (DataException ex) { Logger.getLogger(EventTableModel.class.getName()).log(Level.SEVERE, null, ex); } } </code></pre>
java
[1]
4,989,258
4,989,259
Can't catch TAB keyUp
<p>I'm trying to catch the TAB key event, but it dosen't work, I tried using this code, but still no result, wath should I do :</p> <pre><code> protected override bool IsInputKey(Keys keyData) { if (keyData == Keys.Tab) return true; return base.IsInputKey(keyData); } </code></pre> <p>pleas help! Thanks!</p> <p>I'm trying to do this:</p> <pre><code> private void comboBox1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab) { try { DataView dv = glObalDataSet.Tables["JOBURI"].DefaultView; dv.RowFilter = "CONT = '" + comboBox1.SelectedValue.ToString() + "'"; comboBox2.DataSource = LoadDataTable(dv); comboBox2.DisplayMember = "JOB"; comboBox2.AutoCompleteCustomSource = LoadAutoComplete("JOB", dv); comboBox2.AutoCompleteMode = AutoCompleteMode.SuggestAppend; comboBox2.AutoCompleteSource = AutoCompleteSource.CustomSource; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } </code></pre>
c#
[0]
5,917,835
5,917,836
Java: Using String.indexOf() to check for the apostrophe character
<p>I am trying to parse a string and I need to use substring to do it. The string contains the apostrophe characters. My question is, how do I use temp to get String.indexOf to get the index of the apostrophe character?</p> <pre><code>//temp variable currently contains the string 'hello' including the apostrophe character String finalWord = temp.substring(temp.indexOf('''), temp.indexOf('.')); </code></pre>
java
[1]
2,699,041
2,699,042
Is it programmer responsibility to delete temp file
<p>Currently, I have an application, which will save a temporary screenshot, and let user share it through facebook. The image saving code is more or less as follow.</p> <pre><code>// Use external cache dir, as our image file is large (&gt;1M) File outputDir = this.getExternalCacheDir(); File tempFile = File.createTempFile("CHEOK", "CHEOK", outputDir); // In Desktop's J2SE, this file will automatically be deleted, once my desktop // application quit. However, this is not the case for Android. My guess is, JVM // is not terminated, even our Android application had quit. tempFile.deleteOnExit(); </code></pre> <p>I realize even I quit my Android application (By pressing system "back" button), the tempFile is still there even we are using <code>deleteOnExit</code>. My guess is that the JVM is not terminated yet.</p> <p>May I know, is it our application programmer responsibility, to delete the created temp file, during Activity's <code>onDestroy</code>? If not, what is the common best practice?</p>
android
[4]
4,824,651
4,824,652
Regarding Multitasking in Android application
<p>I want to launch more than one application at the same time.Like one application should run in the background when a new application is started,and i have to switch between those two application.If anyone having the code to do this please help me.Give some website links to know about the multitasking in android and how to achieve it.</p>
android
[4]
2,470,671
2,470,672
problem with drop down value in php
<p>i have a drop down list which is populated dynamically from database table i.e</p> <pre><code>&lt;form method=post action='dropdown.php'> &lt;?php $query="SELECT DISTINCT style FROM style"; $result = mysql_query ($query); echo "&lt;select name=style[] size=4 value='' multiple>Choose Style&lt;/option>"; while($nt=mysql_fetch_array($result)){//Array or records stored in $nt echo "&lt;option value=$nt[style]>$nt[style]&lt;/option>"; } echo "&lt;/select>";// Closing of list box mysql_close($conn);?> &lt;input type=submit> &lt;/form></code></pre> <p>When i post the form to another page the value of dropdown after space is not shown i.e if i select (Micro Pave) from drop down list then it will only show Micro. my php code is</p> <pre><code>$style=$_POST['style']; if( is_array($style)){ while (list ($key, $val) = each ($style)) { echo $val."&lt;br/>"; } }</code></pre>
php
[2]
5,259,938
5,259,939
How to connect GUI screens in Android ?
<p>How to connect GUI screens in Android? I have created several screens and I want to connect these using buttons. </p>
android
[4]
3,272,832
3,272,833
Why two for statements will not run together in python?
<p>I am trying to run a Python program to calculate the total and average charges that are contained within a CSV file. </p> <p>I then want to calculate the total and average charge per invoice. The program calculates the total charges and average charges correctly, but the second for statement will not run. Both for statement run independently correctly.</p> <pre><code>import csv f = open("transport.csv", "r") reader = csv.DictReader(f) charges_per_inv = dict() inv_reader = csv.DictReader(f) inv_dict = dict() counter = 0 inv_counter = 1 for row in reader: batch_num = row['Batch#'] if batch_num not in charges_per_inv: charges_per_inv [batch_num] = 0.0 charges_per_inv [batch_num] += float(row['Amount']) counter = counter + 1 #print charges_per_inv #Just a check dvalue = [(v) for v in charges_per_inv.values()] #print dvalue total = sum(dvalue) average = float(total)/ counter #print counter #Just a check print "The total charges is, ", total print "The average charge is, ", average a = raw_input("Enter Invoice#: ") for i in inv_reader: inv_num1 = i["Invoice#"] if inv_num1 == a: if inv_num1 not in inv_dict: inv_dict[inv_num1] = 0.0 inv_dict[inv_num1] += float(i['Amount']) inv_counter = inv_counter + 1 print inv_dict #Just a check inv_amount = [(v) for v in inv_dict.values()] #print inv_amount inv_total = sum(inv_amount) inv_average = float(inv_total)/ inv_counter #print inv_counter #Just a check print "The total charges is, ", inv_total print "The average charge is, ", inv_average </code></pre> <p>Here is the output for the program.</p> <pre><code>The total charges is, 9069.87 The average charge is, 72.55896 Enter Invoice#: 617537 The total charges is, 0 The average charge is, 0.0 </code></pre>
python
[7]
2,464,804
2,464,805
update attribute a element in arraylist on java?
<p>I have a class</p> <pre><code>Class TextChunks extends Token { ArrayList&lt;Token&gt; arrt = new ArrayList&lt;Token&gt;(); } </code></pre> <p>extent fron class :</p> <pre><code>class Token { String s; int frequency = 1 ;// Tern frequency in TextChunk } </code></pre> <p>Now in token i have arraylist token , i want to update attribute frequency of token in Texchunks when have more than one tokens same .</p> <p>For clearly a give a example :</p> <p>Texchunks :" in particular in domain and range in some " </p> <p>So have 8 token : in,particular,in,domain,and,range,in,some</p> <p>i want update attribute frequency for token : in this example when i get attribute frequency of token "in" must return 3</p> <p>it mean when i call : get frequency of Texchunks when dislay :</p> <pre><code>in 3 particular 1 in 3 domain 1 and 1 range 1 in 3 some 1 </code></pre> <p>here my code :</p> <pre><code>public TextChunks updateFrequencyOfTokenInTextChunks (TextChunks tc) throws CloneNotSupportedException { TextChunks result = (TextChunks) tc.clone(); for (int i =0 ; i&lt; result.arrt.size() ; i++ ){ int j=i+1; if (result.arrt.get(i).compareTwoToken(result.arrt.get(j))== true ) { // help here how to update attribute result.arrt.get(i) // and result.arrt.get(J) = ++ and } } return tc; } </code></pre> <p>Thanks in advandce </p> <p>Here is method compare two token</p> <pre><code> public boolean compareTwoToken(Token tk){ if(this.s.toLowerCase().trim().equals(tk.s.toLowerCase())) return true; return false; } </code></pre>
java
[1]
822,018
822,019
How can I create a button that takes me back to a previous view?
<p>In my current iPhone application, I have four views. I would like to move from the first view to any of the three other views.</p> <p>In one of these second views, how would I create a button that takes me back to the first view?</p>
iphone
[8]
3,682,509
3,682,510
What is the "correct" way to start and close a PHP statement?
<p>Is there any difference or associated risk opening with the following PHP variations?</p> <pre><code>&lt;? echo "hello world!"; ?&gt; &lt;?php echo "hello world!"; ?&gt; &lt;?="hello world!"?&gt; </code></pre> <p>Also, is it necessary to close all scripts with <code>?&gt;</code></p>
php
[2]
4,988,610
4,988,611
How to listen esc key on terminal?
<p>i'm making a program without GUI, and i want catch the ESC key when is pressed for cancel a input (using Scanner).</p> <p>I'm searching on google an here but i just found for SWING</p>
java
[1]
2,031,025
2,031,026
Fatal error: Call to undefined function imagettftext()
<p>I have both GD and Freetype installed but I can't make it work. The server run CentOS 5 with cpanel.</p> <p>I read on php.net that I need to compile PHP with more options with</p> <pre><code>--with-gd --enable-gd-native-ttf --with-png --with-zlib-dir=/usr/local/lib/zlib-1.2.1 --with-ttf --with-jpeg-dir=/usr/local/lib/jpeg-6b/ --with-freetype-dir=/usr/local/lib/freetype-2.1.9/ --with-xpm-dir=/usr/X11R6/ </code></pre> <p>However, I can't figure out where I should type this.</p>
php
[2]
3,322,388
3,322,389
What is the disadvantage of setting php.ini variables in the script?
<p>What is the disadvantage of setting php.ini variables in the script ? (I set up in index.php - starting point of we site.)</p> <p>My client saying I must add all ini variable changes in php.ini file not in the script .</p> <p>Is there any security problem or runtime exceptions can happen if I set these variables in the script ?</p>
php
[2]
1,299,701
1,299,702
No constructor overloading in Python - Disadvantage?
<p>I was going through DiveIntoPython and came across this:</p> <blockquote> <p>Java and Powerbuilder support function overloading by argument list, i.e. one class can have multiple methods with the same name but a different number of arguments, or arguments of different types. Other languages (most notably PL/SQL) even support function overloading by argument name; i.e. one class can have multiple methods with the same name and the same number of arguments of the same type but different argument names. Python supports neither of these; it has no form of function overloading whatsoever. Methods are defined solely by their name, and there can be only one method per class with a given name. So if a descendant class has an <code>__init__</code> method, it always overrides the ancestor <code>__init__</code> method, even if the descendant defines it with a different argument list. And the same rule applies to any other method.</p> </blockquote> <p>Isn't this a major disadvantage that a subclass's <code>__init__</code> method will <em>always</em> override a superclass's <code>__init__</code> method? So if I'm initializing some variables and calling some functions in a class <code>class1</code>'s <code>__init__</code>, then I derive a subclass <code>class2(class1)</code> of it, I'd have to reinitialize all of <code>class1</code>'s variables and call those functions in <code>class2</code>'s <code>__init__</code>?</p> <p>I'm pretty sure I'm misunderstanding all this, so it'd be great if someone clarifies this up.</p>
python
[7]
5,581,716
5,581,717
How to clear the previous activity after starting new activity
<p>Hello guys Im having a problem in how to clear the previous activity after starting new activity</p> <p>I already try this code but it doesn't work when I press back button</p> <p>here are the code ive tried</p> <pre><code>startActivity(new Intent(this, ErrorActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); </code></pre> <p>are they any other ways to do it or something missing from my code ?? I appreciate the for your reply thx </p>
android
[4]
3,150,417
3,150,418
BarCode Reader iphone Application
<p>I want to create a bar code reader application in iphone. What to do to implement this functionality in my application. Please,Give the detail process.</p>
iphone
[8]
3,245,137
3,245,138
Passing variable to input in pop-up window with jquery
<p>Guyz, I've a weird situation: I need to pre-compile input field when visitor opens a pop-up window by clicking on the button.</p> <p>See here: <a href="http://www.ageditalia.it/" rel="nofollow">http://www.ageditalia.it/</a> in the header click on a little banner that says email and password. Pop-up will jump out. I need these password and email written on the banner to be inserted with jquery automatically.</p> <p>I tried this:</p> <pre><code>$("a:.loginonthefly-open").click(function (event) { $("#auth_username").blur(function() { if ($(this).val() == "") { $(this).val("haha"); } }); $("#auth_username").blur(); }); </code></pre> <p>but field input gets cleared, I see my haha text for few seconds and than it disappears.</p> <p>I don't understand what is going on,</p> <p>Any help appreciated!</p> <p>EDIT: So far I got this, it works only on the second click when html is inserted in dom. Doesnt work on first click on fresh page load!</p> <pre><code>$("a:.loginonthefly-open").click(function (event) { if($("#auth_username").val() == "") { $("#auth_username").delay(200).queue(function(){ $("#auth_username").val("TEST"); }); } }); </code></pre> <p>How do I make it work on first load?</p> <p>Obviously I need a better handler than click. any thoughts?</p>
jquery
[5]
590,752
590,753
How to handle Windows XP or VISTA Events in JAVA
<p>I'd like to ask another question how to handle Windows' events in Java. To be specific, I'd like to know how to handle events such as mouse moved or mouse clicked in Windows XP and Vista. I want to wire my own custom behavior in my application to these events, even when my application is inactive or otherwise hidden.</p> <p>All help is appreciated!</p>
java
[1]
5,349,011
5,349,012
Generate form dynamically and submit it by jquery
<p>i was searching google just to have way out to generate &amp; submit form by jquery and i found code snippet but few things was not clear to me.</p> <pre><code>function submitValues(url, params) { var form = [ '&lt;form method="POST" action="', url, '"&gt;' ]; for(var key in params) form.push('&lt;input type="hidden" name="', key, '" value="', params[key], '"/&gt;'); form.push('&lt;/form&gt;'); jQuery(form.join('')).appendTo('body')[0].submit(); } </code></pre> <p>why [] this third bracket is used like </p> <pre><code>var form = [ '&lt;form method="POST" action="', url, '"&gt;' ]; </code></pre> <p>what is the meaning of the line <strong>jQuery(form.join('')).appendTo('body')[0].submit();</strong> why <strong>form.join('')</strong> has been used and why write like <strong>appendTo('body')[0]</strong> why <strong>[0]</strong></p> <p>please guide me in detail for those above bold syntax. thanks</p>
jquery
[5]
5,118,903
5,118,904
Why does parseInt("09") return 0 but parseInt("07") return 7?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/850341/workarounds-for-javascript-parseint-octal-bug">Workarounds for JavaScript parseInt octal bug</a> </p> </blockquote> <p>This is related to a question someone else is working on and part of the problem came down to this. Why does </p> <pre><code>parseInt("09") </code></pre> <p>return <code>0</code> but </p> <pre><code>parseInt("07") </code></pre> <p>return <code>7</code>?</p>
javascript
[3]
3,034,163
3,034,164
Redirect Loop Error.
<p><strong>This web page has a redirect loop The web page at localhost:3613/SqaSuite/LessPermission[dot]aspx has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer. Here are some suggestions: Reload this web page later. Learn more about this problem. Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.</strong></p> <p>Despite of clearing cookies and having no recursive and/or many loop redirecting, i am having this error. help ? </p>
asp.net
[9]
2,883,151
2,883,152
Cannot uninstall Java
<p>I am unable to uninstall the Java JRE from my system. I have used Windows Installer Cleanup but still the Java folder is in Program Files.</p> <p>How can I remove Java from my PC? I'm using Windows Vista Home Premium.</p>
java
[1]
3,555,592
3,555,593
get the newwest feed title in php?
<p>now i want to on a php page showing the 5 newwest articles title of a blog.the blog is form others.and has the rss feed. how to get that? if by the rss feed.how to do? thank you.</p>
php
[2]
1,914,667
1,914,668
Android same screen size with different density
<p>I've read a lot about screen sizes and densities in android .. <br/> But seems like I'm missing something about it .. <br/> I've designed my layouts using HVGA emulator skin .. When I tried different screen sizes for HVGA ( 2 to 10 inches ) it just worked fine .. but when I tried using different skin with different density like ( WVGA800 ) it didn't appear like expected .. <br/> <b> So when I test my app against (WVGA800 skin )( 4 inch screen size ) there is a white space below the layout (it doesn't fill the whole screen ) but it works fine for (HVGA skin )( 4 inch screen size ) although both of the skins are classified as (normal screen ) but with different densities .. </b> <br/> Any ideas why this happened or what is the difference between ( 4inch HVGA ) and (4inch WVGA800 ) !! although they both are described as (normal screen size ) .. <br/> <b> Note : I know about (dp - fill parent ..... ) and all these stuff but it seems it doesn't work well for me .. </b></p>
android
[4]
3,606,556
3,606,557
Get a pop up every time a user selects another value in a dropdown list with jQuery?
<p>the following code gives me an alert with the selected value on page load</p> <pre><code>var itemLevel = $('Select[title=Item Level] option:selected').text(); alert(itemLevel); </code></pre> <p>But how do I do it if the user selects another value in the dropdown list and I want a new pop up with that value instead?</p> <p>Thanks in advance.</p>
jquery
[5]
3,883,351
3,883,352
setprop/getprop
<p>hi I am trying to modify values of some android properties. I am fairly new to this so I would appreciate it if anyone could help me.</p> <p>i am trying to modify the following settings ril.MSL and other data settings for my phone.</p> <p>question is getprop shows me the value of net.cdma.rtsp.proxy.addr but does not for ril.MSL. </p> <p>it does allow me to use setprop on both these attributes but it seems like it does not let me change the values.</p> <p>is there way i can tell which properties are read only and which can be modified? furthermore, without root access can i somehow read the ril.MSL? its hidden from me at the moment. If the property is read only why cant I read it? </p> <p>also are there any xml files i can use to edit/set to get this info?</p> <p>thanks</p>
android
[4]
3,236,620
3,236,621
communication through socket: one server and two clients
<p>I have three entities: A,B and C. A is a server and B and C are clients. A is a multithread server implemented using the class in <code>java.net</code></p> <p>I would realize a communication in which B sends a message to A, A send a message to C and C send a message B.my question is: the clients C must be even a server or is must be only a client that forward the message?</p> <pre><code>public class ServerA{ public static void main(String[] args){ boolean listening = true; int port_number = 8888; try{ ServerSocket ss = new ServerSocket(port_number); System.out.println("Waiting for incoming connection..."); while(listening){ new Thread(new ServerThread(ss.accept())).start(); } } catch(IOException ioe){ioe.printStackTrace();} } } public class ServerThread implements Runnable{ @Override public void run(){ } </code></pre> <p>}</p>
java
[1]
2,360,036
2,360,037
How do I use vector as input buffer for socket in C++
<p>I normally set up a huge size buffer and read data from socket and I realized that it is not a good way to read data. </p> <p>I used to have something like this</p> <pre><code>int bufsize = 4096; char *buf; int recv = read(sock, buf, bufsize) </code></pre> <p>I liked to use std::vector to replace the char buffer. I am not sure this is the better way though. </p> <p>Could you please provide me sample tutorials or examples about this?</p> <p>Thanks in advance...</p>
c++
[6]
2,420,535
2,420,536
How do I test if an object is inside another one using Jquery?
<p>Without using plug-ins, how would I check if an element is inside another? I tried using<br> <code>element.hover();</code><br> but to no avail. Is this possible with pure JQuery, or should I look for a workaround?</p> <p>The code currently looks like</p> <pre><code>$(document).ready(function(){ $(".element_to_drag").mousedown(function(){ $(this).addClass("dragging"); $(".dragging").live("mousemove", function(e) { var offset = $("#container").offset(); var x = offset.left; var y = offset.top; $(this).css("position", "absolute"); $(this).css("left", e.pageX - x); $(this).css("top", e.pageY - y); }) $(".dragging").live("mouseup", function(e) { $(this).removeClass("dragging"); }) $("#elementContainer").hover(function() { $(".dragging").css("background-color", "red"); }); }); }); </code></pre> <p>I'm very much still learning, feel free to critique anything.</p>
jquery
[5]
5,234,230
5,234,231
How USB keyboard communicate with Android Emulator
<p>I want to understand how PC based USB keyboard communicates with Android Emulator?, How key events are processed? Please help me to understand this.</p> <p>Thank You, </p> <p>Deepak C.</p>
android
[4]
3,186,039
3,186,040
Java: System.out and System.err output to the same stream?
<p>When using <code>System.out.println</code> or <code>System.err.println</code> what is the difference? In a console app they seems to be practically the same.</p> <p>Is there a way to change this?</p>
java
[1]
3,452,357
3,452,358
Press buttons at the same time
<p>I need to handle multiple button presses in a gui on the screen at the same time. I have looked everywhere and tried to implement my own listeners and everything without success. Any hint? </p> <p>Thank in advance!! </p>
android
[4]
5,546,842
5,546,843
How to detect The movement of the device?
<p>I want to detect a movement like a Moo Box, I reverse the phone and when I turn it back it fire an action... For Android. What is the best way</p> <p>It is possible to custom an event listenner</p>
android
[4]
1,438,326
1,438,327
when inside ready(), can I add functions?
<p>When creating functions for re-use, is it possible to create a function inside the:</p> <pre><code> $(document).ready(function () { }); </code></pre> <p>block of code?</p>
jquery
[5]
1,969,505
1,969,506
c++ How to use a ctor from another ctor?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/12030769/calling-another-constructor-when-constructing-an-object-with-const-members">Calling another constructor when constructing an object with const members</a> </p> </blockquote> <p>I want the latter to use the former. How can i do that in c++?. If it's not possible why can't i make the <code>*this = regMatrix</code> assignment? </p> <pre><code>RegMatrix::RegMatrix(int numRow,int numCol) { int i; for(i=0;i&lt;numRow;i++) { _matrix.push_back(vector&lt;double&gt;(numCol,0)); } } RegMatrix::RegMatrix(const SparseMatrix &amp;sparseMatrix) { RegMatrix regMatrix(sparseMatrix.getNumRow(),sparseMatrix.getNumCol()); vector&lt;Node&gt; matrix = sparseMatrix.getMatrix(); cout &lt;&lt; "size: " &lt;&lt; matrix.size() &lt;&lt; endl; for(std::vector&lt;Node&gt;::const_iterator it = matrix.begin(); it != matrix.end(); ++it ) { cout &lt;&lt; "Position: [" &lt;&lt; (*it).i &lt;&lt; ", " &lt;&lt; (*it).j &lt;&lt; "] Value:" &lt;&lt; (*it).value &lt;&lt; endl; regMatrix._matrix[(*it).i][(*it).j] = (*it).value; } *this = regMatrix; } </code></pre>
c++
[6]
3,456,056
3,456,057
color of the <li> change in on mouse over and click event using jquery
<p>I want to change the color of the li as red on mouse over. And keep the same color in click event also. I have the following list,</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;ul&gt; &lt;li&gt;list1&lt;/li&gt; &lt;li&gt;list2 &lt;ul&gt; &lt;li&gt;sublist1&lt;/li&gt; &lt;li&gt;sublist2&lt;/li&gt; &lt;li&gt;sublist3&lt;/li&gt; &lt;li&gt;sublist4&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;list3&lt;/li&gt; &lt;li&gt;list4&lt;/li&gt; &lt;/ul&gt; &lt;/body&gt; &lt;/html&gt; list1 list2 sublist1 sublist2 sublist3 sublist4 list3 list4 </code></pre> <p>If i click the list1, it color should be change into red, at the same time if i mouse over the other list it will be displayed as red. Its default color is black.</p>
jquery
[5]
1,472,205
1,472,206
Remove duplicates from array
<p>I have two arrays, like this:</p> <pre><code>$array1 = array( 'ADAIR', 'ADAM', 'ADAMINA', 'ADDISON', 'ADDY', 'ADELLE', 'ADEN', 'ADOLPH', 'ADRIANNA' ); $array2 = array( 'ADAIR', 'ADAMINA', 'ADRIANNA' ); </code></pre> <p>How do I make a third array, without duplicates? <strong>We should take first array and remove from it duplicates from second array.</strong></p>
php
[2]
1,571,791
1,571,792
Automatically Selecting File and Submitting, Javascript
<p>So I am trying to programmatically browse and I want to upload a file to an input tag with the type of file.</p> <p>How would I go about this? I don't want the user to have to input any data, but to instead go after a predefined file.</p>
javascript
[3]
276,365
276,366
How can I make an array when there are duplicate values?
<p>I have data that contains links for a navigation bar. It should be structured exactly like an unordered list, with a header and then all of the corresponding links below that header. I cannot seem to build this correctly. This would be some sample data from the database.</p> <pre><code>HEADING LIST LINK Favs google http://... Favs yahoo http://... Favs stackoverflow http://... Site first link http://... Site second link http://... </code></pre> <p>This data should then <strong>group</strong> all of the headings into one and then display the links associated with them. Is this even possible or maybe there is a better way?</p> <p>I plan to use the "HEADING" and "LIST" to dynamically build a <code>&lt;UL&gt;</code> type of menu.</p> <p><hr /></p> <p>Well, this isn't working as I had hoped. Here is the array that is being built from the database. Notice how sidebar[0] and sidebar[1] rpeat the value "Favs". This will repeat the same value on my form which I don't want. All of the duplicate names should be grouped together. Is this possible?</p> <pre><code>Array ( [date] =&gt; Sun, 25 Oct 2009 [sidebar] =&gt; Array ( [0] =&gt; Array ( [Favs] =&gt; Array ( [author_sidebar_link] =&gt; google.com ) ) [1] =&gt; Array ( [Favs] =&gt; Array ( [author_sidebar_link] =&gt; yahoo.com ) ) [2] =&gt; Array ( [Offsite] =&gt; Array ( [author_sidebar_link_title] =&gt; something ) ) [3] =&gt; Array ( [Something] =&gt; Array ( [author_sidebar_link] =&gt; something else ) ) ) ) </code></pre>
php
[2]
5,919,363
5,919,364
C++ - MPIR: Fastest Log Function?
<p>MPIR is a really good library that I am currently using in C++ to deal with large numbers. Unfortunately, it does not have any log functions. Because of that, I am seeking a fast log function for MPIR's mpz_class.</p> <p>We are all well aware of the fact that there are some log functions that are already provided in C++ (or should be), which are located in the Math header file (Math.h). Unfortunately, they can not handle big numbers, which is one of the many reasons why I am using MPIR library,</p> <pre><code>::mpz_class Log( ::mpz_class n ) { ::mpz_class ret; return ret; }; </code></pre> <p>There are some cases in which the log of n returns floating value. Hence, our log function must be able to return a floating value. If we were to do the Log of 15, it should return 1.17609125906.</p>
c++
[6]
2,654,125
2,654,126
Update Gridview on treeview node checked
<p>I need to update or filter the records in gridview, when I check a node in treeview <strong>without postback.</strong> I tried placing the gridview in update panel and registered ASYNCPOSTBACKTRIGGER for treeviews NODECHECKCHANGED event, but still the postback occurs.</p> <p>How can I solve this or any other approach? please help</p>
asp.net
[9]
3,525,430
3,525,431
Convert HH:MM:SS to seconds in xcode
<p>Hi I have the code to separate hour,min,sec Now i have to convert it in to seconds.and nsnumber</p> <pre><code> NSRange range = [string rangeOfString:@":"]; NSString *hour = [string substringToIndex:range.location]; NSLog(@"time %@",hour); NSRange range1= NSMakeRange(2,2); NSString *min = [string substringWithRange:range1]; NSLog(@"time %@",min); NSRange range2 = NSMakeRange(5,2); NSString *sec = [string substringWithRange:range2]; NSLog(@"time %@",sec); </code></pre>
iphone
[8]
3,185,029
3,185,030
syntax error in python due to whitespaces i think
<p>I am still confused in the way of writting a python code as i am used to java codes with brakets and i cant fully understand the indentation concept. So this is a code that produces a syntax error so any one can help please ? Thank You in advance</p> <pre><code>def SendSMS2 (phone_number,sms_text): print 'made it to def' res = MDM.send('AT+CMGS='+ phone_number + '\r',5) n=0 while n &lt; 20: res=MDM.receive(1) if res.find("&gt;") &gt;-1: print n break else: n = n +1 res = MDM.send(sms_text, 10) if res != -1: print 'Text sent ok' res = MDM.sendbyte(0x1a,10) n=0 while n &lt; 20: res=MDM.receive(1) if res.find("+CMGS") &gt;-1: print n break if res.find("ERROR")&gt;-1: print 'sms ok' else: print 'not good' else: n = n +1 print 'def completed *******************' </code></pre>
python
[7]
2,399,789
2,399,790
How To get Calling time of the web service
<ol> <li><p>I am working on an application,in which i get response from web service.</p> <p>2.I use soap,i want time when i call to web service,and to show in text view.</p> <p>3.please any body give some idea.</p></li> </ol>
android
[4]
2,139,571
2,139,572
C# Correct way to change DateTime value?
<p>Is is possible to change the value returned by DateTime? Or at least assign it to a variable then change that variable?</p> <pre><code> internal int hour; internal int minute; DateTime time = DateTime.Now; public int incrementHour(int step) { if (step &gt; 0 &amp;&amp; hour &lt; 24) { //step = step % hour; hour = (hour + step) % 24; time.AddHours(hour); return hour; }//end of if else { MessageBox.Show("Please enter a positive number."); return 0; }//end of else }//end of incrementHour </code></pre> <p>Addhours doesn't really do anything from the looks of it. </p>
c#
[0]
3,776,323
3,776,324
Cannot set the background color of "TD" using JQuery
<p>I have a table as under</p> <pre><code>&lt;table &gt; &lt;tr&gt; &lt;th scope="col"&gt;EmpId&lt;/th&gt;&lt;th scope="col"&gt;EmpName&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;1&lt;/td&gt;&lt;td&gt;ABC&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;2&lt;/td&gt;&lt;td&gt;DEF&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>I want to set the background color of only the <strong>"td"</strong> elements of the table and not <strong>"th"</strong>. I have tried with</p> <pre><code>$("table").children("td").css('background-color', '#00ff00'); OR $("table").children("tr").children("td").css('background-color', '#00ff00'); </code></pre> <p>But with no result. </p> <p>Please help as what mistake I am doing?</p> <p>Thanks</p>
jquery
[5]
5,699,101
5,699,102
Animating Opacity of an image using mouseover and mouseleave events
<p>I have 2 images inside a with opacity set to 0.2 :</p> <p>When I hover over the div, I want to bring the opacity to 1 for the 2 images, here is the code :</p> <pre><code>$(".comment-thread").live("mouseover", function () { $(this).find('.comment-rating-down').animate({ opacity: 1 }, 500); $(this).find('.comment-rating-up').animate({ opacity: 1 }, 500); </code></pre> <p>});</p> <p>$(".comment-thread").live("mouseout", function () {</p> <pre><code> $(this).find('.comment-rating-down').animate({ opacity: 0.2 }, 500); $(this).find('.comment-rating-up').animate({ opacity: 0.2 }, 500); </code></pre> <p>});</p> <p>What happens is when I hover over the div, the 2 buttons blinks like 4 times and more as if it is buffering the animation.</p> <p>Is there a better technique ?</p> <p>Thanks</p>
jquery
[5]
1,400,355
1,400,356
Uploading video to Youtube from PHP driven webpage
<p>It is possible to upload a video file from my own webpage on you tube without using google. If yes how to do it?</p>
php
[2]
4,478,429
4,478,430
Can i copy 'vector' elements in 'set' using the copy algorithm?
<p>I am getting the run time error in following code. Please let me know can i copy vector elements in set?</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;set&gt; using namespace std; int main() { vector&lt;int&gt; v; set&lt;int&gt; kk; set&lt;int&gt;::iterator itr; for (int i=0; i&lt;6;i++) v.push_back(i*2); copy(v.begin(), v.end(),inserter(kk, itr)); } </code></pre>
c++
[6]
5,304,154
5,304,155
Create div tag template and reuse
<p>Is it possible to create a template e.g with lots of other elements inside it with proper attribute "tagging" and reuse it with jquery? For instance when you want to display user submitted comments without refreshing the page. The reason I ask this is because the code between the div tags are rather long. So using for instance prepend() would be to long to rewrite.</p> <p>Whats the best approach for larger manipulations? Create a separate html? Im pretty new to manipulation, but since I have a programming background i would expect that there is an efficient way to reuse already existing HTML instead of redefining it in jquery.</p>
jquery
[5]
1,330,337
1,330,338
onChildClick events stop after scrolling a listview
<p>I have an app that uses an ExpandableListView widget filled with items via a BaseExpandableListAdapter. The app was built for the Android Version 1.6, and when I test it using the Android Emulator (version 1.6 build) everything works fine. I can scroll the list up and down and when I tap on any items in the list I get a onChildClick() event.</p> <p>However, when I try to run this same app on an real Android phone (running Gingerbread), I only get onChildClick() events if I don't scroll the ExpandableListView. If I scroll the list too much, I no longer get onChildClick events (nor itemClickEvents also). </p> <p>So I'm baffled. Why do I not get any onChild or onItem click events for the listview items after I scroll it? Note, that if I scroll it just a small amount (say, 2 or three lines) I do get click events, but any more scrolling and then I no longer get click events for any item in the list.</p> <p>Any suggestions or advice would be appreciated.</p> <p>Thanks.</p>
android
[4]
840,230
840,231
Java client-server application example
<p>Please advice where can I see the source code example of a simple client-server application (code for both)?</p>
java
[1]
5,053,615
5,053,616
Make the tab to become side scollable
<p>The red box is the part that I want to make it side-scrollable, because it has 4 options and it is all cramped together. I wish to make it 2 options in the 1st view and followed by swiping to right we have another 2 options show.</p> <p>Can you all guide me on how to do it?</p>
android
[4]
1,517,987
1,517,988
android - How to download the images from the web and how to use int the app without getting the out of memory exception
<p>I my application one issue is there. please suggest how to do it. Issue: Downloading the images from the web and how to use it in the app.</p> <ol> <li>For this , first i am downloading the images from the web and these images are stored in the sdcard dynamically. But here i am getting out of memory exception. one more problem is there it is not working in the mobiles which don't have sdcard.</li> </ol> <p>Please suggest the better way how to do it. can any body help me.</p> <p>thanks</p>
android
[4]
4,063,378
4,063,379
Service that broadcasts different message types
<p>I want to make a service that I can register to. The service will broadcast messages of different "types" and each application can register itself to recieve messages of different type.</p> <p><strong>For example:</strong></p> <p>I want to write a servive that reads the twitter messages of some user and broadcasts to the systems the tags. Then a consumer can register to recieve only messages of tag "foo", and recieve the tweet message. Another consumer can register to recieve only messages of tag "bar", and recieve the tweet message.</p> <p>Lets assume I know how to build a service. My first idea is to just broadcast a something, and then filtering it in the apps. But I am not happy about this solution. I know there are some android services that work similar to what I want, but I found no reference on the web on how to implement this.</p> <hr> <p>Some RTFM I have done is:</p> <ul> <li><a href="http://groups.google.com/group/android-developers/browse_thread/thread/e1863d2822b22a33/90873ef925cd2aad" rel="nofollow">http://groups.google.com/group/android-developers/browse_thread/thread/e1863d2822b22a33/90873ef925cd2aad</a></li> <li><a href="http://www.vogella.de/articles/AndroidServices/article.html" rel="nofollow">http://www.vogella.de/articles/AndroidServices/article.html</a></li> <li><a href="http://stackoverflow.com/questions/3998650/what-is-the-simplest-way-to-send-message-from-local-service-to-activity">What is the simplest way to send message from local service to activity</a></li> <li><a href="http://stackoverflow.com/questions/2463175/how-to-have-android-service-communicate-with-activity">How to have Android Service communicate with Activity</a> -> not good for me, as this question is about a single process, and I need the service talking to several different processes </li> </ul> <p>The main problem, is that most of the docs on the internet are about me calling the service, and not the service calling me.</p>
android
[4]
1,780,927
1,780,928
how to code a progress bar
<p>I'm building a youtube player with custom controls using the youtube api:</p> <p><a href="http://code.google.com/apis/youtube/youtube_player_demo.html?playerType=chromeless&amp;playerVersion=as3" rel="nofollow">http://code.google.com/apis/youtube/youtube_player_demo.html?playerType=chromeless&amp;playerVersion=as3</a></p> <p>I've got the play/pause/skip buttons all done but I've got to create a progress bar and I can't think how to do it. I've never programmed a progress bar before. I can access the total video time and also poll the current play time using setinterval...so every 250ms for example I can poll to find out the videos current position.</p> <p>My question is how do I make use of that data to create a progress bar? I'm thinking of a div that I could manipulate in width to show video progress. My problem is how do i make use of the data (total video duration and current time) to decide when and how much to increase the width of this div.</p> <p>Hope this makes sense.</p>
javascript
[3]
5,028,323
5,028,324
Pages does not find my PHP includes
<p>I am having an include folder with haeder.inc.php, nav.inc.php and footer.inc.php.</p> <p>So, I do want to organize my php pages by sections. </p> <p>I mean, I do want to have a pic folder, then a video folder and put inside all php pages related to each folder.</p> <p><strong>Problems</strong> The php pages does not find my include folder (haeder.inc.php, nav.inc.php and footer.inc.php.)</p> <p>I hope it makes sense. </p>
php
[2]
3,988,573
3,988,574
Detect string/user input language
<p>I wanted to know if there is a way to detect if the user's input is in greek charset.</p> <p><strong>Edit:</strong><br> Just to be more clear, I need to recognize the language the user types and not the phone's locale. <br><br>For example, my phone is in English and let's say my keyboard is in Russian, the getDefault() returns "en", but I need to have "ru" at that point.<br></p> <p><br> I do not know if this is available out of the box from android, maybe an approach to detect the string's character codes and see if is in English alphabet or in another. Any points on this?<br><br>I imagine something like <br><code>if character belongs to K then is English</code> <br><code>(where K is the essemble of english characters)</code> </p> <p><br><strong>Solution:</strong><br></p> <p>Finally I used regular expression to determine if the string is in English.<br></p> <pre><code>String pattern = "^[A-Za-z0-9. ]+$"; if (string.matches(pattern) // is English else // is not English </code></pre> <p>If someone has to propose a better solution I will mark it as answer.</p>
android
[4]
789,420
789,421
Dynamic graph generation
<p>I'm looking for JS library to help me in task like this. I've got sentences divided into words on the left side. Each word is displayed as bordered box. On the right side is place for editor. For each sentence I want to create a graph (tree) in a way that you drag&amp;drop boxes into editor. Graph will be stored as JSON array. I'm looking for library which will help me in generating this type of graphs. Any ideas or maybe other solutions for this problem?</p> <p><img src="http://i.stack.imgur.com/1gywb.jpg" alt="enter image description here"></p>
javascript
[3]
5,810,808
5,810,809
Company name in info.plist file - iPhone
<p>I am planning to release an iPhone app. Where can I set the company's name in the info.plist file?</p> <p><strong>UPDATE:</strong></p> <p>In addition to the company's name, I wanted to set the Product name and version.</p> <p>Is iTunes Connect the only option? or we can do it in the project itself.</p>
iphone
[8]
4,766,833
4,766,834
What is wrong with this php line?
<pre><code>var $foo = array('foo' =&gt; $bar); </code></pre> <p>I am getting an UNEXPECTED T_VARIABLE error. I can't use variables when creating arrays?</p> <p>This declaration is inside a class, and I am running PHP v5.3.2</p> <p>When removing the var, I get another error <code>Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION</code></p> <p>Thanks</p>
php
[2]
4,458,814
4,458,815
Get running time of a thread java
<p>How can I get the runtime a thread in java such as: at 00:30 minutes of Thread[n], something() happened.</p> <p>I'm basically looking to make a log file for a program dealing with audio files.</p> <p>Thank you.</p>
java
[1]
2,028,023
2,028,024
How to know the element is a child of a parent
<pre><code>&lt;ul id="ulel"&gt; &lt;li id="liel"&gt; &lt;a id="ael"&gt;&lt;/a&gt; &lt;/li&gt; ... &lt;/ul&gt; </code></pre> <p>How I can know that if <code>#ael</code> anchor exists inside <code>#ulel</code> in jquery?</p>
jquery
[5]
953,025
953,026
What is a good tutorial for peer-to-peer networking on the iPhone?
<p>I would like to make a game where two players are connected via WiFi or Bluetooth, but I've not found any good tutorials out there on this. What resources do you recommend for learning peer-to-peer networking on the iPhone?</p>
iphone
[8]
3,212,638
3,212,639
How to develop for multiple websites in parallel?
<p>If it makes any difference, I am using Xampp on windows for my web server &amp; PHP (all web pages are PHP based, some include JS, all include CSS file).</p> <p>The point is that I have a local directory which represents <code>http://localhost</code> and if I want to develop multiple websites I have to copy them all under that directory.</p> <p>And since most of them have CSS, images and many have JS, I end up with the images/JS/CSS for all websites mixed in to <code>http://localhost/images</code>, <code>http://localhost/css</code>, etc.</p> <p>And when I come to upload them it's a nightmare. I am worried that I might forget to upload some vital files, or to upload files that do not belong to the site.</p> <p>What's the solution?</p> <p>In my case, all files are PHP, so should I tweak <code>$_SERVER['DOCUMENT_ROOT']</code> but I wonder what the general approach by professional web designers is.</p>
php
[2]
3,870,977
3,870,978
cannot be applied to operands of type 'int' and 'int'"
<p>My C# code:</p> <pre><code>public int printallancestor(Node root, Node key) { if(root == null) return 0; if(root == key) return 1; if(printallancestor(root.leftChild,key)||printallancestor(root.rightChild,key)) { Console.WriteLine(root.iData); return 1; } return 0; } </code></pre> <p>The following line <code>if(printallancestor(root.leftChild,key)||printallancestor(root.rightChild,key))</code> from above code i get following error <strong>cannot be applied to operands of type 'int' and 'int'</strong>. What is wrong with this?</p>
c#
[0]
104,013
104,014
Photo Tagging in Javascript
<p>What I want to know is how can I make a drag selection box using JavaScript. </p> <p>What I mean, is when you click the left mouse button and drag, a "wire" (I don't know the term for it) should appear , like on your desktop. </p> <p>Clicking and dragging on an image and when released a search box should appear below the dragged area.</p> <p>I'm sure this is possible, but I didn't find any example.So , can you help me ?</p>
javascript
[3]
2,925,337
2,925,338
Using javascript to create a value in url and submit that value via form?
<p>I have a site that request that they could send out different urls to clients to track what links are being used. I told them to use google analytics but they are requesting to stay away from it.</p> <p>What they are asking is they want to send a url to there customers such as, <a href="http://www.yoursite.com/?link=Nameoflink" rel="nofollow">http://www.yoursite.com/?link=Nameoflink</a></p> <p>They want to get that cookie and set it. Then when the contact form is used they want to be able to submit that link name with the form submission to show what links are being used to go directly to there site.</p> <p>I was told this is possible but i have no knowledge of that custom of javascript or cookie expertise... =/</p>
javascript
[3]
1,983,177
1,983,178
Why can't I cast to B*?
<p>I'm trying to cast to B* using operators but it's not working. Why? Thanks.</p> <pre><code>struct B; struct A { A() = default; operator (B *)() { return new B(); } }; struct B { B() = default; }; int main() { A a; B *b = a; } </code></pre> <p>I get the error: <code>cannot convert 'A' to 'B*' in initialization</code></p>
c++
[6]
1,797,449
1,797,450
Failed to run stanford CS107 assignment files on my Mac or PC, help~
<p>I was auditing Stanford cs107 and unable to get the assignment files (which could be found here <a href="http://see.stanford.edu/see/materials/icsppcs107/assignments.aspx" rel="nofollow">http://see.stanford.edu/see/materials/icsppcs107/assignments.aspx</a>) working on my Mac or PC. I tried to run it on Ubuntu through VM, it didn't work either. </p> <p>In assignment 1, the file rsg-sample-linux shows not executable, unlike it is on the assignment PDF file. After I used chmod to change it to be executable, the terminal on my Mac says "cannot execute binary file", and Ubuntu says "no such file directory" something like that.</p> <p>I really want to go through all the assignments while auditing this class</p> <p>Thanks!</p>
c++
[6]
5,811,357
5,811,358
ArrayList Into String
<p>I have a <code>Activity</code> that pulls an <code>Array</code> from the previous <code>Activity</code>. I can use this code below which gets the <code>Array</code> from the previous <code>Activity</code> and puts it into a <code>TextView</code>.</p> <p><strong>Update using <code>initWheel(R.id.passw_1, names.toArray(new String[names.size()]));</code> fixed the problem</strong></p> <pre><code>ArrayList&lt;String&gt; names = intent.getStringArrayListExtra("KEY"); TextView et2 = (TextView) findViewById(R.id.editText2); et2.setText(""); if (names.size() &gt; 0) { for (String str : names) { et2.append(str + " "); } } </code></pre> <p>This works fine but is not what I need exactly. Instead of it populating a <code>TextView</code> I need it to fill a <code>String</code> which is like this </p> <p><code>initWheel(R.id.passw_1, "ArrayList Here");</code></p> <p>I have another which will be set by default in the code that looks like this and I need the array to populate the one above in the same format:</p> <p><code>initWheel(R.id.passw_2, new String[] { "Foo", "Bar" });</code></p>
android
[4]
3,067,262
3,067,263
lvl integration
<p>I read many tutorials but I don't understand how integrate lvl to my app. My situation: I've an app with some preferences "disabled". I done a check (using pm). So, using if/else I check if app key (downloadable from market) is installed or not. I don't understand how integrate lvl to protect my app. Is there a good tutorial or same advices?</p> <pre><code> PackageManager manager = getPackageManager(); if (manager.checkSignatures("core.package.name", "key.package.name") == PackageManager.SIGNATURE_MATCH) { //full version isEnabled = true; getPreferenceManager().findPreference("keep").setEnabled(true); } else { [...] // free version </code></pre>
android
[4]
717,307
717,308
Need to ecape non ascii characters in javascript
<p>i belive this question has already be asked, but i can not find it. The question is: Is there any function to do the following ?</p> <pre><code>var specialStr = 'ipsum áá éé lore'; var encodedStr = someFunction(specialStr); // then encodedStr should be like 'ipsum \u00E1\u00E1 \u00E9\u00E9 lore' </code></pre> <p>I need to encode those character out of ascii range, and need to do it with that encoding (i don't know its name , is it unicode maybe?)</p> <p>Thanks a lot.</p>
javascript
[3]
872,259
872,260
Location Service
<p>i create a service class that extends location listener. whenever the location changed i has to do some work. </p> <p>Firstly i do my work in "onLocationChanged" function but here problem is that when location changes and "onLocationChanged" called then the work i do in "onLocationChanged" repeat continously. </p> <p>Then i set set latitude and longitude in "onLocationChanged" function and call another function in timer, but within timer, my function cannot be called and give error "Can't create handler inside thread that has not called looper.prepare".</p> <p>Any one can help me please that how can i call function repeatdly after some specific time within service.</p>
android
[4]
4,672,139
4,672,140
How do you break down a new project with an existing mega PHP site?
<p>I've got to dive into a very large PHP site and have my first client meeting today. All they gave me so far was the URL. </p> <p>How do you guys go about gathering/structuring/documenting and preparing for a new project in a PHP environment? What things do you ask for up front?</p> <p>PS - I know there are other general questions about this but I want a PHP-flavored one, including tools (even if universal) and approaches.</p> <p>Thanks!! I'm excited but also scared.</p>
php
[2]
5,581,420
5,581,421
How to make the following C# GroupBy function better?
<p>I have a <code>Dictionary</code> of type <code>IDictionary&lt;string, Country&gt;</code>, whose the <code>Key</code> is name of a city and the Value is an <code>Enum</code> type of <code>Country</code>. </p> <p>Items in this dictionary would look like these: &lt;"Vancouver", Country.Canada>, &lt;"Seattle", Country.US>, &lt;"New York", Country.US> etc.</p> <p>I need to group all the items in the dictionry by value (i.e. Country). And output strings like this:</p> <p>"US Cities: Seattle, New York" "Canada Cities: Vancouver"</p> <p>Here is what I've written:</p> <pre><code>public void GroupByCountry(IEnumerable&lt;KeyValuePair&lt;string, Country&gt;&gt; dict) { string text = string.Empty; var groups = dict.GroupBy(p =&gt; p.Value, p =&gt; p.Key); foreach (var g in groups) { List&lt;string&gt; citiesInGroup = new List&lt;string&gt;(); foreach (string city in g) { citiesInGroup.Add(ext); } text += string.Format("{0}: {1}\n", Enum.GetName(typeof(Country), g.Key), string.Join("|", citiesInGroup.ToArray())); } Log.Info(logCategory, string.Format("Result:\n{0}", text)); } </code></pre> <p>This code works. But I am wondering if it can be more concise and elegant?</p>
c#
[0]
1,642,661
1,642,662
Transfer records
<p>Suppose I have a datagridview with 100 records </p> <p>When I select a record</p> <p>record go to the Datagridview form2</p> <p>Then when I came back to form1</p> <p>And others chose a record</p> <p>It also goes to form2, but there is also the previous recession</p> <p>Want datagridview in form2 remains constant</p> <p>I hope you understand what I mean</p>
c#
[0]
5,070,945
5,070,946
Java: howto write equals() shorter
<p>I get headaches when I have to write nearly 10 lines of code to say <code>2 Objects are equal, when their type is equal and both's attribute is equal</code>. You can easily see that in this way of writing the number of lines increase drastically with your number of attributes.</p> <pre><code>public class Id implements Node { private String name; public Id(String name) { this.name = name; } public boolean equals(Object o) { if (o == null) return false; if (null == (Id) o) return false; Id i = (Id) o; if ((this.name != null &amp;&amp; i.name == null) || (this.name == null &amp;&amp; i.name != null)) return false; return (this.name == null &amp;&amp; i.name == null) || this.name.equals(i.name); } } </code></pre>
java
[1]
5,347,605
5,347,606
passing multidimensional arrays to function
<p>I have a method in my class which uses a 3dimensional tfpairexp as input parameter. and I need to use the values in tfpairexp later.</p> <pre><code>void calctfpairexp (int tf1, int tf2, double tfpairexp[][2][3]) { int ctr,c; for (int j = 0; j &lt; cchips &amp;&amp; (c = chips[j].crepls); j += c) { int ctrl_no=0; for (int *p = chips[j].ctrl ; p &amp;&amp; (ctr=*p)&gt;=0; ++p,ctrl_no++) { for (int k = 0; k &lt; c; ++k) { tfpairexp[j][ctrl_no][k]=interactionFunc(2,3,1); } } } } </code></pre> <p>I call the method inside the class like this: <code>calctfpairexp(tf1,tf2,tfpairexp);</code> and I need to use values inside tfpairexp in next lines. but the compiler gives error in this line: </p> <pre><code>`calctfpairexp(tf1,tf2,tfpairexp);` </code></pre> <p>It says that it can't find the suitable the suitable funciton for calctfpairexp. any idea?</p>
c++
[6]
1,288,216
1,288,217
runtime/compile time polymorphism
<p>In the below code , why b1.subtract() fails . Please explain me the reason ie., what happens in JVM while invoking that method .</p> <pre><code>class Base { public void add() { System.out.println("Base ADD"); } } class Child extends Base { public void add(){ System.out.println("Child ADD"); } public void subtract() { System.out.println("Child Subtract"); } } class MainClass { public static void main(String args[]) { Base b1 = new Base(); Base b2 = new Child(); Child b3 = new Child(); b1.add(); b2.subtract(); // ?????????**previously it was b1.subtract and its wrong b2.add(); b3.subtract(); } } </code></pre>
java
[1]
3,075,857
3,075,858
Changing the signature of one method
<p>So I have the following method </p> <pre><code>public static &lt;T extends Comparable&lt;? super T&gt;&gt; void bubbleSort( T[] a) //public static void bubbleSort(Comparable[] a) { for(int top = a.length-1; top &gt; 0; top--) for(int i = 0; i &lt; top; i++) if(a[i+1].compareTo(a[i]) &lt; 0) { T tmp = a[i]; //Comparabl tmp = a[i]; a[i] = a[i+1]; a[i+1] = tmp; } } </code></pre> <p>How do I change the method signature in order to be able to call it from something like</p> <pre><code>public int sortByTitle() { return Sorting.bubbleSort(lib); // (lib is lib = new ArrayList&lt;Object&gt;(); } </code></pre> <p>I must not use collection methods or comparator object.</p>
java
[1]
860,823
860,824
Javascript prototype inheritance issue
<p>I'm having an issue with prototype inheritance and I can't find out why it's not working properly.</p> <p>The snippet is this:</p> <pre><code>function Field(newKey, val) { this.key = newKey || ""; this.value = val || ""; } Field.prototype.isEmpty = function() { return this.value === undefined || this.value === null || this.value === ""; }; function DoubleField(newKey, val) { this.base = Field; this.base(newKey, val); } DoubleField.prototype = new Field(); DoubleField.prototype.constructor = DoubleField; function IntegerField(newKey, val) { this.base = DoubleField; this.base(newKey, val); } IntegerField.prototype = new DoubleField(); IntegerField.prototype.constructor = IntegerField; var f = new Field('keyfield', 'valField'); var d = new DoubleField('keydouble', 'valDouble'); var i = new IntegerField('keyinteger'); var res = f.isEmtpy(); </code></pre> <p>The call to f.isEmpty is failing? Why? Calls to d.isEmpty or i.isEmpty work just fine as expected.</p> <p>I cannot realize what I'm doing wrong. Any help would be much appreciated!</p>
javascript
[3]
5,659,881
5,659,882
permission for my php to create a dynamic file on the server
<p>For a project I need my php file to create a dynamic file (on remote server which I bought) which loads into a flash component. Everything is working fine on my localhost. But once I upload it to the server, it throws the following errors:</p> <pre><code>Warning: fopen(output.html) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\vhosts\x.co.in\httpdocs\blabla.php on line 25 Warning: DOMDocument::save(k_id.xml) [domdocument.save]: failed to open stream: Permission denied in C:\Inetpub\vhosts\x.co.in\httpdocs\blabla.php on line 136 </code></pre> <p>where on those lines fopen is written.</p> <p>I understood as there is no permission to my php file to create any dynamic files on the server. So i just wanna understand is there a way by which I can privilege my php to create that file on the server. </p> <p>I've the login access, which I think I've to put somewhere in code before it tries to create such file...but i dont know how to figure this...any suggestions?</p>
php
[2]
5,688,985
5,688,986
Is there a way to shorten the condition if it always compares to the same thing?
<p>I have always found it annoying when I need to write a condition that compares the same item over and over again since I would have the type the item so many times:</p> <pre><code>string x = textBox1.Text; if (x == "apple" || x == "orange" || x == "banana" ...) ... </code></pre> <p>I want something like this (but of course this is not correct syntax):</p> <pre><code>if (x == "apple" || "orange" || "banana" ...) </code></pre> <p>Is there a solution other than using an array of the strings?</p>
c#
[0]
1,124,873
1,124,874
PHP - I need a way to replace square brackets with dynamic data
<p>I am trying to build a system which will allow the user to enter a certain amount of text in a textarea field, within the text entered, the user will enter a "variable" in the format [VAR], the text VAR will be replace by the "variable" the user needs such as [AMOUNT], which will query a database to find the amount for the user, i need a PHP script will find those square bracket variable and replace it by some dynamic data. </p> <p>Can anybody help?</p> <p>Regards, Roddy</p>
php
[2]
2,720,017
2,720,018
Member Access in Java
<p>I have code where a variable name is identical to the class name. I.e.:</p> <pre><code>class Foo { static public void main(String[] args) { Integer Foo; Foo.main(args); } } </code></pre> <p>How can I call the main-method without renaming the variable or the class?</p>
java
[1]
593,127
593,128
How to connect with database and retrieve values from database using android?
<p>I need to create a database in cloud using android. How to connect with that database and retrieve values from database using android?</p>
android
[4]
2,164,133
2,164,134
Why are the methods of the Math class static?
<p>Why are the methods of the Math class static ?</p>
java
[1]
5,996,712
5,996,713
Shifting all the values in an array one index higher with the displaced last element placed as the first element
<p>I'm struggling with the below code in JS please help:</p> <p>Currently trying to get</p> <p>[20,30,40,50]</p> <p>to be</p> <p>[50,20,30,40]</p> <p>any tips?</p> <p>Here is the code I have so far below!</p> <pre><code>// A program to shift all the values in an array one index higher, with the displaced last element being placed as the first element var test = [20,30,40,50]; for (i=0; i&lt;test.length;i++) { alert(test[i] + " is currently index: " + [i]); } test[0] = test[test.length-1]; for (i=0; i&lt;test.length;i++) { alert(test[i] + " is now index: " + [i+1]); } </code></pre>
javascript
[3]