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,473,042 | 1,473,043 | jQuery - Use quick filter from ajax results | <p>I've downloaded jquery plugin <a href="https://github.com/bdelespierre/jquery-quickfilter" rel="nofollow">Quick Filter for Jquery</a> and I tried to use it for ajax post results but it's not working. Does anyone have idea what could be wrong or how to modify it?</p>
<p>Direct link to jquery plugin:
<a href="https://github.com/bdelespierre/jquery-quickfilter/blob/master/jquery.quickfilter-0.0.1.js" rel="nofollow">https://github.com/bdelespierre/jquery-quickfilter/blob/master/jquery.quickfilter-0.0.1.js</a></p>
<p>This is how jquery request look like:</p>
<pre><code> $('#cam').change(function(e){
serializedData = $("#thisid").serialize() ;
$.ajax({
url: "/results.php",
type: "post",
data: serializedData,
success: function(response, textStatus, jqXHR){
$('#cam-list').html(response);
}
});
});
</code></pre>
| jquery | [5] |
2,644,683 | 2,644,684 | Implementing counter in Android | <p>I have got an application where I need to show counter from 3 to 1 then quickly switch to another activity. Will TimerTask will be suitable for doing this? Can anybody show me an example of exactly how to do it?</p>
<p>CountDownTimer Worked. Code for showing timer for 3 seconds is.</p>
<pre><code>new CountDownTimer(4000, 1000) {
public void onTick(long millisUntilFinished) {
Animation myFadeOutAnimation = AnimationUtils.loadAnimation(countdown.this, R.anim.fadeout);
counter.startAnimation(myFadeOutAnimation);
counter.setText(Long.toString(millisUntilFinished / 1000));
}
public void onFinish() {
counter.setText("done!");
}
}.start();
</code></pre>
| android | [4] |
5,854,193 | 5,854,194 | Get what page the visitor visit in PHP | <p>I was trying to get what page the visitor visit:</p>
<p>Here is my code: </p>
<pre><code>$url = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$urlcomplete = $url;
$url = explode(".com/",$url);
$urlcount = count($url);
$newurl = '';
for ($start = 1; $start < $urlcount; $start++) {
if ($newurl != '') {
$newurl .= '.com/';
}
$newurl .= $url[$start];
}
$url = explode('/',$newurl);
$urlcount = explode('?',end($url));
$url[count($url) - 1] = $urlcount[0];
$urlcount = count($url);
</code></pre>
<p>By using the code above, all the subpage will be store in the $url.</p>
<p><a href="http://stackoverflow.com/questions/ask">http://stackoverflow.com/questions/ask</a></p>
<pre><code>$url[0] = 'questions'
$url[1] = 'ask'
</code></pre>
<p>Just want to ask, is this good way, or there are others better way?</p>
| php | [2] |
184,659 | 184,660 | How to handle Windows XP or VISTA Events in JAVA | <p>I'd like to ask another question how to handle Windows' events in Java. To be specific, I'd like to know how to handle events such as mouse moved or mouse clicked in Windows XP and Vista. I want to wire my own custom behavior in my application to these events, even when my application is inactive or otherwise hidden.</p>
<p>All help is appreciated!</p>
| java | [1] |
843,971 | 843,972 | Error while sending mail (attachment file) | <p>in my application i am using to send mail with attachments i write the code like this </p>
<p>Using System.Net.Mail;</p>
<p>MailMessage mail = new MailMessage();</p>
<pre><code> mail.Body = "<html><body><b> Name Of The Job Seeker: " + txtName.Text + "<br><br>" + "The Mail ID:" + txtEmail.Text + "<br><br>" + " The Mobile Number: " + txtmobile.Text + "<br><br>" + "Position For Applied: " + txtPostionAppl.Text + "<br><br>" + "Description " + txtdescript.Text + "<br><br></b></body></html>";
mail.From = new MailAddress ( txtEmail.Text);
mail.To .Add (new MailAddress ( mailid));
mail.Priority = MailPriority.High;
FileUpload1.PostedFile.SaveAs("~/Resume/" + FileUpload1.FileName);
mail.Attachments.Add(filenme);
SmtpMail sm = new SmtpMail();
sm.Send(mail);
</code></pre>
<p>it is giving error at attachment like mail.Attachemts.Add(filena)</p>
<p>like this</p>
<p>'System.Collections.ObjectModel.Collection.Add(System.Net.Mail.Attachment)' has some invalid arguments.</p>
| asp.net | [9] |
110,786 | 110,787 | Checking strings with | <p>I have a series of if statements in a function like this:</p>
<pre><code>if time == "%%00":
#code
elif time == "%%15":
#code
elif time == "%%30":
#code
elif time == "%%45":
#code
</code></pre>
<p>Where time is 24 hour format ie. 0000-2400 and I'm checking what 15 interval time is at. All the statements are ignored however, so "%%interval" doesn't work. Is it just something simple I'm missing here or do I need a different method?</p>
| python | [7] |
5,682,221 | 5,682,222 | How do I support my iOS 3.1.2 users now that I've upgraded to Xcode 3.2.3? | <p>I recently released a new version of my iPhone app that was built for iOS 3.1.2. Now I want to release a very small bugfix update, but in the time between my last release and now, I've upgraded Xcode to 3.2.3 and upgraded my test iPhone to 4.0.</p>
<p>Since these are very simple changes, I want my iOS 3.1.2 users to be able to get these fixes but it looks like Xcode wants me to build for iOS 3.2. That doesn't really go back far enough for me.</p>
<p>I've done some research (mostly around SO) and learned that it's possible to use SDK 3.2 and simply set the Deployment Target to 3.1.2. But if I do that, how can I do a basic sanity check of my app's compatibility with that OS, given that I have a brand new development environment and SDK? My physical hardware is now OS 4, and the iPhone Simulator that ships with Xcode doesn't seem to simulate OS 3.1.2.</p>
<p>Is it possible to get an older version of the SDK to test my code? Do I have any other options?</p>
| iphone | [8] |
5,257,163 | 5,257,164 | Mute only the running apps sound in android | <p>I am developing an android application in which there is some speech to the user. there is also a mute button. Can i mute the sound of my application alone, not affecting the sound of music player if it is playing in the back ground??</p>
| android | [4] |
2,485,095 | 2,485,096 | ListView's onScroll event spamming | <p>I've attached an AbsListView.OnScrollListener to a ListView, and whenever there's only one item in the ListView (or at least - I can see the end of the list without scrolling), Android spams out with onScroll events even without the screen being touched.</p>
<p>Has anyone encountered this?</p>
| android | [4] |
658,922 | 658,923 | Windows FTP Clients works, PHP FTP client fails | <p>I've got ftp accounts for two webservers, "STORE" and "APP":</p>
<ul>
<li><em>STORE</em>: no PHP </li>
<li><em>APP</em>: Hosts simple FTP script: "<em>APP/login.php</em>"</li>
</ul>
<p>Using <em>Filezilla</em> to access STORE and APP it works fine.</p>
<p>Using <em>APP/login.php</em> to access:</p>
<ul>
<li><em>APP</em>: Login (and upload)</li>
<li><em>STORE</em>: Login fails "<em>Login incorrect.</em>" :(</li>
</ul>
<p>Filezilla settings for <em>APP</em> and <em>STORE</em> are the same.</p>
<p>Why would make a difference if I was using a <strong>windows client</strong>, or a <strong>web-hosted PHP client</strong>?</p>
<p>Can the <em>STORE</em> firewall tell the difference?</p>
| php | [2] |
39,900 | 39,901 | .attr("disabled", "disabled") problem | <p>i have this function where basically add and remove the disabled attribute form a input field: </p>
<pre><code>$(bla).click(function(){
if (something) {
console.log($target.prev("input")) // gives out the right object
$target.toggleClass("open").prev("input").attr("disabled", "disabled");
}else{
$target.toggleClass("open").prev("input").removeAttr("disabled"); //this works
}
})
</code></pre>
<p>the <code>removeAttr</code> works fine but when i need to add the disabled again it does just nothing. My console.log is triggering (and giving me back the right input field) so I'm sure my that my if statement works. But if i inspect the DOM with firebug the disabled attribute does not appear.</p>
<p>can someone help me?</p>
<p>PS: please don't focus on the function or the if statement itself, works fine its just that attr that does not work for disabled... </p>
<p><em>edit</em>: its an input type="hidden" is it possible that disabled does not work on hidden fields?</p>
| jquery | [5] |
2,152,866 | 2,152,867 | how to bound area in accelerometer? | <p>i am working on an application which is based on accelerometer.</p>
<p>i have a ball which moves on the basis of acclerometer.</p>
<p>i have tried to bound the area of ball in about 320 by 480.</p>
<p>but when the ball reaches one of the corner, the ball gets out of bounded area and gets disappear, and comes again from anywhere.</p>
<p>i have no idea what i am doing wrong.</p>
<p>here is the code i m using</p>
<pre><code>static inline BOOL bounce(float* val, float* delta, float min, float max) {
#define FLIP(val, c) (c - (val - c))
if (*val < min || *val > max) {
*delta = -(*delta * 0.00);
float loc = *val < min ? min : max;
*val = FLIP(*val, loc);
return YES;
}
return NO;
}
-(void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration;
{
#define CAP(val, max) (val < -max ? -max : (val > max ? max : val))
CGPoint delta = CGPointMake(CAP(self.delta.x + acceleration.x, 1.5),CAP(self.delta.y - acceleration.y, 1.5));
CGPoint location = CGPointMake(self.location.x + delta.x, self.location.y + delta.y);
if (fabsf(acceleration.x) > kAccelerationThreshold || fabsf(acceleration.y) > kAccelerationThreshold || fabsf(acceleration.z) > kAccelerationThreshold)
{
}
if (bounce(&location.x, &delta.x,20, self.view.bounds.size.width - 25 ) || bounce(&location.y, &delta.y,20, self.view.bounds.size.height - 20))
{//25, 20
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate);
}
self.delta = delta;
self.location = location;
self.ballView.center = self.location;
}
</code></pre>
<p>waiitng for reply
regards</p>
| iphone | [8] |
3,010,967 | 3,010,968 | Find K max values from a N List | <p>I got requirements-
1. Have random values in a List/Array and I need to find 3 max values .
2. I have a pool of values and each time this pool is getting updated may be in every 5 seconds, Now every time after the update , I need to find the 3 max Values from the list pool.</p>
<blockquote>
<p>I thought of using Math.max thrice on the list but I dont think it as
a very optimized approach.
<strong>> Won't any sorting mechanism be costly as I am bothered about only top
3 Max Values , why to sort all these</strong></p>
</blockquote>
<p>Please suggest the best way to do it in JAVA</p>
| java | [1] |
652,463 | 652,464 | How to find MAC address of an Android device programatically | <p>How do i get Mac Id of android device programatically. I have done with IMIE Code and I no in device how to check Mac id but having no idea how to find out programatically. Your Advice is appreciated.</p>
| android | [4] |
4,808,452 | 4,808,453 | what is the error in this code | <p>in the code below i m trying to reverse the string there is no compile time error but ,nothing is displayed .what is wrong ?</p>
<pre><code> string string1="arunachalam";
void reverseStr()
{
for(int i=string1.length();i<0;i--)
{
cout<<string1[i];
}
}
</code></pre>
| c++ | [6] |
4,235,325 | 4,235,326 | Rich text box event | <p>I have some problem in my project in window form. Problem is that when I type something in the richtext box than I want to fetch each word individually in another string variable one by one. So which event will be fired on it and how i will be get it.
So I am worry about that how i solve this problem.</p>
<p>Thanks in advance.</p>
| c# | [0] |
2,603,066 | 2,603,067 | What is the best way to send 1200x8 floats to Android? | <p>Now I'am creating strings in C# and send it via socket one by one in this format "0 0 0 0; 0 0 0 0".
And then parsing on Android. But I think it's not the best way. Maybe you can suggest me something?</p>
| android | [4] |
5,638,410 | 5,638,411 | Window.close working sometimes and sometimes not | <p>According to <a href="https://developer.mozilla.org/en-US/docs/DOM/window.close?redirectlocale=en-US&redirectslug=window.close" rel="nofollow">Mozilla</a>,
window.close() won't work in FF if window is not opened with window.open();</p>
<p>We have implemented ExtJS in a project and a new window/tab is opened with anchor tag and target='_blank'. In new window, there is close button with js code: 'window.close();'.</p>
<p>As per mozilla standard, this code should not work at all but strangely it works in some cases and doesn't work in some cases.</p>
<p>Can anyone provide some hint/suggestion or workaround please?</p>
| javascript | [3] |
2,348,132 | 2,348,133 | String.format() to fill a string? | <p>I need to fill a String to a certain length with dashes, like:</p>
<pre><code>cow-----8
cow-----9
cow----10
...
cow---100
</code></pre>
<p>the total length of the string needs to be 9. The prefix "cow" is constant. I'm iterating up to an input number. I can do this in an ugly way:</p>
<pre><code>String str = "cow";
for (int i = 0; i < 1000; i++) {
if (i < 10) {
str += "-----";
}
else if (i < 100) {
str += "----";
}
else if (i < 1000) {
str += "---";
}
else if (i < 10000) {
str += "--";
}
str += i;
}
</code></pre>
<p>can I do the same thing more cleanly with string format?</p>
<p>Thanks</p>
| java | [1] |
2,484,563 | 2,484,564 | C++ Multiplying 2 ND Matrices | <p>Tricky question, how to multiply 2 ND metrices? of course columnsA == rowsB...
Here's what i've got:</p>
<pre><code>void multiply(int *A, int *B, int r1, int c1, int r2, int c2) {
int sum = 0;
for (int i=0;i<(c1*r2);i++) {
for (int j=0;j<c1;j++) {
sum += A[(i-i%c1)+j] * B[(i%c1)+j*c1];
}
cout << sum << " ";
sum = 0;
}
}
</code></pre>
<p>Calling it:</p>
<pre><code>multiply(&A[0][0],&B[0][0],rowsA,columnsA,rowsB,columnsB);
</code></pre>
<p>Works only for rectangular matrices, obviously. Any suggestion? :)</p>
| c++ | [6] |
212,458 | 212,459 | C#: Remote Image size without downloading it | <p>I have an image's URL. Is it possible to find out its size(in bytes) and dimensions without downloading the complete image?</p>
<p><strong>EDIT</strong></p>
<pre><code>HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "HEAD";
HttpWebResponse resp = (HttpWebResponse)(req.GetResponse());
System.Console.WriteLine(resp.ContentLength);
</code></pre>
<p>I have written this code. It works fine for first two time and the third time it gives <code>WebException</code> i.e. "operation timed out" irrespective of the image url. Is there something that I am missing here?</p>
| c# | [0] |
4,618,391 | 4,618,392 | Is there any function to return a relative path from public_html to the file location? | <p>I need a function to return a relative path of the file , every where i run it.
for example this is my code in "loc.php" :</p>
<pre><code><?
echo whereiam();
?>
</code></pre>
<p>outputs in these directories should be:</p>
<pre><code>public_html/loc.php : /
public_html/folder1/folder2/loc.php : ../../
</code></pre>
<p>Is there any built-in function in php for this use?</p>
| php | [2] |
2,933,894 | 2,933,895 | Calling no argument constructor of super class | <p>If a class does not provide any constructor,the compiler will provide a default constructor,which in turn call's the no-argument of the super class. Why is this call to the no-argument constructor of the super class needed?</p>
| java | [1] |
3,385,100 | 3,385,101 | Why does the following jquery work in jsfiddle, but not on any browser? | <p>I tried opening the following code in both FF and chrome, nothing happened. But when I loaded the exact code in jsfiddle, it worked . </p>
<p><a href="http://jsfiddle.net/Nuh9w/" rel="nofollow">jsfiddle link</a></p>
<p>HTML: </p>
<pre><code><!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" media="screen" href="fgerg.css" />
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#showButton').click(function() {
$('#x2').css('visibility','visible');
});
});
</script>
</head>
<body>
<input type="button" id="showButton" value="show" />
<p id="x"> gergreg</p>
<p id="x2"> sadeijnfciu </p>
</body>
</html>
</code></pre>
<p>CSS:</p>
<pre><code>#x {
display:none;
}
#x2 {
visibility: hidden;
}
</code></pre>
<p>For anyone interested, the rectangle after the last <code>});</code> caused the whole mess. Anyone know what is that ?
<img src="http://i.stack.imgur.com/uUwDK.png" alt="Wierd special character"></p>
| jquery | [5] |
5,297,058 | 5,297,059 | Use web service in WinCE5 | <p>I write a program in WINCE5(c# 2.0) and want to interaction with my web service also written in C#2.0.</p>
<p>But when I use WSDL utility to generate a Service.cs and refer to it in my CE project as usual. I found I can not pass compile due to:</p>
<pre><code>The type or namespace name 'AsyncCompletedEventArgs' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?)
</code></pre>
<p>As you may know, there're some differents in .NET Compact framework. But who can kindly tell me how to fix the issue?</p>
| c# | [0] |
4,170,847 | 4,170,848 | Double for loop not working | <p>Im trying to solve Euler's Project 9 using PHP. Im pretty sure my logic is fine, but my double for-loop only goes through the first loop, completes the second loop and stops. Any1 knows what Im doing wrong? I want to do the first one 998 times and the second one 998 times. ( NB: I know that I can optimize the code because I $ will never be higher then 331 due to a
<pre><code>//
//A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
//a² + b² = c²
//
//For example, 3² + 4² = 9 + 16 = 25 = 5².
//
//There exists exactly one Pythagorean triplet for which a + b + c = 1000.
//Find the product abc.
$na = array();
$a=1;
$b=1;
$c=0;
$z=998;//upper bound
for($a;$a<$z;$a++){
for($b;$b<$z;$b++){
$c=(1000-$a)-$b;
if(($a*$a)+($b*$b)==($c*$c))
echo "played: $a + $b + $c = 1000<br />";
}
}
</code></pre>
<p>Result is (When I comment the if out) :
played: 1 + 1 + 998 = 1000
to
played: 1 + 997 + 2 = 1000</p>
| php | [2] |
3,578,593 | 3,578,594 | AVAudioPlayer hanging the entire application | <p>I'm using AVAudioPlayer to play sound effects in an iPhone game.
This is part of my code:</p>
<pre><code>AVAudioPlayer *player = [dict objectForKey:@"Player"];
if (player.playing) {
player.currentTime = 0;
} else {
[player play];
}
</code></pre>
<p>One sound that can be played repeatedly and very often, since it plays based on user interaction. As the user moves his finger, I call this piece of code repeatedly.</p>
<p>If you do so, the application hangs and this is the error I get on the crash log:</p>
<pre><code>0 libSystem.B.dylib 0x3146bb18 semaphore_timedwait_signal_trap + 8
1 libSystem.B.dylib 0x3146297c semaphore_timedwait_signal + 8
2 libSystem.B.dylib 0x3145f0fe _pthread_cond_wait + 898
3 libSystem.B.dylib 0x3145f25a pthread_cond_timedwait_relative_np + 10
4 AudioToolbox 0x348ddd50 CAGuard::WaitFor(unsigned long long) + 116
5 AudioToolbox 0x3491b94c ClientAudioQueue::ServicePendingCallbacks() + 232
6 AudioToolbox 0x3491ba60 AudioQueueReset + 44
7 AVFoundation 0x34d16668 -[AVAudioPlayer setCurrentTime:] + 444
</code></pre>
<p>This looks to me like a locking issue inside AVAudioPlayer, and I haven't been able to solve it. I tried with different sound formats (CAFF and IMA4) and both fail in the same way.</p>
<p>Any pointer? I'd really like to stick to AVAudioPlayer since its much simpler to use than Audio Queues, but I need the sounds to play and not crash my application.</p>
| iphone | [8] |
1,393,987 | 1,393,988 | using method that take variable number of parameters | <p>I am trying to make a method that build new object of the class (PhoneBook) using different constructors according to the number of parameters ,, but it gives an error </p>
<p>( Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 )</p>
<pre><code>public static PhoneBook createObjects(String fName,String lName,String num,String...optional)
{
n++;
if (optional[0]==null)
ArrayOfObjects[n]=new PhoneBook(fName,lName,num);
else if (optional[1]==null)
ArrayOfObjects[n]=new PhoneBook(fName,lName,num,optional[0]);
return ArrayOfObjects[n];
}
</code></pre>
| java | [1] |
1,645,069 | 1,645,070 | jQuery: is there a bug in how jQuery.ui.sortable ajax:update sends data? | <p>code: <a href="http://jsfiddle.net/WRppV/4/" rel="nofollow">http://jsfiddle.net/WRppV/4/</a></p>
<p>I should get something like</p>
<pre><code>"content"=>
["141", ["203", "206", "204", "205"],
"142", ["215", "207"]]
</code></pre>
<p>but i get </p>
<pre><code> Parameters: {"action"=>"sort_contents", "content"=>"207,215", "controller"=>"contents"}
</code></pre>
<p>Which are the last two values in the array.... I should be getting everything shouldn't I?</p>
| jquery | [5] |
3,225,073 | 3,225,074 | Tool for only combining JavaScript files, without compressing or uglyfying? | <p>I have a backbone app with over 50 small JavaScript files. Now I want to put all those in one single file, but it should still be readable, so:</p>
<p><strong>Is there a tool for combining JavaScript files without minifying or uglyfying them?</strong></p>
| javascript | [3] |
59,493 | 59,494 | what is the masterpage on this asp.net webformpage? | <p>I have a asp.net webformpage without a MasterPageFile property at the top but I have asp:content tags in there. I assume this page has a masterpage what is the masterpage in this case?</p>
| asp.net | [9] |
1,044,601 | 1,044,602 | Android Programming Tutorials: #6 | <p>I started working through the tutorials in Mark L Murphy's book "Android Programming Tutorials". In Tutorial #6, they are starting to work with tabs. I copied the code:</p>
<pre><code> TabHost.TabSpec spec=getTabHost().newTabSpec("tag1");
spec.setContent(R.id.restaurants);
spec.setIndicator("List", getResources()
.getDrawable(R.drawable.list));
getTabHost().addTab(spec);
spec=getTabHost().newTabSpec("tag2");
spec.setContent(R.id.details);
spec.setIndicator("Details", getResources()
.getDrawable(R.drawable.restaurant));
getTabHost().addTab(spec);
getTabHost().setCurrentTab(0);
</code></pre>
<p>into my application, and got syntax errors on "getTabHost".
I am using </p>
<pre><code>import android.app.Activity;
import android.app.ActivityGroup;
import android.app.TabActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
</code></pre>
<p>How do I clear the "The method getTabHost() is undefined for the type ListerApp" error? Am I missing an import?</p>
| android | [4] |
426,837 | 426,838 | Android: How to add listener to hardware menu button? | <p>I'm currently trying to add a click listener to the menu hardware button. Currently I'm just putting my onclick logic into the onCreatePanelMenu-method and return false. But that just feels wrong.</p>
<p>Is there a more clean way?</p>
<p>The code currently looks like that:</p>
<pre><code>@Override
public boolean onCreatePanelMenu(int featureId, Menu menu) {
Toast.makeText(this, "HALLO!", Toast.LENGTH_SHORT).show();
return false;
}
</code></pre>
| android | [4] |
1,646,770 | 1,646,771 | Question about implementing abstract functions in C++? | <p>I am learning and testing a piece of C++ code as follows:</p>
<pre><code>#include "stdafx.h"
#include <iostream>
using namespace std;
#include <conio.h>
#include <cstring>
class Shape {
public:
Shape() {};
~Shape() {};
virtual void display() const = 0;
virtual double volume() const = 0;
};
class Square : public Shape {
public:
Square() {};
~Square() {};
void display() const;
double volume() const;
};
void Square::display() const {
cout << "Square!!!!!!!!!!!!!!" << endl;
}
double Square::volume() const {
cout << "Square Volume........." << endl;
return 0.0;
}
int _tmain(int argc, _TCHAR* argv[])
{
Shape *s;
s = new Square; // error here
(*s).display();
return 0;
}
</code></pre>
<p>The above code does not compile successfully. it produces: "<strong>fatal error LNK1120: 1 unresolved externals</strong>".
Can anyone help me out with that?
I am using MS VS C++ 2005.
Thanks</p>
| c++ | [6] |
4,196,597 | 4,196,598 | How to tell php to create a directory and another directory inside that one | <p>How do I tell php to create a directory and then another directory inside that directory?</p>
<p>I'm using mkdir here. I have a folder called images. I need to create a folder inside images called 'user', then a folder under user called '15'. I can create the folder called user in one go. How can I do both together?</p>
| php | [2] |
2,445,155 | 2,445,156 | how to capture the clear event when clear button is pressed in notification bar in android | <p>HI,
in Android when the clear button is pressed on the notification screen i want to capture that in my application and do some stuff. please help me in how to achieve this.</p>
| android | [4] |
4,792,581 | 4,792,582 | Android onGestureListener and onTouchListner | <p>I am working in android. I have some functionality which is to be done on these following methods:-</p>
<pre><code>1. MotionEvent.ACTION_DOWN
2. MotionEvent.ACTION_UP
3. MotionEvent.ACTION_MOVE
</code></pre>
<p>and i also want to do <code>fling()</code> on that image.</p>
<p>For above requirement i implemented <code>onGestureListener</code> and <code>onTouchListener</code> in my application, but these are not working properly. <code>onTouchListener</code> is working but <code>onGestureListener</code> is not working. When i remove <code>onTouchListner</code> code then <code>onGestureListener</code> is working correctly.</p>
<p>So please suggest me what should i do for this. I want to implement these four methods in my application.</p>
<pre><code>1. MotionEvent.ACTION_DOWN
2. MotionEvent.ACTION_UP
3. MotionEvent.ACTION_MOVE
4. onFling
</code></pre>
| android | [4] |
3,984,500 | 3,984,501 | Am I using the webbrowser.open() wrong, or does it not work as advertised? (Python) | <p>Given this python code:</p>
<pre><code>import webbrowser
webbrowser.open("http://slashdot.org",new=0)
webbrowser.open("http://cnn.com",new=0)
</code></pre>
<p>I would expect a browser to open up, load the first website, then load the second website <em>in the same window</em>. However, it opens up in a new window (or new tab depending on which browser I'm using).</p>
<p>Tried on Mac OSX with Safari, Firefox and Chrome and on Ubuntue with Firefox. I'm inclined to believe that <em>new=0</em> isn't honored. Am I just missing something?</p>
<p>tia,</p>
| python | [7] |
2,737,685 | 2,737,686 | Linq to Entities: cannot be translated into a store expression | <p>I am trying to execute this query, but I am getting an error: cannot be translated into a store expression.</p>
<p>If I can't do it this way how can I implement it? I am using C#. </p>
<p>I am trying to display training records if the date taken is not this year. Any suggestion is highly appreciated. </p>
<pre><code>tr = from l in t.Trainees
where !db.UserTrainings.Any(ut => ut.Trainees.TraineeId == l.TraineeId &&
ut.Passed == true &&
ut.DateTaken >= l.DateEnded.Value.AddYears(-1))
...... rest of the query.
</code></pre>
| c# | [0] |
4,270,306 | 4,270,307 | A little php help with this string formatting | <p>I have a string in this format:</p>
<pre><code> /SV/temp_images/766321929_2.jpg
</code></pre>
<p>Is there any small piece of code to get the numbers BEFORE the underscore, BUT AFTER temp_images/? In this case I want to get <strong>766321929</strong> only... ?</p>
<p>Thanks</p>
| php | [2] |
4,567,344 | 4,567,345 | How to Create a class dynamically with its variables and methods in Java? | <p>How to Create a class dynamically with its variables and methods in Java without using Reflections.</p>
<p>I want that the class should be created at runtime with variables like age, name and method like display(String age,String name). </p>
| java | [1] |
881,061 | 881,062 | Detect if elements are removed jQuery | <p>Ok,</p>
<p>so I have:</p>
<pre><code><ul>
<li>hello</li>
<li>bye</li>
</ul>
</code></pre>
<p>Then:</p>
<pre><code>$('li').click(function(){
$(this).remove();
})
</code></pre>
<p>But then i have:</p>
<pre><code>if($('ul li').length == 0){
$('ul').append('<li>You haven\'t favourited anything. Get to it!</li>');
}
</code></pre>
<p>But it doesn't work!</p>
| jquery | [5] |
3,215,265 | 3,215,266 | How to pass a variable with in jquery to mysql | <p>I found this code for the infinite scroll pagination but there is one problem. I can pass a variable from this page going to democontent.php</p>
<p>Could anyone help me with this one? What I need to do is to pass an ID from this code to democontent.php I can't figure out what I have been doing wrong.</p>
<pre><code><script type="text/javascript">
$(function(){
$('#content').scrollPagination({
'contentPage': 'democontent.php', // the page where you are searching for results
'contentData': {}, // you can pass the children().size() to know where is the pagination
'scrollTarget': $(window), // who gonna scroll? in this example, the full window
'heightOffset': 10, // how many pixels before reaching end of the page would loading start? positives numbers only please
'beforeLoad': function(){ // before load, some function, maybe display a preloader div
$('#loading').fadeIn();
},
'afterLoad': function(elementsLoaded){ // after loading, some function to animate results and hide a preloader div
$('#loading').fadeOut();
var i = 0;
$(elementsLoaded).fadeInWithDelay();
if ($('#content').children().size() > 0){ // if more than 100 results loaded stop pagination (only for test)
$('#nomoreresults').fadeIn();
$('#content').stopScrollPagination();
}
}
});
// code for fade in element by element with delay
$.fn.fadeInWithDelay = function(){
var delay = 0;
return this.each(function(){
$(this).delay(delay).animate({opacity:1}, 200);
delay += 100;
});
};
});
</script>
</code></pre>
| jquery | [5] |
3,627,321 | 3,627,322 | Target membership affects images on 3.1.x device but not 4.x | <p>When deploying my project to a 3.1.x device I noticed that some images were missing.</p>
<p>They appear on a 4.x device just fine with the same executable.</p>
<p>I know the device is case sensitive and the code is using the correct filename.</p>
<p>What I noticed was the missing graphics were not included in my target. When I check the box to include them in my target and rebuilt they appear in 3.1.x</p>
<p>Any ideas why would the target setting only affect the 3.1.x device?</p>
<p>Is there a way to make sure my whole asset directory structure is included in the build target without manually setting each file in get info?</p>
| iphone | [8] |
4,305,849 | 4,305,850 | Adding the sum of three digits | <p>So I am writting a program that inputs a 3 # digit and breaks it apart. I am having trouble figuring out how to then add the separate digits altogether?</p>
<p>For example: The user inputs 345</p>
<p>My program will break the #'s apart to 3,4,5 but how do I then add those numbers together?</p>
<p>this is my code thus far, </p>
<pre><code>#set variable
val = raw_input("Type your three digit number please: ")
print 'The first digit is {}'.format(val[0])
print 'The second digit is {}'.format(val[1])
print 'The third digit is {}'.format(val[2])
#set variable
total = [val[0] +val [1] + val[2]]
total_value = total
print 'The sum of the three digits is' total_value
</code></pre>
| python | [7] |
2,080,155 | 2,080,156 | How to implement Reachability class | <p>I want to add the Reachability class to my app. I went through tutorials and examples available on net. But still they give errors. I followed this link. <a href="http://stackoverflow.com/questions/1083701/how-to-check-for-an-active-internet-connection-on-iphone-sdk">How to check for an active Internet Connection on iPhone SDK?</a></p>
<p>But I am getting error in this also. I want concrete solution on this.</p>
<p>If somebody can mention the good tutorial or example, I would highly appreciate it.</p>
<p>I want to know that,if network connection is broken in between the transferring, due to power failure (in case of wifi), or bad connection (in case of 3G), does this Reachability class have methods for that ?</p>
<p>Errors:</p>
<p>1)Use of undeclared identifier NotReachable.
2)Use of undeclared identifier ReachableViaWiFi.
3)Use of undeclared identifier ReachableViaWWAN.</p>
| iphone | [8] |
5,266,331 | 5,266,332 | PHP variables inside Xenforo template | <p>I'm trying to include a PHP file in XenForo template , I think my params are wrong but anyway , it just doesn't output if I put {$varhere}. Can anyone help? My code:
Class:
<a href="http://codepad.org/BaImQd1O" rel="nofollow">http://codepad.org/BaImQd1O</a>
Listener:
<a href="http://codepad.org/KrNxaN4z" rel="nofollow">http://codepad.org/KrNxaN4z</a>
My question is , what params I need to make it work in the template I need?</p>
| php | [2] |
4,809,322 | 4,809,323 | Is there a website to pay for code/hire programmers easily? | <p>I need to a piece of php code that goes beyond my abilities so I need to hire somebody to do it. It's not really something too long or complex so I wanted to know if there was a straightforward way to post my request and find somebody to do it for a certain amount. Does such a website exists or what's the best alternative? Anyway thanks a lot</p>
| php | [2] |
2,872,878 | 2,872,879 | How to combine an initial page loop function with a keyup function? | <p>I am using jQuery 1.6.2</p>
<p>When my page loads, I run a loop that finds input fields, calculates their needed size, and resizes them. Here's the function:</p>
<pre><code>// MINIMIZE TEXT FIELDS ON LOAD
$(":text").each(function() {
var MyString = $(this).val();
var MyMax = $(this).attr("maxlength");
var MySize = minimizeText(MyString, MyMax);
$(this).attr("size", MySize);
});
</code></pre>
<p>The loop accesses this function:</p>
<pre><code>var minimizeText = function minimizeText(MyString, MyMax) {
var MyLength = MyString.length;
var MySize = MyLength + 5;
if (MySize < MyMax && MySize < 50) {
return MySize;
} else if (MyMax > 50 ) {
return 50;
} else {
return MyMax;
}
}
</code></pre>
<p>If the user changes the text in the input field, the size is recalculated to fit the text in the field.</p>
<pre><code>// MINIMIZE TEXT FIELDS ON KEYUP
$(":text").keyup(function() {
var MyString = $(this).val();
var MyMax = $(this).attr("maxlength");
var MySize = minimizeText(MyString, MyMax);
$(this).attr("size", MySize);
});
</code></pre>
<p>Both of these work perfectly well. My goal here is to condense this code and still make it readable. My question is how can I combine these two so that the text field are checked on load as well as on keyup?</p>
| jquery | [5] |
650,597 | 650,598 | Converting Gregorian date to Hebrew in Python | <p>I am looking for a function or library that converts Gregorian dates into Hebrew one.
After searching, I found one <a href="https://sourceforge.net/projects/pythondateutil/" rel="nofollow">library</a> that let you convert from Gregorian to Julian and finally to Hebrew and vice verse, but discovered that it's not very accurate -- only the part that converts Gregorian to Julian is accurate.</p>
<p>Does anybody know where I can find such a function or library?</p>
| python | [7] |
3,523,240 | 3,523,241 | how to get latitude and longitude from the address in MKMapkit? | <p>I have implemented one application .In which i want to get latitude and longitude from the address.I dont want to use java script.Is it possble then please help me.</p>
| iphone | [8] |
5,195,692 | 5,195,693 | PHP traverse array with zero values | <p>I am using the following loop to traverse an array where i need both the value and the key field.</p>
<pre><code>while ($value = current($a)) {
echo "$value ".key($a).'<br />';
next($a);
}
</code></pre>
<p>The problem is that the traversal only takes place till a '0' is encountered in the array as the while statement says.Is there any way i can traverse array with zero values(size of array varies) and get both value and key.</p>
| php | [2] |
3,067,591 | 3,067,592 | integrating barcode scanner into php application? | <p>We have been developing web application in php.<br>
We need barcode scanner to be integrated into our application.</p>
<p>Our application is divided into two modules, users and merchant.</p>
<p>When user comes and scans the card, merchant should be identified the user by barcode number. Admin will give barcode number and that is being sent to the card manufacturer and the number will be assigned to the magnetic stripe.</p>
<p>As i know scanner can acts as a key board, can you please tell the method to integrate barcode scanner into this php web based application?</p>
| php | [2] |
4,872,289 | 4,872,290 | IndexOf does not correctly identify if a line starts with a value | <p>How can I remove a whole line from a text file if the first word matches to a variable I have?</p>
<p>What I'm currently trying is:</p>
<pre><code>List<string> lineList = File.ReadAllLines(dir + "textFile.txt").ToList();
lineList = lineList.Where(x => x.IndexOf(user) <= 0).ToList();
File.WriteAllLines(dir + "textFile.txt", lineList.ToArray());
</code></pre>
<p>But I can't get it to remove.</p>
| c# | [0] |
5,769,860 | 5,769,861 | GCM registration id returns empty after successfully registered | <p>I am getting an empty string for regID after the device registered with GCM server successfully.. I am getting a full regID from my GCMIntentService class after some delay. I just need it in my activity.. Can any one help me out .. Thanks .. here is the code to register my device</p>
<pre><code> private void registerDevice() {
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
if (GCMRegistrar.isRegistered(this)) {
Log.d("info", GCMRegistrar.getRegistrationId(this));
}
regID = GCMRegistrar.getRegistrationId(this);
if (regID.equals("")) {
GCMRegistrar.register(this, APIConfig.SENDER_ID);
regID = GCMRegistrar.getRegistrationId(this);
} else {
Log.d("info", "already registered as" + regID);
}
}
</code></pre>
| android | [4] |
569,342 | 569,343 | Javascript number format to number | <p>I need to remove the number formatting of integers.</p>
<p>//French
1 925 => 1925</p>
<p>1.925 => 1925</p>
<p>1,925 => 1925</p>
<p>So, it's basically about removing the thousend separator. Numbers are only integers... no decimals.</p>
| javascript | [3] |
3,420,573 | 3,420,574 | Capturing file output in PHP (fputcsv) | <p>I'm attempting to capture the output of <code>fputcsv()</code> in order to use <code>gzwrite()</code> to actually write to a tab-delimited file. Basically, I'm querying a database and I want to put these rows into a gzipped CSV file and I'd rather use <code>fputcsv()</code> than actually append <code>"\t"</code> and <code>"\n"</code> everywhere. Can I somehow do this with output buffering or something similar?</p>
<p>Here's the basic outline of what I have:</p>
<pre><code>$results = get_data_from_db();
$fp = gzopen($file_name, 'w');
if($fp) {
foreach ($results as $row) {
???//something with gzwrite() ?
}
gzclose($fp);
}
</code></pre>
<p>Thanks!</p>
<p>EDIT: My understanding was that <code>gzwrite()</code> needs to be used to actually write to the file in order for it to actually be gzipped - is this not correct?</p>
| php | [2] |
1,002,464 | 1,002,465 | Delete a line containing string in text file using php | <pre><code><?php
$myFile = "myfile.txt";
$fh = fopen($myFile, 'rt');
$theData = fread($fh, filesize($myFile));
$aDoor = $_GET['idno'];
echo $aDoor;
$theData = preg_replace('/\n?.*$aDoor.*$/m', '', $theData);
fwrite($fh, $theData);
fclose($fh);
echo $theData;
?>
</code></pre>
<p>preg_replace('/\n?.<em>SOMETEXT.</em>$/m', '', $theData); it is working </p>
<p>Now how to use $aDoor string</p>
| php | [2] |
3,005,791 | 3,005,792 | looping lists in java | <p>I have a simple java statement along the lines of:</p>
<pre><code> String[] ykl = yklList.get(0).split(" ");
</code></pre>
<p>where, yklList is an ArrayList containing sentences which are split into words. The above works fine.</p>
<p>When I now try and loop this:</p>
<pre><code>Loop:1
for (int i=0;i<=4;i++)
{
String[] ykl = yklList.get(i).split(" ");
}
</code></pre>
<p>It does not seem to work and throws me a compile error. Is the above loop wrong?</p>
<p>I have another for loop after the above:</p>
<pre><code>Loop:2
for (String ykl : yklList)
{
//do something
}
</code></pre>
<p>It throws me a compile error here saying:</p>
<pre><code>cannot find symbol
symbol : variable ykl
location: class test
for (String ykl : yklList)
</code></pre>
<p>Presumably Loop 1 went wrong somewhere?</p>
<p><strong>Edit:</strong></p>
<p>The "full" code looks something like this:</p>
<pre><code>for (int i=0;i<=yklList.size()-1;i++)
{
String[] ykl = yklList.get(i).split(" ");
}
for (String y : ykl)
{
t.add(y);
}
</code></pre>
<p>and the error is:</p>
<pre><code>cannot find symbol
symbol : variable ykl
location: class test
for (String y : ykl)
</code></pre>
| java | [1] |
5,629,827 | 5,629,828 | pointers to derived members of the class | <p>if I have for example some class <code>Base</code> and derived from it <code>Derived</code>
Also I have some list of shared pointers:</p>
<pre><code>list<shared_ptr<Base> > list
</code></pre>
<p>I create shared pointer:</p>
<pre><code>line 5 shared_ptr<Derived> ptr(new Derived(//some constructor));
</code></pre>
<p>my question is, can I do something like this:</p>
<pre><code>list.push_back(ptr);
</code></pre>
<p>if Yes, can somebody explain why can I recieve an error (I receive this on the line 5)</p>
<pre><code>no matching function for call to //here It writes me my constructor to Derived
</code></pre>
<p>thanks in advance for any help</p>
| c++ | [6] |
3,093,084 | 3,093,085 | Is it better allow a function to throw or throw in the constructor? | <p>I think, it is easier explain using an example. Let's take a class that model the speed of a Formula 1 car, the interface may look something like:</p>
<pre><code>class SpeedF1
{
public:
explicit SpeedF1(double speed);
double getSpeed() const;
void setSpeed(double newSpeed);
//other stuff as unit
private:
double speed_;
};
</code></pre>
<p>Now, negative speed are not meaningful in this particular case and neither value greater then 500 km/h. In this case the constructor and the setSpeed function may throw exceptions if the value provide is not within a logical range.</p>
<p>I can introduce an extra layer of abstraction and insert a extra object instead of double.
The new object will be a wrapper around the double and it will be construct and never modify.
The interface of the class will be changed to:</p>
<pre><code>class ReasonableSpeed
{
public:
explicit ReasonableSpeed(double speed); //may throw a logic error
double getSpeed() const;
//no setter are provide
private:
double speed_;
};
class SpeedF1
{
public:
explicit SpeedF1(const ReasonableSpeed& speed);
ReasonableSpeed getSpeed() const;
void setSpeed(const ReasonableSpeed& newSpeed);
//other stuff as unit
private:
ReasonableSpeed speed_;
};
</code></pre>
<p>With this design SpeedF1 cannot throw, however I need to extra pay an object constructor every time I want to reset the speed.</p>
<p>For class where a limited set of value are reasonable (for example the Months in a calendar) I usually make the constructor private and provide a complete set of static functions. In this case it is impossible, another possibility is implement a null object pattern but I am not sure it is superior to simply throw an exception.</p>
<p>Finally, my question is:</p>
<p>What is the best practise to solve this kind of problem?</p>
| c++ | [6] |
3,716,776 | 3,716,777 | Java server / web client | <p>I would like to create a java desktop application (server) with a swing client , in the mean time , i also want to have a web client , that could not be java EE based , but php , or even simple html/jquery .</p>
<p>I want my server app to be desktop , to be able to make push notification to the swing client every time , a web client , interact with the desktop server . </p>
<p>is such a thing possible , if yes , where do i start for the desktop server / web client communication , any tutorial ? </p>
| java | [1] |
1,303,833 | 1,303,834 | how to add cursor type on a table row using javascript? | <pre><code> var tbl = document.getElementById(TABLE_NAME);
var nextRow = tbl.tBodies[0].rows.length;
row.setAttribute('style', "cursor: pointer;");
</code></pre>
<p>This will add double click event on table row.right..!!!But i m facing problem in internet explorer.working perfect in all other browsers.
For adding style i am handling this:</p>
<pre><code>var cell2 = row.insertCell(1);
var browser=navigator.appName; if(browser == "Microsoft Internet Explorer")
{
cell2.style.setAttribute("cssText", "color:black; width:300px;");
}
else
{
cell2.setAttribute("style", "color:black; width:300px;");
}
</code></pre>
<p>how to add double click event which will work on internet explorer too...</p>
| javascript | [3] |
1,034,077 | 1,034,078 | How can I know all the tuesdays of a given month? | <p>For instance in Sept I would need: </p>
<p>1,8,15,22 and 29</p>
<p>Thanks</p>
| java | [1] |
5,751,931 | 5,751,932 | multiple jquery animations | <p>I have 3 divs on my page that Im trying to give an appearance of expanding out using the jquery .animate width function. The thing is I dont want them all to expand at the same time but I also dont want them to only start when the one before it has finished. Im kinda needing them to start a few miliseconds after the previous once has started so there just slightly out of sync, if that makes sense?</p>
| jquery | [5] |
5,900,426 | 5,900,427 | Input Method without a view | <p>I have a service that gets Unicode characters over WiFi, which should be entered to a EditText in which the cursor is currently positioned (sort of a remote desktop)</p>
<p>I'm trying to figure out what will be the best way to input text to EditText views (and similar view) without showing a keyboard layout on the screen.</p>
<p>Is the IME the right direction? or is there a way to inject a keypress (Unicode char) to the system?</p>
<p>Thanks!</p>
| android | [4] |
4,849,581 | 4,849,582 | How to change the title of the Tab Dynamically | <p>I have three tabs in my Application. On an event under one Tab, i want to change the title of an another existing Tab. This is the title that we provide while adding the tabs to the TabHost. </p>
<p>Eg: TabHost.addTab(tabHost.newTabSpec("Tab2")).setIndicator("I need to be Changed dynamically").setContent....</p>
<p>In the above example, the title of the tab2 that i provided under setIndicator(), should be changed dynamically.</p>
<p>Is there any way to accomplish this.</p>
| android | [4] |
1,316,956 | 1,316,957 | PHP MYSQL update with hash variables | <p>I need some help understanding the correct way to mix variables with strings like this. I have tried every configuration I can think of and I keep getting an error.</p>
<pre><code><?php
include('connect.php');
foreach($_GET['item'] as $key=>$value) {
mysql_query("UPDATE userprojectlist SET category_display_order = '$key' WHERE category_id = '$value' ");
}
?>
Notice: Undefined index: item in updatedb.php on line 3
Warning: Invalid argument supplied for foreach() in pdatedb.php on line 3
</code></pre>
| php | [2] |
2,228,168 | 2,228,169 | Where can I find Android's new features | <p>Android has so many features such as PUSH NOTIFICATIONS.... </p>
<p>Can anyone point me at the place where the new and updated features are documented. I am new to android and want to know about new features in order to improve my programming skills.</p>
<p>Thanks in advance....</p>
| android | [4] |
674,908 | 674,909 | android and multiple running of the same application | <p>I write application on android which will be runnig all the time on background. There will be only one starting view on first run. I want to user run instance of my app only once, and cant run any other instance at the time. When he try to run this app when one instance of this app is running already he sould see some warning notification. My problem is I dont know how to prevent user from multiple start of my app. Is this possible? If it is possible, how can I do it? Thanks for any help.</p>
| android | [4] |
4,951,365 | 4,951,366 | How to deal with the Music Time? | <pre><code>Cursor mCursor = this.getContentResolver().query( MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
long mTime = mCursor.getLong( mCursor .getColumnIndex(MediaStore.Audio.AudioColumns.DURATION));.getColumnIndex(MediaStore.Audio.AudioColumns.DURATION));
</code></pre>
<p>Enter code here I want to <code>mTime</code> change to 00:00 model; How to do ??? Who can help me ?? </p>
| android | [4] |
1,914,164 | 1,914,165 | Javascript error in syntax? | <p>I've been trying to write a function that makes all links execute a function on click, but I have NO idea why this isn't working:</p>
<pre><code>function interceptLinks() {
var ls = document.links, numLinks = ls.length
for (i=0; i<numLinks; i++) {
if ls[i].onclick {
//Don't do anything, cause there's already code there!
}
else {
ls[i].onclick = "reloadInfo();";
}
}
}
</code></pre>
<p>It just throws a "interceptLinks is not defined" error when I run the function.</p>
| javascript | [3] |
946,088 | 946,089 | how can we know iphone has got information from Internet? | <p>i want to display activity indicator when i search from the internet.but how can
i know the iphone has got response from the internet to stop animating activity indicator?
is there any method?</p>
| iphone | [8] |
2,774,004 | 2,774,005 | How to get location name in Android using Lattitude and Longitude | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/9409195/how-to-get-complete-address-from-latitude-and-longitude">How to get complete address from latitude and longitude?</a> </p>
</blockquote>
<p>How to get location name in Android using Lattitude and Longitude till the City Name and street name</p>
| android | [4] |
31,000 | 31,001 | "SD Card" permission appears on 2.0 devices? | <p>I wrote an Android application. These are the permissions I requested:</p>
<ul>
<li>INTERNET</li>
<li>ACCESS-COARSE-LOCATION</li>
<li>ACCESS-FINE-LOCATION</li>
<li>ACCESS-NETWORK-STATE</li>
<li>CHANGE-NETWORK-STATE</li>
</ul>
<p>On 1.5 devices, it looks fine. I tried on a 2.0 device, and it also shows an additional permission when installing the app:</p>
<ul>
<li>SD CARD READ / WRITE</li>
</ul>
<p>Is that just coming up by default now on any 2.0 device we install apps on? I do use <code>Context.openFileOutput()</code> to write a file to disk, but only to the app sandbox location, never to SD card.</p>
<p>Thanks</p>
| android | [4] |
3,285,023 | 3,285,024 | Missing .dll files c++ | <p>I am coding in c++ visual studios express 2010 and have been creating a program. I thought it would run fine, but when other people try to run it, they just get missing .dll error. I know that I probably am not obtaining the .exe correctly, but I don't know what to do. </p>
<p>Can someone tell me how to compile CLR console applications so that they include these libraries?</p>
<p>The .dll file is MSVCR100D.dll and I don't know if there are more of them.</p>
<p>Thanks :)</p>
| c++ | [6] |
699,300 | 699,301 | org.apache.commons.net.ftp.FTPClient.storeFile freezing interaction and animations | <p>I'm using org.apache.commons.net.ftp.FTPClient to communicate with an ftp server via an android app I'm making that records video and then uploads it to the ftp server. Everything is fine until I call storeFile at which point the app prevents any interaction until the uploading is completed. Is there any way around this? I'm currently developing for API lvl 12.
My set up is as follows I have a class that calls a service in the background to handle recording of the video as well as the ftp setup. In the FTP class I have any of my fptclient interaction within asynctasks. Here is my method for uploading the file:</p>
<pre><code>public boolean upload(String srcFilePath, String desFileName, String desDirectory)
{
if(!isLoggedIn())
{
return false;
}
boolean status = false;
try
{
status = new AsyncTask<String, Void, Boolean>(){
@Override
protected Boolean doInBackground(String... args) {
boolean status = false;
try {
String srcFilePath = args[0];
String desFileName = args[1];
String desDirectory = args[2];
FileInputStream srcFileStream = new FileInputStream(srcFilePath);
// change working directory to the destination directory
if (changeDirectory(desDirectory,true)) {
status = mFTPClient.storeFile(desFileName, srcFileStream);
}
srcFileStream.close();
return status;
} catch (Exception e) {
Log.d(TAG, "upload failed");
e.printStackTrace();
return false;
}
}
}.execute(srcFilePath, desFileName, desDirectory).get();
} catch (InterruptedException e)
{
e.printStackTrace();
return status;
} catch (ExecutionException e)
{
e.printStackTrace();
return status;
}
return status;
}
</code></pre>
<p>Any help would be immensely appreciated!</p>
<p>Devunwired's post worked! Hoorah!</p>
| android | [4] |
5,166,901 | 5,166,902 | Sum of the maximum downsequence number in an array | <p>Given this array</p>
<pre><code>int [] myArray = {5,-11,2,3,14,5,-14,2};
</code></pre>
<p>You are to find the maximum sum of the values in any downsequence in an unsorted array of integers. If the array is of length zero then maxSeqValue must return Integer.MIN_VALUE.</p>
<p>You should print the number, 19 because the downsequence with the maximum sum is 14,5.
Downsequence number is a series of non-increasing number.</p>
<p>These are the codes that i used but i guess that there are some cases which is still not accounted for.
Any ideas, thanks in advance.</p>
<pre><code>public class MaxDownSequence{
public int maxSeqValue(int[] a){
int sum=Integer.MIN_VALUE;
int maxsum=Integer.MIN_VALUE;
for (int i=1;i<a.length;i++){
if(a[i]<a[i-1]){
sum = a[i] + a[i-1];
if (sum>maxsum){
maxsum=sum;
}
}
else {
sum=a[i];
if (sum>maxsum){
maxsum=sum;
}
}
}
if (a.length==0){
return Integer.MIN_VALUE;
}
else{
return maxsum;
}
}
public static void main(String args[]){
MaxDownSequence mySeq = new MaxDownSequence();
int [] myArray = {5,-11,2,3,14,5,-14,2};
System.out.println(mySeq.maxSeqValue(myArray));
}
</code></pre>
<p>}</p>
| java | [1] |
514,016 | 514,017 | how can i make a function see a variable outside it | <p>How can I place a variable inside a function when it is run in order to preg_match the right information. Here is my existing code:</p>
<pre><code>$username = "test";
function is_txt($file) {
return preg_match('/backup-[0-9]+\.[0-9]+\.[0-9]+_[0-9]{2}-[0-9]{2}-[0-9]{2}_'.$username.'.tar.gz/', $file) > 0;
}
</code></pre>
<p>What I am attempting to do is pull the $username variable from outside the function and allow it to be seen within it so I can pull the right matches in my while loop. While the previous comes back blank, if i do the following it works:</p>
<pre><code>$username = "test";
function is_txt($file) {
$username = "test";
return preg_match('/backup-[0-9]+\.[0-9]+\.[0-9]+_[0-9]{2}-[0-9]{2}-[0-9]{2}_'.$username.'.tar.gz/', $file) > 0;
}
</code></pre>
| php | [2] |
1,017,334 | 1,017,335 | Commutative oprator overloading + of 2 different objects | <p>Hi<br>
I have 2 classes which represent a matrix:<br>
1. RegularMatrix - O(n^2) representation<br>
2. SparseMatrix - a matrix that is represented as linked list (without zeros).</p>
<p>lets say i have:</p>
<pre><code>RegularMatrix a;
SparseMatrix b;
</code></pre>
<p>i want to be able to do:</p>
<pre><code>a+b;
</code></pre>
<p>and also: </p>
<pre><code>b+a;
</code></pre>
<p>so i'm overloading the + operator. My question is, since I want the addition to be commutative (a+b = b+a), do i need to implement 2 overloadings, one for each case?</p>
<pre><code>RegularMatrix operator+(const RegualarMatrix &, const SparseMatrix &);
RegularMatrix operator+(const SparseMatrix & ,const RegualarMatrix &);
</code></pre>
<p>or is there a general form which the compiler decides by itself?</p>
<p>Thank you</p>
| c++ | [6] |
953,911 | 953,912 | Redirect after PHP Login | <p>I have a subdomain </p>
<p>accounts.mysite.com </p>
<p>What i want is one login panel for that subdomain, then after a user logs in it directs them to their own page (and stops them from viewing 'other account' pages). </p>
<p>So when they go to accounts.mysite.com that is the login page. User logs in using specific name, pass. After successful login directed to their accounts page but blocks all other pages. </p>
<p>Here is what I have so far </p>
<pre><code><?php
ob_start();
$host="localhost"; // Host name
$username="******"; // Mysql username
$password="*******"; // Mysql password
$db_name="medpro_test"; // Database name
$tbl_name="members"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Define $myusername and $mypassword
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file
session_register("myusername");
session_register("mypassword");
header('Location: user.php?id=' . $_SESSION['user_id']);
}
else {
$result = MYSQL_QUERY($sql) or die('Query failed: ' . mysql_error() . "<br />\n$sql");
echo "Wrong Username or Password";
}
ob_end_flush();
?>
</code></pre>
<p>I am a noob so any help would be appreciated!</p>
| php | [2] |
2,813,773 | 2,813,774 | Add drop shadow to slide out navigation | <p>I have implemented slide out navigation using <a href="https://github.com/gitgrimbo/android-sliding-menu-demo" rel="nofollow">this</a>. <img src="http://i.stack.imgur.com/zAgEh.png" alt="current implementation"></p>
<p>The content should drop shadow near menu list's right edge; like <img src="http://i.stack.imgur.com/mK76B.png" alt="expected result"> </p>
<p>I'm trying to add shadow by adding a view to content left edge, but it wont show up.</p>
<p>Any clue on how to do this will be appreciated.</p>
| android | [4] |
1,951,840 | 1,951,841 | Crash while trying to concatenate two strings | <pre><code>#include<iostream>
using namespace std;
char *concat(char *string1,char *string2)
{
char *stringfinal=new char[strlen(string1)+strlen(string2)+2];
stringfinal=string1;
char *dest=new char[strlen(string1)+strlen(string2)+2];
dest = stringfinal;
while(*dest != '\0')
{
dest++;
}
*dest=' '; // Point 1
while(*string2 != '\0')
*dest++=*string2++; //Point2
*dest='\0';
return stringfinal;
}
int main()
{
char *str1="Anurag";
char *str2="Jain";
char *strfinal = new char[strlen(str1)+strlen(str2)+2];
strfinal=concat(str1,str2);
cout<<strfinal;
cin.get();
}
</code></pre>
| c++ | [6] |
4,746,267 | 4,746,268 | Background Image Rotator | <p>I need some suggestions and ideas to improve a background image rotator.</p>
<p>The script as of now is very basic but I'm looking to change 2 thing.</p>
<ol>
<li>I want the images to fade into each other.</li>
<li>I need to be able to preload the images so it doesn't have the delay when loading them when they first display.</li>
</ol>
<p>Thoughts?</p>
<pre><code><script type="text/javascript">
var images = ['bg1.png', 'bg2.png', 'bg3.png'];
var curImage = 0;
function switchImage()
{
curImage = (curImage + 1) % images.length
document.body.style.backgroundImage = 'url(images/' + images[curImage] + ')'
}
window.setInterval(switchImage, 5000);
</script>
</code></pre>
<p>Example: <a href="http://www.nickersonweb.com/demo/PMS/index.html" rel="nofollow">http://www.nickersonweb.com/demo/PMS/index.html</a></p>
| javascript | [3] |
125,220 | 125,221 | Fancybox stoping other jquery animation on run | <p>Fancy box stops the jquery animation when starting .
I have this js script :</p>
<pre><code> $("a[class=fancybox]").fancybox({
'hideOnContentClick': true,
'titlePosition' : 'outside',
'overlayColor' : '#3d6a87',
'overlayOpacity' : 0.9
});
$('.portfoliobox').live('mouseenter', function(e) {
$(this).closest('.portfoliobox').find('div.portfoliodetails').animate({marginLeft: '0', opacity: 0.8}, 200);
});
$('.portfoliobox').live('mouseleave', function(e) {
var $widthofdiv = $(this).closest('.portfoliobox').find('.portfoliodetails').width();
$(this).closest('.portfoliobox').find('div.portfoliodetails').animate({marginLeft: $widthofdiv}, 200);
// alert($widthofdiv);
});
</code></pre>
<p>when I click a FANCYBOX link located inside DIV .portfoliodetails the animation on mouseleave stops and remains frozen .</p>
<p>Any idea what to do ?
from what I understand I need to make jQuery run the mouseleave animation.. but how ?</p>
| jquery | [5] |
3,592,396 | 3,592,397 | enforce a no spacebar when filling up input form | <p>I have an input form for username, but I wish to not let the user to add space OR press spacebar when adding a username, how to do that in jquery, I mean, how to add such validation in my current code ?</p>
<pre><code> if(document.getElementById("cvusername")!== null && (cvusername == "" || cvusername.length < 5 || cvusername.length > 30)){
alert("-username is required\n-should not be less than 5 characters\n and not greater than 30 characters");
return false;
}
</code></pre>
| jquery | [5] |
376,662 | 376,663 | Short if this else that in PHP? | <p>I was searching for some shorthand if/else code, but unlike <code>$var ? $a : $b</code> it doesn't need an 'else'-like returned value. What I want would be basically this, but shorter:</p>
<pre><code>$myVariable = "abc";
echo $myVariable ? $myVariable : "hello";
echo $myVariable ? "hello" : $myVariable;
</code></pre>
<p>I'm kind of used to do such a thing in Lua, which goes like:</p>
<pre class="lang-lua prettyprint-override"><code>local myVariable = "abc"
-- In case myVariable is false, print "hello". Otherwise it prints "abc"
print ( myVariable or "hello" )
-- In case myVariable does have something (So, true) print "goodday."
print ( myVariable and "goodday" )
</code></pre>
<p>So I wondered, does PHP have the functionality to do such a thing?
Thanks.</p>
| php | [2] |
4,895,711 | 4,895,712 | C# inheritence and static classes | <p>Why can't a static class be inherited into a normal class?</p>
| c# | [0] |
5,242,908 | 5,242,909 | Notification FLAG_ONLY_ALERT_ONCE not working on 2.1 | <p>I'm trying to create a notification when an alarm fires. No problem so far.
A notification is shown. The problem is on my device (2.1 Update 1) it is displayed as an ongoing notification. While on another device (2.2) it is working fine and is actually shown as a one time only notification. Has anyone experienced this behaviour, and more important has anyone been able to fix it. It seems like 2.1 is not respecting the <code>FLAG_ONLY_ALERT_ONCE</code> or any flags for that mather. See my code below. Any help would be appreciated.</p>
<pre><code>public class AlarmHandler extends BroadcastReceiver {
NotificationManager nm;
@Override
public void onReceive(Context context, Intent intent) {
Debug.log("Alarm notification received");
nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence from = intent.getStringExtra("AlarmType");
CharSequence message = intent.getStringExtra("AlarmType");
Intent newIntent = new Intent(context, Splashscreen.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, intent.getIntExtra("RequestCode", 0),
newIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
Notification notif = new Notification(R.drawable.icon,
null, System.currentTimeMillis());
notif.setLatestEventInfo(context, from, message, contentIntent);
notif.flags |= Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_AUTO_CANCEL;
Debug.log("flags: "+notif.flags);
Debug.log("Defaults: "+notif.flags);
nm.notify(intent.getIntExtra("RequestCode", 0), notif);
}
}
</code></pre>
| android | [4] |
701,540 | 701,541 | pass an expression to a javascript function | <p>I have the following code from a javascript book and the callback seems to be passed an expression as an argument. Is that the case or am I seeing this wrong? I didnt know, even though it works, that that was possible.</p>
<pre><code>function multiplybytwo(a,b,c,callback) {
var i, ar =[];
for(i=0;i<3;i++)
{
ar[i] = callback(arguments[i]*2);
}
return ar;
}
function addone(a) {
return a+1;
}
myarr =multiplybytwo(1,2,3,addone);
</code></pre>
| javascript | [3] |
4,533,918 | 4,533,919 | In python, how can I count the times a condition is met within a function? | <p>I am very new to programming in general, and while I'm sure this looks like homework, it likely is for somebody, but I'm teaching myself, so it's "self-homework"?</p>
<p>Anyway, I want to count the number of times a turtle leaves the window as it randomly makes squares. I also wanted to put a dot down at every point it exits the screen, but that's just for my own fun.</p>
<p>I know I am setting outs to 0 every time through, but I can't figure out how to create an accumulator pattern (if that's the right thing to do) within a function like this that already has to return a value.</p>
<p>Here's my code:</p>
<pre><code>import random
import turtle
def isInScreen(w,t):
leftBound = - w.window_width()/2
rightBound = w.window_width()/2
topBound = w.window_height()/2
bottomBound = -w.window_height()/2
turtleX = t.xcor()
turtleY = t.ycor()
stillIn = True
outs = 0
if turtleX > rightBound or turtleX < leftBound:
t.dot()
t.right(180)
t.forward(50)
outs += 1
print(outs)
return outs
if turtleY > topBound or turtleY < bottomBound:
t.dot()
t.right(180)
t.forward(50)
outs += 1
print(outs)
return outs
if outs == 4:
stillIn = False
return stillIn
t = turtle.Turtle()
wn = turtle.Screen()
t.shape('turtle')
while isInScreen(wn,t):
coin = random.randrange(0,2)
if coin == 0:
t.left(90)
else:
t.right(90)
t.forward(50)
wn.exitonclick()
</code></pre>
<p>Any advice would be appreciated.</p>
| python | [7] |
371,910 | 371,911 | If I have the contents of a zipfile in a Python string, can I decompress it without writing it to a file? | <p>I've written some Python code that fetches a zip file from the web and into a string:</p>
<pre><code>In [1]: zip_contents[0:5]
Out[1]: 'PK\x03\x04\x14'
</code></pre>
<p>I see there's a zipfile library, but I'm having trouble finding a function in it that I can just pass a bunch of raw zip data. It seems to want to read it from a file.</p>
<p>Do I really need to dump this to a temp file, or is there a way around it?</p>
| python | [7] |
1,887,444 | 1,887,445 | Transform Dictionary-Like Input to a Dictionary | <p>How do I transform a dictionary input to a real dictionary that I can process?</p>
<p>When I execute an external command, this is what I get.</p>
<pre><code>{'aaa': {'test_a': 0.11666666666667,
'test_b': 1,
'total_c': 0.11666666666667},
'bbb': {'test_a': 32.883333333332999,
'test_b': 1,
'total_c': 0.11666666666667},
'ccc': {'test_a': 11, 'test_b': 31, 'test'_c': 33}}
</code></pre>
<p>So, as you can see, the above is already a dictionary-format already. I was just thinking of doing something like.</p>
<pre><code> #!/usr/bin/python
import command
result = commands.getoutput('<execute_external_command')
</code></pre>
<p>So that 'result' becomes a dictionary and I can just process it like any dictionary.</p>
| python | [7] |
2,310,823 | 2,310,824 | How to play audio songs one after other which is placed in resources folder in iphone | <p>I am new to iphone.I am working on audio player here i am struck in the middle because i am facing some issue that is here in my project i have 2 directories in resource folder.In each directory i have 6mp3 audio files.So my issue is when user gives the path to the 3rd mp3 song in first directory in resources folder from that we have to play continuous all the songs like 4th,5th,6th mp3files also which is placed in that directory in resources folder.here is my code for this</p>
<pre><code> NSString *chapterString =@"3";
NSString *string = [[NSBundle mainBundle]pathForResource:chapterString ofType:@"mp3" inDirectory:@"raj"];
NSLog(@"string is %@",string);
url = [NSURL fileURLWithPath:string isDirectory:YES];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];
</code></pre>
<p>If any body know this please help me..</p>
| iphone | [8] |
336,814 | 336,815 | Solitaire python | <p>I have a code here for moving the card from the deck to the foundation pile.. I've imported the necessary details, etc. My problem is its too long. Is there any way to make it shorter?? How? Thanks :)</p>
<pre><code>def dtof():
suit = raw_input("enter suit: ")
v = trash.pop()
if suit == "D":
if card.suitNumber[v.suit] == 1:
if card.rankNumber[v.rank] == 0:
Diamond.append(v)
elif card.rankNumber[v.rank] == card.rankNumber[Diamond[-1].rank] + 1:
Diamond.append(v)
else:
trash.append(v)
return Diamond[-1]
else:
trash.append(v)
elif suit == "H":
if card.suitNumber[v.suit] == 2:
if card.rankNumber[v.rank] == 0:
Heart.append(v)
elif card.rankNumber[v.rank] == card.rankNumber[Heart[-1].rank] + 1:
Heart.append(v)
else:
trash.append(v)
return Heart[-1]
else:
trash.append(v)
elif suit == "C":
if card.suitNumber[v.suit] == 4:
if card.rankNumber[v.rank] == 0:
Clubs.append(v)
elif card.rankNumber[v.rank] == card.rankNumber[Clubs[-1].rank] + 1:
Clubs.append(v)
else:
trash.append(v)
return Clubs[-1]
else:
trash.append(v)
elif suit == "S":
if card.suitNumber[v.suit] == 3:
if card.rankNumber[v.rank] == 0:
Spade.append(v)
elif card.rankNumber[v.rank] == card.rankNumber[Spade[-1].rank] + 1:
Spade.append(v)
else:
trash.append(v)
return Spade[-1]
else:
trash.append(v)
else:
trash.append(v)
</code></pre>
| python | [7] |
4,766,114 | 4,766,115 | Detecting blog or forum software using python? | <p>Is there a way beside checking for known signatures in the site content to find out what kind of software is the website running e.g vbbuliten,WP etc, preferably python.</p>
| python | [7] |
4,260,354 | 4,260,355 | Jquery Toggle Text, Selecting all instances | <p>So the problem I'm having is I have this Div "Reply" and inside of it is an h1 tag with the word Hide in it. The word Hide is wrapped in a span tag with the class of "Toggle" I have Jquery code which basically says everytime you click on the Div it will toggle the hide text in the span tag to show and of course if you click again it will revert back to normal, The problem I have is that I have multiple instances of these classes and its changing the text for the other ones. I wonder if there is a way in jquery to only toggle the specific one im clicking on while keeping all my other classes the same (because I need to reuse them a lot).</p>
<p>Jquery </p>
<pre><code> $('.Reply').toggle (
function() { $("span.Toggle").html("Show");}
,function() { $("span.Toggle").html("Hide");}
);
</code></pre>
<p>HTML</p>
<pre><code><div class="Reply">
<h1><span class="Toggle">Hide</span> This Text</h1>
</div>
<div class="Reply">
<h1><span class="Toggle">Hide</span> This Text</h1>
</div>
</code></pre>
| jquery | [5] |
3,900,270 | 3,900,271 | Need help in refactoring my python script | <p>I have a python script which process a file line by line, if the line
matches a regex, it calls a function to handle it.</p>
<p>My question is is there a better write to refactor my script. The
script works, but as it is, i need to keep indent to the right of the
editor as I add more and more regex for my file.</p>
<p>Thank you for any idea.
Now my code end up like this:</p>
<pre>
for line in fi.readlines():
result= reg1.match(line)
if result:
handleReg1(result)
else:
result = reg2.match(line)
if result:
handleReg2(result)
else:
result = reg3.match(line)
if result:
handleReg3(result)
else:
result = reg4.match(line)
if result:
handleReg4(result)
else:
result = reg5.match(line)
if result:
handleReg5(result)
</pre>
| python | [7] |
1,406,800 | 1,406,801 | gridview asp.net | <p>I've gridview which was working fine with a small dataset in development.But in production it has to bind to thousands of records which is making it slower to load.is there a way to improve performance.Like retriving the data during gridview pageindex changing</p>
<p>Regards,
Ravi </p>
| asp.net | [9] |
1,244,993 | 1,244,994 | Google play Does not search my app do any optimisation needed | <p>Google play Does not search my app do any optimisation needed.
My app name is Xmas Catch and package name is com.xmascatch
when i search by xmascatch it searchs well but when i search by Xmas Catch it doesnt show my app
Help me please....</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.