Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
1,620,082
1,620,083
How to manually dispatch hashchange event
<p>1 - What is correct syntax for WebKit (primary for Safari on iPad, good if it works on Win Chrome) to <code>.addEventListener</code> to <code>hashChange</code> event?</p> <p>2 - Is is possible (and how) to manually/programmatically dispatch hashChange event by <code>.dispatchEvent</code> on browsers mentioned above?</p> <p>TIA.</p> <p>I've found answer for 1:</p> <p><code>window.addEventListener("hashchange", function() {console.log(location.hash)});</code></p> <p>But I still have no idea how to dispatch <code>hashchange</code> manual since I don't know what <code>EVENTOBJECT</code> I should pass to <code>window.dispatchEvent(EVENTOBJECT)</code>.</p>
javascript
[3]
3,182,320
3,182,321
Calculate after X days from today
<p>Hi Friends i am develop a webpage in that i need to calculate x days from a specified date , The problem is we exclude the saturday and sunday . For example $Shipdate = '06/30/2009' and the x is 5 means , i want the answer '7' [ie 30 is tuesday so after 5 days it will be sunday , so there is two holiday(saturday and sunday) so we add 5+2(for saturday and sunday)]=7. Please help me to find out , Thanks in advance.</p>
php
[2]
2,040,881
2,040,882
Enter key on EditText hitting onKey twice
<p>I've attached an OnKeyListener to an EditText. I've overrode the onKey handler to capture a KeyEvent.</p> <p>When a user hits the enter key (either their computer enter key while using the emulator, or the hardware enter key on their phone with a hardware keyboard), the onKey handler gets executed twice. Both executions have the keyCode 66.</p> <p>Why is this happening?</p> <p>I want my screen so when the user hits the enter key, a search is performed. Because of what is happening, the search is needlessly happening twice.</p> <p>My method looks like this:</p> <pre><code> mFilter.setOnKeyListener(new View.OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { // perform search return true; } return false; } }); </code></pre>
android
[4]
568,552
568,553
How to uninstall Iphone sdk?
<p>Here Im getting a problem when Im uninstalling the Iphone sdk through terminal with the command as:</p> <pre><code>sudo /Developer/Library/uninstall-devtools mode=all;; </code></pre> <p>When I used this its displaying the command is not found.</p> <p>Is there any other method to unistall Iphone sdk?</p> <p>Anyone's help will be much appreciated.</p> <p>Thank you, Monish.</p>
iphone
[8]
5,427,354
5,427,355
Filter url based on parameters
<p>i want to filter the url based on some parameters in it, separated by a plus (+).</p> <p>This is a sample url:</p> <p><strong>http://localhost/a.php?f1=a+b+1&amp;f2=c+d+2&amp;f3=e+f+3&amp;.............</strong></p> <p>Now i want to get each of the parameters in f1, f2, f3....... like i want to fetch the values of a, b, and 1 from parameter f1.</p> <p>How can i go ahead with this...</p>
php
[2]
1,295,806
1,295,807
getting error while building the project
<p>I am getting the following error while building using ant:-</p> <p>BUILD FAILED H:\USE\android-sdk-windows\tools\ant\ant_rules_r3.xml:361: The following error occurred while executing this line: H:\USE\android-sdk-windows\tools\ant\ant_rules_r3.xml:174: apply returned: 255</p>
android
[4]
2,109,607
2,109,608
image rotation /animation
<p>I need a java method to rotate an image like <a href="http://upload.wikimedia.org/wikipedia/commons/thumb/7/76/Wheel_of_Fortune_template.svg/513px-Wheel_of_Fortune_template.svg.png" rel="nofollow">this</a>, I would like to have some kind of animation like the real "wheel of fortune" Do you have any suggestions? </p> <p>P.S. If it is possible to rotate that image how can I handle the values?</p> <p>thank you </p>
java
[1]
1,330,433
1,330,434
Javascript - Repeated Characters
<p>I'm trying to create a program to repeat the word entered for as many times as it has characters, I've tried several different methods which are not working, here is the work so far. </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Repeat Word&lt;/title&gt; &lt;script type="text/javascript"&gt; //Program: Repeat Word //Purpose: Repeat word for as many times as it has characters //Date last modified: 4/11/12 var word = ""; word = prompt("Enter the word you would like repeated?") &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>An example of what I want it to repeat for hello would be...</p> <pre><code>Enter a word: Hello Hello Hello Hello Hello Hello </code></pre>
javascript
[3]
2,304,403
2,304,404
How do I use try .. except or if ...else to validate user input?
<p>I want to restrict user input so that a provided <code>N</code> obeys <code>N &gt;0</code> or <code>N &lt; 100</code>.</p> <p>Should I use <code>if... else</code> or <code>try... except</code>? Could you provide examples of both approaches?</p>
python
[7]
4,651,566
4,651,567
Popextender closes the panel after commit
<p>I'm creating a panel with a multi select CheckBoxList, attached to a TextBox through a PopControl extender.</p> <p>I'm using the <code>.commit()</code> method of the <code>PopControl</code> extender to display the selected item.</p> <p>When I select an item from the CheckBoxist the panel closes, and I want to select the item without closing the panel.</p> <p>What am I doing wrong?</p> <p><strong>Markup</strong></p> <pre><code>&lt;asp:TextBox ID="txtCountry" runat="server" Skinid="longTextbox" AutoPostBack = "false" OnClientItemSelected="passtohidden()" /&gt; &lt;asp:Panel ID="pnlLocation" runat="server"&gt; &lt;asp:UpdatePanel runat="server" ID="upLocation"&gt; &lt;ContentTemplate&gt; &lt;asp:CheckBoxList ID="chkLocation" SkinID ="chkColor" runat="server" AutoPostBack = "true" onselectedindexchanged="chkLocation_SelectedIndexChanged" /&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="txtCountry" EventName="TextChanged" /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; &lt;/asp:Panel&gt; &lt;asp:PopupControlExtender ID="Panel1_PopupControlExtender" runat="server" Enabled="True" Position="Bottom" PopupControlID = "pnlLocation" TargetControlID="txtCountry" /&gt; </code></pre> <p><strong>Code behind</strong></p> <pre><code>protected void chkLocation_SelectedIndexChanged(object sender, EventArgs e) { string strSelected = ""; foreach (ListItem l in chkLocation.Items) { if (l.Selected) { strSelected += l.Text + " ,"; } } //txtCountry.Text = strSelected; Panel1_PopupControlExtender.Commit(strSelected); } </code></pre>
asp.net
[9]
5,523,944
5,523,945
Cant assign value from getElementById to date?
<p>I've got this:</p> <pre><code> var lDate = document.getElementById('txtLeaveDate'); var rDate = document.getElementById('txtReturnedDate'); </code></pre> <p>Err...javascript so how do I assign the value of txtLeaveDate to a date variable</p> <p>I tried:</p> <p><code>var myDate = new Date(lDate.value);</code></p> <p>But this assigns some long value....</p> <p>I can do it if I try:</p> <pre><code>var today = new Date(); var day2 = new Date(); day2.setDate(today.getDate() + 30); </code></pre> <p>But the issue is I need to get the date from txtLeaveDate not by a date variable</p> <h1>edit complete code</h1> <pre><code>var theLDate = new Date(lDate.value); var theRDate = new Date(rDate.value); //check if return date is a sunday, if it is no need //to do anything, //else make it a sunday while (theRDate.getDay() != 0) theRDate.setDate(theRDate.getDate() + 1); //at this point RDate is a sunday... while(theLDate.valueOf() &lt;= theRDate.valueOf()) { if(theLDate.getDay() == 0) { //sunday var li = document.createElement('li'); li.setAttribute('id', ['liID' + count]); var month = theLDate.getMonth(); var day = theLDate.getDate(); var year = theLDate.getFullYear(); var theDay = month + '/' + day + '/' + year + ' (Sunday)'; li.innerHTML = theDay; ul.appendChild(li); } theLDate.setDate(theLDate.getDate() + 1); count++; } </code></pre> <p>But when I pick 2 dates in my calendar like so:</p> <p><img src="http://i.stack.imgur.com/I00Oy.png" alt="enter image description here"></p>
javascript
[3]
2,822,116
2,822,117
Set focus in Listbox in MVVM pattern
<p>I am trying to set a focus on the first Item of listBox. I am binding the value to listbox, contaning a textbox by a onpropertychange method and I want to set focus in the first item. how can I achieve that? </p>
c#
[0]
855,729
855,730
XMLHttpRequest cannot load file://... Origin null is not allowed by Access-Control-Allow-Origin
<p>I see that the above question was asked earlier, however even after referring them I wasn't able to figure out a way for me, hence I took the liberty to start a new post for this question.</p> <p>I have a getjson.html file containing the following code</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("button").click(function(){ $.getJSON("json_data.txt",function(result){ $.each(result, function(i, field){ $("div").append(field + " "); }); }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;button&gt;Get JSON data&lt;/button&gt; &lt;div&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The json_data.txt contains the following,</p> <pre><code>{ "firstName": "John", "lastName": "Doe", "age": 25 } </code></pre> <p>When I open the getjson.html file in the browser, it gives an error:</p> <blockquote> <p>"XMLHttpRequest cannot load file://..... Origin null is not allowed by Access-Control-Allow-Origin."</p> </blockquote> <p>Someone Please suggest a simple solution regarding this about how could I make this thing possible.</p> <p>P.S: I am writing a web app on go.</p>
javascript
[3]
4,516,917
4,516,918
c# file move (file is already used by another process)
<p>I am moving files from one folder to another. If I try to move the entire folder to the folder within that particular folder I cannot do that. But if I move it outside it works fine. How can I move my folder to the folder within that folder?</p> <p><strong>this gives error</strong></p> <pre><code> if (System.IO.Directory.Exists(PhysicalPath)) { string sourcePath = "c:\\copypath\\"; string targetPath = "c:\\copypath\\abc\\"; System.IO.Directory.Move(sourcePath, targetPath); } </code></pre> <p><strong>this works fine</strong></p> <pre><code> if (System.IO.Directory.Exists(PhysicalPath)) { string sourcePath = "c:\\copypath\\"; string targetPath = "c:\\abc\\"; System.IO.Directory.Move(sourcePath, targetPath); } </code></pre>
c#
[0]
3,478,078
3,478,079
how to detect references to members of temporary objects
<p>My colleague recently compiled our program in Windows, and discovered a bug of the sort: </p> <pre><code> std::string a = "hello "; std::string b = "world"; const char *p = (a+b).c_str(); printf("%s\n", p); </code></pre> <p>which for some reason did not crash in our Linux executables.</p> <p>None of our compilers give any kind of warning, so we are now worried that this error might exist in the code. </p> <p>Although we can <em>grep</em> for <code>c_str()</code> occurrences and do a visual inspection, there is a possibility that one might have also done the following:</p> <pre><code>struct I { int num; I() { num=0; } }; struct X { I *m; X() { m = new I; } ~X() { delete m; } I get() { return *m; } // version 1, or I&amp; get() { return *m; } // version 2 }; </code></pre> <p>and accessed it like:</p> <pre><code> I&amp; a = X().get(); // will get a reference to a temporary, or a valid copy? cout &lt;&lt; a.num; </code></pre> <p>instead of :</p> <pre><code> cout &lt;&lt; X().get().num; </code></pre> <p>which is safe <em>(isn't it?)</em></p> <p><strong>Question:</strong> Is there a way I can catch such errors (perhaps using the compiler, or even an assertion) ?<br> I need to be sure that if author of <code>struct X</code> changes <code>get()</code> between <em>version 1</em> and <em>2</em> that the program will warn for the error</p>
c++
[6]
1,804,305
1,804,306
Why does ASP.NET publish my local folder paths?
<p>In a common ASP.NET Web Forms page, I specify the location of a backup file as follows:</p> <pre><code>string backupFilePath = "../data/backups"; ICronjobTask[] tasks = new ICronjobTask[] { new FileBackupCronjobTask(backupFilePath) }; </code></pre> <p>The <code>ICronjobTask</code> is executed later on. When calling the published page on my web server, an error message tells me that parts of the path <code>"C:\Windows\SysWOW64\inetsrv\data\backups\file.txt</code> could not be found.</p> <p>Why does ASP.NET publish my local directory structure? How do I turn this off?</p>
asp.net
[9]
1,091,241
1,091,242
Problem in erasing element in list
<pre><code>struct ScheduleTaskInfo { unsigned int nTaskID; __time64_t timeStartTime; __time64_t timeEndTime; }; typedef list&lt;ScheduleTaskInfo&gt; SchedulerList; SchedulerList::iterator itrSchedulerList; for(itrSchedulerList = gSchedulerList.begin();itrSchedulerList != gSchedulerList.end();itrSchedulerList++) { SYSTEMTIME st; GetLocalTime(&amp;st); CTime ctSyatemTime(st); if (itrSchedulerList-&gt;timeEndTime == ctSyatemTime.GetTime()) { itrSchedulerList = gSchedulerList.erase(itrSchedulerList); } } </code></pre> <p>I am doing this it is crashing in for loop.I think it is due to erase(); Am I doing something wrong here??Please suggest me on this </p>
c++
[6]
4,764,379
4,764,380
regex.test(): where does it come from?
<p>I am curious about the use of the function named <em>test</em> (line 3) below:</p> <pre><code>var pattern = /[1-9][1-9]{5}/; var str = 'this is 248760!'; alert(pattern.test(str)); </code></pre> <p>I saw this script in a book and there is no definition of the <code>test(str)</code> function. </p> <p>Why does it alert <code>true</code> instead of giving an error?</p>
javascript
[3]
944,616
944,617
jQuery click function, wait for it to complete before starting again?
<p>At the moment when I double/treble/etc click on the .next button the script is ran, I need it to queue after each other? How can I do this so that the function is completed before starting again?</p> <p>HTML</p> <pre><code>&lt;ul id="one" class="first selected"&gt; &lt;li class="pic_one"&gt;&lt;/li&gt; &lt;li class="pic_two"&gt;&lt;/li&gt; &lt;li class="pic_three"&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul id="two"&gt; &lt;li class="pic_one"&gt;&lt;/li&gt; &lt;li class="pic_two"&gt;&lt;/li&gt; &lt;li class="pic_three"&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul id="three" class="last"&gt; &lt;li class="pic_one"&gt;&lt;/li&gt; &lt;li class="pic_two"&gt;&lt;/li&gt; &lt;li class="pic_three"&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>jQuery</p> <pre><code>$('.slider .next').click(function(){ if($('.slider ul.selected').hasClass('last')){ // leave blank } else { $('.slider ul.selected').hide('slide', { direction: "left" }, 1000); $('.slider ul.selected').removeClass('selected'); $('.slider ul').parent().next('ul').show('slide', { direction: "right" }, 1000).addClass('selected'); } }); </code></pre>
jquery
[5]
165,154
165,155
C# drawing Rectangle with precision coordinates. How?
<p>How do I draw a Rectangle in C# with precision coordinates?</p> <p>Example:</p> <pre><code>Rectangle test1 = new Rectangle(X, Y, Width, Height); </code></pre> <p><strong>Width</strong> and <strong>Height</strong> values seem to <strong>have to be integers</strong>.</p> <p>Is it possible to give Rectangle, <strong>inch size coordinates</strong> somehow?</p> <pre><code>Rectangle test2 = new Rectangle(100, 50, 1.93inches, 0.52inches); </code></pre> <p>Thanks for any help.</p>
c#
[0]
3,392,224
3,392,225
Add sound when turning page with the keyboard
<p>How to add a turning pages sound effect without to use the Next / Previous buttons, because it also controlled by the keyboard arrows.</p>
javascript
[3]
127,219
127,220
accessing static variable in multi threading system
<p>I have to take one input from console in first java program. That input i have to pass in second java program which is getting executed as thread from the main method of first java program.</p> <p>I made the variable as static and tried accessing in second java program but it is showing null value(default value).</p> <p>I am not supposed to make the object of first program also. Please suggest me how to do?</p>
java
[1]
1,966,951
1,966,952
Why do these two code fragments differ
<p>I just noticed that when I change the last line in the code fragment from <code>potential =+ rep_pot</code> to <code>potential = potential + rep_pot</code>, I get completely different behaviour. Has anybody got any idea why this is happening?</p> <pre><code>double potential = euclideanDistance(i, goal); for (IntPoint h: hits){ double dist = euclideanDistance(i, h); double a = range - dist; double rep_pot = (Math.exp(-1/a)) / dist; potential =+ rep_pot; } </code></pre>
java
[1]
6,033,719
6,033,720
Getting Null Pointer in PreparedStatement.close()
<p>im trying to insert values from textfield to mySql using jdbc but my problem is im having a null pointer error when closing my prepared statement. here's my code</p> <pre><code> private Connection con; private Statement stm; private ResultSet rs; private PreparedStatement ps ; public void dbConnect(){ try{ Class.forName("com.mysql.jdbc.Driver"); this.con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbTestDrive" + "", "root", "password"); } catch(ClassNotFoundException ex){} catch(SQLException ex){} } public boolean insert(Member member)throws SQLException{ this.dbConnect(); boolean success = false; String query = "INSERT INTO try VALUES(?, ?)"; try { this.ps = this.con.prepareStatement(query); this.ps.setString(1, member.getMemberId()); this.ps.setString(2, member.getFirstName()); int rows = this.ps.executeUpdate(); if(rows&gt;0){ success = true; } } catch (SQLException ex) { ex.printStackTrace(); throw ex; } finally{ this.ps.close(); // this is my line: 56 (im getting null pointer here) this.con.close(); } return success; } </code></pre> <p>here's the stacktrace:</p> <pre><code> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at rtu.tomis.dao.MemberDao.insert(MemberDao.java:56) at rtu.tomis.gui.AddMemberView.btnSaveActionPerformed(AddMemberView.java:993) at rtu.tomis.gui.AddMemberView.access$800(AddMemberView.java:21) at rtu.tomis.gui.AddMemberView$9.actionPerformed(AddMemberView.java:476) </code></pre> <p>thank u for your help</p>
java
[1]
3,881,524
3,881,525
call function in php, little help please
<p>How can I call a function like below:</p> <pre><code> $display_table="&lt;table&gt;&lt;tr&gt;&lt;td&gt;FUNCTION_CALL_HERE();&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"; </code></pre> <p>I have tried brackets and all, but the function wont get called...</p> <p>How should I make this work? (syntax problems I think)</p> <p>Thanks</p>
php
[2]
4,807,708
4,807,709
event, when (inner) html changes
<p>I would like to catch the event when the innerHTML of an element changes due to "ajaxing".</p> <p>I mean something like this:</p> <pre><code>$('.t_error span').html.change(function(){ ... }); </code></pre> <p>Thanks for help!</p>
jquery
[5]
5,423,245
5,423,246
Scrolling vertical text in 2 different divs
<p>I want to scroll 2 <code>div</code>s when I start the page. I add to the onload the events, but it stops here:</p> <pre><code>var cross_marquee=document.getElementById(marque) cross_marquee.style.top=0 </code></pre> <p>Can someone help me?</p> <p>The code is:</p> <pre><code>var delayb4scroll=2000 var marqueespeed=1 var pauseit=0 var copyspeed=marqueespeed var pausespeed=(pauseit==0)? copyspeed: 0 var actualheight='' var actualheightDiv2='' function scrollmarquee(){ if (parseInt(cross_marquee.style.top)&gt;(actualheight*(-1)+8)) cross_marquee.style.top=parseInt(cross_marquee.sty le.top)-copyspeed+"px" else cross_marquee.style.top=parseInt(marqueeheight)+8+ "px" } function initializemarquee(marque, container){ var cross_marquee=document.getElementById(marque) cross_marquee.style.top=0 marqueeheight=document.getElementById(container).o ffsetHeight actualheight=cross_marquee.offsetHeight if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit cross_marquee.style.height=marqueeheight+"px" cross_marquee.style.overflow="scroll" return } setTimeout('lefttime=setInterval("scrollmarquee()" ,30)', delayb4scroll) } window.onload=initializemarquee('wtvmarquee', 'wtmarqueecontainer') window.onload=initializemarquee("wtvmarqueeDiv2", "wtmarqueecontainerDiv2") </code></pre>
javascript
[3]
5,070,946
5,070,947
different between getView vs getDropDownView with SpinnerAdapter
<p>When you implement SpinnerAdapter you get <a href="http://developer.android.com/reference/android/widget/SpinnerAdapter.html#getDropDownView%28int,%20android.view.View,%20android.view.ViewGroup%29" rel="nofollow">getDropDownView</a>, how is it different from <code>getView</code> which you have as you need to extend <code>BaseAdapter</code>.</p>
android
[4]
3,509,777
3,509,778
Passing an empty object into jQuery function
<p>When reading Pub/Sub library by Ben Alman, I got confused at the very first line that he passed an empty object into jQuery function. Also, he uses bind function object just to apply it in that nearly "empty" object (I used firebug to examine that object and it just return an jQuery object contain empty object inside). Could someone explain this logic for me? Thank sooo much! P/S: I understand the usage and the idea behind Pub/Sub pattern in non-framework context, just don't understand its implementation in jQuery. </p> <p>Here is the code of library I've read:</p> <pre><code> (function($){ var o = $({}); $.subscribe = function() { o.bind.apply( o, arguments ); }; $.unsubscribe = function() { o.unbind.apply( o, arguments ); }; $.publish = function() { o.trigger.apply( o, arguments ); }; })(jQuery); </code></pre>
jquery
[5]
3,675,856
3,675,857
Parsing string sections
<p>What techniques/modules would you use to parse specific string sections. Given lines of the type:</p> <pre><code>field 1: dog field 2: first comment: outstanding field 1: cat field 2: comment: some comment about the cat </code></pre> <p>The field names always end with a colon, the field values can be blank and the fields are separated by spaces only. I just want access to the field values. I know how I would do this using regular expression but I'm sure there are more elegant ways to do this with Python. </p>
python
[7]
5,832,763
5,832,764
BBCode like setup on richtextbox
<p>I am trying to parse a BBCode that I am designing for a richtextbox on my C# program. I am kind of lost how I can do this though. It is not HTML, it is using the </p> <pre><code>using System.Windows.Forms; </code></pre> <p>How can I replace only part of the text inside of this textfield with bold/italic/underline/colored? I am not trying to get too fancy with the bbcode, just want to be able to do those 4 things. Here is an example of the regular expression I was going to use:</p> <pre><code>/\[b\](.*?)\[\/b\]/is </code></pre> <p>Thanks for any pointers :)</p>
c#
[0]
1,285,420
1,285,421
how to change onclick event with jquery?
<p>I have create a js file in which i am creating the dynamic table and dynamically changing the click event for the calendar but onclicking the calender image for dynamic generated table, calendar popup in the previous calendar image. Please help me</p> <p>code</p> <pre><code>/***------------------------------------------------------------ * *Developer: Vipin Sharma * *Creation Date: 20/12/2010 (dd/mm/yyyy) * *ModifiedDate ModifiedBy Comments (As and when) * *-------------------------------------------------------------*/ var jq = jQuery.noConflict(); var ia = 1; jq(document).ready(function(){ jq("#subtaskid1").click(function() { if(ia&lt;=10){ var create_table = jq("#orgtable").clone(); create_table.find("input").each(function() { jq(this).attr({ 'id': function(_, id) { return ia + id }, 'name': function(_, name) { return ia + name }, 'value': '' }); }).end(); create_table.find("select").each(function(){ jq(this).attr({ 'name': function(_,name){ return ia + name } }); }).end(); create_table.find("textarea").each(function(){ jq(this).attr({ 'name': function(_,name){ return ia + name } }); }).end(); create_table.find("#f_trigger_c").each(function(){ var oclk = " displayCalendar(document.prjectFrm['"+ ia +"dtSubDate'],'yyyy-mm-dd', this)"; //ERROR IS HERE var newclick = new Function(oclk); jq(this).click(newclick); }).end(); create_table.appendTo("#subtbl"); jq('#maxval').val(ia); ia++; }else{ var ai = ia-1; alert('Only ' + ai + ' SubTask can be insert'); } }); }); </code></pre>
jquery
[5]
5,585,379
5,585,380
Image generated by PHP not cached
<p>I generate some picture with PHP, and those picture are not cached by the browser.</p> <p>I ouput some picture through a php file the url looks like this :</p> <p><a href="http://127.0.0.1:8080/workspace/cps/index.php?act=file&amp;act2=preview_or_icon&amp;template=disable&amp;file_id=341" rel="nofollow">http://127.0.0.1:8080/workspace/cps/index.php?act=file&amp;act2=preview_or_icon&amp;template=disable&amp;file_id=341</a></p> <p>in my php file i've :</p> <pre><code>header('Content-Type: image/jpeg'); header('Content-Transfer-Encoding: binary'); //Read File </code></pre>
php
[2]
2,413,251
2,413,252
setTimeout in select box change event
<p>When I have autopostback set to true on a select box, why is the 'setTimeout' necessary in the onchange event? Why isn't __doPostBack just called directly?</p> <pre><code>onchange="javascript:setTimeout('__doPostBack(\'ctl00$myselect\',\'\')', 0)" </code></pre>
asp.net
[9]
4,133,783
4,133,784
PHP function: find argument's variable name, and function calls line number
<p>I want to do something like this for simplifying logging operations. Any idea what I should put in for <code>?[1]?</code> and <code>?[2]?</code>?</p> <pre><code>function log_var($var) { $line = ?[1]?; $var_name = ?[2]?; $line--; $filepath = 'log-' . date('Y-m-d'). '.txt'; $message = "$line, $var_name = $var\n"; $fp = fopen($filepath, "a"); fwrite($fp, $message); fclose($fp); @chmod($filepath, 0666); return TRUE; } </code></pre> <p>This how I'd use the function in code (numbers are assumed to be line numbers in actual code):</p> <pre><code>23 $a = 'hello'; 24 log_var($a); 25 $b = 'bye'; 26 log_var($b); </code></pre> <p>And this is what I want to be written to the log file:</p> <pre><code>23, a = hello 25, b = bye </code></pre> <p><strong>EDIT</strong> I converted Paul Dixon function a bit and added the result as an answer. The new form does even MORE than I originally hoped for. Thank you again guys!</p>
php
[2]
1,284,756
1,284,757
jQuery and reference to js and vsdoc.js files
<p>Within vs.net I need to set references to both js and vsdoc.js files for jQuery. Things work great if the script files are within the project HOWEVER I really want to reference a standard folder on our server i.e. <a href="http://www.domain.com/script/jQuery" rel="nofollow">http://www.domain.com/script/jQuery</a> for the location of these files. On our local workstation we have these files located in <a href="http://localhost/script/jQuery" rel="nofollow">http://localhost/script/jQuery</a> </p> <p>How can I reference both consistent location as well as get the benefits of intellsense and F5 (development server) references working well?</p> <p>thx</p>
jquery
[5]
1,092,406
1,092,407
Aztec encoder for Android
<p>I am looking for Aztec encoding library which can convert a string to Aztec barcode image for use in my application.</p> <p>I have seen ZXing <a href="http://code.google.com/p/zxing/" rel="nofollow">http://code.google.com/p/zxing/</a> but it only does decoding (convert Aztec image into its textual representation). I am looking for encoder which can convert a string to Aztec image.</p> <p>Any pointers would be appreciated.</p> <p>Thanks, Yasir</p>
android
[4]
3,871,237
3,871,238
Help using ImageSwitcher in android
<p>So In my program I used to use Imageviews in my layout to display images and had it so when a user pressed the Imageview it changes images. But i recently upgraded my project to version 8 and updated by SDK and i see now that there is a ImageSwitcher view under Transitions. I would like to replace my ImageViews with ImageSwitchers. Ive googled and searched all over but i cant seem to figure out how it works. I was wondering if anyone would be able to explain or show me an example of code on how to use it. What i want is very basic. I just want it to display an image from a bitmap and then when the user swipes left or right it changes the bitmap. I already have the bitmaps. I just cant figure out the code.</p> <p>I tried using this code to start out but i couldnt get it to work with the bitmap</p> <pre><code>ImageSwitcher is = (ImageSwitcher) findViewById(R.id.imageSwitcher1); is.setImageResource(bmap); </code></pre> <p>I tried using this new code to turn my bitmap into a drawable but it always crashes when run. Is there something i can fix?</p> <pre><code>Drawable d = new BitmapDrawable(bmap); ImageSwitcher is = (ImageSwitcher) findViewById(R.id.imageSwitcher1); is.setImageDrawable(d); </code></pre>
android
[4]
5,133,268
5,133,269
Selective Desaturation as picture effect
<p>I am working on image processing app for android!! and I have to do some picture effect like "selective Desaturation" Does any body know how this works?</p> <p>Can you help me with the code?</p> <p>Thanks</p>
android
[4]
320,067
320,068
TimeSpan how to save and update
<p>OK .. here is one that I find interesting. I am using a datatable to hold a bunch of values. I need to store a TimeSpan. I am able to make a column for the TimeSpan data type. I am able to insert the data into the column. Now comes the interesting part ...</p> <p>I need to pull out that TimeSpan data and add another TimeSpan data value to it and resave it. I see that there is no way to '.toTimeSpan' it from a string. Which is the way i am trying to bring it back from the table.</p> <p>So ... Anyone out there have the answer here?</p> <p>The code is in C#</p>
c#
[0]
1,714,694
1,714,695
can someone switch this to if statements instead of switch?
<p>I get this error when I try to compile it on old java machine. And I need to switch to if statements? Can someone shed a light on this to switch to if statement? I get this error </p> <blockquote> <p>incompatible types<br> found : java.lang.String<br> required: int </p> </blockquote> <p>Here is the code</p> <pre><code> switch(name) { String label; Rotor(){;} Rotor(String name){ switch(name){ case "B": conversion_chart = B; break; case "C": conversion_chart = C; break; case "I": conversion_chart=I; notch = NOTCH[0]; break; case "II": conversion_chart=II; notch = NOTCH[1]; break; case "III": conversion_chart=III; notch = NOTCH[2]; break; case "IV": conversion_chart=IV; notch = NOTCH[3]; break; case "V": conversion_chart=V; notch = NOTCH[4]; break; case "VI": conversion_chart=VI; notch = NOTCH[5]; break; case "VII": notch = NOTCH[6]; conversion_chart=VII; break; case "VIII": notch = NOTCH[7]; conversion_chart=VIII; break; } label = name; position = 0; } </code></pre>
java
[1]
4,618,174
4,618,175
serial key validation in c#
<p>I completed my project in C#.Net. I Added a serial key in it. At the time of installation it asks me for the key. The key format is also given by me, but I don't know how to validate that key. Please give me some way how to validate that key. Now my key is validated by visual studio or I don't know who. How is the key's validation done? But I want to do the validation by my own. Is it possible? And if yes, how?</p> <p>i added the customer information dialog. and format is given by using the serial number template. but for validation it create the problem that visual studio's logic is so simple &amp; it is if the some of digits is / by 7 then key is valid.so i want to use the my logic like use sha1,MD5 so where i have to do coding. The design of the customer info dialog is not show,if it is shown then i do the coding on validate button. But now what i have to do?</p>
c#
[0]
3,481,235
3,481,236
Unload AppDomain Assembly
<p>I want to read some information from a .Net assembly, then modify the DLL by appending a short sequence of characters.<br> The first part works fine, but the second step fails, as the assembly is still in use.<br> This is the case although I loaded the assembly in its own AppDomain and after I finished step 1 unloaded the AppDomain.</p>
c#
[0]
2,496,027
2,496,028
Find out time it took for a python script to complete execution
<p>I have the following code in a python script:</p> <pre><code>def fun() #Code here fun() </code></pre> <p>I want to execute this script and also find out how much time it took to execute in minutes. How to find out how much time it took for this script to execute ?.Some example would be really appreciated.</p> <p>Thank You</p>
python
[7]
1,249,798
1,249,799
ListView onListItemClick setcontentview crash?
<p>I have been trying to set a new xml layout, when a particular item on this list is clicked. Am I missing something, because the emulator crashes when clicked?! setContentViewById(R.id.newxml file)</p> <pre><code>public class intentProject extends ListActivity { ListView list; ArrayAdapter&lt;String&gt; aa; List&lt;String&gt; data = new ArrayList&lt;String&gt;(); public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); data.add("France"); data.add("Japan"); data.add("Russia "); data.add("Poland"); data.add(" USA"); ArrayAdapter&lt;String&gt; aa = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,data ); setListAdapter(aa); } protected void onListItemClick(ListView l, View v, int position, long id) { // TODO Auto-generated method stub super.onListItemClick(l, v, position, id); this.setContentView(R.layout.main2); } } </code></pre>
android
[4]
3,156,161
3,156,162
jQuery: Stop dropdown menu from collapsing when clicking on its children
<p>I have a top nav bar and some of its items trigger dropdowns/slide-downs.</p> <p>My problem is that whenever I click an item, or actually any area within the dropdown, the dropdown collapses.</p> <p>What I need help with is figuring out how to avoid collapsing the dropdown when a child element is clicked (or well, anywhere within the dropdown area since I'd like to account for accidental clicks inside the dropdown but that are not actually clicks on a child element).</p> <p>Here's the basic <strong>HTML</strong> structure I have:</p> <pre><code>&lt;ul class="dropdown"&gt; &lt;li&gt;&lt;a href="#" class="noclick nojs"&gt;Select your Topic&lt;/a&gt; &lt;ul class="nojs" &gt; &lt;li&gt;&lt;a href="#"&gt;Link 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link 3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>My JavaScript:</p> <pre><code>$('.dropdown li').click(function() { //Hide all other drop downs that are visible, and remove the class 'selected' $(this).siblings('.selected').removeClass('selected').find('ul:visible').slideUp('fast'); //Show/Hide dropdowns $(this).toggleClass('selected'); $('ul:first', this).stop(true, true).slideToggle('fast'); }); </code></pre> <p>Here's a <strong><a href="http://jsfiddle.net/rzea/zEQVK/1/" rel="nofollow">DEMO</a></strong></p> <p>Any help is greatly appreciated.</p> <p>Thanks.</p>
jquery
[5]
5,686,258
5,686,259
Why is my array outputting one row
<p>My $aExtensionObjects print_r fine shows all of the things in the array but $aExtensionName only seems to output one why?</p> <pre><code>$aExtensionObjects Array: Array ( [0] =&gt; Extension Object ( [iID:private] =&gt; [sExtensionName:private] =&gt; 2147483647 [db:private] =&gt; MySQLiPluggin Object ( [sqliConnection:private] =&gt; mysqli Object ( ) [Query:private] =&gt; [getResult:private] =&gt; ) [bExisting] =&gt; 1 ) [1] =&gt; Extension Object ( [iID:private] =&gt; [sExtensionName:private] =&gt; 876378990 [db:private] =&gt; MySQLiPluggin Object ( [sqliConnection:private] =&gt; mysqli Object ( ) [Query:private] =&gt; [getResult:private] =&gt; ) [bExisting] =&gt; 1 )) ) Etc.. $aExtensionName Array: Array ( [] =&gt; 989898 ) </code></pre> <p>The code [ed: maybe?]</p> <pre><code> $manExtensionManager = new extensionManager(); $aExtensionObjects = $manExtensionManager-&gt;getallExtensions(); $aExtensionName = array(); for($iCount=0; $iCount&lt;count($aExtensionObjects);$iCount++){ $Extension = $aExtensionObjects[$iCount]; $aExtensionName[$Extension-&gt;getExtensionID()] = $Extension-&gt;getExtensionName(); } </code></pre>
php
[2]
1,272,190
1,272,191
get additional info from the link which launched my app
<p>my app launches on clicking a link.</p> <p>But there is additional information that the link contains which my app wants. </p> <p>The link is something like this : </p> <p><a href="http://update_app_config.com?parameter1=" rel="nofollow">http://update_app_config.com?parameter1=</a>'value1'&amp;parameter2='value2'&amp;parameter3='value3' </p> <p>can I get an object of key,value pair which contains the parameter and values or do I have to parse it myself?</p> <p>Thanks</p>
android
[4]
1,355,497
1,355,498
Write a txt file in windows service
<p>I want to write some text in txt file through windows service in asp.net &amp; backend as vb.net...</p> <p>Plz help</p>
c#
[0]
3,229,911
3,229,912
Java trying to check for anything multiplied by 60
<p>I am coding a console game for the lulz and now im trying to check if the player is on the level 60, 120, 180, i.e. anything that is multiplied by 60. </p>
java
[1]
4,187,130
4,187,131
What does the error "expected ";" before obj" mean?
<p>I am wrtting a program in C++ using my own header file.</p> <pre><code> //main.cpp #include&lt;iostream&gt; #include"operation.h" using namespace std; main() { int a; cout &lt;&lt;"Enter the value a"; cin&gt;&gt;a; //class name add //obj is object of add add obj; obj.fun(a); } //operation.h class add { void fun(int b) { int c,d=10; c=d+b; cout&lt;&lt;"d="&lt;&lt;d; } } </code></pre> <p>when I compile using g++ compiler in linux it is showing this error:</p> <pre><code>expected ";" before obj* -&gt;*obj not declared in this scope </code></pre> <p>I don't understand this error, can someone help me?</p>
c++
[6]
868,349
868,350
declaring an array within an array
<p>I've just started a Java programming class and I'm having trouble setting up an array within an array. </p> <p>Example:</p> <pre><code>public class ABLoop { int x; ABLoop[]Loop = new ABLoop[x]; int[]numb; public void fortime(int number){ x=number; for(int multiplier = 0; multiplier &lt;= x; multiplier++){ Loop[multiplier]= new Loop[multiplier+1]; </code></pre> <p>For the new Loop, it keeps saying that Loop cannot be resolved to a type. Don't know what that means; can anyone offer suggestions? What I'm trying to do is for each element of Loop array, I want a new array created with elements equating to multiplier + 1.</p>
java
[1]
1,097,318
1,097,319
Populating selected value from dropdownlist into textbox
<p>I'am following an example from <a href="http://jsfiddle.net/ubrcq/" rel="nofollow">http://jsfiddle.net/ubrcq/</a> <br> But I cant seem to get it up. below are my codes</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; $('#hours').change(function() { $('#hours_text').val( this.value ); });​ &lt;/script&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&gt; &lt;/head&gt; &lt;body&gt; &lt;select name="hours" id="hours" class="time"&gt; &lt;option value="01"&gt;01&lt;/option&gt; &lt;option value="02"&gt;02&lt;/option&gt; &lt;option value="03"&gt;03&lt;/option&gt; &lt;option value="04"&gt;04&lt;/option&gt; &lt;option value="05"&gt;05&lt;/option&gt; &lt;option value="06"&gt;06&lt;/option&gt; &lt;/select&gt; &lt;input type="text" id="hours_text" name="hours_text" value="01"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
1,944,988
1,944,989
Java: How to use Timer class to call a method, do something, reset timer, repeat?
<p>Sorry for asking such a basic question, but I am a Java beginner and have been futzing around with various solutions to this problem and have gotten myself kind of knotted up. I've tried with Threads and then discovered this Timer class and have messed around with it without success so far. If you could post <strong>executable code with a main method</strong> so I could see it working and start playing around from there, that would be great. Thanks.</p> <ol> <li>Launch program</li> <li>call doSomething() method  //</li> <li>Generate random number and set Timer for that long.</li> <li>When Timer goes off, call doSomething again.</li> </ol> <p>Probably using this (or??): <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Timer.html" rel="nofollow">http://docs.oracle.com/javase/6/docs/api/java/util/Timer.html</a></p>
java
[1]
1,353,057
1,353,058
Templatized Virtual function
<p>We know that C++ doesn't allow templated virtual function in a class. Anyone understands why such restriction?</p>
c++
[6]
3,980,956
3,980,957
Can jQuery detect a specific URL and perform a function based off that URL?
<p>I have a site I'm working on. I need to be able to perform a specific function if the URL matches a specific URL. Here's an example of what I'm trying to do:</p> <p>If the URL matches this URL:</p> <p><a href="http://www.example.com/EIFS-items/search.php?l2=3,15,25" rel="nofollow">http://www.example.com/EIFS-items/search.php?l2=3,15,25</a></p> <p>then I want to have jQuery add a class of "show" to the div with the class of "content" below.</p> <p>Is this possible?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Title&lt;/title&gt; &lt;style type="text/css"&gt; .content { display: none; } .show { display: block; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="content"&gt; Lorem ipsum dolor sit amet, consectetur adipisicing elit. &lt;/div&gt;&lt;!-- end .content --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
4,454,622
4,454,623
iphone avoid save state
<p>In my app I need to avoid the saving state, in fact, I whis that each time the user starts the app, the app will be relaunced like the first time... how can I do?</p>
iphone
[8]
5,294,029
5,294,030
Jquery get input value inside list which is inside a div
<p>I have something like the following</p> <pre><code>&lt;div id="container"&gt; &lt;ul id="name_list"&gt; &lt;li class="name"&gt; &lt;input type="hidden" class="name_val" value="5" /&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>I am trying to get the value of the input. So far I have the following Jquery statment.</p> <pre><code>$("#container li.name input.name_val").val(); </code></pre> <p>this does not work anyone know a better way?</p>
jquery
[5]
1,891,274
1,891,275
Logcat app (filter stock app)
<p>I want to write an app which can log every application that the user has launched. For example, when the user open "phone" app, the logger app will log down the time and "phone" app opened. </p> <p>I have studied the source code for <a href="http://code.google.com/p/alogcat/" rel="nofollow">alogcat</a> but couldn't find where to add in the code to achieve my aim.</p> <p>I have also looked at the Intent description, it said that <code>ACTION_DIAL</code> action will be fired if a phone dials a number, but when i tried to find this keyword in alogcat, i couldn't find it?</p> <p>May I know which code should i add to keep track of which application has been opened at what time? What parameter/keyword should i look out for for a certain application that has launched?</p> <p>I have tried to search for a <a href="http://www.openintents.org/en/intentstable" rel="nofollow">list</a> of registered intents protocol, but it seems like it is not accurate..</p> <p>thanks in advanced for help!</p>
android
[4]
2,216,595
2,216,596
cant get jquery hover to work with .live()
<p>the second function isnt working?</p> <pre><code>$('.edit_hover').live('hover', function(e){ $(this).stop(); var half_width = ($(this).css('width').slice(0, -2))/2; var half_height = ($(this).css('height').slice(0, -2))*0.3; console.log(half_width); var top = ($(this).position().top) + half_height; var left = ($(this).position().left) + half_width; $('#edit_hover').css('top', top).css('left', left).fadeIn(300); //add overlay $(this).css('position', 'relative').append('&lt;div class="edit_overlay" style="position: absolute; top:0px; left:0px; height:100%; width: 100%; background: #999; opacity: 0.5;"&gt;&lt;/div&gt; ') }, function(){ $(this).stop(); $(this).find('.edit_overlay').remove(); $('#edit_hover').fadeOut(300); }); </code></pre>
jquery
[5]
1,794,066
1,794,067
onSaveInstanceState and Fragments?
<p>How can I get a fragment to save it's state? I've tried everything but no luck, nothing is working.</p> <p>Ive tried adding:</p> <pre><code>public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); myWebView.saveState(outState); Log.w("///////", "onSaveInstanceState"); } </code></pre> <p>But this never gets called.</p> <p>Any ideas?</p> <hr> <p>I'm now trying to restore the state of the web view:</p> <pre><code>@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mainView = (View) inflater.inflate(R.layout.frag_b, container, false); myWebView = (WebView) mainView.findViewById(R.id.webviewtest); myWebView.setWebViewClient(new MyWebViewClient()); myWebView.getSettings().setPluginsEnabled(true); myWebView.getSettings().setBuiltInZoomControls(false); myWebView.getSettings().setSupportZoom(false); myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); myWebView.getSettings().setAllowFileAccess(true); myWebView.getSettings().setDomStorageEnabled(true); myWebView.loadUrl("http://www.google.com"); myWebView.setId(1); myWebView.restoreState(savedInstanceState); Log.w("///////", "onCreateView"); return mainView; } </code></pre> <p>But the above doesnt work, any ideas?</p>
android
[4]
5,094,490
5,094,491
How can I set an existing Explorer.exe instance to select a file?
<p>I can easily get Explorer to open up and select a file using the following :</p> <pre><code>string argument = @"/select, " + filePath; System.Diagnostics.Process.Start("explorer.exe", argument); </code></pre> <p>However when I come to opening up the next file, I will get a new instance of explorer. This could result in our users opening having hundreds of explorers open by the end of an intensive day.</p> <p>How can I get it to reuse an already open explorer instance to select the file I want?</p> <p>Visual Studio can do this when you right click on a tab and select <em>Open containing folder...</em> providing explorer is already opened at the same directory. How has it been able to do this?</p>
c#
[0]
5,990,089
5,990,090
Opposite of nl2br? Is it str_replace?
<p>So the function nl2br is handy. Except in my web app, I want to do the opposite, interpret line breaks as new lines, since they will be echoed into a pre-filled form.</p> <p>str_replace can take <code>&lt;br /&gt;</code> and replace it with whatever I want, but if I put in \n, it echoes literally a backslash and an n. It only works if I put a literal line break in the middle of my script, and break the indentation (so there are no trailing space).</p> <p>See:</p> <pre><code> &lt;?=str_replace('&lt;br /&gt;',' ',$foo)?&gt; </code></pre> <p>Am I missing escape characters? I think I tried every combination...</p>
php
[2]
4,187,428
4,187,429
Javascript array Swapping
<p>I have javascript array </p> <pre><code>var s=[{"1":"one"},{"2":"two"},{"3":"three"},{"ALL":"ALL"}]; </code></pre> <p>Here i want to check the condition,If BMW is present in the array.I want to move this "BMW" to zero position and existing zeroth value moved next(ist position) to the ALL.</p> <p>Please give some suggestions or answers for how to handle this scenario,</p> <p>Thanks in Advance.</p> <p>Chaitu</p>
javascript
[3]
1,199,485
1,199,486
My if statement based on array value being empty refuses to work
<p>I wrote the following script to echo out the contents of a outlook CSV File.</p> <p>Here is a part of the script which breaks down the CSV into an array that extracts only the following three values, first name, last name and email.</p> <pre><code>for ($i=87; $i&lt;= $countdel-87; $i=$i+88 ){ if(empty($readout[$i])){ echo "&lt;b style=\"color:RED;\"&gt;FIRST NAME N/A&lt;/b&gt;"; } else{ echo str_replace("Categories","",$readout[$i]).".........................."; } if(empty($readout[$i+2])){ echo "&lt;b style=\"color:RED;\"&gt;LAST NAME N/A&lt;/b&gt;".".........................."; } else{ echo $readout[$i+2].".........................."; }; if(empty($readout[$i+14])){ echo "&lt;b style=\"color:RED;\"&gt;EMAIL N/A&lt;/b&gt;"; } else{ echo $readout[$i+14]; }; echo "&lt;br&gt;"; } </code></pre> <p>The code then spits out a string that looks like this:</p> <pre><code>Joe ............. Smith ...............jSmith@yahoo.com </code></pre> <p>Now say that we do not have the last name or email, instead it will spit out</p> <pre><code>Joe .......... LAST NAME N/A .............. EMAIL N/A </code></pre> <p>This all works just dandy. Where I am having the problem is when I do not have the first name, as it prints out.</p> <pre><code>........... Smith ..............jSmith@yahoo.com </code></pre> <p>This piece of code is where the problem seems to be:</p> <pre><code>if(empty($readout[$i])){ echo "&lt;b style=\"color:RED;\"&gt;FIRST NAME N/A&lt;/b&gt;"; } </code></pre> <p>It appears that the <code>$readout[$i]</code> is never empty although I never see anything print out when there is no value. However all the other <code>$readout[$i+$foo]</code> arrays to work.</p>
php
[2]
1,344,734
1,344,735
Call forwarding
<p>I would like to forward all calls to my number on to the new predefined number automatically. Is it possible to forward incoming call ?</p> <p>Probably it is possible for Froyo at least. I found application called Easy Call Forwarding. <a href="http://www.appstorehq.com/easycallforwarding-android-189596/app" rel="nofollow">http://www.appstorehq.com/easycallforwarding-android-189596/app</a> But many people reckon it doesn't work actually.</p> <p>We can notice forwarded call by <code>onCallForwardingIndicatorChanged()</code> from <code>PhoneStateListener</code> but I have no idea how to set forwarding mode.</p>
android
[4]
1,209,110
1,209,111
how to disable save as option of browser
<p>how we can disable save as option of browser by php?</p>
php
[2]
3,269,027
3,269,028
Every Object is a function and every function is Object - Which is Correct?
<p>I was reading this link <a href="http://en.wikipedia.org/wiki/JavaScript_syntax" rel="nofollow">JavaScript_syntax</a></p> <p>This seems to be cyclic - that every function is an Object and every Object itself is a function. Which is the atomic one? Can someone explain in a better way?</p>
javascript
[3]
1,895,570
1,895,571
Update GUI when a boolean in a class changes
<p>I'm trying to have my Activity update an ImageView whenever a boolean value changes in another class. </p> <p>Therefore i have some sort of timer that starts on my first <b>onCreate()</b></p> <pre><code>private void startTimer() { mHandler.removeCallbacks(mUpdateTimeTask); mHandler.postDelayed(mUpdateTimeTask, 2000); // first run after 2 secs } private Runnable mUpdateTimeTask = new Runnable() { public void run() { connectionControl.checkNetworkState(); System.out.println("online?: " + connectionControl.isOnline()); mHandler.postDelayed(this, 15000); // repeat every x/1000 secs } }; </code></pre> <p>My class <b>ConnectionControl</b> has a boolean, that gets set to either true or false whether my app can reach a specific http-host. Now my question is: how can i achieve a automatic change on the ImageView in my Activity to display the boolean's value? I already looked at Observer-Pattern, EventListener, BroadcastReciever but I'm stuck at finding the right solution. Also, i want to use the listening in other Activities.</p> <p>What has worked so far was starting/stopping the timer-thing for each activity and have the ImageView update inside the <b>run()</b> method. But my guess is, there has to be a way around the redundancy.</p>
android
[4]
5,803,047
5,803,048
Read JSON with jQuery
<p>I want to load a JSON file and read the following data</p> <pre><code>{ "extTitle": { "message": "test1" }, "extName":{ "message": "test2" } } </code></pre> <p>This is how I load the data</p> <pre><code>function loadLocales(){ var userLang = (navigator.language) ? navigator.language : navigator.userLanguage; switch(userLang){ default: $.getJSON("_locales/ne/messages.json", function(data){ return data; }); break; } } </code></pre> <p>When I try to read with the following function I get an </p> <pre><code>i18n undefined error </code></pre> <p>.</p> <pre><code>function getValue(key){ var i18n = loadLocales(); return i18n[key].message; } </code></pre> <p>Any ideas?</p>
jquery
[5]
78,228
78,229
cant print images with JavaScript print function
<p>I am trying to print a report which includes text and images. I am using a javascript function to invoke the print functionality. Everything works well except the images on the page do not show up in the new print window. I have included all the CSS files with it but still my images dont appear in the new print window. Its the same even if I dont include the CSS links.</p> <p>My javascript function to print is :</p> <pre><code>function printfun(){ var disp_setting = "toolbar=no,location=no,directories=no,menubar=no,"; disp_setting += "scrollbars=no,left=0,top=0,resizable=yes,width=900 height=650,modal=yes,"; var content_vlue = document.getElementById('&lt;%= tblCharts.ClientID %&gt;').innerHTML; var docprint = window.open("", "", disp_setting); docprint.document.write('&lt;html&gt;&lt;head&gt;'); docprint.document.write('&lt;/head&gt;'); docprint.document.write('&lt;body onLoad="self.print()"&gt;'); docprint.document.title = ""; docprint.document.write('&lt;link href="../style/design.css" rel="Stylesheet" type="text/css" /&gt;'); docprint.document.write('&lt;link href="../App_Themes/style/graphs.css" rel="Stylesheet" type="text/css" /&gt;'); docprint.document.write(content_vlue); docprint.document.write(tblCharts); docprint.document.write("&lt;/body&gt;&lt;/html&gt;"); docprint.document.close(); docprint.focus(); } </code></pre>
javascript
[3]
815,695
815,696
Android insertImage and the Gallery Application
<p>I am adding a bmp file to the media store using the line below </p> <pre><code>ContentResolver cr = getContentResolver(); Uri uri = Uri.parse(MediaStore.Images.Media.insertImage(cr, bmp, "name", "now")); </code></pre> <p>I then go to the gallery application and it shows the image, but shows it under "Camera Pictures".</p> <p>Is there a way to change this to its own group, perhaps to its own group? Do I need a custom content provider for this?</p> <p>Thanks.</p>
android
[4]
4,379,320
4,379,321
How does java get to know which implementation object of interface to return?
<p>Please be gentle while answering, I am not a java developer (or developer in General)</p> <p>While trying xml parsing with java I came across following - </p> <pre><code>NodeList nodelist = document.getElementsByTagName("item"); </code></pre> <p>Herein xml dom object let me collect all objects depending on tag name I provide, but return type is an Interface called - nodelist. Since interface can not be instantiated it was a bit surprising for me.</p> <p>Keeping break point and debugging the code I realized that I actually get object for class DeepNodeListImpl which implements NodeList interface. </p> <p>How does this happen? How does java know to return object of "some implementation" held by my Interface "object" in the statement declared above.</p> <p>One more thing - while reading the java <a href="http://download.oracle.com/javase/1.4.2/docs/api/org/w3c/dom/NodeList.html" rel="nofollow">api</a> I found that IIOMetadataNode implements the NodeList but my previous code snippets does not get me object of type IIOMetadataNode </p>
java
[1]
3,975,596
3,975,597
Intent problems in Android
<p>I have two Activities in my Android Application, Activity A and Activity B. Activity A triggers Activity B by an Intent and then when I'm in Activity B, which is a listView I click on a particular item and pass data back to Activity A by using putExtras() as part of my Intent when going back to Activity A. </p> <p>The problem that I have is that when I select on an item from the listView that I want to pass back to Activity A the application crashes, but when I use a normal intent, which doesn't pass any data across Activities it works fine.</p> <p>The code below demonstrates what I am trying to do.</p> <p>Activity A </p> <pre><code>public class ActivityA extends Activity { private String myString; @Override protected void onCreate(Bundle savedInstanceState) { Button selectEvent = (Button) findViewById(R.id.events); myString = savedInstanceState != null ? savedInstanceState.getString("myKey"):null; if(myIntentString == null) { Bundle extras = getIntent().getExtras(); myString = extras != null ? extras.getString("myKey"):null; } selectEvent.setText(myString); selectEvent.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(ActivityA.this, ActivityB.class); ActivityA.this.startActivity(myIntent); } }); } } public class ActivityB extends ListActivity { private String selection; private final int SECONDARY_ACTIVITY_REQUEST_CODE = 0; String[] listOfNames = {"Peter", "Paul", "John"}; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.events); setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, listOfData)); } protected void onListItemClick(ListView l, View v, int position, long id) { selection = l.getItemAtPosition(position).toString(); Intent myIntent = new Intent(getApplicationContext(), ActivityA.class); myIntent.putExtra("myKey", selection); startActivityForResult(myIntent, SECONDARY_ACTIVITY_REQUEST_CODE); } } </code></pre> <p>Your help would be most appreciated, thank you.</p>
android
[4]
2,741,632
2,741,633
How to remove duplicate values from a list in c++
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4877504/how-can-i-remove-duplicate-values-from-a-list-in-c">How can I remove duplicate values from a list in c++?</a> </p> </blockquote> <p>Hi, I have to remove duplicate values from a list in c++. can any one tell me how to do that as I am new to c++.</p> <p>Any sample code will be highly appreciated.</p> <p>Regards Shekhar</p>
c++
[6]
423,248
423,249
How do I show a hidden div using jQuery Toggle?
<p>I have a portfolio section I am building on a page that displays a thumbnail of an image. I also have a hidden div that contains information about the portfolio project that I would like to show when a user mouses over the thumbnail.</p> <p>Here is the HTML:</p> <pre><code>&lt;div class="portfolio"&gt; &lt;a href="#"&gt;&lt;img src="photos/work_2.jpg" alt="work_1" width="181" height="180"&gt;&lt;/a&gt; &lt;div class="portfolio-overlay" style="display:none;"&gt; &lt;p class="client-name"&gt;Encore Azalea&lt;/p&gt; &lt;div class="white-line"&gt;&lt;/div&gt; &lt;p class="services"&gt;website redesign +&lt;br /&gt;mobile site launch&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Here is the jQuery:</p> <pre><code>&lt;script&gt; $(".portfolio a").hover(function () { $(".portfolio-overlay").toggle("slow"); }); &lt;/script&gt; </code></pre> <p>My intent is to display .portfolio-overlay when you mouse over the image and hide it when you mouse out. </p> <p>I know there is something missing with the jQuery but, if I knew what it was, I wouldn't be posting this (you know how it goes).</p> <p>Thanks.</p>
jquery
[5]
4,412,038
4,412,039
Why is this not reversing the numbers in my vector when they get copied to my file?
<p>The program runs perfectly, and the numbers of my vector end up in my file, but they're not reversed. </p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;fstream&gt; using namespace std; void reversevector(vector&lt;double&gt; &amp;vd, int i, int j) { if(i&gt;=j) { double temp = vd[i]; vd[i]=vd[j]; vd[j]=temp; i++; j--; } } int main() { double n = 0; vector&lt;double&gt; vd; while (cin&gt;&gt;n) { vd.push_back(n); } reversevector(vd,0,vd.size()-1); ofstream ofs("reversedlist.txt"); if(!ofs) { cout&lt;&lt;"error"; exit(1); } for(int i=0; i&lt;vd.size(); i++){ ofs&lt;&lt;vd[i]; } ofs.close(); } </code></pre> <p>For example: If I put 12345 into my vector, it should print out 54321 into my file. When I open my file, it still contains 12345.</p>
c++
[6]
478,906
478,907
close current web form in asp.net
<p>How i can close current web form in web based application? I have tried with following code:</p> <pre><code>mybutton.Attributes.Add("onclick","window.close()") </code></pre> <p>But its not working Help me. Thank you.</p>
asp.net
[9]
1,920,022
1,920,023
New to Android.....Using Samsung Captivate for debugging
<p>Just wondering I have searched but I have not found an answer. My question is I installed the latest sdk 4.0 platform. I am testing with a Samsung Captivate which runs on 2.2. When I debug I get the error about them being on different platforms. My question I quess is probably stupid, But can I ever use the captivate to test my apps I build in platform 4.0 or must I stay at the 2.2 level? New to this....Can I update my phone or just test using the 2.2 platform.</p>
android
[4]
5,259,770
5,259,771
Output unformated?
<p>I am newbie in Python. Was doing an exercise in LearnPythonTheHardWay by Mr. Zed Shaw. I have been stuck with this problem</p> <p>here is the code:</p> <pre><code>age=input("How old are you?"); height=input("How tall are you?"); weight=input("How much do you weight?"); print ("age = %r height = %r weight = %r" %(age,height,weight)) </code></pre> <p>And its output:</p> <pre><code>D:\Python&gt;python sample1.py How old are you?22 How tall are you?182 How much do you weight?178 age = '22\r' height = '182\r' weight = '178\r' </code></pre> <p>I am not understanding, how is that, I am getting "\r" with the output? Please help !!!</p>
python
[7]
3,031,018
3,031,019
Resuming back to an activity without restarting the activity
<p>am having a two activities that interact. activity A picks input values and sends to activity B for the user to confirm input before submitting. activity B should allow the user to go back to activity A to edit input values if required or submit the values if they are ok. If user submits values, activity A should be finished and if he edits, then he goes back to activity A.</p> <p>I have used <code>startActivityForResult()</code> and <code>setResult()</code> methods to kill the activity A when the user submits the values that has worked perfectly, but when i click the edit button to return to activity A, it call the activity A using a new Intent, and subsequently, it starts the activity A, yet previously started activity A is still running . what i want is to resume the activity A where it was left with the existing values before activity B started on click of the back button. How do i achieve this?? Your assistance is highly appreciated</p>
android
[4]
4,774,890
4,774,891
how to implement the foldout animation view like the original iPhone google map app?
<p>all coder , I see the foldout animation view in the original iPhone google map app, I want the same effect in my view , but I have not find solution ...</p> <p>how to do the same animation via iPhone sdk ? any tip will be much appreciated...</p> <p>thanks...</p> <p>iRobin</p>
iphone
[8]
4,841,492
4,841,493
BuildAction "Content" in Asp.net
<p>what doing BuildAction "Content" in Asp.net?what is difference "None" buildAction and "Content" Build Action?</p>
asp.net
[9]
2,592,289
2,592,290
Javascript IFrame/designmode and onkeydown event question
<p>Apologize if this is answered already. Went through some of the related questions and google, but ultimately failed to see why this isn't working.</p> <p>My code is as follows</p> <pre><code>&lt;iframe id="editor"&gt;&lt;/iframe&gt; editorWindow = document.getElementById('editor').contentWindow; isCtrlDown = false; function loadEditor() { editorWindow.document.designMode = "on"; editorWindow.document.onkeyup = function(e) { if (e.which == 91) isCtrlDown = false; } editorWindow.document.onkeydown = handleKeyDown; } function handleKeyDown(e) { if (e.which == 91) isCtrlDown = true; if (e.which == 66 &amp;&amp; isCtrlDown) editFont('bold'); if (e.which == 73 &amp;&amp; isCtrlDown) editFont('italic'); } function editFont(a,b) { editorWindow.document.execCommand(a,false,b); editorWindow.focus(); } </code></pre> <p>This code works perfectly in Chrome, but the keyboard shortcuts do not work in Firefox. In fact, in Firefox it does not seem to register the events for keyup/keydown at all.</p> <p>Am I doing something grossly wrong here that is mucking up Firefox?</p>
javascript
[3]
1,484,877
1,484,878
bubble sort logic error
<p>I was trying a basic sorting exercise and I was hoping I could receive some help with what is probably a basic logic error.</p> <pre><code>int[] numbers = new int[] { 2, 5, 11, 38, 24, 6, 9, 0, 83, 7 }; for (int loop = 0; loop &lt; numbers.Length; loop++) { Console.WriteLine(numbers[loop]); } Console.WriteLine("Performing a bubble sort"); bool flag = false; do { for (int loop = 0; loop &lt; numbers.Length - 1; loop++) { if (numbers[loop] &gt; numbers[loop + 1]) { int temporary = numbers[loop]; numbers[loop] = numbers[loop + 1]; numbers[loop + 1] = temporary; flag = true; } } } while (flag == false); for (int loop = 0; loop &lt; numbers.Length; loop++) { Console.WriteLine(numbers[loop]); } </code></pre> <p>kind regards</p> <p>arianule</p>
c#
[0]
924,546
924,547
How to add background image in paint class in Android?
<p>I am working on android. I want add background image to paint class but there is no setBackground() in paint class. How to add background image by using paint class? </p>
android
[4]
5,724,127
5,724,128
Python: Sorting a list of strings by string template?
<p>Say I have a list containing strings that look like this:</p> <pre><code>"00x000s00g00wfds0d" "dkdf00sdf00sdfg00jk" "kf00dfjkd0sdl0sd0f0" </code></pre> <p>etc... random letters intermixed with 0's.</p> <p>but I want to sort them by their 0's. By this I mean, I want the sorted list to look something like this:</p> <pre><code>"00jksdn0sdf00dfgdfvb" "00sdkml0dfg00egbfnnv" "00myvcb0xfb00dfgdrhd" </code></pre> <p>Where I arrange things in groups of their relative positions of 0's. Apologies if this doesn't make much sense.</p>
python
[7]
3,403,344
3,403,345
Android device Back Button close the app not move to Main Activity
<p>How can I use the Android back button to move back within my app instead of closing my app? this is my activity stack Activity A (Main Activity) OK button press -->Activity B OK button Press -->Activity C</p> <p>When i tab the device Back button it moves to Activity B then again i press the back button app get close (move to android home screen)</p> <p>I need to go to Main Activity when user back press on Activity B? </p> <p>NOTE: Im not calling any finish() when moving to next activity..</p> <p>Sam</p>
android
[4]
5,827,478
5,827,479
Store default value in iPhone
<p>I am developing my first iPhone application. I need store some values in a place where the values will not get lost if the app is deleted. </p> <p>I need this to get the number of days the user actually used the app. Is this possible to do?</p> <p>Thanks in advance!</p>
iphone
[8]
31,346
31,347
remove all children of ul element thats means remove all li's
<p>I am doing the following code to remove all the children of UL.Is it right to do.ALl the childrens are li element.</p> <p>thickBoxProductLists is the id of UL element</p> <pre><code> $('#thickBoxProductLists').children().remove(); </code></pre>
jquery
[5]
250,784
250,785
Return type information of a class from shared library
<p>I have a class in shared library and a function in shared library which can create an object of the class type. My question is, can I return the type information from a shared library function, in some standard way, such that I can use that type information in decltype to instantiate an object of class for shared library in main loop?</p>
c++
[6]
947,018
947,019
Will big size of the app reject users from using it?
<p>The games prevent this by making the core app only which then downloads the graphics and other stuff on the first run. </p> <p>But what about the apps which have heavy animations and which final size is around 100MB (maybe even 200MB)? Regardless of the app's quality, does size matter? Do big apps reject users from downloading it?</p> <p>And the final question, is there a way to download the heavy stuff to a place where a user will not be able to delete it? I think it's not possible, but I'd rather ask the community. </p>
android
[4]
1,056,902
1,056,903
Counting ajaxcalls and get their status
<p>Is there any way to count all the ajaxcalls made when a page loads and get the status of each one? I would like to create a progressbar that shows the page loading process (since its built up from different html files loaded using jquery ajax).</p>
jquery
[5]
1,265,830
1,265,831
Regarding to save previous record in asp.net
<p>Hi I have one label for question, radiobuttonlist for their answers, next button to move next question &amp; previous button. I am displaying one question per page after clicking next button next question appears, but when i click previous button previous question appears. But i want previous question with earlier selected answer when i click to previous button. Asp.net c# Thank you.</p>
asp.net
[9]
5,131,988
5,131,989
Javascript variable scroll issue
<p>I have a page whereby the user can press left + right buttons to scroll through numbers between 1-10.</p> <p>The default value is 0 which displays blank.</p> <p>There are two buttons at the bottom which allow the user to 'Clear' the number - reseting it to 0. Or to 'Shuffle', picking a random number.</p> <p>After this the user can submit these numbers into a database.</p> <p>My issue is, if the user were to scroll to 5 (for example), click shuffle then submit, it would submit '5' instead of the random number it should have generated.</p> <p>Also if the user only clicks 'shuffle' then submit, it'll input '0'.</p> <p>The issue with the 'clear' button is similar, if the user scrolls to 5, then hits reset, the variable would stay at '5' when submitted.</p> <p>I'm probably overcomplicating something very simple, and im sorry if i am, but this is annoying me.</p> <p>Thankyou ~ </p>
javascript
[3]
5,653,536
5,653,537
Android development for beginners
<p>I want to learn Android development and create mobile apps. What would be the recommended resources (There's too many on the web)? </p>
android
[4]
3,062,154
3,062,155
PHP: If $_GET then bold it
<pre><code>echo '&lt;a href="?view=new&amp;days=2"&gt;2&lt;/a&gt; • &lt;a href="?view=new&amp;days=4"&gt;4&lt;/a&gt; • &lt;a href="?view=new&amp;days=7"&gt;7&lt;/a&gt; • &lt;a href="?view=new&amp;days=14"&gt;14&lt;/a&gt; • &lt;a href="?view=new&amp;days=30"&gt;30&lt;/a&gt; days'; </code></pre> <p>I have this as a "submenu", for showing newest members. You can choose for how many within days you want to see the newest users on the site. </p> <p>Its much repeating myself, the only thing that is changing is days=30 in the link, and "30" as linktext.</p> <p>Now I would like to check if $_GET["days"] == 2, then bold it, <code>&lt;strong&gt;2&lt;/strong&gt;</code>.</p> <p>I could do this myself, but then it would be just duplicating it all, and in every link do the $_GET["days"] == 1, $_GET["days"] == 2, $_GET["days"] == 3..</p> <p>Isnt there a smarter way to do this without repeating myself all the time?</p>
php
[2]
4,549,148
4,549,149
Calling context (array or scalar) in PHP?
<p>Is it possible for a function or method in PHP to determine whether the caller expects an array return value or not (ala Perl's <code>wantarray</code> operator)? Specifically, I'd like to create a <code>__get()</code> magic method that automatically returns an array if the caller expects one, and a sensible scalar value if not. So something like this:</p> <pre><code>public function __get($name) { if (wantarray()) { // data is stored internally as an array of arrays // return appropriate array as-is return $this-&gt;data[$name]; } else { // caller doesn't expect an array, return imploded string instead return implode(', ', $this-&gt;data[$name]); } } </code></pre> <p>Basically, does PHP have an equivalent to Perl's <code>wantarray</code> operator or otherwise allow for the determination of this sort of calling context?</p>
php
[2]
5,774,194
5,774,195
Finding the hole in my custom php script?
<p>Today i received very unpleasant email about that one guy has got all my database users records and also he attached a part of screen shot as a proof with the same exact info as in database.</p> <p>How would i start to look where is the problem? What type of hacking attack is that?</p> <p>Any help appreciated.</p>
php
[2]
4,587,728
4,587,729
Loading Images issue in UITableViewCell
<p>I get Images from a URL using XML Parsing. I loaded the all images from url in to UITableViewCell using Parsing. But when i press the scrollbar in UITableView, it make slowly to loading images.</p> <p>I used the following code.</p> <pre><code>NSString *image1 =[images objectAtIndex:indexPath.row]; NSLog(@"Images ..... = %@",image1); NSData *mydata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[images objectAtIndex:indexPath.row]]]; UIImage *myimage = [[UIImage alloc] initWithData:mydata]; UIImageView *imageView = [ [ UIImageView alloc ] initWithImage: myimage ]; imageView.frame = CGRectMake(0.0f, 00.0f, 60.0f, 63.0f); [cell.contentView addSubview:imageView]; </code></pre> <p>If anybody knows that there is any solution to increasing Loading speed, please help me.</p> <p>Thanks.</p>
iphone
[8]