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
4,005,571
4,005,572
display imageView
<p>if i have an ImageView and i want to display it if sum = 10 otherwise it must be hidden how can i do this in java </p> <pre><code> &lt;ImageView android:id="@+id/a" android:src="@drawable/cancel" android:layout_width="25dp" android:layout_height="50dp" android:layout_marginTop="20dp" android:layout_marginLeft="20dp" android:contentDescription="@string/delete" &gt;&lt;/ImageView&gt; </code></pre> <p>thansk </p>
android
[4]
2,093,629
2,093,630
jQuery Display Horizontal Scale Multiple Marker
<p>I am looking for jQuery Solution to display the 4 values on a horizontal scale line. The values are Minimum, Maximum, Average, and Current. It is not a 2 Dimensional Graph. Just a simple 4 points on a single horizontal line with the markers pointing to those points.</p> <p>To show what I am trying to achieve, here is a sketch</p> <p><img src="http://i.stack.imgur.com/aOPh7.png" alt="enter image description here"></p>
jquery
[5]
4,348,641
4,348,642
Object class override or modify
<p>Is there possibility to add method to object class, to use method on all objects?</p>
python
[7]
627,113
627,114
Android Class Tree
<p>I'm fairly new to programming with the Android SDK. Was wondering if a program existed that shows the class and package tree with the source code in an easy to read format.</p> <p>Was thinking something like <a href="http://uncodex.elmuerte.com/" rel="nofollow">UnCodeX</a> but for Android rather than UnrealScript.</p> <p>Also preferably for Linux?</p>
android
[4]
1,907,874
1,907,875
python saving the excess of a float to int conversion
<pre><code>x=10.5 if x==10.5: x=int(x)+1 y= .5 </code></pre> <p>ok i have x=10.5 i want to round up to 11 but say the .5 to use later is there any way to do this when i dont know what x will be all the time?</p> <p>i have to real place to start or even if its possible i do know how to change it to an int but i want to store what ever it took off and store to y right now id have to write 100 of if statments to figure what do say and that just doent strike me as the best way to do it</p>
python
[7]
5,697,410
5,697,411
How to make a double 'continue' in a loop?
<p>Is it possible to make a double continue and jump to the item after the next item in the list in python?</p>
python
[7]
1,853,506
1,853,507
How to delete duplicate values in an array?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/9673/remove-duplicates-from-array">Remove duplicates from array</a> </p> </blockquote> <p>I have an int array which contains a defined number of elements, all positive. I want to get an array from this one where all the elements appear only once. e.g. If the first array was something like <code>{2000,2011,2011,2012,2009,2009,2000}</code>, I want to get this <code>{2000,2011,2012,2009}</code>. How can I do this? I tried lots of things with for loops but I can't manage to do something good.</p>
c#
[0]
4,963,056
4,963,057
Two separate console windows for input and output?
<p>I have two threads - one awaits for input and the other is printing the debugging info.</p> <p>However only one console window, so I can't type 'exit' (or whatever to stop the process), because <code>System.out.println</code> constantly prints the stuff. Can I have two separate console windows for each?</p> <p>P.S. I wouldn't want to use Swing just for this purpose - there must be a way.</p>
java
[1]
342,234
342,235
What is the difference in php5 between $this and &$this
<p>I have some confusion about $this and &amp;$this, please describe this point .</p> <h3>Update:</h3> <p>Thanks for reply. I know about pass by value and pass by reference. Please see the following program.</p> <pre><code>///////////////////////////////////////////////////// class my_class { var $my_var; function my_class ($var) { global $obj_instance; $obj_instance = $this; $this-&gt;my_var = $var; } } $obj = new my_class ("something"); echo $obj-&gt;my_var; echo $obj_instance-&gt;my_var; //////////////////////////////////// </code></pre> <p>In this program <code>$obj_instance = $this;</code> is copy the variable but output of this somethingsomething but when I am using <code>$obj_instance = &amp;$this;</code> the output is somethings. Why is it different?</p> <p>Thank you.</p>
php
[2]
454,154
454,155
What is the differnce between these two types using jquery
<pre><code> $('tr td:first-child').click(function() { var foobar = $(this).text(); $("#showgrid").load('/Product/List/Item?id=' + foobar); }); </code></pre> <p>when I am seding foobar value like this in the Actionresult method I am getting string id value perfectly but I am not able to display the grid?</p> <p>but intresting thing is when I am seding like this</p> <pre><code> $("#showgrid").load('/Product/List/Item?id=' + "12345"); </code></pre> <p>then I am able to display the grid.. foobar result is same 12345..</p> <p>what is the differnt between these two types?</p> <p>can any body help me out.. </p> <p>thanks</p>
jquery
[5]
1,325,399
1,325,400
javascript force date into input field
<p>i have 2 input fields for a check in date and a check out date. when the user puts in the dates it calculates the nights. However i dont want the user to be able to put a date 30 days after the check in date. Ive used an alert to bring up a message if nights is greater then 30 however the date u selected goes into the check out date. Im trying to use innerHTML to force the date in the check out to be what i want it to be ie 1 day after the check in date if they have selected more then 30 days. Heres part of my code.</p> <pre><code>function DoDepart() { Date.fromUKFormat = function(sUK) { var A = sUK.split(/[\\\/]/); A = [A[1],A[0],A[2]]; return new Date(Date.parse(A.join('/'))); } var a = Date.fromUKFormat(document.getElementById('datepicker').value); var b = Date.fromUKFormat(document.getElementById('departure').value); var x = ((b - a) / (24*60*60*1000)); if (x &gt; 30) { alert("check out date must be within 30 days of your check in date"); document.getElementById('departure').innerHTML = 'hey';&lt;!--this bit must be wrong } document.getElementById('n').value = x; }; </code></pre> <p>any help would be appreciated</p>
javascript
[3]
5,293,832
5,293,833
How to avoid IllegalStateException during updating adapter?
<p>Is there any way to avoid <code>IllegalStateException</code> during updating listView?? it gives error like the content of adapter has changed but ListView did not receive notification. so tell me any way to avoid or catch that exception.</p>
android
[4]
5,958,672
5,958,673
Unable to explode on 'þ' when using file_get_contents()
<p>I need to get the contents of a remote file, and then explode those contents on the symbol: "þ".</p> <p>I can make it work if the string I am exploding is just a local variable, but I can't get it to work with file_get_contents();</p> <pre><code>$string = '1þClassic Los 1/10þþ15þ1þTrueþ2þCú'; $parts = explode("þ", $string); var_dump($parts); </code></pre> <p>result:</p> <pre><code>array(8) { [0]=&gt; string(1) "1" [1]=&gt; string(16) "Classic Los 1/10" [2]=&gt; string(0) "" [3]=&gt; string(2) "15" [4]=&gt; string(1) "1" [5]=&gt; string(4) "True" [6]=&gt; string(1) "2" [7]=&gt; string(2) "Cu" } </code></pre> <hr> <pre><code>$string = file_get_contents('file.txt'); $parts = explode("þ", $string); var_dump($parts); </code></pre> <p>result:</p> <pre><code>array(1) { [0]=&gt; string(42) "1þClassic Los 1/10þþ15þ1þTrueþ2þCú" } </code></pre> <p>Why can't I explode on that symbol when I use file_get_contents() ?</p>
php
[2]
3,783,672
3,783,673
Why when you return object by reference you dont need to be worried that the reference will be destroyed?
<p>you have the following:</p> <pre><code>Person&amp; getPersonByName(string name); </code></pre> <p>Why don’t you need to be worried that the return person from the getPersonByName will be destructed as soon as the method ended so the caller method will work on destructed data.</p> <p>Thank you</p>
c++
[6]
3,116,175
3,116,176
how to get mouse position in windows and auto-click somewhere
<p>I want to write a program in C# like Ghost-Mouse or auto-clicker. It will find the mouse location in windows and click there as i instructed. The question is, What code should I write to find specific mouse x and y locations and click globally. Can I get a sample code please? Thanks in advance.</p>
c#
[0]
2,635,160
2,635,161
Javascript: How can I declare non-global static methods?
<p>How can I declare non-global static methods in js?</p> <pre><code>foo.bar = function() { function testing{ console.log("statckoverlow rocks!"); } function testing2{ console.log("testing2 funtction"); } } </code></pre> <p>How can I call the testing functions? I am a newbie in JS. </p> <p>Thanks for help.</p>
javascript
[3]
4,264,311
4,264,312
Array to single string with Index
<p>I have a NSMutableArray that has a list of data. I use a for (i++) to create a action on every list item after the view has been loaded. So i create a NSString like this:</p> <pre><code>NSString *localString = [detailListArray objectAtIndex:i]; </code></pre> <p>So when i NSLOG the localString i see that the data of that row has been loaded in to the NSString.</p> <pre><code>C, { ID = 0; Name = "PLISTFILE.plist"; } </code></pre> <p>)</p> <p>But i need an NSString that only has the value of the field Name = "" in the content. So i need an NSString that has its row value but not with ID etc. only the name value.</p> <p>I have tried NSDictonary but couldn't get it working. Please help!</p>
iphone
[8]
3,175,281
3,175,282
Need specific time each week in PHP
<p>I have a DIV on a page that I wanted to show only on Thursdays between 7pm and 8pm (local time) on a site. I made a post a while back and found my answer for that. <a href="http://stackoverflow.com/questions/9230462/show-something-at-a-specific-time-each-week-using-php">Previous Post Here.</a></p> <p>I was using this code to do so:</p> <pre><code>if( date('l') == "Thursday" &amp;&amp; date('G') &gt;= 19 &amp;&amp; date('G') &lt; 20 ) </code></pre> <p>However now I need to show the div from 6:59:30 to 8:01pm (server time) and I'm not quite sure how I would format the statement above for that?</p> <p>This would need to run weekly for an indefinite time until I remove the code.</p>
php
[2]
2,372,767
2,372,768
Session variable not storing the selected drop down value
<p>I am trying to store a selected drop down value in session variable and every time i print that variable which i am using on other page it shows me the last value of array from which i am populating my drop down basically. here is the code;</p> <pre><code>&lt;?php $options = array('2CHECKOUT','PAYPAL'); ?&gt; &lt;select name="payment" style="width:225px;" id ="mySelect"&gt; &lt;?php foreach($options as $opt) { ?&gt; &lt;?php $selected = (isset($_SESSION['payment']) &amp;&amp; $opt == $_SESSION['payment']) ? ' SELECTED' : ''; echo '&lt;option value="'.$opt.'"' .$selected.'&gt;'.$opt.'&lt;/option&gt;'; ?&gt; &lt;?php } ?&gt; &lt;?php error_log("the session var".print_r($_SESSION['payment'])); ?&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <p>Can somebody help me?</p>
php
[2]
3,941,941
3,941,942
javascript prototype inheritance?
<pre><code>var pluginProto = m[0].prototype; var cnds = pluginProto.cnds; if (position_aces) { cnds.CompareX = function (cmp, x) { return cr.do_cmp(this.x, cmp, x); }; } </code></pre> <p>I thought above code should inherit thier values in a reverse way <br/><br/> (define var cnds -> var pluginProto.cnds = cnd -> m[0]prototype = pluginProto) <br/><br/> and I am still wondering how above code can inherit thier values to m[0]prototype without any problem. <br/><br/> what am I missing about prototype inheritance? is prototype can reference any values without <br/></p> <p>limitation of when the value created?</p>
javascript
[3]
2,906,749
2,906,750
Create form and input field through javascript
<p>I am doing my javascript assignment in which I have a form and there are multiple buttons in it. I want that javascript should render like</p> <pre><code>&lt;form&gt; &lt;input /&gt; &lt;button /&gt; &lt;/form&gt; </code></pre> <p>but it is rendering like this</p> <pre><code> &lt;form&gt; &lt;/form&gt; &lt;input /&gt; &lt;button /&gt; </code></pre> <p>sample code</p> <pre><code>var formTag = document.createElement('form'); document.body.appendChild(formTag); var txtInput = document.createElement("input"); var txtNode = document.createTextNode("0"); txtInput.setAttribute("id", "txtInput"); txtInput.appendChild(txtNode); document.form.appendChild(txtInput); </code></pre>
javascript
[3]
401,418
401,419
Gallery view scroll listener
<p>I am using a gallery view to display images from SD card. If images in the left side I want to show a arrow as the indication of that. Similarly for the right side. Simply I want to listen the scroll operation of the gallery. Is there any possible way in Android?</p> <p>I used onscroll for it but works only for tapping the gallery.</p> <pre><code> public boolean onScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { System.out.println("SCROLLED"); return false; } </code></pre>
android
[4]
329,308
329,309
looking for openid server in python
<p>I am looking for an open source server for openid. Looking for an active community project which provides an openid implementation, preferably open source code in python. </p>
python
[7]
2,482,168
2,482,169
What is the best way to represent a composite key (key containing two values) of a Class and a Boolean
<pre><code>HashMap&lt;Pair&lt;Class&lt;T&gt;,Boolean&gt;,String&gt; abc = new HashMap&lt;Pair&lt;Class&lt;T&gt;,Boolean&gt;,String&gt;(); </code></pre> <p>What is the best way to represent Pair here... Does Java offer anything?</p> <p>My key will always be a {class,boolean} pair. </p> <p>Thanks!</p>
java
[1]
491,736
491,737
.done is not a function
<p>I've another problem. I get an error in firefox and I don't know what my fault is. I always did it like this way and I never got an error. I already check lower/uppercase mistakes but I can't find anything.</p> <p>Thanks</p> <hr> <p>*<strong>$.ajax({type: "POST", url: "ajax/check_username.php", data: {username: username}}).done is not a function*</strong></p> <hr> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#username").keyup(function(){ var username = $("#username").val(); $(".usernameFeedback").fadeIn("fast"); $.ajax({ type: "POST", url: "ajax/check_username.php", data: { username: username } }).done(function( msg ) { $("#loadingImage").hide(); if(msg.status != "error") { if(msg.available == "yes") { $(".usernameFeedback span").text(msg.message); $(".usernameFeedback span").removeClass("notok"); $(".usernameFeedback span").addClass("ok"); } else { $(".usernameFeedback span").text(msg.message); $(".usernameFeedback span").addClass("notok"); } } }); return(false); }) }); &lt;/script&gt; </code></pre>
jquery
[5]
3,704,555
3,704,556
issue regarding the horizontal scroll using page controller
<blockquote> <p>I am use this code for add the table in scrollview.</p> </blockquote> <pre><code> tblList = [[UITableView alloc] initWithFrame:CGRectMake(20+(i*320), 100, 280, 300) style:UITableViewStylePlain]; tblList.delegate=self; tblList.dataSource=self; [self.ListscrollView addSubview:tblList]; [tblList release]; (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; if(tableView==tblList) { [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil]; cell=self.tblViewCell; self.tblViewCell=nil; UILabel *datelabel1 = (UILabel*)[cell.contentView viewWithTag:2]; datelabel1.text = [NSString stringWithFormat:@"%@",[[retriveTaskDesc objectAtIndex:indexPath.row] valueForKey:@"description"]]; return cell; } </code></pre> <blockquote> <p>when I change the scrollview the value of the retriveTaskDesc is change. I am setting that value in scrollViewDidScroll then I reload the table I get the value in cellForRowAtIndexPath but in the display of label the value are not displaying correctly the old value of retriveTaskDesc is displaying in that label.</p> </blockquote>
iphone
[8]
3,404,829
3,404,830
A good manual on c#
<p>Hey all; i have learned the c# language moving away from java , i have learned all what's new in that language and i found it to be pretty much interesting , i would like to enthusiasm to attempt implementing some projects but yet i have no ideas in mind. does anyone happen to know a good lab manual or something similar? Thanks Alot</p>
c#
[0]
406,627
406,628
jquery filter raw html form load()
<p>I want to load part of an external page int on OS X widget. Using JQuery I can load the page but I then encounter errors trying ot put it in to the page. </p> <p>I am having a problem filtering the returned html before I put it on the page.</p> <p>I would like to be able to fetch the page, filter out the table I want, then append it to the page (at loadArea div)</p> <pre><code> $(document).ready(function() { $().load("source.html", function(request) { $("#loadArea").append(request).filter(".myclass"); // this is in callback because the loading is asynchronous and you cant filter it before it is all there) }); }); </code></pre> <p>When I do the above nothing appened to the screen and the page is blank (it should be the colour black -> something is breaking the whole page)</p> <p>Is doing it with the empty selector $() the right way? Am I going about it generally in the right way?</p>
jquery
[5]
5,511,817
5,511,818
C++ private members accessible?
<p>I have this project in our signals class which uses C++. I was tinkering with our instructors code when I saw this:</p> <pre><code>ListData::ListData(const ListData&amp; newlist) : Data(), nbNodes(newlist.nbNodes) {} </code></pre> <p>This is a "copy constructor" as he says, and should be roughly equivalent to the following:</p> <pre><code>ListData::ListData(const ListData&amp; newlist){ Data = ""; //copy nbNodes of newList to current instance nbNodes = newlist.nbNodes; } </code></pre> <p>But what bothers me is that <code>nbNodes</code> is a private member. <strong>How could this constructor access the <code>nbNodes</code> of the passed <code>newList</code> if it's private?</strong></p>
c++
[6]
5,435,028
5,435,029
Asyncronous Servlet do not serves multiple request
<p>i have some problem with async request in java... Simply have following servlet: </p> <pre><code>public class Notifier extends HttpServlet{ public void service(final ServletRequest req, final ServletResponse res){ final AsyncContext ctx = req.startAsync();` ... } </code></pre> <p>I thoght, that this servlet serves thousand request (by few threed), but wen i test it by ajax only 6 request received on servlet side;</p> <p>test code snippet is following: </p> <pre><code>for(i=0;i&lt;5000;i++){ var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { </code></pre> <p>  } }</p> <pre><code>xmlhttp.open("GET","http://localhost:8080/Notifier?mode=authorised&amp;a="+i,true); xmlhttp.send(); } </code></pre> <p>I have not idea why Notifier servlet does not serve all request which i send from browser...</p> <p>Thank you in advance...</p>
java
[1]
3,982,172
3,982,173
Changing background onchange on check box: jquery
<p>I am new to jquery and i am having problem i want to change background color of parent div when i click at checkbox</p> <p>Please Advice</p> <p>Thank You </p> <pre><code>&lt;script type="text/javascript"&gt; function chngbg(id){ id2 = "d-" + id; $(id2).addClass('bg'); } &lt;/script&gt; &lt;div class="dataDiv" id="d-&lt;?=$row-&gt;id?&gt;"&gt; &lt;input type="checkbox" onchange="chngbg($(this).val());" value="&lt;?=$row-&gt;id?&gt;" name="cbox" /&gt;&lt;/span&gt; &lt;/div&gt; </code></pre>
jquery
[5]
5,128,293
5,128,294
Convert Arraylist to message
<p>How do i convert an arraylist into a message</p> <p>This is for converting an msg to arraylist.</p> <pre><code>ArrayList extractData = (ArrayList) msg.obj; </code></pre> <p>How do i do the opposite? Is this right?</p> <pre><code>Message msg=(Message) arraylist; </code></pre>
android
[4]
2,258,347
2,258,348
what's reason for this error?
<p>Terminating app due to uncaught exception 'NSGenericException', reason: '<em>*</em> Collection &lt;__NSArrayM: 0x175800> was mutated while being enumerated</p>
iphone
[8]
3,504,595
3,504,596
need help with javascript hint with php
<p>i am using javascript field hint. problem occurred when I try to put code php translation into the hint itself.</p> <pre><code>&lt;?php $interest= '&lt;span class="hint"&gt;Eg: Cooking or Singing or Dancing&lt;span class="hint-pointer"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;';?&gt; </code></pre> <p>if i try to put </p> <pre><code> &lt;?php $interest = '&lt;span class="hint"&gt;__("Eg: Cooking or Singing or Dancing")&lt;span class="hint-pointer"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;';?&gt; </code></pre> <p>the field hint at page will be displayed like this "<strong>__("Eg: Cooking or Singing or Dancing")</strong>"</p> <p>if i try to put</p> <pre><code>$interest = '&lt;span class="hint"&gt;__('Eg: Cooking or Singing or Dancing')&lt;span class="hint-pointer"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;';?&gt; </code></pre> <p>or </p> <pre><code>$interest = '&lt;span class="hint"&gt;' __('Eg: Cooking or Singing or Dancing')'&lt;span class="hint-pointer"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;'; </code></pre> <p>error will be displayed:</p> <pre><code>Parse error: syntax error, unexpected T_STRING in C:\wamp\www\estandard\app\views\companies\company.ctp on line 7" </code></pre> <p>thanks in advance.</p>
php
[2]
296,107
296,108
Shopping list in Python
<p>I'm learning Python (and programming in general) by making small programs. Below is a basic shopping program which will return a list of items to buy based on the selected food.</p> <p>I'd like to improve it and allow user to select several foods at once (e.g. user input would be "1, 2, 3") and return a list of ingredients based on that.</p> <p>What kind of approach should I take? I'm using Python 2.7 and here is my existing code:</p> <pre><code>mm_soup = ['minced meat', 'potatoes', 'frozen vegetable'] sunday_soup = ['chicken with bones', 'noodles', 'soup vegetable'] gulas = ['pork meat', 'food cream', 'potatoes', 'onion', 'frozen peas'] print "What would you like to cook on weekend?" print "Here are the options:" print "1. Minced Meat Soup" print "2. Sunday Soup" print "3. Gulas" choose = raw_input("&gt; ") if choose == '1': print "Buy", ", ".join(mm_soup) + "." elif choose == '2': print "Buy", ", ".join(sunday_soup) + "." elif choose == '3': print "Buy", ", ".join(gulas) + "." else: print "Hmmm. No such food on the list." </code></pre>
python
[7]
1,763,049
1,763,050
int.Parse, Input string was not in a correct format
<p>How would I parse an empty string? <code>int.Parse(Textbox1.text)</code> gives me an error: </p> <blockquote> <p>Input string was not in a correct format.<br> System.FormatException: Input string was not in a correct format.</p> </blockquote> <p>If the text is empty (<code>Textbox1.text = ''</code>), it throws this error. I understand this error but not sure how to correct this.</p>
c#
[0]
4,656,939
4,656,940
Multiline label in asp.net
<p>I want to use a multiline label but as the control is brouser dependent,even on setting the height width and wrap property of the label control i am unable to display a multiline text...It doesn't support every brouser in the same way... Can anyone help me out</p>
asp.net
[9]
3,288,940
3,288,941
Android Simulate Roaming
<p>I have an application which takes certain action when Phone gets a Roaming event.To test that its perfectly working , can i simulate the SIM Roaming event.Its not practically possible for me to do that in reality</p>
android
[4]
5,736,462
5,736,463
String to Multidimensional Arrays
<p>I have a string which represents a multidimensional array in the format: [[A, a], [B, b]] </p> <p>Is there a easy way to convert this string into multidimensional arrays. </p> <p>Though, for now I am just looking for the above solution the string itself is bit more complicated.</p> <p>for example in [[A, a], [B, b]] </p> <pre><code>where A could be "This is a sample text, but could be complicated" There is a high possibility that the delimiter comma exists in the text (which will be escaped) </code></pre> <p>Thanks, for any suggestions.</p>
java
[1]
1,106,834
1,106,835
After Window.history.pushState() go back to prev URL
<p>I have grid of products. Each product row in the grid can be expended to show the full product details (done with Ajax).</p> <p>For SEO purposes when a row is expended am using :</p> <pre><code>window.history.pushState() </code></pre> <p>to change the URL.</p> <p>For example: URL such as:</p> <pre><code>http://mydomain.com/bouquets/cityName </code></pre> <p>will be changed to:</p> <pre><code>http://mydomain.com/bouquets/cityName/prodId </code></pre> <p>The problem is when another row expended the new URL will be:</p> <pre><code>http://mydomain.com/bouquets/cityName/prodId/prodId </code></pre> <p>The third row expended:</p> <pre><code>http://mydomain.com/bouquets/cityName/prodId/prodId/prodId/ </code></pre> <p>and so on...</p> <p>When a row expended after the first time, I need to do in JS something like:</p> <pre><code>&lt;a href= "../URL" &gt; </code></pre>
javascript
[3]
2,963,411
2,963,412
Page Redirection Issue using session Id
<p>I have login page I am doing authentication using http handler to precompiled application.</p> <p>Already in the application sessions are used to redirect to a page after authentication.</p> <p>Please suggest me how can i redirect using session variable through http handlers in precompiled application.</p> <p>Note:i have no idea which session variable used.</p>
asp.net
[9]
5,161,410
5,161,411
Environment variables passed by Runtime.exec(String)
<p>Are the environment variables of the parent process(e.g. shell) available in the environment in which a child process that is invoked using Runtime.exec(command) run? I had a look at the API documentation but it's not specified there. </p> <p>My use case is this</p> <p><code>mainScript.sh</code> invokes <code>java MainClass</code></p> <p><code>MainClass</code> invokes <code>Runtime.exec("hi.sh")</code></p> <p>Now, is a variable <code>MY_ENV</code> that is set and exported in <code>mainScript.sh</code> available to <code>hi.sh</code>?</p> <p>PS: I'm aware of the 2nd API that takes explicit <code>String[] envp</code>.</p> <p><a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4064912" rel="nofollow">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4064912</a> has some vague info.</p>
java
[1]
1,974,180
1,974,181
whats the best way to find multiple appearance of string within a list in python?
<p>Lets say i have the following list:</p> <blockquote> <p>['ab=2','bc=5','ab=1','cd=6','ab=7']</p> </blockquote> <p>whats the best (efficient) way to find all appearance of the word 'ab' in this list</p>
python
[7]
2,742,289
2,742,290
how to add an image source inside href in code behind in asp.net
<p>i'm developing a asp.net website.I have a xml file. it has a structur lie :</p> <pre><code> &lt;Image Header="AboutUS"&gt; &lt;Imagepath&gt;guest.jpg&lt;/Imagepath&gt; &lt;imagetitle&gt;welcomeguest&lt;/imagetitle&gt; </code></pre> <p></p> <p>i have to read this data and display this in a asp.net page: My code look like this. </p> <pre><code> XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("~/multipleimage.xml")); XmlNode root = doc.DocumentElement; XmlNodeList nodeList = root.SelectNodes("Image"); foreach (XmlNode node in nodeList) { HtmlAnchor a1 = new HtmlAnchor(); Image imagesource = new Image(); string path = "Uploads/"; string imageurl = path + node.SelectSingleNode("Imagepath").InnerText; imagesource.Height = 95; imagesource.Width = 95; Div1.Controls.Add(imagesource); </code></pre> <p>now i want to use light box effect for this images.but i dont know how to give ahref for image from code behind...</p> <p>Need help...</p>
asp.net
[9]
1,632,067
1,632,068
How to get the date of every sunday
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/590385/how-to-get-all-dates-of-sundays-in-a-particular-year-in-java">How to get all dates of sundays in a particular year in Java</a> </p> </blockquote> <p>How can I get the date of the coming Sunday?, I am creating a time sheet system so I would like to always get the next Sunday date... until the date has passed.. </p> <p>so if it's Monday it should give me the date of the next Sunday, and on Monday 12:00 am, the next next Sunday and etc...</p> <p>How can I do this in java?, to always get the next Sunday date?</p> <p>Thank you</p>
java
[1]
1,375,943
1,375,944
Read android device info from windows
<p><br> Is it possible to get android device info (e.g. firmware version) from windows, when device is connected with PC by USB cable? As I understand AT commands are not available. I was trying to use "adb", but I cannot see any usefull options. Maybe there is some text file with device info on the filesystem of the phone, so I could use "adb shell" to read this file?<br> Regards!</p>
android
[4]
5,726,528
5,726,529
Division of integers in a String
<p>I have this string the first is the hours, second minutes, third seconds.</p> <pre><code>744:39:46 </code></pre> <p>How do I divide the hours '744' in PHP?</p>
php
[2]
3,293,598
3,293,599
Can't add contents to file using file_put_contents
<p>I'm outputting the contents of a file to another file, but the contents is just not being put into the second file. It creates the file but does not put the output to the file, it displays the output on the screen.</p> <pre><code>require_once 'templates/'.$layout.'/contact.php'; ob_start(); $content = ob_get_clean(); file_put_contents($dir.'/contact.php',$content); chmod($dir.'/contact.php',0777); </code></pre> <p>The funny thing is when I do this file_put_contents($dir.'/contact.php','dsf'); it writes to the file, when doing file_put_contents($dir.'/contact.php',$content); is does not?</p>
php
[2]
1,374,608
1,374,609
Tutorial for Spinning Wheel Android?
<p>Where can I find a tutorial for spinning wheel (don't know if this the correct terminology) android? This one like what I am looking for:</p> <p><img src="http://i.stack.imgur.com/0GpVS.jpg" alt="enter image description here"></p> <p>but I always come up with this in search result:</p> <p><img src="http://i.stack.imgur.com/TaMs8.png" alt="enter image description here"></p>
android
[4]
1,642,750
1,642,751
Delegates and Memory Leaks in iPhone?
<p>I have a tableview(being IBOutlet) and tableviewController in my ViewController </p> <p>what I do is</p> <p>//.... allocation for tableviewController self.tableview.delegate = tableviewController;</p> <p>//now this increases the retain count of tableviewController...</p> <p>So in deallocation do I need to set the tableview delegate to nil...like</p> <p>self.tableview.delegate = nil; or self.tableview = nil; // is sufficient to make sure that the retain count of tableviewController get decreased by 1.</p>
iphone
[8]
4,314,856
4,314,857
Checking to see if a string is already added into a list c#
<p>I am working on some c# I have inherited.</p> <p>I have a problem in that something is being repeated twice in the output, I think I have identified in the controller where this is being added;</p> <pre><code>if(!isDirectUK) rollingPriceSupp.Add(new KeyValuePair&lt;string, float&gt;("Personal Insurance", (float)insuranceCost)); ViewData["vRollingPrice"] = rollingPriceSupp; </code></pre> <p>How can I put a check at that point to see if the string "Personal Insurance" has already been added, so as to avoid it bieng repeated twice ?</p>
c#
[0]
625,640
625,641
how to which version of javascript the browser is using by javascript?
<p>Is it possible to detect which javascript version the browser currently is using.</p> <p>I want to know if it is Ecmascript 4/5/6</p> <p>Is it possible by using the console??</p>
javascript
[3]
5,505,663
5,505,664
How to make my app support for multiple screen with unique alignment of all elements present on screen?
<p>i am doing a android application that having the table layout and buttons i want to support my app to multiple screens what is the precautions i have to take any help,thanks in advance</p>
android
[4]
3,419,548
3,419,549
Connection code to connect iphone to web server
<p>Can anyone help me to connect iphone to web server??</p>
iphone
[8]
2,898,922
2,898,923
How stop alertDialog excecution
<p>I need to stop the excecution app, until the user click OK. This's my method...</p> <pre><code>public void mostrarMensaje(String mensaje) { final Message NO_HANDLER = null; final AlertDialog alertDialog = new AlertDialog.Builder(this).create(); alertDialog.setTitle("Atención"); alertDialog.setMessage(mensaje); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { alertDialog.setButton("OK",NO_HANDLER) ; alertDialog.dismiss(); } }); alertDialog.setIcon(R.drawable.listo); alertDialog.show(); } </code></pre>
android
[4]
5,778,802
5,778,803
Access shared drive using OPENDIR
<p>I want to display all the drives in my system through PHP, So i used opendir. Here a problem i had already mapped a drive in the name of Z: this drive not showing while we try to displaying the drives in browser. </p> <p>Basically i am having c: drive and additionally i have mapped the Z: drive from network connection. Please help me how to show both the drives in browser</p>
php
[2]
374,210
374,211
Do I really need to add "\n" to every PHP statement that I write in a script if I dont want my output to be like totally messed up?
<p>I'm learning PHP and writing it and executing in the browser is cumbersome. So I write it as a script and execute it on the terminal, such as</p> <pre><code>me@machine $ php script.php </code></pre> <p>However, it seems to me, all statements are printed to the same line, if not explicitly a newline character is also printed.</p> <pre><code>&lt;?php echo "Hello World.\n"; ?&gt; </code></pre> <p>If I omit <code>\n</code>, I end up with</p> <pre><code>me@machine $ php hello_world.php Hello World. &gt; me@machine $ </code></pre> <p>which kind of is lame.</p> <p>Do I really, like really really (as in "totally really"), need to type <code>\n</code> for every statement I like to test?</p>
php
[2]
303,259
303,260
Javascript and Inheritance
<p>Say I have a <em>Class</em>:</p> <pre><code>function Foo() { this.foo1 = null; this.foo2 = function() { return false;}; } </code></pre> <p>And I want other objects to inherit variables &amp; functions from it.</p> <pre><code>function Bar(){} function Baz(){} </code></pre> <p>Then instantiate my objects:</p> <pre><code>var bar = new Bar(); bar.foo1 // returns null bar.foo2() // returns false </code></pre> <p>What's the proper function to <em>include</em> <code>Foo</code> in <code>Bar</code> and <code>Baz</code>?</p> <hr> <p>I already did <code>Bar.prototype = new Foo();</code> but it seems to fail on our beloved IE (&lt;9).</p>
javascript
[3]
304,021
304,022
How to check an item in a list view programmatically?
<p>Iam using a list item in my application. Iam using the adapter:</p> <pre><code>adapter adapter = new ArrayAdapter&lt;Settingsmodel&gt;(this, android.R.layout.simple_list_item_checked, listItems); </code></pre> <p>In that i want to check the tick mark of the selected list item manually. I searched a lot. Could'nt find a way to do it. Please help me if anybody knows.</p>
android
[4]
3,975,272
3,975,273
Android show selected ringtone
<p>In my app,there is a option to change a ringtone. Ringtone picker pops up and user can change it. So when restart the tablet that ringtone is set but not marked on the picker. How can I do that ? In other works, ringtone picker shows that there is no rightone set.</p> <pre><code>private void setRington() { Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Select ringtone for notifications:"); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false); intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION); if (notification_uri == null) { intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri)null); } else { intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(notification_uri)); } startActivityForResult(intent, 5); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK &amp;&amp; requestCode == 5) { Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); if (uri != null) { RingtoneManager.setActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE, uri); Settings.System.putString(getContentResolver(), Settings.System.NOTIFICATION_SOUND, uri.toString()); notification_uri = uri.toString(); } } } </code></pre>
android
[4]
1,246,428
1,246,429
what is the difference between Convert.ToInt16 or 32 or 64 and Int.Parse?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/199470/whats-the-main-difference-between-int-parse-and-convert-toint32">Whats the main difference between int.Parse() and Convert.ToInt32</a> </p> </blockquote> <p>Hi</p> <p>I want to know what is the different between :</p> <pre><code>Convert.ToInt16 or Convert.ToInt32 or Convert.ToInt64 Int.Parse </code></pre> <p>both of them are doing the same thing so just want to know what the different?</p>
c#
[0]
479,185
479,186
ASP.Net Control.ResolveUrl quirks
<p>I have a weird issue. When resolving urls for script elements, the src element must be in ' '. With link elements the href must be in " ", or the code nugget gets rendered into html for some reason. The code snippet below illustrates the problem more clearly. Why is this the case? </p> <pre><code>&lt;script src='&lt;%:Page.ResolveUrl("~/JavaScript/jQuery/jquery-1.7.2.js") %&gt;' type="text/javascript"/&gt; &lt;link href="&lt;%:Page.ResolveUrl("~/CSS/Foundation/foundation.css") %&gt;" rel="stylesheet" type="text/css" /&gt; </code></pre> <p><strong>Edit</strong> Just noticed the script element src tag works fine when enclosed in " " or ' ', but the link element href tag only seems to work when enclosed in " ".</p>
asp.net
[9]
386,504
386,505
Android:How to add support the javascript alert box in WebViewClient?
<p>Hi I implement the many things using the webViewClient like onUnhandledKeyEvent,shouldOverrideUrlLoading and more.If want to add the support for alertbox then need to switch to WebChromeClient then i can not do other things.Any one know how mix the both future?<br/> I have check the code for javasript alert box at <a href="http://lexandera.com/2009/01/adding-alert-support-to-a-webview/">http://lexandera.com/2009/01/adding-alert-support-to-a-webview/</a></p> <p><br/> Thank you</p>
android
[4]
3,799,011
3,799,012
PHP: How to access the first element of an array returned by a static function
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4639265/php-explode-and-array-index">php explode and array index</a> </p> </blockquote> <p>In PHP 5.3...</p> <p>I have a dynamic static method that always returns an array. In some cases it will return an array containing only one element. I want to assign, in one statement, the first element of the array to a variable. At the moment I have to do this:</p> <pre><code>$user = User::findByEmail($_SESSION['email']); $user = $user[0]; echo $user; </code></pre> <p>I want to avoid the part...</p> <pre><code>$user = $user[0]; </code></pre> <p>I expect something like this to work:</p> <pre><code>$user = User::findByEmail($_SESSION['email'])[0]; // not working </code></pre> <p>or</p> <pre><code>$user = User::findByEmail($_SESSION['email'])-&gt;get(0); // not working </code></pre> <p>or</p> <pre><code>$user = User::findByEmail($_SESSION['email']).get(0); // not working </code></pre>
php
[2]
3,710,544
3,710,545
How can I use an initialize a static array with a known num of elements?
<p>I have an enum type with a last item 'num_of_types'. (that is, it will be 15, in example) I'like to have a static array_of_types[num_of_types], to easily count the number of each type I create. My idea is to have: array_of_types[the_type]++;</p> <p>But, I have no idea to declare and initialize this static array?</p>
c++
[6]
4,043,851
4,043,852
How can I target elements whose classes don't contain the ID of this element?
<p>Specifically, I want to say: <em>for elements whose class value doesn't contain this element's ID value, execute this function</em>.</p> <p>For example, clicking <code>#foo</code> will execute <code>fadeOut()</code> on the list items whose classes don't contain <code>.foo</code> in the following HTML:</p> <pre><code>&lt;button id="foo"&gt;foo&lt;/button&gt; &lt;button id="bar"&gt;bar&lt;/button&gt; &lt;button id="baz"&gt;baz&lt;/button&gt; &lt;ul&gt; &lt;li class="foo"&gt;Lorem&lt;/li&gt; &lt;li class="foo bar"&gt;Ipsum&lt;/li&gt; &lt;li class="baz"&gt;Dolor&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>So upon clicking <code>#foo</code>, the last list item should disappear, since the first two both contain the <code>.foo</code> class.</p>
jquery
[5]
3,559,529
3,559,530
Open window.print() in a new window
<p>I'm currently configuring a print button for a website I'm working on. The print button use the window.print() function with the onclick event. It's working correctly but it opens the print in the same window and I would like to open it in a new window instead.</p> <p>I've tried with a target="_blank" but with the same result.</p> <pre><code>&lt;a href="javascript:" onclick="javascript: window.print();" target="_blank"&gt; &lt;img src="/resources/images/skins/icisherbrooke/b-imprimer.jpg" width="64" height="12" border="0" /&gt; &lt;/a&gt; </code></pre> <p>Is there another way than target to open the print window in a new window?</p> <p>Thanks.</p>
javascript
[3]
3,200,212
3,200,213
UISlider, slide to unlock
<p>I need to add an UISlider control in my iphone application. That should look like the "Slide to unlock" slider which is displayed in any iphone or ipod touch. I am unable to figure out how to do this.</p> <p>In slide to unlock slider, if we leave the thumbImage in the middle of the slider it comes back to the left side automatically. How do we get this kind of functionality working in our project.</p>
iphone
[8]
2,957,364
2,957,365
How to set Custom EditTextField properties in android?
<p>I am new to android .can any one solve the following problem? I just create the class like below .I need to know how to set property for the Edit text field</p> <pre><code>public class CustomEditText extends EditText{ public CustomEditText(Context context) { super(context); // TODO Auto-generated constructor stub } </code></pre> <p>}</p> <p>Note: I mean the property like this Edittext.setText("Demo"); Thanks in advance.</p>
android
[4]
5,872,062
5,872,063
Android StdInput and StdOutput to native process
<p>Here is some code that doesn't work. I think it should and was hoping someone could tell me why it doesn't. It started out to be one thing and then grew into this which didn't work. Now its become kind of a challenge. Basically it starts the sh shell program and attempts to send commands to it and get back the results. It works fine, once. The second time, it stops at writer.close() as if its already closed and I think it is! It it doesn't have the close() it hangs waiting for something to happen. I guess for it to close? I have tried flush() and newline() but they didn't seem to help. I have tried it in the emulator and also on a phone. Same results.</p> <pre><code>@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); body = (EditText)findViewById(R.id.bodyEditText); body.setOnEditorActionListener(mSendListener); try { // Start the shell and save the process id process = Runtime.getRuntime().exec("/system/bin/sh"); } catch (IOException e) { body.append("Shell Error\n$ "); e.printStackTrace(); } }//oncreate public void shellExec(String cmd) { try { // Create a writer for the standard input to the shell // and write the command BufferedWriter writer = new BufferedWriter( new OutputStreamWriter(process.getOutputStream())); writer.write(cmd+"\n"); writer.close(); // Create a reader for the standard output of the shell // and read the result BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream())); int i; char[] buffer = new char[4096]; StringBuffer output = new StringBuffer(); while ((i = reader.read(buffer)) &gt; 0) output.append(buffer, 0, i); reader.close(); // Add the result to the EditText text body.append(output.toString()+"\n$ "); } catch (IOException e) { body.append(cmd+" Error"+"\n$ "); } }//shellexec </code></pre>
android
[4]
2,922,766
2,922,767
Printing values from a loop in PHP
<p>Below is a loop I have in my code. Once when the starting and ending values are a zero the loop prints a value zero (0). But what I need to do here is when the starting and ending value is zero, it should print nothing. Can someone please tell me how to change the approach?</p> <pre><code>while ($recQ = mysqli_fetch_array($runx)) { for($ii=$recQ['start']; $ii&lt;=$recQ['end']; $ii++) { if (!in_array($ii, $exclude)) { echo $ii.", "; } } } </code></pre>
php
[2]
6,033,311
6,033,312
how to send email using only through javascript or jquery?
<p>I am doing a project on platform java using jsp and servlets I want to implement logic for a contact form for people who want to tell me feedback from the site The feedback would go directly to the adminstrator's email. How would I do that?</p>
javascript
[3]
3,730,361
3,730,362
Console.Read not returning my int32
<p>I don't get why my integer isn't coming out correctly, Console.Read() method says it's returning an integer, why isn't WriteLine displaying it correctly?</p> <pre><code>int dimension; dimension = Console.Read(); Console.WriteLine(""+ dimension); </code></pre>
c#
[0]
5,806,102
5,806,103
What does ios when it calls didreceivememorywarning?
<p>I want to know What does ios when it calls didreceivememorywarning? Thanks</p>
iphone
[8]
1,869,751
1,869,752
add an event to an element
<p>I am a new learner of javascript, the following code is from the javascript definitive guide.</p> <pre><code>function addEvent(elem, evtType, func) { if (elem &amp;&amp; typeof(elem) == "object") { if (elem.addEventListener) { elem.addEventListener(evtType, func, false); } else { elem["on" + evtType] = func; } } } </code></pre> <p>why it add </p> <pre><code> if (elem.addEventListener) { elem.addEventListener(evtType, func, false); } </code></pre> <p>but the <code>window.onload</code> works ok under every browsers. the following is my test example.</p> <pre><code>&lt;script type="text/javascript"&gt; window.onload=myFuntion(); function myFuntion(){ alert("test"); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt; testtste &lt;/h1&gt; &lt;/body&gt; </code></pre> <p>it works ok under IE ff.</p>
javascript
[3]
4,815,340
4,815,341
overwrite java class in jar
<p>I have class called org.jbpm.task.Comment in my jbpm.jar.</p> <p>However, this it's a CR1 version and there is a bug in the class that I would like my application to overwrite.</p> <p>Is it fine just to have a class in my project under com.jbpm.task called Comment and everywhere even in other jars it will refer to mine?</p>
java
[1]
1,770,101
1,770,102
Inaccurate device orientation retuned by UIDeviceOrientationDidChangeNotification
<p>I'm listening to the UIDeviceOrientationDidChangeNotification in order to adjust my UI based on the device's orientation. </p> <p>The problem is that the device orientation I'm getting from the notification seems inaccurate. If I start with the phone in portrait orientation and vertical (as if taking a picture with it) the orientation I get from the notification is correct. As the tilt of the phone approaches horizontal (as in laying flat on a table top) the orientation switches to landscape. This happens much before the phone is actually flat on the table. And this is without rotating the phone towards landscape at all. Is as if it had a preference for landscape. </p> <p>When using other apps, like mail, I don't see this same behavior. It seems that mail only switches orientation once it's really sure you've gone to the new orientation.</p> <p>Any help greatly appreciated.</p> <p>Thanks,</p>
iphone
[8]
4,999,395
4,999,396
ViewWillAppear/Disappear not called when the view is created programmatically
<p>I have a root view controller class. This view has few buttons. on the click of the button, I show tab bars. So basically, I have the implementation of tab bar and navigation controlls. Basically, I have data that i shown in table view format. The other view are created programmatically. </p> <p>Now, the problem is on the root view I am able to hide the naviagtion bar using</p> <p>[self.navigationController setNavigationBarHidden:YES animated:animated];</p> <p>but, when I click on the buttons, the navigation bar is hidden from on the next view.I tried putting breaks on viewdidappear and viewdiddisapear method but these mehtods are not fired. </p> <p>Can you please help me on how to ensure that either these methods are fired or on how to get the navigation controller shown except on the first view. </p>
iphone
[8]
5,549,470
5,549,471
best way to replace a string?
<pre><code>string '/home/adam/Projects/red/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg' (length=85) </code></pre> <p>what i need is just <a href="http://localhost/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg" rel="nofollow">http://localhost/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg</a></p> <p>what is the best way doing it ? i mean useing strlen ? substr_replace ? substr ? im a bit confused what is the best way doing this? becouse there is many ways to do this.</p> <p>edit* there is no newbie tag :|</p> <pre><code> // get from database red/storage/22ff0bc0662bd323891844f6ed342cce2603490ec0_tumb_2.jpg $image_path = $this-&gt;data['products'][0]['image_small']; $exploded = end(explode('/', $image_path)); $myurl = DOMAIN; $myfullurl = $myurl."/storage/".$exploded; </code></pre> <p>// it works!, but let see the comments maybe there is a better way :)</p>
php
[2]
5,771,401
5,771,402
Why does SQL statement update more records than it needs to?
<p>I have problem with my code specifically on the update code.</p> <pre><code>private void updatebtn_Click(object sender, EventArgs e) { String Fname = fnametb.Text; String Lname = lnametb.Text; String Age = agetb.Text; String Address = addresstb.Text; String Course = coursetb.Text; { connection.Open(); OleDbCommand select = new OleDbCommand(); select.Connection = connection; select.CommandText = "Select * From Accounts"; OleDbDataReader reader = select.ExecuteReader(); while (reader.Read()) { OleDbCommand insert = new OleDbCommand("UPDATE Accounts SET Firstname=@Fname, Lastname=@Lname, Age=@Age, Address=@Address, Course=@Course WHERE Lastname='"+ reader[2].ToString()+"'", connection); insert.Parameters.Add("@Fname", OleDbType.VarChar).Value = Fname; insert.Parameters.Add("@Lname", OleDbType.VarChar).Value = Lname; insert.Parameters.Add("@Age", OleDbType.VarChar).Value = Age; insert.Parameters.Add("@Address", OleDbType.VarChar).Value = Address; insert.Parameters.Add("@Course", OleDbType.VarChar).Value = Course; insert.ExecuteNonQuery(); fnametb.Clear(); lnametb.Clear(); agetb.Clear(); addresstb.Clear(); coursetb.Clear(); listBox1.Items.Clear(); searchtb.Clear(); } connection.Close(); } } </code></pre> <p>above is my code. Whenever I update one record, all the records in the table are affected.I think there's something wrong with the reader. Please help, thanks.</p>
c#
[0]
3,069,071
3,069,072
Change content of <option> elements
<p>I have a <code>select</code> widget with a couple of AJAX enhancements.</p> <pre><code>&lt;select id="authors"&gt; &lt;option value="1"&gt;Foo Bar&lt;/option&gt; &lt;option value="2" selected="selected"&gt;Bar Baz&lt;/option&gt; &lt;/select&gt; </code></pre> <p>Now, if the selected option changes, I want to change the "content" ("Foo Bar" and "Bar Baz" in the example). How can I do that with jQuery? I tried the following, but obviously, it doesn't work.</p> <pre><code>$('#authors').change(function(){ $('#authors option[selected=selected]').html('new content'); }); </code></pre> <p>/edit: to clarify, the selector <code>'#authors option[selected=selected]'</code> works fine, it selects the correct <code>option</code> DOM element. But <code>.html('new content')</code> does nothing.</p> <p>2nd edit: OK, this is embarrassing. I tried my code in Chrome's JavaScript console, where it didn't have any effect. After jAndy clearly demonstrated that it works in jsFiddle, I tried it in the FireBug console, and there it works. Lesson learned :-)</p>
jquery
[5]
3,466,465
3,466,466
php: how to create a new form
<p>This is a newbie question...</p> <p>I receive data from the user via a form, if one of the fields I get is marked 'yes' I want to send him a new form. </p> <p>How is this done?</p> <p>edit: I know how to check the value of my original form's variable via $_POST. I know the conditionals, I'm asking for the syntax for <em>creating</em> the new form or redirecting the user to another html page with the new form.</p>
php
[2]
526,914
526,915
php speed testing of conditionals
<p>Assume there is already an if statement on the page. </p> <p>Now, out of:</p> <pre><code>a second if statement else else if </code></pre> <p>Which is fastest and which is slowest to run? </p> <p>Does it matter if $a only takes 2 possible values?</p> <p><em>edit: Sample code:</em></p> <pre><code>$a=2; if ($a==1){ ... } </code></pre> <p>THEN</p> <pre><code>if ($a==2){ ... } </code></pre> <p>OR</p> <pre><code>else { ... } </code></pre> <p>OR</p> <pre><code>else if ($a==2){ ... } </code></pre>
php
[2]
2,153,449
2,153,450
Javascript (how to check Id exist or not in IE7 Browser)
<p>How do I check if Id exist or not in IE7 browser. Below is my code but it does not run successfully in IE7.</p> <pre><code>if(document.getElementById('Username') != null) { alert("In"); } </code></pre> <p>When run this code comes true part and show alert box even though Id ('Username) does not exist.</p>
javascript
[3]
5,161,764
5,161,765
Best practices for error handling in jQuery plugin
<p>What are some of the best practices for handling errors from within a custom jQuery plugin?</p> <p>So far I am checking for the error conditions, using console.log and returning from my plugin. The idea is that I dont want to stop any other js on the page from working but still provide an error message to the user. </p> <p>The type of error conditions in particular I am thinking of are required parameters being passed in to te plugin etc.</p> <p>I am new to writing jquery plugins so please excuse this if it is a stupid question.</p> <p>I just really want to know from experienced developers what they do with regards to this.</p>
jquery
[5]
1,339,382
1,339,383
How to enable editing textfield with the delete feature working
<p>I have a textfield, which can have at most only one character. When the focus is on the textfield, (1) if the character count is more than 1, then the textfield shouldn't enable editing. (2) But we should be able to delete that one character and replace it with another. </p> <p>Right now I cant find a way to make both my conditions work. If I disable editing, the delete feature doesn't work. If I enable it, the textfield length condition is not satisfied.</p>
iphone
[8]
340,317
340,318
Problem with time zone conversion iPhone
<p>I have a date in milli seconds(EST) and a user specific time zone. I want to convert it to the user specified time zone. Following is the code I tried. Need help:</p> <pre><code> float val = ([managedObject.lmt_ms floatValue])/(1000.0); NSDate * dt = [NSDate dateWithTimeIntervalSince1970:val]; NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"PST"]; NSTimeZone* destinationTimeZone = [NSTimeZone timeZoneWithAbbreviation:usrtimezone]; NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:dt]; NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:dt]; NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset; NSDate* destinationDate = [[[NSDate alloc] initWithTimeInterval:interval sinceDate:dt] autorelease]; NSLog(@"Dest time is:%@",destinationDate); </code></pre>
iphone
[8]
5,549,997
5,549,998
need help cleaning data in $_POST array
<p>this doesn't work. When I enter html into the form. For instance when I enter a horizontal rule it displays in the echo output even though the $value was passed through strip_tags.</p> <pre><code>function sanitizeString($var){ $var = strip_tags($var); $var = htmlentities($var); return stripslashes($var); } foreach($_POST as $key =&gt; $value){ echo $key."&lt;br&gt;"; sanitizeString($value); echo $value."&lt;br&gt;"; } </code></pre>
php
[2]
5,993,863
5,993,864
prevents a class unsetting in php
<p>I created a class implementing ArrayAccess and I added it a function to prevents WRITE actions:</p> <pre><code> $Obj-&gt;Add("key","something"); $Obj-&gt;Add("key2","something2"); $Obj-&gt;SetReadOnly(); // sets read only property unset($Obj["key2"]); // throws error, object is readonly </code></pre> <p>But, i want to prevent unsetting object too:</p> <pre><code> unset($Obj); </code></pre> <p>I can do it?I hear suggestions. Thanks for help!.</p>
php
[2]
4,053,220
4,053,221
trying to change string -> int
<p>I'm trying to use javascript to change a <code>string</code> to an <code>int</code>.</p> <pre><code>var intVal = gSpread1.Text * 1; </code></pre> <p>I want <code>intVal</code>'s Type to be <code>int</code>.</p> <p>I can get an int value, if <code>gSpread1.Text</code> is smaller than 1000.</p> <p>But if <code>gSpread1.Text</code> is larger than 1000, <code>intVal</code> returns <code>NaN</code></p> <p>What is the correct way to use <code>ParseInt</code> to ensure that it always returns an <code>int</code> value?</p>
javascript
[3]
4,018,173
4,018,174
Dragging MKPinAnnotationView throws error
<p>I have an AddressAnnotation class that conforms to the MKAnnotation class. I use the MKReverseGeocoderDelegate methods to get the address from the user's location. In that delegate, I drop the pin. I set the pin to be draggable, and when the following method is called, I start the reverse geocoder again.</p> <pre><code>- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState { if (newState == MKAnnotationViewDragStateEnding) { CLLocationCoordinate2D newCoordinate = view.annotation.coordinate; MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:newCoordinate]; reverseGeocoder.delegate = self; [reverseGeocoder start]; } } </code></pre> <p>It works for about 3 pin drags, until I get the following error. I'm not sure what it means or what is going on. Any help would be appreciated. Thanks!</p> <p>"An instance 0x1b7ac0 of class AddressAnnotation was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to stop here in the debugger. Here's the current observation info:"</p>
iphone
[8]
194,236
194,237
How I can get rid of None values in dictionary?
<p>Something like:</p> <pre><code>for (a,b) in kwargs.iteritems(): if not b : del kwargs[a] </code></pre> <p>This code raise exception because changing of dictionary when iterating.</p> <p>I discover only non pretty solution with another dictionary:</p> <pre><code>res ={} res.update((a,b) for a,b in kwargs.iteritems() if b is not None) </code></pre> <p>Thanks</p>
python
[7]
870,666
870,667
Python: list files in the current directory ONLY
<p>In Python, I only want to list all the files in the current directory ONLY. I do not want files listed from any subdirectory or parent.</p> <p>There do seem to be similar solutions out there, but they don't seem to work for me. Here's my code snippet:</p> <pre><code>import os for subdir, dirs, files in os.walk('./'): for file in files: do some stuff print file </code></pre> <p>Let's suppose I have 2 files, holygrail.py and Tim inside my current directory. I have a folder aswell and it contains two files (let's call them Arthur and Lancelot) inside it. When I run the script, this is what I get:</p> <pre><code>holygrail.py Tim Arthur Lancelot </code></pre> <p>I am happy with holygrail.py and Tim. But the two files, Arthur and Lancelot, I do not want listed.</p>
python
[7]
595,589
595,590
Restoring page scroll position with jQuery
<p>I have a page operation that uses something like:</p> <pre><code>$('#thetable tbody').replaceWith(newtbody); </code></pre> <p>in an ajax callback. Sometimes, if the user had scrolled the page down, this operation has the understandable side effect of scrolling the page back up. But the replacement appears seamless to the user so it's a bit annoying to have to scroll back down again. And since the <code>newtbody</code> normally has the same vertical height as the one it replaced, we should be able to make the script do it instead.</p> <p>Now, since I found that executing:</p> <pre><code>$('body').scrollTop(300); </code></pre> <p>from the JS debugger console does what I hoped it would, I thought the simple remedy would be:</p> <pre><code>var scrollsave = $('body').scrollTop(); $('#thetable tbody').replaceWith(newtbody); $('body').scrollTop(scrollsave); </code></pre> <p>but no joy. I haven't resorted to <a href="http://flesler.blogspot.com/2007/10/jqueryscrollto.html">jQuery.ScrollTo</a> yet.</p>
jquery
[5]
4,194,278
4,194,279
My Android "massage viberator" application does not stop vibrating even after the process is killed?
<p>I will try to be as brief as possible... I have published a very simple android application it's name is "Vib-e-rator PRO". It's purpose is obvious, it can be used as a masssage vibrator or as an erotic stimulator...</p> <p>My Problem is don't have an Android Phone to test my app in real time.</p> <p>I have been recieving mixed comments from people. A few users say its working fine. But majority of them complained that the Phone would n quit vibrating even after the closing application. </p> <p>Later i speculated that when ever the user switched off the vibrator and quit the app it would work as expected. If any user (most of em) directly closed the application ( either through the close option provided in the app itself or by pressing the END button in the phone ) without switching off the vibrator then it would not stop vibrating.</p> <p>So i added myvib.Cancel() (myvib is the context for Phone Vibrator) in the exit block the close option provided in my app. For the other scenario, when it is closed by pressing the END button in phone, i have no idea how to solve it... So friends please advice me what is necessary to do... The comments i have been receiving from many users of my app is really embarassing.... </p>
android
[4]
4,644,953
4,644,954
Store multi-line input into a String (Python)
<p>Input:</p> <pre class="lang-none prettyprint-override"><code>359716482 867345912 413928675 398574126 546281739 172639548 984163257 621857394 735492861 </code></pre> <p>my code :</p> <pre><code>print("Enter the array:\n") userInput = input().splitlines() print(userInput) </code></pre> <p>my problem here is that, <code>userInput</code> only takes in the first line value but it doesn't seem to take in values after the first line? </p>
python
[7]
4,723,505
4,723,506
activate Jquery based on div value
<p>I have a div, lets say <code>&lt;div id="books"&gt;250&lt;/div&gt;</code>. I'm trying to implement an if function where if the books div was equal or above than 250 it would activate the following script.</p> <pre><code> &lt;script type="text/javascript"&gt;//&lt;![CDATA[ $(window).load(function(){ $(document).ready(function () { $('.hideship').hide(); $('#current_country').change(function () { $('.hideship').hide(); $('#'+$(this).val()).show(); }) }); });//]]&amp;gt; &lt;/script&gt; </code></pre>
jquery
[5]
2,043,439
2,043,440
Zend Gdata google calendar
<p>How to import events to google calendar from a .ics or csv file using Zend Gdata ? Is it possible to share the google calender with user specific events using zend gdata?</p>
php
[2]
1,456,898
1,456,899
Write Plugin for Android App
<p>i'll try to develop an app which is enabled for plugins like in windows-.Net-world DLLs.</p> <p>i will have small rectangle-linearlayouts in my app where the user is able to manage them with visible on/off. later on i or someone else will give the user a new plugin, which the apps is displaying now.</p> <p>is it possible? if yes: how? are there good sites out there you could direct me?</p> <p>regards fly</p>
android
[4]
1,647,544
1,647,545
Auto click button
<p>I have a page, on page I have one button, that button click performs 3 functions. I need to auto call the button click event as soon the single function call done. After completion of each function I added the code </p> <pre><code>script = " document.getElementById('" &amp; btnCreateApprove.ClientID &amp; "').click(); }" ScriptManager.RegisterStartupScript(Me, Me.GetType(), "btnCreateApproveClick", script, True). </code></pre> <p>by adding this code I can call the button click automatically after a function call completion, The page is having one Update panel which says "Processing please wait.." it displays when function is performing its action. After the first auto click I got the error object reference not found for the update panel. I think my auto click call happens before the page fully loaded. Let me know what to do.</p>
javascript
[3]