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
6,001,496
6,001,497
jQuery: Handling background/container click
<p>I have a big div, and a small button inside the div.</p> <p>When the div is clicked, I want it to do something.<br> When the button is clicked, I want it to do something else.</p> <pre><code>$('#myDiv').click(OnDivClicked); $('#myButton').click(OnButtonClicked); </code></pre> <p>Currently when the button is clicked, both OnDivClicked and OnButtonClicked are fired.</p> <p>How do you prevent OnDivClicked getting fired when the button is clicked?</p> <p>Thanks in advance.</p>
jquery
[5]
699,744
699,745
jQuery validate onfocusout
<p>I am trying to validate this form located here: <a href="http://jsfiddle.net/PEmFH/8/" rel="nofollow">http://jsfiddle.net/PEmFH/8/</a> I want to validate on onfocusout (validate every time the user leaves the field). It is not working for some reason.</p> <p>Please find the updated fiddle here: <a href="http://jsfiddle.net/PEmFH/11/" rel="nofollow">http://jsfiddle.net/PEmFH/11/</a></p>
jquery
[5]
2,562,374
2,562,375
PHP, Generating Primes, Whats Wrong
<p>Whats wrong with this? The conditional statement looks solid enough, yet all numbers are included</p> <pre><code>function generate_primes(){ $max = 100; $primes = array(); for($current_pointer = 1; $current_pointer &lt;= $max; $current_pointer++){ for($divider = 1; $divider &lt;= $current_pointer; $divider++){ //if(in_array($divider, $primes)){ if(($current_pointer % $divider === 0) &amp;&amp; ($divider !== 1) &amp;&amp; ($divider === $current_pointer)){ $primes[] = $current_pointer; } //} } } print_r($primes); } generate_primes(); </code></pre>
php
[2]
4,147,521
4,147,522
Why is my app filtered for Android 1.5 and 1.6 devices?
<p>Our last update for our application caused it to be filtered out for Android 1.5 and Android 1.6 devices. We did not change anything in our manifest (aside from the updated version code). </p> <p>These similar questions did not help:<br> <a href="http://stackoverflow.com/questions/4952197/android-app-no-longer-visible-by-android-1-5-on-devices">Android App no longer visible by Android 1.5 on devices</a><br> <a href="http://stackoverflow.com/questions/7225372/android-app-not-appearing-in-market-for-1-51-6-devices-bluetooth-is-androidreq">Android app not appearing in Market for 1.5&amp;1.6 devices, Bluetooth is android:required=&quot;false&quot;</a> </p> <p>We created a test app with a stripped down manifest and compiled it with the Android 1.5 SDK. Even this basic app is filtered out. We tried contacting Android Market support five days ago but Google makes it pretty clear they don't want to provide support to developers and say that it's unlikely we'll get a reply.</p> <p>Here is the <strong>full</strong> AndroidManifest.xml for the test app:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.highwaynorth.test" android:versionCode="6" android:versionName="6.0"&gt; &lt;uses-sdk android:minSdkVersion="3" /&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt; &lt;activity android:name=".MainActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Why is this being filtered?</p>
android
[4]
2,803,902
2,803,903
how to unzip a zip file containing files with special characters in its name in android?
<p>how can I unzip a zip file containing files with special characters in its name in android programmatically? my file names are like <strong>&lt;_Artist>Hello&lt;_Artist>.txt</strong> .</p>
android
[4]
2,077,471
2,077,472
Should I check if ProgressBar isShowing before dismissing it?
<p>Im dismissing progress dialog when AsyncTask is finished. Should i check isShowing before dismissing it?</p> <p>I've tried remove this check and it works normally, but may be there are hidden traps?</p> <pre><code>if (progressDialog.isShowing()) { progressDialog.dismiss(); } </code></pre>
android
[4]
177,176
177,177
.toFixed() not working
<p>im using this code</p> <pre><code>$('tr').each(function () { var td = $(this).children('td').eq(1); var val = td.html(); if (val &gt; 1000) { var fixedVal = parseFloat(parseFloat(val).toFixed(3)); td.html(fixedVal / 1000 + " KM"); } else { td.html(Math.round(val) + " M"); } }); </code></pre> <p>and yet iam getting values like </p> <pre><code>3.5101280000000004 KM 8761.596300000001 KM </code></pre> <p>the problem is that <code>.toFixed()</code> is not working properly.</p>
javascript
[3]
3,951,344
3,951,345
How to create a div using wrap() and then select it in jquery?
<p>I am doing the following within a jquery plugin and I'm looking a way to select the divs after they are created. I'd like to avoid giving them an id as then I would need to concern myself with making the id unique.</p> <pre><code>$('.something').wrap('&lt;div /&gt;'); </code></pre> <p>also:</p> <pre><code>$('.something').after('&lt;div&gt;&lt;/div&gt;'); </code></pre> <p>Thanks for any help</p>
jquery
[5]
4,956,234
4,956,235
A javascript to calulate multiplications of all elements
<p>I am searching a Javascript that will calculate multiplication of all elements. For example I have :</p> <pre><code>&lt;div id=div_to_calculate&gt; &lt;label id=value&gt; 1.5 &lt;/label&gt; &lt;label id=value&gt; 1.9 &lt;/label&gt; &lt;label id=value&gt; 2.5 &lt;/label&gt; &lt;label id=value&gt; 1.7 &lt;/label&gt; &lt;/div&gt; </code></pre> <p>I need to calculate all elements where id=value.</p> <p>Thank you.</p>
javascript
[3]
2,370,298
2,370,299
get imagepath from database and after that get the image from sdcard in android
<p>hello i am new to android and so thinking how the thing can be done.so the task is, previously i had some imagepath already save in the sqlite database and on the private folder inside sdcard,now i want to retrieve it from the database so with my knowledge it can done through <em>cursor</em>,now i got the imagepath with some unique id,now i want to use that imagepath and get the specified image from the private folder of sdcard,and now when we got the image we had to display on the gridview also.if code is require please let me know. thanks.</p>
android
[4]
1,696,461
1,696,462
How to check for end of tag in Python using minidom?
<p>I'm trying to create an expression from an XML. Reading from top node I want to put the node one by one into a stack, once I hit a closing tag I want to pop all elements in the stack. How do I check the end of a tag ?.</p> <p>TIA, </p> <p>John</p> <p>Answer: </p> <p>OK, I think I've the solution, using a recursive function like this:</p> <pre><code>def findTextNodes(nodeList): for subnode in nodeList: if subnode.nodeType == subnode.ELEMENT_NODE: print("element node: ",subnode.tagName) # call function again to get children findTextNodes(subnode.childNodes) print('subnode return: ', subnode.tagName) elif subnode.nodeType == subnode.TEXT_NODE: print("text node: ",subnode.data) </code></pre> <p>When the 'subnode return' it hits the closing tag!.</p> <p>Thanks everybody!.</p>
python
[7]
1,764,855
1,764,856
Loading images from the server is very slow
<p>I am trying to load images from the server and want to know how can i convert the images into the thumbnails so that they get uploaded fast and how can i get the larger images from the thumbnails fast . I have tried many things. </p> <p>Thanks in advance</p>
android
[4]
5,191,990
5,191,991
Adding an integer number to a Unicode character - What does this do?
<p>I am learning C# in the beginners level. I do not understand what adding an integer number to a Unicode character does. What does the addition do in the example below?</p> <pre><code>int amount = int.Parse(number.Text); steps.Text = ""; string current = ""; do { int nextDigit = amount % 8; amount /= 8; int digitCode = '0' + nextDigit; char digit = Convert.ToChar(digitCode); current = digit + current; steps.Text += current + "\n"; } while (amount != 0); </code></pre>
c#
[0]
189,333
189,334
python lottery suggestion
<p>I know python offers random module to do some simple lottery. Let say random.shuffle() is a good one.</p> <p>However, I want to build my own simple one. What should I look into? Is there any specific mathematical philosophies behind lottery?</p> <p>Let say, the simplest situation. 100 names and generate 20 names randomly.</p> <p>I don't want to use shuffle, since I want to learn to build one myself.</p> <p>I need some advise to start. Thanks.</p>
python
[7]
2,845,540
2,845,541
In C# how to create a List<T> with a default count of zero?
<p>Rookie question: </p> <p>I have been experiencing a minor bug in my mvc2 application. I was able to trace it back to this code:</p> <pre><code>List&lt;Stream2FieldTypes&gt; Stream2FieldTypes = new List&lt;Stream2FieldTypes&gt;(); foreach (var item in stream.Stream2FieldTypes) { Stream2FieldTypes.Add(item); } </code></pre> <p>The problem that I am experiencing is that when I instatiate the new list, it has a count of one. I'm thinking that this is probably due to my using the constructor. So I tried this:</p> <pre><code>List&lt;Stream2FieldTypes&gt; Stream2FieldTypes; foreach (var item in stream.Stream2FieldTypes) { Stream2FieldTypes.Add(item); } </code></pre> <p>But, of course this will not compile because of an error on <code>Stream2FieldTypes.Add(item);</code>. Is there a way that I can create a <code>List&lt;Stream2FieldTypes&gt;</code> and make sure that the count is zero?</p>
c#
[0]
4,079,454
4,079,455
Reading using fstream character by character and passing the fstream to a function for further reading?
<p>Ok so I'm trying to open a file for reading and I want to read the first character only then depending on what that character is I send it to a given function. For example if it is a number, I send it to a function that continues reading to see if its just an int or a float. I cant seem to figure out how to do this </p> <pre><code>void dummy(char dum, std::ifstream&amp; fin){ char test = dum; fin&gt;&gt;test; string simple = simple + test; simple = simple + test; ofstream outFile; outFile.open("output.txt"); outFile&lt;&lt;simple&lt;&lt;"\n"; return; } int main(int argc, char *argv[]){ char c; //ifstream readFile; /*if(argc &gt;= 1){ readFile.open(argv[1]); }*/ ifstream readFile; readFile.open("input.txt"); readFile.unsetf(ios_base::skipws); readFile&gt;&gt;c; while(!readFile.eof()) { switch(c){ case 'a': dummy(a,readFile); } } } </code></pre> <p>it keeps throwing this error: Microsoft C++ exception: std::bad_alloc at memory location (location). Any help is greatly appreciated. </p>
c++
[6]
449,850
449,851
Convert a string date with full month names to a date object in java
<p>How can I convert dates with full month names into a Date object in Java? Here's a sample date that I need to convert: 6 December 2002.</p> <p>Thanks.</p>
java
[1]
1,952,785
1,952,786
How can I make jquery load after all images loaded completed?
<p>I have a page full of images with different width and height. I need to get thire width. But jquery always make it before the images loaded. so the width of the image I got was a broken image width. </p> <p>I tried $(document) and $(window), all faild. Anyone can help me?</p>
jquery
[5]
381,336
381,337
How to efficiently render different things at different times in a game?
<p>Sorry for the ambiguous title. What I am wondering is what is an efficient way to alternate rendering between lets say a main menu, options menu, and "in the game." </p> <p>The only two ways I've come up with so far are to have 1 render function, with code for each part (menu, ...) and a variable to control what gets drawn, or to have multiple render functions, and use a function pointer to point to the appropriate one, and then just call the function pointer.</p> <p>I always wonder how more professional games do it. </p>
c++
[6]
2,905,228
2,905,229
How can I align image vertical center in a Linear Layout
<p>I have the following layout, which is 1 icon on the left and 2 text views (stack on top of each other) on the right. I would like to have the text1 vertically center in the panel and when I make the text2 Visible.GONE. Can you please tell me how can i do that? </p> <pre><code>&lt;RelativeLayout android:id="@+id/panel" android:layout_width="fill_parent" android:layout_height="?android:attr/listPreferredItemHeight"&gt; &lt;ImageView android:id="@+id/icon1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_gravity="center_vertical"/&gt; &lt;TextView android:id="@+id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/icon1" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_gravity="center_vertical"/&gt; &lt;TextView android:id="@+id/text2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/icon1" android:layout_below="@id/text1" android:textAppearance="?android:attr/textAppearanceSmall"/&gt; &lt;/RelativeLayout&gt; </code></pre>
android
[4]
1,160,148
1,160,149
Problem compiling C++ class
<p>I am running a C++ program which uses a class from another .cpp file. The class only has a constructor. It works when I test it separately. The main program compiles,but when I run it, I have a bug in the constructor. Any one can think of any situation that could happen? Thanks. </p> <p>I guess I just run the code in terminal, and it is fine. But when I try to build a project in eclipse, it shows following code has multiple definition error:</p> <pre><code>class model { public: int textures []; float vertices[][3]; float triangles[][13]; public: model(const char*); // constructor }; model::model(const char* filename) { </code></pre> <p>error message is: multiple definition of `model::model(char const*)'</p> <p>any idea?</p>
c++
[6]
107,150
107,151
What is the best approach to scale complex layout
<p>What is the best approach to scale complex layout so it will shrink on small screens (buttons, text images) and stretch on big proportionally? For example i have an calendar layout with month title, grid full of day numbers, navigation buttons etc. I want it to be fullscreen on 320x480 and on 1280x720 with all elements stay on screen just scaled if needed.</p>
android
[4]
2,944,108
2,944,109
what is the best way to write a for in loop to the page
<pre><code>var family = { dad: 'Father', mom: 'Mother', son: 'Boy', daughter: 'Girl' } for ( var person in family ) { console.log('&lt;li&gt;' + 'the ' + person + ' is a ' + family[person] + '&lt;/li&gt;') } </code></pre> <p>I want to know what the best way to insert this into the DOM instead of logging it to the console. I want to use just JavaScript</p>
javascript
[3]
3,095,342
3,095,343
How can I remove some characters from a C# string?
<p>I have the string:</p> <pre><code>http://127.0.0.1:96/Cambia3 </code></pre> <p>The number 96 could be anything from 75 to 125. </p> <p>Is there a simple way that I could remove this number to get:</p> <pre><code>http://127.0.0.1/Cambia3 </code></pre>
c#
[0]
4,656,271
4,656,272
RDTSC vs. StopWatch
<p>I programmed my own string matching algorithm, and I want to measure its time accuratly, to compare it with other algorithms to check if my implementation is better.</p> <p>I tried (StopWatch), but it gives different time in each run, because of multiple processes running of the Windows OS. I heared about (RDTSC) that can get the number of cycles consumed, but I do not know if it gives different cycles number in each excution too ?</p> <p>Please help me; Can (RDTSC) give an accurate and same measurment of cycles for a C# function, or it is similar to (StopWatch) ? Which is the best way to get cycles number for a C# function alone without the other running processes ? and thanks alot for any help or hint</p>
c#
[0]
361,219
361,220
Initializing an Array with a Single Value
<p>Is there a more compact way to do this sort of initialization?</p> <pre><code>for (var i = 0; i &lt; arraySize; i++) array[i] = value; </code></pre>
javascript
[3]
4,566,170
4,566,171
option in select is not selected without alert() in jQuery
<p>I have the following code snippet in my jquery. <code>update_obj['events']</code> holds the values of the options that I want to get selected. I have a set of <code>select</code> elements and their id begins with <code>event_drop_down_</code>. This code works fine. But if I comment the <code>alert(v)</code> the options are not get selected in the <code>select</code> elements. The only other event related to the <code>select</code> elements is <code>.change()</code>. I commented it and tried, still the issue persists. Any help/suggestion to overcome this is highly appreciated.</p> <pre><code> var i =0; $(update_obj['events']).each(function(v){ alert(v); $('#event_drop_down_' + i + ' option[value=' + update_obj['events'][v] + ']').attr('selected', 'selected'); i = i+1; }); </code></pre>
jquery
[5]
443,573
443,574
How to get the current context? i have to use it in the array adapter
<p>I want to use it in tha array adapter. when i put "this" in a sub activity to create an adapter it is not working.</p>
android
[4]
2,609,543
2,609,544
C# check if one collection of values contains another
<p>Suppose I have two collections as follows:</p> <p>Collection1: "A1" "A1" "M1" "M2"</p> <p>Collection2: "M2" "M3" "M1" "A1" "A1" "A2"</p> <p>all the values are string values. I want to know if all the elements in Collection1 are contained in Collection2, but I have no guarantee on the order and a set may have multiple entries with the same value. In this case, Collection2 does contain Collection1 because Collection2 has two A1's, M1 and M2. Theres the obvious way: sorting both collections and popping off values as i find matches, but I was wondering if there's a faster more efficient way to do this. Again with the initial collections I have no guarantee on the order or how many times a given value will appear</p> <p>EDIT: Changed set to collection just to clear up that these aren't sets as they can contain duplicate values</p>
c#
[0]
2,060,989
2,060,990
onblur name field
<p>I can't seem to find a way to get the javascript to take the inputted name I put in the box to make it appear where the paragraph is as output when the onblur event happens.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;!-- INFX1606 - Starter kit for Assignment 5. --&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;meta name="author" content="Joey Fultz"&gt; &lt;meta name="description" content="Assignment 5"&gt; &lt;title&gt;First Swing at Javascript&lt;/title&gt; &lt;link href="css/style.css" rel="stylesheet" type="text/css" media="all" /&gt; &lt;script type="text/javascript" src="js/scripts.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="all"&gt; &lt;div class="title"&gt; &lt;h2&gt;Javascript&lt;/h2&gt; &lt;/div&gt; &lt;div&gt; &lt;h3&gt;Name and Banner&lt;/h3&gt; &lt;/div&gt; &lt;span&gt; &lt;label for="namebanner"&gt;Name:&lt;/label&gt; &lt;input type="text" id="namebanner" name="namefield" onblur="showname() value"&gt; &lt;/span&gt; &lt;p id="p1"&gt;&lt;/p&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; function showname() { var x = document.getElementById("namebanner"); x.value = x.value.to("p1"); } </code></pre> <p>I want to know why my javascript is wrong and why it won't show my name when the onblur event happens.</p>
javascript
[3]
3,291,764
3,291,765
Disable a Spinner Value?
<p>How to Disable a Spinner Value?</p>
android
[4]
4,004,066
4,004,067
How to compare two values in Java?
<p>I need to compare two objects in Java, but they contain a lot of members, some not visible, and I don't have access to the source code - they're objects from a third-party package.</p> <p>I need to find out what are the differences between them. Something like comparing chunks of memory in C++. But I don't know how to do it in Java.</p> <p>Any help?</p> <p>EDIT: Some further info: I am doing some operations on two objects - on one the ops succeed, on the other they fail. However I can't tell what's different, that's why I need this comparison. I can't seem to get reflection to work, member not visible exception or smth like that on private members.</p>
java
[1]
2,441,367
2,441,368
js Diagonal movement at minute speeds
<p>There are numerous questions on SO similiar to this but not exactly as far as I could tell.</p> <p>Want to move an object along a path at a slow pace. Here's an example of what I've got.</p> <pre><code>var moverateX,moverateY; function setup (){ var opp=targetY-startY; var adj=targetX-startX; var hyp=Math.sqrt ((opp*opp)+(adj*adj)); moverateY=10*(opp/hyp); moverateX=10*(adj/hyp);} function okgo (){ obj.style.left=currentX+moverateX+'px'; obj.style.top=currentY+moverateY+'px'; setTimeout (function (){okgo ();},50);} </code></pre> <p>It works but moves too quickly. If I change the number the ratio is multiplied by to a smaller one, the object misses the end target. eg:</p> <pre><code>var moverateY=2*(opp/hyp); var moverateX=2*(adj/hyp); //moves slower but misses the end mark by a fair margin </code></pre> <p>Any ideas?</p>
javascript
[3]
2,196,070
2,196,071
Get value array in javascript
<p>How to get value in javascript when input name/id generated by looping, just like this.</p> <pre><code>name="items[1AV08EBfeb][srdnReqQty1AV08EBfeb]" --js-- var form = document.forms[0]; var get = form.items[1AV08BBjan][srdnReqQty1AV08BBjan].value; alert(get); //error missing ] --js-- </code></pre> <p>Any suggestion ?</p> <p>Thanks<br/> MRizq</p>
javascript
[3]
4,446,770
4,446,771
How to add javascript to php page
<p>I see a lot of script adding Javascript to their webpages in different ways and am trying to figure out the correct way to do it. For example, in the header of one of the php scripts I use it has this:</p> <pre><code>&lt;script type="text/javascript" src="/javascriptfile.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; var stuff = "file.php"; var ip_add = '32.42.42.442'; &lt;/script&gt; </code></pre> <p>What I don't understand is why would you ever put the full javascript code in the header instead of just including it within a file. For example, why not move the javascript mentioned about into it's own file and just just use this in your header:</p> <pre><code>&lt;script type="text/javascript" src="/javascriptfile.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/javascriptfile2.js"&gt;&lt;/script&gt; </code></pre> <p>Are there certain times you should have the full javascript displayed in the page source instead of just linking to it in its own javascript file?</p>
javascript
[3]
2,425,259
2,425,260
Taking string Input and making a int array
<p>How do I take an string input and make it into an int array? </p> <pre><code>string input = Console.ReadLine(); int numb = Convert.Toint32(input); int[] intArray = // what do i write here to make it take the "input" length, and put the input into an int array? </code></pre>
c#
[0]
3,901,280
3,901,281
jQuery Sticking Fade On Clicks
<p>I have three divs with the class 'thumbs' and they are used to select products. I'm currently using the following code to highlight the current choice:</p> <pre><code>$('.thumbs').hover(function(){ $(this).stop().fadeTo("normal", 1.0); },function(){ $(this).stop().fadeTo("slow", 0.5); }); </code></pre> <p>By default all choices are at 50% opacity, when you hover over the choice it will fade to 100% opacity and when you move your mouse it will go back to 50%. The problem is I want it to stay at 100% when an option is clicked, and then only have the other 2 options changed on hover. Then when another option is clicks I want that to go to 100% opacity and the others to go back to 50%. I hope I've explained myself well, if not feel free to comment. Any help would be greatly appreciated.</p>
jquery
[5]
2,686,931
2,686,932
DNS server connont be found
<p>I am new to android . i created a simple examples and run it in emulator ,ever time where the emulator prepare to running i give me an warning : DNS server not found and emulator start normally ,what this mean? and what this effect on my application?and why android do'es needs an DNS server ? </p>
android
[4]
1,026,475
1,026,476
jQuery validate phone number
<p>I'd like to validate phone number as: (000) 111-1111 I'm using this snippet, which works fine if the user enters only numbers. but if he started with a brackets, all crashes .. I really would need help ...</p> <pre><code>$("input#phone1,input#phone2").keyup(function() { var curchr = this.value.length; var curval = $(this).val(); //var numericReg = /^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/; var numericReg = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/; if(!numericReg.test(curval)) { $(this).prev('label').append(tag_error + numeric_chars_only + end_tag); console.log($(this)+numeric_chars_only); } if (curchr == 3) { $("input#phone1").val("(" + curval + ")" + " "); } else if (curchr == 9) { $("input#phone1").val(curval + "-"); } }); </code></pre>
jquery
[5]
2,138,026
2,138,027
How to force the DropDownList to take both value and text of the source?
<p>I've struggling for hours now with this issue. I have a list that I keep in the Session</p> <pre><code>Session["AllDev"] = taskData.DisplayAllDevelopers(); </code></pre> <p>I use it later this way.</p> <pre><code>_ddlAllDev.DataSource = (ListItemCollection)Session["AllDev"]; _ddlAllDev.DataBind(); </code></pre> <p><strong>DisplayAllDevelopers()</strong> method returns a ListItemCollection. Each ListItem contains the <strong>ID</strong> of the Developer as Value and the <strong>name of the Developer</strong> as Text. But When I check the items collection, I find that the DropDownList has both the value and the text set to the name of the devoloper. Is there a way to force the DropDownList to keep the Value and the Text as the source is?</p> <p>Thanks for helping.</p>
asp.net
[9]
4,565,213
4,565,214
how could we obtain magnitude of frequency from a set of complex numbers obtained after performing FFT in python?
<p>Hi folks i don't know what to do after obtaining a set of complex numbers from FFT on a wav file.How could i obtain the corresponding frequencies.This is output i got after performing FFT which is shown below</p> <pre><code>[ 12535945.00000000 +0.j -30797.74496367 +6531.22295858j -26330.14948055-11865.08322966j ..., 34265.08792783+31937.15794965j -26330.14948055+11865.08322966j -30797.74496367 -6531.22295858j] </code></pre>
python
[7]
3,855,251
3,855,252
C# if (strValue == "FALSE" | strValue == "TRUE")
<p>I have a string that contains a value of either TRUE or FALSE or null, this value is read from a text file which is outside of my control. What is the best way to use '|' with 'if'? Keeping in mind strValue could also be null, if strValue is null then I don't want to enter the if statement.</p> <pre><code>if (strValue == "FALSE" | strValue == "TRUE") { //do stuff } </code></pre> <p>Thanks</p>
c#
[0]
2,708,281
2,708,282
Calculate the difference b/w two given times in java
<p>I am trying to calculate the difference between given two times and i find some problem in it. Suppose we have times value are "11:AM" and 10:00 AM". I am able to calculate but there is a bit of confusion in AM ,PM. Thanks in advance</p> <p>I am using following code: import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date;</p> <p>public class StringToDate {</p> <pre><code>public static String timeDiff(String time1, String time2) { String Time = null; int difference; String a1 = time1.substring(6); String a2 = time2.substring(6); try { // Define a date format the same as the expected input SimpleDateFormat sdf = new SimpleDateFormat("HH:mm a"); // Get time values of the date objects long l1 = sdf.parse(time1).getTime(); long l2 = sdf.parse(time2).getTime(); difference = (int) (l2 - l1); difference = (difference &lt; 0 ? -difference : difference) / 60000; if (difference &gt; 60) { int Hour = difference / 60; int Mins = difference % 60; if (Mins == 0) Time = Hour + " Hours"; else Time = Hour + " Hours" + " " + Mins + " Mins"; } else { Time = difference + " " + "Mins"; } } catch (ParseException e) { e.printStackTrace(); } return Time; } public static void main(String[] args) { String diff = StringToDate.timeDiff("10:00 AM", "01:00 PM"); System.out.println("Difference: " + diff); } </code></pre> <p>}</p>
java
[1]
1,178,096
1,178,097
Is it possible jQuery to call the siblings of a closest element?
<p>I have the following jQuery:</p> <pre><code>$(this).closest('div.mcoup').find('div.delcoup').slideToggle(400) .siblings().children('div.delcoup').slideUp(400); </code></pre> <p>What I'm trying to do is get the siblings of the div.mcoup element then find all children of the siblings with the class .delcoup then slide them up.</p> <p>Is this possible?</p>
jquery
[5]
2,629,741
2,629,742
Prefixing string from Android Database
<p>I am trying to display information from a database in my android app. However, I would like it prefixed with the character €. Is that possible?</p> <p>My Current code:</p> <pre><code>String[] from = new String[]{savingDB.KEY_DATE}; int[] to = new int[]{R.id.date}; </code></pre> <p>What I tried:</p> <pre><code>String[] from = new String[]{"€" + savingDB.KEY_DATE}; int[] to = new int[]{R.id.date}; </code></pre>
android
[4]
589,265
589,266
PHP beginner design patterns and frameworks
<p>I am planning to start learning PHP and MySQL for developing e-commerce type websites. I have 3 months of free time to start doing this, and a programming background of Java and javascript of 1 year of practical experience. </p> <p>I have already selected 2 books that will get me started and get me on an intermediate level : <a href="http://rads.stackoverflow.com/amzn/click/0672329166" rel="nofollow">PHP and MySQL Web Development 4th Edition</a> and <a href="http://www.apress.com/9781590598641" rel="nofollow">Beginning PHP and MySQL E-Commerce From Novice to Professional</a>.</p> <p>I am interested in developing e-commerce websites and I want to do it right since I will also be doing it for other people in the near future (6-8 months from the moment I start). </p> <p>While I am sure about the first book that will help me achieve what I need for the second I am open to suggestions.</p> <p>My first problem is that these 2 books won't be enough for what I need. I have no experience in using MVC architecture which seems to be the main architecture these days for writing big and sustainable projects and also no knowledge of any other design pattern which is used these days. </p> <p>Can anybody recommend a good book or resource for understanding and writing MVC projects and getting familiar with good OOP design patterns?</p> <p>My second problem is that I am undecided if I should learn a PHP framework immediately or I should try working with it as it is. If I am going to learn a framework, I decided on Codelgniter. Is it a good choice for e-commerce development?</p> <p>I mostly chose it because it is considered one of the fastest frameworks. I am not seeking to start a holy war on wether is best to use a framework or not what I want is to know if it is a good idea to learn a framework immediately after I learned PHP ? If it is or not a good idea I would like some arguments so I can better decide.</p> <p>I already decided I will use a framework on some point so I can increase productivity so I am not seeking a debate.</p>
php
[2]
2,163,579
2,163,580
How to add list items for a combo box
<p><br> I have tried to create items for a combo box but it is not working.Please help me out. This is what i have so far;</p> <pre><code>private void cb_avg_weeks_month_SelectedIndexChanged(object sender, EventArgs e) { cb_avg_weeks_month.Items.Add('1'); cb_avg_weeks_month.Items.Add('2'); cb_avg_weeks_month.Items.Add('3'); } </code></pre> <p>Note:<br> <code>cb_avg_weeks_month</code> describes the name i have assigned to my combo box.</p>
c#
[0]
3,269,699
3,269,700
jQuery - Change text in an input field after it's created
<p>How can I write a script that will change an input field's text value, but the field is not yet created?</p> <p>The script is loaded before the input field is created. It needs to know that when any input with a certain class is created, it will then have some text put in to its value. Can this be done with <code>live()</code>?</p> <p>To clarify, the order of events are:</p> <p><strong>1</strong> - Application-wide JavaScript for the page is loaded. This contains script something along the lines of:</p> <pre><code>$('.myDiv input').each(function() { $(this).val('some text'); }); </code></pre> <p><strong>2</strong> - A second page-specific script is now loaded, which dynamically creates an input on the page, with no value. <strong>I CANNOT MODIFY THIS SCRIPT.</strong> This is important, I need a solution that does not modify this script (otherwise I wouldn't be posting here).</p> <pre><code>$('.myDiv').html('&lt;input type="text" /&gt;'); </code></pre>
jquery
[5]
5,644,304
5,644,305
Java out of heap space error while calling constructor.newInstance(String) multiple times
<pre><code>String type = “ClassNames”; MyInterface mi = (MyInterface) constructor.newInstance(type); </code></pre> <p>Above code snippet is called multiple times (around 3000 Classes) in my program and this leads to out of heap space error. Heap size reaches to 1024mb. Any workaround to keep the heap size low? Thanks!</p> <p><strong>The interface</strong></p> <pre><code>public interface MyInterface { public String[] getRowHeader(); public String[] getHeaderTable(); public String[][] getDataForSearch(); public String getInfoText(); } </code></pre> <p><strong>Public Class implementation</strong></p> <pre><code>public TablePanel() { try { guiInit(); } catch (Exception exception) { exception.printStackTrace(); } } </code></pre> <p>This guiInit() does the swing component initialization. </p> <p>In the same class methods are implemented like this below</p> <pre><code>public String[][] getDataForSearch() { return rowNames; } </code></pre>
java
[1]
4,871,057
4,871,058
Beginning Java : Finding the greatest number out of a list
<p>I am trying to write a code that prompts the user for three numbers and the program is supposed to say what number is the greatest. I didn't want to do a bunch of "System.out.print" in the if and else if statements. The error according to the debugger is that "greatest" and "greatest1" have not been initialized. </p> <pre><code>import java.util.Scanner; public class number1 { public static void main(String[] args) { double a, b, c; double greatest, greatest1; Scanner keyboard = new Scanner(System.in); System.out.print("Enter one number :"); a = keyboard.nextDouble(); System.out.print("Enter another number :"); b = keyboard.nextDouble(); System.out.print("Enter a third number :"); c = keyboard.nextDouble(); if(a &gt; b &amp;&amp; a &gt; c) { greatest = a; } //end of if statement else if(b &gt; a &amp;&amp; b &gt; c){ greatest = b; } else if(c &gt; a &amp;&amp; c &gt; b) { greatest = c; } else if(a==b &amp;&amp; c &lt; a) { greatest = a; greatest1 = b; } else if(a==c &amp;&amp; b &lt; a) { greatest = a; greatest1 = c; } else if(b==c &amp;&amp; a &lt; b) { greatest = b; greatest1 = c; } else { System.out.print("All of the numbers are greatest"); } System.out.print("The greatest number is: " +greatest+ "and" +greatest1); } } </code></pre>
java
[1]
1,007,866
1,007,867
open div with the help of javascript
<p>I want to open div when i take my mouse cursor on some specific link, and hide that div when i mouesout from the link.</p>
javascript
[3]
4,081,978
4,081,979
How to store image path in sqlite database in iphone
<p>I am new to iphone programming. Can any body tell me that how to store image path in sqlite database,i now how to store image in database but i dont want to store image.I want to store only path of the image in photo gallery.</p> <p>Please can any body tell me. Thanks </p>
iphone
[8]
4,812,276
4,812,277
POST a HTML Form programmatically and display response
<p>I need to prepare ASP.NET site with form, fill form in code behind and then submit form to external site.</p> <p>For example: user open www.myshop.com/pay.aspx, he does not have to fill anything because I fill form values in code behind and then user is automatically redirected to external site www.onlinepayments.com (with form data sent in POST).</p> <p>I am able to make it work with regular hidden form and javascript that submits form but I dont like this way (user can see html).</p> <p>So I use WebRequest class in code behind like in this answer: <a href="http://stackoverflow.com/questions/26857/how-do-you-programmatically-fill-in-a-form-and-post-a-web-page/26881#26881">How do you programmatically fill in a form and &#39;POST&#39; a web page?</a></p> <p>However in this answer Response is string (target site html). What can I do with this string? I want my user see target site (conent and URL) like it would happen with regular html POST.</p>
asp.net
[9]
4,426,848
4,426,849
function to return string in javascript
<p>I am trying to call an ajax request to my server for json data using a function. If I console out the <code>resp</code> variable inside the ajax function it will show the data successfully. If i try to set the ajax function to a variable, and then console that variable it returns undefined. Any ideas who to make the function request the data and then set ti to a variable to be consoled?</p> <pre><code>function jsonData(URL) { var xhr = new XMLHttpRequest(); xhr.open("GET", URL, true); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { var resp = JSON.parse(xhr.responseText); return resp; } } xhr.send(); } jsonString = jsonData(http://mywebsite.com/test.php?data=test); console.log(jsonString); </code></pre>
javascript
[3]
1,384,906
1,384,907
Problem when receiving focus on a list (Android)
<p>I have the following XML layout for a ListActivity.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; </code></pre> <p> <br> </p> <p></p> <pre><code> &lt;ListView android:id="@+id/android:list" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;TextView android:id="@+id/android:empty" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="No Contacts" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>My problem is that if I have focus on any of the header <code>ImageButton</code>s then when pressing down with the dpad the list <b>get focus on its 7th row</b> (depending on row height), <b>and not on the first row</b>. I've seen the same behavior on Fring application, under Contacts.</p> <p>I tried by listening for the OnKey event for the <code>KeyEvent.KEYCODE_DPAD_DOWN</code> and triggering a implicit focus on the first item of the list, but I don't know how to do it either.</p> <p>Do you have any idea on how to focus the first row of the List when getting the focus with a KeyEvent?</p>
android
[4]
5,255,727
5,255,728
python: convert "5,4,2,4,1,0" into [[5, 4], [2, 4], [1, 0]]
<p>Is there a "straightforward" way to convert a str containing numbers into a list of [x,y] ints?</p> <pre><code># from: '5,4,2,4,1,0,3,0,5,1,3,3,14,32,3,5' # to: [[5, 4], [2, 4], [1, 0], [3, 0], [5, 1], [3, 3], [14, 32], [3, 5]] </code></pre> <p>By the way, the following works, but wouldn't call it straightforward... Also, it can be assumed that the input str has been validated to make sure that it only contains an even number of numbers interleaved by commas.</p> <pre><code>num_str = '5,4,2,4,1,0,3,0,5,1,3,3,14,32,3,5' numpairs_lst = [] # ends up as [[5, 4], [2, 4], [1, 0], ...] current_num_str = '' # the current num within the str; stop when a comma is found xy_pair = [] # this is one of the [x,y] pairs -&gt; [5, 4] for ix,c in enumerate(num_str): if c == ',': xy_pair.append(int(current_num_str)) current_num_str = '' if len(xy_pair) == 2: numpairs_lst.append(xy_pair) xy_pair = [] else: current_num_str += c # and, take care of last number... xy_pair.append(int(current_num_str)) numpairs_lst.append(xy_pair) </code></pre>
python
[7]
3,419,514
3,419,515
I need a class that creates a dictionary file that lives on disk
<p>I want to create a very very large dictionary, and I'd like to store it on disk so as not to kill my memory. Basically, my needs are a cross between cPickle and the dict class, in that it's a class that Python treats like a dictionary, but happens to live on the disk. </p> <p>My first thought was to create some sort of wrapper around a simple MySQL table, but I have to store types in the entries of the structure that MySQL can't even hope to support out of the box. </p>
python
[7]
4,496,791
4,496,792
Is there any xml-include-like thing for Java class?
<p>When we make Android layout in XML, we can use <code>include</code> to make some other layout the part of the host layout. Is there such thing for Java class?</p> <p>I am attaching a top bar layout to every screen and it contains buttons. Now in every Java class I have to copy/paste the initialization code. </p> <p>Is there any shortcut for such scenarios? Can <code>Application</code> class facilitate anyhow? If anyone has a working solution, please share it with me. </p> <p>For example, in XML I can use</p> <pre><code>//...xml layout elements &lt;include layout="@layout/topbar" /&gt; //...some other xml layouts </code></pre> <p>so it would be cool to be able to use in Java code something where I could instantly initiate buttons, register <code>onClick</code> events and set actions to these events. It all the same piece of code I am using, after all. </p>
android
[4]
571,148
571,149
Local variable in closure changing from outside of it.This is a javascript bug or I am doing something wrong?
<p>I am using closure for privacy. I dont understand why and how to change local variable from outside of closure.</p> <p>I wrote a script for explain problem to you.</p> <pre><code>var MyAjax=(function(){ //Create a local variable for privacy var _opts={ cache:true } ,getDefaultOptions=function(){ return _opts }; //return only getDefaultOptions function return { getDefaultOptions:getDefaultOptions } })() //I am merging new ajax options with default options. var defaults=MyAjax.getDefaultOptions(); var reqOptions= $.extend(defaults,{cache:false}); // I am getting expected result console.log("extended var",reqOptions) //{cache:false} // I am getting non expected result // I should get {cache:true} but I am getting { cache:false } console.log("defaults",MyAjax.getDefaultOptions()) //{cache:false} </code></pre> <p>Why this happening and how ?</p>
javascript
[3]
3,799,333
3,799,334
Accesing Richtextbox from a class
<p>I'm trying to append text in my richtextbox which is called ConsoleText. It's not working very well. I'm using a property in my form to access the richtextbox in the Class.</p> <p>It looks like this:</p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); } //Skipped the rest public string ACText { set { ConsoleText.AppendText(value); } } </code></pre> <p>Now from my class's constructor.</p> <pre><code> public McDonalds(string email, string pass) { Form1 f = new Form1(); f.ACText = "test"; } </code></pre> <p>It's not showing any text in my richtextbox sadly. I know it works, because i can in the property use a messageBox and see that the value is passed into it.</p> <p>Thanks in advance i really need help with this.</p>
c#
[0]
1,132,575
1,132,576
Is it safe to use $_SERVER["SCRIPT_NAME"]
<p>I do not want to pass GET or POST variables to a script. I want to use the filename and use it to lookup the product from the phpscript for example:</p> <p>......./DELL1500.php ......./COMPAQ1213.php</p> <p>I have three questions:</p> <ol> <li><p>Where does PHP get the data from $_SERVER["SCRIPT_NAME"] is it from the server or the clients browser?</p></li> <li><p>Can anyone think of any security issues of using this?</p></li> <li><p>Could this in anyway be incompatible with any older browsers. I assume not if its provided by the server?</p></li> </ol> <p>Cheers,</p> <p>Cameron</p>
php
[2]
2,398,024
2,398,025
How to format a float number without rounding?
<p>I'm trying to format a float number (lets say 341.75) by setting the decimal point to "1". I tried:</p> <pre><code>var num = 341.75; alert(num.toFixed(1)); // output: 341.8 alert(num.toPrecision(1)); // output: 341.8 </code></pre> <p>but what I need is 341.7 ! apparently both methods try to round it, is there a way to do that without rounding ? </p>
javascript
[3]
1,062,335
1,062,336
Malzilla Tutorial #4 - how to get it working
<p>I am trying to understand the basic work flow of using <a href="http://malzilla.sourceforge.net/" rel="nofollow">Malzilla</a> , and therefore doing the tutorials. But already in the <a href="http://malzilla.sourceforge.net/tutorial04/index.html" rel="nofollow">first one</a>, where you actually get to do something I am lost as it doesn't work for me at all, even though I follow it step by step.</p> <p>In the first paragraph where you have to concatenate the string and then translate it using the <code>MiscDecoders-&gt;DecodeUCS2</code>, I am getting not printable chars as a solution, after concatenating and using the decoder.</p> <p>In the second paragraph where you are told to run the script after adding the function-call at the bottom of the script, the Decoder tells me that he cannot handle the <code>arguments.callee.toString()</code> method and therefor wont run the script. </p> <p>How outdated are those tutorials and how can I get them to work?</p>
javascript
[3]
4,469,684
4,469,685
Estimate seconds left (based on time & progress)
<p>I'm trying to estimate how many seconds is left of an MSI installation. Though I know this will not be accurate, my calculation seems more off than it should be - how can I improve? One problem is that often I find that the progress rockets from ~0% to ~95% which for a very long time evaluates to 0 seconds left.</p> <p>I get the progress event from the MSIs, and each time progress is updated I do the following:</p> <pre><code> private int CalculateSecondsLeft(DateTime start, int overallProgress) { lock (this) { if (overallProgress == 0) { return 0; } var timeSpent = DateTime.Now - start; double cal1 = timeSpent.TotalSeconds / overallProgress; double cal2 = cal1 * (100 - overallProgress); return (int)cal2; } } </code></pre>
c#
[0]
2,371,264
2,371,265
Why does my plist file exist even when I've uninstalled an app and wiped the simulator?
<p>I am trying to detect the existence of a plist file on application start. When my data class (descendant of NSObject) is initialized, it loads the plist file.</p> <p>Before it loads, it checks to see if the file exists, and if it doesn't, it sets the data = nil instead of trying to process the array of data in the plist file.</p> <p>However, every time it starts it indicates the file exists. Even when I uninstall the app in the organizer <strong>and</strong> when wiping the simulator directory (iPhone Simulator/3.0/Applications).</p> <p>I have the following static method in a library class named FileIO:</p> <pre><code>+(BOOL) fileExists:(NSString *)fileName { NSString *path = [FileIO getPath:fileName]; // gets the path to the docs directory if ([[NSFileManager defaultManager] fileExistsAtPath:path]) return YES; else return NO; } </code></pre> <p>In my data class:</p> <pre><code>//if( [FileIO fileExists:kFavorites_Filename] ) [FileIO deleteFile:kFavorites_Filename]; if ([FileIO fileExists:kFavorites_Filename]) {NSLog(@"exists"); </code></pre> <p>The "exists" is logged every time unless I un-comment the method to delete the file.</p> <p>How can the file exist if I've deleted the app? I've deleted the simulator directory and uninstalled on the device but both say it still exists.</p> <p>What gives???</p>
iphone
[8]
4,940,425
4,940,426
Listbox mousedown and doubleclick
<p>I am not able to get MouseDoubleClick event fired for my ListBox. I have added MouseDown Event. Every time I double click MouseDown Event is fired Why is this happening?</p>
c#
[0]
5,055,549
5,055,550
How to populate a vector/list with all derived classes of a base class
<p>I would like to get a vector/list of derived class pointers (one corresponding to each derived class from an abstract base class) given the base class name, for instance.</p>
c++
[6]
4,020,375
4,020,376
Why use an @property?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1554546/when-and-how-to-use-the-builtin-function-property-in-python">When and how to use the builtin function property() in python</a> </p> </blockquote> <p>What is the difference between:</p> <pre><code> @property def has_open_positions(self): """ Returns True if the current production has active jobs it is hiring for. """ if JobPost.objects.filter(production=self).exists(): return True return False </code></pre> <p>and without the <code>@property</code>? I understand if you have an @ you can't call <code>object.has_open_positions()</code>, instead you'd do <code>object.has_open_positions</code>, but why would that matter? </p>
python
[7]
4,963,249
4,963,250
jQuery filter SELECT options based on Radio PRE - selected on load
<p>So I posted the question yesterday (<a href="http://stackoverflow.com/questions/877328/jquery-disable-select-options-based-on-radio-selected-need-support-for-all-brows">Link</a>) and got the answer I needed but for the life of me I can't get this to happen if the value is selected on the body load. it only works if the user clicks the radio then it filters the options. HELP Please!!!</p> <p>the Function</p> <pre><code>jQuery.fn.filterOn = function(radio, values) { return this.each(function() { var select = this; var options = []; $(select).find('option').each(function() { options.push({value: $(this).val(), text: $(this).text()}); }); $(select).data('options', options); $(radio).click(function() { var options = $(select).empty().data('options'); var haystack = values[$(this).attr('id')]; $.each(options, function(i) { var option = options[i]; if($.inArray(option.value, haystack) !== -1) { $(select).append( $('&lt;option&gt;').text(option.text).val(option.value) ); } }); }); }); }; </code></pre> <p>How to call</p> <pre><code>$(function() { $('#theOptions').filterOn('input:radio[name=abc123]', { 'abc': ['a','b','c'], '123': ['1','2','3'] }); }); </code></pre> <p>Thanks in advance</p> <p>BTW Here is a <a href="http://jsbin.com/anoci" rel="nofollow">DEMO</a> of it in action</p>
jquery
[5]
5,269,016
5,269,017
Easy jQuery Question - Selecing a div with the same class as the a
<p>I want to do this, but haven't figured it quite out yet...</p> <pre><code> $(document).ready(function() { $("a.whateverclass").click(function() { $("div.whateverclass").show(); return false; }); </code></pre> <p>Basically when a link with a certain class is clicked all divs with that class are shown. The classes can be any class. And I won't know the name(s) of the classes in the application.js file so I need to match equal classes.</p>
jquery
[5]
5,966,549
5,966,550
How to edit the URL in javascript before setting the 'add to favorite' in IE?
<p>I am developing a web site using asp.net and javascript. </p> <p>In my web site, if the user is trying to set the URL as bookmark (from the favorites menu) from any page other than the home page, I need to set the home page as a bookmark.</p> <p>So, the url that should pass to the IE built-in function should be the home page url.</p> <p>How to achieve this?</p>
javascript
[3]
1,355,314
1,355,315
Cancel functionality in a href
<p>I have a link like</p> <pre><code>&lt;a href="www.site.com" class="cancel"&gt;go there &lt;/a&gt; </code></pre> <p>And then I have some jQuery:</p> <pre><code>$(".cancel").click(function(){ confirm("sure??"); }); </code></pre> <p>But when I click cancel in the alert box it still goes to www.site.com in stead of doing nothing. How to solve this?</p>
jquery
[5]
1,020,267
1,020,268
DataTable fnFooterCallback summing columns
<p>I have problem with summing columns using jQuery DataTable fnFooterCallback. For example i have values in column (double fields):</p> <p>2.0 3.0 4.0</p> <p>I get total value in footer cell: 2.0 3.0 4.0 instead 9.0 What's wrong?</p> <p>Here is the code:</p> <pre><code> $(document).ready(function() { $('#example').dataTable({ "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { var iTotal = [0,0,0,0,0,0,0,0,0]; for ( var i=0 ; i&lt;aaData.length ; i++ ) { iTotal[0] += aaData[i][5]; iTotal[1] += aaData[i][6]; iTotal[2] += aaData[i][7]; iTotal[3] += aaData[i][8]; iTotal[4] += aaData[i][9]; iTotal[5] += aaData[i][10]; iTotal[6] += aaData[i][11]; iTotal[7] += aaData[i][12]; } var nCells = nRow.getElementsByTagName('th'); nCells[5].innerHTML=iTotal[0]; nCells[6].innerHTML=iTotal[1]; nCells[7].innerHTML=iTotal[2]; nCells[8].innerHTML=iTotal[3]; nCells[9].innerHTML=iTotal[4]; nCells[10].innerHTML=iTotal[5]; nCells[11].innerHTML=iTotal[6]; nCells[12].innerHTML=iTotal[7]; } } ); } ); </code></pre> <p>Thanks for help and sorry for my english :)</p>
jquery
[5]
1,499,934
1,499,935
motionbegan:withevents: not being called
<p>Has anyone had any luck to get motionbegan:withevents: to fire in a view controller? Someone had mentioned that I had to set the view controller to be the first responder but souldn't the event get pushed down the responder chain?</p>
iphone
[8]
2,163,553
2,163,554
How do i create a global unique error id? C#
<p>I want to create a bunch of errors. each specific to its own class and module. Then i would like to attach the id to an exception so when my msg change the id is still the same. How do i create this list of errors without maintaining a large global enum ?</p>
c#
[0]
1,506,980
1,506,981
How to change a string to a int number in C++?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2634558/converting-string-to-int-in-c">converting string to int in C++</a> </p> </blockquote> <p>I have tried include <code>stdlib.h</code> but it doesn't work.</p>
c++
[6]
3,440,101
3,440,102
Geasture recognizer doubts
<p>haii i have this code in UISWitchControl for activating the autoscroll function</p> <pre><code> -(IBAction)_clickautoscroll:(id)sender { if(switchcontrolautoscroll.on){ if autoscrollTimer== nil) { autoscrollTimer = [NSTimer scheduledTimerWithTimeInterval:(55.0/1000.0) target:self selector:@selector(autoscrollTimerFired:) userInfo:nil repeats:YES]; } } else{ [switchcontrolautoscroll setOn:NO animated:YES]; [autoscrollTimer invalidate]; [self.table scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO]; } } - (void)autoscrollTimerFired:(NSTimer*)timer { CGPoint scrollPoint = self.table.contentOffset; scrollPoint = CGPointMake(scrollPoint.x, scrollPoint.y + 1); [self.table setContentOffset:scrollPoint animated:NO]; } </code></pre> <p>It works fine,but i have long-gesture-recognizer to end the autoscroll the code is</p> <pre><code>-(void) handleLongPressOnUndoGesture:(UILongPressGestureRecognizer*)recognizer { //[switchcontrolautoscroll setOn:NO animated:YES]; [autoscrollTimer invalidate]; [self.table scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO]; } </code></pre> <p>but when i tap taptohold it stops the autoscroll and but the application crash. is there any defect in my code. Thanks.</p>
iphone
[8]
4,928,871
4,928,872
initializing static const member from data file
<p>For the following code:</p> <pre><code>class A { public: static const int VAL; }; </code></pre> <p>I know that I can assign VAL a value in the class declaration:</p> <pre><code>class A { public: static const int VAL = 3; }; </code></pre> <p>or in the CPP file:</p> <pre><code>const int A::VAL = 3; </code></pre> <p>But I would like to read the value in from a data file. I have a function now, let's call it F() which reads in the value I want:</p> <pre><code>void F() { int value = ReadValueFromDataFile(); //But I can't do this: const int A::VAL = value; //member cannot be defined in the current scope } </code></pre> <p>How can I assign the value of VAL based on a value read in from a data file?</p>
c++
[6]
4,757,089
4,757,090
Co- browsing implementation in java
<p>Co-Browsing in the context of web browsing, is the joint navigation through the Internet by two or more people accessing the same web pages at the same time. </p> <p>for more information please have a look at <a href="http://en.wikipedia.org/wiki/Cobrowsing" rel="nofollow">http://en.wikipedia.org/wiki/Cobrowsing</a></p> <p>here are some paid alternatives which does this </p> <p><a href="http://www.livelook.com/co_browsing.asp" rel="nofollow">http://www.livelook.com/co_browsing.asp</a></p> <p><a href="http://www.unblu.com/" rel="nofollow">http://www.unblu.com/</a></p> <p>any help regarding what technology is being used to implement this or technical specifications ?</p> <p>i am trying to implement co-browsing using java, has any one have prior experience with that if its possible or any existing java library doing the same? </p> <p>if there is not any solution what approach should i use to implement this. </p>
java
[1]
5,972,992
5,972,993
Multiple OracleCommands per OracleConnection
<p>I am opening a connection to a database in which I need to issue multiple deletes before closing the connection. I have the following code but it looks strange with all the using statements. Is there a better way to do this? Is this the correct way to use the using statement with connections/commands?</p> <pre><code>using(OracleConnection oracleConnection = new OracleConnection(connectionString)) { string table1Command= "DELETE FROM TABLE1..."; using(OracleCommand oracleCommand = new OracleCommand(table1Command, oracleConnection)) { oracleCommand.ExecuteNonQuery(); } string table2Command= "DELETE FROM TABLE2..."; using(OracleCommand oracleCommand = new OracleCommand(table2Command, oracleConnection)) { oracleCommand.ExecuteNonQuery(); } } </code></pre>
c#
[0]
3,389,656
3,389,657
Elegant alternative to if statements to output variables in PHP
<p>Looking for an elegant approach in PHP to take in a variable and then output two preset values. </p> <p>Instead of using a series of if statements like below, wondering if there is a more elegant solution.</p> <p>Example:</p> <pre><code>if ($edit_array[1] == job) { $table = 'jobs'; $id = 'job_id'; } </code></pre>
php
[2]
4,930,291
4,930,292
Assign a Object to another Object in jQuery
<p>I am trying to assign an object to another other in jQuery but I am getting error. I am quite new to jQuery so all helps are much appreciated. Following is the code i am trying to do.</p> <pre><code> while ($(obj)) { $(obj) = $(obj).children(":first"); } </code></pre> <p>It is trying to traverse through a table.</p>
jquery
[5]
5,459,908
5,459,909
Comparing Two Strings
<p>I am using <code>isEqualToString</code> to compare two strings? as follows:</p> <pre><code> if ( [ somethingString isEqualToString: @"MyString" ] ) { //do something } else { //do something else } </code></pre> <p>Now, I have examined <code>somethingString</code> with <code>NSLog</code> and it appears ok in that it shows what I expected. But, the if statement is not working.</p> <p>I am thinking that even though the Debugger shows the object there before the if is executed, the type or something else is amiss.</p> <p>The somethingString comes from the <code>UIPickerView</code> which is populated with an array of objects...if this makes any difference.</p> <p>Any thoughts?</p> <p>ps. I have tried using the compare: and that definitely does not work.</p>
iphone
[8]
5,587,356
5,587,357
How to edit library source files on NetBeans?
<p>I am doing JAVA project based on the SSJ (Stochastic Simulation in Java) libraries. In my project I have followed the required steps to import the SSJ library files and also the source files.</p> <p>When looking at the SSJ library files in the project's Libraries branch, only class files appear shown, but when I open them I can view the source code (which I couldn't before, as I hadn't imported the sources) so I assume everything was imported correctly.</p> <p>When I run the examples provided with the library everything runs fine and as expected. But if I try to change the source code for the libraries for instance, changing the text on an output, the changes I make to the source files aren't reflected in the output from the java programs.</p> <p>Any hint on what I might be doing wrong?</p> <p>I understand this might be hard to understand or test as I can't quite create and SSCCE for this matter. The library files are hosted here (http://www.iro.umontreal.ca/~simardr/ssj/ssj-20120216.zip) and the source code here (http://www.iro.umontreal.ca/~simardr/ssj/ssj-source.html).</p> <p>Thanks in advance for all your help!</p>
java
[1]
5,144,263
5,144,264
Hardware accelerated Live Wallpaper
<p>I'm trying to create a Live Wallpaper that can leverage HArdware acceleration on sdk 14. But Live wallpaper I create is using:</p> <pre><code>Canvas canvas = surfaceHolder.lockCanvas(); </code></pre> <p>And Romain Guy already mentioned Canvas created by such methods are not hardware accelerated. So is there an alternative way by which I can create a Canvas for LWP?</p> <p>p.s. I'm not using any of the unsupported hardware-accelerated canvas methods.</p>
android
[4]
1,281,759
1,281,760
jquery validation - optional field
<p>In a registration form middleName field is optional. When the users enters his/her middleName, then it should validate that field.</p> <p>I have used the following code to achieve the above scenario, but it is not working.</p> <pre><code>$("#middleName").rules("add", {checkName: true, required: false, messages: {checkName: "Please enter a valid middle name"} }); jQuery.validator.addMethod("checkName", function(value, element) { var regExp = new RegExp(/^[a-zA-Z0-9\s|\,|\.|\-|\']+$/); return regExp.test(value); }, "Please enter a valid name." ); </code></pre> <p>Can anyone suggest me to achieve the above scenario.</p>
jquery
[5]
4,552,745
4,552,746
return an array refrence variable from a method?
<p>Consider the follwing code:</p> <pre><code>class Box { int size; Box(int s) { size = s; } } public class Laser { public static void main(String[] args) { Box b1 = new Box(5); Box[] ba = go(b1, new Box(6)); ba[0] = b1; for (Box b : ba) { System.out.print(b.size + " "); } } static Box[] go(Box b1, Box b2) { b1.size = 4; Box[] ma = {b2, b1}; return ma; } } </code></pre> <p>What is the result? i solved it to be 5 4 but it's not the right one, the right answer is 4 4, how that come?</p>
java
[1]
4,392,382
4,392,383
Python: Is it possible to have an actual memory leak in Python because of your code?
<p>I don't have an example of code but I'm curious if you do bad coding practice, is that possible?</p>
python
[7]
5,749,701
5,749,702
loop through two sql queries php
<p>Hi I have two tables (users &amp; friends) I need to connect to the friend table to bring all the friends for a user id, then connect to the user table and bring the information for that user, using the friend id. I have the code below but this only brings one user.</p> <p>It needs to count the number of users online.</p> <pre><code>function online_friends() { $ID = ($_SESSION['ID']); $friend = "SELECT * FROM `friends` WHERE `user_id` = '$ID' AND `accepted` = 'TRUE'"; $result=mysql_query($friend); while ($row = mysql_fetch_assoc($result)) { $friend_id = $row['friend_id']; $get = "SELECT * FROM `users` WHERE `ID` = '$friend_id' AND `online` = 'TRUE'"; $result_friend=mysql_query($get); $count_friends=mysql_num_rows($result_friend); } return $count_friends; } </code></pre> <p>Thanks Edit: I have checked these manually by running through phpmyadmin and it brings two or more rows.</p>
php
[2]
3,414,293
3,414,294
Variable declaration inside a loop
<p>One common dilemma I have faced throughout programming is regarding declaring variables inside a loop. Say I have to perform something like the following: </p> <pre><code>List list=myObject.getList(); Iterator itr=list.iterator(); while (itr.hasNext()){ BusinessObject myBo=(BusinessObject)itr.next(); process(myBo); } </code></pre> <p>In the above snippet, should <code>myBo</code> be declared outside the loop or does declaring it inside the loop not cause harm to memory and performance?</p>
java
[1]
4,855,076
4,855,077
Changing the text when toggle
<p>I am trying to change the text when the user clicks but does not seems to work ..below is the code.</p> <p>not working sample: <a href="http://jsfiddle.net/3jt3P/1/" rel="nofollow">http://jsfiddle.net/3jt3P/1/</a></p> <pre><code>&lt;a href="#" class="slide" onclick="firstclick();"&gt;Show First&lt;/a&gt; ... &lt;a href="#" class="slide1" onclick="secondclick();"&gt;Show Second&lt;/a&gt; &lt;div id="one" class="content"&gt;one&lt;/div&gt; &lt;div id="second" class="content"&gt;two&lt;/div&gt; &lt;script type="text/javascript"&gt; function firstclick() { $('#second').hide(); $('#one').slideToggle(400, function () { debugger if ($(this).is(":visible")) { $('.slide &gt; a').text('Hide First'); $('.slide1 &gt; a').text('Second'); } else { $('.slide &gt; a').text('First'); } }); return false; } function secondclick() { $('#one').hide(); $('#second').slideToggle(400, function () { if ($(this).is(":visible")) { $('slide1 &gt; a').text('Hide Second'); $('slide &gt; a').text('First'); } else $('slide1 &gt; a').text('First'); }); return false; } $(document).ready(function () { // Hide the "view" div. $('#one').hide(); $('#second').hide(); }); &lt;/script&gt; </code></pre>
jquery
[5]
833,865
833,866
How to start new activity when recieve new sms (I used Intent but is show error)?
<p>How do i start new activity if particular sms receive and its have particular value? i used intent but is show error in code this error is show in intent </p> <blockquote> <p>The method startActivity(Intent) is undefined for the type SmsReceiver</p> </blockquote> <p>below is my code:</p> <pre><code>package com.mypackage; import java.util.Map; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.telephony.SmsMessage; import android.widget.Toast; public class SmsReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { //---get the SMS message passed in--- Bundle bundle = intent.getExtras(); SmsMessage[] msgs = null; String str = ""; if (bundle != null) { //---retrieve the SMS message received--- Object[] pdus = (Object[]) bundle.get("pdus"); msgs = new SmsMessage[pdus.length]; for (int i=0; i&lt;msgs.length; i++){ msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]); str += "SMS from " + msgs[i].getOriginatingAddress(); str += " :"; str += msgs[i].getMessageBody().toString(); str += "\n"; if(str.contains("00")); { Intent k = new Intent(this.getApplicationContext(), AgAppMenu.class); startActivity(k); } } //---display the new SMS message--- Toast.makeText(context, str, Toast.LENGTH_SHORT).show(); } } } </code></pre>
android
[4]
3,596,533
3,596,534
Using a string value as an attribute
<p>I want to loop through a collection of string values and insert them as attributes. Something like this:</p> <pre><code>foreach (var result in results) { var one = result.GetStuff(); var two = result.Find(one); foreach (var user in users) { one.Properties["something"].Value = two.something; } } </code></pre> <p>'users' is a collection of string values. Where you see "something" (two places), I want to be using a string value from 'users'. How can I do this?</p>
c#
[0]
3,546,051
3,546,052
Transfer XML data
<p>When SQL is offline, I tried to send data in SQL through Xml but xml data is not transfered.</p> <p>Code is here:</p> <pre><code>DataRow[] shouldInserted = AMSParent.con.dst.Tables["dept_tbl"].Select("dept_name='" + dept_txt.Text.ToString() + "'"); if (shouldInserted.Length == 0) { DataRow dr = AMSParent.con.dst.Tables["dept_tbl"].NewRow(); dr["dept_name"] = dept_txt.Text; AMSParent.con.dst.Tables["dept_tbl"].Rows.Add(dr); AMSParent.con.dst.Tables["dept_tbl"].AcceptChanges(); AMSParent.con.dst.AcceptChanges(); AMSParent.con.dst.WriteXml(Application.StartupPath + "\\offlineTables.xml", XmlWriteMode.WriteSchema); try { File.Delete(Application.StartupPath + "\\offlineTables.con"); } catch { } encdec.Encrypt(Application.StartupPath + "\\offlineTables.xml", Application.StartupPath + "\\offlineTables.con", ""); try { File.Delete(Application.StartupPath + "\\offlineTables.xml"); } catch { } dept_txt.Text = ""; MessageBox.Show("Successfully added"); </code></pre> <p>Is there any solution? Thanks!</p>
c#
[0]
4,002,197
4,002,198
Including headers inside class declaration / definition
<p>I know you can do something like:</p> <p>def.h:</p> <pre><code>A(); int x; </code></pre> <p>A.h</p> <pre><code>class A { public: #include "def.h" } </code></pre> <p>A.cpp</p> <pre><code>A::A() { x = 0; } int main() { A a; return 0; } </code></pre> <p>My questions is: why would you do this? Are there any advantages? I can see how it would be helpful if you have some classes with the same members but not the same base, but is it worth the hassle? It's not very readable, is it? Also, how does the compiler treat these includes? Does it just paste the content of the header where it's included (kind of like a macro)?</p>
c++
[6]
2,619,430
2,619,431
list.append or list +=?
<p>Which is more pythonic?</p> <pre><code>list.append(1) </code></pre> <p>or</p> <pre><code>list += [1] </code></pre>
python
[7]
4,058,563
4,058,564
Fix a id in JQuery
<p>I am using JQuery for my application.. Having a doubt on how to add a id to my element tr.</p> <p>My code is </p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function(){ var tr = document.createElement('tr'); var td1=document.createElement('td'); tr.appendChild(td); }); &lt;/script&gt; </code></pre> <p>I am trying to add an id to the tr element </p> <p>like </p> <p>EDIT : by $(tr).attr('id', 'entryRow'+increment); And resolved..Thanks</p>
jquery
[5]
754,555
754,556
compareTo method java
<p>I'm working on homework and need someone to walk me through something. I am learning about arrays and basically I have an array that collects a lastname, firstname, and score. I need to write a compareTo method that will compare the last name and then the firstname so the list could be sorted alphabetically starting with the last names and then if two people have the same last name then it will sort the first name.</p> <p>I'm confused because all of the information in my book is comparing numbers and not objects or I guess Strings? I think strings are considered objects when working with arrays. This is really confusing me so if somone can walk me through it I would appreciate it. Here is what I have coded so far but I know it's wrong but it at least explains what I think I'm doing.</p> <pre><code> public int Compare(Object obj) // creating a method to compare { Student s = (Student) obj; //creating a student object // I guess here I'm telling it to compare the last names? int studentCompare = this.lastName.compareTo(s.getLastName()); if (studentCompare != 0) return studentCompare; else { if (this.getLastName() &lt; s.getLastName()) return - 1; if (this.getLastName() &gt; s.getLastName()) return 1; } return 0; } </code></pre> <p>I know the &lt; and > symbols are wrong but like I said my book only shows you how to us the <code>compareTo</code> method using numbers which I think is kind of unfair to expect me to understand how to compare objects. </p>
java
[1]
4,521,778
4,521,779
Unchecking the checked checkboxes while scolling the list in Android?
<p>My problem is list of checkboxes are there which are checked in gridview , while scrolling the list, those checked one is turned to unchecked one.</p>
android
[4]
5,139,870
5,139,871
Javascript popup window to be in fron and not steal focus
<p>As stated in the Title, i'm trying to figure out if it's possible in Javascript to:</p> <ul> <li>Open a popup through my parent site with window.open </li> <li>Have that popup display in front of the parent</li> <li>Not lose <strong>keyboard</strong> focus from the parent window.</li> </ul> <p>So something like the functionality of the popup notification of Windows Messenger for example</p> <p>Any ideas?</p> <p>Regards, user523842 :P </p>
javascript
[3]