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
5,032,954
5,032,955
changing the href with jquery
<p>I have an image with an ID of 27. </p> <p>I need to change the href of the link that surrounds it. How do i do this with jquery?</p> <p>Here is my link and image attribute. Note. I cant set the id to the link.</p> <pre><code>&lt;a href=""&gt;&lt;img src="" id="27"&gt;&lt;/a&gt; </code></pre>
jquery
[5]
1,258,197
1,258,198
Get iframe contents using Javascript
<p>I have an iframe and I need to get the contents of it and extract some information from this. Is this possible using Javascript?</p> <p>I have looked somewhere that this is not possible if the other page runs on a different server but I need to confirm this.</p>
javascript
[3]
5,375,136
5,375,137
Javascript version of showOptionDialog
<p>Im wondering if there is a javascript function like java's showOptionDialog, where the user can chose between two different options in the dialog</p> <p>Thanks, Matt</p>
javascript
[3]
5,651,508
5,651,509
Android application publish
<p>i am using License Verification Library for my paid Android application.<br> so is there any necessity to add eula(End User License Agreement) to my application? </p>
android
[4]
1,965,235
1,965,236
address of elements of structure of different types
<p>i want to find address of elements of structure in memory here is my code</p> <pre><code> #include &lt;iostream&gt; using namespace std; struct B{ int k; float t; char s; unsigned int m; long q; double x; unsigned long z; }; int main(){ B b[]={3,4.23,'A',123,123L,23.340,700}; void *t=&amp;b[0]; void *n=&amp;b[0]+7; while(t!=n){ cout&lt;&lt;t&lt;&lt;endl; t++; } return 0; } </code></pre> <p>i dont know if it is correct code and also here is errors</p> <pre><code>1&gt;------ Build started: Project: tests, Configuration: Debug Win32 ------ 1&gt; tests.cpp 1&gt;c:\users\7\documents\visual studio 2010\projects\tests\tests\tests.cpp(16): warning C4305: 'initializing' : truncation from 'double' to 'float' 1&gt;c:\users\7\documents\visual studio 2010\projects\tests\tests\tests.cpp(22): error C2036: 'void *' : unknown size ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== </code></pre> <p>please help</p>
c++
[6]
3,767,642
3,767,643
Javascript contains statement
<p>I'm trying check a field in a database to see if it does not contain either "UK_CONTACTS or a blank. If it is either of these conditions I want to copy the that field to another field. I am very very new at this and have come up with the following and have written in text "does not contain" as I don't know the correct syntax for javascript.</p> <pre><code>function getdbasename(){ var dbasedata = document.forms[0]._dbase_name.value; } If (dbasedata does not contain "UK_CONTACTS" || dbasedata does not contain " ") { _area.value = _dbase_name.value; } </code></pre> <p>Probably miles out but it's my best shot.</p>
javascript
[3]
4,926,574
4,926,575
How to save this string correctly?
<p>This is my code:</p> <p>URL: </p> <pre><code>http://www.mysite.com/t.php?title=The%20Police%20-%20Don't%20Stand%20So%20Close%20to%20Me%20'86%20- </code></pre> <p>PHP:</p> <pre><code>&lt;?php if(!empty($_GET['title'])){ &gt; &lt;form method="post" action="t.php?done=yes" enctype="multipart/form-data"&gt; &lt;input type="text" name="title" &lt;?php echo "value=\"".htmlspecialchars($_GET['title'])."\""; ?&gt; &gt; &lt;input name="submit" value="Submit" type="submit" /&gt; &lt;/form&gt; &lt;?php } &gt; &lt;?php if(!empty($_POST['title'])){ echo mysql_real_escape_string($_POST['title']); // I have to put the string in a database ( I haven't added that part ) } &gt; </code></pre> <p>If I follow the first URL and then submit the form, I get this string:</p> <pre><code>The Police - Don\\\'t Stand So Close to Me \\\'86 - </code></pre> <p>instead of:</p> <pre><code>The Police - Don't Stand So Close to Me '86 - </code></pre> <p>Why ? How can I get the last string ?</p> <p>Thanks</p> <p>.</p> <p><strong>EDIT:</strong></p> <p>I have just discovered that magic_quotes_gpc is ON because get_magic_quotes_gpc() return TRUE. </p>
php
[2]
1,189,480
1,189,481
C++ Hello World not compiling
<p>I just recently installed OSX lion and got xcode 4.</p> <p>I made a file in a directory somewhere and put this code in it:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { cout &lt;&lt; "Hello World!"; return 0; } </code></pre> <p>Then I ran gcc filename.cc</p> <p>and I get these errors:</p> <p>1.cc:3:20: error: iostream: No such file or directory 1.cc: In function ‘int main()’: 1.cc:8: error: ‘cout’ was not declared in this scope</p> <p>what's wrong?</p> <p>EDIT:</p> <p>if I run g++ filename.cc I get the same errors.</p> <p>1.cc:3:20: error: iostream: No such file or directory 1.cc: In function ‘int main()’: 1.cc:8: error: ‘cout’ was not declared in this scope</p>
c++
[6]
5,375,760
5,375,761
Why doesn't static main work in C++?
<p>The code below doesn't work. </p> <pre><code>#include&lt;iostream&gt; class Application { public: static int main(int argc, char** argv) { std::cin.get(); } }; </code></pre> <p>I thought that static member functions are just the same as normal functions, and static WinMain works fine. Why doesn't static main work?</p> <p>well, I think i somewhat got begin to understand, thank you for all the answers.</p>
c++
[6]
5,437,246
5,437,247
Validate Session with Http Module
<p>I need to validate the Session with the HTTP Module. I have some aspx pages and in that pages am just validating, whether the sessions are null or not, like</p> <pre><code> if (Session["LoggedInUser"] != null) { user = (User)Session["LoggedInUser"]; } else { FormsAuthentication.SignOut(); FormsAuthentication.RedirectToLoginPage(); } </code></pre> <p>is it possible to validate the sessions(from any aspx page) with the help of HTTP Modules?</p> <p>I got some idea here, <a href="http://stackoverflow.com/questions/276355/can-i-access-session-state-from-an-httpmodule">Can I access session state from an HTTPModule?</a>, but I dunno where I have to add this class file and how I've refer this class file, so that I can access this from any aspx page, I really don't have any idea about this, can anyone help me out here, thanks in advance</p>
asp.net
[9]
2,061,512
2,061,513
Access wrapping element with `wrap()`
<p>I'm using the jQuery function <code>wrap()</code>, which returns the original object, not the wrapping object. Is there an easy way to access the wrapping object?</p>
jquery
[5]
39,581
39,582
Initializing an array of arrays
<p>I am wondering if there is an easier way to do the same thing than below but with less code.</p> <pre><code> private $table = array( array(array(), array(), array(), array(), array()), array(array(), array(), array(), array(), array()), array(array(), array(), array(), array(), array()), ... array(array(), array(), array(), array(), array()) ); </code></pre> <p>I know this is doable in C++, tho not sure if there is something similar in PHP.</p> <p>Thanks in advance for the help.</p>
php
[2]
4,388,011
4,388,012
[CLOSE]Javascript: how i can know when the IE file download prompt pop up?
<p>Now i have a problem below:</p> <p>i've added a div on my page to forbid user to click buttons, links or fields when user click the DOWNLOAD button. So i need to remove this div when the IE file download prompt pops up or when user clicks "save", "save as" or "cancel" on it.</p> <p>How can I reach this?</p> <p><strong>IE only considered please.</strong></p>
javascript
[3]
5,925,250
5,925,251
JQuery - Check when image is loaded?
<p>I am having a bit of trouble working out when an image has been loaded.</p> <p>I have been told that the following function will work but it isn't doing anything.</p> <pre><code>$("#photos img:first").load(function (){ alert("Image loaded!"); }); </code></pre> <p>There are no error's in my code. Everything else in my script works great.</p> <p>My HTML looks like this.</p> <pre><code>&lt;div id="photos"&gt; &lt;img src="../sample1.jpg" style="background-color:#000033" width="1" height="1" alt="Frog!"/&gt; &lt;img src="../sample2.jpg" style="background-color:#999999" width="1" height="1" alt="Zooey!"/&gt; &lt;/div&gt; </code></pre> <p>Do I have the wrong JQuery function? It should also be noted that the visibility is set to hidden. However even when visible there is no alert.</p> <p>Any ideas?</p>
jquery
[5]
4,273,692
4,273,693
how to check installed application in iphone device
<p>I am developing an application in which i need to find the apps which are already installed in iphone device such as Skype, facebook. I need to check it objective -c . Please give me code snippet if possible otherwise a link to get the solution. If it not possible then tell me other way to check installed application in iphone deveice .</p> <p>Thanks in advance ......</p>
iphone
[8]
1,348,239
1,348,240
Finding if an element is childless
<p>I have an array that contains all elements on the page. How would I test if an element is childless while looping through the array? I would prefer to stay with standard javascript. Here is pseudocode that explains it:</p> <pre><code>for each element in elementlist: if element is childless: do something else: do something different </code></pre>
javascript
[3]
1,440,001
1,440,002
this.shift = {x:this.x, y:this.y} works but not this.shift.x = this.x and this.shift.y = this.y?
<pre><code>this.x = (Math.random()*canvasWidth); this.y = (Math.random()*canvasHeight); (1) this.shift = {x: this.x, y: this.y}; (2) this.shift.x = this.x; this.shift.y = this.y; </code></pre> <p>Hi guys, I am playing with canvas and on my way to create a particle system.</p> <p>The first (1) one will work but not the second (2) one why? I am getting an error saying "Cannot set property 'x' of undefined" when debug using Chrome dev tools.</p> <p>Any idea?</p>
javascript
[3]
1,810,168
1,810,169
C++ - Values change unexpectedly
<p>For some reason, the values of a passed struct change without me accessing them. I found this out by debugging with Visual Studio. Here is the code:</p> <pre><code>bool Screen::blitSurface(SDL_Surface* src, int x, int y, SDL_Rect* rect) { SDL_Rect* offset; offset-&gt;x = x; offset-&gt;y = y; SDL_BlitSurface( src, rect, screen, offset ); return true; } </code></pre> <p>The struct that is changing is 'rect'. When it is passed, rect->x is 0 and rect->y is 16. However, at the next breakpoint (offset->x = x;) rect->x is a random number (for instance, -13108), same with rect->y. Does anybody have an idea as to why this happens? I'm completely lost, and have no idea where to start.</p> <p>--EDIT--</p> <p>Ok, I updated the code to this, but it's still having the problem.</p> <pre><code>bool Screen::blitSurface(SDL_Surface* src, int x, int y, SDL_Rect* rect) { SDL_Rect offset; offset.x = x; offset.y = y; SDL_BlitSurface( src, rect, screen, &amp;offset ); return true; } </code></pre> <p>However, it did get me thinking. If I create a local struct, and return a pointer to it, it is deleted once the function completes? For example, does this work?</p> <pre><code>SDL_Rect* getRect(int x, int y, int width, int height) { SDL_Rect rect; rect.x = x; rect.y = y; rect.w = width; rect.h = height; return &amp;rect; } </code></pre> <p>This is where I get the 'rect' variable that I am passing to 'blitSurface'.</p>
c++
[6]
1,282,909
1,282,910
jQuery perfomance when trying to hide rows in table
<p>i have the performance problem. I have a table with 500 rows for example, i try to hide column in it, and spend near 10seconds on waiting.</p> <pre><code>&lt;table&gt; &lt;thead&gt; &lt;th class="c1"&gt;ColumnName1&lt;/th&gt; &lt;th class="c2"&gt;ColumnName2&lt;/th&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;td class="c1"&gt;data&lt;/td&gt; &lt;td class="c2"&gt;data&lt;/td&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>i use smth like</p> <pre><code>jQuery('.c2').hide(); </code></pre> <p>Can anybody give me advice how to improve speed in this issue.</p> <p>Thanks!</p>
jquery
[5]
4,136,025
4,136,026
How to manually click a Jquery multiselect box?
<p>I have a few multi select boxes on a page. When the user clicks a certain checkbox, I would like one of the multiselect boxes on the page to automatically be clicked with a certain value. Do you have any idea of how to do this?</p> <p>Thank you!</p> <pre><code>$("#select_country").multiselect({ multiple: false, header: "Select a country", noneSelectedText: "Select a country", selectedList: 1 }); </code></pre> <p>====== so far I've tried these methods with no success:</p> <pre><code>$("#select_country").multiselect("widget").find("input:checkbox").each(function(){ this.click(); }); $("#select_country").multiselect("widget").find("input:checkbox").triggerHandler('click'); $("#select_country").trigger('click'); </code></pre>
jquery
[5]
2,860,906
2,860,907
I thought there's only one manifest file in an Android Project
<p>What's it means by that comment of "The activity you are calling should appear not only in the Manifest for its own package, but in the Manifest for the CALLING package, too." I only have one package. </p> <p><a href="http://stackoverflow.com/questions/3433778/android-content-activitynotfoundexception">android.content.ActivityNotFoundException:</a></p>
android
[4]
1,328,532
1,328,533
javascript copying array to another
<p>i have the following code snippet, where inside for loop the value to contain is not getting assigned, is this is the proper way to copy array to other.??</p> <p>as here </p> <pre><code> var groupCondition = "ALL-OF-THEM&amp;ALL-OF-THEM&amp;ALL-OF-THEM&amp;ALL-OF-THEM&amp;"; var groupParam = "rsTxTraceMsgAside&amp;rsExpTraceMsgAside&amp;rsTxTraceMsgBside&amp;rsExpTraceMsgBside&amp;#hp1TxTraceMsg&amp;hp1ExpTraceMsg&amp;#"; var grpNameArr = groupParam.split("#"); var groupcn= groupCondition.split("&amp;"); var m=grpNameArr.length; var contain=new Array(); var cmds=new Array(); var ii; for(ii=0;ii&lt;(m-1);ii++) { contain[ii] = groupCn[ii]; cmds[ii] = grpNameArr[ii]; } </code></pre>
javascript
[3]
1,582,228
1,582,229
Memory allocation for an Exception
<p>Can you please explain, where the instances of Exception or it's children are allocated in memory? Is it heap or stack, or something else?</p> <p>Thanks!</p>
java
[1]
5,428,816
5,428,817
Dictionaries in Python
<p>What do these two statements mean in Python?</p> <pre><code>distances[(clust[i].id,clust[j].id)]=distance(clust[i].vec,clust[j].vec) d=distances[(clust[i].id,clust[j].id)] </code></pre> <p>I am guessing that the first statement assigns clust[i].id and clust[j].id keys of the distances map to the result of the distance(..) function. However, I am confused since lists are represented using [ ] and dictionaries using { } in Python. What's the correct answer? </p>
python
[7]
3,567,512
3,567,513
How can I scroll through a set of images using jQuery?
<p>I have a set of MRI images and want to build an interface which people can use to scroll trough them. I can export them as JPGs or 1 AVI. Are there plugins that do this? When I search google I only find these portfolio sliders which are not what I need. When I scroll forward or backward I need the new image to appear in the same spot as the previous. No effects.</p>
jquery
[5]
4,227,391
4,227,392
Inconsistent accessibility error with the following c# code. Why?
<p>Whats wrong with the following c# code? Compiler reports this error:</p> <p>Inconsistent accessibility: parameter type 'ClassLibrary1.Interface1' is less accessible than method 'ClassLibrary1.Class1.Class1(ClassLibrary1.Interface1)'</p> <p>with the following code:</p> <pre><code>interface Interface1&lt;T&gt; { bool IsDataValid(); /* Other interfaces */ } public class Class1&lt;T&gt; { public Interface1&lt;T&gt; interface1; public Class1(Interface1&lt;T&gt; interface1) { this.interface1 = interface1; } } </code></pre> <p>I've since designed my code differently using inheritence to but if anyone could tell me what the above is wrong I'd greatly appreciate it.</p>
c#
[0]
5,563,188
5,563,189
Running a python script from another script
<p>I wish to a run a python script which takes options and arguments from another python script.</p> <blockquote> <pre><code>For example run C:\\code\\old_start_training_generic_depth.py -i 10 -l 2 from C:\\code\\start.py </code></pre> </blockquote>
python
[7]
2,735,912
2,735,913
What is the difference between an JSON and Array?
<p>What is the difference between an JSON and Array? Why do they call JSON Objects and Array Objects. </p> <p><a href="http://wiki.appcelerator.org/display/guides/Using+TableViews+-+data.js" rel="nofollow">http://wiki.appcelerator.org/display/guides/Using+TableViews+-+data.js</a></p> <p>Is this an Array or JSON? How can i identify?</p>
javascript
[3]
2,034,133
2,034,134
in saveState what's my context?
<p>I am trying to do some cleanup within a saveState() call. I want to pop-up a dialog if there is an error on exiting the activity, but the activity is already gone by this point.</p> <p>I want to have this happen from an activity called StudentEdit but what should the context be? When I use StudentEdit.this, the dialog pops up and then disappears. getApplicationContext causes a null pointer exception.</p> <pre><code>private void saveState() { // some error checking code // if blah blah AlertDialog alertDialog = new AlertDialog.Builder(StudentEdit.this).create(); alertDialog.setMessage("error"); alertDialog.setButton(BUTTON_POSITIVE, "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do something for yes } }); alertDialog.setButton(BUTTON_NEGATIVE, "No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); // kill dialog StudentEdit.this.finish(); // kill the activity } }); alertDialog.show(); } </code></pre>
android
[4]
5,703,740
5,703,741
Number formatting: how to convert 1 to "01", 2 to "02", etc?
<p>I'm new to C#. I have numbers like 1,2,3 and I would like to make them into strings "01","02" and "03". Can someone tell me how I can do this. </p>
c#
[0]
314,902
314,903
How to auto refreash previous content after press back button form current content android
<p>I developed a android notepad application, I have view interface and edit interface, suppose I edit content in edit interface and press back button to view interface, the view interface's content should be changed from previous one, at the moment I can't update the view content in the same time, how can I achieve that, please help, thanks! And is there is a way that I can refresh the tab content once I click the tab in tab layout, thanks!</p>
android
[4]
3,955,679
3,955,680
how to detect discard button is pressed when sending email android
<p>how to detect discard button is pressed when sending email android</p>
android
[4]
4,097,923
4,097,924
Generate random string from a list of string with certain probabilities
<p>I am trying to generate random string from list of array string with required probablities in java.i am able to generate random string but dont know how do with probabilities.I have to run program almost 25 - 30 times </p> <pre><code>Probability for abc is 10% for def is 60% for ghi is 20% for danny is 10% </code></pre> <p>But i am not able to do this.</p> <pre><code> import java.util.*; public class newyork { public static void main(String[]args) throws Exception { // othr fun public static void abc() { //Strings to display String [] random = {"abc","def", "ghi","danny"}; //Pick one by one String no1= random[(int) (Math.random()*(random.length))]; String no2 = random[(int) (Math.random()*(random.length))]; String no3 = random[(int) (Math.random()*(random.length))]; //print randomly generated strings System.out.println("Here you go : " + no1 + " " + no2 + " " + no3 + "); } </code></pre>
java
[1]
1,818,413
1,818,414
Will hasOwnProperty ever return false from inside a for...in loop?
<p>If I do this: </p> <pre><code>for (var i in obj) { if (obj.hasOwnProperty(i)) console.log("Has property: " + i); else console.log("Doesn't have property: " + i); } </code></pre> <p>Will <code>obj.hasOwnProperty(i)</code> ever return <code>false</code>? If so, when?</p>
javascript
[3]
3,285,865
3,285,866
Setting an object to a split array
<p>I'm not a javascript guru. I've got the following code below:</p> <pre><code>var aCookieValues = sCookieContentString.split('&amp;'); // split out each set of key/value pairs var aCookieNameValuePairs = aCookieValues.split('='); // return an array of each key/value </code></pre> <p>What I'm trying to do is split the first string via &amp; and then create another array that takes the first array and splits it further via the = character that exists in every value in the aCookieValues array</p> <p>I get the error aCookieValues.split is not a function.</p> <p>I've seen an example that basically does the same thing but the second time this guy is using a loop:</p> <p>(http://seattlesoftware.wordpress.com/2008/01/16/javascript-query-string/)</p> <pre><code> // '&amp;' seperates key/value pairs var pairs = querystring.split("&amp;"); // Load the key/values of the return collection for (var i = 0; i &lt; pairs.length; i++) { var keyValuePair = pairs[i].split("="); queryStringDictionary[keyValuePair[0]] = keyValuePair[1]; } </code></pre> <p>Ultimately what I'm trying to achieve here is a final dictionary with key/value pairs based off the '=' split. I'm simply trying to split up a cookie's values and shove it into a nice dictionary so I can then get certain values out of that dictionary later on.</p>
javascript
[3]
5,990,542
5,990,543
android : communication between service running in background and activity
<p>I have a service running in the background. Based on some condition it has to start some activity. Activity has to send back the response.</p> <p>I did google search and found out we have to use Notification mechanism. But I am not clear how to send the response back from activity to the service running.</p> <p>Also service is collecting sensor data(acclerometer, gps). So should activity be started in separate thread so that collecting sensor data is not affected.</p> <p>Please clarify.</p>
android
[4]
3,090,815
3,090,816
Difference between foo() and function() { foo(); }
<p>Is there any advantage of wrapping a function with an anonymous function? I mean a particular example:</p> <pre><code>function asyncFuntion(callback) { setTimeout(callback, 6000); }; asyncFuntion(function() { console.log('Calling after 6 s.'); }); </code></pre> <p>and with the wrapped function:</p> <pre><code>function asyncFuntion(callback) { setTimeout(function() { callback(); }, 6000); }; asyncFuntion(function() { console.log('Calling after 6 s.'); }); </code></pre> <p>In both cases output is the same. So is there any difference? The second version is what I found learning js. I realize that such a form is useful when we need closures but here? </p>
javascript
[3]
1,023,967
1,023,968
How can I avoid vote spam on my PHP site
<p>I am doing a voting system on my website. </p> <p>Visitors do not need to login to vote the product they like. But how can I prevent them from clicking the like or dislike button many times for one product ?</p> <p>I intend to detect the IP address of the visitor to avoid vote spam. Is that a good way?</p> <p>Thanks for any suggestions!</p>
php
[2]
5,685,075
5,685,076
Is it possible that Javascript keep same expression value?
<p>I was wondering if javascript calculate (again) same expressions as it encounters them : </p> <p>for example : </p> <p><code>alert(new Date().getTime()+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1+1-1-new Date().getTime())</code></p> <p><code>output : 0</code></p> <p>it's hard to test it like it but I thought that all the <code>+/-1</code> will take it some time ( a tick) so I could see a difference.</p> <p>But the answer is 0.</p> <p>So , </p> <p>Is it zero because its just too fast or because JS treats the first new Date() as the same as the later one ? </p>
javascript
[3]
5,184,059
5,184,060
how can i use sqlite with android mobile?
<p>i create sqlite database and it works fine with emulator bur when i try this application on my android mobile it give my exception sqliteException no such table anyone tell me why and how can i solve this problem ? Thanks</p>
android
[4]
967,607
967,608
Closing a form and doing something on return to another form
<p>I have a mainForm and a saveForm. I never close the mainForm, just let the saveForm appear over the top.</p> <p>When i close the saveForm, I want a piece of code to run on returning to mainForm.</p> <p>What is the best way to achieve this?</p>
c#
[0]
1,379,909
1,379,910
Re-run jquery script when ajax call is made
<p>I have a jquery float box plugin. The document is loaded and on a buttonpress an ajaxcall triggers box.php which parse the box <code>#floating-box</code> to be floated (the box is then showed on alla pages from now on). The problem is that the script which is within <code>$(document).ready(function(){..</code> does not find the box (if I refresh it works so the scipt is OK). I am novice but I guess this could be solved with some kind of <code>live</code>solution. Can someone guide me in the right direction?</p> <p>start of jquery script. the script works so the whole script itself is not of interest, rather how to re-run it when box.php have parsed the box <code>#floating-box</code> but still to run it on every document load since the box appears on all pages from now on and needs to float on them too.</p> <pre><code>var $floatingbox = $('#floating-box'); if($('#floating-container').length &gt; 0){.. </code></pre>
jquery
[5]
1,247,737
1,247,738
Changing a library's name in Python
<p>I have a rather large personal python library that I use for projects. I want to release it to the public, but first I wanted to change the name to something a little less silly then the personal anecdote that I named it after. </p> <p>Lets say I have a library name "FooBarLib" and it is contained within the folder "FooBarLib" and internally it makes references to "import FooBarLib.moduleName" and what have you. </p> <p>I want to change it to "NewLibName" and have every instance in every file of "FooBarLib" replaced with "NewLibName". </p> <p>What is the best way to go about this?</p>
python
[7]
730,188
730,189
How can you restrict certain apps from launching on Android?
<p>I'm trying to build a sandboxed environment in which only certain apps are allowed to be launched.</p> <p>I had originally decided to try polling all running apps in the background to see which ones were running, then killing any that weren't on the whtielist. However, I discovered that you can only kill background processes, not active tasks.</p> <p>If this can be done, how? </p>
android
[4]
4,216,896
4,216,897
Keeping track of visitors in my shopping cart application?
<p>I'm writing a simple shopping cart application and have hit a road block. Currently my shopping cart application associates the shopping cart (in the DB) with the user's id on the site, but I want to allow visitors to add items to the cart as well. </p> <p>I asked this question a while back on stackoverflow and the one answer I got was "use sessions." However, after reading about sessions, it appears that the session variables are destroyed when the user closes their browser, and on top of that there is a time limit to how long they can last. Additionally, I read that having lots of session variables can "bog down" the server.</p> <p>So now I'm back to square one. Should I use session variables to keep track of visitors who want to add things to their cart (I would like a visitors cart to remain available to them for a few weeks)? I also thought of using their IP address, but I know that that changes depending on where they are connecting to the internet (if using a laptop).</p> <p>What do you recommend?</p>
php
[2]
4,409,843
4,409,844
Calculating Day, Month, Year
<p>How do I calculate Day, Month, Year exactly?</p> <p>Means..</p> <p>From 2th Jan 1990 to 9th May 2009 is..</p> <p>xxx Days, xxx Months, xxx Years.</p> <p>Any idea how to do that?</p> <p>I tried Timespan and Tick().. Both failed to do so..</p>
c#
[0]
1,775,797
1,775,798
Running a jQuery from a different page
<p>So I have the following files <code>a.html</code>, <code>b.html</code>, <code>c.js</code>. I would like to be able to achieve the following:</p> <p>When I click on a link on <code>a.html</code>, be redirected to <code>b.html</code>, and only after <code>b.html</code> is completely loaded, then my <code>c.js</code> runs and make references to an element of <code>b.html</code>. For instance opens a panel.</p>
jquery
[5]
282,813
282,814
uploading a file from iphone to server
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3465361/how-to-upload-a-file-to-the-server-in-iphone-sdk">How to upload a file to the server in iPhone SDK?</a> </p> </blockquote> <p>hi </p> <p>i am a beginner in iphone applications i want to make an application for transfering a file from iphone to server to later print it .how can i perform it can anyone tell me the code for this .</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface printerapplicationAppDelegate : NSObject &lt;UIApplicationDelegate&gt; { UIWindow *window; UILabel *display; UILabel *display1; IBOutlet UIButton *print; IBOutlet UIButton *cancel; IBOutlet UITextField *addres; IBOutlet UITextField *name; } -(IBAction) print: (id) sender; -(IBAction) cancel: (id) sender; @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UILabel *display; @property (nonatomic, retain) IBOutlet UILabel *display1; @property (nonatomic, retain) IBOutlet UITextField *name; @property (nonatomic, retain) IBOutlet UITextField *address; @end </code></pre>
iphone
[8]
5,616,955
5,616,956
Refresh content in Tab of TabActivity
<p>I have a tab with an intent as its content:</p> <pre><code> tabHost.addTab(tabHost.newTabSpec("tab3") .setIndicator("Chart") .setContent(lineChartIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))); </code></pre> <p>How is it possible to refresh the content of a tab? I am thinking of a method like</p> <pre><code>tab.refreshContent() </code></pre> <p>or similar. Background is: My intent contains a graph and I want to repaint this graph upon click of a button while the tab remains selected. Thanks.</p>
android
[4]
307,395
307,396
I dont want to register my app in facebook ,i need post comments on user facebook wall page
<p>I don't want to register my app in Facebook, I need to post comments on the users Facebook wall page. How to implement this? If I press button it should show users Facebook wall page to publish comments about app.</p>
android
[4]
2,099,241
2,099,242
Accessing from an Abstract Class
<pre><code>public abstract class Password { private String password; private final static String ENCRYPTION_METHOD; static { ENCRYPTION_METHOD = "CLEAR TEXT"; } public Password(String password) { password = password; } public String getPassword() { return password; } public boolean matches (String aString) { if (aString.equals(password)) { return true; } else { return false; } } public String toString() { return password; } public static String getEncryptionMethod() { return ENCRYPTION_METHOD; } abstract String decrypt(); </code></pre> <h2> }</h2> <pre><code> public class EncryptedPassword extends Password { private final static String ENCRYPTION_METHOD; static { ENCRYPTION_METHOD = "PERMUTATION"; } public EncryptedPassword(String password) { super(password); } public boolean matches (String aString) { if (aString.equals("True")) { return true; } else { return false; } } public String toString() { return "Password: " + super.toString(); } public String decrypt() { return password; } public static String getEncryptionMethod() { return ENCRYPTION_METHOD; } </code></pre> <p>}</p> <p>Hi, i was wondering if you guys knew how I return my password on my EncryptedPassword class, but still by keeping it concrete and keeping my Password class Abstract. Is there any basic way of doing it. Also, sorry for the terrible formatting..</p>
java
[1]
3,267,341
3,267,342
PHP giving strange diff. in time
<p>Hi i have a script its returning time diff. on diff. computer when all on same network it return time same on Site but when 1 comp. is on diff. network it return diff. time</p> <p>i am struggling with this i know php is server side language i have checked there is not any JavaScript code for this so its not taking Client time</p> <p>its using</p> <pre><code> &lt;?php echo time(); ?&gt; </code></pre> <p>i can't able to post Full code but its using time() and then subtracting from saved mysql time</p>
php
[2]
3,623,931
3,623,932
PHP array question
<p>How do I show the dates number format next to its name in the array using PHP? So that the number format is saved in the database and the month name is displayed?</p> <p>Here is the php code.</p> <pre><code>$month_options = array("Month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); </code></pre>
php
[2]
5,360,231
5,360,232
JSON Parsing NullPointerException in android
<p>I am learning JSON parsing in android. My logcat is showing NullPointerException onpostexecute method. I have shared the code below.</p> <pre><code> protected String doInBackground(String... urls) { // TODO Auto-generated method stub try { // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url1); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); result = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } return result; } protected void onPostExecute(String result) { // try parse the string to a JSON object try { jObj = new JSONObject(result); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } } public JSONObject getJSONFromUrl() { return jObj; } </code></pre> <p>JSONParser object in Main Activity </p> <pre><code>JSONParser jParser = (JSONParser) new JSONParser().execute(url); try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO: handle exception e.printStackTrace(); } // getting JSON string from URL JSONObject json = jParser.getJSONFromUrl(); </code></pre> <p>I can't figure out the problem. provide suggestions....</p>
android
[4]
3,741,475
3,741,476
Disable a widget from showing if app isn't licensed?
<p>I just spent around an hour implementing the android market licencing tools into my app.</p> <p>The app in question is a widget, I want to know how I would go about stopping the widget (a button) from functioning, if the app isn't licensed.</p> <p>Does anyone know how this could be accomplishes?</p>
android
[4]
718,767
718,768
how to find number of similar words in two strings?
<p>I have two stings:</p> <pre><code>$var_x = "Depending structure"; $var_y = “Depending on the structure of your array "; </code></pre> <p>Can you please tell me how can I found out, how many words in var_x is in var_y? In order to do that, I did the following:</p> <pre><code>$pieces1 = explode(" ", $var_x); $pieces2 = explode(" ", $var_y); $result=array_intersect($pieces1, $pieces2); //Print result here? </code></pre> <p>But this didn't show many how many of var_x words are in var_y</p>
php
[2]
5,143,902
5,143,903
Precedence between conversion operators in C++
<p>During parameter resolution for a function which expects a pointer, why is the the reference-to-pointer conversion being selected rather than the pointer conversion?</p> <pre><code>template&lt;typename T&gt; class resource_ptr { public: operator T*()const {...} // &lt;- C1: Convert to raw pointer for observation. operator T*&amp;() {...} // &lt;- C2: Convert to reference to pointer, for assignment. ... }; ... void AcquireResource(resource_class *&amp;); // Assigns to the given pointer. void UseResource(resource_class *); ... resource_ptr&lt;resource_class&gt; rpResource; AcquireResource(rpResource); // &lt;- Calls C2, as expected. UseResource(rpResource); // &lt;- Calls C2. C1 would have been nice. UseResource((resource_class*)rpResource); // &lt;- Still calls C2. ??? </code></pre> <p>Note that in this particular design, since C2 is granting write access, it asserts that the resource pointer is currently unassigned, to prevent resource leaks. So it's important that C2 only get used when we actually want the pointer by reference, as when passing to an API which assigns to it. As it stands, this design is broken.</p> <p>(These conversions can be replaced with explicit functions, but I would like to understand this issue.)</p>
c++
[6]
1,002,912
1,002,913
C++ -- Should the subclass destructor explicitly call base class destructor?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/677620/do-i-need-to-explicitly-call-the-base-virtual-destructor">Do I need to explicitly call the base virtual destructor?</a> </p> </blockquote> <p>Hello all,</p> <p>I would like to know whether or not a sub-class destructor should call base-class destructor explicitly. My answer is NO.</p> <p>For example,</p> <pre><code>class A { public: A() {...} virtual ~A() {...} protected: ... private: ... }; class B: public A { public: B() {...} virtual ~B() { ... // should we call destructor of A? } protected: ... private: ... }; </code></pre> <p>Thank you</p>
c++
[6]
3,944,901
3,944,902
How do I consume a key event in javascript, so that it doesn't propagate?
<p>How do I consume a key event in javascript, so that it doesn't propagate?</p>
javascript
[3]
2,245,129
2,245,130
Can javascript be used to write to a file?
<p>Can javascript be used to write to a file ? Sorry restate that (Can javascript be used to write to a file on the web server it is hosted on? ).</p>
javascript
[3]
3,311,487
3,311,488
subprocess() arguments in Python
<p>I have an argument in Python that is screwing up my subprocess() command. The argument is:</p> <pre><code>--server-args="-screen 0, 1280x800x24" args = [ 'xvfb-run', '--server-args="-screen 0, 1280x800x24"', '/usr/bin/python', '/root/AdamN-python-webkit2png-3ae4322/webkit2png.py', '-o', filename, url, ] </code></pre> <p>I think it's escaping the double quotes. Is there a work around for this?</p>
python
[7]
4,562,883
4,562,884
how to remove first item from spinner
<p>whenever i create a spinner by default it shows first element in spinner. i want to show my own hint on that spinner.</p> <p><strong>note:- i am receiving data from web services.</strong></p> <p>my code is:-</p> <pre><code> &lt;Spinner android:id="@+id/spinnerAtlasContactSignup" android:layout_width="200dip" android:layout_height="46dp" android:layout_below="@+id/editCompanySignup" android:layout_marginBottom="60dp" android:layout_marginTop="10dp" android:background="@drawable/slect_box1x" android:ems="10" android:padding="10dp" android:prompt="@string/atlas_contact" /&gt; private void initializeSpinner(ArrayList&lt;AtlasContact&gt; atlastContacts) { ArrayAdapter&lt;AtlasContact&gt; adapter = new ArrayAdapter&lt;AtlasContact&gt;(this,android.R.layout.simple_spinner_item, atlastContacts); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinnerAtlasContact.setAdapter(adapter); </code></pre> <p>here <code>AtlasContact</code> is a class which accepts the data coming from web services.</p>
android
[4]
123,903
123,904
what does 'objects being subclassable' mean?
<p><a href="http://diveintopython.net/getting_to_know_python/everything_is_an_object.html" rel="nofollow">Dive into Python</a> - </p> <blockquote> <p>Different programming languages define “object” in different ways. In some, it means that all objects must have attributes and methods; in others, it means that all objects are subclassable. In Python, the definition is looser; some objects have neither attributes nor methods (more on this in Chapter 3), and not all objects are subclassable (more on this in Chapter 5). </p> </blockquote> <p>I am coming from <code>C++/Java</code> background. </p>
python
[7]
2,809,233
2,809,234
recursion problems
<p>I'm grabbing links from a website, but I'm having a problem in which the higher I set the recursion depth for the function the results become stranger </p> <p>for example when I set the function to the following </p> <pre><code>crawl_page("http://www.mangastream.com/", 10); </code></pre> <p>I will get a results like this for about half the page </p> <p><strong>http://mangastream.com/read/naruto/51619850/1/read/naruto/51619850/2/read/naruto/51619850/2/read/naruto/51619850/2/read/naruto/51619850/2/read/naruto/51619850/2/read/naruto/51619850/2/read/naruto/51619850/2</strong></p> <p>EDIT </p> <p>while I'm expecting results like this instead </p> <p><strong>http://mangastream.com/manga/read/naruto/51619850/1</strong></p> <p>here's the function I've been using to get the results </p> <pre><code>function crawl_page($url, $depth) { static $seen = array(); if (isset($seen[$url]) || $depth === 0) { return; } $seen[$url] = true; $dom = new DOMDocument('1.0'); @$dom-&gt;loadHTMLFile($url); $anchors = $dom-&gt;getElementsByTagName('a'); foreach ($anchors as $element) { $href = $element-&gt;getAttribute('href'); if (0 !== strpos($href, 'http')) { $href = rtrim($url, '/') . '/' . ltrim($href, '/'); } if(shouldScrape($href)==true) crawl_page($href, $depth - 1); } echo $url,"\r"; //,pageStatus($url) } </code></pre> <p>any help with this would be greatly appreciated </p>
php
[2]
1,820,853
1,820,854
how to use onclick event of <a>
<p>i want to use <code>onclick</code> event of <code>&lt;a&gt;</code> when i use srh like below doesn't work</p> <pre><code>... &lt;a oncick="reg_Click"&gt;...&lt;/a&gt; or &lt;a onclick="reg_Click" runat="server"&gt;...&lt;/a&gt; //function protected void reg_Click(object sender, EventArgs e) {... </code></pre>
asp.net
[9]
1,316,510
1,316,511
javascript class - this.method called with setInterval
<p>I have a javascript class</p> <pre><code>funtion MyClass() { MyClass.prototype.fooMethod = function () { // some logic goes here... } MyClass.prototype.fooMethod2 = function () { this.fooMethod(); } } </code></pre> <p>Everything works as expected when I call like this:</p> <pre><code>var m = MyClass(); m.fooMethod2(); </code></pre> <p>However when I have this code called by setInterval I get an error: "Uncaught TypeError: Object [object DOMWindow] has no method 'fooMethod'"</p> <pre><code>var m = MyClass(); var intervalId = setInterval(m.fooMethod2, 100); </code></pre> <p>Is there any way I can use setInverval to call my method?</p>
javascript
[3]
5,456,896
5,456,897
asp.net now() function with different time zones
<p>I will be entering some values into a database based on input from users. One value will be the date and time of the input.</p> <p>I'm not sure how this works at all, but a user from e.g. New York enters some data and the website is hosted in the UK...what time will be stored?</p> <p>Up until now I had been using the "now()" function to record the date and time, but just occured to me that this could happen! What else should I use?</p> <p>Thanks,</p>
asp.net
[9]
1,916,714
1,916,715
iterative Newton's method
<p>I have got this code to solve Newton's method for a given polynomial and initial guess value. I want to turn into an iterative process which Newton's method actually is. The program should keeping running till the output value "x_n" becomes constant. And that final value of x_n is the actual root. Also, while using this method in my algorithm it should always produce a positive root between 0 and 1. So does converting the negative output (root) into a positive number would make any difference? Thank you. </p> <pre><code>import copy poly = [[-0.25,3], [0.375,2], [-0.375,1], [-3.1,0]] def poly_diff(poly): """ Differentiate a polynomial. """ newlist = copy.deepcopy(poly) for term in newlist: term[0] *= term[1] term[1] -= 1 return newlist def poly_apply(poly, x): """ Apply a value to a polynomial. """ sum = 0.0 for term in poly: sum += term[0] * (x ** term[1]) return sum def poly_root(poly): """ Returns a root of the polynomial""" poly_d = poly_diff(poly) x = float(raw_input("Enter initial guess:")) x_n = x - (float(poly_apply(poly, x)) / poly_apply(poly_d, x)) print x_n if __name__ == "__main__" : poly_root(poly) </code></pre>
python
[7]
2,232,019
2,232,020
Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed
<p>when i create a web request in my class file and execute it then an error occured </p> <p>Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed</p> <p>what can i do for this</p>
asp.net
[9]
3,833,818
3,833,819
How can I delete specific rows from a table?
<p>I have a table with <code>n</code> number of rows. The value of <code>n</code> changes/updates every minute. The first <code>&lt;td&gt;</code> of every row will either contain some text, or it will be blank. I want to delete/remove all the rows except, the first row and the row whose first cell contains the text <code>'xyz'</code>. So, how will I be able to do this? This <code>table</code> element is stored in the variable <code>parentTable</code>.</p> <p>I'm kind of new to javascript and programming. Any help would be appreciated. Thanks.</p> <p>I tested it with just the second row, but nothing happened even though the text is not <code>xyz</code> in the cell. </p> <pre><code>if(parentNode.childNodes[1].innerText !== "xyz") parentTable.deleteRow[1]; </code></pre> <p>And how do I loop around every row and do this?</p> <p>EDIT: HTML for first cell in every row.</p> <pre><code>&lt;td class=wbwhite align=center width=40 style="border-top: none; border-left:none; border-right:none;"&gt; &amp;nbsp; &lt;a href="www.kasdjfkasd.sadsdk.comi" class=pi&gt;xyz&lt;/a&gt; &amp;nbsp; &lt;/td&gt; </code></pre>
javascript
[3]
2,685,671
2,685,672
Java Serialization with object input/output stream
<p>In java, we are serializing the objects i.e. object state over network using serializable marker interface and object streams(serilaze and deseriaze). But we are having a different streams to write the object state.why we are marked the serialization for that object?.</p>
java
[1]
91,669
91,670
Javascript generate random number from 0 to 75
<p>I am using something like this: <code>alert("Random number is: "+ Math.floor(Math.random() * 75) + 0);</code>. To create a random number between 0 and 75. Any idea how I can create a random number between 0 and 75 that IS NOT one of the numbers in this comma-parsed string: <code>$not_these_numbers = "17,26,52,75";</code>.</p>
javascript
[3]
5,011,120
5,011,121
How back button is working in the browser?
<p>I have listed projects in main work page, If i click on the project it will direct to work page where details have been displayed,If i click on the back button its is redirecting main work page.I want back button should redirect the previous project please help.</p>
php
[2]
4,354,335
4,354,336
Javascript getElementById in separate JS file, src written with javascript
<p>i want someone to include a JS file of me which does something neat. I thought i put it up just like Google: you put a script tag in your source and the google js takes care of everything. in my php file is this:</p> <pre><code>echo '&lt;script type="text/javascript" src="http://www.site.com/gadget.js"&gt; &lt;/script&gt;'; </code></pre> <p>i that gadget.js, i write a span:</p> <pre><code>document.write('&lt;span id="GadgetPicture&gt;'); document.write('&lt;/span&gt;'); window.setTimeout('refreshImage();', 2000); </code></pre> <p>in the refreshImage function, i want to reference my span:</p> <pre><code>document.getElementById("GadgetPicture"); </code></pre> <p>But it gives me null... Does anybody know why?</p> <p>also, <code>document.getElementById("body")</code> also give null.</p> <p>Michel</p>
javascript
[3]
5,814,182
5,814,183
fetch html content from website
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-with-php">How to parse and process HTML with PHP?</a> </p> </blockquote> <p>I have used this code for fetching html content from given website of url.</p> <pre><code>**Code:** ================================================================= example URL: http://www.qatarsale.com/EnMain.aspx /* $regexp = '/&lt;div id="UpdatePanel4"&gt;(.*?)&lt;\/div&gt;/i'; @preg_match_all($regexp, @file_get_contents('http://www.qatarsale.com/EnMain.aspx'), $matches, PREG_SET_ORDER);*/ /* </code></pre> <p>but $matches returns blank array. I want fetch all html content that are found in div id="UpdatePanel4".</p> <p>If anybody have any solution please suggest me.</p> <p>Thanks</p>
php
[2]
1,738,228
1,738,229
Run PHP code on a specific domain only
<p>I need to echo out some specific php code only on the sub-domain of a site. This is where I am so far.</p> <pre><code>&lt;?php if($_SERVER['SERVER_NAME'] != "http://support.demo.com") echo "&lt;?php bb_head(); ?&gt;"; ?&gt; </code></pre> <p>Of course if this worked I'd not be asking a question. Help is appreciated.</p>
php
[2]
5,396,355
5,396,356
how to get world wide current date and time
<p>i want to access the current date/time. i did some query it gives me the system date/time. when i changed the system date then it gives the changed date/time. but i want the current date/time after changing the date/time. </p> <p>Note: I am not connected to the Internet and i want to do this in windows c#.net</p>
c#
[0]
2,386,844
2,386,845
Download PHP array as a file
<p>I have an array with 3 attributes. I want to create a downloadable link for a file which has the array in a tab-delimited format.</p> <pre><code>ATTR1 ATTR2 ATTR3 23.7 45.89 1.09 .... ..... .... .... ..... .... .... ..... .... </code></pre>
php
[2]
1,154,462
1,154,463
need help understanding cin buffer behavior
<p>The code below shows the output as </p> <blockquote> <pre><code>enter something abc you entered: a you entered: b you entered: c </code></pre> </blockquote> <pre><code> #include "stdafx.h" #include &lt;iostream&gt; using namespace std; int _tmain(int argc, _TCHAR* argv[]) { char c; while(cin&gt;&gt;c) { //Do something cout&lt;&lt;"you entered: "&lt;&lt;c&lt;&lt;"\n"; } return 0; } </code></pre> <p>why is it not showing only the first character entered? I know I can force it to ignore the cin buffer after first char by using</p> <p><code>cin.ignore(1,'\n')</code></p> <p>but shouldnt it only ready one character and ignore the rest?</p>
c++
[6]
1,872,121
1,872,122
Generic Dictionary as ref method param
<p>I am trying to do something like this</p> <pre><code>public void GetData(ref Dictionary&lt;T,V&gt; dataDictionary) { } </code></pre> <p>Where T can be GUID, string, or int and V is custom user or item object.</p>
c#
[0]
1,510,320
1,510,321
store comparators objects in array
<p>I have defined 4 comparators for my object like this:</p> <pre><code>public static Comparator&lt;mObject&gt; comp0 = new Comparator&lt;mObject&gt;() { @Override public int compare(mObject l, mObject r) { ...compare } }; public static Comparator&lt;mObject&gt; comp1 = new Comparator&lt;mObject&gt;() { @Override public int compare(mObject l, mObject r) { ...compare } }; public static Comparator&lt;mObject&gt; comp2 = new Comparator&lt;mObject&gt;() { @Override public int compare(mObject l, mObject r) { ...compare } }; public static Comparator&lt;mObject&gt; comp4 = new Comparator&lt;mObject&gt;() { @Override public int compare(mObject l, mObject r) { ...compare } }; </code></pre> <p>Now i want to create an array with the 4 comparators ,like this :</p> <pre><code>public final static Comparator&lt;mObject&gt;[] Object_comparators = { comp0, comp1, comp2, comp3}; </code></pre> <p>but Eclipse underlines everything between {..} like it is an error .Why is it ,and how could i fix it ?</p>
java
[1]
3,047,221
3,047,222
some questions i have when converting from classic asp to .NET
<p>in my classic asp website, there is an <code>objCMD</code> variable being set to the value of <code>Server.CreateObject("ADODB.Command")</code>. i think that <code>objCMD</code> should be turned into a <code>SqlCommand</code> .NET object, but i need confirmation first. i'm still not sure what <code>Server.CreateObject("ADODB.Command")</code> is doing.</p> <p>can someone explain <code>Server.CreateObject()</code> to me?</p>
asp.net
[9]
4,261,240
4,261,241
onclick on span using jquery
<p>I have the following HTML</p> <pre><code>&lt;a title="Prev" data-event="click" data-handler="prev" class="ui-datepicker-prev ui-corner-all"&gt; &lt;span class="ui-icon ui-icon-circle-triangle-w"&gt;Prev&lt;/span&gt; &lt;/a&gt; </code></pre> <p>I need to change 'Prev' once click on span using jquery</p> <p>this my code</p> <pre><code>$(".ui-icon.ui-icon-circle-triangle-w").click(function(){ $(".ui-icon.ui-icon-circle-triangle-w").html('«'); }); </code></pre> <p>but it dows not work, Why?</p>
jquery
[5]
4,435,095
4,435,096
I have a txt file. How can I take dictionary key values and print the line of text they appear in?
<p>I have a txt file. I have written code that finds the unique words and the number of times each word appears in that file. I now need to figure out how to print the lines that those words apear in as well. How can I go about doing this? </p> <blockquote> <p>Here is a sample output: Analyze what file: itsy_bitsy_spider.txt<br> Concordance for file itsy_bitsy_spider.txt itsy : Total Count: 2 Line:1: The ITSY Bitsy spider crawled up the water spout Line:4: and the ITSY Bitsy spider went up the spout again</p> </blockquote> <pre><code>#this function will get just the unique words without the stop words. def openFiles(openFile): for i in openFile: i = i.strip() linelist.append(i) b = i.lower() thislist = b.split() for a in thislist: if a in stopwords: continue else: wordlist.append(a) #print wordlist #this dictionary is used to count the number of times each stop countdict = {} def countWords(this_list): for word in this_list: depunct = word.strip(punctuation) if depunct in countdict: countdict[depunct] += 1 else: countdict[depunct] = 1 </code></pre>
python
[7]
4,706,473
4,706,474
how to call [object htmlDivElement]
<p>i want to call the functions <strong>movein(this)</strong> &amp; <strong>moveout(this)</strong> directly with out using onmouseover or onmouseout by the way (<strong>this</strong>) is [object htmlDivElement]</p> <pre><code> var tb = '&lt;div id="' + o.id + '" onmouseover="movein(this);" onmouseout="moveout(this);"&gt;&lt;div&gt;&lt;table&gt;\n'; </code></pre>
javascript
[3]
4,731,897
4,731,898
Android: When is it appropriate to store images in the assets rather than the drawable folders?
<p>I have a bunch of images that are common for all resolutions (currently I only support one resolution. There are reasons for this).</p> <p>My question is, when is it appropriate to store images in the assets folder rather than the drawable folder?</p>
android
[4]
3,078,022
3,078,023
Extending interfaces using inheritance
<pre><code>class IA { public: virtual void a() = 0; }; class A: public IA { public: virtual void a() { } }; class IB { public: virtual void b() = 0; }; class B: public IB, public A { public: virtual void b() { } }; void f(IA* p) { } int main() { B b = B(); IB* p = &amp;b; f(p); } </code></pre> <p>Is this the correct way to implement interfaces with inheritance in C++? If so, how do I get the line <code>f(p);</code> in my code to compile? Basically, I would like if <code>IB</code> could inherit from <code>IA</code> but this will cause problems for B.</p> <p><strong>UPDATE</strong></p> <p>What I want is for <code>IB</code> to include <code>IA</code>'s interface, as follows. However this code wont compile since <code>IA::a()</code> and <code>A::a()</code> conflict with each other. What should I do?</p> <pre><code>class IA { public: virtual void a() = 0; }; class A: public IA { public: virtual void a() { } }; class IB : public IA { public: virtual void b() = 0; }; class B: public IB, public A { public: virtual void b() { } }; </code></pre> <p><strong>UPDATE 2</strong></p> <p>This compiles, does it look correct? Do I need all these virtuals</p> <pre><code>class IA { public: virtual void a() = 0; }; class A: virtual public IA { public: virtual void a() { } }; class IB: virtual public IA { public: virtual void b() = 0; }; class B: virtual public IB, public A { public: virtual void b() { } }; </code></pre>
c++
[6]
3,373,365
3,373,366
Is it possible to tell if all checkboxes are checked on a dynamic form?
<p>I have a form which can populate from 1-100 elements based on a user's internal preferences. On my subsequent php page, i want to divert action if ALL checkboxes from the previous page are checked. I know checkboxes can come through as an array but I am unable to develop a solution for both a single array (one name, several boxes, e.g. types of fruit) or multiple arrays (several fields with different types, e.g. <code>fruit[], cars[], magazines[]</code>)</p>
php
[2]
2,311,398
2,311,399
Array PopFront Method C++
<p>Trying not to lose it here. As you can see below I have assigned intFrontPtr to point to the first cell in the array. And intBackPtr to point to the last cell in the array...:</p> <pre><code>bool quack::popFront(int&amp; nPopFront) { nPopFront = items[top+1].n; if ( count &gt;= maxSize ) return false; else { items[0].n = nPopFront; intFrontPtr = &amp;items[0].n; intBackPtr = &amp;items[count-1].n; } for (int temp; intFrontPtr &lt; intBackPtr ;) { ++intFrontPtr; temp = *intFrontPtr; *intFrontPtr = temp; } return true; } </code></pre> <p>In the else statement I'm simply reassigning to ensure that my ptrs are where I want them. For some reason I'm popping off the back instead of off the front.</p> <p>Anyone care to explain?</p>
c++
[6]
5,717,874
5,717,875
Intercept all current and future links
<p>Just wondering if there is a way with jquery to intercept a link when clicked. The problem is that some of the links on my page are not loaded when the page is first loaded. I have a vague recollection of hearing that jquery has a way of intercepting all current and future links. Here is the code I have. It works on all links there were there at the start but the links that were loaded onto the page later are not getting intercepted by this function</p> <pre><code>$('a').trackClick({ areaClick: function(element) { return getAreaClicked(element); }, href: function(element) { return getHrefFromElement(element); }, text: function(element) { return getTextFromElement(element); }, exceptions: function(element) { return isException(element); } }); </code></pre>
jquery
[5]
3,399,036
3,399,037
What is the difference between decodeURIComponent and decodeURI?
<p>What is the difference between the JavaScript functions 'decodeURIComponent' and 'decodeURI'?</p>
javascript
[3]
2,139,242
2,139,243
Retrieving data from simplexml_load_file
<p>Working with the simplexml_load_file() function, I get a side effect. To understand what I mean, see this code: </p> <pre><code>$result = simplexml_load_file($xml_link); $arr = array(); foreach ($result-&gt;element as $elem) { $arr[] = $elem-&gt;number[0]; } print_r($arr); </code></pre> <p>Output:</p> <pre><code>Array ( [0] =&gt; SimpleXMLElement Object ( [0] =&gt; 330411879136 ) [1] =&gt; SimpleXMLElement Object ( [0] =&gt; 370346266228 ) [2] =&gt; SimpleXMLElement Object ( [0] =&gt; 370346266223 ) ) </code></pre> <p>How would I store data into the array so that output would look like so:</p> <pre><code> Array ( [0] =&gt; 330411879136 [1] =&gt; 370346266228 [2] =&gt; 370346266223 ) </code></pre>
php
[2]
2,608,088
2,608,089
Android - is there a way to edit color in a part of a string that is displayed?
<p>I have a part of the code that calls a toString on an object and the toString basically spits out the string that will be shown on the screen.</p> <p>I would like to change the color of one part of the string. </p> <p>I just tried something like this:</p> <pre><code> String coloredString = solutionTopicName + " (" + commentCount + ")"; Spannable sb = new SpannableString( coloredString ); ForegroundColorSpan fcs = new ForegroundColorSpan(Color.rgb(140, 145, 160)); sb.setSpan(new ForegroundColorSpan(Color.BLUE), solutionTopicName.length(), solutionTopicName.length()+3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return sb.toString(); </code></pre> <p>But I am still seeing the same colors appear without change. </p> <p>Thanks!</p>
android
[4]
4,096,282
4,096,283
Defined error message in the PHP
<p>How do I "make" error messages in best practices? Right now I just have <code>$error = '';</code> and then just a lot of if(){}s that do <code>.= 'Message&lt;br&gt;'</code>, and then <code>if (!empty($error)) { echo $error; }</code>, which I assume is a terrible thing.</p>
php
[2]
4,669,132
4,669,133
Getting started with Android code samples - permissions error
<p>New to android. Running Eclipse on Ubuntu 9.10 with Android SDK plugin installed and working. Trying to get some code samples from <a href="http://developer.android.com/resources/samples/get.html" rel="nofollow">http://developer.android.com/resources/samples/get.html</a> , and following its procedure to load said samples in Eclipse yields:</p> <pre><code>Parent of resource: /home/user/android-sdk/platforms/android-4/samples/Notepad/.project is marked as read-only. </code></pre> <p>chmod is not recursive, so I entered ~/android-sdk/platforms and "chmod 777 *" ie. all folders in /platforms. Still doesnt work. Appears to be be a bug in Eclipse that wants to create the project in the SDK folder rather than under ~/workspace. </p>
android
[4]
3,536,127
3,536,128
Java JNI: How to create an array of byte arrays in native code?
<p>I'm looking to create an array of byte arrays in native code. I plan to use NewObjectArray() for the outer array, since Java arrays are objects. What should I specify as the class identifier for a Java byte array?</p>
java
[1]
4,859,192
4,859,193
Android Testing
<p>I have found 'Robolectric' framework to be efficient for testing in android. I am currently using 'netbeans' as my IDE for developing android app.</p> <p>So how can I setup Robolectric in netbeans?</p> <p>Thanks</p>
android
[4]
633,266
633,267
Remove Specific Elements from 2D Array
<pre><code>Array ( [0] =&gt; Array ( [0] =&gt; a [1] =&gt; b [2] =&gt; c [3] =&gt; c [4] =&gt; d ) ) </code></pre> <p>I have 2D array as of <code>$arr[0][$i];</code></p> <p><code>$i</code> is the only part that increments, whereas <code>0</code> is fixed.</p> <p><strong>1. I need to remove element a and b via a search inside the array.</strong></p> <p><em>My attempt did not delete the elements:</em></p> <pre><code>$posts = array_diff($posts, array("a", "b")); </code></pre> <p><strong>2. I would like to eliminate all duplicated values and leave only one i.e. removing all c's except one c.</strong></p> <p>The final output would be:</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; c [1] =&gt; d ) ) </code></pre> <p>I'm trying to figure it out, however, your help will be very much appreciated.</p>
php
[2]
3,015,744
3,015,745
How to parse a text file with c#?
<p>How do I parse a Textfile like:</p> <blockquote> <p>{:block1:} </p> <p>%param1%= value1</p> <p>%param2% = value2</p> <p>%paramn% =valuen</p> <p>{:block2:}</p> <p>1st html - sourcecode Just copy 1:1</p> <p>{:block3:} </p> <p>2nd html - sourcecode Just copy 1:1 ...{:block4:} </p> <p>3rd html - sourcecode Just copy 1:1</p> </blockquote> <p>I would like to convert data to a XmlDocument. Blocks are identified by {::} and params are identified by %%=</p> <p>Thanx a lot.</p> <p>What I'm looking for is more an idea but complete code. I have found many examples reading ini-files using RegEx and a TextReader to get some lines. The problem is: It's possible, that more than one {:block:} is within a line. There are so many whitespaces, linebreaks... </p>
c#
[0]
5,569,415
5,569,416
test object not retaining the value after being passed by the constructor in google test
<p>I am using google test/mock framework for unit testing. I call the constructor of the base class I am testing in my SetUp function. I set certain private members of the class using the object generated in SetUp to modify my test's behavior. When my test function invokes the base function that I am testing, the address of the private member variables change and therefore the tests seg fault. I need to figure out the cause of such behavior since it doesn't happen with another similar file that I am testing.</p> <pre><code>//Class to test //base code //header file class To_Test { friend My_test_class; private: TestStruct* sptr; //pointer to a structure, set by some random function elsewhere public: To_Test(); ~To_Test(); boolean Function_1(); } //cpp file To_Test::To_Test() { sptr = NULL; } boolean To_Test::Function_1() { boolean variable; variable = sptr-&gt;bool; if (variable) { do something return TRUE; } return FALSE; } //Test framework //test class header file #include "To_Test.h" class My_test_class : public :: testing :: Test { public: To_Test *ToTestObj; virtual void SetUp(); void Test_Function_1(); } //gtest.cpp file My_test_class::SetUp() { ToTestObj = New To_test; } My_test_class::Test_Function_1() { ToTestObject-&gt;sptr = (RandomStruct*) malloc (sizeof(RandomStruct)); sptr-&gt;bool = TRUE; ASSERT_TRUE(TRUE = ToTestObject-&gt;Function_1()); } </code></pre> <p>The address of ToTestObject in SetUp, in Test_Function_1 and Function_1 is the same. However, the address of sptr in SetUp and Test_Function_1 is different from that of Function_1. Therefore, when I step through Function_1 when test is executing, sptr has no memory as it points to NULL and the execution fails when it tries to access the memory at sptr->bool.</p> <p>I am not sure what is causing this issue. Any help is really appreciated!</p>
c++
[6]