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,825,991
1,825,992
Using PHP to Extract Content From Tags
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-with-php">How to parse and process HTML with PHP?</a> </p> </blockquote> <p>Given an HTML file, how can PHP be used to extract strings from each, say, <code>&lt;font&gt;</code> tag within the document?</p>
php
[2]
4,888,850
4,888,851
Error in Simple Cursor Adapter, not working
<pre><code>Cursor searchCursor = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[] {"_id",Phone.DISPLAY_NAME}, Phone.DISPLAY_NAME + " like ?", new String[]{ "%" + cc.get("contactName").toString() + "%"}, null); startManagingCursor(searchCursor); while(searchCursor.isAfterLast() == false) { final String name = searchCursor.getString(searchCursor.getColumnIndex(Phone.DISPLAY_NAME)); final String number = searchCursor.getString(searchCursor.getColumnIndex(Phone.NUMBER)); str =new String[]{name,number}; ada = new SimpleCursorAdapter(this, R.layout.view_contacts_listview_layout, searchCursor, str, new int[] { R.id.contactName, R.id.contactPhoneNo }); } lvSearch.setAdapter(ada); </code></pre> <p>The cursor query running fine only getting problem in simple cursor adapter.</p>
android
[4]
334,940
334,941
Android - Honeycomb - Action Bar tab fragments save/restore state
<p>In the docs it says to ensure you save a fragment's state when using tabs with the action bar so that when you switch tabs the fragment will look as it did before. How is this done? Using the sample for handling tabs, onSavedInstanceState is not called when the tab is switched so where would I save the state? Do I do it at the activity level? I only want the state to be transient.</p> <p>Thanks</p>
android
[4]
4,662,470
4,662,471
Windows Service application app.config
<p>I developed a Windows service application and in my <code>app.config</code> file I need to encrypt my password and decrypt in my application. </p> <p>How can I do this ?</p>
c#
[0]
4,008,123
4,008,124
iPhone Dev. Apps: "Promo Codes" button in iTunes is missing
<p>I have got a few apps in my iTunes Developer Backend. Since yesterday the "Promo Code" button is missing in some of my apps details view. The rest of my apps have still this button and I can download promocodes. Does any one know this problem and maybe solved it?</p> <p>Thx :-)</p>
iphone
[8]
1,293,477
1,293,478
C# Modulus Counting
<p>Good Day,</p> <p>I am writing an application where I'm downloading a file that is over 30MB. I am keeping track of how many bytes that have been currently been downloaded.</p> <p>My question is:</p> <p>I want to determine when I go past 1M, 2M, 3M and so forth.</p> <p>My logic is:</p> <pre><code>int totalFileSave = 0; ... ... int bytesRead = responseStream.Read(buffer, 0, 4096); totalFileSave += bytesRead; while (bytesRead &gt; 0) { // How do I test when I hit 1M, 2M, 3M and so forth... bytesRead = responseStream.Read(buffer, 0, 4096); totalFileSave += bytesRead; } </code></pre>
c#
[0]
2,425,922
2,425,923
What is the difference between setting properties to the global object and the window object?
<pre><code>this.f = function() {}; window.d = function() {}; d(); f(); </code></pre> <p>Any difference?</p>
javascript
[3]
5,496,035
5,496,036
Change browser time
<p>Is there any way to change the browser's time without manipulating the system clock?</p>
javascript
[3]
2,931,804
2,931,805
Method with Var Method input?
<p>In C#:</p> <p>Is it possible define a method that <strong>input parameter</strong> is any <strong>method</strong>?</p> <p>Let me better description:</p> <p>I want a method with signature </p> <pre><code>bool IsDoit(var method) { try { method(...); return true; } catch{return false;} } </code></pre> <p>This get a method and return a boolean that is throw exception or not!</p> <p>Generic Delegate? Generic Action? Generic Func?</p> <p>Do You have any idea or it is <strong>not possible</strong>?</p>
c#
[0]
192,503
192,504
Get Another Process' QueryPerformanceCounter()
<p>I'm trying to run QueryPerformanceCounter() function from a particular process and get its return value to my C# application. Since those two processes (my application and the application i'm trying to affect) are different, what kind of strategy should i follow?</p>
c#
[0]
1,791,647
1,791,648
Canvas Larger Than Screen
<p>I am drawing a grid and I want it to be larger than the screen size so that a user can drag the screen left/right/up/down to get to the rest of the grid.</p> <p>What is the best way to do that? I've tried drawing a larger bitmap to the canvas, but didn't get anywhere. </p> <pre><code> protected void onDraw(Canvas canvas) { super.onDraw(canvas); Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE); Bitmap testBitmap = Bitmap.createBitmap(1000, 1000, Bitmap.Config.ARGB_8888); canvas.drawBitmap(testBitmap, 0, 0, paint); canvas.drawPaint(paint); //other grid drawing code here } </code></pre>
android
[4]
2,681,752
2,681,753
Dendropy interpop module python
<p>I'm currently trying to work with the python Dendropy library and include some PAUP commands inside my code.</p> <p>I'm using the tutorial mentioned in the <a href="http://packages.python.org/DendroPy/tutorial/paup.html" rel="nofollow">python library</a>, but it's giving me an error.</p> <p>So what I'm doing is I'm trying to estimate a tree from a distance matrix:</p> <p><em><strong>Distance matrix A (Numpy array)</em></strong></p> <pre><code>[[ 0 2 7 8 16 17] [ 2 0 5 6 17 16] [ 7 5 0 9 15 13] [ 8 6 9 0 18 16] [16 17 15 18 0 5] [17 16 13 16 5 0]] import dendropy from dendropy.interpop import paup #A is a distance matrix like this tree = paup.estimate_tree(A, 'nj') </code></pre> <p>The error I'm getting is: <code>ImportError: No module named interpop</code></p> <p>I have PAUP installed on my machine and the tutorial does not talk about installing any additional modules.</p> <p>Any help would be appreciated.</p> <p><em><strong>EDIT</em></strong> does this work with NUMPY arrays ?? because it seems to give an error with numpy arrays.. and how to solve this problem ??</p>
python
[7]
4,081,106
4,081,107
static method - when to return an array argument as void and return as an array?
<p>I've been reading this section about static methods and about passing arrays by call-by-reference. So my question is: When is it ever a good time to return an array argument as an array as opposed to void?</p> <p>Thanks in advance!</p>
java
[1]
3,308,296
3,308,297
getApplication use in onClick method
<p>I use Application to access my data. And while buttom be click, I want to use the data which in Application. I use below code:</p> <pre><code>b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { MyData md = (MyData)this.getApplication(); md.setName(""); md.setIP(""); } }); </code></pre> <p>But the error show:</p> <pre><code>The method getApplication() is undefined for the type new View.OnClickListener(){} </code></pre> <p>How to use getApplication in onClick method?</p>
android
[4]
4,086,991
4,086,992
Is this an example of selectors?
<p>I see the following piece of code</p> <pre><code>input[type='button']text:visible:enabled:first </code></pre> <p>What does this code do. Which feature of jquery is this? Is this selector example? Any links to read more on it?</p>
jquery
[5]
2,364,561
2,364,562
I am using addClass/removeClass and "data-" attribute to show/hide divs. How can I add next/previous?
<p>I am trying to work out the template for an ebook. This is what I have at present: <a href="http://jsbin.com/otakab/2/edit" rel="nofollow">http://jsbin.com/otakab/2/edit</a> But the next/previous doesn't work. Can you supply working code?</p> <pre><code>// Following function works $(function() { $(".pageNumbers a").on("click", function(e) { // Add highlight to the element clicked and remove highlighting from its siblings $(this).addClass("highlight").siblings().removeClass("highlight"); // Make use of our data attribute to show the correct page and hide the siblings $($(this).data('page')).show().siblings(".page").hide(); }); // Finally, dynamically click first page to start things off for the user //and provide proper highlighting and showing of text $("#a-1").click(); }); // Following function DOES NOT WORK $(function() { $(".direction a").on("click", function(e) { // Trying to show the next/previous hidden div $($(this).data('page')).show().siblings(".page").hide(); }); }); </code></pre>
jquery
[5]
842,150
842,151
How to detect shortcut in Home screen
<p>I have an app that allows you to create "shortcuts" in Home Screen. But can i detect if the "shortcuts" already exist, i didn't have to create it again. Thanks.</p>
android
[4]
4,838,621
4,838,622
How to detect context in Views
<p>I have simple template system for my View, something like:</p> <pre><code>&lt;h2&gt;%var1%&lt;/h2&gt; </code></pre> <p>And when I want escape variable i use filter:</p> <pre><code>&lt;h2&gt;%var1|html%&lt;/h2&gt; </code></pre> <p>But I want to write "system" to detect context of current variable. System will return html, xml, css or other depending on current context and variable will be correctly escaped.</p> <p>Can you help me where can I start? Thank you!</p>
php
[2]
948,618
948,619
How can I cast a Long to an int in Java?
<pre><code>Long x; int y = (int) x; </code></pre> <p>Eclipse is marking this line with the eror: Can not cast Long to an int.</p>
java
[1]
4,319,075
4,319,076
Overloaded output operator in base class
<p>I have a number of classes that represent various computer components, each of which have an overloaded <code>&lt;&lt;</code> operator declared as follows:</p> <pre><code>friend ostream&amp; operator &lt;&lt; (ostream&amp; os, const MotherBoard&amp; mb); </code></pre> <p>Each returns an ostream object with a unique stream describing that component, some of which are composed of other components. I decided to create a base class called <code>Component</code> in order to generate a unique id as well as some other functions that all the components will publicly derive. Of course, the overloaded <code>&lt;&lt;</code> operator doesn't work with pointers to <code>Component</code> objects.</p> <p>I was wondering how I would effect something like a pure virtual function that will be overwritten by each derived class's <code>&lt;&lt;</code> operator so I could do something like:</p> <pre><code>Component* mobo = new MotherBoard(); cout &lt;&lt; *mobo &lt;&lt; endl; delete mobo; </code></pre>
c++
[6]
4,279,050
4,279,051
jQuery - Reversing the sequental fade-in plugin
<p>I'm wondering if there ar any ways to make this plugin: <a href="http://www.thewebsqueeze.com/web-design-tutorials/sequential-fade-in-jquery-plug-in.html" rel="nofollow">http://www.thewebsqueeze.com/web-design-tutorials/sequential-fade-in-jquery-plug-in.html</a> showing fade in items at the top?</p> <p>Thanks a lot!</p>
jquery
[5]
501,800
501,801
How does this method work?
<p>I have often come across this way of registering an action listener.</p> <p>Though I have been using this method recently but I don't understand how's and why's of this</p> <p>Here is one :{</p> <pre><code>submit=new JButton("submit"); submit.addActionListener(new ActionListener(){ // line 1 public void actionPerformed(ActionEvent ae) { submitActionPerformed(ae); } }); //action listener added </code></pre> <p>} Method that is invoked :</p> <pre><code>public void submitActionPerformed(ActionEvent ae) { // body } </code></pre> <p>In this method, I don't need to implement ActionListener. Why?</p> <p>Also, please explain what the code labeled as <code>line 1</code> does.</p> <p>Please explain the 2 snippets clearly. </p>
java
[1]
468,209
468,210
AVPlayerItem metaData notifications
<p>I've a HTTP live streaming app. that its videos contains metadata, I need to trigger an event when metadata faced but using AVPlayerItem!!! How can I do that??</p>
iphone
[8]
193,859
193,860
How can we add shadow on the image only rounded and other part same as previous?
<p>We can give a shadow effect all above the image but if we wanna give the shadow for some particular shape like as circle and the other part of image does not effected by the shadow then what should i do to handle this ?</p> <p>thanks in advance .</p>
android
[4]
3,466,083
3,466,084
How to deal with the certain pattern of tuples
<p>if </p> <pre><code>list_1 = [(1, 1), (1, 3), (1, 4), (2, 2), (2, 3)] </code></pre> <p>Consider an element of the tuple as (i, j) Now we know if we know that if we know that if (1, 3) exists then (1,1) and (1,2) should exists if any one of it is missing an error is reported. The error detection should be done one by one first for (1,1) then for (1, 2). similarly if we know that for another sequence if (2,3) exists then similarly (2,1) and (2, 2) would exists.</p> <p>also this is an example list. The example could also be like:</p> <p>list_1 = [(1, 3), (1, 4), (2, 2), (2, 3), (3,1) (3,4)] now in this case if (3, 4) exists then (3,1),(3,2) and (3,3) should exists. This pattern can be determined by the max of jth element of each 'i' My code is as gi</p> <pre><code>for i, e in enumerate(list_1): i1 = (1,1) if i1 not in list_1: raise ValueError, '%s is missing in %s' %(i1, production) if (e[0] == e[1]) and ((e[0],e[1]) not in list_1): #if i1 not in list_1: raise ValueError, '%s is missing in %s' %((e[0], e[1]), production) print e, e[0], e[1], (e[0], e[1]) if i!=len(list_1)-1: if e[0]==list_1[i+1][0] and e[1]!=list_1[i+1][1]-1: raise ValueError, '(%s,%s) is missing in %s ' %(e[0], e[1]+1, production) </code></pre>
python
[7]
5,471,050
5,471,051
php __get method and visbility types behavior
<pre><code>class Magic{ public $a="i"; public $b=array("a"=&gt;"A","b"=&gt;"B","c"=&gt;"C"); public $c=array(1,2,3); public function __get($v) { echo "&lt;br/&gt;get-&gt;$v"; return $this-&gt;b[$v]; } public function __set($var,$val) { echo "&lt;br/&gt;set-&gt;$var: $val,"; $this-&gt;$var=$val; } } $m=new Magic(); echo $m-&gt;a." , ".$m-&gt;b." ,".$m-&gt;c." ,"; $m-&gt;c="CC"; echo $m-&gt;a." , ".$m-&gt;b." ,".$m-&gt;c; </code></pre> <p><strong>Output</strong>:i , Array ,Array ,i , Array ,CC</p> <p>Now, I modify the visibility to protected for variable $b and $c.</p> <p><strong>Output</strong>: bci , B ,C ,c: CC,bci , B ,C</p> <p>As far as I understand _<em>get and</em>_set is called for undefined var .So, when access modifier or visibility is set to protected why __get() is called !.</p> <p>Can someone explain ..... I am not able to understand this.</p>
php
[2]
653,882
653,883
How to reach "globals" from inside a class in PHP
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1877136/access-global-variable-from-within-a-class">Access global variable from within a class</a> </p> </blockquote> <p>I got the following code:</p> <pre><code> $foo = 'foo'; class bar { public function __construct() { var_dump($foo); } } $bar = new bar(); </code></pre> <p>this results in a NULL value. Is it possible to reach $foo inside the class bar? with some fancy magic word in php?</p>
php
[2]
1,865,086
1,865,087
How Would I have a Gift App or Add App Store Rating Button into an app
<p>I know that apps in the App Store have a gift this app and ratings button links right in the app that link directly to the page. How would I get the URL of my apps gift this app and rating page?</p> <p>Regards.</p>
iphone
[8]
4,025,505
4,025,506
Loop won't stop at given value
<p>I was trying to create a sliding panel that will hide itself with a simple js animation. Here the developing link: <a href="http://carportal.webpronto.it" rel="nofollow">http://carportal.webpronto.it</a> just click on "hide panel" to see the search tab go left.</p> <p>The issue is the following: I tried to give a value for the panel to stop when it reaches the position left: -25% But the panel continue his fool run versus the infinite. here the script i used:</p> <pre><code>&lt;script type="text/javascript"&gt; var scrollSpeed = 50; var step = 1; var current = 0; var endposition = 25; function closeBAR(){ current -= step; if (current == endposition){ stop; } $('#colleft').css("left",current+"%"); var init = setInterval("closeBAR()", scrollSpeed); } &lt;/script&gt; </code></pre> <p>What's wrong with my script?</p>
javascript
[3]
4,142,887
4,142,888
What is purpose of using `void` here?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/666936/what-is-the-point-of-void-in-javascript">what is the point of void in javascript</a> </p> </blockquote> <p>What is purpose of using <code>void</code> here ? if just remove <code>void()</code>, it should also work, right?</p> <pre><code>var b=document.body; if(b&amp;&amp;!document.xmlVersion) { void(z=document.createElement('script')); void(z.src='http://www.google.ca/reader/ui/subscribe-bookmarklet.js'); void(b.appendChild(z)); } else { location='http://www.google.com/reader/view/feed/'+encodeURIComponent(location.href); } </code></pre>
javascript
[3]
5,805,860
5,805,861
Does List.subList keep a reference to the original list?
<p>If I have a variable</p> <pre><code>LinkedList list </code></pre> <p>and repeatedly do the following to extract the tail of 'list'</p> <pre><code>// Some operation that adds elements to 'list' // max_size = some constant list = (LinkedList) list.subList(list.size()-max_size, list.size()); </code></pre> <p>do I end up with a lot of references to the 'previous' list?</p> <p>So basically what I'm trying to do here is to remove an initial segment of the list.</p> <p>Is there a better way to remove an initial segment of a LinkedList? I think the data structure of LinkedList should allow linear time (linear in the size of the initial segment to be removed) operation.</p>
java
[1]
4,098,491
4,098,492
How to stripe rows with jQuery while excluding some particular rows
<p>I'm using the following to stripe rows:</p> <pre><code>$(".stripeMe tr:even").addClass("alt"); </code></pre> <p>I have a table with some rows. To mark the rows for the user I set one (or more rows) to have</p> <pre><code>style="background-color: red;" </code></pre> <p>Is there a way to continue to use my existing way of striping rows yet leave that one row different? I want to say "Add the class alt to all even rows except when I tell you not to"</p>
jquery
[5]
5,313,993
5,313,994
Why am I forced to os.path.expanduser in python?
<p>I'm sure it's intentional, so can someone explain the rationale for this behavior:</p> <pre><code>Python 2.7.2 (default, Oct 13 2011, 15:27:47) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2 Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; from os.path import isdir,expanduser &gt;&gt;&gt; isdir("~amosa/pdb") False &gt;&gt;&gt; isdir(expanduser("~amosa/pdb")) True &gt;&gt;&gt; &gt;&gt;&gt; from os import chdir &gt;&gt;&gt; chdir("~amosa/pdb") Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; OSError: [Errno 2] No such file or directory: '~amosa/pdb' &gt;&gt;&gt; chdir(expanduser("~amosa/pdb")) &gt;&gt;&gt; </code></pre> <p>It's really annoying since, after all, the path with a username in it <em>can</em> be resolved unambiguously... I want to write code that can handle any sort of input that a user might give me, but this behavior requires me to call expanduser on every path my code has to deal with. It also means that anywhere I print that path out for the user to see, it will be slightly less legible than what they gave me.</p> <p>This seems inconsistent with the concept of "duck typing" in which I generalize to mean that I expect python not to whine to me unless there's actually a problem...</p>
python
[7]
455,886
455,887
Find out value of child custom control from parent custom control at client side
<p>How to find out the value of child custom control from parent custom control on client side.</p>
asp.net
[9]
4,635,394
4,635,395
StringBuilder performance in C#?
<p>I have a <code>StringBuilder</code> object where I am adding some strings like follows:</p> <p>I want to know which one is better approach here, first one is this:</p> <pre><code>StringBuilder sb = new StringBuilder(); sb.Append("Hello" + "How" + "are" + "you"); </code></pre> <p>and the second one is:</p> <pre><code>StringBuilder sb = new StringBuilder(); sb.Append("Hello").Append("How").Append("are").Append("you"); </code></pre>
c#
[0]
1,489,449
1,489,450
Android spinner prompt text not showing
<p>The first year from the data array is shown instead of the text from prompt in my spinner. I tried adding the prompt in XML, but I also tried from code. Furthermore, it gives me a "resource not found error", when adding the spinnerSelector attribute.</p> <h3>XML</h3> <pre><code>&lt;Spinner android:id="@+id/spinnerYear" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_marginLeft="10dip" android:layout_marginRight="10dip" android:drawSelectorOnTop="true" android:padding="5dip" android:prompt="@string/spinner_header" android:background="@drawable/selector_yearspinnerback" android:layout_below="@+id/linearLayout_gender_btns" android:layout_centerHorizontal="true"&gt;&lt;/Spinner&gt; -- android:spinnerSelector="@drawable/category_arrow" </code></pre> <h3>Code</h3> <pre><code>ArrayList&lt;String&gt; yearList = new ArrayList&lt;String&gt;(); int now = new Date().getYear() + 1900; for (int i = now; i &gt; now - 110; i--) { yearList.add(i + ""); } Spinner spinner = (Spinner) findViewById(R.id.spinnerYear); ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, yearList); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); </code></pre>
android
[4]
796,579
796,580
What is wrong with this code??? it says the error Identifier expected
<pre><code> public static Dictionary&lt;uint, Items.GroundItem&gt; ItemFilter(Client C, Dictionary&lt;uint, Items.GroundItem&gt; oggettiInteri) { Dictionary&lt;uint, string&gt; Filtr = new Dictionary&lt;uint, string&gt;(); Dictionary&lt;uint, Items.GroundItem&gt; Rientro = new Dictionary&lt;uint, Items.GroundItem&gt;(); if (C.Looting) Filtr = Program.RareItem; //Program doesnt contain defenition for Rare item else if (C.LootMoney) { Filtr.Add(1090020, "Money"); Filtr.Add(1091000, "Money"); Filtr.Add(1091010, "Money"); Filtr.Add(1091020, "Money"); } } </code></pre>
c#
[0]
473,944
473,945
Rand() function cause error when I replace static value with random value
<p>What am I doing wrong</p> <p>I have this script, and added the <code>$randnumber = rand(100, 500);</code> function to it, this should generate a random number for me between 100 and 500.</p> <pre><code> $randnumber = rand(100, 500); function word_limiter( $text, $limit = $randnumber, $chars = '0123456789' ) </code></pre> <p>The problem is that it gives me a error: </p> <blockquote> <p>Parse error: syntax error, unexpected T_VARIABLE</p> </blockquote> <p>While if I use the function as:</p> <pre><code>function word_limiter( $text, $limit = '200', $chars = '0123456789' ) </code></pre> <p>it works 100%, I have tried it like this:</p> <pre><code>function word_limiter( $text, $limit = ''.$randnumber.'', $chars = '0123456789' ) </code></pre> <p>but still get an error?</p>
php
[2]
1,204,848
1,204,849
how can i insert a break line after a ul element - using Jquery
<p>I would like to insert a br after the first UL element I have used both after and insertAfter but it inserts it multiple times. thanks in advance</p> <pre><code> &lt;div id="usual1"&gt; &lt;ul class="tabs1"&gt; &lt;li&gt;&lt;a href="#Home" class="selected"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#NewPages" class=""&gt;NewPages&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="NewPages" style="display: none;"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
2,520,758
2,520,759
can we send messages to user even when the application is closed in iphone sdk?
<p>i m making an application where data is accesed from website and displayed with an application.i have made an action which will tell the user that new data has arrived.this will work properly if the application is open .but if the application is closed than ,is there any way to tell the user that new data has arrived ,,so that he can open the application and check the data?</p>
iphone
[8]
1,670,891
1,670,892
cross-platform splitting of path in python
<p>I'd like something that has the same effect as this:</p> <pre><code>&gt;&gt;&gt; path = "/foo/bar/baz/file" &gt;&gt;&gt; path_split = path.rsplit('/')[1:] &gt;&gt;&gt; path_split ['foo', 'bar', 'baz', 'file'] </code></pre> <p>But that will work with Windows paths too. I know that there is an <code>os.path.split()</code> but that doesn't do what I want, and I didn't see anything that does.</p>
python
[7]
5,301,727
5,301,728
how to display the go back style UIBarButtonItem programmatically
<p>When One of my app nagivate from one controller ti another, the 'go back' UIBarButtonItem disappear, so I wrote codes:</p> <pre><code> UIBarButtonItem *barButton1 = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:self action:@selector(barButtonItemPressed:)]; self.navigationItem.leftBarButtonItem = barButton1; [barButton1 setImage:[UIImage imageNamed:@"fdj.png"]]; [barButton1 release]; </code></pre> <p>It works, but it display as</p> <p><img src="http://i.stack.imgur.com/8BdJ1.png" alt="enter image description here"></p> <p>but I prefer the style (like standard go back barbuttonitem</p> <p><img src="http://i.stack.imgur.com/efrPA.png" alt="enter image description here"></p> <p>Is it possible?</p> <p>Welcome any comment</p>
iphone
[8]
3,005,893
3,005,894
Intercept Phone Calls to display contact Info
<p>This question is more of a "is it possible" question.</p> <p>Is it possible for Android to use a different contact list from an application when displaying the identity of an incoming caller?</p> <p>So for example, if a person calls and their identity is in the apps contact list, but NOT in the internal devices contact list, i want to make the id found in the apps contact list show up on the caller id of the incoming call. </p> <p>Any insight would be appreciated! </p>
android
[4]
1,033,283
1,033,284
Help with __add__
<p>I am trying to understand how <code>__add__</code> works:</p> <pre><code>class MyNum: def __init__(self,num): self.num=num def __add__(self,other): return MyNum(self.num+other.num) def __str__(self): return str(self.num) </code></pre> <p>If I put them in a list</p> <pre><code>d=[MyNum(i) for i in range(10)] </code></pre> <p>this works</p> <pre><code>t=MyNum(0) for n in d: t=t+n print t </code></pre> <p>But this does not:</p> <pre><code>print sum(d) TypeError: unsupported operand type(s) for +: 'int' and 'instance' </code></pre> <p>What am I doing wrong? How can I get the <strong>sum()</strong> to work?</p> <p><strong>UPDATE</strong></p> <p>My problem is how to use the sum on a list of objects that support the <code>__add__</code>, need to keep it as generic as possible.</p>
python
[7]
2,660,445
2,660,446
A way to get at non-static information from Static Context
<p>I know you can't static members from instance members.</p> <p>But lets say I have in one assembly this:</p> <pre><code>public class ClassA { public List&lt;order&gt; GetOrders(int orderID) { ... } } </code></pre> <p>Then in another assembly this:</p> <pre><code>public static ClassB { private static void DoSomethingElse(int orderID) { List&lt;order&gt; orderList = ClassA.GetOrders(orderID); ...rest of code } } </code></pre> <p>Is there any way to still get at that method in Class A some other way...some work around to this?</p>
c#
[0]
3,425,124
3,425,125
Replace string using php preg_replace
<p>Hi all i know preg_replace can be used for formatting string but i need help in that concerned area my url will be like this</p> <p><a href="http://www.example.com/index.php/" rel="nofollow">http://www.example.com/index.php/</a><br> also remove the http,https,ftp....sites also</p> <p>what i want is to get result as</p> <p>example.com/index.php</p>
php
[2]
2,073,375
2,073,376
Javascript Date Sorting
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4365116/javascript-date-sorting-by-convert-the-string-in-to-date-format">Javascript date sorting by convert the string in to date format</a> </p> </blockquote> <p>Hi, </p> <pre><code>2010-11-08 18:58:50 2010-11-09 17:49:42 2010-11-09 17:49:42 2010-11-24 19:44:51 2010-11-09 13:54:46 2010-11-23 20:06:29 2010-11-23 20:06:04 2010-11-15 17:51:37 ..................... .............. .......... </code></pre> <p>like this i have n number of string formats .How can i convert these strings in to date format and sort accordingly....please</p> <p>Thanks in advance, Joseph </p>
javascript
[3]
732,801
732,802
ajax star rating control not updating
<p>i am using ajax based star rating control... i have created a usercontrol for it... on my page i have placed the usercontrol... their is strange behaviour... on rating_changedd event i set the readonly to true and update the database... but after postback when page reload it still allow me to update the rating... </p> <p>how can i make the star rating control readonly on postback?</p>
asp.net
[9]
1,491,152
1,491,153
How to set time range in a day using UIDatePickerView
<p>I am using UIDatePickerView, just like we can set the date range using "maximumDate" and "minimumDate", is there any way to set time range in a day like from 9.00 am to 6.00 pm ?</p>
iphone
[8]
2,953,535
2,953,536
"Minimal" source files to create Android app using Eclipse + ADT
<p>I am trying to understand the anatomy of a MINIMAL Android application, using Eclipse + ADT (Android Development Toolkit).</p> <p>Please can you advise what is the MINIMAL set of source files I need, for example :-</p> <pre><code>src / package / MainActivity.java res / layout / activity_main.xml res / menu / activity_main.xml (??) AndroidManifest.xml (any other source files needed?) </code></pre> <p>Please can you advise what is the MINIMAL that I need to put into each file in order for it to run on the AVD (Android Virtual Device) ?</p> <p>For example, which of these files needs to contain reference(s) to which other files, etc?</p> <p>Thank you for your time and help,</p> <p>Best regards,</p> <p>James</p>
android
[4]
3,635,976
3,635,977
Java: Do Thread pools execute tasks simultaneously or sequentially?
<p>My understanding of thread pool is that that when you pass a thread pool a method it picks a thread from its active pool and sends the method off to be executed. My understanding of a thread is that if you put some code in it, it will run through the code without stopping until it is told to sleep or stop.</p> <p>My question:</p> <p>When you pass several methods (of roughly equal length to execute) to a thread pool one after another does the thread pool manage sharing between the different threads being executed so that the tasks finish almost simultaneously or does it execute them one after another - for example, task 1 goes into thread 1, thread 1 starts executing it and thread 2 with task 2 in it hasn't had a chance to run until task task 1 has finished because thread 1 was running through the code it has been given without any explicit messages to sleep - so then thread 2 will execute and the tasks will essentially finish one after another.</p> <p><strong>Basically, do I have to explicitly make sure the code I give to a thread pool has a breaks in it for the threads to run simultaneously? Or do I get this for free when using a thread pool manager?</strong></p>
java
[1]
4,507,554
4,507,555
jQuery grab specific img src folder name
<p>So my img src generates like this <code>img/0001/name0001/img0001.jpg</code> and im trying to grab <code>/name0001/</code> only any idea ? thanks!</p> <p>my code:</p> <pre><code>var parent = $('.img'); $(parent, document).click(function() { var dirz = this.src; var dirb = dirz.split('/')[2]; alert(dirb); }); </code></pre> <p>it alerts with blank?</p>
jquery
[5]
2,924,572
2,924,573
show a message if the filename already exists
<p>I am using c# .net windows form application. i have to save few inputs in defaultsetting.xml file but if there is invalid file with same file name "defaultsetting.xml" i should show msg in the status bar.. How can I do this?</p>
c#
[0]
4,099,466
4,099,467
Cross-references and garbage collection
<p>There is an application with an extensive object graph. This graph mainly consists of a set of subgraphs which are connected to the rest of the graph through the only reference. But internally each such subgraph has some number of cross-references among objects. Once in a while such a sub graph needs to be thrown away. Would it be enough just to set to null the only referece which points to that subgraph to make it eligible for garbage collection?</p> <p>My concern is that internal cross-references may "protect" the entire subgraph from garbage collection. In other words, is the garbage collector wise enough to figure out that all references in a subgraph do not leave the boundaries of the subgraph and therefore entire subgraph can be purged.</p>
java
[1]
5,337,693
5,337,694
Hide function is not working
<p>I have simple hide and show function but it is not working. any help would be appreciated </p> <pre><code>&lt;head&gt; &lt;script type="text/javascript"&gt; $(function(){ $('a').click(function(){ var visible= false; if(visible){ $('div').hide('slow') } else { $('div').show('slow') } visible=!visible; }) }) &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div style="background:#F00; width:500px; height:50px"&gt;&lt;/div&gt; &lt;a href="#"&gt;hide&lt;/a&gt; &lt;div class="append"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre>
jquery
[5]
3,406,058
3,406,059
How can I create a carousel?
<p>I looked for answers on this, but I can not find an example that could help me. I am looking to do a carouselle of this form can finger-scroll with arrows.</p> <p><img src="http://i.stack.imgur.com/nRpsA.png" alt="enter image description here"></p> <p>Thanks for the help</p>
android
[4]
1,652,198
1,652,199
jquery, post multiple variables
<p>I am brand new to jquery and trying to modify a basic script from php academy.</p> <p>the jquery script is:</p> <pre><code>&lt;script type="text/javascript"&gt; function get() { $.post('getpeopleinjobs.php', { postvarfname: form.firstname.value, postvarlname: form.d = surname.value }, function(output) { $('#age').html(output).show(); }); } &lt;/script&gt; </code></pre> <p>and my form code is:</p> <pre><code> &lt;form name="form"&gt; &lt;input type="text" id="firstname"&gt; &lt;input type="text" id="surname"&gt; &lt;input type="button" value="get" onclick="get();"&gt; &lt;/form&gt; </code></pre> <p>This worked perfectly when I was passing just one variable and my code snippet was:</p> <pre><code>$.post('getpeopleinjobs.php', { postvarfname: form.firstname.value } </code></pre> <p>I then tried to add a second variable with </p> <pre><code>$.post('getpeopleinjobs.php', { postvarfname: form.firstname.value, postvarlname: form.d = surname.value } </code></pre> <p>It does not work now in Internet Explorer but interestingly enough it does work in Chrome?</p> <p>Any advice for the beginner?=</p>
jquery
[5]
3,452,591
3,452,592
Problem building following upgrade to Android 2.3
<p>I picked up the new 2.3 version of the SDK platform and tools, and when I build, I get eight instances of the error below. Then errors about missing resources. Presumably my resources have failed to build.</p> <pre><code>W/ResourceType( 8168): Bad XML block: header size 146 or total size 3145924 is larger than data size 0 </code></pre> <p>Googling indicates that perhaps a Clean would fix, but it does not.</p> <p>Googling also indicates that this error would be caused by a poorly formatted XML document, but I have not changed any resources since the upgrade (or for that matter any code), and the code was building and working fine pre-upgrade.</p> <p>Any idea what's up, or suggestions to troubleshoot?</p>
android
[4]
248,032
248,033
Display latest image in directory ending in
<p>I'd like to display the last modified image in a directory that ends in a specific way.</p> <p>I have it working to display the last file in the directory I only don't know how to go about filtering the result to only display the latest in the directory ending in "wide-block.jpg"</p> <pre><code>&lt;?php $base_url = 'images/folio/web-portfolio'; $newest_mtime = 0; $show_file = 'images/folio/no-image.jpg'; if ($handle = opendir($base_url)) { while (false !== ($latestFile = readdir($handle))) { if (($latestFile != '.') &amp;&amp; ($latestFile != '..') &amp;&amp; ($latestFile != '.htaccess')) { $mtime = filemtime("$base_url/$latestFile"); if ($mtime &gt; $newest_mtime) { $newest_mtime = $mtime; $show_file = "$base_url/$latestFile"; } } } } echo '&lt;img src="' .$show_file. '" alt="Latest from the web"&gt;'; ?&gt; </code></pre> <p>I got that code from somewhere else and realize it won't need the second if statement of != file types listed once my check of display the latest file ending in "wide-block.jpg".</p>
php
[2]
3,907,572
3,907,573
How do I convert a string into a variable reference?
<p>I have to add a lot of shared folders from a configuration file. the names are very long, but all ends in "Name", "Domain", "Username" and "Password".</p> <p>An example is:</p> <pre><code>AddSharedFolder( myConfigurationHandler.MyConfiguration.MyService.RSController.repositoryName, myConfigurationHandler.MyConfiguration.MyService.RSController.repositoryDomain, myConfigurationHandler.MyConfiguration.MyService.RSController.repositoryUsername, myConfigurationHandler.MyConfiguration.MyService.RSController.repositoryPassword); </code></pre> <p>My idea was to call it like</p> <pre><code>AddSharedFolder( "myConfigurationHandler.MyConfiguration.MyService.RSController.repository"); </code></pre> <p>Then have an overloaded AddSharedFolders method:</p> <pre><code>private static void AddSharedFolder(string prefix) { AddSharedFolder(prefix + "Name", prefix + "Domain", prefix + "Username", prefix + "Password"); } </code></pre> <p>Obviously the last method is wrong. But how do I convert the string into a variable name? Or is this a really dumb programming practice?</p>
c#
[0]
2,812,528
2,812,529
Remove all script elements using JS
<p>I am trying to remove all script elements from a HTML page. But for some reason, I can only remove about half of them using the below:</p> <pre><code>function t(){ var r = document.getElementsByTagName('script'); for (var i = 0; i &lt; r.length; i++) { if(r[i].getAttribute('id') != 'a'){ r[i].parentNode.removeChild(r[i]); } } } </code></pre> <p>I have that if condition so that I don't remove the executing script.</p> <p>I am essentially trying to create a <em>dynamic</em> Javascript dis-abler for my selenium tests.</p>
javascript
[3]
5,904,291
5,904,292
Merge two list with some order rule in python
<p>I don't know how to give an accurate title, but here's the problem.</p> <p>The problem:</p> <p>I want to give a ranking list (imagine some top list) with some position preserved already.</p> <p>Say I got 7 slots <code>[1, 2, 3, 4, 5, 6, 7, 8]</code> and some has already preserved postion 1, 3, 4, 7, 9. (As we only have 8 slots, the perserved postion 9 will means the last slot.)</p> <p>Then I have 2, 5, 6 slots left, which I have to fill them with other objects.</p> <p>The simplified question:</p> <p>I have two list:</p> <pre><code>&gt;&gt;&gt; a = [1, 3, 4, 7, 9] &gt;&gt;&gt; b = [object_x, object_y, object_z] </code></pre> <p>And I want to merge them to this:</p> <pre><code>&gt;&gt;&gt; c = [1, object_x, 3, 4, object_y, object_z, 7, 9] </code></pre> <p>(We can take the 'object_x' here as 0.)</p> <p>That's it, just want to see if there is an elegant way to implement this.</p> <p>(Edit whole question based on the comments. Thank you guys very much.)</p>
python
[7]
5,034,516
5,034,517
Handling network disconnect
<p>I am trying to do "long polling" with an HttpWebRequest object.</p> <p>In my C# app, I am making an HTTP GET request, using HttpWebRequest. And then afterwards, I wait for the response with beginGetResponse(). I am using ThreadPool.RegisterWaitForSingleObject to wait for the response, or to timeout (after 1 minute).</p> <p>I have set the target web server to take a long time to respond. So that, I have time to disconnect the network cable.</p> <p>After sending the request, I pull the network cable.</p> <p>Is there a way to get an exception when this happens? So I don't have to wait for the timeout?</p> <p>Instead of an exception, the timeout (from RegisterWaitForSingleObject) happens after the 1 minute timeout has expired.</p> <p>Is there a way to determine that the network connection went down? Currently, this situation is indistinguishable from the case where the web server takes more than 1 minute to respond.</p>
c#
[0]
2,866,292
2,866,293
Identifying a Javascript object
<p>I am having a problem identifying a javascript object</p> <pre><code>function A(x, y){ this.boo = function(){ } } var aa = new A("1", "2"); aa.boo(); </code></pre> <p>In the code, is 'aa' a javascript object? Does it inherit properties from object.prototype too? If yes, how can I be sure (from a novice).</p>
javascript
[3]
991,146
991,147
how to erase an image drawn by canvas?
<pre><code> @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub Log.d("dd","draw"); mBitmap=BitmapFactory.decodeResource(this.getResources(),R.drawable.image1); canvas.drawBitmap(mBitmap, srcRect,dstRect,null); mBitmaps=BitmapFactory.decodeResource(this.getResources(),R.drawable.paintball); canvas.drawBitmap(mBitmaps, 180,200,null); } </code></pre>
android
[4]
5,561,580
5,561,581
setTitle text appearance
<p>I'm using Theme.Dialog on one of my activities. I'm using setTitle(mMyTitle) to set the title. I would also like to set the textAppearance. How would I go about this?</p> <p>I'm not sure if I can make my own title layout for this, since I'm already using Theme.Dialog.</p>
android
[4]
4,736,963
4,736,964
Do return true; continue the script till end in the same function?
<p>My function goes something like this</p> <pre><code>function multiple_delete($checkbox, $table, $url, $picture1 = 0, $picture2 = 0, $picture3 = 0){ $count = count($checkbox); for($j=0;$j&lt;$count;$j++) { $delete_id = $checkbox[$j]; $query = "SELECT * FROM $table WHERE id = '$delete_id'"; $result = mysql_query($query); $row = mysql_fetch_array($result); return true; if( $picture1 !== 0 &amp;&amp; $picture2 !== 0 &amp;&amp; $picture3 !== 0) { $pic_1 = $picture1; $pic_2 = $picture2; $pic_3 = $picture3; unlink($pic_1); unlink($pic_2); unlink($pic_3); return true; } if( $picture1 !== 0 &amp;&amp; $picture2 !== 0 &amp;&amp; $picture3 == 0 ) { $pic_1 = $picture1; $pic_2 = $picture2; unlink($pic_1); unlink($pic_2); return true; } } for($i=0;$i&lt;$count;$i++) { $del_id = $checkbox[$i]; $sql = "DELETE FROM $table WHERE id='$del_id'"; $result_delete_data = mysql_query($sql); } alert('Deleted Successfully'); redirect_url($url); return true; } </code></pre> <p>In the above function if the first or second condition returns true, then will it continue over the for loop below or it will simply halt the script ? </p> <p>If return true will halt the script then</p> <p>EDIT: Is it ok if I remove the return statement from the if conditions? And is it necessary for us to define the return statement in a user defined function? </p>
php
[2]
4,383,647
4,383,648
javascript prev next fuction
<p>I have asp.net code as</p> <pre><code>&lt;div class='OuterDiv'&gt; &lt;div class='InnerDiv' id='product_827'&gt; &lt;a onclick="javascript:ajaxLightboxPopup(827,'', this)" href="javascript:void(0);" style='text-decoration: none;'&gt; &lt;img width='85' height='85' src='pngs/100942644.jpg' /&gt;&lt;div class='product-code' style='text-decoration: none;' width='120px'&gt; KWD 1.75 &lt;/div&gt; &lt;/a&gt; &lt;/div&gt; &lt;div class='InnerDiv' id='product_828'&gt; &lt;a onclick="javascript:ajaxLightboxPopup(828,'', this)" href="javascript:void(0);" style='text-decoration: none;'&gt; &lt;img width='85' height='85' src='pngs/101255432.jpg' /&gt;&lt;div class='product-code' style='text-decoration: none;' width='120px'&gt; KWD 2.25 &lt;/div&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and I have javascript function as </p> <pre><code>function ajaxLightboxPopup(productId, page, cntrl) { var pref = 'product_'; var prevElement = jQuery('#' + pref + productId).prev(); var prevElemHTML = prevElement.html(); } </code></pre> <p>here the requirement, My page containing 3 Outer Div and each outer div containing 5 innerDiv. The same inner div with same id will be repeated in more than outer div. When I var prevElement = jQuery('#' + pref + productId).prev(); statement to get previous element of innerdiv from 2 or 3 outer div its always points to Previous of inner div present in 1 outer div. How to solve this..</p>
javascript
[3]
2,126,733
2,126,734
How to make child page for each story of parent webpage.?
<p>I have posted stories from database to my view.php page.i want to link each story's title with its own webpage (child page of view.php page).for example..</p> <pre><code>view.php?id=123 </code></pre> <p>is linked to story no .1 and</p> <pre><code>view.php?id=124 </code></pre> <p>is linked to story no. 2</p> <p>thus i want to link each story to its own webpage ...</p>
php
[2]
2,149,145
2,149,146
How to prevent numbers in the input box and just display text?
<p>I found a script that works but I have no idea how it is working. </p> <p>The <code>split()</code> method this example uses is giving me painful headache. Does anyone have an idea of how that <code>split()</code> method is working in this example? Can we pass numbers as first argument to <code>split()</code> method? Is that a separator, if it is why is it not enclosed within quotes?</p> <p><strong>Script</strong></p> <pre><code>function noNumbers(field) { for ( var i = 0; i &lt; 10; i++ ) { field.value = field.value.split(i).join(""); } } </code></pre> <p><strong>HTML</strong> </p> <pre><code> &lt;form&gt; Type some text (numbers not allowed): &lt;input type="text" onkeyup="noNumbers(this);" /&gt; &lt;/form&gt; </code></pre>
javascript
[3]
5,994,382
5,994,383
Java Scaling Font with AffineTransform
<p>Anyone have an example snippet showing how to scale a Font using AffineTransform?</p> <p>Thanks.</p>
java
[1]
3,186,625
3,186,626
How to apply effects to only newly appended nodes (jQuery)
<p>I am loading in html via AJAX and appending it to a DIV but I want to be able to select the newly loaded in html and apply a hide().fadeIn() to elements in that newly appended html.</p> <p>Current function looks something like this</p> <pre><code>wall = new Object(); wall.showWall = function (options) { // Use this to initiate the comment wall $.ajax({ url: "activity_results.html?"+options, cache: false, success: function(html){ $("#comments .loader").hide(); // The wall's comment spinner requestStuff.showResponse(); // Trigger the addComment function if (!options){ // Make sure we are not paging wall.showMore(); } $("#comments").append(html).hide().fadeIn("slow"); } }); } </code></pre> <p>When new html gets loaded into #comments I want to be able to only fade in those nodes.</p>
jquery
[5]
3,950,063
3,950,064
where can i host PHP Zend framework application?
<p>I've created a PHP Zend framework based application and would like to test it by hosting it somewhere. Can anyone please tell me if any free webhost providers exist that has support for zend framework ?</p> <p>Your help's really appreciated.</p>
php
[2]
4,118,350
4,118,351
Jquery: add one line to each class
<p>I have class <code>dot</code> and have html code like that:</p> <pre><code>&lt;span class="dot"&gt;Text1&lt;/span&gt; &lt;span class="dot"&gt;Text2&lt;/span&gt; &lt;span class="dot"&gt;Text3&lt;/span&gt; </code></pre> <p>I want to add to each element who has class <code>dot</code> additional text automatically. For example, add <code>&amp;#8226;</code> code that it would be </p> <pre><code>&lt;span class="dot"&gt;&amp;#8226; Text1&lt;/span&gt; &lt;span class="dot"&gt;&amp;#8226; Text2&lt;/span&gt; &lt;span class="dot"&gt;&amp;#8226; Text3&lt;/span&gt; </code></pre> <p>I imagine it should be done with jquery, so any help?</p> <p>Thanks.</p>
jquery
[5]
5,010,622
5,010,623
When would one use the BRICK permission?
<p>In Android, there used to be a permission with the name <a href="http://developer.android.com/reference/android/Manifest.permission.html#BRICK">BRICK</a> that could be used to potentially disable the device. Other than hearing it as an urban myth, I do not really know if this permission can really be used to brick a device. </p> <p>All I can think of are the following reasons:</p> <ul> <li>To build a <a href="http://en.wikipedia.org/wiki/LoJack">LoJack</a> kind of an application that can remote disable a phone should it discover that the phone was stolen. </li> <li>For enterprises to be able to remote-wipe a phone should the phone get lost somewhere.</li> </ul> <p>Is there any other sane reason why a third-party app would require to use it? And why was it removed (not sure) from GingerBread?</p> <p>Also, what does it really do anyways? Reset the phone to its factory settings? </p>
android
[4]
5,323,197
5,323,198
jQuery val() function not replacing String correctly
<p>So how the code was supposed to work is that "Logged in as" is being replaced by "Hello":</p> <pre><code>$("strong:contains('Logged in as:')").val(function (i, w) { return w.replace("Logged in as:", "Hello"); }); </code></pre>
jquery
[5]
3,389,816
3,389,817
Block USB mass Storge or USB Port pro grammatically?
<p>I am working on Device Administrator application,As per requirement I have to block the USB port or USB Storage to prevent device communication through USB.Is it possible to do with Java code? -please share me any sample code or Docs. Thanks in advance..</p>
android
[4]
2,416,463
2,416,464
a total sum of 2 textviews
<pre><code>private int ScoreCount; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.score); final TextView TotalScore = (TextView) findViewById(R.id.TotalScore); final TextView One = (TextView) findViewById(R.id.Score1); One.setOnClickListener(new OnClickListener() { public void onClick(View v) { ScoreCount++; Front9.setText("" + ScoreCount); } }); </code></pre> <p>If i fill a random number in both textviews, i want a sum of the 2 numbers in the totalscore. how do i do that. is the code i added the right way to do this. i know that the onclicklistener is not the right way but what to use instead.</p> <p><img src="http://i.stack.imgur.com/8M4zi.png" alt="enter image description here"></p>
android
[4]
579,759
579,760
string::erase() gives different result in linux/windows
<p>I have a piece of code which reads in a line from a file, then removes the whitespace and tells you the length of the string. In windows it works as I expect it to, however in linux it returns a different result.</p> <p>Code:</p> <pre><code> // Find how many characters are in the first line std::string line; std::ifstream map ("level1.map"); getline(map,line); // Remove whitespace from the string to get the useful length of line for ( unsigned int i = 0, j ; i &lt; line.length( ) ; ++ i ) { if ( line [i] == ' ' ) { for ( j = i + 1; j &lt; line.length ( ) ; ++j ) { if ( line [j] != ' ' ) break ; } cout &lt;&lt; j; line = line.erase ( i, (j - i) ) ; } } // Output cout &lt;&lt; line.size() &lt;&lt; endl; </code></pre> <p>It's essentially just trying to determine how many tile columns there are in the map file, where the map is formatted thusly on each line:</p> <p>2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2</p> <p>And so whitespace needs to be removed.</p> <p>In windows given an initial line length of 160 the end length is 80, however when compiled in linux the initial length is 160, but the end length is 81. The only place the value becomes different appears to be after line = line.erase ( i, (j - i) ) ;</p> <p>Any ideas why this is happening?</p>
c++
[6]
2,222,524
2,222,525
Packing values into a single int
<p>Let's say I have a couple of variables like apple, orange, banana</p> <p>I have 8 apples, 1 orange, 4 bananas.</p> <p>Is it possible to somehow convert those values into a single integer and also revert back to their original values based on the computed integer value?</p> <p>I found an example online.</p> <pre><code>int age, gender, height; short packed_info; . . . // packing packed_info = (((age &lt;&lt; 1) | gender) &lt;&lt; 7) | height; . . . // unpacking height = packed_info &amp; 0x7f; gender = (packed_info &gt;&gt;&gt; 7) &amp; 1; age = (packed_info &gt;&gt;&gt; 8); </code></pre> <p>But it doesn't seem to work as it should when I entered random numbers.</p>
java
[1]
1,130,928
1,130,929
Resources NotFoundException?
<p>I'm getting crash reports from android marketplace:</p> <pre><code>android.content.res.Resources$NotFoundException: Resource ID #0x.... </code></pre> <p>I get about 17 of these a week. It's pointing me to the following in my code:</p> <pre><code>context.getResources().getDrawable(R.drawable.foo); </code></pre> <p>That resource is definitely present in my /drawable folder. I have several hundred thousand installs, I'm not sure how this could be failing for some users, but working for the vast majority. I'd like to find out what's going on, because they can't use the app in this state. Any ideas?</p> <p>Thanks</p> <p>--------- Update ----------------------</p> <p>Also I can see the entry for the drawable in question in my R.java file, looks like:</p> <pre><code>public static final int foo=0x7f020034; </code></pre> <p>I do a clean build of the project, then straight after that do my release build (no code modification in between to give the automatic eclipse build stuff possibly let the R file go awry)</p> <p>Thanks</p>
android
[4]
5,222,944
5,222,945
How do I create a help overlay like you see in a few Android apps and ICS?
<p>I am wanting to create help overlays like the ones you see when ICS loads for the first time or in apps like ES File Explorer or Apex Launcher (there are more, but I can't think of them right now). Is this just a relative layout with one view sitting on top of the other? I haven't been able to find any sample code for doing such a thing. Anyone know how this is done or have any ideas?</p> <p><img src="http://i.stack.imgur.com/4CCh0.png" alt="ES File Explorer"> <img src="http://i.stack.imgur.com/Sx19T.png" alt="ES File Explorer"></p>
android
[4]
5,810,994
5,810,995
Code echoing a \n somehow
<p>I am using the following code to share my sessions between PHP and Node.JS.</p> <p><a href="http://pastie.org/4874088" rel="nofollow">http://pastie.org/4874088</a></p> <p>What the problem is, is that as I have to include it at the beginning of every script, I get a weird problem:</p> <p>Basically somewhere along that code there is <strong>something</strong> that <strong>is echoing a new line</strong>, breaking some AJAX functions that I use (sharing small text bits between client and server).</p> <p>I am having a hard time finding this ugly line; can you find it?</p> <p>It is important to note that the line must be exactly in this file and not in</p> <pre><code>require("$appDirectory/vars/lib/Predis/Autoloader.php"); </code></pre> <p>as I tried removing the predis client, too.</p> <p>Thanks in advance.</p> <p>Screenshot: <a href="http://imgur.com/RSpyA" rel="nofollow">imgur.com/RSpyA</a> : line 1 is the problem:</p> <p><img src="http://i.stack.imgur.com/WOZyJ.png" alt="enter image description here"></p>
php
[2]
4,222,033
4,222,034
Accessing Label inside a Row in JQuery
<p>I have a textbox and labels inside rows of a table. To access the textbox I'm using<br> <code>data= $(this).find('#txtName').val();</code></p> <p>Now I'm not able to access the label in the same way. The label is rendered as<br> <code>&lt;label for="Total"&gt;$65.00&lt;/label&gt;</code></p> <p>How can I access the label's value and assign a value to it?</p>
jquery
[5]
5,779,181
5,779,182
JQUERY - Waiting for window.location.href to Complete
<p>I am using the following line to kick off main.php which loads an iframe:</p> <pre><code> window.location.href = '/main.php?token='+obj.token; </code></pre> <p>I need to wait for the iframe to complete loading so the $_GET token can be obtained.</p> <p>After this I want to run the below line to remove the token from the command line:</p> <pre><code> window.history.pushState("object or string", "Title", "/new-url"); </code></pre> <p>At the moment pushState always fires to quickly and then token is lost. Is there a way to delay this until the iframe is completely loaded? Don't want to use a timer as it might not work sometimes.</p> <p>thx</p>
jquery
[5]
68,730
68,731
Read asp.net Page Import Directive at runtime
<p>Is there any way to read the asp.net Import directives at runtime? I have an ExpressionBuilder that is passed a number of class names. Right now I have to fully qulify these names but if I could read the namespaces from within the ExpressionBuilder, I can save myself a lot of typeing...</p> <pre><code>&lt;%@ Import namespace="MyNameSpace.Data.Library" %&gt; </code></pre> <p>// // </p> <pre><code>string GetNamespace() { return Page.blablabla(); // MyNameSpace.Data.Library } </code></pre> <p>a bit more info:</p> <p>I am using System.Web.BuildManager.GetType() to get the type of my object. When does (or can it) somehow reference the Import directives?</p>
asp.net
[9]
4,106,352
4,106,353
How can I convert the special character \u0097 into NsString?
<p>How can I convert the special character <code>\u0097</code> into NsString?</p>
iphone
[8]
3,093,345
3,093,346
IF- ELSE condition - run the code in the ELSE section
<p>I have got the following IF condition code:</p> <pre><code>if ((depth &lt;= min_depth ) &amp;&amp; (leaf_colour == "red")){ for (i = 0; i &lt; array_2D.length; i++) { var leaf_size = array_2D[i][1]; if (leaf_size == 10 || leaf_size == 11){ alert("Error message."); break; // we found an error, displayed error message and now leave the loop } else{ go to the next else section } } }//end of if condition else{ ... ... ... ... ... } </code></pre> <p>Inside the 'FOR' loop, if (leaf_size == 10 || leaf_size == 11), we break the loop and do nothing but if this is not the case, i would like to run the code in the next ELSE section.</p> <p>I do not want to copy the whole block of code and paste it inside the 'else' section of the for loop as it's quite long.</p> <p>Is there a way of running the code in the second else section?</p>
javascript
[3]
1,598,330
1,598,331
XML Parsing.....is AML is supported in iPhone
<p>I m comfortable with XML Parsing....but my response is coming in AML Aras markup language...could any one let me know,,is AML is supported by iPhone...if YES how can i Parse AML response.....appropriate code will be appreaciated</p> <p>Thank you in advance</p>
iphone
[8]
4,864,785
4,864,786
Monitor apps power usage
<p>Is there a way to programmatically access the <code>settings-&gt;about phone-&gt;battery usage</code> stuff? We'd like to monitor how much power our app is using.</p>
android
[4]
4,311,752
4,311,753
Developing FM App for android
<p>Is this possible to develop FM App for android just like how we using in all mobiles?. I'm staying in Bangalore, Karnataka, India and here FM channels are like Radio Indigo (91.90MHz), Radio One (94.30MHz), Radio City (91.10MHz) and others, so i want to access these channels from my app. Is there any tutorial link or suggestions will be appreciated.</p>
android
[4]
3,317,007
3,317,008
Format as currency in Javascript
<p>I have a variable which is made up of a multiplication of 2 more variables</p> <pre><code> var EstimatedTotal = GetNumeric(ServiceLevel) * GetNumeric(EstimatedCoreHours); </code></pre> <p>Is it possible, and if so how, or what is the function called to format this as currency? I've been googling only I cant find a function and the only ways I've seen are really, really long winded</p>
javascript
[3]
4,033,805
4,033,806
How to set the WebChromeClient to open the new page in the same view?
<p>I load the url in the WebView but, when the user click some button the new url is loaded in the android browser not in my webview. What should I do?</p> <p>Thanks in advance.</p>
android
[4]
4,452,448
4,452,449
Exact Word Regex
<p>I used this from another question that I asked (<a href="http://stackoverflow.com/questions/12908277/whole-word-php-regex">Whole Word PHP Regex</a>)</p> <pre><code>$partnumber = "4.7585"; $productname = "Eibach 4.7585.880 Sport Plus Kit"; if(preg_match('/[^\B\.]'.preg_quote($partnumber).'[^\B\.]/i', $productname)){ echo "****************Exact Match****************"; } </code></pre> <p>It seems to work great except for the following example: </p> <pre><code>$partnumber = "19150"; $productname = "PIAA 9150 Lamps - Deno-2 LED"; if(preg_match('/[^\B\.]'.preg_quote($partnumber).'[^\B\.]/i', $productname)){ echo "******************Exact Match******************"; } </code></pre> <p>That is returning as an exact result. Not sure why. Any ideas?</p>
php
[2]
3,554,778
3,554,779
@property @synthesize
<p>Why you do @synthesize and @property things on Xcode? What is the explanation in really simple terms?</p>
iphone
[8]
940,035
940,036
How to completely black out background on Android dialog?
<p>I am showing an Activity with dialog theme (android:theme="@android:style/Theme.Dialog")</p> <p>When I pop up this activity, I want to completely blacken out the background activity. Currently, the activity underneath has too much clutter, and even though it is blurred, it is still too visible.</p> <p>Thanks.</p>
android
[4]
1,628,982
1,628,983
adjusting container position with scrolling
<p>I am attempting to make it so that a set of elements in a div container constantly are present in the a Viewport. I have tried a couple of different approaches but they seem to have repainting issues.</p> <p><strong>Question:</strong> Any major optimizations to improve performance and remove the visual side effects that stand out? If not, then any alternative approaches?</p> <p>First approach:</p> <pre><code> $(viewport).scroll(function () { m_grid.css({ 'marginTop': viewport.scrollTop() + 'px' }); }) </code></pre> <p>This one causes tiny shaking effects that are obvious to the user.</p> <p>Second approach:</p> <ul> <li>Place a div below and above the contents, shrink and expand them with a little rudimentary math to fill the unused space of the scrollable container.</li> </ul> <p>Issue with this approach was that it causes flickering at the edges of the content most likely due to the constant resizing.</p> <p>Third approach:</p> <ul> <li>Place a div that mimics the scrolling behavior directly over where the original scrollbar would be then simple bind scrolling events to it that forwards them to the actual container.</li> </ul> <p>Issue with this one is that since the div that actually performs the scrolling is a fake, the mouse wheel wouldn't be usable since it would not have focus when hovering over the elements in the viewport.</p> <p>Any thoughts on improvements or alternate approaches? It has to be performance-centric.</p>
javascript
[3]
3,083,272
3,083,273
Debug android application
<p>I am developing an Android application where I get the following exception while writing to the database:</p> <pre><code>An exception occurred: android.database.sqlite.SQLiteException </code></pre> <p>But it doest say anything else(not even the stack trace). </p> <p>In general I find it very difficult to debug android SDK exceptions.</p> <p>Any suggestions/tips on how to debug while developing android applications?</p> <ul> <li>I am using Eclipse to develop the application. </li> </ul>
android
[4]
2,390,383
2,390,384
target previous $this
<p>How do I target $this (from 'each' context) from inside 'click' function. I want to remove awkward .parents().find() code.</p> <pre><code>$('.layout.responsive').each(function () { $('.area.optional', this).before('&lt;a href="#" class="toggle_responsive" onClick="return false"&gt;Show details&lt;/p&gt;').hide(); $('.toggle_responsive', this).click(function () { $(this).parents('.layout.responsive').find('.area.optional').toggle(); }); }); </code></pre>
jquery
[5]
5,734,804
5,734,805
How to loop through an array that is nested within an object?
<p>I'm trying to get the contents of data within the subject array using jquery. How can this be done ? I tried using <code>$.each</code> but couldn't get the contents . </p> <pre><code> "student": { "name": "sdfdsf", "age": 3, "subject": [ { "science": "dfsdfdfd", "book": "sdfds" }, { "math": "vbcb", "book": "sdfds" } ] } </code></pre>
jquery
[5]