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
1,155,215
1,155,216
How to put bundle in arraylist with hashmap vallue in android
<p>Hi friends I am getting arraylist with hashmap like this <code>ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;()</code> I want to put it in bundle can anybody give example</p> <p>Thanks</p>
android
[4]
1,613,910
1,613,911
How can i get a list of my application's widgets that are active on the user's homescreen?
<p>From the docs:</p> <p>AppWidgetManager.getAppWidgetIds(ComponentName provider) Get the list of appWidgetIds that have been bound to the given AppWidget provider.</p> <p>This returns a list of widget ids including widgets that have been deleted from the homescreen. Is there a way besides tracking the add/delete events and mainlining my own list to retrieve this information?</p>
android
[4]
2,896,544
2,896,545
Force downloading an image via php script works but the image only opens in paint not photoshop
<p>Here is my php script which executes the download:</p> <pre><code>$link = 'www.example.com'; $url = urlencode($link); $image = "http://chart.googleapis.com/chart?chs=75x75&amp;cht=qr&amp;chl=$url&amp;choe=UTF-8&amp;chld=L|0"; $filename = file_get_contents("$image"); header("Pragma: public"); header("Expires: 0"); // set expiration time header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment; filename='qr code';"); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); echo $filename; </code></pre> <p>This downloads a file but it only opens in paint not photoshop. As a hint there doesn't appear to be a file type associated with the file (e.g. png or jpg).</p> <p>I need all the headers above so this works in all browsers.</p> <p>Thanks.</p>
php
[2]
4,016,522
4,016,523
How can I create a new class instance from a class within a (static) class?
<p>I'm new to Java (have experience with C#),</p> <p>This is what i want to do:</p> <pre><code>public final class MyClass { public class MyRelatedClass { ... } } public class OtherRandomClass { public void DoStuff() { MyRelatedClass data = new MyClass.MyRelatedClass(); } } </code></pre> <p>which gives this error in Eclipse: "No enclosing instance of type BitmapEffects is accessible. Must qualify the allocation with an enclosing instance of type BitmapEffects (e.g. x.new A() where x is an instance of BitmapEffects)."</p> <p>this is possible in C# with static classes , how should it be done here?</p>
java
[1]
6,012,233
6,012,234
JQUERY: Image replacing problems
<p>Having an issue with my "hideText" image replacing my "showText" Anyone know why? This works fine if show and hide are both text, but not at all when show and hide are images.</p> <pre><code>$payload .= '&lt;script type="text/javascript"&gt;&lt;!-- $(document).ready(function() { var showText="&lt;img src=\'images/panelOpen.gif\' /&gt;"; var hideText="&lt;img src=\'images/panelup.gif\' /&gt;"; $(".toggle").prev().append(\'&lt;a href="#" class="toggleLink"&gt;\'+showText+\'&lt;/a&gt; \'); $(\'.toggle\').hide(); $(\'a.toggleLink\').click(function() { if ($(this).html()==showText) { $(this).html(hideText); } else { $(this).html(showText); } $(this).parent().next(\'.toggle\').toggle(\'slow\'); return false; }); }); //--&gt; &lt;/script&gt;'; </code></pre>
jquery
[5]
1,253,971
1,253,972
A generic error occurred in GDI+ in C#
<p>I am using a 3rd party control to read barcode from a bitmap file. Below is the code for my method.</p> <pre><code>public void ShowBarcode(IntPtr img) { int nBarCode; SoftekBarcodeLib2.BarcodeReader barcode = new SoftekBarcodeLib2.BarcodeReader(); barcode.ReadCode39 = 1; barcode.ReadNumeric = 1; nBarCode = barcode.ScanBarCodeFromBitmap(img); for (int i = 1; i &lt;= nBarCode; i++) { MessageBox.Show(barcode.GetBarString(i)); } } </code></pre> <p>For some reason I am getting the above mentioned error at barcode.ScanBarCodeFromBitmap the value of img is 65863972</p>
c#
[0]
4,470,404
4,470,405
PHP Asset Packaging Library
<p>anyone know a great asset management/packaging library for PHP making asset (images, css, js) deployment and optimization super easy much like <a href="http://documentcloud.github.com/jammit/">Jammit for Rails</a>.</p>
php
[2]
4,759,032
4,759,033
eq() method question
<p>For example, I have this HTML structure:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a class="ac_list_a"&gt;some text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="ac_list_a"&gt;some text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="ac_list_a"&gt;some text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="ac_list_a ac_current_a"&gt;some text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="ac_list_a"&gt;some text&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="ac_list_a"&gt;some text&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I need to get the next or previous <code>ac_list_a</code> from <code>ac_current_a</code>.</p> <p>I have tried to do like this:</p> <pre><code>var all_a = $('.ac_list_a,.ac_current_a').eq('.ac_current_a').next(); </code></pre> <p>But it doesn't work.</p> <p>How would you solve it?</p> <p><strong>Update</strong></p> <p>That is, of course I can do it the dumb way, by assigning class to all <code>li</code> elemnts, then using </p> <pre><code>parents(class).next().find(a.class) </code></pre> <p>But is it possible to do it more dynamic way? Because the structure of HTML could change in the future.</p>
jquery
[5]
4,829,471
4,829,472
Add jQuery results for form
<p>I am having an issue trying to add several variables together. The variables are results from other formulas and do not display as a form element. The code below is just a snippet of the whole program:</p> <pre><code>//card 1 interest $('#card_bal_1, #card_int_1').keyup(function() { var card_mon_int_1 = parseInt($("#card_bal_1").val()) * ((parseInt($("#card_int_1").val()) / (12)) * (.01)); if (!isNaN(card_mon_int_1)) { $("#card_mon_int_result_1").html(card_mon_int_1); //floor or round } }); //card 2 interest $('#card_bal_2, #card_int_2').keyup(function() { var card_mon_int_2 = parseInt($("#card_bal_2").val()) * ((parseInt($("#card_int_2").val()) / (12)) * (.01)); if (!isNaN(card_mon_int_2)) { $("#card_mon_int_result_2").html(card_mon_int_2); //floor or round } }); //total interest paid $('#card_mon_int_result_1, #card_mon_int_result_2').keyup(function() { var total_card_monthly_interest = parseInt($("#card_mon_int_result_1").val()) + parseInt($("#card_mon_int_result_2").val()); if (!isNaN(total_card_monthly_interest)) { $("#total_monthly_interest").html(total_card_monthly_interest); //floor or round } });​ </code></pre> <p>The HTML is basically: </p> <pre><code>&lt;span id="card_mon_int_result_1"&gt;&lt;/span&gt; &lt;span id="card_mon_int_result_2"&gt;&lt;/span&gt; &lt;span id="total_monthly_interest"&gt;&lt;/span&gt; </code></pre> <p>This is just one example of trying to get this to work. I understand the results of the interest of card 1 and card 2 are not not form elements. So my problem is converting card 1 and card 2 interest paid into variable so then to add them together.</p> <p>Any suggestions are greatly appreciated!</p>
jquery
[5]
5,833,135
5,833,136
syntax error, unexpected '['
<p>hi im new to php and i have this error i don't know what is the cause and i tried to solve it but no luck .. here is the error</p> <pre><code>syntax error, unexpected '[' in C:\wamp\www\co\admin\modules\common\lib\classes\modules.php on line 169 </code></pre> <p>here is my code </p> <pre><code> foreach ( $parts as $part ) { 169=&gt; $value = explode( "=", $part )[1]; $key = explode( "=", $part )[0]; if ( !$key ) { continue; } $temp[$key] = $value; } </code></pre> <p>thanks in advance for your help</p>
php
[2]
3,047,203
3,047,204
How to get month difference in jquery having only months and years
<p>How to get the month difference in jquery while my input contains just months and years, but not day? My input is from :(4-2011) To :(5-2015) .</p>
jquery
[5]
972,907
972,908
Dynamically creating elements using jQuery
<p>I am building a list of checkbox items in jQuery based on an array returned from a handler.</p> <p>The containing element is the <code>.listContainer</code> element below and then each dynamic element I want to add to this takes the form of the <code>.listContainerItem</code> element. Each item will have checkbox value and label based on the array item creating it.</p> <pre><code>&lt;div class="listContainer"&gt; &lt;div class="listContainerItem"&gt; &lt;input type="checkbox" value="1" /&gt; &lt;div class="listContainerItemLabel"&gt;Checkbox 1&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>At the point of the function that has the array passed to it, what is the most efficient way of creating this? I have been trying to accomplish it as below, but quickly running into major performance issues.</p> <pre><code>function AddItemToListContainer(item) { var currentItems = $j("#listContainerAvailable .listContainerItem"); if ($j.grep(currentItems, function (e) { return $j(e).find(":checkbox:first").val() == item.Id; }).length === 0) { labelDiv = $j("&lt;div /&gt;").addClass("listContainerItemLabel").html(item.Text); itemToAdd = $j("&lt;div /&gt;").addClass("listContainerItem").append("&lt;input type=\"checkbox\" value=\"" + item.Id + "\" /&gt;").append(labelDiv); currentItems.append(itemToAdd); } } </code></pre> <p>I've looked at <code>.map</code> function, but not sure quite how to implement it. Can someone point me in the right direction?</p>
jquery
[5]
3,680,837
3,680,838
jquery-ui-dialog-extra gives error when used with jQuery-ui-1.9.1
<p>I am using jQuery-ui-dialog-extra to add minimize/maximize/restore buttons to a standard jQuery UI dialog. Its was working perfect when I was using jQuery-ui-1.8.16.Now I have upgraded the jQuery-ui from jQuery-ui-1.8.16 to jQuery-ui-1.9.1 .</p> <p>Now the problem is when I click 'minimize' button of dialog, then dialog is minimized.But when I click 'maximize' button to restore the size and position the dialog remain as it is and an error is displayed on console: <code>Uncaught Error: no such method '_generatePosition' for draggable widget instance</code>. </p> <p>For more understanding please look into <a href="http://jsfiddle.net/S4LzA/5/" rel="nofollow">http://jsfiddle.net/S4LzA/5/</a></p> <p>Please let me know how to solve this issue.Thanks in advance.</p>
jquery
[5]
5,073,918
5,073,919
Generate 8-byte number in Java
<p>I'm a little bit confused, how to do this. I know I can use Random class to generate random numbers, but I don't know how to specify and generate 8-byte number?</p> <p>Thanks, Vuk</p>
java
[1]
3,707,585
3,707,586
jQuery how to access JavaScript variable
<p>I know this is a very simple (rather stupid) quesiton </p> <p>I have a javascript array <code>chart["Ref"]</code> how would access it in Jquery</p> <p>can you access javascript variables from jquery and vice versa.</p> <p>Yes I know jquery is JavaScript still ;-)</p>
jquery
[5]
5,552,797
5,552,798
Javascript fade image in and out
<p>I am fairly new to JavaScript and i need a very simple script to fade an image in and out slowly on a loop. Any help would be much appreciated. </p>
javascript
[3]
1,636,793
1,636,794
Android Application
<p>When i run the app. I am getting this error. [INSTALL_FAILED_MISSING_SHARED_LIBRARY] when installing the application.</p>
android
[4]
3,770,598
3,770,599
strpost can't find > character
<p>I need to find an image tag in a text entered in TinyMCE. I'm triyng to find the position of 'img', and then, the first '>' starting on the position where appears 'img'. So, I'm doing:</p> <pre><code>strpos($text, '&gt;') </code></pre> <p>but this don't return anything. What I'm doin wrong? thanks!!</p> <hr> <p>Thanks for the answers!!! I've found my problem:</p> <pre><code>$text = $act-&gt;getText(ESC_RAW) </code></pre> <p>Without ESC_RAW, symbols like &lt; and > are omitted.</p>
php
[2]
2,123,530
2,123,531
Android: how to center a button programatically created?
<p>I need to create a button programatically and have it centered on the layout, both horizontally and vertically. I am trying with the following code:</p> <pre><code>LinearLayout ll = (LinearLayout)findViewById(R.id.layoutItem); Button b = new Button(this); b.setBackgroundDrawable(getResources().getDrawable(R.drawable.button)); b.setLayoutParams(new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)); b.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL); ll.addView(b); </code></pre> <p>But it's not working. The button comes out on top all to the left.</p> <p>Any clues on how to fix this?</p> <p>Thanks a lot.</p>
android
[4]
4,765,324
4,765,325
Convert ObjectResult<string> to ObjectModel.Collection<string>
<p>One of the data member in my data contract is of type <code>System.Collections.ObjectModel.Collection&lt;string&gt;</code>. I am getting a result of type <code>ObjectResult&lt;string&gt;</code> after executing a function import . How to convert <code>objectresult&lt;string&gt;</code> to <code>ObjectModel.Collection&lt;string&gt;</code>. Is there any direct cast exists?</p>
c#
[0]
1,146,514
1,146,515
Is C# going existential on me?
<p>For some reason an if(false) seems to be actually working. The ReferenceEquals call is in there as an extra test. Before it was just user==null which came out as false and yet the if statement still preceded to.. </p> <p>[UPDATE] This is a SharePoint/ASP.Net enviroment so yes it's multithreaded. However none of the code I've written is doing any threading. This is a simple enough call results in a boolean type that an if statement seems to think false=true. I've tried a clean solution, restarting the dev enviroment, restarting the machine. I can't find any evidence that the code in the debugger is different to whats being executed.</p> <p>[NOTE] The code isn't very good as I've hacked it around a bit to try different things and investigate why this is going a bit wrong. Don't hold the bad code against me. For example userFound should really be named userNotFound</p> <p><img src="http://img228.imageshack.us/img228/6869/snippit.png" alt="alt text" /></p>
c#
[0]
3,499,325
3,499,326
clean way to accomplish -- if x in [(0, 1, 2), (2, 0, 1), (1, 2, 0)]:?
<p>If not, then a canonical name for a function? 'Cycle' makes sense to me, but that's taken.</p> <p>The example in the header is written for clarity and brevity. Real cases I'm working with have a lot of repetition. (e.g., I want [1, 1, 0, 0, 0, 2, 1] to "match" [0, 0, 2, 1, 1, 1, 0])</p> <p>This type of thing is obscuring my algorithm and filling my code with otherwise useless repetition.</p>
python
[7]
1,788,167
1,788,168
Sending messages between threads in C#
<p>How can I sending and receiving message between threads?</p>
c#
[0]
4,691,869
4,691,870
Building Dynamic jQuery Menu Using $(window).scrollTop();
<p>I'm pretty new to jQuery but I'm trying to set things up so that when you scroll down past the global navigation at the top of the page a smaller menu with the same links pops out from the side. Here is the code I'm working with:</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $(window).scroll(function(){ var a = $(window).scrollTop(); if (a &gt;= 150){ $('#sideNav a:eq(1)').animate({'margin-right': '0', 'opacity': '1'}, 500); $('#sideNav a:eq(2)').delay(100).animate({'margin-right': '0', 'opacity': '1'}, 500); $('#sideNav a:eq(3)').delay(200).animate({'margin-right': '0', 'opacity': '1'}, 500); $('#sideNav a:eq(4)').delay(300).animate({'margin-right': '0', 'opacity': '1'}, 500); } else if (a &lt; 150){ $('#sideNav a:eq(4)').animate({'margin-right': '150', 'opacity': '0'}, 500); $('#sideNav a:eq(3)').delay(100).animate({'margin-right': '150', 'opacity': '0'}, 500); $('#sideNav a:eq(2)').delay(200).animate({'margin-right': '150', 'opacity': '0'}, 500); $('#sideNav a:eq(1)').delay(300).animate({'margin-right': '150', 'opacity': '0'}, 500); } }); }); &lt;/script&gt; </code></pre> <p>The first if statement works fine and the animations work but adding in the else if to make it disappear when you scroll back to the top seems to break it. The animations still work but they don't fire until a few seconds after the page has been scrolled to the appropriate place and they look slower and choppy. I think the problem is I need to check to see what state the menu is in and then stop the animations if it is already in that state but I'm not sure how to go about doing it. </p>
jquery
[5]
1,701,321
1,701,322
How to convert an object to a byte array in C#
<p>I have a collection of objects that I need to write to a binary file. </p> <p>I need the bytes in the file to be compact so I can't use BinaryFormatter. BinaryFormatter throws in all sorts of info for deserialization needs.</p> <p>If I try byte[] myBytes = (byte[])myObject I get a runtime exception.</p> <p>I need this to be fast so I'd rather not be copying arrays of bytes around. I'd just like the cast byte[] myBytes = (byte[])myObject to work!</p> <p> OK just to be clear, I cannot have <em>any</em> metadata in the output file. Just the object bytes. Packed object-to-object. Based on answers received, it looks like I'll be writing low-level Buffer.BlockCopy code. Perhaps using unsafe code. </p>
c#
[0]
2,215,583
2,215,584
conversion of jpeg to svg in android
<p>I want to know how to convert jpeg files to svg files in android? Thank you in advance. Or can I convert pdf into svg format?</p>
android
[4]
4,709,194
4,709,195
Which screen size and density should I design Android for?
<p>I've been doing some reading on 4-screen sizes, and 4-densities for Android screen size suppor. I want to get a quick prototype app up and running. Is there any type of strategy for this or should I just (based on device size+density mostly used %'s) design for the normal screensize with med+high+xhigh dpi? Is there a best practice here?</p>
android
[4]
5,511,534
5,511,535
Python: Problems adding items to list in a class
<p>I've got a class defined with a method to add items to it:</p> <pre><code>class ProdReg: def __init__(self): self.__PListe=[] def addProdukt(self,pItem): self.__Pliste.append(pItem) </code></pre> <p>When I instantiate a ProdReg object and try to add an object to it with the following code i gent an error:</p> <pre><code>pr.addProdukt(b) </code></pre> <p>I get the following error: AttributeError: <code>'ProdReg' object has no attribute '_ProdReg__Pliste'</code></p> <p>What's wrong? I'm not able to figure thisone out.</p> <p>/Andy.l</p>
python
[7]
3,102,761
3,102,762
Javascript checkboxes
<p>I want to know the number of checboxes checked in javascript. If only one checkbox is checked then it should show an alert message, otherwise it should do the processing. I tried <code>if(names[i].checked&gt;2)</code> but it is not working.. Please help.</p> <pre><code>function insert_slide(ed, height, width) { var img=new Array(); var names=document.getElementsByName('image_id'); for(i=0;i&lt;names.length;i++) { if(names[i].checked) { img[i] = "&lt;IMG SRC='" + names[i].value + "'"; if(height != '') { img[i] += " height='" + height + "'"; } if(width != '') { img[i] += " width='" + width + "'"; } img[i] += " style='margin: 5px;' &gt;"; editor.nicCommand("insertHTML", img[i]); }} hide_lightwindow(); } </code></pre>
javascript
[3]
4,930,118
4,930,119
Variable was not declared in this scope?
<p>I'm getting this error in several methods for several variables (all of which are vectors):</p> <pre><code>error: ‘parent’ was not declared in this scope </code></pre> <p>I've tried wrapping my method implementations inside of "namespace DisjointSubsets { ... }", but that causes other problems. It seems to only do this for vectors, and I've tried adding a "#include vector" at the start of the cpp file, it didn't change anything.</p> <p>Here is the header file:</p> <pre><code>#ifndef UNIVERSE #define UNIVERSE #include &lt;vector&gt; class DisjointSubsets { public : DisjointSubsets ( unsigned numberElements = 5 ) ; unsigned findDS ( unsigned ) ; bool unionDS ( unsigned , unsigned ) ; private : vector&lt;unsigned&gt; parent ; vector&lt;unsigned&gt; rank ; unsigned size ; } ; #include "DisjointSubsets.cpp" #endif </code></pre> <p>And here is an example of one of the methods I wrote in the cpp file (which has no #includes):</p> <pre><code>unsigned DisjointSubsets::findDS(unsigned index) { return parent[index]; } </code></pre> <p>(Changed the method to be non-functional, but still illustrate the kind of line that would cause a problem. Just in case someone else working on the assignment stumbles across this.)</p>
c++
[6]
2,090,039
2,090,040
Where shall variables be defined within a method?
<p>Suppose, I have a method with a parameter of <code>Object</code> type. The method returns nothing - <code>void</code>.</p> <p>First it checks whether the parameter is not null (or any other check, like <code>objectParam.isEnabled()</code>)</p> <pre><code>if (objectParam.isEnabled()) { // ok } </code></pre> <p>Now, if the condition is satisfied, I need local variables. If it's not, then I don't need any variables.</p> <p>WHERE SHOULD I define them? Inside the "if scope" or just after the method header?</p> <p>Of course, I can do it wherever I like, but which way should be a better practice?</p>
java
[1]
5,914,281
5,914,282
How to set, search location in Google map to country specific
<p>I am working with Google map in my application. I need to set the search location for a specific country(eg India). For example If i search any place (eg. paris) it should search only in India. Is there any method to search, without passing country name India in the URL.</p>
android
[4]
74,970
74,971
Displaying images from an array of drawtables in android
<p>I am new to android and experimenting with it.I have 3 pngs.I am setting the first png using ImageView.setImageResource() Now what I have to do is: When the user touches the png on screen I have to display the remaing pngs as well. I have tried :</p> <pre><code>for(int i =0;i&lt;treeArray.length;i++) { image1.setImageResource(treeArray[i]); print the value i } </code></pre> <p>Now the problem is the the value of i is incrementing perfectly but I cannot see the respective images on the emulator. I have tried many other ways by searching on google but the problem still persists </p>
android
[4]
2,250,364
2,250,365
"onModify" event for <select>
<h2>TL;DR</h2> <p>How can I watch for changes in markup in <code>&lt;select&gt;</code> and, more importantly, <code>&lt;option&gt;</code> tags? </p> <p>I <strong>don't</strong> want to listen for the <code>.change()</code> event (<code>onChange</code>), but I <strong>do</strong> want to listen for any changes in attributes (<code>disabled="disabled"</code>), values (<code>value="foo"</code>) or text.</p> <h2>The long version</h2> <p>I'm writing a simple <code>&lt;select&gt;</code> replacement plugin for jQuery. As one of the features, I'd like it to dynamically update with the select box. The one feature I'm stuck with is how to watch for events such as another piece of JS changing one of the <code>&lt;select&gt;</code>'s <code>&lt;option&gt;</code>s by, for example, changing it's text, value or disabled state.</p> <p>I've found a question <a href="http://stackoverflow.com/questions/843318/jquery-modify-event">here</a> that provides a solution, however it just sets up a <code>setTimeout()</code> to poll the element.</p> <p>Is there a clean (by which I mean "not using <code>setTimeout()</code>) way of watching for modifications of elements, specifically the <code>&lt;option&gt;</code>s inside a dropdown select control? The three main things I want to watch for are:</p> <ul> <li>When the text of the option is changed.</li> <li>When it is disabled or enabled.</li> <li>When it's value is changed.</li> </ul> <p>All of these triggered by a piece of JS not related to the plugin I'm writing.</p>
jquery
[5]
2,853,094
2,853,095
Python elif Statement acting unconditional
<p>Not sure why my code is defaulting to this elif. But it's never getting to the else statement. Even going as far as throwing index out of bound errors in the last elif. </p> <p>Please disregard my non use of regex. It wasn't allowed for this homework assignment. The problem is the last elif before the else statement.</p> <pre><code>if item == '': print ("%s\n" % item).rstrip('\n') elif item.startswith('MOVE') and not item.startswith('MOVEI'): print 'Found MOVE' elif item.startswith('MOVEI'): print 'Found MOVEI' elif item.startswith('BGT'): print 'Found BGT' # ... elif item.find(':') and item[(item.find(':') -1)].isalpha(): print 'Mya have found a label' else: # Never get to this branch print 'Not sure what I found' </code></pre>
python
[7]
2,189,721
2,189,722
Numberofcomparison and nunber of item movements
<p>Im using c++ and is using insertion sort</p> <p>Where in the insertion sort algoithm should we put a counter to monitor number of item movements and number of item comparison. I have included my setup below</p> <pre><code>void InsertionSort::insertion_sort() { int key,i,count = 0; for(int j=1;j&lt;10;j++) { key=Arr1[j]; i=j-1; while(Arr1[i]&gt;key &amp;&amp; i&gt;=0) { Arr1[i+1]=Arr1[i]; i--; numberOfItemMovements++; } Arr1[i+1]=key; } } } </code></pre> <p>as you can see, i cant seem to figure out where comparison counter should be put, although the item movement counter is good and work as expected. thanks</p>
c++
[6]
4,195,838
4,195,839
How can you stop a progress dialog running when network access drops?
<p>I have an app that goes out to a website to grab XML for processing. This process is in a separate thread and works fine when I have 3G or WiFi available. I also have code that checks signal before actually running the thread so it won't attempt with no connectivity.</p> <p>During my testing I walked into a building that blocked all signal so the proces started while I was outside and had signal but when I went inside the signal dropped and my Progress dialog just kept runnnig, I had to manually shut the program down to get it to recover.</p> <p>Is there a good way to deal with this without requiring the user to manually shut down the app if this situation happens?</p>
android
[4]
5,618,801
5,618,802
Python string comparison with different case and float
<p>why python is giving output like this:</p> <pre><code>&gt;&gt;&gt; 'apple' &gt; 'T' True &gt;&gt;&gt; 'apple' &gt; 't' False </code></pre> <p>It should be True for both cases.right?</p> <p>Edit:</p> <p>I got the Idea of ASCII Table.Thanks!!</p> <p>Now what about this.Is 11.1 is being treated as '11.1'?</p> <pre><code>&gt;&gt;&gt; 'apple' &gt; 11.1 True </code></pre>
python
[7]
2,461,743
2,461,744
PHP Split String After X Characters Into Separate Word
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/9648019/php-str-split-without-word-wrap">PHP: str_split without word-wrap</a> </p> </blockquote> <p>Let's say I have this string :</p> <pre><code>$string = "Lorem ipsum dolor sit amet"; </code></pre> <p>and I have character limit on my database : 15 characters. by using str_split($string,15), I got this result :</p> <pre><code>Array ( [0] =&gt; Lorem ipsum dol [1] =&gt; or sit amet ) </code></pre> <p>this looks ugly to me... how to cut string to the closest word using PHP but the result is like this :</p> <pre><code>Array ( [0] =&gt; Lorem ipsum [1] =&gt; dolor sit amet ) </code></pre>
php
[2]
4,752,943
4,752,944
Checking bits in a byte using for loop
<p>I was recently studying C# where i came across following for loop</p> <pre><code>// Display the bits within a byte. using System; class ShowBits { static void Main() { int t; byte val; val = 123; for(t=128; t &gt; 0; t = t/2) { if((val &amp; t) != 0) Console.Write("1 "); if((val &amp; t) == 0) Console.Write("0 "); } } } </code></pre> <p>I am not able to understand that Why in doing t=t/2 in the incrementing/decrementing section of the for loop . plz explain</p>
c#
[0]
3,822,863
3,822,864
How do I return an elements class in jQuery?
<p>I would like to send the class of an element to a function. Basically, I need to tell showAjaxLoader() that it should show the loading icon for the element being clicked!</p> <pre><code>jQuery(function($) { var showAjaxLoader = function(selector) { $(selector).empty().html('&lt;img src="loading.gif" /&gt;'); }; $(".add") .bind("ajax:beforeSend", function(event, data, status, xhr) { var class = this.class; showAjaxLoader(class); }); }); </code></pre>
jquery
[5]
1,302,464
1,302,465
android vedio recording with emulator
<p>1) is it possible to record vedios and audios using android emulator(using webcam) ? , and storing the recorded vedio or audio into the pc possibly as</p> <p>recorder.setOutputFile("C:/test.mp4");</p>
android
[4]
3,377,558
3,377,559
String [] Array Error
<p>When I used a String [] array, like this: </p> <pre><code> import java.lang.String.*; import java.text.DecimalFormat; import java.text.NumberFormat; public class JavaJoe { public static void main(String args[]) { String [] day = {"Monday", "Tuesday", "Wednesday", "Thursday", "Saturday", "Sunday"}; </code></pre> <p>the output of this:</p> <pre><code>if(day[0] == ("Monday")) { double cost = 30; double totalCost = 30 * 1.15; //cost including tax money = money - totalCost; System.out.println("It is " + day + " and Joe has to spend " + decimal.format(totalCost) + " on a new pair of shoes. He has " + decimal.format(money) + " left."); } //if </code></pre> <p>gave me this: </p> <blockquote> <p>It is [Ljava.lang.string;@1ea2dfe and Joe has to spend $34.50. He have $165.50 left.</p> </blockquote> <p>Can you tell me why? Why doesn't it tell me that it's Monday? Thanks in advance!</p>
java
[1]
3,396,162
3,396,163
Error providing image from another site
<p>Basically what I want to do is have a section on my site, where you provide the username of a user, example: NOTCH </p> <p>Where it then goes to the minecraft host and finds the user's skin. "Skin Stealer" if you like.</p> <p>However I'm getting an error and have no idea how to get around it..</p> <pre><code>&lt;?php if ($_GET['user']) { $user = $_GET['user']; if(trim($user) == '') { die('No username entered!'); } $user = preg_replace('/\s+/', '', $user); header('Content-Type: image/png'); $picture = '&lt;img src="http://s3.amazonaws.com/MinecraftSkins/$user.png"&gt;'; $getpicture = file_get_contents("$picture"); echo $picture } ?&gt; </code></pre> <p>The HTML is just a basic form which reads the php page called 'mcskin.php'</p>
php
[2]
2,033,407
2,033,408
MapView with button on bottom
<p>I'm trying to place a button at the bottom of my layout. Here's what I did</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;com.google.android.maps.MapView android:id="@+id/map" android:layout_width="fill_parent" android:layout_height="wrap_content" android:apiKey="mykey" android:clickable="true" /&gt; &lt;Button android:id="@+id/button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>This works well enough, but the button is overlayed on top of the mapview. I want the mapview to end right on top of the button. I thought I could just set the mapview to layout_height="wrap_content" but that didn't work.</p> <p>Any suggestions?</p>
android
[4]
924,943
924,944
Save as Ringtone from ContextMenu
<p>I have created a button that onClick plays a mp3 file.I have also create a context menu that when you press the button for 2 secs it prompts you to save it as ringtone.How can i save it somewhere in my sd?this is my code:</p> <pre><code> public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); Toast.makeText(a.this, "Touch and listen", Toast.LENGTH_SHORT).show(); Button button = (Button) findViewById(R.id.btn1); registerForContextMenu(button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v){ MediaPlayer mp = MediaPlayer.create(a.this, R.raw.myalo); mp.start(); Toast.makeText(a.this, "Eisai sto myalo", Toast.LENGTH_SHORT).show(); } }); @Override public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("Save As:"); menu.add(0, v.getId(), 0, "Ringtone"); } @Override public boolean onContextItemSelected(MenuItem item) { if(item.getTitle()=="Ringtone"){function1(item.getItemId());} else {return false;} return true; } public void function1(int id){ Toast.makeText(this, "Ringtone Saved", Toast.LENGTH_SHORT).show(); } } </code></pre>
android
[4]
4,144,739
4,144,740
Search a word in a text file and return its frequency
<p>How to search for a particular word in a text file containing texts of words and return its frequency or occurrences ? </p>
java
[1]
1,376,514
1,376,515
Listview and button with image inserted in one of tab (in Tab layout- Tabs are aligned at bottom) is overlapping
<p>I have aligned the Tabs at bottom. For each tab i have included the saperate layout. In one Tab i have used Relative layout and inserted the Table layout(with button and image) and list view . But list view is overlapping on bottom Tabs and table layout.</p> <p>I have searched for this issue on forums but did'ent find any solution.</p> <p>Thanks</p>
android
[4]
3,573,546
3,573,547
is it possible to create the connectivity of android with ftp server
<p>is it possible to create the connectivity of android with ftp server. i am going to create an application where login information about user is placed on ftp server.</p>
android
[4]
3,781,539
3,781,540
Unexpected T_FUNCTION?
<p>I've question about solving in php version 5.2.7, where i get an error Parse error: syntax error, unexpected T_FUNCTION in /home/ ... /mainMenu.php on line 56. The code is</p> <pre><code>class MainMenu { ... private static function toRec($arr) { ... usort($newArr, function($a, $b) {//this was line 56 return $a['nav_order'] - $b['nav_order']; }); ... } ... } </code></pre> <p>What is alternative for php 5.2?</p> <p>Thank you</p>
php
[2]
3,861,942
3,861,943
C++: malloc : error: invalid conversion from ‘void*’ to ‘uint8_t*’
<p>I got this problem:</p> <p>invalid conversion from ‘void*’ to ‘uint8_t*’</p> <p>When doing this:</p> <pre><code>int numBytes; uint8_t *buffer; buffer=malloc(numBytes); //error here, why? </code></pre> <p>or must I have to put it like this?</p> <pre><code>buffer=malloc(numBytes); </code></pre> <p>Please explain...</p> <p>Thanks in advance.</p>
c++
[6]
5,923,532
5,923,533
Generate lists with exactly one item in common
<p>In Python, I'm poking around with an idea but I'm not exactly sure how to implement it correctly.</p> <p>I have a pool of 26 letters ('A' - 'Z'), and each letter can be used as many times as needed. I want to create lists using these letters; each list will be 10 letters long with no repeats inside them, and I want to guarantee that if I compare any two lists generated, there will be <em>exactly one</em> letter in common.</p> <p>Questions:</p> <ul> <li>Is there a simple way to do this (i.e., by using library functions)?</li> <li>Can I calculate the maximum number of lists I'll be able to create given the size of the pool (pool_size) and the length of the list (list_length)? </li> </ul> <p>Any pointers to relevant material would be appreciated; I don't need an implementation so much as somewhere to lay my Archimedean lever (to be read as: I need a foundation before I can build my idea).</p> <p>"Give me a place to stand on, and I will move the earth." - Archimedes</p> <p><strong>UPDATE</strong>: How naive of me to think that the alphabet was enough to work with. Let's expand the pool to 300 symbols, but keep the lists at length 10. Does that work?</p>
python
[7]
2,066,431
2,066,432
how to create a PDF file uing javascript in IE
<p>I want to create a PDF file based on users' query result (in html table). What is the best javascript/lib I can use for IE? I found jsPDF but it does not support IE. </p>
javascript
[3]
1,181,174
1,181,175
Background Color of a list item in ListView
<p>I am creating a audio player in android and showing a list of songs in a list view. I wants to change background color of currently playing song in list view. The song is changed when song is completed and in this case set background color of this song and remove background color from previous selected song in the list.</p>
android
[4]
2,126,354
2,126,355
How to Zoom the image from bitmap stream
<p>I need to zoom the bitmap image. How to do that. I don't want to use from drawable folder. Please advice me. Thanks in advance!</p>
android
[4]
5,539,590
5,539,591
Issue with post method in jquery
<p>I am trying to send input using jQuery. Though I have succeeded and getting output but my issue is I am unable to perform action on output..</p> <pre><code> $('#email').blur(function(){ var email = $('#email').val(); $('#emailrespond').show().html('&lt;img width="80" height="27" src="images/dot.gif" &gt;'); $.post('showuserstatus.php', { emailid: email }, function(data) { if (data == "YES"){ $('#emailrespond').show().html('Registered'); } if (data == 'BLANKVALUE'){ alert(data); $('#emailrespond').show().html('&lt;img width="27" height="27" src="images/error2.gif"'); } else { $('#emailrespond').show().html(''); } }); }); </code></pre> <p>I have got ouput as YES as well as BLANKVALUE I tried using alert. but the action is not performed. as I tried alert in these condition I come to know its escaping condition.</p>
jquery
[5]
2,010,516
2,010,517
PHP sanitization question
<p>I was wondering how would you sanitize the $_SERVER['REQUEST_URI'], $_POST['email'] and $url code in the code snippets below using PHP.</p> <p>I'm using PHP Version 5.2.14</p> <p>Code Snippets.</p> <pre><code>&lt;form method="post" action="&lt;?php $_SERVER['REQUEST_URI']; ?&gt;"&gt; &lt;/form&gt; $email = $_POST['email']; //Grabs the email address $page_url = $url; //Grabs the pages url address. </code></pre>
php
[2]
3,223,424
3,223,425
What does a static modifier on a constructor means?
<p>I saw this kind of code at work: </p> <pre><code>class FooPlugin : IPlugin // IPlugin is a Microsoft CRM component, it has something special about it's execution { static FooPlugin() { SomeObject.StaticFunction(); // The guy who wrote it said it's meaningful to this question but he can't remember why. } } </code></pre> <p>Any idea what does a static modifier on a constructor mean and why in this case it is required?</p>
c#
[0]
1,163,749
1,163,750
How to implement such a view transition effect
<p>Suppose my app will display some text and thumbnail image on the screen. When the user tap the image, the app will display the larger image whose size is fit the screen, remains the same ratio, just like the UIImageView.contentMode = UIViewContentModeScaleAspectFit. I want to implement such a view transition when display larger image, that is just like when we click a folder locates on the desktop of your Mac computer. When you double click the folder on the desktop, it will open the Finder with transition animation. And there is also a backward transition when you close the Finder, the animation just like the Finder window zoom out and fade to the folder located on the desktop. So suppose the folder is my thumbnail image, and the Finder window is my larger image that will display to fit the iphone screen. How to implement such view transition effect?</p> <p>Hope I state my question clearly.</p> <p>Thank you.</p> <p>best regards.</p>
iphone
[8]
3,891,615
3,891,616
Turning my phone between vertical and horizontal is calling onCreate of the activity every time?
<p>How do I make it to where the activity persists through orientation change of the device? If I click in an edittext view, the keyboard comes up, but if I turn my phone sideways after that, the keyboard goes away.</p> <p>I debugged the code and it's calling onCreate every time I change the orientation of my phone.</p> <p>Thanks a lot</p>
android
[4]
3,716,920
3,716,921
How to clone a TextView?
<p>Say I have a textview that I got from xml.</p> <pre><code>final View popupView = getLayoutInflater().inflate(R.layout.popup, null); final TextView tvPop = (TextView)popupView.findViewById(R.id.tvKeyPop); </code></pre> <p>But I want to have multiple <strong>tvPop</strong> 's, how should I clone them?</p> <p>Thanks.</p>
android
[4]
5,390,789
5,390,790
Compare two objects that contain enum values of the same enum type
<p>I have an enum type defined: EnumType Now imagine</p> <pre><code>object A = EnumType.Value1; object B = EnumType.Value2; </code></pre> <p>I would like to make the comparison ( A == B ) give me the correct result independent of the type of Enum used. In the comparison, the object will always contain enums, and both will be of the same type.</p> <p>How can I achieve this?</p>
c#
[0]
3,598,487
3,598,488
Getting the approximated time of a web page to load in Java
<p>In a programme I am writing in Java, I generate random (existing) addresses. For each address, I want to calculate something. I don't want to do this calculation if the page is very big, because then it would take much time.</p> <p>So I thought, that if I know approximately how much time it would take to get the information, I could determine whether to operate that calculation, or not.</p> <p>Preciseness is not important; I wouldn't care if it takes a second more than requested (although I wouldn't want it to exceed around 5-6 seconds).</p> <p>I am generating articles from Wikipedia, if it helps.</p> <p>Thank you in advance.</p>
java
[1]
1,378,356
1,378,357
Localization of windows form c#
<p>i have seen people localize their form using resource. put text data in resource file and show those text data in windows form apps fetch from resource file. but my requirement is different that when my apps will on any pc and that pc language is set Germany or french then all control caption of my apps will be shown in that language. how could i do this....what code i need to write. i need to write very minimum code to implement it.</p> <pre><code>static int Main( string[] argv ) { CultureInfo ci = CultureInfo.InstalledUICulture ; Console.WriteLine("Default Language Info:" ) ; Console.WriteLine("* Name: {0}" , ci.Name ) ; Console.WriteLine("* Display Name: {0}" , ci.DisplayName ) ; Console.WriteLine("* English Name: {0}" , ci.EnglishName ) ; Console.WriteLine("* 2-letter ISO Name: {0}" , ci.TwoLetterISOLanguageName ) ; Console.WriteLine("* 3-letter ISO Name: {0}" , ci.ThreeLetterISOLanguageName ) ; Console.WriteLine("* 3-letter Win32 API Name: {0}" , ci.ThreeLetterWindowsLanguageName ) ; return 0 ; } </code></pre> <p>the above way i can get current language set of the OS. please discuss this issue in details. thanks</p>
c#
[0]
4,888,583
4,888,584
Calling background service from BroadcastReceiver
<p>I am trying to call a push notification background service from BroadcastReceiver class, but my application crashes. The code is given below:</p> <pre><code>public class AlarmReceiver extends BroadcastReceiver { static int count=1; @Override public void onReceive(Context context, Intent intent) { Intent myIntent=new Intent(context,NotifyService.class); myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(myIntent); } } </code></pre> <p>The manifest entry: </p> <pre><code>&lt;receiver android:name=".AlarmReceiver"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.BOOT_COMPLETED"/&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;service android:name=".NotifyService"&gt; &lt;/service&gt; </code></pre> <p>The error:</p> <pre><code>05-24 15:17:00.042: ERROR/AndroidRuntime(424): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.android.alarm/com.android.alarm.NotifyService}; have you declared this activity in your AndroidManifest.xml? </code></pre> <p>When I call this service through an Activity it's working, but my goal is to call this service from a BroadcastReceiver.</p>
android
[4]
356,003
356,004
Offline language most similar to javascript?
<p>Just a quick query ...</p> <p>I would like to ask people's opinions as to which language is most similar to javascript? I don't program for a living, but I have been learning javascript in my spare time. I would now like to have a shot at making a desktop application, and I think it would help to choose one which is most similar, if at all possible, to javascript?</p> <p>e.g. python, ruby, C#, visual basic ... I have no idea and haven't had much luck googling this</p> <p>Thanks</p> <p>Matt</p>
javascript
[3]
2,880,830
2,880,831
Animation with JQuery, please show me a better "way"
<p>Sorry but iam an JS Newbie (-: I have to animate some span tags inside an div, this code works but it looks horrible..</p> <pre><code>$('#div span.t1').fadeIn(1500, function() { $(this).next().fadeIn(1500, function() { $(this).next().fadeIn(1500, function() { $(this).next().fadeIn(1500, function() { $(this).next().fadeIn(1500, function() { $(this).next().fadeIn(1500, function() { $(this).next().fadeIn(1500, function() { $(this).next().fadeIn(1500, function() { $(this).next().fadeIn(1500, function() { $('#ownage').animate({ backgroundColor: 'red', color: '#FFF', fontSize: '30px' }, 2000); }); }); }); }); }); }); }); }); }); </code></pre> <p>Html Example:</p> <pre><code>&lt;div id="div"&gt; &lt;span class="a1"&gt;TEXT1&lt;/span&gt; &lt;span class="a2"&gt;TEXT2&lt;/span&gt; ... &lt;/div&gt; </code></pre> <p></p> <p>Is there a "faster" way?</p>
jquery
[5]
3,992,542
3,992,543
C# time in microseconds
<p>I am searching how to format time including microseconds. I'm using class DateTime, it allowes (using properties) to get data till miliseconds, which is not enougth. I tried using Ticks, but I didn't know how to translate it to microseconds.</p>
c#
[0]
5,226,349
5,226,350
Checkbox .change() event not firing inside of jQuery .when()
<p>I have two ajax functions that fetch JSON objects using .getJSON and then build a table and drop-down menu using the contents of those objects. This much is working fine. Now I'm attempting to attach an event to each of the checkboxes located in the first column of the table. Naturally I want this to happen after the ajax calls are done. JQuery's .when() function seems like a good solution in that it will wait until both ajax functions are complete. Below is my code. I'm not sure what I did wrong. For some reason the alert inside of the .when function does not fire. Can someone point out what I've done wrong?</p> <pre><code>$(document).ready(function () { $.when(createSpotsTable(), createMarketDropDown(1)) $('input:checkbox').click(function () { $('input:checkbox').change( alert("Hello world!") ); }); }); </code></pre>
jquery
[5]
5,474,750
5,474,751
WordPress 2.8.5 & 'Responsive Twenty Ten' - error
<p>So, According to the WordPress theme download page; the theme 'Twenty Ten' and it's child theme/plugin 'Responsive Twenty Ten' are compatible with 2.8+ </p> <p><em>I'm stuck with using 2.8.5 at work, I don't have an answer to why - but am.</em> </p> <p>I've uploaded both the plugin and the base theme manually - and was stoked to begin implementation of the graphical mock-up when;</p> <pre><code>Fatal error: Call to undefined function home_url() in /data/24/1/0/139/1815302/user/1967139/htdocs/wp-content/themes/twentyten 3/header.php on line 63 </code></pre> <p>Anyone have any suggestions as to what causes this error and how to fix it?</p> <hr> <p>Thanks for your response Chip; but I'm a little confused with your advice - </p> <p>Your advising me to edit the <em>header.php</em>, but then your saying it will create more errors, so that's not really an option then?</p> <p>But your last suggestion seems like a good idea; how do I revert the theme to the old version? Is this something your suggesting I do in the code or is there a place I can download the old version?</p> <p><em><strong>Edit:</em></strong> On the download WP page for the 'Responsive Child theme/plug in' it says it's WordPress 2.8+ compatible - the base version I downloaded didn't specify it's compatibility so it may very well be an updated version not compatible with 2.8 - though I feel like I've seen that theme for years, so hopefully I can find an older version and get it going with the child theme. </p> <p>-cheers!</p>
php
[2]
4,059,661
4,059,662
how do I make this compile?
<p>This is my code snippet:</p> <pre><code>import java.awt.*; import java.net.*; import javax.swing.*; import java.awt.event.*; class chatboxServer { JFrame fr; JPanel p; JTextArea ta; JButton send; chatboxServer() { fr=new JFrame("ChatBox_SERVER"); p=new JPanel(); ta=new JTextArea(); ta.setRows(20); ta.setColumns(20); send=new JButton("send"); fr.add(p); p.add(ta); p.add(send); fr.setVisible(true); fr.setSize(500,500); fr.setResizable(false); try { // Making server listen to port number 3000 ServerSocket s=new ServerSocket(3000); } catch(Exception exc) { JOptionPane.showMessageDialog(new JFrame(),"Cannot Listen :3000"); } try { Socket s=null; s=ServerSocket.accept(); } catch(Exception exc) JOptionPane.showMessageDialog(new JFrame(),"Accept Failed :3000"); } } public static void main(String args[]) { new chatboxServer(); } } </code></pre> <p>The error that I get is:</p> <blockquote> <p>Non static method cannot referenced from static context.</p> </blockquote> <p>Please explain how can I can make this compile?</p>
java
[1]
4,948,435
4,948,436
MPMusicPlayerController function stop causes crash
<p>I use codes below to play ipod audio library.</p> <pre><code>if( musicPlayer==nil) { MPMusicPlayerController* playa=[[MPMusicPlayerController alloc]init]; musicPlayer=playa; [ playa release]; } musicPlayer = [MPMusicPlayerController applicationMusicPlayer]; [musicPlayer setShuffleMode: MPMusicShuffleModeOff]; [musicPlayer setRepeatMode: MPMusicRepeatModeNone]; [musicPlayer setQueueWithItemCollection: userMediaItemCollection]; [musicPlayer play]; </code></pre> <p>when I pressed a button, it will fire function below to stop playing</p> <pre><code>-(void)stopMusicPlayer; { if (playbackState == MPMusicPlaybackStatePlaying) { [ musicPlayer stop]; } } </code></pre> <p>but it crash and exit.</p> <p>Welcome any comment</p> <p>Thanks interdev</p>
iphone
[8]
177,022
177,023
PHP Date Range Check
<p>I have 2 date ranges</p> <pre><code>[contract_start_date] =&gt; 2011-10-20 [contract_end_date] =&gt; 2011-10-29 </code></pre> <p>and I want to verify if the dates below are in range of the date range above</p> <pre><code> 2011-05-05 and 2011-10-10 </code></pre> <p>the dates given must not in any way exceed the range of the contract </p> <p>Is there a function for this in PHP ?</p>
php
[2]
2,370,918
2,370,919
android.app.Application invoking ArrayAdapter.notifyDataSetChanged
<p>I have a static class which extends android.app.Application (<strong>HireApplication</strong>) which is doing a lot of my background work. I create AsyncTasks here, I store the largest data objects that my application uses. I'm writing this code in the Application class so that I can reuse it between separate activities for Phones and Tablets.</p> <p>This feels like the right way to layout my app, but now I have a problem. An AsyncTask has finished and needs to run notifyDataSetChanged on an ArrayAdapter within a Fragment (<strong>ListFragment</strong>).</p> <p>Here is my solution:</p> <p><strong>ListFragment:</strong></p> <pre><code>public void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); myListAdapter = new MyListAdapter(getActivity(), HireApplication.myList); HireApplication.myListAdapter = myListAdapter; // Tell the application where the ListView is so that it can notifyDataSetChanged } </code></pre> <p><strong>HireApplication:</strong></p> <pre><code>public static ArrayAdapter&lt;BikeStation&gt; stationListAdapter = null; private static void asyncTaskCompleteCallback() { {...} myListAdapter.notifyDataSetChanged(); } </code></pre> <p>Now, this works... but it doesn't feel right. I am giving the Application a reference back to a UI element which sounds like it's a bit tightly coupled, but I don't know a better way to do this.</p> <p>Is there a better way of my Application notifying my ArrayAdapter or Fragment that it should take some action to update the UI with fresh data?</p> <p>Cheers.</p>
android
[4]
300,436
300,437
Is file closed or still in memory?
<pre><code>lines = len(open(filename, 'r').readlines()) //or open(filename, 'w').writelines(lines) </code></pre> <p>Does this lines in python, closes the opened file? If not how to close files which are not assigned to any variable? Also what these type of coding is called, is it "refcounting semantics"?</p>
python
[7]
5,543,983
5,543,984
Can I do a timer loop and timeout for serial port communication in C#?
<p>I'm more familiar with C language and recently I've been ask to do C# for serial communication. Below is my code for receiving data from COM port:</p> <pre><code>public void RxData() { int i = 0; int Data; bool StartRx = false; int timer; while (true) { Data = sp.ReadByte(); if (Data == 0x01) { StartRx = true; } if (StartRx == true) { RxBuffer[i++] = Data; } if (Data == 0x04) { RxChkSum = RxBuffer[i - 2]; break; } timer++; if(timer&gt;100) { timer = 0; break; } } } </code></pre> <p>Above is the way I receive data starting with 0x01 and ends with 0x04.</p> <p>I'm incrementing a timer to count til 100 and quit the while loop in case I don't receive any data. Some sort like a timeout.</p> <p>But seems like the timer don't work. When I don't receive any data, my program just stuck in the while loop forever.</p> <p>I know this is the way we write in embedded c programming. But is this the right way to write in C#?</p>
c#
[0]
4,265,810
4,265,811
Reloading python module with flattened namespace
<p>I have a package with a similar structure as scipy/numpy, where you have a few main submodules, and each submodule contains functions from various files that have been flattened into the same namespace. Let's say</p> <pre><code>package/ sub1/ __init__.py file1.py file2.py </code></pre> <p>And then <code>sub1/__init__.py</code> looks like this:</p> <pre><code>from .file1 import func1, func2 from .file2 import func3 </code></pre> <p>The result is that I can do</p> <pre><code>import package.sub1 package.sub1.func1() </code></pre> <p><strong>However</strong>, the problem is that the following does not work:</p> <pre><code>&gt;&gt;&gt; import package.sub1 -- change things in file1.py -- &gt;&gt;&gt; reload(package.sub1) </code></pre> <p>The function does not update. It works if I do <code>import package.sub1.file1</code> instead, so there is something with flattening the namespace, that makes it lose the connection to the module. My main question is how I can still use the <code>reload</code> command, while still getting the benefits of being able to write sibling functions in separate files.</p>
python
[7]
3,075,351
3,075,352
Python: Converting a list into a dictionary?
<p>I have a list:</p> <pre><code>['100 ug/ml', '50 ug/ml', '25 ug/ml', '12.5 ug/ml', '6.25 ug/ml', '3.125 ug/ml', '1.5625 ug/ml', '0 ug/ml'] </code></pre> <p>and I want to make it into a dictionary where these numbers are keys with empty values:</p> <pre><code>growth_data = {'100 ug/ml': '', '50 ug/ml': '', '25 ug/ml': '', etc...} </code></pre>
python
[7]
3,117,449
3,117,450
calling telerik report using report viewer in asp.net
<p>I have a telerik report.using this report we can filter data by selecting the dropdown value.when i see preview my report works fine.when i call this report using report viewer in asp.net web fom it is not working properly.</p>
asp.net
[9]
5,049,962
5,049,963
Checking for input "0" (zero) with cin
<p>I'm trying to have a program loop, accepting input and producing output until the user enters "0" as the input.</p> <p>The problem is, my program accepts two values for input, like this:</p> <pre><code>cin &gt;&gt; amount &gt;&gt; currency; </code></pre> <p>So, I tried to have a while statement like this:</p> <pre><code>while (amount != 0 &amp;&amp; currency != "") { cin &gt;&gt; amount &gt;&gt; currency; cout &lt;&lt; "You entered " &lt;&lt; amount &lt;&lt; " " &lt;&lt; currency &lt;&lt; "\n"; } </code></pre> <p>However, the while statement always executes, even if I enter <code>0</code> as input.</p> <p>How do I write the program such that it accepts two values as input except when the user enters 0, in which case it terminates?</p>
c++
[6]
924,951
924,952
Accesing a file outside my applicadtion data folder
<p>Where should I copy a file (in my case it is a sqlite database) to let my application copy it to its data folder? I have tried some locations with no luck. It seems I don't have enough permissions.</p>
android
[4]
3,949,229
3,949,230
What is the best solution for collecting location info in the background?
<p>I want to make an application that gets the phone location each 30 min and save it to a DB (and transmits to a webserver).</p> <p>The application should be running in the background for a few hours while the user can be doing other things with his phone (games, calls...)</p> <p>Can someone please advice what is the best solution for this project? (Service? AlermManager?) </p>
android
[4]
5,293,535
5,293,536
Dropping data in range buckets
<p>I have two dimentional data stored in a sorted list of tuples, as follows:</p> <pre><code>data = [(0.1,100), (0.13,300), (0.2,10)... </code></pre> <p>The first value in each tuple, the X value, only occurs once for the list of tuples. In other words, there can only be one value for 0.1 etc. </p> <p>I then have a sorted list of buckets. A bucket is defined as a tuple containing a range and an id, as follows:</p> <pre><code>buckets = [((0,0.14), 2), ((0.135,0.19), 1), ((0.19,0.21), 2), ((0.19,0.24), 3)... </code></pre> <p>A range is with respect to the X axis. So, the id 2 has two buckets above and ids 1 and 3 have only one, respectively. The first bucket for id 2 has a range from 0 to 0.14. Please note that buckets can overlap. </p> <p>So, I need an algorithm which drops the data into the buckets and then adds up the scores. For the data above, the result would be:</p> <pre><code>1:0 2:410 3:10 </code></pre> <p>Notice how each piece of data is caught by a bucket associated with the id 2, hence it gets the score <code>100+300+10=410</code>.</p> <p>How might I write an algorithm to do this?</p>
python
[7]
3,560,489
3,560,490
Python nice print
<p>I have a string like this:</p> <blockquote> <p>G O S J A J E K R A L J</p> </blockquote> <p>I would like to print it like this:</p> <blockquote> <p>['G', 'O', 'S', 'J', 'A'....</p> </blockquote> <p>I tried with:</p> <pre><code>print s, print list(s), </code></pre> <p>Any ideas ?</p>
python
[7]
4,155,150
4,155,151
How to fire an jquery action when a div is appended?
<p>I need to fire an jquery action when a div is appended.</p> <p>Something like: </p> <pre><code>if ($('div#myDiv').is_appended()) { console.log('the div has been appended'); } </code></pre> <p>Is this possible?</p> <p><strong>Why do I need this</strong></p> <p>This question is related to this <a href="http://stackoverflow.com/questions/15083511/how-to-execute-jquery-inside-a-modal-window">question</a> where I have I modal div which is loaded after the jquery library, then I can't target the element in it. </p> <p>Now I'm trying to do something when the modal div is load, not sure if I get it done though,</p>
jquery
[5]
3,422,496
3,422,497
How to set digital clock font Android
<p>I am designing an app with digital clock. I have designed that except the font part. I want to show the clock font in "digital clock font"(like in digital watches) instead of normal font. Can someone tell me how to do this?</p> <p>Thanks</p>
android
[4]
2,180,321
2,180,322
How can I specify a null as an XML attribute for Android?
<p>I am a beginner in android.I m trying to run some of the examples in eclipse.I was able to do the simple ones but not database involved applications because they involve 2 .java files(databasemanager class and activity class). I dont know which to copy where and run.I know it is silly...but consider me being a beginner .Anyone please help me out in this....</p> <p>here is the link to the database app i tried: <a href="http://www.anotherandroidblog.com/2010/08/04/android-database-tutorial/8/" rel="nofollow">http://www.anotherandroidblog.com/2010/08/04/android-database-tutorial/8/</a></p>
android
[4]
1,147,794
1,147,795
add these values in a list using python "app and a.b.c.d" Output in ["app", "and","a.b.c.d"]
<p>I am having Text to convert in a list </p> <pre><code>"app and a.b.c.d" </code></pre> <p>Output should be </p> <pre><code>["app", "and", "a.b.c.d"] </code></pre>
python
[7]
2,563,477
2,563,478
trouble converting image to a drawable, android
<p>I want to download an image and have it as a drawable in my object class</p> <pre><code>for(int i=0;i&lt;jArray.length();i++){ json_data = jArray.getJSONObject(i); Programme Progresult = new Programme(); Progresult.name = json_data.getString("name"); Progresult.event = json_data.getString("event"); Progresult.price = json_data.getString("price"); String p = json_data.getString("preview"); try { is2 = (InputStream) new URL(p).getContent(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Progresult.progpreview = Drawable.createFromStream(is2, "src name"); arraydata.add(Progresult); } </code></pre> <p>I'm getting some decode errors</p> <pre><code>03-23 20:36:51.401: D/skia(795): --- decoder-&gt;decode returned false 03-23 20:36:51.680: D/skia(795): --- decoder-&gt;decode returned false 03-23 20:36:51.933: D/skia(795): --- decoder-&gt;decode returned false 03-23 20:36:52.450: D/skia(795): --- decoder-&gt;decode returned false 03-23 20:36:53.120: D/skia(795): --- decoder-&gt;decode returned false </code></pre> <p>I think it might be something god to do with the url to the image that is being retrieved, here is one of them....</p> <pre><code>"http://ec2-##-###-##-###.eu-west-1.compute.amazonaws.com/corkgaa/Match%20programmes/sample1.bmp" </code></pre> <p>Any help appreciated :)</p>
android
[4]
4,761,322
4,761,323
handling a compute intensive operation
<p>I'm writing a web based application (large cargo aircraft weight and balance) in which the user enters pallet weights. When an individual pallet weight is entered, a number of checks have to be made to determine if that weight can be accepted. The checks are all relatively trivial in terms of compute cycles required; one is not. As I understand it, JavaScript is single-threaded, which I take to mean that if the user starts to enter a weight in another pallet position, he's going to be locked out until the previous weight is fully processed.</p> <p>I can't afford to have the user waiting every time he enters a weight (which they don't have to do at the moment as the app currently doesn't make that last check properly). Currently I'm thinking of not doing the final compute-intensive step until all weights are entered and the user signifies so by clicking on a button. However, this will deprive the user of immediate feedback as to which weight initially triggered the problem, a problem in which multiple weights may contribute, and which is going to be hard to sort out if they have to wait until the last.</p> <p>My Google searches on the topic have been somewhat useful, but I'm asking here for possible ideas for an up-to-date solution to the dilemma. Any suggestions are most welcome. The context of the problem can be observed by going to <a href="http://terryliittschwager.com/WB/JWB.php" rel="nofollow">http://terryliittschwager.com/WB/JWB.php</a> and selecting an aircraft.</p>
javascript
[3]
5,634,089
5,634,090
os.unlink multiple file in python
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/991279/deleting-files-by-type-in-python-on-windows">Deleting files by type in Python on Windows</a> </p> </blockquote> <p>How can I delete all files with the extension ".txt" in a directory? I normally just do</p> <pre><code>import os filepath = 'C:\directory\thefile.txt' os.unlink(filepath) </code></pre> <p>Is there a command like os.unlink('C:\directory\'*.txt) that would delete all .txt files? How can I do that? Thanks!</p>
python
[7]
260,748
260,749
striking through the text
<p>I need to strike through the text of a multi-line label. Is there a way to do it? Any suggestion would be greatly helpful. Thanks,</p>
iphone
[8]
45,303
45,304
How to figure out which instance of java has a class loaded
<p>I'm trying to figure out how a system works. When I do a 'ps -A' I see several java processes. Is there a way to run a command that will examine a java instance and let me know what all jars or classes are loaded from that instance (preferably without stopping the instance)?</p>
java
[1]
4,462,702
4,462,703
java design - user preset system
<p>I'm working on a pattern system where the user can store presets of all the parameters, and I want to include the possibility to interpolate between presets. We are talking about many parameters (80-100), so I guess it has to be as fast as possible. What would be a smart way to do this? Some useful suggestions are very appreciated. </p> <p>Thanks in advance! </p>
java
[1]
1,131,818
1,131,819
Check that word all words from one string exist in the other
<p>How can I check that all the words from string #2 exist in String #1? It should be case insensitive and I want exclude all punctuation and special characters during comparison of words.</p> <p>Any help?</p> <p>Thanks.</p>
java
[1]
5,280,518
5,280,519
How to set Root View when using inflate method of LayoutInflater?
<p>After i looking up <a href="https://developer.android.com/reference/android/view/LayoutInflater.html#inflate%28int,%20android.view.ViewGroup,%20boolean%29" rel="nofollow">inflate</a>, i found it quit hard to understand what does the root view mean. Is it just the parent view of this generated xml hierarchy or the uppest view of the whole view hierarchy.<br></p> <p>I think the answer most probably be the former. But I am facing a problem. If in the case that i can't get the parent view of this generated hierarchy, do i have to set the layout parameter everytime i inflate a hierarchy tree?<br></p> <p>Here is my code. And the LinearLayout can't fill the parent. I think the <code>layout_height</code> and <code>layout_width</code> of the LinearLayout must be set to <code>wrap_content</code>.<br></p> <p>storage_status.xml<br></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;com.android.contacts.StorageStatusView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent"&gt; &lt;View android:layout_height="50px" android:layout_width="50px" android:background="#f00"/&gt; &lt;/com.android.contacts.StorageStatusView&gt; </code></pre> <p>Snippets in java file.</p> <pre><code>private class QuickActionClickListener implements QuickAction.OnActionItemClickListener { @Override public void onItemClick(QuickAction source, int pos, int actionId) { switch (actionId) { case ACTION_ID_STORAGE_STATUS : final LayoutInflater inflater = getLayoutInflater(); new AlertDialog.Builder(ContactsListActivity.this) .setTitle(UIUtils.getString(ContactsListActivity.this, R.string.storage_status)) .setView(inflater.inflate(R.layout.storage_status, null)) .show(); break; } } } </code></pre> <p>Thanks in advance. And sorry for my poor english.</p>
android
[4]
3,369,165
3,369,166
store objects in $_GET
<p>how can i store an object in the $_GET array in PHP. i want to pass an object containing database information from one page to another page via the $_GET array, so there would be no need to access the database again.</p>
php
[2]
4,871,037
4,871,038
Defining Files to a java program at runtime
<p>Hello all java newbie here... I'm writing a java program that has to read from an external text file, (inquiries) and then write out the responses to the inquiries to another external text file. </p> <p>Now the program will not know the path name of the files until run time when the path name for both the input and output files will be passed via the arguments parameter. The path name will be the same for both files, the actual file names I have defined in two string variables..e.g. </p> <pre><code>final static string RqstFname = "RqstFile.txt" final static string RespFname = "RespFile.txt" </code></pre> <p>Now all the examples of File constructor use always have a <strong>hardcoded</strong> <code>path\file_name string</code>. can I pass a string variable to the <code>File Contructor</code> ?? </p> <p>Thanks very much </p>
java
[1]
3,921,450
3,921,451
Most Instructive Open Source Android Projects?
<p>I'm looking to compile a list of instructive open-source Android projects.</p> <p>My criteria for instructiveness:</p> <ul> <li>High code quality</li> <li>Good API coverage, demonstrating how various parts of the API interact</li> <li>Continually improved, showing that the designs are in fact maintainable</li> <li>Good aesthetic quality</li> </ul> <p>In other words, the apps that as <em>intermediate to advanced</em> Android developers we should be looking to for guidance, and not simply tutorials that demo a few concepts.</p>
android
[4]
1,173,285
1,173,286
Site root for backend and frontend
<p>Let's say that I have this website file root structure:</p> <ul> <li>frontend /home/username/public_html/</li> <li>backend /home/username/public_html/admin/</li> </ul> <p>In frontend folder there is a file called config.php. In this file I get the site root of my website like this:</p> <pre><code>define('ROOT', dirname(__FILE__)); </code></pre> <p>This file is also included in both index files (index.php) in frontend and backend. But for backend, the root is /home/username/public_html/admin/, which should actually be /home/username/public_html/. How can I do this, in one line, in config.php?</p> <p><strong>LE:</strong></p> <p>Demo code <a href="http://pastebin.com/LGrrJzaV" rel="nofollow">http://pastebin.com/LGrrJzaV</a></p>
php
[2]