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
518,656
518,657
little jquery calculation
<p>I need some simple calculations done using jquery.</p> <p>This example <a href="http://jsfiddle.net/tbL5r/" rel="nofollow">http://jsfiddle.net/tbL5r/</a> is pretty close. It just needs a little tweaking:</p> <ol> <li><p>the user should input the price.</p></li> <li><p>I need the sum of the all prices calculated.</p></li> <li><p>It should calculate without clicking buttons.</p></li> </ol> <p>Cheers and Thanks</p>
jquery
[5]
2,258,581
2,258,582
how to import a project's package into an android project?
<p>how can we import a project's package into an android project?</p>
android
[4]
3,639,930
3,639,931
php for "high-traffic" websites
<p>I have read that PHPs "probable" weakness is how it handles "concurrency". With only sessions and cookies to keep track of user state, how can PHP handle the following situations with high accuracy:</p> <ol> <li><p>multiple users check out with one item that has only 1 stock in inventory (sorry for grammar mistakes, but you pretty much get the picture already)</p></li> <li><p>multiple users logging into the same user account using the same login details</p></li> <li><p>multiple users editing an the same image at the same time (though this rarely happens in real life)</p></li> </ol> <p>or any other transactions that demands multiple thread handling</p> <p>(I apologize if I misused terms here)</p>
php
[2]
175,014
175,015
Jquery Insert HTML
<p>I'm using: <a href="http://jquery.malsup.com/form/#getting-started" rel="nofollow">http://jquery.malsup.com/form/#getting-started</a> to submit my form, Ajax styleee.</p> <p>However the form submits correctly and the data is sent however the fields on the form continue to have data in them. How can I clear them on submit? Hiding the form and displaying thank you would also be acceptable?</p> <pre><code>$(document).ready(function() { $('#pollform').ajaxForm(function() { $('#pollform').hide(); }); }); </code></pre>
jquery
[5]
3,463,917
3,463,918
Find real url of masked image in php?
<p>If theres n image hidden like this:</p> <pre><code>?ID=578 </code></pre> <p>insteadof its real url, is there a way to find out?</p> <p>I tried looking at the web console to see if its downloaded but i only found the php request.. url is nowhere , help me please</p>
php
[2]
5,193,498
5,193,499
Search a string for newlines within a string just containing "\n"
<p>I have a really annoying issue that I can't fix :(</p> <pre><code>private static final String NEW_LINE = System.getProperty("line.separator"); text = "\n"; int count = text.split(NEW_LINE).length; </code></pre> <p><code>count</code> keeps returning 0 when it should return 1 I think its because <code>\n</code> isnt actually a string but a newline.</p> <p>Is there a way to fix this?</p>
java
[1]
4,613,668
4,613,669
How to find out a^b of very large numbers in python?
<p>I am trying to find out <code>a^b</code> in python, of really large no.s </p> <p>My code is this:</p> <pre><code>t=raw_input() c=[] for j in range(0,int(t)): n=raw_input() a=[] a,b= (int(i) for i in n.split(' ')) c.extend(pow(a,b)) for j in c: print j </code></pre> <p>And I am getting an error like this:</p> <pre><code>raceback (most recent call last): File "C:/Python26/lastdig.py", line 7, in &lt;module&gt; c.extend(pow(a,b)) TypeError: 'int' object is not iterable </code></pre> <p>Whats wrong in my prob and is it an efficent way to find out powers of large numbers?</p>
python
[7]
3,597,654
3,597,655
MPMusicPlayerController doesn't respect device mute switch?
<p>I'm using the MPMusicPlayerController application music player, created like:</p> <pre><code>appMusicPlayer = [MPMusicPlayerController applicationMusicPlayer]; </code></pre> <p>The issue is that it will play music no matter which setting the device mute switch is in, it doesn't seem to care either way. Is there some audio session mode I need to be in to have it respect the mute switch?</p>
iphone
[8]
3,925,179
3,925,180
Is there any way to optimise this code?
<p>I have a piece of code which will invert all the checkboxes on my form. I have multiple elements (not just checkboxes but also <code>&lt;input type='text'&gt;</code>'s) in it. The reason I need it to be optimised is because it takes about two to three seconds to select all the checkboxes (275 right now).</p> <p>Here's my code:</p> <pre><code>function FormInverse() { var iCheckbox = 1; // Because there are multiple input elements, we need to distinquish the input element ID and the row id var FormLength = document.FormFacturen.elements.length; for (i=0; i &lt; FormLength; i++) { var FormElementType = document.FormFacturen.elements[i].type; if (FormElementType == "checkbox") { var Elements = document.getElementsByClassName('row' + iCheckbox); // Alle elementen in de array zetten var iNumElements = Elements.length; for (iElement=0; iElement &lt; iNumElements; iElement++) { if (document.FormFacturen[i].checked == true) { Elements[iElement].className = "invoice-tr-standard row" + iCheckbox; } else { Elements[iElement].className = "invoice-tr-clicked row" + iCheckbox; } } iCheckbox++; document.FormFacturen[i].checked = !document.FormFacturen[i].checked; } } } </code></pre> <p>And here is the <code>document.getElementsByClassName</code> function:</p> <pre><code>document.getElementsByClassName = function(cl) { var retnode = []; var myclass = new RegExp('\\b'+cl+'\\b'); var elem = document.getElementsByTagName('*'); for (var i = 0; i &lt; elem.length; i++) { var classes = elem[i].className; if (myclass.test(classes)) retnode.push(elem[i]); } return retnode; }; </code></pre>
javascript
[3]
2,636,879
2,636,880
Should I dispose of an object such as Hashtable or a string by setting it to null?
<p>I have a Hash table that takes strings. What is the best way to dispose them ? After using the hash table, should I call clear and then set the object to null ? Or would just setting the hash table object to null suffice ? </p>
c#
[0]
464,616
464,617
how to detect when a shortcut key is pressed in javascript
<p>How can i detect a shortcut key, [ in my case [ ctrl + shift + k ] ] in javascript? Like, i have to show a dialog if user presses this key.</p>
javascript
[3]
1,864,923
1,864,924
jQuery - parseJSON not a function?
<p>I'm using Wordpress 3 and jQuery 1.4.2. Firebug tells me $.parseJSON is not a function and I'm stumped as to why. </p> <p>Any suggestions are appreciated.</p> <pre><code>$(document).ready(function(){ $('#subscribe_form_submit').click(function(){ function updatePage(theResponse, textStatus, XMLHttpRequest){ theResponse = $.parseJSON(theResponse); console.log(theResponse); if(theResponse == "OK!"){ $('#subscribe').fadeOut('fast', function(){ $('#subscribe').html("&lt;br /&gt;&lt;h3 style=\"text-align:center;border:1px solid #fff;background-color:#d3eefe;padding:8px;\"&gt;Thanks!&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;"); $('#subscribe').fadeIn('slow'); }); } else{ theResponse = $.parseJSON(theResponse); console.log(theResponse); } } var theData = $('#subscribe').serialize(); $.ajax({ type: 'GET', url: 'http://www.foo.com/wp-content/themes/thesis_17/custom/subscribe.php?' + theData, dataType: 'json', success: updatePage(), error: function(xhr, textStatus, errorThrown){ console.log((errorThrown ? errorThrown : xhr.status)); } }) }); </code></pre> <p>});</p>
jquery
[5]
5,009,133
5,009,134
How to root android device, Emulator?
<p>I'm making an application in android. In which I want to show Punjabi text in my view, most people told me we can add different fonts through rooting. After that I'm able to show Punjabi text in device. Can you tell me how I can root my emulator or android device so I can show Punjabi font in my application.</p> <p>Thanks in advance</p>
android
[4]
2,740,659
2,740,660
Error: 'template<class T> class Two' used without template parameters
<p>Hey so I'm trying to compile:</p> <pre><code>//ASSIGNMENT #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; template &lt;class T&gt; class Two { private: T x,y; public: Two (T a, T b); friend void Show (Two p); ~Two(); }; //ASSIGNMENT template &lt;class T&gt; Two::Two (T a, T b){ x = a; y = b; } friend void Two::Show(Two p){ cout &lt;&lt; p.x &lt;&lt; " and " &lt;&lt; p.y &lt;&lt; endl; } int main () { Two&lt;int&gt; class2(2,3); Show(class2); } </code></pre> <p>The assignment was to define the members of the class (in the //ASSIGNMENT tags). I don't know why it won't compile... Thanks!</p>
c++
[6]
1,014,816
1,014,817
How to search the children of a HTMLDivElement?
<p>I have an HTMLDivElement, and my goal is to find a div nested beneath this. Ideally, I'd want something like getElementById, but that function doesn't work for HTMLDivElement. Do I need to manually traverse the graph, or is there an easier way?</p> <p>Thanks</p>
javascript
[3]
2,454,024
2,454,025
How can I get one variable to equal 0 by using another variable to define that variable?
<p>In Java, suppose I have two variables, <code>x1</code> and <code>xName</code>.</p> <p>How can I get <code>x1</code> to equal 0 by using <code>xName</code>?</p> <p><code>xName</code>'s value is <code>"x1"</code>. How can I change <code>x1</code>'s value with <code>xName</code>?</p> <p>I have my reasons for not just changing x1 to 0.</p> <p>edit: To clarify, I want to use xName to define x1. if x1 = 1 initially. I want to do this basically xName = 0. and x1 becomes 0 because xName's value is "x1". I've never come across it before so I'm just wondering if this was possible.</p>
java
[1]
4,250,874
4,250,875
How can i sort the dictionary using keys in c#---Is it possible using LINQ?
<pre><code> Dictionary&lt;string,string&gt; l_dictData = new Dictionary&lt;string,string&gt; </code></pre> <p>the above dictionary contains data like this:</p> <pre><code> (1)key = "4" value"122" (2)key = "8" value"1772" (3)key = "0" value"166" </code></pre> <p>Required output:</p> <pre><code> (1)key = "0" value"166" (2)key = "4" value"122" (3)key = "8" value"1772" </code></pre>
c#
[0]
20,033
20,034
extend SplFileObject with fread method
<p>PHP5 introduced an object-oriented file wrapper, <strong>SplFileObject</strong>. I guess I just found out why hardly anybody is using it. It's purely line-oriented, there is no fread() method - which the corresponding frwite seemed to suggest.</p> <p>So now I'm wondering if I can extend it. I'm however not sure what's the better workaround. SplFileObject is not particular helpful in tucking the file pointer ($fp) away - it's either a private attribute or ZE-internal resource. So how would I extend it to get a fread method?</p> <ul> <li>Implement fread() as string collecting <strong>loop with fgets()</strong>, with eventual seeking if only a specific size was requested and fgets read too far until the next \n line break.</li> <li>Use a custom constructor, which opens the file a second time and stores a <strong>secondary file pointer</strong>, in case I want to call fread() instead of the parent class methods.</li> </ul> <p>I'd go for the fgets workaround loop, but it sounds cumbersome and slow and provides for more potential pitfalls. OTOH opening a secondary file pointer seems not a good approach either and needs a custom destructor too.</p>
php
[2]
781,170
781,171
jQuery that works inside of a function ... but not outside?
<p>In the following jQuery code:</p> <pre><code> $(document).ready(function(){ function parse(document){ $(document).find("entry").each(function(){ $("#items").append( '&lt;h3&gt;&lt;a href="#"&gt;'+$(this).find('title').text()+'&lt;/a&gt;&lt;/h3&gt;'+ '&lt;div&gt; '+$(this).find('summary').text()+'&lt;/div&gt;' ); $('#items &gt; div').hide(); }); } $.ajax({ type: "GET", url: 'www.---.com', // name of file you want to parse dataType: "xml", success: parse, error: function(){alert("Error: Something went wrong");} }); //ANIMATION $('#items h3').click(function(){ $(this).next().animate({'height':'toggle'}, 'slow', 'easeOutBounce'); }); $('#footer').click(function(){alert("Why does this work, but not the bouncing panels?")}); }); </code></pre> <p>The section marked //ANIMATION works when I place it inside the parse() function, but is very flaky. When placed outside of it, as above, it will not run at all.</p> <p>Why? I'm really banging my head on the wall trying to understand why it won't run.</p>
jquery
[5]
4,140,604
4,140,605
how will this cout statement run
<pre><code>int a[10][5]; for (int i = 0; i &lt; 10; i++) { for (int j = 0; j &lt; 10; j++) { cout &lt;&lt; i[j[a]]; cout &lt;&lt; j[i[a]]; } } </code></pre> <p><em>Edit</em>:assume the values are already initialized to the array and is this cout valid then? </p> <p>please explain the <code>i[j[a]];</code> part only regardless of the program I'm concerned about that statement only!</p>
c++
[6]
5,327,549
5,327,550
How can I tell if a certain key was pressed in Python?
<pre><code>import sys print (sys.platform) print (2 ** 100) input('press Enter to exit') </code></pre> <p>Suppose I wanted to use the number 1 as the button that must be pressed to exit. How would I go about doing this?</p>
python
[7]
227,394
227,395
How to use jQuery mouseover from an array?
<p>I have a sample code:</p> <pre><code>&lt;a href=""&gt;&lt;/a&gt; &lt;textarea&gt;&lt;/textarea&gt; &lt;object&gt;&lt;/object&gt; &lt;img src="" /&gt; &lt;div id="content"&gt;&lt;/div&gt; </code></pre> <p>I had using this:</p> <pre><code>jQuery("a").mouseover(function() { alert(); }); jQuery("textarea").mouseover(function() { alert(); }); jQuery("object").mouseover(function() { alert(); }); jQuery("img").mouseover(function() { alert(); }); jQuery("#content").mouseover(function() { alert(); }); </code></pre> <p>Can I using this ?</p> <pre><code>var object = ["a","textarea","object","img", "content"]; jQuery.each(object, function() { jQuery(this).mouseover(function(){ alert(); }); }); </code></pre> <p>How to ideas using jQuery mouseover from an array ? </p>
jquery
[5]
934,593
934,594
now() returns wrong value when date() and server time are correct
<p><code>now();</code> = 1319959284</p> <p><code>date("Y/m/d");</code> = 2011/10/30</p> <p>if I run <code>date</code> on my server, the time is spot on</p> <p><strong>edit 3</strong> I'm an idiot</p> <p><strong>edit 2</strong> I am thinking that the UNIX timestamp is not the same as the MYSQL timestamp</p> <p><strong>Edit 1</strong>: I have only thought that to be wrong because when I try to insert this into a TIMESTAMP field in MYSQL, no digits are entered. </p> <p>If I insert a number such as 20050224124736, it seems to be valid. </p> <p>Screenshot of <a href="http://i.imgur.com/Ce3pB.png" rel="nofollow">PHPMYADMIN</a></p> <p><a href="http://i.imgur.com/h33Uz.png" rel="nofollow">another screen</a></p>
php
[2]
2,957,886
2,957,887
How to fetch a select tag value from child page javascript?
<p>I have a parent page where a select tag is there. It has a number of options. Now the user can select one of the options.</p> <p>But the problem is the select tag doesnt have an id instead it has a name which is generated in runtime.</p> <p>Now i want to fetch the selected value from child page javascript. Can anyone please provide me the pointers for this?</p>
javascript
[3]
5,417,188
5,417,189
Ordered function defenitions | Benefits
<p>Jslint will call out errors if functions are defined out of order.</p> <p>Obviously jslint is strict, but I wonder if there are any benefits to putting functions in order. </p> <p>By that I mean defining them before they are called.</p>
javascript
[3]
5,584,079
5,584,080
Why am I getting null when trying to retrieve a value from a ContentValues object?
<p>I am getting a NullPointerException when trying to retrieve/insert values from a ContentValues object that I'm a passing to my database method. I have several columns in my db table and instead of passing all those as params to the method, I'm trying to simplify it a little bit.</p> <p>Here's a sample of the code:</p> <pre><code>public class MyActivity extends Activity { private Calendar calendar = Calendar.getInstance(); // other methods in here.... public void onClick( View v ) { int year = calendar.get( Calendar.YEAR ); int month = calendar.get( Calendar.MONTH ); int date = calendar.get( Calendar.DAY_OF_WEEK ); int weekOfYear = calendar.get( Calendar.WEEK_OF_YEAR ); ContentValues values = new ContentValues(); values.put( YEAR, year ); values.put( MONTH, month ); values.put( DATE, date ); values.put( WEEK_OF_YEAR, weekOfYear ); if( everythingIsGood ) { // the problem starts after this. mDb.addToDatabase( values ); } } </code></pre> <p>Here's the database method:</p> <pre><code>public class Database { // other methods.... public long addToDatabase( ContentValues values ) { // I'm getting a NullPointerException right here, trying to retrieve // a value from this ContentValues object int weekOfYear = values.getAsInteger( WEEK_OF_YEAR ); values.remove( WEEK_OF_YEAR ); // do other stuff long pId = this.getParentId( weekOfYear ); // And, if I take the above out, right here values.put( PARENT_ID, pId ); mDb.insert( table_name, null, values ); } } </code></pre> <p>So, am I not allowed to manipulate the ContentValues object? Is this bad practice, should I just pass all those variables to the method?</p> <p>Note: I know for a fact that the values are not null.</p> <p>Thanks in advance.</p>
android
[4]
2,730,996
2,730,997
Starting video capture on one click in android
<p>I want to start camera and also to automatically start recording just by clicking an app in android. I have the code to start the camera but I do not know how to start auto capture of the video. Please help. the code I have for launching camera- </p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_c1_main); Intent intent = new Intent("android.media.action.VIDEO_CAPTURE"); StartActivityForResult(intent,CAPTURE_VIDEO_ACTIVITY); } </code></pre> <p>I found about view.performclick but do not know how to use for camera</p>
android
[4]
2,940,176
2,940,177
Define a temporary dir under www to upload files
<p>I'm trying to upload a file to the apache public_html directory. Well I believe it deserves to mention that I'm on a virtual hosting environment running on a VPS with a few domains and sub-domains.</p> <p>Usually on my XAMPP server I wouldn't have any problems loading files to temporary folder but on the new server It's impossible it gives me an error when trying to upload.</p> <p>I've checked the superglobal $_FILES and I get this error:</p> <pre><code>array(1) { ["file"]=&gt; array(5) { ["name"]=&gt; string(9) "test.gif" ["type"]=&gt; string(0) "" ["tmp_name"]=&gt; string(0) "" ["error"]=&gt; int(1) ["size"]=&gt; int(0) } } </code></pre> <p>I've tried to set a tmp folder on the server with get_init('/tmp') without any success.</p> <p>Thank you very much for your kind attention.</p>
php
[2]
4,835,210
4,835,211
can't go back button
<p>I have a problem with my Android app. I have three Activities that all connect with one another with a Image button. </p> <p>My problem is I can't go back on any of the pages, just forwards. I have been reading about the back button and how to keep its state and not kill (End) it, so the user can click back if needed too. </p> <p>I am new to Android and I know there's a lot to learn. So thank you for your help.</p> <p>Java code for first Activity:</p> <pre><code>package my.hope; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.ImageView; import android.content.Intent; public class NewhopeActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView myImage = (ImageView) findViewById(R.id.imagebutton1); myImage.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub Intent intent = new Intent(NewhopeActivity.this, Act2.class); startActivity(intent); } }); } </code></pre> <p>}</p> <p>XML code:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/mint"&gt; &lt;ImageButton android:id="@+id/imagebutton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="250dp" android:background="@drawable/ic_launcher" android:onClick="Act2" android:src="@drawable/ic_launcher" /&gt; &lt;/LinearLayout&gt; </code></pre>
android
[4]
5,022,453
5,022,454
Display image intent rebuilds cache
<p>When I create an intent and pass it a URI of the path of the image on the <a href="http://en.wikipedia.org/wiki/Secure_Digital" rel="nofollow">SD card</a>, like this:</p> <pre><code>Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(uri, "image/*"); startActivity(intent); </code></pre> <p>The image displays after about 15 seconds, because the image viewer has to rebuild its image cache. It says in the debugger </p> <blockquote> <p>Unable to read the index file sdcard/Android/data/com.cooliris.media/cache/picasa-thumbsindex.</p> </blockquote> <p>I'm 99% sure this is a permissions issue, it cannot access its cache file. How do I fix this?</p>
android
[4]
1,176,792
1,176,793
Option to create new contact from pick list
<p>My application wants a functionality of picking a contact from the phone contact, I have achieved this using the following intent </p> <pre><code>Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI); startActivityForResult(intent, 001); </code></pre> <p>How do i start pick contact activity with an option to create a new contact from the pick list, similar to the one which is available in inbuilt Launcher appliation </p>
android
[4]
2,223,945
2,223,946
gwt in netbeans
<p>can i install GWT in netbeans?</p>
java
[1]
848,845
848,846
How to display session values in php
<p>I used session as a array and stored user selected values in that session array. I want to check particular value present in that session array, if user selected value present present in that session ignore it otherwise add in that session array.</p>
php
[2]
5,770,695
5,770,696
does onCreate fire any listener - android
<p>I am creating a android library, In that I want to find if the OnCreate of the main application is running? . I dont know whether oncreate fire any listener. Anybody knows will oncreate fires any listener. Any ideas? Thanks.</p>
android
[4]
4,797,068
4,797,069
Javascript Conflict ajax mail and scriptaculous
<p>I've added a javascript element I found in a guide. It is as follows</p> <pre><code>$(document).ready(function () { $('.dropdownbutton').click(function () { $.post("send.php", $(".mycontactform").serialize(), function (data) { }); $('#success').html('Message sent!'); $('#success').hide(2000); }); }); </code></pre> <p>The existing javascript was</p> <pre><code> function toggleDisplayWait(divId, imgId, durationmSec) { if(!$(divId).visible()) { move = Effect.BlindDown; newImage = "./img/minus.png"; } else { move = Effect.BlindUp; newImage = "./img/plus.png"; } move(divId, {duration: durationmSec / 1000.0 }); setTimeout(function() { $(imgId).src = newImage; }, durationmSec) } function BDEffect(divId, imgId) { /* new Effect.BlindDown(element, {duration:3}); }*/ if(!$(divId).visible()) { move = Effect.BlindDown; newImage = "./img/feedbacktab_open.png"; setTimeout(function() { $(imgId).src = newImage; }, 0) } else { move = Effect.BlindUp; newImage = "./img/feedbacktab.png"; setTimeout(function() { $(imgId).src = newImage; }, 2) } move(divId, {duration:2}); /*setTimeout(function() { $(imgId).src = newImage; }, 0)*/ } &lt;/script&gt; </code></pre> <p>But neither the OLD code nor the NEW code works now.</p> <p>Error console now reporting "$(divId).visible is not a function" when i try to use the old script</p>
javascript
[3]
4,392,771
4,392,772
Android shake detection on emulator
<p>I am pretty new to android. I have a use case where I need to detect a shake and show some images in my application. Can I test shake functionality on android emulator ? What are the other alternatives apart from testing it on a real phone ?</p>
android
[4]
3,336,050
3,336,051
Why is my function not working?
<p>Now that I have my other questions answered, this function isn't working. What's wrong?</p> <p><a href="http://stackoverflow.com/questions/5461425/weird-javascript-statement-what-does-it-mean">Weird JavaScript statement, what does it mean?</a></p> <p><a href="http://stackoverflow.com/questions/5460733/how-to-handle-click-event-in-javascript">How to handle click event in javascript?</a></p> <pre><code>function myFunc() { return { obj = this; }; } </code></pre>
javascript
[3]
597,575
597,576
Why is the output of `echo true ? 'a' : true ? 'b' : 'c';` 'b'?
<p>I have this bit of PHP code:</p> <pre><code>echo true ? 'a' : true ? 'b' : 'c'; </code></pre> <p>The output of this is:</p> <blockquote> <p>b</p> </blockquote> <p>But the output I expected was:</p> <blockquote> <p>a</p> </blockquote>
php
[2]
211,938
211,939
How to define two dependent generic interfaces?
<p>I encountered a problem while using a generic interface. Initial condition was as follows:</p> <pre><code>interface Itemplate1 { ... } interface Itemplate2&lt;T&gt; where T : Itemplate1 { ... } </code></pre> <p>It works like a charm! But when I kept going to do rest of my application design, I noticed that <code>Itemplate1</code> members also need <code>Itemplate2</code>.</p> <pre><code>interface Itemplate1&lt;T&gt; where T : Itemplate2&lt;?&gt; { ... } interface Itemplate2&lt;T&gt; where T: Itemplate1&lt;?&gt; { ... } </code></pre> <p>How can I do it? Many Thanks</p>
c#
[0]
2,442,824
2,442,825
multiple spans in a charsequence
<p>when ever I set a span in a charsequence, then set the text in a text view its fine, it comes out right. I am using this</p> <p>Ssb.setSpan(new StyleSpan(Typeface.ITALIC), start, end, 1);</p> <p>Then set the text of the TextView.</p> <p>But when I get the text from the text view and then get the text from it using tv.getText(); it returns the CharSequence expected but when I set the span somewhere else in the cs the other span when the text is set it's not there.</p> <p>Im sorry for lack of code. I have no proper internet access at home so im posting this from my phone. </p>
android
[4]
575,838
575,839
Javascript will not load the pictures
<p>I want to load these banner.png files to the screen but all it prints out is the actual text from the banner array?</p> <pre><code>function randImg(){ var banner = new Array(); banner[0] = 'banner1.png'; banner[1] = 'banner2.png'; banner[2] = 'banner3.png'; maxImg = banner.length; randNum = Math.floor(Math.random()*maxImg); return banner[randNum]; } </code></pre> <p>any thoughts? I think I need to some how add a src but I am not sure how.</p>
javascript
[3]
4,754,295
4,754,296
Eclipse is not recognizing my android phone
<p>I am using eclipse on windows i want to run application on my samsung android phone but eclipse is not recognizing my device pease somebody help me</p>
android
[4]
3,742,632
3,742,633
How can I add commas to numbers in PHP
<p>I would like to know how can I add comma's to numbers. To make my question simple.</p> <p>I would like to change this:</p> <pre><code>1210 views </code></pre> <p>To:</p> <pre><code>1,210 views </code></pre> <p>and :</p> <pre><code>14301 </code></pre> <p>to</p> <pre><code>14,301 </code></pre> <p>and so on for larger numbers. Is it possible with a php function?</p>
php
[2]
2,585,766
2,585,767
Accessing method and parameter history with Java
<p>I'm currently working in a project in Liferay in which i'd like to be able to access my method and parameters these methods were given, in the history. This is done in case there is an exception being thrown in certain blocks of code.</p> <p>I've already searched and it is easy to get the method name history (Thread.currentThread().getStackTrace();) but i'd like to also know what parameters were given to these methods.</p> <p>For example:</p> <pre><code>public class A { public static void main(String[] Args) { try { System.out.println(new B().someMethod(5)); } catch (Exception e) { //GET HISTORY } } } public class B { public int someMethod(int i) throws Exception { i += 2; throw new Exception("Expected Exception to Generate History Search"); return i; } } </code></pre> <p>Is it possible to learn how can i, in class A, when I catch the exception, all that data? And of so, how do I do that?</p>
java
[1]
3,578,947
3,578,948
ASP.NET Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
<p>I have problem with that code:</p> <pre><code>HttpContext.Current.Response.Redirect("~/Examples/my.aspx"); //or HttpContext.Current.Response.Redirect("~/Examples/my.aspx",true); </code></pre> <p>the code above generates the error as I mentioned at this topic's title. </p> <p>I simply need to refresh my ASP.NET page, I can't use that code instead:</p> <pre><code>HttpContext.Current.Response.AddHeader("Refresh","2"); </code></pre> <p>because it says about IIS pipeline mode</p> <p>The puprose is that I must get into OnLoad method where some conditions are true after refresh/redirect</p>
asp.net
[9]
3,635,454
3,635,455
Saving XML file content to String or StringBuilder
<p><BR></p> <p>I want to save The whole content of XML file to a string or stringbuilder. Please let me know how can i achive that??<BR></p> <p>My Function needs to copy or Save a XML file content Completely to string or stringbuilder.<BR> It is External Content(XML File).After that I need to change the Content(onf field ) of the xml file Can i achive it through C#. please let me know.</p> <p>I Have following content in XML format , i want to put into one string and pass that to another Function in order to achive my Work.</p> <hr> <pre><code> &lt;wsa:Address xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"&gt;http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous&lt;/wsa:Address&gt; &lt;wsa:ReferenceParameters xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"&gt; &lt;wsman:ResourceURI&gt;http://schema.unisys.com/wbem/wscim/1/cim- &lt;/wsa:ReferenceParameters&gt; &lt;/p:Source&gt; &lt;/p:INPUT&gt;"; </code></pre> <p>--------------------------------------------------<BR></p> <p>Regards,<BR> Channaa</p>
c#
[0]
3,101,552
3,101,553
OutOfMemoryError while rendering in libgdx
<p>I have to render mesh array in using libgdx in render(). I used handler because every time I'm getting new data in getMeshToRender() method in meshArr array.</p> <pre><code> onCreate() { handler.removeCallbacks(sendUpdatesToUI); handler.postDelayed(sendUpdatesToUI, 1000); // 1 second } Runnable sendUpdatesToUI = new Runnable() { public void run() { //DisplayLoggingInfo(); getMeshToRender(); handler.postDelayed(this, 1000); // 1 seconds } }; getMeshToRender() { ....... meshArr = new Mesh[numMesh]; ....... } </code></pre> <p>in Render() method it initially loads that meshArr but then crashes with OutOfMemoryError.</p> <p>Any solution will be aprreciable. Thanks</p>
java
[1]
2,583,337
2,583,338
ASP.NET: Best way to grab a file path from a form thats residing in network share (UNC path)
<p>In our intranet environment I am trying to have a way of (like file upload / telerik file explorer) selecting a file using a browser and then returning the path only. I need to save the path in database and users need to select the file from network shared drive.</p> <p>For telerik explorer u need to implement custom provider to do that and I am unable to do it using file upload control.</p> <p>Tips regarding a user friendly solution will be highly appreciated.</p>
javascript
[3]
1,850,122
1,850,123
How to export html form data to json file
<p>How do I save html registration form data into a JSON file then log in based on it, without using any server side scripting languages? I want to use only Javascript and jQuery.</p> <p>HTML file "simple form" contains:</p> <p>First Name, Middle Name, Last Name, User Name, Password, Confirm Password, E-Mail, Phone</p> <p>When a user enters his data and clicks the register button, his data will be saved in a JSON file on the server. I have created this JSON file on the server as:</p> <pre><code>C:\inetpub\wwwroot\usersData.txt </code></pre> <p>And based on this file <code>usersData.txt</code>, when another user wants to register, I need to check the that user name is unique, if it is a unique user name, save his data back to the JSON file.</p> <p>I also need to know how to update the password in the JSON file when I use a hypothetical <code>change_password()</code> JS function.</p>
javascript
[3]
1,967,549
1,967,550
ArrayList : How does the size increase?
<p>I have a basic question on Java Array List.</p> <p>When a Array List is declared and initialized using default constructor, memory space for 10 elements will be created. Now, When I add 11th element, what happens? Will a new memory space created with 20(or more ) element capacity(This requires copying elements from 1st memory location to new location) OR some thing else?</p> <p>I checked <a href="http://download.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html">here</a>. But I didn't find an answer.</p> <p>Please share the knowledge. Thanks.</p>
java
[1]
2,499,658
2,499,659
Can I add ready() in the top of a jQuery plugin?
<p>I am trying to write a plugin, following the guidelines from jQuery site. </p> <p>I am also trying to incorporate everything into it, including creating new div elements. </p> <p>Those div's need to be created on document ready, so I am trying to figure the best options here.</p> <p>This is what I currently have and it works fine, but it doesn't looks right for some reason, even though I cannot see anywhere that it shouldn't be done that way. </p> <p>Is there a better way to do it?</p> <pre><code>$(document).ready(function() { var message_bar = "&lt;div id="something"&gt;&lt;/div&gt;"; $('body').prepend(message_bar); }); (function( $ ){ $.fn.displayMessage = function(options) { ... </code></pre>
jquery
[5]
3,167,010
3,167,011
store different objects
<p>I want to create different classes and they should be all stored in one ArrayList. If i use:</p> <pre><code>interface ProgramInterface { void someMethods(); } public abstract class CustomProgram implements ProgramInterface { // stuff } </code></pre> <p>Then i can make my own class like</p> <pre><code>class P_randomBars extends CustomProgram { </code></pre> <p>What i like about this is that the methods from the interface show up in the javadoc and from CustomProgram in the same page (CustomProgram).</p> <p>But then i can't store them in one array (or i have to store them as object which i don't want).</p> <p>Another way is:</p> <pre><code>public interface CustomProgram { void someMethods(); } public abstract class ProgramBase { // stuff } </code></pre> <p>And then i create a classes like:</p> <pre><code>class P_randomBars extends ProgramBase implements CustomProgram{ </code></pre> <p>What i like is that i can store classes i make like that in a ArrayList. Like: <code>ArrayList&lt;CustomProgram&gt; programs = new ArrayList&lt;CustomProgram&gt;();</code></p> <p>But in the javadoc the abstract class and the interface are not connected which make's unclear for the user that he has to extend and then implement.</p> <p>Is there a solution for this?</p>
java
[1]
5,633,543
5,633,544
collections in C#
<p>I am coming from a C++ background and i am trying to teach myself C# I am still a student and this isnt a school project and that i am on break right now. My main focus has been C/C++, java</p> <p>I have an old school project from 2 years back that i did in C++ that stores DVD, book, DVD, info in a container and then displaying it. I am trying to make the same program in C#</p> <p>I have 2 questions that are very similar..</p> <p>In my program a used typedef on the container and made objects of the container like so:</p> <pre><code>typedef set&lt;Item*&gt; ItemSet; ItemSet allBooks; // holds all the information ItemSet allCDS; ItemSet allDVDs; </code></pre> <p>First question is there is no typdef in C# i think its equivalent is using? But i cant use it on a container. Is there a way to do something similar above in C# or should i just create multiple sets? I decided that Hashset is similar to set in C++</p> <pre><code>HashSet&lt;Item&gt; keys = new HashSet&lt;Item&gt;(); </code></pre> <p>Second question is i also used typedef on a set outside the class and then in the private section i made and object of the set. Can i do this in C#?</p> <pre><code>typedef set&lt;string&gt; StringSet; class Item { private: string Title; StringSet* Keys; // holds keywords </code></pre> <p>I do realize C# has no pointers!</p>
c#
[0]
6,001,091
6,001,092
Take screenshot from UIVIEW+ipad
<p>I want to take the screenhot of viewcontroller I had write this:-</p> <pre><code>- (UIImage *)captureScreenInRectWOScroll:(CGRect)captureFrame { CALayer *layer; layer = self.view.layer; UIGraphicsBeginImageContext(captureFrame.size); CGContextClipToRect (UIGraphicsGetCurrentContext(),captureFrame); [layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return screenImage; } </code></pre> <p>The way i am calling this method:-</p> <pre><code>UIImage *img_woscroll1 =[self captureScreenInRectWOScroll:CGRectMake(35,147,497,260)]; </code></pre> <p>I wann to take screenshot of Address from below attached image:- <img src="http://i.stack.imgur.com/9UL3k.png" alt="enter image description here"></p> <p>When i am taking hte screenshot from the above code i Got the image with lot of blank space(greencolor image at top) at top side if image:-</p> <p><img src="http://i.stack.imgur.com/etDF0.png" alt="enter image description here"></p> <p>Please help me..How to take proper screenshot from image such that i will not get blank image on topside.</p>
iphone
[8]
5,418,333
5,418,334
android Runtime Exception
<p>When i run my android application it shows an exception "android runtime exception" with a message "Error: thread attach failed". it happens before the execution of "OnCreate" mathod of main class. what will be reason for that error?? anybody please help. </p>
android
[4]
2,028,352
2,028,353
php mkdir, folder name and structure
<p>I need to make an new folder on my server, and this also works just fine using mkdir()</p> <p>But can someone tell me how to make both folder name and structure using mkdir()??</p> <p>Folder name will be = $_SESSION['username']; </p> <p>and structure inside the new folder should be = /folder1/folder2/folder3/folder4/</p> <p>Thanks for your time.</p> <p>/thar</p>
php
[2]
1,636,722
1,636,723
text editor for android - how to hook into other applications
<p>Can you please point me into the right direction please.</p> <p>Basically I would like to code up a text editor application to suite my personal needs (would like it to specially handle some keyboard combination - as shift + x, etc).</p> <p>The first question - is to how to implement the text editor itself - I know there is a class TextView and I would need to handle OnPress methods (or something like this) to override inputs (e.g. if the user pressed shift + X - I would like "XXXX" to append to the input). Is TextView where should I start or where a better (at the same time simple for a novice in the android programming) to start?</p> <p>My second question is, once I implemented such application - how can I hook/integrate it to/with other applications - such as sms/email applications, etc.</p> <p>If you can point me to some article/source code on the web - would really appreciate this, because it is quite important to me, it really is.</p> <p>Cheers.</p>
android
[4]
301,502
301,503
Designing an asynchronous task library for ASP.NET
<p>The ASP.NET runtime is meant for short work loads that can be run in parallel. I need to be able to schedule periodic events and background tasks that may or may not run for much longer periods.</p> <p>Given the above I have the following problems to deal with:</p> <ul> <li>The AppDomain can shutdown due to changes (Web.config, bin, App_Code, etc.)</li> <li>IIS recycles the AppPool on a regular basis (daily)</li> <li>IIS itself might restart, or for that matter the server might crash</li> </ul> <p>I'm not convinced that running this code inside ASP.NET is not the right thing to do, becuase it would allow for a simpler programming model. But doing so would require that an external service periodically makes requests to the app so that the application is keept running and that all background tasks are programmed with utter most care. They will have to be able to pause and resume thier work, in the event of an unexpected error.</p> <p>My current line of thinking goes something like this:</p> <p>If all jobs are registered in the database, it should be possible to use the database as a bookkeeping mechanism. In the case of an error, the database would contain all state necessary to resume the operation at the next opportunity given.</p> <p>I'd really appriecate some feedback/advice, on this matter. I've been considering running a windows service and using some RPC solution as well, but it doesn't have the same appeal to me. And I'd instead have a lot of deployment issues and sycnhronizing tasks and code cross several applications. Due to my business needs this is less than optimial.</p>
asp.net
[9]
3,083,310
3,083,311
jquery with radio button
<p>whats wrong with this code? Why don't show value?</p> <p>Thanks</p> <pre><code>&lt;script&gt; $(document).ready(function() { $('#radio_div').change(function(event){ var value = $("input[@name='rdio']:checked").val(); $('#update_text').html('Radio value:' + value); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="radio_div"&gt; &lt;input type="radio" name="rdio" value="a" /&gt; &lt;input type="radio" name="rdio" value="b" /&gt; &lt;input type="radio" name="rdio" value="c" /&gt; &lt;/div&gt; &lt;div id="update_text"&gt;Please push radio button&lt;/div&gt; </code></pre>
jquery
[5]
538,684
538,685
php validate integer
<p>I`m wonder why this not working</p> <pre><code> echo gettype($_GET['id']); //returns string if(is_int($_GET['id'])) { echo 'Integer'; } </code></pre> <p>How to validate data passing from GET/POST if it is integer ?</p>
php
[2]
2,234,083
2,234,084
Searching list of lists
<p>I have a list of data like this</p> <pre><code>data = [['A',11],['A',22],['B',14],['C',23],['C',31],['B',12]] </code></pre> <p>I put the unique items in an other list like this:</p> <pre><code>search=[] for item in data: if search.count(item[0]) == 0: search.append(item[0]) # search contains ['A', 'B', 'C'] </code></pre> <p>How do I search the list <code>data</code> with the list <code>search</code> and produce output like?</p> <pre><code>['A', [11,22]] ['B', [14,12]] ['C', [23,31]] </code></pre>
python
[7]
5,865,177
5,865,178
Android fingerpaint canvas color
<p>I'm messing about with Fingerpaint.java in the SDK <a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html" rel="nofollow">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FingerPaint.html</a></p> <p>I've made a few adjustments to where I can save the bitmap and reopen to edit it later. Got that all working. Only issue is the canvas color on the saved copy is black rather than the color I set it too which means the canvas color when I go into edit is also black. I load my saved bitmap as such: The rest of the file is more or less the same as the one in the SDK. I'm just trying to figure out how I can get my canvas back to the desired color as when I first created it.</p> <pre><code> public MyView(Context c) { super(c); Bundle extras = getIntent().getExtras(); imageURI = extras.getString(Intent.EXTRA_SUBJECT); mBitmap = BitmapFactory.decodeFile(imageURI); Drawable d = new BitmapDrawable(mBitmap); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); d.setBounds(0, 0, width, height); d.draw(canvas); mBitmap = bitmap; mCanvas = canvas; mPath = new Path(); mBitmapPaint = new Paint(Paint.DITHER_FLAG); } </code></pre>
android
[4]
4,811,934
4,811,935
Simple dropdown and ie6 problem
<p>I have created a dropdown menu with jquery: <a href="http://www.designer-depot.com/lgn/index.html" rel="nofollow">here</a> Everything is ok but in ie6. I know ie6 not supported z-index, but is there any solution for ie6? Thanks in advance</p>
jquery
[5]
256,180
256,181
Why my androiv virtual device only opens the google page in my WebView?
<p>If I write </p> <pre><code>webView.loadUrl("http://www.google.com"); </code></pre> <p>The google page opens normally, but if I put another addres, like</p> <pre><code>webView.loadUrl("http://www.android.com"); </code></pre> <p>The page does not open. Is this a bug with my AVD? It does not appears anyone error message. I try for other pages, like Bing, and the web page opens normally.</p>
android
[4]
2,328,045
2,328,046
php - not able te receive the email
<p><strong>Below is the code</strong></p> <pre><code>&lt;?php ini_set('display_errors',1); error_reporting(E_ALL|E_STRICT); include('config.php'); // table name $tbl_name="temp_members_db"; // Random confirmation code $confirm_code=md5(uniqid(rand())); // values sent from form $name=$_POST['name']; $email=$_POST['email']; $country=$_POST['country']; // Insert data into database $sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')"; $result=mysql_query($sql); // if suceesfully inserted data into database, send confirmation link to email if($result){ // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email; // Your subject $subject="Your confirmation link here"; // From $header="from: your name &lt;your email&gt;"; // Your message $message="Your Comfirmation link \r\n"; $message.="Click on this link to activate your account \r\n"; //$message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code"; $message.="http://localhost/confirmation.php?passkey=$confirm_code"; // send email $sentmail = mail($to,$subject,$message,$header); } // if not found else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Confirmation link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } ?&gt; </code></pre>
php
[2]
4,442,571
4,442,572
How to find error occurring in getScript in jquery
<p>I am using getScript function to fetch and execute a js file. </p> <p>Whenever there is an error, execution stops and I don't see any error message in firebug. No description of error. </p> <p>I even tried surrounding try catch around getScript, even that doesn't work. So how to find what error occurred while running that script.</p>
jquery
[5]
4,997,481
4,997,482
Javascript "cannot read property "bar" of undefined
<p>I've got a function that takes 3 parameters. The problem I have is one of the parameters is a property of a sometimes undefined value of an Object (i.e. it takes in <strong>thing.foo.bar</strong>, and sometimes <strong>thing.foo</strong> is undefined, so it can't access <em>bar</em>). </p> <p>What's a way around this? Within the function's declaration, I have a conditional checking: <code>if (!parameterName)</code>, but the browser (Chrome) is still throwing an error that it can't read the <strong>bar</strong> property of undefined.</p> <p>Thank you!</p>
javascript
[3]
2,731,132
2,731,133
Go back to start or repeat raw input a number of times
<p>I have written a code and it works, now as there are variable in the code I want at the end to ask the person if they wish to quit/continue, they say continue it goes all the way back to the first question. Also is there a way to ask at the start how many times the question is to repeat itself. Sorry can't upload code as it is over 150 lines long ta Greggy D</p>
python
[7]
4,743,656
4,743,657
How can I check through a string array of roles and return the most senior role?
<p>The following code returns an array of roles for my user:</p> <pre><code>var userRoles = Roles.GetRolesForUser(); </code></pre> <p>The possible roles are:</p> <pre><code>public enum RoleType { Default = 10, Guest = 20, User = 30, Admin = 40, Super = 50 } </code></pre> <p>How can I make my code check through the userRoles array and return the highest RoleType that it can find?</p>
c#
[0]
5,493,128
5,493,129
JavaScript + Reference object in another function?
<p>If I create an object in an onLoad function, then attempt to reference that object within an onChange function, the object is 'undefined'... how do I reference it?</p> <p><strong>HTML:</strong></p> <pre><code>&lt;body onLoad="loaded()"&gt; &lt;select onChange="updateObject(event)"&gt; &lt;option value="v1"&gt;--v1--&lt;/option&gt; &lt;option value="v2"&gt;--v2--&lt;/option&gt; &lt;/select&gt; &lt;/body&gt; </code></pre> <p><strong>JS:</strong></p> <pre><code>function loaded(){ var obj = new ObjectExample(); } function updateObject(event){ console.log(obj); } </code></pre>
javascript
[3]
5,223,841
5,223,842
Forced to use jQuery instead of $
<p>I'm was doing my page with jquery scripting all of then written like <code>$.</code> , <code>$(</code> My sample code like here</p> <pre><code>&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; function dome(){ $.ajax({ async: false, type: 'POST', url: 'test.php', success: function(data) { alert('ok'); } }); } </code></pre> <p>But I also have to use a Prototype library, then after add code <code>&lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"&gt;&lt;/script&gt;</code> </p> <p>My above function did not work any longer The error report from firebug is <strong>TypeError: $.ajax is not a function</strong> Then only way to solve this is to change <code>$.ajax({</code> to <code>jQuery.ajax({</code></p> <p>Do you know how can I manage to do coding as short like I did before ($.)?</p>
jquery
[5]
3,218,897
3,218,898
Android: SearchView
<p>this is what I have in xml file </p> <pre><code> &lt;SearchView android:id="@+id/searchView1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:iconifiedByDefault="false"&gt; &lt;/SearchView&gt; </code></pre> <p>This is how its looks on device</p> <p><img src="http://i.stack.imgur.com/EtOq3.png" alt="enter image description here"></p> <p>But I want this think to look like this:</p> <p><img src="http://i.stack.imgur.com/kCBan.png" alt="enter image description here"></p> <p>How to do that ? Is that possible with searchView or I should use EditText with image inside ?</p> <p>P.S: Searchview is not in action bar</p>
android
[4]
2,237,615
2,237,616
how to make video player fluid width and height?
<p>how would you make these video players height and width 100% and resize with the page <a href="http://scripts.reloadlab.net/customYtPlayer/" rel="nofollow">http://scripts.reloadlab.net/customYtPlayer/</a></p> <p><code>&lt;a class="youtube" href="http://www.youtube.com/watch?v=CD2LRROpph0" style="width: 100%;"&gt;&lt;/a&gt;</code> </p> <p>makes the video player the width of the window and it remains that way when resizing it whereas i want it to be resizable with the window. and you cant specify height but i would also like that to be resizeable with the window when resizing it.</p>
jquery
[5]
2,729,250
2,729,251
Why c++? Where to start?
<p>I know there was many questions like this one, but please hold on one more. All programming languages I know now are made for web purposes. I've been learning ActionScript, php and a bit of Javascript, AJAX, etc.. I've liked php very much but I'm still looking something I'll really love! That's why I want to try something new. Can You tell me what are positives and negatives of this language? Is there some big example of C++ usage? Is it a good language to start this journey (maybe You can recommend something else)? Are there some good video tutorials which I can buy on CD/DVD? Could You recommend some books?</p>
c++
[6]
6,009,105
6,009,106
jquery click image select next span without class or id
<p>I am trying to add a text line to an image without an id or a class I have a series of images such as</p> <pre><code> &lt;img src="../img/star.png" /&gt;&lt;span&gt;no text here until left img is clicked&lt;/span&gt; &lt;img src="../img/someotherpicture.png" /&gt;&lt;span&gt;no text here until left img is clicked&lt;/span&gt; &lt;img src="../img/anotherpicture.png" /&gt;&lt;span&gt;no text here until left img is clicked&lt;/span&gt; </code></pre> <p>and for jquery i have</p> <pre><code>$(document).ready(function(){ $("img").click(function(){ $("img").next.$("span").val("info inserted after clicking on the img next to spa"); }) }); </code></pre> <p>I'm a little bit confused as to how i should use next here, or maybe i should use find? I always have an img followed by a span.</p>
jquery
[5]
597,462
597,463
Forms with a variable number of fields
<p>I'm attempting to create a sort of marketplace. Each item on the market has a type (i.e. the item being sold), a value, a quantity, a seller name, and an id, and all of this information is stored in a MySQL database.</p> <p>When the user views the market, all entries in the market are returned. In addition, an input text field appears at the end of each entry. The user can enter any number between leaving it blank (0) and the max quantity available.</p> <p>My problem is that since each input field is the result of a while loop of unknown iterations, I can't simply hard code a name into each field. I've tried using a counter variable to keep track and make names, but it doesn't seem to be working. For example: <code>name='.$i++.'</code></p> <p>On a related note, in order for the program to work, each field needs to send two values - the id (which I can use to look up the rest of the entry's values) and the quantity that the user wishes to purchase. I've been doing this with a hidden field before the input quantity field. I'm not sure if this is a good way of going about this, but I should note that there's no need as far as I can tell for the id to be kept secret.</p> <p>Just so everything's clear, here's a basic UI mockup: <a href="http://img850.imageshack.us/img850/2654/marketui.jpg" rel="nofollow">http://img850.imageshack.us/img850/2654/marketui.jpg</a></p> <p>Note that the column starting with consists of user inputted values (i.e. the 100s are the values of user-inputted text fields). The hitch is that while there are 2 rows in this example, the actual number is not deterministic, and so I can't hard code names for each input field.</p>
php
[2]
3,704,391
3,704,392
Passing Variables Error
<p>Im getting this annoying error and tried every i know but in this case it hasnt helped.</p> <p>I have in my delegate....</p> <pre><code>vid_name = [push objectForKey:@"vid"]; </code></pre> <p>(in the console .... vid = "video" )</p> <p>now in my normal page i have </p> <pre><code>NSString *videoName = [(MissileAppDelegate *)[[UIApplication sharedApplication] delegate] vid_name]; NSString *path = [[NSBundle mainBundle] pathForResource:videoName ofType:@"mp4"]; </code></pre> <p>when i run this and it comes to play the video, i get an error that doesnt even relate to the video, it happens with all variables i try and pass over using the [push objectForKey:@"vid"];. if i just vid_name =@"video" it works fine.</p> <p>Any Ideas?</p> <p>Alex</p>
iphone
[8]
133,202
133,203
java: how to read a txt file to an Array of strings
<p>Hi i want to read a txt file with N lines and the result put it in an Array of strings.</p>
java
[1]
5,123,645
5,123,646
Returning after a period of inactivity in my Android Application causes destroy set Values
<p>I have a Problem with my Application that when it goes to the <strong>background</strong> and then return back after <strong>2-3 minutes of inactivity</strong>, then Application's <strong>on-Create method</strong> is called and values are set to the <strong>default values</strong>, kindly help me to diagnose this Problem and further Application contains a lot of sounds and image-processing in it, may be this fact causes an issue. Thanks</p>
android
[4]
3,715,553
3,715,554
Bold First Line of Output
<p>I need to add <code>&lt;b&gt;</code> tags around the first line of text, but not contained in a paragraph tag - rather just all the text before the first <code>&lt;br&gt;</code>. </p> <p>It's a PHP string being echoed, so it seems to me pretty simple but I'm not sure how I'd get just that section of text, bold it, and then continue with the rest as normal. </p> <pre><code>$str = "First Line&lt;br&gt;SecondLine&lt;br&gt;Third Line&lt;br&gt;"; echo $str; //output: &lt;b&gt;First Line&lt;/b&gt;&lt;br&gt;SecondLine&lt;br&gt;ThirdLine&lt;br&gt;"; </code></pre>
php
[2]
1,187,883
1,187,884
Implement new tab on web browser control for C#
<p>I want to build my own web browser, but I'm stuck on operation for adding new tab, does anyone have any idea to make it done?</p> <p>The final result will should like this.</p> <p><img src="http://i.stack.imgur.com/Em0Lx.png" alt="enter image description here"></p>
c#
[0]
3,045,128
3,045,129
Which is fastest in PHP?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1813673/php-string-concatenation-a-b-vs-a-b-performance">PHP String concatenation - &ldquo;$a $b&rdquo; vs $a . &ldquo; &rdquo; . $b - performance</a> </p> </blockquote> <pre><code>&lt;?php $url = 'http://www.google.com/'; //case 1 $case1 = 'The URL is '.$url.'.'; //case 2 $case2 = "The URL is $url."; //case 3 $case3 = 'The URL is {url}.'; $case3 = str_replace('{url}', $url, $case3); ?&gt; </code></pre> <p>Thank you!</p>
php
[2]
384,281
384,282
Passing type 'var' into a method in C#
<p>I have some sub queries which are of data type var. These are getting working on a data table. I would like to pass these into another method, how can i do that? Ex:</p> <pre><code> var subquery1= from results in table.AsEnumerable() where //some condition select new { column1=results.field1, column2 = results.field2 etc., } var subquery2= from results in table.AsEnumerable() where //different condition select new { column1=results.field1, column2 = results.field2 etc., } </code></pre> <p>Now, I would like to define some method to pass these subquery1, subquery2 as variables. ex: </p> <pre><code>void updategrid(var queries) { //some logic } </code></pre> <p>And execute the method: </p> <pre><code>updategrid(subquery1); updategrid(subquery2); </code></pre> <p>When i try to use var in the method when defining it is not liking it. Please help me in how to do that. Thanks.</p>
c#
[0]
333,180
333,181
How to remove leading and trailing spaces from strings in a Python list
<p>i have a list:</p> <pre><code>row=['hi', 'there', 'how', ...........'some stuff is here are ','you'] </code></pre> <p>as you can see <code>row[8]='some stuff is here are '</code></p> <p>if the last character is a space i would like to get everything except for the last character like this:</p> <pre><code>if row[8][len(row[8])-1]==' ': row[8]=row[8][0:len(row[8])-2] </code></pre> <p>this method is not working. can someone suggest a better syntax please?</p>
python
[7]
5,879,438
5,879,439
SQlite unable to open
<p><img src="http://i.stack.imgur.com/LAVzn.png" alt="enter image description here"> I create my database using sqliteadmin (version 0.8.3.2),I place this file into my asset directory and then copy this file into <code>data/data/mypackage/databases/mydb</code>,its ok.now when I am trying to open this file getting exception as <code>android.database.sqlite.SQLiteException: unable to open database file</code>,below code i am using to open the mydb.</p> <pre><code>private static final String DB_PATH = "/data/data/src.com/databases/"; private static final String DB_NAME = "mydb"; String mypath = DB_PATH + DB_NAME; try{ dbBF = SQLiteDatabase.openDatabase(mypath, null, SQLiteDatabase.OPEN_READWRITE); }catch(Exception ex) {System.out.print("H![enter image description here][1]ere is an Exception"+ex); } Cursor cur = dbBF.rawQuery("SELECT * FROM"+"myTable" , null); </code></pre>
android
[4]
1,301,906
1,301,907
How to register event on elements that don't yet exist?
<p>I am trying to register a event on elements like this:</p> <pre><code>$(document).ready(function() { $('.classname').change(function(){ alert ('This line is never triggered'); }); }); </code></pre> <p>But the problem is that .classname elements are later loaded into the dom by ajax. So, how do I correctly register an event in this case? Is it possible to do it only once (I mean, not every time the new element appears?)</p>
jquery
[5]
1,991,320
1,991,321
Variables in an array
<p>I'm trying to put a mysql query into a function, however when I do a mysql_fetch_array I need to specify the row's name. How can I put a variable in a function?</p> <pre><code>function config($setting_name,){ while($config_db = mysql_fetch_array(mysql_query("SELECT {$setting_name} FROM config WHERE id='1'") { echo $config_db['@@@@HERE@@@@']; } } </code></pre>
php
[2]
5,258,935
5,258,936
How can I pass array of objects as arguments to a RESTful service
<p>I've a types class, which contains key and value properties and I need to send array of types objects to restful service. I tried the below url, but its not working. Please correct it. Thanks in advance.</p> <p><a href="http://localhost:8080/CRService/services/CRService/newContentObjectRequest?User=abcd&amp;types=" rel="nofollow">http://localhost:8080/CRService/services/CRService/newContentObjectRequest?User=abcd&amp;types=</a>{"key":name, "value":xyz}&amp;types={"key":assigned_to, "value":abcd}&amp;types={"key":status, "value":COMPLETED}</p>
c#
[0]
2,455,530
2,455,531
exception reading http Stream
<p>The code pasted below gets an exception on tha line that says... InputStream in = new BufferedInputStream(urlConnection.getInputStream());<br> It's an IO exception that says: java.net.UnknownHostException: www.android.com</p> <p>I checked and that is a valid url. I got the original code from the android docs on HttpURLConnection although I had to fix serveral bugs in the docs code.</p> <p>Why am I getting this exception? thanks, Gary</p> <pre><code>import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import android.app.Activity; import android.os.Bundle; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); HttpURLConnection urlConnection = null; try { URL url = new URL("http://www.android.com/"); urlConnection = (HttpURLConnection) url.openConnection(); InputStream in = new BufferedInputStream(urlConnection.getInputStream()); readStream(in); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { urlConnection.disconnect(); } } </code></pre>
java
[1]
5,776,365
5,776,366
What data structure discards the oldest item when a new one is added?
<p>I've been trying to remember this and it's driving me crazy.</p> <p>Basically, it's like a small array, of let's say size five, and as you add items it starts to fill up. When it's full, and you add a new item, the oldest one (first added) is removed.</p> <p>You can access the values by something like variable[0], variable[1] etc, where variable [0] is the oldest value, and variable 4 the newest.</p> <p>Any ideas on what this is called? Is it a standard C++ type, or did I just see it somewhere as a custom class?</p>
c++
[6]
428,232
428,233
How to do image rotation as well as image 3DTransform?
<p>How to do image rotation(CGAffineTransformRotate) as well as image 3DTransform(CATransform3DRotate)? My problem is when I change the rotation and then make 3D Transform, Image goes to the initial image. Similarly when I change the 3D Transform after change the rotation goes to the initial image. I am using below code.</p> <p>For Rotation :</p> <pre><code>- (void)rotateImage:(UIRotationGestureRecognizer *)recognizer { self.transform = CGAffineTransformRotate(recognizer.view.transform, recognizer.rotation); recognizer.rotation = 0; } </code></pre> <p>For 3D Transform :</p> <pre><code>- (void)moveImage:(UIPanGestureRecognizer *)recognizer { if ([recognizer respondsToSelector:@selector(translationInView:)]) { CGPoint translation = [(UIPanGestureRecognizer *)recognizer translationInView:recognizer.view.superview]; self.xTranslation = translation.x; self.yTranslation = translation.y; // CALayer *layer = self.layer; CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; rotationAndPerspectiveTransform.m34 = 1.0 / 500.0; rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, - self.xTranslation / 50.0 * M_PI / 180.0f, 0.0f, 1.0f, 0.0f); self.layer.transform = rotationAndPerspectiveTransform; rotationAndPerspectiveTransform.m34 = - 1.0 / 500.0; rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, - self.yTranslation / 50.0 * M_PI / 180.0f, 1.0f, 0.0f, 0.0f); self.layer.transform = rotationAndPerspectiveTransform; } } </code></pre> <p>I want both rotation and 3D Transform. I am using UIPanGestureRecognizer for 3DTransform and UIRotationGestureRecognizer for rotation. How to do this? Thanks in advance. </p>
iphone
[8]
2,405,023
2,405,024
PHP white screen on error
<p>I'm getting a white screen every time a PHP application drops an error. I checked php.ini and error_reporting = E_ALL and display_errors = On Also I checked with the php_info() function and error_reporting is set to 6135 which is correct.</p> <p>I already tried adding: error_reporting(E_ALL); ini_set('display_errors', TRUE); to my index.php but didn't worked.</p> <p>Also I don't have any custom error handler function. Does anybody what else can cause a white screen in PHP?</p> <p>by the way, it's not caused by an unclosed bracket neither, if I intentionally leave an error in the index.php it is displayed.</p> <p>But when I try to load a heavy page, the white screen is displayed. I'm using the same MySql server for other applications without problems.</p>
php
[2]
5,946,314
5,946,315
Android notification of
<p>Android, Notification, and download this information by clicking on the Notification inside information, this information is an apk file, how to get the click event?</p>
android
[4]
5,915,471
5,915,472
JQuery function is not working after URL Rewriting
<p>Refer to my this question: <a href="http://stackoverflow.com/questions/5403247/page-not-redirecting-properly-url-rewriting-asp-net">Page not redirecting properly, URL rewriting (Asp.NET)</a> </p> <p>Which is resolved except one thing.</p> <p>Though I have put the code to eliminate post back for .jpg and other file extension, JQuery at the web page is not working.</p> <pre><code>&lt;script type="text/javascript" src="JS/jquery.js"&gt;&lt;/script&gt; </code></pre> <p>I have written it like the above. I have tried to change the path like</p> <pre><code>&lt;script type="text/javascript" src="~/JS/jquery.js"&gt;&lt;/script&gt; </code></pre> <p>but no luck.</p> <p>Any suggestion</p>
asp.net
[9]
3,154,061
3,154,062
how client browser data is saved in php array
<p>how client browser data is saved in php array if php processes on server side?</p>
php
[2]
2,119,424
2,119,425
Can I explicitly reference a JavaScript global variable that's been shadowed by a local with the same name?
<p>I've seen tons of posts about the difference between global and function scope in JavaScript, far too many to link here. I've also seen my exact question <a href="http://stackoverflow.com/questions/10235973/modifying-global-variable-with-same-name-as-local-variable">asked about Python</a>. So what I want to know is, how can I access a global variable when a "closer" scope also has a variable with the same name?</p> <pre><code>var a = "global"; function b(){ var a = "local"; var magic = ...; // somehow put "global" in magic console.log(magic); // should print "global" } </code></pre> <p><em>In browser only</em>, I figured out that you can use <code>window.a</code> to specify the global. Is there anything that works server-side as well?</p>
javascript
[3]
5,024,122
5,024,123
How to make a list item full selection when clicked on it?
<p>I have an app in which i should show the list item selection when clicked on it. But when i clicked on it it is showing the selection only on the text but not on the full row? How to do that? </p>
android
[4]
3,350,975
3,350,976
how to deal with multiple ids in query as i have problem in the following code
<pre><code>&lt;head&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("input").click( function(){ alert(this.id); $('#comments'+this.id).show(); } ); }); &lt;/script&gt; &lt;style type="text/css"&gt; .comments{ width:500px; height:350px; background:#06F; display:none; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="text" id="1"&gt;&lt;/input&gt; &lt;input type="text" class="title" id="2"&gt;&lt;/input&gt; &lt;input type="text" class="title" id="1"&gt;&lt;/input&gt; &lt;div id="comments1" class="comments"&gt;box 1&lt;/div&gt; &lt;div id="comments2" class="comments"&gt;box 2&lt;/div&gt; &lt;div id="comments1" class="comments"&gt;box 3&lt;/div&gt; &lt;/body&gt; </code></pre>
javascript
[3]
3,831,105
3,831,106
Dynamic ListView Columns At Runtime
<p>I want to give users the ability to customize the columns of an asp.net ListView. </p> <p>For example: there are 10 columns of data, a user should be able to select any number of columns to be displayed on their personalized view of a ListView.</p> <p>I have investigated how to accomplish this task and what I have come up with is; implementing the ITemplate interface at run time based on a particular users setting. </p> <p>The following msdn article describes how to implement the ITemplate interface. <a href="http://msdn.microsoft.com/en-us/library/aa289501%28VS.71%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa289501%28VS.71%29.aspx</a></p> <p>Is there a different (better?) way to accomplish my goal that I should be aware of? </p>
asp.net
[9]
2,392,057
2,392,058
PHP How to find if 2 dates are equal
<p>I have a date field that submits the chosen dates and I want to find out if the end date is today.</p> <p>So for example I want to compare 21-May-2012(today) to 21-May-2012(submitted) and see if they match or not.</p> <p>Can someone please help?</p> <p>Thanks in advance</p>
php
[2]