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 |
|---|---|---|---|---|---|
4,197,748 | 4,197,749 | java: if...else statement might be incorrect in my code | <p>As an output, "Player card" should be outputted with randomly selected suit and value, however it's not with my code. </p>
<p>Is there something missing or I have my if...else statements messed up? I know I can use do...while, but I want to be able to do it with if...else statements.</p>
<pre><code>public static void main(String[] args){
//A new object, player card for the card suit.
Card player = new Card();
//Setting the suit for player card to be displayed randomly
player.setSuit((int) (Math.random()*4));
//Setting the value for player card to be displayed randomly
player.setValue(1 + (int)(Math.random()*12));
//A new object, computer card for the card suit
Card comp = new Card();
//Setting the suit for computer card to be displayed randomly
comp.setSuit((int) (Math.random()*4));
//Setting the value for computer card to be displayed randomly
comp.setValue(1 + (int)(Math.random()*12));
if((comp.getValue()== player.getValue()) && (comp.getSuit() == player.getSuit()))
System.out.println("Player Card: " + player.getValueString() + " of " + player.getSuitString());
System.out.println("Computer Card: " + comp.getValueString() + " of " + comp.getSuitString());
if(player.getValue() > comp.getValue())
System.out.println("Player won!");
else if(player.getValue() < comp.getValue())
System.out.println("Computer won!");
else
System.out.println("Tie!");
</code></pre>
| java | [1] |
4,047,042 | 4,047,043 | Problems Referencing Jquery 1.9.1 but 1.7.1 works fine | <p>I am referencing jQuery like below in my code and it works fine:</p>
<pre><code><script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
</code></pre>
<p>However when I reference the newest version (below) it acts as if there is no jQuery</p>
<pre><code><script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</code></pre>
<p>I'm quiet new to jQuery and I'm not even sure how to test this issue, any help would be greatly appreciated. </p>
<p><strong>Update</strong></p>
<p>Here is a Fiddle to what I'm trying to do:
<a href="http://jsfiddle.net/aeNke/" rel="nofollow">http://jsfiddle.net/aeNke/</a></p>
<p>In 1.7.1 the list is sortable however it does not alert the order,
in 1.9.1 the list is not sortable at all.</p>
<p>The only error my am recieving in the error console is "TypeError: jQuery.curCss is not a function</p>
| jquery | [5] |
2,392,313 | 2,392,314 | How to identify content page loads in a master page dynamically? | <p>I have a master page 'Master1' and i have used a content place holder 'content1' and loads
pages 'Page1' and 'page2' in the 'content1'. Is there any way to identify which page is loaded to the content place holder whether it is 'Page1' or 'Page2' dynamically.</p>
| asp.net | [9] |
4,538,229 | 4,538,230 | how to convert json object into class object | <p>How to convert this json clsError and userId values</p>
<p><strong>String temp="{"clsError":{"ErrorCode":110,"ErrorDescription":" Request Added"},"UserID":36}"</strong></p>
<p>and pass them as parameters</p>
<p><strong>clsError errorObject=new clsError(UserID,clsError);</strong></p>
| android | [4] |
4,036,036 | 4,036,037 | Facing problem while printing KeyCode using jQuery | <p>I have a small requirement that is to print the Keycode when any key is pressed.<br>
Below is my code.. But it doesn't seems to work, Please someone help me </p>
<pre><code>$('document').keyup(function()
{
alert(event.keyCode);
});
</code></pre>
| jquery | [5] |
1,694,013 | 1,694,014 | Showing google maps on a dialog | <p>I have an activity that extends MapActivity.
I want to show map inside a dialog in this activity.
i.e when I click a button it will show a dialog with a mapview, but this crashes because it is howing this exception</p>
<pre><code>Caused by: java.lang.IllegalArgumentException: MapViews can only be created inside instances of MapActivity.
</code></pre>
<p>Please help me.</p>
| android | [4] |
1,764,415 | 1,764,416 | Javascript Copy Object in chain style | <p>I have a declared an Object something like below:</p>
<pre><code>var seriesOptions = {
y: 99
};
</code></pre>
<p>In my code I keep creating adding new objects and add as a property to seriesOptions object :</p>
<pre><code>drilldown = {
x: [90,20,40]
}
categories = {
z: [20,30,40.50]
}
values = {
p:[30,50,60]
}
</code></pre>
<p>Then:</p>
<pre><code>seriesOptions['drilldown'] = drilldown
seriesOptions.drilldown['categories'] = categories;
seriesOptions.drilldown['values'] = values;
</code></pre>
<p>where drilldown, categories and values are another object </p>
<p>Now I have to copy try to copy seriesOptions object into another array <strong>seriesOpts</strong> like in a chain format </p>
<pre><code>if(seriesOpts.length == 0)
seriesOpts.push(seriesOptions);
else
seriesOpts[seriesOpts.length - 1].drilldown = $.extend(true, {}, seriesOptions);
</code></pre>
<p>meaning that the new seriesOptions would be chained under last seriesOptions.drilldown object. </p>
<p>My issue is that I am not able to see the seriesOptions.y value in </p>
<blockquote>
<p>seriesOpts[seriesOpts.length - 1].drilldown</p>
</blockquote>
<p>object? I am expecting something like below:</p>
<blockquote>
<p>seriesOpts[x].y : 99</p>
<p>seriesOpts[x].drilldown.y : 99</p>
</blockquote>
<p>Please let me know what wrong I am doing in my code?</p>
<p>Note I am using $.extend to copy the object to new one. So how can I retain both old and new values like : seriesOpts[x].y and seriesOpts[x].drilldown.y are accessible?</p>
<p>Thanks in advance.</p>
| javascript | [3] |
5,978,096 | 5,978,097 | Generating new ids for table rows | <p>I have developed an expand/collpase data grid where each TR will expand/collapse the child rows within. Also, it can create new TR's with child rows having the ability to expand/collapse using .live() function.</p>
<p>As of now, id's for the parent TR and child TD and hardcoded. Now i have to generate unique id for parent and child rows using jquery. How can i do that..?</p>
<p>Here is the implementation: <a href="http://jsfiddle.net/pixelfx/wJBgt/14/" rel="nofollow">Demo</a></p>
<p>This is how expand/collapse works <a href="http://www.javascripttoolbox.com/jquery/" rel="nofollow">Expand/Collapse logic</a></p>
<p>Thanks,
Ravi.</p>
| jquery | [5] |
798,349 | 798,350 | In Python how to construct a str for help(object) | <p>I need a str object created out of the text displayed in help(some_object).
simply typecasting to str doesn't work.</p>
<pre><code>>>> s = str(help(object))
>>> print s
None
</code></pre>
<p>Whats the correct way to do this ?</p>
| python | [7] |
5,006,169 | 5,006,170 | How to take a screenshot in Java? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/58305/is-there-a-way-to-take-a-screenshot-using-java-and-save-it-to-some-sort-of-image">Is there a way to take a screenshot using Java and save it to some sort of image?</a> </p>
</blockquote>
<p>How to take a screenshot in Java?</p>
| java | [1] |
1,655,224 | 1,655,225 | DOM Element Creation vs. .innerHTML vs. Direct | <p>When generating dynamic content, which way is better to simply create the HTML and insert it into a .innerHTML or to create elements in the DOM directly?</p>
<p>I'm not concerned with complexity or other. Just processing time on the client.</p>
<p>Which is quicker?</p>
<p>If I had to guess in order of efficiency (low processing time) this would be:</p>
<ol>
<li>DOM Creation</li>
<li>.innerHTML property insertion</li>
<li>direct writing</li>
</ol>
<p>This would be inversely related to the complexity of implmenting:</p>
<ol>
<li>direct writing</li>
<li>.innerHTML property insertion</li>
<li>DOM Creation</li>
</ol>
<p>This is a validatin question? Can someone validate that this is the trade-offs for determining how to update the client (i.e. javascript) when considering complexity and speed?</p>
<p><strong>Research:</strong></p>
<p>I'm not concerned with security like they are here->
<a href="http://stackoverflow.com/questions/3027914/jquery-dom-element-creation-vs-innerhtml">InnerHTML vs. DOM - Security</a></p>
<p><a href="http://stackoverflow.com/questions/8461851/what-is-better-appending-new-elements-via-dom-functions-or-appending-strings-w">InnerHTML vs. DOM</a>
This is not a duplicate as it covers only part of my question.</p>
| javascript | [3] |
2,061,627 | 2,061,628 | iphone app and gzip post | <p>I need an iphone app to post data from time to time to a webservice. Can the iphone post the data in a gzip format? if yes, can you point me in the right direction on how to accomplish this</p>
<p>Thanks</p>
| iphone | [8] |
43,778 | 43,779 | How to force android to install app on internal memory | <p>I've an app that i download from private server, it installs ok on most phones but i'm having problems installing it on a HTC Desire C. The phone has no sdcard present. I've searched around and found a manifest setting that should hint at internal storage or say that there is at least no preference to where the app is installed.</p>
<pre><code><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.carefreegroup"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto" >
</code></pre>
<p>This does not work however.</p>
<p>How can i tell android that the app <strong>MUST</strong> be installed on the internal memory</p>
<p>Thanks Matt</p>
| android | [4] |
2,975,929 | 2,975,930 | Hide Battery,Signal and Time on an activity | <p>How can I hide all things like battery,signal and time on an activity.
I am using following code for hiding title:</p>
<pre><code>requestWindowFeature(Window.FEATURE_NO_TITLE);
</code></pre>
<p>But what about rest things hiding? How to do that?</p>
| android | [4] |
1,678,747 | 1,678,748 | Why's PHP complaining about my register_shutdown_function()? | <p>I try to register a shutdown function to log an fatal error. Nice stuff, if it would work for my class...</p>
<p>Inside a method I do this:</p>
<pre><code>register_shutdown_function(array($this, 'handleFatalError'));
</code></pre>
<p>handleFatalError is not static, and it's public:</p>
<pre><code>public function handleFatalErrors() {
if(is_null($e = error_get_last()) === false) {
//mail('your.email@example.com', 'Error from auto_prepend', print_r($e, true));
}
}
</code></pre>
<p>PHP says:</p>
<blockquote>
<p>Warning: register_shutdown_function()
[function.register-shutdown-function]:
Invalid shutdown callback
'ErrorManager::handleFatalError'
passed in ...</p>
</blockquote>
<p>Why's that an invalid callback?</p>
| php | [2] |
2,133,644 | 2,133,645 | Integer storage - Hexadecimal/Octal | <p>I understand that integers are stored in binary notation, but I was wondering how this affects the reading of them - for example:</p>
<p>Assuming </p>
<pre><code>cin.unsetf(ios::dec); cin.unsetf(ios::hex); and cin.unsetf(ios::oct);
</code></pre>
<p>the user inputs</p>
<pre><code>0x43 0123 65
</code></pre>
<p>which are stored as integers. Now assume that the program wants to recognize these values as hex, oct, or dec and does something like this.</p>
<pre><code>void number_sys(int num, string& s)
{
string number;
stringstream out;
out << num;
number = out.str();
if(number[0] == '0' && (number[1] != 'x' && number[1] != 'X')) s = "octal";
else if(number[0] == '0' && (number[1] == 'x' || number[1] == 'X')) s = "hexadecimal";
else s = "decimal";
}
</code></pre>
<p>the function will read all of the integers as decimal. I put in some test code after the string conversion to output the string, and the string is the number in decimal form. I was wondering if there is a way for integers to keep their base notation.</p>
<p>Of course you could input the numbers as strings and test that way, but then there is the problem of reading the string back as an int. </p>
<p>For example:</p>
<pre><code> string a = 0x43;
int num = atoi(a.c_str());
cout << num; // will output 43
</code></pre>
<p>It seems like keeping/converting base notation can get very tricky. As an added problem, the hex, dec, and oct manipulators wouldn't even help with the issue shown above since the integer is being stored completely incorrectly, it's not even converting to a decimal.</p>
| c++ | [6] |
5,072,109 | 5,072,110 | Is it possible to use HTTP byte ranges using curlpp | <p>Is it possible to get http byte ranges when using curlpp library in c++?</p>
| c++ | [6] |
4,487,882 | 4,487,883 | Is there a way to rollback an animation using only jQuery? | <p>Imagine I have the following animations:</p>
<pre><code>$("#myObject").animate({
/* animation 1 */
}).animate({
/* animation 2 */
}).animate({
/* animation 3 */
});
</code></pre>
<p>I was wondering if is there a way to animate <code>#myObject</code> back on a reverse order with reverse attributes without writing it all over again.</p>
<p>I was thinking about making a css class and toggle it, but it won't have the animation steps. Also, css3 animations is not an option for this project.</p>
<p>Is it possible?</p>
| jquery | [5] |
957,967 | 957,968 | jquery - Lookup values on change | <p>I want to post back to the server to run a lookup function. So when a user types their email address into a textbox and "clicks out" I want to call my C# function:</p>
<pre><code>UserInfoObject LookupUserInfo(string Email)
{
//...
}
</code></pre>
<p>My jQuery abilities are not very good. So, I could use some help setting up the basic structure. The <a href="http://api.jquery.com/category/ajax/" rel="nofollow">API</a> is overwhelming. Do I need ajax? Custom AJAX seems a little too advanced for my skill level.</p>
<p>In my overly simplistic view:</p>
<pre><code>$('#textBox').OnChange(function {
//call some C#
//Use object info to populate textbox2 and textbox3
}
)};
</code></pre>
| jquery | [5] |
2,942,036 | 2,942,037 | Android google account synch | <p>I am working on one application. It works on C2DM. Everything is working fine. It is device tracking application. But if i change sim and restart my device my Google account is not automatically signing in and it asks for Google account password and not getting notifications.</p>
<p>I want when i change my sim and restart the device Google account should automatically sync and should not ask for password.</p>
<p>Any help would be appreciated..</p>
| android | [4] |
4,158,657 | 4,158,658 | After doing append not able to find the element in Jquery | <p>Hi Guys i have this below code in JQuery, where i basically create a new select on the fly and and then when i try to find it i cannot find it . Please advice</p>
<pre><code> var parent = optionElement.parent();
var strHTML = "";
var tempClass = optionElement.attr("class");
strHTML = "<select name='" + optionElement.attr("name") + "' id='" + optionElement.attr("id") + "' class ='" + optionElement.attr("class") + "' >" + GetSearchOptionFilteredData(sOpt, true) + "</select>";
optionElement.remove();
parent.append(strHTML);
**alert(parent.find(tempClass).length); <-- this gives 0**
</code></pre>
| jquery | [5] |
3,300,475 | 3,300,476 | tool for designing GUI in Android | <p>i am a fairly new android developer. i wanted to ask you if there is an easier way to make GUI design in android?
i mean i always have to code the layout files which is very cumbersome and time-energy consuming. Plus the graphical layout provided by Eclipse is not at all helpful.</p>
<p>Is there a tool with which i can design the XML files....something like the tool offered in iphone development.
Android is provided by Google, there has to be a more sophisticated way of GUI designing.</p>
<p>thank you in advance.</p>
| android | [4] |
1,462,462 | 1,462,463 | How to stop the page load? | <p>I am using timer control in our web application in asp.net, i had set the time interval for 1 sec, for that reason my page loadiing is calling again and again, how can i prevent this?</p>
| asp.net | [9] |
1,838,797 | 1,838,798 | How can I create an empty variable based on another data type in Python? | <p>How can I create empty variable that has the same data type of another variable?</p>
<pre><code> data = get_data()
new_variable = data.data_type() #just create empty variable
</code></pre>
<p>In the above case, if <code>data</code> is a list then <code>new_variable</code> will be <code>list()</code></p>
| python | [7] |
3,287,460 | 3,287,461 | multi-dimensional stdClass Object | <p>I've got a rather large multidimensional stdClass Object being outputted from a json feed with PHP.</p>
<p>It goes about 8 or 9 steps deep and the data that I need is around 7 steps in.</p>
<p>I'm wondering if I can easily grab one of the entires instead of doing this:</p>
<p>echo $data->one->two->anotherone->gettinglong->omg->hereweare; </p>
<p>I'm saying this because the data structure may change over time.</p>
<p>Is this possible?</p>
| php | [2] |
1,763,849 | 1,763,850 | how to convert > and < with "<" and ">" within a string if brackets are exist using regular expression | <p>I want to replace <code>&lt;</code> with < and <code>&gt;</code> with > using regular expression if any these brackets or both the brackets exist in a string. so how do I check whether these brackets exist within a string with regular expression and replace any of them with < and > respectively.</p>
| jquery | [5] |
3,631,112 | 3,631,113 | How can I determine the number of objects that exist of a specific class? | <p>What is the best way to return the number of existing objects of a class?</p>
<p>For instance, if I have constructed 4 MyClass objects, then the returned value should be 4. My personal use for this is an ID system. I want a class's constructor to assign the next ID number each time a new object of the class is constructed.</p>
<p>Thanks in advance for any guidance!</p>
| python | [7] |
1,216,929 | 1,216,930 | QueryString Parameter | <p>My code:</p>
<pre class="lang-html prettyprint-override"><code><html>
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:NorthWindConnectionString %>"
SelectCommand="GetProductsByCategoryID"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:QueryStringParameter Name="CategoryID"
QueryStringField="CategoryID" />
</SelectParameters>
</html>
</code></pre>
<p>I'm using on my ASP.NET page a stored procedure.<br>
But this page is giving a blank page it should give me when I click on the other page the products corresponding to the categoryId clicked all is working fine except this page is giving blank result.</p>
<p>If I put for example <code>defaultValue="2"</code> it gives me result so what I might be missing?</p>
<p>The link is built with such code:</p>
<pre><code><ItemTemplate> <a href="QueryStringParameterTest.aspx? CategoryID=<%# Eval("CategoryID") %>"> <%# Eval("CategoryName") %></a> </ItemTemplate>
</code></pre>
| asp.net | [9] |
2,222,730 | 2,222,731 | Please explain this PHP code/syntax related to building forum pages | <p>OK so i am trying to build a forum from scratch and i realize the pages corresponding to topics will have to be generated dynamically somehow. I'm looking at a forum i frequently visit and I would like someone to explain the PHP syntax/code for the flow that I see as I have never seen the "something.php?x=something" type of structure before.</p>
<p>OK so user first visits site and the page says</p>
<pre><code>http://forumname.com/index.php?sid=someLongSetOfChars
</code></pre>
<p>(im guessing this is a session id?...what is the "?" where can i learn about it)</p>
<p>clicking login takes you to</p>
<pre><code>forumname.com/ucp.php?mode=login (what is mode? how do i know to do this?)
</code></pre>
<p>after logging in successfully you get</p>
<pre><code>forumname.com/index.php?sid=otherLongSetofChars
</code></pre>
<p>this page has the various forums in different categories.</p>
<p>Clicking on one of the categories gives:</p>
<pre><code>http://forumname.com/viewforum.php?f=1
</code></pre>
<p>Clicking on one of the topics gives:</p>
<pre><code>http://forumname.com/viewtopic.php?f=1&t=192053
</code></pre>
<p>All these things sort of make sense to me (semantically) but I am wondering how they actually work and how to implement them. What variables would I have to define and where and are these pages created and stored on my server?</p>
<p>Thanks</p>
| php | [2] |
4,302,722 | 4,302,723 | Below code upload files to ftp and return file and byte count, how to make it run parallel? | <pre><code> private async Task Upload(Ftp ftpHost)
{
//var assetImages is List<FileInfo>
var uploadedOrderFileByteCount = 0;
var uploadedOrderFileCount = 0;
foreach (var fi in assetImages.Where(fi => fi.Exists))
{
uploadedOrderFileCount++;
var count = ftp.Upload(fi);
uploadedOrderFileByteCount += await count;
fi.Delete();
}
}
</code></pre>
| c# | [0] |
2,328,421 | 2,328,422 | simple asp.net webforms ul li menu with selected class | <p>I have a simple unordered list with links in it.</p>
<pre><code><body>
<div id="topMenu">
<ul>
<li><a class="selected" href="../Default.aspx">Start</a></li>
<li><a href="../Category/ShowAll.aspx">Categories</a></li>
<li><a href="../Elements/ShowAll.aspx">Elements</a></li>
<li><a href="../Articles/ShowAll.aspx">Articles</a></li>
</ul>
</div>
<asp:ContentPlaceHolder ID="MainContentPlaceholder" runat="server">
</asp:ContentPlaceHolder>
</body>
</code></pre>
<p>I want to change the class of the link i click to the "selected" class, which is the easiest way to do this. I thought about making it into linkbuttons and saving the info in the session, but that seems overkill, there has to be an easier approach?</p>
| asp.net | [9] |
186,846 | 186,847 | How to find a call is unanswered in iphone | <p>If i make a call from an application using</p>
<pre><code>[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://1234567890"]];
</code></pre>
<p>How can i check if the call is answered or unanswered</p>
<p>Thanks,</p>
| iphone | [8] |
5,106,593 | 5,106,594 | javascript function to get all images in html | <p>I wanted to have a javascript function to basically return an array of all the img src there is in a page, how do I do this? </p>
| javascript | [3] |
391,480 | 391,481 | How to convert vector to array C++ | <p>I want to convert vector of double to array of double. Can any one help me to do this</p>
| c++ | [6] |
2,425,644 | 2,425,645 | In javascript, how to redirect to SELF , with an extra variable? | <p>I'd like to grab the current URL.
Then, append a "&p=1" to it.</p>
<p>And redirect it! </p>
| javascript | [3] |
3,954,662 | 3,954,663 | PHP validate something after 24 hours | <p>i have php app where i want to check something after 24 hours or on daily bases.
i have a columns in database lastscan in which the last scan time stored
i only want to know in PHP how to trigger the check after 24 hours passed
want to run a php task every 24 hours</p>
| php | [2] |
3,332,538 | 3,332,539 | How big is an object reference in Java and precisely what information does it contain? | <p>As a programmer I think of these as looking like "the java.lang.Object at address 1a234552" or similar for something like the <code>s</code> in</p>
<pre><code>Object s = "hello";
</code></pre>
<p>Is this correct? Therefore are all references a fixed size?</p>
| java | [1] |
4,135,987 | 4,135,988 | An issue about c/c++ Segmentation fault | <p>I wrote a simple program to test array pointer:</p>
<pre><code> #include <iostream>
using namespace std;
int main(){
int (*array)[10];
int i, j;
for (i = 0; i < 10; i++){
for (j = 0; j < 10; j++)
array[i][j] = 1;
}
for (i = 0; i < 10; i++){
for (j = 0; j < 10; j++)
cout << array[i][j] << " ";
cout << endl;
}
return 0;
}
</code></pre>
<p>why the g++ "Segmentation fault"?
by the way, my os is ios x64.</p>
<p>Thanks
Chuan</p>
| c++ | [6] |
3,223,431 | 3,223,432 | How to hide a row that containing more than one empty cell? | <p>For the table below, row2 and row3 have more than 1 empty cell(<code><td></td></code>), how can I use jQuery to check if each row in the table have more than 1 empty cell, than hide that row accordingly?</p>
<h3>UPDATED:</h3>
<p>If I want to check if each row(td) contain more than ONE cell(td) that is containing JUST witespace, than hide that row?</p>
<p>Thanks</p>
<pre><code><table>
<tr class="row1">
<td>a</td>
<td>b</td>
<td>c</td>
<td>d</td>
</tr>
<tr class="row2">
<td>a</td>
<td>b</td>
<td></td>
<td></td>
</tr>
<tr class="row3">
<td></td>
<td></td>
<td>c</td>
<td></td>
</tr>
...
<tr class="row100">
<td>a</td>
<td>b</td>
<td>c</td>
<td></td>
</tr>
</table>
</code></pre>
| jquery | [5] |
615,974 | 615,975 | Android: Manage application execution | <p>I want to make startup cleaner application for Android 1.6. My query is how to manage application that starts while phone boot or starts. </p>
<p>Thanks </p>
| android | [4] |
4,172,117 | 4,172,118 | Error 1 Use of unassigned local variable 'rental' | <p>I get the error. The way I am looking at is I want the value that is returned from dayrental() * 19.95 to be stored in rental. </p>
<p>Use of unassigned local variable 'rental'</p>
<pre><code> private void button1_Click(object sender, EventArgs e)
{
double rental;
if (checkBox1.Checked == true)
rental = dayrental() * 19.95;
label4.Text = Convert.ToString(rental);
}
private void label4_Click(object sender, EventArgs e)
{
}
public double dayrental()
{
var timeSpan = dateTimePicker2.Value - dateTimePicker1.Value;
var rentalDays = timeSpan.Days;
return (double) rentalDays;
//label4.Text = Convert.ToString(rentalDays);
}
</code></pre>
| c# | [0] |
3,140,400 | 3,140,401 | IDisposable Interface | <p>I know about <code>IDisposable</code> Interface and it's use in .net but there is a question in my mind that If i am writing all managed code , does implementing <code>IDisposable</code> interface make any sense?</p>
<p>i know when and how to use Idisposible but my question is if i am writing all managed code say a simple class nothing expensive in it so if i implement <code>IDisposable</code> in this class and do some cleanup like freeing some global values, Does it make some sense?</p>
| c# | [0] |
5,601,047 | 5,601,048 | importing a text file | <p>any way easier to do this??</p>
<p>i'm trying to import a file which is four lines:</p>
<pre>
name
phone
mobile
address
</pre>
<p>I'm using:</p>
<pre><code>public void importContacts() {
try {
BufferedReader infoReader = new BufferedReader(new FileReader(
"../files/example.txt"));
int i = 0;
String loadContacts;
while ((loadContacts = infoReader.readLine()) != null) {
temp.add(loadContacts);
i++;
}
int a = 0;
int b = 0;
for (a = 0, b = 0; a < temp.size(); a++, b++) {
if (b == 4) {
b = 0;
}
if (b == 0) {
Name.add(temp.get(a));
}
if (b == 1) {
Phone.add(temp.get(a));
}
if (b == 2) {
Mobile.add(temp.get(a));
}
if (b == 3) {
Address.add(temp.get(a));
}
}
}
catch (IOException ioe) {
JOptionPane.showMessageDialog(null, ioe.getMessage());
}
txtName.setText(Name.get(index));
txtPhone.setText(Phone.get(index));
txtMobile.setText(Mobile.get(index));
txtAddress.setText(Address.get(index));
}
</code></pre>
<p>is their an easier way? looks long winded!</p>
| java | [1] |
4,812,120 | 4,812,121 | Confusing code with ? operator | <p>I was reading through someones old code and I found this line:</p>
<pre><code> menuItem.Checked = (menuItem.Checked == false) ? true : false;
</code></pre>
<p>I dont understand what it does and how. any help?</p>
| c# | [0] |
4,686,334 | 4,686,335 | java- create simple byte offset index of a text file | <p>I would like to index every 100th line of a very large text file with its corresponding byte offset. As I'm reading through the file to create my index with a bufferedreader, is it possible to figure out which byte position I am at?</p>
| java | [1] |
5,477,205 | 5,477,206 | on unload event of browser | <p>HI </p>
<p>I wanna timeout session from client page,i tried below code but not able to execute code need some help of how i can handle OK or CANCEL events from user</p>
<pre><code><script>
function onBeforeUnloadAction(){
return "Would u like to discard Changes";
}
window.onbeforeunload = function(){
if((window.event.clientX<0) ||
(window.event.clientY<0))
{
return onBeforeUnloadAction();
}
}
</script>
</code></pre>
| javascript | [3] |
1,270,956 | 1,270,957 | logic with bool | <p>I have this logic in my analysis file.
The user has the option to choose a input file. if an error occurs or if the user has a invalid entry in the input file, then the logic checks and prints the error. </p>
<p>This method returns a bool success. Depending on if all the input is valid, successtakes T/F.
If success = T, then the next step analyzing the input starts.
Now here's my question. How do i return a false`
;</p>
<pre><code>if (xxx > 100)
{
errMsg = "Number of xxx should be <= 100";
swRpt.WriteLine(errTitle + errMsg);
}
// sizing
;
swRpt.WriteLine(" Epsilon");
//Repair
success = Numerical.Check("repair", inputs.repair.ToString(),
out dtester, out errMsg);
if (!success)
{
swRpt.WriteLine(errTitle + errMsg);
}
success = Numerical.Check("prob", inputs.prob.ToString(),
out dtester, out errMsg);
if (!success)
{
swRpt.WriteLine(errTitle + errMsg);
}
</code></pre>
<p>so now finally </p>
<pre><code>if (success)
{
//run the analysis method
}
if(!success)
{
exit
}
</code></pre>
<p>I need to exit if even one input is wrong. the first could be wrong and the last one could be a correct input value. </p>
| c# | [0] |
6,022,461 | 6,022,462 | findObjectsInBackgroundWithBlock of PFQuery callback never get called | <p>I am using Parse SDK for my iOS App.</p>
<p>Where in a PFQuery Objects has a callback for findObjectsInBackgroundWithBlock.</p>
<p>It seems that the callback or Block for this executes after a long time (45 minutes) when there are large number of objects or sometimes never get called.</p>
<p>Any help is appreciated.</p>
| iphone | [8] |
5,832,666 | 5,832,667 | android - frame animation in value/arrays.xml | <p>i have simple anim </p>
<p>simple_anim.xml</p>
<pre><code><animation-list xmlns:android=”http://schemas.android.com/apk/res/android” id=”selected” android:oneshot=”false”>
<item android:drawable=”@drawable/frame1″ android:duration=”50″ />
<item android:drawable=”@drawable/frame2″ android:duration=”50″ />
</animation-list>
</code></pre>
<p>it is possible to create frame animation in value/arrays.xml</p>
<pre><code> <?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<array name="entries">
<item>@drawable/simple_anim</item>
<item>@drawable/image2</item>
<item>@drawable/image3</item>
<item>@drawable/image4</item>
<item>@drawable/image5</item>
</array>
</resources>
</code></pre>
| android | [4] |
3,078,528 | 3,078,529 | Check if first radio button w/jQuery | <p>If i build a list of items with radiobuttons next to them, how do I check the first one by default?</p>
| jquery | [5] |
2,101,181 | 2,101,182 | Can Android App be embedded in Web page like old plain java applet? | <p>I know nothing about android platform and can't find answer to this basic question on internet.</p>
<p>Update: OK I cannot embed Android App per se. But can I embed something in Java in Android Webbrowser ?</p>
| android | [4] |
1,931,379 | 1,931,380 | How to add quick search box to our application? | <p>How to add quick search box (QSB) to our application?</p>
| android | [4] |
3,545,462 | 3,545,463 | Where do you recommend an experienced developer learn Javascript? | <p>I'd like to learn some Javascript <strong>before</strong> jumping into a framework like jQuery or Moo Tools.</p>
<p>Since I'm already familiar with C#/Java/Python, I'd like a resource that just shows me how to do things and not waste time with, this is an object, here's how you add numbers, etc.</p>
<p>What resource would you recommend for me? Thank you very much.</p>
| javascript | [3] |
3,608,376 | 3,608,377 | JQuery Add Dynamic rows along with delete button | <p>I have 4 textbox fields I want to give a link to ADD. when clicked on Add it should display the 4 rows belowthe existing rows as well a delete button.</p>
<p>Should be repeated when clicking on ADD.</p>
<p>So delete button should start displaying from second row when clicked on add.</p>
<p>If I click on delete button corresponding row should be deleted</p>
<p>Any help is appreciated</p>
| jquery | [5] |
6,024,793 | 6,024,794 | Push integer from Input to array | <p>Hi im trying to get the number pushed into the array but cant seem to link the input to the array any help please </p>
<pre><code><html>
<body>
<form id="myform">
<input type="text" name="input">
<button onclick="myFunction()">Add number</button>
</form>
<br>
<div id="box"; style="border:1px solid black;width:150px;height:150px;overflow:auto">
</div>
<script>
var number= [];
function myFunction()
{
number.push=("myform")
var x=document.getElementById("box");
x.innerHTML=number.join('<br/>');
}
</script>
</body>
</html>
</code></pre>
| javascript | [3] |
637,567 | 637,568 | Pass Parameters To XMLHttpRequest Object | <p>How can I pass parameters to the XMLHttpRequest Object? </p>
<pre><code>function setGUID(aGUID) {
var xhReq = new XMLHttpRequest();
xhReq.open("POST", "ClientService.svc/REST/SetAGUID" , false);
xhReq.send(null);
var serverResponse = JSON.parse(xhReq.responseText);
alert(serverResponse);
return serverResponse;
}
</code></pre>
<p>I need to use javascript instead of jquery, in jquery I got it to work with this code, but cant seem to figure it out the straight javascript way..</p>
<pre><code>function setGUID(aGUID) {
var applicationData = null;
$.ajax({
type: "POST",
url: "ClientService.svc/REST/SetAGUID",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ aGUID: aGUID }),
dataType: "json",
async: false,
success: function (msg) {
applicationData = msg;
},
error: function (xhr, status, error) { ); }
});
return applicationData;
}
</code></pre>
| javascript | [3] |
508,774 | 508,775 | Blacklist and preg_match | <p>I thought I had this figured out, but I'm running into an issue. I'm creating a URL blacklist in my application. I need to block all subdomains, directories, etc from an array of domains. Below is the array I have:</p>
<pre><code>$blacklist = array(
'/\.google\./',
'/\.microsoft\./',
);
</code></pre>
<p>Here is where I'm checking:</p>
<pre><code> $host = parse_url($url, PHP_URL_HOST);
$blackList = $GLOBALS['blacklist'];
foreach($blackList as $stop) {
if (preg_match($host === $stop)) {
die('blacklisted');
}
}
</code></pre>
<p>When I run this, it doesn't die as intended.</p>
| php | [2] |
37,535 | 37,536 | jQuery - call the element this into another function | <p>I have this jQuery function :</p>
<pre><code>$('a[name=pmRead]').click(function(e) {
e.preventDefault();
$(this).parents(".pmMain").find(".pmMain5").toggle();
$.ajax({
type: 'POST',
cache: false,
url: 'pm/pm_ajax.php',
data: 'pm_id='+$(this).attr('id')+'&id=pm_read',
dataType: 'json',
success: function(data) {
$('#pmCouter').html(data[0]);
//HOW CAN I CALL THIS HERE? I'D like to do $(this).parents(".pmMain").find(".pmMain5").append('ciao');
}
});
});
</code></pre>
<p>As you can see in the code, I'd like to recall <strong>this</strong> into the <em>$.ajax</em> function. How can I do it?</p>
| jquery | [5] |
2,745,519 | 2,745,520 | how do I make this compile? | <p>This is my code snippet:</p>
<pre><code>import java.awt.*;
import java.net.*;
import javax.swing.*;
import java.awt.event.*;
class chatboxServer {
JFrame fr;
JPanel p;
JTextArea ta;
JButton send;
chatboxServer() {
fr=new JFrame("ChatBox_SERVER");
p=new JPanel();
ta=new JTextArea();
ta.setRows(20);
ta.setColumns(20);
send=new JButton("send");
fr.add(p);
p.add(ta);
p.add(send);
fr.setVisible(true);
fr.setSize(500,500);
fr.setResizable(false);
try { // Making server listen to port number 3000
ServerSocket s=new ServerSocket(3000);
} catch(Exception exc) {
JOptionPane.showMessageDialog(new JFrame(),"Cannot Listen :3000");
}
try {
Socket s=null;
s=ServerSocket.accept();
} catch(Exception exc)
JOptionPane.showMessageDialog(new JFrame(),"Accept Failed :3000");
}
}
public static void main(String args[]) {
new chatboxServer();
}
}
</code></pre>
<p>The error that I get is:</p>
<blockquote>
<p>Non static method cannot referenced from static context.</p>
</blockquote>
<p>Please explain how can I can make this compile?</p>
| java | [1] |
3,720,656 | 3,720,657 | Checking if two divs contain content, and if not adding a class to their container div | <p>I am trying to check whether two child divs contain content and if they do not ie they are empty then I would like to add a class to their parent div.
This is my code but this adds the class="noBorder" to the parent div if the child divs are empty or not.</p>
<pre><code>if(('div.nav-previous:empty') && ('div.nav-next:empty')) {
jQuery('div#nav-below').addClass('noBorder')
};
</code></pre>
<p>Any help with this would be much appreciated.</p>
<p>Gina</p>
| jquery | [5] |
2,601,936 | 2,601,937 | Regarding shutdownhook understanding | <p>I was going through shutdown hook feature of java , My analysis was ..shutdownhook allows to register a thread that will be created immediatly but started only when the JVM ends ! So it is some kind of "global jvm finalizer", and you can make useful stuff in this thread (for example shutting down java ressources like an embedded hsqldb server). This works with System.exit(), or with CTRL-C / kill -15 (but not with kill -9 on unix, of course).</p>
<p>Please advise more practical uses and please also if possibe an small example will help to make understanding more clear..!</p>
| java | [1] |
4,266,362 | 4,266,363 | WTL integration of Lightweight HTML layout and rendering engine in C# | <p>please i want to work in html layout library in C# windows application
you can see this site (Owner library) <a href="http://www.terrainformatica.com/" rel="nofollow">http://www.terrainformatica.com/</a></p>
<p>thank you</p>
| c# | [0] |
404,370 | 404,371 | How to Include Variable inside Class in php | <p>i have some file test.php</p>
<pre><code><?PHP
$config_key_security = "test";
?>
</code></pre>
<p>and i have some class</p>
<p>test5.php</p>
<pre><code> include test.php
class test1 {
function test2 {
echo $config_key_security;
}
}
</code></pre>
| php | [2] |
5,293,298 | 5,293,299 | How do I hide a menu item in the actionbar? | <p>I have an action bar with a menuitem. How can I hide/show that menu item?</p>
<p>This is what I'm trying to do:</p>
<pre><code>MenuItem item = (MenuItem) findViewById(R.id.addAction);
item.setVisible(false);
this.invalidateOptionsMenu();
</code></pre>
| android | [4] |
2,261,327 | 2,261,328 | Difference between jQuery wrap and wrapAll | <p>What's the difference between jQuery .wrap and .wrapAll? They pretty much do the same thing, but what could be the difference?</p>
| jquery | [5] |
2,980,171 | 2,980,172 | Query about setOnClickListener() and onClick() of android | <p>what is actually done by setOnClickListener() method and onClick() method during click </p>
<p>events.why this two method is needed during click events.</p>
<p>please explain in details.</p>
| android | [4] |
1,586,817 | 1,586,818 | how to check whether my c# window app is running first time after installation | <p>I made exe of my window application.I want that, when my exe installed on system and run first time to machine.I want to check if it is running first time, then system will reboot automatically, and after running first time, system should not be reboot every time. </p>
<p>Can i do this ? Please help me.</p>
<p>Thanks in advance.</p>
| c# | [0] |
1,620,142 | 1,620,143 | Global Arrays in C++ | <p>Why the array is not overflowed (e.g. error alert) when the array is declared globally, in other why I'm able to fill it with unlimited amount of elements (through for) even it's limited by size in declaration and it does alert when I declare the array locally inside the main ?</p>
<pre><code>char name[9];
int main(){
int i;
for( int i=0; i<18; ++i){
cin>>name[i];
}
cout<<"Inside the array: ";
for(i=0; i<20; i++)
cout<<name[i];
return 0;
}
</code></pre>
| c++ | [6] |
4,950,785 | 4,950,786 | How to round floating point error in javascript | <p>How to round floating point error in javascript?</p>
| javascript | [3] |
5,572,213 | 5,572,214 | Weird functioning of Application event in iPhone | <p>iPhone app shuts down when ever any call accepted by user. When call ends, app will resume.</p>
<p>I want to capture that event when app resumes after call ends. Howsoever I have tried:
on App delegate:
- (void)applicationWillTerminate:(UIApplication *)application
- (void)applicationDidFinishLaunching:(UIApplication *)application
- (void)applicationDidBecomeActive:(UIApplication *)application
- (void)applicationWillResignActive:(UIApplication *)application</p>
<p>On view load:
viewDidLoad
ViewwillAppear</p>
<p>But non of the above event occur. Dont know how would I know that user is coming back after receiving a call. </p>
| iphone | [8] |
1,561,628 | 1,561,629 | Redirecting user to dynamic error page | <p>Can I configure ASP.NET custom errors so that it would redirect to other site when error has occurred. Even more, I would like to redirect to different web page every time.</p>
<p><strong>Here is my simplified actual case:</strong></p>
<p>User opens my pages with query ?urlpage=http://test.com/error.html and I would like to redirect to this page when error occurs. </p>
<p>How should I act in this scenario?</p>
| asp.net | [9] |
4,966,785 | 4,966,786 | please suggest a good VIDEO PLAYING library for android | <p>I am looking for a good video player ( library ) for android, which would be able to play video files onto a surfaceview or something, allowing me to overlay it with my own play/pause buttons, progress bar, etc.</p>
<p>What library would you suggest?</p>
<p>Thanks! ;)</p>
| android | [4] |
2,915,769 | 2,915,770 | What do DateTime? and using(var x = new y()) mean? | <p>I don't understand what the following lines mean, please explain them to me.</p>
<p>1.</p>
<pre><code>DateTime? pInsertDate;
</code></pre>
<p>At this variable declaration, What does <code>?</code> mean?</p>
<p>2.</p>
<pre><code>using (TransactionScope scope = new TransactionScope())
</code></pre>
<p>At this object creation, What does <code>using</code> mean?</p>
| c# | [0] |
120,486 | 120,487 | Jquery lazyload plugin won't work with external images? | <p>Well i would like to know if this plugin 'load' the img or only fadeIn a img loaded?</p>
| jquery | [5] |
4,948,695 | 4,948,696 | how can i calculate age by datetimepicker | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/9/how-do-i-calculate-someones-age">How do I calculate someone’s age</a> </p>
</blockquote>
<p>How can i calculate age using datetimepicker in c#?</p>
| c# | [0] |
274,614 | 274,615 | About iterator and const problem in C++ | <pre><code>class LogManager {
private:
mutable mapManagerMutex mapMutex;
typedef std::map<std::string, LogStorage*> FileNameToStorageClass;
FileNameToStorageClass m_mapFileNameToLogStrg;
public:
int write( const string& strFileName, char* text ) const;
};
int LogManager::write( const string &strFileName, char* text ) const
{
mapManagerMutex::scoped_lock lock(mapMutex);
FileNameToStorageClass::iterator iter;
iter = m_mapFileNameToLogStrg.find(strFileName);
if(iter != m_mapFileNameToLogStrg.end())
{
// do some thing.
}
else
{
return -1;
}
return 0;
}
</code></pre>
<p>Above code compiles if i don't have const at end of write function. If i add const at end i am getting following error</p>
<pre><code>D:/LogManager.cpp:133: error: no match for 'operator=' in 'iter = ((const RtsInfrastructure::RtsCommon::Diagnostics::LogManager*)this)-
cc: C:/QNX650/host/win32/x86/usr/lib/gcc/i486-pc-nto-qnx6.5.0/4.4.2/cc1plus caught signal 1
</code></pre>
<p>Does any body know why we are seeing this?</p>
| c++ | [6] |
363,110 | 363,111 | About the global keyword in python | <pre><code># coding: utf-8
def func():
print 'x is', x
#x = 2 #if I add this line, there will be an error, why?
print 'Changed local x to', x
x = 50
func()
print 'Value of x is', x
</code></pre>
<ol>
<li>I dont't add the <code>global x</code> in func funtion, but it can still find <code>x</code> is 50, why?</li>
<li>When I add the <code>x=2</code> line in the func function, there will be an error (<code>UnboundLocalError: local variable 'x' referenced before assignment</code>), why?</li>
</ol>
| python | [7] |
1,278,411 | 1,278,412 | 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] |
2,048,346 | 2,048,347 | difference between jdk and bdk? | <p>difference between jdk and bdk ?</p>
| java | [1] |
1,103,331 | 1,103,332 | How do write a template which can decide which constructor to call? | <p>I'd like to be able to construct an A or B without having to think about the number of constructor arguments.</p>
<p>The second constructor is not legal C++ but I wrote it like this as an attempt to express what I want.</p>
<p>Is there an enable_if trick to selectively enable one of the constructors?</p>
<p>(e.g. depending on the number of constructor arguments of A and B.)</p>
<p>I need this to test about 15 classes with 1, 2 or 3 constructor arguments.</p>
<pre><code>struct A
{
A(int x)
{
}
};
struct B
{
B(int x, int y)
{
}
};
template<typename T>
struct Adaptor // second constructor is illegal C++.
{
T t;
Adaptor(int x, int y)
: t(x)
{
}
Adaptor(int x, int y) // error: cannot be overloaded
: t(x, y)
{
}
};
int main()
{
Adaptor<A> a(1,2);
Adaptor<B> b(1,2);
return 0;
}
</code></pre>
| c++ | [6] |
5,574,696 | 5,574,697 | Why can't I use the Context of a Service to display an AlertDialog | <p>Why can't I use the Context of a Service to display an AlertDialog ?</p>
<p>I can do it with Toast!</p>
| android | [4] |
3,895,414 | 3,895,415 | How to compare Array index according to button tag? | <pre><code>indexpath.row for array b.tag
0 Date1 0
1 india 1
2 pakistan 2
3 Date2 3
4 Zimbabwe 3
5 England 4
6 Date3 6
7 Australia 5
8 Westindes 6
9 Date3 9
10 Shrilanka 7
11 southAfrica 8
</code></pre>
<p>Here, indexpath.row for array is my Array. Now when i click on <code>b.tag=3</code> then I want to display Array index 4th value i.e Zimbabwe and not the Date2 which is on array index 3. Similarly, for b.tag=6 and b.tag=9. For that following is the code that i have written.</p>
<p>please take a look...</p>
<pre><code>if (b.tag!=[arr objectAtIndex:path])
{
NSLog(@"Team name %@",[arr objectAtIndex:b.tag]);
}
</code></pre>
<p>From the above code my first record result is coming right i.e of b.tag=1 and b.tag=2,but not for others because my Array index and b.tag are different. So please help me out of this.</p>
<p>Any help will be appreciated.</p>
<p>Thanks in Advance.</p>
| iphone | [8] |
5,156,522 | 5,156,523 | Why would people use `$a = $b = 2;` in PHP? | <p>Why would people use this format? Whats different between this and <code>$a=2; $b=2;</code>?</p>
| php | [2] |
4,898,781 | 4,898,782 | How to Avoid Constructor calling During Object Creation? | <p>I want to avoid the constructor calling during object creation in java (either default constructor or user defined constructor) . Is it possible to avoid constructor calling during object creation??? </p>
<p>Thanks in advance......</p>
| java | [1] |
3,090,205 | 3,090,206 | Problem building a complete binary tree of height 'h' in Python | <p>Here is my code. The complete binary tree has 2^k nodes at depth k.</p>
<pre><code>class Node:
def __init__(self, data):
# initializes the data members
self.left = None
self.right = None
self.data = data
root = Node(data_root)
def create_complete_tree():
row = [root]
for i in range(h):
newrow = []
for node in row:
left = Node(data1)
right = Node(data2)
node.left = left
node.right = right
newrow.append(left)
newrow.append(right)
row = copy.deepcopy(newrow)
def traverse_tree(node):
if node == None:
return
else:
traverse_tree(node.left)
print node.data
traverse_tree(node.right)
create_complete_tree()
print 'Node traversal'
traverse_tree(root)
</code></pre>
<p>The tree traversal only gives the data of root and its children. What am I doing wrong?</p>
| python | [7] |
2,305,218 | 2,305,219 | JavaScript alert box with timer | <p>I want to display the alert box but for a certain interval. Is it possible in JavaScript?</p>
| javascript | [3] |
3,316,247 | 3,316,248 | Python: Calling subclass's method within super method call | <p><strong>EDIT: My assumptions were wrong; the code below does in fact work like I wanted it to. The behaviour I was observing turned out to be caused by another bit of the code I was working with that I overlooked because it looked completely unrelated.</strong></p>
<p>So I have some code structured like this:</p>
<pre><code>class B(object):
def foo(self):
print "spam"
def bar(self):
do_something()
self.foo()
do_something_else()
class C(B):
def foo(self):
print "ham"
def bar(self):
super(C, self).bar()
print "eggs"
c = C()
c.bar()
</code></pre>
<p>This would do_something(), print "spam", do_something_else(), and then print "eggs". However, what I <em>want</em> to do is do_something(), print "ham", do_something_else(), and then print "eggs". In other words, I want to call B's bar method from C's bar method, but I want <em>it</em> to call C's foo method, not B's.</p>
<p>Is there a way to do this? Note that in the actual code I'm dealing with, both the B class and the code that actually calls c.bar() are part of an evolving third-party library, so mucking with that would be a last resort.</p>
| python | [7] |
190,961 | 190,962 | Alert message not popped up after using Array.concat method | <p>I tried the following code in <code>IE9, Chrome</code>. But it is not working in both browsers.</p>
<p>In <code>Firefox</code>, it is working fine</p>
<pre><code><script type="text/javascript">
var first = ['a','b','c','h','i','j'];
var second = ['d','e','f','g'];
var insertPosIndex = 3;
first.splice.apply(first, Array.concat(insertPosIndex, 0, second));
alert(first);
</script>
</code></pre>
<p>I am expecting the output as <code>a,b,c,d,e,f,g,h,i,j</code></p>
| javascript | [3] |
4,149,413 | 4,149,414 | Is it possible to resolve domain names to an IP address with PHP? | <p>Well, very simple question. So that's good news for you, I guess.</p>
<p>More thorough explanation:</p>
<p>I have a PHP script allowing me to add urls to a database. I want the script to resolve the url to an IP address as well, to store that, too. However, some of the URLs are like this:</p>
<p><code>http://111.111.111.111/~example/index.php</code></p>
<p>So it also needs to work with that.</p>
<p>I'm not <strong>SURE</strong> that this is possible, but it only makes sense it would be.</p>
<p>So: Is it possible, and if so, how?</p>
| php | [2] |
3,558,400 | 3,558,401 | open file dialog not working in vista and 2008 environment | <p>i am using Vista . I designed MSi file through Visual Studio
2008 Setup and deployment project in which I added one custom action. In
the custom action, I am opening OpenFile dialog.
This Open File dialog is not showing mapped drive or network locations.
Can anybody help???</p>
| c# | [0] |
1,929,229 | 1,929,230 | Is there a tool which will package a copy of the JRE with my application so that it can run regardless of whether or not the user has Java installed? | <p>This is my first brush with actually distributing a Java application. I'm coming from a Python background, which has a fantastic set of tools for distribution called PyInstaller, and Py2App. Both of these package up a copy of the Python Interpreter along with the application so that there's nothing to install for the end user. They simple see an <code>.EXE</code> or <code>.app</code> double click it, and the program starts. </p>
<p>So far, I have been unable to find a similar tool for Java. The idea behind this app is that it's stored on a flashdrive so it can be run without installing anything on the host machine. </p>
<p>I've found decent tools for Windows. For instance, <a href="http://launch4j.sourceforge.net/">Launch4J</a> appears to do the trick, but it's for windows only. I'm desperately in need of similar functionality, but for making an app. </p>
<p>Has anyone faced this conundrum before? Are there any tools which I could use? </p>
| java | [1] |
2,879,832 | 2,879,833 | select query in sql-light dont work for me in android | <p>this code work for me:</p>
<pre><code>SQL = "SELECT _id,Fname,Lname,Phone,Car,CarNum,PicNum from MEN order by Lname,Fname";
.
.
public void update_list(String NN) {
c = db.rawQuery(NN, null);
startManagingCursor(c);
String[] from = new String[]{"_id","PicNum","Fname","Lname","Car","CarNum" };
int[] to = new int[]{ R.id._id,R.id.MyPic,R.id.Fname ,R.id.Lname,R.id.Car,R.id.CarNum };
SimpleCursorAdapter notes = new SimpleCursorAdapter (this, R.layout.my_list, c, from, to);
setListAdapter(notes);
setListAdapter(new SimpleCursorAdapter(this, R.layout.my_list, c, from,to) {
</code></pre>
<p>but if my query like this:</p>
<pre><code>SQL = "SELECT _id,Fname + Lname as Fname,Lname,Phone,Car,CarNum,PicNum from MEN order by Lname,Fname";
</code></pre>
<p>i got 0 in the column Fname. </p>
| android | [4] |
2,566,248 | 2,566,249 | Alias method and pass static argument too | <p>I was wondering if anybody had any ideas on how to easily alias a method (without creating another method) but pass a static argument too? An example (from how we would normally alias the object - but it obviously doesn't work) to demonstrate what I mean.</p>
<pre><code># Short and to the point
# Normal: alias = method
alias = method("static", arguments)
</code></pre>
| python | [7] |
606,625 | 606,626 | How to iterate the installed fonts using javascript? | <p>How to iterate the installed fonts using javascript?</p>
| javascript | [3] |
5,061,075 | 5,061,076 | Android: How to make scrollable table with frozen table headers? | <p>I wonder how I could make a scrollable table with static table header ? (with different elements in cells like buttons, images, etc.) </p>
<p>I have already made some of this, but i dont know how to make columns in different tables match each other by width.</p>
<pre><code><TableLayout>
<TableRow>
Table headers...
</TableRow>
<ScrollView>
<TableLayout > <!-- Table content--></TableLayout >
</ScrollView>
</TableLayout>
</code></pre>
<p>Thanks !</p>
| android | [4] |
5,001,579 | 5,001,580 | complex text rendering by avoiding the built in canvas.drawText - any way to render text to a bitmap and then display in an imageview instead? | <p>I've been struggling with androids limited support for complex text rendering, particularly lack of arabic support for ligatures and shaping. Although you can get around the shaping problem by using the specific unicode escape codes to display the arabic string, it doesn't handle displaying diacratics correctly since it renders them on top of each other. </p>
<p>The text renders properly on a graphic using java.awt.Graphics2D but that isn't supported in android, that code is: </p>
<pre><code>InputStream is = converter.class.getResourceAsStream("ARIAL.TTF");
Font font = Font.createFont(Font.TRUETYPE_FONT, is);
Font medium_font = font.deriveFont(32f);
BufferedImage sizedBufferedImage = new BufferedImage((rounded_width+10),(rounded_height+14), BufferedImage.TYPE_INT_ARGB);
Graphics2D g_sized = sizedBufferedImage.createGraphics();
g_sized.setColor(Color.black);
g_sized.setFont(medium_font);
g_sized.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g_sized.drawString(word_arabic, 5, 7+max_ascent);
ByteArrayOutputStream imgoutstr = new ByteArrayOutputStream();
ImageIO.write(sizedBufferedImage, "png", imgoutstr);
</code></pre>
<p>I can then get the Graphics2D object into a Bitmap using the ImageIO class and finally display it into an ImageView. I need to do this at runtime because the strings are coming from a database. </p>
<p>My problem is I can't find any alternative way of writing the word into a graphics object that I can then eventually get into a drawable/bitmap for display in android as an imageview, I'm trying to bypass androids text rendering and use an alternative text renderer that fully supports unicode and can handle the complext text rendering I need. Putting it into an image allows me to have android display the word verbatim as an image rather than trying to render it. </p>
<p>Is there any way to draw text into a graphics object instead of androids canvas, eventually putting the rendered graphics object into a bitmap that android can use? Androids canvas.drawString doesn't render the string properly and renders text differently than Graphics2D for complex text.</p>
| android | [4] |
5,470,162 | 5,470,163 | mute sound through phone speaker Android api | <p>I want the to mute all sounds coming through the phone speaker but keep the sounds going through the headphones. Is this possible?</p>
<p>I was looking at:
setMicrophoneMute(true);
and
setSpeakerphoneOn(false);</p>
<p>but neither seem to have any affect. Is this even possible? I have this permission in my manifest:</p>
<p></p>
<p>I couldn't see any methods that would accomplish what I want in the audio manager but maybe I just don't understand the api.</p>
| android | [4] |
1,626,089 | 1,626,090 | Change process priority in Python, cross-platform | <p>I've got a Python program that does time-consuming computations. Since it uses high CPU, and I want my system to remain responsive, I'd like the program to change its priority to below-normal.</p>
<p>I found this:
<a href="http://code.activestate.com/recipes/496767/">Set Process Priority In Windows - ActiveState</a></p>
<p>But I'm looking for a cross-platform solution.</p>
| python | [7] |
3,818,178 | 3,818,179 | php forcing type | <p>I have a collegue who constantly assigns variable and forces their type. For example he would declare something like so:</p>
<pre><code>$this->id = (int)$this->getId();
</code></pre>
<p>or when returning he will always return values as such:</p>
<pre><code>return (int)$id;
</code></pre>
<p>I understand that php is a loosely typed language and so i am not asking what the casting is doing. I am really wondering what the benefits are of doing this - if any - or if he is just wasting time and effort in doing this?</p>
| php | [2] |
5,571,342 | 5,571,343 | Macbook Security Alarm Task | <p>I intend to put my macbook on my landing/hallway for when the people downstairs come up to rummage through my bedroom/rooms, such that when an intruder is detected a set of scripted events occur, such as a countdown from 10 followed by very loud music, but the existing software is either commercial or insufficient. Im not intending to spend money on this.</p>
<p>Given a Macbook or desktop with a webcam. and using java, what libraries would I need to implement a basic version of the above? Also what references for implementing these kinds of motion detection programs would be useful?</p>
| java | [1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.