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
2,682,824
2,682,825
JavaScript setSelectionRange() method and cursor position
<p>I have the following piece of JavaScript for dynamically inserting unicode characters - represented below by the txtToIns variable - into a body of text</p> <pre><code>elmt.value = elmt.value.substring(0, elmt.selectionStart) + txtToIns + " " + elmt.value.substring(elmt.selectionStart, elmt.selectionEnd) + elmt.value.substring(elmt.selectionEnd, elmt.value.length) + " "; elmt.focus(); elmt.value = elmt.value.trim(); </code></pre> <p>With the above the cursor is always at the end of the text. Is there any way I can place it directly after txtToIns? And no, txtToIns.focus() won't work</p>
javascript
[3]
3,921,923
3,921,924
JavaScript to start and stop timing
<p>I have some problems with JavaScript timings..Basically i want it to start timing when it goes out of focus and when it comes back to focus, the timing will stop and it will display.</p> <pre><code>var start,end,isTimerOn=0; window.addEventListener('blur', function() { //when user get out of the screen /*Start Time when user goes out of focus*/ start = new Date().getTime(); }); window.addEventListener('focus', function() { //when user focus on the screen if (isTimerOn==1) { end = new Date().getTime(); var time = end - start; //time will be in ms. eg: 1 sec will be 1000 /*Convert to seconds*/ var y=Math.round(time/1000); start=0; //reset isTimerOn=0; //reset alert('Execution time: ' + y + 'secs'); //this will print the time how long the user has been away } }); </code></pre> <p>Now the isTimerOn variable is a flag which will be set when:</p> <pre><code>function ProcessThisSearch(form) { //alert("OI!"); //test is js is working. var test=form.search.value; //alert(test); //test if value can be retrieved if (test) { isTimerOn=1; window.open('http://www.'+test+'.com'); } } </code></pre> <p>This function ProcessThisSearch(form) will be invoked in the following HTML form:</p> <pre><code>&lt;form align=right action="mainheader.jsp" method="POST"&gt;&lt;input type="text" name="search"&gt;&lt;input type="submit" value="Open Website" onClick="ProcessThisSearch(this.form)"&gt;&lt;/form&gt; </code></pre> <p>I believe the problem is with the isTimerOn variable. Because I have tested the two event listener and it is working. Only when I add isTimerOn variable, it doesn't seem to work.</p>
javascript
[3]
2,112,604
2,112,605
Why is __init__.py not being called?
<p>I'm using Python 2.7 and have the following files:</p> <pre><code>./__init__.py ./aoeu.py </code></pre> <p><code>__init__.py</code> has the following contents:</p> <pre><code>aoeu aoeuaoeu aoeuaoeuaoeu </code></pre> <p>so I would expect running aoeu.py to error when Python tries to load <code>__init__.py</code>, but it doesn't. The behavior is the same whether PYTHONPATH is set to '.' or unset.</p> <p>What's going on?</p>
python
[7]
4,070,292
4,070,293
java: how to obfuscate the account information in my application?
<p>There is a function that can keep the users' account information in my application.I wanna keep it safely.How can I obfuscate the information ?And how to decode it rightly when I wanna use? Thanks a lot!</p>
java
[1]
3,751,698
3,751,699
Does a virtual function override a non-virtual function of the same name in a base class?
<p>Is the following standard conforming? Can you cite the section?</p> <pre><code>struct A { virtual void func() = 0; }; struct B { void func(){} }; struct C : public A, public B { virtual void func(){ B::func(); } }; </code></pre> <p>I'm getting a strange compiler warning in VS2010 in equivalent but more complicated code pointing to <code>func</code>'s declaration in the derived-most class: <code>warning C4505: unreferenced local function has been removed</code>. I have no idea why the compiler thinks a virtual function declared in a class is a local; however I can't repro that warning in a simpler example.</p> <h1>Edit:</h1> <p>I figured out a small repro case for the warning. I think I was going down the wrong path assuming it was related to function hiding. Here's the repro case:</p> <pre><code>template&lt;typename T&gt; struct C { int GetType() const; virtual int func() const; // {return 4;} // Doing this inline removes the warning &lt;-------------- }; template&lt;typename T&gt; int C&lt;T&gt;::GetType() const { return 0; } template&lt;&gt; int C&lt;int&gt;::GetType() const { return 12; } template&lt;typename T&gt; int C&lt;T&gt;::func() const { return 3; } // Adding the following removes the warning &lt;-------------------- // template&lt;&gt; // int C&lt;int&gt;::func() const // { // return 4; // } </code></pre> <p>I'm fairly sure this is just a VS2010 bug.</p>
c++
[6]
1,790,516
1,790,517
Change background color of python shell
<p>Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions?</p>
python
[7]
834,554
834,555
jQuery: How to show an element and use the highlight effect at the same time?
<p>I have two elements on a page.</p> <pre><code>&lt;div id="a"&gt;content&lt;/div&gt; &lt;div id="b" style="display:none"&gt;different content&lt;/div&gt; </code></pre> <p>When I click the currently displayed <code>div</code>, I want to hide it and show the other one. This is easy to do:</p> <pre><code>$('#a').hide(); $('#b').show(); </code></pre> <p>But now I want to take it a step further and highlight the element as it is being displayed. I think that it will involve <code>effect("highlight")</code>, but I can't get it to work. How do I achieve this?</p>
jquery
[5]
5,832,625
5,832,626
Duplicating Meta Description when using get_meta_tags function, only want the description
<p>When echo'ed out instead of just removing all of the other meta tags it seems to be duplicating the description, for example:</p> <p>BBC has 13 different meta tags, when I echo out just the description in my script it is duplicating it 13 times.</p> <pre><code>&lt;?php //make the array $TAarray = explode("\n", strip_tags($_POST['TAData'])); foreach ($TAarray as $key =&gt; &amp;$line) { $line = trim($line); // get the meta data for each url $tags = get_meta_tags($line); echo '&lt;tr&gt;'; foreach ($tags as $meta) { echo (isset($tags['description']))?"&lt;br&gt;&lt;br /&gt;\nDescription($line):&lt;br&gt;\n".$tags['description']:"&lt;br&gt;\nDescription($line):&lt;br&gt;\nNo Meta Description."; /*echo '&lt;td&gt;' . $meta . '&lt;/td&gt;';*/ } echo '&lt;/tr&gt;'; } ?&gt; </code></pre> <p>Here is the URL incase anyone wanted to see it working: <a href="http://php-playground.co.cc/testdir/metaex.php" rel="nofollow">http://php-playground.co.cc/testdir/metaex.php</a></p> <p>PS</p> <p>I know the checkboxes are not working they are only there for the layout</p>
php
[2]
1,250,682
1,250,683
strange string error
<p><strong>program:</strong></p> <pre><code> CCompussGradientOperator dlg; string p = "preqitt"; string k = "Kirnch"; string r3 = "Robison"; f(dlg.DoModal() == IDOK) { CDib dib = m_Dib; BOOL ret = FALSE; if(dlg.m_Combo_Operators == p ) { switch(dlg.m_nFunction) { case 0: ret ; } } } </code></pre> <p><strong>error</strong>:</p> <p>Error 18 error C2065: 'string' : undeclared identifier d:\2nd\imagetool\imagetooldoc.cpp 870 1 ImageTool</p> <p>string is a data type then why it does make me error.. its strange for me... any one can help me ..thanks </p>
c++
[6]
5,318,810
5,318,811
PHP filter bad words
<p>I have a filter bad words codes below I want to replace this ARRAY with the .txt file so that I can put all the bad words into the txt file or is there any way to use MYSQL database to store the badwords and then call from there ? </p> <pre><code>FUNCTION BadWordFilter(&amp;$text, $replace){ $bads = ARRAY ( ARRAY("butt","b***"), ARRAY("poop","p***"), ARRAY("crap","c***") ); IF($replace==1) { //we are replacing $remember = $text; FOR($i=0;$i&lt;sizeof($bads);$i++) { //go through each bad word $text = EREGI_REPLACE($bads[$i][0],$bads[$i][1],$text); //replace it } IF($remember!=$text) RETURN 1; //if there are any changes, return 1 } ELSE { //we are just checking FOR($i=0;$i&lt;sizeof($bads);$i++) { //go through each bad word IF(EREGI($bads[$i][0],$text)) RETURN 1; //if we find any, return 1 } } } $qtitle = BadWordFilter($wordsToFilter,1); </code></pre>
php
[2]
3,522,453
3,522,454
Android : Can i call my onresume() inside onpause().?
<p>I want that just before my application goes in background the user should get a dialogue box asking if i want to exit this application. And if user selects no then i want that he should be resumed to my application again instead of launching another application. So,is it possible in android? One solution can be like this that i call <strong>onresume()</strong> inside <strong>onpause()</strong> or <strong>onstop()</strong>.But can this be done. Please help me out.</p> <hr> <p>My code is like this:-</p> <pre><code>public void onPause() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("Do you want to quit"); builder.setCancelable(false); builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MytestprojectActivity.this.finish(); } }); builder.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show(); super.onPause(); } </code></pre> <p>first i basically want to see if it runs on calling of onpause() or not. so, what i got is that it pauses my activity, goes to another activity and when my activity restarts then it shows me the dialogue box. m i missing something.?</p>
android
[4]
3,632,162
3,632,163
Getting local declaration hides instance variable warning message for multiple statements
<p>I can't get this code to work.</p> <p>Declared playpauseButton just above the given below statements</p> <pre><code>UIButton *playpauseButton = [UIButton buttonWithType:UIButtonTypeCustom]; </code></pre> <p>Getting local declaration of <code>playpauseButton</code> hides instance variable warning message for following statements</p> <pre><code>playpauseButton addTarget:self action:@selector(playpauseAction:) forControlEvents:UIControlEventTouchUpInside]; playpauseButton.frame = CGRectMake(0, 0, 30, 30); [playpauseButton setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateNormal]; [playpauseButton setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected]; UIBarButtonItem *play = [[UIBarButtonItem alloc] initWithCustomView:playpauseButton]; </code></pre> <p>After i defined <code>playpauseAction method</code> </p> <pre><code>-(void)playpauseAction:(id)sender { if( playpauseButton.state == UIControlStateNormal ){ [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected]; [audioPlayer play]; self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0 target:self selector:@selector(displayviewsAction:) userInfo:nil repeats:NO]; } else if (playpauseButton.state == UIControlStateSelected) { [sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateNormal]; [audioPlayer pause]; [self pauseTimer]; } else if (playpauseButton.state == UIControlStateNormal) { [sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected]; [audioPlayer play]; [self resumeTimer];}} </code></pre> <p>Some help please.</p> <p>Thanks.</p>
iphone
[8]
641,348
641,349
Python format throws KeyError
<p>The following code snippet:</p> <pre><code>template = "\ function routes(app, model){\ app.get('/preNew{className}', function(req, res){\ res.render('{className}'.ejs, {});\ });\ });".format(className=className) </code></pre> <p>throws a KeyError:</p> <pre><code>Traceback (most recent call last): File "createController.py", line 31, in &lt;module&gt; });".format(className=className) KeyError: ' app' </code></pre> <p>Does someone know why?</p>
python
[7]
297,012
297,013
Create static instances of a class inside said class in Python
<p>Apologies if I've got the terminology wrong here—I can't think what this particular idiom would be called.</p> <p>I've been trying to create a Python 3 class that statically declares instances of itself inside itself—sort of like an enum would work. Here's a simplified version of the code I wrote:</p> <pre><code>class Test: A = Test("A") B = Test("B") def __init__(self, value): self.value = value def __str__(self): return "Test: " + self.value print(str(Test.A)) print(str(Test.B)) </code></pre> <p>Writing this, I got an exception on line 2 (<code>A = Test("A")</code>). I assume line 3 would also error if it had made it that far. Using <code>__class__</code> instead of <code>Test</code> gives the same error.</p> <pre><code> File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "&lt;stdin&gt;", line 2, in Test NameError: name 'Test' is not defined </code></pre> <p>Is there any way to refer to the current class in a static context in Python? I could declare these particular variables outside the class or in a separate class, but for clarity's sake, I'd rather not if I can help it.</p> <p>To better demonstrate what I'm trying to do, here's the same example in Java:</p> <pre><code>public class Test { private static final Test A = new Test("A"); private static final Test B = new Test("B"); private final String value; public Test(String value) { this.value = value; } public String toString() { return "Test: " + value; } public static void main(String[] args) { System.out.println(A); System.out.println(B); } } </code></pre> <p>This works as you would expect: it prints:</p> <pre><code>Test: A Test: B </code></pre> <p>How can I do the same thing in Python?</p>
python
[7]
4,354,317
4,354,318
Variable not found. Referencing objects from another class
<p>Background:</p> <p>I'm creating a basic download centre on a concurrent server.</p> <p>I create file objects in the <code>Server class</code> under a main method</p> <pre><code>File[] files = { new File("1. Program", "myProgram.jar"), new File("2. Image", "myPicture.jpg"), new File("3. Book", "myBook.txt")}; </code></pre> <p>This references to the <code>File class</code> where I create constructors and getters.</p> <pre><code>class File { private String option; private String fileName; public File(String option, String fileName) { this.option = option; this.fileName= fileName; } public String getOption() { return option; } public String getFileName() { return fileName; } public void getFileOptions(File[] files) { for (File f : files) { System.out.printf("The option is %s\n", f.getOption()); } } } </code></pre> <p>I am attempting to call the <code>getFileOptions</code> method from my <code>ServerState class</code>. </p> <pre><code>theOutput= File.getFileOptions(files); </code></pre> <p>The output is a string that is returned to a client.</p> <p>My IDE says that <code>(files)</code> cannot be found. Any ideas where I'm going wrong? Cam I not return results to a class where the object wasn't initially created? </p>
java
[1]
4,795,712
4,795,713
Play a sound only using phone audio
<p>I'm developing a sort of alarm clock application and I need to play my sound specifically through the phone audio and <em>not through Bluetooth</em>. (I learned this the hard way as I missed all three of my set alarms this morning because the alarms played through my Bluetooth headset)</p> <p>How can I play a sound that only plays through phone audio and not Bluetooth?</p>
android
[4]
4,072,916
4,072,917
how to convert array into variables in php
<p>I want to create a function that takes the name of a table and an array with the column name and value to use it to generate an INSERT in MySQL</p> <p>Check my code.</p> <p>Unfortunately this technique does not work as it always generates a comma after each value and this generates an error when entering data. Anyone know a better way to create this function?</p> <pre><code>&lt;?php $arrayDados = array('nome' =&gt; 'Renato', 'idade' =&gt; 24, 'peso' =&gt; 36, 'mae' =&gt; 'neide'); $colunas = ""; $valores = ""; $tabela = 'cadastro'; foreach ($arrayDados as $key =&gt; $value) { $colunas .= $key . ', '; $valores .= $value.', '; } $sql = "INSERT INTO $tabela ($colunas) VALUES ($valores)"; echo $sql;` </code></pre>
php
[2]
4,382,757
4,382,758
C++ char comparison not working
<p>It is probably better to say I am doing something wrong rather then say the comparison isn't working. But, I have been going over this code for some time now.</p> <p>I have a recursive function. Most of it is working well, so I will only put the part that isn't working:</p> <pre><code>//In main string C[] = {"S=&gt;bS", "S=&gt;aaT", "T=&gt;aT", "T=&gt;bU", "U=&gt;Ua", "U=&gt;aa"}; CFG CFG1(C); ... string *code; char startNT; //The CFG constructor CFG::CFG(string C[]) { code = C; startNT = code[0][0]; } ... //Inside of processData recursive function for(unsigned int i = 0; i &lt; code-&gt;size(); i++) { if(code[i][0] == startNT) { string newStr = code[i].substr(code[i].find("&gt;")+1); string old = wkString; //This is the recursive call if(processData(inString, wkString.replace(wkString.find_first_of(startNT), wkString.find_first_of(startNT)+1, newStr))) { return true; } cout &lt;&lt; wkString &lt;&lt; endl; wkString = old; } } </code></pre> <p>The comparison that isn't working is code[i][0] == startNT . Well... I should say, isn't working 100% of the time. It works great until half way through the recursive function, code[i][0] becomes 'S' and startNT becomes 'T' (after already proving that it can compare 'S' and 'T' properly somewhere during the call), and it still evaluates to true, which causes the wkString.replace() to break since it can't find the 'T'. </p> <p>It has been awhile since I have used C++, so I am probably making a stupid mistake. Thanks for any help.</p>
c++
[6]
5,009,540
5,009,541
Javascript Inheritance and this
<p>Lets say I have a namespace called ns and ns has to functions on it:</p> <pre><code>ns = {}; ns.Foo = function(message, fn){ this.message = message; fn.call(this); }; ns.bar = function() { alert('Hello, world!'); }; </code></pre> <p>And I call it like this:</p> <pre><code>var foo = new Foo('My Message', function() { bar(); }); </code></pre> <p>I get an error saying bar() is undefined. But if I call it this way:</p> <pre><code>var foo = new Foo('My Message', function() { this.bar(); }); </code></pre> <p>It works. Is there a way to structure my JavaScript so I can just call bar() without the this?</p> <p>Thanks!</p>
javascript
[3]
543,279
543,280
Call another javascript function when a functions is not respondong
<p>I have two javascript functions </p> <pre><code>searchButtonClicked() hidemap() </code></pre> <p>The <code>searchButtonClicked()</code> will be called in <code>body onload</code>.</p> <p>The <code>searchButtonClicked()</code> sometimes not respond. So I want to let it try to execute for 5 seconds and if it dosent execute I want to call <code>hidemap()</code>.</p> <p>Please help. Thanks in advance. Udy</p> <p>here is the function</p> <pre><code>function searchButtonClicked() { if (inlocatorHubMode) { locatorHubSearch(); } else { search(); } } </code></pre>
javascript
[3]
4,540,777
4,540,778
Accesssing the users music library from within an ap
<p>What is the best way to allow the user to access their music library and play their own music within an app?</p> <p>Does it call the library and when the user is done it dismissing the window and returns to the running app or how can this be achieved?</p>
iphone
[8]
3,719,669
3,719,670
Cant find the android keytool
<p>I am trying to follow the Android mapping tutorial and got to this part where I had to get an API key <a href="http://code.google.com/android/add-ons/google-apis/mapkey.html#getdebugfingerprint">http://code.google.com/android/add-ons/google-apis/mapkey.html#getdebugfingerprint</a></p> <p>I have found my debug.keystore but there does not appear to be a keytool application in the directory:</p> <p><strong>C:\Documents and Settings\tward\.android>ls</strong> adb_usb.ini avd debug.keystore repositories.cfg androidtool.cfg ddms.cfg default.keyset</p> <p>There is also no keytool in this directory:</p> <p><strong>C:\Android\android-sdk-windows\tools>ls</strong> AdbWinApi.dll apkbuilder.bat etc1tool.exe mksdcard.exe AdbWinUsbApi.dll ddms.bat fastboot.exe source.properties Jet dmtracedump.exe hierarchyviewer.bat sqlite3.exe NOTICE.txt draw9patch.bat hprof-conv.exe traceview.bat adb.exe emulator.exe layoutopt.bat zipalign.exe android.bat emulator_NOTICE.txt lib</p> <p>I am using eclipse as my editor and believe that I have downloaded all the latest SDK What am I doing wrong?</p>
android
[4]
677,803
677,804
How do I declare a multi-dimensional array in C++?
<p>The following is an example of a multi-dimensional array declaration in C#:</p> <pre><code>var Number = new double[2, 3, 5] { { { 12.44, 525.38, -6.28, 2448.32, 632.04 }, {-378.05, 48.14, 634.18, 762.48, 83.02 }, { 64.92, -7.44, 86.74, -534.60, 386.73 } }, { { 48.02, 120.44, 38.62, 526.82, 1704.62 }, { 56.85, 105.48, 363.31, 172.62, 128.48 }, { 906.68, 47.12, -166.07, 4444.26, 408.62 } }, }; </code></pre> <p>I would like to do the same in C++, but do not know how and have not read <a href="http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list">my C++ book</a>.</p> <p>How can I accomplish this?</p>
c++
[6]
4,773,578
4,773,579
Intercept an HTTP request at browser end to alter some html content
<p>I would like to do as follows. What would be the best way? A general answer will also be fine.</p> <p>I would like to intercept an HTTP request at the client end to alter some html content. For example, I go to CNN.com and rather than an article that's displaying "Two LA Dogs marry", it should say "Ridiculous title blocked".</p> <p>It should be smooth that even a secure certificate won't be disturbed.</p> <p>I am using C#.</p> <p>Thanks!</p> <p>UPDATE: Thank you all for your answers!</p>
c#
[0]
3,512,452
3,512,453
Need a way to select a dropdown's options 1 by 1 to parse data
<p>I have a system that basically copies data from other databases to my own SQL Server so I can format the data to suit my needs. That data is used to populate dropdowns to end up with a variable can return the rows I want to show to the user.</p> <p>All of the databases I've encountered up to now had a logical way the data of the dropdowns was stored. But now I have one that is different and not logical.</p> <p>What I want to do is use the existing website that provides a somewhat logical dropdown itself to get the data I need. That dropdown fills a multiple selection dropdown after a selection. </p> <p>I want to select each option in the first dropdown and then read the data it puts in the second multiple selection dropdown. Is there a way to do this?</p>
c#
[0]
5,951,744
5,951,745
substring function to separate two strings using javascript
<p>I have strings like X,Y. I want to separate X from Y using javascript. Please describe how to as I am new at javascript</p>
javascript
[3]
5,270,810
5,270,811
What is the correct way to identify an Exception?
<p>If exceptions are always fatal, making use of them in Python is easy</p> <pre><code># moduleB.py import moduleC </code></pre> <p>But evaluating an exception requires more than just it's type, we often need to determine where an exception came from</p> <pre><code># moduleA.py try: import moduleB except ImportError as e: print e if str(e) == "No module named moduleB": pass else: raise </code></pre> <p>In some projects this pattern results in a lot of code that is not easy to read. Is this the best way to ensure that I'm catching a local exception? I would like to be able write</p> <pre><code>import moduleB else pass </code></pre>
python
[7]
32,567
32,568
Which is a good opensource user management system?
<p>I'm new to php/mySQL and am trying to create a website which will allow users to register. In future, there will be a paid content area where content will be shown based on the payment status. </p> <p>Is there a good opensource lightweight framework which takes care of the user management part? (Register, edit user info, retrieve lost password etc). I'm a flash platform developer and not aware of how to take care of stuff like session hijacking, XSS etc. </p> <p>Should I go ahead and learn to do all this on my own, without using any framework? I thought of using Wordpress' user management system, but not sure how easy that would be. Any suggestion would be great.</p>
php
[2]
4,167,834
4,167,835
Android: I am unable to have ViewPager WRAP_CONTENT
<p>I have setup a simple ViewPager that has an ImageView with a height of 200dp on each page.</p> <p>Here is my pager:</p> <pre><code> pager = new ViewPager(this); pager.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); pager.setBackgroundColor(Color.WHITE); pager.setOnPageChangeListener(listener); layout.addView(pager); </code></pre> <p>Despite the height set as wrap_content, the pager always fills the screen even though the imageview is only 200dp. I tried to replace the height of the pager with "200" but that gives me different results with multiple resolutions. I am unable to add "dp" to that value. How do I add 200dp to the pager's layout?</p>
android
[4]
3,734,557
3,734,558
Storage of values?
<p>I have a database with 4 tables. Each table has 1 column. 3 of the tables will typically hold only around 8-12 values, the other maybe 100+. The values are basic, color, city, etc. The user clicks a button, up pops a list with values they can select, delete or add.</p> <p>It seems like a lot to have a table for ~8 values. I was wondering if there was a better way to store this data given that values need to be able to be added, deleted and the number will be dynamic.</p>
android
[4]
3,183,558
3,183,559
Retrieving images using Jquery gallery plugin dynamically
<p>How do I dynamically retreieve images using any jquery gallery/slideshow plugins?</p> <p>I have images that I can retrieve like this..</p> <p><a href="http://localhost/images.aspx?id=1" rel="nofollow">http://localhost/images.aspx?id=1</a></p> <p><a href="http://localhost/images.aspx?id=2" rel="nofollow">http://localhost/images.aspx?id=2</a></p> <p>I have already made a REST based service to return an array of those links when I pass the fromdate and todate.</p> <p>After using Jquery to retrieve those links,I want to load the images.</p> <p>The samples in most of the demos only talk about statically assigning images.</p> <p>Please show me a sample on loading the images dynamically.</p> <p>Thanks</p>
jquery
[5]
261,412
261,413
how to get done button event in MPMOviewplayercontroller in iphone?
<p>I have used MPMoviePlayerController for playing video file.I want to get done button event but i dont know how to get can you help me for this questions</p>
iphone
[8]
2,479,493
2,479,494
Android Actvities problem for getting result
<p>I have two activities A &amp; b.</p> <p>in A i have one button which takes me to the activity B. in Activity B i have one edit text. when user enter some values in edittext i m getting the value in some variable. and i want to pass this value back to activity A. i applied the Bundle concept bt it is force closing my app.</p> <p>pls anybody can help me?</p> <p>thanks in advance.</p>
android
[4]
5,235,815
5,235,816
How can I react on an UIApplicationDidReceiveMemoryWarningNotification?
<p>When memory becomes low, the System would send that UIApplicationDidReceiveMemoryWarningNotification notification. But I don't get it... that isn't a Method I must implement in my App Delegate, right? How do I get this notification?</p>
iphone
[8]
3,806,606
3,806,607
How to roll a moderation area
<p>I'd love to create a moderation area for my own social network. The only thing I need is a PHP-script so the moderators can delete unwanted posts by user.</p> <p>Like this:</p> <pre><code>$u = POST['um']; FROM pogs.txt DELETE $u </code></pre> <p>How do you do that in PHP?</p>
php
[2]
3,218,481
3,218,482
How create Startup Tips dialouge windows in C#
<p>As many software when open those shows tip of day... How i can create that in C#, desktop application.</p>
c#
[0]
5,221,952
5,221,953
create a pathName
<p>I want to get the image of a path, but if I use this:</p> <pre><code>String pathname="/path/img.png"; </code></pre> <p>If I use the following method:</p> <pre><code>Bitmap icon = BitmapFactory.decodeFile (pathname); </code></pre> <p>The variable icon returns me null.</p> <p>I don't know to create the pathname.</p> <p>Thanks. Regards</p>
android
[4]
5,411,379
5,411,380
how to submit a form and show the result in that page
<p>im using a form in php to submit some information into my database </p> <p>so i used two function to do this </p> <p>but how to show the result in th same page that has the form </p>
php
[2]
3,310,693
3,310,694
Form names with arrays
<p>I would like to convert: <code>"controllers[page[title_new]]"</code> to <code>"controllers[page][title_new]"</code>. So I can fill a form with input fields like:</p> <pre><code>&lt;?php $name = 'controllers[page[title_new]]' ?&gt; &lt;input type='text' name='&lt;?= $name; ?&gt;'&gt; </code></pre> <p>After you submit the form you get $_POST =</p> <pre><code>array(controllers =&gt; array(page =&gt; array(title_new = ''))); </code></pre> <p>Now to display this I would like:</p> <pre><code>&lt;input type='text' name='&lt;?= $name; ?&gt;' value='&lt;?= $_POST[CONVERT($name)]; ?&gt;'&gt; </code></pre> <p>So is there such a <code>CONVERT</code> built in php? Or how could I do it the best way?</p> <p>*Please note I left out all validation/escaping/htmlentities etc. out for readability</p>
php
[2]
932,083
932,084
Communication between two android devices
<p>Is it possible for two android devices to communicate without using carrier services</p>
android
[4]
3,192,569
3,192,570
problem with require_once
<p>I have a file structure like this</p> <pre><code>config config.php library data.php folder file1.php libs.inc.php test1.php </code></pre> <p>In config file iam including require_once('libs.inc.php'); and require_once('./library/data.php'); In file1.php i am including config file using 'require_once('../config/config.php');' But it showing error in require_once('libs.inc.php'); and require_once('./library/data.php'); How i can solve this problem Thanks in advance..</p>
php
[2]
3,041,778
3,041,779
jquery make div appear when clicked href clicked on
<pre><code>#tabs-1 { display: none; } #tabs-2 { display: none; } #tabs-3 { display: none; } &lt;script type="text/javascript"&gt; $(document).ready(function () { $(this).click(function () { var a = $(this).find("a").attr("href"); $(a).show(); }); }); &lt;/script&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div class="tabs"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#tabs-1"&gt;Nunc tincidunt&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#tabs-2"&gt;Proin dolor&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div id="tabs-1"&gt; &lt;h2&gt;Content heading 1&lt;/h2&gt; &lt;p&gt;Proin elit arcu, rutrum commodo, vehicula tempus, commodo a, risus. Curabitur nec arcu. Doin. Sed ut dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique tempus lectus.&lt;/p&gt; &lt;/div&gt; &lt;div id="tabs-2"&gt; &lt;h2&gt;Content heading 2&lt;/h2&gt; &lt;p&gt;Morbi tfhgdfahsdh&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>I'm trying to make a simple jquery script that makes these divs appear when i click on the ahref in the ordered list. When i run this code it always displays the first element in the ordered list. I want to display the element that is linked in the hyperlink. </p>
jquery
[5]
3,135,523
3,135,524
Store localization texts in database or resource files?
<p>Currently in my Asp.Net website I store localization texts in a table in the database. The table has three columns:</p> <pre><code>TextCode nvarchar(100), CultureId int, TextString nvarchar(MAX) </code></pre> <p>So every time when I need to get a localized text for a specific culture I just do a simple query.</p> <p>The main advantage of this method is simple and also I can update the texts while my web app is running.</p> <p>The obvious drawback is performance. I use resource files for localization in other desktop applications. The reason I chose database is I am under an impression that updating the resource file in asp.net will cause the web app to reload and thus I need to take the site offline when I update the resource file. Is assumption true? What's the "common" approach to store localized texts in Asp.Net?</p> <p>Thanks </p>
asp.net
[9]
2,662,893
2,662,894
Preventing a Destructor from Running in C++
<p>I would like to ensure that an object's destructor does <em>not</em> run. Is there any way to do this other than putting the object on the heap and not calling delete?</p>
c++
[6]
450,722
450,723
Asynctask is just pulling my listview and its making list item count as1
<p>I am using pulltorefresh listview in my application.when I use asynctask to get the data,somehow my listview itemcount is increased to 1,instead of 0.</p> <p>Here is my code for pulltorefresh</p> <pre><code> listView.setOnRefreshListener(new OnRefreshListener() { // @Override public void onRefresh() { // Your code to refresh the list contents goes here listView.setAdapter(null); scroll=true; pic.clear(); id.clear(); name.clear(); msg.clear(); img.clear(); profimg.clear(); objid.clear(); comment.clear(); weburl.clear(); adapter.clear(); likes.clear(); like_or_unlike.clear(); previousTotal = 0; // listView.removeFooterView(footerView); // listView.setAdapter(null); // scroll=true; // notifyDataSetChanged(); // urlval=0; j=0; loading = true; webserv="https://graph.facebook.com/me/home?access_token="+accesstoken; doInBack dob=new doInBack(); dob.execute(); // doback(webserv); Log.e("hi","doback called"); } }); </code></pre> <p>I really cant understand why asynTask class is just pushing my list and my listitem count is temporarily becoming 1 for short time.I really cant understand how to control this problem.</p> <p>Thanks in advance</p>
android
[4]
4,160,701
4,160,702
PHP = append a 0 to the end of a string
<p>I have this function which takes the average user rating given to an item and converts it to a relevant class:</p> <pre><code>function get_user_rating_class($urate_ave){ if($urate_ave==='0.0'){ $user_rating_class='unrated_u'; }else{ $round_to = 0.5; $rounded = round($urate_ave / $round_to) * $round_to; $removedec = str_replace('.','',$rounded); if(strlen($removedec)&lt;2){$removedec.'0';} $user_rating_class='rating_user_'+$removedec; } return $user_rating_class; } </code></pre> <p>No when I put a value, say 3.0 into the function it should come out as rating_user_30 but instead it is coming out as rating_user_3, so there must be something wrong with this line:</p> <p><code>if(strlen($removedec)&lt;2){$removedec.'0';}</code></p> <p>I thought it might be because It was treating the value $removedec as a number rather than a string so I tried adding this line just before it, but no change:</p> <pre><code>$removedec = strval($removedec); </code></pre> <p>Could someone tell me what I am doing wrong here.</p>
php
[2]
5,430,145
5,430,146
C# data structure to handle a file
<p>I have a file which has data in the following format</p> <pre><code>A B ----- 40 3 50 2 60 1 </code></pre> <p>I have to read the file and store it in a data structure that should help me manipulating the data.</p> <p>If it is C I would go with linked list. What should I possibly use for C#?</p>
c#
[0]
4,808,522
4,808,523
spin image clockwise/anticlockwise on touch
<p>Any idea about how to spin image clockwise/anticlockwise on touch.</p>
iphone
[8]
547,080
547,081
Error Placement for jquery validation plugin
<p>For some reason its not putting the error messages down in the div with a class of errorContainer and I'm not sure why when there is an error, however how it looks in the jsfiddle looks messed up compared to my actual page.</p> <pre><code>[http://jsfiddle.net/xtremer360/VtXdk/][1] </code></pre>
jquery
[5]
3,602,097
3,602,098
Overloaded constructor ambiguity
<p>I'm trying to use an overloaded constructor in Java that can accept either an <code>int[]</code> or a <code>String</code>. I'm getting a compile error, which seems to be indicating that in this constructor call would be ambiguous if the variable were a <code>null</code> string, or a <code>null</code> array.</p> <p>Is there an easy way around this?</p>
java
[1]
4,389,676
4,389,677
Android: how to draw borders when I click my view
<p>I have some views like:</p> <pre><code>private class MyViewCircle extends View { public MyViewCircle(Context context) { super(context); // TODO Auto-generated constructor stub } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.RED); canvas.drawCircle(50, 50, 50, paint); } } </code></pre> <p>And add to my LinearLayout</p> <pre><code>LinearLayout img01 = (LinearLayout) findViewById(R.id.img01); img01.addView(myViewCircle); </code></pre> <p>From my XML</p> <pre><code>&lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="#C07BD1" android:id="@+id/img01"/&gt; </code></pre> <p>If I click this view I want to generate borders (means user select this view). If user click again the border will disappear. How can I do that?</p>
android
[4]
5,941,591
5,941,592
Find if the element contains "body" add class
<pre><code>&lt;div class="results"&gt; &lt;div class"right"&gt; &lt;span class="cdh list"&gt;&lt;span&gt; &lt;div&gt; &lt;div class="left"&gt; &lt;ul&gt; &lt;li&gt;&lt;p&gt;&lt;a href="#"&gt;link&lt;/a&gt; some text&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;&lt;a href="#"&gt;link&lt;/a&gt; some text&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;&lt;a href="#"&gt;link&lt;/a&gt; some text&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;&lt;a href="#"&gt;link&lt;/a&gt; body&lt;/p&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="results"&gt; &lt;div class"right"&gt; &lt;span class="cdh list"&gt;&lt;span&gt; &lt;div&gt; &lt;div class="left"&gt; &lt;ul&gt; &lt;li&gt;&lt;p&gt;&lt;a href="#"&gt;link&lt;/a&gt; some text&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;&lt;a href="#"&gt;link&lt;/a&gt; some text&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;&lt;a href="#"&gt;link&lt;/a&gt; some text&lt;/p&gt;&lt;/li&gt; &lt;li&gt;&lt;p&gt;&lt;a href="#"&gt;link&lt;/a&gt; some text&lt;/p&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I want to find &lt; p > tags that contain "body" (and addClass to) the span tag. I want add class just to Upper span.</p>
jquery
[5]
307,818
307,819
Is tight looping bad?
<p>Is tight looping in a program bad?</p> <p>I have an application that has two threads for a game-physics simulator. An updateGame thread and a render thread. The render thread is throttled by causing the thread to sleep for some milliseconds (to achieve the frame-rate I want) and the updateGame thread (that updates my in game objects positions based off some physics equations) was previously throttled by a 10 millisecond sleep.</p> <p>However, I recently unthrottled the updateGame thread and the simulation of my objects movement seems to be significantly more realistic now that I have taken out that 10ms sleep. Is it bad to hot loop or have a tight loop?</p> <pre><code>private class UpdateTask implements Runnable { private long previousTime = System.currentTimeMillis(); private long currentTime = previousTime; private long elapsedTime; public void run() { while(true) { currentTime = System.currentTimeMillis(); elapsedTime = (currentTime - previousTime); // elapsed time in seconds updateGame(elapsedTime / 1000f); try { Thread.currentThread().sleep(1); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } previousTime = currentTime; } } } </code></pre> <p>In this example I'm just sleeping for 1ms (and from my understanding with how millisecond accuracy and the sleep function works this is probably more like 5-10ms. If I sleep for any more than this it starts to have impacts on the accuracy of my collision detection and physics model.</p> <p>Is it a bad practice to have tight loops or loops with 1ms sleeps in them? Is there something else I should do instead?</p>
java
[1]
696,729
696,730
How do I install Imagick for PHP?
<p>I am so confused right now, I have no idea what to do. I want to use Imagciks function but I have NO IDEA HOW. I'm really frustrated because I've never seen something that makes no sense to me. I can't even find a good explanation!</p>
php
[2]
64,732
64,733
how to remove part from the file name extension while downloading as excel
<p><a href="http://jsfiddle.net/n9XRx/8/" rel="nofollow">working code JSFIDDLE</a></p> <pre><code>$( "#clickExcel" ).click(function() { var dtltbl = $('#dtltbl').html(); window.open('data:application/vnd.ms-excel,' + encodeURIComponent($('#dtltbl').html())); }); </code></pre> <p>when i click on download as excel ... i get .part along with the extension like <code>GhCRExp0.xls.part</code> how to download the file without the name .part .Just with the filename <code>GhCRExp0.xls</code></p>
jquery
[5]
2,817,320
2,817,321
PHP Sessions & Forms
<p><strong>Edit</strong></p> <p><strong>How can I rewrite this PHP code for POST[ 'phrase' ] == session[ 'phrase' ] ?</strong> </p> <pre><code>psuedo-code //process_form.php PHP session_start() IF POST SUBMIT IF empty text1 &amp;&amp; empty text2 echo error msg, include HTML FORM ELSE IF empty radiobtn echo error msg, include HTML FORM ELSE IF isset POST[phrase] isstring POST[phrase] isset SESSION[phrase] strlen POST[phrase] &gt; 0 strlen SESSION[phrase] &gt; 0 POST[phrase] == SESSION[phrase] SQL INSERT ELSE echo POST[phrase] echo SESSION[phrase] ELSE include HTML FORM /PHP </code></pre> <p>&nbsp;</p> <p><strong>FORM</strong></p> <pre><code>PHP PEAR CAPTCHA Settings ... require_once 'Text/captcha.php' /PHP HTML FORM METHOD POST process_form.php text1 text2 radio PHP echo [ img src= sha1(session_id()) . '.png?' . time() ] /PHP submit /HTML </code></pre>
php
[2]
5,024,049
5,024,050
Custom Android Layouts
<p>I have an upcoming project that requires me to make a custom layout. I have been looking all over for a way to complete this but with no success. The layout will have custom buttons that need to fit the screen and some other custom views. In other words I need it to look the same on all types of devices. So these custom views need to stretch to fit the screens. Something similar to the weather bug app but the buttons will be at the top and there won't be so many options. The buttons will fit the screen width wise. Basically the layout will not contain any stock UI.</p> <p>I would like to have a book or tutorial that I could follow to help me out here. </p>
android
[4]
3,125,321
3,125,322
java, programm not stopping for scan.nextLine()
<p>When I run the following code it stops to let me enter servername and them port number, after that it is supposed to stop and let me enter username but it never pauses for scan.nextline() and flies straight to enter reciever name??</p> <pre><code>public static void main(String[] args) throws IOException { try { System.out.println("\n\n\nTCP Chat Client\n\nEnter server name:"); Scanner scan = new Scanner(System.in); //get server info from user serverName = scan.nextLine(); System.out.println("\nEnter port number:"); serverPort = scan.nextInt(); System.out.println("Enter your username:\n"); userName = scan.nextLine(); //make connection to server cSocket = new Socket(serverName, serverPort); out = new PrintWriter(cSocket.getOutputStream(), true); in = new BufferedReader(new InputStreamReader(cSocket.getInputStream())); //send username to server out.println(userName); String rcvrname="wefwef"; String message=null; //start messaging while(!(rcvrname.equals("exit"))){ System.out.println("Enter reciever name"); out.println(scan.nextLine()); System.out.println("Enter message"); out.println(scan.nextLine()); } out.close(); in.close(); cSocket.close(); } </code></pre>
java
[1]
4,321,587
4,321,588
Adding html to a placeholder control on the fly
<p>I am a generic markup which I load at runtime froma file as follows:</p> <pre><code>&lt;div id="pagewidth" &gt; &lt;div id="header" &gt; Head &lt;/div&gt; &lt;div id="wrapper" class="clearfix" &gt; &lt;div id="twocols" class="clearfix"&gt; &lt;div id="column2" &gt; Main Content Column &lt;/div&gt; &lt;div id="column3" &gt; right Column &lt;/div&gt; &lt;/div&gt; &lt;div id="column1" &gt; Left Column &lt;/div&gt; </code></pre> <p> Footer </p> <p>I want to add this to a place holder control in asp.net web page. How do I do it?</p>
asp.net
[9]
5,660,431
5,660,432
Remove symbols from link '($_SERVER['REQUEST_URI'])).'
<p>Currently using this code:</p> <pre><code>str_replace(".php","",basename($_SERVER['REQUEST_URI'])) </code></pre> <p>and it outputs like this:</p> <p>Rusko%20-%20Skanker.mp3&amp;sort=1</p> <p>i need it to display so: Rusko - Skanker</p>
php
[2]
2,034,190
2,034,191
I don't understand the last output for this block of code
<p>Well, this code was taken from a practice exam for a programming thing that i'm very under qualified for, but i'd still like to know the reason behind the output for this.</p> <pre><code> #include &lt;iostream&gt; using namespace std; int main(){ char g = 'X', t = '1', *k_ = &amp;t; g = 'y'; cout &lt;&lt; *k_ &lt;&lt; *k_ &lt;&lt; endl; g = 'Y'; cout &lt;&lt; *k_; k_ = &amp;g; t = 'Z'; cout &lt;&lt; *k_ &lt;&lt; *k_ &lt;&lt; *k_ &lt;&lt; endl; return 0; } </code></pre> <p>I don't understand why the output for the last cout is 1YYY if there are only three k_ pointers, and there's that 1 that's bothering me too.</p>
c++
[6]
4,824,029
4,824,030
CentOS Server How to Keep PHP Socket Server running?
<p>I have tried the nohup php socket.php &amp; and the server does start and remain started after the ssh window is closed. But when I got back a while later, its not running again. How can I keep this running?</p>
php
[2]
3,529,343
3,529,344
xhdpi is the largest density to date, right?
<p>There's no such density as "xxhdpi", right? (I know there's "xhdpi", of course). I've got a partner asking for assets in that density, but I cannot find any documentation on that. Have I missed this somehow? Is there a complete list of all known density names? I don't see anything in here, xhdpi is the largest mentioned:</p> <p><a href="http://developer.android.com/guide/practices/screens_support.html" rel="nofollow">http://developer.android.com/guide/practices/screens_support.html</a></p> <p>Thanks</p>
android
[4]
431,587
431,588
java.util.Set adds duplicate entries
<p>The below is my code,</p> <pre><code>public class Myclass{ some code is here. } public static void main(String args[]){ Set&lt;Myclass&gt; set = new HashSet&lt;Myclass&gt;(); Myclass mc = new Myclass(); for(int i=0;i&lt;2;i++){ set.add(mc); } System.out.println("size of set : "+set.size()); } </code></pre> <p>The above code is print the output 2 but it will be 1. Is there any wrong with my code, if so then please suggest me how to avoid adding duplicate entries in set. I have override the equals() in my Myclass class.</p> <p>Please reply me as soon as possible.</p> <p>Thank you.</p>
java
[1]
808,185
808,186
Avoid the jumping when sliding up or down (JQuery)
<p>I'm trying to get it so that upon clicking the pre-defined link, the content section will slide down and the other sections will slide up. I understand I could use JQuery callbacks for this, but for some reason, it always appears to try to slide the box up and then starts to bring it down (so it creates an odd jerky effect).</p> <p>The JQuery can be seen here:</p> <pre><code>$("#welcome_link").click(function () { $("div[id$='_content']").slideUp('fast', function() { $("#welcome_content").slideDown('fast'); }); }); </code></pre> <p>Is there something I've done wrong here? I thought this would work.</p> <p>Thanks!</p>
jquery
[5]
4,428,404
4,428,405
$(document).ready(function() - don't work
<p>I am using Rails &amp; jQuery.</p> <p>Here is HTML which I get:</p> <pre><code>&lt;head&gt; &lt;title&gt;Some&lt;/title&gt; &lt;script src="/javascripts/jquery.js?1305699774" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; alert("2"); $(document).ready(function() { alert("1"); .... </code></pre> <p>When I am refreshing the window I get only one alert message ("2"). Why I didn't get second alert message?</p> <p><img src="http://i.stack.imgur.com/cKlGK.png" alt="enter image description here"></p>
jquery
[5]
2,336,379
2,336,380
get the dimensions of a swf file from a .NET Program
<p>is it possible to get the dimensions of a swf file from c#?</p>
c#
[0]
5,009,763
5,009,764
Best way of stopping java optimising away a method call when performance testing
<p>Im doing some performance optimising on some code, and I've got two ways of doing a calculation.</p> <p>I've got a simple test harness:</p> <pre><code> long start, end; long oldDuration, newDuration; int answer; final int TEST_COUNT = 1000; start = System.currentTimeMillis(); for(int i = 0 ; i &lt; TEST_COUNT; i++) { answer = doCaluculationNewWay() } end = System.currentTimeMillis(); newDuration = end - start; start = System.currentTimeMillis(); for(int i = 0 ; i &lt; TEST_COUNT; i++) { answer = doCaluculationOldWay() } end = System.currentTimeMillis(); oldDuration = end - start; </code></pre> <p>How can I be sure that the JVM isnt just binning the call, knowing that the answer isnt being used?</p> <p>I considered making answer volatile, but Im worried that it will impose an additional performance overhead due to memory synching issues.</p>
java
[1]
5,844,946
5,844,947
JQuery - Retrieve value from another child element of the same parent
<p>I'm fairly new to JQuery and am having trouble with something that I'm sure is simple. Here is an example of some html that I'm working with:</p> <pre><code>&lt;tr&gt; &lt;td&gt;&lt;div class="testclass"&gt;&lt;p&gt;Test text&lt;/p&gt;&lt;/div&gt;&lt;/td&gt; &lt;td&gt;&lt;button class="testButton"&gt;Button text&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt;​ </code></pre> <p>When the button is clicked, I want to get the value in <code>&lt;p&gt;</code> in a previous cell. Here's how I'm currently trying to select it:</p> <pre><code>var text = $(".testButton").parent().parent().closest('p').text(); </code></pre> <p>Within the <code>onClick</code> function of the button, I've also tried:</p> <pre><code>$(this).prev('p').text(); </code></pre> <p>However, it's always <code>null</code>. I've messed around with jsfiddle for a little while trying to get this right, but no luck. Any tips would be appreciated.</p>
jquery
[5]
5,959,420
5,959,421
jQuery - hover function with two classes for an element, a hover for each class
<p>I'm not sure if this is a different problem embedded somewhere in my code, or an issue with the hover function i'm not aware of - </p> <p>in short, i have an element with two classes</p> <pre><code>&lt;input type="image" class="classA classB" ... /&gt; </code></pre> <p>and i have jQuery code like so:</p> <pre><code>$('classA').hover(){ function1, function2 } $('classB').hover(){ function3, function4 } </code></pre> <p>what i'm wanting is that when you hover over the input, BOTH hover functions (function1, function3) get fired. And when you move off it, BOTH functions (function2, function4) are also fired. What appears to be happening is that the classB hover completely overrides or shadows or what have you the classA hover function. </p> <p>Is this intended behaviour (or is this an indication that something is wrong with my much-larger code base?), and if so, what is the general consensus work around?</p>
jquery
[5]
2,190,542
2,190,543
Depth of testing?
<p>I have a fairly basic application. I'm loading it up on 2.1+ on emulators and 2.3.3 on an n1 and basically just making sure everything looks right and does what it's supposed to.</p> <p>I was reading about activity testing on the dev site and it talks about creating test applications and such. I don't get the point of testing whether a textview = a resource string that you set it to or not.</p> <p>How deep do you really need to test fairly basic apps before letting other people use them. Is there really anything that I won't catch using emulators and an n1 that test applications and such will?</p>
android
[4]
1,980,518
1,980,519
Receive an intent from a notification in an activity that's already open?
<p>I have an activity that creates notifications using the following code:</p> <pre><code>Notification notification = new Notification(icon, tickerText, 0); notification.flags |= Notification.FLAG_AUTO_CANCEL; Context context = getApplicationContext(); CharSequence contentText = getString(R.string.subtitle); Intent notificationIntent = new Intent(getBaseContext(), MainActivity.class); notificationIntent.putExtra("num", Integer.toString(i)); Intent deleteIntent = new Intent(getBaseContext(), DeleteActivity.class); deleteIntent.putExtra("num", Integer.toString(i)); PendingIntent contentIntent = PendingIntent.getActivity( getBaseContext(), ran, notificationIntent, 0); PendingIntent deletePendingIntent = PendingIntent .getActivity(getBaseContext(), ran, deleteIntent, 0); notification.setLatestEventInfo(context, text, contentText, contentIntent); notification.deleteIntent = deletePendingIntent; final int NOTIF_ID = ran; mNotificationManager.notify(NOTIF_ID, notification); </code></pre> <p>I keep a list of all the notifications from my app that are currently showing. </p> <p>When the notification is clicked, it opens the MainActivity. I have some code in the onResume() to delete the notification from the list. This works fine.</p> <p>When the notification is dismissed, it triggers DeleteActivity, which also deletes it from my list. This also works fine. </p> <p>The problem is, if MainActivity is already open, and the notification is clicked, the onResume() doesn't run again, and so the notification is gone, but it's not deleted from the list of notifications that the app thinks are showing. </p> <p>I'm wondering if there's any way I can execute a particular piece of code (or even just restart the whole activity) when the intent is received. I know I could just set it to use DeleteActivity instead but I'd rather have it open the MainActivity.</p>
android
[4]
1,662,110
1,662,111
If the wifi disconnects and reconnects is the previous wifi lock valid?
<p>I apply a wifi lock before file transfers over wifi, If the wifi goes off and comes back up, should I create a new lock ? or will the previous one still be valid ?</p> <p>I do not know what android documentation has to say about it..</p> <p>Thanks, </p>
android
[4]
5,086,548
5,086,549
Javascript Error "Missing ; before statement"
<p>I am having a very weird error on this block:</p> <pre><code>&lt;script type="text/javascript"&gt; var captions = new Array(); captions[0] = ""; captions[1] = '&lt;div class="cap-desc"&gt;&lt;h3&gt;No Win - No Fee&lt;/h3&gt;&lt;span class="captionSubhead"&gt;Performance Guarantee&lt;/span&gt;&lt;br /&gt;&lt;span style="color:#636363; font-size:13px;"&gt;Ask Today. We are very confident&lt;br /&gt;you'll be impressed with our results! &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="http://#" class="rmore" target="_blank"&gt;read more&lt;/a&gt;'; &lt;/script&gt; </code></pre> <p>The error tells me that I am missing a ';' before captions[1] but I am pretty sure that captions[0] has a semi-colon!</p> <p>The whole site is here: <a href="http://katron.sourcefit.com/cms02/a&amp;a/" rel="nofollow">http://katron.sourcefit.com/cms02/a&amp;a/</a></p> <p>It has 5 captions now, but same error nonetheless. I tried changing the contents of the caption in question. In this case, it's captions[1] and it works. What is wrong with the caption? I am sure I am closing all tags and quotes and escaping \n to <br /></p>
javascript
[3]
2,598,617
2,598,618
Circular reference between modules?
<p>If have this module</p> <pre><code># mymodule.py import __main__ </code></pre> <p>And I import it in the python interpreter:</p> <pre><code>&gt;&gt;&gt; import mymodule &gt;&gt;&gt; dir(mymodule) ['__builtins__', '__doc__', '__file__', '__main__', '__name__', '__package__'] &gt;&gt;&gt; dir() ['__builtins__', '__doc__', '__name__', '__package__', 'mymodule'] &gt;&gt;&gt; import sys &gt;&gt;&gt; sys.modules['__main__'] == mymodule.__main__ True &gt;&gt;&gt; mymodule == mymodule.__main__.mymodule True </code></pre> <p>I've just created a circular reference by importing a module that imports <code>__main__</code>. Is this bad?</p>
python
[7]
5,232,403
5,232,404
How to prevent DOS attacks using image resizing in an ASP.NET application?
<p>I'm currently developing a site where users can upload images to use as avatars, I know this makes me sound a little paranoid but I was wondering what if a malicious user uploads an image with incredibly large dimensions that will eat the server memory (as a DOS attack), I already have a limit on the file size that can be uploaded (250 k) but even that size can allow for an image with incredibly large dimensions if the image for example is a JPEG that contains one color and created with a very low quality setting. Taking into consideration that the image is uploaded as a bitmap in memory when being resized (ie. not compressed), I wonder if such DOS attacks occur, even to check the image dimensions it has to be uploaded in memory first, did you hear about any attacks that exploited this? Am I too worried?</p>
asp.net
[9]
318,707
318,708
Javascript nested if
<p>Hello everyone I'm trying to do when an option button selected an other option button appears. It works but when the other option button is selected I wanna display text but it does not work here is my code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $(".select-box").change(function() { if ($(".select-box option[value='3']").attr('selected')) { document.getElementById("demo").innerHTML="&lt;select class='select-box'&gt;&lt;option value='4'&gt;a&lt;/option&gt;&lt;option value='5'&gt;b&lt;/option&gt;&lt;/select&gt;"; if ($(".select-box option[value='5']").attr('selected')) { document.write("Hello") } } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;select class="select-box"&gt; &lt;option&gt;Select an option&lt;/option&gt; &lt;option value="1"&gt;no alert&lt;/option&gt; &lt;option value="2"&gt;no alert too&lt;/option&gt; &lt;option value="3"&gt;alert&lt;/option&gt; &lt;/select&gt; &lt;p&gt;&lt;/br&gt; &lt;div id="demo"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
5,122,261
5,122,262
JavaScript file is not read
<p>I have a weird JavaScript problem: I have an HTML page that displays correctly. And I put in the bottom of this page a series of JavaScript links to file like so: </p> <pre><code>&lt;script src="js/myfile.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="js/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt; ... </code></pre> <p>All the js files behaves as expected but the first one doesn't work (there is no path problem), in a sense that even when I simply put no more than an alert message, nothing happens. Is that a browser problem (I am trying on Safari and Chrome, and both displays the same none-message). Can anybody help?</p>
javascript
[3]
3,845,040
3,845,041
preg match php a-zA-Z0-9 and space
<pre><code>if (preg_match ('/[^a-zA-Z0-9]/i', $getname)) { </code></pre> <p>i use this preg_match pattern to check if a string in php contains other charachters than <code>a-zA-Z0-9</code>. i want to add to the pattern the space...i use '<code>/[^a-zA-Z0-9 ]/i'</code> but is not working ... how should i do it? </p> <p>i want to allow spaces including <code>a-zA-Z0-9</code></p>
php
[2]
2,872,305
2,872,306
Pass get_option value to an array
<p>I want to pass get_option value to an array value. This the value that I want to pass to the array.</p> <pre><code>&lt;?php echo stripslashes(get_option('a')); ?&gt; </code></pre> <p>and this is what I am trying to do.</p> <pre><code>&lt;?php $var = array( 'foo' =&gt;'echo stripslashes(get_option('a'));'); </code></pre> <p>Please let me know how can I achieve this.</p>
php
[2]
5,393,647
5,393,648
Two dimensional associative array in PHP
<p>In my code I'm getting data (three columns) from a sql db and I want to store the rows in an associative PHP array. The array must be multi-dimensional because I want to use the row id from the database as a key so that i can fetch values like this:</p> <blockquote> <p>$products["f84jjg"]["name"]</p> <p>$products["245"]["code"]</p> </blockquote> <p>I've tried using the following code but it doesn't work:</p> <pre><code>while ($row = mysql_fetch_row($sqlresult)) { $products = array($row[0] =&gt; array( name =&gt; $row[1], code =&gt; $row[2] ) ); } </code></pre> <p>Also, how should I reference the key if it is taken from a variable? What I want to do is:</p> <pre><code>$productName = $products[$thisProd]["name"]; </code></pre> <p>Will this work?</p>
php
[2]
1,933,675
1,933,676
What does the ! part of !function(){...}(); mean?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/3755606/what-does-the-exclamation-mark-do-before-the-function">What does the exclamation mark do before the function?</a> </p> </blockquote> <p>So I've come across the use of the following by the twitter share button code:</p> <pre><code>!function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (!d.getElementById(id)) { js = d.createElement(s); js.id = id; js.src = "//platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs); } }(document, "script", "twitter-wjs"); </code></pre> <p>And I was just wondering what the <code>!function</code> bit does.</p> <p>I'm guessing is short for <code>(function(){...})();</code> but I couldn't find anything online to confirm it.</p>
javascript
[3]
3,237,972
3,237,973
Why is the C++ scope resolution operator ::?
<p>This is one of the few questions I didn't find an answer to in Design and Evolution of C++ by Stroustroup. Why is the C++ scope resolution operator ::, as opposed to just :?</p> <p>I'm guessing it's because : is already used to indicate the start of an initialization list in a constructor. Does anyone else agree, disagree, or have a definitive answer on this?</p>
c++
[6]
1,548,698
1,548,699
getElementsByTagName("!") returns all elements in documents in IE and ( I think FF), but doesn't return anything in Chrome. Is there an alternative?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/4256339/javascript-how-to-loop-through-all-dom-elements-on-a-page">Javascript: How to loop through ALL DOM elements on a page?</a> </p> </blockquote> <pre><code>var arr = document.getElementsByTagName("!"); </code></pre> <p>returns all elements in document in IE, but doesn't return anything in Chrome. </p> <p>Is there a cross-browser alternative ?</p> <p>Update: The ! option returns all tags in a document in an array.</p>
javascript
[3]
2,703,059
2,703,060
Taking average of user input number
<p>This is my code</p> <pre><code>import java.util.*; import java.io.*; public class eCheck10A { public static void main(String[] args) { PrintStream out = System.out; Scanner in = new Scanner(System.in); out.print("Enter your integers"); out.println("Negative = sentinel"); List&lt;Integer&gt; aList = new ArrayList&lt;Integer&gt;(); for (int n1 = in.nextInt(); n1 &gt; 0; n1 = in.nextInt()) { if(n1 &lt; 0) { break; } } } } </code></pre> <p>if i want to take all the numbers that I enter for n1, and average them out, how do i refer to all these numbers? I am going to put them in the IF statement, so if a negative number is entered, the program stops and posts their average.</p>
java
[1]
491,370
491,371
Javascript Submit
<p>Hi I have the following script in my form </p> <pre><code>function pdf() { var frm = document.getElementById("form1"); frm.action = "http://www.abbysoft.co.uk/index.php"; frm.target="_blank" frm.submit() } </code></pre> <p>this is called from the following in my form <code>&lt;input class="buttn" type="button" value="Test" onclick="pdf()"</code></p> <p>The code work up to the frm.submit() but it will not submit </p> <p>Can anyone offer any advice please ?</p>
javascript
[3]
5,655,351
5,655,352
Failed to add recipient: @localhost [SMTP: Invalid response code received from server (code: 555, response: 5.5.2 Syntax error. k4sm217886weq.33)]
<p>I wrote PHP code that suppose to send mail via smtp.gmail.com:587 (using PEAR::Mail) to users with their forgotten password upon request. I get this error message "Failed to add recipient: @localhost [SMTP: Invalid response code received from server (code: 555, response: 5.5.2 Syntax error. k4sm217886weq.33)] ". I do not know how to handle this. </p> <p>Please assist.</p>
php
[2]
128,189
128,190
upload multiple images with php
<p>I have xml file with collection image urls and I want upload this url using php. I try using this function:</p> <pre><code>public function get_file($source, $destination) { $ctx = stream_context_create(array('http' =&gt; array('timeout' =&gt; 90))); $content = file_get_contents($source, null, $ctx); $f = fopen($destination, "wb"); fwrite($f, $content); } </code></pre> <p>I try download about 7000 images, but after about 500 images, it ceases to copy images and hangs on the file. What's wrong?</p>
php
[2]
4,116,445
4,116,446
Class variable in Java
<pre><code>class C3 { public static int n = 0; public int m = 0; public C3() { n++; m++; } public void display() { System.out.println(n + " " + m);} } } </code></pre> <p>Execution of: - </p> <pre><code>C3 c1 = new C3(); c1.display(); C3 c2 = new C3(); c1.display(); c2.display(); </code></pre> <p>Prints numbers (output) </p> <pre><code>1 1 2 1 2 1 </code></pre> <p>Can anyone please explain me the output step by step? i am a bit confused about the 2nd line of output, why didn't both m and n value increase? also in 3rd output why didn't it start from beginning?</p>
java
[1]
1,021,268
1,021,269
Aliasing the jQuery Namespace
<p>According to jQuery online document, if we want to avoid naming conflict, we could write our script like the followings: </p> <pre><code>jQuery(document).ready(function($) { // Code using $ as usual goes here. }); </code></pre> <p>While I feel the following approach much easier to understand:</p> <pre><code>(function($){ //function to create private scope with $ parameter //private scope and using $ without worry of conflict })(jQuery); //invoke nameless function and pass it the jQuery object </code></pre> <p>The first approach seems harder for me to consume. My guess here is (with the first approach) that later on the anonymous function will be called behind the scene which will take <strong>jQuery</strong> as its parameter.</p> <p>However I am not sure if my thinking is right. Could some one help me with it? Thank you.</p>
jquery
[5]
5,767,056
5,767,057
Getting last item this line using python
<p>I have output <code>['Q 0006 005C 0078 0030 0030 0033 0034 ONE_OF 0002 ']</code> I want only 0002 last item in this and how to remove these [' '] from the output</p>
python
[7]
1,301,990
1,301,991
android key event problem
<p>I have a parent ScrollView with a child view. When the user presses the back button, I want the child view to handle the event. I have tried a couple of things but none of them seem to work. pressing the back button kill sthe activity.</p> <pre><code>public class GameScrollView extends ScrollView{ public GameScrollView(Context context) { super(context); } @Override public boolean onInterceptTouchEvent (MotionEvent ev){ return false; } @Override public boolean onKeyDown (int keyCode, KeyEvent event){ return false; } } </code></pre> <p>in the child view I have the following code</p> <pre><code>public class GameView extends View implements OnTouchListener, onKeyListener{ public boolean onKey(View v, int keyCode, KeyEvent event){ if(keyCode == KeyEvent.KEYCODE_BACK){ //do stuff } invalidate(); return true; } } </code></pre> <p>In the ScrollView I have also tried overriding the dispatchKeyEvent method to return false, but that did not work either. What am I doing wrong here?</p> <p>Thanks!</p>
android
[4]
2,003,321
2,003,322
request time out occurs, while executing process
<p>I am developing an application in asp.net 2.0, where i am products details from one site to another. But as there are thousands of products to upload, request time out occurs and the process does not complete.</p> <p>Can any one help me or suggest me how i can avoid request timeout to occurs in between. my application is in asp.net 2.0 and using InProc session state.</p> <p>Thanks in advance.</p> <p>i also set execution time out in web.config as follows:</p> <pre><code>&lt;httpRuntime executionTimeout="3500" maxRequestLength="2097151" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/&gt; </code></pre>
asp.net
[9]
662,903
662,904
Get window title on new window
<p>I'm writing a keylogger type application, and I have pretty much everything done, my problem is getting the window title, I don't want to write the window title every time they press a key, I can get the window title, like I know how to, but how would I only write it to the log when its a new window?</p>
c++
[6]
4,139,547
4,139,548
Change default java installation
<p>I have many Java versions installed on a Windows 7 machine. Some of them are 32 bits, some are 64 bits. Now as default it starts one of those last versions (1.7 64 bits). How do I tell my Windows 7 machine to use another version of Java? One of the reasons is that I'm developing a JNI project from Microsoft Visual Studio C++ - it uses also java 1.7 64 bits.</p> <p>Best regards, Andrej</p> <p>I have set: </p> <p>User variable: JAVA_HOME=C:\j2sdk1.4.2_04 PATH=%JAVA_HOME%\bin;%PATH%</p> <p>and system variable: JAVA_HOME=C:\j2sdk1.4.2_04 PATH=...a_lot_of_paths...;%JAVA_HOME%\bin;%PATH%</p> <p>I had no idea which is better to set - for user or system settings. Done both.</p> <p>System restart.</p> <p>And...it didn't helped :( When I run "java -version" from cmd i have java 1.7, but not java 1.4 like defined in PATH.</p> <p>after run C:>where java I got two results:</p> <p>C:\Windows\System32\java.exe C:\j2sdk1.4.2_04\bin\java.exe</p> <p>Who let Java go to my windows directory ???!!! </p> <p>How to deal with that?</p>
java
[1]
4,380,568
4,380,569
How to check if a file can be opened by a third party application before download
<p>In my application I want to download a file and view it. The issue is that I need to check whether there is any third party application installed on the device that can open the file format(Mime) before it is downloaded. Is this possible?</p>
android
[4]
3,535,159
3,535,160
Moving a div using mouse which is inside another div?
<p>I have a div, inside that i have dynamically created another div.I need to move the dynamically created div and have to place it in desired position..Please Help.</p> <p>I am having one main div. i am creating multiple divs dynamically using javascript and appending with main div as it's child.I have to move the dynamically created divs inside the main div on dragging on each div.I am able to get id of currently selected div(created dynamically)</p>
javascript
[3]
1,723,161
1,723,162
I tried to forward a method to super, but it occasionally doesn't work. Why?
<p>This is the code in question, simplified for this example:</p> <pre><code>/** A version of Hashtable that lets you do * table.put("dog", "canine");, and then have * table.get("dogs") return "canine". **/ public class HashtableWithPlurals extends Hashtable { /** Make the table map both key and key + "s" to value. **/ public Object put(Object key, Object value) { super.put(key + "s", value); return super.put(key, value); } } </code></pre>
java
[1]
1,490,129
1,490,130
parsing file by using thread
<p>I had a file named <code>sample.txt</code> 2GB (example). I want to split the file into four parts and each should be read simultaneously and write on the other file <code>Sample1.txt</code> simultaneously.</p> <p>Please help me.</p>
java
[1]
1,809,457
1,809,458
How to enable XDebug extension on my php?
<p>I am running php on a macbook pro running mountain lion. Mountain lion comes with XDebug pre-installed, so based on a tutorial I've found , I made three steps. First I've uncomment this line in my php.ini :</p> <pre><code>zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so" </code></pre> <p>Secondly I've uncomment this line in my php.ini :</p> <pre><code>xdebug.remote_enable=1 </code></pre> <p>And finally I restarted the apache server with :</p> <pre><code>sudo apachectl restart </code></pre> <p>The problem is that I see no xdebug appearing in my php details when I run a phpinfo(). Thank you.</p> <p>PS : The path of the above xdebug.so file is correct.</p>
php
[2]