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
120,859
120,860
Why my index == "string" is not working in JS?
<p>I have a problem with an equal statement in Javascript. Look at this screenshot:</p> <p><img src="http://i.stack.imgur.com/cCLpA.png" alt="enter image description here"></p> <p>I am trying to check whether index is the same as "Delete", but it is never true. It also is not true if I try <code>index === "Delete"</code> or <code>index == "Delete"</code>.</p>
javascript
[3]
3,984,072
3,984,073
We Have a countdown timer in java script
<p>We Have a countdown timer in java script ,the problem we are facing right now is when a other user opens the same page he is not able to see the updated version or timer which r running right now ,can you pls suggest some solution </p>
javascript
[3]
5,506,106
5,506,107
How to create javascript function lookup object?
<p>I'm attempting to create a function lookup in Javascript essentially mapping a data type to a function that does something for that data type. Right now I have something similar to:</p> <pre><code>var Namespace = Namespace || {}; Namespace.MyObj = function () { var stringFunc = function(someData) { //Do some string stuff with someData }; var intFunc = function(someData) { //Do some int stuff with someData }; var myLookUp = { 'string': stringFunc, 'int' : intFunc }; return { PublicMethod: function (dataType, someData) { myLookUp[dataType](someData); } }; } (); </code></pre> <p>When I invoke <code>Namespace.MyObj.PublicMethod(dataType, someData)</code> I get an error that myLookUp is not defined. I'm assuming I'm not going about setting up the function lookup object correctly, but not sure how to do so. Thanks for any help.</p>
javascript
[3]
557,523
557,524
Simplify a Fraction
<p>How can I simplify a fraction in PHP?</p> <p>For instance, converting <code>40/100</code> to <code>2/5</code>.</p> <p>The only way I could think of is to do a prime factorization on both numbers and compare like results, but I'm not really sure how to do that either.</p>
php
[2]
5,382,987
5,382,988
Disable button unless bot selectors have value
<p>OK, I have two HTML select elements and a button. I need to disable the button unless <strong>both</strong> of the selectors have any but default (na) values.</p> <p>I've got this so far, but it doesn't really work. What am I missing? </p> <p><strong>JS</strong></p> <pre><code>function toggleBtn() { if($(".mySelect").val() == "na") { $(this).parents("td").find("input:button").attr("disabled", "disabled"); } else { $(this).parents("td").find("input:button").attr("disabled", ""); } }); toggleBtn(); $(".mySelect").change(toggleBtn()); </code></pre> <p><strong>HTML</strong></p> <pre><code>&lt;table&gt; &lt;tr&gt; &lt;td&gt; &lt;select class="mySelect"&gt; &lt;option value="na"&gt;&lt;/option&gt; &lt;option value="1"&gt;value 1&lt;/option&gt; &lt;option value="2"&gt;value 2&lt;/option&gt; &lt;/select&gt; &lt;select class="mySelect"&gt; &lt;option value="na"&gt;&lt;/option&gt; &lt;option value="3"&gt;value 3&lt;/option&gt; &lt;option value="4"&gt;value 4&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;input type="button" value="click me"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
jquery
[5]
5,783,473
5,783,474
Play RTMP video streaming on android videoview
<p>I just wanna play an rtmp video streaming in android videoview or android default player.ex "rtmp://cp67126.edgefcs.net/ondemand/mediapm/osmf/content/test/akamai_10_year_f8_512K ".How could i do tht?Examples are much better..</p> <p>Thanks.</p>
android
[4]
2,698,674
2,698,675
Java search functionality
<p>There is a requirement in my Java project where the user will enter the customer name/ number in the front-end screen and hit search button, the system should display all the matching customer names with links to the customer details. I have been asked to write </p> <p>a web service to implement this functionality which will fetch the customer records from the database and display it in the front-end. </p> <p>Please help me how to do this. thanks in advance!!</p>
java
[1]
2,808,688
2,808,689
preg_match returns empty array
<p>i always use preg_match and it always works fine</p> <p>but today i was trying to get a content between two html tags <code>&lt;code: 1&gt;DATA&lt;/code&gt;</code></p> <p>And i've a problem</p> <p>my code will explain my problem</p> <pre><code>function findThis($data){ preg_match_all("/\&lt;code: (.*?)\&gt;(.*?)\&lt;\/code\&gt;/i",$data,$conditions); return $conditions; } /* plain text working fine */ $data1='Some text...Some.. Te&lt;code: 1&gt;This is a php code&lt;/code&gt;'; /* A text with a new lines Not working.. */ $data2='some text.. some.. te &lt;code: 1&gt; This is a php code .. &lt;/code&gt; '; print_r(findThis($data1)); /* OUTPUT [0][0] =&gt; &lt;code: 1&gt;This is a php code&lt;/code&gt; [1][0] =&gt; 1 [2][0] =&gt; This is a php code */ print_r(findThis($data2)); /* OUTPUT Nothing!!!!!!! */ </code></pre>
php
[2]
1,953,229
1,953,230
need a jquery code example: connect a sortable list to another sortable list located in an iframe
<p>I need a simple and clear JQuery code example (using Sortable UI) of how to connect two sortable lists, one of which is located in an iframe. </p> <p>Please consider the below example. One sortable list (#sortable1) is in the main document. The other sortable list(#sortable2) is in the iframe. I need to be able to drag items from one list to another and vice versa.</p> <pre><code>&lt;ul id="sortable1"&gt; &lt;li&gt;item 1&lt;/li&gt; &lt;li&gt;item2&lt;/li&gt; &lt;/ul&gt; &lt;iframe src="sortable2.html"&gt;&lt;/iframe&gt; </code></pre> <p>Contents of "sortable2.html"</p> <pre><code>&lt;ul id="sortable2"&gt; &lt;li&gt;item 1&lt;/li&gt; &lt;li&gt;item2&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I'll be very grateful if someone could post a working example. I'm sure it'll be helpful to many other people. </p> <p>Thank you in advance!</p>
jquery
[5]
3,042,440
3,042,441
unix timestamp conversion results not accurate php
<p>I am trying to convert a unix timestamp into readable text. The timestamp is stored in a database and shown in a table. The problem is the results are not accurate. <hr /> <strong>Code:</strong></p> <pre><code>&lt;td&gt;'.date("F j, Y, g:i a", strtotime($row['expire'])).'&lt;/td&gt; </code></pre> <p><hr /> <strong>database:</strong></p> <p><img src="http://i.stack.imgur.com/xWpiG.png" alt="enter image description here"> <hr /> <strong>Result:</strong></p> <p><img src="http://i.stack.imgur.com/vpbYx.png" alt="enter image description here"></p>
php
[2]
5,866,185
5,866,186
How to identify data is Encoded using Server.UrlEncode() Asp.net
<p>Can we identify whether input data is Encoded using <strong>Server.UrlEncode()</strong> method or not? <br /> I am looking for something like "<strong>Server.IsUrlEncoded</strong>"?</p>
asp.net
[9]
559,009
559,010
date_default_timezone_set showing incorrect time
<p>I uploaded the following to a server in the US:</p> <pre><code>date_default_timezone_set('Asia/Calcutta'); echo date("Y-m-d H:i:s"); // time in India </code></pre> <p>The time displayed is 15 minutes prior to that of the actual time in India. </p> <p>What am I doing wrong here? What code will <strong>always</strong> show the time in India accurate to the second?</p>
php
[2]
1,961,890
1,961,891
How to know when a View has scrolled into view
<p>We are currently developing an app that displays large data sets in "registers" and in rows. We are using a TableLayout as the base view and then adding table rows for every item (with a LinearLayout in each row).</p> <p>I have noticed that once the amount of records get beyond a certain point (1000+ records), the device slows down tremendously. I am sure that this is a simple memory issue(maybe rendering too?) and have devised a plan that could increase the speed.</p> <p>We have implemented continuous paging on a lot of silverlight projects, and I figure that this is the best approach to take in Android?</p> <p>The only problem I have now is to recognize when a specific view (say row 100) has been scrolled into view, so that I can start to render the next couple of lines.</p> <p>Does anyone know how to do this, or of a better way to implement/handle large data sets?</p> <p>Regards</p>
android
[4]
1,874,663
1,874,664
How to create a list of all built-in PHP functions a project makes use of?
<p>Background: PHP allows providers to disable functions (directive "disable_functions"). So in order to get to know if your project is running on a specific server you'll have to check:</p> <ol> <li>What built-in (=excluding user-defined) functions is your to-be-deployed project using?</li> <li>Are the functions available on the specific host?</li> </ol> <p>(Question (2) is a trivial loop over the result (1) with <code>function_exists</code>.)</p> <p>In order to get the harvesting working (=a mostly complete set of built-in functions used on the development servers) one could create a list of functions with <code>get_loaded_extensions()</code>, <code>get_extension_funcs()</code> and <code>get_defined_functions()</code> (and access it's 'internal' array for the built-in functions).</p> <p>Now the question: How would you extract/grep the built-in PHP functions used in the project from your (possibly hundreds of) source files?</p> <p>It could be a nice PERL job or somethig like that. How would you do it?</p>
php
[2]
4,113,546
4,113,547
how to use if else conditon on button press based on image of button?
<p>I am trying to use some logics on the base of button click.i use button as checkmark and when i click on this check mark the image of button changed into checked.png or unchecked.png.On that basis i use this code...</p> <pre><code>if([UIImage imageNamed:@"checkbox_ticked.png"]) { isActiveStr=[arrayPickerData objectAtIndex:17]; NSLog(@" is active value is %@ ",isActiveStr); isActiveStr=nil; } else { NSLog(@"no vlaue send"); isActiveStr=[[NSMutableString alloc]initWithString:@"1"]; NSLog(@" is active value %@",isActiveStr); } </code></pre> <p>Now i dont know how to use the else condtion...i run this code but it always run only if codition.It never goes in else conditon.I want that i codtion is true it goes in if part and when condition is false it goes in else part.And how i use image property of button to check the condition.</p>
iphone
[8]
514,507
514,508
java Inverse BigInteger?
<p>I know : p,b,g,</p> <pre><code>(g^(a*b)) mod p = X </code></pre> <p>b,p,g is BigInteger</p> <p>Now I want compute : <code>g^a mod p</code></p> <pre><code>{X^(b^-1)} mod p = g^(a*b*(b^-1))) mod p = g^a mod p </code></pre> <p>In java <code>BigInteger</code> have only <code>modInverse(BigInteger m)</code> Returns a <code>BigInteger</code> whose value is <code>(this^-1 mod m).</code></p> <p>How to compute <code>b^-1</code> in java <code>BigInteger</code>?</p>
java
[1]
3,945,378
3,945,379
Sticky jquery selected option
<p>I have a page that shows users info like address, phone, name, etc., but the phone field is a select option where I can choose between (Phone,<br> For each user I have a select option:</p> <pre><code>&lt;select class="smpullinput" id="middle_column_type&lt;? echo $idtable; ?&gt;"&gt; &lt;option id="Phone" value="Phone"&gt;Phone&lt;/option&gt; &lt;option id="Office" value="Office"&gt;Office&lt;/option&gt; &lt;option id="Cellphone" value="Cellphone"&gt;Cellphone&lt;/option&gt; &lt;/select&gt; //$idtable its just an ID </code></pre> <p>And then I display the data using simple jquery:</p> <pre><code>var idtable = &lt;?=$idtable?&gt;; $('#middle_column_type'+idtable).change(function() { if( $('#middle_column_type'+idtable).val()=="Phone" ) { $("#disp_p"+idtable).html(varp).show(); } if( $('#middle_column_type'+idtable).val()=="Office" ) { $("#disp_o"+idtable).html(varo).show(); } if( $('#middle_column_type'+idtable).val()=="Cellphone" ) { $("#disp_c"+idtable).html(varc).show(); } }); </code></pre> <p>And I use span to display the phones. What I want now is to have a "sticky" select option, that if I change the select box to Cellphone in any user the other users get the new option, I know that in order to do that I need to use my class="smpullinput" (in my case) I tried some stuff that did not work. Not sure if I was clear enough?</p> <p>Thanks</p>
jquery
[5]
3,903,229
3,903,230
Javascript,auto refresh
<p>i currently am using the below javascript code below, </p> <pre><code> &lt;script type="text/javascript"&gt; function PrintWindow() { window.print(); CheckWindowState(); } function CheckWindowState() { if(document.readyState=="complete") { window.close(); } else { setTimeout("CheckWindowState()", 2000) } } PrintWindow(); //window.onfocus = function() { window.close(); } // Trying to auto refresh the page after 3 seconds of no use. function setIdle(cb, seconds) { var timer; var interval = seconds * 1000; function refresh() { clearInterval(timer); timer = setTimeout(cb, interval); }; $(document).on('keypress, click', refresh); refresh(); } setIdle(function() { location.href = location.href; }, 3); &lt;/script&gt; </code></pre> <p>My original question was how to go home when the print box was finished but was told this was impossible, so i am now wondering how to auto refresh the page after so many seconds have passed, i have added in code to do this but it is not working</p> <p>i have now managed to fix it, if any one is wondering :</p> <p>var timer = null;</p> <pre><code>function goAway() { clearTimeout(timer); timer = setTimeout(function() { window.location = 'http://localhost:8080/fileuploadWithPreview'; }, 5); } window.addEventListener('mousemove', goAway, true); goAway(); // start the first timer off </code></pre> <p>This when the window is closed takes me to the home page so it is possible to do</p>
javascript
[3]
4,460,417
4,460,418
Java - is `null` an instance of `object`?
<p>I read that null isn't an <code>instanceof</code> anything, but on the other hand that <strong>everything</strong> in Java extends <code>objects</code>.</p>
java
[1]
1,200,667
1,200,668
Cumulative count of unique values in a dictionary
<p>I have a huge dictionary dd{} where I have people and sets of fruits they prefer:</p> <pre><code>A set(['Apple', 'Orange', 'Strawberries']) B set(['Banana', 'Strawberries', 'Orange', 'Kiwi', 'Dates']) C set(['Apple', 'Kiwi', 'Grapes']) A set(['Banana', 'Orange', 'Apple', 'Lemon']) </code></pre> <p>I want a cumulative count for the fruits, meaning for the 1st person, the number of his preferred fruits, for the 2nd person, the number of fruits belonging to the previous person PLUS the number of his own preferred fruits that didn't exist in the previous person's set and so on. I want to have a result like this:</p> <pre><code>1 3 2 6 3 7 4 8 </code></pre> <p>The incrementing numbers in the first column are the persons and the second column the cumulative number of the fruits. How do I implement this in Python? Thanks, Adia.</p>
python
[7]
5,813,022
5,813,023
Inserting HTML as a last child of a selected tag using JQuery
<p>I am new to JQuery. I'm reading JQuery in action, but only up to page 39 and need some quick help!</p> <p>Please note: I'm simplifying my actual requirement, so what I'm asking for may sound odd but I'm just tryin to get to the crux of the JQuery expression and not my situation (related to an animation plugin).</p> <p>I have my HTML code (which is generated and I dont want to change) :</p> <pre><code>&lt;div class="favorite"&gt; &lt;div&gt; &lt;a href='http://www.stackoverflow.com'&gt;Stackoverflow&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Now that I want to do is insert the text '(favorite)' INSIDE the A tag after the current contents. Or in other words as the last child of the <code>&lt;a&gt;</code>.</p> <pre><code>&lt;div class="favorite"&gt; &lt;div&gt; &lt;a href='http://www.stackoverflow.com'&gt;Stackoverflow (favorite)&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The best I have so far is this :</p> <pre><code>$('&lt;span&gt; (favorite)&lt;/span&gt;').insertAfter('.favorite div a'); </code></pre> <p>Of course this ends up putting the (favorite) text OUTSIDE the A link and it wont be underlined (which I want). </p> <p>I need to somehow say .parent().lastChild() but I'm not quite sure how to do that.</p> <p>Note: I had to put <code>&lt;span&gt;</code> in because otherwise it didnt see it as 'insertable' text. I'm sure there a way around that too but thats a secondary concern.</p>
jquery
[5]
2,819,533
2,819,534
iPhone-SDK: Adding Image on Navigation Bar:
<p>I have a navigation controller which also has a table view. I want to add an image left side of the navigation bar on top programmatically. When i tried to add by the below code in viewDidLoad:</p> <p>CGRect frame = CGRectMake(0.0, 0.0, 94.0, 33.0); UIImageView *image = [ [UIImageView alloc]initWithImage:[UIImage imageNamed:@"topBarImage.png"] ]; image.frame = frame; [self.view addSubview:image];</p> <p>but it is adding to top of the table view instead of navigation tab. I think, this image should be added as navigationItem. But i don't how to add an image on left side of navigation bar programmatically. Could some one guide please? </p> <p>Clave/</p>
iphone
[8]
5,796,287
5,796,288
How to read line (from a file) and then append + print in python?
<pre><code>for line in file: print line </code></pre> <p>In the code above when I change it to:</p> <pre><code>for line in file: print line + " just a string" </code></pre> <p>This only appends "just a string" to the last line</p> <p>PS: Python newbie</p>
python
[7]
1,236,141
1,236,142
Creating An HtmlTable Using An ASP.NET Repeater Dynamically Bound to an Object List using ExtensionMethods.WebControls;
<p>I'm trying to create a repeater control and create the template programattically in webform. I found the post <a href="http://stackoverflow.com/questions/11110594/creating-an-htmltable-using-an-asp-net-repeater-dynamically-bound-to-an-object-l">here</a> <a href="http://stackoverflow.com/questions/11110594/creating-an-htmltable-using-an-asp-net-repeater-dynamically-bound-to-an-object-l">Creating An HtmlTable Using An ASP.NET Repeater Dynamically Bound to an Object List</a></p> <p>but it has a using statement for ExtensionMethods.WebControls. That seems to have a method for GenericHtmlControl called RenderHtml. </p> <p>How do i get ExtensionMethods.WebControls in my project?</p>
asp.net
[9]
3,949,592
3,949,593
Mouseenter not working with div jquery
<p>I have this div that when the mouse enters it, I want it to show a button within itself. For example here's the code for the div:</p> <pre><code>&lt;div id="menuitem1" style="height: 50px;" class="menuitem"&gt; &lt;input type="button" class="menuclear" value="Clear" style="margin-left: 10px; display: none;"/&gt; &lt;/div&gt; </code></pre> <p>And here is the jquery code:</p> <pre><code>$(".menuitem").mouseenter(function() { $(this).next(".menuclear").show(); }); </code></pre> <p>This code however doesn't work. I've tried mouseover and hover but still nothing. How do I change the code to make it show the button when the mouse enters the div? It's important to note that I cannot give these items specific id's because there are about thirty other div's and buttons with these same classes.</p>
jquery
[5]
4,094,665
4,094,666
parsing MonthDate string in a leap year
<p>please consider the following snippet:</p> <pre><code> SimpleDateFormat parser = new SimpleDateFormat("MMdd"); parser.setLenient(false); try { Date date = parser.parse("0229"); System.out.println(date); } catch (ParseException e) { e.printStackTrace(); } </code></pre> <p>I have a text field which should contain a date in the format MMdd (no year, as it should always default to the current year). </p> <p>This year, 2012, a leap year, I found myself in the strange situation of not being able to parse the valid date February 29th. </p> <p>The calendar used by the code above always defaults to 1970, which, though luck, was not a leap year. Hence trying to parse "0229" always throws a parse exception.</p> <p>Any idea on how to parse this?</p>
java
[1]
4,865,008
4,865,009
How to pass a method to qsort?
<p>There is a class that contains some data and it sorts them at some point of time. I use <code>qsort()</code> and I'd like to keep the comparing function within the class as a method. The question is how to pass a method to <code>qsort()</code> so that the compiler (g++) don't throw any warnings?</p> <p>Attempt 1:</p> <pre><code>int Data::compare_records(void * rec_1, void * rec_2){ // [...] } void Data::sort(){ qsort(records, count, sizeof(*records), &amp;Data::compare_records); } </code></pre> <p>This way generates an error:</p> <pre><code>error: cannot convert ‘int (Data::*)(const void*, const void*)’ to ‘int (*)(const void*, const void*)’ for argument ‘4’ to ‘void qsort(void*, size_t, size_t, int (*)(const void*, const void*))’ </code></pre> <p>Attempt 2 :</p> <pre><code>void Data::sort(){ qsort( records, count, sizeof(*records), (int (*)(const void*, const void*)) &amp;Data::compare_records ); } </code></pre> <p>This way generates a warning:</p> <pre><code>warning: converting from ‘int (Data::*)(const void*, const void*)’ to ‘int (*)(const void*, const void*)’ </code></pre> <p>How to do it the right way then?</p>
c++
[6]
305,176
305,177
How do I store complex objects in javascript?
<p>I need to be able to store objects in javascript, and access them very quickly. For example, I have a list of vehicles, defined like so:</p> <pre><code>{ "name": "Jim's Ford Focus", "color": "white", isDamaged: true, wheels: 4 } { "name": "Bob's Suzuki Swift", "color": "green", isDamaged: false, wheels: 4 } { "name": "Alex's Harley Davidson", "color": "black", isDamaged: false, wheels: 2 } </code></pre> <p>There will potentially be hundreds of these vehicle entries, which might be accessed thousands of times. I need to be able to access them as fast as possible, ideally in some useful way.</p> <p>For example, I could store the objects in an array. Then I could simply say <code>vehicles[0]</code> to get the Ford Focus entry, <code>vehicles[1]</code> to get the Suzuki Swift entry, etc. However, how do I know which entry is the Ford Focus?</p> <p>I want to simply ask "find me Jim's Ford Focus" and have the object returned to me, as fast as possible. For example, in another language, I might use a hash table, indexed by name. How can I do this in javascript? Or, is there a better way?</p> <p>Thanks.</p>
javascript
[3]
2,778,382
2,778,383
Abstract class and operator!= in c++
<p>I have problem implementing the operator!= in a set class deriving from an abstact one. The code looks like this:</p> <pre><code>class Abstract { public: //to make the syntax easier let's use a raw pointer virtual bool operator!=(const Abstract* other) = 0; }; class Implementation { SomeObject impl_; //that already implement the operator!= public: bool operator!=(const Abstract* other) { return dynamic_cast&lt;Implementation*&gt;(other)-&gt;impl_ != this-&gt;impl_; } }; </code></pre> <p>This code works but it has the drawback to use dynamic_cast and I need to handle error in casting operation.</p> <p>This is a generic problem that occur when a function of a concrete class it is trying to using some internal information (not available at the abstract class level) to perform a task.</p> <p>Is there any better way to solve this kind of problem?</p> <p>Cheers</p>
c++
[6]
2,398,503
2,398,504
selecting items in a listview
<pre><code>i have got a difficult task in my hand i dont knw how to do it,and my question is </code></pre> <p>i want to select a particular subitem in a row of a listview.for ex if the row contains 5 subitems,if i click the 3rd subitem it only gets selected.can anybody help me out</p> <p>thank you very much dude.i solved the issue successfully </p>
c#
[0]
4,320,106
4,320,107
How to remove "," in end of text in php?
<p>I have a text:</p> <pre><code>"2G Network":"GSM 850","3G Network":"HSDPA 850", </code></pre> <p>How to remove "," in end of text in php </p> <pre><code>"2G Network":"GSM 850","3G Network":"HSDPA 850" </code></pre>
php
[2]
1,566,533
1,566,534
Private functions / Variables enforcement in python
<p>I see a lot of python code that does "loose" private variables / functions. They'll declare functions / variables with one underscore (eg. _foo) and then use it just in the class / file. It really annoys me that they don't use the double underscore because eventually, someone will call this "private" member from outside the class. </p> <p>Is there some way to enforce the privacy on single underscores (without changing to doubles)? Thanks!</p>
python
[7]
3,734,717
3,734,718
Using ltrim(); to take away '0's from the start of my users input
<p>I ask for a user to input 4 numbers or letter from 1 - 9 and a-f. </p> <p>i then take these numbers and letters and <code>str_replace</code> them with 4 byte values. </p> <p>So if the user inputs <code>00FF</code>, the value would be <code>0000 0000 1111 1111</code>, as <code>0000</code> is the 4 byte value of <code>0</code> and <code>1111</code> is the 4 byte value of <code>F</code>. </p> <p>I want to get rid of any leading <code>'0's</code> from the total collection of 4 byte values.</p> <p>I have tried using the below code to get rid of the 0's from the start of it.</p> <pre><code>$hexvalue2 = ltrim($hexvalue,'0'); echo $hexvalue2; </code></pre> <p>However, this is not working, when looking at PHP.net as far as my knowledge goes this seems correct, but obviously its not.</p> <p>Can anyone tell me where i am going wrong please? or perhaps suggest an alternative?</p> <p>Thank you</p>
php
[2]
2,466,322
2,466,323
How to play multiple video in Gstreamer using java
<p>I am currently trying to play multiple videos in java using netbeans. I am able to play multiple videos using multiple gstreamer players but how do i use one player to play multiple videos instead so that it will not lag? </p>
java
[1]
511,549
511,550
Graceful Handling of Technical PHP/SQL errors
<p>I'm developing a PHP web application that is heavy on the database interactions. My question is, how do I display "Pretty" errors. I've got all kinds of exceptions and what not in pretty much every aspect of the app, but they still just awkwardly post the error text (which I currently have working perfectly) either above a half loaded page or on a blank, white background.</p> <p>How do I go about rerouting these to a generic error page that has a nice, contained spot for inserting the error message so that clients and testers can communicate it to me.</p> <p>My immediate guess would be to post these errors, but I don't know how to do that outside a form much less inside of a function. </p>
php
[2]
5,413,495
5,413,496
Script with which I can change the font dynamically when the page is live using JavaScript
<p>I want a JavaScript with which I can change the font dynamically when the page is live (Arial to Times). But when I click Arial or Times, the page should not get refreshed. Can anyone please help me in this? Or can anyone please provide a script for this?</p>
javascript
[3]
5,528,618
5,528,619
updating date "day/month/year" in DatePicker in Android
<p>I want to update the date picker to a given date (day,month,year) I used this code </p> <pre><code> date.updateDate(year, month, day); </code></pre> <p>where day,month and year are of type int. I have an exception while debugging "source not found" at this line. what's the wrong with my code?? thanks</p>
android
[4]
1,350,655
1,350,656
Web application runs very fast but don't know why?
<p>I've a web application. It runs slow. But if I load the Sql Server Mgmt Studio in the server side with database [use] and [go]. The web application responses very fast. Why ?</p> <p>My question is I didn't do anything but the my website response is greatly improved (approx 5~10 times faster) by launching the sql server mgmt studio in the web server, execute the command :- 1) use [database_used_by_the_website] 2) go</p> <p>and leave the sql mgmt studio unclosed. </p> <p>My website responses amazingly fast. It is a result from experiment. I don't know why ?</p>
asp.net
[9]
2,821,327
2,821,328
Not able to use new resource identifiers in Android with targetSdkVersion defined in manifest
<p>I'm developing an Android application that I'd like to be compatible with 1.5 (SDK version 4). I'm testing the application on 2.2 (SDK version 8). To do this, I'm including in the manifest file the line</p> <pre><code>&lt;uses-sdk android:minSdkVersion="4" android:targetSdkVersion="8" /&gt; </code></pre> <p>I thought this would allow me to use the newest manifest elements and APIs, but I'm getting a compile error whenever I try to use them. For example, I try to define the element <code>installLocation</code> to allow the app to be installed on the SD card, but Eclipse gives me the error</p> <blockquote> <p>No resource identifier found for attribute 'installLocation' in package 'android'</p> </blockquote> <p>Is there something else I have to do to get this to work? If I can't get this to work, what benefit is defining <code>targetSdkVersion</code>?</p>
android
[4]
644,313
644,314
Convert a string array to byte array
<p>I want to make a file which reads String array but initially I am having only byte array so first I want to convert it into string array, so how can I do so. </p>
c#
[0]
3,788,261
3,788,262
Switch focus between opened dialogs
<p>is there any way to programmatically switch focus between shown dialogs? To resume... I need method dialog.requestFocus(), but there is no some like that...</p> <p>Thanks...</p>
android
[4]
3,934,321
3,934,322
Stay logged in on a website in an application lifecycle
<p>I was able log in through my android app to <a href="http://yearbook08.com/" rel="nofollow">http://yearbook08.com/</a> using this code:</p> <pre><code> String URL="http://yearbook08.com/login.php"; HttpClient httpclient = new DefaultHttpClient(); HttpResponse response = null; HttpPost httppost = new HttpPost(URL); List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); nameValuePairs.add(new BasicNameValuePair("userId", uname)); nameValuePairs.add(new BasicNameValuePair("password", pass)); try { httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { response = httpclient.execute(httppost); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>Now when I move to another activity I want to retrieve <a href="http://yearbook08.com/wall.php" rel="nofollow">http://yearbook08.com/wall.php</a> but the web server does not recognize my last login and asks me to login again.</p> <p>Is there a way that I can stay logged in after once logging in? Kindly help !</p>
android
[4]
5,151,464
5,151,465
Python 2 + Python 3 + library
<p>I have both Python 2 and 3 in the same machine and installed a library (requests) through my package manager. I am only able to import it in Python 2, is it meant to be like that? If not how can I import it in Python 3? </p>
python
[7]
24,506
24,507
Statement in "except" tag not working in python
<p>I have written the following code to save an album from a website.</p> <pre><code>import urllib2 import webbrowser import os page=1564848 fileno=1 for fileno in range(1,24): pages=str(page) filenos=str(fileno) picture_page = "url-to-the-website"+pages+".jpg" page=page+1 os.chdir("/home/comrider/Album/") if not os.path.exists("3"): os.makedirs("3") os.chdir("/home/user/Album/3") try: opener1 = urllib2.build_opener() page1 = opener1.open(picture_page) my_picture = page1.read() filename = filenos + picture_page[-4:] fileno=fileno+1 fout = open(filename, "wb") fout.write(my_picture) fout.close() except: fileno=fileno-1 #This statement is not working pass </code></pre> <p>Since there are missing image number i have given a try and except statement and in the except statement I have given a statement to decrement the file no. that was incremented in the try statements. But that code is not working resulting in incomplete downloading of the album. The working platform is linux. Please help. thanks in advance.</p>
python
[7]
2,816,007
2,816,008
How to only show some of the values in an array in an textbox?
<p>I have come across a problem that i cant salve, What i have is an string array with 60 values in it and they concists of either "vacant" or "reserved". Now what i need to do is to show only those arayy index that are either vacant or reserved and i have no clue on how to go about it. :/ I am stumped to say the least. I know how to get the number of eatch sort in the array so thats no problem.</p> <p>I just cant figure out how to get those index values into a method that diplays them in my textbox. My thinking is that since i know how many they are i can atleast know the number of iterrations needed to show them all in the textbox.</p> <p>So please i need some ideas as i am apparently experiencing a major brainfreez :P (both my two grey ones are fighting)</p> <p>Thanks for any ideas!</p> <p>//Regards</p>
c#
[0]
2,157,440
2,157,441
Create array from dynamically generated select textfields jquery
<p>I have a repeating table row with a select list. I want to create an array from the number of select textfields a user has generated. I am using .each function to iterate through all the select textfields. Here is the code I am using. The id of the dynamically created list is "countrylist" </p> <pre><code>$("#Submitcountry").click(function(){ $("#countrylist").each(function() { var countrylist= [$("#countrylist").val()]; //var countrylist = [1,2,3,4,5] alert(countrylist); });}); </code></pre> <p>As from the above, I want to see the values that I have selected. The only problem is that the alert only shows the first row. All help appreciated</p>
jquery
[5]
5,242,916
5,242,917
Upload application to android market with same version name and code
<p>I have created my app in android and for checking the in-App purchase, i uploaded the app in market as a draft application.Everything i checked regarding the in-app purchase.Now i want to publish my app in the market.Can i use the same version name and version code for that? </p> <p>Note: I tested my app as a draft application</p> <p>So any problem for publishing app?</p> <p>Can anyone help me ?</p>
android
[4]
942,604
942,605
Getting started with jQuery
<p>What is a good place to start playing with jQuery, besides the jQuery website. I'm having trouble with the way the site is set up - I dislike it. </p>
jquery
[5]
364,623
364,624
XMLHttpRequest error: Origin not allowed by Access-Control-Allow-Origin
<p>Basically I want to create an AddOn for Firefox which will fetch only RSS feeds from particular website. But I am getting an error:</p> <blockquote> <p>XMLHttpRequest cannot load <a href="http://www.-" rel="nofollow">http://www.-</a>** Origin <code>http://localhost:59382</code> is not allowed by Access-Control-Allow-Origin.</p> </blockquote> <p>Can anyone explain how to resolve this error?</p>
javascript
[3]
4,923,656
4,923,657
how to remove an element from a nested list?
<p>if i have an nested list such as:</p> <pre><code>m=[[34,345,232],[23,343,342]] </code></pre> <p>if i write <code>m.remove(345)</code> it gives an error message saying element not in the list.</p> <p>i want to know how to remove an element from the nested list,easily??</p>
python
[7]
1,953,035
1,953,036
performing the same query on two different servers but one seems to fail
<p>I have shared hosting with two different hosting providers.</p> <p>I have the smallest DB query ever (no stress)</p> <p>all I do is simply echo out some info from a table, nothing crazy:</p> <pre><code>$loop_query = "SELECT * FROM my_table"; $sl = mysql_query($loop_query, $db_connect); while ($db = mysql_fetch_array($sl)){ echo $db['name'], $db["age"];} </code></pre> <p>Now I test this on <strong>Server A</strong>, everything works fine.</p> <p>But on <strong>Server B</strong>, it fails.</p> <p>I either get a blank page or i get a browser error: connection closed by remote server.</p> <p>Now I have a few other pages on server B which involve DB queries, and they work fine.</p> <p>I'm completely lost.</p> <p>Any help would be much appreciated.</p>
php
[2]
2,884,947
2,884,948
iphone EXC_BAD_ACCESS caused by emergency_mutex
<p>My iphone app occasionally crashes on the simulator and device with this message in the debugger:</p> <pre><code>Program received signal: “EXC_BAD_ACCESS”. Data Formatters unavailable (Error calling dlopen for: "/Developer/Applications/Xcode.app/Contents/PlugIns/GDBMIDebugging.xcplugin/Contents/Resources/PBGDBIntrospectionSupport.A.dylib": "dlopen(/Developer/Applications/Xcode.app/Contents/PlugIns/GDBMIDebugging.xcplugin/Contents/Resources/PBGDBIntrospectionSupport.A.dylib, 10): no suitable image found. Did find: /Developer/Applications/Xcode.app/Contents/PlugIns/GDBMIDebugging.xcplugin/Contents/Resources/PBGDBIntrospectionSupport.A.dylib: open() failed with errno=24") </code></pre> <p>The stack track just says:</p> <pre><code>0 (anonymous namespace)::emergency_mutex 1 ?? 2 __NSFireTimer 3 CFRunLoopRunSPecific 4 CFRunLoopRunInMode 5 GSEventRunModal 6 GSEventRun 7 UIApplicationMain 8 main </code></pre> <p>I have no idea what that means or how to go about debugging it.</p>
iphone
[8]
3,496,992
3,496,993
Grid view data export to text file its not working in IE 9
<p>when its in local system its working fine..i can download\open\save everything its working bcoz its http:..when it come to production is https:so its not working...my code is below</p> <pre><code> Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=sample.txt"); Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.text"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); Response.Write(strExport.ToString()); Response.End(); </code></pre> <p>its working in mozilla and chrome</p>
asp.net
[9]
4,315,551
4,315,552
Add image from database after building jar
<p>So, I have a java program which reads a MySQL database. It reads lots of things from there and, one of them, is the path for images.</p> <p>Is there a way I can add an image path in this database and make a built jar show it without rebuilding?</p>
java
[1]
2,505,958
2,505,959
Converting classes to an library
<p>Hi experts i have created a set of UItableviewcustom cell classes. Now can i group those classes to an static library so that i can include that library in whichever project i want and i can use it.</p>
iphone
[8]
2,460,908
2,460,909
including jquery
<p>I know that wordpress ships with jquery. I have built my site first in html and every script that I have running in the html version works fine running version 1.4.2. I included this same jquery script and now one of my features don't work. This is how I am loading jquery into the head of my site</p> <pre><code>function register_savior_scripts(){ wp_deregister_script('jquery'); wp_enqueue_script('prettyPhoto', get_template_directory_uri().'/js/jquery.prettyPhoto.js', array('jquery')); wp_enqueue_script('js-scripts',get_template_directory_uri().'/js/jquery.js'); wp_enqueue_script('slider', get_template_directory_uri().'/js/coin-slider.min.js', array('jquery')); } add_action('wp_head','register_savior_scripts', 0); </code></pre> <p>If I check the head, I see the script. It looks like this</p> <pre><code>&lt;script type='text/javascript' src='full path removed/js/jquery.js?ver=3.4.1'&gt;&lt;/script&gt; </code></pre> <p>It's not version 3.4.1. Not sure that matters. The script that it is running I put directly into the head and is this code</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $(".controls").click(function(e){ if($(this).hasClass('down-arrow')) { $(this).addClass('up-arrow').removeClass('down-arrow'); } else { $(this).addClass('down-arrow').removeClass('up-arrow'); } e.preventDefault(); $("#logo-background").slideToggle("slow"); }); }); </code></pre> <p></p> <p>Is there a better way to load the script above into the head? Do you know why it would work on the html but not wordpress?</p> <p>All it does is slide a div up or down to hide it if you press a link. </p>
jquery
[5]
3,880,348
3,880,349
How to represent a bitmask using DebuggerDisplay attribute
<p>I have a class with 8 bool's, and I want to represent those bools as 1 or 0 in the debugger, how can I achieve this?</p>
c#
[0]
514,225
514,226
Is there any way to display a portion of an external web site into my site?
<p>Can we do this using jQuery? if so, how? </p>
jquery
[5]
4,395,388
4,395,389
Finding and changing the value of a single "href" value using Simple Html DOM Library
<p>i need help in parsing a href attribute of a single anchore tag and then changing its value in a php file using "simple html dom" library. Below is the html code:- </p> <pre><code>&lt;li id="toggle"&gt; &lt;a id="open" class="open" href="#" style="display: block; "&gt;&lt;/a&gt;&lt;/li&gt; </code></pre> <p>Now i want to get this specific href value and change it to some page like say, Logout.php depending upon if the user is logged in or not. And here is my php code:</p> <pre><code>&lt;?php include 'simple_html_dom.php'; session_start(); $html = new simple_html_dom(); $html-&gt;load_file('index1.php'); if(!isset($_SESSION['username'])){ $ret = $html-&gt;find('li[id=hello]'); $ret = "Hello Guest"; $tog = $html-&gt;find('li[id=toggle]'); $tog = "Log In | Register"; }else{ $user = $_SESSION['username']; $ret = "Hello " . $user; $tog = "Log out"; $hrf = $html-&gt;find('a[id=open]'); $hrf-&gt;href = 'Logout.php'; } ?&gt; </code></pre> <p>Now except finding and changing the "href" value, all other things are working properly. Any help is welcomed. Thanks in advance.</p>
php
[2]
1,302,335
1,302,336
'live' responses on time consuming php scripts?
<p>Many times i run time consuming PHP scripts that echo status updates like 'batch 1 finished', 'batch 2 finished' etc. </p> <p>i've noticed that sometimes the server responds in a 'live' manner and you can see these status updates as the 'jobs' finish, printed on the browser.</p> <p>But in other times you have to wait for the script to end, and the browser displays all the status updates at once.</p> <p>When does the first happen? Is it the browser? Is it PHP setup? The way the script is coded? </p>
php
[2]
2,321,892
2,321,893
I am getting errors in php
<p>I am getting this error and I have done everything I can think about. Can someone help me out I have been working on this all day. I am still a little newbie at it. Thanks.</p> <p>Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in C:\wamp\www\member-form.php on line 81 error on connect </p> <pre><code>else{ $hostname="localhost"; $database="contact"; $mysql_login="username"; $mysql_password="password"; 81.if (!($db = mysql_connect($hostname, $mysql_login , $mysql_password))){ echo "error on connect"; } else{ if (!(mysql_select_db($databse, $db))){ echo mysql_error(); echo "&lt;br&gt;error on table connection"; } else{ $SQL="Insert into tblUsers(username,password,firstname,lastname,email,address,city,state,zip, phone,signupDate)values)'".$_POST['username']."',PASSWORD('".$_POSR['password1']."'),'".$_POST['firstname']."','".$_POST['lastname']."','".$_POST['address']."','".$_POST['city']."','".$_POST['state']."','".$_POST['zip']."','".$_POST['phone']."',NOW())"; mysql_query($SQL); if (is_numeric(mysql_insert_id())){ header("Location:member-content.php?name=".$_POST['username']); } else{ echo "Sorry, there was an errot.Please try again ot contact the administrator"; } mysql_close($db);//closeing out connection,done for now } } } ?&gt; </code></pre>
php
[2]
3,552,681
3,552,682
jQuery Storing Element in a Variable
<p>I have the code below which when a list item is clicked an animation occurs.</p> <p>What I'm having trouble with is making the list item when clicked again reverse the animation effect.</p> <p>I'm trying to store the clicked list item in a variable but having trouble with this as my variable never stores the elements details?</p> <p>There may be a better way of doing this but any help or advice would be great?</p> <pre><code> &lt;ul class="circles"&gt; &lt;li class="c-1"&gt;&lt;div class="c-1-active"&gt;Text Link&lt;/div&gt;&lt;/li&gt; &lt;li class="c-2"&gt;&lt;div class="c-1-active"&gt;Text Link&lt;/div&gt;&lt;/li&gt; &lt;li class="c-3"&gt;&lt;div class="c-1-active"&gt;Text Link&lt;/div&gt;&lt;/li&gt; &lt;/ul&gt; $('#home ul.circles li').click(function() { alert(testing); if(testing &gt; "" || testing == $(this).find('div')) { testing.animate({opacity: 0, top:'180px'}, 1000 ); } $(this).find('div').animate({opacity: 0.8, top:'0'}, 1000 ); var testing = $(this).find('div'); }); </code></pre>
jquery
[5]
3,308,650
3,308,651
Java: How to delete all the characters after one character in the String
<p>I have a String which contains a date for exemple 01-01-2012 then an space and then the time 01:01:01. The complet string is: "01-01-2012 01:01:01"</p> <p>I would like to extract only the date from this string so at the end I would have 01-01-2012 but don't know how to do this.</p> <p>Thank you</p>
java
[1]
5,636,442
5,636,443
Javascript ++ vs +=1
<pre><code>var a = "ab"; var b = "ab"; a+=1; // "ab1" b++; // "NaN" </code></pre> <p>(Tested on chrome's V8)</p> <p>Can someone explain why the results are different based on the internal atomic actions of the <code>++</code> arithmetic operator and the <code>+=</code> assignment operator with argument <code>1</code></p>
javascript
[3]
4,227,235
4,227,236
Creating AVD screen based on physical device
<p>I have a Android tablet and I want to create an Android Virtual Device (AVD) whose screen is as close to the physic device as possible (in terms of size and resolution).</p> <p>I tried copying the resolution from the device settings, but the size of things in the emulator screen still look different. The device reports it's density is xlarge, but (as far as I understand) these density aliases are approximations anyway.</p> <p>Is there a way (even an app that I would install on the device) to know what settings I have to create the AVD with to get a equivalent screen?</p> <p>The device is not from a major manufacturer, it's unlikely that I will find a 'ready-made' AVD.</p>
android
[4]
3,070,756
3,070,757
Remove line break for csv import
<p>I have a text field in the database with datatype also as text. It holds comments and stuff. Now when I read this and export in a csv if it finds a new line in that comment such as</p> <pre><code>This is a comment This is another line </code></pre> <p>The csv import show "This is another line" in next line and thus mess up my data.</p> <p>So far I have tried str_replace(), trim(). Still don't seem to do anything. I have looked for similar answers in stackoverflow but couldn't find one that suits my problem</p> <p>Thanks</p>
php
[2]
204,193
204,194
Sometimes print_r() dies
<p>I know this is not so precise question. Sometimes <code>print_r ($something, true);</code> results in stopping request. No error happens, but its like I used the <code>die();</code> function. May it die on larger datas?</p>
php
[2]
217,249
217,250
Javascript event for dragging file onto input type=file
<p>Ok, I got drag &amp; drop upload working correctly when dragging files onto some div element, but what if the user drags the file onto the input type=file field? I have to include that field for people who want to use the regular file select, but the change event attached to that field doesn't fire when I drag a file onto it, just when I select a file.</p> <p>So what is the event that fires when you drag the file onto the input field? (works in Firefox at least)?</p>
javascript
[3]
1,953,938
1,953,939
The height of text between different browsers
<p>I made an easy example and try to get the height of string.</p> <pre><code>jQuery(function () { var jqSpan = $('span'); jqSpan.css({ 'font-family': 'Arial', 'font-size': '24px', 'font-weight': 'bold' }); $('#result').text(jqSpan[0].offsetHeight); }); </code></pre> <p><a href="http://jsfiddle.net/DCBP9/1/" rel="nofollow">http://jsfiddle.net/DCBP9/1/</a></p> <p>I found the value is different between the different browsers. I have used reset.css, but it's value still not the same.</p> <p>For example: (Mac)<br> In my example, Chrome is 27, Firefox is 28, Opera is 25, and Safari is 27</p> <p>I know each browser has its own render engine, but I want to know is it possible to let them identical.</p>
javascript
[3]
4,698,370
4,698,371
Getting error: Uncaught TypeError: Object .thumbnail has no method 'hover'
<pre><code>&lt;script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { ('.thumbnail').hover( function () { $('.hovImage').css('display', 'block'); }, function () { $('.hovImage').css('display', 'none'); }); }); &lt;/script&gt; </code></pre> <p>I'm getting error "Uncaught TypeError: Object .thumbnail has no method 'hover'" with the above. I can't figure out where the error is coming from. Help please!</p>
jquery
[5]
2,366,381
2,366,382
Inform Class(A), when Class(B) delegate methods complete execution using Notification in iphone SDK?
<p>I have written custom delegate methods in ClassFile(B), now i am calling them from ClassFile(A), now i want to notify Class(A) when class(B) delegate methods complete its execution. </p> <p>How can i do in Objective C (in Iphone SDK) ?? </p> <p>A working sample example will be more appreciable.</p> <p>Thanks</p>
iphone
[8]
1,886,187
1,886,188
how to get the value of the hidden list in javascript
<p>I've a hidden field in my jsp</p> <pre><code>&lt; s: hidden id ="lstId" value = "obj.lstVendors" / &gt; </code></pre> <p>Is it possible to get the list in javascript using </p> <pre><code>document.getElementbyId(lstId)? </code></pre>
javascript
[3]
3,661,225
3,661,226
Android App Developer console: Backtrack to previous version?
<p>Is it possible to backtrack to a previous version of a released Android app - if so will this version be replaced as part of the phones update service - or will I need to release a new version of the old app with a incremented version number?</p> <p>Cheers Paul</p>
android
[4]
2,096,377
2,096,378
How to get the default homepage from the default browser
<p>how can i get the default homepage from the default browser (IE, firefox,...) in C#.</p>
c#
[0]
3,453,116
3,453,117
How to create a Loading Data splash screen in C# windows Forms Application?
<p>i have an C# Windows Forms application project.and there's a form with a datagridview and a button.when user click on the button a huge amount of data will be loaded to datagridview that takes time. i want to show a simple animated gif image like "Loading Data" while data is loading, on the center of screen.like this <a href="http://webpagebynumbers.com/wp-content/uploads/2011/09/Red-014-loading.gif" rel="nofollow">http://webpagebynumbers.com/wp-content/uploads/2011/09/Red-014-loading.gif</a> which will be still animated while data is leading and close after data loading finishes .if you have used "Nero" or Acrobat reader there's something like what i want when those applications start. and even a slight transparent shadow under the animated screen and even the speed of rotation depend on how fast the process is.how can I do that?</p>
c#
[0]
2,751,581
2,751,582
OO Javascript and this keyword. Object Literals
<p>I'm having issues with Javascript properties and "this" keyword. Forgive me here for asking my third and final JS OOP question. OOP in Javascript has been a headache for me today.</p> <p>I'm trying to set the property 'source' but the error console is saying it's undefined in parseSource method.</p> <p>After a little research I believe this.source is is referring to window.source? The code is a boilerplate from Mozilla. When creating extensions init is called by FireFox when the plugin is initialized.</p> <p>What's the best way to go about setting the properties when creating objects using literal notation?</p> <pre><code>var myExtension = { source: null, init: function() { // The event can be DOMContentLoaded, pageshow, pagehide, load or unload. if(gBrowser) { gBrowser.addEventListener("DOMContentLoaded", this.onPageLoad, false); } }, onPageLoad: function(aEvent) { doc = aEvent.originalTarget; // doc is document that triggered the event win = doc.defaultView; // win is the window for the doc // Skip frames and iFrames if (win.frameElement) return; this.source = win.document.getElementById('facebook').innerHTML; myExtension.parseSource(); }, parseSource: function() { if(this.source == null) { // So something } else { // Do something else } } } window.addEventListener("load", function() { myExtension.init(); }, false); </code></pre>
javascript
[3]
4,696,978
4,696,979
validating html color codes JS
<p>i am looking for code to validate html color codes. wanna check if user typed valid color code, can you guyz help ?</p> <p>i know i need that regex stuff but i cant understand a think about that regex things :S</p> <p>thanks</p>
javascript
[3]
3,362,569
3,362,570
deleting the file (FileInfo) in asp.net
<p>in my page. when i upload image i did image management. after that i want to delete the original image but i am getting error that the file is already using, like below <strong>(The process cannot access the file 'D:\sasiweb\myimage\Images\jalsa.jpeg' because it is being used by another process.)</strong></p> <p>and this is my code</p> <p>protected void sizeManage(string filename) {</p> <pre><code> string fn = Server.MapPath("~/Images/" + filename ); System.Drawing.Bitmap newimg = new System.Drawing.Bitmap(fn); int h = newimg.Height; int w = newimg.Width; if (w &gt; 100) { objJpeg = new ASPJPEGLib.ASPJpeg(); objJpeg.Open(Server.MapPath("~/Images/" + FileUpload1.FileName.ToString())); int L = 100; objJpeg.Width = L; objJpeg.Height = objJpeg.OriginalHeight * L / objJpeg.OriginalWidth; objJpeg.Save(Server.MapPath("~/Images/" + "small" + FileUpload1.FileName)); string path = Server.MapPath("~/Images/" + FileUpload1.FileName.ToString()); FileInfo file = new FileInfo(path); file.Delete(); } else { } } protected void Button1_Click(object sender, EventArgs e) { FileUpload1.SaveAs(Server.MapPath("~/Images/" + FileUpload1.FileName.ToString())); sizeManage(FileUpload1.FileName.ToString()); } </code></pre> <p>i am getting error at file.delete();</p> <p><strong>(The process cannot access the file 'D:\sasiweb\myimage\Images\jalsa.jpeg' because it is being used by another process.)</strong></p>
asp.net
[9]
1,391,540
1,391,541
Get folders name from Assets directory
<p>I'm trying to get the names of my folders in "assets". I can get the names of the files with an AssetManager by using the method assetManager.list(). But the problem is that it return only files' name and not folders' names. So I'm trying to use the listFiles() method but i can't access to the Assets directory; I've try the following :</p> <pre><code>File dir = new File ("file:///android_asset/"); File[] files= dir.listFiles(); </code></pre> <p>But it doesn't work :( ... Is there a way to get the folders' names contained in the Assets directory ?</p>
android
[4]
2,436,287
2,436,288
accessing super class in java
<p>Am I using the superclass correctly to access the <code>title</code>, <code>minutes</code> and <code>price</code>?</p> <pre><code> public class Video extends CollectionItem { public Video(String title, int minutes, double price) { super(title,minutes,price); } public String getTitle() { return super(title); } public int getMinutes() { return super(minutes); } public double getPrice() { return super(price); } public double pricePerMinute() { return super(price)/super(minutes); } } </code></pre> <p>here is my superclass can you check to make sure i did everything correctly i am very new to this and i did research i just thought that super() was the correct way</p> <pre><code>Public class CollectionItem { public String title; public int minutes; public double price; public int pages; public Video(String title, int minutes, double price) { this.title = title; this.minutes = minutes; this.price = price; } public Book(String title, int pages, double price) { this.title = title; this.pages = pages; this.price = price; } public String getTitle() { return title; } public int getPages() { return pages; } public double getPrice() { return price; } public int getMinutes() { return minutes; } } </code></pre>
java
[1]
5,224,201
5,224,202
Javascript advanced topics
<p>Where could I find a list of descriptions of all advanced topics of Javascript? I am preparing a learning or training topics of Javascript, targeted for the users who has basic Javascript knowledge (know grammar, wrote basic function before and know basic debugging skills). And they want to learn how to proceed next step to know more advanced topics of Javascript and become guru. </p>
javascript
[3]
3,147,246
3,147,247
change the value of the button of the button clicked
<p>On inserting the new <code>&lt;li&gt;</code>, I have to set the value of the button clicked to Delete. How can I do that? </p> <p>With the actual code, it`s working only once, and on adding other list, the button no more has the the value 'Delete'. </p> <pre><code>$("#mylist :button").click( function() { var text = $(this).val(); if (text == "Delete") { $(this).parent().remove(); } else { $(this).val("Delete"); } }); $("#mylist li:last-child").live('click', function() { $(this).parent().append('&lt;li&gt;' + '&lt;input type = "textbox"&gt;' + '&lt;input type = "button" value= "Save"&gt;' + '&lt;/li&gt;'); }); &lt;div&gt; &lt;ul id="mylist"&gt; &lt;li id="1"&gt;1&lt;button id="Button3"&gt;Delete&lt;/button&gt; &lt;/li&gt; &lt;li id="2"&gt;2&lt;button id="Button2"&gt;Delete&lt;/button&gt;&lt;/li&gt; &lt;li id="3"&gt;3&lt;button id="another_entry"&gt;Save&lt;/button&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre>
jquery
[5]
1,719,236
1,719,237
Loading form2 many times from form1
<p>I have c# form1 with random numbers created and show those numbers in form2, and I again create new random numbers in form1, and when I try to show form2 for the secnd time I have seen the first time created numbers not the second time ( the data in form2 are not changed). I would appreciate If some one can help. The code for form1 and form2 are:</p> <pre><code>//form1 public static int var2; Form secondForm = new Form2(); private void Form1_Load(object sender, EventArgs e) { var2 = RandomNumber(1, 50); secondForm.Show(); secondForm.Refresh(); Thread.Sleep(2000); secondForm.Hide(); var2 = RandomNumber(1, 50); secondForm.Show(); secondForm.Refresh(); } private int RandomNumber(int min, int max) { Random random = new Random(); return random.Next(min, max); } //form2 private void Form2_Load(object sender, EventArgs e) { this.Invoke(new EventHandler(DisplayText1)); } private void DisplayText1(object sender, EventArgs e) { textBox1.AppendText(" "); textBox1.AppendText(Form1.var2.ToString()); } </code></pre>
c#
[0]
2,400,941
2,400,942
CustomAttributes not behaving as expected
<p>I would expect there to be three lines of output from this code, but there are none:</p> <pre><code>[AttributeUsage( AttributeTargets.Property )] public class FieldAttribute : System.Attribute { public String FieldName { get; set; } } public class Host { [Field] public String FieldOne { get; set; } [Field(FieldName="Foo")] public String FieldTwo { get; set; } [FieldAttribute] public String FieldThree { get; set; } public String FieldFour { get; set; } } class Program { static void Main( string[] args ) { Type t = typeof(Host); foreach ( Object att in t.GetCustomAttributes( typeof(FieldAttribute), true ) ) { Console.WriteLine( att.ToString() ); } } } </code></pre> <p>Am I missing soemthing obvious?</p> <p>Andrew</p>
c#
[0]
3,088,474
3,088,475
Rusty/Beginner C++ compiler error
<p>I'm a relatively experienced programmer, coming back into some C++ review for a class. We have an assignment to write a couple relatively simple c++ programs. Getting an odd error that I'm not used to, but I'm sure it's child's play for this community.</p> <pre><code>int pull_next_element (int r, std::vector&lt;int&gt;&amp; sequence) { int x = sequence[0]; sequence.erase(sequence.begin()); //orig: sequence.erase(0); return x; } </code></pre> <p>Error I was getting:</p> <pre><code>Error C2664: 'std::_Vector_iterator&lt;_Myvec&gt; std::vector&lt;_Ty&gt;::erase(std::_Vector_const_iterator&lt;_Myvec&gt;)' : cannot convert parameter 1 from 'int' to 'std::_Vector_const_iterator&lt;_Myvec&gt;' </code></pre> <p>EDIT: Replaced with iterator instead of numerical index, and otherwise fixed this problem throughout the code. Thanks everyone.</p>
c++
[6]
4,465,338
4,465,339
Best way to do jquery form validation?
<p>Okay, so we have input boxes for the following:</p> <pre><code>firstname, lastname, email, password, city, state, captcha, terms and conditions </code></pre> <p>I've done the validation for all of these input boxes.</p> <p>This validation is seperate for each ID, and works via <code>change()</code></p> <p>The e-mail and captcha use ajax, and if they are successful, it returns true.</p> <p>I also have all of the validation inside the form <code>submit()</code></p> <p>But when the form is submitted, the validation on the ajax takes place again and the form is submitted WHILE the ajax request is processing.</p> <p>How would I make the form delay submitting until the validation has ran and then auto submit? Like a sort of delay feature?</p> <p>Each part of validation returns a var named <code>error</code> - error can either be <code>true</code> or <code>false</code></p> <p>If the error is false, it prevents form submit by returning false.</p> <p>I've been thinking of scrapping the whole <code>submit()</code> validation, as its just a duplicate validation running on submit and basically running in a loop, and I was thinking of disabling the submit button with jquery unless everything is validated via <code>change()</code>?</p>
jquery
[5]
4,013,364
4,013,365
Get the value of a URL after the last slash
<p>All, Say I have the following URL values:</p> <p><a href="http://website.com/tagged/news/" rel="nofollow">http://website.com/tagged/news/</a> <a href="http://website.com/tagged/news" rel="nofollow">http://website.com/tagged/news</a> <a href="http://www.website.com/tagged/news/" rel="nofollow">http://www.website.com/tagged/news/</a> <a href="http://www.website.com/tagged/news" rel="nofollow">http://www.website.com/tagged/news</a></p> <p>I'd like to have a PHP function to get news in this example. So I want the value after the last slash if it isn't blank and if that value is blank, then I'd like to get the value before that slash.</p> <p>I found this post: <a href="http://stackoverflow.com/questions/5921075/get-last-word-from-url-after-a-slash-in-php">Get last word from URL after a slash in PHP</a></p> <p>But I'd like to be really sure just in case someone types a slash at the end of the URL.</p>
php
[2]
5,563,542
5,563,543
Android HttpPut example code
<p>could anyone give me a httpPut request example code?</p>
android
[4]
5,267,043
5,267,044
Need to try and count repeated lists within a list
<p>Im trying to count how many repeated lists there are inside a list. But it doesnt work the same way I could count repeated elements in just a list. Im fairly new to python, so apologies if it sounds too easy.</p> <p>this is what i did</p> <pre><code>x= [["coffee", "cola", "juice" "tea" ],["coffee", "cola", "juice" "tea"] ["cola", "coffee", "juice" "tea" ]] dictt= {} for item in x: dictt[item]= dictt.get(item, 0) +1 return(dictt) </code></pre>
python
[7]
135,831
135,832
Prevent horizontal scrolling with javascript?
<p>Does anyone know if there is a way to prevent the user from being able to scroll horizontally? ive used overflow-x:hidden css, but it can still sometimes scroll (but only sometimes, its weird..)</p> <p><a href="http://www.kaiserroof.com" rel="nofollow">http://www.kaiserroof.com</a></p> <p>Would it be possible to disable keystroke events for right/left arrows as well as left/right mousewheel with javascript? if there is no horizontal scrolling, they wouldnt need those buttons anyway. I thought there was a way to do this with javascript, but i cant remember? like onkeypress "left arrow" return false? i dont know too much javascript though..</p>
javascript
[3]
3,435,933
3,435,934
Capturing the contents of native prototypes
<p>Try and do the following:</p> <pre><code>for (var key in String.prototype) console.log(key); </code></pre> <p>It gives you...nothing (well, unless you defined some foreign stuff yourself.) However, you still have <code>String.prototype.split</code> for example. I tried it on every other native object (<code>Number</code>, <code>Array</code>, <code>Object</code>) for the same result.</p> <p>The following also "doesn't work":</p> <pre><code>for (var key in Array) console.log(key); </code></pre> <p>While there's <code>Array.isArray</code> for example.</p> <p><code>Object.keys(Array.prototype)</code> gives an empty array, and so does <code>Object.keys(Array)</code>. However, <code>Object.keys(jQuery)</code> for example provides a giant array, as expected.</p> <p>So, why can't we iterate over natives provided by the browser, yet still access them?</p>
javascript
[3]
4,847,057
4,847,058
Header location redirect after logout to remove ?q=logout
<p>As it says I need to remove the ?q=logout. First I tried this </p> <pre><code>if ($_GET["q"] == "logout") { $user-&gt;user_logout(); header("location:".$_SERVER["SERVER_NAME"]); } </code></pre> <p>The second thing i tried:</p> <pre><code>if ($_GET["q"] == "logout") { $user-&gt;user_logout(); header("location:include/redirect_home.php"); } </code></pre> <p>and in redirect_home.php</p> <pre><code>header("location:".$_SERVER["SERVER_NAME"]); </code></pre> <p>In both cases the page redirects to www.mypage.com/?q=logout I need to remove the ?q=logout after $user->user_logout(); is processed </p>
php
[2]
4,772,055
4,772,056
Doing 2 things at the same time in Java
<p>Well, I'm working on an online game in Java. I have a client and a server. And the speech system waits for a new message to be displayed like this:</p> <pre><code>public void addSpeech(String msg) { String newMsg = parsel10n(msg); m_narrator.addSpeech(parsel10n(newMsg)); while (!m_narrator.getCurrentLine().equalsIgnoreCase(newMsg)) ; while (!m_narrator.getAdvancedLine().equalsIgnoreCase(newMsg)) ; } </code></pre> <p>The problem is.. the rest of the application stops because of the while loops. I don't see any other players move or see the chat while in this loop. Is there a way I could run this method without touching the rest of the application (client) with the loops? Should threads be involved? I hope you'd be able to answer me. </p>
java
[1]
5,676,126
5,676,127
display images from a folder in a specific order
<p>In my php project I have a folder named Gallery1 (path is images/gallery1). Which contains images named 1.jpg, 2.jpg, 20.jpg, 8.jpg etc. I want to display all the images from that folder in ascending order (1.jpg, 2.jpg, 8. jpg, 20.jpg etc). Does anyone know this?</p> <p>Thanks in advance</p>
php
[2]
895,050
895,051
Are there other Type in addition to the class to be called by hasattr
<p>For code:</p> <pre><code>class a(object): a='aaa' b=a() print hasattr(a,'a') print hasattr(b,'a') </code></pre> <p>who can be called by hasattr except 'class somebody'?</p> <p>Thanks!</p>
python
[7]
4,043,645
4,043,646
Android SOAP issue
<p>i m calling soap web service in my application. i m getting an image URI as a response. i want to set it to the image view. i m not able to do that.</p> <p>how can i do that?</p> <p>pls help me..</p>
android
[4]
3,191,448
3,191,449
android list contents notifications
<p>how to calculate total number of items in a listbox and display in a text box?</p> <p>I want to dynamically add the number of items in the list and display in front of the heading in brackets and also in front of its image like a notification showing the pending requests</p>
android
[4]
5,652,316
5,652,317
After using the jQuery ".css" method, how do you change it back to normal?
<p>This is my original CSS for my <code>#frame</code> div.</p> <pre><code>....#frame{ position:relative; top:35px; } </code></pre> <p>Then, I use jQuery to change the CSS of my div...</p> <pre><code>$('#frame').css("position","absolute"); $('#frame').css("left",50); </code></pre> <p>Now, how do I clear all those changes, and revert back to normal?</p>
jquery
[5]
1,619,377
1,619,378
Gridview does not comes up using custom class
<p>My gridview does not renders if I am using my derived GridClass, It does render when I add GridView object to myLayout but not when I add My Grid Object/ :( .Here's is the code</p> <pre><code> public class parentClass extends MyotherClass { Grid _gridV = null; public void createGridMenu(GridViewAdapter adp ) { _gridV = (Grid) inflater.inflate(R.layout.Mygridmenu, null); _gridV.setAdapter(adp); MyLinearLayout.add(_gridV); } class Grid extends GridView{ Grid() { super(myContext); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } //My other methods } </code></pre>
android
[4]
3,892,397
3,892,398
Traversing through a generic collection
<p>Lets say I have function </p> <pre><code>void sell(Collection&lt;? extends T&gt; items) { for (? e : items) { stock.add(e); } } </code></pre> <p>as you can see i want to iterate through the items, but I cannot use the notation <code>? e</code>, because it spits out the error "illegal start of expression".</p>
java
[1]