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,291,948
4,291,949
Javascript set select box size attribute does not seem to work
<p>I have a select box with the class attribute set to <code>class="styled"</code>. The reason being that the select box has been styled (it uses a background url to give it a custom appearance). If I remove this class attribute I can simple use <code>size="10"</code> in the html tag, or change it dynamically with:</p> <pre><code>var o_select = document.getElementById("mySelect"); o_select.size = "10"; </code></pre> <p>(or, <code>o_select.setAttribute("size", "10");</code>) </p> <p>It seems to be the class attribute causing the problems. Please help!</p>
javascript
[3]
2,040,746
2,040,747
jQuery - wrap issue - want to declare elements
<p>Hi I have a wrap() that is working fine, but the problem is, I need to be able to tell it where to start the wrap (by an element ID..#start) and where to end it (again, by an element ID...#end). Is this possible? Did I do a good job of phrasing the question? Thanks.</p>
jquery
[5]
2,670,454
2,670,455
How to retain the time of the countdown timer even when the page is refreshed
<p>i have countdown timer in java script ,i want to retain the countdown time even when the page is refreshed can you please suggest me what direction i have to follow </p>
javascript
[3]
5,789,250
5,789,251
android - How to connect the Device to the Emulator
<p>My Application is working properly in emulator. I am running the application in the device using the ".apk" file. But it is not working properly. So i want to test the application in the device using Eclipse logcat. How to connect the Real device to the Eclipse for debugging the application in the device. I follow the steps of this link "http://developer.android.com/guide/developing/device.html" . i am facing the problem after setting the path (i.e,The Google USB Driver is located in \google-usb_driver). The error is the hardware is not installed. How to handle this. My device is "Samsung Galaxy Apollo GT-i5801". Please can anybody help me.</p> <p>thanks</p>
android
[4]
2,540,733
2,540,734
Jquery .click() callback
<p>I am unsure if this is a "callback' that I need or not, but basically I am trying to emulate the reversal of the function like on the .hover() effect with the .click() effect. Is this possible. So basically, if the user clicks again on the link, the reverse of what just happened, ie a div closing as opposed to opening, will happen. Is it possible to do this with .click()?</p> <pre><code>$(document).ready(function(){ $('.content_accrd').css({"height":"0px"}); $('.paneltop').click( function() { $(this).css({"background-position":"0px -21px"}) .siblings().animate({"height":"100px"}, 200) }, function() { $(this).css({"background-position":"0px 0px"}) .siblings().animate({"height":"0px"}, 200); }) }) </code></pre>
jquery
[5]
1,016,667
1,016,668
Replacing width and height in markup with a JS regular expression
<p>I have two JS variables X and Y. In my markup there's a line starting with:</p> <pre><code>&lt;iframe frameborder="0" width="600" height="337" .. </code></pre> <p>I want to replace the width's value by X's value and the height's value to Y's value. Could somebody help me with the regular expression to achieve this ?</p>
javascript
[3]
1,546,996
1,546,997
Why do they have the same ID?
<pre><code>public class Bird { private static int id = 0; private String kind; public Bird(String requiredKind) { id = id + 1; kind = requiredKind; } public String toString() { return "Kind: " + kind + ", Id: " + id + "; "; } public static void main(String [] args) { Bird [] birds = new Bird[2]; birds[0] = new Bird("falcon"); birds[1] = new Bird("eagle"); for (int i = 0; i &lt; 2; i++) System.out.print(birds[i]); System.out.println(); } } </code></pre> <p>Why this returns <code>Kind: falcon, Id: 2; Kind: eagle, Id: 2</code> I really can't figure it out? birds[0] and birds[1] have different instances, how they have ID of 2? Why it's not 1 and 1?</p>
java
[1]
1,354,883
1,354,884
traverse to parent td and tr from a item click in a cell
<p>I have a link ( anchor ) tag in a table cell on every row of an html table. On click of this anchor tag I want to use jquery ( preferably) to traverse back to the parent td and tr and get object reference to it. </p> <p>how can i use jquery at best here to navigate\traverse in dom.</p> <p>I can do a method like this but not sure if jquery has better ways for this.</p> <pre><code>function findRowNumber(element) { // element is a descendent of a tr element while(element.tagName.toLowerCase() != "tr") { element = element.parentNode; // breaks if no "tr" in path to root } return element.rowIndex; } </code></pre>
jquery
[5]
3,706,120
3,706,121
what is garbage collector in java and how can we use it
<p>what is garbage collector in java and how can we use it</p>
java
[1]
2,086,224
2,086,225
jQuery - Given a TextArea Val()- How to get everything before the first line break
<p>I have a text area that allows for returns (enter key). I'd like to know how to get everything in the textarea that is before the first linebreak/return/enter key?</p> <p>Should I use something like split?</p>
jquery
[5]
3,896,710
3,896,711
Error when installing my app on the phone
<p>I have a <code>LG P500</code> with <code>Android 2.2</code> and when I want to install any <code>.apk</code> a message appears:</p> <pre><code> "There is problem parsing package" </code></pre>
android
[4]
1,174,541
1,174,542
Grouping items by match set
<p>I am trying to parse a large amount of configuration files and group the results into separate groups based by content - I just do not know how to approach this. For example, say I have the following data in 3 files:</p> <pre> config1.txt ntp 1.1.1.1 ntp 2.2.2.2 config2.txt ntp 1.1.1.1 config3.txt ntp 2.2.2.2 ntp 1.1.1.1 config4.txt ntp 2.2.2.2 </pre> <pre> The results would be: Sets of unique data 3: Set 1 (1.1.1.1, 2.2.2.2): config1.txt, config3.txt Set 2 (1.1.1.1): config2.txt Set 3 (2.2.2.2): config4.txt </pre> <p>I understand how to glob the directory of files, loop the glob results and open each file at a time, and use regex to match each line. The part I do not understand is how I could store these results and compare each file to a set of result, even if the entries are out of order, but a match entry wise. Any help would be appreciated.</p> <p>Thanks!</p>
python
[7]
925,761
925,762
How a reference address become NULL in C++?
<p>I have a coredump,it shows a reference address is NULL....</p> <p>details:</p> <pre><code>(gdb) bt #0 0xffffe410 in __kernel_vsyscall () #1 0x005b6c10 in raise () from /lib/libc.so.6 #2 0x005b8521 in abort () from /lib/libc.so.6 #3 0xf749e641 in Application::fatalSignal () at Application.cc:277 #4 &lt;signal handler called&gt; #5 SdlProcess::procedureReturn (this=0x0, aSignal=0, aArg1=1, aArg2=0x0) at /include/c++/4.1.1/bits/stl_list.h:652 #6 0x08112edb in Sdl::authFailurer (aSdlProcess=@0x0, aLabel=0, aSignal=0, arg2=0x0) at /Mgr/SdlAuth.cc:1781 #7 0x00000000 in ?? () ================ define: Sdl::authFailurer(SdlProcess&amp; aSdlProcess, int aLabel, int aSignal, int /*arg1*/, void* arg2) #5 aSdlProcess.procedureReturn(0, 1, 0); </code></pre> <p>and in stl_list.h:652</p> <pre><code> bool empty() const { return this-&gt;_M_impl._M_node._M_next == &amp;this-&gt;_M_impl._M_node; } ----&gt;652 in procedureReturn() { ... if (!mProcedureStack.empty())----&gt;here,mProcedureStack is a datamember of SdlProcess ... { ...} } </code></pre>
c++
[6]
1,184,446
1,184,447
About Php development
<p>I have developed two projects: one in osdate and other is my own code. I want to improve my code standard. Can anyone suggest a standard and how to organize a project before starting? I don't have any senior programmers in my office and so I have to learn by myself.</p>
php
[2]
5,089,599
5,089,600
javascript for creating link url from elements w/o specific IDs
<p>In a CMS that returns a list of results from a search, I have a list of items that looks something like this: </p> <pre><code>&lt;ul class="results_odd_row"&gt; &lt;li class=title&gt; Title &lt;/li&gt; &lt;li class=published&gt; Year &lt;/li&gt; &lt;li class="author"&gt; Author &lt;/li&gt; &lt;li class="avail"&gt; Out; try &lt;a href="http://another.search"&gt;Another Search&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul class="results_even_row"&gt;... &lt;/ul&gt; &lt;ul class="results_odd_row"&gt;... &lt;/ul&gt; ...etc... </code></pre> <p>For the "try another search" link, I'd like to append onto the url some information about the record, like "http://another.search?title=[title]&amp;author=[author]", so that information can be used to execute the other search. </p> <p>How can I identify elements that have no specific ID, and where there are multiple elements of the same class on the same page? In pseudo code, what I want might be something like: </p> <pre><code> 1. href = base URL (http://another.search) plus 2. the text from the first &lt;li&gt; element above with class="title" 3. the text from the first &lt;li&gt; element above with class="author" </code></pre> <p>Also, I'm limited by the CMS to whatever javascript I can use within the A tag. </p> <p>If it's not already obvious, I'm a complete newbie with javascript, so please don't feel your potential response is insultingly basic.</p>
javascript
[3]
275,879
275,880
hour format in javascript
<p>In my javascript iam using GetHour and GetMinutes function.For eg:Current Time is 2:03.If in this case i use GetHour(),it returns 2.Instead i need 02.Can anybody help?</p>
javascript
[3]
2,818,716
2,818,717
How to assign value to id?
<p>I have one string name as id in my .aspx.cs page and one javaScript function SetValue(val) on .aspx page in which I have to assign val to that id. How will I do this in java script fuction SetVal(val)?</p>
javascript
[3]
3,412,315
3,412,316
Parse error: syntax error, unexpected T_VARIABLE on line 1 in contactengine.php
<p>I am getting the error "Parse error: syntax error, unexpected T_VARIABLE on line 1" in the contactengine.php file when I send a form to this file. Funny thing is its working fine on another server:</p> <pre><code>&lt;?php $EmailFrom = Trim(stripslashes($_POST['Email'])); $EmailTo = "enquiries@clareelizabethcreche.ie"; $Subject = "Clare Elizabeth Creche Contact Form"; $Name = Trim(stripslashes($_POST['Name'])); $Phone = Trim(stripslashes($_POST['Phone'])); $Email = Trim(stripslashes($_POST['Email'])); $Inquiry = Trim(stripslashes($_POST['Inquiry'])); $validationOK=true; if (!$validationOK) { print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=error.htm\"&gt;"; exit; } if ($_POST['Email']=="") { Print("Please fill in this field!&lt;br&gt;"); } $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Phone: "; $Body .= $Phone; $Body .= "\n"; $Body .= "Email: "; $Body .= $Email; $Body .= "\n"; $Body .= "Inquiry: "; $Body .= $Inquiry; $Body .= "\n"; $success = mail($EmailTo, $Subject, $Body, "From: &lt;$EmailFrom&gt;"); if ($success){ print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=inquiryconfirmation.php\"&gt;"; } else{ print "&lt;meta http-equiv=\"refresh\" content=\"0;URL=error.htm\"&gt;"; } ?&gt; </code></pre>
php
[2]
1,928,995
1,928,996
on "bluetoothChat" giving error bluetooth is not available
<p>I worked on <strong>bluetoothChat</strong> on sdk15, no error is showing in problems but when I run it shows <strong>"Bluetooth is not available"</strong> and in logcat showing 04-14 19:04:11.064: E/BluetoothChat(1214): --- ON DESTROY ---, ON CREATE..., IN TAG DALVIKVM-- IN TEXT >> NOT LATE ENABLING CheckJNI (already on) showing and in cosole it is giving more error after run this application like as :-</p> <p>[ [2012-04-22 19:16:19 - ddmlib] An established connection was aborted by the software in your host machine java.io.IOException: An established connection was aborted by the software in your host machine at sun.nio.ch.SocketDispatcher.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(Unknown Source) at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source) at sun.nio.ch.IOUtil.write(Unknown Source) at sun.nio.ch.SocketChannelImpl.write(Unknown Source) at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213) at com.android.ddmlib.Client.sendAndConsume(Client.java:575) at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348) at com.android.ddmlib.Client.requestAllocationStatus(Client.java:421) at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:837) at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:805) at com.android.ddmlib.DeviceMonitor.processIncomingJdwpData(DeviceMonitor.java:765) at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:652) at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:44) at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:580) ] please help me on this what should I do for this.</p>
android
[4]
3,311,433
3,311,434
What is the error in this program? It's showing uncaught typeerror
<p>I get the following error</p> <blockquote> <p>uncaught typeerror : object is not a function</p> </blockquote> <p>in the code below. </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Reverse&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="rev1"&gt; Enter the string : &lt;input type="text" name="str"&gt; &lt;input type="button" value="click" onclick="rev1()" /&gt; </code></pre> <p>And this is the place where I found the error:</p> <pre><code>reverse of given string : &lt;input type="text" name="res"&gt; &lt;/form&gt; &lt;script type="text/JavaScript"&gt; function rev1(){ //var a=rev1.str.value; //document.write("hello"); alert("hello"); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>What might cause this and how do I solve it?</p>
javascript
[3]
5,032,750
5,032,751
Cookies shared between WebView instances in different processes?
<p>Do WebView instances in my process share cookies and cache with WebView instances created by other processes? </p> <p>Say I have my website www.example.com, and there's a login page there. If the user logs into my site from the native browser app, then they come into my app later on where I have an embedded WebView instance, will their login cookies still be present? Or do they have to login again?</p> <p>Thanks</p>
android
[4]
308,833
308,834
Bring application to front after user clicks on home button
<p>My application is in <strong>running mode[foreground]</strong> and user clicks on home button, which puts application to <strong>background[and still running]</strong>. I have alarm functionality in my application which fires up. I want is when my alarm goes off i want to bring my background running application in foreground and from last state in which it was. </p> <pre><code> &lt;application android:name="nl.ziggo.android.state.management.MainEPGApp" android:icon="@drawable/icon" android:label="@string/app_name" android:largeHeap="true" android:logo="@drawable/app_logo" &gt; &lt;activity android:name=".SplashScreen" android:label="@string/app_name" android:launchMode="singleTop" android:screenOrientation="nosensor" android:theme="@style/Theme.Sherlock" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".Starter" android:configChanges="orientation|screenSize" android:screenOrientation="behind" android:launchMode="singleTop" android:uiOptions="none" android:windowSoftInputMode="adjustPan" /&gt; &lt;/application&gt; </code></pre>
android
[4]
5,933,831
5,933,832
How to change the background of multiple activities at the same time?
<p>I am developing an app with 3 activities. Every activity has the same background. I want to enable the users to change the background of all the three activities. So i used a AlertDialog to provide the user several choices. When the user click the items on the Dialog, the background will be changed.</p> <p>I have tried two ways of implementing this function above:</p> <p>1) use the Android:theme in AndroidManifest.XML. This really worked. But the bad thing was that all the View in the application will extend the theme. I made the background of unrelated views null. But i can not remove extended theme in the Dialog. This made my dialog very ugly. </p> <p>2) I applied 'style' in the layout xml of the three activity. But the problem is that i can not modify the background attribute in the style programmatically. </p> <p>Does someone have some idea to deal with this problem? thx! </p>
android
[4]
1,847,779
1,847,780
Dynamically create content of table php
<p>I am trying to create a table where users choose which week they want - 1 to 52, and then across the top of the table have the days Monday through Sunday and down the side 5 different meal times.</p> <p>I would like to know how i would fill the contents of the table with values stored in a database that correspond the the right day and meal time? In a .php webpage. for example:</p> <pre><code> Monday Tuesday Wednesday .... Breakfast Meal 1 Meal 3 Meal 6 Meal 2 Lunch Meal 3 Meal 4 </code></pre> <p>Each meal has an id linking it to a meal time and a day.</p>
php
[2]
5,256,138
5,256,139
how to go one view to another view?
<p>I create one Application for Language Display. Now, I need to display the Another Page when I tapped on first button then go to Another Page. If I tapped on Second Button, It will back on first Page. </p> <p>How to code it?</p> <p>Thanks in Advance...</p> <p>Rahul Rana</p>
iphone
[8]
1,969,337
1,969,338
Android to PC communication
<p>I am working on a project to guide blind students. I am using WiFi Tags and android mobile. WiFi tags are placed on the wall and android is carried by blind student. The student's time table, shortest path algorithm to reach specific lecture hall is loaded onto HOST.</p> <p>Whenever android mobiles comes in vicinity of any Wifi tag, it receives the beacons from WiFi Tag. In order to achieve this, android has to scan all the wifi devices every 3 sec(say).So, the android has to forward the WiFi tag id (mac address), android mac id, Received Signal Strength to the HOST. So, how should I do this? What are the different applications to be loaded onto the android mobile? How should the scanning be done?</p> <p>Once HOST receives the data from android, it will determine the shortest path in accordance to algorithm and has to send back instruction (say direction - Go Left) to android. So, how can we do this? Since the student is visually impaired, the incoming msg should be audio.</p> <p>Please let me know how to achieve this? I am new to android.</p> <p>Thanks Shaban</p>
android
[4]
3,434,676
3,434,677
Linker error when trying to add constant to iterator
<pre><code>#include &lt;string&gt; #include &lt;iostream&gt; using namespace std; struct foo { static const int X = 3; static char bar(const string &amp;str) { // return str[X]; // this works return *(str.begin() + X); // this fails } }; int main() { cout &lt;&lt; foo::bar("abcdefg") &lt;&lt; endl; } </code></pre> <p>When compiling this, I get a linker error saying "undefined symbol foo::X". If the previous line is uncommented instead, then it compiles. What makes it different between these two?</p>
c++
[6]
3,811,450
3,811,451
Why are Safari and Chrome's Javascript engine's running 1.5?
<p>I was browsing the MDC Doc Center page on <a href="https://developer.mozilla.org/en/JavaScript/Guide/Closures" rel="nofollow">Closures</a>. And it mentions the introduction of the <strong>let</strong> keyword but only for use with browsers running at least the 1.7 release.</p> <p>So I looked on <a href="http://en.wikipedia.org/wiki/Javascript_1.7#Versions" rel="nofollow">Wikipedia</a> only to find that Safari and Chrome are on 1.5, while it seems every new release of Firefox has been using a newer release of JS.</p> <p>Why is that?</p>
javascript
[3]
2,538,981
2,538,982
RelativeLayout items not relative
<p>I'm going to switch this to use a Table instead of a ListView, but my concern is that these items are not relative as they should be given the provided XML.</p> <p>Is there something about the RelativeLayout being inside of Linear that's causing an issue?</p> <p><img src="http://i.stack.imgur.com/MdwS9.png" alt="enter image description here"></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;ViewSwitcher android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/dashboardViewSwitcher" android:layout_gravity="center"&gt; &lt;RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;include android:layout_width="wrap_content" android:layout_height="wrap_content" layout="@layout/loading" /&gt; &lt;/RelativeLayout&gt; &lt;RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/dashboardActivity_Header" android:id="@+id/dashboardActivityHeader"/&gt; &lt;ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/dashboardActivityList"/&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/dashboardNews_Header" android:id="@+id/dasboardNewsHeader"/&gt; &lt;ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/dashboardNewsList"/&gt; &lt;/RelativeLayout&gt; &lt;/ViewSwitcher&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
4,512,635
4,512,636
Jquery External Scripts
<p>I am using the following external jquery files in my default.aspx page.</p> <pre><code> &lt;script type="text/javascript" src="Scripts/jquery-1.2.6.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="Scripts/jquery-ui-personalized-1.5.2.packed.js"&gt; &lt;/script&gt; &lt;script type="text/javascript" src="Scripts/DefaultTab.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="TooltipScript/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="TooltipScript/easyTooltip.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="Scripts/Validation.js"&gt;&lt;/script&gt; </code></pre> <p>The first three scripts i have used for tabs. The next two are used for the tooltip plugin. The last script is used for performing validation on my default.aspx page. However my problem is that when i remove tooltip js from the page , then my tab works fine.But as soon as i include them again , tabs dont work. What could be the problem , what is the best way to refer to external js files. How should these js files be ordered inorder for all of them to work. Any help is much appreciated. Thanks</p>
jquery
[5]
1,490,806
1,490,807
Is there a function()[key] similar syntax for PHP?
<p>I always loved how i can quickly do with JavaScript:</p> <pre><code>function hello(){ return ['foo', 'bar']; } hello()[0]; // foo </code></pre> <p>Why can't we do such things with PHP or is there another short syntax for that?</p>
php
[2]
3,848,399
3,848,400
Javascript conditional order evaluation
<p>Can I count on Javascript failing immediately when one condition in an expression results to false?</p> <pre><code>f = {'a':'b'}; if (f.a !== undefined || f.a === 'b') { // Is this OK to use, because the second condition will never be evaluated? } </code></pre>
javascript
[3]
299,064
299,065
Difference between HTTPContextBase.User and MembershipUser
<p>Please clarify.</p>
asp.net
[9]
140,146
140,147
using tag on a button and passing tag value in next view label-iphone
<p>i am having some buttons whose tags have been set from 1 to 10.Now if user clicks on the buttons, the tag value should be send in next screen/nib's label.</p> <pre><code>-(IBAction) gotoGameScreen:(id)sender { [self playAudio]; UIButton *btn=(UIButton *)sender; NSLog(@"Use Selected Level=%d",btn.tag);//here i am getting the tag value as 1. GameScreen *gameScreen = [[GameScreen alloc] initWithNibName:@"GameScreen" bundle:nil]; [self.navigationController pushViewController:gameScreen animated:YES]; [gameScreen release]; } </code></pre> <p>any suggestion? Thanks</p>
iphone
[8]
3,264,733
3,264,734
Temporary variable used for each iteration of a large loop, strings are immutable so what should I use?
<p>I have a loop like:</p> <pre><code>String tmp; for(int x = 0; x &lt; 1000000; x++) { // use temp temp = ""; // reset } </code></pre> <p>This string is holding at most 10 characters.</p> <p>What would be the most effecient way of creating a variable for this use case?</p> <p>Should I use a fixed size array? Or a stringbuffer instead?</p> <p>I don't want to create 1million variables when I don't have to, and it matters for this method (performance).</p> <p><b>Edit</b> <strong>I simplified my scenerio, I actually need this variable to be at the class level scope as there are some events that take place i.e. it can't be declared within the loop.</strong></p>
java
[1]
3,244,735
3,244,736
Java:Get a value from a thread using some polling mechanism and kill the thread based on the value…?
<p>how can i poll for value from another thread. For eg: I have a method in ThreadA which calls a method of another Thread(ThreadB). I need to use some polling mechanism so that for every 5 seconds I should be able to check the value of return type(String) of that method and based on the value (say SUCCESS/FAILURE) i should be able to kill the ThreadB. How can it be done.. Please help.</p> <p>This can be done with Observer patter, but now small change -- I am polling every 5 secnds for the value of threadB. but the value of ThreadB will change only after 10 min. here my question is in every 5 seconds how can i get the value of ThreadB without invoking it everytime. ThreadB can only be invoked once.</p>
java
[1]
24,286
24,287
locate nearby hospitals on google map
<p>Hi anyone plesae give me suggestions to show near by hospitals on google map. I am trying to do this since 3days and i am searching in internet since 3 daysbut i am not getting any solutions . It seems really difficult for me</p>
android
[4]
3,047,870
3,047,871
How to get the URL the client used
<p>In ASP.NET, how can I know whether the user has typed the default document in the URL or not&mdash;i.e., distinguish if the URL ends with <code>/</code> or <code>/Default.aspx</code>?</p>
asp.net
[9]
1,519,492
1,519,493
When I say require("http://url.com/directory/file.php?test=name") it returns 0 why is this?
<p>When I say require("http://url.com/directory/file.php?test=name") it returns 0 why is this? I also cannot call values ($value) with PHP. How can I do this? What am I doing wrong here?</p>
php
[2]
3,811,448
3,811,449
Bitmap.createBitmap() on Android 2.2 issue
<p>I have tested my game on HTC Desire with Android 2.2. Game is 2D with custom defined sprites with multiple bitmap images (frames). Frames are generated from one larger image using method Bitmap.createBitmap(): <br> <br> <code>bitmapFrames[currentFrame][0] = Bitmap.createBitmap(image, startX, startY, width, height, matrix, true);</code> <br></p> <p>It works ok on Android 1.5 and 1.6 devices. Also it works ok on all emulators (1.5, 1.6, 2.1 and 2.2) but on real HTC Desire device all sprite frames are drawn. It looks like above mentioned method ignore parameters startX, startY, width, height when creating bitmap frame. <br>Any clue about this issue?</p>
android
[4]
1,765,700
1,765,701
Android RMI with UI Thread
<p>I am trying to remote invoke method form other apk. Everything is working except fact that invoking method has to do some operations on UI and must be run from UI Thread. Method which was invoked with Method.invoke() are running in separate thread and has no access to UI. Is AsyncTask is a proper way to solve this problem? Or maybe exists a better solution.</p>
android
[4]
5,889,948
5,889,949
Can I do an assignment operation between two istream_iterators?
<p>Can I do an assignment operation between two istream_iterators? If so then what will be the behaviour, i.e. will both the iterators point to the same location in the file, i.e. will we get two pointers to the same line in a file?</p> <p>If so, can I increment one iterator, read some lines, and then assign it back to other iterator and then again start reading lines from the same location where we were earlier?</p> <p>Basically I want to write a program that simulates for loop. But this should happen while parsing a file.</p>
c++
[6]
3,727,680
3,727,681
Distributing a development version of an iPhone application
<p>My company has recently started developing custom iPhone applications for various clients. One of the challenges we are running into is how to get these applications to the client so they can review them during the development process.</p> <p>Ideally, this would just be a matter of sending them the app file and having them install it on their iPhone. Of course app signing makes things much more complicated than that. We would have to add their phone ID to our development profile, have them provision their phone to accept the app, then install the app. This creates a headache for us of course in trying to walk the client through this process.</p> <p>At this point, our best solution is either to simply send them screenshots or to snail-mail an iPod Touch back and forth with the app installed on it. Of course neither of those options is ideal.</p> <p>Is there a better way to distribute development versions of iPhone/iPod Touch apps to non-technical clients?</p>
iphone
[8]
4,984,580
4,984,581
binary tree insertion 3
<p>I am trying to write my own binary tree and I have problems with insertion. The values in tree are duplicated. I have inner static class Node with "Node right,left and int value" fields and outer class BinaryTree with one field - Node root.</p> <p>The code of insertion:</p> <pre><code>public void insert(int number) { if (root.isEmpty()) root.value = number; else { Node node = root; insert(number, node); } } private void insert(int number, Node node) { if (number &lt; node.value &amp;&amp; node.left != null) { node = node.left; insert(number, node); } else { if (node.left == null) node.left = new Node(null, null, number); } if (number &gt; node.value &amp;&amp; node.right != null) { node = node.right; insert(number, node); } else { if (node.right == null) node.right = new Node(null, null, number); } } </code></pre> <p>What i am doing wrong?</p>
java
[1]
5,081,045
5,081,046
Can two ListViews use the same ArrayAdapter?
<p>As far as I know, ArrayAdapter is used to handle data for ListView's content. I have two ListViews (in the same activity) that contain the same data, <strong>with two different behaviors (should be handle in two different onListItemClick() )</strong> though. Can I use the same ArrayAdapter for both of them? I can check this but I'm not sure it will create bug if I use the same Adapter.</p> <p>Furthermore,if I don't extend ListActivity as in this <a href="http://www.vogella.de/articles/AndroidListView/article.html" rel="nofollow">tutorial</a>, how can I handle onListItemClick() events from those ListViews?</p> <p>Thank in advance</p>
android
[4]
3,105,813
3,105,814
How to apply an animation color effect on a div
<p>I have this jQuery function :</p> <pre><code>$('.tracklistOff').find('.trackon').clone().insertAfter(($(param).parents('.trackon'))); </code></pre> <p>I clone the div and I add it. The CSS class of <code>trackon</code> is :</p> <pre><code>.trackon{width:710px; height:26px; color:#CCCCCC; font-weight:bold; float:left;} </code></pre> <p>I'd like, when I add it, to put a red background color of trackon, and shade it to black; a sort of fadeIn(), without starting from hide (but from red) and finish to the <code>trackon</code> background (in my context, should be white). How can I do it without any plugins?</p>
jquery
[5]
5,564,070
5,564,071
using jquery to remove links, but not images
<p>I have a that has a bunch of list items, each with an image wrapped in a hyperlink. I'm trying to write some jQuery that will remove the links, but not the images. Is this possible?</p>
jquery
[5]
1,108,563
1,108,564
Iterate through form not working
<p>I have been using this code to iterate through form elements and until now it has worked flawless:</p> <pre><code>$(document).ready(function() { $(':input', '#myform').each(function() { alert('test'); $(this).attr('disabled', 'disabled'); }); }); </code></pre> <p>But on this new form it does not work, even though the form is almost the same as the others, it's too big to put it all here though. If I try this code, one messagebox pops up, if I set the alert() to show the name of $(this), it shows the form name...</p> <pre><code>$(document).ready(function() { $('#myform').each(function() { alert('test'); }); }); &lt;form id="myform" name="myform" method="POST"&gt; .... </code></pre> <p>Any idea why this happens? Thank you</p>
jquery
[5]
4,534,623
4,534,624
How to Place ActionBar Items in Main ActionBar and Bottom Bar
<p><img src="http://i.stack.imgur.com/c1VVk.jpg" alt="enter image description here"></p> <p>The Google+ app has a layout where it has action bar items in the main action bar and the bottom. Currently I am using android:uiOptions="splitActionBarWhenNarrow" to place items in the bottom bar. How can I place items on both the top and bottom?</p>
android
[4]
3,721,171
3,721,172
C++ illegal digit, simple issue
<p>I'm running against this error:</p> <pre><code>int temp = 0789; error C2041: illegal digit '8' for base '8' </code></pre> <p>For what I can understand is that the compiler understands any number that begins with 0 like 0123 to be octal. But how can I tell the compiler to just take it with the 0 in front?</p>
c++
[6]
3,116,253
3,116,254
How to let C++ know that an operator has been overloaded for a class
<p>Is it possible to write a template function for which a particular type of classes have some functions or overloaded operators? For instance</p> <pre><code>template &lt;typename T&gt; void dosomething(const T&amp; x){ std::cout &lt;&lt; x[0] &lt;&lt; std::endl; } </code></pre> <p>In this context I'm assuming that x is a class that behaves like an array, that is, I have overloaded the <code>[]</code> operator as well as the <code>&lt;&lt;</code> so that it can work with <code>std::cout</code>. </p> <p>The actual code that I have is slightly different but gcc is giving me</p> <pre><code>error: subscripted value is neither array nor pointer </code></pre> <p>This must be because it doesn't know that I'm expecting <code>T</code> to be of some class that overloads the <code>[]</code> operator. Does anyone know if it is possible to overcome this? I'd like to let c++ know that the particular type <code>T</code> will have the <code>[]</code> overloaded. </p>
c++
[6]
5,141,023
5,141,024
add diffrent intent to each notification
<p>Currently i'm developing android app witch will show notifications(advertisements, discounts avalible and so on) when i'm near some shop. The problem is there could be many shops around and as a result many notifications, so how can i set difrent intents for my notifications if they are generated like this:`</p> <pre><code>private void notifymes(String adress, String prece,int poz) { // TODO Auto-generated method stub Context context = this.getApplicationContext(); notificationManager = (NotificationManager) context .getSystemService(NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(this, showadvert.class); notificationIntent.putExtra("lat", rdat.get(poz).lata); notificationIntent.putExtra("longa", rdat.get(poz).longa); notificationIntent.putExtra("adr", rdat.get(poz).adrese); notificationIntent.putExtra("prece", rdat.get(poz).prece); contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification = new Notification(); notification.setLatestEventInfo(context, prece, adress, contentIntent); notification.icon = android.R.drawable.stat_notify_sync; notification.tickerText = "Good deal avalible"; notification.when = System.currentTimeMillis(); notificationManager.notify(poz, notification); } </code></pre> <p>I would be pleased if you could help me out.</p> <p><strong>EDIT:</strong>(data is in sql database) ` As you didn't understand me i will give example. So the example is..... i have 3 or more notifications witch were generated by some loops and this code. Each of the notification has to pass difrent data to another activity.</p>
android
[4]
2,663,926
2,663,927
java HashMap containsKey is returning false though key is present
<p>I am using a HashMap data structure to store a SqMatrix (square matrix), where the key is of type MatrixIndex (which contains row and col) and the value is of type Integer. </p> <p>But when I am getting false as output of "if (mat.containsKey(key))" though the HashMap has the corresponding key in it.</p> <p>The main code: </p> <pre><code>public static void main(String[] args) { Random generator = new Random(); int val = 0; Types.MatrixIndex key, key1; int matSz = (int) Math.floor(Math.sqrt(10)); Types.SqMatrix mat = new Types().new SqMatrix(matSz); //matSz*matSz elements //HashMap&lt;Types.MatrixIndex,Integer&gt; hMap= new HashMap&lt;Types.MatrixIndex,Integer&gt;(10); for (int r=0; r&lt;matSz; r++) { for (int c=0; c&lt;matSz; c++) { if (r&lt;c) { val = generator.nextInt(2) &gt; 0? -1 : val; key =(new Types()).new MatrixIndex(r, c); key1 = (new Types()).new MatrixIndex(c, r); mat.put(key, val); mat.put(key1, val); generator.setSeed(System.currentTimeMillis()); } } } for (int r=0; r&lt;matSz; r++) { val = 0; for (int c=0; c&lt;matSz; c++) { if (r!=c) { key = (new Types()).new MatrixIndex(r, c); if (mat.containsKey(key)) { val = val + mat.get(key); } } } key1 = (new Types()).new MatrixIndex(r, r); mat.put(key1, val); } </code></pre> <p>Do anybody have an idea on why the containsKey is returning false though it is present in the HashMap?</p> <p>Thanks in advance,</p> <p>Somnath</p>
java
[1]
4,448,363
4,448,364
const string vs. #define
<p>i need to share some strings in my c++ program. should i use #define or const string? thanks</p> <p>mystring1.h </p> <pre><code>#define str1 "str1" #define str2 "str2" </code></pre> <p>Or<br> mystring2.h </p> <pre><code>extern const string str1; extern const string str2; </code></pre> <p>mystring.cpp </p> <pre><code>const string str1 = "str1"; const string str2 = "str2"; </code></pre>
c++
[6]
276,374
276,375
Python import causing syntax error
<p>I'm an old-fashioned Pascal programmer, new to OOP and Pyhton, so please bear with me...I've got a book on Python and I've searched here first (although lots of similar threads - not checked every one)...</p> <p>I'm trying to write a program to include existing modules written by others in my company. According to my Python book, I should be able to import whole modules or just specific classes. The book says that when 'import' is used, it actually runs the specified code (not like the INHERIT I'm used to in Pascal).</p> <p>I have this structure in the module, mod.py, I want to use:</p> <pre><code>from x.y.z import stuff class c1(superclass): def func1(self): .... def func2(self, db): .... with self.db as handler: .... </code></pre> <p>and I've got a basic script, test.py, that does just this:</p> <pre><code>from mod import c1 print "Hello" </code></pre> <p>when I execute 'python test.py', I get the error message:</p> <pre><code>'with self.db as handler' - invalid syntax </code></pre> <p>I think I'm missing something fundamental here, so any help much appreciated.</p>
python
[7]
3,359,268
3,359,269
Reading formatted input from an istream
<p>The problem below has been simplified from real requirements.</p> <p>Consider the following program:</p> <pre><code>#include &lt;iostream&gt; #include &lt;iterator&gt; #include &lt;string&gt; #include &lt;set&gt; #include &lt;algorithm&gt; using namespace std; typedef string T; // to simplify, always consider T as string template&lt;typename input_iterator&gt; void do_something(const input_iterator&amp; first, const input_iterator&amp; last) { const ostream_iterator&lt;T&gt; os(cout, "\n"); const set&lt;T&gt; words(first, last); copy(words.begin(), words.end(), os); } int main(int argc, char** argv) { const istream_iterator&lt;T&gt; is(cin), eof; do_something(is, eof); return 0; } </code></pre> <p>The program extracts all the words from an <code>istream</code> (<code>cin</code>) and does something with them. Each word is seperated by a white space by default. The logic behind the formatted extraction is inside the <code>istream_iterator</code>.</p> <p>What I need to do now is to pass to <code>do_something()</code> two iterators so that the extracted words will be separated by a punctuation character instead of a white space (white spaces will be considered as "normal" characters). How would you do that in a "clean C++ way" (that is, with the minimum effort)?</p>
c++
[6]
631,360
631,361
Why 0 || 1 returns true in php?
<p>In Javascript and Python, <code>0 || 1</code> returns <code>1</code>.</p> <p>But in PHP, <code>0 || 1</code> returns true.</p> <p>How to do if I want <code>0 || 1</code> return <code>1</code> in PHP?</p> <p>another example,</p> <p><code>$a</code> is <code>array(array('test'))</code></p> <p>I want <code>$a['test'] || $a[0] || array()</code> return <code>array('test')</code>, How to do?</p>
php
[2]
1,608,010
1,608,011
Javascript: getElementById() wildcard
<p>I got a div, and there i got some childnodes in undefined levels.</p> <p>Now I have to change the ID of every element into one div. How to realize?</p> <p>I thought, because they have upgoing IDs, so if the parent is id='path_test_maindiv' then the next downer would be 'path_test_maindiv_child', and therefore I thought, I'd solve that by wildcards, for example:</p> <pre><code>document.getElementById('path_test_*') </code></pre> <p>Is this possible? Or are there any other ways?</p>
javascript
[3]
1,111,159
1,111,160
how to reassign value to an object using constructor in c++
<p>I came through a pretty interesting question... what can be the class declaration for the following segment of code in c++..</p> <pre><code>int main(){ Point f(3,4); //class Point f(4); } </code></pre> <p>the object declaration can be done by declaring a constructor f(int, int). But how can we use a constructor declaration to assign values to an object?? Even if define another constructor f(int), this will not work... as constructors are called only during object declaration. Please suggest a way to do this....</p>
c++
[6]
966,720
966,721
Port of CreateFile INVALID_HANDLE_VALUE
<p>So I'm porting this stuff from c++ to c#. And part of it looks like this:</p> <pre><code> m_hParstat = CreateFile( _T("\\\\.\\LPTSTAT1"), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( m_hParstat == INVALID_HANDLE_VALUE ) { // do some stuff } </code></pre> <p>So in my c# code I've got </p> <pre><code>[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile); public const int FILE_ATTRIBUTE_NORMAL = 0x00000080; public const uint GENERIC_READ = 0x80000000; public const uint OPEN_EXISTING = 3; public const UInt32 INVALID_HANDLE_VALUE = 0xffffffff; </code></pre> <p>And then </p> <pre><code> m_hParstat = CreateFile("\\\\.\\LPTSTAT1", GENERIC_READ, 0, IntPtr.Zero, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, IntPtr.Zero); if (m_hParstat.ToInt32() == INVALID_HANDLE_VALUE) { } </code></pre> <p>But VS is saying that the comparison is useless because the constant is outside the range of int. How do I check my handle for a valid value?</p>
c#
[0]
5,409,781
5,409,782
Break apart variable contents and load into array with php
<p>This is what i have.</p> <pre><code>$number = 25880; </code></pre> <p>I need to break that up into individual lines in an array so i can read it like this</p> <pre><code>$numbers['1'] = 2 $numbers['2'] = 5 $numbers['3'] = 8 $numbers['4'] = 8 $numbers['5'] = 0 </code></pre> <p>How do i do this in php?</p>
php
[2]
2,257,467
2,257,468
Change color of div and remove text of span using Jquery
<pre><code>&lt;td class="tdLeftZoneCss" id="tdLeftZone"&gt; &lt;div&gt; &lt;div style="border-bottom-color: black;"&gt; &lt;span&gt;John&lt;/span&gt; </code></pre> <p>1) I want to change color (black to #F2F2F2) of 2nd Div </p> <p>2) I want to remove text ('John') written in span</p> <p>How to do that using Jquery?</p>
jquery
[5]
4,523,652
4,523,653
How can I turnoff suggestions in EditText?
<p>How can I turnoff suggestions in EditText in Android?</p>
android
[4]
1,193,351
1,193,352
Find String with regexp
<p>How can I find if a string starts with <code>[</code> and ends with <code>]</code> in JavaScript?</p> <pre><code>var str = '[["a" , "b"]]'; </code></pre> <p>And is there any way to identify if the above string is typeof array of array?</p>
javascript
[3]
2,278,586
2,278,587
Facebook need curl php extension in ubandu
<p>I have installed php5 in my ubandu.I am using graph api to commuicate with facebook.But i am getting the error like "Facebook needs the CURL PHP extension".I know that i have to add "extension=php_curl.dll" line in the php.ini file.but the existing ini file is not having any extension. And there is no file called "php_curl.dll".</p>
php
[2]
4,271,200
4,271,201
Memory management and performance
<p>If I allocate an object in a method, 'getASprocket' and call it this way, will there be a leak here?</p> <pre><code>Sprocket *sprock = [Sprocket getASprocket]; // store this returned value as an ivar ivarSprock = [sprock retain]; // release the originally acquired object [sprock release]; </code></pre> <p>The Sprocket object is allocated and returned this way:</p> <pre><code>– (Sprocket *)getASprocket { Sprocket *sprocket; sprocket = [[Sprocket alloc] init]; return [sprocket retain]; } </code></pre> <p>Also, would changing from <code>'[sprocket retain];'</code> inside the 'aSprocket' method to <code>'return [sprocket autorelease];'</code> make worse performance hit?</p>
iphone
[8]
4,614,168
4,614,169
AVAudioPlayer seek performance is not good
<p>We are a developing an application which is supposed to play long audio files. duration of audio file can be upto 23 hours...</p> <p>we are trying to use this AVAuidoPlayer for this purpose. To perform fast forward we are setting CurrentTime property of AVAudioPlayer. if the forward duration is just few minutes or even upto 20 minutes everything works fine. But if we try to jump by say 2 hours time then setCurrentTime call on the player take too long time ( almost 30-40 seconds). This is not acceptable behavior.</p> <p>please let me know if anybody managed to successfully use AVAudioPlayer setCurrentTime property to jump long durations (say 2 hours)</p>
iphone
[8]
5,979,165
5,979,166
Oneliner: Why does this yield undefined is not a function?
<p>Why does the following line sometimes yield the message "undefined is not a function" in the chrome dev console: </p> <pre><code>(callbackOrUndefined || function() {})(); </code></pre> <p>The idea is to execute callback if it is truthy, i.e. a function, otherwise execute the empty function.</p> <p>I had to replace it with :</p> <pre><code>if (callbackOrUndefined !== undefined) callbackOrUndefined(); </code></pre> <p>Edit: I guess I wasn't clear enough. It sometimes seem to evaluate the block to undefined(); and I don't understand how and why.</p>
javascript
[3]
4,089,574
4,089,575
Whats wrong with this method?
<p>I'm new to java can someone please explain to me whats wrong with this method: </p> <pre><code>clas Hello { public static void main (String[]arg) { Document.write ("hello world") ; }} </code></pre>
java
[1]
5,979,790
5,979,791
Is there any free software for Android that can send my geolocation to a web service?
<p>Is there any free software for Android that can send my mobile phone's geolocation information to a Google map or to my own URL?</p>
android
[4]
3,215,627
3,215,628
fileinfo_open() Fatal error
<p>i am using PHP 5.3 and i have checked that my fileinfo is enabled. But when i run my code its occurring an error </p> <blockquote> <p>Fatal error: Call to undefined function finfo_open()</p> </blockquote> <p>Anyone can help me to fixed this, here is my code.</p> <pre><code>$mime=finfo_open(FILEINFO_MIME,filename); echo "File Type is: ".$mime; </code></pre>
php
[2]
49,277
49,278
What are the differences between using array offsets vs pointer incrementation?
<p>Given 2 functions, which should be faster, if there is any difference at all? Assume that the input data is very large</p> <pre><code>void iterate1(const char* pIn, int Size) { for ( int offset = 0; offset &lt; Size; ++offset ) { doSomething( pIn[offset] ); } } </code></pre> <p>vs </p> <pre><code>void iterate2(const char* pIn, int Size) { const char* pEnd = pIn+Size; while(pIn != pEnd) { doSomething( *pIn++ ); } } </code></pre> <p>Are there other issues to be considered with either approach?</p>
c++
[6]
1,294,420
1,294,421
jQuery is doubling my cloning everytime I click a link to clone html?
<p>The following html snippet contains an input, a select and a link. When I click the link, I want to basically clone line, I want the new line to be appended to the last line. I also would like the link to be removed and be added to the last line. I want to have the even carried over as well. I will put my jquery code below the html. </p> <pre><code>&lt;div id="lines"&gt; &lt;div class="line"&gt; &lt;span&gt;Value&lt;/span&gt;&lt;input type="text" name="value" class="value"/&gt; &lt;span&gt;Type&lt;/span&gt; &lt;select name="type" class="type"&gt; &lt;option&gt;$&lt;/option&gt; &lt;option&gt;%&lt;/option&gt; &lt;/select&gt; &lt;a id="addLine" href="#"&gt;Add&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; $(document).ready(function() { $('#addLine').click(function() { $('.line').clone({withDataAndEvents:true}).appendTo('#lines'); }); }); </code></pre> <p>When I click add, it first adds a second line below the first one, but then when I click add again, it adds 2 lines, so I have 4, every time I click add, it is doubling the amount of lines which is what I don't want. I also want add removed from all the lines except the last one. I probably will have a Remove as well to remove a specific line, so I would like suggestions on how to handle this.</p>
jquery
[5]
877,041
877,042
How to get an Android WakeLock to work?
<p>My WakeLock isn't keeping my device awake.</p> <p>In <code>OnCreate()</code> I've got:</p> <pre><code>PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "My Tag"); mWakeLock.acquire(); </code></pre> <p>then:</p> <pre><code>new CountDownTimer(1320000, 200) { public void onTick(long millisUntilFinished) { // I update a progress bar here. } public void onFinish() { // I finish updating the progress bar. mWakeLock.release(); } }.start(); </code></pre> <p>The screen turns off before the timer finishes, how can I make the screen stay visible?</p> <p><code>mWakeLock</code> is a field previously declared like so:</p> <pre><code>private PowerManager.WakeLock mWakeLock; </code></pre> <p>My device uses Android 1.6. I would really appreciate any help to resolve this.</p>
android
[4]
1,045,064
1,045,065
code to calculate time in nanoseconds
<p>i have following code</p> <pre><code>#include &lt;iostream&gt; #include &lt;time.h&gt; #include &lt;stdlib.h&gt; #include &lt;stdio.h&gt; int main(){ //nanoseconds int x,y; x=6700; y=10000; int z=0; clock_t t =clock(); while (y!=0){ z+=x&lt;&lt;2; x=x&gt;&gt;2; y&gt;&gt;=2; } t=clock()-t; t=1000*t/CLOCKS_PER_TICK; printf("%d\n",t); } </code></pre> <p>but it writes that</p> <pre><code>1&gt;c:\users\david\documents\visual studio 2010\projects\nano_seconds\nano_seconds.cpp(20): error C2065: 'CLOCKS_PER_TICK' : undeclared identifier </code></pre> <p>but i have read that there exist in c++ such keyword</p>
c++
[6]
4,155,930
4,155,931
jQuery partial form reset to initial value
<p>I have a form that has a bunch of input type="text" boxes that are loaded with values from a database. I can then change these values and POST. This form has a few subsections that I have boxed in with framesets. What I would like to do is give the user a button to undo any changes they have made to inputs in a particular fameset. I know I can use:</p> <pre><code>$('#myForm').get(0).reset(); </code></pre> <p>To reset the entire form. I was hoping that I could do something like:</p> <pre><code>$('#myForm #myFrameset').get(0).reset(); </code></pre> <p>or</p> <pre><code>$('#myForm input').get(0).reset(); </code></pre> <p>to reset the input boxes within a particular frameset. However, (valuable lesson of the day for this noob) .reset() is only a form selector so when I ('#myForm #myFrameset') I am selecting an element and not a form. </p> <p>I don't want to reload from the database because it seems to me that the data I want is there. I just can't figure out how to access it without resetting the entire form. I'm going to work on a function where I store the value in the input placeholder and set the input value to the placeholder value on reset button click. It should work but I'm wondering is there a simpler way to do this in jQuery? Is there a better way to do this in general?</p>
jquery
[5]
2,775,862
2,775,863
Sending Multitouch report descriptor and input report to Android phone (jelly bean) via AOA 2.0
<p>I need to send Multitouch report descriptor and corresponding input reports to Android phone (Jelly Bean version) via AOA 2.0 protocol. I am able to send the descriptor and input report successfully, but android device considering only one touch. Any help regarding this would be a great helpful to me.</p> <p>I am doing in this way:</p> <ol> <li>Switch the phone to AOA mode</li> <li>Send Multitouch report descriptor in a single command</li> <li>send Report data of 14 bytes which contains first touch <code>(x,y)</code> and second touch <code>(x,y)</code> information.</li> </ol>
android
[4]
4,831,701
4,831,702
Convert list of lists to delimited string
<p>How do I do the following in Python 2.2 using built-in modules only?</p> <p>I have a list of lists like this:<br /> [['dog', 1], ['cat', 2, 'a'], ['rat', 3, 4], ['bat', 5]]</p> <p>And from it I'd like to produce a string representation of a table like this where the columns are delimited by tabs and the rows by newlines. </p> <pre><code>dog 1 cat 2 a rat 3 4 bat 5 </code></pre> <p>i.e.<br /> 'dog\t1\ncat\t2\ta\nrat\t3\t4\nbat\t5'</p>
python
[7]
4,223,041
4,223,042
php parse string parameters to array
<p>i need to parse string param to array</p> <p>Examples:</p> <pre><code>p10s2z1234 </code></pre> <p>Output</p> <pre><code>Array( 'p' =&gt; 10, 's' =&gt; 2, 'z' =&gt; 1234 ) </code></pre> <p>thank any advance.</p>
php
[2]
3,151,726
3,151,727
Creating a regex for parsing screens resolutions
<p>I have a string of text that somewhere will contain the resolution to my vid in the format <code>###x###</code> or <code>####x####</code> (ex. 320x240 or ex. 1024x1280 ex. 320x1024 etc.) or any combo in between. I am not great at regexes yet and I was wondering if anyone could point out where I am going wrong.</p> <pre><code>$res='some long string'; $search='/([0-9]{3-4})x([0-9]{3-4})/'; preg_match($search, $res, $matches); $res1=$matches[1]; $res2=$matches[2]; </code></pre>
php
[2]
2,028,984
2,028,985
Symfony mssql_connect
<p>I am facing a problem with mssql_connect. I am using symfony1.1. mssql_connect working properly in actions. But I am getting " Call to undefined function mssql_connect()" when i call mssql_connect from symfony task. Any one please help me to solve this issue. Thanks in advance</p> <p>Avinash</p>
php
[2]
3,856,477
3,856,478
php script to Verify a User’s Email Address
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/201323/what-is-the-best-regular-expression-for-validating-email-addresses">What is the best regular expression for validating email addresses?</a><br> <a href="http://stackoverflow.com/questions/5285604/php-script-that-test-e-mail-address">Php script that test e-mail address</a> </p> </blockquote> <p>Can anyone suggest me is there a php script to Verify a User’s Email Address. I want to know user entered email is valid or not(email working or not).</p>
php
[2]
3,984,022
3,984,023
Android, trying to call a new intent from a touch event
<p>I'm trying to make a app that when the screen is touch it will call up a new intent. I have code that catches the touch event in the view class. When I try to create a new intent, Intent(this, cYesNoDisplay.class);, i get a error saying the constuctor is undefined, I'm assuming the constructor is not defined in the view base class, but the Activity class?</p> <p>I'm confused about how to do this, is there a way for my View class that is a member of the intent class, to call it some how???? I figure there must be a wy to do this, still learning Java. Ted</p>
android
[4]
1,161,075
1,161,076
Assign shortcut keys to input button using jQuery
<pre><code>&lt;html&gt; &lt;script&gt; $('#pasteButton').click( function() { // place code for this button // ctrl + v shortcut should work for this button // how? } }); &lt;/script&gt; &lt;body&gt; &lt;input type="button" id="pasteButton" value="Paste" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Thanks in advance. Similarly, I also need to cut / copy selected text from a textarea using buttons.</p>
jquery
[5]
1,948,160
1,948,161
Suppress layout animation on one child view
<p>I'm setting layout animation to list view (my items are dropping down). In list view I have a header that I don’t what to animate.</p> <p>How can I suppress animation on my header?</p>
android
[4]
1,780,113
1,780,114
Test for empty nested array
<p>I have the following array:</p> <pre><code>array(4) { [29] =&gt; NULL [31] =&gt; NULL [33] =&gt; NULL [35] =&gt; NULL } </code></pre> <p>I would like to test all keys if all keys contain NULL values. </p>
php
[2]
1,654,420
1,654,421
Button action inside list view
<p>I have a list view with a custom adapter. the layout for the adapter has some ImageViews which act as buttons. I implemented the onclicklistner for these</p> <pre><code>listView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1,int arg2, long arg3) { ImageView btn = (ImageView) arg1.findViewById(R.id.btn); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // for the button action Log.d("Button Action", "Clicked"); } }); } } </code></pre> <p>when i click the button first time it does not do any thing .i have to click twice to get the button work. Why is this. can any one point me my mistake </p> <p>thanks in advance</p>
android
[4]
5,975,812
5,975,813
How to open child window in another child windows's tab in javascript?
<p>I am struggling over here with a simple problem in javascript.<br> what I want to do:<br> 1. open a popup(p1) from main page.<br> 2. open another popup(p2) from first popup(p1).<br> 3. now I want to open popup from p2 in p1's tab.<br> I am using following code:<br></p> <pre><code>var test = null; // open first popup(p1) from main page function openpopup1(URL,id) { test = eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=850,height=650,left = 520,top = 300');"); } // open second popup(p2) from p1 popup function openpopup2(URL,id){ eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=650,height=300,left=650,top = 280');"); } // now open popup into p1's tab from p2 popup function openpopupTop1stab(){ var newTab = window.open("tab.html"); window.test.opener(newTab); // this code is not working } </code></pre> <p>How can I solve this problem?</p>
javascript
[3]
730,113
730,114
iPhone: Slide photos by finger
<p>I want to implement something like Iphone Photo Gallery... How to slide images by finger, and how to do that animation if I want to slide photos by clicking on button ? Thanks...</p>
iphone
[8]
5,010,092
5,010,093
How to change values using jquery?
<p>How do i go about changing the values inside the style for width and height using jquery? </p> <pre><code>&lt;div id="id11t" style="position: relative; width: 1022px; height: 446px;"&gt; </code></pre> <p>Thanks</p>
jquery
[5]
4,980,312
4,980,313
How to extract base 10 mantissa and exponent using gpmlib in C++
<p>I need to extract significand and exponent of a double in C++ using gpmlib. Ex: double a = 1.234; I would like to extract 1234 as significand and 3 as exponent so that a = 1234e-3. I heard that gpmlib supports this type functions. I am not sure how to this library.</p> <p>Please share some sample code using this library.</p> <p>Thanks, Sei</p>
c++
[6]
4,401,600
4,401,601
Decrement a variable in an incrementing for loop
<p>In my python script, I am itterating through a list (headerRow) starting at index 9. I want to check to see if it is already in the database, and if not then add it to a database with an auto-incementing primary key. I then want to send it through the loop again to retrieve it's primary key.</p> <pre><code>for i in range (9, len(headerRow)): # Attempt to retrieve an entry's corresponding primary key. row = cursor.fetchone() print i if row == None: # New Entry # Add entry to database print "New Entry Added!" i -= 1 # This was done so that it reiterates through and can get the PK next time. print i else: # Entry already exists print "Existing Entry" qpID = row[0] # ... </code></pre> <p>Here is the output of my script:</p> <pre><code>9 New Question Added! 8 10 New Question Added! 9 11 </code></pre> <p>As you can see, my issue is that range() doesn't care what the existing value of <code>i</code> is. What is the preferred python way to do what I'm trying to do?</p> <p>Thanks in advance,</p> <p>Mike</p>
python
[7]
1,092,654
1,092,655
filtering on Class name not working using jquery filter method
<p>When I attempt to filter on a class name using jquery filter method, it does not work (no data is inserted into the #Test1Section', for example,</p> <pre><code> $(data).find('.test1WrapperDiv').appendTo('#Test1Section'); </code></pre> <p>but if when I use the element name as a filter it works but not what I won't.</p> <pre><code> $(data).find('div').appendTo('#Test1Section'); </code></pre> <p>php file</p> <pre><code> echo "&lt;div class='test1WrapperDiv'&gt;"; echo "&lt;div&gt;&lt;p&gt; Row 1 &lt;/p&gt;&lt;/div&gt;"; echo "&lt;div&gt;&lt;p&gt; Row 2 &lt;/p&gt;&lt;/div&gt;"; echo "&lt;div&gt;&lt;p&gt; Row 3 &lt;/p&gt;&lt;/div&gt;"; echo "&lt;div&gt;&lt;p&gt; Row 4 &lt;/p&gt;&lt;/div&gt;"; echo "&lt;/div&gt;"; echo "&lt;div class='test2WrapperDiv'&gt;"; echo "&lt;div&gt;&lt;p&gt; Row 1 &lt;/p&gt;&lt;/div&gt;"; echo "&lt;div&gt;&lt;p&gt; Row 2 &lt;/p&gt;&lt;/div&gt;"; echo "&lt;div&gt;&lt;p&gt; Row 3 &lt;/p&gt;&lt;/div&gt;"; echo "&lt;div&gt;&lt;p&gt; Row 4 &lt;/p&gt;&lt;/div&gt;"; echo "&lt;/div&gt;"; $.post("test.php",{sendword: test1, table: table_name1} function(data) { $(data).find('.test1WrapperDiv').appendTo('#Test1Section'); }); </code></pre> <p>How do I get it to work using a CSS class name?</p>
jquery
[5]
3,432,646
3,432,647
I have issue with jQuery Accordion
<p>i m working on jQuery accordion and i got the code from this <a href="http://jqueryui.com/demos/accordion/" rel="nofollow">link</a> accordion working perfectly but the issue is i want to open 2nd tab by default when user come over my page i want to show them the content in second tab . </p> <p>plaese help me out </p> <p>Thanks in advance</p>
jquery
[5]
1,207,273
1,207,274
removing objects from an object array in php?
<p>for example say i have an object array called $list looks like this:</p> <pre><code>&lt;(stdClass)#16 (3) { ["1"]=&gt; &lt;(8) "50504496" ["2"]=&gt; &lt;(8) "12435374" ["3"]=&gt; &lt;(8) "12436374" </code></pre> <p>Im doing a foreach on the object array and removing them if they exist in the database i.e</p> <pre><code> foreach($list as $l){ //do the query if( it exists){ //remove from objects: this is where i need help!! } } </code></pre> <p>i have the db logic, im just stuck to know how i can remove objects, i was thinking maybe i should create a new object and add them thier. thanks }</p>
php
[2]
4,626,961
4,626,962
Encoding Querystring Params
<p>I am wondering if maybe I have this wrong with the double %%</p> <p><a href="http://www.someone.com/SomePage.aspx?aid=%%MA%5FID%%&amp;tid=%%RECI%5FID%%&amp;" rel="nofollow">http://www.someone.com/SomePage.aspx?aid=%%MA%5FID%%&amp;tid=%%RECI%5FID%%&amp;</a></p> <p>is it %% or % to encode querystring values?</p>
asp.net
[9]
2,214,540
2,214,541
Easy template implementing
<p>Suppose I've written class template declaration somewhere in <code>collector.h</code>:</p> <pre><code>template &lt;class T, int maxElements&gt; class collector { T elements[maxElements]; int activeCount; public: collector(); void process(); void draw(); }; </code></pre> <p>and implementing its three methods in <code>collector.cpp</code>:</p> <pre><code>template &lt;class T, int maxElements&gt; collector&lt;T, maxElements&gt;::collector(){ //code here } template &lt;class T, int maxElements&gt; void collector&lt;T, maxElements&gt;::process(){ //code here } template &lt;class T, int maxElements&gt; void collector&lt;T, maxElements&gt;::draw(){ //code here } </code></pre> <p>Is there any way of not writing <code>template &lt;class T, int maxElements&gt;</code> and <code>&lt;T, maxElements&gt;</code> for every function's implementation? Something like that:</p> <pre><code>template &lt;class T, int maxElements&gt;{ collector&lt;T, maxElements&gt;::collector(){ //code here } void collector&lt;T, maxElements&gt;::process(){ //code here } void collector&lt;T, maxElements&gt;::draw(){ //code here } } </code></pre>
c++
[6]
223,006
223,007
How to clear Jquery validation error messages?
<p>I am using jquery validation plugin for client side validation.</p> <p>but i want to clear error mesages on my form clear button</p> <p>editUser() is called on click of Edit User button.</p> <pre><code>clear button having separated function clearUser(){ // Need to clear previous errors here } function editUser(){ var validator = $("#editUserForm").validate({ rules: { userName: "required" }, errorElement: "span" , messages: { userName: errorMessages.E2 } }); if(validator.form()){ // form submition code } } </code></pre> <p>Thanks</p>
jquery
[5]
1,133,148
1,133,149
My own copy() function collides with std::copy()
<p>I have a header file. In this header I want to use a map for a class. But after I include I get a <code>no matching function error</code>, because I have a copy() function in the project(really big project). I saw on this website <a href="http://www.sgi.com/tech/stl/download.html" rel="nofollow">http://www.sgi.com/tech/stl/download.html</a> that map contains a using std::copy so I guess it collides with that.</p> <p>I cannot make any changes to the copy function, so is there a way I can use map in this header file ? (no other place). Is there a way so my copy functions don't collide ?</p> <p>I use Visual Studio 2008 on Windows 7.</p>
c++
[6]
3,461,066
3,461,067
How to error in manage
<p>i have designed web application in asp.net...i have publish a website.. i have create virtual directory and copy the publish file.... and browse the website...</p> <p>The error r occure</p> <blockquote> <p>Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p> <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</p> <p>Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</p> </blockquote> <p><img src="http://i.stack.imgur.com/bSy3g.png" alt="enter image description here"></p>
asp.net
[9]