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
2,464,015
2,464,016
XML and PHP questions
<pre><code>$new = $doc-&gt;createElement("Cars"); </code></pre> <p>to open an element how would I close this element?</p> <p>and if i have a text box </p> <pre><code>&lt;input type="text" name="toCity"&gt; </code></pre> <p>how can i write what the user puts in the textbox as an element?</p> <p>Any help would be appreciated.</p>
php
[2]
4,305,971
4,305,972
Restricting window.find to a textarea
<p>Right now clicking on a function name in the yellow box highlights it first then clicking again scrolls the textarea. How do I just scroll the textarea?</p> <pre><code>$('.codepointer').live('click', function() { window.find($(this).text()); e.preventDefault(); return false; }); </code></pre> <p><img src="http://i.stack.imgur.com/MiW32.gif" alt="enter image description here"></p>
javascript
[3]
4,071,879
4,071,880
dynamically add buttons?
<p>i want to add some buttons dynamically at some positions,can anyone suggest a sample code for this?? </p>
android
[4]
1,331,023
1,331,024
How to get the list of files under the directory in a JAR file
<p>I want to know the list of files under the 'META-INF/config' directory in a JAR file.</p> <p>I am using the below code to retrieve the files list. But it is failing.</p> <pre><code> Enumeration&lt;URL&gt; path = Thread.currentThread().getContextClassLoader().getResources("META-INF/config/"); while(path.hasMoreElements()) { URL path1 = path.nextElement(); System.out.println("File =" +path1.getFile()); File configFolder = new File(path1.getPath()); File[] files = configFolder.listFiles(); for (File file : files) { System.out.println("\nFile Name =" + file.getName()); } } </code></pre> <p>Can somebody help me in fixing this?</p> <p>Thanks In Advance, Maviswa</p>
java
[1]
5,307,223
5,307,224
Your opinion on the best jquery book
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/60971/jquery-book-recommendation">jQuery book recommendation?</a> </p> </blockquote> <p>I'm looking to purchase a jquery book. I'm a strong C# developer whose had experience with dojo. Now, I'm building my own site and am looking to learn a new platform in the process. So, I've chosen jquery.</p> <p>With dojo, I know how to make my own widgets. I want to learn about ways to plug into jquery to make reusable controls. Also, I plan to make heavy use of json with ajax.</p> <p>Other things to consider:</p> <ul> <li>I would call my javascript expertise as intermediate. </li> <li>I'd like to find a book that is as up to date with the jquery platform as possible as I know that in a few months it will likely be out of date.</li> </ul> <p>What book or books would you reccomend?</p>
jquery
[5]
109,492
109,493
About system properties
<p>I know how to access the android system properties from application layer. In framework layer Systemproperties.java class take the responsibility to get all the properties.But internally it call some c code for getting the properties like native_get(key,value);Anyone please tell me which file is basically refer in the c code.</p>
android
[4]
4,098,013
4,098,014
Avoiding Bad PHP Coding
<p>There is a lot of books and tutorials about php that are completely different from each other. </p> <p>How can I choose the right way? Is the only way is test with xdebug or phpUnit or benchmark? </p>
php
[2]
1,931,889
1,931,890
Can anyone help me check where is my problem?
<p>Question as bellow:</p> <p>Write a program to implements an interview scheduler.</p> <p>These are the requirements for the interview scheduler:</p> <p>A prompt asks the executive secretary to input the time for the first interview, and then a loop continues to prompt for input of subsequent interview, and then a loop continues to prompt for input of subsequent interview times. Input terminates when the secretary enters a time at or after 5:00 pm. A loop executes pop() operations until the queue is empty. Each iteration outputs the time that the appointment begins, along with the amount of the time available for the director to carry out the interview. When the queue becomes empty, the time for the last interview is the difference between the office-closing time of 5:00 pm. and the prior starting time for the last interview.</p> <pre><code>import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class TimeSchedule { public static void main(String args[]) { Queue TimeList = new LinkedList(); DateFormat df = new SimpleDateFormat("HH:mm"); df = DateFormat.getDateInstance(DateFormat.LONG); boolean loopstoper = false; try { Date limit = df.parse("17:00"); Scanner scan = new Scanner(System.in); String time = scan.nextLine(); Date date = df.parse(time); while (loopstoper == false) { if (date.before(limit)) { TimeList.offer(date); } else { loopstoper = true; while (TimeList.size() &gt; 0) { System.out.println("Time Schedule = " + TimeList.poll()); } } } } catch (Exception e) { e.printStackTrace(); } } } </code></pre> <p>please help me check my work correct or not because it cannot run in Netbean software? Is that answer match that question? Thanks for your helping.</p>
java
[1]
1,097,986
1,097,987
Off WARN logs of a class
<p>How can i off the warn logs of a particular <code>class(com.service.infra)</code> in my <code>log4j.properties</code>.</p> <pre><code>log4j.rootLogger=DEBUG,QuietAppender,SilentAppender,LoudAppender log4j.appender.QuietAppender=org.apache.log4j.RollingFileAppender log4j.appender.QuietAppender.Threshold=WARN log4j.appender.QuietAppender.File=/Log/front-log log4j.appender.QuietAppender.layout=org.apache.log4j.PatternLayout log4j.appender.QuietAppender.layout.ConversionPattern= %m%n log4j.appender.SilentAppender=org.apache.log4j.DailyRollingFileAppender log4j.appender.SilentAppender.Threshold=INFO log4j.appender.SilentAppender.File=/par/info,infoLog log4j.appender.SilentAppender.DatePattern='.'dd-MM-yy log4j.appender.SilentAppender.layout=org.apache.log4j.PatternLayout log4j.appender.SilentAppender.layout.ConversionPattern=%d{dd/MM/yy kk:mm:ss.SSS} %-3p [%t] %x (%F:%L) - %m%n </code></pre> <p>Here, i want to turn off warn logs in my info log file <strong>/par/info,infoLog</strong>, But for warn log file it should be logged to a file <strong>/Log/front-log</strong></p>
java
[1]
235,441
235,442
jQuery plugin to filter result from a select drop down box
<p>Here is one jQuery plugins which allow me to filter the result of drop down values. I am looking for a plugin which allows user to type right there in the drop down box and it filters records. Anyone knows of such plugin.</p> <p>In that plugin dropdown box displays all the choices. User can go and pick a value or user can filter the result by typing something.</p> <p><a href="http://nihilex.com/droplist-filter" rel="nofollow">http://nihilex.com/droplist-filter</a></p> <p>Update:</p> <p>Looks I found what I was looking for. Here is the <a href="http://plugins.jquery.com/project/SexyCombo" rel="nofollow">plugin</a> and here is the <a href="http://phone.witamean.net/sexy-combo/examples/index.html" rel="nofollow">demo</a>. </p>
jquery
[5]
1,659,307
1,659,308
Compiler Warning CS1701 when using csc.exe
<p>I'm trying to compile by command line a series of cs into a dll which uses Telerik.Web.UI.dll.</p> <p>It compiles but I don't understand why I get this CS1701 warning about assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' as it says it's not sure it corresponds to 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' and that I should provide a runtime strategy.</p> <p>What all this mumbo jumbo, how to fix it ?</p> <p>Update: command line used</p> <pre><code>C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe /t:library *.cs /out:test.dll /r:"C:\Program Files\Telerik\RadControls for ASP.NET AJAX Q3 2009\Bin\Telerik.Web.UI.dll" </code></pre>
c#
[0]
5,214,482
5,214,483
Best way to store an image from a url in php?
<p>I would like to know the best way to save an image from a URL in php.</p> <p>At the moment I am using </p> <pre><code>file_put_contents($pk, file_get_contents($PIC_URL)); </code></pre> <p>which is not ideal. I am unable to use curl. Is there a method specifically for this?</p>
php
[2]
3,056,066
3,056,067
android game control
<p>Help me with control in my adnroid game)</p> <p>I have 2 buttons: to move left and to move right. If we press left sprite moves left and if we press right sprite moves.</p> <p>Here is code:</p> <pre><code>public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE){ touchX = event.getX(); } if(touchX == arrow_leftX){ gameLoopThread.setRunning(false); } else if(touchX == arrow_leftX){ playerX = playerX - xSpeed; } else if(touchX == arrow_rightX){ playerX = playerX - xSpeed; } else if(touchX == arrow_rightX){ gameLoopThread.setRunning(false); } return super.onTouchEvent(event); } </code></pre> <p><strong>So the Problem is:</strong></p> <blockquote> <p>it moves only left, i dont know how to move right ?</p> </blockquote>
android
[4]
4,208,536
4,208,537
Code behind the wait timer
<p>Can someone tell me the code for this expression, <code>"Waiting for" + n + "Seconds"</code> such that the text displays only once in the output and the variable <code>n</code> keeps changing.</p> <p>Thanks.</p>
c#
[0]
1,895,636
1,895,637
What to do after send request to server?
<p>I want to insert data in database, but I used jquery, so cannot simply direct insert in database.I have to use ajax http request..I've already type ajax http request in the js file in my visual studio 2008....then I send request to server..After that what to do?How am I going to insert the data in database? help me!!! </p> <p>This is my ajax http request:</p> <pre><code>// Define http_request var httpRequest; try { httpRequest = new XMLHttpRequest(); // Mozilla, Safari, etc } catch(trymicrosoft) { try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch(oldermicrosoft) { try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch(failed) { httpRequest = false; } } } if(!httpRequest) { alert('Your browser does not support Ajax.'); return false; } //=============================== // Action http_request httpRequest.onreadystatechange = function() { if(httpRequest.readyState == 4) if(httpRequest.status == 200) alert(httpRequest.responseText); else alert('Request Error: '+httpRequest.status); } httpRequest.open('GET',document.location.href,true); httpRequest.send(null); xmlhttp.open("GET","Default.aspx",true); xmlhttp.send(); </code></pre>
jquery
[5]
4,787,423
4,787,424
Dropdown always selects the first value
<pre><code> &lt;select id="form_city" name="form"&gt; &lt;option value="All"&gt;View All&lt;/option&gt; &lt;option value="1"&gt;General&lt;/option&gt; &lt;option value="0"&gt;Proposed&lt;/option&gt; &lt;/select&gt; </code></pre> <p>In the front end, irrespective of what i have selected in the dropdown, it always takes "All" as selected and when submit the form "All" value goes to action every time. Please help</p>
java
[1]
3,794,535
3,794,536
How to get a slice from "arguments"
<p>All you know that <code>arguments</code> is a special object that holds all the arguments passed to the function.</p> <p>And as long as it is not an array - you cannot use something like <code>arguments.slice(1)</code>.</p> <p>So the question - how to slice everything but first element from <code>arguments</code>?</p> <p><strong>UPD</strong>:</p> <p>seems like there is no way without converting it to an array with</p> <pre><code>var args = Array.prototype.slice.call(arguments); </code></pre> <p>If someone posts another solution it would be great, if not - I'll check the first one with the line above as an answer.</p>
javascript
[3]
1,158,426
1,158,427
jquery selectors
<p>I would like to select the p elements inside a particular div, #homepage. I know how to select all the #homepage, or all of the li's on the page, but how do I selected a nested group of li's?</p> <p>Thank you!</p>
jquery
[5]
5,260,196
5,260,197
One dropdown at a time - setting a flag
<p>If you click the dropdowns at this site: <a href="http://ryanbent.com/" rel="nofollow">http://ryanbent.com/</a> - I want each of those tabs to only OPEN one at a time. If you click one, then close the other.</p> <p>I understand the thought behind it, i sent a class when you click it, and I am trying to go through each of them, but I cant seem to get it to work. I think its my selectors. My code is below:</p> <pre><code>function HideMenu(){ //$('.open').stop().animate({'top':'-480px'},500,"linear"); $('.open').slideUp(); $(this).removeClass("open"); $("#fuzz").fadeOut(); } function checkMenu(){ $('.open').slideUp(); } $('#contact').toggle(function() { checkMenu(); $('#contact-pull').show().animate({'top':'-50px'}).addClass("open"); //$('#contact-pull').slideDown(); }, function() { HideMenu(); $('#contact-pull').animate({'top':'-180px'}) }); $('#about').toggle(function() { checkMenu(); $('#about-pull').show().animate({'top':'55px'}).addClass("open"); // $('#about-pull').slideDown(); }, function() { HideMenu(); $('#about-pull').animate({'top':'-465px'}) }); $('#portfolio').toggle(function(){ checkMenu(); $('#portfolio-pull').animate({'top':'75px'}).addClass("open"); }, function() { HideMenu(); $('#portfolio-pull').animate({'top':'-150px'}); }); </code></pre> <p>Does anyone have any suggestions on how I can get this working? I have been struggling with this and cant seem to get it to work. I set the flag fine, but I need to check for it.</p>
jquery
[5]
2,239,091
2,239,092
a simple problem about RegExp in Javascript
<p>I have a text:</p> <pre><code> &lt;font class="myclass"&gt;class abc&lt;/font&gt; </code></pre> <p>and i have a pattern: class now, i want to find the word "class" before "abc" but not in the <code>&lt;font class="myclass"&gt;</code> ,how could i do with RegExp in javascript? Thanks! :)</p>
javascript
[3]
2,874,773
2,874,774
How to count the number of occurrences of words in a text
<p>I am working on a project to write a program that finds the 10 most used words in a text, but I got stuck and don't know what I should do next. Can someone help me please?</p> <p>I came this far only:</p> <pre><code>import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; import java.util.regex.Pattern; public class Lab4 { public static void main(String[] args) throws FileNotFoundException { Scanner file = new Scanner(new File("text.txt")).useDelimiter("[^a-zA-Z]+"); List&lt;String&gt; words = new ArrayList&lt;String&gt;(); while (file.hasNext()){ String tx = file.next(); // String x = file.next().toLowerCase(); words.add(tx); } Collections.sort(words); // System.out.println(words); } } </code></pre>
java
[1]
814,793
814,794
how can retrieve image in sdcard in byte convertion in android application
<p>I am working in android application retrieve image in sdcard in image read in byte convertion how can solve this type of problem i am getting in image uri in sdcard </p>
android
[4]
2,190,480
2,190,481
Cannot call derived class method in a function that takes base class as parameter
<p>I have the following problem:</p> <pre><code>class A { void f() {} } class B extends A { void g() {} } class C extends A { void h() {} } void foo(A temp) { temp.g(); } </code></pre> <p>I want my foo() function to take a base class parameter, so I can work with B &amp; C. But inside the funciton I have a call to a derived class method, so of course I get an error.<br> I also tried this inside the foo function:</p> <pre><code>if(temp instanceof B) { B somevar = (B)temp; } else if( temp instanceof C) { C someVar = (C)temp; } someVar.g(); </code></pre> <p>But still I have a compile errors that it doesnt know who someVar is. How could I make this to work ? </p> <p>Thanks.</p>
java
[1]
78,582
78,583
Changes NIVO slider Sliding effect
<p>I have a problem with sliding effect of NIVO SLIDER.Now its overlapping images one after another from left to right.But i want to shift the images from left to right instead of overlapping like easy slider.Is it possible?Url is here <a href="http://www.markupxpert.com/nivo/" rel="nofollow">http://www.markupxpert.com/nivo/</a> </p>
jquery
[5]
4,905,507
4,905,508
python: can i set a variable to equal a function of itself?
<p>Can I do this?</p> <pre><code>var1 = some_function(var1) </code></pre> <p>When I tried to do this I got errors, but perhaps I was doing something wrong.</p>
python
[7]
166,836
166,837
URLSpan on Spanned Text not showing in drawn StaticLayout
<p>I'm building a custom view that mimics TextView but which supports text wrapping by managing multiple internal StaticLayouts.</p> <p>Everything is working out quite well, but I'm having trouble with viewing some HTML. Most of the HTML markup is translated to Spans via <code>Html.fromHtml</code>. This includes the a-link elements which, when I step through with the debugger, I can see are becoming URLSpan objects.</p> <pre><code> mSpannedArticleText = Html.fromHtml(mInboundArticleText); </code></pre> <p>In the above, mInboundArticleText is the inbound string passed to setText and mSpannedArticleText is the Spanned object which will be passed to the StaticLayout. Everything in the StaticLayout renders great except <em>I cannot see the URLSpans.</em> I know they are attached to the mSpannedArticleText and I create a new StaticLayout using:</p> <pre><code>updatedLeftColumnLayout = new StaticLayout(mSpannedArticleText, mBodyTextPaint, leftColumnWidth, Layout.Alignment.ALIGN_NORMAL, (float) 1.0, (float) 0.0, true); </code></pre> <p>I'm not sure what would be causing this issue but, after looking at the source code for TextView, I can't seem to locate any special handling of URLSpans, nor do I see any exception cases in StaticLayout. I'm hoping someone can shed some light on what I might be doing incorrectly in building the Spanned text or other requirements for using URLSpans which I might not have setup.</p>
android
[4]
1,200,886
1,200,887
problem with the variables scope
<pre><code>// Calculating term frequency System.out.println("Please enter the required word :"); Scanner scan = new Scanner(System.in); String word = scan.nextLine(); String[] array = word.split(" "); int filename = 11; String[] fileName = new String[filename]; int a = 0; for (a = 0; a &lt; filename; a++) { try { System.out.println("The word inputted is " + word); File file = new File( "C:\\Users\\user\\fypworkspace\\TextRenderer\\abc" + a + ".txt"); System.out.println(" _________________"); System.out.print("| File = abc" + a + ".txt | \t\t \n"); for (int i = 0; i &lt; array.length; i++) { int totalCount = 0; int wordCount = 0; Scanner s = new Scanner(file); { while (s.hasNext()) { totalCount++; if (s.next().equals(array[i])) wordCount++; } System.out.print(array[i] + " ---&gt; Word count = " + "\t\t " + "|" + wordCount + "|"); System.out.print(" Total count = " + "\t\t " + "|" + totalCount + "|"); System.out.printf(" Term Frequency = | %8.4f |", (double) wordCount / totalCount); System.out.println("\t "); } } } catch (FileNotFoundException e) { System.out.println("File is not found"); } } </code></pre> <p>This is my code to calculate the word count, total words and the term frequency of a text file containing text. The problem is i need to access the variable wordcount and totalcount outside of the for loop. But changing the place to declare the variable wordcount and totalcount changes the results too making it not accurate. Can someone help me on the variables so that i can get accurate results and also access the variables outside of the for loop ? </p>
java
[1]
5,450,576
5,450,577
What is the single character after a value called/exactly do in C#? (eg 1.00m)
<p>What is this feature "called" when you add a literal chracter beside the value of certain types?</p> <pre><code>decimal d = 1.00m; </code></pre>
c#
[0]
508,642
508,643
Can anyone provide me any resource to learn OpenGL for android?
<p>I am a android application Developer, for future purpose i want to learn OpenGl.Can anyone guide me or suggest me anything.</p>
android
[4]
3,698,041
3,698,042
Get last location latitude and longitude
<p>This is my code.</p> <pre><code>public class MyLocationListener implements LocationListener { @Override public void onLocationChanged(Location loc) { Location location = mlocManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); LastLocationLat = location.getLatitude(); LastLocationLongi = location.getLongitude(); LocationLat = loc.getLatitude(); LocationLongi = loc.getLongitude(); if(loc.hasSpeed()) { float mySpeed = loc.getSpeed(); Toast.makeText(getApplicationContext(), ""+mySpeed, 2000).show(); } } @Override public void onProviderDisabled(String provider) { Toast.makeText(getApplicationContext(), "Gps Disabled", Toast.LENGTH_SHORT).show(); } @Override public void onProviderEnabled(String provider) { Toast.makeText(getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show(); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { Toast.makeText(getApplicationContext(), "Gps onStatusChanged", Toast.LENGTH_SHORT).show(); } } </code></pre> <p>But i did not get last location in this code i got same latitude and longitude </p>
android
[4]
2,171,021
2,171,022
urllib2 not retrieving an url with hashes on it
<p>I'm trying to get some data from a webpage, but I found a problem. Whenever I want to go to the next page (i.e. page 2) to keep retrieving the data on it, I keep receiving the data from page 1. Apparently something goes wrong trying to switch to the next page.</p> <p>The thing is, I haven't had problems with urls like this: </p> <pre><code>'http://www.webpage.com/index.php?page=' + str(pageno) </code></pre> <p>I can just start a while statement and I'll just jump to page 2 by adding 1 to "pageno" </p> <p>My problem comes in when I try to open an url with this format:</p> <pre><code>'http://www.webpage.com/search/?show_all=1#sort_order=ASC&amp;page=' + str(pageno) </code></pre> <p>As</p> <pre><code>urllib2.urlopen('http://www.webpage.com/search/?show_all=1#sort_order=ASC&amp;page=4').read() </code></pre> <p>will retrieve the source code from <a href="http://www.webpage.com/search/?show_all=1" rel="nofollow">http://www.webpage.com/search/?show_all=1</a></p> <p>There is no other way to retrieve other pages without using the hash, as far as I'm concerned.</p> <p>I guess it's just urllib2 ignoring the hash, as it is normally used to specify a starting point for a browser.</p>
python
[7]
2,428,547
2,428,548
What is the best way to implement operator<?
<p>Sorry if this is a stupid question, but it's something that I'm curious about.</p> <p>I am overloading the less-than operator for my sort algorithm based on last name, first name, middle name. I realize there is not a right or wrong here, but I'm curious as to which style is written better or preferred among fellow programmers.</p> <pre><code>bool CPerson::operator&lt;(const CPerson&amp; key) const { if (m_Last &lt; key.m_Last) || ( (m_Last == key.m_Last) &amp;&amp; (m_First &lt; key.m_First) ) || ( (m_Last == key.m_Last) &amp;&amp; (m_First == key.m_First) &amp;&amp; (m_Middle &lt; key.m_Middle) ) return true; return false; } </code></pre> <p>or</p> <pre><code>bool CPerson::operator&lt;(const CPerson&amp; key) const { if (m_Last &lt; key.m_Last) return true; else if ( (m_Last == key.m_Last) &amp;&amp; (m_First &lt; key.m_First) ) return true; else if ( (m_Last == key.m_Last) &amp;&amp; (m_First == key.m_First) &amp;&amp; (m_Middle &lt; key.m_Middle) ) return true; else return false; } </code></pre> <p>or</p> <pre><code>bool CPerson::operator&lt;(const CPerson&amp; key) const { if (m_Last &lt; key.m_Last) return true; if (m_Last == key.m_Last) if (m_First &lt; key.m_First) return true; if (m_Last == key.m_Last) if (m_First == key.m_First) if (m_Middle &lt; key.m_Middle) return true; return false; } </code></pre>
c++
[6]
4,361,401
4,361,402
ASP.NET with MVC 2 in VS2010
<p>Hi i want to do a work in asp.net using mvc and ajax i have a button when i click that button,its text should be changed.e.g before click(Click me) after click(u clicked me) but i want to do this work in MVC2 i have studied but couldn't understood mvc kinfly do this example so that i can understand it easily</p> <p>Best Regards: Shaahan</p>
c#
[0]
3,557,237
3,557,238
Where to find good resources to learn Events and EventListener in javascript and know more about it?
<p>Where to find good resources to learn Events and EventListner in javascript and know more about it?</p> <p>i want to know more about it form beginner to high level</p>
javascript
[3]
6,027,494
6,027,495
How to find N longest lines in a text file
<p>Write a program to read a multiple line text file and write the 'N' longest lines to stdout.</p> <p>There was a similar question but I didn't really understand it since it involves using a min-heap and that would create more work since I'd have to create a min-heap data structure. </p> <p>I tried to create an array that size n. Then sort it but I would have to sort it each and every time I inserted a new line into the array. I'd like to know what's the simple approach and what would be the optimal one.</p>
java
[1]
4,525,494
4,525,495
A way to make the player move
<p>I want to create a game just like mario. Now, I need a camera for my player, so it looks like the player is actually moving around, how would I do this? The only way I can think of, is moving the environment when the player is moving, so it looks that the player is moving, which he is actually not, is this the best way, or are there any other, better ways?</p>
java
[1]
2,522,995
2,522,996
How to wp_enqueue_script jQuery inside a Plugin
<p>I would like to use jQuery in my Wordpress plugin. I'm trying to load the jquery library using the enqueue script but its throwing an error.</p> <p><em>Error: $ is not a function</em></p> <p>Here's the code snippet that's inside my main plugin.php file...</p> <pre><code>function ($post) { wp_enqueue_script('jquery'); ?&gt; &lt;script type="text/javascript"&gt; function doTestParse(searchString){ var rx = new RegExp('(?![^&lt;]+&gt;)'+searchString, "gi"); $(this).html($(this).html().replace(rx, '&lt;b&gt;$&amp;&lt;/b&gt;')); } &lt;/script&gt; &lt;?php ?&gt; </code></pre>
jquery
[5]
343,267
343,268
How can i include file to all files in the same folder
<p>How can i include file to all files in the same folder like in wordpress <code>functions.php</code> it runs in all files in the script how can i do that</p>
php
[2]
2,743,971
2,743,972
Java: Prevent subclass from providing a different interface than base class
<p>Is there a means to prevent a subclass from exposing public methods other than those defined in the base class, at compile-time?</p> <p>For example:</p> <pre><code>abstract public class AClass { abstract public void anAllowedMethod(); } public class BClass extends Aclass { public void anAllowedMethod() { } public void anAdditionalNonAllowedMethod() { } private void thisMethodIsAllowedBecauseItsNotPublic() { } } </code></pre> <p>Perhaps there is some keyword I can use in AClass to declare the subclass can only implemented the methods defined in AClass (ie. "anAllowedMethod()")?</p>
java
[1]
98,568
98,569
android location listener question
<p>I am developing an location aware application that needs to know the users location. The problem is that the application doesn't seem to work properly.</p> <p>By properly I mean that every time I have to first open an application (like cardio trainer) in order to get a GPS signal and then run my program, otherwise the GPS icon on the notification bar is blinking like it blinks when the device tries to get GPS signal and after a while it stops and no location is returned!</p> <p>this is really weird because it shouldent stop, is there an interval that android provides the gps to get signal?</p> <p>on the documentation I haven't found anything about that.</p> <p>my code is as follows:</p> <pre><code>lm.isProviderEnabled(LocationManager.GPS_PROVIDER); lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 10, locationListenerGps); LocationListener locationListenerGps = new LocationListener() { public void onLocationChanged(Location location) { locationResult.gotLocation(location); Log.e("##################","MyLocation got GPS location accuracy: "+location.getAccuracy()+" Altitute: "+location.getAltitude()+" log: "+location.getLongitude()+" lat: "+location.getLatitude()); } public void onProviderDisabled(String provider) {} public void onProviderEnabled(String provider) {} public void onStatusChanged(String provider, int status, Bundle extras) {} }; </code></pre> <p>That should open the gps provider and register a listener called locationListenerGps that would be called by the location manager every 1 minute or 10 meters right?</p> <p>why I have to open cardioTrainer first to get a GPS signal?</p> <p>thanks in advanced maxsap </p>
android
[4]
5,820,527
5,820,528
Grading Program - Compile/executing c++ code within c++
<p>I am writing a program to grade c++ code that students submit. Right now it uses a system call to compile every source file then redirects the input to a file and calls the new executables in processes and searches the output for certain strings. This also allows me to have a timeout on processes for programs that crash.</p> <p>Is there a better way to do this than a system call? Or a better way to do this in general?</p>
c++
[6]
1,732,849
1,732,850
How to fix apple mobile driver software installation failure?
<p>I have a jail broken iPhone 4s and before, it perfectly synced with my iTunes. But since I updated my iTunes to its latest version, my laptop which runs on windows vista doesn't detect my iPhone. It says "apple mobile device driver software installation failed". I tried reinstalling iTunes but still, same problem occurred. Also, I tried restarting the device driver in the administrative tools but still, the problem wasn't resolved. Any help fixing this? Also, i may have edited my windows registry to resolve my issue with iTunes wit it's cd/DVD driver. Could this be connected to the error? Help me fix this. Tnx.</p>
iphone
[8]
4,665,345
4,665,346
Negative key in binary search method in Java
<p>What does it mean when the second argument is negative. I'm looking at a piece of code that searches for a key in an array. But what does a negative key mean ?</p> <pre><code> for (int i = 0; i &lt; N; i++) { int j = Arrays.binarySearch(a, -a[i]); } </code></pre>
java
[1]
83,379
83,380
Does android application runs in Background?
<p>I'm developing android application in which I have to notify when application get into background.</p> <p>Can you guys let me know whether android app runs in background? Also <strong>lifecycle</strong> of android app in application level.</p>
android
[4]
638,754
638,755
Jquery Date Picker with different links
<p>I am new to Jquery. I am using JQuery DatePicker as a calender entry with some date showing in different colour but my problem is that when I want to assign a link to that date it is now working well...Here is the code</p> <p><strong>I defined the pink and green as style as well and is working perfect.</strong></p> <pre><code>var events = {}; events[new Date("02/14/2011")] = new Event("Valentines Day", "pink"); events[new Date("02/18/2011")] = new Event("Payday", "green"); $('#calender').datepicker({ changeMonth : true, changeYear : true, beforeShowDay : function(date) { var event = events[date]; if (event) { return [ true, event.className, event.text ]; } else { return [ true, '', '' ]; } }, onSelect : function(date) { var event = events[date]; alert(event.text ,"Event on " + date); } }); </code></pre> <p>title on date 02/14/2011 and 02/18/2011 is perfectly working because of beforeShowDay but when I am doing the same thing in onSelect it is showing undefined.Thanks in advance......Thanks</p>
jquery
[5]
1,612,957
1,612,958
Use of type() for method calls
<p>Why does <a href="http://www.python.org/dev/peps/pep-0343/" rel="nofollow">PEP-343</a> use type() in this situation here?</p> <pre><code> mgr = (EXPR) exit = type(mgr).__exit__ # Not calling it yet value = type(mgr).__enter__(mgr) </code></pre> <p>Couldn't we just as well use <code>exit = mgr.__exit__</code> and <code>value = mgr.__enter__()</code>? Seems simpler to me, but I assume I'm missing something.</p>
python
[7]
3,827,687
3,827,688
redirect to a page if response.redirect fails
<p>I have a response.redirect(url), it goes to another site. In the event this fails, how would I redirect again to a 'redirect fail' page? the request is bieng sent from the code behind an aspx page. I have an httpmodule in place already if that could be used? Thanks in advance.</p>
c#
[0]
121,865
121,866
String.Format in .aspx not showing rest of text after
<pre><code>&lt;div visible="false" runat="server"&gt;&lt;a href='&lt;%#string.Format("{0}removeAllItems=true", this.Page)%&gt;' onclick="return confirm('Are you sure you want to remove all items?')"&gt;Remove all items&lt;/a&gt;&lt;/div&gt; </code></pre> <p>when I run this, it doesn't show the querystring portion, just the page.aspx. I don't see why the rest of that string after {0} is being cut off.</p>
asp.net
[9]
2,746,863
2,746,864
Program crashes by "out string"
<p>I am using this dll where one of the methods expects string as an argument by out, i.e.</p> <pre><code>void function(out string param); </code></pre> <p>When I am passing the string by out, the program crashes. I am using C#. The output I am getting in output debug window of VS2010 is as follows: The program '[4116] Managed (v4.0.30319)' has exited with code -1073741819 (0xc0000005).</p> <p>The problem is sudden and short so I don't know how to explain further, but if you have further questions let me know...</p> <p>Update: This is ActiveX dll and I came across the tutorial mentioning that COM returns string in Unicode. Is that what is causing the problem?</p>
c#
[0]
5,730,049
5,730,050
How to list usb devices in my android application?
<p>is there a way/api to list all the usb devices plugged in ? Thanks a lot =]</p>
android
[4]
924,900
924,901
Android: Overflow icon event listener
<p>Does anyone know how to add a listener to the action overflow menu button ( the three dots on the action bar )? I would like to add elements dynamically to the overflow menu, and I can't figure out how to do it.</p> <p>Help please :)</p>
android
[4]
5,061,537
5,061,538
Using Constructor for default member value
<p>In C++11, can do this to initialize an object without using initialization list:</p> <pre><code> class Z{ int a=0; int b; z():b(0){} //&lt;-- a already initialized }; </code></pre> <p>What I'm wondering is for class types, which of these is preferable:</p> <pre><code> class Z{ std::vector&lt;int&gt;a=std::vector&lt;int&gt;(); //or instead: std::vector&lt;int&gt;a(); int b; z():b(0){} //&lt;-- a already initialized }; </code></pre>
c++
[6]
5,360,640
5,360,641
iframe returns content using the server internet connection
<p>Does anyone know if it is possible to code an iframe on a website to return data using the servers internet connection as opposed to the clients?</p> <p>Thanks</p>
c#
[0]
324,492
324,493
listening to keyboard input
<p>I have a Java program that runs in the background without any UI.</p> <p>Can it listen to keyboard input?</p>
java
[1]
195,483
195,484
PHP Call a function with default parameter, but in the middle of parameter list?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/579331/is-it-possible-to-skip-parameters-that-have-default-values-in-a-php5-function">Is it possible to skip parameters that have default values in a php(5) function call?</a> </p> </blockquote> <p>Lets say this is my function :</p> <pre><code>function myFunc($a ,$b = 'ball',$c = 'cat') { echo "$a $b $c" ; } myFunc("apple"); // output : "apple ball cat" myFunc("apple","box"); // output : "apple box cat" </code></pre> <p>How can I call <code>myFunc</code> with default parameter for <code>$b</code>, eg</p> <pre><code>myFunc("apple", SOMETHING_HERE , "cow" ); // output : "apple ball cow" </code></pre>
php
[2]
577,111
577,112
Find - using PHP and wrap everything after in <span>
<p>I am printing using PHP</p> <pre><code>&lt;?php echo $article-&gt;link($article-&gt;title()); ?&gt; </code></pre> <p>This string holds something like </p> <pre><code>"Team Member - Job Title" </code></pre> <p>What id like to do is wrap everything after the dash in a span so i can change its colour.</p> <p>Any help would be greatfully appreciated. </p>
php
[2]
2,352,662
2,352,663
Critical tools that every Java Developer should have in his toolbelt?
<p>I was trying to compile a list of tools that a good Java Developer should be know of, and keep in his Developer Tool Belt</p> <p>I can think of a few</p> <ul> <li>Eclipse Development Environment - There are other IDEs, but you should know how Eclipse of eclipse.</li> <li><a href="http://junit.org/" rel="nofollow">JUnit</a> - Java Unit Testing Framework. Of course there are others, but...</li> <li><a href="http://ant.apache.org/" rel="nofollow">ANT</a></li> <li><a href="http://maven.apache.org/" rel="nofollow">Maven</a></li> <li><a href="http://www.soapui.org/" rel="nofollow">Soap UI</a> - for testing SOAP endpoints</li> <li><a href="http://jrat.sourceforge.net/" rel="nofollow">jrat</a> - Java Profiler. I don't know of other good Java profilers</li> <li><a href="http://www.varaneckas.com/jad" rel="nofollow">Java Decompiler</a> - For when you just <strong>have</strong> to know what's in the jar file</li> </ul>
java
[1]
5,451,528
5,451,529
Delete Temp File in Java
<p><em>Am having the below code , creating a Temp file and read that and deleting the file. But after deletion also file available to read .Please help to find wrong with my code....</em></p> <pre><code>public static void main(String args[]) throws Exception { Calendar mSec = Calendar.getInstance(); String fileName="hubname_"+"msgname_"+mSec.getTimeInMillis(); String str ="Hello How are you doing ......."; System.out.println("fileName :"+fileName); File f = File.createTempFile(fileName, ".xml"); FileWriter fw = new FileWriter(f); fw.write(str); fw.flush(); fw.close(); printFileContent(f); f.delete(); printFileContent(f); } public static void printFileContent(File f)throws Exception { BufferedReader reader = new BufferedReader( new FileReader(f)); String line = null; StringBuilder stringBuilder = new StringBuilder(); String ls = System.getProperty("line.separator"); while( ( line = reader.readLine() ) != null ) { stringBuilder.append( line ); stringBuilder.append( ls ); } System.out.println("stringBuilder.toString() :"+stringBuilder.toString()); } </code></pre> <p><strong>Output :</strong></p> <pre><code>fileName :hubname_msgname_1358655424194 stringBuilder.toString() :Hello How are you doing ....... stringBuilder.toString() :Hello How are you doing ....... </code></pre>
java
[1]
602,312
602,313
Best practice for creating objects used in for/foreach loops
<p><br> What's the best practice for dealing with objects in for or foreach loops? Should we create one object outside the loops and recreate it all over again (using new... ) or create new one for every loop iteration?<br> Example: </p> <pre><code>foreach(var a in collection) { SomeClass sc = new SomeClass(); sc.id = a; sc.Insert(); } </code></pre> <p>or </p> <pre><code>SomeClass sc = null; foreach(var a in collection) { sc = new SomeClass(); sc.id = a; sc.Insert(); } </code></pre> <p>Which is better?</p>
c#
[0]
5,385,362
5,385,363
In PHP what does |= mean, That is pipe equals (not exclamation)
<p>I just found this in some code and I can't find anything on the web or php manual. Most likely since its an irregular character.</p> <p>Here is one of the lines that uses it.</p> <pre><code>$showPlayer |= isset($params['node']) &amp;&amp; $params['node']; </code></pre>
php
[2]
6,598
6,599
Continue performing a function while Android phone is asleep?
<p>I want to create an Android app which requires a function to be run every 30 seconds or so, even when the phone goes to sleep and the user isn't using it. Is this possible to do in Android with services, or do even they shut off when the phone goes to sleep?</p>
android
[4]
4,301,675
4,301,676
What is the best way to compare a value against 'undefined'?
<p>Is there any differences between</p> <pre><code>var a; (a == undefined) (a === undefined) ((typeof a) == "undefined") ((typeof a) === "undefined") </code></pre> <p>Which one should we use?</p>
javascript
[3]
540,618
540,619
detect the widest cell w/ jQuery
<p>I have a table with different values. First column contains labels. I need to get the width of the widest label. I assume I need some sort of a loop, but then what?</p> <pre><code>$("#myTable td:nth-child(1)").width(); </code></pre> <p>Thanks. </p>
jquery
[5]
4,194,458
4,194,459
finding the whole number portion of a number
<p>How can you find the whole number of a given decimal or other number in JavaScript?</p> <pre> Given Result ----- ------ 1.2 1 1.5 1 1.9 1 </pre> <p>What's the best way to perform this for both positive and negative numbers?</p>
javascript
[3]
4,766,504
4,766,505
File & file_get_contents bugging on reading simple file
<p>file or file_get_contents do not read this sample file properly</p> <p><code>&lt;?php<br> ?&gt;</code></p> <p>This is the test program</p> <pre><code>$flines=file('../include/test.php'); echo '&lt;pre&gt;'; print_r($flines); echo '&lt;/pre&gt;'; for($i=0;$i&lt;count($flines);$i++) { echo("$i:".$flines[$i]."\n&lt;br&gt;"); } echo "File Get Contents"; echo(file_get_contents('../include/test.php')); </code></pre> <p>This is the output</p> <p><code>Array (<br> [0] => ?><br> )<br> 0:1:?><br> File Get Contents </code></p> <p>Basically it skips the php declaration for some reason... and the file is empty<br> <strong>addition</strong> every works fine when removing the opening <code>&lt;</code> of course </p>
php
[2]
3,855,418
3,855,419
Problem in reading the contents of the manifest file
<p>hello i downloaded the apk file for the android application called othikyatha (<a href="http://code.google.com/p/othikyatha/" rel="nofollow">http://code.google.com/p/othikyatha/</a>) from Google Code. i have tried running the project along with the source code obtained from <a href="http://www.java2s.com/Open-Source/Android/Location/othikyatha/Catalogothikyatha.htm" rel="nofollow">http://www.java2s.com/Open-Source/Android/Location/othikyatha/Catalogothikyatha.htm</a>. And i have not been able to view the contents of the xml files in /res folder and manifest file. the contents appear encrypted. is there a way of decrypting the contents of these xml files??</p>
android
[4]
1,640,480
1,640,481
Can I change the apps view based on if a file has been saved?
<p>Please help! I'm a newbie to programming and I'm having the following trouble. I am trying to write my first iphone app and I would like it to do the following.</p> <p>When the app launches user enters name, presses button and goes to new view. Their name is saved to file and used through out the app. That much I have managed.</p> <p>I would like the app to check to see if there is a saved file when it is launched and go directly to second view instead of the first view. I'm have search for days looking for an answer and I'm still not sure how to do this.</p> <p>At the risk of seeming stupid do I use an IF statement and how do I write it. Please help.</p> <p>Thanking you in advance.</p>
iphone
[8]
1,362,585
1,362,586
How to get the nextSibling after the first nextSibling?
<p>We are able to run this code</p> <pre><code>str.parentNode.nextSibling.tagName </code></pre> <p>and get the name accordingly. What we need is the <code>nextSibling</code> after this <code>nextSibling</code> so we tried this</p> <pre><code>str.parentNode.childNodes[3].tagName </code></pre> <p>is not working? Any solution to this?</p>
javascript
[3]
583,711
583,712
Starting an Activity or Service with its own memory space
<p>I have a memory intensive process that needs to run and still allow the user to continue using the application. The application will throw out of memory errors if the user uses the app while this process is running. The following code launches an app from another app.</p> <pre><code>ntent intent = new Intent(Intent.ACTION_MAIN); intent.setComponent(new ComponentName("com.package.address","com.package.address.MainActivity")); startActivity(intent); </code></pre> <p>Is it possible to start an activity or service that lives inside an application as a new application or have it run outside the memory space of the currently running application? </p> <p>I read about the android:launchMode attribute but it does not look like any of the attribute values will work. </p> <p>I also read about creating a global service but the documentation does not state anything about where the service runs. Does a global service run in its own memory space or the memory of the application using it?</p> <p>Any suggestions would be greatly appreciated.</p> <p>Chris</p>
android
[4]
4,479,555
4,479,556
Easiest way to save data in savedInstanceState when managing an adapter(viewpager)
<p>I'm working with an adapter(viewpager) and when the app changes orientation it loses its information. Which is the easiest way to conserve this information? I was going to use savedInstanceState inside the adapter but it doesn't recognise it.</p>
android
[4]
991,894
991,895
How to display data in TextView
<p>I have a view in which there is a text box where user enters data, when clicks on submit, I want to store the input and display in another box.</p> <pre><code>final EditText edittext = (EditText) findViewById(R.id.edittext); mText = (TextView) findViewById(R.id.timepicker_input); </code></pre> <p>How can I do it, please help</p>
android
[4]
3,598,974
3,598,975
Implicit cast operator from object
<p>I was wondering if someone could think of a nice workaround for not being able to add an implicit cast operator, for object, on your own class. The following example illustrates the kind of code I would like</p> <pre><code>public class Response { public string Contents { get; set; } public static implicit operator Response(object source) { return new Response { Contents = source.ToString(); }; } } </code></pre> <p>This won't compile because it upsets the C# compiler and it tells me</p> <pre><code>user-defined conversions to or from a base class are not allowed </code></pre> <p>Turning response into Response and doing</p> <pre><code>public static implicit operator Response&lt;T&gt;(T source) </code></pre> <p>is unfortunately not an option. My guess is going to be <em>no</em>, but could anyone think of a nice workaround/hack to get this to work. I would love to be able to do</p> <pre><code>public Response Foo() { return new Bar(); } </code></pre> <p>and end up with a Response.Contents that said <em>Whatever.Namespace.Bar</em></p>
c#
[0]
4,498,361
4,498,362
Eclipse debugging - any way to pass in "extras" for launching intent?
<p>I'm developing Activity which works on data passed in Intent in extras. This Activity is supposed to be launched by other activities in my app.</p> <p>However, during development/debugging, I launch this Activity directly, and want to simulate extras in Intent (obtained from getIntent) to pass in desired testing params (sort of command-line parameters).</p> <p>In Eclipse Run configurations, I can just select Launch action, but no additional data.</p> <p>Is there some way? Or I must hardcode testing params in java, and not forget to comment them out when testing is finished?</p>
android
[4]
3,898,592
3,898,593
jQuery Append String vs Object Containing String
<p>I understand that both of these will insert html into an element.</p> <p>What are the differences between these 2 methods though?</p> <p>String:</p> <pre><code>$("div").append("&lt;h1&gt;Header&lt;/h1&gt;"); </code></pre> <p>Object:</p> <pre><code>$("div").append($("&lt;h1&gt;Header&lt;/h1&gt;")); </code></pre> <p>Is it just that you can do stuff like this?</p> <pre><code>$("div").append($("&lt;h1&gt;&lt;/h1&gt;").html("Header")); </code></pre>
jquery
[5]
5,934,648
5,934,649
Spinner itemClick shows force close in android
<p>I have used 4 tabs.I want show tabbar in all activity so i used to call activity like this,</p> <pre><code> Intent intent=new Intent(); intent.setClass(DontAllow.this.getParent(),HomePage.class); View view = getLocalActivityManager() .startActivity("Review opportunities", intent .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView(); setContentView(view); </code></pre> <p>I call activity like this, 1st activity-->2nd activity(spinner click)-->error</p> <pre><code> Spinner country = (Spinner) findViewById(R.id.spinner1); Spinner State = (Spinner) findViewById(R.id.spinner2); ArrayAdapter Contries_array = new ArrayAdapter(DontAllow.this,android.R.layout.simple_spinner_item,Countries); ArrayAdapter States_array = new ArrayAdapter(DontAllow.this,android.R.layout.simple_spinner_item,States); Contries_array.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); States_array.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item); country.setAdapter(Contries_array); State.setAdapter(States_array); </code></pre> <p>please help me...how to overcome this problem.</p>
android
[4]
3,824,770
3,824,771
How to create a registry entry from a c# application?
<p>I am developing a windows application in .NET framework, using C#. At the time of application installation I want to write into the registry a certain value. So I have two questions regarding this :</p> <ol> <li><p>How can I execute a code for creating a registry entry at time of installation or there is some settings in the framework which allows us to do so ?</p></li> <li><p>I don't want to create a new node in the registry, can I use some common place anywhere, in the registry or an existing node where I can store my value without affecting the local system settings ?</p></li> </ol> <p>Please help me out.</p> <p>Thanks,</p> <p>Bibhu</p>
c#
[0]
5,795,720
5,795,721
How to activate event?
<p>Hi How can I activate Event ? for example: to activate the Form_Load from my Button in the Form or to activate scan barcode event</p> <p>thank's</p>
c#
[0]
4,752,687
4,752,688
Java connecting to Http which method to use?
<p>I have been looking around at different ways to connect to URLs and there seem to be a few.</p> <p>My requirements are to do POST and GET queries on a URL and retrieve the result.</p> <p>I have seen</p> <pre><code>URL class DefaultHttpClient class HttpClient - apache commons </code></pre> <p>which method is best?</p>
java
[1]
5,586,908
5,586,909
Index was out of range while delete
<p>Why do i get this error(Index was out of range. Must be non-negative and less than the size of the collection.)?</p> <p>Code :</p> <pre><code> object value = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex ].Value; object minus = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value; object delte = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 2].Value; if (value is DBNull || minus is DBNull || delte is DBNull) { return; } else if (value.Equals("+")) { produseTableAdapter.PlusCantitate(DateTime.Now, dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex -5].Value.ToString()); FillData(); dataGridView1.Rows[e.RowIndex].Selected = true; } else if (minus.Equals("-")) { produseTableAdapter.MinusCantitate(DateTime.Now, dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex - 5].Value.ToString()); FillData(); dataGridView1.Rows[e.RowIndex].Selected = true; } else if (delte.Equals("Delete")) { if (MessageBox.Show("Really ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { produseTableAdapter.DeleteQuery(dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex - 5].Value.ToString()); FillData(); dataGridView1.Rows[e.RowIndex].Selected = true; } else { return; } } </code></pre> <p>The problem is with the Cells[e.ColumnIndex + 1] &amp;&amp; Cells[e.ColumnIndex + 2]. Next cell from object value is another button and next after this is another button. How can i get the indexes of this buttons ?</p>
c#
[0]
5,294,952
5,294,953
Error when using substr limit text with format html?
<pre><code>$text = '&lt;p&gt;Download game &lt;a href=""&gt;Avatar&lt;/a&gt; for &lt;b&gt;Iphone 3GS&lt;/b&gt;&lt;/p&gt;'; &lt;?php echo strip_tags(substr($text, 0, 10))." ..."; ?&gt; </code></pre> <p>But resut is <code>...</code>.</p> <p>How to fix it?</p>
php
[2]
1,237,302
1,237,303
Passing a const vector<pointers> to a method but changing value pointed to
<p>I have following code (only relevant portions shown for sake of brevity - please let me know if I have been too brief):</p> <pre><code>class my_class { public: my_class() {m_i=0;} set(int i) {m_i = i;} private: int m_i; } void CallMod() { // create a bunch of my_class* o = new my_class() and store in vector&lt;my_class*&gt; // vObject (left out for brevity) Mod(vObject); // will vObject contain pointers to objects that have m_i == 2 } void Mod(vector&lt;my_class*&gt; const &amp; vObject) { BOOST_FOREACH(my_class o, vObject) { o-&gt;set(2); } } </code></pre> <p>Does this mean that while vObject is const, the modification done by the call to o->set(2) will be retained once Mod returns? Does that indicate that the "const" qualifier will not allow modify operations on vObject (i.e. the vector) but allows modification on the contained pointers to my_class?</p> <p>Did I understand this right? Any duplicate questions that answers this - I couldn't find one - links most appreciated.</p>
c++
[6]
2,320,344
2,320,345
the ui of "New Message" of Mail app?
<p>How to implement the UI of "New Message" of Mail app in iPhone.?</p>
iphone
[8]
354,382
354,383
Whats new in Python 3.x?
<p><a href="http://docs.python.org/dev/3.0/whatsnew/3.0.html" rel="nofollow">http://docs.python.org/dev/3.0/whatsnew/3.0.html</a> says it lists whats <em>new</em>, but in my opinion, it only lists <em>differences</em>, so has does anybody know of any <em>completely new</em> Python features, introduced in release 3.x?</p> <p>To Avoid Confusion, I will define a completely new feature as something that has never been used in any other code before, somehting you walk up to and go "Ooh, shiny!". E.g. a function to make aliens invade, etc.</p>
python
[7]
2,813,245
2,813,246
How can Ioad all Images into an imagelist from a specific folder in c#
<p>How can I load all <code>Images</code> into an image list from a specific folder in c#? thanks!</p> <pre><code>List&lt;Texture2D&gt; images = new List&lt;Texture2D&gt;(); string folderPath = "MyImages/"; for(int i= 0; i&lt;Count; i++) { try{ images.Add(Content.Load&lt;Texture2D&gt;(folderPath + i.ToString));} catch{break;} } </code></pre> <p>This works but I need to convert the filenames into 1 to N. But I have to keep the filenames(the name of the personImage) for future use (for recognition output).</p>
c#
[0]
3,297,731
3,297,732
Use of ToTitleCase
<p>I wonder if anyone can help, I am trying to change something from caps to lower case with the Caps first letter, I undertsand I can use ToTitleCase - but I'm struggling to get this going;</p> <pre><code> &lt;%= Html.Label("rblDeposit." + (i + 1).ToString(), item.Text.ToLowerInvariant())%&gt; </code></pre> <p>I understand I need to supply a string into the ToTitleCase, but how do I do apply this to item.text part ?</p> <p>I thought I could do something like this;</p> <pre><code>&lt;%= Html.Label("rblDeposit." + (i + 1).ToString(), item.Text.ToTitleCase(item.Text))%&gt; </code></pre> <p>Thanks</p>
c#
[0]
4,862,839
4,862,840
How to pass mutable objects by value to java
<p>Is there any way that I can pass mutable Objects by value to a function in java?</p> <p>What I actually want is to pass an object to a method, do some operations on it (change it) and again call that method with that old object only(not the changed value). </p> <p>here is some sample:</p> <pre><code> { MyObj obj = new MyObj(); obj.setName("name"); append(obj); System.out.println(obj.name); prepend(obj); System.out.println(obj.name); } void append(MyObj obj){ obj.name+="1"; } void prepend(MyObj obj){ String a = "1"; obj.name=a+obj.name; } </code></pre> <p>At the end of this code, I want output as:</p> <pre><code>name1 1name </code></pre>
java
[1]
341,934
341,935
Interface to versioned dictionary
<p>I have an versioned document store which I want to access through an dict like interface. Common usage is to access the latest revision (get, set, del), but one should be able to access specific revisions too (keys are always str/unicode or int).</p> <pre><code>from UserDict import DictMixin class VDict(DictMixin): def __getitem__(self, key): if isinstance(key, tuple): docid, rev = key else: docid = key rev = None # set to tip rev print docid, rev # return ... In [1]: d = VDict() In [2]: d[2] 2 None In [3]: d[2, 1] 2 1 </code></pre> <p>This solution is a little bit tricky and I'm not sure if it is a clean, understandable interface. Should I provide a function </p> <pre><code>def getrev(self, docid, rev): ... </code></pre> <p>instead?</p>
python
[7]
2,768,860
2,768,861
Dynamically limit maximum number of checkboxes selectable
<p>I found many scripts to limit max number of checkboxes that can be selected in a page with javascript, for example here is one:</p> <p><a href="http://www.plus2net.com/javascript_tutorial/checkbox-limit.php" rel="nofollow">http://www.plus2net.com/javascript_tutorial/checkbox-limit.php</a></p> <p>However I don't need a specific number, but a VARIABLE one.</p> <p>This means that I need to have a percentage limit instead of just a number.</p> <p>For example, limit user selection to max 30% of the checkboxes in the page.</p> <p>Any help on how to achieve this is highly appreciated!</p>
javascript
[3]
1,753,220
1,753,221
How do I get my code to work?
<p>I have a one assignment </p> <p>I have to make one dimension array with 20 numbers - first 10 numbers are from 1 do 10. others 10 numbers I have to get in method called Dopolni - where I have to sum together array with one another like - p11 = p0+p1, p12 = p1+p2, p14 = p2+p3 and so on - I dont know how to arrange it to get those other 10 numbers - help please</p> <p>my code till now is </p> <pre><code>static void Dopolni(int[] p) { for (int i = 11; i &lt; 20; i++) { p[i] = p[i] + 1; } } static void Main(string[] args) { int[] p = new int[20]; for (int i = 1; i &lt; 20; i++) { if (i &lt;= 10) { p[i] += i; } Console.WriteLine("{0}", p[i]); } Dopolni(p); Console.WriteLine(p); Console.ReadKey(true); } </code></pre> <p>All numbers I have to write out in main window. Hope someone can help out</p>
c#
[0]
5,773,792
5,773,793
Hard refreshing a page with Javascript
<p>I have a question, I'm opening a pop-up window using javascript then a window pops-up, there I make changes to the css file, when I click on close the following javascript is being used to refresh the window opener page </p> <pre><code>window.opener.location.reload(); window.close(); </code></pre> <p>But the css remains cached in the browser, after the next refresh this only disappears. Is there a way I can hard refresh the opener page using javascript?</p>
javascript
[3]
2,779,340
2,779,341
can we access public method defined in a default class outside the package in java?
<p>The main method in java is defined as a public method, and this method is defined in a default class. lets say</p> <pre><code>class test{ public static void main(String args[]){ System.out.println("Hi"); } } </code></pre> <p>can you please explain how the JVM is able to access this main method as the class is default and it can be accessed only with in the package.</p>
java
[1]
1,861,429
1,861,430
What should I do to practice?
<p>I start a year long industrial placement in September where i will be coding in Java predominantly. I am going to use the summer to brush up on my Java as in year one of the degree Java was the main language taught for OOP modules. However this year i have had no Java exposure except for an algorithms module, which was one of eight, so as you can see i am probably getting really rusty!.</p> <p>What i wanted to know is, how does the "real world" java programming differ from university coding and what do you suggest i brush up on that would be different to my normal workings. As a start I definitely need to get familiar with a professional IDE like NetBeans, opposed to having used BlueJ throughout but more specifically what coding practices should I get more familiar with.</p> <p>I appreciate they wont expect me to be a qualified full developer and will give me time, but I would like to hit the ground running as it were, with me having full hopes to secure a permanent position after I finish my degree.</p>
java
[1]
5,427,837
5,427,838
How to get the id of the item being focused as a result of KeyEvent in GridView?
<p>I am executing <strong>KeyEvent.KEYCODE_DPAD_UP</strong>, as a result one of the item in GridView gains focus. My requirement is to obtain the id(or position) of that item. Is it possible to get it? Any help or guidance will be well appreciated.</p>
android
[4]
4,983,874
4,983,875
What's the sample rate for touchMove of Cocoa Touch?
<p>When touch moves, touchMove is called by system. What's the interval between 2 moves?</p>
iphone
[8]
2,225,707
2,225,708
How to remove a list option item in a select field?
<p>I have the following code:</p> <pre><code>function removeUsers() { var removedUsers = document.getElementById('&lt;%=removedUsers.ClientID%&gt;'); var lbCurrent = document.getElementById('&lt;%=lbCurrent.ClientID%&gt;'); if (lbCurrent &amp;&amp; lbCurrent.selectedIndex != -1) { for(i=lbCurrent.length-1; i&gt;=0; i--) { if(lbCurrent.options[i].selected) { //add the removed user to the removedUsers var removedUsers.value += lbCurrent.options(i).value + ";"; lbCurrent.options[i] = null; } } } selectAllItems(); } </code></pre> <p>This is causing me problems in firefox:</p> <pre><code>removedUsers.value += lbCurrent.options(i).value + ";"; </code></pre> <p>Can someone help??</p> <p>Thanks</p>
javascript
[3]
1,946,277
1,946,278
php and connections
<p>I have a problem with my code and the concatenation in some parts, please help! my code is:</p> <pre><code>include('connection.php'); $q_books="SELECT name BID FROM books"; $r_books=mysql_query($q_books,$connection) or die(mysql_error()); $n_books=mysql_num_rows($q_books); for($i=0; $i&lt;$n_books; $i++){ echo "&lt;a href=\"bookinfo.php?BID=\".mysql_result($r_books,$i,'BID')"; echo mysql_result($r_books,$i,'name');&lt;a&gt;&lt;br/&gt; } </code></pre>
php
[2]
2,481,821
2,481,822
How to get songs from album in android?
<p>I am getting all album details. Now I want to get all songs from any album. How to query for songs in a specific album?</p> <p>I've used this code to get album details:</p> <pre><code>Cursor cursor = contentResolver.query( MediaStore.Audio.Albums.getContentUri("external"), new String[] { MediaStore.Audio.Albums.ARTIST, MediaStore.Audio.Albums._ID, MediaStore.Audio.Albums.NUMBER_OF_SONGS, MediaStore.Audio.Albums.ALBUM}, null, null, MediaStore.Audio.Albums.ALBUM + " ASC"); </code></pre> <p>Please anybody help me.</p> <p>Thanks</p>
android
[4]
2,978,165
2,978,166
Switch case with Boolean
<p>I am trying to create a prefix text value for a project. I am using switch case for that. When the user select the relevant radio button we should give the prefix value.</p> <p>what should I give after the "switch ()"</p> <p>The value coming from user selection is a boolean value. The output is string.</p> <p>any help..</p> <pre><code> public string officePostfix() { string postfix = null; switch (...) { case SheetMgrForm.Goldcoast = true: postfix = "QLD"; break; case SheetMgrForm.Melbourne = true: postfix = "MEL"; break; case SheetMgrForm.Sydney = true: postfix = "SYD"; break; case SheetMgrForm.Brisbane = true: postfix = "BIS"; break; } return postfix; } </code></pre>
c#
[0]
4,365,167
4,365,168
Incrementing array value in PHP Session variable
<p>I have this array in PHP session, which I want to step through one step at a time.</p> <p>How do I get the current array index and move one step forward or backward? Here's the code:</p> <pre><code>for ($i = 0; $ &lt; 10; $i++){ $result_array[] = $i; } $_SESSION['theValue'] = $result_array; </code></pre> <p>I tried:</p> <pre><code>$_SESSION['theValue'] [0]++; </code></pre> <p>to move the array one step at a time, but it only displays the same value at that index. Is there a way I can keep incrementing the index?</p> <p>I'm not sure I'm making much sense.</p>
php
[2]
1,315,133
1,315,134
Scandinavian characters and file_get_contents()
<p>I am loading contents from a URL; the URL is in the form www.example.com/?keyword=something. I get the specific content based on user's keyword like this:</p> <pre><code>$url = 'www.example.com/?'; $url = $url."keyword=$something"; function getData ($url) { $data = file_get_contents($url); return $data; } </code></pre> <p>The original data contains Scandinavian characters like Ö or Å. After loading, those characters are not any more readable. How to fix this special character problem? </p> <p>UPDATE: </p> <p>I changed the code this way:</p> <pre><code>function getData ($url) { $data = urlencode(file_get_contents($url)); $data = urldecode($data); return $data; } </code></pre> <p>Didn't help either. Also <code>$data = utf8_decode(urldecode($data));</code> and <code>echo utf8_decode(urldecode(getData($keyword)));</code> don't help. What am I doing whrong here?</p>
php
[2]