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
3,719,515
3,719,516
What's the point of a main function and/or __name__ == "__main__" check in Python?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/419163/what-does-if-namemain-do">What does &lt;if __name__==&rdquo;__main__&rdquo;:&gt; do?</a> </p> </blockquote> <p>I occasionally notice something like the following in Python scripts:</p> <pre><code>if __name__ == "__main__": # do stuff like call main() </code></pre> <p>What's the point of this?</p>
python
[7]
388,923
388,924
Is it possible to have a member pointer to an array in a struct?
<p>Is it possible to have a member pointer to an array in a struct? I would like to do something like below:</p> <pre><code>struct A { int array[10]; int sizeOfArray; }; template&lt;int size&gt; class B { public: B(int (A::*arrayLocation)[size], int A::*arraySize): memberArray(arrayLocation), memberArraySize(arraySize)) { } void setValue(A* pobj1) { for(int i = 0; i &lt; pobj1-&gt;*memberArraySize; i++) { (pobj1-&gt;*memberArray)[i] = 1; } } private: int (A::*memberArray)[size]; int A::*arraySize; }; int main() { A obj2; B&lt;10&gt; obj1(&amp;A::array, &amp;A::sizeOfArray); obj1.setValue(&amp;obj2); } </code></pre>
c++
[6]
2,781,160
2,781,161
What's the point of FILL_AND_STROKE?
<p>Android newb here, so I'm trying out the android graphics classes. I wanted to draw some arcs/circles with a fill color and black outline. The Paint class has a style for FILL_AND_STROKE, but there doesn't seem to be a way to set the fill color vs. stroke color. So as far as I can tell it's the same as FILL?</p> <p>So what's the point of FILL_AND_STROKE if you can't set a separate fill and stroke color? I haven't managed to find a good explanation.</p> <p>(I solved my simple problem by doing a fill first, then a stroke, naturally)</p> <p>Edit: I ran into this bug report: <a href="http://code.google.com/p/android/issues/detail?id=4086">http://code.google.com/p/android/issues/detail?id=4086</a></p> <p>Comment 4 and 5 seem to imply that FILL_AND_STROKE is basically the same as FILL and it will be 'fixed' in 2.2. I guess they'll add a new color?</p>
android
[4]
387,576
387,577
How to get a list of unchecked checkboxes when submitting a form?
<p>I have this code for example :</p> <pre><code>$b = ""; while ($row = mysql_fetch_array($rows)) { if ($row['enabled'] == 1) { $b = "checked"; } else { $b = "": } </code></pre> <p>echo "&lt;\input name='nam[$row[id]]' type='checkbox' value='$row[id]' $b />";</p> <p>}</p> <p>When I execute this code, I will get a list of checkboxes, some of them are checked and others are not.</p> <p>I can use this code to get a list of checked checkboxes.</p> <pre><code> if (isset($_POST['sub'])) { //check if form has been submitted or not $nam = $_POST['nam']; if (!empty($nam)) { foreach($nam as $k=&gt;$val){ // proccess operation with checked checkboxes } } </code></pre> <p>I need to know how I can get list of unckecked checkboxes after submitting the form.</p> <p>Thanks in advance.</p>
php
[2]
5,537,598
5,537,599
Access a List in JUnit Test Case
<p>I have this ParkingLot.java</p> <pre><code> public class ParkingLot { private final int size; private Car[] slots = null; List&lt;String&gt; list = new ArrayList&lt;String&gt;(); public ParkingLot(int size) { this.size = size; this.slots = new Car[size]; } public List licenseWithAParticularColour(String colour) { for (int i = 0; i &lt; slots.length; i++) { if (slots[i].getColour() == colour) { System.out.println(slots[i].getLicense()); list.add(slots[i].getLicense()); return list; } } return null; } </code></pre> <p>}</p> <p>I have created a ParkingLotTest.java as follows</p> <pre><code>public class ParkingLotTest { private Car car1; private Car car2; private Car car3; private Ticket ticket1; private Ticket ticket2; private Ticket ticket3; private ParkingLot parkingLot; private List&lt;String&gt; list = new ArrayList&lt;String&gt;(); @Before public void intializeTestEnvironment() throws Exception { this.car1 = new Car("1234", "White"); this.car2 = new Car("4567", "Black"); this.car3 = new Car("0000", "Red"); this.parkingLot = new ParkingLot(2); this.ticket1 = parkingLot.park(car1); this.ticket2 = parkingLot.park(car2); this.ticket3 = parkingLot.park(car3); this.list = parkingLot.list; } @Test public void shouldGetLicensesWithAParticularColour() throws Exception { assertEquals(, parkingLot.licenseWithAParticularColour("White")); } </code></pre> <p>}</p> <p>In the above Test Case, I want to check that the List is filled with the correct Licenses. 1. How do i create a field in the ParkingLotTest.java so that the List in the first class is same as list in the second class file.</p>
java
[1]
2,909,442
2,909,443
Should all the using directives for namespaces be inside the namespace?
<p>Microsoft StyleCop provided a warning when the using directives for namespaces are provided outside of the namespace. Is this really required as my view on this is that using dircetives for namespaces is for providing a alias name for namespace and for removing the need for providing the namespace name when a class/interface is used. I dont think it will be used for loading the assembly.</p>
c#
[0]
5,162,819
5,162,820
How to handle conditional-imports-dependent exceptions?
<p>I'm wondering what is the most elegant way to handle exceptions that depend on a conditional import. For example:</p> <pre><code>import ldap try: ... l = ldap.open(...) l.simple_bind_s(...) ... except ldap.INVALID_CREDENTIALS, e: pass except ldap.SERVER_DOWN, e: pass </code></pre> <p>In the real-world scenario (the one that made me think of this), we have a cherrypy server with a 'login' page. And the login method does a lot of stuff - one of them is authentication.</p> <p>However, I can use something else than LDAP to do authentication, in which case I do not want to import ldap at all.</p> <p>But if I make the 'import ldap' statement conditional (e.g. it only gets imported when USE_LDAP value is True in a config file), I have to do something with the 'except's too. The question is: what? </p> <p>Catch a generic Exception, use an if statement to check whether we use LDAP (i.e., ldap is imported) and then use isinstance to check, whether the Exception is the correct type (ldap.INVALID_CREDENTIALS)?</p> <p>Try to concentrate the code that depends on ldap at one place and re-raise a user defined exception that finally gets caught in the login method?</p> <p>What would you suggest as the most pythonic?</p>
python
[7]
2,368,495
2,368,496
Invoking a service on other java application running on the same machine
<p>I created a command line interface on a small java application I created for personal use. For the moment the cli is resided in the same project as the original application but I'm planning to extract it into it's own project, effectively building 2 separate executable jars enabling me to start the cli as needed and query the other running program for information.</p> <p>I'm trying to figure out the easiest and most lightweight solution to call a remote service, on the same machine. I looked at spring remoting but many of the provided solutions such as HttpInvoker, Hessian/Burlap, JAX RPC web services are based on HTTP or SOAP and therefore not suited for the job. JMS also seems like overkill.</p> <p>This leaves me with RMI, which looks rather heavyweight, and possibly JMX? Suggestions?</p>
java
[1]
524,300
524,301
Java Index Array Out of Bounds Exception
<p>This loop is strange. </p> <p>I ran this in Java, it gives an Index out of bounds exception. I can't find an <code>int l</code> declaration anywhere in the source code and i can't figure out what it is and found out that it is legal for it to be declared this way.</p> <p>But the deal here is, i don't understand what this piece of code is doing. For any size of <code>resultSIList</code>, it gives an <code>ArrayIndexOutOfBoundsException</code>.</p> <pre><code>for (int i = offset, l = Math.min(i + maxItemsInOnePage, totalSIs); i &lt; l; i++){ resultSIList.get(i); } </code></pre> <p><strong>EDIT</strong>: Thanks all.</p> <p>Here is a runnable code i am using to try to understand this entire loop. Yes it is a horrible piece of junk.</p> <pre><code>public class IndexOutOfBoundsTest { public static void main(String args[]){ int offset = 50; int maxItemsInOnePage = 50; int totalSIs = 50; final int buildThis = 15; List resultSIList = new ArrayList(); // build list for(int zz = 0; zz &lt; buildThis; zz ++){ resultSIList.add("Hi " + zz); } try{ for (int i = offset, d = Math.min(i + maxItemsInOnePage, totalSIs); i &lt; d; i++){ System.out.println(resultSIList.get(i)); } }catch(Exception e){ e.printStackTrace(); } } } </code></pre>
java
[1]
6,002,785
6,002,786
Javascript performance consideration. Is dot operator faster than subscript notation?
<p>Is dot operator faster than subscript notation?</p> <pre><code>var obj = {x: '5'}; obj.x = 'some value'; obj['x'] = 'some value'; </code></pre>
javascript
[3]
793,795
793,796
Figure out the element in the a table (using class) when using jquery
<p>I am using a table grid in my HTML and while clicking on a specific <code>col</code> in each row, I dynamically create an additional row using <code>&lt;tr&gt;</code>. The additional row is used to submit data to the server and remove it after submit. Now I would like in addition to this that the row number of the table will be sent to the server as well. </p> <p>The table is changed dynamically as I am adding rows for editing. I thought about fixing this by giving each <code>&lt;tr&gt;</code> a class named <code>task_entry</code> and by counting the number of <code>.task_entry</code> elements I will be able to figure out which row I am in. However I cannot get this to work. I tried to use <code>$(".task_entry").index(this)</code> but it returns -1.</p> <p>Can anyone help?</p>
jquery
[5]
5,246,817
5,246,818
how to change html image src by j-query
<p>view.aspx </p> <pre><code>&lt;img src ="~/UserControls/Vote/Images/Arrow Up.png" id = "voteupoff" runat = "server" alt ="vote up" class="voteupImage" style="height: 45px; width: 45px"/&gt; </code></pre> <p>i wnat to change it src ~/UserControls/Vote/Images/aftervoteupArrowUp.png when click on image i means</p> <p>view.js</p> <pre><code> $('img.voteupImage').live('click', function() { $('img.voteupImage').attr('src', aftervoteUp); } but it's not working.. </code></pre>
jquery
[5]
4,271,511
4,271,512
How to move a movie from Camera Roll to app's Documents folder?
<p>How can I copy/move a movie from Camera Roll to an app's own Documents folder?</p>
iphone
[8]
2,147,946
2,147,947
Set custom color to the Table row according to table data by jQuery
<p>I am facing a problem regarding jquery Heat Color. i want to set a custom color to the all row according to a table data of that row.The is generated in run time.i set a hidden text field and comparing with this value set a particular color.i am using the code..</p> <p>$("#tblreg > tbody > tr").heatcolor()//for every row of the table ......</p> <p>var days = $("#DRRecvdays").val();//DRRecvdays is the id of textbox</p> <p>but this returns always the 1st row value (1st row's 'DRRecvdays' text value) </p> <p>please help me as soon as possible..</p> <p>Thanking you..</p> <p>Ashish </p>
jquery
[5]
5,566,039
5,566,040
jQuery .show()/.hide() not working
<p>I am trying to use jQuery hide and show functions. It didn't really work. Here is my code:</p> <pre><code> $("button#demoButton").click(function () { $("p#demo").hide("slow"); }); </code></pre> <p>Edit: When I clicked button, nothing happened.</p>
jquery
[5]
4,434,245
4,434,246
Alternative to using KSOAP for accessing WebService from Android application due to KSOAP jar size
<p>I am adding <strong>ksoap2-j2se-full-2.1.2.jar</strong> as external jar into Android project &amp; accessing the <strong>SOAP API</strong> to access <strong>.NET webservices from Android application</strong>. <strong>The size of the ksoap2-j2se-full-2.1.2.jar is 96 KB</strong> &amp; so I dont want to increase the size of the Android application by using the external jar.</p> <p>Kindly provide an <strong>alternate option by which we can access the .NET webservice from Android application so that the size of the Android application get reduced</strong>.</p> <p>Warm Regards,</p> <p>Chiranjib </p>
android
[4]
3,371,793
3,371,794
document.write is stopping me from printing
<p>When I create a document using javascript document.write</p> <p>this is an iframe</p> <p>then i call iframe.print()</p> <p>nothing happens no error and no print dialog.</p> <p>how can I print?</p> <pre><code>MyFrame.document.write('&lt;html&gt;&lt;body&gt;'+HTMLText + '&lt;/body&gt;&lt;/html&gt;'); document.getElementById("IFramePrint").style.display = "inline"; MyFrame.focus(); MyFrame.print(); </code></pre>
javascript
[3]
3,876,386
3,876,387
"Unable to load DLL ..... Invalid access to memory location" error
<p>I am using a third party .dll (<a href="http://www.soft.tahionic.com/" rel="nofollow">from this website</a>) which generates Hardware ID. I am using it as per the <a href="http://www.soft.tahionic.com/download-hdd_id/hardware%20id%20programming%20source%20code/how%20to%20call%20it.html#dotnet_C#" rel="nofollow">direction</a> provided on that site. </p> <pre><code> [DllImport("HardwareIDExtractorC.dll")] public static extern String GetIDESerialNumber(byte DriveNumber); private void btnGetHardwareId_Click(object sender, EventArgs e) { MessageBox.Show(GetIDESerialNumber(0)); } </code></pre> <p>But it is raising the following error-</p> <p>Unable to load DLL 'HardwareIDExtractorC.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6)</p> <p>Am i missing anything here?</p>
c#
[0]
4,407,481
4,407,482
How to Adjust the size of text in the TextView?
<p>I have look to a lot of tutorial to how to adjust a textView but i don't really a understand how?</p> <p>i am using a simple Activity that have a TextView that i went it to be the bigger as possible That is the class </p> <pre><code>public class Zoom extends Activity { private String productName; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.zoom); Intent intent = getIntent(); productName = intent.getStringExtra("ChoosenMed"); TextView productNameTextView=(TextView)findViewById(R.id.prodcutNameZoomTextView); productNameTextView.setText(productName); } } </code></pre> <p>Now what i went is to adjust the productNameTextView to fit the screen each time when i use this activity, like when the word its big the text will be smaller then when the word its smaller.</p> <p>Thank for helping</p>
android
[4]
3,505,974
3,505,975
Trouble playing audio files in javascript array
<p>I'm trying to create a button which when clicked plays an audio file and then when it's clicked again plays the next file in my array. I get it to play but when I click it the second time it plays both the first file AND the second. When I press it the third time it plays the first, second and third. Seems like I need to reset something or other to clear the first two tracks of the page. Here is what I have:</p> <pre><code> &lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;script language="javascript" type="text/javascript"&gt; audio = new Array('audio1.mp3','audio2.mp3','audio3.mp3'); index = 0; function playSound() { if(index&lt;3){ document.getElementById("start").innerHTML=document.getElementById("start").innerHTML + "&lt;embed src=\""+audio[index]+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" /&gt;"; index++; } else{ index = 0; document.getElementById("start").innerHTML=document.getElementById("start").innerHTML + "&lt;embed src=\""+audio[index]+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" /&gt;"; index++; } } &lt;/script&gt; &lt;button id="start" type = "button" onclick="playSound();"&gt;Start&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
4,379,225
4,379,226
running several system commands in parallel
<p>I write a simple script that executes a system command on a sequence of files. To speed things up, I'd like to run them in parallel, but not all at once - i need to control maximum number of simultaneously running commands. What whould be the easiest way to approach this ?</p>
python
[7]
2,102,461
2,102,462
Java apache commons collections primitives import issues
<p>I have commons-primitives-1.0.jar added as external executable jar on my eclipse.<br> So i am able to <code>import org.apache.commons.collections.primitives.ArrayUnsignedShortList;</code></p> <p>and I have a function </p> <pre><code>private void start() { _nexts = new ArrayList(_iterators.size()); for (int i = 0, m = _iterators.size(); i &lt; m; i++) { _nexts.add(null); } _nextSet = new BitSet(_iterators.size()); _prevFrom = new ArrayUnsignedShortList(); &lt; ---give me error here } </code></pre> <p>it says,</p> <blockquote> <p>The constructor ArrayUnsignedShortList() is not visible</p> </blockquote> <p>I am not quite sure how to go about fixing this error because when i looked at the <code>ArraysUnsignedShortList.java</code>, it does have constructor. </p> <p>Help? </p> <p><a href="http://commons.apache.org/proper/commons-primitives/apidocs/org/apache/commons/collections/primitives/ArrayUnsignedShortList.html" rel="nofollow">http://commons.apache.org/proper/commons-primitives/apidocs/org/apache/commons/collections/primitives/ArrayUnsignedShortList.html</a></p> <p>public ArrayUnsignedShortList() Construct an empty list with the default initial capacity.</p> <p>^ so i should be able to call it..</p>
java
[1]
2,586,075
2,586,076
c# Validation for login
<p>My script isnt checking the requirement can u help me out with this? I'm trying to make it run the script before it run the onclick to check if login is right.</p> <pre><code> &lt;script type="text/javascript"&gt; function checkform() { var name = document.getElementsByTagName("UserName"); var pw = document.getElementsByTagName("Password"); if(name.charAt(0)!='s'){ document.getElementById("divMessage").innerHTML = "Please insert an S infront"; return false; if(pw.length&lt; 8 &amp;&amp; pw.length&gt;16){ document.getElementById("divMessage").innerHTML = "Please key in a longer password"; return false; } }else{ return true; } &lt;/script&gt; &lt;asp:Button ID="btnLogin" class="button" runat="server" CommandName="Login" OnClientClick ="return checkform()" onclick="btnLogin_Click" text="Login" /&gt; </code></pre>
asp.net
[9]
4,628,970
4,628,971
window.location affected by escape key?
<p>I have a timer to refresh the page, and it's working:</p> <pre><code>updateCountdown = function() { if (Variables.Seconds == Infinity) { } else if (Variables.Seconds == 0) { $countdown.text('Bam!'); window.location.replace(Variables.PageName); } else { $countdown.text(Variables.Seconds--); setTimeout(updateCountdown, 1000); } }; </code></pre> <p>Then I have this:</p> <pre><code>document.onkeydown=function(e) { if (e.which==27) { Variables.Seconds = 0; updateCountdown(); } }; </code></pre> <p>When I press escape, then $countdown.text says 'Bam!', but the page does not refresh like it does whenever Variables.Seconds normally decrements to 0.</p>
javascript
[3]
4,650,121
4,650,122
How to avoid repeted creation Jquery wrapper?
<p>Is there any way to avoid using <code>$("#check1")</code> second time in below statement? </p> <pre><code>$("#check1").prop("checked",!$("#check1").prop("checked")); </code></pre> <p>By any trick can I do something like below?</p> <pre><code>$("#check1").prop("checked",!this.prop("checked")); </code></pre>
jquery
[5]
2,247,135
2,247,136
Decrease text size if too long
<p>I have a couple textviews, I would like to limit them to a certain visual length, say 50% width of screen. If the text reaches 50% of the screen, I would like to do something to stop it from continuing across the screen. I thought maybe if it hits that limit, to just decrease the textsize for every character so that it fits.</p> <p>How would I do that... or is there a better way to handle this?</p>
android
[4]
4,920,956
4,920,957
call method name and body from sql server
<p>i want to call a method using MethodInfo and MethodBody Class of System.Reflection and the name and body of the method is in sql server how can i do that please help</p> <pre><code> SqlConnection con = new SqlConnection(GlobalData.GetConnectionString()); SqlCommand cmd = new SqlCommand("select CodeSnippet from SubMenu where Role_ID='"+GlobalData.RoleID+"' and ChildMenu='"+sender.ToString()+"'", con); if (con.State == ConnectionState.Closed) { con.Open(); } SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { string codeSnippet = reader["CodeSnippet"].ToString(); Type type = typeof(Helper); MethodInfo method = type.GetMethod(codeSnippet); Helper c = new Helper(); method.Invoke(c, null); } if (con.State == ConnectionState.Open) { con.Close(); } </code></pre> <p>i have done with this now i want the method body from the microsoft sql server</p>
c#
[0]
5,853,408
5,853,409
how to run app in background while phone is in any state
<p>i want to build recycle bin app for that my app observe all the deleted events that happens in phone and make a notification to the user is that a particular file is deleted. for this reason app should be run in background without displaying any ui to the user.</p>
android
[4]
4,323,404
4,323,405
Why can't I increment a variable of an enumerated type?
<p>I have a enumerated type <code>StackID</code>, and I am using the enumeration to refer to an index of a particular vector and it makes my code easier to read. </p> <p>However, I now have the need to create a variable called <code>nextAvail</code> of type <code>StackID</code>. (it actually refers to a particular stackID ). I tried to increment it but in C++, the following is illegal:</p> <pre><code>nextAvail++; </code></pre> <p>Which sort of makes sense to me ... because there's no bounds checking.</p> <p>I'm probably overlooking something obvious, but what's a good substitute?</p> <hr> <p>I also want to link to <a href="http://stackoverflow.com/questions/1390703/enumerate-over-an-enum-in-c/1391479#1391479">this</a> question.</p>
c++
[6]
1,712,351
1,712,352
Dynamically create Instance fields for a JavaScript Object
<p>I have a dynamically-created list of strings called 'variables'. I need to use these strings as the instance variables for an array of JavaScript objects.</p> <pre><code>var objectsArr = []; function obj(){}; for (var i=0; i&lt;someNumberOfObjects; i++ ) { ... objectsArr[i] = new Object(); for (var j=0; j&lt;variables.length; j++) { objectArr[i].b = 'something'; //&lt;--this works, but... //objectArr[i].variables[j] = 'something'; //&lt;---this is what I want to do. } } </code></pre> <p>The commented-out line shows what I am trying to do.</p>
javascript
[3]
6,014,138
6,014,139
substr not working? php
<p>Unfortunately I can't point you to a live example. But I've got a form that submits a bunch of data to the database.</p> <p>I retrieve the 'date' field with </p> <pre><code>genesis_custom_field('date') </code></pre> <p>and the output date is "mm/dd/yyyy" e.g., 02/19/2012</p> <p>so shouldn't </p> <pre><code>echo substr(genesis_custom_field('date'), 0, 2) . '&lt;-M&lt;br /&gt;' </code></pre> <p>output "02"</p> <p>instead, it's outputting the full date format, "02/19/2012".</p> <p><strong>INTENTS AND PURPOSES</strong></p> <p>for intents and purposes, here's the code sample.</p> <pre><code>// The Query $reviews_query = new WP_Query('showposts=1'); // The Loop while ( $reviews_query-&gt;have_posts() ) : $reviews_query-&gt;the_post(); echo substr(genesis_custom_field('date'), 0, 2) . '&lt;-M&lt;br /&gt;'; endwhile; // Reset Post Data wp_reset_postdata(); </code></pre> <p>with the intended output of</p> <pre><code>02&lt;-M </code></pre> <p>but I'm getting</p> <pre><code>02/19/2012&lt;-M </code></pre>
php
[2]
3,916,498
3,916,499
How can I turn this jquery into a function?
<p>I would like to turn the below jquery code into a function so i could add links to the list and not have to touch the jquery. I'm assuming I will have to put the image name into the <code>&lt;a href&gt;</code> tag somewhere.</p> <p>html code</p> <pre><code>&lt;img id="storyimg" src="1.png" alt="img" /&gt; &lt;ul class="sb_menu"&gt; &lt;li&gt;&lt;a href="linkpage.htm" class="newslink1"&gt;Link 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="linkpage.htm" class="newslink2"&gt;Link 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="linkpage.htm" class="newslink3"&gt;Link 3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>jquery</p> <pre><code>$('a.newslink1').bind('mouseover', function() { $('img#storyimg').attr("src", "1.png"); }); $('a.newslink2').bind('mouseover', function() { $('img#storyimg').attr("src", "2.png"); }); $('a.newslink3').bind('mouseover', function() { $('img#storyimg').attr("src", "3.png"); }); </code></pre>
jquery
[5]
5,623,459
5,623,460
How to get display keyboard event in android
<p>I have GridView <code>android:layout_height="match_parent"</code> with Editboxes, in <code>LinearLayout</code> with <strong>fix android:layout_height</strong>.</p> <p>When I touch editbox, appears keyboard.</p> <p><strong>How to change android:layout_height in LinearLayout when keyboard appears and when disappears?</strong></p>
android
[4]
5,281,055
5,281,056
Convert into database date in java
<p>I want to convert user entered date 31-12-2012 into PostgreSQL date format. i am appending date 'day-month-year' (31-12-2012)</p>
java
[1]
5,953,638
5,953,639
Preventing multiple clicks from initiating animate
<p>I have a div box that if I double click will expand to the entire page. If I press a button that is produced once the div has expanded, the div box will minimize back to its original size. However, if I double click the div box, the event will be triggered twice, expanding the div box then immediately minimizing it. So I tried using .one() but did not realize that it only works once. What could I use to allow only one click at a time without firing multiple events? Here is the jsbin and below is strictly the jquery code. <a href="http://jsbin.com/eqezas/3/edit" rel="nofollow">http://jsbin.com/eqezas/3/edit</a></p> <pre><code>$("#block").one('click', function(){ $('#block1').hide(); $("#block").animate({ width: "100%", height: "100%", opacity: 0.4, fontSize: "3em", }, 1500, function() { $('#but').show(); }); }); $('#but').one('click',function() { $('#block1').show(); $("#block").animate({ width: "100px", height: "40px", opacity: 1, fontSize: "1em", }, 1500 ); $('#but').hide(); return false; }); </code></pre>
jquery
[5]
706,744
706,745
How to disable webview zoom out?
<p>I am loading javascript file in webview but If I double click a web view, it zooms out. Is there any way to disable that? </p> <p>Thanks Monali</p>
android
[4]
1,363,811
1,363,812
Video storing giving warnings
<p>how to save a video file into sdcard? I tried using the documentation procedure but it didnt helped me. So i wet to another procedure but its giving a</p> <blockquote> <p>08-06 13:50:08.218: V/stopped here here(899): /mnt/sdcard/myfolder/abcmyCapturedVideoooo.3gp (Permission denied) </p> </blockquote> <p>warning.(enetered catch block where i printed this message) I included the permission write to external storage but even am not allowed to store the file.</p> <p>can any one help me please. thanks in advance</p>
android
[4]
880,086
880,087
Looking for duplicate in local text file
<p>please could someone help me with this duplicate checking function. I'm still quite fresh when it comes to PHP, so please excuse me, if this is a simple fix.</p> <p>I'm storing a list of email addresses to a file called list.txt. Here is the content of the file (each on a new line):</p> <pre><code>bob@foo.com sam@bar.com tracy@foobar.com </code></pre> <p>Now I have a function (not working) that should check if email is already in the list:</p> <pre><code>function is_unique($email) { $list = file('list.txt'); foreach($list as $item){ if($email == $item){ return false; die(); } } return true; } </code></pre> <p>When I call the function in this test, with an existing email address, it still returns true:</p> <pre><code>if( is_unique('bob@foo.com') ) { echo "Email is unique"; } else { echo "Duplicate email"; } // Returns true even though bob@foo.com is in the list </code></pre> <p>I appreciate anyone's input.</p>
php
[2]
5,885,992
5,885,993
how do I create a popup menu like when you push the bookmark icon in safari.. SEE PIC
<p>Hope this isn't a lame question but for the life of me I cannot figure out how to make a pop-up button menu like the image I've attached from my phone. Any help is appreciated!</p> <p><img src="http://i.stack.imgur.com/lj9RK.png" alt="http://i.stack.imgur.com/pMbRg.png"></p>
iphone
[8]
5,590,424
5,590,425
JavaScript prototype.init craziness
<p>Could someone please explain the significance of prototype.init function in JavaScript and when it is called during object instantiation?</p> <p>Why would you want to overwrite it with an empty function?</p> <p>I am reading the JavaScript for Web book and am stuck on the this for the past few hours...what is piece of code supposed to achieve?</p> <pre><code>var Class = function(){ var klass = function(){ this.init.apply(this, arguments); }; klass.prototype.init = function(){}; // Shortcut to access prototype klass.fn = klass.prototype; // Shortcut to access class klass.fn.parent = klass; ... } </code></pre> <p>This is just too much magic for me...:)</p>
javascript
[3]
5,090,351
5,090,352
Changing onClick to be random
<p>I'm looking to make the handler OnClick to just be random instance instead of requiring user interaction.</p> <pre><code>// add the canvas in document.body.appendChild(mainCanvas); document.addEventListener('mouseup', createFirework, true); document.addEventListener('touchend', createFirework, true); // and now we set off update(); } /** * Pass through function to create a * new firework on touch / click */ function createFirework() { createParticle(); } </code></pre> <p>Thanks! :)</p>
javascript
[3]
718,815
718,816
JavaScript remove array
<p>I tried doing <code>delete weapons[i];</code> but even do when I do <code>weapons.length</code> I still get 1. Even though it should be 0. How do I definitely remove an array from <code>weapons[]</code> array?</p> <p>I comb over the weapons array by doing this:</p> <pre><code> for (var i = 0, setsLen = weapons.length; i &lt; setsLen; ++i ) { var searchWeapon = weapons[i].split("|"); // console.log('['+i+'] &gt;&gt; Weapon ID: ' + searchWeapon[0] + ' | Y: ' + searchWeapon[1] + ' | X: ' + searchWeapon[2]); if (searchWeapon[1] == Y &amp;&amp; searchWeapon[2] == X) { delete weapons[i]; } } </code></pre> <p>and I store each array as <code>3|10|4</code> where <code>3</code> is weapon ID, <code>10</code> is Y, and <code>4</code> is X.</p>
javascript
[3]
4,150,322
4,150,323
Split String and multiply 8
<p>I am having trouble with this. The user needs to enter a string and then I need to count the string and multiply the same string. For example, if the user entered the string The quick brown fox jumps over the lazy dog;<br> The output should look like this, The = 22% quick = 11% brown = 11% fox = 11% jumps = 11% over = 11% lazy = 11% dog = 11%</p> <p>Here is my code </p> <pre><code> string phrase = "The quick brown fox jumps over the lazy dog"; string[] arr1 = phrase.Split(' '); for (int a = 0; a &lt; arr1.Length; a++) { Console.WriteLine(arr1[a]); } Console.ReadKey(); </code></pre> <p>The value is 22%, it was calculated using this formula, 2/9 * 100. 2 because "the" was used twice, divided by 9 because there are 9 words in the string. I am trying to compare each string to determine if they are the same but unable to do so. </p>
c#
[0]
5,500,520
5,500,521
Load Google Map in iPhone Application
<p>How can I load a google Map in my iPhone application?</p> <p>Here I don't require entire web page, but just the graph part (zoomable).</p> <p>any sample code link.(if available).</p> <p>Thanks in advance.</p>
iphone
[8]
1,824,877
1,824,878
document.addForm.submit() not working in firefox
<p>addForm is used as the form id, but the form submit is not working in firefox.</p> <pre><code>$(function() { var date = $("#todo_due").val(); var text = $("#todo_due").val(); if (date &amp;&amp; text) { document.addForm.submit(); } else if (!date &amp;&amp; !text) { new Messi('{$LANG.main.todo_validation}', {ldelim}title: '{$LANG.error.error}', titleClass: 'info', modal: true{rdelim}); } else if (!text) { new Messi('{$LANG.main.todo_validation_desc}', {ldelim}title: '{$LANG.error.error}', titleClass: 'info', modal: true{rdelim}); } else { new Messi('{$LANG.main.todo_validation_date}', {ldelim}title: '{$LANG.error.error}', titleClass: 'info', modal: true{rdelim}); } }); </code></pre>
jquery
[5]
5,350,211
5,350,212
DeliveryNotificationOptions won't work on gmail and hotmail
<p>I am using SmtpClient to send a message through a gmail account, I set DeliveryNotificationOptions to DeliveryNotificationOptions.OnSuccess, the message sent ok, but there is no delivery notifiacton. I also tried hotmail, still no delivery notification. However the same code works fine on outlook exchange server.</p> <p>any ideas? Cheers Harry</p>
c#
[0]
1,852,191
1,852,192
How do inner classes work in c#?
<p>If I have a class like:</p> <pre><code>public class C1 { public class SC1 {} public class SC2 {} public class C1() { } } </code></pre> <p>Why can't I do this:</p> <pre><code>C1 c1 = new C1(); c1.SC1.somePropety = 1234; </code></pre>
c#
[0]
5,995,694
5,995,695
How to get url, that app try to reach?
<p>I would like to know, how to get url, that app try to reach?</p> <p>For example if "Angry Bird" try to reach www.ab.com/update.txt i would like to know about this.</p> <p>Thanks.</p>
android
[4]
227,186
227,187
How to clear edit box in grid view
<p>I have Gridview in my activity. Data adapter for my GridView:</p> <pre><code>private class EfficientAdapter extends BaseAdapter { ... public View getView(int position, View convertView, ViewGroup parent) { final ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.item3, null); holder = new ViewHolder(); holder.Attitude_Value = (EditText) convertView.findViewById(R.id.editText1); holder.Attitude_Value.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable edt) {attitude_values.set(holder.ref, edt.toString());} public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3){} public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {}}); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.ref=position; holder.Attitude_Value.setText(attitude_values.get(position)); return convertView; } ... </code></pre> <p>How can I clear editbox in grid view, when I focus in it, before start typing?</p>
android
[4]
3,735,268
3,735,269
portable code between windows and linux
<p>I have an aplication written for linux,and i want to make it to execute under windows too. So how can i make a specific line in code to execute only if the programs runs under windows ? I know its somehting with #ifdef... Thanks</p>
c++
[6]
5,560,102
5,560,103
accessing "models" of a javascript object
<p>I have an object that looks like this in my javascript console:</p> <pre><code>r {length: 1, models: Array[1], _byId: Object, constructor: function, model: function…} _byId: Object length: 1 models: Array[1] 0: r _changing: false _events: Object _pending: false _previousAttributes: Object attributes: Object collection: Array[20] created_at: Wed Mar 27 2013 03:24:31 GMT-0400 (Eastern Daylight Time) __proto__: Object changed: Object cid: "c26" collection: r __proto__: s length: 1 __proto__: Array[0] __proto__: s </code></pre> <p>I should have paid attention in class... but how can I access that "collection: Array[20]"? Is there a way?</p>
javascript
[3]
5,986,454
5,986,455
Preferred way of declaring and converting primitives to strings
<p>I have 3 options:</p> <ol> <li>Declare <code>double member</code> and later when I have to pass <code>String</code> use <code>member + ""</code>.</li> <li>Declare <code>double member</code> and later when I have to pass <code>String</code> use <code>Double.toString(member)</code>.</li> <li>Declare <code>Double member = 0.0</code> and later when I have to pass <code>String</code> use <code>member.toString()</code>.</li> </ol> <p>My opinions:</p> <ol> <li>The shortest one. However, <code>member + ""</code> will be converted to <code>new StringBuilder().append(member).append("").toString()</code>, which seems not elegant.</li> <li>In <code>Double.toString(member)</code> I don't like that it doesn't start from the word <code>member</code>, which is the most important. We only need to convert it. It's better if <code>member</code> is in the beginning, because I pay most attention to the beginning of word. Quick glance and I know "ah, ok I'm passing member". And with <code>Double.toString(member)</code> my very first concentration goes to "ah, ok... a Double, we are doing toString... of a member! Ah ok".</li> <li><code>member.toString()</code> looks fine and it can be typed even faster then + "", because of autocompletion in Eclipse. However, objects are much slower then primitives. <a href="http://simononsoftware.com/primitives-and-objects-benchmark-in-java/" rel="nofollow">Reference.</a></li> </ol> <p><strong>What is the best option?</strong> Maybe there are some other options?</p>
java
[1]
5,067,683
5,067,684
super.clone() Queries?
<p>Kindly clarify me for the following questions.</p> <ol> <li>Does <code>super.clone()</code> perform Deep copying or shallow copying?</li> <li>In the below example, why don't we need class <code>CompositeObjCloneMe</code> as cloneable? Does <code>cObj</code> won't be cloned while trying to clone <code>CloneMe</code> object? Note: Even making <code>CompositeObjCloneMe</code> as cloneable doesn't have any impact on output.</li> <li>Why the output is behaving like shallow copying (Not deep coppying) since program is setting primitive value(<code>setCObjValue = 100</code>) of a class? (where primitive fields are deeply copied)</li> <li><p>Is it immutable Objects &amp;&amp; primitives are inherently deeply copied?</p> <pre><code>class CloneMe implements Cloneable { private CompositeObjCloneMe cObj; public CloneMe() { cObj = new CompositeObjCloneMe(); } public void setCObjValue(int myOwnDt) { this.cObj.setObj(myOwnDt); } public int getCObjValue() { return this.cObj.getObj(); } //Clone public Object clone() throws CloneNotSupportedException { return super.clone(); } } class CompositeObjCloneMe {//implements Cloneable{ private int value = 20; public void setObj(int i){ value = i; } public int getObj(){ return value; } // public Object clone() throws CloneNotSupportedException{ // return super.clone(); // } } public class CloneTest { public static void main(String arg[]) { CloneMe realObj = new CloneMe(); try { CloneMe cloneObj = (CloneMe) realObj.clone(); realObj.setCObjValue(100); System.out.println(realObj.getCObjValue() + " " + cloneObj.getCObjValue()); } catch (CloneNotSupportedException cnse) { System.out.println("Cloneable should be implemented. " + cnse); } } } </code></pre></li> </ol> <p>OUTPUT: 100 100</p>
java
[1]
5,879,001
5,879,002
Android - Is this Code correct?
<p>is the below mentioned code correct</p> <pre><code>public boolean checkRecipe(CharSequence recipename) throws SQLException { Cursor checkRecursor=rDb.query(true, DATABASE_TABLE, new String[]{KEY_TITLE}, KEY_TITLE+"="+recipename, null, null, null, null, null); if(checkRecursor!=null) return true; else return false; } </code></pre> <p>I'm trying to check whether a given entry is present in the table or not. </p>
android
[4]
4,305,441
4,305,442
iPhone saving a web page to Home Screen
<p>I have iOS5 on my iPhone4 and when I tried to save a web page to the home screen I pressed the icon at the bottom and was given a list of options. None of the options was to Add to Home Screen. The options I see are Add Bookmark, Add to Reading List, Mail Link to this Page, Tweet and Print. </p> <p>I have always saved web pages to the home screen before. I have searched Apple's site and I'm not getting any results on this problem. Is this something new in iOS5? </p>
iphone
[8]
5,819,849
5,819,850
PHP Warning inside CMD
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5709066/php-warning-wbexec">PHP Warning: wbExec</a> </p> </blockquote> <p>How should I deal with the message "PHP Warning: wbExec: Could not run application C:\foldername_path1\filename1.phpw in C:\foldername_path1\filename2.php"</p> <p>The fact that exactly the same code works on one computer but doesn't on another one proves that on the second one is something wrong with xp system. I already taken care for malware and any registry issues.</p>
php
[2]
503,767
503,768
c++ unorderd_map got me seg fault
<pre><code>#include &lt;unordered_map&gt; #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;vector&gt; #include &lt;utility&gt; #include &lt;algorithm&gt; using namespace std; unordered_map &lt;string, int&gt; setupDictionary(vector&lt;string&gt; book) { unordered_map&lt;string, int&gt; table; for (int i =0;i&lt; book.size(); i++) { string word = book[i]; if(word != "") { if (table.find(word)==table.end()) { std::pair&lt;std::string,int&gt; myshopping (word,0); table.insert(myshopping); }else { int num = table[word]; std::pair&lt;std::string,int&gt; myshopping (word,num+1); table.insert(myshopping ); } } } return table; } int main() { vector&lt;string&gt; book; book[1] = "hello"; book[2] = "world"; book[3] = "hello"; book[4] = "world2"; unordered_map &lt; string, int&gt; dict= setupDictionary(book); // printf("%s,%d",dict["hello"]); } </code></pre> <p>Compile and build is good. But after I run it, I got segmentation fault. Need help Dont really know whats wrong in my code. Thank you indeed!</p>
c++
[6]
1,218,279
1,218,280
What is a better way to save the items of the playlist?
<p>In my music player if you add songs to the playlist , program first creates a directory by the name of playlist and then a <code>.txt</code> file. In this file , it adds the path or name of the song added in the playlist.Each entry is on a new line.So if i create a playlist named "Ghazals" and add 100 songs into that playlist 100 new lines are inserted in the txt file under the folder named "Ghazals".</p> <p>If there are 50 playlists there will be 50 folders and in each folder there will be txt files that has the list of songs. </p> <p>For sure,this is not the right way . What should i do to avoid this <em>(the cluster)</em> ? For example how do players like "window media player" save their playlists ?</p>
java
[1]
4,828,739
4,828,740
Complicated way of Javascript function
<p>I observe a different (different for me) way to write function of javascript or jquery,,,you guys kindly guide me about the working of this one.</p> <pre><code>(function () { //some statements of javascript are sitting here //some statements of javascript are sitting here //some statements of javascript are sitting here //some statements of javascript are sitting here //some statements of javascript are sitting here }()); </code></pre> <p>Truly I'm not understanding <code>(function(){}());</code>.</p> <p>No one is calling it but it is being called properly.</p> <p>If any piece of tutorial you guys know, concerned to it, then tell me.</p>
javascript
[3]
3,292,744
3,292,745
What will be the fastest way to access an element from a collection?
<p>What will be the fastest way to access an element from a collection?</p> <p>I am thinking should be in the order (low to high):</p> <p>Indexing an Array &lt;= indexing a collection/list &lt;= use key on Dictionary</p> <p>But I am not sure... </p> <p>1) Is indexing an array has same speed as indexing a list?</p> <p>2) And will the indexing speed will grows as the size of the array/list grows?</p> <p>From my understanding... indexing array should kind of using a pointer to point to the index of the element, which is caculated by the element size. So it should has same speed as indexing collection/list?</p> <p>From what I know if we use Dictionary to look for a value, the speed of getting a value will grows as the size of Dictionary grows.</p> <p>3) I just wonder what will be the fastest way to access an element from a collection?</p> <p>Have been wondering for long time is my assumption is correct :)</p> <p>Thanks</p>
c#
[0]
2,901,540
2,901,541
"maximum recursion depth exceeded" when "property" is applied to instance variable "self.x"
<p>I was reading property(), which I understand is attribute access goes through the method specified in property(). But I got "RuntimeError: maximum recursion depth exceeded", when executed the following code.</p> <pre><code>class Property(object): def __init__(self): self.x = "Raj" def gettx(self): print "getting x" return self.x def settx(self, val): print "Setting x" self.x = val def dellx(self): print "deleting" return self.x x = property(gettx, settx, dellx, "I'm object property") p = Property() print "p.x", p.x p.x = "R" print "p.x:", p.x </code></pre> <p>Is it not possible to apply property in this way. Because it worked fine when 'self.x' changed to self._x and self.__x.</p>
python
[7]
3,657,121
3,657,122
Error in function prototype
<p>Why does this code result in error?</p> <pre><code>class CommonRuntine { public: struct TProcess; TProcess GetProcessByName(LPCSTR ProcessName); }; </code></pre> <p>It says "<strong>E2293 ) Expected</strong>" on the "<em>};</em>" bit</p> <p>PS : LPCSTR is a type</p>
c++
[6]
198,194
198,195
alert when clicking on disabled tag
<p>i disable any input and select with this code:</p> <pre><code> var elements = ['#lbl1' ,'#lbl2','#lbl3','#lbl4','#lbl5','#lbl6','#lbl7']; jQuery.each(elements, function(element) { $(elements[element]).attr('disabled', true); }); </code></pre> <p>now, i want to if user clicking on the disabled tags alert for user:</p> <pre><code>var elements = ['#lbl1' ,'#lbl2','#lbl3','#lbl4','#lbl5','#lbl6','#lbl7']; jQuery.each(elements, function(element) { $(elements[element]).click(function{ if ( $(elements[element]).attr() == 'disabled') alert('DISABLED'); }); }); </code></pre>
jquery
[5]
5,786,013
5,786,014
How to replace whitespaces with dashes
<p>My idea is to remove special characters and html codes and replace the whitespaces to dashes let us doing it step by step</p> <pre><code>$text = "Hello world)&lt;b&gt; (*&amp;^%$#@! it's me: and; love you.&lt;p&gt;"; </code></pre> <p>now i'm want the output become <code>Hello-world-its-me-and-love-you</code> I've tired this code for removal of special characters and html codes </p> <pre><code>$array = array(); $array[0] = "/&lt;.+?&gt;/"; $array[1] = "/[^a-zA-Z0-9 ]/"; $textout= preg_replace($array,"",$text); </code></pre> <p>Now the output will be like this <code>Hello world its me and love you</code> so is there any way i can modify this code so that the text output become exact as i do needs <code>Hello-world-its-me-and-love-you</code></p> <p>~ thank you</p>
php
[2]
3,953,120
3,953,121
What library can I use to implement event driven programming in Python?
<p>Maybe something like Django signals that doesn't depend on Django.</p> <p>Django signals can be used to <a href="http://larrymyers.com/articles/4/django-signals-and-caching" rel="nofollow">clear cache on saving a model</a>, I'm trying to do the same.</p>
python
[7]
4,328,556
4,328,557
How to get the inner html value
<pre><code>var str_f = document.getElementById("" + j + "").innerHTML; &lt;p&gt; &lt;span style="color: red"&gt;advertising cctv/bust&lt;/span&gt; &lt;span style="color: red"&gt;a&lt;/span&gt;tion &lt;/p&gt; </code></pre> <p>how can i get the value</p>
javascript
[3]
3,963,255
3,963,256
How to enable User to surf during ASP.NET DLL upload
<p>I am using ASP.NET as the backend for windows phone browser. Sometime I need to make changes on the ASP.NET Pages WHILE users are surfing the website. I want to know how can I provide un-interrupted service to user in such a way they can surf during ASP.NET DLL uploading process:</p> <p><strong>Assume</strong></p> <ol> <li><p>say, there are a few ASP.NET (DLL) in production WebServer in such a way that all aspx pages in the one Folder and all DLL(s) in bin-folder.</p></li> <li><p>page(1).aspx , page(1.2).aspx , page(1.n).aspx from DLL(1) and page(2.1).aspx, page(2.2) from DLL(2)</p></li> <li><p>default.aspx from DLL(1)</p></li> </ol> <p><strong>Question</strong></p> <p>What will happen if I upload the updated DLL(2) to the production server and leave DLL(1) as it is : </p> <ol> <li><p>Can user call the deafult.aspx? </p></li> <li><p>Will user still be able to call aspx pages from DLL(1) during the uploading process?</p></li> </ol>
asp.net
[9]
30,512
30,513
Java Call constructor multiple times
<p>I have a class that's essentially like:</p> <pre><code>class Child extends Parent { public void reinitialize() { super(); // illegal } } </code></pre> <p>Basically, I want to call the constructor again to reinitialize. I can't refactor out the initialization code into its own method, because <code>Parent</code> is a library class I can't modify the source of.</p> <p>Is there a way to do this?</p>
java
[1]
5,322,222
5,322,223
Create a list (of tuples?) from two lists of different sizes
<p>I am stuck trying to perform this task and while trying I can't help thinking there will be a nicer way to code it than the way I have been trying.</p> <p>I have a line of text and a keyword. I want to make a new list going down each character in each list. The keyword will just repeat itself until the end of the list. If there are any non-alpha characters the keyword letter will not be used.</p> <p>For example:</p> <pre><code>Keyword="lemon" Text="hi there!" </code></pre> <p>would result in</p> <pre><code>('lh', 'ei', ' ', 'mt' , 'oh', 'ne', 'lr', 'ee', '!') </code></pre> <p>Is there a way of telling python to keep repeating over a string in a loop, ie keep repeating over the letters of lemon?</p> <p>I am new to coding so sorry if this isn't explained well or seems strange!</p>
python
[7]
5,785,342
5,785,343
Python - Indentation error while using IDLE and if - else block, works fine on command line
<p>I get the following indentation error</p> <pre><code>&gt;&gt;&gt; number = 35 &gt;&gt;&gt; if number == 35: print 'true' else: File "&lt;pyshell#130&gt;", line 3 else: ^ IndentationError: unindent does not match any outer indentation level &gt;&gt;&gt; </code></pre> <p>This happens only on IDLE and not on command line. I am using Python 2.6.4 on Windows XP. I have searched online, but not been able to find any answer as to why I get this error. Thankful for any help.</p> <p>And to add - The code may not look properly indented when copied and pasted. But it was properly indented on the IDLE interface.</p>
python
[7]
3,948,617
3,948,618
Javascript dynamic table (delete row)
<p>can anyone help me in deleting table row. I have a dynamic table created for to do list rows are added dynamically using the array. also delete button is added for every row and my question is how would you remove the row form the table while the button is pressed. All the data has to be removed form the array. Thank</p>
javascript
[3]
4,858,639
4,858,640
jquery scrollable displays all items
<p>I am trying to create a basic list using jQuery scrollable, but I have a problem in that the entire list is being displayed - not a subset as supposedly defined by the 'size' parameter in scrollable().</p> <p>I am testing in Chrome, and it does not detect any javascript errors. Futhermore, the list seems to be capturing the mousewheel when I hover over it, so something seems to be working.</p> <p>I based this off this example <a href="http://flowplayer.org/tools/demos/scrollable/vertical.html" rel="nofollow">here</a>, and seeing as the example works in my browser, I must making some really damn obvious error. I am using the same css/js as was provided in the example.</p> <p>Can anyone enlighten me?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" href="css/scroll.css" type="text/css" media="print"&gt; &lt;script src="js/jquery.js"&gt;&lt;/script&gt; &lt;script&gt; // execute your scripts when DOM is ready. this is a good habit $(function() { // initialize scrollable $("div.scrollable").scrollable({ vertical:true, size:10, clickable:false // use mousewheel plugin }).mousewheel(); // get handle to scrollable API var api = $("div.scrollable").scrollable(); // append new item using jQuery's append() method for (i = 0 ; i &lt; 30 ; i++) { api.getItemWrap().append( '&lt;p&gt;added'+i+'&lt;/p&gt;' ); } api.reload().end(); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="scrollable vertical"&gt; &lt;!-- root element for the items --&gt; &lt;div class="items"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
1,385,574
1,385,575
Increase size of the image view (android)
<p>I have an imageview that loads and image in the xml. </p> <p>I was wonder, how can I programmatically increase the image size ( or reduce it) by scale of 2? (so double it or make it half size)</p> <p>Please help Thanks</p>
android
[4]
4,497,520
4,497,521
iphone image. multiple touches/drag
<p>The problem im facing rightnow is that in an above portion i have scrollview which have different images clicking on it will clone a same image on to the screen. i have enable touches so i can drag it, but when i clicked another image and it comes to the screen i can drag that anotther image but not the previous one now. can any one have a solution so i can drag multiple images on clicking on it. i can put 4-5 on it for my use.</p> <p>i have use this code: Code:</p> <pre><code>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch=[[event allTouches]anyObject]; CGPoint location = [touch locationInView:touch.view]; g1.center = location; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [self touchesBegan:touches withEvent:event]; } </code></pre> <p>thanks in advance. </p>
iphone
[8]
1,267,465
1,267,466
PHP SQL Syntax Check if theres a match
<p>I am trying to query the db in php and get if there is a match / success but it's not resulting in success although it should so I've thinking there's a syntax error?</p> <p>Here is the code:</p> <pre><code>if ($db_found) { $SQL = "SELECT * FROM wp_users where user_login='.$user.'"; $result = mysql_query($SQL); //Check if theres a match if $result &gt; 0 { echo 'There was a match'; } ... } </code></pre>
php
[2]
2,040,469
2,040,470
jQuery - Are there Multiview/Column plugins that are not using jQuery Mobile?
<p>I keep searching the web and almost all of the plugins are using <a href="http://jquerymobile.com/" rel="nofollow">jQuery Mobile</a>.</p> <p>Are there any other Multiview/Column plugins that are generic?</p>
jquery
[5]
3,796,798
3,796,799
What does "\u7cfb\u7edf\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\u3002" mean?
<p>I post some parameters to a PHP page and return some message, looks like <code>\u7cfb\u7edf\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\u3002</code>, I don't know what that means?</p>
php
[2]
2,410,065
2,410,066
PHP Linkify Links In Content
<p>I've been working on a little project, and I find myself in a position where I need a php function which can linkify URLs in my data, while enabling me to set some exceptions on links I don't want to linkify. Any idea of how to do this?</p>
php
[2]
3,845,773
3,845,774
How do I learn Java5 or Java6?
<p>I'm a very experienced Java programmer who has spent my entire time working with Java 1.4 and earlier. Where can I find a quick reference that will give me everything I need to know about the new features in Java5 and later in a quick reference?</p>
java
[1]
58,040
58,041
How to keep radio selected states when hitting browser back button?
<p>I am handling a survey multistep form with many radio sets.</p> <p>They have some default states</p> <p>User operates over them to select his preferences.</p> <p>Now the client wants when hitting either browser back button or the side navigator links (a set of links pointing to previous stages of the survey) to have the radio states the user previously chose.</p> <p>Here is how the navigator looks like:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a href="index.php?site=form1"&gt;Step1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="index.php?site=form2"&gt;Step2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="index.php?site=form3"&gt;Step3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>There is only one $_SESSION that collects data throughout the survey.</p> <p>I know I can load information directly from $_SESSION but I need to replace the default states when the request comes from the navigator links/ back button.</p>
php
[2]
3,515,148
3,515,149
Should the "sub"-activities in a TabActivity bind services?
<p>I am building an application based on a tabbed activity. There are about 12 tabs at any given time.</p> <p>I have built a download service, for my own use, which requires binding to it. I've found a few questions about the issue binding Services from tabs, but I haven't found anything discussing the best way to design this.</p> <p>My paths seem to be:</p> <ol> <li>Bind the download service in the tab's activities using getParent() or getApplicationContext() as the context to bind to.</li> <li>Bind the download service once in the TabActivity and then expose it via a static method to other Activities making up the tabs.</li> <li>Redesign the download service so that it does not require binding. (I'm not really sure this is a viable option or buys me much)</li> </ol> <p>I'm basically in a toss up between 1 and 2. It seems like #1 seems to make the activities more independent, but I'm not sure if its going to cause problems having the tab "sub" activities binding the same service 12 times on the tab activitie's context. Similarly, I'm not sure if it is good practice to expose state-dependent objects, like a Service, via a static method to other Activities. I'm concerned it may create a number of race conditions that need to be accounted for depending on when the binding happens and when the tab activities are started.</p> <p>What seems like the better design?</p>
android
[4]
2,000,223
2,000,224
Do you have to release IBOulets in dealloc?
<p>Do you have to release IBOulets in dealloc? I'm not sure on this one because I didn't do the alloc and typically you only release for something you called alloc on. Anyone know?</p>
iphone
[8]
620,003
620,004
When and why should $_REQUEST be used instead of $_GET / $_POST / $_COOKIE?
<p>Question in the title.</p> <p>And what happens when all 3 of $_GET[foo], $_POST[foo] and $_COOKIE[foo] exist? Which one of them gets included to $_REQUEST?</p>
php
[2]
5,060,012
5,060,013
returning two values
<p>How can I modify this:</p> <pre><code>if ( reader.GetString( reader.GetOrdinal( "Status" ) ) == "Yes" ) { return true; // Return Status + Date it was Completed } else { return false; // Return Status + null Date. } </code></pre> <p>To return two values? Currently it returns the column 'Status' from the database with the value of Yes or No. How can I have it return the completed date and the status?</p>
asp.net
[9]
5,909,320
5,909,321
how to unblock specific usb port
<p>I have block all usb through this code. It will block all usb port.</p> <pre><code> RegistryKey key = Registry.LocalMachine.OpenSubKey ("SYSTEM\\CurrentControlSet\\Services\\UsbStor",true); if (key != null) { key.SetValue("Start", 4, RegistryValueKind.DWord); } key.Close(); </code></pre> <p>and unblock with this code.but it unblock all usb port. </p> <pre><code>RegistryKey key = Registry.LocalMachine.OpenSubKey ("SYSTEM\\CurrentControlSet\\Services\\UsbStor", true); if (key != null) { key.SetValue("Start", 3, RegistryValueKind.DWord); } key.Close(); </code></pre> <p>My problem is to unblock only specific usb port. How we unblock only one usb port.</p> <p>Please help me. </p> <p>Thanks in advance.</p>
c#
[0]
5,557,494
5,557,495
jQuery UI: - Switch Class but add a hover effect?
<p>I have the following jQuery code to add a class to "p" tags within an "li" when you hover over them... but how can i make this more interesting by adding a transition effect rather than just a straight switch?</p> <p>code:</p> <pre><code>$(document).ready(function() { $('li').hover(function() { $('p', this).toggleClass('hovered'); }); }); </code></pre>
jquery
[5]
3,601,684
3,601,685
$ not defined error in jquery
<p></p> <pre><code>&lt;script type= "text/javascript"&gt; //&lt;!CDATA[[ $(init); function init() { $("#heading").load("head.html"); $("#menu").load("menu.html"); $("#content1").load("story.html"); $("#content2").load("story2.html"); $("#footer").load("footer.html"); }; //]]&gt; &lt;/script&gt; </code></pre>
jquery
[5]
5,861,321
5,861,322
Request superuser rights to edit file
<p>I'm planing an app where i need to edit a system file.</p> <p>I can only edit that file with root rights. I have a rooted dev phone with Superuser.apk installed. Other apps that require root do request root access on first start. I want to do the same but I can't find any hints on how to request superuser rights for my app.</p> <p>I found something about an intent android.intent.action.superuser but when I try to launch an activity for that intent action I get an <code>ActivityNotFoundException</code>.</p> <p>Any ideas?</p>
android
[4]
3,830,902
3,830,903
remove parent (header) of button, and add textarea in its place
<p>I have this html right now:</p> <pre><code>&lt;h1&gt;&lt;span class = 'highlight'&gt;&lt;input type='image' class='removeall' src='remove.png'&gt; &lt;input type='image' class='edit' src='edit.png'&gt; {$result['title']}&lt;/span&gt;&lt;/h1&gt; &lt;form action = "addin.php" method="get"&gt; &lt;textarea name="add" id="add"&gt;&lt;/textarea&gt; You have &lt;span id="charsLeft"&gt;&lt;/span&gt; chars left &lt;/br&gt; &lt;input type="submit" value="Add"&gt; &lt;/form&gt; </code></pre> <p>What I want to do in jquery is onclick of the .edit <code>&lt;input&gt;</code> type, <code>&lt;h1&gt;&lt;/h1&gt;</code> and its contents would be removed, and the later html (textarea) should fadein in its place. Anyone know a simple way to do this?</p> <p>&nbsp;</p>
jquery
[5]
2,803,100
2,803,101
android large screen support
<p>In order to fit different resolution, I use the layout-480 * 320 layout-800 * 480 layout-1280 * 720 under the res folder, my test machine is a galaxy nexus, a resolution of 1280 * 720, galaxy nexus load the layout-800 * 480 folder and don not load 1280 * 720 folder why?</p>
android
[4]
5,578,715
5,578,716
can i make a panel transparent for a certain key color like the forms c#?
<p>i have a panel and i wanna make it transparent for a color key (black) and place a flash in it with black background color, then i can still show the form under it</p>
c#
[0]
3,571,141
3,571,142
java servlet programming errror
<pre><code>C:\Tomcat5.5\webapps\WEB-INF\classes&gt;javac MyServlet.java MyServlet.java:2: package javax.servlet does not exist import javax.servlet.*; ^ MyServlet.java:3: package javax.servlet.http does not exist import javax.servlet.http.*; ^ MyServlet.java:5: cannot find symbol symbol: class HttpServlet public class MyServlet extends HttpServlet ^ MyServlet.java:7: cannot find symbol symbol : class HttpServletRequest location: class MyServlet public void doGet(HttpServletRequest req, HttpServletResponse res) throws Serv letException,IOException ^ MyServlet.java:7: cannot find symbol symbol : class HttpServletResponse location: class MyServlet public void doGet(HttpServletRequest req, HttpServletResponse res) throws Serv letException,IOException ^ MyServlet.java:7: cannot find symbol symbol : class ServletException location: class MyServlet public void doGet(HttpServletRequest req, HttpServletResponse res) throws Serv letException,IOException ^ 6 errors </code></pre>
java
[1]
5,256,742
5,256,743
e.Cancel does not work
<p>I have VS 2010 and want to cancel the form closing event via a Yes|No|Cancel dialog, but when I put the e.Cancel in the event handler for the dialog box, I get an error that says "'System.EventArgs' does not contain a definition for 'Cancel' and no extension method 'Cancel' accepting a first argument of type 'System.EventArgs' could be found (are you missing a using directive or an assembly reference?)." Also the word "Cancel" has a red line under it. Everything I've read online says this is the only way to cancel a FormClosing event. I tested the code in VS2008 and it does the same thing.</p> <p>The code for the event handler is below:</p> <pre><code>private void displayMessageBox(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Do you want to save the changes to the document before closing it?", "MyNotepad",MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { saveToolStripMenuItem_Click(sender, e); } else if (result == DialogResult.No) { rtbMain.Clear(); this.Text = "Untitled - MyNotepad"; } else if (result == DialogResult.Cancel) { // Leave the window open. e.Cancel() = true; } </code></pre> <p>Here are the usings (in the event it makes a difference):</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; </code></pre>
c#
[0]
3,669,433
3,669,434
Zend: best way to implement custom form validation?
<p>I have a few custom form validation rules I wish to apply. Things like ensuring the password has one capital letter, at least one number, and a symbol.</p> <p>Where would be best to implement these custom validation rules?</p> <p>I am currently validating them in a controller, but obviously that won't scale very well when I expand. So I was going to implement them as view helpers.</p> <p>I don't have too much experience with zend_form. Is there a way to set a custom validation handler when constructing the form object?</p> <p>Thanks!</p>
php
[2]
1,358,174
1,358,175
characters and files in C++
<p>I have to make a program where the filename is composed of two parts: the first one is fixed and the second one can change during the program e.g "fixpart_integer.dat". I tried to do this in C++ but I did not succeed. The fisrt probelm is: how can i convert a number to a char ; and how can i concanate these 2 characters ; and how to declare this final char in the right way in order to open this filename ?</p> <p>Many questions but I did find an easy way to do this.</p>
c++
[6]
4,269,906
4,269,907
PHP sleep() function killing script after some time
<p>I am experiencing a problem when using sleep() function in php for a long period of time, if i test the following code all runs perfectly:</p> <pre><code>&lt;?php set_time_limit(0); $i = 0; while($i &lt; 10) { echo $i.'&lt;br /&gt;'; if($i == 5){ echo 'sleeping 5 secs&lt;br /&gt;'; sleep(5); echo 'waking up&lt;br /&gt;'; } $i++; } ?&gt; *****OUTPUT**** 0 1 2 3 4 5 sleeping 5 secs waking up 6 7 8 9 *****OUTPUT**** </code></pre> <p>It sleeps 5 seconds and after that the "waking up" is echoed without problems, but, if I raise the amount of seconds the script is sleeping to lets say 15 minutes the output is the following:</p> <pre><code>*****OUTPUT**** 0 1 2 3 4 5 sleeping 900 secs //(15 mins) *****OUTPUT**** </code></pre> <p>The script appears to be killed after 15 minutes of sleeping!!, what could be causing this? note that I set the max_execution_time flag to infinite with set_time_limit(0); at the top of the script.</p> <p>I will appreciate any help, thanks!</p>
php
[2]
4,466,012
4,466,013
file() VS file_get_contents() which is better? PHP
<p>I just want to know how to improve the speed of the web application I am creating.</p> <p>I am also open to other suggestions.</p> <p>fread or file_get_contents??</p>
php
[2]
5,579,902
5,579,903
How to pass multiple parameters values from one php page to another
<p>Below is the setup I am using:</p> <p>I have this button(submit):</p> <pre><code>&lt;input type="submit" name="pageaction" class="contact_list_uploadcsv_btn" value="Send SMS" /&gt; </code></pre> <p>pageaction: is a switch case"Send SMS" in the controller.php, so when the user press "Send SMS" it will perform the case"Send SMS".There are some parameter in this page templates.php which I want to redirect them to Sendsms.php page when the user press "Send SMS button".</p> <p>So I have templates.php which contain the button and the fields(values) that I want to take them to Sendsms.php. Controller.php linking between the two pages templates.php and Sendssms.php</p> <p>The fields in template.php are :</p> <pre><code>&lt;div class="contacts_checkbox_02"&gt;&lt;input name="template_id" id="template_id" type="checkbox" value="'.$templates_row['template_id'].'" style="margin-top:0px;" /&gt;&lt;/div&gt; &lt;div class="search_title01" id="title"&gt;'.$templates_row['title'].'&lt;/div&gt; &lt;div class="message_body01" id="body"&gt;'.$templates_row['body'].'&lt;/div&gt; </code></pre> <p>When the user check the checkbox and press "Send SMS" it should redirect him to "Sendsms.php" and pass the the values of [title] and [body].</p> <p>Could you please help with this?</p> <p>Thanks,</p>
php
[2]
781,009
781,010
Take a ScreenShot from Android Device as iPhone
<p>I have a problem that I have to make an Android App which take a screenshot of Android device same as iPhone does. So, Is it possible to make such kind of Android App? If yes, then provide me some suggestions or example for doing the same.</p> <p>Thanks in advance.</p>
android
[4]
3,394,634
3,394,635
what is the error in this code and why?
<pre><code>class Person { String name = “No name"; public Person(String nm) { name = nm; } } class Employee extends Person { String emplD = “0000”; public Employee(String id) { empID = id; } } public class EmployeeTest { public static void main(String[ ] args) { Employee e = new Employee(”4321”); System.out.println(e.empID); } } </code></pre>
java
[1]