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 |
|---|---|---|---|---|---|
226,504 | 226,505 | Textbox allows only alphanumeric and also allow leftarrow(<-) | <p><strong>Requirement:</strong> Textbox should allow only alphanumeric.</p>
<p><strong>My Problem:</strong>
My code is allowing only alphanumeric. But problem is leftarrow(<-) is not working in google cromo and IE. Its working in mozilla firefox. For enter the backward text, its not allowing leftarrow(<-) key. How can i resolve it. </p>
<p><strong>code:</strong></p>
<pre><code>@Html.TextBoxFor(model => model.textId, new
{
onkeyup = "this.value=this.value.replace(/[^A-Za-z0-9]/g,'');"
})
</code></pre>
| jquery | [5] |
5,140,342 | 5,140,343 | Painting to a specific area of the browser in PHP | <p>I've been looking into PHP GD an awful lot, but all the examples seem to indicate that you need to redirect the browser to another page. Now I've managed to get it displayed inline by writing a php file that runs the picture painting code. What I need to do now, is to stop all the random text appearing at the top of the screen. How do I do that?</p>
| php | [2] |
2,408,302 | 2,408,303 | How can I add a class member if the other class' constructor requires arguments? | <p>I'm not coding much in C++, so please forgive me if this is trivial.</p>
<p>My class "Foo" looks somewhat like this:</p>
<pre><code>class Foo {
public: Foo(int n) { }
};
</code></pre>
<p>Another class "Bar" is now supposed to have a class member of type "Foo".</p>
<pre><code>class Bar {
private: Foo f;
};
</code></pre>
<p>This obviously fails, because there is no constructor for "Foo" that does not require any arguments. However, stuff like <code>Foo f(1);</code> fails, too.</p>
<p>Is there any way to solve this problem? Or am I supposed to use a pointer here?</p>
| c++ | [6] |
539,871 | 539,872 | How to use jQuery's load(fn) method so it actually works | <p>JQuery documentation has this to say about .load(fn) (<a href="http://docs.jquery.com/Events/load#fn" rel="nofollow">http://docs.jquery.com/Events/load#fn</a> ):</p>
<blockquote>
<p>Note: load will work only if you set
it before the element has completely
loaded, if you set it after that
nothing will happen.</p>
</blockquote>
<p>So when one is supposed to bind the load event for <code><div id="test"></code>? As far as I understand doing it before this div actually appears won't work, because $('#test') won't select it, and doing it after that is, as mentioned above, too late. Following code seems to support this:</p>
<pre><code><html>
<head></head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$('#test').load(function(event) { event.target.css('color', 'blue'); alert('a');});
</script>
<div id="test">TEST</div>
<script type="text/javascript">
$('#test').load(function(event) { event.target.css('color', 'red'); alert('b');});
</script>
</body>
</html>
</code></pre>
<p>After loading it nothing happens (no color changes, no alerts) and Firebug says everything is ok.</p>
| jquery | [5] |
677,947 | 677,948 | How to convert hex string to hex number? | <p><br>
I have integer number in ex. 16 and i am trying to convert this number to a hex number. I tried to achieve this by using hex function but whenever you provide a integer number to the hex function it returns string representation of hex number, </p>
<pre><code>my_number = 16
hex_no = hex(my_number)
print type(hex_no) // It will print type of hex_no as str.
</code></pre>
<p>Can someone please tell me how to convert hex number in string format to simply a hex number.<br>
Thanks in advance<br>
Rupesh Chavan</p>
| python | [7] |
2,665,875 | 2,665,876 | Strange behavior in Date constructor | <p>Here's a little excerpt from my Javascript console:</p>
<pre><code>> x
"Dec 16, 2012 03:40 PM"
> typeof(x)
"string"
> new Date(x)
Invalid Date
> new Date("Dec 16, 2012 03:40 PM")
Sun Dec 16 2012 15:40:00 GMT-0800 (PST)
</code></pre>
<p>I am stumped about why <code>new Date(x)</code> doesn't work whereas if I pass the same string directly, it works fine. Does anyone know?</p>
| javascript | [3] |
5,780,354 | 5,780,355 | Android share text and image | <p>I need to share text+image via Facebook, email etc. Now, I use this code:</p>
<pre><code>Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.settings_share_text));
//Uri path = Uri.parse("android.resource://com.android.mypackage/" + R.drawable.arrow);
Uri path = Uri.parse("android.resource://com.android.mypackage/drawable/arrow.png");
intent.putExtra(Intent.EXTRA_STREAM, path );
Intent mailer = Intent.createChooser(intent, null);
startActivity(mailer);
</code></pre>
<p>The problem is that when I use "arrow.png", it says "Couldn't show attachment" and doesn't attach image; when I remove .png, I cannot open attached file later.
Basically, I need to attach png from drawable and some text and share it via ACTION_SEND </p>
| android | [4] |
1,804,583 | 1,804,584 | How to swap dataTable row values? | <p>MyScenario,I have three rows .I want swap values of first column.How to achieve this?</p>
| c# | [0] |
4,690,596 | 4,690,597 | PHP Continue sending email but stop page loading? | <p>My page executes a script that takes a relatively long time to complete. I would like to make it so that the user can submit information, immediately echo "Complete", and allow the user to exit the page while the script continues executing. How can I do this?</p>
| php | [2] |
702,910 | 702,911 | Missing Assembly Reference for OfficeMergeControlException | <p>When I try to use the code to combine multiple .docx files (the first listing at: <a href="http://stackoverflow.com/questions/247666/how-can-i-programatically-use-c-sharp-to-append-multiple-docx-files-together">How can I programatically use C# to append multiple DOCX files together?</a>), I seem to be missing an assembly reference for OfficeMergeControlException. </p>
<p>I'm using .NET Framework 4. </p>
<p>Any ideas? </p>
<p>Thanks,
Rich</p>
| c# | [0] |
3,769,347 | 3,769,348 | Clear and add content | <p>I have the following paragraph to which content of array added </p>
<pre><code>$('#pop').html(arr.join('<br>'))
</code></pre>
<p>I want to do like clear and add.</p>
<pre><code>$('#pop').text('').html(arr.join('<br>'))
</code></pre>
| jquery | [5] |
1,883,763 | 1,883,764 | How to dynamically set textview height android | <p>In my application I need to set dynamic text to my textview so I want it to get resized dynamically. I have set:</p>
<pre><code><TextView
android:id="@+id/TextView02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="normal"
android:layout_weight="1"
android:singleLine="false"
android:minLines="4" />
</code></pre>
<p>And from java code I am setting <strong>text</strong> of the <strong>textview</strong> at runtime..</p>
<p>My textview height is not going beyond 1 line and the text is getting cut. Can anybody please help?</p>
<p>Thanx in advance.
And from java code I am setting <strong>text</strong> of the <strong>textview</strong> at runtime..</p>
<p>My textview height is not going beyond 1 line and the text is getting cut. Can anybody please help?</p>
<p>Thanx in advance.</p>
| android | [4] |
4,292,384 | 4,292,385 | Php code that explodes tags from a form, puts commas after each one and breaks them in groups | <p>I have a form where I want to submit tags like this:</p>
<pre><code>tag1
tag2
tag3
tag4
...
tag n
</code></pre>
<p>*each tag on it's own line.</p>
<p>I get the tags in my php page:</p>
<pre><code>$tags = get_option('tags');
</code></pre>
<p>I now separate each tag by the new line criteria:</p>
<pre><code>$tag = explode("\n", $tags);
</code></pre>
<p>In a loop, I echo them:</p>
<pre><code>$i = '-1';
while(){ // usually a wordpress loop
$i++;
echo $tag[$i];
}
</code></pre>
<p>Finally I get:</p>
<pre><code>Tag1
Tag2
Tag3
...
Tag n
</code></pre>
<p>Here is where I need help.</p>
<ol>
<li><p><strong>I can't find a way to group tags - lets say by 3 and not explode them with every new line - "\n"
That would enable me to get something like this:</strong></p></li>
<li><p>*<strong>*Automatically put a comma after each tag in each line, except the last one.</strong></p></li>
</ol>
<p>It would be something like this:</p>
<pre><code>Tag1, Tag2
Tag3, Tag4
....
Tag n-1, Tag n
</code></pre>
<p>Any ideas?</p>
<p>Ty!</p>
| php | [2] |
2,331,892 | 2,331,893 | javascript multidimensional Array and associative array | <p>i am new of javascript, i have been told by someone, he said "speak strictly, javascript doesn't have multidimensional Array and associative array ". but in a book, i saw the following </p>
<pre><code>var my_cars=Array();
my_cars["cool"]="Mustang";
$a=Array(Array(0,1),2);
</code></pre>
<p>so the opinion form he is wrong? am i right?</p>
| javascript | [3] |
721,844 | 721,845 | Comparing text in EditText | <h3>My code:</h3>
<pre><code>final EditText et1 = (EditText)findViewById(R.id.et1);
et1.setOnFocusChangeListener(new OnFocusChangeListener(){
@Override
public void onFocusChange(View v, boolean hasFocus) {
if ( hasFocus )
{
et1.setTextColor(0xFF000000);
if ( et1.getText().equals("Email") ) { et1.setText(""); }
}
else
{
et1.setTextColor(0xFF7F7F7F);
if ( et1.getText().equals("") ) { et1.setText("Email"); }
}
}
});
</code></pre>
<p>et1 has "Email" in it by default. When the user clicks on it, I want it to clear.
The <code>OnFocusChangeListener</code> works fine as the color changes, but the text does not change, i.e. the </p>
<pre><code>if ( et1.getText().equals("Email") )
</code></pre>
<p>doesn't fire. Nor does the <code>equals("")</code>, after I clear the et.</p>
<p>What am I doing wrong?</p>
| android | [4] |
5,658,808 | 5,658,809 | referencing external javascript file | <p>I want to store array value in an external javascript file and then use an internal script to write a loope that lists the values of the array stored in the external file.
my javascript file is:</p>
<pre><code>var Arr = new Array("one", "two", "three")
</code></pre>
<p>My internal script</p>
<pre><code><script src="test.js" datatype "text/javascript"></script>
<script type="text/javascript">
for (x in Arr)
{
document.write("<br />"+ Arr[x]);
}
</script>
</code></pre>
| javascript | [3] |
1,294,632 | 1,294,633 | SqlReader, Repeater controls and CommandArgument problem | <p>I have a repeater control that generates a list of links from a SqlReader. I'm trying to create a button alongside each link that will allow the user to delete that link. My original thought was to use the <%#Eval("URL") %> expression in the Item template like below. However the CommandArgument in the ItemCommand method would always come back empty.</p>
<pre><code><asp:Repeater ID="rptLinks" runat="server" onitemdatabound="rptLinks_ItemDataBound"
onitemcommand="rptLinks_ItemCommand">
<ItemTemplate><a href="<%# DataBinder.Eval(Container.DataItem, "URL") %>" target="_blank"><%# DataBinder.Eval(Container.DataItem, "URL") %></a><asp:ImageButton visible="false" ID="btnDeleteLink" runat="server" ImageUrl="/Images/DeleteIcon.gif" CommandName="DELETE" CommmandArgument=<%#Eval("URL") %> />
</ItemTemplate>
<SeparatorTemplate><br /></SeparatorTemplate>
</asp:Repeater>
</code></pre>
<p>The next thing I tried was to use the ItemDataBound event to programatically set the CommandArgument, but I can't figure out what to cast the e.Item.DataItem into so I can reference the ["URL"] Item.</p>
<pre><code>protected void rptLinks_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
ImageButton btnDelete;
btnDelete = (ImageButton) e.Item.FindControl("btnDeleteLink");
if (btnDelete != null)
{
btnDelete.Visible = (bool)ViewState["LinkEditing"];
string URL = ((WhatTypeGoesHere)(e.Item.DataItem))["URL"].ToString();
btnDelete.CommandArgument = URL;
}
}
</code></pre>
| c# | [0] |
5,560,428 | 5,560,429 | Autotab input with javascript | <p>I have 3 inputs that need to tab to the next when the max length are reached.
These 3 inputs come with values and when the user change the value of the first input it focus on the next and so on.</p>
<p>My problem is that since my second input has already the length it jumps to the third input. If the use input the values slowly it don't do this.</p>
<p>The source of the problem is that if the typing is too fast the first keyup event is fired after the second type and it fires on the second input.</p>
<p>I've written a <a href="http://jsfiddle.net/pvXuS/4/" rel="nofollow">jsfiddle</a> with the problem and this is my function to wire the auto focus change.</p>
<pre><code> function WireAutoTab(CurrentElement, NextElement) {
CurrentElement.keyup(function (e) {
//Retrieve which key was pressed.
var KeyID = (window.event) ? event.keyCode : e.keyCode;
var FieldLength = CurrentElement.attr('maxlength');
//If the user has filled the textbox to the given length and
//the user just pressed a number or letter, then move the
//cursor to the next element in the tab sequence.
if (CurrentElement.val().length >= FieldLength && ((KeyID >= 48 && KeyID <= 90) || (KeyID >= 96 && KeyID <= 105)))
NextElement.focus();
});
}
</code></pre>
<p>Is there any other event that I can use to prevent this? The behavior that I want is that even if the second input has value, it stops on it.</p>
| javascript | [3] |
1,698,295 | 1,698,296 | ASP.NETand TFS: Getting TF30076 Error | <p>i'm developing an ASP.NET application to deal with TFS server programmatically to list all TFS projects and give the ability to add work items to any TFS project. if i run the application locally using visual studio local host --> every this is running as required.</p>
<p>if i host the application on my iis , i face the following error :</p>
<p>TF30076: The server name {tfsServerName} provided does not correspond to a server URI that can be found. Confirm that the server name is correct.</p>
<p>i don't know what is the difference between the two cases.</p>
<p>any help please ????? </p>
| asp.net | [9] |
382,373 | 382,374 | iPhone: How to create dynamic instances for any built-in class object? | <p>I want to create dynamic instances for a built in class object. I am not sure how to achieve this.
For example, the below audio player object instance i want to create dynamically, so that I can play dynamic multiple data.</p>
<pre><code>audioPlayer = [[AVAudioPlayer alloc] initWithData:pData error:nil];
</code></pre>
<p>instead of this, i want to be something like below,</p>
<pre><code>audioPlayer1 = [[AVAudioPlayer alloc] initWithData:pData error:nil];
audioPlayer2 = [[AVAudioPlayer alloc] initWithData:pData error:nil];
audioPlayer3 = [[AVAudioPlayer alloc] initWithData:pData error:nil];
</code></pre>
<p>Here, 1, 2, 3 can be added dynamically, because i don't know how many i have to add at once, it has to be dynamically created. </p>
<p>I though i can do like, </p>
<pre><code>AVAudioPlayer *[NSString stringWithFormat:@"audioPlayer%d", value] = [[AVAudioPlayer alloc] initWithData:pData error:nil];
</code></pre>
<p>But this is not acceptable.</p>
<p>Could someone help me on this to resolve?</p>
| iphone | [8] |
3,932,817 | 3,932,818 | Reload the view in iphone (in viewWillAppear) | <p>I got a little app that has a button whose click is handled via</p>
<pre><code>- (IBAction)click:(id)sender { }
</code></pre>
<p>Now, what I want is after click() runs, I want the view to refresh/reload itself, so that viewWillAppear() is re-called automatically. Basically how the view originally appears.</p>
<p>Of course I can call viewWillAppear manually, but was wondering if I can get the framework to do it for me?</p>
| iphone | [8] |
1,607,081 | 1,607,082 | Get joined string from list of lists of strings in Python | <p>I have a list of lists and a separator string like this:</p>
<pre><code>lists = [
['a', 'b'],
[1, 2],
['i', 'ii'],
]
separator = '-'
</code></pre>
<p>As result I want to have a list of strings combined with separator string from the strings in the sub lists:</p>
<pre><code>result = [
'a-1-i',
'a-1-ii',
'a-2-i',
'a-2-ii',
'b-1-i',
'b-1-ii',
'b-2-i',
'b-2-ii',
]
</code></pre>
<p>Order in result is irrelevant.</p>
<p>How can I do this?</p>
| python | [7] |
4,975,195 | 4,975,196 | Fragment does not show when switching between tabs on TabHost | <p>i have a tab host with three tabs ,two of them have activities that contain the same subclass of Fragment (i am testing the behaviour of the fragment on different positions) .So when i switch from the first tab to the second the Fragment shows succesfully ,but when i come back to the fisrt nothing is on screen .May be it is a problem of lifecycle ,can someone help me to figure out a solution to that ?</p>
<p>for informations,i am working with android.support.v4 package .</p>
| android | [4] |
3,937,091 | 3,937,092 | Sublime Text 2 not detecting python library if installed in /opt | <p>I am attempting to install <a href="http://www.sublimetext.com/" rel="nofollow">Sublime Text 2</a> in /opt/sublime_text. Once all the files are in there, I believe the executable not detecting the python libraries and throwing the following error:</p>
<p><img src="http://i.stack.imgur.com/PC5xV.png" alt="enter image description here"></p>
<ul>
<li>I have python installed on my system already (2.7.3).</li>
<li>I am able to run Sublime Text 2 from my home directory.</li>
</ul>
<p>I've tried copying just the <code>__future__.pyo</code> file into the /opt/sublime_text folder but I get the same error message.</p>
<p>Is there a solution which doesn't require me to extract all of the python libraries in the application folder?</p>
| python | [7] |
1,017,272 | 1,017,273 | Scroll position lost when hiding div | <p><a href="http://jsfiddle.net/cbp4N/16/" rel="nofollow">http://jsfiddle.net/cbp4N/16/</a></p>
<p>If you show the div. Change the scroll position and then hide and show it agian the scroll position is lost. </p>
<p>am I doing anything wrong or is this a bug.
Is there a way round it with som plugins.</p>
<p>/Anders</p>
<p>Thanks for the answers and solutions. But what if the div that I hide is a outer div and the scrolling div is deep inside the div I hide. Is there a smart way to also fix this. Becuse now I cant set/save the scroll position in the callback of the hide/show</p>
| jquery | [5] |
2,838,144 | 2,838,145 | Is it possible to change the title of a tab in a tabbed content while using tabber.js? | <p>I am using tabber.js script for creating a tabbed content and I would like to change the title of a tab during an onclick event.</p>
<p>I tried setting the title like this,
document.getElementById("mytab1").title = "New Title";</p>
<p>But this does not work.. Any other ideas?</p>
<p>Thanks </p>
| javascript | [3] |
2,349,899 | 2,349,900 | PHP - url question | <p>How can I turn example 1 into example 2 using PHP</p>
<p>Example 1</p>
<pre><code>http://www.example.com/categories/fruit/apple/green
</code></pre>
<p>Example 2</p>
<pre><code>http://www.example.com/categories/index.php?cat=fruit&sub1=apple&sub2=green
</code></pre>
| php | [2] |
2,520,524 | 2,520,525 | How can I have my activity display in android contact menu, like i.e. facebook app? | <p>I would like to launch my android application from a contact menu which is displayed after clicking on a contact shortcut on android desktop, like on attached graphic.</p>
<p>I couldn't find any materials on this in docs, but I think it should be possible, as i.e. facebook application puts it's icon in this menu. I tried to find something in it's AndroidManifest.xml file but with no effect (I'm not familiar with android development so I don't even know what to look for - Activity, intent, intent-filter, provider?</p>
<p>I would appreciate link to docs or at least hint on terminology to google for.</p>
<p>//edit</p>
<p>It seems that my question is duplicate of : <a href="http://stackoverflow.com/questions/8858819/how-to-integrate-your-app-in-quick-contact-on-the-native-contact-app-on-android">How to integrate your app in QUICK CONTACT on the native contact app on android?</a> which has some helpful resources.</p>
<p><img src="http://i.stack.imgur.com/DkJwn.png" alt="screenshot showing the menu"></p>
| android | [4] |
761,803 | 761,804 | Trying to keep age/name pairs matched after sorting | <p>I'm writing a program where the user inputs names and then ages. The program then sorts the list alphabetically and outputs the pairs. However, I'm not sure how to keep the ages matched up with the names after sorting them alphabetically. All I've got so far is...</p>
<p>Edit: Changed the code to this -</p>
<pre><code>#include "std_lib_facilities.h"
struct People{
string name;
int age;
};
int main()
{
vector<People>nameage;
cout << "Enter name then age until done. Press enter, 0, enter to continue.:\n";
People name;
People age;
while(name != "0"){
cin >> name;
nameage.push_back(name);
cin >> age;
nameage.push_back(age);}
vector<People>::iterator i = (nameage.end()-1);
nameage.erase(i);
}
</code></pre>
<p>I get compiler errors for the != operator and the cin operators. Not sure what to do. </p>
| c++ | [6] |
643,795 | 643,796 | .net functions of an exe used in excel. how to use some of the variables of the exe which may change in other functions or on load? | <p>I am using some of the functions of .net application in excel through COM. But whenever i call some function of the .net, i need to open exe and send some values to the form of the exe and use some of the values from the running exe. How do i do this? please help..</p>
| c# | [0] |
590,218 | 590,219 | Working with delegate method in pickerview | <p>i'm working with pickerview.. here the problem is, while changing the interface orientation the viewForRow method should call.But,here the delegate method is working only for the zero component and not for the another component.. here the problem is only for the device with ios5 remaining are working proper.Any suggestions pls....</p>
| iphone | [8] |
3,895,227 | 3,895,228 | Set reminder to Calendar without UIInteraction | <p>I want to set reminder to calendar without user interface. means i have NSDate object to be set to calendar. how can it be done. i have gone through the UIEventKit framework. but it require UI interaction .</p>
<p>Looking for yr suggestion.</p>
| iphone | [8] |
398,641 | 398,642 | Tab icon guidelines and icons in general | <p>i recently downloaded a free app and noticed that the icons on the apps tab were colored. and had a slight 3d perspective. so i just wanted to find out if there is anything wrong doing this in a commercial related application. because from reading the icons guideline documentation for android, they kind of sound very strict on things like that. </p>
<p>so are we allowed to create what is pleasing in the eyes and override the guidelines?.. ;)</p>
| android | [4] |
4,158,243 | 4,158,244 | What is the usage of else: after a try/except clause | <blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/1316002/when-is-it-necessary-to-add-an-else-clause-to-a-try-except-in-python">when is it necessary to add an <code>else</code> clause to a try..except in Python?</a><br>
<a href="http://stackoverflow.com/questions/855759/python-try-else">Python try-else</a> </p>
</blockquote>
<pre><code>for arg in sys.argv[1:]:
try:
f = open(arg, 'r')
except IOError:
print 'cannot open', arg
else:
print arg, 'has', len(f.readlines()), 'lines'
f.close()
</code></pre>
<p>What is usage of this else clause, and when will it be executed? </p>
| python | [7] |
1,399,580 | 1,399,581 | Java Design confusion | <p>I am having a bit of trouble with the design aspect of my JAVA program, there a couple of ways in which I have thought of doing, but I dont know which way is best, or if there is a better way to do it?. Below is an example of one way</p>
<pre><code> << ABSTRACT >>
Rooms class
extends extends extends
Room TYPE U Connector X Connector U
AGGREGATE walls - into each room type
</code></pre>
<p>The reason why I am getting a bit confused is that the 3 different types of rooms that I am using only differ in there property values(height,width etc..), but all have the same properties. Does this warrant creating a new class for EACH room type?.</p>
<p>Or should I do it the other way which is having the one rooms class and instantiating it three times for each room type and just changing its properties via setters and getters?.</p>
<p>because I would have to set each rooms properties and its aggregated wall properties which could get quite long!.</p>
<p>Any help is greatly appreciated.</p>
| java | [1] |
5,756,459 | 5,756,460 | can I use "lock" across projects? | <p>I have project and class library.
I need class library to update storage items. In my project i need to access these storage items. Can I use <code>lock</code> on the same instance from different projects and will this work?</p>
| c# | [0] |
199,534 | 199,535 | Write to specific line in PHP | <p>I'm writing some code and I need to write a number to a specific line. Here's what I have so far:</p>
<pre><code><?php
$statsloc = getcwd() . "/stats/stats.txt";
$handle = fopen($statsloc, 'r+');
for($linei = 0; $linei < $zone; $linei++) $line = fgets($handle);
$line = trim($line);
echo $line;
$line++;
echo $line;
</code></pre>
<p>I don't know where to continue after this. I need to write $line to that line, while maintaining all the other lines.</p>
| php | [2] |
108,402 | 108,403 | Leave While Loop? | <p>I can't get out of the While Loop in my code and out of the method. The user has the option to enter 1 or 2 and 0 to cancel(to leave the menu and the method). But as the code are now, I guess the default option in the Switch prevent it from leaving the While Loop!? Can I do it in another and better way?</p>
<pre><code> // Read user input
public void ReadUserInput()
{
Console.Write("Your choice? ");
int choice = -1;
while (choice != 0)
{
if (int.TryParse(Console.ReadLine(), out choice))
{
switch (choice)
{
case 1:
ShowSchedule(1);
break;
case 2:
ShowSchedule(2);
break;
default:
ErrorMessage(); // Call method to show error message
ReadUserInput(); // Call method for new input
break;
}
}
else
{
// Call method to show error message
ErrorMessage();
Start();
}
}
}
</code></pre>
| c# | [0] |
5,203,167 | 5,203,168 | Writing to a log, inside a timer, that's inside a thread, from another thread | <p>I'm working on writing an application that scans an imageboard for images, then downloads them. Ofcourse this has to be threaded, because multiple boards could be scraped at once. I've got the basic funcionality done already, but now I'm hitting a wall.</p>
<p>Currently I start threads by giving an url, then press a button, this button starts a thread which points to a class.</p>
<p>My problem resides inside this class, as I'm using a timer there.</p>
<p>Currently the data gets pushed to the log at one go, but should be pushing the data as it is set. </p>
<p>Currently this is my function that is bound to the tick event of my timer:</p>
<pre><code> public void scanForImages(object s, ElapsedEventArgs e)
{
if (status != 1 && status != 4)
{
status = 1;
int i = 0;
while (status == 1)
{
main.updateLog(th.Name + ": Blaat\n");
i++;
if (i > 50)
{
status = 4;
t.Stop();
main.updateThreads("Aborting: " + th.Name, th);
th.Abort();
}
}
}
else
{
t.Stop();
}
}
</code></pre>
<p>It is returning output in my textbox, but it's pushing everything at once( All the <code>th.Name + ": Blaat\n"</code></p>
<p>updateLog:
public void updateLog(string txt)
{ </p>
<pre><code> if (InvokeRequired)
{
Action action = () => textBox2.AppendText(txt);
textBox2.Invoke(action);
}
else
{
textBox2.AppendText(txt);
}
}
</code></pre>
<p>What am I doing wrong? (More code can be supplied, if neccessary)</p>
| c# | [0] |
405,832 | 405,833 | PHP base navigation help | <p>currently i have :</p>
<pre><code>$page = basename($_SERVER['REQUEST_URI']);
<li<?php if($page == 'index.php?page=product') print ' id="current"'; ?>><a href="index.php?page=product">Products</a></li>
</code></pre>
<p>but however when url is something like index.php?page=product&item=100</p>
<p>the class 'id=current' doesn't apply.</p>
<p>any workaround? </p>
<p>thank you for help.</p>
| php | [2] |
175,500 | 175,501 | Javascript split to split string in 2 parts irrespective of number of spit characters present in string | <p>I want to split a string in Javascript using split function into 2 parts.</p>
<p>For Example i have string:</p>
<pre><code>str='123&345&678&910'
</code></pre>
<p>If i use the javascripts split, it split it into 4 parts.
But i need it to be in 2 parts only considering the first '&' which it encounters.</p>
<p>As we have in Perl split, if i use like:</p>
<pre><code>($fir, $sec) = split(/&/,str,2)
</code></pre>
<p>its splits str into 2 parts, but javascript only gives me:</p>
<pre><code>str.split(/&/, 2);
fir=123
sec=345
</code></pre>
<p>i want sec to be:</p>
<pre><code>sec=345&678&910
</code></pre>
<p>How can i do it in Javascript.</p>
| javascript | [3] |
3,738,041 | 3,738,042 | Dynamic id name in jquery | <p>I have this code to add class and remove attribute,but the problem is that I have dynamic id name who depends from row id. I try with <code>'#ee'+x</code> but doesn't work. Please help, how can I set dynamic value in jQuery </p>
<pre><code>$('#ee').change(function(){
if ($(this).is(":checked")) {
$('#we').addClass("hide");
$('.re').removeAttr('checked');
}
else {
$('#we').removeClass("hide");
}
});
</code></pre>
| jquery | [5] |
2,888,410 | 2,888,411 | Customize Keyboard | <p>How we can make a custom keyboard with button on top next,previous and done..</p>
| iphone | [8] |
3,742,256 | 3,742,257 | Android loading in images of with different dpi, some do not appear | <p>I'm loading external images from a url, which they are all the same resolution. However, the images that are below 100dpi do not appear. The rest are 100 dpi and they do appear.</p>
<p>I can't wrap my head around this dpi resolution concept, and why I can't use these images even though they are the same resolution at the others.</p>
<p>I've added two test images. Could someone try to add these images externally to imageViews? I want to see if you are able to display them.</p>
<p><a href="http://bloggr.geespot.ca/offbroadway-poster.jpg" rel="nofollow">http://bloggr.geespot.ca/offbroadway-poster.jpg</a><br>
<a href="http://bloggr.geespot.ca/eppleworth.jpg" rel="nofollow">http://bloggr.geespot.ca/eppleworth.jpg</a></p>
| android | [4] |
1,591,186 | 1,591,187 | Blink image with JQuery | <p>Is it possible to blink a image with JQuery?</p>
<p>I need to blink certain image with specific class. It should work in both IE and firefox</p>
| jquery | [5] |
4,765,514 | 4,765,515 | Global Variable Count | <p>How to count the number of global variables in C++ with a program that I can run with Grep?</p>
| c++ | [6] |
1,194,748 | 1,194,749 | calculating values from input, in PHP | <p>I'm studying for finals and i came across this question:</p>
<blockquote>
<p>Write a php script to read a positive integer, n from a input box and calculate the value of 1+2+-- n...</p>
</blockquote>
<p>ive have tried for long and done sufficient research, but i have not been able to complete this so far i have:</p>
<pre><code><html>
<head>
<title>
</title>
</head>
<body>
<form action="inputnum.php" method="post" >
num:<input type="text" name="num" size ="5"/>
<input type = "submit" value = "Submit Order" />
<?php
$num=$_POST["num"];
if ($num==0)$num=="";
for($i=0; $i<=$num; $i++){
}
echo"($num+$i)";
?>
</form>
</code></pre>
<p>
</p>
<p>can anyone help me out?
Thanks in advance!</p>
| php | [2] |
70,913 | 70,914 | Which function to call? (delegate to a sister class) | <p>I just read about this in the C++ FAQ Lite</p>
<p>[25.10] What does it mean to "delegate to a sister class" via virtual inheritance?</p>
<pre><code> class Base {
public:
virtual void foo() = 0;
virtual void bar() = 0;
};
class Der1 : public virtual Base {
public:
virtual void foo();
};
void Der1::foo()
{ bar(); }
class Der2 : public virtual Base {
public:
virtual void bar();
};
class Join : public Der1, public Der2 {
public:
...
};
int main()
{
Join* p1 = new Join();
Der1* p2 = p1;
Base* p3 = p1;
p1->foo();
p2->foo();
p3->foo();
}
</code></pre>
<p>"Believe it or not, when Der1::foo() calls this->bar(), it ends up calling Der2::bar(). Yes, that's right: a class that Der1 knows nothing about will supply the override of a virtual function invoked by Der1::foo(). This "cross delegation" can be a powerful technique for customizing the behavior of polymorphic classes. "</p>
<p>My question is:</p>
<ol>
<li><p>What is happening behind the scene.</p></li>
<li><p>If I add a Der3 (virtual inherited from Base), what will happen? (I dont have a compiler here, couldn't test it right now.)</p></li>
</ol>
| c++ | [6] |
4,727,928 | 4,727,929 | Static members in Java | <p>I've read Statics in Java are not inherited. I've a small program below which compiles and produces <code>2 2</code> as output when run. From the program it looks like k (a static variable) is being inherited !! What am I doing wrong?</p>
<pre><code>class Super
{
int i =1;
static int k = 2;
public static void print()
{
System.out.println(k);
}
}
class Sub extends Super
{
public void show()
{
// I was expecting compile error here. But it works !!
System.out.println(" k : " + k);
}
public static void main(String []args)
{
Sub m =new Sub();
m.show();
print();
}
}
</code></pre>
| java | [1] |
4,381,998 | 4,381,999 | File type is returning null in chrome browser | <p>I have used file uploader(used PHP) in my application.</p>
<p>In FireFox, and Internet Explorer8 working when I try below statement.</p>
<pre><code>print $_FILES['upladed']['type'];
</code></pre>
<p>But in chrome I am getting null value(not printing anything).</p>
<p>If I use <code>var_dump($_FILES['upladed']['type']);</code> then I am getting result as</p>
<pre><code>string '' (length=0)
</code></pre>
<p>Please suggest some pointers.</p>
<p>Thanks</p>
<p>-Pravin</p>
| php | [2] |
1,268,489 | 1,268,490 | final table and add elements in android | <p>I have a final table:</p>
<pre><code> final Item itemsList[] = new Item[]{
new Item(R.drawable.per1,contacts.get(0).getName(),contacts.get(0).getTitle(), contacts.get(0).getPhone(),contacts.get(0).getTitle(),contacts.get(0).getEmail())
};
</code></pre>
<p>And this is my problem. I want to add to this table more than one element. Elements I get from list "contacts". And If I have 10 elements in list "contacts" I want to add to "itemList" 10 elements but I can't do this because my itemList is final and it must be final, because I need this way. How I can add number of elements to itemList dynamically?</p>
| android | [4] |
2,115,651 | 2,115,652 | Static class object | <p>Why are static class objects allowed in C++? what is their use?</p>
<pre><code>#include<iostream>
using namespace std;
class Test {
static Test self; // works fine
/* other stuff in class*/
};
int main()
{
Test t;
getchar();
return 0;
}
</code></pre>
| c++ | [6] |
5,798,256 | 5,798,257 | microsoft agent for asp.net website | <p>hi is there a possibility of creating an agent like Microsoft office agent for a website.
i am planning to build one for my website.
any help in this context would be highly appreciable. thanks</p>
| asp.net | [9] |
18,810 | 18,811 | check if div contains li then removing another element using jquery | <p>If <code>div#FeatureIconsWrapper</code> contains NO <code>li</code></p>
<p>Then <code>div#productInfoGrid</code> is hidden by either by css or removed completly.</p>
<p>I have tried(is this correct?):</p>
<pre><code>$("div#FeatureIconsWrapper:not(li)")({
$("div#productInfoGrid").hide();
});
</code></pre>
| jquery | [5] |
2,468,089 | 2,468,090 | Explanation about a Java statement | <pre><code>public static void main(String[] args) {
int x = 1 + + + + + + + + + 2;
System.out.println(x);
}
</code></pre>
<p>I can compile above method. Is there any explanation about the allowed multiple "+" operator?</p>
| java | [1] |
1,291,127 | 1,291,128 | Invalid length for a Base-64 char array | <p>I'm receiving this error from one of our web pages: "Invalid length for a Base- char array".</p>
<p>This is the stacktrace from my exception:</p>
<pre><code>at System.Convert.FromBase64String(String s)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState)
at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState)
at System.Web.UI.SessionPageStatePersister.Load()
</code></pre>
<p>Code behind .cs:</p>
<pre><code>protected override PageStatePersister PageStatePersister
{
get
{
return new SessionPageStatePersister(Page);
}
}
</code></pre>
<p>What would cause this error?</p>
<p>Thanks,
saj</p>
| asp.net | [9] |
2,012,031 | 2,012,032 | How to create dynamic String Array if we dont know number of strings in the beginning? | <p>I have the HashMap, if i want to create string array of hashmap.values(), we can create it as</p>
<pre><code>String[] strArray = new String[hashmap.size()]
</code></pre>
<p>But my problem is, if hashmap value contains for example "A,B,C" then i need to add A and B and C to strArray. <strong><em>Facing issue in creating dynamic HashMap.</em></strong> </p>
| java | [1] |
5,385,879 | 5,385,880 | alias for int32,int64 | <pre><code>class Program
{
static void Main(string[] args)
{
Int64 a = Int64.MaxValue;
Int64 b= Int64.MinValue;
try
{
checked
{
Int64 m = a * b;
}
}
catch (OverflowException ex)
{
Console.WriteLine("over flow exception");
Console.Read();
}
}
}
</code></pre>
<p>if the variables are declared as int, i am getting the compilation error, conversion is requreid from int to long.</p>
<ol>
<li>why am I getting this error although i am using int.</li>
<li>What are the alias <code>Int32</code> and <code>Int64</code></li>
<li>When to use <code>Int32</code> and <code>Int64</code>, does it depend on OS?</li>
</ol>
| c# | [0] |
196,257 | 196,258 | Repeater Item template loading | <p>On a web page I have a repeater that I want to assign a template to it:</p>
<pre><code> repeater1.ItemTemplate = Page.LoadTemplate("Template.ascx");
</code></pre>
<p>On this template i have a buttons. I need to handle the Click events of those buttons.<br />
Is it possible to handle then on web page's codebehind file or I must create a codebehind file for Template.ascx? </p>
<p>Because if create a codebehind for Template.ascx I can't access properties that were declared on the web page.</p>
| asp.net | [9] |
124,626 | 124,627 | Is it required to learn Python 2.6 along with Python 3.0? | <p>If I learn python 3.0 and code in it, will my code be still compatible with Python 2.6 (or 2.5 too!)?</p>
<p><hr></p>
<p>Remarkably similar to:</p>
<p><a href="http://stackoverflow.com/questions/410609/if-im-going-to-learn-python-should-i-learn-2-x-or-just-jump-into-3-0/410626">If I'm Going to Learn Python, Should I Learn 2.x or Just Jump Into 3.0?</a></p>
| python | [7] |
3,259,103 | 3,259,104 | How to lock back button | <p>I want to lock back button while my data process.
I use AsyncTask to process data as below:</p>
<pre><code>class Process extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
progDailog = new ProgressDialog(ShareFolderActivity.this.getParent());
progDailog.setMessage("Loading...");
progDailog.setIndeterminate(false);
progDailog.setMax(100);
progDailog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
progDailog.setCancelable(true);
progDailog.show();
lock = true;
}
@Override
protected String doInBackground(String... aurl) {
//process
return null;
}
@Override
protected void onPostExecute(String unused) {
super.onPostExecute(unused);
PostLoad();
progDailog.dismiss();
lock = false;
}
}
</code></pre>
<p>And below onBackPressed():</p>
<pre><code>@Override
public void onBackPressed() {
if(!lock) {
//back action
}
}
</code></pre>
<p>When at doInBackground back button be pressed, the back action not do, but the progDailog dismiss.
How can I modify to avoid it dismiss?</p>
| android | [4] |
4,636,200 | 4,636,201 | Find time until a date in Python | <p>What's the best way to find the time until a date. I would like to know the years, months, days and hours. </p>
<p>I was hoping somebody had a nice function. I want to do something like: This comment was posted 2month and three days ago or this comment was posted 1year 5months ago.</p>
| python | [7] |
4,981,168 | 4,981,169 | Jquery, How to get prev() input box value? | <pre><code><tr>
<td>Arizona</td>
<td>AZ</td>
<td>
<input id="item_Rate" name="item.Rate" size="5" type="text" value="1.00" />
</td>
<td>
<a href="javascript:UpdateTaxRate(this, 4)">Update</a>
</td>
</tr><tr>
<td>Arkansas</td>
<td>AR</td>
<td>
<input id="item_Rate" name="item.Rate" size="5" type="text" value="2.00" />
</td>
<td>
<a href="javascript:UpdateTaxRate(this, 5)">Update</a>
</td>
</tr><tr>
<td>California</td>
<td>CA</td>
<td>
<input id="item_Rate" name="item.Rate" size="5" type="text" value="3.00" />
</td>
<td>
<a href="javascript:UpdateTaxRate(this, 6)">Update</a>
</td>
</tr>
</code></pre>
<p>I have like above table, and I want to get the previous DOM input box value when I click the update.</p>
<p>How can I get that?</p>
| jquery | [5] |
5,971,527 | 5,971,528 | Yielding a dictionary containing an object's attributes in Python | <p>I'm currently trying to write a piece of code that will dump all attributes of a given class instance to a dictionary so that I can change them without changing the source object. Is there a method for doing this, or perhaps a built-in dictionary I can copy and access?</p>
<p>What I'm really doing is making a special class that copies the actual attributes (and their corresponding values) from instances of varying other classes. Basically it would mimic any instance of any class.</p>
<p>For example, object x has attributes x.name and x.number, "Joe" and 7, respectively. I want my new object mimic, object y, to copy the attributes so that y now has attributes y.name and y.number, "Joe" and 7.</p>
<p>Thanks!</p>
<p><strong>EDIT:</strong> <em>I found what I was looking for shortly after posting this!</em></p>
<p><a href="http://stackoverflow.com/questions/61517/python-dictionary-from-an-objects-fields">Python dictionary from an object's fields</a></p>
<p>That's pretty much all I needed to know.</p>
| python | [7] |
1,255,270 | 1,255,271 | Python variable assignment confusion | <p>Why is it that when I do the following:</p>
<pre><code>x = y = {}
</code></pre>
<p>Everytime I modify, x like <code>x[1] = 5</code>, I also end up modifying y and vice versa?</p>
| python | [7] |
5,405,294 | 5,405,295 | javascript var declaration within loop | <pre><code>/*Test scope problem*/
for(var i=1; i<3; i++){
//declare variables
var no = i;
//verify no
alert('setting '+no);
//timeout to recheck
setTimeout(function(){
alert('test '+no);
}, 500);
}
</code></pre>
<p>it alerts "setting 1" and "setting 2" as expected, but after the timeout it outputs "test 2" twice - for some reason the variable "no" is not reset after the first loop...</p>
<p>i've found only an "ugly" workaround...</p>
<pre><code>/*Test scope problem*/
var func=function(no){
//verify no
alert('setting '+no);
//timeout to recheck
setTimeout(function(){
alert('test '+no);
}, 500);
}
for(var i=1; i<3; i++){
func(i);
}
</code></pre>
<p>Any ideas on how to workaround this problem in a more direct way? or is this the only way?</p>
| javascript | [3] |
2,084,854 | 2,084,855 | Why is there no "++" operation in Python? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3654830/why-there-are-no-and-operators-in-python">Why there are no ++ and — operators in Python?</a> </p>
</blockquote>
<p>This question may seem strange, but I'm wondering why is there no such operation in Python.<br /><br />
I know, <code>x += 1</code> is almost as simple as <code>x++</code>, but still. There is such operation in most languages I'm familiar with (C, C++, Java, C#, JavaScript, PHP), but there isn't in Python.<br /><br />
Maybe it has something to do with the phylosophy of this language?</p>
| python | [7] |
4,066,346 | 4,066,347 | Understanding large Java Code Base | <p>Are there resources on going about trying to understand a large java code base. Like for example, a graph persistence implementation. If there is minimal / missing documentation, what kinds of approaches do you take ? Are there any books that deal with this ? I know one called Brownfield App Development in .NET. </p>
<p>Perhaps something similar ?</p>
| java | [1] |
1,348,999 | 1,349,000 | I want to get data from two tables.my query is giving data but WHERE clouse is not giving me data which i want | <p>i have two tables DISCIPLINE and SUBJECT.</p>
<p>DISCIPLINE table has _DISCIPLINE_ID as a primary key and a DISCIPLINE_Name column.</p>
<p>SUBJECT table has _SUBJECT_ID as a primary key SUBJECT_Name and DISCIPLINE as a Forign key.
i want to select Subject from SUBJECT table Who has the same _DISCIPLINE_ID in the DISCIPLINE table.</p>
<p>here is my query:</p>
<pre><code>SELECT DISCIPLINE._DISCIPLINE_ID,
SUBJECT.SUBJECT_Name
FROM DISCIPLINE,
SUBJECT
WHERE SUBJECT.DISCIPLINE = DISCIPLINE._DISCIPLINE_ID
</code></pre>
<p>it gives me data but it selects all the Subjects and DISCIPLINE.</p>
| android | [4] |
4,530,847 | 4,530,848 | Detect broken internet connection whenever the application is running | <p>I'm already using the code below to detect if the user is connected to the internet at the application's splash screen, but I need to detect this whenever the user is in a specific activity. Imagine you are using turn-by-turn navigation and you depend on internet connection, so you must detect a broken internet connection when it happens. </p>
<p>How can I do this without slowing down the app with an infinite loop?</p>
<pre><code>private boolean isOnline(Context context) {
try {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
} catch (Exception exc) {
return false;
}
}
</code></pre>
| android | [4] |
5,287,745 | 5,287,746 | Values are not displaying on TextView | <p>I have a couple issues with a math program im currently working on im trying to make a delete button so the user can remove any mistake made and also i want to append("0") but it does nothing when i press both buttons. When i append values from 1-9 it displays it but wierdly it does nothing when pressing delete and one. answer is a TextView. Any ideas would be appreciated.</p>
<pre><code> case R.id.delete:
answer.append("");
break;
case R.id.zero:
answer.append("0");
break;
</code></pre>
| android | [4] |
1,977,569 | 1,977,570 | Why does the assignment operator return anything | <p>I have been thinking about this for a while. Especially since assignment operator is called on objects that have already been allocated a space on the heap/stack. While researching on this topic I came across the following <a href="http://faculty.cs.niu.edu/~hutchins/csci241/assignop.htm" rel="nofollow">link</a> which states that the purpose of returning a reference is merely for the sake of chaining. Is that the only reasoning for returning a reference form an assignment operator ?</p>
| c++ | [6] |
1,492,606 | 1,492,607 | What is wrong with the program | <p>I am getting error for below code:</p>
<pre><code>#include "parent_child.h"
#include "child_proces.h"
int main() {
childprocess::childprocess(){}
childprocess::~childprocess(){}
/* parentchild *cp = NULL;
act.sa_sigaction = cp->SignalHandlerCallback;
act.sa_flags = SA_SIGINFO;
sigaction(SIGKILL, &act, NULL);
}*/
printf("Child process\n");
return 0;
}
</code></pre>
<blockquote>
<p>ERROR: child_proces.cpp: In function âint main()â:
child_proces.cpp:11: error: expected <code>;' before â{â token
child_proces.cpp:12: error: no matching function for call to
âchildprocess::~childprocess()â child_proces.h:9: note: candidates
are: childprocess::~childprocess() child_proces.cpp:12: error:
expected</code>;' before â{â token</p>
</blockquote>
| c++ | [6] |
3,696,922 | 3,696,923 | asp.net logout authentication how to code? | <p>have completed the basic user login asp.net authentication services as well as the web data service. Now I am supposed to add the logout service. I was told that when the user logs out currently, 'they are not really logged out' in fact what happens is that you can back browser back into the app it reloads, so it is a security problem as you can imagine.
I am looking at some code from another developer here, is that all I need then the last bit about the logout? How to I call this method? Currently the logout is quite simple here: </p>
<pre><code><HyperlinkButton content="Logout" NavigateURI="Http://www.mymainwebsite.com" />
</code></pre>
<p>how to code it now with respect to the logout authentication issue?</p>
<hr>
| asp.net | [9] |
4,622,232 | 4,622,233 | copying elements of an array-list to the other array-list | <p>I have written such a simple code:</p>
<ul>
<li><p>I have written this line in my class's constructor : <code>List element = new ArrayList();</code></p></li>
<li><p>I have a variable named <code>cost</code> which its type is <code>int</code> </p></li>
<li><p>one method will return three lists with different objects: <code>listOne, listTwo, listThree</code></p></li>
<li><p>in another method I have written below code which this method will use those lists that are created in the method above.this method will be called three times for three lists above. each call for each list.</p>
<pre><code>// begining of the method:
int cost = 0;
if(cost==0){
element = listOne;
cost = 3;
}
if(cost<4){
element = listtwo;
cost = 6;
}
// end
System.out.println(element.toString());
</code></pre></li>
</ul>
<p>Unfortunately, instead of printing <code>listTwo</code> it will print <code>listThree</code> (if we have 4 or more lists it will print the last one)!</p>
<p>Is there any problem with if-else condition?</p>
<p>thanks</p>
<p>EDIT: this is my main code but its condition is like the code above:
<code>auxiliaryList</code> in the code below is <code>listOne</code> or <code>list Two</code> or <code>listThree</code> respectively.</p>
<pre><code>cost = 0;
public void method {
System.out.println(element.toString());//number one
if (cost== 0) {
element = auxiliaryList;
cost = 3;
}
else if( cost<4){
element =auxiliaryList;
cost = 6;
}
}
return;
}
}
</code></pre>
<p>also the line which is declared with <code>//number one</code> shows me that before going to the if/else condition ,the element list will be set to the current list in the method.</p>
| java | [1] |
1,871,734 | 1,871,735 | PHP: Forcing a download not working | <p>I have the following code to push a zip file for download.</p>
<pre><code>$filename = "ResourcePack_".time().".zip";
$destination = $basepath."downloads/$filename";
if($this->createdownload($files,$destination,false)){
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Length: ". filesize("$destination").";");
header("Content-Disposition: attachment; filename='$filename'");
header("Content-Type: application/octet-stream; ");
header("Content-Transfer-Encoding: binary");
ob_end_flush();
@readfile($destination);
if(file_exists($destination)){
unlink($destination);
}
}
</code></pre>
<p>I know the createdownload function is working to generate the zip file just fine because I see the file being created on the server. The problem is file is being written to the browser as a bunch of garbage instead of opening a download stream. Am I missing something in my headers?</p>
<h1>EDIT</h1>
<p>I was right. My problem is not with the php, but that calling the php file that generates this code via a JQuery $.ajax call is the problem. Using $.ajax automatically sets the Accept-Encoding request header to values incompatible with zip files. So, intead of using $.ajax I just used a simple window.open javascript command to call the same php page and it works just fine with the headers.</p>
| php | [2] |
1,500,102 | 1,500,103 | difference between streams | <p>What is the difference between all these classes such as StreamReader, BufferedStream, FileStream, MemoryStream?</p>
| c# | [0] |
3,226,873 | 3,226,874 | implementing authentication in soap header | <p>i am trying to create a soap server in Java. i want to implement the authentication at soap header.
so when soap client is querying the soap server, first the soap header is verified from soap header and let the client access the soap server functions. </p>
| java | [1] |
1,476,943 | 1,476,944 | alternate CSV row deletion | <p>I have a csv file as follows:</p>
<pre><code>gindex
1
1
2
2
3
3
7
7
</code></pre>
<p>I printed each element twice by mistake. How can I delete each repeated row and get the following results:</p>
<pre><code>gindex
1
2
3
7
</code></pre>
| python | [7] |
218,575 | 218,576 | How can I preserve views and controllers across restart of an application in iPhone? | <p>I am building up a game and want to give user a continue functionality when he restarts the application. So I want to know how to code or what to do to start an application where it left last time.</p>
<p>Is there any sample code available in app center which explains how can this be possible.</p>
<p>Tnx in advance.</p>
| iphone | [8] |
3,507,622 | 3,507,623 | Replace \n by \\n | <p>I have a xml string shown below:</p>
<pre><code>String xml = @"<axislable='ihgyh\nuijh\nkjjfgj'>";
</code></pre>
<p>Now when I try to output the xml it shows <code><axislable='ihgyh\nuijh\nkjjfgj'></code></p>
<p>But my requirement is to break the line like below</p>
<pre><code><axislable='ihgyh
uijh
kjjfgj'>
</code></pre>
<p>I have tried replacing the xml using <code>xml = xml.Replace("\n", "\\n");</code> But it doesnt seems to work.Any ideas how to break the line?</p>
<p>Regards,
Sharmila</p>
| c# | [0] |
2,097,236 | 2,097,237 | How do I exclude elements whose ID ends in a certain suffix using jQuery | <p>I have this jQuery function:</p>
<pre><code>$(this).change(function(){
alert('I changed. ID: ' + $(this).attr("id"));
});
</code></pre>
<p>I need the alert to fire <strong>except</strong> when the id name ends in <code>-0</code>. I think I should be using the <code>$=</code> operator. I cannot figure out how to make it work.</p>
| jquery | [5] |
5,938,233 | 5,938,234 | Jquery Submit form and POST certain values to another script | <p>I have a payment button on a page that submits info to a payment processor and on the same page there is a form with some custom fields that updates a contact info when u submit it.</p>
<p>Im using a jquery script that submits the payment button and at the same time POSTS the values of the form to the updatecontact php script.</p>
<p>But its not working, its not posting the values to the updatecontact php script.</p>
<p>Please take a look at the code below to see if u can discover what am i doing wrong.</p>
<p><a href="http://jsfiddle.net/QunPb/1/" rel="nofollow">http://jsfiddle.net/QunPb/1/</a></p>
<p>The URL where the code is: <a href="http://ofertasclaras.com/envio.php" rel="nofollow">http://ofertasclaras.com/envio.php</a></p>
| jquery | [5] |
5,423,389 | 5,423,390 | Display Images Using Android Native Library | <p>I want to improve the performance of my app by displaying images using android native library in C language.This issue is due to large amount of memory required by the images in my app.</p>
| android | [4] |
3,509,768 | 3,509,769 | Justify the output of bahavior of 'or' keyword | <p>Consider the statement below:</p>
<p>Prob 1:</p>
<pre><code>>>> a="abc"
>>> 'd' or 'e' in a
'd'
</code></pre>
<p>Someone please explain this . I was expecting a True or False ...</p>
<p>Prob 2:</p>
<pre><code>>>> print any(c in a for c in 'da')
True
</code></pre>
<p>Whats happening here ? If i do this ,</p>
<pre><code>>>> (c in a for c in 'da')
<generator object <genexpr> at 0x011E4300>
</code></pre>
<p>As you can see , it gives generator object...What role does 'any' (method,function ??) play
here? And the result ?</p>
<p>Prob 3:</p>
<pre><code>>>> Pattern="sdfdfg"
>>> if '\\'or '^' or '.' in Pattern:
print "yes"
else:print "no"
yes
</code></pre>
<p>How on earth is this "YES" ??</p>
<p>Show me the light someone plz...........</p>
| python | [7] |
3,793,128 | 3,793,129 | spell check text editor plugin | <p>how can I spell check in my text area, I have dictionary which is provided by Javascript spell check but its not working it contains one <code>Testinstall.htm</code> while installing this I got struck in server test,i dont want to use third party tool is there any other way to achieve spell check for text area</p>
<p><code>software:- javascript,html,sql</code></p>
| javascript | [3] |
558,082 | 558,083 | Javascript, why treated as octal | <p>I'm passing as parameter an id to a javascript function, because it comes from UI, it's left zero padded. but it seems to have (maybe) "strange" behaviour?</p>
<pre><code> console.log(0000020948); //20948
console.log(0000022115); //9293 which is 22115's octal
console.log(parseInt(0000022115, 10)); // 9293 which is 22115's octal
console.log(0000033959); //33959
console.log(20948); //20948
console.log(22115); //22115
console.log(33959); //33959
</code></pre>
<p>how can I make sure they are parsing to right numebr they are? (decimal)</p>
<p>EDIT:</p>
<p>just make it clearer:</p>
<p>those numbers come from the server and are zero padded strings. and I'm making a delete button for each one.</p>
<p>like: </p>
<pre><code>function printDelButton(value){
console.log(typeof value); //output string
return '<a href="#" onclick="deleteme('+value+')"><img src="images/del.png"></a>'
}
and
function printDelButton(value){
console.log(typeof value); //output numeric
console.log(value); //here output as octal .... :S
}
</code></pre>
<p>I tried :<code>console.log(parseInt(0000022115, 10)); // 9293 which is 22115's octal</code> and still parsing as Octal</p>
| javascript | [3] |
2,466,472 | 2,466,473 | Detect when the foreground application changes in android? | <p>My app is a service, and I want to do the different tasks according to the different foreground application.</p>
<p>I know that I could get the current foreground application info. by <code>ActivityManager.getRunningAppProcesses()</code>.</p>
<p>However, is there a way to detect when the foreground application changes without polling the foreground application info. periodically?</p>
| android | [4] |
3,121,137 | 3,121,138 | Javascript window.print() defaults to PDF | <p>A print button on a site I am working on opens a new window and populates it with some HTML. I call <code>window.print()</code> which works fine, but the default printer for myself and others who have tested it is always a PDF writer if one is available on the system. Is there a way to open the print dialog box with the appropriate default printer selected so that the user does not have to select their printer every time?</p>
| javascript | [3] |
5,244,191 | 5,244,192 | Javascript:Build xml format | <p>I need to build a xml as
XML: </p>
<pre><code><Root>
<Item1 absord="aa">
<XItem n="a" v="b"/>
<XItem n="a" v="b"/>
<XItem n="a" v="b"/>
</Item1>
<Item1 absord="bb">
<XItem n="a" v="b"/>
<XItem n="a" v="b"/>
<XItem n="a" v="b"/>
</Item1>
</Root>
</code></pre>
<p>I`ve written a js function as below: </p>
<pre><code> function BuildChildXml(s, name,n)
{
var xj=OrchGenericObj.GetXMLObj("<R15></R15>");
var INode1 = xj.createElement("Item1");
INode1.setAttribute("Absord", n)
var INode = xmlnewObj.createElement("XItem");
INode.setAttribute("Name", name);
INode.setAttribute("Urlpath",s);
xj.documentElement.appendChild(INode);
INode1.appendChild(xj)
}
</code></pre>
<p>Output:</p>
<pre><code><Root>
<Item1 absord="aa"/>
<XItem n="a" v="b"/>
<Item1 absord="bb"/>
<XItem n="a" v="b"/>
</Root>
</code></pre>
<p>But i`m not getting the required output.
Please correct the function.</p>
| javascript | [3] |
3,042,847 | 3,042,848 | how to specify the genric type in runtime | <p>I'm having a arraylist which I need to specify the type in runtime.</p>
<pre><code>ArrayList<String> alist = new ArrayList<String>();
</code></pre>
<p>I need to specify the type "String" at runtime. how can I do that.
It should not be static.</p>
| java | [1] |
3,586,859 | 3,586,860 | jquery loop and compare values | <p>Is it possible to use jqueries each loop in this form to dissolve hyperlinks?</p>
<pre><code> $(document).ready(function() {
var toExclude =['http://www.google.com', 'http://example'];
$.each(toExclude, function(key, value) {
$("a[href='+value+']").replaceWith(function(){
var matches = value.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
var domain = matches && matches[1];
return domain;
});
});
});
</code></pre>
| jquery | [5] |
3,154,120 | 3,154,121 | How to cast/ covert List of objects to queue of objects | <p>i need to convert a list of Objects to a Queue maintaining the same order</p>
<p>Any idea how to do it?</p>
<p>Thanks</p>
| c# | [0] |
3,377,801 | 3,377,802 | How to reference an object that was created in a different object | <p>I am testing my two classes with a file called test.py. I am just learning programming so this is just a practice program. There is one atlas(map) and i can put multiple 'robots' inside one map. </p>
<pre><code>#test.py
from Atlas import Atlas
atlas = Atlas()
atlas.add_robot('rbt1')
#atlas.py
from Robot import Robot
class Atlas:
def __init__(self):
...
def add_robot(self, robot, zone = 'forrest'):
self.robot = Robot(robot)
print 'added robot %s to %s' % (robot, zone)
#robot.py
class Robot():
def __init__(self, rbt, zone = 'forrest'):
self.name = rbt
print "%s initiated" % rbt
def step(self, direction):
...
</code></pre>
<p>I use the code "atlas.add_robot('rbt1')" to put a new robot inside the atlas.</p>
<p>I want to be able to control the robot with a command such as "rbt1.step('left')" in test.py.</p>
| python | [7] |
3,934,889 | 3,934,890 | moving text in textview | <pre><code>TextView txt = new TextView(this);
txt.setText(“This is moving text”);
txt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
txt.setTextColor(Color.rgb(187, 88, 15));
txt.setPadding(10, 10, 0, 0);
txt.setEllipsize(TruncateAt.MARQUEE);
txt.setSingleLine();
txt.setMarqueeRepeatLimit(10);
txt.setFocusable(true);
txt.setHorizontallyScrolling(true);
txt.setFocusableInTouchMode(true);
txt.requestFocus();
txt.setTypeface(Typeface.SERIF,Typeface.BOLD);
</code></pre>
<blockquote>
<p>I tried to create the moving text for the textview but it will not moving . i try to use setMarqueeRepeatLimit . how to do it?</p>
</blockquote>
| android | [4] |
765,810 | 765,811 | DropDownList SelectedIndex always = 1 | <p>I have a dropdownlist in a page. The values of all the list items = "0". I have viewstate turned off. When the page posts back, the selected index always = 1 in Page_load event, regardless of the selection in the list. If the values of the list items are different, the selectedIndex has the proper value. Is this normal behavior?</p>
| asp.net | [9] |
1,218,364 | 1,218,365 | Assign numeric results from query to text from array | <p>I'm just learning PHP and I've searched for a while on this, but I'm afraid I may not know exactly how to ask it, so an explanation will probably work best. Basically I have a group by/count query returning 3 records.</p>
<pre><code>Status Total
0 2
1 3
2 2
</code></pre>
<p>On my page I would like to display:</p>
<pre><code>Status Total
Dev 2
Active 3
Arch 2
</code></pre>
<p>So I basically just want to assign the values 0, 1 and 2 to a text value. I've tried creating an array, then assigning the return number field equal to the array.</p>
<pre><code>$_status = array(0 => 'Development', 1 => 'Production', 2 => 'Archive');
while($rowStat = mysql_fetch_assoc($resDev))
{
echo "<tr><td>$_status[$rowStat['status']]</td><td>{$rowStat['devprojects']}</td></tr>";
};
</code></pre>
<p>Any help is much appreciated.</p>
<p>Thanks.</p>
| php | [2] |
5,745,553 | 5,745,554 | toggle on double click, jquery | <p>How do I show or hide a div on double click with jquery?</p>
<pre><code>$("body").dblclick(function() {
$("#plot_on_map_form").show("medium").css({top: event.pageY,left: event.pageX});
},
function() {
$("#plot_on_map_form").css({display:"none"});
}
);
</code></pre>
| jquery | [5] |
4,683,178 | 4,683,179 | How to improve the audio quality of RTSP links | <p>I am using rtsp links to stream audio in my application.</p>
<p>The quality of audio is poor in phone when compared to desktop. Is there a way to improve the audio quality in Android. I am using mediaplayer API's to play the audio.</p>
| android | [4] |
4,928,555 | 4,928,556 | How can I implement similar to the web query feature in Excel in java? | <p>I'm new here and I hope I'm not asking something which has already been answered. I have searched everywhere but am yet to discover an adequate answer.</p>
<p>My objective is fairly simple: I want to create a program which will stream the live gold and silver rates from: <a href="http://www.24hgold.com/english/gold_silver_prices_charts.aspx?money=GBPound" rel="nofollow">this website</a></p>
<p>How would I be able to pinpoint the values that I want to download? Currently, I have managed to implement this using Microsoft Excel's web query feature wherein I am able to select a table from the webpage. However, I want to make it a standalone application.</p>
<p>By the way, I need to retrieve the rates to perform a calculation which is then displayed to the user.</p>
<p>I would greatly appreciate any ideas on how this can be achieved.</p>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.