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,347,540
2,347,541
Big delay using Intent.ACTION_HEADSET_PLUG when the device is sleeping
<p>I have some troubles using a <code>BroadcastReceiver</code> when the device is sleeping. I use this code in the <code>OnReceive</code> metod:</p> <pre><code>public void onReceive(Context context, Intent intent) { Intent i = new Intent(context, ConnectionActivity.class); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP , C.WAKE_UP_TAG); wl.acquire(); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } </code></pre> <p>When I plug in the headphone and the screen is off, there is a delay between 5 and 30 seconds until the screen turns on. </p>
android
[4]
5,886,678
5,886,679
Turn on Wifi using a Widget
<p>i need to toggle wifi on and off when user clicks a widget icon...</p> <pre><code>WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); if(wifiManager.isWifiEnabled()) wifiManager.setWifiEnabled(false); else wifiManager.setWifiEnabled(true); </code></pre> <p>How do i implement it using pendingIntents?</p>
android
[4]
2,195,618
2,195,619
Conditionally modify global variable
<p>I'd like to do something like this, but I get a SyntaxWarning and it doesn't work as expected</p> <pre><code>RAWR = "hi" def test(bool): if bool: RAWR = "hello" # make RAWR a new variable, don't reference global in this function else: global RAWR RAWR = "rawr" # reference global variable in this function print RAWR # if bool, use local, else use global (and modify global) </code></pre> <p>How do I get this to work? Passing in True or False modifies the global variable.</p>
python
[7]
847,981
847,982
soap based xml parsing using libxml2
<p>i am using simple nsxml soap based parser but in the response it gives me 300 to 500 tunes of data so nsxml parser is not desirable in this scenario please guide how can i use soap based libxml2 parser along with a sample code would be a bost to me as i have no idea regarding the libxml2 parsing method </p>
iphone
[8]
2,206,381
2,206,382
creating a coupon for ipassbook using passsource.com, does anybody know how iphone determines which application to open based on the url?
<p>i am working on creating a coupon for ipassbook using passsource.com, does anybody know how iphone determines which application to open based on the url?</p> <p>I created a sample coupon with passsource.com API and it redirected me to the following URL <a href="http://www.passsource.com/create.php?data=eNortjIxsVIKCUpyyzRIiwox1Q4Jjig38rNwNw73145wtkiqLE43zYsIsSjxjYxyDHZ1tVWyBlwwl9EPgQ,,&amp;template_id=2" rel="nofollow">http://www.passsource.com/create.php?data=eNortjIxsVIKCUpyyzRIiwox1Q4Jjig38rNwNw73145wtkiqLE43zYsIsSjxjYxyDHZ1tVWyBlwwl9EPgQ,,&amp;template_id=2</a></p> <p>Asking to send this to the user, if the user opens this URL in the iphone it opens passbook application. I did not understand how? I even verified particular headers but none specific.</p>
iphone
[8]
20,523
20,524
Searching an element with specific text in jQuery
<p>I want to get an element that contains specific text. When I use the :contains selector, the result is also all of the parents elements of that specific element.</p> <p>Also, if there is more than on element that actually contains the text, the result of the selector is very cumbersome. Is it possible to get only the elements themselves which contains the specific text?</p> <p>Thanks, Joel</p> <p>EDIT:</p> <p>Example:</p> <pre><code>&lt;body&gt; &lt;div&gt; &lt;div&gt; &lt;div&gt;text&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>and $("div:contains('text')") results in:</p> <pre><code>[&lt;div&gt;​…​&lt;/div&gt;​, &lt;div&gt;​…​&lt;/div&gt;​, &lt;div&gt;​text​&lt;/div&gt;​] </code></pre> <p>I want a way to only get the <code>&lt;div&gt;text&lt;/div&gt;</code> element. (I know I can use .get(-1) to get that last element, but I want to know if there is something more gemeric).</p>
jquery
[5]
2,321,845
2,321,846
Make Array From Checkbox
<p>I wan't to make an array from checkbox.</p> <p>I've use <code>array($_POST[test],$_POST[test1],$_POST[test2])</code> It works, but if once of array is NULL the array also NULL</p> <p>So what I wan't is if once of array is NULL, it's not in array</p> <p>Like this</p> <pre><code>$_POST['test']=NULL; $_POST['test1']="ARAAY1"; $_POST['test2']="ARRAY2"; </code></pre> <p>and it will be <code>array($_POST[test1],$_POST[test2])</code></p>
php
[2]
3,593,468
3,593,469
Are anonymous functions more effecient over calling functions?
<p>I'm just starting to learn about jQuery. I'm more of a html+css web designer so you can probably tell functions will take a little bit to adapt to, especially anonymous ones. </p> <p>So what's the difference if between </p> <pre><code>$('p.expander').toggle( function() { $(this).prev().addClass('open'); }, function() { $(this).prev().removeClass('open'); } ); </code></pre> <p>and say... </p> <pre><code> function toggle1 () { $(this).prev().addClass('open');} function toggle2 () { $(this).prev().removeClass('open');} $('p.expander').toggle(toggle1, toggle2); </code></pre> <p>Do you use anonymous functions if you're using it once? And if you're going to use functions more than once, you should call it? </p> <p>And as the title states, is one more effecient than the other? Because it seems like 99% of the articles use anonymous articles. I find it hard to read the code sometimes because I forget what a semicolon or parenthesis is for. </p>
jquery
[5]
1,346,110
1,346,111
JQuery - why does live work but click doesn't?
<p>We have a page with this structure:</p> <pre><code>&lt;script type="text/javascript" src="/js/lots.of.javascript.js"&gt;&lt;/script&gt; &lt;jsp:include page="html.jsp"/&gt; </code></pre> <p>The JavaScript has lots of <code>$(function(){...}</code> blocks. In one block we tried a <code>$("#mylink").click(...)</code> but this did NOT work. However the corresponding <code>.live('click'</code> DID work. Why is this? </p> <hr> <p><strong>Update</strong>: More specifically I am assuming the click and live statements ARE running after the link has been added to the DOM as the link is included in the html.jsp file and the statements are executed in <code>$(function(){...}</code> blocks... So given this I'm not sure why click wouldn't work...</p>
jquery
[5]
2,699,328
2,699,329
JQuery dialog & dynamic data issue
<p>i know it is possible to load data dynamically into jquery dialog like</p> <pre><code>(document).ready(function () { $('a#popup').live('click', function (e) { var page = $(this).attr("href") var $dialog = $('&lt;div&gt;&lt;/div&gt;') .html('&lt;iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"&gt;&lt;/iframe&gt;') .dialog({ autoOpen: false, modal: true, height: 450, width: 'auto', title: "Edit Employee", buttons: { "Close": function () { $dialog.dialog('close'); } }, close: function (event, ui) { __doPostBack('&lt;%= btnRefresh.ClientID %&gt;', ''); } }); $dialog.dialog('open'); e.preventDefault(); }); }); </code></pre> <p>so i just want to know when i am loading another page data into jquery dialog like</p> <pre><code>var $dialog = $('&lt;div&gt;&lt;/div&gt;') .html('&lt;iframe style="border: 0px; " src="' + page + '" width="100%" height="100%"&gt;&lt;/iframe&gt;') </code></pre> <p>then how can i determine that data has been loaded into dialog?</p> <p>basically i need to show a busy icon when data is loading and when i can determine programmatically that data is loaded and now it can be shown into dialog then i will stop showing busy icon and just show the actual data into dialog...i search google but found nothing similar....so i need advise and sample code. thanks</p>
jquery
[5]
419,332
419,333
FileVersionInfo.GetVersionInfo getting old version of an exe swapped at runtime
<p>I have a program executing in c# that is sometimes updated while it is running by swapping the exe to a new one. I want the program to routinely check if it has been updated and if so, restart. I use the following function to do this.</p> <pre><code> public static bool DoINeedToRestart(string exe_name) { Version cur_version = new Version(MainProgram.StartVersion); Version file_version = new Version(GetProductVersion(exe_name)); MessageBox.Show("Comparing cur_version " + cur_version.ToString() + " with " + file_version.ToString()); if (file_version &gt; cur_version) { return true; } return false; } public static string GetProductVersion(string path_name) { FileVersionInfo myFI = FileVersionInfo.GetVersionInfo(path_name); return myFI.FileVersion; } </code></pre> <p>MainProgram.StartVersion is set when the program is started to be the current version using the GetProductVersion(exe_name)</p> <p>exe_name is set to be the name of the executable that is being updated. </p> <p>The problem I have is once the MainProgram.exe file has been updated (I verify this manually by looking at the file properties and checking the file version), the GetProductVersion still returns the old file version and I have no idea why! Any help is greatly appreciated. I'm running Windows Vista with .Net 3.5.</p>
c#
[0]
3,437,837
3,437,838
mobile website design for android phones
<p>i want to design a website for android mobile phones using html.can any one please help me out. Where should i start?</p> <p>How to write css or should i recreate a new website for mobile phones?</p>
android
[4]
2,952,767
2,952,768
Eclipse Swing to JavaC?
<p>I made a program using Eclipse, but I want to learn to compile it with JavaC.</p> <p>I downloaded the JavaSDK jdk1.7.0 and installed it at C:\</p> <p>My .java file is in C:\java</p> <p>I then compiled the program using C:\jdk1.7.0\bin\javac Game.java</p> <p>It uses a package layout manager so I downloaded swing-layout-1.0.1.jar and just put it straight into C:\ then tried to execute using:</p> <pre><code>java -classpath C:\swing-layout-1.0.1.jar Game </code></pre> <p>All I get is Error:Could not find or load main class Game</p> <p>Any idea what I'm doing wrong? </p>
java
[1]
4,039,675
4,039,676
What is the difference between "string" and "String"?
<p>What is the difference between these two declarations?</p> <pre><code>string str; String str; </code></pre>
c#
[0]
4,714,390
4,714,391
Location Manager Error : (KCLErrorDomain error 0)
<p>Location Manager Error : Operation could not be completed(KCLErrorDomain error 0)</p> <p>why this error occurs?</p>
iphone
[8]
2,735,734
2,735,735
Stringify only a field in JavaScript
<p>I would want that at passing an object at JSON.Stringify, it checks if it has a field like "val" for stringify only that field, else been stringfied everything.</p> <p>Is possible to change JSON.Stringify to stringy only a determined field?</p>
javascript
[3]
627,211
627,212
Could not load file or assembly 'xxx' or one of its dependencies. An attempt was made to load a program with an incorrect format
<p>I just checked out a revision from Subversion to a new folder. Opened the solution and I get this when run:</p> <p><strong>Could not load file or assembly 'xxxx' or one of its dependencies. An attempt was made to load a program with an incorrect format.</strong></p> <p>This is the same code I had checked in a while ago. Why now is it doing this? I now also see a Debug x86 instead of just Debug in that xxx project's bin folder. What is Debug x86 and why don't I just have Debug only like I used to in the bin folder?</p>
c#
[0]
4,450,134
4,450,135
Application doesn't execute Form1_load method when started by Scheduled Task
<p>I have an App in C# using Windows Forms. My application is working normally, but when I want to start it by OS (Windows 7) using Scheduled Task, it doesn't load Form1_load method. How could I solve this problem?</p> <p>Here is a body of Form1_load method:</p> <pre><code> private void Form1_Load(object sender, EventArgs e) { try { bool fResult = false; fResult = registerDeviceNotification(); g_oGeneratorManager = new CGeneratorManager(); if (true != fResult) { Debug.WriteLine("Register device notification failed"); MessageBox.Show("Register device notification failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } lblStatus.Text = "Running"; } catch (Exception ex) { this.Visible = false; CLog.Err(ex.Message); MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } </code></pre>
c#
[0]
1,397,377
1,397,378
Result of expression 'this.getURL'[undefined] is not a function
<p>When i call a method directly without a setInterval the function works correctly</p> <pre><code>slider.prototype.onTouchEnd = function(e){ clearInterval(this.inter); this.getURL(this.url + '/' + this.eid.id + '/' + this.currX); e.preventDefault(); } </code></pre> <p>putting the same function in a setInterval give me following error: Result of expression 'this.getURL'[undefined] is not a function</p> <pre><code>slider.prototype.onTouchStart = function(e){ e.preventDefault(); this.inter = setInterval("this.getURL('www.google.com')",100); } </code></pre> <p>the code of getURL is:</p> <pre><code>slider.prototype.getURL = function(url){ console.log(url); verzoek=new XMLHttpRequest(); verzoek.onreadystatechange=function(){ if(verzoek.readyState==4) { if(verzoek.status==200) { var data=verzoek.responseText; } } } verzoek.open("GET", url, true); verzoek.send(null); } </code></pre> <p>the this.inter is created in the constructor</p> <pre><code>var slider = function(eid){ ... this.inter = null; } </code></pre> <p>I tried so many things but it keeps failing.</p> <p>Thx in advance</p>
javascript
[3]
4,179,106
4,179,107
iPhone MapView gets removed
<p>I have a tabBar in my application. In one of the section i have two views which i toggle between using segment buttons.</p> <p>In one of the view i have MapView which i use to display list of users using their pic as annotation. On the other view i have tableView which shows the same users in table format. </p> <p>Now everything is working fine, i am getting all the users and it displays fine on the map. It works perfectly most of the time on all device and all iOS but sometimes when i bring the mapView to front or toggle or try to zoom in. Both the views (tableView and mapView) just gets removed somehow and i see black screen (which is btw my superview so thats not a problem). </p> <p>Does anyone know why this happens. It happens frequently on iPhone 3G the older iPhone. </p> <p>Thanx for any help.</p>
iphone
[8]
1,190,050
1,190,051
.next() and .addClass() not working in jquery
<p>Hello friends following is my code</p> <p>HTML</p> <pre><code> &lt;ul&gt; &lt;li&gt; &lt;div class="input"&gt;&lt;input name="" type="checkbox" value="" id="a"/&gt;&lt;/div&gt; &lt;div &gt;Name of the survey goes here | 35 Points - &lt;span&gt;Begin Survey&lt;/span&gt;&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>Jquery</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $('#a').click(function(){ $(this).next('div').addClass('.check_clicked'); }) }) &lt;/script&gt; </code></pre> <p>CSS</p> <pre><code>.check_clicked { text-decoration:line-through; color:#b6a7a7; } </code></pre> <p>I just want to if check box value checked then class <code>.check_clicked</code> should apply on next div </p>
jquery
[5]
4,130,737
4,130,738
C#: What are some things i need to know about opening and saving files (eg. validation)
<p>i am using the <a href="http://msdn.microsoft.com/en-us/library/microsoft.win32.openfiledialog_members.aspx" rel="nofollow">common file dialog</a>. i think there will be many things i need to know and validate eg. file type, file exists, not enough memory etc. </p> <p>for file type, can i limit file types that can be opened using open file dialog? filter seems to still allow the user to type in a file with a different filetype. must i validate in code?</p> <p>can i say that just by setting <code>CheckFileExists = True</code>, i should not need to check again in code the file exists? </p> <p>is there a need to validate if there is a <code>OutOfMemoryException</code>? i am thinking, if all i should be opening is small files, i can get away with not handling that? not a good practice i guess?</p> <p>are there any others i missed out?</p>
c#
[0]
5,484,551
5,484,552
android how to draw triangle, star, square , heart on the canvas
<p>I am able to draw circle and rectangle on canvas by using path.addCircle() and path.addRect().Like that i want on touch i am able to draw triangle, star, square and heart. How can I do that? Give me a way with sample examples. Thanks</p>
android
[4]
5,699,383
5,699,384
Detect Phone Vendor at installation
<p>I am developing device specific application, Can anybody knows how to detect android phone vendor i.e <code>samsung</code> or <code>htc</code> etc in <code>android</code> ... Is this possible?. That according to phone vendor i can decide to install application on that phone or not !!!!</p>
android
[4]
1,131,421
1,131,422
PHP - Adding a character instead of a comma
<p>I have the following string, this is written froma database, so im not sure what the values are, but an example would be</p> <pre><code>my name, his name, their name, testing, testing </code></pre> <p>What i want to do is take out the last comma and add a space and the word 'and' so it appears as follows:</p> <pre><code>my name, his name, their name, testing and testing </code></pre> <p>Any help would be great.</p> <p>Cheers</p>
php
[2]
694,245
694,246
Check if options is selected
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/149573/check-if-option-is-selected-with-jquery-if-not-select-a-default">Check if option is selected with jQuery, if not select a default</a> </p> </blockquote> <p>I have html like this:</p> <pre><code>&lt;div id="somedivid"&gt; &lt;select class="someclass"&gt; &lt;!-- options --&gt; &lt;/select&gt; &lt;select class="someclass"&gt; &lt;!-- options --&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <p>How to check if options is selected in both select boxes?</p> <p>EDIT: i cant change html, so it means i cant add ids to select elements.</p>
jquery
[5]
3,559,224
3,559,225
How to ignore case when comparing string?
<p>I am using linq to search through a list (user enters query in a textbox).</p> <p>I want this to be case-insensitive and tried to use IgnoreCase, but I have no idea where to put it.... I know I could use upper or lower, but I would like to hear if anybody has any alternative methods? What would be considered best practise? Regex did not seem to work either?</p> <pre><code> string searchQuery = tbSearchQuery.Text; var something= from x in y where x.Subject.Contains(searchQuery) select x; </code></pre>
c#
[0]
4,327,056
4,327,057
Remove all unused resources from an android project
<p>I want to remove all unused layouts, strings, drawables, colors, etc from my Android res directory. Are there any tools that will give me a list of files and I can remove from my repository and elements within specifics files (e.g. unused string entries) that are no longer used?</p> <p>I use Eclipse/vim and would rather not <a href="http://stackoverflow.com/questions/5824357/is-there-a-tool-to-find-unused-resources-in-an-android-project">install IntelliJ for this</a> if possible.</p>
android
[4]
3,983,569
3,983,570
Double Click to open file directory from an item in listview
<p>I hope that there is a very straightforward way to allow a user to do a <code>Doubleclick</code> event on either items inside a listview.</p> <p>The items in my listview happens to have a filepath, so if possible, i want to draw out that filepath from the item that i've selected and open up as a windows to show where the file is located. Something like that...is that complicated?</p>
c#
[0]
1,999,828
1,999,829
Getting the url of the loaded image in a rotator (Javascript)
<p>Quick version: I have a url that calls a separate server (that I have no access to) that then loads one of 100 images. Is there anyway in which to check which image it returns?</p> <p>I was hoping for a js solution, but am flexible in that regard.</p> <p>Slightly longer version: I have an image on my page that's dynamically chosen by an external server. The server chooses one of 100 different images depending on a predefined set of criteria. I'd like to be able to check the server response and see what image it loads so I can change some of the other page elements through javascript.</p>
javascript
[3]
2,413,308
2,413,309
Direct access data in file
<p>How can I access 'directly' the data between 200th and 300th characters in a file in a secondary storage device?</p>
java
[1]
1,282,870
1,282,871
Parent does not contain constructor that takes 0 arguments
<p>If I have this code in C#:</p> <pre><code>public abstract class Parent { private int x; public Parent(int x) { this.x = x; } public abstract void foo; } public class Child { public override void foo() { x = x + 10; } } </code></pre> <p>I get error that: </p> <blockquote> <p>Parent does not contain constructor that takes 0 arguments. </p> </blockquote> <p>How can I fix it, without creating non-parametric constructor?</p>
c#
[0]
1,750,438
1,750,439
Can't read the content of a property file by using the relative path
<p>My java class is residing in the folder <code>/webserver/tomcat-instance/webapps/shop/WEB-INF/classes/com/mobile/commons</code> but the actual property file is residing in the location <code>/webserver/tomcat-instance/webapps/shop/WEB-INF/classes/resources</code> directory. Now in my java file i put the relative path as <code>/WEB-INF/classes/resources/prop.properties</code> to read the intended file but every time i'm getting the FileNotFound Exception.</p> <p>Please help me resolving this issue. What should i use as a relative path as i don't want to use the absolute path.</p> <p>Thanks, Sourav </p>
java
[1]
1,512,569
1,512,570
convert view to image in android
<p>hi everyone i m trying to send a chart via email in android application how can i attach that chart to email application. Thanks .....</p>
android
[4]
336,651
336,652
Android device guidelines/requirements
<p>Are there any requirements/guidelines for an Android device? like numbers of buttons or minimum buttons required.</p> <p>Also are there any android devices which do not have the menu and back buttons?</p> <p>( I am aware that no menu/back buttons will kill most of the apps in terms of usability , I just wanted to know more on the topic :-) ) </p>
android
[4]
2,925,888
2,925,889
How to catch touch event of an dialog when it is clicked outside
<p>Actually i have <code>Dialog</code> in my activity, what i want is suppose the dialog is open, then on Touch of outside dialog i want to dismiss the dialog and at the same time i want to call a function which do some update in my activity.</p> <p>Initially i used <code>MyDialog.setCanceledOnTouchOutside(true);</code> But these will only dismiss and in my case, at the same time i want to call some functions whenever user click outside of dialog. So what should i do, I know that if i can extend the <code>Dialog</code> class and override its <code>onTouchEvent</code> method then it will be solved but in my case my class already extends Activity class and in java we can't extend more then one class..</p> <p>So what will be the best solution for that. Please help me to solve this out</p>
android
[4]
3,947,466
3,947,467
Changing step values in seekbar?
<p>I have a seekbar, while moving it I want to change values from 0 to 200. I have a TextView, where I display those values while moving the seekbar. But I don't want to have every value from that interval(0,1,2,3,4,5...), but to have 10, 20, 30...so on. So when I move the seekbar, I want to display 10,20,30,40....to 200. Can somebody give me a hint or an example how to do this?</p>
android
[4]
5,508,848
5,508,849
how to display value of session variable in textbox in php
<p>in my project I need to take the value of selected link from one page to another page and it should be display in the textbox.</p> <p>for this i have used session variable code is as below :</p> <p>in caledar.php</p> <p>This is not the entire script ... there is one class which generates the calendar code. below is the function. </p> <pre><code>function getDateLink($day, $month, $year) { // Only link the first day of every month $link = ""; if ($day) { $selectedDate = $day.$month.$year; var_dump($selectedDate);die; //session_register("$selectedDate"); //session_start(); if (isset($_GET["selectedDate"])) $_SESSION['date'] = $selectedDate; //("location:login_sucessful.php"); $link = "Leave_app.php"; } return $link; } </code></pre> <p>in application.php</p> <pre><code>&lt;input type="text" id="Editbox1" name="strt_date" value="&lt;?PHP if(isset($_SESSION['date'])){echo $selectedDate;}?&gt;"&gt; </code></pre> <p>It is not working. also not receiving any error message.</p>
php
[2]
5,210,107
5,210,108
Showing Selected Values on a Multiselect box
<p>I have made a single page for adding as well as editing data. In the page i have a multiselect box. I want to know how can i display the selected values in case of editing? My code is :</p> <pre><code>$categories=$objdb-&gt;select("vtiger_cf_601", false, "*", false, false); $discountstudentInfo = $objdb-&gt;select('paytbl_discounts_students', false, "*", "WHERE fk_paytbl_discounts_discountid = '".$_GET['discountid']."' ", false); &lt;select id="cmbCategory[]" name="cmbCategory[]" class="combo" multiple="multiple"&gt; &lt;option value="" selected="selected" &gt;Select&lt;/option&gt; &lt;?php foreach($categories as $category) { foreach($discountstudentInfo as $discountstudentinfo) { if($discountstudentinfo[fk_paytbl_discounts_discountid]==$category[cf_601id]) { $class="selected=selected"; } else { $class=""; } echo '&lt;option value="'.$category[cf_601id].'" "'.$class.'"&gt;'.$category[cf_601].'&lt;/option&gt;'; } } ?&gt; &lt;/select&gt; </code></pre> <p>Regards,</p> <p>Pankaj </p>
php
[2]
1,925,033
1,925,034
C#: Is there a way to use expressions as a variable/parameter?
<p>I'd like to know if it is possible to use an expression as a variable/parameter in C#. I would like to do something like this:</p> <pre><code>int x = 0; public void g() { bool greaterThan = f("x&gt;2"); bool lessThan = f("x&lt;2"); } public bool f(Expression expression) { if(expression) return true; else return false; } </code></pre> <p>Here's what I don't want to do:</p> <pre><code>int x = 0; public void g() { bool greaterThan = f(x, '&lt;', 2); } public bool f(int x, char c, int y) { if(c == '&lt;') return x &lt; y; if(c == '&gt;') return x &gt; y; } </code></pre> <p>Really what I'm getting at is a way to get around using a switch or series of if statements for each of: &lt; > &lt;= >= == !=. Is there a way to do it?</p> <p>Edit: Suppose that the expression is a string, like "x &lt; 2". Is there a way to go from the string to a predicate without using a series of if statements on the condition?</p>
c#
[0]
4,326,989
4,326,990
How to find the device details for android
<p>I want to find out about the name, android version, screen size, battery status, network status and other details of the device on which the app is running. Is there a specific inbuilt class for the device details or will I have to use some third party tool.</p>
android
[4]
1,082,519
1,082,520
Read double value from a file C#
<p>I have a txt file that the format is:</p> <pre><code>0.32423 1.3453 3.23423 0.12332 3.1231 9.23432432 9.234324234 -1.23432 12.23432 ... </code></pre> <p>Each line has three double value. There are more than 10000 lines in this file. I can use the ReadStream.ReadLine and use the String.Split, then convert it. I want to know is there any faster method to do it.</p> <p>Best Regards,</p>
c#
[0]
4,385,823
4,385,824
Double icons in Applications list
<p>I'm noticing that there are double icons for an application I recently built. Is this being caused by an issue in my manifest? Or is this an artifact from a previously deleted rev of the apk?</p>
android
[4]
1,582,351
1,582,352
How to make Custom Android ListView to read phone contacts?
<p>Include the standard <code>ListView</code> widget in your layout, invoke <code>setAdapter()</code> to provide your data and child views, and connect a listener via <code>setOnItemSelectedListener()</code> to find out when the selection has changed.</p>
android
[4]
2,233,816
2,233,817
Polymorphic constructor.name property access
<p>Given the JavaScript code:</p> <pre><code>function Parent() { ... } function Child() { ... } Child.prototype = new Parent(); // toString implementation on the parent object Parent.prototype.toString = function() { return this.constructor.name; } // And the code: alert(new Child()); </code></pre> <p>... will output "Parent" when the wanted outcome is to get the "Child" string back (the <code>constructor.name</code> inside the parent <code>toString</code> implementation should return the child constructor name).</p> <p>Is this possible in JavaScript?</p>
javascript
[3]
4,989,382
4,989,383
references in c++ problem
<p>I heard references in c++ can be intitalized only once but this is giving me 1 is my output and not returning any error!</p> <pre><code> struct f { f(int&amp; g) : h(g) { h = 1; } ~f() { h = 2; } int&amp; h; }; int i() { int j = 3; f k(j); return j; } </code></pre>
c++
[6]
4,841,169
4,841,170
How to display "username" and "password" as default in text boxes in javascript?
<p>I want two text boxes with default text in both i.e "username" and "password". When we click inside the text box the text should disappear so the user can type their own username and password.</p> <p>However, the password field is not readable by default.</p> <p>How is it possible, kindly help me??? Thanks in advance.</p>
javascript
[3]
4,204,216
4,204,217
delaying asynchronous callbacks
<p>how to give delays for a asynchronous callbacks, is there any way to pause,or resume(current process for a certain time),or any availability of sleep mode</p>
c#
[0]
3,790,034
3,790,035
Saving image on iOS 5.1.1 works randomly
<p>I am trying to save an image taken from UIImagePickerController using the following code:</p> <pre><code>NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *path = [docsDirectory stringByAppendingPathComponent:@"myImage.png"]; UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"]; [UIImagePNGRepresentation(image) writeToFile:path atomically:YES]; </code></pre> <p>After saving the image i again read the image in another screen :</p> <pre><code>NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *path = [docsDirectory stringByAppendingPathComponent:@"myImage.png"]; UIImage *extractedImage= [UIImage imageWithContentsOfFile:pngPath]; </code></pre> <p>This code runs fine on iPhone 4 (iOS 5.1.1), but on devices iPhone 4's (iOS 5.1.1), iPad 1 (iOS5.1) and iPad 2's (iOS5.1.1) this code works randomly.</p> <p>Sometimes the is image is saved the very first time and sometimes it gets saved after trying 2-3 times.</p>
iphone
[8]
1,266,165
1,266,166
Python function confusion
<p>While programming with python I am often confused with the following ambiguity:</p> <p>should it be: function(a) or a.function(). Although the question is too general and can someone tell me which situation happens when?</p>
python
[7]
1,182,590
1,182,591
Run ActivityInstrumentationTestCase2 sub class programatically
<p>I have few testcases in the sub-class of ActivityInstrumentationTestCase2. When i run them using adb shell am instrument -w .... it works and launches my target activity. But as I have to launch the test on getting some broadcast I need to launch it programmatically, but I don't know how to do that. Pls help</p>
android
[4]
4,232,834
4,232,835
C++ introduction: self study
<p>I created the program to read from text file and remove special characters. I can't seem to code better the if statement. Please help. I searched online for the right code statements but they have all advanced code statements. The book I am learning from has the last(14th) chapter with strings and file open and closing code. I tried creating an array of special chars, but did not work. Please help me!</p> <pre><code> int main() { string paragraph = ""; string curChar = ""; string fileName = ""; int subscript=0; int numWords=0; ifstream inFile; //declaring the file variables in the implement ofstream outFile; cout &lt;&lt; "Please enter the input file name(C:\owner\Desktop\para.txt): " &lt;&lt; endl; cin &gt;&gt; fileName; inFile.open(fileName, ios::in); //opening the user entered file //if statement for not finding the file if(inFile.fail()) { cout&lt;&lt;"error opening the file."; } else { getline(inFile,paragraph); cout&lt;&lt;paragraph&lt;&lt;endl&lt;&lt;endl; } numWords=paragraph.length(); while (subscript &lt; numWords) { curChar = paragraph.substr(subscript, 1); if(curChar==","||curChar=="."||curChar==")" ||curChar=="("||curChar==";"||curChar==":"||curChar=="-" ||curChar=="\""||curChar=="&amp;"||curChar=="?"|| curChar=="%"||curChar=="$"||curChar=="!"||curChar==" ["||curChar=="]"|| curChar=="{"||curChar=="}"||curChar=="_"||curChar==" &lt;"||curChar=="&gt;" ||curChar=="/"||curChar=="#"||curChar=="*"||curChar=="_"||curChar=="+" ||curChar=="=") { paragraph.erase(subscript, 1); numWords-=1; } else subscript+=1; } cout&lt;&lt;paragraph&lt;&lt;endl; inFile.close(); </code></pre>
c++
[6]
3,369,569
3,369,570
GridView scrolling out of view and scroll bars disappears on Android
<p>I have a very strange bug in my gridview</p> <pre><code>&lt;GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numColumns="auto_fit" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" android:columnWidth="90dp" android:stretchMode="columnWidth" android:gravity="center" </code></pre> <p>/></p> <p>I displays images in a gridview and can scroll up and down </p> <p>However if I scroll fast upwards and the top line of images pass the bottom of the screen and I can no longer scroll and am just left with a empty screen</p> <p>Any ideas?</p>
android
[4]
1,786,051
1,786,052
How can we tell the difference between an actual and apparent type?
<p>If you have a class hierarchy and you'd like to determine what could be actual types that an object is pointing to, is the answer just any subclass of the object? If the object is an abstract class, can you still declare a pointer of that object that's apparent and actual type is that object?</p>
c++
[6]
2,605,398
2,605,399
creating simple server for android application
<p>I am currently working on an android application, and my application contains a lot of pictures and videos, that increase the size of the project. Now, I want to have a simple server for my application, so that I save all the needed media on that server. But I don’t have any idea how to do that, can you please refer to any tutorial, website or source code as a starting point.</p> <p>Thanks in advance,</p>
android
[4]
4,636,903
4,636,904
Android page control like book?
<p>I want to develop page control like <strong>book</strong>,means when user drags over page(left or right) control will <strong>move next page or previous page(with view also move)</strong>, depending on which way the user dragged using their finger.</p>
android
[4]
1,230,848
1,230,849
Search function on listview
<p>I am altering the question now!</p> <p>I have the search working using the following:</p> <pre><code>//check the array for a match foreach (Delivery d in mainForm.myDeliveries) { if (d.DeliveryName == searchValue) { ListViewItem item = lstDeliveryDetails.Items.Add(d.DeliveryName); item.SubItems.Add(d.DeliveryAddress); item.SubItems.Add(d.DeliveryDay); item.SubItems.Add(d.DeliveryTime); item.SubItems.Add(d.DeliveryMeal); item.SubItems.Add(d.DeliveryInstructions); item.SubItems.Add(d.DeliveryStatus); } } </code></pre> <p>My question is, what is the best way to now search all the other values, to make a complete search? I know i could do if else statements and go through address, day, time, etc.</p> <p>Is there a better way to acheive this? And at the moment, the user has to enter the entire name to get the result, can i make it if they only enter a part of the name?</p>
c#
[0]
1,826,851
1,826,852
Regarding the 3D model displaying issue of .3ds file in min3D android project
<p>I have display issue when I open 3d <strong>.3ds</strong> file through min3D android open source project. The following given below is the approach and step involved before issue raised. (1) I have developed the my own 3D modeling and save it as monster_high1.3ds</p> <p>(2) Min3D project successfully able to parse and create the object , I am confirmed for this output </p> <p>(3) But 3d model isn't displaying at the same XYZ coordinates which I have looked through 3D Max design tools after rendering. That is there is different rendering in context to coordinates by autodesk 3D Max tools and min3D project.</p> <p>(4) However when I used the .3ds file shipped with the project it is displaying properly .</p> <p>(5) From the code this issue shouldn’t be comes which is mention below Public void initScene() { //Source code<br> scene.camera().target = monster.position() ; }</p> <p>Which set the camera to current parse object position? (6) Is there is any way to map the same look from render point of view between any 3D design tools ( like Autodesk 3D Max , render ) to min3d Google open source project .</p> <p>Please help me to solve this issue. Thanks in advance.</p>
android
[4]
450,886
450,887
How to get particular array value in php?
<p>I have the following <code>$qtips_messages</code> array,</p> <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 1 [tips_title] =&gt; email_tips [tips_message] =&gt; ex:xxxxx@xyz.com [tips_key] =&gt; key_email ) [1] =&gt; Array ( [id] =&gt; 2 [tips_title] =&gt; website_tips [tips_message] =&gt; ex:http://www.yahoo.co.in [tips_key] =&gt; key_website ) [2] =&gt; Array ( [id] =&gt; 3 [tips_title] =&gt; zipcode_tips [tips_message] =&gt; ex:60612 [tips_key] =&gt; key_zipcode ) [3] =&gt; Array ( [id] =&gt; 4 [tips_title] =&gt; phone_tips [tips_message] =&gt; ex:1234567890 [tips_key] =&gt; key_phone ) ) </code></pre> <p>For example, I want to get the tips message for the tip_title 'email_tips' I have tried with following code,</p> <pre><code>foreach($qtips_messages as $qtipsArray){ foreach($qtipsArray as $qkey=&gt;$qvalue){ if($qtipsArray['tips_title'] == 'email_tips'){ $emailtipsMessage = $qtipsArray['tips_message']; } } } </code></pre> <p>When i ran the above code i did not get any value.<br> What is wrong with this code?</p>
php
[2]
4,044,833
4,044,834
Starting an external activity, getting permission error
<p>I'm trying to start the preferences activity in the native messenger client from my application. in AOSP Mms.apk does not have an intent filter setup on that activity. Regardless I'm trying to find a work around to launch the user into that screen.</p> <pre><code> Intent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(ComponentName.unflattenFromString("com.android.mms/com.android.mms.ui.MessagingPreferenceActivity")); intent.addCategory("android.intent.category.LAUNCHER"); try { startActivity(intent); } catch (Exception e) { AppUtils.alertError(this, error); } </code></pre> <p>I'm receiving </p> <pre><code>java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.android.mms/.ui.MessagingPreferenceActivity } from ProcessRecord{406e2738 674:com.handmark.genericapp/10034} (pid=674, uid=10034) requires null </code></pre> <p>Any thoughts?</p>
android
[4]
528,587
528,588
UIWebView, quote characters with Arial font not showing up correctly
<p>I have some .html with the font defined as: </p> <p><code>&lt;font color="white" face="Arial"&gt;</code></p> <p>I have no other style applied to my <p> tag. In it, when I display data like:</p> <p><code>&lt;b&gt; “Software” &lt;/b&gt;</code></p> <p>or </p> <p><code>&lt;b&gt;“Software”&lt;/b&gt;</code></p> <p>they both display characters I do not want in the UIWebView. It looks like this on a black background:</p> <p><img src="http://i.stack.imgur.com/qHH9D.png" alt="enter image description here"></p> <p>How do I avoid that? If I don't use <code>font face="arial"</code>, it works fine. </p>
iphone
[8]
4,952,360
4,952,361
actionbar nullpointer exception
<p>I am new to android. My minimum API level needs to be 7, so that I can test the app on my htc hero. My target API level is 17. The error concerns the actionbar. Some code is added by eclipse and I guess I need it to propperly run my app on the latest android versions:</p> <pre><code>getActionBar().setDisplayHomeAsUpEnabled(true); </code></pre> <p><code>getActionBar()</code> gives NPE on API 7, but not on API 17. How do I solve this without deleting the code (which I will presumably need for modern API levels)?</p>
android
[4]
3,171,364
3,171,365
I'm getting wrong String value
<pre><code>void displayId(PrintWriter stdOut, StringResources resources, IPatchBundle group, String[] ids){ for(int i=0;i&lt;ids.length;i++) System.out.println("Mids from cmdMds"+ids); } </code></pre> <p>The above code produces <code>[Ljava.lang.String;@152cf21</code>. I tried putting <code>.toString()</code> too, still getting the same. Please help me to get the actual value.</p>
java
[1]
5,034,718
5,034,719
JQuery image fade speed
<p>What is the syntax to assign a speed to each fade?</p> <pre><code> function fadeIn() { $(this).fadeIn( fadeOut ); } function fadeOut() { $(this).fadeOut( fadeIn ); } fadeIn.call($("#myImage")); </code></pre>
jquery
[5]
4,527,387
4,527,388
Crawl Images, Whole Web Pages and cache them
<p>I am starting a project and wonder the relationship between the characters in images and the whole web page where the images reside.</p> <p>I want to crawl some images and their web pages. I need to save the crawl result in local disk for further analysis. I wonder if there is any open source for this issue? </p>
python
[7]
5,762,321
5,762,322
Is there some way I could combine this C# code?
<p>I have the following code. It looks to me like there is a way I could combine it into one statement but I am not sure how to do this. </p> <pre><code>List&lt;SelectListItem&gt; items = new List&lt;SelectListItem&gt;(); var emptyItem = new SelectListItem(){ Value = "", Text = "00" }; items.Add(emptyItem); ViewBag.AccountIdList = new SelectList(items); </code></pre> <p>Can someone tell me if it's possible to simplify this. </p> <p>Thanks,</p>
c#
[0]
1,798,820
1,798,821
how to estimate a performance unit in a c++ program
<p>What I mean, to measure performance in some algorithm I need to do it in terms of some unit. So, basically if I ignore declarations and definitions of objects and consider only operations , how would you estimate the time each operation consums in run time?. </p>
c++
[6]
2,452,705
2,452,706
how can i remove "\n" in string in php?
<p>how to remove "\n" in string?<br> I used 3 method bellow ,seams that only the "\s+" works , but I only want to remove \n,not all space ,how to do the job?<br> need help, this question had puzzled me for a long time.</p> <pre><code>$str="&lt;p&gt; hello&lt;br&gt; world &lt;/p&gt;"; //$str=str_replace("\n","",$str); $str=preg_replace("@\n@","",$str); //$str=preg_replace("@\s+@"," ",$str); echo $str; </code></pre>
php
[2]
4,107,525
4,107,526
Limiting double to 3 decimal places
<p>This i what I am trying to achieve:</p> <p>If a double has more than 3 decimal places, only keep until the first 3 dec places (do not round.)</p> <p>Eg.: 12.878999 -> 12.878</p> <p>If a double has less than 3 decimals, leave unchanged</p> <pre><code>Eg.: 125 -&gt; 125 89.24 -&gt; 89.24 </code></pre> <p>I came across this command:</p> <pre><code>double example = 12.34567; double output = Math.Round(example, 3); </code></pre> <p>But I do not want to round. According to the command posted above, 12.34567 -> 12.346</p> <p>but I need it to stay: 12.345</p>
c#
[0]
1,095,031
1,095,032
php multidimensional arrays and foreach
<p>Hi everyone I am having an oddity where in my foreach loop the last element is the same as the 2nd to last</p> <p>Here is my code so far <a href="http://slexy.org/raw/s21pArCYrU" rel="nofollow">php code (pastbin site)</a></p> <p>I threw a print_r just before the loop to see if it was an error in the construction of the array, but it prints out everything just fine.</p> <p>(sorry I cant post more than 1 link )</p> <p>here is the output of the script www.breze.ca/test.htm</p> <p>here is a sample of the .mdb I am working with here <a href="http://www.breze.ca/sample.mdb" rel="nofollow">http://www.breze.ca/sample.mdb</a><br></p> <p>Thanks for any help (and sorry if my coding is sloppy or insane)</p>
php
[2]
2,394,504
2,394,505
iPhone:How do i insert few rows in the middle of existing table?
<p>If i want to insert few rows in the middle of the existing table, how do i approach it? Where all that i should be careful when doing such thing? Is there any good sample source available?</p> <p>Appreciate your helps.</p> <p>Thank you.</p>
iphone
[8]
2,605,161
2,605,162
several if else if conditions
<p>I have a java class inside there is a method which need to return some integer value based upon conditions met now, I have put some <code>if...else</code> conditions inside the method of class as shown below and in comment I have written when this conditions will be executed.</p> <p>Please advise that my logic inside the method <code>def()</code> <code>if</code> conditions is correct or not and also please let me know if any conditions executed will it check for remaining conditions or not.</p> <pre><code>class abc { private static SUCCESS = 1; private static FAILURE = 2; public void int def() { if (a=20 &amp;&amp; b==30) { if (c==30 &amp;&amp; d==40) // nesting IF condition will go if a=20 &amp; b=30 { // do something return SUCCESS; // IF this condion is met will it check remaing conditions or not } else { return FAILURE; // IF this condion is met will it check remaing conditions or not } } else if( g==50 &amp;&amp; d==60) { // do something if (t==56 &amp;&amp; p==98) // nesting IF condition will go if g=50 &amp; d=60 { // do something return SUCCESS; // IF this condion is met will it check remaing conditions or not } return FAILURE; // IF this condion is met will it check remaing conditions or not } else return FAILURE; // default return means if any othe if or else if block is satisfied then this default value will be returned from the method } } </code></pre>
java
[1]
1,908,548
1,908,549
Could someone help me edit my first attempt at code for a blinking address replacement?
<p>So, I'm totally new to this and trying to produce an effect where an old address blinks a few times, then some new text replaces it. However, the minute I use .replaceWith(), it overrides all the other .fade and the .append calls.</p> <pre><code> &lt;div id="footer-address"&gt; &lt;strong&gt;Address&lt;/strong&gt;&amp;nbsp;&amp;nbsp; Old Address&lt;/div&gt; &lt;script&gt; $( document ).ready(function() { $( "#footer-address" ).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400).fadeOut(400).replaceWith("We have moved! Our new address is").fadeOut(400).append("&lt;strong&gt;Address&lt;/strong&gt; New Address"); }); &lt;/script&gt; </code></pre> <p>I appreciate you whacking me up side the head and offering the correct way to do something like this.</p> <p>Thanks.</p>
jquery
[5]
4,803,056
4,803,057
textColor not applied when used as them
<p>I have a style that includes textColor, textSize, textStyle and typeface. When applied directly to an EditText widget, the color of the text is as specified (as well as the other attributes), but when applied as a theme to the activity or the entire application, the size is fine but the color is not applied. What I am missing?</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="fap" parent="android:Theme.Holo"&gt; &lt;item name="android:textSize"&gt;24sp&lt;/item&gt; &lt;item name="android:textColor"&gt;#FF0000&lt;/item&gt; &lt;item name="android:textStyle"&gt;normal&lt;/item&gt; &lt;item name="android:typeface"&gt;normal&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre>
android
[4]
1,819,070
1,819,071
finally method with try in java
<p>class DaemonThread extends Thread {</p> <pre><code>public void run() { System.out.println("Entering run method"); try { System.out.println("In run Method: currentThread() is" + Thread.currentThread()); while (true) { try { Thread.sleep(500); } catch (InterruptedException x) { System.out.println("hi"); } // System.out.println("In run method: woke up again"); finally { System.out.println("Leaving run1 Method"); } } } finally { System.out.println("Leaving run Method"); } } public static void main(String[] args) { System.out.println("Entering main Method"); DaemonThread t = new DaemonThread(); t.setDaemon(true); t.start(); try { Thread.sleep(900); } catch (InterruptedException x) {} System.out.println("Leaving main method"); } } </code></pre> <p>why second finally method not run...as i know finally method must have have to run whatever the condition is ..but in this case only first finally method, why not second finally run.</p>
java
[1]
2,894,573
2,894,574
extract line matching string in javascript
<p>If a string is( \n separating line)</p> <pre><code>this is good string 1 this is bad string 1 this is good string 2 this is bad string 2 . . . </code></pre> <p>I want get string that has lines that match a phrase say "good string"</p> <pre><code>this is good string 1 this is good string 2 </code></pre>
javascript
[3]
2,934,377
2,934,378
MediaPlayer Service and Camera Service
<p>Can you please tell me if MediaPlayer Service and Camera Service are running in same process or different process? How can I find that out from Android source?</p> <p>Thank you.</p>
android
[4]
12,330
12,331
Excluding numbers from an array
<p>The code below returns a table with a row for every word or number that appears in <code>$commentstring</code>. Each word or number appears as <code>$word</code> in the table below. How can I exclude numbers?</p> <pre><code>$words = explode(" ", $commentstring); $result = array_combine($words, array_fill(0, count($words), 0)); arsort($words); foreach($words as $word) { $result[$word]++; arsort($result); } echo "&lt;table&gt;"; foreach($result as $word =&gt; $count1) { echo '&lt;tr&gt;'; echo '&lt;td&gt;'; echo "$word"; echo '&lt;/td&gt;'; echo '&lt;td&gt;'; echo "$count1 "; echo '&lt;/td&gt;'; echo '&lt;/tr&gt;'; } echo "&lt;/table&gt;"; </code></pre>
php
[2]
731,503
731,504
Recommendations for implicit versus explicit line joining
<p>I would like to know recommendations about <a href="http://docs.python.org/reference/lexical_analysis.html#implicit-line-joining">Implicit Line Joining</a> versus <a href="http://docs.python.org/reference/lexical_analysis.html#explicit-line-joining">Explicit Line Joining</a> in Python.</p> <p>In particular, do you favor one form over the other? What do you recommend as the general default? What criteria do you have for choosing one over the other, and if you do have a preference of one, when do you make exceptions for the other?</p> <p>I have an answer in mind for this question that reflects my own biases, but before I post my own answer I would like to know what others think... and if you can have a better set of criteria than what I have in mind, then I'll certainly accept your answer over my own.</p> <p>Some of the recommendations may be generalized to this choice in other programming languages, but my own bias is somewhat stronger in Python due to some language-specific features, so I'd like to know both the general and the Python-centric reasoning you may have on this topic.</p> <p>For some background, the discussion happened around a <a href="http://stackoverflow.com/questions/8626835/what-is-the-meaning-of-this-python-statement">particular question on stackoverflow</a>, but I thought it was more appropriate to move the discussion over to here as a question to avoid cluttering up the answer on SO with this tangent since it has veered off-topic from the original question. You can look at that question and its answers for the example code snippets that got the discussion going.</p> <p>Here is a simplified example:</p> <pre><code>join_type = "explicit" a = "%s line joining" \ % (join_type) # versus join_type = "implicit" b = ("%s line joining" % (join_type)) </code></pre>
python
[7]
1,292,037
1,292,038
composite keys in map
<p>Hello I cannot find any info on what I need to do to make two keys seems equal. That is, i need to provide a custom compare method that will be used by map.put() Implementing comparable doesnt help.</p> <p>For example, this code doesnt work as intended - for the purposes of my program, two keys n and n2 ARE the same.</p> <pre><code>private class N implements Comparable&lt;N&gt; { int value; int stuff; String z; @Override public int compareTo(N arg0) { if (arg0.z.equals(z)) return 0; return 1; } } public void dostuff() { HashMap m = new HashMap(); N n = new N(); n.z = "1"; N n2 = new N(); n2.z = "1"; m.put(n, "one"); m.put(n2, "two"); // will print refs to two instances! - wrong Iterator it = m.keySet().iterator(); while (it.hasNext()) { System.err.println(it.next()); } } </code></pre>
java
[1]
2,204,678
2,204,679
Running Java application on server
<p>I have access to a server using SSH. I need to run a stand-alone Java application on it to access a MySQL server installed there. How do I go about in doing this?</p>
java
[1]
5,142,902
5,142,903
When to use an Abstract Class and an Interface
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/761194/interface-vs-abstract-class-general-oo">Interface vs Abstract Class (general OO)</a> </p> </blockquote> <p>Please explain to me, with an example, in what situation to use an Abstract class and Interface. In most scenarios people tend to use Interfaces rather than Abstract Classes in general, why? Explain the uses of them. Thanks in advance</p>
java
[1]
3,324,788
3,324,789
Setting a default src to img element
<p>Some people set default src to img element in the following way:</p> <pre><code>&lt;img src="foo.jpg" onerror="this.src='default.jpg'" /&gt; </code></pre> <p>I think it's not the best way because a additional http request will be sent when onerror event be fired, and our log component will log the worthless error message.</p> <p>I think I can do in following way:</p> <p>Create a HttpHandler(.ashx) to send appropriate image to client. So I can write a img in page like this: <code>&lt;img src=‘ImageHandler.ashx?id=foo.jpg’/&gt;</code>. App will check whether the image(<code>foo.jpg</code>) exists or not, then decides to send foo.jpg or default.jpg.</p> <p>Is it right? Do you have better resolution? </p>
asp.net
[9]
1,500,595
1,500,596
my app can't open keycharmap file
<p>I created a function that enlarges an avatar when the user clicks on it. The function then generates a dialog. When I press the back button to remove the dialog then it's not possible any more to click on the avatar again. The dialog won't show again.</p> <p>Why this happens? Someone help me please.</p> <pre><code>03-05 14:30:12.620: W/KeyCharacterMap(15555): Can't open keycharmap file 03-05 14:30:12.620: W/KeyCharacterMap(15555): Error loading keycharmap file '/system/usr/keychars/synaptics.kcm.bin'. hw.keyboards.262148.devname='synaptics' 03-05 14:30:12.620: W/KeyCharacterMap(15555): Using default keymap: /system/usr/keychars/qwerty.kcm.bin </code></pre>
android
[4]
4,510,384
4,510,385
javascript check form for radio group
<p>HiExperts,</p> <p>I am creating a form with a javascript validation function for a radio group. The idea is, when "None" is checked, no div pop up, and when "Monday" or "Tuesday" is checked, a div pop up:-</p> <pre><code>//the form &lt;form name="form_sf" id = "form_sf" method="post" action="process.php" onSubmit="return check_sf_form_info(form_sf,'all')"&gt; &lt;input name="date" id="date" type="radio" value="nil" onChange="check_sf_form_info(form_sf,2)" /&gt;None &lt;input name="date" id="date" type="radio" value="mon" onChange="check_sf_form_info(form_sf,2)" /&gt;Monday &lt;input name="date" id="date" type="radio" value="tue" onChange="check_sf_form_info(form_sf,2)" /&gt;Tuesday &lt;/form&gt; //the javascript function check_sf_form_info(form,mark,edit){ if(mark==2 || mark=="all"){ if(form.date.value!=="nil"){ price.innerHTML="$100"; price.style.display="block"; price.style.height="auto"; }else{ price.innerHTML=""; price.style.display = "none"; } } } </code></pre> <p>Would experts please teach me where I have done wrongly? Thanksalot!</p>
javascript
[3]
3,313,528
3,313,529
How to get the position of a span nested within a textarea
<p>I have a span that is nested within a textarea, and would like to get the offset of this span relative to the document. Zero is always returned for left and top, and I'm not sure why.</p> <p>Here is a <a href="http://jsfiddle.net/c2J36/" rel="nofollow">jsFiddle</a> with the following code to demo</p> <pre><code>$(document).ready(function(){ $("#textarea1").html("1234 &lt;span id='span1' style='color:red'&gt;5678&lt;/span&gt;"); var offset = $("#span1").offset(); alert("span1 left: " + offset.left + " top: " + offset.top); }); </code></pre> <p>I see why the position of the span would be zero, relative to the textarea. But I don't understand why the offset is returning zero. If anyone could help me out here I'd appreciate it.</p> <hr> <p>Edit: My goal was to position something above the span when it was clicked. I couldn't get the offset of the span mentioned above, so I decided to use the mouse coordinates instead.</p> <pre><code>$("#id").dblclick(function(e){ alert("X: " + e.pageX + " Y: " + e.pageY); }); </code></pre>
jquery
[5]
5,018,746
5,018,747
PHP don't wait for response / reply return immediately
<p>I have a web service written in PHP to which an iPhone app connects to. When the app calls the service, a series of notification messages are sent to Apple's APNs server so it can then send Push Notifications to other users of the app.</p> <p>This process can be time consuming in some cases and my app has to wait a long time before getting a response. The response is totally independent of the result of the notification messages being sent to the APNs server.</p> <p>Therefore, I would like the web service to send the response back to the app regardless of whether the messages to APNs have been sent.</p> <p>My current code:</p> <pre><code>&lt;? &lt;...&gt; echo $chatID; // This has to be printed immediately include('apns.php'); // Just invoke this, dont wait for response! ?&gt; </code></pre> <p>How do I do this?</p>
php
[2]
4,739,180
4,739,181
PHP pass a var into $_FILES inside function
<p>I am working on an admin area that will have file uploads on several pages. Regardless of the name of the form field I want to do some specific processes, but I'm a bit stuck on how to do this in a function. I have the code below, which I knew going in wouldn't be correct, but I'm not sure how to achieve what I'm trying to do.</p> <pre><code>function fileprocessor ($file) { echo $_FILES['$file']['tmp_name']; } </code></pre> <p>Any thoughts?</p>
php
[2]
3,871,582
3,871,583
Android: How to do create custom EditText with a clickable arrow on the right
<p>I would like to have an EditText with one modification: on the right (still inside the EditText) there is an arrow pointing downwards, that I can set OnClickListener to. So when user clicks on the arrow it displays a menu. What is the best way to do this?</p>
android
[4]
4,972,809
4,972,810
When I run following url on my browser it runs fine but when i use php function its getting 505 Page . Can any one help me with that
<p>$output = file_get_contents("http://www.canadapost.ca/cpc2/addrm/hh/current/indexa/caONu-e.asp"); var_dump($output);</p>
php
[2]
1,691,844
1,691,845
Output to CSS multiple backgrounds using PHP
<p>On my template I have a number of fields where the user(s) can choose and select from few options to use as a background on their site.</p> <p>There are two separate backgrounds, called from the ID's of <code>background-one</code> and <code>background-two</code>, stored in separate arrays.</p> <p>To output the first background:</p> <pre><code>&lt;?php $background = of_get_option('background-one'); { if ($background['color'] &amp;&amp; $background['image']) { echo 'body { background: ' . $background['color'] . ' url(' . $background['image']. ') ' .$background['repeat']. ' ' .$background['position']. ' ' .$background['attachment']. ';'; echo ' }'; } else if ($background['color']) { echo 'body { background: ' . $background['color']. ';'; echo ' }'; } else if ($background['image']) { echo 'body { background: ' . 'url(' . $background['image']. ') ' .$background['repeat']. ' ' .$background['position']. ' ' .$background['attachment']. ';'; echo ' }'; }; } ?&gt; </code></pre> <p>However, as I'm extremely new to PHP, my question is how would I be able to output the second background?</p>
php
[2]
1,417,667
1,417,668
File Upload/Download module in PHP
<p>I have a online PHP application to which I want that the Admin should be able to upload files at file system using PHP / HTML forms and the other users can download the files. The application should log the number of downloads for a specific file. The files should appear in proper folders as organized by the admin.</p> <p>I am searching for such a module that should be able to do these generic tasks.</p> <p>If you know such then please share your comments.</p>
php
[2]
4,571,271
4,571,272
Android surfaceview animation
<p>I'm trying to achieve animation on a surfaceview. But, my surfaceview's background is transparent, and I can't clear away the pixels of last frame. Can I achieve some animations on transparent surfaceview? Maybe I only use 'Animation' class on a view. Thanks!</p> <hr> <p>Maybe I didn't describe the question clearly. I want to achieve a animation, but surfaceview can't refresh last graph.It looks like the picature.</p> <p><img src="http://i.stack.imgur.com/9suhx.png" alt="enter image description here"></p> <p>The background is transparent. I known draw canvas with color can clean the last drawn graph. But its background is transparent, the method doesn't achieve refresh. Please help me. Thanks! </p>
android
[4]
5,313,249
5,313,250
Regarding Better Approach of Handling Properties
<p>I need to read the two of the following attributes of user details through properties file.</p> <pre><code>username and userid. </code></pre> <p>There may be <code>n</code> number of users inside the properties file.The number is not fixed. In this case what is the best practice to handle this requirement using properties file in java.</p> <p>How about using the following approach.</p> <p>Inside the properties file :</p> <pre><code> userA = Jhon#001 userB = Smith#002 userC = Snack#003 </code></pre> <p>Please provide your pointers on the same.</p>
java
[1]
3,033,224
3,033,225
get the page a user viewed before current
<p>instead of</p> <pre><code>login.php?ref=http://mysite.com/lastpage </code></pre> <p>could I get the before page somehow else? tried HTTP_REFERER but cant get it to work</p> <pre><code>Notice: Undefined index: HTTP_REFERER in C:\test\login.php on line 18 </code></pre> <p>// Newbie</p>
php
[2]
5,215,123
5,215,124
is it possible to remove an html comment from dom using jquery
<p>just wondering if there was a way to remove an html comment using jquery.</p> <pre><code>&lt;!-- &lt;div id="main"&gt;Some text &lt;/div&gt; --&gt; </code></pre> <p>thanks </p>
jquery
[5]
1,851,200
1,851,201
C# equivalent of Event Objects in c++ , winapi
<p>is there an equivalent in C# of the event objects created in c++ using the win api function "CreateEvent".</p>
c#
[0]
5,313,680
5,313,681
What is the shortest way of checking if JS value exists?
<p>Assuming I have this :</p> <pre><code>var a = parseInt(prompt("Enter A")); var b = parseInt(prompt("Enter B")); var c = parseInt(prompt("Enter C")); </code></pre> <p>What is the <em>shortest</em> way to check if a value exists in all 3 variables ?</p> <p>Doing <code>if(a &amp;&amp; b &amp;&amp; c)</code> is <em>not</em> accurate cause <code>0</code> is falsy.</p> <p><em>p.s. <strong>a,b,c can be ints or strings</strong>...Also , There must be a trick here...</em></p> <p>for the string example : </p> <pre><code>var a = (prompt("Enter A")); var b = (prompt("Enter B")); var c = (prompt("Enter C")); </code></pre>
javascript
[3]
2,961,556
2,961,557
java, swing, awt, remove focus from all objects
<p>I'm doing this project for school and for some reason one of by Buttons in one of my Panels has focus(i can change it with the tab button) Well whatever button has the focus is acting weird.</p> <p>Is there a way that I can have no button have focus? ie. have nothing selected by the tab button?</p> <p>notice the Rectangle button has a dotted line around it. I want to make that go away.</p> <p>Thanks! <img src="http://i.stack.imgur.com/P8plY.png" alt="alt text"></p>
java
[1]
4,094,165
4,094,166
How to add the different views for different segments in the segment control?
<p>Iam developing one application.In that i use the segment control with 5 segments.Every segment has separate view.So when we click on any segment another view will be appear below the segment control at the same view.Like this all segments print the different views in the same view.How to get this please tell me how to do this.</p>
iphone
[8]