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
279,812
279,813
Why is my function not executiong my global variable?
<pre><code>&lt;script type="text/javascript"&gt; var number = "10"; (function(){ alert(number); alert(eval('number=22')); })(); var func = function() { alert (new Function( 'return (' + number + ')' )()); } func(); // prints 22. &lt;/script&gt; </code></pre> <p>It first alerts <code>10</code>, then alerts <code>22</code> then why is it alerting <code>22 again instead of 10</code>. Does eval function overrides my variable in global scope.</p>
javascript
[3]
4,130,358
4,130,359
dispose the existing and open new form in c#
<p>I have two forms in my program. The first is the login form and the other is the home form. When i click the 'Enter' button on the login form, it should close or dispose the login form and then open the new home form. I have not been able to do this. Please help me out.</p>
c#
[0]
2,715,569
2,715,570
Possible reasons for not being able to see a control from the codebehind?
<p>I am looking at a Main.Master with a single <code>&lt;asp:Content&gt;</code> control and inside that some ASP.NET login stuff (LoginView, LoginName, etc).</p> <p>I tried adding a <code>Label</code> like so:</p> <pre><code>&lt;asp:LoginName ID="LoginName1" runat="server" FormatString="Welcome {0} &lt;br /&gt;" /&gt; &lt;asp:Label ID="Label1" runat="server" /&gt; </code></pre> <p>but it doesn't show in the codebehind.</p> <p>Any obvious reason for this?</p>
asp.net
[9]
2,296,194
2,296,195
Save file in the internal storage of android device
<p>I'm trying to make an application that save a temporary file on the sd card.</p> <p>if the user don't have a sd card I want the application save the file in internal storage</p> <p>sory for my english.</p>
android
[4]
5,234,251
5,234,252
Android: Draw circle of alphabets
<p>I am working in android, I want to draw a circle of Alphabets, in this every alphabets A to Z must show. and this each alphabet must be clickable or touchable.</p> <p>My view should look like following one:- <img src="http://i.stack.imgur.com/JI7Zt.png" alt="enter image description here"></p> <p>I do not have any idea related to this, how should I start ? please give me some suggestion so I can go ahead.what things should I use to do this.</p> <p>you may provide me some suitable links. </p> <p>Thank you in advance.</p>
android
[4]
2,253,862
2,253,863
android suggestion on zooming
<p>I have to zoom particular area or particular pixels in picture when touched.</p> <p>Please suggest how to go about this.</p>
android
[4]
5,288,773
5,288,774
Thousands Seperator in Python
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators-in-python-2-x">how to print number with commas as thousands separators in Python 2.x</a> </p> </blockquote> <p>Does anyone know of an easier way to make numbers have thousands separation than this:</p> <pre><code>def addComma(num): (num, post) = str(num).split('.') num = list(num) num.reverse() count = 0 list1 = [] for i in num: count += 1 if count % 3 == 0: list1.append(i) list1.append(',') else: list1.append(i) list1.reverse() return ''.join(list1).strip(',') + '.' + post </code></pre> <p>It works, but it seems REALLY fragile...</p>
python
[7]
1,006,558
1,006,559
access the outer div using an element inside it
<pre><code>&lt;div class='container'&gt; &lt;a href="#"&gt;Click&lt;/a&gt; &lt;/div&gt; </code></pre> <p>How can I access the outer div using the anchor as a starting point in jQuery?</p>
jquery
[5]
4,297,500
4,297,501
match multiple array values, with value correct order
<p>Suppose I have</p> <pre><code> // the idea of the array below are ['from', 'to'] var runA = [2,6] var runB = [4,1] var input = [1,4,2,6,2] </code></pre> <p>How can match store to <code>runA</code>, so that of <code>2,6</code> are in the correct order? It should return true.</p> <p>But for <code>runB</code>, it should return false, even if it contains both values 1, and 4, but does not match the correct 'from', 'to' order.</p>
javascript
[3]
2,675,146
2,675,147
image loaded from database does not show
<p>guys. I tried to load image stored in mysql blob field with php, but the image does not show correctly. In firebug, I got these infos: get-image.php Dimensions0 × 0File size5.35KBMIME typeimage/jpeg</p> <p>Here is my code</p> <p>HTML</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Demo of Database Image in a page&lt;/title&gt; &lt;/head&gt; &lt;body&gt; Here is your picture:&lt;br&gt; img src=get-image.php?id=1 width=400 height=300&gt;&lt;br&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>PHP</p> <pre><code>&lt;?php include "db.php"; $conn = OpenDbConnection(); $key = $_GET["id"]; $tkey = "" . $key . ""; $strsql = "SELECT * FROM `images` WHERE `image_id` = " . $tkey; $rs = mysql_query($strsql, $conn) or die(mysql_error()); if (!($row = mysql_fetch_array($rs))) { die("File not exists."); } header("Content-type: image/jpeg"); echo $row["content"]; mysql_free_result($rs); mysql_close($conn); ?&gt; </code></pre> <p>Please someone tell me what is wrong with my code?</p>
php
[2]
5,236,657
5,236,658
How to Determine Frequency (In Hertz, Real Time) with Java Sound
<p>I've been looking around and I've found some questions similar to mine but have never been quite satisfied with the answers. I'm more or less a Java n00b, although I am moderately proficient with C++ and I would consider myself intermediate to advanced, as a programmer in general. I'm looking to write a program in Java that functions similarly to a tuner - what I want to do is record an instrument's pitch over about a 3 second time frame, and to measure the average deviation. (This is for a band class.)</p> <p>What I'm thinking is that I'll have a big array of numbers, and each entry in the array will be a number in terms of frequency. I want to be able to loop through the array, and calculate the average Hertz for displaying it on screen or something. So what I want to do is have some way of "polling" (for lack of a better word) the microphone to see what frequency is being inputted right that instant.</p> <p>Is there a simple way to accept audio input from a microphone in terms of Hertz? This will be in Java, under a Windows platform.</p>
java
[1]
3,004,322
3,004,323
How to find 3rd part of location pathname?
<p>I want to get 'second' in the following sample web address. </p> <p><a href="http://www.mywebsite.com/first/sedond/third.html" rel="nofollow">http://www.mywebsite.com/first/sedond/third.html</a></p> <p>"first" can be any length. i.e. contact, images etc</p> <p>If I use document.location.pathname, I get "/first/sedond/third.html". If I use document.location.pathname[1], I get "f".</p> <p>How can I get "first" part by using document.location.pathname?</p> <p>Thanks in advance.</p>
javascript
[3]
3,002,869
3,002,870
POST _viewstate with php
<p>Hi I'm trying to send post values using a PHP script to an external website and get the result. My code is as follows</p> <pre><code>$postdata = http_build_query( array( 'drpservice' =&gt; 091, 'drpdirection' =&gt; 1, 'drpbusstop' =&gt; 18051 ) ); $opts = array('http' =&gt; array( 'method' =&gt; 'POST', 'header' =&gt; 'Content-type: application/x-www-form-urlencoded', 'content' =&gt; $postdata ) ); $context = stream_context_create($opts); $result = file_get_contents($url, false, $context); echo $result; </code></pre> <p>However, it won't return the required results unless I can manage to send in the hidden _VIEWSTATE value. Anyone able to help?</p>
php
[2]
2,442,734
2,442,735
App freeze when I remove [super loadView]
<p>When I remove the [super loadView]; the view wont display. The superclass is UIViewController.</p> <pre><code>- (void)loadView { [super loadView]; UITableView *tableview = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 367.0f) style:UITableViewStylePlain]; tableview.dataSource = self; tableview.delegate = self; self.tableView = tableview; [tableview release]; [self.view addSubview:self.tableView]; } </code></pre> <p>Any idea why? Thanks in advance!</p>
iphone
[8]
627,682
627,683
scanner class in java
<p>Hey I'm trying to compile the following piece of code to basically read stuff from a file but it refuses to work. it gives me an java.io.FILENOTFOUNDEXCEPTION error at line4. help would be appreciated.</p> <pre><code> import java.io.*; import java.util.*; public class test{ public static void main(String args[]) { File fin = new File ("matrix1.txt"); Scanner scanner = new Scanner(fin); while (scanner.hasNextLine()){ String line = scanner.nextLine(); System.out.println(line); } } } </code></pre>
java
[1]
269,063
269,064
How to use Printershare application in my android application
<p>I want to take a print of pdf file in my application.so,I want to use printershare application which is installed in my mobile.</p> <p>How to use that printershare application?and how can I send pdf file path through the intent.</p> <p>Thanks</p>
android
[4]
622,739
622,740
adding echo deletes textareas
<p>When adding my echo statements, the textarea boxes dissapear. This is the selection of code:</p> <pre><code>&lt;?php $rs_settings = mysql_query("select * from thesis where id='$_SESSION[user_id]'"); ?&gt; &lt;br&gt;&lt;?php while ($row_settings = mysql_fetch_array($rs_settings)) {?&gt; &lt;form action="thesis.php" method="post" name="regForm" id="regForm" &gt; &lt;div class="forms"&gt; Title of Proposed Thesis&lt;span class="required"&gt;*&lt;/span&gt; &lt;textarea name="thesis_name" type="text" id="thesis_name" size="600"&gt;&lt;?php echo $row_settings['thesis_Name']; ?&gt;&lt;/textarea&gt; Abstract&lt;span class="required"&gt;*&lt;/span&gt; &lt;textarea name="abstract" type="text" id="abstract" size="600"&gt;&lt;?php echo $row_settings['abstract']; ?&gt;&lt;/textarea&gt; &lt;?php } ?&gt; </code></pre> <p>Does anyone know which piece of code is cauisng this?</p>
php
[2]
3,996,149
3,996,150
Static Way to get Context on Android - Is it safe?
<p>I realize there is a very interesting technique, to get Context in Android in an easy way.</p> <p><a href="http://stackoverflow.com/questions/2002288/static-way-to-get-context-on-android">Static Way to get Context on android?</a></p> <p>However, I also came across</p> <p><a href="http://stackoverflow.com/questions/4797187/android-static-variable-null-on-low-memory">Android : Static variable null on low memory</a></p> <p>Is it possible that the static variable used to hold context, become null during low memory?</p>
android
[4]
837,480
837,481
Android live wallpaper (+Background)
<p>I have LiveWallpaper which is in the fact that the fall snow. In what ways to add a background? I want to insert a picture.</p> <p>Code : <a href="http://pastebin.com/8VGN5LX5" rel="nofollow">http://pastebin.com/8VGN5LX5</a> To Admins please paste here code. I got error "Oops! Your question couldn't be submitted because:</p> <pre><code>Your post does not have much context to explain the code sections; please explain your scenario more clearly. </code></pre> <p>"</p>
android
[4]
1,498,389
1,498,390
Returning pointer to wchar_t from function
<p>Why this code doesn't work?</p> <pre><code>wchar_t path[300]; wchar_t *PathCreator(wchar_t *dir, wchar_t *fileName) { int j = 0; while(j &lt; 300) { path[j] = '\0'; j++; } int i; i = 0; while(*dir != '*') { path[i] = *dir; i++; dir++; } wchar_t *t = fileName; while(*t != '\0') { path[i] = *t; i++; t++; } path[i] = '\0'; //std::wcout &lt;&lt; path &lt;&lt; std::endl; return path; } int _tmain(int argc, _TCHAR* argv[]) { std::wcout &lt;&lt; PathCreator(L"A",L"B"); } </code></pre>
c++
[6]
3,582,207
3,582,208
When I try calling the bubbleSort method within the class I get "itemsPriority can not be resolved to a type."
<p>As a part II to an assignment I must implement a sort method (I've chosen a bubbleSort) to sort an array of priorities from user input. In my previous part I program I accomplished this without a sort, by keeping track of what index the priority was assigned to. </p> <p>I've been trying to implement a bubblesort in my ShoppingList class with plans to call the sort from my GoShopping (main) class. However this does not seem to be working, most likely because I am very new to Java.</p> <p>When I try calling the bubbleSort method within the class I get itemsPriority can not be resolved to a type. I'm greatful for any advice.</p> <pre><code>public class ShoppingList public ShoppingList () { super(); } private int[] itemsPriority = new int[7]; public void pry(int itemsPry, int index) { itemsPriority[index] = itemsPry; } //run through the 2 arrays 7 times to give user their item and price public int getPriorityItem(int i) //getItemAtPriority { for(int j = 0; j&lt; 7;j++){ if(i == itemsPriority[j]){ return j; } } return -1; } public String getItemNameAtPriority(int i) { for(int j = 0; j&lt; 7;j++){ if(i == itemsPriority[j]){ return itemNames[j]; } } return null; } //set itemPriority to use for shopping public void setPriorityItem(int i, int PriorityItem) { this.itemsPriority[i] = PriorityItem; public int getitemsPriority(int i){ return itemsPriority[i]; } public void bubbleSort(int[]itemsPriority) { boolean swapped = true; int temp; while (swapped) { swapped = false; for (int i = 0; i &lt; itemsPriority.length - 1; i++) { if (itemsPriority[i] &gt; itemsPriority[i + 1]) { temp = itemsPriority[i]; itemsPriority[i] = itemsPriority[i + 1]; itemsPriority[i + 1] = temp; swapped = true; </code></pre>
java
[1]
4,904,611
4,904,612
Dynamically added links not working
<p>Im having problems trying to fire an event (alert) on my script. This is the html:</p> <pre><code>&lt;div class="dynamic-form"&gt; &lt;form&gt; &lt;div class="inputs"&gt;&lt;/div&gt; &lt;a href="#" id="add"&gt;ADD&lt;/a&gt; &lt;input name="submit" type="button" class="submit" value="Submit"&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>And the JS:</p> <pre><code>$(document).ready(function(){ var i = 1; $('#add').click(function() { $('&lt;div id="d' + i + '" class="fielddiv"&gt;&lt;input type="text" class="field" name="dynamic[]" value="' + i + '" /&gt;&lt;a href="#" id="remove_question"&gt;Cancella&lt;/a&gt;&lt;hr&gt;&lt;/div&gt;').fadeIn('slow').appendTo('.inputs'); i++; }); $('#remove_question').on("click", function(event) { alert('dsfsfd'); //$('#d' + $this.attr('todel')).remove(); }); // here's our click function for when the forms submitted $('.submit').click(function(){ var answers = []; $.each($('.field'), function() { answers.push($(this).val()); }); if(answers.length == 0) { answers = "none"; } alert(answers); return false; }); }); </code></pre> <p>The remove question on click function should fire an alert but is not doing anything, not even an error, what am i doing wrong? Here is a <a href="http://jsfiddle.net/Z6x8X/" rel="nofollow">jsfiddle</a> too.</p>
jquery
[5]
2,156,916
2,156,917
File not found error in Asp.net 4.0
<p>On Local host,my solution works fine but on server when i deploy ,it gives that file not found error. and the error message is something like this.<code>http://localhost:27375/favicon.ico</code> I don't have any such file in my application.I tried to create on in the root folder but no luck.any help is highly appreciated</p>
asp.net
[9]
3,537,924
3,537,925
JQuery scroll to top of page
<p>Is there a way to pro grammatically scroll to the top of a page with jQuery? I am currently trying to do this with the following code but it is not working. I am using Firefox currently,</p> <pre><code>$(window).scrollTop($(document).height()); </code></pre>
jquery
[5]
3,771,377
3,771,378
What is the proper usage of the menu.addIntentOptions()?
<p>I don't understand the correct usage of <code>menu.addIntentOptions()</code></p>
android
[4]
3,355,673
3,355,674
Issue with member of custom object
<p>I have a custom class</p> <pre><code>@interface XYZ : NSObject </code></pre> <p>{ int sum; .... }</p> <p>@property (nonatomic, assign) int sum; .....</p> <p>In my method, I initialize a new class as:</p> <pre><code>XYZ *myClass = [[XYZ alloc] init]; </code></pre> <p>Then in a for loop in that method, I assign the value of sum based on a condition:</p> <pre><code>if( ) </code></pre> <p>{ myClass.sum = val;</p> <p>NSLog(@"%d", myClass.sum); }</p> <p>The NSLog prints the correct value. (The value here is = 6)</p> <p>Now, once I am out of the for loop, I again print the value of sum using the same NSLog statement:</p> <pre><code>NSLog(@"%d", myClass.sum); </code></pre> <p>This time the value is 0. I never understood why. Thinking that the value was not retained, I even used the NSString and NSNumber data types but I have not had any success.</p> <p>Is it something very basic I am missing? Please advice.</p> <p>Thanks for any help in advance</p>
iphone
[8]
4,864,324
4,864,325
Reload file.js every minute
<p>I read (somewhere else on this site) you can't reload (or inject javascript) onto a page that is already rendered. Is there any other way of doing this. For instance an iFrame?</p> <p>I have a recent comment widget.js and I need to constantly get it to reload without reloading the whole page. </p> <p>Any ideas? </p> <p>edit: The site has recent comments on it and they are displayed via a recentcomment.js Once the page is loaded it doesn't update itself unless you reload the page. I want it to update itself, a way to do this is to just reload the js file on the page, correct? </p>
javascript
[3]
4,061,805
4,061,806
Cos(90) returning a value very close to 0, but I need 0?
<p>The values for temp_x_btm_left = 0 &amp; temp_y_btm_left=1;</p> <pre><code>angle = 90; //Moving the bottom left coordinates _btm_left.real() = (temp_x_btm_left * cos(angle*PI/180)) - (temp_y_btm_left * sin(angle*PI/180)); _btm_left.imag() = (temp_x_btm_left * sin(angle*PI/180)) + (temp_y_btm_left * cos(angle*PI/180)); </code></pre> <p>The code is supposed to rotate the object 90 degrees counter-clockwise, which it does but the <code>_btm_left.imag()</code> returns a value really close to 0 = 1.437949e-009, and I really need it being 0. </p> <p>I've tried <code>setprecision()</code> and <code>setw()</code> but it doesn't seem to have any effect. Are there any methods for anything like this or do I need to create my own to solve this?!</p>
c++
[6]
2,182,448
2,182,449
Decoding html to normal characters java
<p>I have socket stream which prints text to screen. If i have a string which should be "sælger" i receive "s&amp;AAOGlger" - My question is: Is there some kind of library that is able to decode the following piece of text so it becomes sælger.</p> <p>The characters i'm using most is the danish letters æøåÆØÅ</p> <p>Best regards </p>
java
[1]
355,709
355,710
how many characters can be sent using get in php
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request">maximum length of HTTP GET request?</a> </p> </blockquote> <p>how many characters can be sent using get in url in php.</p> <p>means what is the limitation to send data using GET method in php</p> <p>I am trying to send the dat like the following. But in the next page i am not getting all the data.</p> <p>xmlhttp2.open("GET","http://localhost/My_Project/LeaveLength_Ajax.php?_Get_FromDate="+FromDate_G+"&amp;_Get_ToDate="+ToDate_G+"&amp;PLAvailabe_JS="+PLAvailabe_JS +"&amp;CLAvailabe_JS="+CLAvailabe_JS +"&amp;LWPAvailabe_JS="+LWPAvailabe_JS+"&amp;MLAvailabe_JS ="+MLAvailabe_JS +"&amp;COMPAvailabe_JS="+COMPAvailabe_JS+"&amp;FromHomeAvailabe_JS="+FromHomeAvailabe_JS +"&amp;LeaveType_JS="+LeaveType_JS,true);</p> <p>Please help me to sort this problem.</p>
php
[2]
1,554,071
1,554,072
How to cache string data to sdcard?
<p>I want to cache json string to sdcard and retrive this cache data for future using. could anyone help me out</p>
android
[4]
278,418
278,419
Python - Read string from binary file
<p>I need to read up to the point of a certain string in a binary file, and then act on the bytes that follow. The string is <code>'colr'</code> (this is a JPEG 2000 file) and here is what I have so far:</p> <pre><code>from collections import deque f = open('my.jp2', 'rb') bytes = deque([], 4) while ''.join(map(chr, bytes)) != 'colr': bytes.appendleft(ord(f.read(1))) </code></pre> <p>if this works:</p> <pre><code>bytes = deque([0x63, 0x6F, 0x6C, 0x72], 4) print ''.join(map(chr, bytes)) </code></pre> <p>(returns 'colr'), I'm not sure why the test in my loop never evaluates to <code>True</code>. I wind up spinning - just hanging - I don't even get an exit when I've read through the whole file.</p>
python
[7]
1,613,154
1,613,155
Which class is executed first in Python?
<p>Is it proper practice to have all code within classes? I have one class that does all my calculating and whatnot. But I have all the rest of the code (mainly used to call the class) outside of a class. It looks like this.</p> <pre><code>class bigClass: executing here functions and whatnot blah blah b=bigClass() b.bigClassfunction() </code></pre> <p>My question is whether those last two lines should go in a class of their own? Or do I just leave them to float about not bound to a class.</p>
python
[7]
5,454,370
5,454,371
jQuery ajax() option - xhr
<p>In jQuery ajax function there is xhr option. Does someone know more details, usability or sample usage of this option?</p>
jquery
[5]
5,872,174
5,872,175
Android error: Unable to parse SDK content
<p>hi I used the following command</p> <pre><code> android -v list target </code></pre> <p>The following error appears:</p> <pre><code> Error: Error parsing the sdk. Error: androidcode/out/host/linux-x86/platforms is missing. Error: Unable to parse SDK content. </code></pre> <p>How can I resolve this?</p>
android
[4]
2,355,826
2,355,827
How is jQuery documentation generated
<p>I am looking at the <a href="http://dev.jquery.com/browser/tags/1.3.2" rel="nofollow">source code of jQuery in subversion</a> . What I would like to know is how jQuery docuemtation is generated since I do not see any documentation in the source code. Unlike Java/Ruby there is no documentation done when a method is defined. So where is the repository for the jQuery documentation in the svn ?</p> <p>I personally use <a href="http://view.jquery.com/trunk/tools/api-browser/" rel="nofollow">this</a> site to browse the jQuery methods. </p> <p>Please note that my question is not about how to get documentation. I am curious about how the documentation is generated and where is the repository for that. </p> <p>I would like to embed the documentation in a fun personal project and hence the question.</p>
jquery
[5]
5,707,696
5,707,697
CharacterPicker element - a case of NumberPicker
<p>I need to incorporate sliding/choosing though a set of letters. There's a DateTime component and not so commonly used NumberPicker but I haven't found anything for alphabet scrolling yet.</p> <p>Can you suggest any solution. I need exactly the same functionality as DateTime picker but just one column wide that can be populated with letters.</p> <p>p.s. I also need to slide through a set of numbers but I guess it's a particular case of CharacterPicker. Thanks.</p>
android
[4]
1,215,823
1,215,824
Class Inheritance Problem
<p>I have A.php and B.php</p> <p>A.php</p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set("display_errors",1); class myClass { function hello() { return 'hello'; } } ?&gt; </code></pre> <p>B.php</p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set("display_errors",1); require_once('/A.php'); $a = new myClass(); testing(); function testing() { echo $a -&gt;hello(); } ?&gt; </code></pre> <p>B.php inherits A.php , if i run B.php,but it show "Fatal error: Call to a member function hello() on a non-object."</p> <p>So the question is simple, how can i correct this ,but "$a = new myClass();" is not inside the function, since in .NET world can do this, i believe PHP also possible.</p> <p>And one more question is, what is the modify of function in A.php ,if i have not state private/public/protected?</p>
php
[2]
3,061,463
3,061,464
Catch event on the Flash particular file close
<p>I want to keep watch until the myfile.fla close not the Flash.exe<br> ie<br> I want to wait till the myfile.fla close not the Flash.exe<br> ie<br> How can I catch event of myfile.fla close not the Flash.exe<br> In c#</p> <pre><code>' Open the notepad application info.FileName = "Flash.exe" ' Pass a text file name so that notepad will open it info.Arguments = "c:\MyFile.fla" process.StartInfo = info ' Start the process (notepad) process.Start() </code></pre>
c#
[0]
2,366,245
2,366,246
ConnectException: operation timed out
<p>I have the following class that opens a socket connection to query a WHOIS server. Unfortunately, every time I run it (e.g. java WHOIS google.com) it always throws the exception:</p> <p><strong>Contacting the WHOIS server for 'google.com' at whois.internic.net:43 Exception in thread "main" java.net.ConnectException: Operation timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at java.net.Socket.(Socket.java:375) at java.net.Socket.(Socket.java:189) at WHOIS.performWhoisQuery(WHOIS.java:11) at WHOIS.main(WHOIS.java:28)</strong></p> <p>The problem seems connection timeout and i tried setting the timeout to a longer value (e.g. 5000) and it didn't work. Does it have to do with proxy and/or firewall? I got stuck whole day on it. </p> <pre><code>public class WHOIS{ public static void performWhoisQuery(String host, int port, String query) throws Exception { System.out.println(" Contacting the WHOIS server for '" + query + "' at " + host + ":" + port); Socket socket = new Socket(host, port); InputStreamReader isr = new InputStreamReader(socket.getInputStream()); BufferedReader br = new BufferedReader(isr); PrintWriter out = new PrintWriter(socket.getOutputStream(), true); out.println(query); String aLine = ""; while ((aLine = br.readLine()) != null) { System.out.println(aLine); } } public static void main(String[] args) throws Exception { String domainNameToCheck = args[0]; performWhoisQuery("whois.internic.net", 43, domainNameToCheck); } </code></pre> <p>}</p>
java
[1]
3,416,332
3,416,333
Are there any downsides to storing properties on Javascript arrays?
<p>I know that Javascript Arrays are actually objects, and because they are objects, they can have properties. Here's an example:</p> <pre><code>var a = [1, 2, 3]; a.currentIndex = 2; a.next = function() { ... }; a.prev = function() { ... }; a.length // returns 3 </code></pre> <p>To me this seems like it could come in very handy. I see numerous reasons why you might want to store state or utility functions on the actual array itself and not on some other variable. It even seems better than having the array as a property of an object with the other stuff stored on that object.</p> <p><strong>Here's my question:</strong></p> <p>Does anyone know of any issues with storing properties on a Javascript array? Does it work in all browsers? Is there any evidence that this will change with future versions of Javascript? Is there any general wisdom about whether or not it's a good practice?</p> <p>(p.s. For the record, I don't need to iterate over the array with a for...in loop. I understand that such a loop would include the properties as well)</p>
javascript
[3]
2,602,012
2,602,013
How to integrate this cacheBitmap method, with this image getter code?
<p>How would i go about integrating this cache method..</p> <pre><code>public void putBitmapInDiskCache(Uri url, Bitmap avatar) { File cacheDir = new File(this.getCacheDir(), "thumbnails"); File cacheFile = new File(cacheDir, ""+url.hashCode()); try { cacheFile.createNewFile(); FileOutputStream fos = new FileOutputStream(cacheFile); avatar.compress(CompressFormat.PNG, 100, fos); fos.flush(); fos.close(); } catch (Exception e) { Log.e("error", "Error when saving image to cache. ", e); } </code></pre> <p>With this code....</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(this.myContext); try { URL aURL = new URL(myRemoteImages[position]); URLConnection conn = aURL.openConnection(); conn.setUseCaches(true); conn.connect(); InputStream is = conn.getInputStream(); /* Buffered is always good for a performance plus. */ BufferedInputStream bis = new BufferedInputStream(is); /* Decode url-data to a bitmap. */ Bitmap bm = BitmapFactory.decodeStream(bis); bis.close(); is.close(); Log.v(imageUrl, "Retrieving image"); /* Apply the Bitmap to the ImageView that will be returned. */ i.setImageBitmap(bm); } </code></pre> <p>EDIT: Gives me a syntax error </p> <pre><code>The constructor File(File, int) is undefined Uri imageUri = new Uri(aURL); File cachePath = new File(new File(myContext.getCacheDir(), "thumbnails"), imageUri.hashCode()).exists(); if (new File(new File(myContext.getCacheDir(), "thumbnails"), imageUri.hashCode()).exists()) { } else { </code></pre> <p>EDIT2: Another syntax error</p> <pre><code>Cannot instantiate the type Uri Uri imageUri = new Uri(aURL); </code></pre>
android
[4]
4,091,464
4,091,465
how can I change the properties of DataGridViewImageCoulmn to be stretchImage (as pictureBox)?
<p>how can I change the properties of DataGridViewImageCoulmn to be stretchImage (as pictureBox)? </p> <p>in my DataGridView- have a DataGridViewImageCoulmn, I add it image of different sizes, it is changing the row height. I want to set a fixed height of the image and of the line</p>
c#
[0]
190,184
190,185
Searching for array of needle values with strpos()
<p>I'm trying to use strpos to search for some key words in a string using PHP. My question is how would I go about adding a array so I search for "keyword1" and "keyword2" to the code below.</p> <pre><code>if (strpos($string,'keyword1') !== false) { $hasstring = "yes"; } </code></pre> <p>Thanks</p>
php
[2]
4,861,271
4,861,272
Question over Json sorting
<blockquote> <p><a href="http://www.devcurry.com/2010/05/sorting-json-array.html" rel="nofollow">http://www.devcurry.com/2010/05/sorting-json-array.html</a></p> </blockquote> <p>I came across this article, i want few explantions over this article. </p> <pre><code> function SortByName(x,y) { return ((x.Name == y.Name) ? 0 : ((x.Name &gt; y.Name) ? 1 : -1 )); } arr.sort(SortByName); </code></pre> <ol> <li><p>What would be the arguements for arr.sort(x,y). What will be passed to the function from the JSON Object. </p></li> <li><p>What does the SortByName function return. I don't understand the entire line. can anyone give me more details over this.</p></li> </ol>
javascript
[3]
2,564,005
2,564,006
Jquery very slow in IE
<p>could anyoone help me and tell why my superfish and slide menu are very slow in IE 6/7 and fast as hell in FF?</p> <p>I think is because of jquery used in template. Template was prucased from template monster (32021) and I just changed pictures and links. </p> <p>Site address is <a href="http://www.blb-invest.com" rel="nofollow">http://www.blb-invest.com</a></p> <p>Thanks in advance Darko</p>
jquery
[5]
4,338,987
4,338,988
What are the differences between g++ version 4.0.0.8 and 4.3.2?
<p>What's the difference between g++ 4.0.0.8 and g++ 4.3.2? These two are the most common C++ compilers that I have seen used in various programming competitions.</p> <p>I tried to google it, but found nothing.</p>
c++
[6]
14,928
14,929
Android List Activity with dynamically loaded images form the web in android
<p>I give description of My project</p> <p>In my project In the first section i have parsed the xml data of Video categories and image url links from My web service.I have parsed that data and receive that data in <code>ArrayList</code> in My main activity.The first <code>ArrayList</code> is the list of video categories and the second <code>ArrayList</code> is the the list of video image urls and i have to display <code>ArrayList</code> of image urls as <code>ImageView</code> in <code>ListView</code> ,i have no idea for that,please give me some solution.</p>
android
[4]
4,496,035
4,496,036
Android scientific calculator
<p>I am new so please be patient with me. What I want is to build an advanced calculator for android. I need to convert a string variable (ex. "3+5^8") into a math equation.. I am looking for something like the eval() function for excel. </p>
android
[4]
2,392,096
2,392,097
Add a class dependent on number of selected option
<p>I have a select-box used a lot of times on a page.</p> <pre><code>&lt;div class="some-div"&gt; &lt;a class="maybe"&gt;Maybe&lt;/a&gt; &lt;select class="selectclass"&gt; &lt;option&gt;Maybe&lt;/option&gt; &lt;option&gt;Yes&lt;/option&gt; &lt;option&gt;No&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <p>How could I using jQuery add a class to 'a' element dependent on the number of the selected option? The class must be taken not from the value because the site is multilingual, but from the number of the option: 'maybe' for 1st, 'yes' for 2nd and 'no' for the 3rd. The select is used many times on the page so it should apply only for the one which is in action. </p> <p>Thanks in advance! </p>
jquery
[5]
5,697,829
5,697,830
Connecting to a database in visual studio 2010 using c# credentials
<p>I'm pretty new to c# asp.net etc so bear with me :) I've been looking on the internet for the right syntax so I can connect to my database which is on my computer.</p> <p>I've tried this:</p> <pre><code> SqlConnection myConnection = new SqlConnection("server=localhost;" + "Trusted_Connection=yes;" + "database=mmcinfo.mdf;"); </code></pre> <p>But i get an error on the myConnection.Open(); saying:</p> <blockquote> <p>SqlException was unhandled by user code A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)</p> </blockquote> <p>I know im doing something wrong in calling the right database/server etc but i havent got a clue how to fix this.</p>
asp.net
[9]
5,047,638
5,047,639
php global variables with variable names
<p>I am trying to have a function that among other things declares global variables based on a variable that i give it. the part that fails is making the variables global</p> <pre><code>function setGlobalVariable($name) { global $name, $arrayname_{$name}; } </code></pre> <p>any idea? thanks :)</p>
php
[2]
5,201,473
5,201,474
Multiple #define within #ifdef or #ifndef
<p>This is a simple question, but I have not ran across similar code before to know the answer. Basically, am I allowed to have more than two #define in an #ifdef or #ifndef statement? For a basic example:</p> <pre><code> #ifdef __GNUC__ #define HELLO(x) x #define WORLD(y) y #else #define __attribute__(x) #define expect(expression, value) (expression) #endif </code></pre> <p>Thank you</p>
c++
[6]
5,173,968
5,173,969
Unable to restore stdout to original (only to terminal)
<p>I need to output all my print statements to both terminal and file. I've found a solution in <a href="http://stackoverflow.com/questions/616645/how-do-i-duplicate-sys-stdout-to-a-log-file-in-python">this stackoverflow question</a> So i use </p> <pre><code>class Tee(object): def __init__(self, name): self.file = open(name, "a") self.stdout = sys.stdout sys.stdout = self def __del__(self): sys.stdout = self.stdout self.file.close() def write(self, data): self.file.write(data) self.stdout.write(data) sys.stdout = Tee("log.txt") </code></pre> <p>That's works great , </p> <p>My problem is when i want to stop writing to file and go back to normal operation that's print only to terminal<br> I tried to use del(sys.stdout) to invoke the <strong>del</strong> method with no luck.<br> i even tried to change the last line to:</p> <pre><code> multiple_print = Tee("log.txt") sys.stdout = multiple_print </code></pre> <p>and than use del(multiple_print) and failed</p> <p>No matter what i tried , further uses of <em>print</em> still written to terminal and file both.</p> <p>Any ideas?</p>
python
[7]
4,744,535
4,744,536
why no color output with Python?
<p>I have a batch file which calls .Net solution to build the project. On the dos console window, the warning and error will be in different color, green and red, looks nice. When the batch file called from Python, no color at all, all in a single color. Is it possible to get the same colorful result with python? my call to the batch file is like this: </p> <pre><code>p = subprocess.Popen('manualBuild.bat', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) for line in p.stdout.readlines(): print line, retval = p.wait() </code></pre> <p>thanks</p>
python
[7]
1,121,118
1,121,119
Add an item from listview to favourite list
<p>i'm looking for a good idea to make a fav list of a listview. the ListView is parsed from website server. I added new star image and once it clicked it change to yellow color as "favourited item", what i want is an idea of how to save this clicked item to a favourites list ... what i have think of yet is to make local xml file and add each item i click on to this xml and parse it in the favourites list activity, does it look as a good idea ? or there's a better way to do it ! thanks</p>
android
[4]
1,105,910
1,105,911
How can I programmatically close all other applications from my iPhone application?
<p>Is it possible to programmatically close all running applications on the iPhone except my own from within my own application? If so, how?</p>
iphone
[8]
3,335,865
3,335,866
preg_match and preg_replace for youtube url
<p>i have this code </p> <pre><code>preg_match_all('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&amp;]v=)|youtu\.be/)([^"&amp;?/ ]{11})%i', $asd, $match); </code></pre> <p>to find youtube key of urls like </p> <pre><code>&lt;a href="http://www.youtube.com/watch?v="&gt;http://www.youtube.com/watch?v=ZiJRPREeQ1Q&lt;/a&gt; &lt;br /&gt; &lt;a href="http://www.youtube.com/watch?v=GaEZgqxPHLs&amp;feature=related"&gt;http://www.youtube.com/watch?v=GaEZgqxPHLs&amp;feature=related&lt;/a&gt; </code></pre> <p>this work good to find the code ZiJRPREeQ1Q and GaEZgqxPHLs , now i want to replace all the html line with a new code </p> <p>wanna to use </p> <pre><code>preg_replace </code></pre> <p>to find the whole youtube url </p> <pre><code>&lt;a href="*"&gt;*&lt;/a&gt; </code></pre> <p>to a new code how can i do that ?</p> <p>--------------adds--------------</p> <p>after i get the code of youtube from url by preg_math_all i used this code to extract the codes </p> <pre><code>foreach($match[1] as $youtube){ // $youtube; // this handle the youtube code $match = ""; // what can i write here relative to $youtube ? $str .= preg_replace($match, 'new code',$content); // $content handle the whole thread that contain the youtube url &lt;a href=*&gt;*&lt;/a&gt; } </code></pre> <p>the only thing that i need that what's regular expression that i can use to replace youtube code </p>
php
[2]
6,010,922
6,010,923
eclipse - stuck with chinese in android virtual device
<p>When I run my android emulator in eclipse, all my keyboard characters gets translated to chinese when I try to write text. Why is this?</p> <p>Thanks</p>
android
[4]
4,100,457
4,100,458
random shuffle operation
<p>i have following code</p> <pre><code>#include &lt;iostream&gt; #include &lt;cstdlib&gt; using namespace std; int main() { int a[] = {2, 1, 4, 3, 5, 6, 7, 9, 8, 10, 11}; int n = sizeof(a) / sizeof(int); int k=0; for (int i = 0; i &lt; n; i++) { k = i + rand() % (n-1-i); int s = a[i]; a[i] = a[k]; a[k] = s; } for (int i = 0; i &lt; n; i++) { cout &lt;&lt; a[i] &lt;&lt; " " &lt;&lt; endl; } return 0; } </code></pre> <p>but it gives me runtime error,i know there is a lot of method in internet ,just i choose such simple for exam preparation in university,please help me what is wrong?</p>
c++
[6]
3,779,264
3,779,265
How to disable a TextView
<p>Is there any command i can use in activity class that disables TextViews that are created in xml file? i want to put that in an if clause like:</p> <pre><code>if (something ==null){ TextView.dontcreate(); } else { TextView.setText("Hello"); } </code></pre>
android
[4]
1,613,358
1,613,359
Sorting headers for Data Columns
<p>For the data obtained from data set, how to design Sorting headers for Data Columns in grid view in asp.net?</p> <p>Thank You.</p>
asp.net
[9]
5,096,391
5,096,392
jquery Add and Remove Classes?
<p>I need a script that adds a 2 to the end of a class in a div with the id .sideboxtopleft on clicking of a link with the id of posts.</p> <pre><code>&lt;script&gt; $(".posts").click(function () { if ($('.sideboxtopleft').is('#sideboxtopleft2')) { $('.sideboxtopleft').removeClass('2'); } else{ $('.sideboxtopleft').addClass('2'); } }); &lt;/script&gt; &lt;div id="sideboxtopleft" class="sideboxtopleft"&gt; &lt;a href="#post" id="posts"&gt;&lt;h3&gt;RECENT POSTS &lt;div id="arrow" class="arrow"&gt;&lt;/div&gt;&lt;/h3&gt;&lt;/a&gt; &lt;/div&gt; &lt;div id="sideboxtopright" class="sideboxtopright"&gt; &lt;a href="#comments" id="comments"&gt;&lt;h3&gt;RECENT COMMENTS &lt;div id="arrow" class="arrow2"&gt;&lt;/div&gt;&lt;/h3&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>However it doesn't seem to want to work properly. Any help?</p>
jquery
[5]
1,032,176
1,032,177
Python not returning expected value when comparing files
<p>I am trying to build this script to check if a file on a remote server contains a set suffix, IE .ok, .err, .log. I can't figure out why I am getting the return that I am <code>"('\\\\THPNWSS5\\d$\\DA$Utils\\log\\networker', [], ['P3EWS.err']) nothing is equal</code>"<br/> I know there is something wrong with my try statement but I can't see it. </p> <pre><code> chkbkpstats = csv.reader(file('c://temp//networkerservers1.csv')) srvrs = [] for row in chkbkpstats: srvrs.append({'Name' : row[0], 'Instance' : row[1]}) for srvr in srvrs: srvrName = (srvr['Name']) srvrInst = (srvr['Instance']) w2k3chk = r'\\%s\d$\DA$Utils\log\networker' % srvrName w2k8chk = r'\\%s\c$\ProgramData\folder\DA$Utils\log\networker' % srvrName try: c = wmi.WMI(srvr['Name']) except: print 'Error connecting to %s to check OS version' % srvrName else: osVer = c.Win32_OperatingSystem()[0].Caption if '2003' in osVer: for file in os.walk(w2k3chk): print file try: if srvrInst == srvrInst + ".log": print 'The Backup for %s on %s still running' % (srvrInst, srvrName) if srvrInst == (srvrInst + ".ok"): print 'Completed Successfully' if srvrInst == (srvrInst + ".err"): print 'Backup failed' except: print 'nothing is equal' #print '%s is w2k3' % srvr['Name'] elif '2008' in osVer: print '%s is w2k8' % srvr['Name'] </code></pre>
python
[7]
5,587,798
5,587,799
Java se "occurred during initialization of VM"
<p>I installed jdk se 32bit on windows 7 x64. At "http://www.oracle.com/technetwork/java/javase/downloads/index.html" for windows.</p> <p>And I got this error message.</p> <blockquote> <p>C:\Users\Administrator>javac -version Error occurred during initialization of VM java.lang.ClassNotFoundException: error in opening JAR file d:\Program Files (x8 6)\prg_java\jdk1.6.0_26\jre\lib\rt.jar at java.security.AccessControlContext.(AccessControlContext.java :77) at java.security.AccessController.getStackAccessControlContext(Native Me thod) at java.security.AccessController.getContext(AccessController.java:484) at java.lang.Thread.init(Thread.java:358) at java.lang.Thread.(Thread.java:476)</p> <p>java.lang.ClassNotFoundException: error in opening JAR file jdk1.6.0_26\jre\lib\rt.jar</p> </blockquote> <p>How can I solve this problem?</p> <p>Thanks in advance.</p>
java
[1]
4,156,741
4,156,742
How to handle required default constructor
<p>In writing a copy constructor for one of my classes ( which holds a few objects of other UDTs ), I am required to create a default constructor for those UDTs, even though they were never really meant to have one.</p> <p>Is it fine to just implement a blank default constructor and be done with it? The only time the default constructor is invoked is during this copying, when the object is created and then the values of the corresponding object are copied to it. Thus, whatever values are assigned to the object in the default constructor will never actually be used.</p> <p>The problem I see is that some member variables aren't initialized in a blank default constructor. Should I just write one that gives dummy values instead? Any other recommended ways to handle this?</p> <p>Edit: I understand that a copy constructor doesn't NEED a default constructor if I were to define copy constructors for the other classes, but I didn't, so it does need it. </p>
c++
[6]
1,860,859
1,860,860
Android: creating a multidimensional array for a ListView Adapter
<p>Here is what I have now:</p> <pre><code>private Object mainArray[] = {R.drawable.main_logo, "page_4"}; private Object studioArray[] = {R.drawable.studio_logo, "page_5"}; private Object gArray[] = {R.drawable.g_logo, "page_6"}; private Object venues[] = {mainArray,studioArray,gArray}; </code></pre> <p>I pass the venues array object to my adapter, however I can't get the size of the object: venues.size(); Is there a better way of doing this?</p>
android
[4]
1,404,455
1,404,456
How to replace one string with another in whole application in android?
<p>I have to change one text with another when user select option from settings,For example I have to change Kilometers in to miles when user select it from option. And When i select it i have to change kilometer into Miles thought the application , Please help me if anyone knows how to do it? </p>
android
[4]
1,990,125
1,990,126
jquery: fill in text box (min of 5 characters) and will tick checkbox
<p>I have a checkbox which i would like to check if the user fills in the text box that follows it. This must be a min of 5 characters for it to check the checkbox.</p> <pre><code>&lt;input type="checkbox" id="olt3" name="olt3" &lt;?php if (!empty($mychecklist-&gt;pro)) echo 'checked' ?&gt;&gt; &lt;input type="text" id="pro" name="pro" value="&lt;?php echo $mychecklist-&gt;pro?&gt;"&gt;Please supply your ID </code></pre> <p>thanks in advance for any help.</p>
jquery
[5]
5,770,603
5,770,604
php quoting problem
<p>I have this PHP code</p> <pre><code>echo '&lt;a href="#" onclick="updateByQuery(\'Layer3\', ' . json_encode($query) . ');"&gt;Link 1&lt;/a&gt;'; </code></pre> <p>which generates a link like this:</p> <pre><code>&lt;a href="#" onclick="updateByQuery('Layer3', "Ed Hardy");"&gt;Link 1&lt;/a&gt;&lt;li&gt;Link 2&lt;/li&gt; </code></pre> <p>Causing the javascript to not be called. How would I make it generate single quotes around the result of $query, in this case ed hardy?</p>
php
[2]
4,438,247
4,438,248
How to Align div's horizontally such as text within gets ellipsed
<p>I have 2 div's which have some text in them. They are encapsulated within a parent Div which has fixed height and width. I want to ellipse the text if they overflow outside the parent div.</p> <p>Here is my HTML</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; .pDiv { width:50px; height:20px; border: 1px solid red; overflow: hidden; text-overflow: ellipsis; } .div1 { position: relative; float: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .div2 { position: relative; float: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class ='pDiv'&gt; &lt;div class ='div1'&gt;test testing&lt;/div&gt; &lt;div class ='div2'&gt;test1&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I want the text to be ellipsed if either the div1 text is long or the div2 text is long.</p> <p>Any solutions?</p>
javascript
[3]
1,445,735
1,445,736
Best way to send data to aspx page in ASP.NET 2.0/3.5?
<p>Which is Best way to send data to aspx page, and <strong>why</strong>?</p> <ul> <li>using query string</li> <li>using session</li> <li>using cross page postback </li> <li>Something else</li> </ul> <p>Thanks.</p> <hr> <blockquote> <p>What are you trying to achieve? More info. please</p> </blockquote> <p>For example search form and advanced search form or multi step user registration.</p>
asp.net
[9]
4,304,790
4,304,791
Huffman Decompression retrieving tree
<p>Just doing the last bit of my project and am completely stumped, unsure as of how to retrieve the tree to do the decompression after compressing a file? Thanks in advance!</p> <p>EDIT terribly sorry, here's my code: <a href="http://pastebin.com/SHkvTy0s" rel="nofollow">http://pastebin.com/SHkvTy0s</a></p> <p>and also updated the original question, thanks!</p>
java
[1]
5,939,279
5,939,280
Getting the scrollbar height of a browser
<p>Is their any javascript code to get the scroll height. I mean the scroll bar is how far from the top. Please help me thanks in advance</p>
javascript
[3]
160,081
160,082
Changing multiple control properties at once
<p>I'm needing to change a bunch of properties in a large amount of controls. I'm having trouble getting it to work. Am I on the right track?</p> <pre><code>foreach(var c in this.Controls.OfType&lt;Label&gt;()) { c.Text = "test"; } </code></pre> <p>What's happening is var c is just creating a new object and not editing the existing one. How can I access the real control?</p>
c#
[0]
4,029,479
4,029,480
Unable to add options in a listbox using JQuery in IE however works fine in firefox
<p>I have a small JQuery code to Populate/Filter a list box based on a drop down value. However its working fine in Firefox but throws invalid argument error when adding option to list box at following line of code in IE9.</p> <pre><code>catvalues.add(el); </code></pre> <p>here is the complete code:</p> <pre><code>var names = $('#names'); $('select[title="Category possible values"] &gt; option').appendTo('#names'); var catvalues =$('select[title="Category possible values"]')[0]; $('select[title="ProductName"]').change(function() { var val = $(this).children("option:selected").text(); $('select[title="Category possible values"]').empty(); var opts=names.clone(); opts.children().each(function(idx, el) { if (el.text.indexOf(val) &gt;= 0) { catvalues.add(el); } }); }); </code></pre>
jquery
[5]
843,715
843,716
Android Trying to make scratch away game
<p>I'm trying to make a game that will have a black screen, when you swipe the screen, the black portion you touch will disappear and show a image behind it. The object is to keeping swiping until you can guess what the image is.</p> <p>I have seen other apps that do this. I'm stuck on how to do it. My idear was to modify a bitmap by changing the pixcels to see through. But I don't see any way of getting access to the bitmaps memory, or maybe there is another way to do this????</p>
android
[4]
4,998,432
4,998,433
Java Performing Actions on a Website
<p>Yesterday I posted this <a href="http://stackoverflow.com/questions/15103944/retrieving-data-in-java">Retrieving Data in Java</a> . I'm curious it is possible to make a java program run while a web browser is open and then have it do stuff on a website. If I have facebook open on a browser, could it type the current time in the status box and then click post? Or let's say I make the program able to take input from the user (perhaps using scanner?) and then based on the input, it could load google, type it into the search bar and then click search.</p>
java
[1]
879,542
879,543
Solving a random maze recursively
<p>I'm trying to solve a randomly generated maze in Java using recursion. What makes my situation different from others on this site is that I'm using bitwise operations to move through the maze rather than cells in a grid. When an area is clicked on the maze, my program should display a red path to the end. I cannot find out how to mark my tracks on a path in order to backtrack.</p> <p>I'm using a method searchMaze(int row, int col, byte d) in order to move through the maze in my Main class: <a href="http://pastie.org/3515632" rel="nofollow">http://pastie.org/3515632</a></p> <p>Here are the other sources I'm using for maze generation/path handling: <a href="http://pastie.org/3515624" rel="nofollow">http://pastie.org/3515624</a> http://pastie.org/3515627</p> <p>How could I go about incorporating a backtracking function into my code?</p>
java
[1]
1,347,103
1,347,104
Hyperlink for textview in android
<p>I want to create a hyperlink to textview in android. So in my layout I have given <code>android:clickable="true"</code> to the textview. Previously it worked for my other layouts. But now it is not working. When I am clicking on the textview it remained as it is.What may be the problem? Please help me.</p>
android
[4]
3,451,686
3,451,687
Input-Tag Feature-Detection in JQuery
<p>Could somebody explain exactly how this feature detection is working?</p> <pre><code>// Create a dummy element for feature detection if (!('placeholder' in $('&lt;input&gt;')[0])) { </code></pre> <p>This line of code detects whether or not the browser supports the placeholder attribute on input elements.</p> <p>I'd like to be a bit more comfortable with what is going on under the hood here before deploying to production.</p> <p>Will this end up cycling through all possible attributes of the input element, just to check for the existence of a <code>placeholder</code> element? If this is the case, I was not aware that we get access (in some fashion) to elements that aren't spelled out explicitly in the markup.</p> <p><a href="http://www.jacklmoore.com/notes/form-placeholder-text" rel="nofollow">Code Source</a></p>
jquery
[5]
1,601,671
1,601,672
Android - A way to trigger onRetainNonConfigurationInstance?
<p>Is there a way to trigger the calling of onRetainNonConfigurationInstance on my activity, so getLastNonConfigurationInstance() returns something the next time the activity is created?</p> <p>I ask because I have a memory leak in my application which only appears/crashes my app after my phone is left idle for hours, so I believe the issue is here.</p> <p>Force Stop in Settings does not cause this. Any help would be greatly appreciated as i've spent days chasing red herrings to catch this bug.</p>
android
[4]
2,760,458
2,760,459
how to check request come from parent window for child window
<p>Please help I have develop two web pages.I want to check for open the child window. that come from parent window or direcltly copy paste the url of the page in javascript.</p>
javascript
[3]
4,664,564
4,664,565
How to combine OnClickListener and OnTouchListener for an ImageButton
<p>I need to do something when the user presses the <code>imageButton</code> I've tried to create a static class that implements <strong>both</strong> <code>OnClickListener</code> and <code>OnTouchListener</code></p> <pre><code>static class ClickListenerForScrolling implements OnClickListener, OnTouchListener </code></pre> <p>That has the following methods:</p> <pre><code> @Override public void onClick(View v) </code></pre> <p>and </p> <pre><code>@Override public boolean onTouch(View arg0, MotionEvent arg1) </code></pre> <p>The whole idea behind this is to change the image source of the <code>ImageButton</code> when the user touches it, and perform a task when the user presses this button. Can anybody give me a hint on how to do so? </p>
android
[4]
5,882,528
5,882,529
java string immutable confusion
<p>If java strings are immutable then how can we write as:</p> <pre><code>class str{ public static void main(){ String s = new String(); s = s+"abc"; } } </code></pre>
java
[1]
5,189,700
5,189,701
killProcess can be used in some cases?
<p>I have a logout button in my activity. In my case the killProcess do what I want to do instead of the finish(), but is it a good idea to use killProcess? I have read that is better not to use killProcess but in some cases seems to be useful. </p>
android
[4]
3,954,658
3,954,659
Life Scope of Temporary Variable
<pre><code>#include &lt;cstdio&gt; #include &lt;string&gt; void fun(const char* c) { printf("--&gt; %s\n", c); } std::string get() { std::string str = "Hello World"; return str; } int main() { const char *cc = get().c_str(); // cc is not valid at this point. As it is pointing to // temporary string internal buffer, and the temporary string // has already been destroyed at this point. fun(cc); // But I am surprise this call will yield valid result. // It seems that the returned temporary string is valid within // scope (...) // What my understanding is, scope means {...} // Is this valid behavior guarantee by C++ standard? Or it depends // on your compiler vendor implementations? fun(get().c_str()); getchar(); } </code></pre> <p>The output is :</p> <pre><code>--&gt; --&gt; Hello World </code></pre> <p>Hello, may I know the correct behavior is guarantee by C++ standard, or it depends on your compiler vendor implementations? I have tested this under VC2008 and VC6. Works fine for both.</p>
c++
[6]
704,618
704,619
Beginner array problem, extracting items from a 2D array to list and manipulate
<p>I am learning arrays in PHP and would like to know how to do something like extracting and calculating items in a multidimensional array, for a small receipt exercise I am attempting: </p> <pre><code>$products = array('Textbook' =&gt; array('price' =&gt; 35.99, 'tax' =&gt; 0.08), 'Notebook' =&gt; array('price' =&gt; 5.99, 'tax' =&gt; 0.08), 'Snack' =&gt; array('price' =&gt; 0.99, 'tax' =&gt; 0) ); </code></pre> <p>My trouble is finding out how to list the items separately in order to print or calculate (for example, multiplying an item by it's sales tax), to display as a receipt. I know my HTML and CSS, I know how to do basic calculations within PHP, but looping through a multidimensional array has gotten me stuck. Thank you very much for any tips. </p>
php
[2]
4,578,610
4,578,611
IComparable Interface
<pre><code>using System; using System.Collections; public class Temperature : IComparable { // The temperature value protected double temperatureF; public int CompareTo(object obj) { Temperature otherTemperature = obj as Temperature; if (otherTemperature != null) return this.temperatureF.CompareTo(otherTemperature.temperatureF); else throw new ArgumentException("Object is not a Temperature"); } public double Fahrenheit { get { return this.temperatureF; } set { this.temperatureF = value; } } public double Celsius { get { return (this.temperatureF - 32) * (5.0/9); } set { this.temperatureF = (value * 9.0/5) + 32; } } } public class CompareTemperatures { public static void Main() { ArrayList temperatures = new ArrayList(); // Initialize random number generator. Random rnd = new Random(); // Generate 10 temperatures between 0 and 100 randomly. for (int ctr = 1; ctr &lt;= 10; ctr++) { int degrees = rnd.Next(0, 100); Temperature temp = new Temperature(); temp.Fahrenheit = degrees; temperatures.Add(temp); } // Sort ArrayList. temperatures.Sort(); foreach (Temperature temp in temperatures) Console.WriteLine(temp.Fahrenheit); } } </code></pre> <p>This is an example i have taken from MSDN. In the above example , in the compareTo( this.TemperatureF.CompareTo(otherTemperature.temperatureF) is used so how the comparsion is done by sort function() of the arraylist. Who provides the other reference object(this) for the comparsion?</p>
c#
[0]
1,337,257
1,337,258
I need to create a user defined alerts feature. How does one design a flexible class for alerting?
<p>I'm working on a project where the user will create an alert. As a narrative, the alerts can be like, "Did enough records get imported?", "Are the records getting processed fast enough?" "Are too many records being skipped?", etc. The "etc." is making this hard. This is a prototype project. There aren't many requirements. I can create specific classes for various alerts, but if I could come up with a more abstract concept that will allow users to define an alert without requiring too much technical knowledge, that would be ideal. I was kind of thinking of something like Outlook's Rules wizard (configurable lists of conditions and user defined values). Does anyone have experience with such a system? I just need a best practice or good suggestion to get me rolling down the right path. Thanks!</p>
c#
[0]
5,377,924
5,377,925
how can create files and how to implement code for read content into file and write content into file
<p>hi all how to implement code for Write content into a file &amp; read content from file and how create files and how can to enter text in it to write and read files </p> <p>help me any one of you</p>
android
[4]
5,390,289
5,390,290
Jquery - Toggle all slides on click event
<p>Using jquery I have the function below. When the button is clicked it slides a div underneath that button, however there are multiple buttons on the page and if they click one button I want to make sure if any other buttons were clicked their div toggles back to sliding up so only one div is showing at any given time when a button is clicked. Any suggestions?</p> <pre><code>$('.ftable').delegate('.button.green.table','click',function() { ftableid = $(this).attr('title'); $("#formtable" + ftableid).slideToggle("fast", function() { //code here }); return false; }); </code></pre>
jquery
[5]
254,901
254,902
iPhone:Mapview move pin issue
<p>I have Mapview and I successfully plot all pins on map and when I select a pin also add one button which is rightCalloutAccessoryView and when I click on button at that time I want to move all pins and selected pin display in center of mapview so please give me idea to develop this functionality..</p> <p>Sorry for bad English.</p> <p>Thanks in advance.</p>
iphone
[8]
1,635,693
1,635,694
jQuery: how to replace content without affecting children
<p>I want to replace tag with tag, but not replacing all the children elements (just the parent). How to do it with jQuery ?</p> <p>thanks</p>
jquery
[5]
2,279,745
2,279,746
How to find out the previously selected navigation link in jQuery?
<p>I have a navigation set up using ULs, LIs, and As. The hightlighted/selected tab's anchor has a class of selected. When a new nav link is clicked, how can I find out what the ID of the previously selected anchor's tab is?</p>
jquery
[5]
4,124,443
4,124,444
Is there a wildcard class selector
<p>If i have a few classes named something similar is there a way to grab them all in one shot</p> <pre><code>#instance1 #instance2 #instance3 #instance4 ("#instance").click(function() //GRAB ALL OF THEM </code></pre>
jquery
[5]
202,880
202,881
Android: Detect when another Activity is launched (or your activity loses focus)
<p>Like the title says, I need to detect when my app loses focus because another app is launched (Phone call comes in, or user hits Home etc).</p> <p>Overriding Activity.OnStop does not work because that is called even when switching activities within my app.</p>
android
[4]
4,463,198
4,463,199
PHP value doesn't equal to what it echoes
<p>I got a value in <code>$array[1]</code> and I want to know what it is, so I can compare it in other parts of my code.</p> <p>So I echo out $array[1] and I get "vrij &amp;nbsp &amp;nbsp " or "vrij "</p> <pre><code>$value = $array[1]; echo $value ; // outputs "vrij " if($value = $array[1]){ echo "TRUE 1"; } if($value = "vrij "){ echo "TRUE 2"; } </code></pre> <p>The problem is, it only echo's TRUE 1. I copy pasted the echo exactly but it doesn't return TRUE 2</p>
php
[2]
163,494
163,495
Invoke Android Oficial Home by Application set as home
<p>In my android project, has a tag in the manifest, which allows the user to mark it as default. Whenever the home button is pressed, my application is called, always... I wanted to put a button in my application to call the home of the official Android. Not my application as default. How to do this?</p> <p>Any ideas? </p> <p>Thanks! </p>
android
[4]
5,125,232
5,125,233
Validating via regular expressions
<p>I am validating a web page via a javascript function using regular expressions. Here is my variable:</p> <pre><code>var RE_phone = /^[\d\+]{3,4}([\- ]?)\d{1,3}([\- ]?)\d{3}([\- ]?)\d{4}$/; </code></pre> <p>I need to validate both national and international numbers. So far it is working correctly for international numbers.</p> <p>Here is an example of a national number that I would like to be able to accept as a valid number: 04 4784897 or 044784897.</p> <p>Can I please have some help to modify my regular expression variable to accept national phone numbers in the above format?</p>
javascript
[3]