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
3,221,087
3,221,088
How to operate jQuery object correctly?
<pre><code>$('table.diyform').children('tbody').children('tr').each(function() { var $tds = $(this).children('td'); var label = $tds[0].find('a').html(); var required = $tds[0].find('input').html(); }); </code></pre> <p>The problem lies in <code>$tds[0]</code> but I don't know the correct way to do it yet.</p>
jquery
[5]
2,710,672
2,710,673
JavaScript cleaner/purifier?
<p>Is there any way to cleanup JavaScript code? </p> <p>I want to enable users to post arbitrary JS but i want to filter some of it out, like eval and document.write. Do you know of any tool that can do this?</p>
javascript
[3]
3,348,561
3,348,562
If statement to control user input
<p>The code given works fine but not with the original code. I would like the code to offer a number 1 through 5 and only accept a number 1 through 5. The number choosen Within range would still return random integers.</p> <pre><code>import random user_input = raw_input("Enter a number between 1 and 5 : ") selected_elem = [] while len(selected_elem) &lt; int(user_input): if user_input &gt;= int(6): print ("That is not an option...") random_elem = random.randrange(1, 10, 1) if random_elem not in selected_elem: selected_elem.append(random_elem) print ("Here are the numbers... ")+ str(selected_elem) </code></pre>
python
[7]
1,402,571
1,402,572
sending a fax from Android with a call (not an online service)
<p>Is there a way to send a fax from an android phone using the phone (and not some fax server or service)? Is there a Java library that I could start with?</p>
android
[4]
538,365
538,366
Select throwing error WSAENOTSOCK
<p><strong>ISSUE THAT I AM FACING</strong>:-</p> <p>Select(..) API is throwing error when called with FD_SET set containing IPv6 and IPv4 sockets on Win7 Home premium but the same application is running fine on other win7 machine. But if i use only IPv6 or IPv4 socket in FD_SET then it runs fine. So i think, system support both IPv6 and IPv4.</p> <p>I tried using the server from the link below :-</p> <p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms738639%28v=vs.85%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/ms738639%28v=vs.85%29.aspx</a></p> <p>Even this sample is same error from select call.</p> <p>Anyone can please help me in getting the reason behind this error and solving this issue.</p> <p>Thanks!!!</p>
c++
[6]
1,192,279
1,192,280
meta tag in wordpress
<p>how can i get the information which i have stored in the wordpress pages using meta tag.</p>
php
[2]
4,657,863
4,657,864
jquery refreshing a div without using other files?
<p>Right now, i know if i want to reload a div every xx seconds, i must place the div in a separate file, and use the first file to load then every xx seconds, so use code like:</p> <pre><code>&lt;script&gt; $(document).ready(function(){ $('#chat_holder').load('file.page.php'); setInterval(function(){ $('#chat_holder').load('file.page.php'); }, 10000); }); &lt;/script&gt; </code></pre> <p>..so this loads the content into this file. Is there a way to only have one div and reload in every xx seconds in all in the same file?</p>
jquery
[5]
3,908,309
3,908,310
how to make thumbnails with php
<p>I was just wondering how I can make thumbnails of images stored in hdd and use them in an html page, also I need the thumbnails to be able to enlarge (to their original size) if clicked on preferably inside a div tag on the same page, I would appreciate if anyone could put me in the right direction</p> <p>thanks</p>
php
[2]
1,850,228
1,850,229
C# empty statement
<p>In C#, I can write something like:</p> <pre><code>using (new MyDisposableClass().MethodA()); </code></pre> <p>The semicolon causes a compiler warning to be shown which states possible mistaken empty statement. I haven't run the above code but won't the method still be called?</p> <p>What uses is there of this type of coding convention? I saw another thread on here about this but I ask in case there areny differences now/therefore different replies.</p> <p>Thanks</p>
c#
[0]
3,636,880
3,636,881
What is the difference in the way static methods and instance methods are used in Java.
<p>While reading a book, i came across this statement: </p> <hr> <p><em>The methods of an object define its behaviour. These methods are called instance methods. It is important to note that these methods pertain to each object of the class. <strong>This should not be confused with the implementation of the methods which is shared by all instances of the class.</em></strong></p> <hr> <p>I know what instance methods are, I know what static methods are (i.e. shared by all instances of the class). The above statement seem to suggest that the implementation of the methods is shared by all instances. What exactly does this mean? It doesnt sound like it is refering to static methods. </p>
java
[1]
5,399,817
5,399,818
How can I get the last 12 months sales subtotals in a table?
<p>I have this code so far which gives me the subtotals for each product for a given month. </p> <pre><code> &lt;?php include("dbaseconn.php"); $query = "SELECT product, SUM(qty) FROM sh_orders GROUP BY product"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "&lt;table width='1050'&gt;" ; echo "&lt;td width='400'&gt;"; echo "". $row['product']. " "; echo "&lt;/td&gt;"; echo "&lt;td&gt;"; echo "". $row['SUM(qty)']. "" ; echo "&lt;/td&gt;"; echo "&lt;br /&gt;"; } ?&gt; </code></pre> <p>TABLE STRUCTURE</p> <pre><code>CREATE TABLE IF NOT EXISTS `sh_orders` ( `building` varchar(50) NOT NULL, `qty` varchar(5) NOT NULL, `product` varchar(50) NOT NULL, `order_id` bigint(5) NOT NULL AUTO_INCREMENT, `unik` varchar(50) NOT NULL, `order_date` varchar(25) NOT NULL, `co_id` varchar(20) NOT NULL, UNIQUE KEY `unik` (`unik`), UNIQUE KEY `id` (`order_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ; </code></pre> <p>I want to show the last 12 months sales - SUM (qty) does that for me, but I need to see each month separately with each product and its total sales for that month. I need this in one table showing each month with each product and total for that month</p> <pre><code>EXPECTED RESULT Month: January 2012 Feb 2012 Marc 2012 Product1: 124 105 76 Product2: 34 23 56 Product3: 12 5 6 </code></pre> <p>I am new to this so please show patience if I ask a million questions.</p>
php
[2]
2,650,944
2,650,945
Weekly event manager code not working in javascript
<p>I have create a weekly event manager in javascript . but something went wrong. the code is not working . Please someone solve the fault.Whats wrong in it ?????</p> <pre><code>var plan=prompt("Hello , Made a week plan. Type the week name to add a event"); var week = ["saturday" , "sunday" , "monday" , "tuesday"]; var saturday; var sunday; var monday; var tuesday; if( plan == "saturday" ) { var saturday=prompt("What will you do in saturday?"); } else if ( plan == "sunday") { var sunday=prompt("What will you do in sunday?"); } else if (plan == "monday") { var monday=prompt("var getknow=prompt(""What will you do in monday?"); } else if (plan == "tuesday" ) { var tuesday=prompt("What will you do in tuesday?"); } var getknow=prompt("Do you want to cheack the schedule? Type the week name"); if ( getknow == saturday) { alert(saturday); } else if (getknow == sunday ) { alert(sunday); } else if (getknow == monday) { alert(monday); } else if (getknow == tuesday) { alert(tuesday); } </code></pre> <p>everything is working now without theese lines of codes </p> <pre><code>var getknow=prompt("Do you want to cheack the schedule? Type the week name"); if ( getknow == saturday) { alert(saturday); } else if ( getknow == sunday ) { alert(sunday); } else if ( getknow == monday ) { alert(monday); } else if ( getknow == tuesday ) { alert(tuesday); } </code></pre>
javascript
[3]
5,633,710
5,633,711
Java codes for USB
<p>I want to create a program using Java for Automatically copied USB's data when it's insert to machine. How I do it? </p>
java
[1]
2,448,840
2,448,841
Scrape a number from separate spans
<p>I need to scrape the number 622104 from this html</p> <p>How can I get the number?</p> <pre><code>&lt;div class="numbersBackground"&gt; &lt;div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl00_numberPanel" class="number"&gt; &lt;div class="numberWrapper"&gt;&lt;span&gt;6&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;&lt;div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl01_numberPanel" class="number"&gt; &lt;div class="numberWrapper"&gt;&lt;span&gt;2&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;&lt;div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl02_numberPanel" class="number"&gt; &lt;div class="numberWrapper"&gt;&lt;span&gt;2&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;&lt;div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl03_commaPanel" class="comma"&gt; &lt;/div&gt;&lt;div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl04_numberPanel" class="number"&gt; &lt;div class="numberWrapper"&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;&lt;div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl05_numberPanel" class="number"&gt; &lt;div class="numberWrapper"&gt;&lt;span&gt;0&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;&lt;div id="ctl00_mainContent_playersOnlineNumberRepeater_ctl06_numberPanel" class="number"&gt; &lt;div class="numberWrapper"&gt;&lt;span&gt;4&lt;/span&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
php
[2]
5,638,582
5,638,583
How to turn to US characters
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/158241/php-replace-umlauts-with-closest-7-bit-ascii-equivalent-in-an-utf-8-string">PHP: Replace umlauts with closest 7-bit ASCII equivalent in an UTF-8 string</a> </p> </blockquote> <p>I need to change strings that have accents E.G: Casá to become Casa. Is there an easy way to do it with PHP? Thanks</p>
php
[2]
2,576,351
2,576,352
Method-Object pairs in Java
<p>I'd like to create a list of method-object pairs. Each method is a function returning a boolean. Then:</p> <pre><code>foreach(pair) { if method evaluates to true { do something with the object } } </code></pre> <p>One way of modelling this that I can think of is to have a class <code>Constraint</code> with a method <code>isValid()</code> and for each constraint produce an anonymous class (overriding the <code>isValid()</code> method). I feel like there could be a nicer way. Can you think of any?</p>
java
[1]
4,128,930
4,128,931
Use jquery show() and animate() together?
<p>I have an issue getting jquery animate to fire after calling show or fadeIn on a hidden absolutely positioned div (display = none). The fadeIn/Show works fine, but the animate does nothing - and the logic function definitely evaluates to true after testing. I'm using IE9. Am I missing something?? Thanks.</p> <pre><code>function checkscroll(x) { $("#" + x).fadeIn(100); var t = $(window).height(); var m = $("#" + x).offset(); var p = m.top; var x = $("#" + x).height(); if ((p + x) &gt; t) { $("#" + x).animate({ marginBottom: "20px"}, "fast"); } } </code></pre>
jquery
[5]
326,390
326,391
Why can't i have classcastexception?
<p>Why can't i have classcastexception? E means C in the example, doesn't it? B is not C, I thought my cast must work only for compiler. Where is my mistake?</p> <pre><code>public class A{ public static void main(String...s){ Monitor&lt;C&gt; m = new Monitor&lt;C&gt;(); C arg2 = new C(); B d = m.f(arg2); System.out.println(d); } } class B extends A{} class C extends B{} class Monitor&lt;E extends B&gt;{ public E f(E E){ return (E) new B();//Why this place didn't give me ClassCastException? } } </code></pre>
java
[1]
162,061
162,062
My date function in PHP doesn't display the correct time
<p>Here's my PHP code:</p> <pre><code>echo date('M j y g:i:A'); </code></pre> <p>This doesn't display correct time. why?</p>
php
[2]
5,517,891
5,517,892
RemoteControlClient image brightness?
<p>I have the intention of allowing users to have pictures on their lock screen. The only way I could find do this easily is through a <code>RemoteControlClient</code>. My issue is the image is rather dim on the lock screen and I'm wondering if there is a setting to make it brighter. The code I set it up with is the following:</p> <pre><code> private void setUpRemoteController() { AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); audioManager.requestAudioFocus(new AudioFocusListener(), AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); ComponentName pareceiver = new ComponentName(this, PAReceiver.class.getName()); audioManager.registerMediaButtonEventReceiver(pareceiver); Intent mediaButtonIntent = new Intent(android.content.Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(pareceiver); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0,mediaButtonIntent,0); remoteControlClient = new RemoteControlClient(mediaPendingIntent); remoteControlClient.setPlaybackState( RemoteControlClient.PLAYSTATE_PLAYING); remoteControlClient.setTransportControlFlags( RemoteControlClient.FLAG_KEY_MEDIA_NEXT | RemoteControlClient.FLAG_KEY_MEDIA_PREVIOUS); audioManager.registerRemoteControlClient(remoteControlClient); Log.d("", "Started and set up controller and receiver"); } </code></pre> <p>On a related note: Is there any way to make the <code>RemoteControlClient</code> show up without hijacking the Audio Focus when I don't actually need it?</p>
android
[4]
2,954,232
2,954,233
Error: NetBeans 7.0 Android SDK 14
<p>I am getting the following error on NetBeans 7.0 trying to run a HelloAndroid application. The Android SDK as well as an Android device have already been detected by NetBeans, and I followed all the instructions given.</p> <blockquote> <p>C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:421: Android Target is not set.</p> </blockquote>
android
[4]
2,729,005
2,729,006
no way to change the large icon of my app
<p>I submitted an app to apple, they said my icon needs to change. I redesigned the icon but found that there is no way to change the icon. If I submitted a new app, the app name will duplicated and be refused</p> <p><img src="http://i.stack.imgur.com/AS5Gl.png" alt="enter image description here"></p> <p>Welcome any any comment</p>
iphone
[8]
5,287,866
5,287,867
Best Practice for JavaDocs - Interface,Implementation, or Both?
<p>I have a DAO interface and implementation of the DAO. The JavaDocs in the interface are what Netbeans displays to the client implementing the DAO methods.</p> <p>Obviously I will need to maintain the JavaDocs in the interface. But what about the implementation of it? On one hand, it is convenient to have them there, but on the other hand, it is duplication, and requires them to be maintained in two places.</p> <p>Just wondering what other Java developers do.</p>
java
[1]
4,706,871
4,706,872
How to put a date value as a number in a jscript array instead of using new Date(2008, 1 ,1)?
<p>I have an array of dates that I am populating adding the dates creating the types and calling their constructor like this: new Date(2008, 1, 1)</p> <p>I was wondering if there is a better way to do this? I am guessing that I can use the numeric representation of Date and put that into the array on the server side and send this array down to the client. I feel that the array with the numbers will be smaller and will result a faster running jscript on the client. </p> <p>I would like to know how it is possible and if this results better performance at all? </p> <p>I am fairly new to jscript.</p>
javascript
[3]
3,208,501
3,208,502
jquery: how to remove the handler setup by .click()?
<p>I found sometimes I hook up 2 functions to the buttun, using .click(function(){}), is it possible for me to remove the prior attached function before I hook up new one?</p>
jquery
[5]
210,922
210,923
How should objects be in a Java game
<p>EDIT: i just deleted the entire post and reformulated the question to be more generic.</p> <p>I want to do a simple strategy game: map, units.</p> <p>Map: one class. Units: another class, self drawn.</p> <p>Simple questions:</p> <ol> <li>How does an unit should redraw itself on the map.</li> <li>A unit should be a JPanel or similar Swing component (just to be able to manage them as an entity with its own mousehandlers) or can be another thing, without neglecting the fact that it should be an autonomous object with its own action handlers and fields.</li> <li>Is this map-units model correct of a simple game that would help me to learn in a fun way Java and OOP fundamentals.</li> </ol> <p>Thats it!</p>
java
[1]
3,004,415
3,004,416
display ['name'] inside of a foreach loop coming from another loop
<p>is it possible to use the indexes values inside of a foreach loop that is contained inside a partent for each. Look at the script below and observe that in the child for each I use <code>echo'&lt;div&gt;' .$product['name'] . '&lt;/div&gt;';</code> When <code>$product[' name '];</code> belongs to the parent for each. is that possible? I am looking to use the index <code>['name ']</code> in the child <code>foreach()</code>.</p> <pre><code>foreach($tree as $product){ echo '&lt;div&gt;' . $product['name']. '&lt;/div&gt;'; foreach($product['variery'] as $variety) { echo'&lt;div&gt;'. $variery['image'] . '&lt;/div&gt;'; echo'&lt;div&gt;' .$product['name'] . '&lt;/div&gt;'; } // end of child for each } //end of parent for each </code></pre>
php
[2]
116,497
116,498
Accessing an object property without knowing the name?
<p>I'm writing a PHP script that accesses two different data objects - one is backed by a DB, the other contains session data. They both contain the same fields - i.e. the data that is in the session object will make its way into the DB once it is validated.</p> <p>I'm trying to write a function that will first check the db-backed object for a value, then check the session-data-backed object for a value. It's not working like I quite expect, however. Here is what I have.</p> <pre><code>&lt;?php function check_cache($field){ // $App is the DB backed object, $data is the session object return $app-&gt;$field ? $app-&gt;$field : $data-&gt;$field ? $data-&gt;$field : ''; } ?&gt; </code></pre> <p>I'd like to be able to call the function like this:</p> <pre><code>&lt;input type="text" value="&lt;?php echo check_cache('address'); ?&gt;" /&gt; </code></pre> <p>...but the function always returns nothing. When I replace the function call with the actual inline code, substituting <code>$field</code> with the field name I want, it works. What am I missing?</p>
php
[2]
1,781,183
1,781,184
Script for adding an image at the very end of the last paragraph for multiple blocks
<p>For each article on a page, I would like to insert an image at the very end of the last paragraph. My HTML looks like this: </p> <pre><code>&lt;div class="storycontent"&gt; &lt;p&gt;One&lt;/p&gt; &lt;p&gt;Two&lt;/p&gt; &lt;p&gt;Three&lt;/p&gt; &lt;/div&gt; </code></pre> <p>There may be several of those sections or only one. There is also an unknown number of <code>&lt;p&gt;&lt;/p&gt;</code> tags. </p> <p>What I would like to do is insert an <code>&lt;img /&gt;</code> at the very end of the last <code>&lt;p&gt;</code> before the closing tag.</p> <p>Here is what I have so far, but it is only appending the image tag to the very last <code>&lt;p&gt;</code> on the page, and not the last one in the <code>storycontent</code> <code>&lt;div&gt;</code></p> <pre><code>jQuery('.storycontent').each( function(){ jQuery(this).last('p').append(img); //img is a var which contains an Image() element; } ); </code></pre>
jquery
[5]
3,426,412
3,426,413
Loading images one by one
<p>I want to load images one by one not all together.In the following code imagedata is the array containing urls from which i need to load images. Here is my code but no success.</p> <pre><code>-(void)loadSingleImage:(int)buttonTag { UIButton *buttonImage =(UIButton *) [self.view viewWithTag:buttonTag]; NSData *imagesubCategoryData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:[imageData objectAtIndex:buttonTag-30]]]; [buttonImage setImage:[UIImage imageWithData:imagesubCategoryData] forState:UIControlStateNormal]; } -(void)loadImageData { for(int i=0;i&lt;[imageData count];i++) { [self loadSingleImage:i+30]; sleep(0.1); } } </code></pre>
iphone
[8]
2,402,425
2,402,426
Concept - Does a queue have direction?
<p>I called it a queue but according to <a href="http://en.wikipedia.org/wiki/Queue_%28data_structure%29" rel="nofollow">wikipedia</a> a queue is a first in first out data structure. </p> <p>You add to the "front". And you remove from the "end".</p> <p>I'm doing the opposite.</p> <p>I'm adding to the "end". And removing from the "front". ( using push() and shift() )</p> <p>Because front and end don't have any concrete meaning does direction even matter?</p> <p>I'm just going off examples from wikipedia and <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/push" rel="nofollow">mdn</a>.</p> <p>Can I call it a queue?</p>
javascript
[3]
1,009,641
1,009,642
Variable assignment with || in value
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2100758/javascript-or-variable-assignment-explanation">JavaScript OR (||) variable assignment explanation</a> </p> </blockquote> <p>Can someone help explain what this line does, and how?</p> <pre><code>var scrollTop = html.scrollTop || body &amp;&amp; body.scrollTop || 0; </code></pre>
javascript
[3]
5,161,438
5,161,439
What is a PHP anonymous function?
<p>What is an anonymous function in PHP? Could you give me a simple example, please?</p>
php
[2]
488,074
488,075
How To Set Browser Cookies With Curl
<p>I have a curl function as shown below. To load this function i use this <code>&lt;img src="http://site.com/pxl.php?i=1.jpg" height="1" width="1" /&gt;</code> but when i do that cookies dont get added to my browser. Is there a way so that when the curl run on the url i collect the cookies from the url and set it to the browser of using accessing <code>&lt;img src="http://site.com/pxl.php?i=1.jpg" height="1" width="1" /&gt;</code></p> <pre><code>function get_content($url,$ref) { $browser = $_SERVER['HTTP_USER_AGENT']; $ch = curl_init(); $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"; $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: max-age=0"; $header[] = "Connection: keep-alive"; $header[] = "Keep-Alive: 300"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Accept-Language: en-us,en;q=0.5"; $header[] = "Pragma: "; // browsers keep this blank. curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, $browser); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, $ref); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_AUTOREFERER, false); $html = curl_exec($ch); curl_close ($ch); return $html; } </code></pre>
php
[2]
4,493,327
4,493,328
IndexOutOfBoundsException in ArrayAdapter
<p>I got a trivial code involving a <code>ListView</code> and a <code>ArrayAdapter</code> which throws a IndexOutOfBoundsException on some devices. The problem is: I do not know how this Exception occurs, I only get the stacktraces from the Developer Console of Android.</p> <p>The reduced code example is shown below. How can the <code>getItem</code> operation of the <code>ArrayAdapter</code> fail for the <code>position</code> element? The <code>ArrayAdapter</code> is never changed, there is no other method in the <code>Activity</code>.</p> <p><strong>I know what a <code>IndexOutOfBoundsException</code> is, I know that I can prevent it by checking the length first. But I'm curious: How can this Exception happen here? How can someone click on a event which does not exist in the datastructure?</strong></p> <p>Reduced code:</p> <pre><code>public class EventListActivity extends Activity { public void onStart() { final ListView listview = new ListView(this); final Event[] events = [Retrieve a Array from somewhere] final ArrayAdapter&lt;Event&gt; a = new ArrayAdapter&lt;Event&gt;(this, R.layout.eventlistitem, events); listview.setAdapter(a); listview.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { Event event = a.getItem(position); ^^^^^^^ throws Exception } }); </code></pre> <p>Exception:</p> <pre><code>java.lang.IndexOutOfBoundsException at java.util.Arrays$ArrayList.get(Arrays.java:75) at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:298) at xxx.EventListActivity$3.onItemClick(EventListActivity.java:130) </code></pre>
android
[4]
851,323
851,324
automatically choose video file without using openfiledialog
<p>I am using AForge code to play video in my program using c# and it works well. here is the code:</p> <pre><code>private void loadButton_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { FileVideoSource fileSource = new FileVideoSource(openFileDialog1.FileName); OpenVideoSource(fileSource); } } </code></pre> <p>This code will play the video when we click the load button and choose what video we want to play. However i want the video automatically choose the selected video after clicking the load button.</p> <p>i try this code however the video its not even playing.</p> <pre><code>private void loadButton_Click(object sender, EventArgs e) { FileVideoSource fileSource = new FileVideoSource("C:\\Users\\videoplay.mp4"); OpenVideoSource(fileSource); } </code></pre> <p>Please help me modifying the code. what did i do wrong?</p>
c#
[0]
4,120,443
4,120,444
Unable to pass string parameter to a simple Javascript function being invoked when a hyperlink is clicked
<p>It's a very simple question but I couldn't figure it out. I'm trying to pass parameters to a Javascript function which is invoked when a hyper link is clicked. </p> <p>It works just fine when the parameters are number but doesn't work when one of them is of type string. I even tried to escape them but unfortunately to no avail.</p> <p>The following is a very simple code.</p> <pre><code>function temp(a, b) { alert(a+ " "+b); } &lt;a href="javascript:void(0);" onclick="temp(x, 2);"&gt;Click&lt;/a&gt; </code></pre> <p>It doesn't work complaining <code>x is undefined</code> <code>x</code> is here <code>onclick="temp(x, 2);"</code>. When I modify the function something like this <code>temp(1,2);</code>, it works and alerts as specified.</p> <p>What might be the reason? What is the solution?</p>
javascript
[3]
3,964,427
3,964,428
Emulator comes up, but is very unstable
<p>The emulator comes up but its very unstable. It keeps giving me the window that asks to send data to microsoft. The it becomes not responding and freezes up. Sometimes I might keep it up for a while and am not doing anything to it and all of a sudden it pops up the debug window. Is there something I can do to make it more stable. </p>
android
[4]
2,888,514
2,888,515
I want to remove the row if that row's <td> contains only B in my below code?
<p>Please check the below code. Here i'm deleting the row, if that row td contains the value "B". But bellow code is removing all rows.</p> <p>jQuery</p> <pre><code>$(document).ready(function() { $("#mytable tr td:contains('B')").parent().remove(); }); </code></pre> <p>HTML</p> <pre><code>&lt;table border="0" align="center" width="45%" cellpadding="2" cellspacing="2" id="mytable"&gt; &lt;tr&gt; &lt;td align="center" width="15%"&gt;A&lt;/td&gt; &lt;td align="center" width="15%"&gt;B&lt;/td&gt; &lt;td align="center" width="15%"&gt;C&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center" width="15%"&gt;AA&lt;/td&gt; &lt;td align="center" width="15%"&gt;BB&lt;/td&gt; &lt;td align="center" width="15%"&gt;CC&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="center" width="15%"&gt;AAA&lt;/td&gt; &lt;td align="center" width="15%"&gt;BBB&lt;/td&gt; &lt;td align="center" width="15%"&gt;CCC&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
jquery
[5]
2,892,051
2,892,052
Iterating through a list based on the value of an Id element inside the list in c#
<p>I have another question that's connected with my class:</p> <pre><code>public class Parent { public IList&lt;ParentDetail&gt; ParentDetails { get { return _ParentDetails; } } private List&lt;ParentDetail&gt; _ParentDetails = new List&lt;ParentDetail&gt;(); public Parent() { this._ParentDetails = new List&lt;ParentDetail&gt;(); } } public class ParentDetail { public int Id { get; set; } } } </code></pre> <p>Presently I iterate through ParentDetails and do some action for each ParentDetail. I am using MVC razor syntax so that's the reason for the @( .. etc</p> <pre><code>@foreach (int index in Enumerable.Range(0, Model.Parent.ParentDetails.Count())) { Model.Parent.ParentDetails[@index].Id </code></pre> <p>This gives me the numbers 1,2,3 ... etc IF the Ids have been assigned sequentially in the list with the first element having an Id of 1 and the second element having an Id of 2 etc. </p> <p>However the Ids in my list are not assigned sequentially. I may have it like this:</p> <pre><code>list-element [0] has an Id of 3 list-element [1] has an Id of 4 list-element [2] has an Id of 1 list-element [3] has an Id of 2 </code></pre> <p>What I need is something equivalent to the foreach that will let me iterate through my list based on the value of Id. Maybe I need to use the Index method to find but I don't know how to put this all into a loop. </p> <p>I know some C# but this is quite far beyond me. Can anyone help out with some ideas. I hope my question makes sense. </p> <p><em>I will watch for comments so please just send a comment if there is something that's not clear.</em> </p> <p>Thank you.</p>
c#
[0]
981,709
981,710
What is the meaning of this?
<p>Code:</p> <pre><code>void *buff; char *r_buff = (char *)buff; </code></pre> <p>I can't understand the type casting of <code>buff</code>. Please help.</p> <p>Thank you.</p>
c++
[6]
4,437,711
4,437,712
navigation bar Android
<p>how do I make a navigation bar like this?</p> <p><a href="http://www.freeimagehosting.net/uploads/8aa355f9ef.png" rel="nofollow">http://www.freeimagehosting.net/uploads/8aa355f9ef.png</a></p>
android
[4]
3,499,500
3,499,501
Casting and ArrayList
<p>I have an ArrayList that contains a number of songs objects.</p> <pre><code>ArrayList&lt;Song&gt; aSong = new ArrayList&lt;Song&gt;(); </code></pre> <p>The Song class looks like this:</p> <pre><code>public class Song { private String sName; private String sLength; public Song(String name, String length){ sName = name; sLength= length; } public String getName(){ return sName; } public String getLength(){ return sLength; } public void edit(String name, String length){ sName = name; sLength= length; } </code></pre> <p>}</p> <p>I'm trying to see if a song exists with the ArrayList method "contains"</p> <pre><code> // example aSong.contains("Song 1") </code></pre> <p>but this returns false even though the song does really exist in the ArrayList. </p> <p>Any help would be highly appreciated and thank you in advance.</p>
java
[1]
4,050,368
4,050,369
qtip - distinct results on distinct table rows
<p>I have table with few rows, after use hover mouse over row I want to display qtip ( <a href="http://craigsworks.com/projects/qtip/docs/#create" rel="nofollow">http://craigsworks.com/projects/qtip/docs/#create</a> ) tooltip. How can I refer to some row id in function, where I define displayed content:</p> <pre><code>$(document).ready(function() { $('.qtip').qtip({ content: $(this) &lt;-- this don't work }); }); </code></pre> <p>I have tables with rows like this:</p> <pre><code> &lt;td class="qtip" id="pic-&lt;?php echo $item-&gt;product_id; ?&gt;"&gt; </code></pre> <p>I want to display row id in tooltip. (for example pic-1232)</p>
jquery
[5]
76,280
76,281
SharedPreferences TextView
<p>I have button, after I click button it will list to the ListView, choose ListView item and this item will display to left of the button, I want after I restart the program the listItem was choosed is display. If anybody know this, please help me? Thanks</p>
android
[4]
4,610,983
4,610,984
How can I define this value(s) in a good and easy way?
<p>I am stuck in a conversion / definition of a function parameter and would very much appreciate some help. I am sure it's an easy one for any experienced c/c++ guy, but not for me, not right now.</p> <p><strong>Problem:</strong></p> <p>creating the right paramter to use with <code>myCommmand(uint8 *pAddr)</code>, which will execute <code>send(pAddr, 6)</code>, which will use those parameters to loop the following 6 times:</p> <p><code>write(reinterpret_cast&lt;unsigned char*&gt;(pAddr)[i]);</code></p> <p>my trouble is, that pAddr has to point to an array of 6 bytes, which i most preferably would like to define as unsigned byte values (0-255) or as hex 00-FF.</p> <p><strong>Restrictions</strong></p> <p>Functions shall not be changed. It is just about creating the parameters.</p> <p><strong>My attemps:</strong></p> <pre><code>uint8 Addr[] = {00,22,122,205,16,04}; uint8 *pAddr = &amp;Addr; </code></pre> <p>but this results in error C2440 (can't convert uint(*)[6] to uint8 *).</p> <p><strong>Desired solution</strong></p> <p>I would lik to know a <em>good</em>, wellformed way to create thise Addr-array or stream, or object to pass on to my functions, by writing their byte or hex values into my code - like in my attempt. I can use <em>boost</em>-libraries. Thanks to all helping me out with this!</p>
c++
[6]
2,190,765
2,190,766
C# Foreach usercontrols I added to a page
<p>I've got this code:</p> <pre><code> protected void ddlTemplate_SelectedIndexChanged(object sender, EventArgs e) { Template t = new Template(); t.LoadById(Convert.ToInt32(ddlTemplate.SelectedItem.Value)); foreach (Widget w in t.TemplateWidgets) { UserControls_Widget ucWidget = (UserControls_Widget)LoadControl("~/UserControls/ucWidget.ascx"); ucWidget.WidgetTitle = w.Name; ucWidget.Parameters = w.Parameters; pnlWidgets.Controls.Add(ucWidget); } } protected void lnkSubmit_Click(object sender, EventArgs e) { foreach (Control cc in pnlWidgets.Controls) { } } </code></pre> <p>Basically I'd like to foreach the Widgets I added to the page in the ddlTemplate_SelectedIndexChanged event. So the question is how do I get the UserControls I added.</p>
c#
[0]
700,941
700,942
How to shield the home key if my app is active? (Screensaver, Lockscreen)
<p>If I want to write a Screensaver or Lockscreen. Is there a way to prevent the home key from going back to the launcher?</p>
android
[4]
3,920,594
3,920,595
Get sum of the same class
<p>I have</p> <pre><code>&lt;div id="english"&gt; &lt;ul&gt; &lt;li&gt;English&lt;/li&gt; &lt;li&gt;Instructor Name&lt;/li&gt; &lt;li class="grade"&gt;85&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="math"&gt; &lt;ul&gt; &lt;li&gt;Math&lt;/li&gt; &lt;li&gt;Instructor Name&lt;/li&gt; &lt;li class="grade"&gt;80&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="science"&gt; &lt;ul&gt; &lt;li&gt;Science&lt;/li&gt; &lt;li&gt;Instructor Name&lt;/li&gt; &lt;li class="grade"&gt;90&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;p id="grade-sum"&gt;Sum of grade here&lt;/p&gt; </code></pre> <p>My question is how I am going to get the sum of that class grade using jquery. The sum should be 255.</p>
jquery
[5]
3,339,065
3,339,066
keeping a division visible in the screen
<p>I am creating a web page in which when user hovers on an image it displays a paragraph which is enclosed in a division under it. When the user moves the cursur out of the image the division disappears.</p> <p>My problem is that when the user clicks the image which is in the bottom of the screen.. i want the page to be scrolled using <strong>javascript</strong> until the division at the bottom is visible... </p> <p>I want to know how to do this one. Which function to use??</p> <p>Thanks in Advance..</p>
javascript
[3]
1,775,062
1,775,063
Inserting and removing commas from integers in c++
<p>Very much a noob here, so it's best to assume I know nothing in any answers.</p> <p>I've been writing a little app, and it's working well, but readability is a nightmare with my numbers.</p> <p>Essentially, all I want to do is to add commas into the numbers displayed on the screen to make it easier to read. Is there a quick and easy way to do this?</p> <p>I've been using stringstream to grab my numbers (I'm not sure why this is even suggested at this point, it was simply advised in the tutorial I worked through), such as(cropping out the irrelevent bits):</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;sstream&gt; using namespace std; int items; string stringcheck; ... cout &lt;&lt; "Enter how many items you have: "; getline (cin, stringcheck); stringstream(stringcheck) &gt;&gt; items; ... cout &lt;&lt; "\nYou have " &lt;&lt; items &lt;&lt; " items.\n"; </code></pre> <p>When that number is typed as something large, amongst everything else it becomes quite a headache to read.</p> <p>Is there any quick and easy way to make it print "13,653,456" as opposed to "13653456" like it would right now (assuming that's what was input of course)?</p> <p>Note: If it matters, I'm making this as a console application in Microsoft Visual C++ 2008 Express Edition.</p>
c++
[6]
95,895
95,896
Performing periodic audits and best practice
<p>I'm doing a windows form and would like an audit task to happen every 30 seconds. This audit is essentially checking a series of services on remote computers and reporting back into a richtextbox the status.</p> <p>Current I have this running in an endless background thread and using an invoker to update the richtextbox in the main form.</p> <p>Is this best practice? If I made an endless loop in my main form that would prevent any of my buttons from working, correct?</p> <p>I'm just curious if every time I want to create a periodic audit check I have to create a new thread which checks the status or file or what have you? </p> <p>Edit: I looked further into the Timer class and decided to go with <a href="http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx" rel="nofollow">System Timer</a> as it proved to be better with a longer function. Thanks for pointing me in the right direction.</p>
c#
[0]
2,414,449
2,414,450
Is there jQuery plugin for displaying tooltips with content of some other page?
<p>Are there any jquery tooltips that could display a content of a provided url? I need it urgently and I've searched and searched and to no avail. I have a page that displays contact information of a certain person (provided in query string) and some other page that displays a list of users. i would like to display this small contact information in tooltip on clicking on a specified user. But I cannot find any tool.</p>
jquery
[5]
2,661,115
2,661,116
write cell data to a html table using innerHTML
<p>having trouble putting together the final function displayLetter(a,b,c,d,e,f,g) and writing to table with innerHTML with array element and variables in variableTest() I know I need to use .length and to determine how many cells I need. W3C only gets me so far. Thanks for the help!</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt; &lt;/title&gt; &lt;script&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;TEST THIS SCRIPT&lt;/h1&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;th&gt;A&lt;/th&gt; &lt;th&gt;B&lt;/th&gt; &lt;th&gt;C&lt;/th&gt; &lt;th&gt;D&lt;/th&gt; &lt;th&gt;E&lt;/th&gt; &lt;th&gt;F&lt;/th&gt; &lt;th&gt;G&lt;/th&gt; &lt;/tr&gt; &lt;a href="add data" id="reload"&gt;Add Employee&lt;/a&gt; &lt;/body&gt; &lt;html&gt; </code></pre> <p>MY JS:</p> <pre><code> function addData() { var testarray = new Array(); testarray[0] = window.prompt("Enter a letter","z"); variableTest(x,y); displaySalary(a,b,c,d,e,f,g); } function variableTest(x,y) { a=1; b=2; c=3; d=4; e=5; } displayLetter(a,b,c,d,e,f,g) { } </code></pre>
javascript
[3]
3,269,310
3,269,311
3ds rendering problem
<p>I'm trying to load a 3ds file using TAO framework, and I finally found a 3ds loader that is written in C#. The loader works fine when I call the rendering Method after setting the matrix as GL_PROJECTION. But when I try to draw the object after setting GL_MODELVIEW matrix, it turns white .. and the colors can slightly appear in the shaded parts ..</p> <p>lighting is enabled .. and light posotion is set using glLightfv correctly</p> <p>I have searched for a ages .. but I found nothing :(</p> <p>could it be a problem with rendering the 3ds model itself ??</p>
c#
[0]
1,311,167
1,311,168
How do i change everything behind a certain point in a Jagged array?
<p>Say I have a jagged array, and position 2,3 is taken by int 3. Every other spot is filled with int 0. How would I fill all the positions behind 2,3 with a 4?</p> <pre><code>0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 </code></pre> <p>to this:</p> <pre><code>4 4 4 4 4 4 4 4 4 4 4 4 4 3 0 0 0 0 0 0 0 </code></pre> <p>Ive tried variations of this:</p> <pre><code>int a = 2; int b = 3; for (int x = 0; x &lt; a; x++) { for (int y = 0; y &lt; board.space[b].Length; y++) { board.space[x][y] = 4; } } </code></pre>
c#
[0]
5,448,180
5,448,181
Extending the DOM
<p>I've recently read that extending the DOM on the whole is bad, because of reasons listed <a href="http://www.nczonline.net/blog/2010/03/02/maintainable-javascript-dont-modify-objects-you-down-own/" rel="nofollow">here</a> and <a href="http://perfectionkills.com/whats-wrong-with-extending-the-dom/" rel="nofollow">here</a>. As I understand it, the main reasons against it are:</p> <ul> <li>It doesn't work very well/at all in IE </li> <li>It is possible to run into conflict, such as if a framework uses <code>Document.prototype.hide</code> and a browser then implements a <code>hide</code> function on document elements</li> <li>Browsers implement things in wildly different ways</li> </ul> <p>However, I haven't seen anyone ask these questions. </p> <ol> <li>If I wanted to extend the DOM, how would I do it safely? Besides the obvious use of a wrapper, how would I natively add a function, such as <code>hide</code> to the DOM as a whole, safely? </li> <li>If it's not possible to implement it safely, what are the specific reasons? Can I implement checks, such as checking <code>typeof Document.prototype.hide == 'undefined'</code> before implementing my own function on the prototype?</li> </ol> <p>In other words, explain to me how I can extend the DOM safely and what I could do to make sure that if a browser were to make the <code>hide</code> function, what I could do to not make my code have to be completely reworked. </p>
javascript
[3]
4,523,020
4,523,021
running a while loop on an interval
<p>I am building a game with a good emphasis on physics. Therefore I need the game to run on a very specific interval. Current code:</p> <pre><code>public double period = .02; //this is the run interval in seconds //main gameLoop public void gameLoop(){ long startTime; long sleep; while(running){ startTime = System.nanoTime(); Graphics2D g = s.getGraphics(); operateEntities(g); g.dispose(); s.update(); //figure out how long it must sleep to take .02s altogether sleep = ((int)(period*1000) - (System.nanoTime() - startTime)*100000); try{ if(sleep &gt; 0){ Thread.sleep(sleep); }else{ System.err.println("Warning: program runtime exceeded period"); } }catch(Exception ex){} gameTime += period; } } </code></pre> <p>This is not working as expected. Currently the main thread is executing without sleeping at all, and the "Warning: program runtime exceeded period" warning is firing.</p> <p>Previously I was using System.currentTimeMillis(), but it was not accurate enough for my purposes, so I switched to System.nanoTime()</p> <p>Increasing the period actually serves to speed up the program, while reducing it slows it down.</p> <p>Is there a simple logic faw? is my understanding of System.nanoTime() off? or is there a better way to run the methods operateEntities, dispose, and update on a specific interval?</p> <p>EDIT: for the record, the program does not take more than .02s to complete. It has been tested</p>
java
[1]
5,734,992
5,734,993
connect to the wifi point with 802.1xEAP
<p>I am trying to connect a wifi access point with security type 802.1xEAP. I know how can I connect a wifi point with WPA and WEP. However, I could not find the way how I can connect to the wifi point with 802.1xEAP. Can you help me how I can do ?</p>
android
[4]
2,534,520
2,534,521
"self" instead of traditional "this" keyword?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1079983/why-do-pythonistas-call-the-current-reference-self-and-not-this">Why do pythonistas call the current reference &ldquo;self&rdquo; and not &ldquo;this&rdquo;?</a> </p> </blockquote> <p>I am wondering why there is in Python the convention to use <code>self</code> in classes instead of the traditional <code>this</code> keyword. It is used in some other languages so why python came up with <code>self</code> keyword??</p>
python
[7]
4,054,184
4,054,185
Why should the interface for a Java class be prefered?
<p><a href="http://pmd.sourceforge.net/">PMD</a> would report a violation for:</p> <pre><code>ArrayList&lt;Object&gt; list = new ArrayList&lt;Object&gt;(); </code></pre> <p>The violation was "Avoid using implementation types like 'ArrayList'; use the interface instead".</p> <p>The following line would correct the violation:</p> <pre><code>List&lt;Object&gt; list = new ArrayList&lt;Object&gt;(); </code></pre> <p>Why should the latter with <code>List</code> be used instead of <code>ArrayList</code>?</p>
java
[1]
3,084,018
3,084,019
PHP Random M or F
<p>I would like to create a function to random between <code>M</code> or <code>F</code> characters. How could I create an function to do that?</p>
php
[2]
3,364,584
3,364,585
How do I calculate the visitors for the last 24 hours?
<p>I have the following code:</p> <pre><code>$ips = file_get_contents($_SERVER['DOCUMENT_ROOT']."/visitors.txt"); $arr = explode(",",$ips); $today = strtotime(date('Y-m-d H:i:s')); for ($n = 0, $max = count($arr); $n &lt;= $max; $n++) { $visArr = explode("#",$arr[$n]); $visDate = strtotime($visArr[1]); //$visArr[1] = 2011-12-27 14:10:45 if($visDate &lt; $today){ unset ($arr[$n]); //remove array item if its date not within 24 hours } } </code></pre> <p>The data is stored like this:</p> <pre><code>xxx.xxx.xxx.xxx#2011-12-27 11:56:24, xxx.xxx.xxx.xxx#2011-12-28 11:56:24, </code></pre> <p>I want to get the visitors from the last 24 hours.</p> <p>I don't want to use MySQL db, I just want to use the txt file but I'm stuck.</p> <p>Thanks in advance.</p>
php
[2]
1,551,474
1,551,475
How is cURL related to web services?
<p>well...just about all I needed to say...lookie here, I'm a total noob in web programming so go easy on me..and oh...if ever it is...could you point me to a simple example? i've worked wiht cURL on a payment API (Authorize.net) but I can't seem to get the picture of how it applies to web services</p>
php
[2]
1,441,259
1,441,260
retrieve image from data base and display it in grid view as a link
<p>I want to retrieve images from the database and display it in grid view as link. When I click on it, it should work as a link and go to another page. And I want the grid view itself to be three columns, all of them have images. Only that means that I want to display images in three columns in the grid view using asp.net.<br> Can anyone help me?</p>
asp.net
[9]
1,322,520
1,322,521
Wrapper objects and equality
<p>Why is it the case that if I run the .equals method on two wrapper objects it will return true as per the WrapperEqualsEquals Class below <strong>but</strong> (and I stress the but) why do we need to override the equals method in the Blob Class below in order for it to return true. Basically why do the wrapper objects get away with having to do an override of the .equals method?</p> <pre><code> class WrapperEqualsEquals { public static void main(String []args) { Integer one=new Integer(1); Integer oneB=new Integer(1); System.out.println(one == oneB); System.out.println(one.equals(oneB)); } </code></pre> <h1> }</h1> <pre><code> class OverrideEquals { public static void main (String [] args) { Blob a= new Blob(1,"a"); Blob b= new Blob(1,"a"); System.out.println(a==b); System.out.println(a.equals(b)); } </code></pre> <h1> }</h1> <pre><code> class Blob { int blobNumber; String blobText; Blob(int blobNumber,String blobText) { this.blobNumber=blobNumber; this.blobText=blobText; } //"overriding" the 'equals' method public boolean equals (Object o) { if (o instanceof Blob) { Blob o2=(Blob)o; return ((o2.blobNumber==this.blobNumber) &amp;&amp;(o2.blobText==this.blobText))? true:false; } else { return false; } } </code></pre> <p>}</p>
java
[1]
2,590,515
2,590,516
What is the purpose of Session Data?
<p>I have searched many questions regarding <code>session_destroy</code> and the often response from the answerers involve quoting directly from the <a href="http://us.php.net/session_destroy" rel="nofollow">PHP manual</a> which states the following:</p> <blockquote> <p>session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. To use the session variables again, session_start() has to be called.</p> <p>In order to kill the session altogether, like to log the user out, the session id must also be unset. If a cookie is used to propagate the session id (default behavior), then the session cookie must be deleted. setcookie() may be used for that.</p> </blockquote> <p>In a question asking "<a href="http://stackoverflow.com/questions/4303311/what-is-the-difference-between-session-unset-and-session-destroy-in-php">What is the difference between session_unset() and session_destroy() in PHP?</a>", the answerer mentions about <code>$_SESSION</code> variable and session storage but never go deep enough.</p> <p>I think a lot of confusion arising from the function <code>session_destroy</code> is due to the lack of understanding regarding session data and mixing it up with <code>$_SESSION</code> variable. I would like to know what is the actual purpose of session data if <code>$_SESSION</code> variable already contains that data?</p> <p>Thanks.</p>
php
[2]
355,044
355,045
What is the best way to do a reference to a function in PHP?
<p>Let's say I can call a method like this: <code>core::get()</code>. What is the best way to reference to this method? Everytime I call a function called <code>get</code> it should call <code>core::get()</code> and pass the same parameters.</p> <p>All I could come up with was this:</p> <pre><code>function get(){ call_user_func_array('core::get', func_get_args()); } </code></pre> <p>But it doesn't look very elegant if I compare it to the way I'd solve this in JavaScript:</p> <pre><code>var get = core.get; </code></pre> <p>I'm sure I missed something in PHP, so does anybody has a better solution for this?</p>
php
[2]
4,076,372
4,076,373
Difference between string.Empty and ""
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/263191/in-c-should-i-use-string-empty-or-string-empty-or">In C#, should I use string.Empty or String.Empty or &ldquo;&rdquo; ?</a> </p> </blockquote> <p>Is there any difference in c# between the following declarations...</p> <pre><code>private string m_port = string.Empty; </code></pre> <p>or...</p> <pre><code>private string m_port = ""; </code></pre> <p>Is it just coding standard that makes it look neater?</p>
c#
[0]
948,702
948,703
how to get a if else to operate based on the char i entered
<p>am trying to get an if else if statement to operate but am getting an error when using it please see the program below thanks</p> <pre><code>public class Info { public static void main(String [] args){ Scanner input=new Scanner(System.in); System.out.print("Enter employee num"); int e_num=input.nextInt(); System.out.print("Enter employee first name"); String e_fname=input.next(); System.out.print("Enter employee surname"); String e_sname=input.next(); System.out.print("Enter employee code C or c,H or h and F or f"); char e_code = input.next().charAt(0); if(e_code==F||e_code==f){ e_code==monthly_paid; } } } </code></pre>
java
[1]
3,908,311
3,908,312
Wrap three repeating div groups into one using jQuery
<p>I have another problem here. I have few repeating groups of divs. There is 3 divs with different classes in one group.</p> <p>What I need to do is wrap the into one 'container'. When I'm using wrapAll it wraps all into one div.</p> <p>And this is my html:</p> <pre><code>&lt;div class="bb_box_tl"&gt;&lt;/div&gt; &lt;div class="bb_box_l"&gt;&lt;/div&gt; &lt;div class="bb_box_lb"&gt;&lt;/div&gt; &lt;div class="bb_box_tl"&gt;&lt;/div&gt; &lt;div class="bb_box_l"&gt;&lt;/div&gt; &lt;div class="bb_box_lb"&gt;&lt;/div&gt; &lt;div class="bb_box_tl"&gt;&lt;/div&gt; &lt;div class="bb_box_l"&gt;&lt;/div&gt; &lt;div class="bb_box_lb"&gt;&lt;/div&gt; </code></pre> <p>This is all in one body.</p> <p>As I result i would like to have them look like this:</p> <pre><code>&lt;div class="box-cont"&gt; &lt;div class="bb_box_tl"&gt;&lt;/div&gt; &lt;div class="bb_box_l"&gt;&lt;/div&gt; &lt;div class="bb_box_lb"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="box-cont"&gt; &lt;div class="bb_box_tl"&gt;&lt;/div&gt; &lt;div class="bb_box_l"&gt;&lt;/div&gt; &lt;div class="bb_box_lb"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="box-cont"&gt; &lt;div class="bb_box_tl"&gt;&lt;/div&gt; &lt;div class="bb_box_l"&gt;&lt;/div&gt; &lt;div class="bb_box_lb"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>Thank you for your help in advance</p>
jquery
[5]
2,979,840
2,979,841
C++ method only visible when object cast to base class?
<p>It must be something specific in my code, which I can't post. But maybe someone can suggest possible causes.</p> <p>Basically I have:</p> <pre><code>class CParent { public: void doIt(int x); }; class CChild : public CParent { public: void doIt(int x,int y,int z); }; CChild *pChild = ... pChild-&gt;doIt(123); //FAILS compiler, no method found CParent *pParent = pChild; pParent-&gt;doIt(123); //works fine </code></pre> <p>How on earth?</p> <p>EDIT: people are talking about shadowing/hiding. But the two versions of doIt have different numbers of parameters. Surely that can't confuse the compiler, overloads in child class which can't possibly be confused with the parent class version? Can it?</p> <p>The compiler error I get is: <strong>error C2660: 'CChild::doIt' : function does not take 1 argument</strong></p>
c++
[6]
3,958,859
3,958,860
Is there a case for a String.IsNullOrEmpty operator?
<p><code>String.IsNullOrEmpty()</code> appears to be an extremely well used method and I find myself wishing there were some shorthand for it. Something like <code>???</code> as it would be used in a similar context to the null coalesce operator but be extended to test for empty as well as null strings. I.e.</p> <pre><code> string text = something.SomeText ??? "Not provided"; </code></pre> <p>What would be your opinions on this? Would it unnecessarily bloat the language? Would it open the floodgates for other mid-level operations to be granted such deep integration with the compiler? Or would it be a useful addition for the language.</p>
c#
[0]
5,341,326
5,341,327
How do I pass a jQuery value to a text box?
<p>I have a function <br></p> <pre><code>$(function(){ $("#divcalendarcolor a").click(function(){ var key = $(this).attr("key"); alert(key); //$('input:textbox').val(key); //$('input[id=RemainderColor').val($('#divcalendarcolor a').val()); }) }); </code></pre> <p>I want to pass the "key value" as the value to a text box. <br></p> <pre><code>&lt;div class="input text"&gt; &lt;label for="RemainderColor"&gt;Color&lt;/label&gt; &lt;input type="textbox" id="RemainderColor" value="" maxlength="20" name="data[Remainder][Color]"&gt; &lt;/div&gt; </code></pre> <p>Please help...</p>
jquery
[5]
3,686,460
3,686,461
Function calls and arrays in PHP
<p>Question 1: What is meaning of <code>expr</code> in the following code?</p> <pre><code> public function getProblem($id) { DB::update($this-&gt;_table_name) -&gt;set(array('views' =&gt; DB::expr('views + 1'))) -&gt;where('id', '=', $id) -&gt;execute(); $res = DB::select("*")-&gt;from($this-&gt;_table_name)-&gt;where('id', '=', $id)-&gt;execute()-&gt;as_array(); return $res[0]; } /** *in another class */ public static function expr($string) { return new Database_Expression($string); } </code></pre> <p>Question 2: What is <code>res</code> doing, and why just <code>res[0]</code>?</p>
php
[2]
2,583,307
2,583,308
relative mouse coordinates in a DIV - javascript
<p>I'm moving the mouse over a div and I want to know the mouse coordinates with respect to the div origin. (upper left corner)</p> <p>I expected the mousemove event to contain the relative (client?) coordinates of the mouse, but apparently it doesn't.</p> <p>In firefox for instance, none of the event properties* contain relative coordinates</p> <p>Am I missing something? </p> <p>*clientX,Y - pageX,Y - screenX, y</p>
javascript
[3]
5,843,733
5,843,734
problem in improving two galleries
<p><strong>Here is my code:</strong> </p> <pre><code> gallery = (Gallery) findViewById(R.id.gallery1); gallery = (Gallery)findViewById(R.id.gallery2); imgView = (ImageView)findViewById(R.id.ImageView01); imgView.setImageResource(Imgid[0]); final ArrayList&lt;searchResults&gt; searchResults = GetsearchResults(); tv = (TextView)findViewById(R.id.name); tv1 = (TextView)findViewById(R.id.citystate); gallery.setAdapter(new Adapter(this, searchResults)); gallery1.setAdapter(new AddImgAdp(this)); </code></pre>
android
[4]
1,196,753
1,196,754
Replacing all occurrences of a string in javascript?
<p>Say I have this string:</p> <pre><code>Test abc test test abc test test test abc test test abc </code></pre> <p>Doing</p> <pre><code>str=str.replace('abc',''); </code></pre> <p>Seems only to remove the first occurrence of <code>abc</code> in the string above. How can I replace ALL occurrences of it?</p>
javascript
[3]
5,075,240
5,075,241
jQuery BLUR - determine what the ID of the clicked item that triggered the blur is?
<p>Given a live('blur', function(e) {} how can you get the attr('id') of the clicked item that triggered the blur?</p>
jquery
[5]
5,327,699
5,327,700
Put a picture(logo) in UITableView in the bottom of a scrollable View which won`t be scrollable
<p>As the title says im searching for an solution for my problem.</p> <p>I tried everything, with the footer section even i tried to put an non funtional Button in the Footer of the UITableView.</p> <p>But it scolls up and down if there are not so many items to show.</p> <p>How can I put an Image in the buttom which won´t move?</p> <p>I have s</p>
iphone
[8]
6,015,014
6,015,015
How to check which side of an element has more room, display a div on that side, Lea Verou "animatable" example page
<p><a href="http://leaverou.github.com/animatable/" rel="nofollow">http://leaverou.github.com/animatable/</a></p> <p>On this page, click a block and see the black box that appears. The black box will appear on either the left or the right of the numbered blocks, depending on which side of the block has more room. You can resize your browser window and the blocks will re-arrange so there's only enough blocks on each line that will fit in the screen. So even when you re-size your browser window, the black box will still look to see which side of the block(that you clicked) has more room, and it will appear on that side.</p> <p>I'm assuming this is done with jQuery, could someone describe the technique she used to do this? I couldn't really find and understand it from looking at her code. I would like to learn the technique to do this, so a description of how to do this would be fine, an example even better. Thanks! </p>
jquery
[5]
5,981,663
5,981,664
iphone force portrait mode from landscape?
<p>I have a complicated structure where I have a custom tab-bar controller that houses multiple navigation controllers. Some of these sub-navigation controllers only support portrait mode so I just turn off rotation when I get to them. When I come into the new navigation controller and it is in landscape is there a way to force auto-rotation to portrait at that time?</p>
iphone
[8]
5,203,303
5,203,304
what is the difference of thread.sleep and systemclock.sleep. and which one should be used in AsyncTask?
<p>I figured out if I exit an activity while is running the AsyncTask in the middle, and when I try to start that activity again, I will have to wait until the previous AsyncTask to finish before the new AsynTask starts. I tried both thread.sleep and systemclock.sleep and it gives me the same result. Which make sense because I guess the thread that I closed and opened are the same. Its there a way to just cancel the AsyncTask if the user exit an activity? Because then the second time the user enter the same activity he wouldn't have to wait until previous finishes. I tried asyntask.cancel(true) in onPause(), it doesn't work, same thing happened.</p>
android
[4]
3,918,423
3,918,424
Getting and using values obtained from multiple text boxes via JQuery
<p>I'm trying to get the values from multiple textboxes using JQuery.</p> <p>I'm a bit of a newbie with Javascript in general. I have a form with the following input element: </p> <pre><code>&lt;input name="milkman" value="jessie"/&gt; &lt;input name="letterman2" value="jim" /&gt; &lt;input name="newmilk" /&gt; </code></pre> <p>I get the values of the first two input elements using:</p> <pre><code>var test_arr = $("input[name*='man']").val(); </code></pre> <p>How do I get at the individual textbox values? When I use the alert() function to echo the value of <code>test_arr</code>, all I see is the first element's value.</p> <p>Kindly assist. </p>
jquery
[5]
2,402,138
2,402,139
postback in asp doesn't refresh control value
<p>I have a div(runat=server) that contain repeater,this repeater is getting is value from datatable</p> <p>when the datatable is empty I do this line of code in asp .net function</p> <pre><code>divname.innerHTML="&lt;img src="...&gt;" </code></pre> <p>on this page there is also a asp:button that fill the datatable with values. when pressing the button ,the above line isn't excute,the page offcourse is doing postback, but the div content isn't changing back to his original value(the repeater).</p> <p>What do I have to do in the postback in order to force the div to get his original values?</p> <p>This is code example:</p> <pre><code> sub page_load(.. if ispostback=false then run_div() end if end sub sub run_div() if datatable.Rows.Count=0 then divname.innerHTML="&lt;img src="...&gt;" end if end sub sub filldata(.... fill datatable repeater.datasource=... repeater.databind run_div() end sub html look like this &lt;div runat=servver id=divname&gt;&lt;asp:repeater&gt;..... &lt;asp:button onclick="filldata"&gt; </code></pre> <p>Thanks for any help</p>
asp.net
[9]
998,700
998,701
how to have multiple headers for different users of wishlist members (three different)
<p>I’ve a created wordpress membership site using wishlist member plugin. But I want to have different header.php based on different logins.</p> <p>Eg: Users are: Print, Web and Free</p> <pre><code>When Free user logs in – I want header1.php to load and stay till he logs out When Print user logs in – I want header2.php to load and stay till he logs out When Web user logs in – I want header3.php to load and stay till he logs out </code></pre> <p>If nobody has logged in the default header.php stays.</p> <p>Please assist on how to do this.</p> <p>Regards, Raghav.</p>
php
[2]
5,442,195
5,442,196
spinner and onItemSelected
<p>If I have 2 spinner depended with type ArrayList></p> <pre><code> spinner2.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView&lt;?&gt; adapterView, View view, int position, long id) { ArrayList&lt;HashMap&lt;String, String&gt;&gt; arrList = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;(); for (HashMap&lt;String, String&gt; map2 : arrList) { String value = map2.get("SectionID"); // Do something Context context = getApplicationContext(); int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, value, duration); toast.show(); Log.d("wwwwwwwwwwwwwwwwwwww: ", value); // Do something } } @Override public void onNothingSelected(AdapterView&lt;?&gt; adapter) { } }); </code></pre> <p>i do like this but kothing happend and logcat not having error</p>
android
[4]
2,260,985
2,260,986
Scrolling to a specific position
<p>I currently have a map for the game I run, the map is already <a href="http://woarl.com/map/turn_26_normal.html" rel="nofollow">quite big</a> and I'd like to make it possible to scroll to a position with Javascript. I have jQuery in use should that be helpful.</p> <p>Thanks</p>
javascript
[3]
4,029,559
4,029,560
Dynamically insert script and execute immediately
<p>I'm building a webservice that automatically combines and minifies a website's javascript. The web owner would just include the following js snippet in the website head, and it creates the minified file and appends it to the head element.</p> <p>The issue I'm seeing is that when a script is dynamically appended it is not necessarily executed before the rest of the body. Since many sites may expect the head scripts to execute before the body is generated, this is an issue. </p> <p>Is there any way I can force the dynamically appended script to execute before anything else? Maybe there is a workaround, like removing the entire body and reinserting it after the appending script loads.. although that seems pretty hacky.</p> <pre><code>&lt;script type="text/javascript"&gt; var minify_files = new Array( 'domain.com/js/one.js', 'domain.com/js/two.js', 'domain.com/js/three.js' ); &lt;/script&gt; &lt;script type="text/javascript" src="minifyservice.com/minify.js"&gt;&lt;/script&gt; </code></pre>
javascript
[3]
4,605,843
4,605,844
characters display of a text file in java
<p>I have a text file which contains a line as a,b,a,b,a,b and I want to display the line as b,b,b,a,a,a </p> <p>any assistance would be appreciated</p>
java
[1]
5,571,967
5,571,968
how to set the background color of selected row in a custom list?
<p>i am trying to change the background color of the selected row in a listview and i am able to do it. But when i am clicking on another row then the background color of the previously selectedrow remains unchanged. I have the position of the previously selected row, Can anybody help me that how can change the background color of previously selected row as it was before??</p>
android
[4]
324,678
324,679
Switch color of title bar programmatically?
<p>I have gone through <a href="http://stackoverflow.com/a/2285722/599116">this</a> to change the color of my title bar. I'm trying to figure out how I would switch that programmatically? Say if a user clicks a button, I want to switch to another predefined color. How might I do that?</p>
android
[4]
1,916,107
1,916,108
Android Karaoke Text?
<p>I have been scratching my head for the past week to do this effect on the text. <a href="http://www.youtube.com/watch?v=gB2PL33DMFs&amp;feature=related" rel="nofollow">http://www.youtube.com/watch?v=gB2PL33DMFs&amp;feature=related</a> Would be great if someone can give me some tips or guidance or tutorial on how to do this.</p> <p>thankz for reading and answering =D</p>
android
[4]
4,872,211
4,872,212
Better way to get where a request actually came from
<p>I am aware that <code>$_SERVER[REFERRER]</code> can be used to detect where a request comes from however it turned out that it can be fooled or even a browser might not send it as part of the request.</p> <p>Could anyone suggest a better way to detect or rather allow requests from own domain only to avoid spoofing, DoS, etc security attacks?</p>
php
[2]
5,824,474
5,824,475
How to connect android market in an application?
<p>I m developing android apps.</p> <p>I have to connect android market in my application.</p> <p>So ,kindly suggest me how to connect android market.</p> <p>Thanks in adv.</p>
android
[4]
5,308,603
5,308,604
C++ include header problem
<p>I am new to c/c++, I am confused about followings:</p> <ol> <li>Whether I should put class declarations in its own header file, and actual implementation in another file?</li> <li>Whether I should put headers like <code>&lt;iostream&gt;</code> in the example.h file or in example.cpp file?</li> <li>If all the classes need to use <code>&lt;iostream&gt;</code>, and I include a class's header file into another class's header, does it mean I included <code>&lt;iostream&gt;</code> twice?</li> <li>If I use a lot STL classes, what is a good practice to use <code>std::</code>?</li> </ol>
c++
[6]
5,420,433
5,420,434
using dbus on Android
<p>I would like to know if it is possible to use DBUS on Android using Java. From what I have been searching till now it appears like there is no DBUS programming support on Android. But then bluetooth on Android uses DBUS. I would like to confirm if it is actually the case. If so, is there a possibility that DBUS would be supported in the future.</p>
android
[4]
3,165,589
3,165,590
Python - Is there a way around 'os.listdir()' returning gibberish for bad folder name?
<p>I have a simple script written in Python:</p> <pre><code>import os def Path(SourcePath): for Folder in os.listdir(SourcePath): print "TESTING: %s" % Folder Path("\\\\192.168.0.36\\PDFs") </code></pre> <p>When i run this it recurses through a remote share on the LAN and just simply displays the names of the folders found. This share primarily contains folders.</p> <p>The problem is that if a folder name has a space at the end of it's name, the above script lists jibberish.</p> <p>For example, if i have the following folders in the above share:</p> <ol> <li>"6008386 HH - Walkers Crisps"</li> <li>"6008157 CPP - Santas Chocolate "</li> <li>"6007458 SCA - Morrisons Bananas"</li> </ol> <p>Notice that "6008157 CPP - Santas Chocolate " has a space at the end. This is the listing from the above script:</p> <ol> <li>"TESTING: 6008386 HH - Walkers Crisps"</li> <li>"TESTING: 6EBA72~1"</li> <li>"TESTING: 6007458 SCA - Morrisons Bananas"</li> </ol> <p>How can i avoid this while recursing the remote dir? I could fix the folder name if only it was returned properly by 'os.listdir()'.</p> <p>Any ideas on how to tackle this?</p>
python
[7]
785,050
785,051
PHP tag closing-- when is needed?
<p><a href="http://framework.zend.com/manual/en/coding-standard.php-file-formatting.html" rel="nofollow">It's recommended</a> that one should not put a PHP closing tag at the end of the file to avoid all sorts of untoward error. But is there any circumstances when PHP tag closing is needed?</p>
php
[2]
5,896,710
5,896,711
how can I change en.jscript file to farsi.jscript?
<p>I use processmaker software and I want change english language to persian.</p>
javascript
[3]