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,845,261
4,845,262
Item wont add to list box
<p>Im converting this simple program from vb to c# it updates, displays, create and delete items from a little access database. Bellow is the PopulateListBox() function in VB it goes through every row in the data set and see if it is deleted, not deleted or has errors. I am getting 2 errors here both on the lines lstAlbums.Items.Add(item); and lstAlbums.Items.Add(delitem); now i realise that the strings are unassigned so i added string item = ""; string delitem = "";</p> <p>then when i start the program it fills every second item in th list box with a blank row.</p> <p>How do i overcome this situation? thank you in advance anyone how can help me. </p> <pre><code> private void PopulateListBox() { string item; string delitem; //clear the list box lstAlbums.Items.Clear(); //access each row in the data set table foreach (DataRow row in myDataSet.Tables["albums"].Rows) { //list the nondeleted rows if (!((row.RowState &amp; DataRowState.Deleted) == DataRowState.Deleted)) item = row["albumCode"] + ", " + row["AlbumTitle"] + ", " + row["ArtistCode"]; //list rows with update errors if (row.HasErrors) item = "(**" + row.RowError + "**)"; lstAlbums.Items.Add(item); //list deleted rows if ((row.RowState &amp; DataRowState.Deleted) == DataRowState.Deleted) delitem = row["albumCode", DataRowVersion.Original] + ", " + row["AlbumTitle", DataRowVersion.Original] + ", " + row["ArtistCode", DataRowVersion.Original] + "***DELETED***"; lstAlbums.Items.Add(delitem); } </code></pre>
c#
[0]
2,356,177
2,356,178
radio buttons and javascript
<p>i have a form with a radio button group(6 radio buttons),</p> <p>id's are r1,r2,r3,r4,r5,r6 </p> <p>and there are 6 hidden tables(display=none;) in this page, </p> <p>tables id's are t1,t2,t3,t4,t5,t6 .</p> <p>i want to change the table's dispaly property as inline if a radio button checked,</p> <p>if,</p> <p>r1 radio checked show table t1,(other tables should be hidden)</p> <p>r2 radio checked show table t2, (other tables should be hidden)</p> <p>r3 radio checked show table t3,(other tables should be hidden)..so on</p> <p>i tried to do this with document.getElementById ,but my code did not worked correctly since i am new to javascript. so how to do this?</p>
javascript
[3]
637,805
637,806
Is "localhost" a constant in Java?
<p>Is "localhost" a constant anywhere in Java SE 6? It's not terribly difficult to type out, but it might be nice to have a constant in many places rather than the String. Are there standard practices around this?</p> <p>Edit: I know how to create a constant. In the past, I've found constants such as org.apache.http.HttpHeaders cleaner than using my own, as they are less prone to typos or accidental edits.</p>
java
[1]
2,331,974
2,331,975
Why Does My Generic Method Require a Cast?
<p>I have a service layer method that I want to expose that should return an instance of an object that extends CMSContent (e.g. Delivery Time, Price). However, in method <strong>getCMSContent</strong>, the compiler is insisting that I do a cast to <strong>T</strong>. Is this cast below acceptable, or am I defeating the purpose of generics?</p> <p>I compile with "-Xlint:unchecked" and receive no warnings, and it functions as I expect.</p> <pre><code> public &lt;T extends CMSContent&gt; T getCMSContent(String cmsKey, Class&lt;T&gt; clazz) { T cmsInstance = (T) CMSObjectCache.getCachedCMSObject(cmsKey, clazz); return cmsInstance; } </code></pre> <p>This is the entire method of getCachedCMSObject</p> <pre><code>public static &lt;T&gt; T getCachedCMSObject(String objectKey, Class&lt;T&gt; cls) { init(); CMSObject cmsObject = cmsObjectCache.get(objectKey); if (cmsObject != null) { return cmsObject.getCMSObject(cls); } return null; } </code></pre>
java
[1]
4,314,009
4,314,010
Can't using append and appendChild in a jQuery?
<p>I have a sample code:</p> <pre><code>jQuery(document.body).append('&lt;div id="wrapper-1"&gt;&lt;/div&gt;').appendChild('&lt;div id="wrapper-2"&gt;&lt;/div&gt;'); </code></pre> <p>How to get this result, how to ideas?</p> <pre><code>&lt;div id="wrapper-1"&gt; &lt;div id="wrapper-2"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
3,414,613
3,414,614
How to close a external application with java
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/62418/knowing-which-java-exe-process-to-kill-on-a-windows-machine">Knowing which java.exe process to kill on a windows machine</a><br> <a href="http://stackoverflow.com/questions/4633678/how-to-kill-a-process-in-java-given-a-specific-pid">How to kill a process in Java, given a specific PID</a> </p> </blockquote> <p>I am trying to find out how to close a particular external exe namely cwserv5.exe. I have succeeded in starting a new external exe and closing it .But not an existing process. Can you help? Below is what I was tinkering with but really lost to be honest</p> <pre><code>package com.TestCase; import java.io.BufferedReader; import java.io.InputStreamReader; public class ReStartEXE { static Process pr; public static void open() { //ProcessBuilder try { Runtime rt = Runtime.getRuntime(); //Process pr = rt.exec("cmd /c dir"); pr = rt.exec("C:\\APPLEGREEN\\webserv\\cwserv5rost.exe"); Thread.sleep(10000); //pr.wait(10000); //pr.waitFor(); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); // String line=null; /*while((line=input.readLine()) != null) { System.out.println(line); }*/ //int exitVal = pr.waitFor(); //pr.destroy(); // Process.kill(pr); // Runtime.getRuntime().exec("taskkill /F /IM cwserv5rost.exe"); //System.out.println("Exited with error code "+exitVal); } catch(Exception e) { System.out.println(e.toString()); e.printStackTrace(); } } public static void Close() { pr.destroy(); } } </code></pre>
java
[1]
3,510,783
3,510,784
Exception not thrown in an async Task configuration
<p>I have the following method</p> <pre><code> public async Task&lt;bool&gt; Connect() { lock (_connectingLock) { if (_connecting) throw new IOException("Already connecting"); _connecting = true; } try { await tcpClient.ConnectAsync(...); } catch (SocketException e) { return false; } finally { lock (_connectingLock) { _connecting = false; } } } </code></pre> <p>Now, I would expect consecutive calls to <code>Connect()</code> to throw an IOException, but it doesn't happen!</p> <p>What could be the cause?</p>
c#
[0]
5,891,400
5,891,401
convert Graphics to Image in c#
<p>How to convert Graphics to Image?</p>
c#
[0]
3,458,229
3,458,230
How to define a class in Javascript
<p>I want to create a class in Javascript. This class should have </p> <ol> <li>private and public variables and functions.</li> <li>static and dynamic variables and functions.</li> </ol> <p>How this can be done ?</p>
javascript
[3]
2,215,759
2,215,760
How to assign very large numbers to variable in java?
<p>I'm getting "integer number too large: 1000000000001" for the following code line. How do I make it so that maxValue can hold 1 quadrillion or 1 trillion?</p> <pre><code>long maxValue = 1000000000001; //1,000,000,000,001 </code></pre>
java
[1]
4,476,474
4,476,475
$.ajax callback function is inside another function
<p>I am having one function which will be called when ever my custom controls get loaded. please refer below code.</p> <pre><code>function load() { getdata(); } function getdata() { $. ajax({ url://remote url, type:"get", success:function(data) { //going to set the data to my control } }); } </code></pre> <p>so success callback function takes some time to return the "data" (i.e fetch the data from remote URL) but load() client side method gets completed and do our control rendering. so i want load() method needs to wait until success function return the data from remote URL and then load() function get completed then i will render our control based on the data.</p> <p>how to do load() function need to wait the callback gets completed.</p> <p>Thanks,</p> <p>Siva</p>
jquery
[5]
317,351
317,352
how to direct output into a txt file in python in windows
<pre><code>import itertools variations = itertools.product('abc', repeat=3) for variations in variations: variation_string = "" for letter in variations: variation_string += letter print (variation_string) </code></pre> <p>How can I redirect output into a txt file (on windows platform)?</p>
python
[7]
1,880,655
1,880,656
how do i configure my android emulator to start running in intelij?
<p>I am getting this error whenever I try to run my emulator:</p> <blockquote> <p>Failed to start emulator: Cannot run program "/home/sypher/android-sdk-linux/tools/emulator": java.io.IOException: error=2, No such file or directory</p> </blockquote>
android
[4]
2,995,866
2,995,867
Resources$NotFoundException exception for drawable - but it does exist?
<p>I'm starting to see an odd set of stack traces from the marketplace crash reports interface. I'm being told a drawable resource does not exist. The xml in question:</p> <pre><code>&lt;ImageView android:layout_width="13dip" android:layout_height="12dip" android:src="@drawable/foo" /&gt; </code></pre> <p>causing:</p> <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.me.app/com.me.app.MyActivity}: android.view.InflateException: Binary XML file line #51: Error inflating class &lt;unknown&gt; ... Caused by: android.content.res.Resources$NotFoundException: File res/drawable-hdpi/foo.png from drawable resource ID #0x7f020166 at android.content.res.Resources.loadDrawable(Resources.java:1732) at android.content.res.TypedArray.getDrawable(TypedArray.java:601) at android.widget.ImageView.&lt;init&gt;(ImageView.java:118) at android.widget.ImageView.&lt;init&gt;(ImageView.java:108) Caused by: java.io.FileNotFoundException: res/drawable-hdpi/foo.png at android.content.res.AssetManager.openNonAssetNative(Native Method) at android.content.res.AssetManager.openNonAsset(AssetManager.java:417) at android.content.res.Resources.loadDrawable(Resources.java:1724) </code></pre> <p>Now "foo.png" exists in both my "drawable" and "drawable-hdpi" folders. I haven't touched either of these drawables in ages - not sure why this error started popping up? Happening on a range of devices, Droids, Nexus Ones, etc.</p> <p>Thanks</p>
android
[4]
5,260,738
5,260,739
Javascript position two elements on top of each other
<p>I have two divs one above the other. The second on is absolutely positioned below it (an absolute div inside a relative div).</p> <p>I want to move the second div on top of the other div, so it appears in the middle.</p> <p>The procedure for this is to set the style.top of DIV2 to be the same as DIV1, this should in theory position it on top of it. However so far attempts have failed.</p> <p>The absolute positioning is working correctly, because putting in values moves it correctly, but I think I am using the wrong way to get the height/top values of DIV1.</p> <p>Ideas?</p> <p>I tried this:</p> <p>divLoading.style.top = divContent.style.top;</p> <p>but it stays where it was.</p> <p>Edit: The problem isn't how absolute/relative works but which javascript values are the correct ones to use. Using DIV2.style.top = DIV2.style.top - DIV1.clientHeight moves it to the top... but clientHeight is not correct, because if DIV1 changes size, it moves DIV2 way too far upwards.</p> <p>Edit: offsetTop seems to be zero.</p>
javascript
[3]
3,652,570
3,652,571
Jquery .ui-widget :active { outline: none; } behaviour in firefox
<p>Hi in one of xhtml page containing select box having more that 10000 option list I am facing one issue select box opening at slow speed in firefox3.5 working fine in IE 7/8</p> <p>When I remove this class .ui-widget :active { outline: none; } from JQuery UI CSS </p> <p>its started to work fine in Firefox 3.5. Any idea for this behavior?</p> <p>Thanks, Amit </p>
jquery
[5]
3,589,527
3,589,528
how to turn a tuple to a string and back in python / how to edit an associative array on a web page
<p><strong>The problem I'm really trying to solve:</strong></p> <p>I have a square table of true/false values, with rows and columns labelled by strings.</p> <p>I want to display this as an html form with checkboxes, allow the user to tick and untick elements, then submit the form, and then I want to reconstruct the array from the form.</p> <p><strong>The subproblem I'm trying to solve at the minute:</strong></p> <p>I have a tuple of two strings, ("foo", "bar")</p> <p>I want to turn that into the name of a checkbox in a webpage</p> <p>And then when the form is submitted, turn that string back into the original tuple.</p> <p>At the moment I'm doing, ("%s$%s" % ("foo", "bar"))-> "foo$bar" and then string.split('$') to get the strings back, which works fine but it's hackish and will break if the strings ever have dollars in them.</p> <p>Obviously I can't just use repr and eval!</p> <p>Is there a sane, standard way to do this?</p>
python
[7]
3,094,817
3,094,818
Using a PropertyGrid to input method parameters
<p>I'd like to use a PropertyGrid to input method parameters.</p> <p>I have some application that will dynamically load user's DLLs and invoke methods with specific signature (a known return type).</p> <p>I'd like to present the user the option to input the arguments to the called method easily with a PropertyGrid control.</p> <p>Problem is -- PropertyGrid works on an Object, and not on a method.</p> <p>I'd like to somehow "transform" the method at runtime into an object with properties reflecting its arguments, passing the input values to the method when invoking it.</p> <p>Offcourse i'd like to have type validation, etc (if provided by the PropertyGrid, dont remember right now).</p> <p>Is there any easy solution for this?</p> <p>Thanks!</p>
c#
[0]
2,655,156
2,655,157
EditText problem
<p>I want to get a character of a string from a EditText and at the same time want to show the current location's latitude and longitude.</p> <p>here shown a part of the code</p> <pre><code>Button btn=(Button)findViewById(R.id.format); btn.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { showCurrentLocation(); } }); protected void showCurrentLocation() { text=name.getText().toString(); String finalText = ""; finalText = Character.toString(text.charAt(3)); Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (location != null) { String message = String.format( "Current Location \n Longitude: %1$s \n Latitude: %2$s", location.getLongitude(), location.getLatitude() ); Toast.makeText(GPSLocator.this, message, Toast.LENGTH_LONG).show(); } } </code></pre> <p>After compiling the code when i give any character and click on the sent button then a message is displayed on the screen like "The application GPSLocator(process com.vetexVervelnc GPSLocator) has stopped unexpectedly. Please try again Forse close " </p>
android
[4]
2,911,776
2,911,777
SEL as a instance property or as static variable
<p>I want to keep track of a callback method in one of my class instance... so that i can call this method later on. How can i do this ..? i thought of storing the reference of call back method in one of the instance variable(SEL datatype). if i am using SEL as the datatype what attributes should i give for the @property...or can i declare this as a static variable... How can i do this.. I am new to iphone .. Pls anybody help me..</p>
iphone
[8]
3,224,256
3,224,257
How to Create an XML Serializer for More than One Type?
<p>I am using the XmlSerializer like this,</p> <pre><code>XmlSerializer xs = new XmlSerializer(typeof(myType)); </code></pre> <p>Now I have 5 different "myType". How do I pass the specific type dynamically so I don't have to repeat the same code 5 times?</p>
c#
[0]
5,206,136
5,206,137
Building C# console project without Visual Studio
<p>I need to create a script that produces an executable from a C# console project. The client system where the script will be run doesn't have Visual Studio, but has the .NET framework installed. How can it be done using minimum/no software installation at the client place.</p> <p>EDIT: Does C# compiler (csc.exe) come with .NET framework. If so, is there any environment variable for the location?</p>
c#
[0]
3,102,393
3,102,394
BraodcastReceiver gets called whenever app loses focus. Any way to suppress this?
<p>I have an app that downloads info from a particular website, currently set to do this once a day. The problem I have is that if I have the app open and I receive a text message, as soon as the pop up appears the download kicks in on my app. I have no idea of where to start trying to solve this. Any ideas?</p> <p>Current workflow: MainActivity -> Start BroadcastReceiver, which sets alarmManager to kick off download at specified time -> another BroadcastReceiver starts an IntentService which handles the list downloading. Pretty much it.</p> <p>Hopefully I've done a decent job of explaining.</p>
android
[4]
2,786,724
2,786,725
A clean installation of Android and its related components
<p>I have Windows 7 64-bit. What versions of Java, eclipse, Adroid SDK, etc I need to install. Also I would like to buy a cheap android device to test my applications instead of virtual one, do you know of any one that is good and easy for testing. Any point/guide to a clean installation and settings would be also helpful. I have tried to install the above technologies but it failed because perhaps incompatible versions. I would like a clean installation to reduce these settings issues.</p> <p>Thanks in advance</p>
android
[4]
2,863,883
2,863,884
On InMobi Addtracker My application is not getting reported
<p>I am using inmobi in my android application. For that i am using InMobiAdTrackerAndroid.jar with this jar i am following documentation.</p> <p>1: We are using following codes inmy application Launcher class IMAdTrackerUtil.setLogLevel(LOG_LEVEL.VERBOSE); IMAdTrackerAnalytics.getInstance().startSession(getApplicationContext(),Constants.INMOBI_APP_ID);</p> <p>2: We are using this constants in place of above bold text public static final String INMOBI_APP_ID = "5cd90875-04c7-476d-aa6e-ee7cf0ac70f6";</p> <p>3: In AndroidManifest.xml class we add following code </p> <pre><code> &lt;receiver android:name="com.inmobi.adtracker.androidsdk.IMAdTrackerInstallRefererReciever" android:enabled="true" android:exported="true" &gt; &lt;intent-filter&gt; &lt;action android:name="com.android.vending.INSTALL_REFERRER" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; </code></pre> <p>4: InMobiAdTrackerAndroid.jar is the library which we are using for inmobi and this library is added in build path.</p> <p>On InMobi site in Reporting i am not getting an Application's name.(Application is present in DashBoard not present in Reporting) I tested application using qrcode of my application and it forwarded me to google play where my application is present. So what is the reason my application is not showing on Reportings. here i a using samsung Tablet with sdk version 11.</p>
android
[4]
4,199,116
4,199,117
Best Practice to return responses from service
<p>I am writing a SOAP based ASP.NET Web Service having a number of methods to deal with Client objects. e.g:</p> <ul> <li>int AddClient(Client c) => returns Client ID when successful</li> <li>List GetClients()</li> <li>Client GetClientInfo(int clientId) In the above methods, the return value/object for each method corresponds to the "all good" scenario i.e. A client Id will be returned if AddClient was successful or a List&lt;> of Client objects will be returned by GetClients. But what if an error occurs, how do I convey the error message to the caller?</li> </ul> <p>I was thinking of having a Response class: Response { StatusCode, StatusMessage, Details } where Details will hold the actual response but in that case the caller will have to cast the response every time. What are your views on the above? Is there a better solution?</p> <p>---------- UPDATED -----------<br> Is there something new in WCF for the above? What difference will it make If I change the ASP.NET Web Service to a WCF Service?</p>
c#
[0]
3,560,589
3,560,590
Handling onActivityResult in Android app having more than one activity
<p>In my android app, I have a main activity which creates two other sub activites through intent. Now, both the sub activity return result to the main activity. In my main activity, how do I handle two "onActivityResult(int requestCode, int resultCode, Intent data)" since it cant have two methods with same name in a given class. Hope my question is clear..</p> <p>Thanks</p>
android
[4]
3,163,256
3,163,257
Why misspelled android:name do not have a warning or error?
<p>I hava a receiver</p> <pre><code> &lt;receiver android:name=".AlarmReceiver" /&gt; </code></pre> <p>But the receiver's class name is AlarmReciver (misspelled)</p> <p>why android-sdk show this mistake or show this when running?</p>
android
[4]
5,794,302
5,794,303
query execution error check
<p>hello please help me out regarding this function </p> <pre><code> function delete($serviceid) { $result = $this-&gt;query=("delete from service where service_id='$serviceid'"); $exe=$this-&gt;executeNonQuery(); if ($exe){ return $success = "Record deleted successfully."; } else { return $error = "Unable to process at this time."; } } </code></pre> <p>$exe is always 1 even if the record is not deleted as may b its because of , it only check that query is executed or not , how can i check if the record is deleted then show success message</p>
php
[2]
3,238,689
3,238,690
Abstract class and operator!= in c++
<p>I have problem implementing the operator!= in a set class deriving from an abstact one. The code looks like this:</p> <pre><code>class Abstract { public: //to make the syntax easier let's use a raw pointer virtual bool operator!=(const Abstract* other) = 0; }; class Implementation { SomeObject impl_; //that already implement the operator!= public: bool operator!=(const Abstract* other) { return dynamic_cast&lt;Implementation*&gt;(other)-&gt;impl_ != this-&gt;impl_; } }; </code></pre> <p>This code works but it has the drawback to use dynamic_cast and I need to handle error in casting operation.</p> <p>This is a generic problem that occur when a function of a concrete class it is trying to using some internal information (not available at the abstract class level) to perform a task.</p> <p>Is there any better way to solve this kind of problem?</p> <p>Cheers</p>
c++
[6]
3,478,825
3,478,826
Java - Convert Unix epoch time to date
<p>I need to convert some epoch time stamps to the real date and have used some of the methods I found on stack overflow, but they give the wrong answer.</p> <p>As an example, one date is "129732384262470907" in epoch time, which is "Mon, 20 Jan 6081 05:24:22 GMT" using <a href="http://www.epochconverter.com/" rel="nofollow">http://www.epochconverter.com/</a></p> <p>However, my code generates: "Wed Dec 24 14:54:05 CST 19179225"</p> <pre><code> String epochString = token.substring(0, comma); long epoch = Long.parseLong(epochString); Date logdate = new Date(epoch * 1000); BufferedWriter timewrite = new BufferedWriter(new FileWriter(tempfile, true)); timewrite.write(logdate); timewrite.flush(); timewrite.close(); </code></pre> <p>The initial timestamp is in miliseconds, which in the examples I saw here I am supposed to multiply by 1000.</p> <p>If I don't multiply by 1000, I get: "Mon Aug 08 01:14:30 CDT 4113025"</p> <p>Both of which are wrong.</p> <p>So where have I made my error?</p>
java
[1]
1,394,012
1,394,013
Why does this rock-paper-scissors almost always returns "tie(draw)"?
<p>This program almost always returns "It's a draw(or tie)". Is it just me or is something wrong? It is a Rock Paper Scissors program that does 10 rounds and shows the results in the end.</p> <pre><code>#!/usr/bin/python # RockPaperScissors from Python import random; i = 1; c = 0; u = 0; d = 0; while i &lt;= 10: userAnswer = input("Do you choose rock, paper, or scissors?"); computerAnswer = random.randint(1, 3); if (computerAnswer == 1): computerAnswer = "rock"; elif (computerAnswer == 2): computerAnswer = "paper"; else: computerAnswer = "scissors"; if (computerAnswer == "rock" and userAnswer == "paper"): print("You won(paper beats rock)"); u = u + 1; elif (computerAnswer == "" and userAnswer == "paper"): print("You lost(rock beats scissors)"); c = c + 1; elif (computerAnswer == "paper" and userAnswer == "rock"): print("You lost(paper beats rock)"); c = c + 1; elif (computerAnswer == "paper" and userAnswer == "scissors"): print ("You won(scissors beat paper)"); u = u + 1; elif (computerAnswer == "scissors" and userAnswer == "paper"): print("You lost(scissors beats paper)"); c = c + 1; elif (computerAnswer == "scissors" and userAnswer == "rock"): print("You won(rock beats scissors)"); u = u + 1; else: print("It's a draw!"); d = d + 1; if (i == 10): print("You won " + str(u) + " times."); print("You lost " + str(c) + " times.") print("It was a draw " + str(d) + " times."); i += 1; </code></pre> <p>The version of Python is 3.2(Python 3.2)</p>
python
[7]
4,885,309
4,885,310
How to add own OMX_decoder in Android?
<p>I want to add my own <code>OMX_Decoder</code> to <code>android</code>, I want to understand that, how much important it is to understand Opencore and Stagefright for same. </p> <p>Say, I go ahead with Android 2.1 which has opencore,what will be the rework I need to do for <strong>Android 2.3</strong> or further android versions. </p> <p>Please help me, how to move ahead what will be the best choice, what will be the steps to add OMX_Decoder in both cases?</p> <p>Please do the needful. </p> <p>Thank You!</p> <p>Deepak C.</p>
android
[4]
5,021,598
5,021,599
Android 2.1: How do I bring the soft keyboard manually?
<p>I've a form that occupies upper half of the screen and I want to show the keyboard at the bottom half all the time. How do I do that?</p> <p>(Android 2.1, NexusOne)</p>
android
[4]
4,614,739
4,614,740
How can I find the element that caused another element to fire the focusout event?
<p>i bind an eventhandler to the focusout-event of my text-inputfield. this handler hides a div with some searchresults as soon as the inputfield losts its focus. </p> <p>following my markup and a screenshot of the situation:</p> <pre><code>&lt;li class="search"&gt; &lt;input type="text" id="searchbox" /&gt; &lt;div id="results"&gt; &lt;ol&gt; &lt;li&gt;...&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/li&gt; </code></pre> <p><img src="http://i.stack.imgur.com/51b5s.png" alt="enter image description here"></p> <p>when the user clicks on a item in the searchresults now, the inputfield fires the focusout event as desired. i expected to be able extracting the element which gets the focus as next out of the eventobject. unfortunatly this seems not to be possible since only (some) mouse-events fill in the relatedTarget-property of the event.</p> <p>is there any easy way to get the element which gains focus next?</p>
javascript
[3]
2,178,292
2,178,293
a question about eval in javascript
<p>thank you. here is the correct question:</p> <pre><code>{ "VID":"60", "name":"\u4f1a\u9634", "requireLevel":"20", "levelMax":"5", "venationRequirement":"0", "description":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8[Affect1]\u70b9", "cost":{"1":"240","2":"360","3":"400","4":"600","5":"720"}, "difficult":{"1":"1024","2":"973","3":"921","4":"870","5":"819"}, "affect":{"1":"200","2":"500","3":"900","4":"1400","5":"2000"}, "descriptions":{ "1":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8200\u70b9", "2":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8500\u70b9", "3":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad8900\u70b9", "4":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad81400\u70b9", "5":"\u6c14\u6d77\u4e0a\u9650\u63d0\u9ad82000\u70b9" } } </code></pre> <p>i used json_encode() in php ,and ajax request to get the response text.</p> <h2>but when i use eval() to parse the response text. it's wrong.</h2> <p>moonshadow and james gregory has answered this question at the comments below.thank you again.</p>
javascript
[3]
4,450,580
4,450,581
variable scoping in javascript
<p>My code is as follows:</p> <pre><code>jQuery(document).ready(function() { var pic = 0; FB.init({appId: '1355701231239404', status: true, cookie: true, xfbml: true}); FB.getLoginStatus(function(response) { if (response.session) { pic = "http://graph.facebook.com/" + response.session.uid + "/picture"; alert(pic); } else { window.location = "index.php" } }); }); &lt;/script&gt; </code></pre> <p>The issue is that the pic inside my if statement has a different scope with the one I declared above? Why and how do I make them the same?</p> <p>What I want is to use this var pic (the one that has been assigned by the if statement) inside the body of my html. I will have another script inside the body, a document.write that uses this pic variable.. as of now when I do a document.write it always gives me 0, as if it's not assigned inside the if statement</p>
javascript
[3]
3,763,857
3,763,858
creating virtual hard Drive
<p>how can I create Virtual Hard Drive (like Z:) that store it's files on physical hard drive (Like C:\Files).</p>
c#
[0]
1,963,701
1,963,702
Returning random numbers in Python using random.py
<p>Basically I need to write a function that returns a list of x random numbers between 0 and y. I need to use the random.py module in Python.</p>
python
[7]
3,982,604
3,982,605
Attaching the source of an external jar file
<p>I want to attach the source code to an external <code>jar</code> file that I have. Normally I would just got to <code>configure build path</code>, expand the jar file and edit the source attachment. But since the jar file is an <code>Android Dependency</code> it does not give me that option.</p> <p>so I have 2 questions then, How can I attach the source to an android dependency or how can I make the jar file not an android dependency so I can attach it like i normally would?</p>
android
[4]
1,898,358
1,898,359
passing float variable as parameter
<p>I am trying to write a method with float parameter and call it using performselector but i am getting error in doing this. Following is my code:</p> <p>[sender performSelector:selector withObject:progress/total];</p> <p>here progress and total both are float variabal.</p> <p>I am trying to call following method in different class</p> <pre><code>-(void) updateProgress:(float)fl { </code></pre> <p>}</p>
iphone
[8]
306,397
306,398
How do I access the value of this JavaScript object?
<p>What type of object is <code>container</code>?</p> <pre><code>var pname = "apples"; var extVal = "oranges"; var container = {}; container = { presName: pname, presVal: pname }; </code></pre> <p>I want to compare the value of <code>presVal</code> (from inside <code>container</code>) to the value of <code>extVal</code>.</p> <p>But I'm not sure how to access <code>presVal</code> to make this comparison.</p>
javascript
[3]
2,499,406
2,499,407
How can i loop thorugth a HashTable keys in android?
<p>I have a hashtable filled with data, but I don't know the keys How can I loop througth a HashTable keys in android? I'm trying this, but it doesnt work:</p> <pre><code>Hashtable output=new Hashtable(); output.put("pos1","1"); output.put("pos2","2"); output.put("pos3","3"); ArrayList&lt;String&gt; mykeys=(ArrayList&lt;String&gt;)output.keys(); for (int i=0;i&lt; mykeys.size();i++){ txt.append("\n"+mykeys.get(i)); } </code></pre>
android
[4]
4,702,611
4,702,612
Why can't one object's property value be used as a property name in another object?
<p>The following gives me an error in my JS console (firebug):</p> <pre><code>var obj1 = {name:'king', val:20}, obj2, objName = obj1.name; obj2 = {obj1.name:obj1.val}; </code></pre> <p>But the following works just fine:</p> <pre><code>var obj1 = {name:'king', val:20}, obj2, objName = obj1.name; obj2 = {objName:obj1.val}; </code></pre> <p>The exact error is: "missing : after property id". I don't need a work-around, I'm curious to know what the problem is here.</p>
javascript
[3]
3,090,058
3,090,059
Why won't this super simple jQuery work?
<pre><code>&lt;style type="text/css"&gt; #box { background: red; width: 100px; height: 100px; color: #fff; line-height: 100px; } &lt;/style&gt; &lt;script type="text/javascript" src="jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function() { $('a#clickMe').click(function(e) { e.preventDefault(); $('#box').css('position', 'absolute').animate({ 'left' : '+=100px' }, function() { if ($('#box').offset().left &gt; $(document).width()) { alert('that is far enough') } }); }); }); &lt;/script&gt; &lt;a href="" id="clickMe"&gt;Click Me&lt;/a&gt; &lt;div id="box"&gt;I Move!&lt;/div&gt; </code></pre> <p>I'm trying to alert "that is far enough" when the box reaches the end of the page. But the alert never shows.</p> <h2>EDIT</h2> <p>Never mind, figured it out. I had to use $(window).width() instead of $(document).width();</p>
jquery
[5]
3,698,602
3,698,603
Point3D and NumberFormatInfo
<p>I am trying to print a list of Point3D. However I don't want them to be printed with the maximal number of decimal digits. I want to be able to control this.</p> <p>So I tried</p> <pre><code>Point3D loc = new Point3D(x,y,z); var formatter = new NumberFormatInfo(); formatter.NumberDecimalDigits = 2; return loc.ToString(formatter); </code></pre> <p>But this didn't work and the point was still printed with too many decimal digits.</p> <p>I would also like to do the same for other data structures that contain double members. I guess that the solution will be the same.</p>
c#
[0]
114,175
114,176
How to Log into file in resource folder?
<pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *logPath = [documentsDirectory stringByAppendingPathComponent:@"console2.log"]; freopen([logPath cStringUsingEncoding:NSASCIIStringEncoding],"a+",stderr); </code></pre> <p>'By this code i get logs in a log file present in Application Path (Application Support--</p> <blockquote> <p>iPhone Simulator--> ...), but i wanted the logs in a log file present in a resource folder. How do i do that ?'</p> </blockquote>
iphone
[8]
4,050,370
4,050,371
PHP - memory limit
<pre><code>max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data ;max_input_nesting_level = 64 ; Maximum input variable nesting level memory_limit = 128M ; Maximum amount of memory a script may consume (128MB) </code></pre> <p>With default 128MB, everything is ok</p> <p>But when i edit php.ini like this</p> <pre><code> memory_limit = 128000000 ; Maximum amount of memory a script may consume (128MB) </code></pre> <p>I got i notice :</p> <p>Fatal error: Allowed memory size of 262144</p> <p>128000000 @ 128MB or apache don't know 128000000 </p>
php
[2]
3,616,717
3,616,718
jquery get generated id with the same class
<p>Here is my code.</p> <pre> //generate a id $(".slide_img_a").each(function(){ $(this).attr("id","img"+(Math.round(Math.random()*100))) }); // get id var img_id = $(".slide_img_a").attr("id"); // alert the id $(".slide_img_a img").hover(function(){ alert(img_id); }); </pre> <p>The problem of this is I have a 5 images with the same class and random id. When I hover the image, the result is he can only alert the id of first image. I wanted to do is when I hover them they will alert thier own id's </p>
jquery
[5]
4,280,959
4,280,960
How to become a good Python coder?
<p>EDITED ALL GREAT COMMENTS - THANK YOU</p> <p>I started with c++ but as we all know, c++ is a monster. I still have to take it and I do like C++ (it takes programming a step further) </p> <p>However, currently I have been working with python for a while. I see how you guys can turn some long algorithm into simple one.</p> <p>I know programming is a progress, and can take up to years of experience. I also know myself - I am not a natural programmer, and software engineering is not my first choice anyway. However, I would like to do heavy programming on my own, and create projects.</p> <p>How can I become a better python programmer?</p> <p>Thank you. </p>
python
[7]
5,581,180
5,581,181
get column name of an excel sheet into a combo box
<p>Im using c# .net windows form application. I have an excell workbook that has three sheets.Sheet1 has data which has 4 columnsand many rows . i haved named them. Now when i click on a button, i should populate the combobox with the column names that i have assigned.</p>
c#
[0]
3,886,856
3,886,857
Object Oriented Design for iPhone
<p>So I've run into this a few times, and am new to OOD so not sure if there is a good way to do this or not. </p> <p>But basically, I have a MainViewController, and then I push a new DetailViewController. In my MainViewController, I have a Reset method that basically resets everything to their default values. </p> <p>If I want to put the button to call Reset in the DetailViewController though, how do I call the method since it's in the MainViewController class? </p> <p>What I've done before is have a reference to the ParentController (in this case, MainViewController), and then call it that way from the DetailViewController. I don't know if this is a good practice though and if there are better ways to do something like this. </p> <p>Thanks.</p>
iphone
[8]
2,019,832
2,019,833
Show a hidden div relative to the hovered element on click with jQuery
<p>I'm trying to get a hidden div to display relative position (directly to the right of the hovered div.)</p> <p>On the fiddle, when the cursor hovers over the div it enlarges and repositions. What I want to achieve but can't figure out... is how to display the div details for 'this' element only, relative to the hovered div.</p> <p>The problems I'm having are:</p> <ol> <li>Getting the child div (.details) to be the only one to display not all of the .details elements. a. Getting it to display relative to the hovered element, not in an absolute position.</li> <li>Cancelling the hover function on click, so that the div details can be navigated to without it disappearing.</li> </ol> <p>Fiddle: <a href="http://jsfiddle.net/pssuT/1" rel="nofollow">http://jsfiddle.net/pssuT/1</a></p>
jquery
[5]
3,522,488
3,522,489
Listbox1 to Listbox2 with button click
<p>I have some information stored in a listbox (listBox1) and want to do something like this:</p> <ul> <li>Click on an item in listBox1</li> <li>Click a button</li> <li>All information is transferred in listBox1 to transferred to listbox2</li> </ul> <p>BUT, I also want to have something else added at the end of the transferred information: numbers in the format of hh:mm:ss.</p> <p>Any help would be very much appreciated! </p>
c#
[0]
4,877,014
4,877,015
Iphone simulator 4.0 Could not find my current location
<p>I installed sdk version 4.0 in mac my friend also installed version 4.0 in his mac.In my iphone simulator 4.0 ,it could find current location.But my friend machine iphone simulator 4.0 had find the current location.</p> <p>What is the problem ? we both connected with wifi network.Both mac machine having ability to find current location.But there is difference in iphone simulator 4.0.</p> <p>Plz help me ? I really need this.</p> <p>Thanks in advance...</p>
iphone
[8]
5,899,733
5,899,734
how can i add a regular item to spinner adapter?
<p>i have a spinner like this:</p> <pre><code>spinner = (Spinner) findViewById(R.id.spin); _spinDb = new SpinAdapter(this); Cursor names = _spinDb.open().getAllSpin(); _adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, names, new String[] {SpinAdapter.COLUMN_NAME}, new int[] {android.R.id.text1}); _adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(_adapter); </code></pre> <p>now, i want to add a "regular" item with the text: "choose item". how can i do it? thanks.</p>
android
[4]
5,205,112
5,205,113
function to return a variable of type of another class
<p>I need a function to take a name and return the details of the record associated with that name.How do i do this? I have all the info. in my result set, but i need a way to pass it to one variable and return the value in java. I am using eclipse-juno under CentOS</p>
java
[1]
4,857,230
4,857,231
Verify that a column exists in the DataRow before reading its value
<p>How do I write code that reads a DataRow but, if filed in DataRow isn't there, it just skips it and moves on, like this for example:</p> <pre><code>string BarcodeIssueUnit; if (dr_art_line["BarcodeIssueUnit"].ToString().Length &lt;= 0) { BarcodeIssueUnit = ""; } else { BarcodeIssueUnit = dr_art_line["BarcodeIssueUnit"].ToString(); } </code></pre> <p>Now, the Column <code>BarcodeIssueUnit</code> can belong to the table but, in some cases, that column does not exist in the table. If it's not there and I read it, I get this error: </p> <pre><code>System.ArgumentException: Column `BarcodeIssueUnit` does not belong to table Line. </code></pre> <p>I just want to run a check if the column is there ok, let see the values, if it's not, just skip that part and go on.</p>
c#
[0]
3,121,499
3,121,500
Which is the better place to declare variables, inside Try block or outside.?
<p>Which is the better place to declare variables, inside the try block or outside?</p> <pre><code>string myString = string.Empty; try { myString = "mytext"; } </code></pre>
c#
[0]
5,912,132
5,912,133
Background service not running when screen is off
<p>I am using WakeLock but it consues a lot of battery. Is there any alternate solution??</p>
android
[4]
1,146,392
1,146,393
Is there a way to make a user-defined Python function act like a built-in statement?
<p>Is it possible to make a user-defined Python function act like a statement? In other words, I'd like to be able to say:</p> <pre><code>myfunc </code></pre> <p>rather than:</p> <pre><code>myfunc() </code></pre> <p>and have it get called anyway -- the way that, say, <code>print</code> would.</p> <p>I can already hear you all composing responses about how this is a horrible thing to do and I'm stupid for asking it and why do I want to do this and I really should do something else instead, but please take my word that it's something I need to do to debug a problem I'm having and it's not going to be checked in or used for, like, an air traffic control system.</p>
python
[7]
2,002,757
2,002,758
error: /SourceCache/GoogleMobileMaps_Sim/GoogleMobileMaps-263.5/googlenav/mac/Loader.mm:231 server returned error: 403
<p>I'm working as iphone developer. i've a problem that in my mapview when ever I want to show location in google map it show me error: /SourceCache/GoogleMobileMaps_Sim/GoogleMobileMaps-263.5/googlenav/mac/Loader.mm:231 server returned error: 403 with square box screen. I got this question in stack overflow but that answer is not working for me. please some one help me.</p>
iphone
[8]
3,863,493
3,863,494
Swapping <div> in a continous JQuery loop
<p>I am working on having a single div animate right to left through the header. Once the div goes off screen and finishes animation I would like to loop the animation but swap the div for another containing a new image. The code is below but not functioning properly. Any help would be greatly appreciated.</p> <pre><code> $(document).ready(function() { var clouds = $('#bg_header .cloud'); var lng = clouds.length; $('.cloud').eq(0).animate({ right: '+=1400' }, 50000, 'linear', anim(1)); function anim(i) { if (i &gt;= lng) { i = 0; } $('.cloud').eq(i).animate({ right: '+=1400' }, 50000, 'linear', anim(i+1)); } }); </code></pre> <p>HTML</p> <pre><code>&lt;div id="bg_header"&gt; &lt;div id="clouds" class="cloud" style="right:-400px;"&gt;&lt;img border="0" alt="animated clouds" src="/images/clouds.png" /&gt;&lt;/div&gt; &lt;div id="clouds2" class="cloud" style="right:-400px;"&gt;&lt;img border="0" alt="animated clouds" src="/images/clouds2.png" /&gt;&lt;/div&gt; </code></pre> <p>CSS</p> <pre><code>#bg_header{ min-width:990px; padding-left:105px; padding-right:105px; right:0; left:0; height:330px; position:fixed; background:url("/images/bg_header.png") repeat-x top center; z-index:1000; clear:both; margin-left:auto; margin-right:auto; } #clouds{ position:absolute; z-index:500; right:0px; top:10px; } #clouds2{ position:absolute; z-index:500; right:0px; top:10px; } </code></pre>
jquery
[5]
3,058,706
3,058,707
make array index 1 instead of index 0 based
<p>How can I make an array start at subscript 1 instead of subscript 0 in python?</p> <p>Basically to solve this <a href="http://www.mathworks.com/support/solutions/en/data/1-8G5UD6/index.html?product=EL&amp;solution=1-8G5UD6" rel="nofollow">problem</a> in python.</p>
python
[7]
3,418,969
3,418,970
How to user Ajax UpdateProgress with Iframe in ASP.NET
<p>I ame trying to show a UpdateProgress image with iframe. But it is not working. I am using this iframe to display several pages. My code is as following..</p> <hr> <p> </p> <pre><code> &lt;iframe runat="server" id="Iframe2" height="565" width="100%" scrolling="no" style="overflow-x:hidden;" frameborder="0" marginheight="0" marginwidth="0" vspace="0" hspace="0"&gt; &lt;/iframe&gt; &lt;asp:HiddenField ID="hdfIndex" runat="server" /&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID="ibtnPrevious" EventName="Click" /&gt; &lt;asp:AsyncPostBackTrigger ControlID="ibtnNext" EventName="Click" /&gt; &lt;asp:AsyncPostBackTrigger ControlID="ibtnPage1" EventName="Click" /&gt; &lt;asp:AsyncPostBackTrigger ControlID="ibtnPage2" EventName="Click" /&gt; &lt;asp:AsyncPostBackTrigger ControlID="ibtnPage3" EventName="Click" /&gt; &lt;asp:AsyncPostBackTrigger ControlID="ibtnPage4" EventName="Click" /&gt; &lt;asp:AsyncPostBackTrigger ControlID="ibtnPage5" EventName="Click" /&gt; &lt;/Triggers&gt; </code></pre> <p></p> <hr> <p>But when I use it without iframe then it works nicely.</p>
asp.net
[9]
1,539,140
1,539,141
Jquery function onclick add class and remove class
<p>I am doing jquery function to enable and disable input type text</p> <p>the first function is working fine and change the class of the a href but the secound function that related to the new class is not working</p> <p>here is the full code</p> <p><a href="http://jsfiddle.net/RcLgz/1/" rel="nofollow">http://jsfiddle.net/RcLgz/1/</a></p>
jquery
[5]
33,255
33,256
Unable to start service after setting alarm
<p>Can you please help me out in resolving this issue...</p> <pre><code> Calendar schedCalendar = Calendar.getInstance(); schedCalendar.clear(); schedCalendar.set(nYear, nMonth, nDay, nHour,nMinute,0); Intent myIntent = new Intent(this,SMSService.class); PendingIntent pendingIntent = PendingIntent.getService(this,0,myIntent,PendingIntent.FLAG_ONE_SHOT); long interval = (schedCalendar.getTimeInMillis()-Calendar.getInstance().getTimeInMillis()); alarmManager.set(AlarmManager.RTC_WAKEUP,(Calendar.getInstance().getTimeInMillis()+interval),pendingIntent); </code></pre> <p>Once i set the alarm.... registered service is not getting started.</p>
android
[4]
2,658,799
2,658,800
How to convert MVS C++ code into executable application?
<p>So I've made a small program in Microsoft Visual Studio C++ (2008 edition) and I want to convert it to .exe format.</p> <p>I know that I can find the .exe in my project directory, however it only runs fine on my own PC. When I send it over to someone else (who doesn't have Visual Studio installed or anything), it doesn't run.</p> <p>I've read a little about this and it seems to be about "linking". Now I don't know anything about linking and I'm not eager to learn in depth about it right now...</p> <p>I just want to make my incredibly simple program (which edits and creates text files) to run in .exe program on any computer. Is this possible, and if so - how?</p> <p>Could you please guide me through the steps? I'm quite new to programming so I really need help on this one.</p> <p>Thank you in advance...</p>
c++
[6]
2,936,142
2,936,143
Why is my key not getting pushed inside the array
<pre><code>var arr = [{ key: "key1", value: "z" }, { key: "key2", value: "u" }, { ... }]; var sorted = arr.sort(function (a, b) { return a.key === b.key ? 0 : a.key &lt; b.key ? -1 : 1; }); sorted.unshift({key:"Unknown", value:"0"}); var StateArr = []; for(i=0;i&lt;sorted.length;i++){ StateArr.push(sorted[i].key); } alert("ARR" +StateArr); </code></pre> <p>Now when i alert my sorted, i don't get any response. Why is my key not getting pushed inside the array. </p>
javascript
[3]
1,788,554
1,788,555
Inserting a valid html link into a string for an email
<p>I'm building a string that will be sent over email. In the string I'd like to include a link, like so:</p> <pre><code>String mailstring = "Blah blah blah blah. Click here for more information." </code></pre> <p>and I'd like the "here" to be a link in the email, such as putting it <a href="http://madeuplink.com" rel="nofollow">http://madeuplink.com</a>. I know I can put the address instead of the 'here' but I'd like to have the link be the word.</p>
c#
[0]
5,512,402
5,512,403
URL rewriting when site is migrated to .net to PHP
<p>The present site is on .net and the new site is on PHP. Google has everything as.net pages. what are the options for URL redirecting/rewriting.</p>
php
[2]
1,009,425
1,009,426
Does python have a shorthand for this simple task?
<p>I've just started to learn the long-heard python language. I've been working with C before. And I find python, as a modern script language is much concise on various tasks.</p> <p>So I was wondering, if I have a list <code>foo = [1, 2, 3, 4, 5]</code>, and I want to pick all the odd numbers out of it into <code>bar</code>. In C, I might use a loop and check each number in <code>foo</code> and copy the elements needed into <code>bar</code>. What do you guys do this "python-style"?</p>
python
[7]
143,377
143,378
JavaScript support for OO Polymorphism?
<p>I would like to understand if JavaScript really support Polymorphism ? With function arguments function overloading appears ok but function overriding in classical OO using inheritance ? Is it also supported by JavaScript Any input pointers would be helpful.</p>
javascript
[3]
4,974,156
4,974,157
convert string to preexisting variable names
<p>How do i convert a string to the variable name in python?</p> <p>e.g. </p> <p>if the program contains a object named, self.post,that contains a variable named, i want to do something like,</p> <pre><code>somefunction("self.post.id") = |Value of self.post.id| </code></pre>
python
[7]
1,840,301
1,840,302
Question related to APNS
<p>Whenever I get a pop-up through the iPhone OS for <a href="http://en.wikipedia.org/wiki/Apple_Push_Notification_Service" rel="nofollow">APNS</a> testing there are 2 conditions:</p> <ol> <li>application is running</li> <li>application is not running</li> </ol> <p>If I click on the view button of the popup through the iPhone OS then which method is called if application is running?</p> <p>If application is not running?</p>
iphone
[8]
4,856,919
4,856,920
Converting keystrokes gathered by onkeydown into characters in JavaScript
<p>I try to convert keystrokes into chracters. In other question someone recommand to use the onkeydown function because onkeypress gets handeled differently by different characters.</p> <p>I don't know how to handle special chracters like ´ ` ' ( ) that might be different in different keyboards around the world.</p>
javascript
[3]
4,411,495
4,411,496
Delete a view and recreate it
<p>Is there a way to remove a view that was set with</p> <pre><code>setContentView(R.layout.set_map_center); mapView = (MapView) findViewById(R.id.mapview); </code></pre> <p>If I call this view again then I get an error saying:</p> <blockquote> <p>java.lang.IllegalStateException: You are only allowed to have a single MapView in a MapActivity</p> </blockquote>
android
[4]
1,913,984
1,913,985
deleting the appended data - jquery
<pre><code>select: function (event, ui) { var staffItem = new Object(); staffItem.StaffId = ui.item.id; staffItem.Name = ui.item.name; staffItem.Photo = ui.item.image; staffItem.Email=ui.item.email; staffItem.Mobile=ui.item.mobile; var data = "&lt;div&gt;&lt;table width='100%'&gt;&lt;tr&gt;&lt;td align='right' &gt;&lt;div class='close16'/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div&gt;&lt;table&gt;&lt;tr&gt;&lt;td rowspan='4' width='50px;'&gt;&lt;img src='" + staffItem.Photo + "' Width='48' Height='48' /&gt;&lt;/td&gt;&lt;td&gt;" + staffItem.Name + " ( " + staffItem.StaffId + " )&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;table cellpadding='0' cellspacing='0'&gt;&lt;tr&gt;&lt;td&gt;" + staffItem.Email + "&lt;/td&gt;&lt;td&gt;&amp;nbsp;|&amp;nbsp;&lt;/td&gt;&lt;td&gt;" + staffItem.Mobile + "&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt; "; $('#staffInCharge').css('background-color','#FFAA55'); $('#staffInCharge').append(data); </code></pre> <p>am using this code to append staff details into a div, and in the close16 class am using a image file(for cross mark to delete the data), if I click the cross mark the appended data should be deleted, how can I do that, and also when I append the new data its appending one by one(below of existing data) i need to append it to the right side, how can I do this.</p>
jquery
[5]
5,085,950
5,085,951
Difference between break and continue in PHP?
<p>What is the difference between <a href="http://php.net/manual/control-structures.break.php" rel="nofollow"><code>break</code></a> and <a href="http://php.net/manual/control-structures.continue.php" rel="nofollow"><code>continue</code></a> in PHP?</p>
php
[2]
2,743,821
2,743,822
what are the essential things that an android developer needs to know?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2828185/interview-questions-for-an-android-developer">Interview questions for an Android developer</a> </p> </blockquote> <p>Hi all what are the essential things that a mid level android developer needs to know..As in things beside the basics of broadcast receiver, Content provider , intent etc.I could not find a good list of interview questions on the internet. Can you guys come up with good interview questions!! </p>
android
[4]
2,857,982
2,857,983
How to compare elements and merge if condition satisfies within arraylist?
<p>i have list of trades, each trades has some attributes like source now, from the list of trades, i want to get all trades that have same source value and combine them together into one trade, for example </p> <pre><code>tradeName quote source quantity price Google GOOG Goldman Sachs 15 610 Microsoft MSFT Barclays 400 28 Google GOOG Goldman Sachs 45 610 Google GOOG Goldman Sachs 40 610 Microsoft MSFT Barclays 1000 28 </code></pre> <p>now based on source information, i should combine trades, so my updated list of trade would be </p> <pre><code>tradeName quote source quantity price Google GOOG Goldman Sachs 100 610 Microsoft MSFT Barclays 1400 28 </code></pre> <p>I am not sure about comparison part, how to go about solving it? </p> <hr> <p>Tried following approach, </p> <pre><code>for (Trade trade : tradeList) { //Not sure how to compare this.trade.source with all sources //of all trades present in the trade. //Logic should be if source matches then quantity should be added //but am not sure how comparison would work. } Class Trade { private tradeName; private quote; private source; private quantity; private price; //Getters and Setters for each of above mentioned attributes. } </code></pre>
java
[1]
2,456,758
2,456,759
JQuery- add css for each img element having a class
<pre><code>$(document).ready(function() { $("img.resizeImage").each(function(){ var img = $(this); var width = $(this).width(); // Current image width var height = $(this).height(); // Current image height // alert("give image size ....."+width+", "+height); var pic_real_width, pic_real_height; $("&lt;img/&gt;").attr("src", $(img).attr("src")) .load(function() { pic_real_width = this.width; pic_real_height = this.height; }); if(pic_real_width &lt; width ){ //alert("display original width.sssss 103.."); $(this).removeAttr("width"); $(this).css("width",pic_real_width); } if( pic_real_height &lt; height ){ //alert("display original height ss.102.."); $(this).removeAttr("height"); $(this).css("height",pic_real_height); } }); }); </code></pre> <p>in above jquery execution flow is not hitting last if conditions. I am not acquiring desired result. If I keep some alert above the two if()s then execution flow goes inside two if conditions. pl help me . How can execute jquery statements line by line..</p>
jquery
[5]
376,239
376,240
jquery form validate not allow space for username field?
<p>I have used <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" rel="nofollow">http://bassistance.de/jquery-plugins/jquery-plugin-validation/</a></p> <p>my form validate :</p> <pre><code>$("#form_person").validate({ rules: { username: { required: true, minlength: 2, maxlength:15 }, password: { required: true, minlength: 2 }, confirm_password: { required: true, minlength: 2, equalTo: "#password" }, email: { required: true, email: true } }, messages: { username: { required: "Please enter a username", maxlength:"max length 15 digits", minlength: "Your username must consist of at least 2 characters" }, password: { required: "Please provide a password", minlength: "Your password must be at least 5 characters long" }, confirm_password: { required: "Please provide a confirm password", minlength: "Your password must be at least 5 characters long", equalTo: "Please enter the same password as above" } }); </code></pre> <p>Anybody help me to validate not allow space on username?</p> <p>thanks</p>
jquery
[5]
2,008,221
2,008,222
can any one give me the code for sample registartion page with validations in android
<p>Hai all, I preapared one registration page with the fields like username ,password,email and mobilenumber.It runs successfully.But i want to validate all those fields now...any one help me how to validate...thanks in advance</p>
android
[4]
3,635,439
3,635,440
Finding all calls to a specific android sdk level
<p>I need to port an Android app to an older version. That is, the app now runs in 4.0, but not in 2.2, so I need to find all API calls incompatible to 2.2 and do a workarround.</p> <p>Is there any tool to do that easilly? That tool whould be theorically simple, it just had to find all function calls and check it's "@since" attribute, but I can't find one.</p> <p>I wonder how other people do that. If I don't find this tool I may do it, but I don't know how much time will I have, or even if I'll have the needed skill.</p>
android
[4]
2,309,502
2,309,503
C# close StreamWriter
<p>Im trying to close a text file that I have created and then read this back into a HTMLDocumentClass.</p> <p>This is the code</p> <pre><code>StreamWriter outfile = new StreamWriter(StripHTMLComps.Properties.Settings.Default.TempFileName); outfile.Write(HTML); outfile.Close(); HTMLDocumentClass doc = null; doc = new HTMLDocumentClass(); IPersistFile persistFile = (IPersistFile)doc; persistFile.Load(StripHTMLComps.Properties.Settings.Default.TempFileName, 0); GC.SuppressFinalize(persistFile); int start = Environment.TickCount; while (doc.readyState != "complete") { if (Environment.TickCount - start &gt; 10000) { } } </code></pre> <p>The document says loading but never completes, I believe that it believes the document is still in being used by another process.</p> <p>Any ideas?</p>
c#
[0]
1,464,519
1,464,520
Android WebView when Wifi off
<p>I have a WebView on my activity and I'm simply setting his url in code from assets like this:</p> <pre><code>wv.loadUrl("file:///android_asset/" + requestedHtmlPath); </code></pre> <p>all works fine when the wifi is on, but when it's off.. nothing happens..</p> <p>The question is: Is the Wifi on is must for the WebView to work with a local html file?</p>
android
[4]
751,233
751,234
Is it possible to swap two variables in Java?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1363186/is-it-possible-to-write-swap-method-in-java">Is it possible to write swap method in Java?</a> </p> </blockquote> <p>Given two values x and y, I want to pass them into another function, swap their value and view the result. Is this possible in Java?</p>
java
[1]
4,868,057
4,868,058
How to create a unique ID in PHP from a long string of user info
<p>I am reading some data from a user's badge via a magnetic swipe. It brings back a long unique text string that includes the user's badge number, their name, and a few other pieces of information. I want to be able to pull up the user's information through their swipe. I was thinking of making an MD5 hash out of the user's data, but i'm not sure how unique the MD5 would be from that swipe so I can store that md5 as how I look up the user in my MySQL database?</p> <p><em>*</em> Update: Sorry, I should add that the badge might not necessarily be from us. It might be from another company, so I really just need to take what is on the badge and create a unique ID from that. </p>
php
[2]
2,845,684
2,845,685
show a window every few seconds in home screen in Android
<p>I`m new to android.</p> <p>I want to write an alarm system in android.</p> <p>I want to show a window (or dialog) every few seconds (or hours) in home screen and i want to hide it after a few second.</p> <p>how can i do it?</p>
android
[4]
2,580,013
2,580,014
generic algorithm to force range to go through zero
<p>I'm looking for a generic algorithm which, given the range values <code>start</code> and <code>end</code> will generate a list of numbers, but <strong>the numbers must go through zero.</strong>. Here's my current code:</p> <pre><code>end = 78 start = -1 * end step_size = 16 numbers = range(start, end+step_size, step_size) $ numbers Out[90]: [-78, -62, -46, -30, -14, 2, 18, 34, 50, 66, 82] </code></pre> <p>so in this particular case, I would subtract 2 from each number, so that the numbers have one zero value. But how could I do this more generally? I'm doing this to calculate the y-tic locations of a graph, and therefore I want them to go through zero once.</p>
python
[7]
5,617,604
5,617,605
adjust div position according to window scroll bar movement
<p>my page content is big and there is a link. when user mouse over the link then a div is popup but when i scroll the browser window then div position should change when it appears. how to write and show the div by jquery in such a way that div should open and adjust position when user drag the scroll bar top &amp; down. please advice how to do it very simply.</p>
jquery
[5]
5,358,737
5,358,738
Storing Db in asset folder or create via code
<p>In my android projects I need database to store data for offline usage.</p> <p>For that I am looking at two options 1)Creating the empty db and copying it to asset 2)Creating the db via code </p> <p>which option will be good as my app is handling secure data. weather it will cause any security vulnerability if we store the db structure in asset folder as it will be easily available if we extract .apk file.</p> <p>Thanks for your support</p>
android
[4]
2,790,686
2,790,687
Multiple web deploys for asp.net
<p>I have an application that is installed at several different client's servers. They each have different web.config files and different virtual folders. At the moment I am compiling, manually copying over, setting up IIS, changing web.config and adding virtual folders for each install and also again when updating.</p> <p>I simply don't know how to deploy using something like Web Deploy or Deployment Package that will let me create different config files or how to manage virtual folders (I would assume I would simply deploy empty folders and would still have to do this part manually). I can handle setting up IIS and virtual folders from the start but I want each client to be able to download new versions and install them without my input (as some Clients are funny about remote access).</p>
asp.net
[9]
5,145,967
5,145,968
convert image to byte array
<p>i want convert image into byte array in php.actually i am accessing web service in dot net.where i want to pass image as byte array.i tried this code</p> <pre><code> $data1 = file_get_contents("upload/1311677409gen1.jpg"); $byteArr1 = str_split($data1); foreach ($byteArr1 as $key=&gt;$val) { $byteArr1[$key] = ord($val); } </code></pre> <p>and send this array name to web service.but i got error parameter is not valid.i googled it.but dont get proper solution.i need it urgent.help.</p> <p>Thanks in advance.</p>
php
[2]
3,535,640
3,535,641
python: print i for i in list
<p>When I printed a list, I got a syntax error when using this method:</p> <pre><code>print i for i in [1,2,3] </code></pre> <p>I knew this is ok when using this method:</p> <pre><code>for i in [1, 2, 3]: print i </code></pre> <p>and I knew that </p> <pre><code>(i for i in [1, 2, 3]) </code></pre> <p>is a generator object, but I just don't get it that why</p> <pre><code>print i for i in [1, 2, 3] </code></pre> <p>does't work. Can anyone give me a clue?</p>
python
[7]
2,556,425
2,556,426
NSString problem on iphone while displaying on UILabel
<p>i have a issue , i am asking as new question as previoes one was messed </p> <pre><code>NSString *s=@"hi\nhello\n\nwelcome to this world\ni m jhon" label.frame = ...//big enough height label.numberOfLines = 0; label.text = s; </code></pre> <p><strong>this code helps me to separate string based on \n</strong></p> <p>but if i do this</p> <pre><code>NSString *s=Ad.content //where Ad.content value is **hi\nhello\n\nwelcome to this world\ni m jhon** label.numberOfLines = 0; label.text = s; </code></pre> <p><strong>i am not able to sperate them by \n</strong> , what i am doing wrong here kindly suggest</p> <p>Thanks</p>
iphone
[8]
389,641
389,642
github API, fork a repo
<p>I'm trying to use the github API with python, but got stuck when wanting to fork a repo. My script so far is:</p> <pre><code>#!/usr/bin/python import json import getpass from restkit import Resource, BasicAuth, request from socketpool import ConnectionPool user= raw_input( "Github user:" ) password=getpass.getpass() auth=BasicAuth(user, password) authreqdata = { "scopes": [ "public_repo" ], "note": "admin script" } resource = Resource('https://api.github.com/authorizations', filters=[auth]) response = resource.post(headers={ "Content-Type": "application/json" }, payload=json.dumps(authreqdata)) token = json.loads(response.body_string())['token'] print token </code></pre> <p>I got the security token, but failed miserably trying to fork a repo.</p> <p>Could you help me with that?</p> <p>THanks in advance!</p>
python
[7]
4,778,519
4,778,520
Include $_POST, $_GET, $_SERVER values in PHP Error Log
<p>I have code like this</p> <pre><code>try { header("Location: http://www.google.com\n-abc"); } catch (Exception $e) { error_log(print_r($_POST, true)); error_log(print_r($_GET, true)); error_log(print_r($_SERVER, true)); } </code></pre> <p>Without the try {} catch {} block, I can see the POST, GET and SERVER variables in my error_log, but with the try {} catch {} block, I only see the default PHP error. </p> <ol> <li>Is there a way to show the POST, GET, and SERVER variables in a try {} catch {} block?</li> <li>Is there a way to have PHP include POST, GET, and SERVER variables for ALL errors that get logged to file and not just wherever I have added error_log(print_r($_POST, true)); ....?</li> </ol>
php
[2]
4,895,915
4,895,916
How to handle NullpointerException in this case
<p>This is my for loop function inside the servlet </p> <p>Here i have a question . The Data will be passed from the USER Interface to this .</p> <p>In some conditions , some information (For example symbol or side ) may not be passed , then in those conditions , i am getting NullPointreException as null would be supplied to it .</p> <pre><code>List&lt;Bag&gt; bags = new ArrayList&lt;Bag&gt;(bagdata.length); for (FormBeanData ld : data) { Bag bag = new Bag(); bag.symbol = ld.getSymbol(); bag.side = ld.getSide(); bags.add(bag ); } </code></pre> <p>Is there anyway we can handle such situations ??</p> <p>Thank you .</p>
java
[1]