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
72,862
72,863
Displaying CSS properties and values of a HtmlControl
<p>I have a <code>&lt;div id="Result" ... &gt;</code> with a bunch of CSS properties and values and I would like to display them when I click a button. This is what I currently have:</p> <pre class="lang-cs prettyprint-override"><code>protected void Button1_OnServerClick(object sender, EventArgs e) { for (int i = 0; i &lt; Result.Style.Value.Length; i++) { Result.InnerHtml += Result.Style.Value[i]; } } </code></pre> <p>The code does display them, however, they are all displayed in a sequence of characters. I would like to get them displayed as properties and values, both with different accessing variable and all pairs on seperate row.</p> <p>I messed with it for a good while but I can not figure it out.</p>
asp.net
[9]
5,341,363
5,341,364
How to return person with max sales in salesperson program- JAVA
<p>Kind of confused by one part of my HW problem. It seems like it would be easy, but I can't put my finger on it. I am trying to return the salesperson with the max and min sales. I am confused on how to do that. Help would be much appreciated.</p> <pre><code>import java.util.Scanner; public class Cray { public static void main(String[] args){ final int SALESPEOPLE = 5; int[] sales = new int[SALESPEOPLE]; int sum, maxperson, minperson; int max = sales[0]; int min = sales[0]; Scanner scan = new Scanner(System.in); //Fill the 5 element array of sales with the user's input for (int i=0; i&lt;sales.length; i++) { System.out.print("Enter sales for salesperson " + i + ": "); sales[i] = scan.nextInt(); //Calculate the max and min sales //How do I return the salesperson i with the the max and min sales? if(sales[i] &gt; max){ max= sales[i]; } if(sales[i] &lt; min){ min = sales [i]; } } System.out.println("\nSalesperson Sales"); System.out.println("--------------------"); sum = 0; for (int i=0; i&lt;sales.length; i++) { System.out.println(" " + i + " " + sales[i]); sum += sales[i]; } System.out.println("\nTotal sales: " + sum); System.out.println("Average sales: " + sum/5); //WHere I want to print the max salesperson. System.out.println("Salesperson" + ); } } </code></pre>
java
[1]
3,535,602
3,535,603
Converting codes written in Python 2 to Python 3
<p>I'm given a task of converting a bunch of codes written in Python 2.7 into Python 3. So my question is What are the fundamental differences between the two and what are the new features expected from conversion? I'm assuming it's not just syntactical issues. Where should I start and what should I focus on? It'll be more helpful if you could be as concrete as possible.. Please help me out and thank you in advance</p>
python
[7]
1,040,410
1,040,411
Can anyone show me how to display this in normal xhtml?
<pre><code>$("body").trigger({ type:"logged", user:"foo", pass:"bar" }); </code></pre>
jquery
[5]
119,701
119,702
Ups Integration and getting Track number
<p>How can I use UPS integration in my asp.net application to get tracking information for a package?</p>
c#
[0]
764,054
764,055
Show form field and focus
<p>In have a selector and when I select a particular option it shows additional form field. At that point I want to switch the focus to the new field. Here's what I tried but it does not seem to work. What am I missing?:</p> <pre><code> $('#mySelector').change(function () { var st = $(this).val(); if (st == 'a') { $('#a').show(function(){ $('#aField').focus(); }); $('#b').hide(); } else if (st == 'b') { $('#a').hide(); $('#b').show(function(){ $('#bField').focus(); }); } else { $('#a, #b').hide(); } }); </code></pre>
jquery
[5]
2,137,897
2,137,898
Replace word with jQuery
<p>I have word Hello on most of my pages and i want to change it to Welcome. Is it possible and if yes how to replace the words with jQuery?</p> <pre><code>Hello &lt;p&gt;Hello user Jack&lt;/p&gt; &lt;div&gt;Hell ow you from us &lt;h1&gt;12344 Hello&lt;/h1&gt; &lt;div&gt;Hellow&lt;/div&gt; &lt;/div&gt; &lt;script src="jquery-1.5.1.min.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre>
jquery
[5]
3,120,273
3,120,274
How does JRE know the line number of code where exception occured?
<p>Consider the following Exception print</p> <pre><code>java.util.NoSuchElementException at java.util.StringTokenizer.nextToken(StringTokenizer.java:332) at com.infoaxe.mr.homefeed.ReduceTwo.reduce(MapReduce.java:290) </code></pre> <p>Since Java is a compiled language and what runs in JVM is the bytecode and not the source code itself how does the exception know on which line it occurred ? Example line 332 in above case ? </p>
java
[1]
5,861,262
5,861,263
Get child of next consecutive div
<p>Apologies for the noobness of the question, I've done a search but can't find anything matching 'get child of next consecutive div'.</p> <p>Any ideas please?</p> <pre><code>//get current var current = $('#holder').find('img.current'); //get next image var next = &lt;div id="holder"&gt; &lt;div class="item odd"&gt; &lt;img class="current" src="project_1.jpg"&gt; &lt;/div&gt; &lt;div class="item even"&gt; &lt;img src="project_2.jpg"&gt; &lt;/div&gt; &lt;div class="item odd"&gt; &lt;img src="project_1.jpg"&gt; &lt;/div&gt; &lt;div class="item even"&gt; &lt;img src="project_2.jpg"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
3,724,149
3,724,150
os.environ['http_proxy'] not working
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/263005/is-it-possible-to-change-the-environment-of-a-parent-process-in-python">Is it possible to change the Environment of a parent process in python?</a> </p> </blockquote> <p>I am using python 2.4.3. I tried to set my http_proxy variable. Please see the below example and please let me know what is wrong. the variable is set according to python, however when i get out of the interactive mode. The http_proxy variable is still not set. I have tried it in a script and also tried it with other variables but i get the same result. No variable is actually set up in the OS. </p> <pre><code>Python 2.4.3 (#1, May 1 2012, 13:52:57) Type "help", "copyright", "credits" or "license" for more information. &gt;&gt;&gt; import os &gt;&gt;&gt; os.environ['http_proxy']="abcd" &gt;&gt;&gt; os.system("echo $http_proxy") abcd 0 &gt;&gt;&gt; print os.environ['http_proxy'] abcd &gt;&gt;&gt; user@host~$ echo $http_proxy user@host~$ </code></pre>
python
[7]
5,030,751
5,030,752
How To Use Kunststube-CSRFP?
<p>I put <a href="https://github.com/deceze/Kunststube-CSRFP" rel="nofollow">Kunststube-CSRFP</a> demo.php on my server : <code>http://domain1.com/demo.php</code> and hit 'TRY IT' button and it says : <strong>Form submission ok.</strong></p> <p>then I look at the source code and copy the token generated by the script into another server (domain2.com) and try to make fake HTML form there :</p> <pre><code>&lt;form action="http://domain1.com/demo.php" method="POST"&gt; &lt;input type="hidden" value="1356266422:QaAnM2IolCk9K1Mme3rOGifwmfmdldzdyg/PBu4ht818lIu52ArKFG2HxUOztmcgwblLcIgymaNheuGY7g6Kg==:nvhnqxfM9upP/UT+FRGf0nXDILFPHaubfdjahVYSm2w9fFHKQ/bQQ6rapjdKN8ype9qaX8TkAZJpxg9RmH8ZM9YWA==" name="_token"&gt; &lt;input type="submit" value="Submit"&gt; &lt;/form&gt; </code></pre> <p>and when I hit 'Submit' button from domain2.php... surprisingly, demo.php on first server (domain1.com) process the token just like from itself and display same string : <strong>Form submission ok.</strong></p> <p>shouldn't be "<strong>Token INVALID.</strong>" come out if it's not submitted from same server? where did I go wrong? thanks!</p>
php
[2]
5,944,630
5,944,631
python string on one line
<p>My string is</p> <pre><code>a b c d </code></pre> <p>I want to do this</p> <pre><code>a b c d </code></pre> <p>How?</p>
python
[7]
1,759,268
1,759,269
Javascript: regex for money values
<p>Been out of the regex game for a while. Trying to come up with something that will allow the user to enter a money value either with/without dollar sign or with/without commas. For example, all the of the following values should be valid:</p> <p>5</p> <p>5.1</p> <p>5.10</p> <p>$5</p> <p>500,000</p> <p>500,000.1</p> <p>500,000.10</p> <p>$100,000,000.50</p> <p>Etc....</p> <p>Could someone please help me out?</p>
javascript
[3]
5,086,477
5,086,478
Eclipse+Android NDK plugin takes too long to build native code on Windows+Cygwin
<p>I have a lib that is derived from webRTC. I can build it from the command line. It takes an acceptable time.</p> <p>I'm now trying to use the NDK plugin of eclipse to be able to debug it. The problem is that it takes too long to build it. It takes about 1 min per file. If there isn't a way to make it faster it would be unusable.</p> <p>I'm running Eclipse on Windows. I added Cygwin for the native code.</p> <p>Is this normal? Has anyone used the NDK plugin on Eclipse running on Linux? Is it so slow on Linux too? Is there something I should do to speed up the compilation?</p>
android
[4]
2,753,094
2,753,095
redirecting a page link and changing page text based on link
<p>OK I am not sure if the question title is actually correct , newbie web developer here so bear with me.<br /> This is an ASP.NET webiste running on IIS 6.0<br /> So here is the problem: I have two pages called Page1 and Home<br /> you can navigate to both like so<br /> www.mysite.com/Page1.aspx, www.mysite.com/Home.aspx</p> <p>Page1 is now undergoing a lot changes so that it is going to end up looking a lot like Home except for some really small text changes. Also there are a number of emails in the wild with customers that link to Page1 and \ or Home </p> <p>What I want is a solution that does the following </p> <ol> <li><p>Create One page( say newhome.aspx) which displays the correct text based on the URL of the link that people clicked on to get here </p></li> <li><p>Let existing links go to this new page( and of course as per the above requirement the appropriate text would be displayed) </p></li> </ol> <p>I guess they sort of are the same requirement , bottom line I want only one page and all legacy links to continue to work as in get redirected to this new page</p> <p>Thanks </p>
asp.net
[9]
4,819,072
4,819,073
Parsing long to a Date object with formatting
<p>I'm trying to do a function that will parse a long millesecond value into a Date object with formatting:</p> <pre><code>public static Date parseDate(long millisec, String format) { try { SimpleDateFormat formatter = new SimpleDateFormat(format); Date formattedDate = new Date(millisec); formatter.format(formattedDate); return formattedDate; } catch (Exception e) { e.printStackTrace(); } return null; } </code></pre> <p>The format I plugged into the function is this: "<code>dd-MM-yyyy HH-mm:ss</code>" And still I am getting this result format: "<code>Thu Apr 19 19:51:22 SGT 2012</code>"</p> <p>Any ideas why I get this kind of result? </p>
java
[1]
1,188,475
1,188,476
Determine if key values in two arrays are equal then update if they are
<p>I've taken up PHP programming as a hobby after work and kids. So, my appologies if this code is bogus...but I've been searching for awhile. Anyways, I am trying to compare the values in two arrays and...where each key value equals another I would like to update that value to '1'. So for example, in one array the values are (2, 4, 1) in the second they are (3, 4, 5). Afterwards the the values that would be in my sql column would be updated to (2, 1, 1). Here is my code. Thank you for any help! </p> <pre><code>$array1 = mysql_fetch_array($x); $array2 = mysql_fetch_array($x1); foreach($array1 as $key =&gt; $value) { if($value == $array2[$key]) { $v = "UPDATE fXnumber SET xnumber = '1'"; mysql_query($v); } } </code></pre>
php
[2]
227,355
227,356
jQuery plugin: Html autocomplete as in Dreamweaver
<p>Is there any jQuery plugin that works as follows: when you type a tag like <code>&lt;p&gt;</code>, the editor will automatically add <code>&lt;/p&gt;</code> and put the cursor after the first tag, it should also display a context sensitive list of valid tags.</p>
jquery
[5]
3,642,800
3,642,801
How screen changes from horizontally to vertically or Vice-versa automatically in Android
<p>Hii</p> <p>I want to know the mechanism how the screen changes automatically from horizontally to vertically or vice-versa in android when we change the position of phone. Example in terms of coding would be highly appreciable.</p> <p>Regards</p> <p>Piyush</p>
android
[4]
3,519,877
3,519,878
Get the first and last item of an array of strings
<p>If I have the following array of strings:</p> <pre><code>string[] stringArray = {"one", "two", "three", "four"}; </code></pre> <p>Is there a way to get the first and last item ("one", "four") in C# from the array, besides using array indexing (stringArray[0], stringArray[3]), something like stringArray.First and stringArray.Last ?</p> <p>Thanks.</p>
c#
[0]
5,529,673
5,529,674
PHP fgetcsv escape '\'
<p>A csv file contains a '\' character in one of its record for which i am not able to get the exact number of key value pair in the array. </p> <p>I am using PHP fgetcsv function as follows-</p> <pre><code> while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { .... } </code></pre> <p>I have also tried escaping the characters as follows.</p> <pre><code> while (($data = fgetcsv($handle, 1000, ",",'"',"\\")) !== FALSE) { .... } </code></pre> <p>But it did not work.What might be the possible solution?</p>
php
[2]
2,163,030
2,163,031
PHP Take a Variable in an If statement literally
<p>I was wondering if it would be possible to do this:</p> <pre><code>$var = '$something == $somethingelse'; if ($var) { // Say hello } </code></pre> <p>and have it mean the same thing as this:</p> <pre><code>if ($something == $somethingelse) { // Say hello } </code></pre> <p>I know this will not work at the moment, because <code>if ($var)</code> checks to see if <code>$var</code> is set or not. But what I'm asking is: is there a method to allow this? Would appreciate an answer.</p> <p>EDIT: Basically I feel I should explain why I am doing this. I want users to be able to control when they get a notification, based off some data that one of their "channels" has saved.</p> <p>For instance, a user only wants to get a notification when their collected data is bigger than 60. So I would get them to choose two fields:</p> <p>First field input of their number (int or float)</p> <p>Second field choises (equals, &lt;, &gt;, =&lt;, =&gt;)</p> <p>The last thing in this if statement would be their data collected by their "channel".</p> <p>I then want to be able to save their choice in a database, somehow, and then later act upon their choices.</p>
php
[2]
5,744,197
5,744,198
Iterating through a list of objects and displaying the property in the combobox
<p>I have 2 combo boxes, the first one lets you pick an interface and the second one should display the appropriate addresses depending on which interface you chose, I have a list of objects, each object is an interface with associated addresses. I need to display these addresses to the combo box after the user chooses what interface to connect to. </p> <p>Here is what I have so far and the problem is that it always displays the addresses for the first interface. The AddressCnt is the number of addresses for each interface. </p> <pre><code> private void cboInterface_SelectedIndexChanged(object sender, EventArgs e) { lblAddress.Text = cboInterface.SelectedItem.ToString(); cboAddress.Items.Clear(); for (int x = 0; x &lt; Interface[0].AddressCnt; x++) { cboAddress.Items.Add(Interface[0].AddressBuff[x].ToString()); } } </code></pre>
c#
[0]
2,451,400
2,451,401
Generating generic getters and setter on javascript object
<p>It is possible to create getters and setters in javascript as shown by</p> <pre><code>Object.defineProperty __define***__ </code></pre> <p>In all those instances, the name of the property is known. </p> <p>Is it possible create a generic one.</p> <p>By this I mean, I have a getter and or setter and it is called irrespective of the property name.</p> <p>Is this possible? If so, how?</p> <p>regards.</p> <p>Note: I did find these after posting the question. Looks like it is currently not possible as the first answer stated.</p> <p><a href="http://stackoverflow.com/questions/7891937/is-it-possible-to-implement-dynamic-getters-setters-in-javascript">Is it possible to implement dynamic getters/setters in JavaScript?</a></p> <p><a href="http://stackoverflow.com/questions/6985582/monitor-all-javascript-object-properties-magic-getters-and-setters">Monitor All JavaScript Object Properties (magic getters and setters)</a></p>
javascript
[3]
5,768,480
5,768,481
Use Input "Id" instead of Input "Name"
<p>Hey guys I managed to get a text input and select box to updated based off of the input box using some javascript....but we changed our form variables so I can no longer use the input "name"...I now need to use the id. How can i alter my javascript to use the id t do what Im currently doing?</p> <p>jsp:</p> <pre><code>TAMCN:&amp;nbsp;&lt;input type="text" id="tamcn" name="tamcn" value="" size="6" maxlength="5" onkeyup="javascript:tamcnSearchUpdated(this.value,'detSearchForm')" onkeypress="javascript:return noenter();" autocomplete="off" /&gt; &lt;select id="tamcnList" name="filterCriteria('TAMCN').values" onchange="javascript:this.form.tamcn.value = '';"&gt; &lt;option value=""&gt;&amp;nbsp;&lt;/option&gt; &lt;c:forEach var="tamcn" items="${tamcns}"&gt;&lt;option value="${tamcn.code}"&gt;${tamcn.code}&lt;/option&gt;&lt;/c:forEach&gt; &lt;/select&gt; </code></pre> <p>javascript:</p> <pre><code> function tamcnSearchUpdated(tamcn, formName) { var tamcnUpper = tamcn.toUpperCase(); document.forms[formName].elements.tamcn.value = tamcnUpper; var len = tamcn.length; if ( tamcnUpper.indexOf('*') &gt;= 0 ) { document.forms[formName].elements['tamcnList'].options[0].selected = 'selected'; return; } for (var i = 0; i &lt; document.forms[formName].elements['tamcnList'].options.length; i++) { if (document.forms[formName].elements['tamcnList'].options[i].text.substr(0,len) == tamcnUpper) { document.forms[formName].elements['tamcnList'].options[i].selected = 'selected'; return; } } </code></pre>
javascript
[3]
1,192,700
1,192,701
How can I check the value of the Next Row while looping using PHP/MYSQL?
<p>I got previousRow of record using this code</p> <pre><code>&lt;?php $previousRow = array(); while ($temp = mysql_fetch_row($res2)) { echo "&lt;br&gt;currentRow:".$temp[1]; echo "previousRow:".$previousRow[1]; $previousRow = $temp; } ?&gt; </code></pre> <h2>oupout</h2> <p>currentRow:1previousRow: </p> <p>currentRow:5previousRow:1 </p> <p>currentRow:6previousRow:5 </p> <p>currentRow:7previousRow:6 </p> <p>currentRow:8previousRow:7</p> <p>How can I check the value of the next row replaced by Previous Row ?</p> <p>Any help would be grateful.</p>
php
[2]
3,426,645
3,426,646
How to automatically close the parent window when the child window is opened in Firefox
<p>i have this code i need to close the parent.html window when the child window opened, i need the code for that working well in IE and Firefox</p> <p>Parent.html</p> <pre><code>&lt;HTML&gt; &lt;SCRIPT TYPE="text/javascript"&gt; function sendTo() { window.open('child.html','_blank','resizable=yes,width='+(screen.width-500)+',height='+(screen.height-500)+''); } &lt;/SCRIPT&gt; &lt;BODY&gt; &lt;form name="form"&gt; &lt;input type="text" value="" name="text1" id="pdetails1"&gt; &lt;input type="text" value="" name="text1" id="pdetails2"&gt; &lt;/br&gt; &lt;input type="submit" value="submit" onClick="sendTo()"&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>child.html</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form&gt; &lt;input type=text name="text5" value=""&gt; &lt;input type=submit name="submit"value="submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
414,937
414,938
get html code into a php variable
<p>I'm don't use PHP that much and right now I'm stuck at a problem. I need to save the site of a webbrowser as a pdf. I'm using right now mPDF (which was suggested in a wiki of stackoverflow) and it seems to work pretty well (I just have simply write a short html code into a php variable and then created the pdf). </p> <p>But now I must get the html code of the actual site in the browser and save it then into a php variable. How can I do that?</p>
php
[2]
4,049,613
4,049,614
Parse error: syntax error, unexpected T_VARIABLE in /home/designea/public_html/blog/blog_end/inc/comments.inc.php on line 1
<p>Im getting this error "Parse error: syntax error, unexpected T_VARIABLE in /home/designea/public_html/blog/blog_end/inc/comments.inc.php on line 1" can somebody help me..here's my code</p> <pre><code>&lt;?php function get_gravatar( $email = $_POST['email1'], $s = 50, $d = 'mm', $r = 'g', $img = false, $atts = array() ) { $url = 'http://www.gravatar.com/avatar/'; $url .= md5( strtolower( trim( $email ) ) ); $url .= "?s=$s&amp;d=$d&amp;r=$r"; if ( $img ) { $url = '&lt;img src="' . $url . '"'; foreach ( $atts as $key =&gt; $val ) $url .= ' ' . $key . '="' . $val . '"'; $url .= ' /&gt;'; } return $url; } ?&gt; </code></pre>
php
[2]
3,093,921
3,093,922
Use jquery :contains and and .eq() to modify text style within specific div
<p>Is it possible to combine the use of :contains and .eq() to search for text within a specific div?</p> <p>I currently use the following two statements which create jquery statements based upon values grabbed from the URL by PHP $_GET[].</p> <p>The first simply checks for link text matching the current $platformString and turns it white.</p> <pre><code>$(\"a:contains('". $platformString . "')\").css(\"color\", \"#ffffff\"); </code></pre> <p>The second shows and hides a div based upon a known value stored in section.</p> <pre><code>$(\".sidebar_content\").eq(" . $section .").toggle(); </code></pre> <p>The problem is that there can be multiple matches of $platformString within other hidden divs, once these are matched they are also turned white.</p> <p>Can I combine the two statements to simply highlight the $platformString within the current $section?</p> <p>Many thanks for any advice you are able to provide.</p> <p>Robert</p>
jquery
[5]
4,296,769
4,296,770
Difference between <?php echo $session_id ?> and <?= $session_id ?>
<p>Is there any particular reason to use one over the other? I personally tend to use the latter, as it just seems to flow better to me.</p>
php
[2]
651,527
651,528
jQuery Slide Toggle help
<p>I have the following code:</p> <pre><code>$("a.sticky-link").click(function (e) { e.preventDefault(); $("div.stickies-box").slideToggle('slow'); $("a.sticky-link").toggleClass("selected"); }); $("div.stickies-box").mouseup(function () { return false }); $(document).mouseup(function (e) { if ($(e.target).parent("a.sticky-link").length == 0) { $("a.sticky-link").removeClass("selected"); $("div.stickies-box").slideUp('slow'); } }); </code></pre> <p>Which basically shows and hides a div when a user clicks a button and then hides it should they click anywhere else on the page. The problem I have is if the box is already shown and the user clicks the button again (assuming they intend to hide the box) it will just quickly hide and reshow the box, when all I want it to do is hide the box.</p> <p>Also instead of sliding can the effect be changed to actually moving up and down as the slide effect looks more like a wipe.</p> <p>Thanks.</p>
jquery
[5]
848,127
848,128
what is wrong with this PriorityQueue?
<pre><code>fringe = new PriorityQueue&lt;Node&gt;(10,new Comparator&lt;Node&gt;(){ @Override public int compare(Node node1,Node node2) { if (f(node1)&gt;f(node2)) return 1; else return -1; } }); </code></pre> <p>I declared a PQ to store some nodes and i want to store the nodes in non-decreasing order according to the f value.function f(Node node) is to calculate the f value for the node. so i override the comparator but right now i found that some nodes with larger f value are placed before the ones with smaller f value in the queue, i checked all over but still cannot find what goes wrong, i assume maybe it is the PQ declaration's problem. Anyone can help me? Thanks in advance!</p>
java
[1]
5,650,092
5,650,093
Whats the difference between if(!Variable) and if(isset($variable))?
<p>Whats the difference between if(!Variable) and if(isset($variable)) ?</p>
php
[2]
1,565,717
1,565,718
Drawing a grid on a PictureBox
<p>I am currently working with a pictureBox. I am having difficulties drawing a grid over the picture box that is approximately the size of 2 x 2 squares. Now the code below is only giving me a line drawn across. How can I proplery draw a full grid on top of the pictureBox?</p> <p><strong>CODE:</strong></p> <pre><code>private Graphics g1; public Form1() { InitializeComponent(); pictureBox1.Image = new Bitmap(500, 500); g1 = Graphics.FromImage(this.pictureBox1.Image); Pen gridPen = new Pen(Color.Black, 2); g1.DrawLine(gridPen, 0, 0, 100, 100); } </code></pre> <p>This what I would like to accomplish: <img src="http://i.stack.imgur.com/bmEgz.png" alt="enter image description here"></p>
c#
[0]
675,741
675,742
android reading from a text file
<p>I have a java class where it reads some data from a text file using a buffered reader and returns that data as a hash map:</p> <pre><code>import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.HashMap; public class FrequencyLoader { public FrequencyLoader() throws FileNotFoundException { } public HashMap&lt;String, Double&gt; loadUnigramFrequencies() throws FileNotFoundException, IOException { HashMap&lt;String, Double&gt; unigramFrequencies = new HashMap&lt;String, Double&gt;(); String line; String[] splittedLine; BufferedReader bf = new BufferedReader(new FileReader("unigramFrequencies.txt")); while ((line = bf.readLine()) != null) { splittedLine = line.split("\\s"); unigramFrequencies.put(splittedLine[0].trim(), Double.parseDouble(splittedLine[1].trim())); } return unigramFrequencies; } } </code></pre> <p>I want to use that in my android application but when I create an instance of this class and try to execute the loadUnigramFrequencies() funtion in the android Activity class I am getting an error that the application has stopped unexpectedly. I am trying to run it on Samsung Galaxy S2. Should the file be placed somewhere in the android project rather than on the disk? if yes then where?</p>
android
[4]
2,301,581
2,301,582
How to wait three seconds then turn to another webpage
<p>I'm new to web development, and I'm currently using ASP.net. I wonder what would I need to do to let the browser wait for 3 seconds so my users can read the text "Customer Successfully Added" before turning to another page? I have attached my code as follows. </p> <pre><code>Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click Dim db As New DatabaseClass db.addProfile(txtLN.Text, txtFN.Text, txtUsername.Text, txtPassword.Text, txtAddress.Text, txtZip.Text, txtPhone.Text, txtEmail.Text) lblMessage.Text = "Customer Successfully Added" End Sub </code></pre> <p>In addition, I'm not sure how to utilize MSDN. For me, its information overload, I'm wondering how to go about finding the solution on MSDN so i would be able to solve my problems in the future. Thank you!</p>
asp.net
[9]
781,642
781,643
How to create a tabView like the image
<p>I would like to create a tabView like in the picture.</p> <p><img src="http://i.stack.imgur.com/I7Awg.jpg" alt="enter image description here"></p> <p>the gradient tab is the one i have clicked</p> <p>but i dont want to be like this for example</p> <p><a href="http://www.androidhive.info/2011/08/android-tab-layout-tutorial/" rel="nofollow">http://www.androidhive.info/2011/08/android-tab-layout-tutorial/</a></p> <p>is that possible to be created from my .xml?any help please?</p> <p>EDIT: .xml code</p> <p> </p> <pre><code> &lt;ImageButton android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@drawable/header" android:layout_weight="1" /&gt; &lt;ImageButton android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@drawable/header_btn1" /&gt; &lt;ImageButton android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@drawable/header_btn2" /&gt; &lt;ImageButton android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@drawable/header_btn3" /&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
3,148,417
3,148,418
jquery execution order
<p>Consider the following code:</p> <pre><code>function searchText() { if($('#searchtext').val() == null || $('#searchtext').val().trim() == '') { alert('must provide a text to search for'); return false; } urllink='http://search.twitter.com/search.json?q=' + escape($('#searchtext').val().trim()) + '&amp;callback=?'; $('#results').html(urllink); $.getJSON(urllink,function(data) { var resultT = {}; $('#results').html(data.results[0].profile_image_url); return data.results; }); } $('#gosearch').click(function() { var data = searchText(); if(data == null) alert('null'); return false; }); </code></pre> <p>I have a breakpoint in firebug in <code>return data.results</code> of <code>searchText()</code>. But it seems that <code>searchText</code> is executed but I do not stop in my break point. It rather checks for data, which is <code>null</code>, and executes <code>alert('null')</code>. then it stops in my break point inside <code>searchText</code>. </p> <p>Why is this happening? Can't I execute functions inside events and wait them to finish before moving to next line in code?</p> <p>thanks</p>
jquery
[5]
2,053,971
2,053,972
Send/Receive Data to server in C#
<p>In my programe I have a need for requesting data from server and upon collecting the response, use the returned data for further processing. </p> <p>I am using "system.net.webrequest" class for the same. I have few questions on this:</p> <ol> <li>after I receive the data (data is of 0.5MB size in minimum) I have to process this entire data to derive some result. I was thinking to store the returned data in a "txt" file and then read the data from that file and process.</li> </ol> <p>Is this a better idea? If not, can you please suggest.</p> <ol> <li><p>I am making post request to several servers (>10 servers) and using data from them. I observed that for some reason if the server is not reachable then my programe stops throwing an exception</p> <p>Server Not Reachable<br> A first chance exception of type 'System.Net.WebException' occurred in System.dll</p></li> </ol> <p>How can I solve this problem? Any idea?</p> <p>Appreaciate your help.</p> <p>Thanks, Rahul</p>
c#
[0]
1,026,981
1,026,982
Finding if a string contains a date and time
<p>I am working on a project where I am reading in a file which could come in two different formats, one includes a date and time and the other doesn't. </p> <p>When I read in the first line I need to check whether the string contains the date and time or not and read the file and based on the check read the file in a certain way. </p> <p>I'm guessing this would be some kind of regular expression but have no idea where to start and can't find anything relevant.</p> <p>Thanks for any help you can provide. </p> <p><strong>UPDATE</strong> I don't think I've been very clear as to what I am asking. When I read the log file line by line the line may come in as:</p> <pre><code>Col1 Col2 Col3 Col4 Col5 </code></pre> <p>Sometimes the line may come in as </p> <pre><code>Col1 17-02-2013 02:05:00 Col2 Col3 Col4 Col5 </code></pre> <p>When I read the line I need to do a check whether there is a date and time string contained within the string. </p>
c#
[0]
465,372
465,373
about android view design
<p>I want to design android game program!</p> <p>i use android DroidDraw program design UI view(Only 2.7" size)</p> <p>absolutelayout.linearlayiut.tablelayout have tried</p> <p>However, the components designed address will change with different resolutions</p> <p>how do design to achieve what I want?</p>
android
[4]
2,605,408
2,605,409
is it possible to shorten a conditional statement checking for a bunch of different values for a single variable
<p>if (hello == 50 || hello == 60 || hello == 70) {</p> <p>would it be possible to shorten this to something like that ?</p> <p>if (hello == (50,60,70));</p> <p>or something along those line, just to avoid having to constantly rewriting the same variable.</p>
java
[1]
4,004,926
4,004,927
Can JavaScript detect onblur() for a window opened through window.open()?
<p>What I'm looking to do is create a new window using <code>window.open</code> and then when the new window opens, I want to check if that window is active throughout? </p> <p>For example: I have</p> <pre><code>myNewWindow = window.open(document.getElementById("inputbox").value).focus(); </code></pre> <p>Once this window opens, I want to increment the value of variable increase if <code>myNewWindow</code> loses focus.</p> <p>I'm doing :</p> <pre><code>if(myNewWindow.onblur()){ increment value... } setTimeout('myNewWindow.close()',3000); // closing window after 3 seconds. So, I'm really trying to check if the window was in focus for those 3 seconds. </code></pre> <p>However, the <code>onblur</code> does not seem to work no matter what I try. but, window does close. Any ideas anyone? I just need to find out if the new opened window was minimized or some out of focus.</p> <p>Its fairly easy to detect if the window in which you are running your JS is losing focus or not. And the same does not seem to work in my case. For example: <a href="http://stackoverflow.com/questions/3479734/test-if-window-has-focus">test if window has focus</a> </p>
javascript
[3]
1,101,145
1,101,146
Java multiplayer server blocking io
<p>I am currently developing a prototype for a game and I need a simple server to run it. At this stage, I don't want to invest the time learning about all the different full-featured multiplayer game servers already there (smartfox, etc...)</p> <p>I know how to develop a basic Server with Threads listening on Sockets but I have ran into a roadblock. Here's the run() function of the Thread</p> <pre><code>public void run() { try { out = new PrintWriter(mSocket1.getOutputStream(), true); in = new BufferedReader( new InputStreamReader( mSocket1.getInputStream() ) ); String inputLine1 = null, outputLine; out.println("hello"); out.flush(); while( (inputLine1 = in.readLine()) != null) { outputLine = mGameControl.processInput(mPlayerNum, inputLine1); out.println(outputLine); out.flush(); if(outputLine.contentEquals("bye")) break; } Terminate(); } catch(IOException e) { e.printStackTrace(); } } </code></pre> <p>Now my problem is that the thread is blocked waiting for input. I do have other similar Threads connected to other client which may result in information being dispatched to all clients...</p> <p>How can I modify it so that a different Thread can interact with it and push info to the client?</p>
java
[1]
5,455,528
5,455,529
Javascript error on page reload using response.redirect in asp.net
<p>I have a button on my page which I use to redirect the user to the same page.</p> <pre><code>protected void Undo123_Click(object sender, EventArgs e) { Page.Response.Redirect(Page.Request.Url.ToString(), true); } </code></pre> <p>I get this error:</p> <pre><code>Microsoft JScript runtime error: Sys.WebForms.PageRequestManagetServerErrorException: An unknown error occurred while processing the request on the server.The status code returned from the server was 500 </code></pre> <p>I got this error on every button click the day before, but when I closed the solution and opened it again, it was gone. Closing the solution does not work now. May I know the reason behind this error and how do I resolve that in my case.</p> <p>Thank you ! </p>
asp.net
[9]
2,768,266
2,768,267
Android: User input on image
<p>I am trying to add user input on a selected image. So far I am able to select the image, then the keypad of the emulator comes up but the text is not added on the image. Following is the code. Could anyone please help me figure it out? Thanks!</p> <pre><code>public class FullImageActivity extends Activity implements OnClickListener { private EditText textArea; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.full_image); // get intent data Intent i = getIntent(); // Selected image id int position = i.getExtras().getInt("id"); ImageAdapter imageAdapter = new ImageAdapter(this); ImageView imageView = (ImageView) findViewById(R.id.full_image_view); imageView.setImageResource(imageAdapter.mThumbIds[position]); textArea = (EditText)findViewById(R.id.ascii_text); } @Override public void onClick(View arg0) { textArea.setText(""); textArea.getText(); } } </code></pre> <p>full_image.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/full_image_view" android:layout_width="fill_parent" android:layout_height="fill_parent"/&gt; &lt;EditText android:id="@+id/ascii_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#000000" android:gravity="center|left" android:hint="" android:inputType="textMultiLine" android:lines="10" android:maxLines="10" android:minLines="10" android:singleLine="false" android:textColor="#ffffff" android:typeface="monospace" /&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
4,361,782
4,361,783
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,281,481
2,281,482
Writing a program to add all the odd numbers in an array
<pre><code> // Write a program to sum all the odd elements of an array a = Number(prompt("a:")); b = Number(prompt("b:")); c = Number(prompt("c:")); sum=Number(0); var test = [a,b,c]; for (i=0; i&lt;test.length;i++) { // All even numbers can be divided by 2 if ((test[i]%2)&gt;0) { alert(test[i] + ":odd"); } else { alert(test[i] + ":even"); } test[i]=0; } sum=0+test[i]; alert(sum); </code></pre> <p>My program works brilliant up until its meant to add up all the numbers where it returns a NaN message! Any ideas on how I can sort this problem out?</p>
javascript
[3]
642,503
642,504
Where do you put global application data in an iPhone app?
<p>I have an app that allows the user to view, manipulate and manage a collection of Schedule objects. Different parts of the app need access to this data. I've experimented with making the collection a singleton, but I didn't find that very clean.</p> <p>I recently changed to storing the global data in the AppDelegate class and using:</p> <pre><code>MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.myGlobalData doSomething]; </code></pre> <p>Which eliminates the need for my global data to be a singleton, but is really just taking advantage of the UIApplication singleton.</p> <p>There really isn't just one primary view controller where it makes sense to store it in my case. So I was wondering what different strategies people use to address this.</p>
iphone
[8]
4,782,812
4,782,813
How to pass a string literal to a function which takes const std::wstring&
<p>I have a function which takes <code>const std::wstring&amp;</code> font_family, i.e.</p> <pre><code>Font Font::CreateFont(const std::wstring&amp; font_family){ ... } </code></pre> <p>By question is how can I call that funcion by passing a string literal (e.g monospace)?</p> <p>I tried </p> <pre><code>CreateFont("monospace"); CreateFont("std::wstring("monospace") ); </code></pre> <p>Both does not compile. Any one have better idea?</p> <p>Thank you.</p>
c++
[6]
5,126,175
5,126,176
Date() converts certain date strings to local time
<p>I'm trying to compare two date strings for equality by wrapping them with the Date() object. I live in Seattle and for some reason, the second date string is converted to PST and then rendered in GMT, resulting in the below: </p> <pre><code>new Date("January 1, 2012") &gt;&gt;&gt; Sun Jan 01 2012 00:00:00 GMT-0800 (PST) new Date("2012-01-01") &gt;&gt;&gt; Sat Dec 31 2011 16:00:00 GMT-0800 (PST) </code></pre> <p>Try the above in the chrome console and you should get the same results. How do I get Date to evaluate the second statement as GMT instead of PST? </p>
javascript
[3]
3,089,152
3,089,153
byte array assignment
<pre><code>byte test[4]; memset(test,0x00,4); test[]={0xb4,0xaf,0x98,0x1a}; </code></pre> <p>the above code is giving me an error expected primary-expression before ']' token. can anyone tell me whats wrong with this type of assignment?</p>
c++
[6]
5,345,147
5,345,148
using a method instead of override string ToString
<p>Every object has its own <code>public override string ToString(){ return string; }</code> method. But we can achieve the same with a custom method. Then why have a separate override string method?</p>
c#
[0]
3,015,157
3,015,158
How to add category and subcategory in shoppingcart
<pre><code>&lt;h2&gt;Add Product&lt;/h2&gt; &lt;?php $sql="select * from category where parent_id=0 "; $res=mysql_query($sql); echo "&lt;FORM METHOD=POST ACTION='' enctype='multipart/form-data'&gt; &lt;TABLE&gt; &lt;TR&gt; &lt;TD&gt;Product Category&lt;/TD&gt; &lt;TD&gt;&lt;SELECT NAME='sel'&gt; &lt;OPTION VALUE='' SELECTED&gt;SELECTED&lt;/OPTION&gt; "; while($row=mysql_fetch_array($res)) { echo "&lt;OPTION VALUE='$row[cid]' &gt;$row[cname]&lt;/OPTION&gt;"; $sql1="select * from category where parent_id= $row[cid]"; $res1=mysql_query($sql1); while($row1=mysql_fetch_array($res1)) { echo"&lt;OPTION VALUE='$row1[cid]' &gt;--$row1[cname]&lt;/OPTION&gt;"; } } </code></pre> <p>Can any one suggest if there is something wrong? I am adding the category and sub category but its not showng the sub category under the category.</p>
php
[2]
2,240,654
2,240,655
C++ and pin tool -- very weird DOUBLE variable issue with IF statement
<p>I am working with pin tool that simulates a processor and having a very strange problem. In the code snippet below, Router::Evaluate() is called repeatedly many times. After it is called several million times, strange behavior occurs intermittently where "_cycles != 0" is evaluated to be true in the first IF statement and to be false in the immediately following IF statement, falling into ELSE block.</p> <pre><code>void Router::Evaluate( ) { //---------debug print code--------- if (_cycles != 0) { cout &lt;&lt; "not a zero" &lt;&lt; endl; if (_cycles != 0) cout &lt;&lt; "---not a zero" &lt;&lt; endl; else cout &lt;&lt; "---zero" &lt;&lt; endl; } //---------------------------------- _cycles += _speedup; while ( _cycles &gt;= 1.0 ) { _Step(); _cycles -= 1.0; } } //class definition class Router : public TimedModule { Protected: double _speedup; //initialized to 1.0 double _cycles; //initialized to 0.0 ... } </code></pre> <p>Below is the output of the code where "not a zero" followed by "---zero" is printed out from time to time seemingly randomly. </p> <pre><code>not a zero ---zero (...some other output...) not a zero ---zero (...some other output...) </code></pre> <p>How could this possibly happen? This is not a multi-threaded program, so synchronization is not an issue. The program is compiled with gcc4.2.4 and executed on 32-bit CentOS. Does anybody have a clue? Thanks.</p> <p>--added---</p> <p>I should have mentioned this, too. I did try printing the value of _cycles each time, and it is always 0.0, which should not be possible... I also used the following g++ options: "-MM -MG -march=i686 -g -ggdb -g1 -finline-functions -O3 -fPIC"</p>
c++
[6]
559,190
559,191
variables in img src
<p>this is going to an easy one i think but for the life of me i cant get it to work.</p> <p>i have a variables $id i want to put it in a img src that i have echo (eg. "uploaded/$id.jpg")</p> <p>i have tried lots of way and looked all over the net and cant get it to work </p> <pre><code>echo " &lt;td&gt; &lt;img src="uploaded'.$id'.jpg"&gt; &lt;/td&gt; "; </code></pre> <p>this is what the echo looks like if anyone can tell me why it is not work would be a big help </p>
php
[2]
1,322,821
1,322,822
Compilation error while compiling 2.1.2 code on 3.0 iphone SDK
<p>When I'm trying to compile 2.1.2 SDK code on 3.0 or higher version, it gives a compilation error saying "CFXMLTreeRef undeclared identifier". Below is the code snippet where it shows the error:</p> <pre><code>#ifdef TARGET_IPHONE_SIMULATOR #import &lt;CoreServices/CoreServices.h&gt; //cause of the preoblem #else #import &lt;CFNetwork/CFNetwork.h&gt; #endif </code></pre> <p>I searched for the "CFXMLTreeRef" in 2.1.2 SDK and it's found, but in SDK version higher than 3.0, I couldn't find it.</p> <p>Can anyone tell where can I find the declartion of "CFXMLTreeRef".</p> <p>I would really appreciate any help.</p> <p>Thanks Puru</p>
iphone
[8]
2,784,233
2,784,234
what is the equivalent reference for "this" in C/C
<p>Guys i just started to learn C# and i have no idea about "this" reference in c# someone can give me a very simple example in real life. I mean why do i need to use "this" in C# or where can i use "this" what is the benefit? </p> <p>Thanks.</p>
c#
[0]
5,705,542
5,705,543
On/Off status with jQuery
<p>There is a plugin to fav &amp; unfav my data? I have an example:</p> <p><strong><code>id name status</code></strong><br /> <code>1 jackii on</code><br /> <code>2 derekk off</code><br /> <code>3 carool on</code><br /></p> <p>I want to on/off my data instally without refresh (the same idea used by many webapps. like gmail ...)</p> <p>Actually I use PHP with $_GET to update the status</p>
jquery
[5]
752,382
752,383
Could someone tell me the purpose of Inner classes and if iterator pattens should or a good idea to use inner classes?
<p>Could someone tell me what the purpose of inner classes are? Also when designing the iterator pattern do we have to use inner classes? Would it be better to use inner classes?</p>
java
[1]
3,795,800
3,795,801
How can i set Brightness value while the activity style is Theme.NoDisplay?
<p>1.First i set the activity style is NODisplay in manifest.xml use the follow code</p> <pre><code>android:theme="@android:style/Theme.NoDisplay" </code></pre> <p>2.I set brightness value use the follow code :</p> <pre><code>public void setBrightness(Activity activity,int brightness){ WindowManager.LayoutParams lparams = activity.getWindow().getAttributes(); lparams.screenBrightness = Float.valueOf(brightness) * (1f / 255); activity.getWindow().setAttributes(lparams); } </code></pre> <p>Program can perform,but the brightness has not changed. </p> <p>What is the reason?</p> <p>Does anyone have any idea about it? Thanks for any help !</p>
android
[4]
3,841,904
3,841,905
In Android how to get CheckBox onCheckedChanged from other activity
<p>the first one - 16.1 Example A Preferences</p> <p><a href="Http://www.bogotobogo.com/Android/android16Preferences.html" rel="nofollow">Android tutorial</a><br> (sorry for the link)</p> <p>Cant for the love of android not get this to work I want to click that CheckBox witch is connected to the autosave PreferenceActivity and at the same time clicking it I want to fire an event to a method in the Activity that started the PreferenceActivity. There i will start a service. </p> <p>`` Sigh hope you understand the probl.</p>
android
[4]
4,115,125
4,115,126
forward break label
<p>How can i do forward jumps like this?? Eclipse is complaining label1 is not found...</p> <p>Thx</p> <pre><code>public class foo { int xyz() { int b = 1; if (b == 0) { break label1; } // MORE CODE HERE label1: return 1; } } </code></pre>
java
[1]
4,442,682
4,442,683
I want to calculate distance in a gps
<p>I am currently working on a gps project. I have read an xml file, I can print out the longitude and latitude bounds in the form of minLat, maxLat, minLon, maxLon. Way,Relation and Node properties like, id, user, uid, version, visible, changeset and timestamp . I can also print out the tag key and value and the reference. My problem now is that I want to calculate the distance between two points with the use of latitude and longitude, it is unclear to me on how do it and which of the properties that I printed out to console I really need to do it. So please I need some help!</p>
java
[1]
5,894,347
5,894,348
How to use Contains(Of T)(T) method?
<p>I have a byte list variable which I store byte array information here:</p> <pre><code>internal List&lt;Byte&gt; portBuffer = new List&lt;Byte&gt;(); </code></pre> <p>And I have another byte array variable:</p> <pre><code>byte[] ret_bytes = { 0x4F, 0x4B }; </code></pre> <p>How can I find out if ret_bytes is inside the portBuffer? The code below seems like not correct.</p> <pre><code>portBuffer.Contains(ret_bytes) </code></pre> <p>Another question, how to find out the position of the first element of ret_bytes in side the portBuffer list if it is inside the list?</p> <p>Thanks</p>
c#
[0]
2,474,957
2,474,958
jQuery combine statements? (follow up)
<p>Thanks for the help on my previous post, @AndyE, your solution works great.</p> <p>now for my follow up, same idea, different function(s)...i tried to implement your previous solution, but couldnt get it to work right...:</p> <pre><code>$(document).keypress(function(e) { if (e.which == 27) { $('#timeline-2010-1').hide(); $('#timeline-2010-2').hide(); $('#timeline-2010-3').hide(); $('#timeline-2010-4').hide(); $('#timeline-2010-5').hide(); $('#timeline-2010-6').hide(); $('#timeline-2010-7').hide(); $('#timeline-2010-8').hide(); $('#timeline-2010-9').hide(); $('#timeline-2010-10').hide(); $('#timeline-2010-11').hide(); $('#timeline-2010-12').hide(); $('#timeline-2010-13').hide(); $('#timeline-2010-14').hide(); $('#timeline-2010-15').hide(); $('#timeline-2010-16').hide(); $('#timeline-2010-17').hide(); } }); $('a.close').click(function() { $('#timeline-2010-1').hide(); $('#timeline-2010-2').hide(); $('#timeline-2010-3').hide(); $('#timeline-2010-4').hide(); $('#timeline-2010-5').hide(); $('#timeline-2010-6').hide(); $('#timeline-2010-7').hide(); $('#timeline-2010-8').hide(); $('#timeline-2010-9').hide(); $('#timeline-2010-10').hide(); $('#timeline-2010-11').hide(); $('#timeline-2010-12').hide(); $('#timeline-2010-13').hide(); $('#timeline-2010-14').hide(); $('#timeline-2010-15').hide(); $('#timeline-2010-16').hide(); $('#timeline-2010-17').hide(); return false; }); }); </code></pre>
jquery
[5]
4,965,367
4,965,368
Java: Call subclass out of another subclass
<p>How can I call a subclass out of another subclass, if the first class was initialized in the main class? It's something like that:</p> <pre><code>public class main { Sub1 test = new Sub1(); Sub2 test2 = new Sub2(); Sub2.bummer2(); } </code></pre> <p>Subclass 1:</p> <pre><code>public class Sub1 { public static void bummer() { System.out.println("got called"); } } </code></pre> <p>The other subclass:</p> <pre><code>public class Sub2 { public static void bummer2() { //here i want to execute Sub1.bummer() without having to initialise it first } } </code></pre> <p>How can I do that?</p>
java
[1]
5,788,380
5,788,381
Navigate between windows in a simple quiz app
<p>I have to make a simple quiz application in JAVA and I have no idea on how to navigate between windows, for example, how to go to the next question or how to go back. I have a single question per window. Can you give me an idea on how to navigate? Should I use repaint() or a CardLayout or something else? Thanks!</p>
java
[1]
3,646,246
3,646,247
Access object from hash map
<p>My Hashmap as declared as <code>HashMap&lt;String, ArrayList&lt;SortableContactList&gt;&gt;</code> where <code>SortableContactList</code> list is a POJO class as </p> <pre><code>public class SortableContactList { private long id; private String displayName; private String homePhone; private String workPhone; private String mobilePhone; private String primaryEmail; private String tags; // Getters and Setters } </code></pre> <p>Initializing my hashmap as </p> <pre><code>myHash.put(keyChar, arrayOfSortableContactList_objects) </code></pre> <p>My need is to get each attribute of an object which stored in arraylist. How can I make this.</p> <p>Thank you!</p>
java
[1]
479,986
479,987
PARSing JSON to ListView
<p>Okay I have went through tons of examples on PARSing my JSON results, with no luck. I have the below JSON example I don't want status info or geoLocation right now. I just want to use stations object and pick some things from the array to display in my ListView as a list. I don't understand any of the documentation out there.</p> <p>Would someone be able to provide a simple example on how read the JSON and put it to a ListView. This would be very helpful. I don't really have any code made up since none of it really worked for me.</p> <pre><code>{ "status": { "error": "NO", "code": 200, "description": "none", "message": "Request ok" }, "geoLocation": { "city_id": "147", "city_long": "Saint-Laurent", "region_short": "QC", "region_long": "Quebec", "country_long": "Canada", "country_id": "43", "region_id": "35" }, "stations": [ { "country": "Canada", "reg_price": "N\/A", "mid_price": "N\/A", "pre_price": "N\/A", "diesel_price": "N\/A", "address": "3885, Boulevard de la C\u00f4te-Vertu", "diesel": "0", "id": "33862", "lat": "45.492367", "lng": "-73.710915", "station": "Shell", "logo": "http:\/\/www.mygasfeed.com\/img\/station-logo\/logo-shell.png", "region": "Quebec", "city": "Saint-Laurent", "reg_date": "N\/A", "mid_date": "N\/A", "pre_date": "N\/A", "diesel_date": "N\/A", "distance": "1.9km" } ] </code></pre>
android
[4]
4,736,142
4,736,143
How can I bind events to HTML generated after the page loads?
<p>I'm using jquery <code>.clone()</code> to add HTML to my page according to user clicks.</p> <p>I'd like to add onclick handlers to the newly created HTML. I know <a href="http://api.jquery.com/on/" rel="nofollow"><code>.on()</code></a> can be used to trigger events on future-created HTML, but I believe that must be written (and executed) <em>before</em> the HTML is created.</p> <p>In this <a href="http://jsfiddle.net/thunderrabbit/Zxq2E/" rel="nofollow">example code</a>, if the user selects "related_id" from the select list, jquery creates a field where the user can enter ids. I'd like to add an ajaxy thing here so the user can type the name of the related item instead of its id. The ajax request will depend on which field the user selected.</p> <p>Generally speaking, I know how to make ajax requests with jquery, but how do I add the field-specific ajax code to my freshly created HTML?</p>
jquery
[5]
2,641,879
2,641,880
php, get values from matrix (array)
<p>I have Matrix and how get value from there? The data obtained from a file, so that the matrix can be of different sizes</p> <p>Thanks</p>
php
[2]
2,539,598
2,539,599
Duplicate methods in java.io.Console?
<p>In <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Console.html" rel="nofollow"><code>java.io.Console</code></a>, there are two methods, <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Console.html#printf%28java.lang.String,%20java.lang.Object...%29" rel="nofollow"><code>printf</code></a> and <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Console.html#format%28java.lang.String,%20java.lang.Object...%29" rel="nofollow"><code>format</code></a>, which appear to be identical. In the API it says</p> <blockquote> <p>An invocation of this method of the form <code>con.printf(format, args)</code> behaves in exactly the same way as the invocation of <code>con.format(format, args)</code></p> </blockquote> <p>So why have two methods? Is there a case where one is preferred?</p> <p>EDIT: They've done this in java.io.PrintStream as well in Java 5 </p>
java
[1]
4,786,389
4,786,390
How do I set a background color for each item in a list view based on content
<p>So I've been modifying the notepad tutorial code: <a href="http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html" rel="nofollow">http://developer.android.com/resources/tutorials/notepad/notepad-ex1.html</a> . </p> <p>Basically what I want to do is to create specific layout styles (i.e. background color) for different rows within the ListView based on the content. So for example, the text for the title is "1" so the background of that row will be red. Or, if the text for the title is "2" then the background of that row (or list item) will be green.</p> <p>What I'm trying to accomplish is to have a summary of the the rows in the database and color-code each row based upon what category (numerical field) the item is stored as.</p>
android
[4]
889,907
889,908
android background service application
<p>Is it possible to create an android application which is purely a background service? There is no need of any icon launcher, layout, etc.If yes, is it possible to do this using eclipse?</p> <p>I just need a Broadcast Listener to listen to my incoming messages and perform some sound and vibration activity. </p>
android
[4]
5,030,631
5,030,632
How can we improve the below line of code?
<p>Can we improve this line of code</p> <pre><code>if ((l_Subscription.PackageInfo.Applications.Where(x =&gt; x.DeviceType != DeviceType.UnKnown)).Count() &gt; 0) { //l_Subscription.DeviceTypeID = ((l_Subscription.PackageInfo.Applications.Where(x =&gt; x.DeviceType == DeviceType.Tablet)).Count() &gt; 0)?() if ((l_Subscription.PackageInfo.Applications.Where(x =&gt; x.DeviceType == DeviceType.Tablet)).Count() &gt; 0) l_Subscription.DeviceTypeID = (int)DeviceType.Tablet; else if ((l_Subscription.PackageInfo.Applications.Where(x =&gt; x.DeviceType == DeviceType.Phone)).Count() &gt; 0) l_Subscription.DeviceTypeID = (int)DeviceType.Phone; } </code></pre> <p>I just tried with the below but not working...Need help</p> <pre><code>int cnt = DoOperation(l_Subscription.PackageInfo.Applications, x =&gt; x.DeviceType != DeviceType.UnKnown); if(cnt &gt; 0) { int cnt1 = DoOperation(l_Subscription.PackageInfo.Applications, x =&gt; x.DeviceType == DeviceType.Tablet); int cnt2 = DoOperation(l_Subscription.PackageInfo.Applications, x =&gt; x.DeviceType == DeviceType.Phone); if(cnt1 &gt; 0) l_Subscription.DeviceTypeID = (int)DeviceType.Tablet; else if (cnt2 &gt; 0) l_Subscription.DeviceTypeID = (int)DeviceType.Phone; } private int DoOperation&lt;TKey&gt;(List&lt;l_Subscription.PackageInfo.Applications&gt; list, Func&lt;l_Subscription.PackageInfo.Applications, TKey&gt; predicate) { int count = 0; count = list.Where(predicate).Count(); return count; } </code></pre>
c#
[0]
2,161,601
2,161,602
slide() gives me error - jQuery
<p>Why does this slide() gives the error</p> <pre><code>$(this).hide("slide", { direction: "down" }, 1000); </code></pre> <p><strong>Error: Message: Object doesn't support this property or method</strong> Thanks Jean</p>
jquery
[5]
8,185
8,186
Debug fails but works in other cases
<p>WHy do I always get |Access is denied| exception during debug ?</p> <pre><code>foreach(Process p in Process.GetProcesses()) { string module=p.MainModule.Filename; } </code></pre> <p>Whatever process it is, the exeption's always called. But it works if I just start without debugging. I'd like to get the full path of the process by the way/.</p>
c#
[0]
1,343,614
1,343,615
how to reference an instance created in another class
<p>I have a function in Class A which I would like to change the value of a field in Class B.</p> <p>Class C has my <code>main()</code> and creates a new instance of class B and Class A. Class A is from an API and one of their functions is a listener function. I would like for that listener function to be able to change the field of Class B, but when I write the code for the listener function, it doesn't recognize Class B's instance. </p> <p>How do I reference that instance?</p> <p>Example code:</p> <pre><code>public class A { public void listenermethod(){ //can't reference Binstance &lt;------- } } public class B { B.field = 1; } public class C { A Ainstance = new A(); B Binstance = new B(); } </code></pre>
java
[1]
3,997,419
3,997,420
Javascript object creation using functions
<pre><code>var boxArea = function() { this.width=2; }; alert(boxArea.width); </code></pre> <p>Good day. Why does this return an undefined value?</p>
javascript
[3]
2,264,768
2,264,769
How generate unique Integers based on GUIDs
<p>Is it possible to generate (highly probable) unique Integer from GUIDs?</p> <pre><code>int i = Guid.NewGuid().GetHashCode(); int j = BitConverter.ToInt32(Guid.NewGuid().ToByteArray(), 0); </code></pre> <p>Which one is better?</p>
c#
[0]
3,126,678
3,126,679
Hide the Application in Application Manager in Android
<p>I want to hide my <strong>Application</strong> in <strong>Android's</strong> <strong>Application Manager</strong>.</p> <p>Is it possible ?</p> <p>How I can achieve this ?</p> <p>Thanks.</p>
android
[4]
3,363,941
3,363,942
Jquery How to build dynamic html
<p>i want to dynamically create 5 tr each having 3 tds with a loop, note: inside each i am filling dynamic html which has dynamic values that are filled from an array</p> <pre><code>&lt;tr&gt; &lt;td&gt;&lt;td&gt;&lt;td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;td&gt;&lt;td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;td&gt;&lt;td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;td&gt;&lt;td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;td&gt;&lt;td&gt; &lt;/tr&gt; </code></pre> <p><strong>what should be inside the td</strong></p> <pre><code> $('#output').append( + '&lt;td&gt;' + '&lt;ul class="listing" style="margin:0 8px 0 0;width:220px;"&gt;' + '&lt;li class="item"&gt;' + '&lt;dl&gt;' + '&lt;dt&gt;&lt;a href="' + pathname + value.SLink + '" &gt;' + value.CName.replace("(Or Similar)", "") + '&lt;/a&gt;' + '&lt;/dt&gt;' + '&lt;dd&gt;fr £' + parseFloat(value.CPrice).toFixed(0) + '&lt;/dd&gt;' + '&lt;dd class="last"&gt;' + value.CType + ', ' + value.CSize + '&lt;br&gt;' + ' Ad: ' + value.Ad + ', Chi: ' + value.Chi + '&lt;br&gt;' + ' Lu: ' + value.Big + ' Big, ' + value.Lu + ' Small' + '&lt;/dd&gt;' + '&lt;/dl&gt;' + '&lt;/li&gt;' + '&lt;/ul&gt;' + '&lt;/td&gt;' ); </code></pre>
jquery
[5]
5,868,393
5,868,394
ObjectDataSource - data biding - asp.net
<p>Here the object "BookShop" has properties AuthorName and AuthorId of type "string", Is it possible to code a user defined class like "BookDetails" so that I can specify something like BookDetails.Author or </p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="ObjectDataSource1" DataTextField="AuthorName" DataValueField="AuthorId"&gt; &lt;/asp:DropDownList&gt; &lt;asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetAuthors" TypeName="BookShop"&gt; &lt;/asp:ObjectDataSource&gt; &lt;/form&gt; </code></pre>
asp.net
[9]
1,208,724
1,208,725
Is there a javascript equivalent of .= for self concatenating?
<p>Rather than doing</p> <pre><code>my_var = my_var+'extra string'; </code></pre> <p>is there a shorthand method like .= in php?</p>
javascript
[3]
1,543,135
1,543,136
How to make infinite loop in an Activity
<p>When somebody is doing some game they can do it like this: <code>mainActivity</code> which extends <code>Activity</code> and in this main activity there is a method e.g: </p> <pre><code>setContentView(BouncingBallView); </code></pre> <p><code>BouncingBallView</code> extends <code>View</code> and there we have got methods: <code>onDraw()</code> <code>invalidate()</code> and these methods are use to do update and they are performing in all frames. </p> <p>My problem is I would like to have some method like "onDraw-invalidate" which are update but in class <code>Activity</code> not in <code>View</code>.</p> <p>I would like to know if there are some main loop, methods which are perform all the time some <code>update()</code>? I know that in <code>Activity</code> there is: <code>onCreate()</code>; <code>onStart()</code>; <code>onRestart()</code>; <code>onResume()</code>; <code>onPause()</code>; <code>onStop()</code>; and <code>onDestroy()</code>, but I can't see update? How would I do this?</p>
android
[4]
5,799,912
5,799,913
Cycle "for" in python like in C
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/477486/python-decimal-range-step-value">Python decimal range() step value</a> </p> </blockquote> <p>I have a cycle in C:</p> <pre><code>for (float i = 0; i &lt; 2 * CONST; i += 0.01) { // ... do something } </code></pre> <p>I need the same cycle in python, but:</p> <pre><code>for x in xxx </code></pre> <p>not the same.</p> <p>How can i make it in python?</p>
python
[7]
387,127
387,128
How can I bypass IE's popup blocker so my JavaScript popup works?
<p>I have to open a new window</p> <pre><code>window.open(); </code></pre> <p>But in IE, it will detects a popup and block, if I allow then the window is opened.</p> <p>How can I bypass this popup blocker and open it directly?</p>
javascript
[3]
4,092,970
4,092,971
QFlags python alternative
<p>In PyQt4, what is the alternative for:</p> <pre><code>class TestClass { public: enum Option { OptionA = 0x0, // 0x000000 OptionB = 0x1, // 0x000001 OptionC = 0x2, // 0x000010 OptionD = 0x4, // 0x000100 OptionE = 0x8, // 0x001000 OptionE = 0x10 // 0x010000 // ... some more options with value which is a power of two }; Q_DECLARE_FLAGS(Options, Option) }; Q_DECLARE_OPERATORS_FOR_FLAGS(TestClass::Options) </code></pre> <p>How do I convert this block to python?</p>
python
[7]
4,162,272
4,162,273
Deleting a line from a file
<p>Please help to solve this problem. I want to delete every line from a file after reading that line. Can we delete like this? I don't want use any temporary file to do this process.</p> <p>please help me, thank you.</p>
java
[1]
699,838
699,839
java inheritance after compilation
<p><code>class Car extends Viecle</code></p> <p><code>Car</code>is compiled.</p> <p>Class <code>Client</code> uses <code>Car</code>.</p> <p>Are fields and methods from <code>Viecle</code> put into <code>Car</code> class during compilation, or <code>Car</code> simply needs class <code>Viecle</code> to be compiled (and not removed) in compile and after - during runtime?</p>
java
[1]
4,454,846
4,454,847
prevent go to the top page
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5448962/scroll-go-to-the-top-page">scroll go to the top page</a> </p> </blockquote> <p>Hi all </p> <p>please how i can prevent go to the top page when post back page (asp.net)</p>
asp.net
[9]
5,854,613
5,854,614
Python Syntax Error on Bit Literal
<p>I have inherited this python program and, being sort of a noob with bits and such I can't figure out what the problem is. I am getting a syntax error on the first line of the following function:</p> <pre><code>def tileKey(self, z, x, y): zBits = z &amp; 0xFFL # 8bits, 256 levels. normally [0,21] xBits = x &amp; 0xFFFFFFFL # 28 bits yBits = y &amp; 0xFFFFFFFL # 28 bits key = (zBits &lt;&lt; 56) | (xBits &lt;&lt; 28) | (yBits &lt;&lt; 0) # return the key value integer 720576213915009588 return key </code></pre>
python
[7]
1,256,824
1,256,825
Operator '&&' cannot be applied to operands of type 'System.DateTime' and 'System.DateTime'
<p>I thought this would work, but apparently it doesn't. Any suggestions please? </p> <pre><code>if (c.ArrivalTime = DateTime.MinValue &amp;&amp; c.ExpiryTime = DateTime.MinValue) { } </code></pre> <p>then I got this, <em>Operator '&amp;&amp;' cannot be applied to operands of type 'System.DateTime' and 'System.DateTime'</em></p>
c#
[0]
5,067,674
5,067,675
Get all elements by inner text
<p>I'm stuck with a problem: I want to search for a string in a html document. So far I tried with window.find(..) method, but I can't get back the node of the found elements. Just for example i can highlight all the matching texts. But I want to put all the nodes in an array, and I can't find a method, which can return me the node of the selected text. The following code only highlights the matching texts, I want to get the (parent) node of it.</p> <pre><code>function doSearchAdam(text) { if (window.find &amp;&amp; window.getSelection) { document.designMode = "on"; var sel = window.getSelection(); sel.collapse(document.body, 0); while (window.find(text)) { document.execCommand("HiliteColor", false, "yellow"); sel.collapseToEnd(); } document.designMode = "off"; } else if (document.body.createTextRange) { var textRange = document.body.createTextRange(); while (textRange.findText(text)) { textRange.execCommand("BackColor", false, "yellow"); textRange.collapse(false); } } </code></pre> <p>}</p> <p>Thanks guys! Adam</p>
javascript
[3]
4,392,276
4,392,277
Removing link from second span
<p>I have a page which list comments of users.</p> <p>My problem is that I have two span</p> <p><img src="http://i.stack.imgur.com/OVyMK.png" alt="enter image description here"></p> <p><img src="http://i.stack.imgur.com/0h31P.png" alt="enter image description here"></p> <p>When i click "devam" link as you see, the second span, the long one is showing.What i want to the is that removing "devamı" button, if the user clicks it.</p> <p>This is my code.What might be the changes?</p> <pre><code> {foreach value=users from=$comment} &lt;tr&gt; &lt;td&gt;{$users.ADD_DATE}&lt;/td&gt; &lt;td&gt;{$users.NAME}&lt;/td&gt; {if $users.COMMENT|count_characters &gt; 95} &lt;td width="340px"&gt;&lt;span id=comment12kisa_{$users.ID}&gt;{$users.COMMENT|truncate:95:"..."} &lt;/span&gt;&lt;a href="" onclick="$('#comment12kisa_{$users.ID}').html($('#comment12kisaa_{$users.ID}').html());return false;"&gt;devamı&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;center&gt;&lt;input type="checkbox" name="checkComment[]" value={$users.Movie_Comment_ID}-{$users.MOVIE_ID} &gt;&lt;/center&gt;&lt;/td&gt; {else} &lt;td width="180px"&gt;{$users.COMMENT}&lt;/td&gt; &lt;td&gt;&lt;center&gt;&lt;input type="checkbox" name="checkComment[]" value={$users.Movie_Comment_ID}-{$users.MOVIE_ID}&gt;&lt;/center&gt;&lt;/td&gt; {/if} &lt;span id="comment12kisaa_{$users.ID}" style="display:none"&gt;{$users.COMMENT}&lt;/span&gt; &lt;/tr&gt; {/foreach} </code></pre>
php
[2]
229,563
229,564
Send Data To Different Domain
<p>I need to send a fairly small amount of data (~215characters) from Domain A to Domain B using only JavaScript (No JQuery, etc). I have full control over Domain B, so how the data gets there really isn't as important as how it's sent (Only using JavaScript) and there is zero need for Domain B to send anything back to Domain A. </p> <p>I believe one solution to this problem is having Domain A request an image file with a query string from Domain B. On Domain B I can then capture the request and parse the data in the query string. In fact, I believe this is how analytics works.</p> <p>Possible other solutions?</p>
javascript
[3]
4,620,564
4,620,565
Python: Download Image From Link Without Picture Extension
<p>How would I go about downloading the picture from the following link:</p> <p><a href="http://cdn.svcs.c2.uclick.com/c2/332b584051f7012f2fd300163e41dd5b" rel="nofollow">http://cdn.svcs.c2.uclick.com/c2/332b584051f7012f2fd300163e41dd5b</a></p> <p>Thanks</p>
python
[7]
5,006,511
5,006,512
"blinking" boolean with system.currentTimeMillis()
<p>Why is this value always true? I just can't figure out how to have a boolean that "blinks" every second.</p> <pre><code>long millis = System.currentTimeMillis(); boolean blink = (Math.floor(millis/1000 + 0.5)==Math.floor(millis/1000)); </code></pre>
java
[1]