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 |
---|---|---|---|---|---|
4,331,759 | 4,331,760 |
parse_str appending ampersand to elements?
|
<p>I've been playing around with cURL, and am trying to send an array through as POST variables. I've decided to use http_build_query to pass the string as expected: </p>
<pre><code>curl_setopt($this->ch, CURLOPT_POSTFIELDS, http_build_query($sendParams));
</code></pre>
<p>I have the receiving end simply <code>print_r</code>'ing the $_POST, so I can see what is being sent through.</p>
<p>However, I am getting an ampersand attached to all of the parent elements <em>after</em> the first, is this normal? I assume that parse_str is used by cURL when parsing the querystring, so here is a super-simplified example that also leads to the ampersands:</p>
<pre><code><?php
$array = array('foo', array('bar' => array('baz' => array(1,2,3))), 'test' => array(2,3,4));
parse_str(http_build_query($array), $vars);
print_r($vars);
?>
</code></pre>
<p>Returns:</p>
<pre><code>Array ( [0] => foo [amp;1] => Array ( [bar] => Array ( [baz] => Array ( [0] => 1 [1] => 2 [2] => 3 ) ) ) [amp;test] => Array ( [0] => 2 [1] => 3 [2] => 4 ) )
</code></pre>
|
php
|
[2]
|
5,512,314 | 5,512,315 |
Can inetAddress be used with inet6/IPv6?
|
<p>Can inetAddress be used with inet6/IPv6?</p>
|
java
|
[1]
|
3,302,134 | 3,302,135 |
send parameters to given url from android using get method
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/13530030/how-to-send-parameters-to-given-url-from-android">how to send parameters to given url from android</a> </p>
</blockquote>
<p>Need to send parameters through a url to web server </p>
<p>url ="http://www.example.com/emilwwy/index.php?regno="+RegisterNo+"&date="+Date;</p>
<p>Can anybody post the code with supporting libraries here</p>
|
android
|
[4]
|
3,053,308 | 3,053,309 |
makefile error for c++
|
<p>What is this error</p>
<pre><code>:!make
g++ -g -I../direc1 -I./ -c final.cpp
make: g++: Command not found
make: *** [final.o] Error 127
</code></pre>
<p>?</p>
|
c++
|
[6]
|
1,038,570 | 1,038,571 |
returning code of function instead of result
|
<p>I saved a function created in jQuery in clean.js file..</p>
<pre><code>jQuery.fn.singleDotHyphen = function(){
return this.each(function(){
var $this = $(this);
$this.val(function(){
return $this.val()
.replace(/\.{2,}/g, '.')
.replace(/-{2,}/g, '-');
});
});
};
</code></pre>
<p>My action file is..</p>
<pre><code><script type="text/javascript">
$(document).ready(function() {
$.noConflict();
$('#title').limitkeypress ({ rexp:/^[A-Za-z.\-\s`]*$/ });
$('#title').blur(function() {
$(this).singleDotHyphen();
});
});
</script>
</code></pre>
<p>Issue is onblur its returning me code of the function where as I want to return the string that reject continuous hyphen and dots...</p>
|
jquery
|
[5]
|
1,441,952 | 1,441,953 |
Missing section declaration (system.web.extensions)
|
<p>I am encountering an issue wherein when I added the system.web.extensions on my web.config, I am getting the error saying, "Missing section declaration(system.web.extensions)".</p>
<p>The main root of this issue comes from another issue, which says "System.InvalidOPerationException: Error during serialization or deserialization using the JSON JavaScriptSerializer.", so when I researched for answers, they said that you need to add this configuration on your web.config,</p>
<pre><code><system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="500000">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>
</code></pre>
<p>But when I add this code, I am getting the "missing declaration issue", question is, what file/s do I need to modify so that the system.web.extensions can be read by my web.config? I am getting stuck here.</p>
<p>@edit: My web application is running on a V2.0, is this achievable using this version?</p>
<p>Thanks.</p>
|
asp.net
|
[9]
|
637,957 | 637,958 |
Equivalent is_file() function for URLs?
|
<p>What is the best way to check if a given url points to a valid file (i.e. not return a 404/301/etc.)? I've got a script that will load certain .js files on a page, but I need a way to verify each URL it receives points to a valid file.</p>
<p>I'm still poking around the PHP manual to see which file functions (if any) will actually work with remote URLs. I'll edit my post as I find more details, but if anyone has already been down this path feel free to chime in.</p>
|
php
|
[2]
|
259,644 | 259,645 |
Which is better loading of images for ListView?
|
<p>I am wondering if which of the two is better in loading images in a listview from web, is it by batch through some number of threads that are running simultaneously or one by one through thread queue?</p>
<p>I have noticed (but I don't know if that is really the implementation) from the youtube app that the images are loaded by batch and it is kinda fast. Even for not only loading images but also requesting some data from the web as well. Does anyone have an idea?</p>
|
android
|
[4]
|
3,135,699 | 3,135,700 |
Module API mismatch between PHP and SSH2 module
|
<p>I'm trying to install the ssh2 extension for PHP, and after hours of working on it, I've near figured it out. I think.</p>
<p>It's compiled and the ssh2.so is in the correct directory and all. The problem, I believe, is version mismatches.</p>
<p>Here's the error it's spouting for me:</p>
<pre><code>PHP Warning: PHP Startup: ssh2: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
</code></pre>
<p>I'm pretty much at a dead end. How can I get the correct ssh2 module API?</p>
|
php
|
[2]
|
4,530,432 | 4,530,433 |
how to set the softkeyboard to show german keys in android
|
<p>i have to make an application in german, and in one of the activities i have to searching.</p>
<p>i have an edittext control for the same. but i want the user to input the text in german, how do set the softkeyboard to pop up with german keys?</p>
<p>thank you in advance.</p>
<p>EDIT: My application is using android 2.2.</p>
|
android
|
[4]
|
1,165,773 | 1,165,774 |
Internet Explorer innerHTML "Object doesn't support this property or method"
|
<p>I have a script that checks the value of a Div Id.</p>
<pre><code> <div id="hour" style="display:none;">2</div>
<div id="min" style="display:none;">1</div>
<div id="sec" style="display:none;">3</div>
hour = document.getElementById("hour").innerHTML;
min = document.getElementById("min").innerHTML;
sec = document.getElementById("sec").innerHTML;
</code></pre>
<p>Works in Chrome, but not in Internet Explorer (Which is where I need it to work)</p>
<p>It gives me the error, "Object doesn't support this property or method"</p>
<p>What is the easier way (preferably one line) to get around this?</p>
|
javascript
|
[3]
|
1,186,302 | 1,186,303 |
forcing a variable to hold certain values only
|
<p>I am using vs 2012. I have a simple string property</p>
<pre><code> string _someString;
public string MyString
{
get
{
return _someString;
}
}
</code></pre>
<p>I want this property to hold only certain values. So that when the client uses this property only those certain values can be used. </p>
|
c#
|
[0]
|
1,899,999 | 1,900,000 |
How to do i need to implemnet paging for jquery grid
|
<p>I have a gird with user data around like 5000 users in the grid..
right now I am displaying all the users in the grid.. but I need to make it like only 500 user for page..
so i need to implement paging in the grid with previous and next buttong on the bottom of the page..
can any body tell me how to do this?</p>
<p>thanks</p>
|
jquery
|
[5]
|
912,710 | 912,711 |
Compare results of different php versions online
|
<p>There is a page where you can compare results of php code in different php versions but I just can't find it. Found it on Stackoverflow some time ago. It was nice because you did not select a version. It just runs the code in all versions and compares the output.</p>
<p>Does someone know what page I am looking for?</p>
|
php
|
[2]
|
2,637,853 | 2,637,854 |
How to force a method to be overridden in java?
|
<p>newbie question.. I have to create a lot of very similar classes which have just one method different between them. So I figured creating abstract class would be a good way to achieve this. But the method I want to override (say, method foo()) has no default behavior. I don't want to keep any default implementation, forcing all extending classes to implement this method. How do I do this?</p>
|
java
|
[1]
|
1,714,124 | 1,714,125 |
jQuery -> Selected Element to HTML
|
<p>I am trying to wrap specific elements in a box if the visitor is using < IE9 so I can apply a box shadow across all browsers.</p>
<p>Unfortunately I cannot quite work out how to do it. Does anyone know how to convert the selected element back into HTML?</p>
<pre><code><script>
$(document).ready(function() {
$('img').each(function() {
var img = $(this).clone();
var html = '<div class="bounding">'+$(img)+'</div>';
$(this).replaceWith(html);
});
});
</script>
</code></pre>
<p>The script is printing out <code>[object Object]</code>. <code>.html()</code> doesn't work because that is basically innerHTML. Is there a jQuery function that achieves this?</p>
|
jquery
|
[5]
|
507,229 | 507,230 |
Best way to select n elements at a time in jQuery
|
<p>I have an <code>ul</code> of <code>li</code> elements, what I want to do is this:</p>
<ol>
<li>If there are 6 or less <code>li</code> elements, select them all and put them into a new <code>ul</code>.</li>
<li>For any number greater than 6 elements, loop through, selecting 6 elements, put into new <code>ul</code>, start at the next <code>li</code> element and continue.</li>
<li>If there are less than 6 element left at the end, they get put into a new <code>ul</code> as well.</li>
</ol>
<p>If I start out with 5 <code>li</code> elements, I would hope to end up with 1 <code>ul</code> element with 5 <code>li</code> children.</p>
<p>If I start out with 40 <code>li</code> elements, I would hope to end up with 7 <code>ul</code> elements, 6 with 6 <code>li</code> children and 1 with 4.</p>
<p>What would be the most efficient way of handling this in jQuery?</p>
|
jquery
|
[5]
|
2,368,468 | 2,368,469 |
circularly linked list in python
|
<p>I am stuck implementing the add function of a circularly linked list in python. I have a head pointer that should be a reference to a node, but every time I add something to the list, head is always None. Here is the code I have so far:</p>
<pre><code>class CircleList():
__slots__ = ('head', 'size')
def __init__(self):
self.head = None
self.size = 0
def __str__(self):
result = "<"
node = self.head
count = self.size
while count != 0:
result = result + str(node.data)
if count != 1:
result = result + ", "
node = node.next
count -= 1
result = result + ">"
return result
def add(self, element):
head = self.head
print(head)
size = self.size
if head == None:
head = Node(element, None)
head.next = head
else:
cursor = head
while cursor.next != head:
cursor = cursor.next
temp = Node(element, head)
cursor.next = temp
size += 1
class Node():
__slots__ = ('data','next')
def __init__(self, data, next):
self.data = data
self.next = next
</code></pre>
<p>Here is the driver:</p>
<pre><code>stream = open('data.txt', 'r')
circlelist = CircleList()
for name in stream
circlelist.add(name)
print(circlelist)
</code></pre>
|
python
|
[7]
|
1,391,753 | 1,391,754 |
how to get indication of "success" from removeall
|
<p>i want to know if my function did remove from my list or not here is my code:</p>
<pre><code> public int RemovePassenger(string name)
{
Passengers.RemoveAll(x => x.PassengerName == name);
return //if the passenger actually been remove or not
}
</code></pre>
|
c#
|
[0]
|
4,585,184 | 4,585,185 |
function return two values
|
<p>I want to ask how effective is this function and if there are any situations when I can use it. Thanks for any answers.</p>
<pre><code>function sum_and_dif(a, b) {
var c = a + b;
var d = a - b;
return c +" " + d;
}
var result = sum_and_dif (200, 10);
document.write(result +"</br>");
var where_is_a = result.indexOf(" ");// Here i detected where is the empty space
var c_number = parseInt(result.substring(0, where_is_a));
var d_number = parseInt(result.substring(where_is_a +1,result.length));
document.write(c_number +"</br>");
document.write(d_number +"</br>");
</code></pre>
|
javascript
|
[3]
|
5,392,345 | 5,392,346 |
How do I append a page's URL to a social media 'sharing' URL in jQuery?
|
<p>How do I create a link that takes the static part of a 'sharing' link (of a social media site like LinkedIn) and appends the url of the current page? So that a user can share the page's URL on their social media account.</p>
<p>I do not want to use Share This or any other such widgets.</p>
<p>Thanks</p>
<p><strong>EDIT</strong></p>
<p>So of the solutions suggested I opted for the jQuery one. After a lot of help, this was the solution:</p>
<p>HTML</p>
<pre><code><a class="linkedin" href="#">LinkedIn</a>
</code></pre>
<p>jQuery</p>
<pre><code>$(document).ready(function() {
$('a.linkedin').click(function() {
var link = document.location;
var url = "https://www.linkedin.com/shareArticle?mini=true&url=" + link;
document.location.href = url;
});
});
</code></pre>
<p>Obviously, it can work for any social media site that allows such URLs.</p>
|
javascript
|
[3]
|
1,445,987 | 1,445,988 |
MS Studio 2008 plugin - Change icon in solution explorer
|
<p>I was exploring on the web but didn't find anything useful..</p>
<p>I managed to read item's name but nothing more..</p>
|
c#
|
[0]
|
4,394,746 | 4,394,747 |
To pass values in a table as an array to javascript
|
<p>Is there a way that I could pass 5 values of a field from a table as an array to javascript function on onchange event of a dropdown box.</p>
<p>The 5 values have to be fetched through sql query.</p>
|
javascript
|
[3]
|
951,248 | 951,249 |
Is there any way to check timer is runned at defined period?
|
<p>i developed an application which sends birthday wishes on facebook wall, but when i am calling someone at same time that i set for sending wishes, then wishes failed to post on facebook wall.
I used Alarm Manager first.
But i want to use timer class and in that timer class i want to check that message is posted to wall or not at defined time or if not then i want to reschedule the timer class to send post.
i have this code for timer class </p>
<pre><code> private final Timer clockTimer;
private class Task extends TimerTask {
public void run() {
timerHandler.sendEmptyMessage(0);
}
}
private final Handler timerHandler = new Handler() {
public void handleMessage (Message msg) {
// runs in context of the main thread
timerSignal();
}
};
private List<SystemTimerListener> clockListener = new ArrayList<SystemTimerListener>();
public SystemTimerAndroid() {
clockTimer = new Timer();
clockTimer.schedule(new Task(), 1000, 1000);
}
private void timerSignal() {
for(SystemTimerListener listener : clockListener)
listener.onSystemTimeSignal();
}
public void killTimer() {
clockTimer.cancel();
}
@Override
public void addListener(SystemTimerListener listener) {
clockListener.add(listener);
}
</code></pre>
<p>this code is repeating after every second so i want to check if it runned for first time then stop the timer and reschedule for next day and so on...
Please help me. </p>
|
android
|
[4]
|
3,125,032 | 3,125,033 |
The field that I set on an global array does not persist
|
<p>On my PHP web-page I have a global array:</p>
<pre><code>$test = array();
</code></pre>
<p>Then I invoke this function:</p>
<pre><code>function f ()
{
global $test;
init( $test );
$test['foo'] // Error: undefined index "foo"
}
</code></pre>
<p>which in turn invokes this function:</p>
<pre><code>function init ( $test )
{
$test['foo'] = 'bar';
$test['foo'] // evaluates to'bar'
}
</code></pre>
<p>As you can see, I get an error. The "foo" field that I've added to the array inside <code>init()</code> did not persist. Why does this happen? I thought I was mutating the global <code>$test</code> inside <code>init()</code>, but it seems that I'm not doing that. What's going on here, and how can I set a "foo" field inside <code>init()</code> that persists?</p>
|
php
|
[2]
|
2,920,870 | 2,920,871 |
Animate a line drawn in CGContext
|
<p>Is there any way to animate a line or circle drawn using Core Graphics?</p>
<p>Thanks in advance!!</p>
|
iphone
|
[8]
|
1,483,630 | 1,483,631 |
Change text color When something is Entered in text box
|
<p>i have form that has multiple input text boxes, Which has got some text message in light color. When User Types something That text should Become Dark.
I got a jquery code which is working, but i cannot use that for multiple text boxes</p>
<pre><code><html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>
<style>
input{color:grey}
</style>
</head>
<body>
<div class="formWrapper">
<form name=form>
<Input type="text" name="name1" value="Eg : Flat-27,Block 4,Skyline" size="30">
</form>
</div>
<script>
$('input').focus(function(){
if($(this).val() == this.defaultValue){$(this).val('');$(this).css("color","Red");}
}).blur(function(){
if($(this).val() == ''){$(this).val(this.defaultValue);$(this).css("color","grey");}
});
</script>
</body>
</html>
</code></pre>
|
javascript
|
[3]
|
162,752 | 162,753 |
Getting content of a website via PHP
|
<p>How do I get the content of a page via PHP? How do i grab the text of a blog post because most RRS feed only give the link to the article so i cant use that. Is there a PHP function for this or anyway about doing this. Please offer some suggestions :).</p>
|
php
|
[2]
|
2,137,786 | 2,137,787 |
Jquery onClick but on Tab
|
<p>This code works fine when the user clicks a field. I want it so that when they tab (press the alt key) or ANY key.. no matter what happens, if this field is active, run this jQuery code. So far I only know .click()</p>
<pre><code>jQuery(document).ready(function(){
$("#fullname").click(function(){
$("#note_email").fadeIn();
});
});
<input type="text" name="fullname" id="fullname" value="" /><div style="display:none" id="note_email">Your name is case sensitive</div>
</code></pre>
|
jquery
|
[5]
|
2,753,220 | 2,753,221 |
how to delete the dynamic uibutton
|
<p>Hello
I have some codes to create dynamic button as below:</p>
<pre><code>- (void)viewDidLoad {
for (int i = 0; i < 9; i++)
for (int j = 0; j < 8; j++) {
forControlEvents:UIControlEventTouchDown];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(10+i*34 , 130+j*30, 30 , 20 );
[button setTitle:@"00" forState: UIControlStateNormal];
[button addTarget:self action:@selector(tapped:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
button.tag = i;
}
}
</code></pre>
<p>I hope to delete the dynamic uibuttons and recreate them.</p>
<p>How can I do</p>
<p>Welcome any comment.</p>
<p>Thanks
interdev</p>
|
iphone
|
[8]
|
4,849,256 | 4,849,257 |
Div left position change using animate function
|
<p>i have 3 div's & one button</p>
<pre><code><div id="Outer">
<div id="main" style='height:200px;width:300px'/>
<div id="child" style='height:20px;'/>
</div>
</code></pre>
<p>when some one will click on the button then child div left will be -20px and gradually
its width will be increase until its width is become to the width of main div and when again click on button the reverse action will be happen.</p>
<p>how could i do this using jquery animate function. thanks</p>
|
jquery
|
[5]
|
2,070,410 | 2,070,411 |
SP.ClientContext.get_current() returning undefined objects
|
<p>I am trying to get some information about the current context through the sharepoint javascript object model and am getting annoying errors.</p>
<pre><code>$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(loadConstants, "sp.js"); });
function loadConstants() {
var ctx = new SP.ClientContext.get_current();
var site = ctx.get_site();
IPC_siteUrl = site.get_url();
IPC_siteId = site.get_id();
var web = ctx.get_web();
}
</code></pre>
<p>This is what im calling in a javascript file in our core javascript file, and when i try to call "ctx.get_site()" I am getting errors through the dev console on ie8.</p>
<p>The property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.</p>
<p>Im not sure why this is happening as im following Microsofts directions.</p>
<p>Any thoughts?</p>
|
javascript
|
[3]
|
890,656 | 890,657 |
send sms programaticaly
|
<p>in my application i wan to send predefine smstext to one single number on certain event ,
it is possible to send sms like that! if yes please help me with sample code </p>
|
iphone
|
[8]
|
809,147 | 809,148 |
How can we custmize Check Box in Android?
|
<p>I want to display Check box like Radio button though is it possible to give our own shape to the check box
if possible than help me please thanks</p>
|
android
|
[4]
|
102,232 | 102,233 |
How to build a single python file from multiple scripts
|
<p>I have a simple python script, which imports various other modules I've written (and so on). Due to my environment, my PYTHONPATH is quite long. I'm also using Python 2.4.</p>
<p>What I need to do is somehow package up my script and all the dependencies that aren't part of the standard python, so that I can email a single file to another system where I want to execute it. I know the target version of python is the same, but it's on linux where I'm on Windows. Otherwise I'd just use py2exe.</p>
<p>Ideally I'd like to send a .py file that somehow embeds all the required modules, but I'd settle for automatically building a zip I can just unzip, with the required modules all in a single directory.</p>
<p>I've had a look at various packaging solutions, but I can't seem to find a suitable way of doing this. Have I missed something?</p>
<p>[edit] I appear to be quite unclear in what I'm after. I'm basically looking for something like py2exe that will produce a single file (or 2 files) from a given python script, automatically including all the imported modules.</p>
<p>For example, if I have the following two files:</p>
<pre><code>[\foo\module.py]
def example():
print "Hello"
[\bar\program.py]
import module
module.example()
</code></pre>
<p>And I run:</p>
<pre><code>cd \bar
set PYTHONPATH=\foo
program.py
</code></pre>
<p>Then it will work. What I want is to be able to say:</p>
<pre><code>magic program.py
</code></pre>
<p>and end up with a single file, or possibly a file and a zip, that I can then copy to linux and run. I don't want to be installing my modules on the target linux system.</p>
|
python
|
[7]
|
5,020,463 | 5,020,464 |
What does delete[] do if given a pointer to the middle of an array?
|
<p>What would happen in the following code?</p>
<pre><code> int *p1 = new int[100];
int *p2 = &p1[50];
delete [] p2;
</code></pre>
<p>I've heard that some implementations of new store the size of the array in the (-1)th array index, but then wouldn't things go horribly wrong in the above?</p>
|
c++
|
[6]
|
2,563,295 | 2,563,296 |
Declaring 'long' over 'int' in Java
|
<p>In Java, if <code>int</code> is enough for a field, and if I use <code>long</code> for some reason, would that cost me more memory? Does that vary on types?</p>
|
java
|
[1]
|
1,717,948 | 1,717,949 |
Can't remove intent extra!
|
<p>I'm creating a notification for the notification tray. I'm specifying a click intent like this:</p>
<pre><code>Intent intent = new Intent(context, MyActivity.class);
intent.putExtra("foo", true);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.setData(Uri.parse("" + System.currentTimeMillis()));
</code></pre>
<p>The MyActivity class gets launched just fine with the "foo" parameter present. However, I cannot get rid of that extra afterwards - it seems to persist in the Intent:</p>
<pre><code>// MyActivity
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// please go away..
intent.removeExtra("foo");
getIntent().removeExtra("foo");
}
</code></pre>
<p>Iterating over the keys of the intent shows that "foo" no longer exists. But if I background the activity, then bring it to the foreground again, the "foo" parameter is present again.</p>
<p>Anyone know how to really get rid of it? I've also tried calling setIntent(), same behavior. It's like the launcher holds onto the original intent and keeps reusing it.</p>
<p>Thanks</p>
|
android
|
[4]
|
4,813,743 | 4,813,744 |
How do you stop reading integer from text file when encounter negative integer?
|
<p>Im trying to write a simple code in c++ to read in integer from a text file, the code should stop reading when it encounter a negative integer. The txt file contains 1 positive integer on each line, and the last line is a negative integer. </p>
<p>My code right now using eof, and it reads in negative integer also, which I dont want.</p>
<pre><code>while(!inFile.eof())
{
inFile >> data;
}
</code></pre>
<p>Text file</p>
<pre><code>10
22
33
34
-1
</code></pre>
<p>Thanks in advance :)</p>
|
c++
|
[6]
|
788,519 | 788,520 |
JavaScript Inheritance
|
<p>I am trying to implement inheritance in javascript. I came up with following minimal code to support it.</p>
<pre><code>function Base(){
this.call = function(handler, args){
handler.call(this, args);
}
}
Base.extend = function(child, parent){
parent.apply(child);
child.base = new parent;
child.base.child = child;
}
</code></pre>
<p>Experts, please let me know if this will be sufficient or any other important issue I may have missed. Based on similar issues faced please suggest other changes.</p>
<p>Here is complete test script:</p>
<pre><code>function Base(){
this.call = function(handler, args){
handler.call(this, args);
}
this.superalert = function(){
alert('tst');
}
}
Base.extend = function(child, parent){
parent.apply(child);
child.base = new parent;
child.base.child = child;
}
function Child(){
Base.extend(this, Base);
this.width = 20;
this.height = 15;
this.a = ['s',''];
this.alert = function(){
alert(this.a.length);
alert(this.height);
}
}
function Child1(){
Base.extend(this, Child);
this.depth = 'depth';
this.height = 'h';
this.alert = function(){
alert(this.height); // display current object height
alert(this.a.length); // display parents array length
this.call(this.base.alert);
// explicit call to parent alert with current objects value
this.call(this.base.superalert);
// explicit call to grandparent, parent does not have method
this.base.alert(); // call parent without overriding values
}
}
var v = new Child1();
v.alert();
alert(v.height);
alert(v.depth);
</code></pre>
|
javascript
|
[3]
|
246,537 | 246,538 |
C++ how to write an operator that isn't a member function?
|
<p>Anyone got an idea on how to write an operator for a class that isn't a member function of the class?</p>
|
c++
|
[6]
|
3,043,857 | 3,043,858 |
How to merge the 3d transformed image?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/12457047/how-to-merge-the-perspective-image3d-transform">How to merge the perspective image(3D Transform)?</a> </p>
</blockquote>
<p>How to merge the 3D transformed image with the background image? I am using the below code.</p>
<pre><code>UIGraphicsBeginImageContext(backgroundImageView.frame.size);
[backgroundImageView.layer renderInContext:UIGraphicsGetCurrentContext()]; //bacgroundImageView here
overlappedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
</code></pre>
<p>Its working fine, but I change the 3D transform to that image(cat image<img src="http://i.stack.imgur.com/Ep26k.png" alt="enter image description here">) Its not working. Please see the attached image. 1st image is transformed image, 2nd image is merged image(this is the issue).Please help me. I have wasted more time for this issue. I hope any one help me. Thanks in advance. </p>
|
iphone
|
[8]
|
4,503,648 | 4,503,649 |
Java, declare variable with multiple interfaces?
|
<p>In Java, is it possible to declare a field/variable whose type is multiple interfaces? For example, I need to declare a <code>Map</code> that is also <code>Serializable</code>. I want to make sure the variable references a serializable map. The <code>Map</code> interface does not extend <code>Serializable</code>, but most of <code>Map</code>'s implementations are <code>Serializable</code>.</p>
<p>I'm pretty sure the answer is no.</p>
<p><strong>Follow up</strong>: I'm fully aware of creating a new interface that extends both <code>Map</code> and <code>Serializable</code>. This will not work as existing implementations (such as <code>HashMap</code>) do not implement my new interface.</p>
|
java
|
[1]
|
1,288,762 | 1,288,763 |
Reverse a character array
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1128985/c-reverse-array">C++ Reverse Array</a> </p>
</blockquote>
<p>How can I reverse a character array? Like this:</p>
<pre><code>char word1[10] = "this";
char word2[10] = word1[10] // in reverse
cout<<word2; // I want it to output "siht"
</code></pre>
|
c++
|
[6]
|
885,417 | 885,418 |
Best way to use PHP to run another remote php script
|
<p>I am wanting to create a web-based cronjob system for my userbase, and would need to know the best way to open a php script on a remote server, and ensure the script runs (could take 3 minutes), and use the least ammount of resources on my own side. </p>
<p>There is the possibility of having hundreds of connections open at one time. </p>
<p>Any advice on how I should go about doing this?</p>
<p>Thanks allot,
Hudson</p>
|
php
|
[2]
|
4,157,991 | 4,157,992 |
Read response of HTTP POST sent from UIWebView
|
<p>Is it possible on IOS 5.1 sdk to read the response of an HTTP post sent from UiWebView in an iPHone app. So the user has browsed to a 3rd party site in the UIWebView and POSTED a form and the server responds to that. I need to know if it possible to intercept the response and then use the results in the app.</p>
<p>Thanks</p>
|
iphone
|
[8]
|
202,579 | 202,580 |
reference type size in java
|
<p>Why does a reference type in java take 8 bytes? Why not less or more than 8 bytes?</p>
|
java
|
[1]
|
2,289,568 | 2,289,569 |
Replace Symbols with jQuery
|
<p>Im looking for function that will allow me to remove (replace) all symbols in my body tag apart from a-z letter.</p>
<p>Is there a simple way of doing this?</p>
<p>Many thanks in advance.</p>
|
jquery
|
[5]
|
4,219,383 | 4,219,384 |
jquery error message place in div (jquery.validate.js)
|
<p>I have the following script which validates pages using jquery.validate.js through a quiz and works perfectly. Im looking to have the error message for required fields to be placed into a div called errormessage. jQuery validate usually returns a message "this field is required".</p>
<p>Here is the script</p>
<pre><code><script type="text/javascript">
var curPage=1;
function NextPage() {
if (curPage < <?= $num; ?>) {
var group = "#page_" + curPage.toString();
var isValid =true;
$(group).find(':input').each(function (i, item) {
if (!$(item).valid())
isValid = false;
});
if( !isValid){ alert("PLEASE MAKE A SELECTION"); }
else{
$("#page_" + curPage.toString()).hide(); //hide current page div
curPage++; //increment curpage
$("#page_" + curPage.toString()).show(); //show new current page div
}
}
}
function PrevPage() {
if (curPage > 1) {
$("#page_" + curPage.toString()).hide(); //show new current page div
curPage--; //increment curpage
$("#page_" + curPage.toString()).show(); //hide current page div
}
}
function InitializePage() {
$(".wizardPage").hide();
$("#page_" + curPage.toString()).show();
$("#surveyForm").validate({onsubmit: false});
}
$(document).ready(InitializePage
);
</script>
</code></pre>
|
jquery
|
[5]
|
1,128,150 | 1,128,151 |
reading from stdin in c++
|
<p>i am trying to read from stdin using c++, using this code</p>
<pre><code>#include <iostream>
using namespace std;
int main() {
while(cin) {
getline(cin, input_line);
cout << input_line << endl;
};
return 0;
}
</code></pre>
<p>when i compile, i get this error..</p>
<pre><code>[root@proxy-001 krisdigitx]# g++ -o capture -O3 capture.cpp
capture.cpp: In function âint main()â:
capture.cpp:6: error: âinput_lineâ was not declared in this scope
</code></pre>
<p>any ideas whats missing?</p>
|
c++
|
[6]
|
1,538,601 | 1,538,602 |
Why 1.-5 = -4.0
|
<pre><code>public static void main(String[] args){
System.out.println(1.-5); // -4.0
}
</code></pre>
<p>Can anyone explain why i got the above result, thanks in advance.</p>
|
java
|
[1]
|
4,945,518 | 4,945,519 |
How do I get OnSubmit to grab an external file?
|
<p>I have this </p>
<pre><code> onsubmit="return validatePP(this);
</code></pre>
<p>I moved all of the validate function to an external file. How do I get it to call the external file?</p>
|
javascript
|
[3]
|
5,825,889 | 5,825,890 |
flash flyer image identification
|
<p>Hi Anyone know how can I access images from (adobe)flash flyer using PHP?.. let's say you have a weekly online flyer
<a href="http://homedepot.shoplocal.com/homedepot/default.aspx?action=entryflash&viewTaskName=ExternalDirectView&categoryId=523472" rel="nofollow">http://homedepot.shoplocal.com/homedepot/default.aspx?action=entryflash&viewTaskName=ExternalDirectView&categoryId=523472</a> </p>
<p>I need to find collaction of all the items "with image" which has "Scott's" in it using php </p>
<p>I need to do it for multiple stores for statistics. So I need to do this programmatically, sometimes they have flyer in HTML but I am looking specifically for flash.</p>
<p>pls. let me know if you have done this or have some suggestions..</p>
|
php
|
[2]
|
4,051,595 | 4,051,596 |
os.walk and read file, having some problems with walking the path
|
<p>Here is the entirety of my code, I am trying to debug it, but it seems like I can't do any reading of files while using os.walk. The problem is that without changing directories, I am hit with a error that 'out.csv' cannot be found, so i put in a chdir(), to move to that directory to read that file, but now it will only read that one file. My estimate is there should be over 300+ of these files. So it seems to stop after just the first file read after I put in the chdir().</p>
<pre><code>#! /usr/bin/env python
import csv, os
current = os.curdir
filescntd = 0
avg = 0
for root, dirs, files in os.walk('ARCIVE'):
for file in files:
base, ext = os.path.splitext(file)
if ('csv' in ext):
os.chdir(root)
print root
f = csv.reader(open('out.csv','rb'))
count = 0
for row in f:
if (count >= 6 and count <= 10):
tempavg = 0
for i in row:
tempavg += float(i)
filescntd += 1
tempavg /= len(row)
avg += tempavg
count += 1
os.chdir(current)
os.chdir(current)
print '---'
avg /= 5.0
print avg
</code></pre>
<p>output:</p>
<pre><code>ARCIVE/8-15-11/temp/29033
---
0.02775
</code></pre>
<p>the option of filescntd is a little misleading, it is the amount of numbers averaged, and it comes to 40.</p>
<p>To clarify, what I want this program to do, is walk this directory tree and open all files that contain 'csv' in the extension, and read lines 6-10, and average those lines. I am having problems with the walking the path and opening the files.</p>
|
python
|
[7]
|
715,384 | 715,385 |
Difference between == and === in JS
|
<blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/523643/difference-between-and-in-javascript">Difference between == and === in JavaScript</a><br>
<a href="http://stackoverflow.com/questions/359494/javascript-vs-does-it-matter-which-equal-operator-i-use">Javascript === vs == : Does it matter which “equal” operator I use?</a> </p>
</blockquote>
<p>What's the difference between <code>==</code> and <code>===</code>? Also between <code>!==</code> and <code>!==</code>?</p>
|
javascript
|
[3]
|
4,360,442 | 4,360,443 |
C# Outputting the reference of an Object
|
<p>in what way can I output the reference of an object in memory.
Like:</p>
<p>Console.WriteLine("Object at Memory Location " + object.Reference);</p>
<p>thanks in advance, I need this to do some debugging.</p>
|
c#
|
[0]
|
3,693,317 | 3,693,318 |
How can empty JavaScript function actually do something?
|
<p>While trying to understand how a web server worked, I came accross this:</p>
<pre><code>//myfile.js
function donothing(){};
//myfile.html
javascript:donothing(open('http://www.acme.com/whatever.jpg','','left=100, right=0, top=100, scrollbars=no, status=no, titlebar=no, resizable=no, toolbar=no, menubar=no, width=255, height=255'))
</code></pre>
<p>I'm no JavaScript expert, so I don't get how an empty function can be made to work. Does someone know?</p>
<p>Thank you.</p>
|
javascript
|
[3]
|
4,800,400 | 4,800,401 |
how to run application on Samsung galaxy tab GT-P1000
|
<p>I just finished developing an application and i want to run and test it on Samsung Galaxy Tab GT-P1000.
i followed the steps on this link. <a href="http://developer.android.com/guide/developing/device.html" rel="nofollow">http://developer.android.com/guide/developing/device.html</a></p>
<p>and I turned on USB debugging and the icon on top says the device is connected through USB. In Eclipse on Windows 7, I don't see the Galaxy Tab in my list. when i tried to see it through run configuration, i can see only my virtual device.</p>
<p>I think i have to install USB drive from this link.
<a href="http://www.samsung.com/us/support/downloads/GT-P1000" rel="nofollow">http://www.samsung.com/us/support/downloads/GT-P1000</a></p>
<p>but i am not sure which sub category to select.</p>
<p>can somebody please please help me...</p>
|
android
|
[4]
|
4,968,784 | 4,968,785 |
add image in treeView
|
<pre><code>TreeNode desktop = new TreeNode();
desktop.Text = "Desktop";
desktop.Tag = "Desktop";
Mycomputer.ImageIndex = 1;
Mycomputer.SelectedImageIndex = 1;
desktop.Nodes.Add("");
treeView1.Nodes.Add(desktop);
TreeNode Mycomputer = new TreeNode("My Computer");
Mycomputer.ImageIndex = 1;
Mycomputer.SelectedImageIndex = 1;
treeView1.Nodes.Add(Mycomputer);
</code></pre>
<p>I am using the <code>ImageIndex</code> property but where is the image?</p>
<p>How do I choose my image and from where?</p>
|
c#
|
[0]
|
325,371 | 325,372 |
Stoping other services like receving call and media player when my application opens?
|
<p>When i open my application , i should not receive any phone call or sms i should stop the media player also. can any one tel me is there any API is available to disable and enable them again once after my application ends.please help me..</p>
<p>Thanks
RAM</p>
|
android
|
[4]
|
4,949,937 | 4,949,938 |
How to retrieve data from an object in a simple way?
|
<p>I have an object, which contains 2 name parameters - see the example below. I understand that to reach the data I need to loop through the object, but I feel this is too annoying. Is there a better way to get the data in simple way?</p>
<pre><code>var obj = {[[[{name:'one'},{name:'two'}]]]};
$.each(obj,function(i,val){
var first = [] // i will get first time
$.each(first, function(i, val){
var second = [] //i will get second time and third later fourth // like so?
})
})
</code></pre>
<p>Does this mean that I should loop the <code>each</code> function four times to get the <code>name</code> values? If so which is the right way to get that? Is there any way to use the same function to get the data?</p>
|
jquery
|
[5]
|
1,414,780 | 1,414,781 |
I need some help concerning using 2 jar files in Java
|
<p>Well I have 2 .jar files. The main jar file is the jar file for my whole project and the other .jar file being the MySql JDBC Connector.</p>
<p>Well basically whats happening right now is that when I build the project I have the one main .jar file with everything but the MySql JDBC Connector .jar file is inside the main jar file when it builds in NetBeans.</p>
<p>Now when I am just running the project from within NetBeans the MySql JDBC driver can be found inside the src/com/game/mysql folder that I have it in. But when I build the project the Java application cannot locate the JDBC driver from within the main jar file.</p>
<p>When I open the main jar file with WinRar I can see that the JDBC jar file is still in its /com/game/mysql/ folder. But why cant the Java application access it?</p>
<p>I have heard that nested .jar files are not supported in Java so Im thinking this might be the reason although Im not sure if thats true. Is there a way that I can make it so that the application can find the JDBC .jar file within the main jar file?</p>
<p>Also I have done the thing in NetBeans where you add the .jar file through right clicking project -> properties -> Library -> Add Folder/Jar. Thats what makes it work in the NetBeans run but still not the App build.</p>
|
java
|
[1]
|
1,371,547 | 1,371,548 |
Javascript calculation not correct
|
<p>i have a weird problem in my javascript, take a look at my code below:</p>
<pre><code>dateParts = document.getElementById('date').value.split('/');
newDays = 14;
year = dateParts[2];
month = parseInt(dateParts[1]) - 1;
day = parseInt(dateParts[0]) + parseInt(newDays);
alert(dateParts[0]+" + "+newDays+" = "+day);
</code></pre>
<p>and assume <code>document.getElementById('date') = 07/01/2013</code></p>
<p>the calculation will give a correct result = <code>07 + 14 = 21</code></p>
<p>the calculation work fine at all date, except for <code>08/01/2013</code> / <code>09/01/2013</code> </p>
<p>which the result is <code>08 + 14 = 14</code>, any idea whats wrong here?</p>
|
javascript
|
[3]
|
429,185 | 429,186 |
Search a list of objects in Python
|
<p>I have a list of Item objects that have a date attribute. I also have a a single date I am grabbing from the database. </p>
<p>I want to search through the list, find all of the list items that are greater than the date I have returned from the database. </p>
<p>My list of Items objects has over a thousand objects in it, so I want to be as efficient as possible. </p>
<p>I assume that looping over every item in my list and checking if it is greater than the date I returned from the db is not the most efficient way to do this.</p>
<pre><code>class Item(object):
def __init__(self, title, link, description, date):
self.title = title
self.link = link
self.description = description
self.date = date
item_list = []
...
#assume I populate the list with a 1,000 Item objects
filtered_list = []
for it in item_list:
if date_from_db > it.date:
filtered_list.append(it)
</code></pre>
|
python
|
[7]
|
379,139 | 379,140 |
What does Java do when we import packages multiple times in the same class?
|
<p>Try this piece of code. It compiles. </p>
<pre><code>import java.io.*;
import java.io.*;
import java.io.*;
import java.util.*;
import java.util.*;
import java.util.*;
import javax.swing.*;
import javax.swing.*;
import javax.swing.*;
public class ImportMultipleTimes
{
public static void main(String[] args)
{
System.out.println("3 packages imported multiples times in the same class.");
}
}
</code></pre>
<p>Does the compiler simply ignore the additional import statements? </p>
|
java
|
[1]
|
2,934,872 | 2,934,873 |
Why is TYPE_ORIENTATION deprecated since API 8.0 ?
|
<p>Why is TYPE_ORIENTATION deprecated since API 8.0 for ANdroid? There's a cross in eclipse but the code runs perfectly fine. </p>
|
android
|
[4]
|
3,452,531 | 3,452,532 |
Handling events of HTML elements inserted by jQuery
|
<p>I currently have an anchor tag that, when clicked, appends another anchor tag to the DOM. This is all done via jQuery. I know what the "id" attribute of the anchor tag to be added will be. However, when I try the following code, it fails to handle the newly added anchor tag's click event:</p>
<p>$("#id").click(function() {
alert("test");
});</p>
|
jquery
|
[5]
|
5,078,238 | 5,078,239 |
JavaScript rewrite/replace text into href (link) on page
|
<p>I need simple JS code(pure JS,no frameworks) to rewrite piece of text into linked anchor(hyperlink) when visitor load page.</p>
<p>Or to be more precise, something same like many advertising services using:
- put JS on existing page
- when JS is fired it connect to my servers, find some data and
rewrites certain phrases in page content into hyperlinks</p>
<p>For now I done part of job where fired JS contact my server, finding appropriate phrases which will convert to hyperlinks, but don't have idea how to rewrite phrase on page into hyperlink.</p>
<p>So, if any body have pure JS solution for this please share with me :) </p>
|
javascript
|
[3]
|
1,170,509 | 1,170,510 |
problem in user location coordinate in mapview
|
<p>I am trying to find the user location coordinate from following code:</p>
<pre><code>- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView* newAnnotation = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"annotation1"];
if (annotation == _mapView.userLocation)
return nil;
CLLocationCoordinate2D location3 = annotation.coordinate;
CLLocationCoordinate2D location4 = _mapView.userLocation.coordinate;
</code></pre>
<p>But it is always returning location coordinate as:</p>
<pre><code><-180.00000000, -180.00000000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 3/25/11 4:41:29 PM India Standard Time
</code></pre>
<p>What's the problem here?</p>
|
iphone
|
[8]
|
5,694,972 | 5,694,973 |
No overload for 'pnlArr_Click' matches delegate 'System.EventHandler'
|
<p>Just starting out on C# and I keep getting stuck on this particular piece code (more precisely the <code>lblArr[i, j].Click += pnlArr_Click;</code> line):</p>
<pre><code>public void CreateLabelArray(int height, int width, int nrofShips)
{
pnlBase.Controls.Clear();
lblArr = new Label[height, width];
int xpos = 0;
int ypos = 0;
for (int j = 0; j < width; j++)
{
int column = j + 1;
for (int i = 0; i < height; i++)
{
Coordinaat pos = new Coordinaat();
pos.X = j;
pos.Y = i;
lblArr[i, j] = new Label();
lblArr[i, j].Left = xpos;
lblArr[i, j].Top = ypos;
lblArr[i, j].Width = 35;
lblArr[i, j].Height = 35;
lblArr[i, j].Tag = pos;
lblArr[i, j].Click += pnlArr_Click;
lblArr[i, j].BackColor = System.Drawing.Color.LightBlue;
lblArr[i, j].BorderStyle = BorderStyle.FixedSingle;
pnlBase.Controls.Add(lblArr[i, j]);
xpos += 0;
ypos += lblArr[i, j].Height;
}
xpos += 35;
ypos = 0;
}
}
</code></pre>
<p>As I am trying to find out what particular mouse button was pressed on a label in an array, I thought this method might work:</p>
<pre><code>public int pnlArr_Click(object sender, MouseEventArgs e)
</code></pre>
<p>The error goes away if i change MouseEventArgs to EventArgs, but then this won't work anymore:</p>
<pre><code>if (e.Button == MouseButtons.Left)
</code></pre>
<p>Any ideas? all help is much appreciated.</p>
|
c#
|
[0]
|
5,983,941 | 5,983,942 |
Getting a category list to stay displayed on my drop down menu
|
<p>Everything works great here but What I'm trying to do is have the list under the Rock category stay displayed until you click on the blues category. I want the Rock category to start off being displayed until another category link is clicked on. Any help would be appreciated since i'm new to javascript. Here is my code and Please see demo... </p>
<p><a href="http://jsfiddle.net/davidzupec/2BTkL/2/" rel="nofollow">http://jsfiddle.net/davidzupec/2BTkL/2/</a></p>
<pre><code>$(function () {
$('a').bind('click',function () {
var Class = $(this).attr('class');
var ulName = 'ul.' + Class;
var Display=$(ulName).css('display');
var Dis = $(ulName).css('display');
$(ulName).siblings().hide();
if (Dis == "block" || Dis == "undefined") {
$(ulName).slideUp();
}
else {
$(ulName).slideDown().show(1);
}
})
});
</code></pre>
|
javascript
|
[3]
|
3,430,079 | 3,430,080 |
Why blank(empty file) java do not not show any error?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2467723/what-happens-if-you-compile-an-empty-java-file">What happens if you compile an empty java file?</a> </p>
</blockquote>
<p>I tried to compile a blank file(.java file)hoping it will show an error.But Java compiler did not shown any error why so?</p>
|
java
|
[1]
|
4,077,417 | 4,077,418 |
Application Crashes when annotation bubble clicked
|
<p>I am creating annotations from database. But when I click on annotation to show bubble application crashes. But when I hardcode the coordinates and create placemarks on map the bubbles popup successfully. below is the code I am fetching from database and loading annotations.</p>
<p>-(void) mapView:(MKMapView *)imnMapView didAddAnnotationViews:(NSArray *)views;
{</p>
<pre><code> BOOL *regionSet=FALSE;
while(sqlite3_step(compiledStatement) == SQLITE_ROW)
{
CLLocationCoordinate2D userCoods1;
NSString *lat = [NSString stringWithUTF8String:(char *) sqlite3_column_text(compiledStatement, 3)];
NSString *longg = [NSString stringWithUTF8String:(char *) sqlite3_column_text(compiledStatement, 4)];
float fLat = [lat floatValue];
float fLong = [longg floatValue];
userCoods1.latitude = (CLLocationDegrees)fLat;
userCoods1.longitude = (CLLocationDegrees)fLong;
if(regionSet == FALSE)
{
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(userCoods1,400000,500000);
[mapView setRegion:region animated:YES];
regionSet=TRUE;
}
NSString *siteName = [NSString stringWithUTF8String:(char *) sqlite3_column_text(compiledStatement, 1)];
NSString *siteAddress = [NSString stringWithUTF8String:(char *) sqlite3_column_text(compiledStatement, 2)];
ParkPlaceMark *placemark=[[ParkPlaceMark alloc] initWithCoordinate1:userCoods1 title:siteName subtitle:siteAddress atm:@"ATM"];
pDescription = @"ATM";
[mapView addAnnotation:placemark];
[placemark release];
}
}
sqlite3_finalize(compiledStatement);
}
</code></pre>
<p>}</p>
<p>And When i just change the userCoords hardcoded and create three different placemarks the bubbles popup and works fine. Please help me getting out of this. thanks in advance.</p>
|
iphone
|
[8]
|
4,521,676 | 4,521,677 |
Android TextView update
|
<p>Hi
I am trying to update a textview to notify the user when the GPS coordinates have been logged.
My problem is that I need to access the location infomation from another class and I cannot directly edit the textview from anything apart from the onCreate class.</p>
<p>here is my code:</p>
<pre><code>public class Location extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
}
public class MyLocationListener implements LocationListener
{
private final String TAG = null;
@Override
public void onLocationChanged(android.location.Location location) {
// TODO Auto-generated method stub
location.getLatitude();
location.getLongitude();
String Text = "My current location is: " + "Latitud = " + location.getLatitude() + "Longitud = " + location.getLongitude();
try
{
File root = Environment.getExternalStorageDirectory();
File gps = new File(root, "log.txt");
BufferedWriter out = new BufferedWriter(
new FileWriter(gps,true)) ;
TextView tv = (TextView)findViewById(R.id.textView1);
tv.setText(Text);
out.write(Text);
out.write("");
out.close();
}
catch (IOException e) {
Log.e(TAG, "Could not write file " + e.getMessage());
}
}
</code></pre>
<p>Thanks</p>
|
android
|
[4]
|
3,529,059 | 3,529,060 |
Java Grouping Images
|
<p>I'm working on a game and had someone propose a challenge for me that I am having trouble solving so I am now turning to the stack overflow community for some help. I am trying to create a game similar to Tanks. I currently have two images (the tank body and tank arm) that I move based on two lines of code. They challenged me to create a separated class for the tank where I upload both images but am only required to draw it onto my game panel once. That is, I will have the tank body and tank arm in the class and can do whatever I need to do to them in there, but when I go to draw it onto my game scree panel, I am only required to write one line of code that simply draws on that class.</p>
<p>For Example: </p>
<pre><code>g.drawImage(tank1, nX1, nY1, null)
</code></pre>
<p>Rather than:</p>
<pre><code>g.drawImage(tank1, nX1, nY1, null)
g.drawImage(tank1, nX1, nY1, null)
</code></pre>
<p>Any links or ideas as to what to do would be appreciated. Example code would be even better.</p>
|
java
|
[1]
|
1,853,859 | 1,853,860 |
Javascript: How to determine the screen height visible (i.e., removing the space occupied by the address bar etc)
|
<p>As asked in the question, how do I find out the screen space available for the webpage through javascript?</p>
|
javascript
|
[3]
|
885,404 | 885,405 |
click listeners for dynaically added imageview
|
<p>I have an activity in my app which displays rss feeds and next to each rss feed arrow image is attached.</p>
<p>I am new to android any help will be appreciated.</p>
<p>i shall explain what i am doing to display rss news ...</p>
<p>i have a seperate dummy xml layout for a single rss.. i have set id for arrow image (which will navigate to the next activity) in it as iv_arrow_img
i am iterating over the news feeds i get and for each news feed i am adding the dummy view again and again...my question is how will i distinguish between different image arrow's ids .. because for now all are having the same id... how will i set onclick listeners to them ???</p>
<p>.....
@devA
taking ur suggestions i have wrote the code
Iterator itr = data.iterator();
int i =0;
while (itr.hasNext()) {
NewsPostDTO newspostdto = itr.next();</p>
<pre><code> view = inflater.inflate(R.layout.rl_news_item, null);
lnContentView.addView(view, LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
ivArrowfwd = (ImageView) view.findViewById(R.id.iv_arrowfwd);
tvNewsHeading.setText(newspostdto.getFeaturedDesc());
tvNewsContent.setText(newspostdto.getDate() + " - " + newspostdto.getTitle());
ivArrowfwd.setId(id);
ivArrowfwd.setTag(newspostdto);
ivArrowfwd.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
System.out.println("sdfsdf" +(ImageView) view.findViewById(id).getTag());
return false;
}
});
id++;
}
</code></pre>
<p>but i am not gettng different tags for each news thought they are unique .. can u tell me where i am doing wrong... ?</p>
|
android
|
[4]
|
1,154,670 | 1,154,671 |
How might a List<T> be reset?
|
<p>I have an object I create and stick in a collection:</p>
<pre><code>public class Level
{
private string id;
private List<LevelTypes> usableLevelTypes; // LevelTypes is an enum
private List<BlockTypes> levelMapping; // BlockTypes is also an enum
public Level(string id, List<LevelTypes> levelTypes, List<BlockTypes> incomingBlocks)
{
this.id = id;
this.usableLevelTypes = levelTypes
levelMapping = incomingBlocks;
}
</code></pre>
<p>Stepping through this, I can see each item being set properly. The object is then placed in a HashSet.</p>
<p>Another class then iterates through the HashSet calling each item's overloaded <code>.ToString()</code> method. </p>
<p>At this point I have all relevant variables in this class on my watch list. Everything within the object called is set properly. "id", "levelMapping" and all other variables that I have not listed including other <code>List<T></code>'s and int's contain their proper values except "usableLevelTypes", which is reported as being empty. </p>
<pre><code>public override string ToString()
{
var s = new StringBuilder();
s.Append("ID: " + id);
s.Append(" Level Types: " + usableLevelTypes[0].ToString()); // At this point,
// this list should have at minimum one value in it. However, it is empty and
// will throw an exception stating as much.
return s.ToString();
}
</code></pre>
<p>At no point is <code>.Clear()</code> called on the usableLevelTypes List and it is read-only. How could it be reset when other lists within the same object are not?</p>
|
c#
|
[0]
|
4,801,464 | 4,801,465 |
How to append some object arrays in C#?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1547252/how-do-i-concatenate-two-arrays-in-c">How do I concatenate two arrays in C#?</a> </p>
</blockquote>
<p>How do I append some object arrays into one big object array?</p>
<p>For example, I have 3 elements of type: <code>object[]</code> and want to make one of it. How to do this?</p>
|
c#
|
[0]
|
297,588 | 297,589 |
Best practices for creating an application which will be upgraded frequently - C++
|
<p>I am developing a portable C++ application and looking for some best practices in doing that. This application will have frequent updates and I need to build it in such a way that parts of program can be updated easily.</p>
<ol>
<li>For a frequently updating program, creating the program parts into libraries is the best practice? If program parts are in separate libraries, users can just replace the library when something changes. </li>
<li>If answer for point 1 is "yes", what type of library I have to use? In LINUX, I know I can create a "<em>shared library</em>", but I am not sure how portable is that to windows. What type of library I have to use? I am aware about the DLL hell issues in windows as well. </li>
</ol>
<p>Any help would be great!</p>
|
c++
|
[6]
|
979,720 | 979,721 |
Check whether a connection exists to a remote host using paramiko
|
<p>I'm using single object of <code>paramiko.SSHClient()</code> for executing a command on a remote machine. When I use <code>ssh.exec_command(cmd)</code>, and the connection to remote host is lost, <code>ssh.exec_command</code> hangs up.</p>
<p>Is there a way to check for connection existence before <code>ssh.exec_command()</code>?</p>
|
python
|
[7]
|
4,482,404 | 4,482,405 |
Javascript object is not function
|
<p>I'm new to Javascript and am confused about the error messages I get:</p>
<p>I have the JavaScript Code:</p>
<pre><code>function tile(x,y) {
return ((worldw * y) + x);
}
alert(tile(5,5));
</code></pre>
<p>But I get the error message in Chrome that "Object is not a function".</p>
<p>How can I fix this and what does the error message mean?</p>
|
javascript
|
[3]
|
1,531,747 | 1,531,748 |
How to save images in a server path folder from iphone application?
|
<p>Right now I am saving the images in a photo album, but I want to save the images in some server path like that can be used in a website. How can I do this?</p>
|
iphone
|
[8]
|
4,981,339 | 4,981,340 |
android toast a Chinese message to user
|
<p>Basically I need to toast a message written in Chinese to user.
However I don't know how to achieve such thing.
Any solution that can help me?</p>
|
android
|
[4]
|
632,351 | 632,352 |
Are these really different functions? jQuery.extend()
|
<p>The jQuery documentation covers the function jQuery.extend()s twice, giving it different definitions. The first relates to extending the jQuery object itself: <a href="http://docs.jquery.com/Core/jQuery.extend#object" rel="nofollow">http://docs.jquery.com/Core/jQuery.extend#object</a>. The second relates to extend an input argument: <a href="http://docs.jquery.com/Utilities/jQuery.extend" rel="nofollow">http://docs.jquery.com/Utilities/jQuery.extend</a></p>
<p>Are these two usages of the same function, or are these actually different functions? I presume its the same function, but then I wonder why its documented twice as different functions.</p>
|
jquery
|
[5]
|
3,790,672 | 3,790,673 |
Style for PrefenceScreen
|
<p>I'd like to be able to customize the view of a <code>PreferenceScreen</code>, and so I'm interested in knowing how to set a style for it. </p>
|
android
|
[4]
|
1,035,142 | 1,035,143 |
Android - How to get the mobile nunber when not stored in the SIM card
|
<p>I want to get the mobile number related with a SIM card. But I know that some celular operators doesn't store the number into the SIM card.</p>
<p>So use the code below will not return anything,</p>
<pre><code>TelephonyManager tm = (TelephonyManager)this.getApplicationContext()
.getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = tm.getLine1Number();
</code></pre>
<p>Anyone knows any other way to get the mobile number?</p>
<p>Maybe some API that retrieves the number using the IMSI of the SIM Card, or maybe the mobile number is stored somewhere on the memory of the device.</p>
<p>One desperate way could be make some kind of request to the operator or carrier to ask for the mobile number for that IMSI, I don't know :)</p>
<p>any help will be appreciated :)</p>
<p>thanks</p>
|
android
|
[4]
|
3,988,397 | 3,988,398 |
android.net.http.RequestQueue not found in andorid.jar
|
<p>I am developing Android Twitter application. I downloaded TwitterClient Demo deom net.
But there is a class file "android.net.http.RequestQueue" that is not available in sDK component in android.jar. Please advise on the same.</p>
|
android
|
[4]
|
3,021,052 | 3,021,053 |
Optimization of UI (.xml files) and java codes in android
|
<p>when I am going to develop an android application. For better performance of my application what are necessary steps. In another word how to optimize my codes and .xml files, in best way. And what are steps to remember when I am going to use huge set of variables. </p>
<p>Thank you!</p>
|
android
|
[4]
|
1,359,789 | 1,359,790 |
PHP exceptions thrown in error handler are not caught by exception handler
|
<p>I use the following function to set my own error handler and exception handler.</p>
<pre><code>set_error_handler
set_exception_handler
</code></pre>
<p>The error handler transforms errors to exception. (throws a new exception)</p>
<p>But these exceptions are not caught by my own exception handler.</p>
<p>error handler example:</p>
<pre><code>function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
throw new Exception("this was an error");
}
</code></pre>
<p>exception handler example:</p>
<pre><code>function exceptionHandler($e){
// don't get here when exception is thrown in error handler
Logger::logException($e);
}
</code></pre>
<p>(I think this can not work anyway)</p>
<p>Should this work ?</p>
<p>Or can someone explain why it can not work ?</p>
<p>EDIT:</p>
<p>I made some tests, and it should work. </p>
<p>Exceptions thrown in the ErrorHandler are getting caught by the ExceptionHandler
And Errors triggered in the ExceptionHandler are getting processed by the ErrorHandler </p>
<p>Just FYI.</p>
<p>My Problem has to be elsewhere</p>
<hr>
<p>EDIT:</p>
<p>I Still have not found why the exception thrown in my errorHandler is not caught by my exceptionHandler.</p>
<p>For Example when I have this somewhere in the code.</p>
<pre><code>trigger_error("this is an error"); // gets handled by the errorHandler
throw new Exception("this is an exception"); // gets handler by the exceptionHandler
</code></pre>
<p>The error gets handled by the errorHandler but the exception thrown in the errorHandler gets not handled by the exceptionHandler.</p>
<p>But if I throw an exception at the same place where I trigger an error, this exception gets handled by the exception handler. </p>
<p>(Hope it is somehow understandable what I mean)</p>
<p>I'm clueless here.
Any Ideas where I have to look for the Problem?</p>
|
php
|
[2]
|
4,304,210 | 4,304,211 |
HelloAndroid]emulator-5554 disconnected! Cancelling 'com.example.helloandroid.HelloAndroid activity launch'!
|
<p>I am new to Android. Follow the HelloAndroid Tutorials by use Eclipse.
After run HelloAndroid, the AVD 'xian_avd2' lunched, but stop there, no " Hello, Android"
displayed on AVD. Looks like Waiting for HOME ('android.process.acore') to be launched...</p>
<p>Not know how to resolve this, please help.
Thanks
wang813</p>
<pre><code>[2010-01-29 00:12:13 - HelloAndroid]------------------------------
[2010-01-29 00:12:13 - HelloAndroid]Android Launch!
[2010-01-29 00:12:13 - HelloAndroid]adb is running normally.
[2010-01-29 00:12:13 - HelloAndroid]Performing com.example.helloandroid.HelloAndroid activity launch
[2010-01-29 00:12:13 - HelloAndroid]Automatic Target Mode: Preferred AVD 'xian_avd2' is not available. Launching new emulator.
[2010-01-29 00:12:14 - HelloAndroid]Launching a new emulator with Virtual Device 'xian_avd2'
[2010-01-29 00:12:37 - HelloAndroid]New emulator found: emulator-5554
[2010-01-29 00:12:37 - HelloAndroid]Waiting for HOME ('android.process.acore') to be launched...
[2010-01-29 00:13:59 - HelloAndroid]emulator-5554 disconnected! Cancelling 'com.example.helloandroid.HelloAndroid activity launch'!
</code></pre>
|
android
|
[4]
|
1,432,010 | 1,432,011 |
ANDROID: on Notification received, I want to refresh the listView with the new data
|
<p>Ths activity it's call from TabActivity.</p>
<p>And I want: if I receive new notification , I want to refresh the list of the current Activity.</p>
<pre><code>public class TestListActivity extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
ListView lv = null;
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, R.layout.test_list, ListUtil.asStringList(TestServiceUtil.getTests())));
lv = getListView();
lv.setSelector(R.drawable.listindicator);
lv.setTextFilterEnabled(true);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(TestListActivity.this, TestViewActivity.class);
// Next create the bundle and initialize it
Bundle bundle = new Bundle();
// Add the parameters to bundle as
bundle.putLong("testId", TestServiceUtil.getTests().get(position).getTestId());
// Add this bundle to the intent
intent.putExtras(bundle);
// Start next activity
TestListActivity.this.startActivity(intent);
}
});
}
}
</code></pre>
<p>I need just example, how i can make the refresh of the list.</p>
|
android
|
[4]
|
1,947,125 | 1,947,126 |
get the field names straight from the db table
|
<p>I’m building a database driven website using WAMP</p>
<p>I have database with table called userinfo with the following field names
DateTime DomainName ComputerName UserName NetworkSettings.</p>
<p>And I have a PHP script with a HTML table</p>
<pre><code>echo "<div id='tableheading'>\n";
echo "<table class='data' border='1'align='center'>\n";
echo "<tr>\n";
echo "<th> DateTime </th>
echo "<th> DomainName </th>
echo "<th> ComputerName </th>
echo "<th> UserName </th>
echo "<th> NetworkSettings </th>
</code></pre>
<p>How do I get the field names straight from the database?</p>
|
php
|
[2]
|
5,127,574 | 5,127,575 |
How to calculate distance from cellID?
|
<p>I want to calculate distance using 2 cellID (i am getting cell id from GsmCellLocation class).</p>
<p>Please help me.</p>
<p>Thanks</p>
|
android
|
[4]
|
1,903,489 | 1,903,490 |
Learn about a javascript object
|
<p>I have an <code>[object Object]</code> being passed as an argument through a jQuery function and I want to learn more about it. I don't want to know anything about this specific situation (unless there is no solution) but how to replicate something like php's <code>var_dump()</code>.</p>
|
javascript
|
[3]
|
4,414,905 | 4,414,906 |
how to save multiple bitmap images to internal storage and read into a list activity
|
<p>How can i write a bitmap image to internal storage, (prefer if i can save the bit map in my Own Directory ex "/data/data/com.myapp/myfolder/img1.png") i need to save the multiple images into this directory.after saving multiple images to above directory i need to show the saved images in a list activity,</p>
<p>Method Use to save the Image to internal Storage</p>
<pre><code>private void saveToInternalSorage(Bitmap bitmapImage,String filename){
ContextWrapper cw = new ContextWrapper(getApplicationContext());
File directory = cw.getDir("myfolder", Context.MODE_PRIVATE);
File mypath=new File(directory,filename+ ".png");
FileOutputStream fos = null;
try {
// fos = openFileOutput(filename, Context.MODE_PRIVATE);
System.out.println("mypath = "+mypath);
fos = new FileOutputStream(mypath);
// Use the compress method on the BitMap object to write image to the OutputStream
bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
</code></pre>
<p>Read the images from Internal Storage.</p>
<pre><code> private File [] loadInternalImages(){
ContextWrapper cw = new ContextWrapper(getApplicationContext());
File directory = cw.getDir("myfolder", Context.MODE_PRIVATE);
File[] imageList = directory.listFiles();
if(imageList == null){
imageList = new File[0];
}
Log.i("My","ImageList Size = "+imageList.length);
return imageList;
}
</code></pre>
<p>Regards,
Sam</p>
|
android
|
[4]
|
3,783,898 | 3,783,899 |
Calling Javascript Factory Method
|
<p>I am learning Object Oriented Java Script. I have below code for Factory Method.</p>
<pre><code>function Foo() {
var value = 1;
return {
method: function() {
return value;
},
value:value
}
}
Foo.prototype = {
bar: function() {}
};
new Foo();
Foo();
</code></pre>
<p>method Foo can be called by two ways. <code>new Foo();</code> or <code>Foo();</code> Both do the same thing and output is same. what is actual difference in java script processing ?</p>
|
javascript
|
[3]
|
4,862,116 | 4,862,117 |
For what argument is std::vector<void*>::reserve an O(1) time operation?
|
<p>I am interested in at least an approximate answer to:</p>
<pre><code>int n;
...
std::vector<void*> vectorOfPointers;
vectorOfPointers.reserve(n);
</code></pre>
<p>For up to which number <strong>n</strong> does the above mentioned program run in <strong>O(1)</strong> ? </p>
<p>Let us suppose that for a laptop running 32 bit Ubuntu with 3 gigabytes of memory, not running any other programs. Is it tens, thousands, millions? What information does one need to know to be able to asses such a question? Is there a way to find out without running any experiments?</p>
<p>I have never studied anything about operating systems but in my imagination, the operating system allocates memory in just 2 steps. It determines the pointer to start the chunk and the pointer of the end of the chunk. The situation can be more complicated because the system may have to tidy up in order to get a big enough chunk of memory. But if we suppose that the system runs just this one program, how can we estimate the time needed? Are there some other aspects to be considered, besides the fragmentation of memory?</p>
<p>EDIT:</p>
<p>sorry, I didn't make my question clear. It is important to consider, that the vector is empty before calling reserve, so no copying of data is required.</p>
|
c++
|
[6]
|
3,339,458 | 3,339,459 |
How do I convert "1.20E+07" to a float?
|
<p>I can't convert the text, "1.20E+07" to a float.</p>
<p>I've tried:</p>
<pre><code>info = CultureInfo.GetCultureInfo ("en-US");
float.TryParse ("1.20E+07", NumberStyles.AllowExponent, info, out cellValue);
</code></pre>
|
c#
|
[0]
|
5,638,274 | 5,638,275 |
NSTimer to update label
|
<pre><code>self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(updateTimerDisplay) userInfo:nil repeats:YES];
[runLoop addTimer:self.timer forMode:NSRunLoopCommonModes];
</code></pre>
<p>This code-snippet is copied from my viewDidLoad method, so it is runned from the main-thread. All it do is to call a method to update a label. </p>
<p>I thought I need to have a own thread for doing this, but after getting help on this at SO I figured out that I did not. </p>
<p>However, I do not understand the <code>NSRunLoopCommonModes</code>. Why does it work?</p>
<hr>
<p>AND the timer updates the label which is a "digital counter" which is on the same screen as a tableview so it CAN'T stop the timer even if the user holds the screen.</p>
<p>Thanks.</p>
|
iphone
|
[8]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.