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,361,685
4,361,686
How do I attach event to popup parent's parent?
<p>I want to attach an event to popup parent's parent.</p> <p>Hierarchy is like this:-</p> <p>Form1(master page) containing iframe opens Form2(without master page) opens a popup.</p> <p>I want to identify Form1 in popup opened by Form2 through Javascript.How do I do it?</p> <p>It works only for Form2.</p> <p>window.opener.document.attachEvent("onclick",setfocus);</p>
javascript
[3]
989,828
989,829
get only specific innerHtml
<p>as far i know how to get innerHTML but now i want to get only specified tags. let say i only want those line of tags who contains <code>test-class</code>.</p> <pre><code>&lt;div id="parent"&gt; &lt;div class="test-class"&gt; some texts &lt;/div&gt; &lt;div class="class_1"&gt; some text &lt;/div&gt; &lt;/div&gt; $(functio() { $('#parent').html(); }); </code></pre> <p>But my expected result should be <code>&lt;div class="test-class"&gt; some texts &lt;/div&gt;.</code> please give me any idea. </p> <p>Thanks in advance. <strong><em>Edit @Js</em></strong></p> <pre><code>&lt;html&gt; &lt;head&gt; /* css &amp; js file attached */ &lt;script type="text/javascript"&gt; jQuery.fn.outerHTML = function(s) { return (s) ? this.before(s).remove() : jQuery("&amp;lt;div&amp;gt;").append(this.eq(0).clone()).html(); } $(function() { var outerHTML = $('#parent').find('.test-class').outerHTML(); alert(outerHTML); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; /* the same html code as above */ &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
1,031,002
1,031,003
Get User-Agent using Android API
<p>Kindly provide me the <strong>Android code to get the User-Agent from the Android mobile device</strong> like in J2me where we can get System information about the mobile device using the J2me API.</p> <p>Also , is there any list of Rdf or useragent string/ xml for the different Android devices available in the market.</p> <p>Kindly help.</p> <p>Warm Regards,</p> <p>Chiranjib Banerjee</p>
android
[4]
3,301,804
3,301,805
Get the first part of a url path
<p>If I have a url like:</p> <p><a href="http://localhost:53830/Organisations/1216/View" rel="nofollow">http://localhost:53830/Organisations/1216/View</a></p> <p>I want to alert the first part of the url path in lowercase format e.g. 'organisations'</p> <p>So far I have:</p> <pre><code>var first = $(location).attr('pathname'); first.indexOf(1); first.replace('/', ''); first.toLowerCase(); alert(first); </code></pre> <p>but it's not working as intended. Can anyone help? Thanks</p>
jquery
[5]
444,068
444,069
connect to oracle XE using c# 2010 express
<p>Just startted with c#. not sure the express version supports connection to oracle or not. if it does, could anyone let me know the steps to do it?</p> <p>Thanks guys.</p>
c#
[0]
1,736,789
1,736,790
Can I make the following assumption when map key is not found?
<pre><code>std::map&lt;std::string, int&gt; m; // Can I make assumption that m["NoSuchKey"] will return 0? std::cout &lt;&lt; m["NoSuchKey"] &lt;&lt; std::endl; </code></pre>
c++
[6]
1,809,260
1,809,261
how do i find out if a certain button has been clicked like in check boxes
<p>e.g </p> <pre><code>if()// button1 is clicked { alert("Button 1 was clicked"); } if()// button2 is clicked { alert("Button 2 was clicked"); } </code></pre>
jquery
[5]
1,989,862
1,989,863
"Notice: Undefined variable" error and foreach loop
<p>Can someone please explain to me why I get "Notice: Undefined variable" for variable $subtotal in the 2nd code snippet but NOT in the 1st code snippet ? What's the difference between them? Are they consider local variables?</p> <p>Also, exactly what is the variable type (Global, Superglobal.. etc) of $cartKey and $cartItem in the foreach loop? How come I didn't need to define/declare them?</p> <pre><code>switch( $_SESSION['shippingMethod'] ) { case "Air": $shipping = $subtotal * 0.1; break; } </code></pre> <p>and</p> <pre><code>foreach( $cart as $cartKey =&gt; $cartItem ) { $subtotal += $cartItem['total']; } </code></pre> <p>Thank you very much in helping.</p>
php
[2]
388,106
388,107
client side folder
<p>folders and files can be created on the client side by using some script?I wanted to create folders and files on client side.</p> <pre><code>mkdir(); </code></pre> <p>like the above which makes folders on the server</p>
jquery
[5]
2,736,109
2,736,110
JavaScript identifiers not to use
<p>I just found out the hard way that naming your variable <code>arguments</code> is a bad idea.</p> <pre><code>var arguments = 5; (function () { console.log(arguments); })(); </code></pre> <blockquote> <p><code>Output: []</code></p> </blockquote> <p>It turns out that <code>arguments</code> is <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Functions_and_function_scope/arguments">"a local variable available within all functions"</a> so in each new execution context, <code>arguments</code> is shadowed.</p> <p>My question is: Are there any other such treacherous names which, like <code>arguments</code>, are not true <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words">reserved words</a>, but will cause still problems?</p>
javascript
[3]
4,309,045
4,309,046
Java - How to identify what is the most frequently used delimiter
<p>I have a string :</p> <p>www.domain.com/I-Need-This-Part</p> <p>I need to detect what the most frequently used delimiter is after the / which in this case is - . The delimiter may change depending on the url.</p> <p>Once I working this out, I will use .split and pass in the most frequently used delimiter to count the parts.</p> <p>Any help on this would be much appreciated.</p> <p>Thank you in advance.</p>
java
[1]
5,071,704
5,071,705
Loading external txt file into a DIV
<p><a href="http://jsfiddle.net/9BCrs/2/" rel="nofollow">http://jsfiddle.net/9BCrs/2/</a></p> <p>With respect to the above fiddle how could I use different links in block 1 to load up an external file (txt, HTML) in block 2 before it slides into view? I know that JQuery.load() will be part of the process</p> <pre><code>$(".block2").load("helloworld.txt"); </code></pre>
jquery
[5]
4,131,804
4,131,805
When is a Custom Content Provider called for?
<p>I have seen custom content providers for sqLite in apps, but thats about it. When should a Custom Content provider be built?</p>
android
[4]
3,575,972
3,575,973
How to make Android share button appear on touch?
<p>I am creating a news app which contains a 'share news' button. Currently this button is showing all the time when user reads the news, which makes news reading irritating. Now my question is how can I make that share button show up when user touch on the screen, and will disappear after 2-3 seconds if it is left without touching. It would be nice if I can make a little animation during the button appearing/disappearing (like, show up from bottom and disappear going down). Please help...</p> <p>Thanks</p>
android
[4]
605,960
605,961
jquery getting listitem id from its child id
<pre><code>&lt;li id="l"&gt;&lt;a href="#"&gt;&lt;img id="i" /&gt;&lt;/a&gt;&lt;/li&gt; </code></pre> <p>I have image id and i want listitem id , i know one way </p> <pre><code>$("#i").parent().parent().attr("id"); </code></pre> <p>Is there any better way than this?</p>
jquery
[5]
3,103,659
3,103,660
Calculate closest matches from array value combinations
<p>I have an array of part lengths, for examples sake:-</p> <pre><code>array(150, 180, 270); </code></pre> <p>I then have a measurement <code>($a = 440)</code></p> <p>I need to calculate the two <strong>closest</strong> possible combinations of lengths which are greater than <code>$a</code> without manually having to write hundreds of possible combinations in order to work it out.</p> <p>So:</p> <p><code>150</code><br> <code>180</code><br> <code>270</code> </p> <p><code>150 + 150</code><br> <code>150 + 180</code><br> <code>150 + 270</code> </p> <p><code>180 + 180</code><br> <code>180 + 270</code></p> <p><code>270 + 270</code> </p> <p><code>150 + 150 + 150</code><br> <code>150 + 150 + 180</code></p> <p>..and so on.</p> <p>This will need to run for a set number of times, rather than just finding the first two matches and stopping, as <code>150 + 150 + 150</code> would be a <strong>closer</strong> match to <code>$a</code> than <code>270 + 270</code> but may run after.</p> <p>edit: I also need to store the combination of parts which made up the match, preferably in an array.</p> <p>I hope I've explained this well enough for somebody to understand.</p>
php
[2]
3,254,091
3,254,092
Enterprise App Distribution (Wi-Fi) says "Could not download app" sometimes
<p>We have an iPhone app developed in-house and distributed over wi-fi following <a href="http://developer.apple.com/library/ios/#featuredarticles/FA_Wireless_Enterprise_App_Distribution/Introduction/Introduction.html" rel="nofollow">apples docs</a></p> <p>About 60% of the employees devices can download the app without any problem. For 40%, the installation process stops at 75% and the message <em>"Could not download app"</em> is shown.</p> <p>Anybody experienced this or know how to get a more descriptive error message?</p> <p>Thanks!</p>
iphone
[8]
544,739
544,740
Getting this Error: Server:: Write Abort: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: QueryClass
<p>I have a JAVA server using MultiThread to communicate with client. Everything of the Server works, except for when a client object is send to Server thread. I have narrowed down the problem to this following lines of code. </p> <p>The error is as a result of this line in the code: queryClass= ((QueryClass)inStream.readObject()); //Read data here and QueryClass is a serialized class. </p> <p>.Am getting the error above. QueryClass is another class, which i have it searialized: Here is my code.</p> <pre><code>public void run(){ try{ ObjectOutputStream outStream=new ObjectOutputStream(clientSocket.getOutputStream()); ObjectInputStream inStream=new ObjectInputStream(clientSocket.getInputStream()); while(true){ sleep(1); queryClass= ((QueryClass)inStream.readObject()); //Read data here serverNotification.UpdateNotification("Performing .. operation for TaxOfficer"); } }catch(Throwable thrown){ System.err.println("Exception Caught : "+thrown+" deleting thread"); } </code></pre>
java
[1]
4,903,569
4,903,570
JQuery: How to rearrange divs dynamically
<p>I'm new to JQuery and I'm creating a site where one can click on one of several links, and a div will pop up with information about that link. The code currently hides all the divs at the start of the page, and uses slideToggle() to show it independently when they're clicked. The only problem is: they're in order in the HTML document. I want to so whichever link you click, it moves all the divs that are being shown, down to make room for the newest one.</p> <p>For example: User clicks Section1. Section1 shows up. User clicks Section2. Section1 is moved down. Section2 shows up on top.</p> <p>Any ideas on how to do this? I tried using prepend() and insert() but to no avail.</p> <p>Thanks, Derek.</p>
jquery
[5]
5,654,259
5,654,260
Need Explanation: Organization with Objects in a Contact List (Javascript, Codecademy)
<p>I've been having some trouble making sense of two javascript functions in this <a href="http://bit.ly/Zroroe" rel="nofollow">contact list project</a> on <a href="http://bit.ly/Zroroe" rel="nofollow">codecademy</a>. </p> <p>Specifically, I got confused with conditions like, "obj" or "prop". I would really appreciate it if someone can explain in detail how these functions work. </p> <p>Here is the code &amp; thank you: </p> <pre><code>var friends = {}; friends.bill = { firstName: "Bill", lastName: "Gates", number: "(206) 555-5555", address: ['One Microsoft Way','Redmond','WA','98052'] }; friends.steve = { firstName: "Steve", lastName: "Jobs", number: "(408) 555-5555", address: ['1 Infinite Loop','Cupertino','CA','95014'] }; var list = function(obj) { for(var prop in obj) { console.log(prop); } }; var search = function(name) { for(var prop in friends) { if(friends[prop].firstName === name) { console.log(friends[prop]); return friends[prop]; } } }; list(friends); search("Steve"); </code></pre>
javascript
[3]
535,052
535,053
Accept either single dict or list of dicts as function argument
<p>I'd like to accept either one dict or a list of dicts as a function argument. So far, I've come up with the following, but I suspect I've missed something completely obvious, and am using something fragile (<code>isinstance</code>):</p> <pre><code>def wrap(f): def enc(inp): if isinstance(inp, list): for item in inp: f(item) else: f(inp) return enc @wrap def prt(arg): # do something with the dict print arg.keys() </code></pre>
python
[7]
2,502,413
2,502,414
Having trouble looping arguments with multiples of three. (newb)
<p>The goal of this program is to run arguments such as "K6V3 20.2 17.4" and use the Weather class to calculate the windchill based on the last 2 numeric arguments and use the first argument as the shorthand name for the area. Im running into a problem when the program is given args in multiples of three, such as "K6V3 20.2 17.4 KCHO 40.0 10.0" Im not sure how to get the loop to restart after the third arg. My program will take the first three args and display the correct information, but it will just repeat that information for the second three args. Here is my code so far, HELP!?!?!</p> <pre><code>public class ChillMapper { public static void main(String args[]) { double ICAO; double t; double v; double windChill; for (int i = 0; i &lt; args.length / 3; i++) { if (args.length % 3 == 0) { ICAO = Text.toDouble(args[0]); t = Text.toDouble(args[1]); v = Text.toDouble(args[2]); windChill = Weather.windChillNA(t, v); Map.setTemperature(args[i], windChill); } } } } </code></pre>
java
[1]
5,390,314
5,390,315
How I update my Access table through textbox interface and show result into grid view?
<pre><code>String conn="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\Data.accdb"; string query = "Insert Into Venue values(@venueID,@vanueName)"; OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, conn); OleDbCommandBuilder cBuilder = new OleDbCommandBuilder(dAdapter); DataTable dTable = new DataTable(); dTable.Rows.Add("@vanueName", textBox1.Text); dAdapter .Fill (dTable ); dataGridView1 .DataSource =dTable ; </code></pre>
c#
[0]
479,573
479,574
Does the Photos App register a URL Handler on the iPhone?
<p>I have read the Apple documentation. They list the apps registered, yet in their example they use a handler not mentioned. https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationEnvironment/chapter_3_section_6.html</p> <p>This post attempts to list the handlers. But it too appears incomplete since the iPod handler is not listed. <a href="http://quinagh.com/applookup/index.php/2009/01/07/iphone-apps-with-special-url-shortcuts/" rel="nofollow">http://quinagh.com/applookup/index.php/2009/01/07/iphone-apps-with-special-url-shortcuts/</a></p> <p>Is there a complete list available? Does anyone know if the Photos app has a registered handler or not for certain?</p>
iphone
[8]
460,664
460,665
return array range
<pre><code>function GetImages($orderByDate, $start, $end) { $container = array(); if ($handle = opendir('uploads')) { while (false !== ($file = readdir($handle))) { if ($file != "." &amp;&amp; $file != "..") { $filename = 'uploads/' . $file; $lastEdit = date("F d Y H:i:s.", filemtime($filename)); $image = array( 'fileName' =&gt; $file, 'lastEdit' =&gt; $lastEdit ); array_push($container, $image); } } closedir($handle); } if($orderByDate) { function date_compare($a, $b) { $t1 = strtotime($a['lastEdit']); $t2 = strtotime($b['lastEdit']); return $t1 - $t2; } usort($container, 'date_compare'); } if(isset($start) &amp;&amp; isset($end)) { array_slice($container, $start, $end); } return $container; } echo '&lt;pre&gt;'; var_dump(GetImages(true, 0, 5)); echo '&lt;/pre&gt;'; </code></pre> <p>Isnt <code>slice</code> the way to go here? Even if i pass a start and an end value, i still get all the records from the array. Thanks</p>
php
[2]
1,211,340
1,211,341
are text.trim() really can't work in IE8
<p>when i test my web-page in chrome and firefox they work fine. but in IE it does not worked.</p> <p>i found that </p> <p><code>(" .class li").text().trim()</code> not worked in IE he give me error that </p> <p>Object doesn't support this property or method. but in FF and chrome they work fine. are i goes something wrong to handle this.</p>
jquery
[5]
2,330,334
2,330,335
Reading File in C++
<p>I am unable to figure out why my code is not able to open and read a file. What am i missing?</p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; using namespace std; int main (int argc, char * const argv[]) { string line; ifstream myfile ("input_file_1.txt"); if (myfile.is_open()) { while (!myfile.eof()) { getline (myfile,line); cout &lt;&lt; line &lt;&lt; endl; } } else { cout &lt;&lt; "Was unable to open the file" &lt;&lt; endl; } return 0; } </code></pre> <p>The file "input_file_1.txt" is int he same directory as my .cpp file and it has read permissions. I even gave gave it 777 permissions and i was unable to read it.</p> <p>Can anyone tell me what i am doing wrong? I really cannot figure it out....</p>
c++
[6]
2,772,645
2,772,646
Cannot be resolved to a variable, after asking user to input variable
<p>It's probably something obvious, but when I'm trying to force the user to keep entering a value until he enters a valid value, I get an error that the variable cannot be resolved.</p> <p>Then if I declare it beforehand I get an error saying duplicate value. </p> <pre><code>do { float x = Float.parseFloat(javax.swing.JOptionPane.showInputDialog("Enter 1"); } while (x != 1); </code></pre> <p>Isn't the compiler supposed to execute the <code>do</code> statement first, before worrying about the <code>while</code>?</p>
java
[1]
4,118,780
4,118,781
text editor program
<p>how to write a program in java for text editor.what things should be there in this program?</p>
java
[1]
4,961,325
4,961,326
Can I run Wine on an Android slate?
<p>I would like to run a small Windows program on an Android slate. It runs just fine under Wine in Ubuntu, but I am unsure how to install &amp; run Wine on the Android slate. </p> <p>Sorry if it's not strictly a programming question. If you want it to be so, I could rephrase it as "will I have to write my Delphi code again Java in order to run it on an Android slate?" </p>
android
[4]
1,418,070
1,418,071
Working mechanism of private inheritance of a class having private constructor
<p>case 1:</p> <pre><code>class ObjectCount { private: ObjectCount(){} }; class Employee : private ObjectCount {}; </code></pre> <p>case 2:</p> <pre><code>class ObjectCount { public: ObjectCount(){} }; class Employee : private ObjectCount {}; </code></pre> <p>In case1: ObjectCount constructor is private and inheritance is private . It gives compiler error</p> <p>In case2: ObjectCount constructor is public and inheritance is private . this code is ok. </p> <p>Can anyone explain how is it happening?</p>
c++
[6]
4,844,791
4,844,792
how to set reminder?
<p>in my application I got the date and time via DatePicker and TimePicker and set reminder on Perticular user selected Date and Time, But I already done Date and Time Picker but don't know how to set reminder on that, Kindly help me.Thanks </p>
android
[4]
1,648,084
1,648,085
Recursively call handlerMessage from a started service?
<p>I need to do some recursive tasks, say do something after every five seconds. How to achieve that? I will need to do the recursive task in the background, so I think I can go with a <code>Started Service</code>.</p> <p>PS. What I am actually trying to do is: taking picture using camera after every five seconds, from a background service.</p> <p>I found following code in the developer-guide. The method below resides in a custom class which extends <code>Handler</code> class:</p> <pre><code>@Override public void handleMessage(Message msg) { // Do Something // HOW CAN i MAKE A RECURSIVE CALL (TO SOMEHOW CALL THIS FUNCTION) AFTER 5 SECONDS? // Stop the service using the startId stopSelf(msg.arg1); } } </code></pre> <p>Can I call something like <code>Thread.sleep(5000)</code> just before <code>stopSelf()</code>? (Not making sense to me...)</p> <p>Or can I call something like <code>this.sendMessageDelayed(msgOb, 5000);</code> ?</p> <p>Thanks.</p>
android
[4]
2,658,451
2,658,452
Activity does not finish even after using return statement or finish call
<p>Following is an onclick method called when a button is clicked. But the code doesn't stop my application. It sends a message and then closes and then restarts again.. I have read the lifecycle model of an activity and fyi this is a single activity application. I also researched on stackoverflow, many of the post describing to have a return statement after finish() call so i have done that too but no results.</p> <p>Where am i going wrong ???</p> <pre><code>public void onClick(View v) { String text = "Demo Message"; String number = &lt;set via a particular code&gt;; if(number.equals("")) { Toast.makeText(this, "Please Enter or Select a Number", Toast.LENGTH_SHORT).show(); } else { sms = SmsManager.getDefault(); PendingIntent sentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Main.class), 0); sms.sendTextMessage(number, null, text, sentIntent, null); Toast.makeText(this, "Message Sent to : " + number, Toast.LENGTH_SHORT).show(); // Stop the Activity... finish(); return; } } </code></pre>
android
[4]
3,323,413
3,323,414
SMS Gateways
<p>My application needs to send notification to users by SMS. Is there any free International SMS gateways which can be used by .NET application?</p>
c#
[0]
4,187,735
4,187,736
can't open file : [Errno 2] No such file or directory
<p>I get the following error when subprocess calls the process newtest.py. The code run as a daemon. When I started the daemon the process was called, it worked fine and did run 8 processes before started giving the error and then the error occurs at every call. The error is </p> <pre><code> /opt/local/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python: can't open file 'newtest.py': [Errno 2] No such file or directory </code></pre> <p>the code is below:</p> <pre><code>for index,row in enumerate(jobs): if index &lt;= new_jobs : dirs=row[0] dirName=os.path.join(homeFolder,dirs) logFile=os.path.join(dirName,(dirs+".log")) proc=subprocess.Popen(["/opt/local/bin/python2.6","newtest.py",dirs],stdout=open(logFile,'a',0),stderr=open(logFile,'a',0)) proId= proc.pid </code></pre> <p>I tried using the full path to newtest.py but it gives the same error. Any suggestions? Many Thanks!</p>
python
[7]
2,219,212
2,219,213
PLIST UPDATING CHANGING THE KEY FROM ITEM O TO SOME NAME
<p>every one </p> <p>i have a problem with my plist ,i was able to write the data to plist which is type Dictionary ,and consists of 4 string items , and my problem is i want to change the dictionary key value to some example: 500k but it is showing default item 0, i want to change this to 500k</p> <p>below is the code i implemented.</p> <pre><code>NSMutableDictionary *nameDictionary = [NSMutableDictionary dictionary]; [nameDictionary setValue:Name forKey:@"fullName"]; [nameDictionary setValue:Salary forKey:@"salary"]; [nameDictionary setValue:Experience forKey:@"expreience"]; [nameDictionary setValue:Designation forKey:@"designation"]; NSMutableArray *plist = [NSMutableArray arrayWithContentsOfFile:@"/Users/nikhil/Desktop/secondProgram/secondProgram/new2.plist"]; NSLog(@"wat is in plist %d",[plist count]); if (plist == nil) plist = [NSMutableArray array]; [plist addObject:nameDictionary]; [plist writeToFile:@"/Users/nikhil/Desktop/secondProgram/secondProgram/new2.plist" atomically:YES]; </code></pre> <p>and in plist is show ing </p> <blockquote> <p>item 0 | Dictionary | (4items)</p> </blockquote> <p>i want to change it to </p> <blockquote> <p>500K | Dictionary | (4items)</p> </blockquote> <p>Please help me ....</p>
iphone
[8]
3,284,220
3,284,221
The method setOnClickListener(new View.OnClickListener(){}) is undefined for the type imageButton1
<p>`i keep getting this error messege and im not sure what im supposed to do</p> <p>The method setOnClickListener(new View.OnClickListener(){}) is undefined for the type imageButton1</p> <pre><code> public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); imageButton1 imagebutton1 = (imageButton1) findViewById(R.id.imageButton1); imageButton1.setOnClickListener(new OnClickListener() { public void onClick(View v) { ImageView iv = (ImageView) findViewById(R.id.imageview1); iv.setVisibility(View.VISIBLE); } }); </code></pre>
android
[4]
4,148,897
4,148,898
Treeview - SelectedNodeChanged not working for appended hyperlink
<p>In the following code</p> <pre><code> &lt;asp:TreeNode Text="node text here &lt;a&gt;Click&lt;/a&gt;" Value="1" Expanded="False"&gt; &lt;asp:TreeNode Text="er" Value="0"&gt;&lt;/asp:TreeNode&gt; &lt;asp:TreeNode Text="err" Value="1"&gt;&lt;/asp:TreeNode&gt; &lt;asp:TreeNode Text="err" Value="2"&gt;&lt;/asp:TreeNode&gt; &lt;/asp:TreeNode&gt; </code></pre> <p>I have custom code in the 'SelectedNodeChanged' event. This event is triggered when I click on the node text ("node text here") but not triggered when I click on the hyperlink (anchor tag "Click"). How can I make the anchor tag click also to behave like 'selectednodechanged'.</p>
asp.net
[9]
1,420,026
1,420,027
Can HTML webpage access c# code instead of PERL scripts
<p>I have <code>HTML</code> forms, which have embedded <code>javascript</code> and <code>PERL</code> code. We have to remove all <code>PERL</code> references from the <code>HTML</code> docs. The <code>HTML</code> calls the <code>PERL</code> methods, which are located in <code>.pl</code> files, through the <code>OnClick</code> setmode call etc. All the <code>PERL</code> methods will be rewritten in <code>C#</code>. To save the <code>HTML</code> webforms, is there a way to call the <code>C#</code> methods from the <code>HTML</code> forms? Or just redoing everything in <code>ASP.NET</code> web application is the only answer? Looking for the minimal option for the <code>C#</code> conversion effort.</p>
asp.net
[9]
1,169,810
1,169,811
jQuery - Set all cookies ending with
<p>I'm wondering if it's possible to use a wildcard to select multiple cookies. I'm using jQuery to save various scroll position and would like to clear them out in one go. At the moment I clear them out individually as below</p> <pre><code> function clearScroll(elementID) { if ($.cookie) { $.cookie(elementID + '_scrollpos', 0); } } </code></pre> <p>What I'd like is a clear all something like below.</p> <pre><code>function clearAllScroll() { if ($.cookie) { $cookie([name$='_scrollpos'],0); } } </code></pre> <p>Is this possible?</p>
jquery
[5]
2,316,869
2,316,870
C# are they the same: Encoding.UTF8.GetBytes & Convert.FromBase64String?
<p>confused by the encoding stuff. are <code>Encoding.UTF8.GetBytes</code> and <code>Convert.FromBase64String</code> are the same?</p>
c#
[0]
4,076,422
4,076,423
Python error "Ordinal not in range" with accents
<p>I'm scraping a table from the Internet and saving as a CSV file. There are characters with French accents in the text, resulting in a unicode error on save:</p> <pre><code> UnicodeEncodeError: 'ascii' codec can't encode characters in position 5-6: ordinal not in range(128) </code></pre> <p>I'd like to find an elegant solution for saving accented characters that I can apply to any situation. I've sometimes used the following:</p> <pre><code> encode('ascii','ignore') </code></pre> <p>but it doesn't work this time, for reasons unknown. I'm also trying to replace the <code>&lt;sup&gt;</code> tags in a cell, so I'm converting it using <code>str()</code> first. </p> <p>Here's the pertinent part of my code:</p> <pre><code> data = [ str(td[0]).split('&lt;sup')[0].split('&gt;')[1].split('&lt;')[0], td[1].getText() ] output.append(data) csv_file = csv.writer(open('savedFile.csv', 'w'), delimiter=',') for line in output: csv_file.writerow(line) </code></pre>
python
[7]
1,049,967
1,049,968
How to stop a timer after certain number of times
<p>Trying to use a timer to do run this 4 times with intervals of 10 seconds each. I have tried stopping it with a loop, but it keeps crashing. Have tried using the schedule function with three parameters, but I didn't know where to implement a counter variable. Any ideas?</p> <pre><code>final Handler handler = new Handler(); Timer timer2 = new Timer(); TimerTask testing = new TimerTask() { public void run() { handler.post(new Runnable() { public void run() { Toast.makeText(MainActivity.this, "test", Toast.LENGTH_SHORT).show(); } }); } }; int DELAY= 10000; for (int i=0; i!=2 ;i++) { timer2.schedule(testing,DELAY); timer2.cancel(); timer2.purge(); } </code></pre>
android
[4]
38,697
38,698
Correct jquery lib for supporting drag and drop of elements?
<p>I'm new to jquery development. I need to get drag and drop support for some elements, and I found this library provides what I need:</p> <p><a href="http://jqueryui.com/" rel="nofollow">http://jqueryui.com/</a></p> <p>is this a good choice? I'm not sure if there are any technical pitfalls, a better library to use for this, etc. The minified js file (with all features) is pretty large ~200kb, I'll have to cut down on that by using their custom config stuff,</p> <p>Thanks</p>
jquery
[5]
4,156,457
4,156,458
content pulled from a .doc file and displayed in a Tinymce editor
<p>I want to display a .doc/.docx/.pdf/.txt file from a directory in the Tinymce Editor. just like u see in monster(resume section)? How can I achieve it?</p>
php
[2]
133,096
133,097
Object Casting in C#
<p>what is the difference as well as the pros and cons between </p> <pre><code> LinkButton lb = (LinkButton)ctl; </code></pre> <p>and</p> <pre><code> LinkButton lb = ctl as LinkButton; </code></pre> <p>I tried using the first one and it gives me error, then I tried the other one with the keyword as, it work just fine.</p> <p>Thank You in Advance.</p>
c#
[0]
67,174
67,175
interpreting this for loop snippet
<p>Here we have a snippet of an array implementation of a binary heap. I would like some help seeing what this for loop means in pseudocode:</p> <pre><code>public void insert (Anytype x) { int hole = ++currentSize; //currentSize is the size of the array for (array[0] = x; x.compareTO(array[hole / 2]) &lt; 0; hole /= 2) array[hole] = array[hole / 2]; array[hole] = x; } </code></pre> <p>I can't seem to understand how this for loop works. Thank you.</p> <p><strong>EDIT</strong> filled the hole</p>
java
[1]
2,454,695
2,454,696
"used struct type value where scalar is required" at .layer.position
<p>I want to make a selection before apply one of two animations, what I thought is: make a Piont "one", if my "myImageView" is at the Point "one", then apply animationNo1, else apply animationNo2, but I got this:"used struct type value where scalar is required", at line "if (myImageView.layer.position = one) " What I do? how can I fix this? Does anyone know exactly what makes the problem happen? Thank you, very much.</p> <pre><code> CGPoint one = CGPointMake(myImageView.layer.position.x, 100); if (myImageView.layer.position = one) { animationNo1 } else { animationNo2 } </code></pre>
iphone
[8]
5,278,172
5,278,173
Fullscreen Background Image Swap
<p>I am using Fullscreenr for the fullscreen background:</p> <p>jquery:</p> <pre><code>var FullscreenrOptions = { width: 1209, height: 770, bgID: '#bgimg' }; jQuery.fn.fullscreenr(FullscreenrOptions); </code></pre> <p>html: <code>&lt;img id="bgimg" src="images/bg1.jpg"&gt;</code></p> <p>To swap background image on navigation hover:</p> <pre><code> $('#about').hover(function() { $('#bgimg').attr('src', 'images/aboutbg.jpg'); }, function () { $('#bgimg').attr('src', 'images/bg1.jpg'); }); $('#work').hover(function() { $('#bgimg').attr('src', 'images/workbg.jpg'); }, function () { $('#bgimg').attr('src', 'images/bg1.jpg'); }); </code></pre> <p>and so on. This works fine for the homepage.</p> <p>What I would like to do is when you are on the ABOUT page (or other specific pages), I would like the fallback background to be the pages background.</p> <p>For instance, the ABOUT page, I changed: <code>&lt;img id="bgimg" src="images/bg1.jpg"&gt;</code></p> <p>to: <code>&lt;img id="bgimg" src="images/aboutbg.jpg"&gt;</code></p> <p>This works on refresh, but when you mouseout of the navigation, it still falls back to bg1.jpg. </p> <p>Is there a way I can pull the id="bgimg" image of current page instead of calling the src in:</p> <pre><code> $('#bgimg').attr('src', 'images/bg1.jpg'); </code></pre> <p>Does this make any sense?? Thanks for any help. </p> <p><a href="http://www.juliandiazvelosa.com" rel="nofollow">Link to site</a></p>
jquery
[5]
700,861
700,862
XMLHttpRequest Synchronous or Asynchronous
<p>In my JS I am sending a get request to the bit.ly api to shorted a URL. The problem is I need the URL returned for use in the code.</p> <p>Would it be best to use a synchronous request for this? As it stands any code after the XHR request that uses the bit.ly would fail because the response has not yet returned the short URL.</p> <pre><code>bitlyXHR.onreadystatechange = function() { if (bitlyXHR.readyState == 4) { if (bitlyXHR.status == 200) { var obj = JSON.parse(bitlyXHR.responseText); // Do something } } }; bitlyXHR.open("GET", "http://api.bitly.com/v3/shorten?login=&amp;apiKey=&amp;longUrl=" + longURL + "&amp;format=json"); bitlyXHR.send(); // Some code here that uses the short URL </code></pre>
javascript
[3]
4,357,732
4,357,733
Creating a struct and a class with the same name
<p><strong>Summary</strong>: What happens if you declare a <code>struct</code> and a <code>class</code> with the same name.</p> <p><strong>Details</strong>:</p> <p>I'm reviewing some code and I saw a warning like this:</p> <pre><code>warning: struct 'foo' was previously declared as a class </code></pre> <p>When compiling with clang there were also a couple of places where clang added notes saying:</p> <pre><code>foo.h:29:1: note: did you mean struct here? class foo; ^~~~~ struct </code></pre> <p>Obviously this is not a good coding practice to have a struct and a class with the same name. It looks like what happened is the developer was writing his own class and used a name that was already in use in another file that he was including and he did not notice that.</p> <p>However, my question is will the compiler be able to tell the difference between the variables that were declared as <code>class foo</code> and the ones that were <code>struct foo</code>?</p> <p><strong>Edit</strong>:</p> <p>Actually what was happening was that the developer was using the <code>class foo</code> in a <code>class bar</code> that he had created. I think that in the meantime the place where the <code>class foo</code> was declared had been changed to a <code>struct bar</code>. So that was why the code was compiling. So I guess the answer to my question is that <code>struct</code> and <code>class</code> are interchangeable when declaring objects. Still I guess it's a good idea to use them consistently.</p>
c++
[6]
1,667,354
1,667,355
Display first 2000 words from a long string (Stripping HTML) C# ASP.NET
<p>I have a field in my database that holds input from an html input. So I have in my db column data. What I need is to be able to extract this and display a short version of it as an intro. Maybe even the first paragraph if possible. </p>
c#
[0]
920,753
920,754
what the point of declaring a static method in a non-static class?
<p>The way I understand it, having a member variable declared as <strong>static</strong> in a <strong>no-static class</strong> causes that member variable to be unique no-matter the number of instances of that class. </p> <p>Now, what happen to a static method declared in non-static class? And (<strong>Most importantly</strong>), what the point of declaring a static method in a non-static class?</p> <p>Thanks for helping</p>
c#
[0]
2,962,964
2,962,965
defining static arrays in Java
<p>hello I have some question about writing class in Java, why this one is not working:</p> <pre><code>public class EvenFibonacciSequences { static final int num = 45; static int calculated[num]; ... } </code></pre> <p>how can I write it correctly? thanks in advance</p>
java
[1]
5,063,745
5,063,746
Batch-convert C# code to use String.Format
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/8674705/resharper-string-format-shortcut">Resharper string.format shortcut</a> </p> </blockquote> <p>In our large code base, unfortunately there are a lot of statements like this:</p> <pre><code>MessageBox.Show("Hello, " + userName + "!"); </code></pre> <p>Obviously, this would be better to facilitate String externalisation:</p> <pre><code>MessageBox.Show(String.Format("Hello, {0}!", userName)); </code></pre> <p>Is there any tool that can automate this job (convert string concatenations to String.Format)?</p> <p>If not, I figure it would be necessary to find a parser that constructs a syntax tree for a given C# source file, find expressions that do string concatenations in this tree (does not seem easy) and convert the found occurences?</p> <p><strong>EDIT</strong>: DevExpress CodeRush does exactly what I want - pretty cool. But unfortunately it only works on the current source file and I have to click every occurence (or so it seems). I would like to do the operation on all of my source files (like with 'Replace all').</p>
c#
[0]
3,903,750
3,903,751
How To Make Dynamic Changing Upload Path
<p>Im trying to make a file upload system where whenever a file is upload the file goes into a uploads folder set like this uploads/2012/09/{randomhash}/.</p> <p>To do this i tried the code below.</p> <pre><code>$hash = RandomString(20); $upload_path = '../../uploads/'.$year.'/'.$month.'/'.$hash.'/'; if (!is_dir($upload_path)) { mkdir($upload_path, 0777); } </code></pre> <p>For some reason its not working and i have no idea why.</p>
php
[2]
2,710,712
2,710,713
How to grab current url and use it in load() function in jQuery?
<p>I want to reload the content of the page I am on, so I am grabbing the div I want to reload of the same page in url as I am currently on and it is working:</p> <pre><code>success : function(msg) { $('#div-to-reload').load('http://localhost/page-i-am-currently-on.php #div-to-reload'); } </code></pre> <p>But I need it to be done dynamically so javascript find out the current URL and append it instead of the hardcoded url </p> <blockquote> <p><code>http://localhost/page-i-am-currently-on.php</code></p> </blockquote> <p>.</p> <p>I have tried this, but it is not working ;( :</p> <pre><code>success : function(msg) { var pathtopage = window.location.pathname; $('#div-to-reload').load('pathtopage #div-to-reload');} </code></pre> <p>Thanks in advance, for any help.</p>
jquery
[5]
3,676,201
3,676,202
How do you retrieve the call list and voicemail messages on the iPhone?
<p>I'm developing an iPhone application that replicates the functionality of the built-in phone application, but adds a few features on top. This is for ad hoc distribution only.</p> <p>In particular, is there a way to programmatically retrieve the last calls received by the phone? Also, how can an application access the list of voicemail messages?</p>
iphone
[8]
2,783,304
2,783,305
Activity indicator not showing when there is loop code?
<p>I am showing an Activity indicator in welcome screen as well as main screen. It is working fine in welcome screen. In main view, there is a 'for' loop code which does some task for 16 times. At this time, device looks like a bit hang, to avoid that i want to show activity indicator. When i add the standard activity code in main screen during some loop(16 times) code going on, i'm not observing the set activity indicator show. It comes only after the loop finished. I tried giving some delay before doing loop code, but still doesn't show during expected time. Otherwise user may think that my app hangs the device, so i want to show activity indicator at that time.</p> <p>Any suggestions to resolve this are welcome !</p> <p>thanks.</p>
iphone
[8]
5,332,808
5,332,809
implementing contacts in android in list and saving contact in database
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1721279/how-to-read-contacts-on-android-2-0">How to read contacts on Android 2.0</a> </p> </blockquote> <p>I am developing an android application in which i have to implement contacts in a list and save all the contacts in the database.I have looked around a sample of codes.i have used content provider and cursor adapter for fetching contacts.But it did not worked for me </p>
android
[4]
4,082,577
4,082,578
Why is this code returning NaN?
<p>blackjack game: I made the deal function below that's supposed to return a random number between 1-4 which represents a suit, as well as another random number between 1-3 which represents a card number. </p> <p>when I test the code by calling <code>console.log(getSuit(card1));</code> it returns NaN</p> <p>Anyone know why? </p> <pre><code>// Make your card constructor again here, but make sure to use private // variables! function Card(num, suit){ var num = num; var suit = suit; getSuit = function(){ return suit; }; getNumber = function(){ return num; }; getValue = function(card){ if (card &gt; 10){ return 10; }else if (card === 1){ return 11; }else{ return card; } }; } // Make a deal function here. It should return a new card with a suit // that is a random number from 1 to 4, and a number that is a random // number between 1 and 13 var deal = function(){ var suit = Math.floor(Math.random * 4 + 1); var number = Math.floor(Math.random * 13 + 1); return new Card(number, suit); }; // examples of the deal function in action var card1 = deal(); var card2 = deal(); console.log(getSuit(card1)); </code></pre>
javascript
[3]
3,155,024
3,155,025
How to get the screen brightness of iphone
<p>I did some searches and found that if want to adjust the brightness, I need to use private framework and apple will reject it.</p> <p>If I just want to get the value of brightness(just get that value to display, not adjust it), is there a way which apple accept?</p>
iphone
[8]
4,333,723
4,333,724
Is there a bug with .removeProp() in jQuery, or am I doing something wrong?
<p><strong>Answered: I'm doing it wrong</strong></p> <p>Selected items in the listbox will show up in the UL below. Click on an item in the UL and it will remove it from the listbox and remove itself from the UL.</p> <p>Reproduce Bug: <a href="http://jsfiddle.net/rkw79/mmBKf/2/" rel="nofollow">http://jsfiddle.net/rkw79/mmBKf/2/</a></p> <ul> <li>Select an item in the listbox</li> <li>Click on that item in the UL, it will disappear and the listbox will show it as unselected</li> <li>Click on that same item in the listbox</li> </ul> <p>Notice that the event is fired, but the item is not added</p> <p>Now do the same steps, except use .prop('selected','') instead of .removeProp('selected'): <a href="http://jsfiddle.net/rkw79/mmBKf/3/" rel="nofollow">http://jsfiddle.net/rkw79/mmBKf/3/</a></p>
jquery
[5]
736,354
736,355
Java: Displaying all data in ArrayList in a table
<p>I am having some problems displaying data in an ArrayList in the form of a JTable.</p> <p>The ArrayList consists of data, but only when the user enters data into JTextField's in a GUI (this GUI is in another class). I have used getText().</p> <p>My ArrayList is in one class, but the GUI for the JFrame for the JTable is in another class. I can't seem to create a JTable in the GUI and I can't seem to be able to get the data from the ArrayList to be displayed in the JTable.</p> <p>The ArrayList consists of 12 JTextFields all of which are Strings which should be the Headings for the JTable. When the program is launched, the user is able to enter their own data as many times as they want which is stored in the ArrayList under each Heading. This data is always different as the user enters different data all the time and therefore, I think, I cannot use this:</p> <pre><code>String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"}; Object[][] data = { {"Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false)}, {"John", "Doe", "Rowing", new Integer(3), new Boolean(true)}, {"Sue", "Black", "Knitting", new Integer(2), new Boolean(false)}, {"Jane", "White", "Speed reading", new Integer(20), new Boolean(true)}, {"Joe", "Brown", "Pool", new Integer(10), new Boolean(false)} }; </code></pre> <p>What do you think I should do? And how should I implement this?</p> <p>Any help is much appreciated!</p>
java
[1]
1,600,472
1,600,473
PHP type-casting to boolean
<p>Can someone explain me why this:</p> <pre><code>var_dump((bool) 1==2); </code></pre> <p>returns</p> <pre><code>bool(true) </code></pre> <p>but </p> <pre><code>var_dump(1==2); </code></pre> <p>returns</p> <pre><code>bool(false) </code></pre> <p>Of course the second return is correct, but why in the first occasion php returns an unexpected value?</p> <p>I use PHP 5.3.8 in Debian GNU/Linux.</p> <p>Thanks</p>
php
[2]
763,673
763,674
How can I fade out, change test and then fade in with jQuery cleanly?
<p>I've been playing with a div I have that changes on a user action. I want to have it fade out, change the node value and then fadeIn.</p> <p>No matter what I try I always see the value change as the element is fading out. Can anyone help?</p> <pre><code> calculator_result.fadeOut(); calculator_result.css("color", "#fff").html("&amp;euro;" + vRelief + ".00"); calculator_result.fadeIn(); </code></pre> <p>This is the code I'm using now but I tried it a few different ways! A delay might work but surely these a cleaner way?</p> <p>Cheers, Denis</p>
jquery
[5]
2,616,463
2,616,464
why this parse from string to DateTime fails in C#?
<p>I have a DateTime <code>eventDate</code> field in my Mysql table which I compose from the inputs when I insert it in db:</p> <pre><code>cmd.Parameters.Add("?eventDate", MySqlDbType.DateTime).Value = DateTime.ParseExact(txtEventDate.Text + " " + txtEventTime.Text, "MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture); </code></pre> <p>and is saved nice: </p> <blockquote> <p>2011-05-05 10:20:00</p> </blockquote> <p>Now, when I read it from DB I want to split it but it fails if I do like this:</p> <pre><code>txtEventDate.Text = DateTime.ParseExact(Reader.GetValue(7).ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture).Date.ToShortDateString(); txtEventTime.Text = DateTime.ParseExact(Reader.GetValue(7).ToString(), "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture).TimeOfDay.ToString(); </code></pre> <p>saying that: </p> <blockquote> <p>String was not recognized as a valid DateTime.</p> </blockquote> <p>Do you see any issue? I cannot figure out where I am wrong...</p>
c#
[0]
2,990,193
2,990,194
open existing java project in eclipse
<p>As one of our dev guy is on vacation, I got his task. The source code is in our svn repository and i got down the java project source. downloaded eclipse 3.3.2 sdk as that were his instruction.</p> <p>How do I open an existing project in eclipse? Coming from MS world, i do not have the luxury of finding a .sln file.</p>
java
[1]
1,530,129
1,530,130
Keep toggled panel open after form submit
<p>I have a contact form that is within a sliding panel and I want the panel to remain open after a user submits a form. Current code is this:</p> <pre><code> jQuery("a.button.large").click(function(){ jQuery("#panel").slideToggle("slow"); jQuery(this).toggleClass("active"); }); </code></pre>
jquery
[5]
4,089,737
4,089,738
What's the C# pattern to perform an action on a series of values?
<p>I have this code:</p> <pre><code>if (PsionTeklogix.Keyboard.Keyboard.GetModifierKeyState(Key.Orange) == KeyState.Lock) PsionTeklogix.Keyboard.Keyboard.InjectKeyboardCommand(Function.Orange, 0, 0); if (PsionTeklogix.Keyboard.Keyboard.GetModifierKeyState(Key.Blue) == KeyState.Lock) PsionTeklogix.Keyboard.Keyboard.InjectKeyboardCommand(Function.Blue, 0, 0); if (PsionTeklogix.Keyboard.Keyboard.GetModifierKeyState(Key.Shift) == KeyState.Lock) PsionTeklogix.Keyboard.Keyboard.InjectKeyboardCommand(Function.Shift, 0, 0); if (PsionTeklogix.Keyboard.Keyboard.GetModifierKeyState(Key.Control) == KeyState.Lock) PsionTeklogix.Keyboard.Keyboard.InjectKeyboardCommand(Function.Control, 0, 0); ... </code></pre> <p>and I want to refactor the code separating the key / function definition from the actions. Key.xxx and Function.xxx aren't from the same type.</p> <p>eg: in Python, I could simply do something like:</p> <pre><code>keys = ( ( Key.Orange, Function.Orange ), ( Key.Blue , Function.Blue ), ( Key.Shift , Function.Shift ), ... ) psi_key = PsionTeklogix.Keyboard.Keyboard for key, func in keys: if psi_key.GetModifierKeyState(key) == KeyState.Lock): psi_key.InjectKeyboardCommand(func, 0, 0) </code></pre> <p>What's "the right way" to do in C#?</p>
c#
[0]
4,355,978
4,355,979
how to design a webpage for all resolution monitors
<p>I have created one web application in asp.net. In my computer'resolution it works fine with out any stretch. But some other monitor resolutions my web application streched. How to solve that screen resolution problem?</p>
asp.net
[9]
2,773,769
2,773,770
PHP rand() advise
<p>I am using the following code</p> <pre><code>$wID=rand(2, 4); </code></pre> <p>to generate numbers from 2 to 4, how can i generate numbers starting from 2 but no maximum?</p>
php
[2]
789,502
789,503
How to access static class variable in static member function of same class?
<p>I provide my sample:</p> <pre><code> class a { public: static int m_n; static int memfuc(); }; int a::memfuc() { int k =m_n; return k; } </code></pre> <p>But the following sample throws linker error: unresolved external symbols</p>
c++
[6]
804,483
804,484
Android ListView Selector Color
<p><strong>Hi All,</strong></p> <p>I have 2 questions regarding a ListView in Android:</p> <ol> <li><p>How can I <strong>get</strong> the color of the listview's focused row ? I tried to use the <strong>ListView.getSelector()</strong> method, which according to its documentation should give me what I'm looking for, but it's giving me a Drawable object which I don't know how to retrieve the color from (if possible...).</p></li> <li><p>How can I <strong>set</strong> the color of the listview's focused row ? Here I tried to use the <strong>setSelector()</strong> method on the listview, passing it a ColorDrawable object, but the result of doing it is that the whole background of the list view is painted in that color... and this is not what I wanted of course...</p></li> </ol> <p>Thanks!</p>
android
[4]
5,784,772
5,784,773
how to add custom message box
<p>hi i am new to ipone. what i need is after running my application if i click menu button it will display about, help just like alert message by selecting about i will open the webpage and by selecting the help it will display some text hoe can i done this. </p>
iphone
[8]
574,032
574,033
Building an app across different Android platforms?
<p>I see a whole bunch of platforms / SDKs, everything from 1.x to 4.x.</p> <p>Does this mean I have to build my app separately for all different versions?</p> <p>My goal is to wrap my HTML5 web app and make it available as a native app in app stores.</p>
android
[4]
835,079
835,080
Active/inactive Jquery nav menu
<p>I'm not skilled with javascript so if anyone can help me I would be very grateful.</p> <p>I have a simple list like this:</p> <pre><code>&lt;ul&gt; &lt;li id="nav1"&gt;Menu 1&lt;/li&gt; &lt;li id="nav2"&gt;Menu 2&lt;/li&gt; &lt;li id="nav3"&gt;Menu 3&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>When a user click on a menu element I'd like to add a class "menu_active".</p> <p>I could reach this result with this code:</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(document).ready(function() { jQuery("#nav1").toggle(function () {jQuery(this).addClass("menu_active");},function () {jQuery(this).removeClass("menu_active");}); jQuery("#nav2").toggle(function () {jQuery(this).addClass("menu_active");},function () {jQuery(this).removeClass("menu_active");}); jQuery("#nav3").toggle(function () {jQuery(this).addClass("menu_active");},function () {jQuery(this).removeClass("menu_active");}); }); &lt;/script&gt; </code></pre> <p>The script work, but if you click on #nav1, then on #nav2, then on #nav3, all three items will have the class "menu_active".</p> <p>Is there a simple way to have only a single menu element highlighted?</p>
jquery
[5]
3,699,343
3,699,344
Compiler in Java surprisingly hangs up while attempting to parse a string value, 2.2250738585072012e-308 to double
<p>I have tried the following code in NetBeans 6.9.1, it should display the value on the console but the compiler surprisingly hangs up. The code snippet is as follows.</p> <pre><code>package demo; public class Main { public static void main(String[] args) { System.out.println("Test Demo:"); double d = Double.parseDouble("2.2250738585072012e-308"); //double d = Double.parseDouble("30000.2250738585072012e-308"); Works with no hangs up. System.out.println("Value = " + d); } } </code></pre> <hr> <p>It may not be the case of the range of double in Java. If the specified value is out of the range, it should throw some exception or result in some error but it hangs up, instead. What should actually be the reason?</p>
java
[1]
4,504,161
4,504,162
Python Sockets use function instead of global socket call
<p>Hello I am trying to port some C code to python. I haven't used python in a few months so feel a bit rusty.</p> <p>Wondering how I can do this. I need to be able to use the send value of the sock object in createConnection function with out making the sock object global.</p> <p>any ideas?</p> <p>*cheers</p> <p>Example code</p> <pre><code>def createConnection(host, port, tcpTimeout): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) sock.connect((host, port)) return sock def useConnectionOne(): sock = createConnection("&lt;Some IP&gt;", &lt;Some Port&gt;, 5) sock.send("Hello world") def useConnectionTwo(): sock = createConnection("&lt;Some IP&gt;", &lt;Some Port&gt;, 5) sock.send("Hello again world") </code></pre>
python
[7]
1,898,953
1,898,954
.on() not working for generated elements
<p>AFAICT this should work but it doesn't. Using jQuery 1.9.0, I have the following:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="js/libs/jquery-1.9.0/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("button").click(function() { $("#area").html("&lt;p&gt;click me&lt;/p&gt;"); }); $("p").on("click", function() { alert($(this).text()); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;some text&lt;/p&gt; &lt;button&gt;Create me&lt;/button&gt; &lt;div id="area"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Why does clicking on "some text" bring the alert but clicking on the generated "click me" not? I thought the whole point of .on() was to enable event handlers on dynamically generated code. According to <a href="http://stackoverflow.com/questions/6658752/jquery-click-event-doesnt-work-on-dynamically-generated-elements">jQuery - Click event doesn&#39;t work on dynamically generated elements</a> this should work but it doesn't. See <a href="http://jsfiddle.net/ymUYy/1/" rel="nofollow">http://jsfiddle.net/ymUYy/1/</a></p>
jquery
[5]
522,752
522,753
python logic error
<p>please help me figure out what is wrong with this code; the first function works fine but the second one returns the wrong number. what the second variable is sup post to return is the remainder of minutes passed since midnight. </p> <pre><code> def get_hours(s): time=s/3600 return time #The get_hour function returns how many hours have passed since midnight. The # parameter is the time in seconds that has passed since midnight. def get_minutes_remainder(s): hours=get_hours(s) minutes=s/60 a=round(hours) b=a-hours b=abs(b) minutes=minutes*b return minutes </code></pre>
python
[7]
3,108,510
3,108,511
Java program will compile but not run
<p>I was wondering if someone could help me with this.</p> <p>I have defined my interface as:</p> <pre><code>interface Model { public String toString(); public Model add (Model m); } </code></pre> <p>There are 2 classes implementing the interface (ClassA and ClassB):</p> <pre><code>class ClassA implements Model { private int val; public ClassA(int x) { val = x; } public String toString() { return ""+ "value of object of class A is " + val; } public Model add (Model m) { if (m instanceof ClassA) return new ClassA(val + ( (ClassA) m).val); else return null; } } class ClassB implements Model { private String str; public ClassB(String s) { str = s; } public String toString() { return str; } public Model add (Model m) { if (m instanceof ClassB) return new ClassB(str + ((ClassB) m).str); else return null; } } </code></pre> <p>My main defines objects of ClassA and ClassB and calls their tostring() methods.</p> <pre><code>public class Example { public static void main (String args[]) { ClassA a = new ClassA(5); ClassB b= new ClassB("Hi"); Model m = b; System.out.println(m.toString()); ClassA a1 = new ClassA(7); m = a.add(a1); System.out.println(m); } } </code></pre> <p>When I try to build this file it compiles fine but, upon trying to run the application I get an error message:</p> <p>"Usage: java [-options] class [args...] (to execute a class) or java [-options] -jar jarfile [args...] (to execute a jar file).....etc...etc"</p> <p>Can anyone help me with this? It's probably something simple. I'm a beginner Java student.</p>
java
[1]
2,228,567
2,228,568
Is it possible to block any application in android
<p>I have to implement functionality in which I can block any application installed in device by filling password. When I click on icon for start application then it should ask for password. Is it possible. Please give suggestion about it. </p>
android
[4]
2,070,083
2,070,084
reorder columns of a csv file containing float, interger and text data?
<p>I would like to do a similar process to a csv file as detailed in <a href="http://stackoverflow.com/questions/6117868/write-csv-columns-out-in-a-different-order-in-python">this question</a>, but I get an error message saying: </p> <pre><code>TypeError: list indices must be integers </code></pre> <p>The csv file that I want to rearrange has a combination of float, text, and interger data types. I'm assuming this is the problem, but can't figure out a way to modify the code below to insert the data. It writes the header information in the new CSV file though.</p> <p>I'm using the same code as suggested by John Machin, but my write names varaible uses: </p> <pre><code>writenames = "ID,average,max,min,median,mode,stddev,skewness,kurtosis".split(",") reader = csv.reader(open("/home/usrs/chris/Summary.csv", "rb")) writer = csv.writer(open("/home/usrs/chris/SummaryNEW.csv", "wb")) readnames = reader.next() names2indicies = dict((name,index) for index, name in enumerate(readnames)) writeindices = [names2string[name] for name in writenames] reorderfunct = operator.itemgetter(writeindices) writer.writerow(writenames) for row in reader: writer.writerow(reorderfunct(row)) </code></pre>
python
[7]
2,765,489
2,765,490
GLU "Camera" reposition
<p>How can I Change the position of the "camera"? this is how i first got it to view the shape i made:</p> <pre><code> GLU.gluLookAt(gl, coords[0], coords[1], cameraZAxis, 0, 0, 0, 0, 1f, 0); </code></pre> <p>while coords[0 &amp; 1] is 0, but on a touch event they are changed to add or subtract 10 according to the position of the touch. </p>
android
[4]
3,874,916
3,874,917
Passing objects to new objects
<pre><code>$P1 = new Player(array( 'name' =&gt; 'Player 1', 'strat' =&gt; new Strategy(&amp;$this) )); </code></pre> <p>This is more or less what I'm trying to do. The reference to $this is obviously wrong. What is the best way to accomplish something like this?</p> <p>Basically, the new Strategy object needs to know what Player it belongs to.</p> <p>Sure I could do like:</p> <pre><code>$P1 = new Player(); $P1-&gt;strat = new Strategy(&amp;P1); </code></pre> <p>but that doesn't seem as concise.</p> <p>Update:</p> <p>I guess instead of passing the new strategy object in the array, I would pass the name of the strategy class instead, and then instantiate a new object in the Player constructor.</p>
php
[2]
4,627,245
4,627,246
jQuery animate not working on $(this)
<p>I am trying to animate a bunch of <code>&lt;div&gt;</code>'s with <code>.animate</code> with this function: </p> <pre><code>slideOut: function(container){ var count = container.siblings().size() - 1; container.siblings().each(function(index, item){ $(item).delay( index * 50 ).animate({ "left" : "-1000px" }, "fast", function(){ if (index == count){ container.delay(container.parent().parent().children().size() &gt; 10 ? 10 * 50 + 300 : container.parent().parent().children().size() * 50 + 300 ).animate({ "left":"-1000px" }, "fast", function(){ container.parent().parent().clone(true, true).appendTo(metro.tiles); metro.overlay(container.parent().parent().parent()); }); } }); }); }, </code></pre> <p>and I am using the following function to bring them back in to the DOM: </p> <pre><code>slideInTiles: function(){ $("#contentWrapper").empty(); $("#contentWrapper").append(metro.tiles.children()); $("#contentWrapper li").animate({"left": "0px"}, "fast"); $("#contentWrapper li.activeTile").css({"left": "0px"}, "fast"); }, </code></pre> <p>The problem, however, is that the <code>&lt;li&gt;</code> I click on does not get animated back in to the mix. I have to use <code>.css</code> to bring it back. Where is the bug in the code that is causing this problem? Also, since I am bringing the active <code>li</code> back by using <code>.css</code> it no longer animates out of the view either. I am pretty sure this has got to do with the <code>.clone</code> method. But how, I can't figure. </p>
jquery
[5]
920,601
920,602
Is it safe to use a class inside the package sun.misc?
<p>For example should I use <a href="http://java-doc.narod.ru/sun/misc/IOUtils.java.html" rel="nofollow">sun.misc.IOUtils</a>?</p>
java
[1]
661,191
661,192
How to get custom virtual keyboard in android?
<p>I need to get virtual keyboard like that contains all numbers maybe through android:keyboard</p> <p>i also need a keyboard that contains all alphabets only</p>
android
[4]
2,169,740
2,169,741
Which of the two would initialize an object faster?
<pre><code>class A { public: int a; A(int x) { a = x; } }; </code></pre> <p>OR</p> <pre><code>class B { public: int b; B(int x):b(x){} }; </code></pre> <p>Which one would initialize the object faster ? Or will same code be generated ultimately for both and the time taken to initialize will remain the same ? Or does it depend on the compiler ?</p>
c++
[6]
950,693
950,694
'$' is undefined
<p>I get this error whether I put the jQuery $.ajax call in a <code>$(document).ready(function() {</code> or not. This is on a ASP.NET MVC .cshtml file.</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function() { $.ajax({ url: '/api/courses', success: function(data) { var list = $('#courses'); for (var i = 0; i &lt; data.length; i++) { var course = data[i]; list.append('&lt;li id="' + course.id + '"&gt;' + course.name + '&lt;/li&gt;'); } } }); }); </code></pre>
jquery
[5]
2,890,711
2,890,712
how to display post in jquery slider and carousel
<p>ok I'm pretty new to wordpress and the codex seems too complicated for a newbie like me. My homepage has both a <a href="http://workshop.rs/projects/coin-slider/" rel="nofollow">slider</a>(which I want it to display <code>5</code> latest post) and a <a href="http://caroufredsel.frebsite.nl/" rel="nofollow">carousel</a>(which should display <code>4</code> older post) </p> <p>I know wordpress uses the query_post() function to display the posts but my problem is how to employ this function in both the carousel and the slider (which are both on the homepage). :(</p>
jquery
[5]
3,494,804
3,494,805
Help with Pixastic Resize using jQuery
<p>Im trying to use Pixastic with jQuery, looking for advice or any examples of it being used with jQuery?</p> <p>Any help appreciated.</p>
jquery
[5]
2,438,406
2,438,407
jquery - any way to hide any class that is less than 3? for instance
<p>I want to have a bunch of spans with classes of different "depths", i.e one may be depth 1, another depth 2, another depth 3.</p> <pre><code>&lt;span class="depth1"&gt;&lt;/span&gt; &lt;span class="depth2"&gt;&lt;/span&gt; &lt;span class="depth3"&gt;&lt;/span&gt; </code></pre> <p>Then, if I want to hide anything that's below depth 3, I don't know how else to do it besides a for loop</p> <pre><code>for (i = 1; i &lt;= 2; i++) $(".depth" + i).hide(); </code></pre> <p>Is there any better way to do this? maybe class ="3" instead of "depth3"? And any way to allow floating points, so that 2.5 and 1.5 will both be hidden too?</p>
jquery
[5]
1,450,677
1,450,678
Variable printing in python
<p>I'm new to Python and I'm trying to declare a variable and print its value.</p> <p>This is my code:</p> <pre><code>#!C:\Python32\python.exe import sys import os import cgi import cgitb cgitb.enable() a = 5 print(a)-------------------------&gt; My doubt is in this line </code></pre> <p>But one of my friends writes that line as <code>print a</code>. In his Python, it is printing that value, but in my case it is showing as "Invalid Syntax". Why is this happening?</p>
python
[7]
1,247,932
1,247,933
How to Validate a readonly="readonly" situation
<p>In javascript, how can I check to see if an item, say "emailAddrs" that is set as readonly="readonly" has a value as I need to perform validation for situations like this before the form is submitted?</p> <p>Thanks</p>
javascript
[3]
1,842,345
1,842,346
Android populate edittext value using bytes?
<p>Is it possible to populate EditText value using bytes in android. I want to display a few number of images in an Edittext. Is there any way i can do this ?</p>
android
[4]
1,638,652
1,638,653
WP8 App misbehaving due to StreamWrite in JavaScript
<p>I would like to save the results calculated on html page in a <strong>textfile</strong> using javascript.</p> <pre><code>&lt;script type="text/javascript"&gt; window.onload = function () { var sw : StreamWriter = new StreamWriter("HTML_Results.txt"); sr.Write('xyz"); *** calculations ****** sr.Write (result); } &lt;/script&gt; </code></pre> <p>by doing this, <strong><em>my WP8 App</em></strong> is misbehaving and not displaying images as usual. This app is an Image Fader (calculates FPS).</p> <p><strong>Also tried:</strong></p> <pre><code>StreamWriter sr; try { sr = new StreamWriter("\HTML5\HTMLResults.txt"); sr.Write("xyz"); File.SetAttributes("HTML5\HTMLResults.txt", FileAttributes.Hidden); } catch(IOException ex) { console.write ("error writing"); //handling IO } </code></pre> <p><strong>The aim is to:</strong></p> <ol> <li>Extract calculated values of several html pages(after getting loaded one by one) in a single text file.</li> <li>A Resultant HTML that reads this text file and displays results in a tabular format.</li> </ol> <p>Is there a better way to this job or the above can be rectified and used? Appreciate help.</p>
javascript
[3]
5,337,700
5,337,701
2D arrays comparison - nested for loop error
<p>I have the following function which compares the first column value in two 2D arrays.</p> <pre><code>var new_array = [['EMI_007','lion','cat'], ['EMI_008','cat','dog'] ]; var existing_array = [['EMI_002','cat','tiger'], ['EMI_004','hen','pig'], ['EMI_007','pigeon','hen'], ['EMI_001','boar','tiger'] ]; </code></pre> <p>The value in new_array[i][0] is compared to the value in existing_array[j][0].</p> <p>If they are the same, the entire row is replaced by the row in <code>new_array</code>, otherwise the <code>new_array</code> row is concatenated to the existing array.</p> <p>In the above example, new_array is compared to existing_array.</p> <p>EMI_007 exists in 'existing_array', so it's replaced by <code>['EMI_007','lion','cat']</code> and ['EMI_008','cat','dog'] is appended to the existing array.</p> <p>I have created the following function but there seems to be an error.</p> <p>If a row with an EMI id found in new_array does not exist in 'existing_array', it is inserted several times.</p> <pre><code>function concat_2D_array(existing_array, new_array){ for (var i=0; i&lt;new_array.length; i++) { for (var j=0; j&lt;existing_array.length; j++) { if(new_array[i][0] == existing_array[j][0]){ alert("ok,it already exists in the existing_array"); existing_array.splice(j,1,new_array[i]); } else{ alert("It is not in the existing array"); // existing_array.concat(new_array[i]); } } } alert("returned existing_array"+existing_array) return existing_array; } </code></pre> <p>Any help is most appreciated</p>
javascript
[3]