Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
2,632,468 | 2,632,469 | How to make event for specific date? | <p>Where event detail should store?How to make alarm for specific event that i don't know.Please help with code or give link for that type of example.
Thank in Advance.</p>
| iphone | [8] |
2,940,869 | 2,940,870 | Search a word which exactly match using python | <p>I have Paragraph contains "I have a good python book so will become pythonist"
my aim is to search only "python" not pythonist how can I do it using python and not take any extra characters before and after</p>
| python | [7] |
268,480 | 268,481 | How to set Multiple SelectedItem on Listbox? | <p>The sample code like this:</p>
<pre><code><asp:Listbox ID="ddlCat" runat="server" SelectionMode="Multiple" />
ddlCat.Items.Insert(0, new ListItem("Item1", "1"));
ddlCat.Items.Insert(1, new ListItem("Item2", "2"));
ddlCat.Items.Insert(2, new ListItem("Item3", "3"));
ddlCat.Items.Insert(3, new ListItem("Item4", "4"));
</code></pre>
<p>I want set 2 default selectedItem on Item1 and Item3, how to do this?</p>
<p>Use those code, only the latest will be selected</p>
<pre><code>ddlCat.SelectedValue = "1";
ddlCat.SelectedValue = "3";
</code></pre>
<p>Thanks a lot!!</p>
| c# | [0] |
5,344,017 | 5,344,018 | problem to draw and fill rect after cgcontextclip | <p>I want to clip a rectangle from cgpath with the following code. I don't get any output. What's wrong?</p>
<pre><code> CGContextRef context = UIGraphicsGetCurrentContext();
CGMutablePathRef thePath = CGPathCreateMutable();
CGPathMoveToPoint(thePath,NULL,(self.x1),(self.y1));
CGPathAddLineToPoint(thePath,NULL,(self.x2),(self.y2));
CGPathAddLineToPoint(thePath,NULL,bx2,by2);
CGPathAddLineToPoint(thePath,NULL,bx1,by1);
CGContextAddPath(context, thePath);
CGContextClip(context);
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CFRelease(thePath);
</code></pre>
| iphone | [8] |
705,111 | 705,112 | want to show icon for settings on UIToolbar | <p>Want to show icon for settings UIBarButtonItem on UIToolbar than text button </p>
<pre><code>UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc]
initWithTitle:@"Settings" style:UIBarButtonItemStyleBordered
target:self action:@selector(settingsButtonTapped)];
</code></pre>
<p>Anyone know how to show icon for settings UIBarButtonItem?</p>
<p>Will appreciate any help.</p>
<p>Thanks so much in advance.</p>
| iphone | [8] |
1,605,191 | 1,605,192 | SystemTray Icon Coordinate - C# | <p>How can I get those coordinates of Application Icon which is find in the Window taskbar's status area (a.k.a. System Tray) in C#?</p>
| c# | [0] |
3,661,575 | 3,661,576 | help with show/hide jquery script | <p>I need a js script show / hide with only shown one div at time others closed. By default any (only one) must be shown.</p>
<p>I have got this script: <a href="http://jsfiddle.net/kolxoznik1/BFV9k/" rel="nofollow">http://jsfiddle.net/kolxoznik1/BFV9k/</a>.</p>
<p>I want to add some class like <code>show</code>: </p>
<pre><code> <div class="toggle show">Content</div>
</code></pre>
<p>If <code>show</code> will be added div will not be hided, he will heve status <code>show()</code> othervise all divs will be <code>hide()</code>.</p>
<p>Suppose someone will help me with my small problem.</p>
| jquery | [5] |
1,061,830 | 1,061,831 | Question about the NSArray | <pre><code>groupContentList = [[NSArray alloc] initWithObjects:
[Product productWithType:@"Device" name:@"iPhone"],
[Product productWithType:@"Device" name:@"iPod"],
[Product productWithType:@"Device" name:@"iPod touch"],
[Product productWithType:@"Desktop" name:@"iMac"],
[Product productWithType:@"Desktop" name:@"Mac Pro"],
[Product productWithType:@"Portable" name:@"iBook"],
[Product productWithType:@"Portable" name:@"MacBook"],
[Product productWithType:@"Portable" name:@"MacBook Pro"],
[Product productWithType:@"Portable" name:@"PowerBook"], nil];
</code></pre>
<p>How to print the value of groupcontestList </p>
| iphone | [8] |
3,018,830 | 3,018,831 | xml parsing in android | <p>when i run my program in out put value shown is null.</p>
| android | [4] |
1,334,257 | 1,334,258 | how to set view in dialog interface? It is overriding onClick(DialogInterface dialog,int which) method but not with onClick(View v) | <pre><code>@Override public void onCreate(Bundle savedInstanceState) { Button saveButton = (Button) findViewById(R.id.saveButton); saveButton.setOnClickListener(saveButtonListener); }
public OnClickListener saveButtonListener = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
if (queryEditText.getText().length() > 0
&& tagEditText.getText().length() > 0) {
makeTag(queryEditText.getText().toString(), tagEditText.getText().toString());
queryEditText.setText("");
tagEditText.setText("");
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(tagEditText.getWindowToken(),
0);
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(
FavoriteTwitterSearches.this);
builder.setTitle((R.string.missingTitle));
builder.setPositiveButton(R.string.OK, null);
builder.setMessage(R.string.missingMessage);
AlertDialog errorDialog = builder.create();
errorDialog.show();
}
}
};
</code></pre>
| android | [4] |
432,065 | 432,066 | Checking for empty number as input | <p>Consider this code:</p>
<pre><code>>>> num = int(raw_input('Enter the number > '))
</code></pre>
<p>If the user types nothing and presses 'Enter', I want to capture that. (Capture an empty input)</p>
<p>There are two ways of doing it:</p>
<ul>
<li>I do a simple <code>num = raw_input()</code>, then check whether <code>num == ''</code>. Afterwards, I can cast it to a <code>int</code>.</li>
<li>I catch a <code>ValueError</code>. But in that case, I can't differentiate between an non-numerical input and a empty input.</li>
</ul>
<p>Any suggestions on how to do this?</p>
| python | [7] |
1,478,015 | 1,478,016 | Remote Mysql Server connection by PHP | <p>While i execute following code:</p>
<pre><code>$db_host = "<IP>"; // Host name
$db_user = "<usr>"; // User name of your database
$db_password = "<pass>"; // Password of your database
$db_name="<db name>"; // Database name
$con = mysql_connect($db_host,$db_user,$db_password);
mysql_select_db($db_name) or die("Cannot select database...");
</code></pre>
<p>It shows following errors:</p>
<p><strong>Warning</strong>: mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter than expected in C:\wamp\www\limosbusesjets\connection.php on line 21</p>
<p><strong>Warning</strong>: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using old authentication in C:\wamp\www\limosbusesjets\connection.php on line 21
Cannot select database...</p>
| php | [2] |
4,117,821 | 4,117,822 | backlight manipulation in Android | <p>Could someone show me in a snipet of code how to set the backlight always on in android ?</p>
| android | [4] |
4,586,088 | 4,586,089 | Interface does not have constructor, then how can it be inherited? | <p>& i have this doubt</p>
<p>As i know the subclass constructor calls the super class constructor by using super();.
But since interface doesn't have any constructor how can inheritance take place??</p>
<p>Please let me know the answer</p>
<p>Thank you </p>
| java | [1] |
5,517,744 | 5,517,745 | SoapHttpClientProtocol Versus HttpWebRequest | <p>I'm doing some performance testing and ran across something puzzling to myself and I was hoping someone could shed some light.</p>
<p>I'm comparing the performance between an HttpWebRequest and a SoapHttpClientProtocol. In my tests I see the SoapHttpClientProtocol class performing twice as fast. However, I expected the HttpWebRequest to performance better.</p>
<p>Thanks for any insight anyone can provide!</p>
<p>Sam</p>
<p>Here is the code for the HttpWebRequest</p>
<pre><code>public string RetrieveValue()
{
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] payload = encoding.GetBytes("sIP=");
string Url = @"url/RetrieveValue";
HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create(Url);
wr.Method = "POST";
wr.KeepAlive = false;
wr.ContentType = "application/x-www-form-urlencoded";
wr.ContentLength = payload.Length;
wr.Timeout = 30000;
HttpWebResponse webResponse;
Stream wrStream = wr.GetRequestStream();
wrStream.Write(payload, 0, payload.Length);
wrStream.Close();
webResponse = (HttpWebResponse)wr.GetResponse();
Stream baseStream = webResponse.GetResponseStream();
string result = null;
using (StreamReader sr = new StreamReader(baseStream))
result = sr.ReadToEnd();
return result;
}
</code></pre>
<p>Here is the Code for the SoapHttpClientProtocol</p>
<pre><code>WebServiceBinding(Name = "Soap", Namespace = "http://namespace.com/")]
public class MyRetriever : SoapHttpClientProtocol
{
[SoapDocumentMethod("http://url.com/Retrieve", RequestNamespace = "http://url.com/", ResponseNamespace = "http://url.com/", Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public string RetrieveValue(string sVal)
{
return (string)base.Invoke("RetrieveValue",
new object[] { sVal })[0];
}
}
</code></pre>
| asp.net | [9] |
5,835,682 | 5,835,683 | Conditional Rule Validation in JQuery | <p>I am using <a href="http://docs.jquery.com/Plugins/Validation#API%5FDocumentation" rel="nofollow">JQuery Validation</a>. Now I want my rules to be invoked only when certain condition is satisfied, namely, I want <code>$("#AppSelectField").is(':hidden')</code> to return <code>false</code>, only then I invoke the rules.</p>
<p>My rules is as follow:</p>
<pre><code>$(function() {
$("#RequestLock").validate({
rules: {
FloorNum:{
required: true,
digits: true
},
},
message: {
FloorNum: "The floor number must be integer",
},
});
});
</code></pre>
<p>How to modify the above section to satisfy my needs? <strong>Note I don't want to write my own custom method for <code>required</code> and <code>digits</code>.</strong> </p>
| jquery | [5] |
4,906,231 | 4,906,232 | Sound Loudly when Push notification arrives | <p>What i am wondering is to ring the Phone Loudly even if Its on Silent mode when any push notification arrives. The Phone may have opened that Application / in Background / not Opened but it should Ring loudly when a Push notification for this application arrives.</p>
| iphone | [8] |
4,512,544 | 4,512,545 | Android : To Find Meaning for the word | <p>i want to find meaning for the English word. For that what can I do in android? any predefined db is using inside android for finding the meaning for the word</p>
| android | [4] |
2,407,257 | 2,407,258 | Global variable is NULL in class method | <p>My first line in my script I have:</p>
<pre><code>$db = new db_class();
</code></pre>
<p>This is just an example to start the db object. Then I have:</p>
<pre><code>class main {
function init() {
$this->session_start();
}
protected function session_start() {
$sh = new session_handler();
session_set_save_handler(
array (& $sh, 'open'),
array (& $sh, 'close'),
array (& $sh, 'read'),
array (& $sh, 'write'),
array (& $sh, 'destroy'),
array (& $sh, 'gc')
);
}
}
</code></pre>
<p>All of the problems are in the in <code>session_handler</code> class. This code:</p>
<pre><code>public function write($id, $data) {
global $db;
var_dump($db); //returns NULL
}
</code></pre>
<p>says that <code>$db</code> is <code>NULL</code> instead of an instance of <code>db_class</code>.</p>
<p>Note, <code>db_class</code> objects work except when calling the <code>write()</code> method:</p>
<pre><code>class main {
function init() {
global $db;
var_dump($db); //returns the db object correctly
$this->session_start();
}
protected function session_start() {
$sh = new session_handler();
session_set_save_handler(
array (& $sh, 'open'),
array (& $sh, 'close'),
array (& $sh, 'read'),
array (& $sh, 'write'),
array (& $sh, 'destroy'),
array (& $sh, 'gc')
);
}
}
</code></pre>
| php | [2] |
3,883,640 | 3,883,641 | Why do PHP's built in functions use constants instead of just strings as parameters? | <p>I noticed that PHP's internal functions never use strings for pre-defined or limited values, only constants.</p>
<p><a href="http://hu2.php.net/manual/en/function.str-pad.php">For example</a>:</p>
<blockquote>
<p><strong>pad_type</strong>:</p>
<p>Optional argument pad_type can be STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH. If pad_type is not specified it is assumed to be STR_PAD_RIGHT.</p>
</blockquote>
<p>What's the reason for not using a string as parameter here?</p>
<p><code>str_pad($test, 10, 0, 'left')</code> seems a lot simpler than <code>str_pad( $test, 10, 0, STR_PAD_LEFT)</code></p>
<p>(This is more of a meta question. I hope it's OK to ask here.)</p>
| php | [2] |
3,576,328 | 3,576,329 | built-in icons for most popular types of files | <p>Whether there is in Android system a database of icons for the most popular types of files? Something like imageres.dll in Windows. Or any application should have its own icons for every file type?</p>
| android | [4] |
3,817,563 | 3,817,564 | PHP site keeps opening to blank page, no errors | <p>First, the premises: PHP loaded on IIS6 on Win2003 STD R2 SP2, PHP_5213 using FastCGI, MySQL_5145.</p>
<p>Customer sent me the site files, which I unzipped to <code>C:\InetPub\wwwroot\<site root></code>, then I created a new site in IIS, pointed to <code><site root></code>, added <code>test.php</code> to the site files for testing and it works, but visiting <code>index.php</code> produces a blank page with no errors. The <code>readme.txt</code> file present makes reference to <code>application.php</code> and explains root folder var and sets it to a non-existent file.</p>
<p>I don't know PHP syntax, but I tried several logical changes with zero results. At this point I'm not even sure if that is the problem anymore. With PHP, MySQL & site debugging have put in over 20 hours. Still confused, I have resorted to heavy drug use and purchased a small firearm, loaded with a single round (even this seemed to take an inordinate amount of time). I've given up all hope.</p>
<p>Someone please help save a new server and/or old administrator.</p>
| php | [2] |
1,754,663 | 1,754,664 | How to overwrite a convenience constructor the proper way? | <p>For example I want to overwrite from UIButton:</p>
<pre><code>+ (id)buttonWithType:(UIButtonType)buttonType
</code></pre>
<p>So I would do:</p>
<pre><code>+ (id)buttonWithType:(UIButtonType)buttonType {
UIButton *button = [UIButton buttonWithType:buttonType];
if (button != nil) {
// do own config stuff ...
}
return button;
}
</code></pre>
<p>is that the right way? Or did I miss something? (yeah, I have been overwriting thousands of instance methods, but never class methods ;) )</p>
| iphone | [8] |
1,224,903 | 1,224,904 | Split and parse window.location.hash | <p>I'm facing issues with splitting and parsing window.location.hash correctly.</p>
<p>First of all, we get few parameters in hash, ex:</p>
<pre><code>#loc=austria&mr=1&min=10&max=89
</code></pre>
<p>As you surely see it's been created for search. When user clicks on pagination link page is being reloaded with the hash. So far so good.</p>
<p>I created function initialise() that is calling every time when there's hash in the URL:</p>
<pre><code>if (window.location.hash) {
var params = (window.location.hash.substr(1)).split("&");
for (i = 0; i < params.length; i++)
{
var a = params[i].split("=");
// Now every parameter from the hash is beind handled this way
if (a[0] == "loc")
{
locationList(a[1]);
}
}
}
</code></pre>
<p>Everythig is almost working... When I choose all search params hash is being... cut. For unknown reason for me. I tried to use <code>if( params.indexOf('loc') )</code> instead of <code>a[0] == "loc"</code> without any luck.</p>
<p>Could you lend me a hand?</p>
<p><strong>Edit</strong><br>
Of course, I was using var a = ... in the loop, it was only copy-paste error.</p>
| javascript | [3] |
5,489,341 | 5,489,342 | Switch Error Codes | <p>How do I create an error handler in Android. In .Net I would simply create a handler the switch the error codes to relay the correct response required to the user.</p>
<p>In this case I am using a SAX parser surrounded by try and catch, when an error is raised I obviously get a message but no unique error ID. there may be ten errors captured by the try\catch block but how do I distinguish between the errors so I can try and handle the expected errors?</p>
<p>Ideally something like this:</p>
<pre><code>switch (e.getErrorID){
case 1000:
//Handle This Expected Error
break;
case 1064:
//Handle This Expected Error
break;
case 2025:
//Handle This Expected Error
break;
default:
//Unexpexted Error
}
</code></pre>
<p>Maybe I should mention, the error im trying to catch is empty document</p>
| android | [4] |
1,855,024 | 1,855,025 | Field testing iPhone for Cell ID and RSSI | <p>I need to write a testing application to retrieve info about <code>cell id</code> and <code>rssi</code> on iphone4 IOS 4.2.1, like FieldTest application (Calling <em>3001#12345#</em> view UMTS Cell Enviroment/GSM Cell Enviroment).</p>
<p>I have tried to import CoreTelephony framework and using private API (<code>CTServerConnectionCreate</code>/<code>CTServerConnectionCellMonitorStart</code>).</p>
<p>In this way I am able to retrieve info if I connect to 2g network.</p>
<p>If enable 3G, when I call <code>CTServerConnectionCellMonitorGetCellCount</code>, cellcount is always 0.</p>
<p>How can I retrieve these info if connected to 3G Network?</p>
| iphone | [8] |
5,502,388 | 5,502,389 | why delay() function not delaying the .load() function? | <p>$("#hastable").delay(2000).load("tbl_clients.php?page=");
It is not working for me.</p>
<p>But otherwise all effect delay successfully for this .delay() function like .hide(),.show()</p>
| jquery | [5] |
2,987,365 | 2,987,366 | escape HTML chracters | <p>I need to HTML encode chracters like my input is <code><test></code> my expected output is <code>&lt;test&gt;</code>.</p>
<p>How can I do this?</p>
| javascript | [3] |
4,132,923 | 4,132,924 | android GPS enable progrmmatically | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4721449/enable-gps-programatically-like-tasker">Enable GPS programatically like Tasker</a> </p>
</blockquote>
<p>I want to get latitude and longitude programmatic in android app. But it depended upon whether the GPS is enabled or not. I used to check the GPS with this code</p>
<pre><code> LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
{
if(!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER ))
{
Intent myIntent = new Intent( Settings.ACTION_LOCATION_SOURCE_SETTINGS );
startActivity(myIntent);
}
}
</code></pre>
<p>But it basically shows the screen to enable it. But i dont want that user should enable it. It should enable automatically if the gps is disabled. </p>
<p>Any sample code would be appreciated.</p>
| android | [4] |
1,695,833 | 1,695,834 | not able to make TextView as focusable | <p>hi im using 3 text views ..i have made them as clickable and i have written action part for those ..but theyr not focussing ...even i have set android:focusable to true ..please help </p>
| android | [4] |
3,520,540 | 3,520,541 | Dynamic VariableFromString in objective C | <p>I want to dynamically create variable from string in objective C.</p>
<p>Like <code>NSClassFromString</code> thats way. In that I want to access variable.</p>
<p>Any idea about this?</p>
| iphone | [8] |
5,253,934 | 5,253,935 | Create classes and compile it from c# | <p>I am creating a custom code generator using c#... this generator now only creates the bussiness entity from tables of a database. But Now what I want is to create a project that contains this classes and after its creation.... Generate the dll from the project.</p>
<p>Is there a way to do this job?</p>
| c# | [0] |
246,434 | 246,435 | C# find first match of string in string array | <p>I have to search for the first match of any string in an string array in a textbox starting from a certain position. Like if I have this string array: </p>
<pre><code>string[] s = { "RTS", "RTL" };
</code></pre>
<p>And this code:</p>
<pre><code>LDA #$43
STA $1000,x
CMP $00
BEQ .main
.return
RTS
.main
add $01
RTL
</code></pre>
<p>It should return RTS since that's the first match (not the RTL). How can I do this? Additionally, would there be a better way of doing this rather than using an array?</p>
<p>Edited since I gave a bad example of what I was trying to do.</p>
| c# | [0] |
859,178 | 859,179 | ABPersonVIewController at DidSelectRowAtIndex - method | <p>i am trying to open ABPersonViewController at 'didSelectRowAtIndexPath:' method. But when i click on one of my record in table view it donot show anything.I am not able to configure out where is the problem. Where 'people' is array having contact name.
here is my code:</p>
<pre>
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ABRecordRef person = (ABRecordRef)[people objectAtIndex:indexPath.row];
ABPersonViewController *pvc = [[ABPersonViewController alloc] init];
pvc.personViewDelegate = self;
pvc.displayedPerson = person;
[self.navigationController pushViewController:pvc animated:YES];
[pvc autorelease];
}
- (BOOL)personViewController:(ABPersonViewController *)personViewController shouldPerformDefaultActionForPerson:(ABRecordRef)person
property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifierForValue
{
return NO;
}
</pre>
| iphone | [8] |
702,132 | 702,133 | Assigning variable OnClick random action | <pre><code>var Rand1 = Math.floor(Math.random()*3);
var Rand2 = Rand1;
while ( Rand2 == Rand1 ){
var Rand2 = Math.floor(Math.random()*3);
}
var step1 = Rand1;
var step2 = Rand2;
function moveto(step1, step2) {
var w = $(document).width();
$('#full').animate({
left: -(step1*w)
}, {
duration: 3000,
});
}
//what element is this supposed to be?
class="img bg-img1" OnClick="moveto('1');">
</code></pre>
<p>My problem is: I need to assign the random number given by Rand1 into the OnClick="moveto('Rand1'); how do i do that ? </p>
| javascript | [3] |
5,135,497 | 5,135,498 | Secure function for validate forms with PHP | <p>I want to know is there a way to check inputs securely with php?</p>
| php | [2] |
829,381 | 829,382 | jQuery - fire click event on live loaded elements | <p>I've an ajax modal with profile data, splitted by special categories, which are folded.</p>
<p>In my global.js, i'm loading the following code:</p>
<pre><code>$(document).on('click', '.msg-head', function() {
if($(this).hasClass('msg-close')) {
$(this).next('.msg-body').show(50);
$(this).removeClass('msg-close').addClass('msg-open');
} else {
$(this).next('.msg-body').hide(50);
$(this).removeClass('msg-open').addClass('msg-close');
}
});
</code></pre>
<p>The modal form which includes the .msg-head classes (categories), is loaded dynamically via click on each profile.</p>
<p>Now i tried to include a hotkey plugin:</p>
<pre><code> $(document).bind('keydown', 'ctrl+1', function(ev) {
$('#model-form .msg-head:eq(0)').click();
return false;
});
</code></pre>
<p>works as expected at the first profile. If I close the first profile and open any other, jquery can't handle the $('#model-form .msg-head:eq(0)') element.</p>
<p>How can I access the first .msg-head element live ???</p>
| jquery | [5] |
2,920,752 | 2,920,753 | Creation of viewmodel for treeview in WPF with grouping of objects | <p>I am creating an application for chatting in WPF(C#.net).
I have created a class User with following attributes:
1.Company_name
2.Branch
3.Designation
4.User_name
I am getting the list of objects of class user.
I want to display the users in treeview as:</p>
<p>Company name1
-Branch1
-:Designation1
*User name1
*User name2
-Branch2
-:Designation1
*User name3
-:Designation2
*User name4</p>
<p>when user list is refreshed, the tree structure will reloaded.
I want to create this tree structure considering users with same parent.
I am getting the user list at run time when a new user logs in.
How to create such tree?
I want to know, how to create such treeview using "ViewModel and display it in WPF window"??</p>
| c# | [0] |
3,606,877 | 3,606,878 | extend onclick function | <p>I have a onclick function like this</p>
<pre><code>onclick = function(){alert('hello')}
</code></pre>
<p>I want to add an additional function to it base on the server response so that I can display more, like not only display hello but also 'you are welcome', how to writ this without jquery?</p>
<pre><code>onclick = function(){alert('you are welcome')}
</code></pre>
<p>thank you for helping.</p>
| javascript | [3] |
772,268 | 772,269 | AudioManager and system volume change receiver | <p>I've followed instructions on <a href="http://android-developers.blogspot.com/2010/06/allowing-applications-to-play-nicer.html" rel="nofollow">this page</a> until "Preparing your code for Android 2.2 without restricting it to Android 2.2". Even if I'm building against 2.3 version, I guess it should be working at this point but it's not. I've registered a receiver in manifest:</p>
<pre><code><receiver android:name="RemoteControlReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
</code></pre>
<p>created a class for RemoteControlReceiver declaration:</p>
<pre><code>public class RemoteControlReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "onReceive", Toast.LENGTH_SHORT).show();
}
}
</code></pre>
<p>and finally boostrapped it in the starting activity.</p>
<pre><code>private AudioManager _audioManager;
private ComponentName _componentName;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
_audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
_componentName = new ComponentName(getPackageName(), RemoteControlReceiver.class.getName());
}
@Override
protected void onResume() {
super.onResume();
_audioManager.registerMediaButtonEventReceiver(_componentName);
_audioManager.requestAudioFocus(new OnAudioFocusChangeListener() {
@Override
public void onAudioFocusChange(int focusChange) {
Toast.makeText(getApplicationContext(), "onFocusChanged", Toast.LENGTH_SHORT).show();
}
}, AudioManager.STREAM_MUSIC, 0);
}
</code></pre>
<p>Could you point out what am I missing here ? I have an assumption that in order to receive thodse messages I my activity has to play any media stuff. I gonna test it right away.</p>
<p>P.S. As you see I've even added some uneccessary code - don't pay attention to requestAudioFocus.</p>
<p>Thanks for any suggestions.</p>
| android | [4] |
971,550 | 971,551 | Casting an object's class | <p>My previous OOP experience has been with Objective-C (which is dynamically typed), however, I am now learning Java. I want to iterate over an ArrayList of objects and perform a certain method on them. Every object in the ArrayList is of the same class. In Objective-C, I would just check in each iteration that the object was the correct class, and then run the method, but that technique is not possible in Java:</p>
<pre><code>for (Object apple : apples) {
if (apple.getClass() == Apple.class) {
apple.doSomething(); //Generates error: cannot find symbol
}
}
</code></pre>
<p>How do I 'tell' the compiler which class the objects in the ArrayList belong to?</p>
| java | [1] |
3,443,177 | 3,443,178 | Blank page when run php file | <p>When I run the bellow php code & fill all data and submit it I get blank page,
so where the problem here ?</p>
<pre><code><br><br>
Create New User :
<br><br>
<table width="90%" border=0><tr><td>
<FORM ACTION="user_login.php" METHOD=POST>
<INPUT TYPE=HIDDEN NAME=p_action VALUE="Create_New_User">
Username : <br><INPUT TYPE=TEXT NAME=p_in_username SIZE="25"> <BR>
eMail : <br><input type=text name=p_in_email size="25"> <br>
<br>
<input type=submit value="Submit">
</FORM>
<?php
?>
</code></pre>
| php | [2] |
3,076,623 | 3,076,624 | To get URL From Safari Browser | <blockquote>
<p><strong>Exact Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3482750/how-to-get-url-from-safari-browser">How to get URL from Safari browser </a> </p>
</blockquote>
<p>I m creating a program which can access the current url being used.
How can i do such in Safari Browser?</p>
| c# | [0] |
4,893,493 | 4,893,494 | file_get_contents memory issue | <p>I'm using file_get_contents just to call a php file (which returns some data); like that:</p>
<p><code>file_get_contents('http://example.com/foo.php');</code> and NOT e.g. <code>$holding_var = file_get_contents('http://example.com/foo.php');</code></p>
<p>Will it use the assigned memory of 20kB (let's say the meant file called by my script returns a 10kB response) or will not use the memory at all since the result is not stored in any variable?</p>
| php | [2] |
2,939,268 | 2,939,269 | php file_exists does not work for array | <p>I posted this question earlier but I have now used the feedback and simplified the php program to show how it still fails.
using the file_exists with an array always fails:
Here is a simple program I wrote that shows the failure:</p>
<pre><code>[root@dsmpp1 steve]# ls -l data
total 4 -rw-r--r-- 1 root root 0 Sep 19 11:41 test_file
[root@dsmpp1 steve]# cat test_file.php
`#!/usr/bin/php -q
<?php
$i=1;
$testarray=array();
$testarray[$i]="test_file";
echo "testarray $testarray[$i]\n";
**if(file_exists("/home/steve/data/testarray[$i]")) {**
echo "file exists\n"; }
else { echo "file does not exist\n"; } `
[root@dsmpp1 steve]# php -q test_file.php
testarray test_file
file does not exist
[root@dsmpp1 steve]#
</code></pre>
<p>I used the double quotes around the directory and file name as suggested earlier
and it is still not working.</p>
| php | [2] |
4,321,127 | 4,321,128 | str.format() problem | <p>So I made this class that outputs '{0}' when x=0 or '{1}' for every other value of x.</p>
<pre><code>class offset(str):
def __init__(self,x):
self.x=x
def__repr__(self):
return repr(str({int(bool(self.x))}))
def end(self,end_of_loop):
#ignore this def it works fine
if self.x==end_of_loop:
return '{2}'
else:
return self
</code></pre>
<p>I want to do this:<br>
<code>offset(1).format('first', 'next')</code><br>
but it will only return the number I give for x as a string. What am I doing wrong?</p>
| python | [7] |
1,010,798 | 1,010,799 | Get property into abstract class | <p>Here's what I have right now: </p>
<pre><code>public abstract class SampleClass
{
public abstract void ShowAll();
public abstract void ExecuteById(int id);
public string sampleString{get;}
}
public sealed class FirstClass : SampleClass
{
public override string sampleString
{
get { return "AA"; }
}
public override void ShowAll()
{
......
}
public override void ExecuteById(int id)
{
......
}
}
public sealed class SecondClass : SampleClass
{
public override string sampleString
{
get { return "BB"; }
}
public override void ShowAll()
{
......
}
public override void ExecuteById(int id)
{
......
}
}
</code></pre>
<p>Now I add a function like this to each of the classes</p>
<pre><code>public void runStoredProcedure(string sampleString)
{
SQLClass.ExecuteStoredProcedure(sampleString)
}
</code></pre>
<p>One of the ways of doing that is to just add this as an abstract to sampleClass and as an ovverride to FirstClass and SecondClass. Altough the only difference is the passing parameter (samplestring).</p>
<p>The question: is it possible to place this function somewhere(probably in SampleClass) and pass overriden string to this function from First/Second classes to avoid overhead?</p>
| c# | [0] |
3,735,922 | 3,735,923 | java how to count the sum of all digits in double variable | <p>I've this code and I managed to count <code>77!</code> number. However I'm a bit confused how to count the sum of all digits in double variable ?</p>
<p>77!= 1.4518309202828584E113. And I can't use integer data types here. What should I do?</p>
<pre><code>package org.kodejava.example.io;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
public class Many {
public static void main(String[] args) {
System.out.println(factorial(77))
}
public static double factorial(double n) {
if (n == 0) return 1;
return n * factorial(n-1);
}
}
</code></pre>
| java | [1] |
328,782 | 328,783 | document.ready is to slow, it takes like 2min to load | <p>I have some problem using document.ready, it slows down the loading time with sometimes up to two minutes.</p>
<p>I saw this link : <a href="http://encosia.com/dont-let-jquerys-document-ready-slow-you-down/" rel="nofollow">http://encosia.com/dont-let-jquerys-document-ready-slow-you-down/</a></p>
<p>So my question is, how can I use that approach instead of document.ready ?</p>
<p>here's my document.ready function inside custom.js file.</p>
<pre><code>$(document).ready(function () {
setBudgetPeriodReadOnly();
adjustTablePerBudgetNiva(budgetNiva);
disableDeletedAccounts();
allowedKeyCodes();
showHideZeroRowsEvent();
removeZeroOnClick();
bindMouseOverOutEvent();
bindTableRowEvents();
returnAsTabEvent();
budgetNivaChangedEvent();
</code></pre>
<p>});</p>
<p>as you see it contains some funtions, and those functions using child functions and so on.</p>
<p>here's a sample of a function using live</p>
<pre><code>function bindMouseOverOutEvent() {
$('#budgetTable tr').live({
mouseover: function () {
$(this).find('td:eq(6)')
.removeClass('budgetBelopp')
.end().toggleClass('budgetTable-hover');
},
mouseout: function () {
$(this).find('td:eq(6)')
.addClass('budgetBelopp')
.end().toggleClass('budgetTable-hover');
}
});
</code></pre>
<p>}</p>
<p>but its not working because its wrapped in a function, and I want them to be wrapped so I see on the function name what the function is doing. </p>
<p>I'm also new to jQuery.</p>
| jquery | [5] |
2,585,816 | 2,585,817 | "Missing method body" error | <pre><code>import java.util.Scanner;
public class Rpn_calculator
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
double ans = 0;
double n = 0;
double r = 0;
String j;
System.out.println();
System.out.println();
System.out.print("Please enter a value for n ");
n = keyboard.nextDouble();
System.out.print("Please enter a value for r ");
r = keyboard.nextDouble();
System.out.println("Please choose one of these operands:+,-,*,nCr,/ to continue, or q to quit ");
j = keyboard.nextLine();
while (j != "q")
{
if(j == "+")
ans = n + r;
if(j == "-")
ans = n - r;
if(j == "*")
ans = n * r;
if(j == "/")
ans = n / r;
if(j == "nCr")
ans = factorial(n + r -1) / (factorial(r)*factorial(n - 1));
System.out.print(ans);
System.out.print("Please enter a value for n ");
n = keyboard.nextDouble();
System.out.print("Please enter a value for r ");
r = keyboard.nextDouble();
System.out.print("Please choose one of these operands:+,-,*,nCr,/ to continue or q to quit ");
j = keyboard.nextLine();
}
}
public static double factorial(double x);
{
double sum = 1;
int i;
for (i = 0; i<= x; i++);
sum = sum * i;
return sum;
}
}
</code></pre>
<p>I am trying to create an RPN calculator for this assignment, I believe I have what I need to make it function, but I have syntax errors with my factorial function. It says "missing method body".</p>
<p>Also, I don't understand why, when I compile it, my string input request is ignored completely - locking the program in the <code>while</code> loop. I hope I'm not missing something really obvious.</p>
| java | [1] |
2,982,733 | 2,982,734 | success or fail popup | <p>i have a php class to show a suceess message or fail message after an action (posting a form/updating a page) currently refreshes the page and psts either 1 or 0 and then the following code - - how can i get this to just pop up and auto close...just like a green tick or cross.....assume need to use jquery - - totally lost here so any advise welcome...thanks</p>
<pre><code> <?
$response = $_GET['response'];
if ($response == '0') {
echo"
<div class=\"error message\">
<h5>FYI, something just happened!</h5>
<p>This is just an info notification message.</p>
</div>
";
}
if ($response == '1') {
echo"
<div class=\"success message\">
<h5>FYI, something just happened!</h5>
<p>This is just an info notification message.</p>
</div>
";
}
?>
</code></pre>
| jquery | [5] |
4,850,586 | 4,850,587 | string replace javascript/jquery | <pre><code>[{"field":"Comment","message":"Message cannot be empty"}]
</code></pre>
<p>In the above string i want to replace the word <strong>comment</strong>. I dont wish to use any other external libraries expect jquery</p>
| javascript | [3] |
3,035,853 | 3,035,854 | Android Fragment stack empty after rotate | <p>I'm using a <code>FragmentActivity</code> to display a stack of <code>Fragments</code> in a single activity app. This is working fine and I can move through the fragments and hit back to go back up the stack until I rotate the device when I end up with the <code>Fragment</code> on the top of the stack rotated but hitting the back button takes me back to the root <code>Fragment</code> with all other <code>Fragment</code>s in between gone.</p>
<p>I'm using the following code to add a <code>Fragment</code> to the stack:</p>
<pre><code>FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.mainContentViewContainer, newFragment, "DetailFragment");
transaction.addToBackStack(null);
transaction.commit();
</code></pre>
<p>What could be causing the stack to be empty after rotate?</p>
| android | [4] |
386,384 | 386,385 | improving a routing class* | <p>I use the class below to route all requests for php on my web application. Can I improve upon this?</p>
<pre><code>/*route*/
class route
{
function __construct($a)
{
if(isset($_FILES['ufile']['tmp_name'])) // handles file uploads
{
new upload();
}
elseif(isset($_POST['a'])) // handles AJAX
{
$b=$_POST['a'];
switch($b)
{
case '0':
new signin();
break;
case '1':
new signup();
break;
case '2':
session::finish();
break;
case '3':
new bookmark('insert');
break;
case '3a':
new bookmark('delete');
break;
case '4':
new tweet();
break;
default:
echo "ajax route not found";
break;
}
}
elseif($a!=0) // handles views
{
new view($a);
}
else
{
// route not found
}
}
}
</code></pre>
<p>Verification(passes)</p>
<pre><code>/*ROUTE
// Test Code - create entry
new route(0);
new route(1);
$_FILES['ufile']['tmp_name']='test file';
new route(0);
unset($_FILES['ufile']['tmp_name']);
$_POST['a']=0;
new route(0);
// Test Cases
// Case 0: echo "not routed: <br>";
// Case 1: echo "view created: $a <br>";
// Case 2: echo "file uploaded <br>";
// Case 3: echo "ajax responded: <br>";
*/
</code></pre>
| php | [2] |
4,718,298 | 4,718,299 | how to enable vertical scroling of web view layout with in scrollview tag | <p>I have problem in scrolling of webview vertically when it's scrolled along vertically,where this webview is with in scrollview tag,how can i enable the scrolling for webview and to disable the scrolling of whole layout when its on webview contained layout.</p>
| android | [4] |
4,242,550 | 4,242,551 | Preventing cell reordering for particular cells in iPhone SDK | <p>I have 2 sections in my UITableView. I want the 2nd section to be movable but the 1st section of cells not.
Specifying canEditRowAtIndexPath and canMoveRowAtIndexPath doesn't help - the first section cells although not showing drag controls, they still change places if a cell from the 2nd section is dragged over.
Is there a workaround for this?</p>
| iphone | [8] |
4,889,798 | 4,889,799 | PHP switch issue | <p>Is this method right?</p>
<pre><code>switch ($_GET['get']){
case 'show':
echo 'show';
break;
case is_numeric($_GET['app']):
echo $_GET['app'];
break;
}
</code></pre>
| php | [2] |
4,623,932 | 4,623,933 | Tigger alertBox from c2dm listener events | <p>I want to add progress and alert dialogs to whatever the active context may be, whenever the listener receives a message. With this code:</p>
<pre><code>public class C2DMMessageReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.w("C2DM", "Message Receiver called");
if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
Log.w("C2DM", "Received message");
final String payload = intent.getStringExtra("payload");
Log.d("C2DM", "dmControl: payload = " + payload);
// Message handling
if(payload.equals("DataUpdate")) {
progressDialog = ProgressDialog.show(context, "Please wait...", "Synchronizing data ...", true);
syncData(context);
progressDialog.dismiss();
AlertDialog.Builder alertbox = new AlertDialog.Builder(context);
alertbox.setMessage("Data was updated");
alertbox.create();
alertbox.show();
}
}
}
}
</code></pre>
<p>I get the following error when i recieve message:</p>
<pre><code>01-07 08:44:38.190: E/AndroidRuntime(750): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
</code></pre>
<p>Trying to figure out what the best way to handle this would be, do I need to cache the active context in a singleton, and then access said singleton from the listener? Or is there a better way? </p>
<p>Thanks</p>
| android | [4] |
3,023,468 | 3,023,469 | Where should you store variables for a search program in java? | <p><strong>I'm wondering which is a more effective storage method in java.</strong> Would be better to save constants in a class or a resource? The constants will be searched later by my Search program which will go through the list of constants so as to recognize possible options. Also if there is a more efficient method of storing them please say so or if i doesn't matter where i store them.</p>
<p><strong>1). A java class called Search is going to be inputted with two or more constants they will then either access a java class that will redirect them as needed.</strong></p>
<p><strong>2). Search will receive the same information but will look to a external resource to see what possible files match it then corresponding what info was give will open a pathway to the java class it correlated.</strong></p>
<p>Which version should be better or will it not matter?</p>
<p>the values the constants contain are going to be ints but each int will have their own unique meaning.</p>
<p>To clarify why i need these arrays each number is going to have a meaning and the arraylists will hold the numbers like 1 may mean work 2 may mean private and so a private work document would have name PDocument has [1,2] so on and so on
hope that clarifies</p>
<p>So which option is more effecient #1 or #2</p>
| java | [1] |
3,653,793 | 3,653,794 | C++ memory cache data structure | <p>I was wondering if there is an equivalent of the MemoryCache class from .net in C++? (http://msdn.microsoft.com/en-us/library/system.runtime.caching.memorycache.aspx) </p>
<p>I'm loading audio files/images frequently in my program and I'd like to avoid reloading audio/video if I've recently used it by keeping it in a memory cache. I realize I could use a map or something similar, but I was wondering if there was a data structure that'd be better suited to this sort of thing? Additionalyl if I used a map, I'd have to continually check when to expire something from the map and remove it</p>
<p>Does boost include something like this? I have that available already.</p>
<p>Thanks in advance</p>
| c++ | [6] |
2,488,971 | 2,488,972 | Object returning NaN when sum values | <p>I'll admit I'm weak in JavaScript and JSON. I've spent a lot of time attempting to figure out why numbers from my objects returns NaN when they are added together. With that in mind, below is my JSON, stored to a variable:</p>
<pre><code>var data = [
{
"acc_ext_id": null,
"cat_code": 10002,
"cat_ds": "REVENUE",
"category_id": null,
"chart_id": null,
"created_at": null,
"dept_id": null,
"feb": null,
"id": null,
"jan": 30,
"note": null,
"total_cost": null,
"updated_at": null,
"year_id": null
},
{
"acc_ext_id": "41260-02600",
"cat_code": 10002,
"cat_ds": "REVENUE",
"category_id": 2,
"chart_id": 2373,
"created_at": "2013-01-15 16:43:52.169213",
"dept_id": 86,
"feb": 45,
"id": 3,
"jan": 60,
"note": "Two",
"total_cost": 105,
"updated_at": "2013-01-15 16:43:52.169213",
"year_id": 1
}
]
</code></pre>
<p>I then attempt to iterate over the objects and sum the values:</p>
<pre><code>var jan;
for (var i=0;i<data.length;i++){
if(data[i].jan != null){
jan += parseFloat(data[i].jan);
console.log(jan);
}
}
</code></pre>
<p>Printed out in the console is <code>NaN</code>. I've attempted to parse the number as well as leave it raw, but to no avail. Is there something wrong with my objects? Here is a jsFiddle to illustrate: <a href="http://jsfiddle.net/5E2pm/3/" rel="nofollow">http://jsfiddle.net/5E2pm/3/</a></p>
| javascript | [3] |
5,401,899 | 5,401,900 | How do you apply htmlentities selectively? | <p>Whenever display text in an HTML document I always put it through htmlentities for a number of reasons. One of the reasons is that if the text contains HTML, I want the browser to display the HTML code, not render it.</p>
<p>The application I am writing requires that I still encode using htmlentities but hyper links need to be left alone.</p>
<p>Is there a way to do this efficiently using existing functions or do I need to implement this functionality?</p>
| php | [2] |
5,137,457 | 5,137,458 | Select next first element in jQuery | <pre><code> <fieldset id="fs1">
<legend id="leg1">First Legend</legend>
<div id="div1">
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque
laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi
<div id="div1Child">
********* Sample text here ****************
</div>
</div>
</fieldset>
<fieldset id="fs2">
<legend id="leg2">Second Legend</legend>
<div id="div2">
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium
voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint
<div id="div2Child">
********* Sample text here ****************
</div>
</div>
</fieldset>
</code></pre>
<p>When I click the <strong><em>legend</em></strong>, I should get the contents of the first div (div1 and div2) only. I don't want to display the "Sample Text Here" which is the child div(Id -->> div1Child and div2Child) of the div. Any help would be appreciated. It's pretty urgent.</p>
<p>Thanks in advance.</p>
| jquery | [5] |
235,859 | 235,860 | php max() and min() on associative array |
<pre><code>print_r($pages);
print max($pages);
print min($pages);
</code></pre>
<p>shows me</p>
<pre><code>Array ( [0] => 1 [1] => 2 [2] => 3 ) 1 2
</code></pre>
<p>While I was expecting the last two numbers to be 3 and 1. How come?</p>
<p>EDIT: further info</p>
<pre><code>$pages = $v->plaintext;
var_dump($pages);
$exp = explode("|", $pages);
print_r($exp);
print max($exp);
</code></pre>
<p>gives</p>
<pre><code>string(324) " 1 | 2 | 3 " Array ( [0] => 1 [1] => 2 [2] => 3 ) 1
</code></pre>
<p>Not sure what the "string(324) is? It's still outputting "1" as the max($exp) ...</p>
<p>EDIT: found solution, I was dealing with strings. This now works and prints out 3.</p>
<pre><code>$pages = $v->plaintext;
$exp = explode("|", $pages);
$exp = array_map("trim", $exp);
$exp = array_map("intval", $exp);
print max($exp);
</code></pre>
| php | [2] |
2,333,451 | 2,333,452 | How do I edit a class within a dll with one program in order to have the information accessed in another? | <p>I am trying to create 2 programs that have common code. I need one to add or delete data to/from an array that can be read by the other. Right now I have created a dll that has the class, but my problem is that I don't know how to properly instantiate it so that both programs will be using the same data. Both processes would not be running at the same time. </p>
| c# | [0] |
2,517,378 | 2,517,379 | If condition not working in android intent activity | <p>I'm new to Android. I need to start a new intent activity based on if condition, but
the if condition is not working, but the value gets printed in the log file.</p>
<p>the code that I use is given below:</p>
<pre><code>package com.example.helloandroid;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageButton next2 = (ImageButton)findViewById(R.id.imageButton1);
next2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
EditText pin =(EditText)findViewById(R.id.editText1); //value from edit text
Log.v("EditText", pin.getText().toString()); //this works in log
if (pin.equals(0000)){
Intent myIntent = new Intent(view.getContext(), home.class);
startActivityForResult(myIntent, 1);
}
}
});
}
@Override
public void onBackPressed() {
return;
}
}
</code></pre>
| android | [4] |
1,931,941 | 1,931,942 | Trouble with Java Clock | <p>I am doing a java clock for class and I am having some trouble with the tickDown() and addClock(Clock cl) parts of my program. I also need a Tester class but I would like to have this compile first. Any other help would be great.</p>
<p>Here is what I have so far...</p>
<pre><code>public class Clock {
private static final HOUR_TO_SECONDS = 3600;
private static final MINUTE_TO_HOURS = 60;
private static final DAY_TO_HOURS = 24;
private int hours;
private int minutes;
private int seconds;
public Clock ()
{
hours = 0;
minute = 0;
seconds = 0;
}
public Clock (int hours, int minutes, int seconds)
{
this.hours = hours;
this. minutes = minutes;
this.seconds = seconds;
}
public Clock (int totalSeconds)
{
hours = (totalSeconds / 3600) % 24;
minutes = (totalSeconds % 3600) / 60;
seconds = totalSeconds % 60;
}
public int getHours ()
{
return hours;
}
public int getMinutes ()
{
return minutes;
}
public int getSeconds ()
{
retuen seconds;
}
public void setHours (int hours)
{
this.hours = hours;
}
public void setMinutes (int minutes)
{
this.minutes = minutes;
}
public void setSeconds (int seconds)
{
this.seconds = seconds;
}
public void tick ()
{
int totalSeconds;
totalSeconds = hours * HOURS_TO_SECONDS + minutes * MINUTES_TO_SECONDS + seconds;
totalSeconds ++;
hours --;
minutes --;
seconds --;
}
public void tickDown ()
{
}
public clone addClock (Clock cl)
{
Clock clock;
int totalSeconds;
totalSeconds = this.hours * HOURS_TO_SECONDS + this.minutes * MINUTE_TO_SECONDS +
this.seconds + cl.getHours() * HOURS_TO_SECONDS + cl.getMinutes() * MINUTES_TO_SECONDS +
cl.getSeconds ();
Clock = new clock (totalSeconds);
return clock;
}
public string toString ()
{
str = "The time is: " + hours + ":" + minutes + ":" + seconds;
return str;
}
</code></pre>
| java | [1] |
5,198,956 | 5,198,957 | how to add 4 buttons in UInav bar for iphone | <p>i want to add 4 buttons in UINAV bar how to do that
should i make them in UINAVBAR controller or navItem or UIBarbutton???</p>
<p>any code will be appreciated
Thanks</p>
| iphone | [8] |
210,989 | 210,990 | how to unlock android phone from service | <p>how to unlock android phone from service(android.app.Service;) when phone is in locked sate</p>
| android | [4] |
1,370,095 | 1,370,096 | Trying to Print List: Getting Empty | <p>Here is my code:</p>
<pre><code>>>> f=open('list.txt')
>>> print list(f)
['bird\n', 'cat\n', 'cat\n', 'cat\n', 'tree']
>>> mylist=list(f)
>>> print mylist
[]
>>> print list(f)
[]
</code></pre>
<p>Why is the list empty??? Earlier in the code it shows the list is the correct list. Further, why it the first command "print mylist" showing an empty list? I had previously set mylist=list(f). Thanks.</p>
| python | [7] |
16,912 | 16,913 | append list within classes (python) | <p>I've run into a problem with inheritance in python that I know how to avoid, but don't completely understand. The problem occured while making a menu but I've stripped down the code to only the real problem.
code:</p>
<pre><code>class menu:
buttonlist=[]
>>> class av(menu):
def __init__(self, num):
self.buttonlist.append(num)
print self.buttonlist
>>> AV=av(12)
[12]
>>> class main(menu):
def __init__(self, num):
self.buttonlist.append(num)
print self.buttonlist
>>> Main=main(14)
[12, 14]
>>> AV.buttonlist
[12, 14]
</code></pre>
<p>I'd expect to get [14] in return by the 'Main=main(14)', and [12] with the 'AV.buttonlist' but instead it seems append has appended the list in all classes and objects :S
can anyone explain to me why this is?</p>
<p>thanks in advance!</p>
| python | [7] |
5,082,463 | 5,082,464 | what's wrong with this jQuery method? | <p>I have this method:</p>
<pre><code>function replaceRightClickIcefacesMethod() {
var oldName = jQuery(".singlePaneOfGlassBlock").attr("oncontextmenu");
oldName = oldName.replace('Ice.Menu.contextMenuPopup', 'contextMenuPopupUpdated');
jQuery(".singlePaneOfGlassBlock").attr("oncontextmenu", oldName);
}
</code></pre>
<p>I do not understand why Firebug reports: </p>
<blockquote>
<pre><code>oldName.replace is not a function
</code></pre>
</blockquote>
<p>Do you see any issue? For me it's just weird...</p>
<p><strong>UPDATE</strong>: Just notice that oldName returns a function, if I do alert(oldName):</p>
<pre><code>function oncontextmenu(event) {
Ice.Menu.contextMenuPopup(event, "j_id88:sectionContextMenu_sub", "j_id88:j_id111:0:j_id123:0:j_id124");
return false;
</code></pre>
<p>}</p>
| jquery | [5] |
5,765,359 | 5,765,360 | Switching between views in android data retained if any | <p>I am new to android development (and also a java newbie) and I noticed that when I switch between views I noticed that any variables declared as static in the view class retains its value but the rest are gone. So I have the following questions if some one is kind enough to answer --</p>
<ol>
<li><p>When to use static for variables if any?</p></li>
<li><p>If I want to retain the state of say my game between these switches (say to see the score or something), what is the way to do it? Is it by using static variables in the class to store everything? If so how do I reset the variables for a new game?</p></li>
</ol>
| android | [4] |
1,801,630 | 1,801,631 | How to hide the x/x display from ProgressDialog? | <p>The <code>ProgressDialog</code> displays the percentage and to right of the TextView there is another TextView which displays texts like x/100 where x = 1,2,3...100. Does anyone know how to hide the x/100 TextView and show only the progress in percentage.</p>
| android | [4] |
433,922 | 433,923 | Error while renaming file | <p>I have used a particular script for renaming the picture the if the file field is empty and username is changed. Username is what I need to save my image. Problem is arising on edit page... that if user don't want to change image and same time want to alter username, than according to me image should be renamed. But if file doesn't exist it is ending with warning message that I don't want... please help me if I can modify script in some what better way.</p>
<pre><code>if($file=="") {
$ext=substr($photo,strrpos($photo,"."));
$newphoto="$name$ext";
//Gives warning message if file not exist..
rename( "poetpic/$photo","poetpic/$newphoto");}
</code></pre>
| php | [2] |
4,683,457 | 4,683,458 | How can I open pdf from my app from remote URL in android | <p>I want to open PDF in my app from Remote URL. Please help me.</p>
<pre><code> Uri path = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.wsa);
final String googleDocsUrl = "http://docs.google.com/viewer?url=";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(googleDocsUrl +path), "text/html");
</code></pre>
<p>Thanks.</p>
| android | [4] |
4,273,171 | 4,273,172 | JavaScript with servlet Get method | <p>I have the following form element in JSP:</p>
<pre><code><form name="testForm" action="./test.do" method="post">
</form>
</code></pre>
<p>Now I want to submit a form with a servlet get method using JavaScript.</p>
<p>Any help is appreciated.</p>
| javascript | [3] |
3,474,733 | 3,474,734 | Link to php script | <p>I have a script which I can run from windows console writing "php backup.php". How to create a link to run it directly from desctop?</p>
| php | [2] |
3,232,380 | 3,232,381 | how select contact detail with widget | <p>i need to select and give detail of contact with this but i don't know how can get detail back (how find result of intent)</p>
<pre><code>public class MainActivity extends AppWidgetProvider {
Context context;
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
super.onUpdate(context, appWidgetManager, appWidgetIds);
this.context = context;
for (int i = 0; i < appWidgetIds.length; i++) {
int appWidgetId = appWidgetIds[i];
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE);
PendingIntent pending = PendingIntent.getActivity(context, 0, intent, 1);
RemoteViews views = new RemoteViews(context.getPackageName(),
R.layout.activity_main);
views.setOnClickPendingIntent(R.id.imageButton1, pending);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
</code></pre>
| android | [4] |
1,531,571 | 1,531,572 | PHP isset function | <p>I believe I am a bit confused with the <code>isset</code> function in PHP. I'm trying to use this function to determine is a field in a form is <code>null</code>... I was under the impressions that the <code>isset</code> function checks to see if a field has a value in it... but I believe the <code>isset</code> function only determines if the thing passed to it exists.</p>
<p>For example.</p>
<p>If I have a form input field with the name attribute set to "day". I would use <code>isset($_GET['day']);</code> to determine if the form input field is not <code>null</code>? Or does <code>isset</code> just check to see if the 'day' exists and doesn't check that value that it passes?</p>
<p>Any help would be great!
Thanks!</p>
| php | [2] |
3,453,893 | 3,453,894 | Delimiter causing w3c validation error | <p>I want my home clear of all W3C errors. I have one final error:</p>
<p><a href="http://validator.w3.org/check?uri=http://storeboard.com" rel="nofollow">http://validator.w3.org/check?uri=http://storeboard.com</a></p>
<p>Here is the code for that error:</p>
<pre><code> if (ErrorFound == 0)
{
if (document.frmRegister.tbPassword.value.length < 8)
{
alert("Password must be at least 8 characters in length.");
document.frmRegister.tbPassword.focus();
ErrorFound = ErrorFound + 1
}
}
</code></pre>
<p>Any ideas how I can keep the same functionality but prevent the W3C Error?</p>
<p>Many Thanks,</p>
<p>Paul</p>
| javascript | [3] |
4,747,727 | 4,747,728 | Auto Complete with locations like the one from Google Maps | <p>I im building a home project and i want to create a auto complete text view used to suggest addresses.To make the story short i world want it to be just like the one in google maps.I am familiar with java and webservices but i realy dont know where to start.</p>
<p>Thank you.</p>
| android | [4] |
4,546,204 | 4,546,205 | Overhead: method call vs. object creation | <p>As far as I understand the JVM, it should generally be cheaper to invoke a method (i.e. allocate a new stack frame, etc), than to create a new object. </p>
<p>However, can we estimate just how big the difference in overhead between the two generally is, assuming that both the method and the object declare the same number of local/instance variables of the same type, and instantiate them to the same values?</p>
| java | [1] |
1,294,496 | 1,294,497 | Jquery checkbox issue | <p>I have a checkbox in a page and on page load it is unchecked. When the checkbox is being checked, the value TRUE is being passed correctly, though when the checkbox is remained unchecked on load of the page, the value FALSE is not being passed. I am using the following code to do this.</p>
<pre><code>$(document).ready(function () {
$('#MemberCountryOptInchkbox').change(function(){
if($(this).attr('checked')){
$(this).val('TRUE');
}else{
$(this).val('FALSE');
}
});
</code></pre>
| jquery | [5] |
279,429 | 279,430 | Conditional operator | <p>What is wrong in this code<br><code>if(getResponseDataMap().containsKey("A"){
a.setText(getResponseDataMap().get("A").toString);
}</code></p>
<p>Converted like this .</p>
<p><code>getResponseDataMap().containsKey("A")?a.setText(getResponseDataMap().get("A").toString()):""</code></p>
<p>where getLocalRequestDataMap is a HashMap . And setText is function of android</p>
<p>It give compile time error <br>
Multiple markers at this line<br>
- Type mismatch: cannot convert from String to
boolean<br>
- Syntax error, insert ")" to complete Expression<br>
- Syntax error on token ")", delete this token<br></p>
| java | [1] |
939,866 | 939,867 | Compiling in Debug Mode versus Release Mode | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/90871/debug-vs-release-in-net">Debug VS Release in .net</a> </p>
</blockquote>
<p>We send out releases almost weekly due to changes and bug fixes in our software.</p>
<p>Granted, that is problem not he best practice but I have a question about the builds.</p>
<p>Most of the builds are being left as Debug when built and then to the client.</p>
<p>What repercussions is/will this cause? Will the program act differently if it is sent in debug mode?</p>
<p>I know there should be proper procedures for sending out releases but our company doesn't work in that reality. I'm trying to set up proper procedures for our customers getting releases so that less bugs go out to them.</p>
<p>Anyhow, any input, theories, or links would be appreciate.</p>
| c# | [0] |
5,842,886 | 5,842,887 | Parameter $now in php function strtotime() | <p>I'm trying to understand what $now parameter is doing in php function </p>
<blockquote>
<p>strtotime(string $time [, int $now = time() ])</p>
</blockquote>
<p>Everybody seems to simply ignore the $now parameter and the documentation for it is not very clear.</p>
<p>How does that parameter really affect the returned value?</p>
| php | [2] |
3,936,883 | 3,936,884 | How to install Python with Wampserver | <p>I want install Python with Wamp or Appserv on windows, how to install ? can it run together ?</p>
| python | [7] |
1,694,264 | 1,694,265 | jquery list confusion | <p>I'm a new to the jQuery world and I'm having a problem that I just can't solve. I have an unordered list with multiple li's. I'm trying to make it so when the user clicks a row, the bg color on the row changes. And when another row is click, that row's bg color changes and the previous on goes back to the default color. This is my code so far:</p>
<pre><code>$('.allVideos ul li').hover(function(){
$(this).css('background','#c7f1f2');
}, function(){
$(":not($(this))").css('background','');
});
</code></pre>
<p>Unfortunately it isn't working as planned. Can anyone explain to me what I am doing wrong?</p>
<p>Thanks</p>
| jquery | [5] |
5,272,412 | 5,272,413 | how to get string from a line of strings? | <p>I have following string:</p>
<pre><code>"hw_core_detectionhook::Iocard const*"
</code></pre>
<p>I have to get only first part, i.e all text present before space, i.e I need the <code>"hw_core_detectionhook::Iocard"</code> part only.</p>
| c++ | [6] |
1,964,151 | 1,964,152 | how to find direction of device movement? | <p>I am implementing one iphone application in which i want to find direction of device on movement.I dont know how to find.Can u help me for this query.Thnks in advance.</p>
| iphone | [8] |
4,077,272 | 4,077,273 | iPhone app size limit | <p>In AppStore Review Guidelines, the following point is given</p>
<p>Apps larger than 20MB in size will not download over cellular networks (this is automatically prohibited by the App Store)</p>
<p>Please clarify me is it .app file size or whole application file size </p>
| iphone | [8] |
1,264,625 | 1,264,626 | time.sleep and suspend (ie. standby and hibernate) | <p>For example, if I do time.sleep(100) and immediately hibernate my computer for 99 seconds, will the next statement be executed in 1 second or 100 seconds after waking up?</p>
<p>If the answer is 1 second, how do you "sleep" 100 seconds, regardless of the length of hibernate/standby?</p>
| python | [7] |
1,723,231 | 1,723,232 | writing into ABAQUS odb file | <p>I have generated a python script that writes data into the odb file by creating a new step. the code works well for the first time but when I try to run it again Abaqus shows a kind of error message that the step name already exists. Does anyone know how to solve this or I will change the step name everytime in the python code?</p>
<p>thanks</p>
| python | [7] |
3,461,591 | 3,461,592 | Why it is showing different output? | <pre><code>x=4
def func():
print("HELLO WORLD")
y=x+2
x=2
print (y)
print (x) # OUTPUT IS 6,2,2
global x # global declaration is done here
func()
print (x) # outputs as 2 but why???? why not 4????
</code></pre>
<p>Why it shows the output as 6,2,2. Indeed i made the print (x) before the global declaration.But i didnt change x value after global declaration but why its printing the x value as 2 after the func().Is it not a sequential execution of statements? or does it read the entire code in the function and then start executing the function line on line? please clear the above program.Thank you in advance</p>
| python | [7] |
5,253,056 | 5,253,057 | Base 64 fwrite using php | <p>I want to use fwrite to post $username in base64 encoded
Here is my current source </p>
<pre><code>$fp = fopen("id.txt", "a");
fwrite($fp, " $username\r\n");
fclose($fp);
</code></pre>
| php | [2] |
1,191,145 | 1,191,146 | How do I enumerate() over a list of tuples in Python? | <p>I've got some code like this:</p>
<pre><code>letters = [('a', 'A'), ('b', 'B')]
i = 0
for (lowercase, uppercase) in letters:
print "Letter #%d is %s/%s" % (i, lowercase, uppercase)
i += 1
</code></pre>
<p>I've been told that there's an enumerate() function that can take care of the "i" variable for me:</p>
<pre><code>for i, l in enumerate(['a', 'b', 'c']):
print "%d: %s" % (i, l)
</code></pre>
<p>However, I can't figure out how to combine the two: How do I use enumerate when the list in question is made of tuples? Do i have to do this?</p>
<pre><code>letters = [('a', 'A'), ('b', 'B')]
for i, tuple in enumerate(letters):
(lowercase, uppercase) = tuple
print "Letter #%d is %s/%s" % (i, lowercase, uppercase)
</code></pre>
<p>Or is there a more elegant way?</p>
| python | [7] |
1,234,799 | 1,234,800 | no Error Messages in imported python classes | <p>i have a couple of python classes, which i import and use in my main program. </p>
<pre><code>## path to classes
sys.path.append(basePath + "classes")
## import some classes
import mainmod
mainModHandler = mainmod.Mainmod()
</code></pre>
<p>I have no problem, working with them, but i wonder, if i have a error in my imported class, i do not get an error message from Python, that only works in my main.py</p>
<p>For example:</p>
<pre><code>class Mainmod(object):
'''
this class provides some helper methods
'''
def __init__(self, *args):
provokeAnError{} # should provoke an error message?
</code></pre>
<p>My python prgramm (linux commandline) does finish but not with an error message. It just stays silent. I of course use try, excepts mostly, but sometimes little errors are unavoidable.</p>
<p>Where or how can i tell python, to give me an error message in my imported classes?</p>
<p>thanks for any help!
Maurice</p>
| python | [7] |
4,294,498 | 4,294,499 | Creating a Temp Dir in Java | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/617414/create-a-temporary-directory-in-java">Create a temporary directory in Java</a> </p>
</blockquote>
<p>I have a test for a create DB method and I need a temp directory to put it in. The directory will be removed after the test is done. I tried using <code>File.createTempFile()</code>, like so:</p>
<pre><code>tempDir = File.createTempFile("install", "dir");
tempDir.mkdir();
</code></pre>
<p>But <code>tempDir</code> is already exists as a file. How do I create a temp directory as opposed to a file?</p>
| java | [1] |
486,807 | 486,808 | Android Browser output download time | <p>I'm looking for a way to output the total download time every time a new page is opened in the Android browser.</p>
<p>I've looked around, but can't find a place to put a timestamp for downloading a web page. There's a performance monitor in onPageStarted and onPageFinished measuring the page loading time, but nothing (that I can see) that measures the download time.</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.