Unnamed: 0
int64 65
6.03M
| Id
int64 66
6.03M
| Title
stringlengths 10
191
| input
stringlengths 23
4.18k
| output
stringclasses 10
values | Tag_Number
stringclasses 10
values |
---|---|---|---|---|---|
3,980,837 | 3,980,838 |
how multi tab browser we can code in java?
|
<p>How multi tab browser we can code in java ?</p>
<p>Which use able in phone for multi page browser using.</p>
|
java
|
[1]
|
2,946,449 | 2,946,450 |
replacing a particular pattern in a string with an auto incrementing number
|
<p>I have a string like <code>"Hello how Hello are Hello"</code>
I want to replace the number of times <code>"Hello"</code> occurs in the above string by an autoincrementing number.</p>
<p>Such that the result would be: <code>"1 how 2 are 3"</code></p>
<p><code>"Hello"</code> can occur any number of times</p>
|
java
|
[1]
|
2,695,837 | 2,695,838 |
Python datatype suitable for my cache
|
<p>I'm searching for the a datatype for a cache, basically I need the functionality of a dict, i.e. random access based on a key, which has a limited number of entries so that when the limit is reached the oldest item gets automatically removed.
Furthermore I need to be able to store it via shelve or pickle and rely on Python 2.4.
Should I subclass dict and add a list to it? Any suggestions?</p>
<p><strong>Edit:</strong><br />
I have not mentioned the scale, I need to keep track of already read items which consist of a signature by which they are identified and I only want to keep track of about a few hundred of them.
collections.deque seem nice but that's a list and I need random access. So dict would seem suitable, however somehow I need to expire items if the limit is hit which means I need to keep track the order in which they have been added.</p>
|
python
|
[7]
|
1,272,793 | 1,272,794 |
How to add an automatic slider function to my jquery slider?
|
<p>I have added a new template to my blogger and it has a slider with some image related to the blog and the problem is " the slider only runs when I click the next button or previous button " and I need to slide it automatically someone help me so,I would have thankful to them..</p>
<p>The code is:</p>
<pre><code><script type='text/javascript'>
jQuery(function() {
var Page = (function() {
var $navArrows = jQuery( &#39;#nav-arrows&#39; ).hide(),
//$shadow = jQuery( &#39;#shadow&#39; ).hide(),
slicebox = jQuery( &#39;#sb-slider&#39; ).slicebox( {
onReady : function() {
$navArrows.show();
//$shadow.show();
},
orientation : &#39;r&#39;,
cuboidsRandom : true,
easing : &#39;ease&#39;
} ),
init = function() {
initEvents();
},
initEvents = function() {
// add navigation events
$navArrows.children( &#39;:first&#39; ).on( &#39;click&#39;, function() {
slicebox.next();
return false;
} );
$navArrows.children( &#39;:last&#39; ).on( &#39;click&#39;, function() {
slicebox.previous();
return false;
} );
};
return { init : init };
})();
Page.init();
});
</script>
</code></pre>
|
jquery
|
[5]
|
5,528,414 | 5,528,415 |
android-Filling the screen with a series of textView and buttons
|
<p>In my code I want to have the following:</p>
<pre><code><LinearLayout>
<LinearLayout>
<Button>
</LinearLayout>
<TextView>
<TextView>
<TextView>
<TextView>
<LinearLayout>
<Button>
</LinearLayout>
</LinearLayout>
</code></pre>
<p>Whare the packing is horizontal (from left to right)</p>
<p>I the textView's changes during the code and I want the left and right button position to be fixed to the leftmost and rightmost of the screen. How can I achieve that?</p>
|
android
|
[4]
|
4,726,162 | 4,726,163 |
What is the equivalent of VB's "Dim" statement in C#?
|
<p>Picking up C#, can't seem to find any useful reference to this, other than examples.</p>
<p>So, what is Dim in C#?</p>
|
c#
|
[0]
|
4,699,732 | 4,699,733 |
New line Python
|
<p>How would I specify a new line in python?</p>
<p>For a comparison to Java in a String you would do something like "First Line\r\nSecond Line"</p>
<p>So How would you do that in Python? For purposes of saving files with more then one line.</p>
|
python
|
[7]
|
2,650,346 | 2,650,347 |
IE9 fadeIn not working
|
<p>Here's the code</p>
<pre><code>$('body').fadeIn(1500, 'easeOutCubic');
</code></pre>
<p>Here's <a href="http://www.trimeragroup.com/" rel="nofollow">an example</a></p>
<p>It works in EVERY OTHER BROWSER, why not IE9 :(</p>
|
jquery
|
[5]
|
865,968 | 865,969 |
Cannot Implicitly Convert Type to system.net
|
<p>I am having an error in my program when trying to download files from a remote server, I am using the System.Net Lib and it is having an issue converting to it.</p>
<p>I am getting the error Message "Cannot implicitly convert type 'System.ComponentModel.AsyncCompletedEventHandler' to System.Net.DownloadProgressChangedEventHandler' on the last line in the code block</p>
<pre><code>AsyncCompletedEventHandler(client_DownloadFileCompleted);
</code></pre>
<h2>Error Line ^</h2>
<p>Form.cs V</p>
<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
namespace Buildcraft_Installer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnStartDownload_Click(object sender, EventArgs e)
{
prgDownload.Visible = true;
WebClient client = new WebClient();
client.DownloadProgressChanged += new
DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadProgressChanged += new
AsyncCompletedEventHandler(client_DownloadFileCompleted);
</code></pre>
<p>I would be very grateful if anyone had a way to resolve this or a workaround to get the same result, thanks :)</p>
|
c#
|
[0]
|
2,539,208 | 2,539,209 |
multi select option printing
|
<p>I am just a beginner in php.
I am trying to print the values of the form when submitted. I used the following code for hobbies which is a field of my form.</p>
<pre><code><?php
$hobbies=array("Reading books","Listening to music","Swimming","Watching TV");
foreach($hobbies as $key=>$value) {
$hobbyvalues='<input name="hobbies" type="checkbox" value="'.$value.'" />'.$value."</br>";
echo $hobbyvalues;
}
?>
</code></pre>
<p>I store the selected hobbies like the following.</p>
<pre><code>$hobbies = $_POST["hobbies"];
echo $hobbies;
</code></pre>
<p>I checked it by selecting more than one hobby and submit the form. But my result prints only the last selected hobby. </p>
<p>I need my code to display all the selected hobbies. How can i do that?</p>
|
php
|
[2]
|
1,535,073 | 1,535,074 |
how to track pageviews of a website without knowing its domain name?
|
<p>first of all let me make it clear that it is nothing like illegal.</p>
<p>I have made a html code and published it on the internet anyone can easily copy the code and use it as per their requirements. Now because i want to check that how much popular my code is, i want to track that <strong>how many times a website with my code is loded in a browser.</strong></p>
<p>I thought google analytics will be a good option but they want the the url of the website to be tracked but my code is openly uploaded and can be used by anyone, <strong>i never know on which url it is implemented.</strong> So can anyone help me out.</p>
<p><strong>If possible i would like to get the information that on what url it is implemented.</strong></p>
<p>Any kind of help is welcome.</p>
|
javascript
|
[3]
|
5,082,830 | 5,082,831 |
Javascript uncheck all checkboxes with <input type="checkbox" name="QuoteRequiredServices[]" syntax
|
<pre><code><label class="checkbox inline">
<input type="checkbox" name="Services[]" value="service1"> Service 1
</label>
<label class="checkbox inline">
<input type="checkbox" name="Services[]" value="service2"> Service 2
</label>
</code></pre>
<p>I am using Services[] so that $_POST['Services'] is mapped to an array in PHP, containing the values required. </p>
<p>However, on the client side I also need to uncheck all these checkboxes after the form has been submitted (to PHP). Fairly simple Javascript: (actual checkbox group is 8 long).</p>
<pre><code>for (j=0; j<8; j++){
fields[6][j].checked=false;
}
</code></pre>
<p>where:</p>
<pre><code>fields[6] = formob.Services[];
formob=document.forms["FooterQuote"];
</code></pre>
<p>The problem is that I cannot put Services[] into a Javascript array. I have tried using the following methods: (pseudo-code, only syntax matters here)</p>
<pre><code>var fields=[formob.text1, formob.text2, formob.text3, formob.Services[]];
//Syntax error at Services[]
var fields=new Array(formob.text1, formob.text2, formob.text3, formob.Services[]);
//Syntax error at Services[]
var fields=new Array(formob.text1, formob.text2, formob.text3);
fields.push(formob.Services[]);
//Syntax error at Services[]
</code></pre>
<p>So, unfortunately I can't push Services[] into a Javascript array, as far as I can tell. </p>
<p>I have also tried using formob.Services instead, and this doesn't work either. </p>
<p>Has anybody got any ideas how I can make the name="Services[]" syntax for checkboxes work in a Javascript array, so I can cycle through and uncheck them all? :)</p>
|
javascript
|
[3]
|
1,262,325 | 1,262,326 |
Graphic object outside of C# app - is it doable?
|
<p>I have already asked here but the only answer was related to positioning. I would need to make an app which would produce an image always following the mouse, outside of the app. I know now how to hook mouse position, but I have no clue how to let the object (image) be on the top of other apps. Anyway I dont know if it is even possible in .NET.
Thanks!</p>
|
c#
|
[0]
|
749,746 | 749,747 |
This Way of Writing?
|
<p>Though i have often come across,i dont understand this way of writing code:</p>
<pre><code>Runnable r=new Runnable() {//<----- (braces start here?)
public void run() {
System.out.println("Hello");
}
}; // ?
</code></pre>
<p>What is this?
Please explain very clearly.</p>
|
java
|
[1]
|
3,767,692 | 3,767,693 |
C++ Function issue involving Distinct Values
|
<p>Ok guys, I was given an assignment, and I am running into a lot of problems with coding this. </p>
<pre><code># include <string>
using namespace std;
int listdistinct( string b[], int n );
// modifies b so that all the distinct values are in b[0..k-1] and returns k
// the distinct values are in the order of their leftmost appearance in original b
// e.g. 3,6,3,19,6,3,11 with n=7 would be changed to 3,6,19,11,?,? with k=4 returned
// worstcase complexity is n log(n) or better.
</code></pre>
<p>I was given this as a starter:</p>
<pre><code>int listdistinct(string b[], int n) {
string a[];
sort b[];
i=1;
for i=0 , i<k {
if b[i] == b[i-1] ;
else { a[n] = b[i-1]; n++;}
}
return n;
}
</code></pre>
<p>Ok so didnt give the best description of my issue.
This is how I think I should code it.</p>
<p>b[] = array of numbers,
a[] = destination of numbers without duplicates, and finally, c[] would be an array taking the order of the array before it is sorted. </p>
<p>What I need to do is, match up the length of b[] and add in numbers, say 1 2 3 4 ... etc to c[] to maintain my order. Then I can sort both of those arrays, so the order number stays with the array number in b[]. </p>
<p>I am having an issue knowing how to set the for loop to do this, how many times to repeat it!</p>
<p>I also do not know how to order the array so that the most frequent one comes to the front of the array. </p>
<p>The biggest problem I am having with this is understanding how to do all of this, and keep the algorithm to an n log n worst case complexity.</p>
|
c++
|
[6]
|
466,674 | 466,675 |
Service.onDestroy() is called directly after creation, anyway the Service does its work
|
<p>I built a Service and it didn't work as expected, so I debugged it. During debugging, I saw that the service's onDestroy() method is called directly after returning from onCreate(). When I comment out the cleanup that happens in onDestroy(), the service does its work, but this should not be my solution. So my question is, why is onDestroy() called so early and why is the service running anyway? Or how can I prevent onDestroy() from being called at the wrong time?</p>
<p>For your information: I've subclassed IntentService.</p>
<p>Thanks for any help.</p>
<p>Binabik</p>
|
android
|
[4]
|
3,352,220 | 3,352,221 |
Server Real Path
|
<p>I wonder whether someone may be able to help me please.</p>
<p>I'm trying to retrieve the file path for an xml file that I use to in a image gallery script I'm building.</p>
<p>My folder structure is as follows:</p>
<blockquote>
<p>website/development/UploadedFiles/'username'folder/'location'
folder/file.xml</p>
</blockquote>
<p>I've put together this to try and get me the path:</p>
<pre><code><?php
chdir('var/www/');
echo realpath('./././file.xml');
?>
</code></pre>
<p>But I receive the following error:</p>
<blockquote>
<p>Warning: chdir() [function.chdir]: No such file or directory (errno 2)
in /homepages/2/d333603417/htdocs/development/real.php on line 2</p>
</blockquote>
<p>I'm sure that I'm making a beginners mistake here, but I wanted to have at least given it a try. I just wondered whether someone could possibly take a lok at this please and let me know where I'm going wrong.</p>
<p>Many thanks</p>
|
php
|
[2]
|
5,473,324 | 5,473,325 |
Custom attrs parameter used in styles.xml
|
<p>I have a set of custom Android layout parameters defined in attrs.xml. Now I would like to use some tags in my styles.xml file.</p>
<p>At the moment I get this error:</p>
<pre><code>error: Error: No resource found that matches the given name: attr 'custom:tag'
</code></pre>
<p>I have tried declaring custom XML namespace as follows:</p>
<pre><code><resources
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/com.my.project"
>
</code></pre>
<p>hoping, that the same logic used in every layout declaration can be applied here, but with no success.</p>
|
android
|
[4]
|
2,079,745 | 2,079,746 |
JavaScript Events like onclick and onload
|
<p>How to display the below using javascript 1.Display password in text form and after displaying when we click on reset button it should be asteriked
2.when we click on password textbox it should be blank</p>
|
javascript
|
[3]
|
1,287,738 | 1,287,739 |
How can I refactor this method?
|
<pre><code>private void Update_Record_Click(object sender, EventArgs e)
{
ConnectionClass.OpenConnection();
if (textBox4.Text == "" && textBox2.Text == "")
{
MessageBox.Show("No value entred for update.");
}
else if (textBox4.Text != "" && textBox2.Text != "")
{
SqlCommand cmd = new SqlCommand("update medicinerecord set quantity='" + textBox2.Text + "' where productid='"+comboBox1.Text+"'", ConnectionClass.OpenConnection());
cmd.ExecuteNonQuery();
cmd = new SqlCommand("update myrecord set price='" + textBox4.Text + "' where productid='" + comboBox1.Text + "'", ConnectionClass.OpenConnection());
cmd.ExecuteNonQuery();
ConnectionClass.CloseConnection();
}
else if (textBox2.Text != "")
{
SqlCommand cmd = new SqlCommand("update myrecord set quantity='" + textBox2.Text + "' where productid='" + comboBox1.Text + "'", ConnectionClass.OpenConnection());
cmd.ExecuteNonQuery();
ConnectionClass.CloseConnection();
}
else if (textBox4.Text != "")
{
SqlCommand cmd = new SqlCommand("update myrecord set price='" + textBox4.Text + "' where productid='" + comboBox1.Text + "'", ConnectionClass.OpenConnection());
cmd.ExecuteNonQuery();
ConnectionClass.CloseConnection();
}
}
</code></pre>
<p>It's working correctly but I want to make it shorter so that it's easier to understand. How can I refactor it?</p>
|
c#
|
[0]
|
4,259,250 | 4,259,251 |
test the timeOut in iPhone (- (void)requestFailed:(ASIHTTPRequest *)request)
|
<p>I would like to test the timeOut error in the requestFailed, i have do like this :</p>
<pre><code>if ([[self.request error] code]== ASIRequestTimedOutErrorType){
// ...
}
</code></pre>
<p>i would like to test this in the simulator but i don't no how to do it.</p>
<p>thanks for your answers</p>
|
iphone
|
[8]
|
3,200,951 | 3,200,952 |
state-of-the-art C++ projects
|
<p>I like to go through existing software projects as a source of learning and new ideas.
doing so I discover things that I did not think were possible</p>
<p>in your opinion, what is the top state of the art C++ project that you have used/develop/extended? can you state reasons why you consider it state of the art and what you can learn from it.</p>
<p>my latest craze is boost::phoenix, <a href="http://www.boost.org/doc/libs/1_43_0/libs/spirit/phoenix/doc/html/index.html" rel="nofollow">http://www.boost.org/doc/libs/1_43_0/libs/spirit/phoenix/doc/html/index.html</a>, which is very comprehensive functional programming library.
Despite its capabilities it is straightforward and easy to extend. After some tweaking I was able to write multithreaded lambda parallel loops and mathematical domain specific language, probably within 2 weeks.</p>
<p>What is yours? (please do not just say boost, as it is huge collection of project)</p>
|
c++
|
[6]
|
3,020,857 | 3,020,858 |
public field of a class not visible in its subclass
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/11405/gcc-problem-using-a-member-of-a-base-class-that-depends-on-a-template-argument">GCC problem : using a member of a base class that depends on a template argument</a> </p>
</blockquote>
<pre><code>template <typename AType, typename OuterClass>
class A{
public:
A (AType a, OuterClass & b) : a(a), b(b) { }
AType a;
const OuterClass & b;
};
template <typename T>
class B {
public:
class C : public A<int, B> {
C(const B & b) : A<int, B>(0, b) {}
int getA() { return a; }
};
};
</code></pre>
<p>This code is a little long, but it's the minimal example I could find to reproduce my problem. Class C should inherit field "a" from its superclass A, and visual c++ compiles it without errors. But for some reason under gcc, in function getA I get "error: ‘a’ was not declared in this scope". What's wrong with this code and how can I make it more portable?</p>
|
c++
|
[6]
|
1,015,256 | 1,015,257 |
Writing a login screen like default android pattern lock
|
<p>I want to write a login screen for my new app like android's default pattern lock. Is there a way to do this? Is there any library to help doing this?</p>
<p>Thanks in advance.</p>
|
android
|
[4]
|
1,218,885 | 1,218,886 |
`.show()` inconsistent behaviour (bug?)
|
<p>I have a hidden element <code>$myHiddenElement</code>. Now if I do</p>
<p><code>$myHiddenElement.show();</code></p>
<p>all is OK. However, if I do</p>
<p><code>$myHiddenElement.show(300);</code></p>
<p>then <code>$myHiddenElement</code> gets the attribute <code>display: block;</code> which damages my layout.</p>
|
jquery
|
[5]
|
5,546,851 | 5,546,852 |
Textfield autocorrection issue
|
<p>I am facing a strange and weird problem related with the UITextField's Autocorrection.
I have a class which is derived from UIScrollView(subclass from UIScrollView), containing some textfield, textview & buttons at the bottom respectively. </p>
<p>I am facing a problem while i input some text in the textfield & autocorrection bubble pops up. If i tap on the bubble to resign it & tap on the button which presents the popover, it comes at correct dimensions. But if i don't disable the bubble and scroll up the view to tap the button, it pops up with wrong positions. </p>
<p>This is what i'm doing for presenting popover: </p>
<pre><code>- (void)presentImagePicker:(UIImagePickerControllerSourceType)type
withAnimation:(BOOL)animated {
if ([popoverViewController_ isPopoverVisible]) {
[popoverViewController_ dismissPopoverAnimated:YES];
return;
}
UIImagePickerController *picker =
[[[UIImagePickerController alloc] init] autorelease];
[picker setDelegate:self];
[picker setSourceType:type];
[[picker navigationBar] setTintColor:[UIColor bloggerBarColor]];
UIPopoverController *popoverController =
[self popoverWithViewController:picker];
CGRect rect = CGRectZero;
if (type == UIImagePickerControllerSourceTypePhotoLibrary) {
rect = [[composeView_ addPhotoLibraryButton] frame];
} else {
rect = [[composeView_ addPhotoCameraButton] frame];
}
[popoverController presentPopoverFromRect:rect
inView:[self view]
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
</code></pre>
<p>Thanks in advance.
Tarun</p>
|
iphone
|
[8]
|
4,634,248 | 4,634,249 |
Am I calling these functions correctly?
|
<p>Please tell me if there is any error when I am calling these functions</p>
<p><strong>1 bool discount (float price, int numberOfItemsPurchased)</strong></p>
<pre><code>bool discount
float price;
int numberOfItemPurchased;
discount = discountP (price, numberOfItemPurchased)
</code></pre>
<p><strong>2 float estimatePetrolPrice (float kms, float price, bool leaded, bool automatic)</strong></p>
<pre><code>float estimatePrice;
float kms;
float price;
bool leaded;
bool automatic;
estimatePrice = estimatePetrolPrice (kms, price, leaded, automatic)
</code></pre>
<p><strong>3 void getData (string & name, string & dateOfBirth, int & age)</strong></p>
<pre><code>string name;
string dateOfBirth;
int age;
getData (name, dateOfBirth, age)
</code></pre>
<p><strong>4 void getVal ( int & item, int & inter, char decflag)</strong></p>
<pre><code>int item;
int inter;
char decflag;
getVal (item, inter, decflag)
</code></pre>
|
c++
|
[6]
|
1,571,149 | 1,571,150 |
Wrapping a JavaScript callback redefining "this"
|
<p>I know about <code>call</code> and <code>apply</code> in JavaScript, but I'm currently stuck with the following scenario.</p>
<p>I'm using <strong>Benchmarkjs</strong>, and it has an API defined like this:</p>
<pre><code>.on(eventType, listener)
</code></pre>
<p>So I'd do, for instance:</p>
<pre><code>/* Register the onStart callback */
suite.on('start', onStart);
</code></pre>
<p>My <code>onStart</code> function will be called so that <code>this === suite</code>.</p>
<p>How can I do so that I can define one of the <code>arguments</code> of <code>onStart</code>?</p>
<p>My code is something like this:</p>
<pre><code>foo = function() {
this.suite.on('start', this.onStart);
}
</code></pre>
<p>I'd like my <code>onStart</code> function to have a reference to <code>foo</code>.</p>
<p>Any suggestions?</p>
|
javascript
|
[3]
|
3,799,154 | 3,799,155 |
How to send data between php pages using javascript
|
<p>I have a variable called messages and I want to pass the value of message(text area) from template.php to sendmessage.php ( text area ) using javascript. Would you please help with this?</p>
<p>Regards,</p>
|
php
|
[2]
|
2,908,762 | 2,908,763 |
PHP recommended tutorials!
|
<p>Am starting my first project in PHP,so am gonna spend some time learning it.
i found some books and tutorials for beginners online, but i thought i would ask here for recommended books and tutorials that helped you the most,i have some programming experience but not with PHP so a book with the basics and many (MANY) examples would be more than great :)
Thanks!</p>
|
php
|
[2]
|
3,448,147 | 3,448,148 |
Removing double quotes
|
<p>What I'm trying to find out is which php function allows me to remove double quotes from the beginning and end of a text string if they exist</p>
|
php
|
[2]
|
1,632,469 | 1,632,470 |
What is good practice when u create a method whose parameter contains 2 objects but it only changes 1
|
<p>for example:</p>
<pre><code> void FilterA(Hashset<T> blackList, List<T> myList)
{
blackList.UnionWith(myList);
}
</code></pre>
<p>I don't know if there would be some good coding styles that separates <code>blackList</code> and <code>myList</code> apart. Or is it necessary at all?</p>
|
c#
|
[0]
|
1,862,110 | 1,862,111 |
Checking whether the application in running or which tab is active
|
<p>I am new to programming. I am trying to develop an application in which i want to find out the time the user has spent with the application.
Say the user works with a number of processes(opens a word file,opens paint, opens a browser and browses,opens photoshop etc) These processes come as different tabs in the taskbar. The user will keep switching the tabs. I want to find out the time spent on each day for photoshop.The user has to enter the login time and logout time in date time format, so i will be able to get the date details. I am planning to use the timer. When the photoshop tab is active the timer should start and when he switches the tab, the timer should stop and the value is stored in a variable. Each time the variable value is updated. But how to detect whether photoshop tab is active tab or how to detect whether the user is using the photoshop.Which event to use to find the tab switch.</p>
|
c#
|
[0]
|
5,705,300 | 5,705,301 |
Android how send command
|
<p>i want to send string command in android like do in vb but i don't to know like translate</p>
<p>this is an example</p>
<p>char(&H1D) + "V" + char(20) + char(65)</p>
<p>how can translate in android? </p>
|
android
|
[4]
|
936,597 | 936,598 |
Javascript check Mouse clicked inside the Circle or Polygon
|
<p>Any one know how to check that wheter a mouse is clicked inside the circle or polygon. My problem is I want to check that if mouse has been clciked inside the circle or polygon. circle or polygon coordinates has been stored inside an array. Any help is really appreciated</p>
|
javascript
|
[3]
|
4,802,640 | 4,802,641 |
How to convert Texture2D to MCvMat
|
<p>I'm in serious need of help on how to convert .net's Texture2D object to EmguCv's MCvMat Object. I've been searching for almost a week now but it seems nobody finds the conversion useful. I've come across some methods written in c++ that convert Texture2D to MIplImage and then to McvMat, but unfortunately, the c++ code don't work for c#. Pls any help is welcome.</p>
|
c#
|
[0]
|
2,632,833 | 2,632,834 |
Evaluation order of new expression?
|
<p>In the following code sample, do the C++ standard guarantee that '++i' is evaluated after the memory allocation (call to operator new) but before the call to X’s constructor?</p>
<pre><code>new X( ++i )
</code></pre>
|
c++
|
[6]
|
1,342,963 | 1,342,964 |
iphone response
|
<p>i am getting response like {"nok"} .... now i want to compare this for check status of data sent or not.<br>
this is my code </p>
<pre><code> NSString *responseStr = [sender responseString];
NSLog(@"response string %@", responseStr);
if([responseStr isEqualToString:@"nok"])
{
NSLog(@"Hiii");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Attenzione: si è verificato un errore di richiesta del premio." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Inviato con successo" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
[self startIscrivity2View];
}
</code></pre>
<p>it's always run else part...</p>
<p>please help me</p>
|
iphone
|
[8]
|
87,861 | 87,862 |
How do you refresh a window in Tkinter
|
<p>If I created Tkinter window with some text that filled the whole window and now wanted to replace the window with a new text, is there a way to refresh the window? </p>
<p>For Example:</p>
<pre><code> a= 100
win= Tk()
win.geometry("500x300")
while a > 0:
if a%2 == 0:
lbl = Label (win, bg = "purple")
lbl.pack()
else:
lbl = Label (win, bg = "blue")
lbl.pack()
a= x-1
</code></pre>
<p>The problem with this code is that the Tkinter window does not refresh and just provides the end result instead of showing the windows changing colors.
Thanks for the help! </p>
|
python
|
[7]
|
921,743 | 921,744 |
Effective way to implement the number of views on images - PHP
|
<p>I've created a website where users can upload images and i'd like to record the total number of views for an individual image. </p>
<p>Now my idea on the implementation is this: </p>
<p>Store the ipaddress of the visitor in a session, fe: </p>
<pre><code>$key = "view_img_".$img->id;
if(!isset($_SESSION[$key]))
{
$_SESSION[$key] = array();
}
$visitorIpAddress = $_SERVER['REMOTE_ADDRESS'];
$found = false;
foreach($ip in $_SESSION[$key])
{
if($ip == $visitorIpAdress)
{
$found = true; //visitor has visited before in the livespan of this session
break;
}
}
if(!$found)
{
//do sql update query for the number of views for this image
$sql = mysql_query("UPDATE ") //etc.
//Add this ip to the list in the session
$_SESSION[$key][] = $visitorIpAdress;
}
</code></pre>
<p>Now my problem is this: </p>
<p>I'd like it to clear a visitor's ipaddress inside the $_SESSION[$key] variable after a certain timelimit to clear resources. </p>
<p>The thing is:<br>
Most of the visitors might only view the image once, and when a certain image gets old it might not be visited any longer, but the session will still exist. </p>
<p>Is there a way to define a lifespan for a specific $_SESSION variable so it resets itself? (equal to $_SESSION[$key] = null) </p>
<p>Or would there be a better way to implement this?</p>
|
php
|
[2]
|
124,434 | 124,435 |
Replace only text inside a div using jquery
|
<p>I have a div like:</p>
<pre><code><div id="one">
<div class="first"></div>
"Hi I am text"
<div class="second"></div>
<div class="third"></div>
</div>
</code></pre>
<p>I am trying to change only the text from "Hi I am text" to "Hi I am replace" using jquery.
This might be easy but I am not able to do it.</p>
<p>Using <code>$('#one').text('')</code> just empties the whole "#One" div.
Thanks...</p>
|
jquery
|
[5]
|
4,038,551 | 4,038,552 |
How can I bind 2 functions to one click event to a button(ID="Display") asynchronously?
|
<p>How can I bind 2 functions to one click event to a button(ID="Display") in such a way that Function B() must wait until Function A() finishes and then executes using Jquery?</p>
<p>Thanks</p>
|
jquery
|
[5]
|
999,980 | 999,981 |
How to extract text from an image using PHP
|
<p>Let's say I have an image which consists of white background and black text. How to extract text from the file and save it as png with transparent backgorund using PHP?</p>
|
php
|
[2]
|
4,153,227 | 4,153,228 |
Change referrer when redirecting
|
<p>What I'm trying to do is use PHP to redirect from web site A to web site B (both are different domains), but I want the referrer in the HTTP headers to be set to web site A (the page that performed the redirect). So, that is, web site B will see web site A as a referrer. </p>
|
php
|
[2]
|
651,353 | 651,354 |
Appending a TextView
|
<p>I have an app which at current will on the press of a button eg. the number 1 button change a text view to have the number 1 in it. What i need to do is append the view so that say when the number 3 is pressed the text view will say 13 instea of just 3. Here is the switch statement i'm using to handle the button presses.</p>
<pre><code>@Override
public void onClick(View c) {
switch (c.getId())
{
case R.id.keypad_1:
TextView prs1 = (TextView) findViewById(R.id.diff);
prs1.setText("1");
}
}
</code></pre>
|
android
|
[4]
|
5,379,913 | 5,379,914 |
System.out.println() don't throws Exception, but System.in.read() throws Exception, Why?
|
<p>I got this from <strong>Java™ I/O, 2nd Edition
By Elliotte Rusty Harold :-</strong></p>
<p><hr /></p>
<p>it would be inconvenient to wrap a try/catch block around each call to System.out.println( ), Sun decided to have PrintStream (and later PrintWriter) catch and eat any exceptions thrown inside a print( ) or println( ) method. If you do want to check for exceptions inside a print( ) or println( ) method, you can call checkError( ):</p>
<p>public boolean checkError( )</p>
<p>The checkError( ) method returns TRue if an exception has occurred on this print stream, false if one hasn't. It tells you only that an error occurred. It does not tell you what sort of error occurred. If you need to know more about the error, you'll have to use a different output stream or writer class.</p>
<p><hr /></p>
<p>I just wana test this checkError method for true return type....</p>
<p>Any clues for creating some practical scenarios for this... <strong>:-)</strong></p>
|
java
|
[1]
|
190,733 | 190,734 |
How to make js check for 0 instead of undefined
|
<p>I have a function which takes a parameter and performs some calculations with it. The parameter is a number. However, when the parameter is 0, js treats it as undefined. So if I have a check for it like: </p>
<p><code>if (param == 0) { ... }</code> </p>
<p>This is always false because <code>param==0</code> is <code>false</code> but <code>param==undefined</code> is true.
So I have to rewrite the code and have a special case for when param=0. </p>
<p>Example:<br>
<code>result= param*123*456 +789;</code>
This has to be changed to: </p>
<pre><code>if (param == undefined) {
result= 789;
} else {
result= param*123*456 +789;
}
return result;
</code></pre>
<p>This is repeating code. There must be a better way. What is the better way?</p>
|
javascript
|
[3]
|
4,685,099 | 4,685,100 |
Timing/Recording input() in Python 3.1
|
<p>I am a beginner at using Python,</p>
<p>I am trying to request input from the user via stdin as a string, but record the time it takes for the user to enter the input, so that it may be played back later.</p>
<p>For example: </p>
<p>"It could take me 10 seconds to type this sentence"</p>
<p>and then if I played that sentence back it would take the same amount of time to redisplay it...</p>
<p>Any basic ideas on which modules to use for timing / input? For output, I am just going to store all the recorded values and times in a dictionary object and read from them. (Seems to be the best way...)</p>
<p>Any guidance or help would be appreciated. I am not a beginner programmer, but just very new to Python, so don't feel like you have to write anything out for me.</p>
<p>Thanks!</p>
|
python
|
[7]
|
3,626,594 | 3,626,595 |
Is there a way to redefine a type hint to a descendant class when extending an abstract class?
|
<p>I will be using the following example to illustrate my question:</p>
<pre><code>class Attribute {}
class SimpleAttribute extends Attribute {}
abstract class AbstractFactory {
abstract public function update(Attribute $attr, $data);
}
class SimpleFactory extends AbstractFactory {
public function update(SimpleAttribute $attr, $data);
}
</code></pre>
<p>If you try to run this, PHP will throw a fatal error, saying that the <code>Declaration of SimpleFactory::update() must be compatible with that of AbstractFactory::update()</code></p>
<p>I understand exactly what this means: That <code>SimpleFactory::update()</code>s method signature must exactly match that of its parent abstract class. </p>
<p>However, my question: Is there any way to allow the concrete method (in this case, <code>SimpleFactory::update()</code>) to redefine the type hint to a valid descendant of the original hint?</p>
<p>An example would be the <code>instanceof</code> operator, which would return true in the following case:</p>
<pre><code>SimpleAttribute instanceof Attribute // => true
</code></pre>
<p>I do realize that as a work around, I could make the type hint the same in the concrete method, and do an instanceof check in the method body itself, but is there a way to simply enforce this at the signature level?</p>
|
php
|
[2]
|
5,615,145 | 5,615,146 |
How do I retain form values upon submit for a <select> loop?
|
<p>How do I retain form values upon submit for a loop?</p>
<p>I've got something like this:</p>
<pre><code><?php
printf ("<optgroup label=\"CATEGORIES\">");
foreach ($category as $key => $val) {
printf ("<option value=\"$key\">$val</option>");
}
printf ("</optgroup>");
?>
</code></pre>
<p>When hitting submit on another part of my form, it resets the values in the select to the top one. I want it to keep the same value. How? For things like input boxes I have this that works: </p>
<pre><code><option value="5" name="results" <?php if($_GET["results"] == '5'){ ?> selected="selected" <?php } ?> >5</option>
</code></pre>
<p>This works because I'm not dynamically populating the dropdown from a database, so I don't need a loop to loop through values and populate the select.</p>
|
php
|
[2]
|
5,533,847 | 5,533,848 |
Where/what is the private variable in auto-implemented property?
|
<p>There is no (explicit) reference to a firstName private variable which FirstName is supposed to be hiding. Could you explain how this works?
I assume there is some private variable that is being getted and setted.
Thanks.</p>
<pre><code>// auto-implemented property FirstName
public string FirstName { get; set; }
</code></pre>
|
c#
|
[0]
|
1,920,436 | 1,920,437 |
eclipse displays error in the manifest
|
<blockquote>
<p>I am using </p>
</blockquote>
<pre><code>android:configChanges="orientation|screenSize"
</code></pre>
<blockquote>
<p>in the manifest. But eclipse gives me an error "string types not allowed"
so what is missing from my eclipse?</p>
</blockquote>
|
android
|
[4]
|
4,543,007 | 4,543,008 |
.on() doesnt works on dynamic elements?
|
<p>My <a href="http://jsfiddle.net/qcdzS/1/" rel="nofollow">code</a> :</p>
<h1>HTML</h1>
<pre><code><div id="box">
<div class="mappa-infobox">
<div class="pulsanti">
<span class="pulsante selected">YES</span>
<span class="pulsante">NO</span>
</div>
</div>
</div>
<div id="example"></div>
</code></pre>
<h1>jQuery</h1>
<pre><code>$(".mappa-infobox .pulsante").on("click", function () {
console.log("ciao");
});
$(window).load(function () {
$('#example').html($('#box').html());
});
</code></pre>
<p>seems that, after the document is loaded and the <code>mappa-infobox</code> "cloned" inside the <code>example</code> div, the handlers are not fired. Why?</p>
|
jquery
|
[5]
|
623,824 | 623,825 |
Disable system sound (ding) for disabled forms
|
<p>I have a form which can be set to .Enabled = false;. The client still might click on it by accident which can turn out to be very annoying since every time you click on it you will get this ding sound. I was wondering whether it's possible to disable that or not.</p>
|
c#
|
[0]
|
5,063,599 | 5,063,600 |
cannot load linear layout from main.xml in a dyanimic layout
|
<p>I am trying to make dynamic layout in which there is a scroll view.
In the scroll view , I am adding vertical linear layout which references main.xml.
The code stops as soon , I try to add the layout referencing main.xml. </p>
<pre><code> ScrollView scroll;
EditText search;
Button checkin;
LinearLayout vt;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
scroll=new ScrollView(getApplicationContext());
vt=(LinearLayout) findViewById(R.id.llv);///referencing linear layout located in main.xml.This is where problem the is occurring.
//vt.setOrientation(LinearLayout.VERTICAL);
scroll.addView(vt);
this.setContentView(scroll);
}
</code></pre>
<p>main.xml ( where R.id.llv is located )</p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/llv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<ToggleButton
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ToggleButton" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
</code></pre>
|
android
|
[4]
|
3,736,380 | 3,736,381 |
How to intercept touch events globally?
|
<p>I have an view which is sometimes covered by some other views. However, if the user slides the finger across the screen, I want to slide that underlying view across the screen, too.</p>
<p>I could start making custom views for all those covering subviews and forward all kinds of touch events, but that's somewhat cumbersome. Maybe there's some kind of notification or another way that a UIView or UIControl subclass can be aware of touch events happening right now, no matter where they are.</p>
<p>In short: I need an UIView subclass or UIControl subclass which knows about any touch events happening on the entire screen. Or at least if tht's not possible, knowing about any touch events happening above itself in the same underlying superview.</p>
<p>Another description: There are 20 views, all reside inside the same superview. The first view is covered by 19 others. But if the user slides across the screen, that first view must slide too, so it must be aware of touch events.</p>
<p>Is there any better solution that making all 19 views forward touch events? (yes, all 19 views respond to touch events in this example)</p>
|
iphone
|
[8]
|
420,506 | 420,507 |
Find and Replace String In Java
|
<p>I have a String as follows</p>
<pre><code>String str=" Hello World, Hello World, Hello";
</code></pre>
<p>I want to replace third "Hello" to "Hi" In Java. Is there any way that I can touch only the part I need in a String ?</p>
|
java
|
[1]
|
2,540,242 | 2,540,243 |
How to unlack the screen and power on when my application is in background when screen is locked in android application?
|
<p>I have developed one application in android ,when my app is in background mode and screen is in locked mode some listeners events are bring my application from back ground to front but it is not onlocking the screen ,I need to onlock the screen and screen power on how can i achieve this in android application </p>
<p>thanks,
santhosh</p>
|
android
|
[4]
|
1,115,645 | 1,115,646 |
keep getting udefined variable for an array
|
<p>I keep getting undefiendd variable for steps in <code>Text5.php</code> when accessing <code>Text2.php</code>. My question is how come I amgetting an undefined variable as I have included the variable <code>$steps</code> as an array:</p>
<p>Text5.php</p>
<pre><code> <?php
$steps = array(1 =>'Text1.php',2 => 'Text2.php',3 => 'Text3.php',4 => 'Text4.php',5 => 'Text6.php',6 => 'Text7.php');
function allowed_in($steps){
// Track $latestStep in either a session variable
// $currentStep will be dependent upon the page you're on
if(isset($_SESSION['latestStep'])){
$latestStep = $_SESSION['latestStep'];
}
else{
$latestStep = 0;
}
$currentStep = basename(__FILE__);
$currentIdx = array_search($currentStep, $steps);
$latestIdx = array_search($latestStep, $steps);
if ($currentIdx - $latestIdx == 1 )
{
$currentIdx = $_SESSION['latestStep'];
return 'Allowed';
}
return $latestIdx;
}
?>
</code></pre>
<p>Text2.php</p>
<pre><code> if (allowed_in()=== "Allowed")
{
//Text2.php code
}
else
{
$page = allowed_in()+1;
?>
<div class="boxed">
<a href="<?php echo $steps[$page] ?>">Link to Another Page</a>
</div>
<?php
}
?>
</code></pre>
|
php
|
[2]
|
4,832,724 | 4,832,725 |
Creating singleton factory
|
<pre><code> String fullName = PATH + "." + name;
Class cl= Class.forName(fullName);
if(name.equalsIgnoreCase("MobileSearch")){
if(msearchType==null){
msearchType=(SearchInterface)cl.newInstance();
}
return msearchType;
}
if(name.equalsIgnoreCase("BookSearch")){
if(bsearchType==null){
bsearchType=(SearchInterface)cl.newInstance();
}
return bsearchType;
}
</code></pre>
<p>How do I get rid of the <code>if</code> statements here.<br />
I am using reflection.<br />
Please help. Thanks in advance.</p>
|
java
|
[1]
|
4,519,494 | 4,519,495 |
Converting String to int in java
|
<p>I need to convert a string to a corresponding int array in java. i wrote the following code but its not working as i expected .</p>
<pre><code> String temp= "abc1";
int[] intArray = new int[temp.length()];
for (int i = 0; i < temp.length(); i++) {
intArray[i] = Integer.parseInt(temp[i]);
}
</code></pre>
<p>I have written an rc4 encryption program which take the key and plain text as int arrays. So I need to convert the user specified key to int array before passing it to the encryption function. Is this the correct way of using key in encryption programs? </p>
|
java
|
[1]
|
447,594 | 447,595 |
C++ data conversion of user defined object
|
<p>In this program we use data conversion from class a to class c.when we use</p>
<pre><code>a(c c1)
{
return (c1.getd()*100)
}
// constructor in class a, this is correct, but when when we use
c(a a1)
{
return (a1.getb()/100)
}
// constructor, then compile error comming that getb is not a member of a please clear what is the problem.
#include<iostream.h>
#include<conio.h>
class a;
class c {
int d;
public:
c() {
d=0;
}
c(int x) {
d=x;
}
int getd() {
return d;
}
void putdata() {
cout<<d;
}
c(a a1){
d=(a1.getb()/100);//here is compile error coming --getb is not a member of a
}
};
class a {
int b;
public:
a() {
b=0;
}
a(int x) {
b=x;
}
void putdata() {
cout<<b;
}
int getb() {
return b;
}
};
void main() {
c c1;
a a1=100;
a a2(100);
c1=a1;
c1.putdata();
getch();
}
</code></pre>
|
c++
|
[6]
|
4,780,139 | 4,780,140 |
How can I find out if a File is a file or directory if it does not exist?
|
<p><code>File.isFile()</code> and <code>File.isDirectory()</code> both return false not only when the <code>File</code> is not the specified type, but also when the <code>File</code> itself does not exist on the filesystem. How can I determine whether the <code>File</code> represents a file or a directory when it does not exist?</p>
|
java
|
[1]
|
1,202,440 | 1,202,441 |
Setting Key/Value Pairs
|
<p>I've created a List as a property of the class, and want to set the Key/Value pairs when defining the List. I was originally using a structure but realized it's probably not the ideal solution so I changed it to a List. The problem is I'm getting an error with the syntax.</p>
<p>Any ideas?</p>
<pre><code>private List<KeyValuePair<String,String>> formData = new List<KeyValuePair<String, String>>[]
{
new KeyValuePair<String, String>("lsd",""),
new KeyValuePair<String, String>("charset", "")
};
</code></pre>
|
c#
|
[0]
|
3,461,098 | 3,461,099 |
Assigning a null value to an int
|
<p>If the following code is possible:</p>
<pre><code>Integer a = null;
int b = a;
</code></pre>
<p>Does it mean that a function returning a possible <code>null</code> value for an integer is a bad practice?</p>
<p>Edit 1:
There are several different opinions in these answers. I am not enough confident to choose one or another.</p>
|
java
|
[1]
|
4,629,251 | 4,629,252 |
How to implement multicast sockets?
|
<p>How can I implement multicast sockets in C#? Any code snippet along with a simple explanation is highly appreciated.</p>
<p>Thanks in advance.</p>
|
c#
|
[0]
|
3,381,134 | 3,381,135 |
android: how to stop slide in-slideout in new activity on android API 7?
|
<p>In andriod API 7 it is automatic <code>slide_in_left</code> and <code>slide_out_right</code> Animation in actvity. so i dont need to do this in each and every activity so how can i stop this animation and how can i animate normally?</p>
<p>Thanks a lot.</p>
|
android
|
[4]
|
1,139,226 | 1,139,227 |
Javascript OOP / Classes
|
<p>I'm sure this question has been asked before, but I can't seem to find the right and/or best format for it. Basically, I am trying to develop some custom Javascript classes for use within my site. I'd like to be able to call them as follows:</p>
<pre><code>MasterClass.SubClass.function(params);
</code></pre>
<p>Any help would be greatly appreciated. Thanks!</p>
|
javascript
|
[3]
|
2,536,517 | 2,536,518 |
onConfigurationChanged not getting called
|
<p>This morning I came up with a problem trying to handle the <code>onConfigurationChanged</code> event. The problem is that the method, which I override, is not getting called when I change the orientation of the phone. Not getting called at all. </p>
<p>I've put <code>android:configChanges="orientation"</code> on the activity defined in the manifest as mentioned on the android documentation, but this don't make a difference.</p>
<p>Have you come up with this problem? </p>
|
android
|
[4]
|
5,640,905 | 5,640,906 |
Simple Deque initialization question
|
<p>I have used the following code to insert some data in a deque.</p>
<pre><code>int data[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
deque<int> rawData (data, data + sizeof(data) / sizeof(int));
</code></pre>
<p>But I dont understand this part of the code,</p>
<pre><code>data + sizeof(data) / sizeof(int)
</code></pre>
<p>What does it mean?</p>
|
c++
|
[6]
|
2,100,925 | 2,100,926 |
Ways of passing arguments - value vs reference vs pointer?
|
<p>In contrast to other programming languages, C++ supports three different kinds of parameter passing:</p>
<ul>
<li>by value</li>
<li>by reference</li>
<li>by address</li>
</ul>
<p>I am programming for a long time with C# and from the point of view from as a C# developer, C++ confuses me. In C# it is fairly easy. Just define what you want and return the result whereas C++ is much more sophisticated. Is there something like an guideline when to use <code>by value</code>, <code>by reference</code>, <code>or by address</code>?</p>
|
c++
|
[6]
|
6,010,915 | 6,010,916 |
C++ Pass by value/reference
|
<p>I have the following code snippet:</p>
<pre><code>vector<DEMData>* dems = new vector<DEMData>();
ConsumeXMLFile(dems);
if(!udp_open(2500))
{
}
</code></pre>
<p>I want the ConsumeXMLFile method to populate the vector with DEMData objects built from reading an XML file. When ConsumeXMLFile returns, the dems vector is empty. I think I'm running into a pass by value problem.</p>
|
c++
|
[6]
|
859,503 | 859,504 |
android: onOptionsItemSelected, return false
|
<p>in onOptionsItemSelected... i was some code that had different cases in the switch block that returned values of true individually, but the end of the block returned false. why is this?</p>
<p>example of how I normally do it</p>
<pre><code>public boolean onOptionsItemSelected (MenueItem item)
switch (item.getItemId()){
case R.id.item1:
startActivity (new Intent (this, PrefsActivity.class));
break;
}
return true
</code></pre>
<p>example of how i saw it and, and am unsure of why it's set up this way... i just learned the first way, so i'm unsure of the logic of this other way...</p>
<pre><code>public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_NEW_GAME:
newGame();
return true;
}
return false;
</code></pre>
|
android
|
[4]
|
2,000,122 | 2,000,123 |
Garbage appears in vector after inserting result of operator
|
<p>I have an object with an operator defined like this:</p>
<pre><code>P& operator +(const P &rhs) {
return P(x + rhs.x, y + rhs.y, z + rhs.z);
}
</code></pre>
<p>It does not have custom copy or assignment operators.</p>
<p>After I assign directly the result of an addition inside the vector, garbage appears inside it.</p>
<pre><code>P p1(1.0, 0.0, 0.0);
P p2(0.0, 0.0, 0.0);
vector<P> v(1);
v[0] = p1 + p2; // v[0] now contains garbage.
</code></pre>
<p>If I do it through a variable, everything is as expected.</p>
<pre><code>vector<P> u(1);
P q = p1 + p2;
u[0] = q; // u[0] contains correct value.
</code></pre>
<p>What can be the reason for such behavior? What is the difference between the two cases?</p>
|
c++
|
[6]
|
3,113,234 | 3,113,235 |
Callback code seems to run before callback is actually called
|
<p>This sounds like a weird title and probably not stated too well. But here's the issue.</p>
<p>I've got this method being called:</p>
<pre><code>function BindFacebookAlbumAndPhotoData()
{
GetAllFacebookAlbums(userID, accessToken, function(aAlbums)
{
if (aAlbums === null || aAlbums === undefined)
{
// TODO: Need to handle this
return;
}
var defaultAlbumID = aAlbums[0].id;
BindFacebookAlbumDropdownList(aAlbums, defaultAlbumID);
BindFacebookThumbnails(userID, accessToken, defaultAlbumID, photosContainerDivID);
SetSelectDefaultOption(defaultAlbumID);
});
}
</code></pre>
<p>So here's the GetAllFacebookAlbums Method:</p>
<pre><code>function GetAllFacebookAlbums(userID, accessToken, callbackFunction)
{
var aAlbums = [];
var uri = "/" + userID + "/albums?access_token=" + accessToken;
// this is an async call so code after this will fire at the same time
FB.api(uri, function(response)
{
// check for a valid response
if (!response || response.error)
{
callbackFunction(albums);
}
for (var i = 0, l = response.data.length; i < l; i++)
{
//do whatever
}
});
// wait for the FB.api call to run a bit before calling code below
window.setTimeout(callbackFunction(aAlbums), 5000);
}
</code></pre>
<p>What's happening is this line is being called before the setTimeout it seems:</p>
<pre><code>var defaultAlbumID = aAlbums[0].id;
</code></pre>
<p>the whole reason I put that timeout in there is so I can wait for the FB.api call to finish. Then call the callback after I know I have data. So how in the world are those lines in my callback being called when I have definitely not seen a 5 second delay before that callback is called?</p>
|
javascript
|
[3]
|
5,078,341 | 5,078,342 |
Adding string with number in php
|
<pre><code>$a = "3dollars";
$b = 20;
echo $a += $b;
print($a += $b);
</code></pre>
<p>Result:</p>
<pre>
23
43
</pre>
<p>I have a question from this calculation.$a is a string and $b is number.I am adding both and print using echo its print 23 and print using print return 43.How is it</p>
|
php
|
[2]
|
5,728,114 | 5,728,115 |
How can I check whether a session is valid per page?
|
<p>So, if a login/registration system is created, so that when the user logs in, the user is redirected to another members-only page (member.php), I would store the login information in the user's session.</p>
<p>When the user navigates to the members page, prior to allowing him to see content, I'd want to make sure that the username/password is valid, and the user is validly logged in. How might I ensure that the user is validly logged in when he/she gets to the member's page, to me it seems like using:</p>
<pre><code>if (!isset($_SESSION['username']))
{
die("You aren't allowed to access this page");
}
</code></pre>
<p>would work, however I want to ensure it's secure, and to me, it just doesn't seem secure enough (because if there was some way of spoofing a session, all they'd have to do would be to include any sort of text as the username).</p>
<p>I don't really know, so how would I check whether the user should have access to the page?</p>
|
php
|
[2]
|
3,884,855 | 3,884,856 |
how to get right offset of an element? - jQuery
|
<p>This is probably a really simple question, but how do I go about getting the right offset of an element in jQuery?</p>
<p>I can do:</p>
<pre><code>$("#whatever").offset().left;
</code></pre>
<p>and it is valid.</p>
<p>But it seems that:</p>
<pre><code>$("#whatever").offset().right
</code></pre>
<p>is undefined.</p>
<p>So how does one accomplish this in jQuery?</p>
<p>Thanks!!</p>
|
jquery
|
[5]
|
2,869,309 | 2,869,310 |
A more suitable way to rewrite this?
|
<p><br>
I have the method: </p>
<pre><code> def checkAgainstDate():
currentDate = date.today()
currentMonth = date.today().month
if currentMonth == 1
year = currentDate.year-1
return date(year, 11, 01)
elif currentMonth == 2:
year = currentDate.year-1
return date(year, 12, 01)
else
return date(currentDate.year, currentMonth-2, 01)
</code></pre>
<p>This just returns the first of the month 2 months ago, which is what i want is there a better approach i could have used using timedeltas? I choose my way because weeks in a month are not always constant.<br>
Thanks in Advance,<br>
Dean </p>
|
python
|
[7]
|
97,414 | 97,415 |
Posting form data from an ASP.Net Website to a MVC Web Application
|
<p>I have two distinct web sites, one an ASP.Net website and the other a ASP.Net MVC web application. I want to be able to post form data (about 15 fields) from the ASP.Net website to the MVC web application. </p>
<p>Ideally I'd like to be able to create a complex object containing all the form data and post it from the website to the controller action but I'm unsure if this is possible.</p>
<p>What are your thoughts on the best way to do this?</p>
|
asp.net
|
[9]
|
4,386,150 | 4,386,151 |
find public html folder using php's ftp functions
|
<p>I have a php script that logs into my servers via the ftp function, and backs up the entire thing easily and quickly, but I can't seem to find a way to let the script determine the folder where the main index file is located.</p>
<p>For example, I have 6 servers with a slew of ftp accounts all set up differently. Some log into the FTP root that has httpdocs/httpsdocs/public_html/error_docs/sub_domains and folders like that, and some log in directly to the httpdocs where the index file is. I only want to backup the main working web files and not all the other stuff that may be in there</p>
<p>I've set up a way to define the working directory, but that means I have to have different scripts for each server or backup I want to do.</p>
<p>Is it possible to have the php script find or work out the main web directory?
One option would be to set up a database that has either the directory to use or nothing if the ftp logs in directly to that directory, but I'm going for automation here. </p>
<p>If it's not possible I'll go with the database option though.</p>
|
php
|
[2]
|
5,362,314 | 5,362,315 |
i cant change static void Main(string[] args)
|
<p>i cant change static void Main(string[] args) in console application
can any one please say me how to change it to anything else</p>
|
c#
|
[0]
|
1,022,320 | 1,022,321 |
Why it is necessary to mention http while redirecting
|
<p>I have done a sample code to redirect to google by clicking on an hyperlink</p>
<p>This one worked fine</p>
<pre><code><asp:HyperLink ID="MyHyperLinkControl" NavigateUrl="http://google.com""
runat="server">link</asp:HyperLink>
</code></pre>
<p>But this does not work </p>
<pre><code><asp:HyperLink ID="MyHyperLinkControl" NavigateUrl="www.google.com"
runat="server">link</asp:HyperLink>
</code></pre>
<p>Can any one give me a detail explanation please</p>
|
asp.net
|
[9]
|
1,110,043 | 1,110,044 |
exception in thread 'main' java.lang.NoClassDefFoundError:
|
<p>The following program is throwing error:</p>
<pre><code>public class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
CLASSPATH C:\Program Files\Java\jdk1.6.0_18\bin\
Path C:\Program Files\Java\jdk1.6.0_18\bin\
JAVAHOME C:\Program Files\Java\jdk1.6.0_18\bin
</code></pre>
<p>Can you please tell me the root cause?</p>
|
java
|
[1]
|
3,994,387 | 3,994,388 |
iphone - table with multiple selections
|
<p>When you have multiple selections enabled for a table and select some cells, the selected cell have a red checkmark on the LEFT side. (see picture) Don't mistake with the right side checkmark.</p>
<p>I have this in place</p>
<pre><code>-(UITableViewCellEditingStyle)tableView:(UITableView*)tableView editingStyleForRowAtIndexPath:(NSIndexPath*)indexPath {
return UITableViewCellAccessoryCheckmark;
}
</code></pre>
<p>Everything is fine. When I tap a cell a red check appears on the LEFT side.</p>
<p>At some point I have to iterate thru the table to discover which cells have this left checkmark. </p>
<p>As far as I tested this is not an accessoryType or a editingStyle. At least in my tests no cell could be detected as selected testing for these properties.</p>
<p>thanks</p>
<p><img src="http://i.stack.imgur.com/0OGVl.png" alt="alt text"></p>
|
iphone
|
[8]
|
1,075,951 | 1,075,952 |
Is there a way to get user declared variables in PHP?
|
<p><strong>get_defined_vars</strong> is about to (citation):</p>
<blockquote>
<p>return a multidimensional array containing a list of all defined variables, be them environment, server or user-defined variables</p>
</blockquote>
<p>well, for my debugging task, I need only those user-defined. Is there php-built-in or supplement function?</p>
<p>EDIT:
Ok I didn't made clear what exactly I was after, here is little example:</p>
<pre><code><?php
/*
this script is included, and I don't have info
about how many scripts are 'above' and 'bellow' this*/
//I'm at line 133
$user_defined_vars = get_user_defined_vars();
//$user_defined_vars should now be array of names of user-defined variables
//what is the definition of get_user_defined_vars()?
?>
</code></pre>
|
php
|
[2]
|
586,243 | 586,244 |
How to get the input and textarea values on change function using jquery
|
<pre><code> $('#filedset').find("select, input, textarea").change(function() {
alert($(this).val());
});
</code></pre>
<p>if I use this code when I change anything on my dropdownlistbox I am getting alert but when I change anything on my Input or textarea changed text i am getting on alert?</p>
<p>is that something i am doing wrong?</p>
<p>thanks</p>
|
jquery
|
[5]
|
3,257,001 | 3,257,002 |
Compare double to decimal value
|
<p>Never needed to do this before till now. </p>
<p>trying to make sure the chargeAmount (which is type decimal) does not go below 1 cent:</p>
<pre><code> if (chargeAmount < 0.01)
throw new ArgumentOutOfRangeException("chargeAmount");
</code></pre>
<p>I tried 0.01D but obviously I am not sure how you format this.</p>
|
c#
|
[0]
|
1,152,888 | 1,152,889 |
How can i detect whether a string is not written in english
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1441562/detect-language-from-string-in-php">detect language from string in PHP</a> </p>
</blockquote>
<p>is there any function in php with which i can assume that there are not any english characters written in a particulsr string.</p>
|
php
|
[2]
|
951,784 | 951,785 |
Android app crashes when retrieving Last Known Location with Location Manager for GPS
|
<p>To be clear: This is an activity in my Android application that is meant to pull the coordinates for the users location using the GPS_PROVIDER. The Activity contains a button which, when pressed, should initiate a method that obtains the coordinate data. The problem is that the application crashes when there is no previously known location information (ie if the phone was recently reset). If I open up the Maps application (for example) and pinpoint my location, then re-open my own application and run this method, it works as intended. My question is why is this crashing and/or how can I prevent this crash from occurring? Help is appreciated, thanks.</p>
<p>This method is run when the button is pressed - and an intent response is generated back to the calling activity when the coordinates are properly found:</p>
<pre><code>protected void getCurrentLocation() {
Location location = null;
try {
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
} catch (IllegalArgumentException iae) { }
if (location != null) {
longV = location.getLongitude();
latV = location.getLatitude();
response(longV, latV);
} else {
getCurrentLocation();
}
</code></pre>
|
android
|
[4]
|
1,451,124 | 1,451,125 |
can not add UILabel to view
|
<p>I am trying to add a UILabel anagrammatically like below</p>
<pre><code>- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg"]]];
[self loadAndDrawButtons];
CGRect frame = CGRectMake(357, 240, 48, 42);
CGRect frame = CGRectMake(357, 200, 48, 42);
UILabel *myLabel = [[UILabel alloc] initWithFrame:frame];
[myLabel setText:@"THIS"];
[myLabel setBackgroundColor:[UIColor clearColor]];
[myLabel setTextColor:[UIColor redColor]];
[myLabel setShadowOffset:CGSizeMake(1, 1)];
[myLabel setShadowColor:[UIColor darkGrayColor]];
[self.view addSubview:myLabel];
}
</code></pre>
<p>So first I set the background for <strong>view</strong> and then I also display some button on the view. Background and button are successfully loaded. Eventually, I am adding a UILabel to <strong>view</strong> and I end up with nothing....
I am thinking that the background and my button will hide my UILabel( I know this is not right way but also give it a try) so that I comment out </p>
<blockquote>
<p>// [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg"]]];</p>
<p>// [self loadAndDrawButtons];</p>
</blockquote>
<p>Now my view is blank without my UILable...
Could any one give my a hint about this problem...Thanks a lot</p>
|
iphone
|
[8]
|
4,236,033 | 4,236,034 |
Does not return java function annotation
|
<p>Is there any way to force the compiler (annotation or othewise) to realize a java function is never returning (i.e. always throwing), so that subsequently it will not error out its usages as the last statement in other functions returning non void?</p>
<p>Here's a simplified/made-up example:</p>
<pre><code>int add( int x, int y ) {
throwNotImplemented(); // compiler error here: no return value.
}
// How can I annotate (or change) this function, so compiling add will not yield an error since this function always throws?
void throwNotImplemented() {
... some stuff here (generally logging, sometimes recovery, etc)
throw new NotImplementedException();
}
</code></pre>
<p>Thank you.</p>
|
java
|
[1]
|
4,284,510 | 4,284,511 |
How to get server-side parameters using jQuery UI remote?
|
<p>I have a php ajax script that is getting called by some jQuery, and I can not seem to get the parameters that are being passed. Here is the example I am working from: <a href="http://jqueryui.com/demos/autocomplete/#remote" rel="nofollow">http://jqueryui.com/demos/autocomplete/#remote</a></p>
<p>In my php side, I did something like this just to see what my parameters are:</p>
<pre><code>error_log ("1) ".var_dump($_GET));
error_log ("2) ".var_dump($_POST));
error_log ("3) ".var_dump($_REQUEST));
</code></pre>
<p>But they all return empty. Can that be? How can I get at the parameters that are being passed?</p>
<p>Thanks!!</p>
<p>Here is my js:</p>
<pre><code>$(function()
{
$( "#birds" ).autocomplete({
source: "/problems/get_categories_ajax.php",
minLength: 2,
select: function( event, ui )
{
log( ui.item ?
"Selected: " + ui.item.value + " aka " + ui.item.id :
"Nothing selected, input was " + this.value );
}
});
</code></pre>
|
php
|
[2]
|
848,066 | 848,067 |
inheritance and pointer uses - advice for correct use
|
<pre><code>class A
{
public:
A(int i):pi(&i){}
int* func()
{
//dosomething
return pi;
}
private:
int*pi;
};
class B:public A
{
A*pa;
public:
int* bar()
{
//dosomething
return pa->func();
}
};
int main()
{
A*pa=new B();
int*pi=pa->bar();
delete pa;
return 0;
}
</code></pre>
<p>Could someone please provide any tips if my above classes (I narrowed it smaller for better view) are good to enter ? I am a little worried that I pick a wrong choice.</p>
|
c++
|
[6]
|
4,814,359 | 4,814,360 |
Serial keys: What to do?
|
<p>I've been reading some posts here and articles around the web but I can't picture a serial keys based system for my application.</p>
<p><a href="http://www.brandonstaggs.com/2007/07/26/implementing-a-partial-serial-number-verification-system-in-delphi/" rel="nofollow">http://www.brandonstaggs.com/2007/07/26/implementing-a-partial-serial-number-verification-system-in-delphi/</a></p>
<p>I read this one but I can't turn the code into Java and I'm not very familiar with the terms either.</p>
<p>What possible insight can you give me on this? Ideally my application will be for sale but I don't expect it to be much popular, I don't mind much if it gets cracked if I have users that appreciate the product and buy it, but I want to avoid it to be easily cracked. Please be as specific as you can, I'm somewhat new to Java.</p>
<p>Thanks in advance.</p>
|
java
|
[1]
|
2,081,762 | 2,081,763 |
What's the most pythonic method for specifying a configuration file?
|
<p>I'm writing a daemon script in Python and would like to be able to specify settings in a file that the program expects to read (like .conf files). The standard library has configparser and xdrlib file formats, but neither seems pythonic; the former being a Microsoft standard and the latter a Sun Microsystems standard.</p>
<p>I could write my own, but I'd rather stick to a well-known and documented standard, than reinvent the wheel.</p>
|
python
|
[7]
|
3,666,946 | 3,666,947 |
Atrix external storage functions return internal sdcard and not removable sdcard
|
<p>I have a large (50 meg) download that I want to load to the sdcard if is mounted. If there is no sdcard, I download it to internal storage. I check for space available in both cases.</p>
<p>My code works great on the emulator and my Droid 2. My Atrix is a different story.</p>
<p>The Motorola Atrix has a built in sdcard. It can also have an external sdcard. The directories are mnt/sdcard and mnt/sdcard-ext. When checking external storage state, Environment.MEDIA_MOUNTED is always returned. When using Environment.getExternalStorageState(), Environment.MEDIA_MOUNTED is always returned. The standard external storage functions ignore the removable sdcard.</p>
<p>Is this unique to the Atrix? If not, do the other devices use sdcard-ext for the removable sdcard?</p>
<p>I really don't want to start coding for specific devices...</p>
|
android
|
[4]
|
4,479,206 | 4,479,207 |
How would I go about implementing a schedule system for a bunch of factory stations
|
<p>I have 5 stations that workers take their tasks from, tasks are of varying length. I am looking to carve up an interactive view that will allow their supervisor to drag around and resize tasks on a day view. Are there any advanced libraries that already do this?</p>
<p>EDIT: Reworded for clarity</p>
|
java
|
[1]
|
1,247,835 | 1,247,836 |
How to select some data from DataTable
|
<p>I want to search some data from DataTable to show in GridView. </p>
<p>Like </p>
<pre><code>(select * from customer where id="1")
</code></pre>
<p>Can I do that?</p>
|
asp.net
|
[9]
|
4,632,670 | 4,632,671 |
Feeding data from memory to MediaPlayer
|
<p>Scenario:
Have encrypted mp3 files in my .apk. Need to decrypt and send to MediaPlayer object.</p>
<p>Problem:
After I read the files and decrypt them, how do I get MediaPlayer to play them ?</p>
<p>Now. MediaPlayer has 4 versions of setDataSource().</p>
<pre><code>setDataSource(String path)
setDataSource(FileDescriptor fd)
setDataSource(FileDescriptor fd, long offset, long length)
setDataSource(Context context, Uri uri)
</code></pre>
<p>None of which are ideal for the situation. Guess ideal would be to give MediaPlayer an InputStream ?</p>
<p>Possible solutions:</p>
<ul>
<li>Write decrypted data to file play
that file. A lot of IO overhead.</li>
<li>Create a dummy http server
(ServerSocket ?) and pass the url to
MediaPlayer. Again, messy. Am I
even allowed to create a socket.</li>
</ul>
<p>Does anyone have a better solution ?</p>
|
android
|
[4]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.