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 |
|---|---|---|---|---|---|
1,881,431 | 1,881,432 | Android NotePad Tutorial 1 : Crash when I click on "Menu" | <p>I am a beginner with Android, and I have a strange bug with the <code>NotePad Tutorial</code> (Exercice 1).
<a href="http://developer.android.com/resources/tutorials/notepad/index.html" rel="nofollow">http://developer.android.com/resources/tutorials/notepad/index.html</a></p>
<p>I imported the sources and completed the code, but when I run the app, and click on the "Menu" button, it crashes (The application .... has stopped unexpectedly. Please try again.)</p>
<p>Then, I imported the solution, and it works normally.</p>
<p>I copied the whole code, resources, manifest from the solution to the first Project ... and still, everything is good with the first project, but when I click "Menu", I have the same crash.</p>
<p>Can someone explain where am I making a mistake?</p>
<p>After some researches, I opened the LogCat.
Here are the lines that seems interesting :</p>
<pre><code>Displayed activity com.android.demo.notepad1/.Notepadv1: 1261 ms (total 1261 ms)
No keyboard for id 0
Using default keymap: /system/usr/keychars/qwerty.kcm.bin
getEntry failing because entryIndex 2 is beyond type entryCount 2
Failure getting entry for 0x7f040002 (t=3 e=2) in package 0: 0x80000001
Shutting down VM
threadid=3: thread exiting with uncaught exception (group=0x4001b188)
Uncaught handler: thread main exiting due to uncaught exception
android.content.res.Resources$NotFoundException: String resource ID #0x7f040002
</code></pre>
<p>I noted that <code>0x7f040002</code> refers to the <code>"menu_insert"</code> string in <code>R.java</code></p>
| android | [4] |
2,789,824 | 2,789,825 | Android: Communication Activity / Service | <p>I have some questions concerning the communication between an Activity and a Service.
I'd like to write a speedmeter application, where the UI is constantly updated with new data derived from the GPS sensor.</p>
<p>So far, I have an LocationListener running in a service. What is the best practice in Android:</p>
<p>1) Access the service from an Activity, let's say every second and update the UI. Or,<br>
2) Let the service update the UI.</p>
<p>Could you provide some helpful links for case 2), please?. </p>
<p>Case 1) shouldn't be a problem with a LocalService and an IBinder interface, right?</p>
<p>Thanks!</p>
| android | [4] |
2,674,838 | 2,674,839 | Attaching an interpretor for Java | <p>I plan to do some independent applications in Java for some very restrictive systems in terms of hardware. It is possible to write and compile Java code to add a small interpreter that they behave like made executable Python program?</p>
| java | [1] |
4,734,630 | 4,734,631 | Uncaught SyntaxError: Unexpected token | <p>I have code like this: </p>
<pre><code>$(function(){
$('.plus').click(function(){
var url = "/accounts/profile/update_thing/" + $(this).parent().attr('id') + "/",
$.getJSON(url, function(data){
var items = []
$.each(data, function(key, val) {
items.push('<li id="' + key + '">' + val + '</li>');
});
$('<ul/>', {
'class': 'my-new-list',
html: items.join('')
}).appendTo('body');
}); })
})
</code></pre>
<p>And Chrome code spectrator saying that i have Uncaught SyntaxError: Unexpected token . in line 4. But I don't know why. Does someone knows what is about?</p>
<p>Ps. Is it normal that I haven't text editor on this site?</p>
| jquery | [5] |
295,598 | 295,599 | jQuery .done after AJAX callback | <p>I'm trying to run some stuff after an AJAX call is completed:</p>
<pre><code>$.ajax({
url: url,
success: //do stuff
}).done(function (){
$('#listings').fadeIn(800).done(function(){
$('#loading').fadeOut(800);
});
});
</code></pre>
<p>This doesn't do the last part which is <code>$('#loading').fadeOut(800);</code>, which should start when <code>$('#listings').fadeIn(800)</code> is done.</p>
| jquery | [5] |
4,731,179 | 4,731,180 | How to thow and catch and timeout exception | <p>I tried to catch() timeout exception, after waited for some time to see one webelement.
But java says timeout exception is never throwable.</p>
<p>The below method waits for any webelement for some (given) time.
Even after the time has elapsed, and could not see the web element, the Catch block will be executed.``</p>
<p>I want to know exactly whether this method fails due to ONLY timedout exception. So, I tried to catch it using:</p>
<pre><code>Catch(TimeoutException te).
</code></pre>
<p>But Java says, this exception is not throwable.</p>
<pre><code>public boolean waitForElement(final String id, String[] resultsValues)
throws Exception {
boolean returnValue = false;
try {
returnValue = new WebDriverWait......
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
</code></pre>
| java | [1] |
2,604,565 | 2,604,566 | Redundant code in exception handling | <p>I've a recurrent problem, I don't find an elegant solution to avoid the resource cleaning code duplication:</p>
<pre><code>resource allocation:
try {
f()
} catch (...) {
resource cleaning code;
throw;
}
resource cleaning code;
return rc;
</code></pre>
<p>So, I know I can do a temporary class with cleaning up destructor, but I don't really like it because it breaks the code flow and I need to give the class the reference to the all stack vars to cleanup, the same problem with a function, and I don't figure out how does not exists an elegant solution to this recurring problem.</p>
| c++ | [6] |
4,912,111 | 4,912,112 | What does it mean the prefix "global::" that intellisense is showing me | <p>In my solution I have a project for the business layer and another one to handle integration; in this last one I have a class to make some service methods invocation. </p>
<p>The Business layer references integration project. There, in the business layer, I have the followig method and when I try to create an instance of the Proxy class, intellisense shows me a lot of "global::". I thinks this global:: makes no diference but <strong>I want to know why the intellisense is showing me that.</strong></p>
<pre><code>public void ActualizarOrdenesDeCompraDesdeElWS()
{
Integracion.ProxyAudifarma proxy = new global::GOA.Integracion.ProxyAudifarma();
}
</code></pre>
<p>I guess this is a trivial C# foundation I'm missing, thanks for your answers.</p>
<p><em><strong>--Post solution edit:</em></strong></p>
<p>The calling was:</p>
<pre><code>namespace GOA.Negocio
{
public class GOA
{
public int ActualizarOrdenesDeCompraDesdeElWS()
{
Integracion.ProxyAudifarma proxy = new global::GOA.Integracion.ProxyAudifarma();
</code></pre>
<p>Class GOA being named as the root namespace was introducing an ambiguity risk. Changing the class name to AplicacionGOA solved my problem and now intellisense don't set the "global::" empty namespace prefix.</p>
| c# | [0] |
4,822,915 | 4,822,916 | How to go from mktime to datetime object? | <p>I have an mktime that I want to have return a datetime object. The best way I came up with seems way too convoluted:</p>
<pre><code>DateTime::createFromFormat("Y-m-d H:i:s",date("Y-m-d H:i:s",mktime(0, 0, 0, $data[$j]['month'], $data[$j]['day'],$data[$j]['year'])));
</code></pre>
<p>any better ways?</p>
| php | [2] |
3,979,081 | 3,979,082 | What is the C# equivalent of Java unsigned right shift operator >>> | <p>I am trying to convert some Java code to C#. How can the following <a href="http://download.oracle.com/javase/tutorial/java/nutsandbolts/op3.html" rel="nofollow">unsigned right shift operation</a> be represented in C#?</p>
<pre><code>int src1, src2, ans;
ans = src1 >>> src2;
</code></pre>
| c# | [0] |
5,254,627 | 5,254,628 | PHP check if a string contains only 0-9 and a few other chars | <p>I want to create a function where you check if a string contains only 0-9 /+*-{} (space) chars. This is similar to google's calculator query check.</p>
<pre><code>function is_calculation($str) {
if (???) {return true;}
return false;
}
</code></pre>
<p>it needs to be something like /[0-9 *-/+ [] {} () ]/</p>
| php | [2] |
5,974,752 | 5,974,753 | How to read a php POST variable in Java | <p>Is it possible read a POST variable set on a server in this way:</p>
<pre class="lang-php prettyprint-override"><code><?php
$_POST['Val'] = 'Ret_value';
?>
</code></pre>
<p>I need to do this with a Java client</p>
| java | [1] |
4,895,560 | 4,895,561 | How to hide post date in tigra calendar? | <p>I am using tigra calender to select the date. I want to know How can I hide or block post date in tigra calendar.</p>
<p>Please help me on this.</p>
| javascript | [3] |
1,972,317 | 1,972,318 | Loading file to string, no such file? | <p>I'm working on a python script to thoroughly mutilate images, and to do so, I'm replacing every "g" in the file's text with an "h" (for now, it will likely change). Here's the beginning, and it's not working:</p>
<pre><code>pathToFile = raw_input('File to corrupt (drag the file here): ')
x = open(pathToFile, 'r')
print x
</code></pre>
<p>After giving the path (dragging file into the terminal), this is the result:</p>
<pre><code>File to corrupt (drag the file here): /Users/me/Desktop/file.jpeg
Traceback (most recent call last):
File "/Users/me/Desktop/corrupt.py", line 7, in <module>
x = open(pathToFile, 'r')
IOError: [Errno 2] No such file or directory: '/Users/me/Desktop/file.jpeg '
</code></pre>
<p>How can the file not exist if it's right there, and I'm using the <em>exact</em> filename?</p>
| python | [7] |
299,859 | 299,860 | How to put variables into calling scope in PHP? | <p>The built-in PHP function parse_str( $str ) parses a query string and sets the variables from it into the current scope. Is there any way for me to create my own function that does something like this and returns values to the scope of the caller?</p>
<p>Example:</p>
<pre><code>function checkset()
{
global $inputs;
for( $counter = 0, $varname = func_get_arg($counter), $counter++)
{
if(isset($inputs[$varname]))
{
calling_scope( $varname, $inputs[$varname] );
}
}
return;
}
</code></pre>
<p>where calling_scope( $varname, $value) would be a function that sets $$varname in the scope where the function is called to $value. Any help is appreciated.</p>
| php | [2] |
6,030,174 | 6,030,175 | android howto create an (incoming phone call) but not for talking | <p>hi again
search around but cant find a way to start developing this
Wanted to send an image to my phone (ftp) and when the image has
arrived and saved to my CD card i would like to have the phone ringing like
it was someone calling. When i answer the image will fill the screen.</p>
<p>What i have done so fare is is that the image is received and saved to CD card.
Only the Phone call thing missing
If you can give me a hint about what I need to do im happy
I know I can start a phone call activity with this code</p>
<pre><code> Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
</code></pre>
<p>Maybe it can be modified to create a dummy call?</p>
| android | [4] |
268,884 | 268,885 | error in running recursion | <p>if running function returns server misconfiguration error</p>
<pre><code> function build_path($cid)
{
$result = array();
$DB = new MySQLTable;
$DB->TblName = 'shop_categories';
$where['cat_id']['='] = $DB->CleanQuest($cid);
$res = $DB->Select('cat_id,cat_name,cat_parent', $where);
if($res !== 'false')
{
$pid = mysql_fetch_array($res);
if($pid['cat_parent'] !== 0)
{
Echo $pid['cat_parent'];
build_path($pid['cat_parent']);
} else {
Echo $pid['cat_id'];
return true;
}
}
return false;
}
</code></pre>
<p>I can't find an error here. Please help.</p>
<p>Sorry for disturbing you all. The trouble was in comparison 'if($pid['cat_parent'] !== 0)': $pid['cat_parent'] was a string with int(0)</p>
<p>Can i build this function to store full path without using GLOBALS and SESSION vars?</p>
| php | [2] |
4,210,999 | 4,211,000 | Can i Split my php codes? | <p>I have a php file with 1000+ lines of code.I am planning to split it using include_once() function (index.php into header.php,side.php etc.. ).It increases readability and make simpler to edit.Will it lead to increase interpreting time or similar issues ?</p>
| php | [2] |
4,675,929 | 4,675,930 | how to change the attribute of a .html file just loaded using jquery | <p></p>
<pre><code><html >
<head>
<title>main files</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<div id="kk">
</div>
<script>
$("#kk").load("template.html");
var new_id="234";
$(#tkk).attr({
id : this.id + '_' + new_id,
name: this.name + '_' + new_id
});
</script>
</body>
</html>
</code></pre>
<p><------------------------------------------------------------------></p>
<p>template.html</p>
<pre><code><h2>Greetings</h2>
<div id="tkk" class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
</div>
</code></pre>
<p>here i want to change the id of tkk after being loaded in main.html file ,but its not working</p>
| jquery | [5] |
3,147,628 | 3,147,629 | Elegant way to add metainformation to char array | <p>I wanna pack some information plus some metadata in a byte array. In the following
I have 3 bytes of information which have a certain offset plus 4 bytes of metadata added
at the beginning of the packet in the end. Solution 1 I came up is pretty obvious to do
that but requires a second tmp variable which I do not really like.</p>
<pre><code>int size = 3;
int metadata = 4;
unsigned char * test = new unsigned char[size];
unsigned char * testComplete = new unsigned char[size+metadata];
test[offest1] = 'a';
test[offest2] = 'b';
test[offest3] = 'c';
set_first_4bytes(testComplete, val );
memcpy(&testComplete[metadata], test, size);
</code></pre>
<p>Another straightforward solution would be to do it the following way:</p>
<pre><code>unsigned char * testComplete = new unsigned char[size+metadata];
testComplete[offest1+metadata] = 'a';
testComplete[offest2+metadata] = 'b';
testComplete[offest3+metadata] = 'c';
set_first_4bytes(testComplete, val );
</code></pre>
<p>However, I don not like here the fact that each time I have the metadata offset to add so that I get the right index in my final packet. Is there another elegant solution which DOES not have the drawbacks of my approaches?</p>
<p>Thanks!</p>
| c++ | [6] |
2,072,081 | 2,072,082 | how to access UI elements in parent activity from fragment | <p>parent activity layout</p>
<pre><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LockerCodeActivity" >
<LinearLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:id="@+id/ctrlActivityIndicator"
android:indeterminateOnly="true"
android:keepScreenOn="false"
/>
<TextView
android:id="@+id/tv_results"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="" />
</RelativeLayout>
</code></pre>
<p>Inflate the fragment in the parent activity onCreate function</p>
<pre><code>FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
Fragment scannerFragment = new ScanFragment();
fragmentTransaction.add(R.id.fragment_container, scannerFragment);
fragmentTransaction.commit();
</code></pre>
<p>Working great so far... now how do I hide the progressbar?
This is what I've tried</p>
<pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_scan, container, false);
ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.ctrlActivityIndicator);
progressBar.setVisibility(View.INVISIBLE);
return view;
}
</code></pre>
<p>I get a null pointer exception</p>
| android | [4] |
4,542,731 | 4,542,732 | How to implement our own delegate methods - objective c | <p>evert one.</p>
<p>I have to share my data from one class to another class,by implementing our own delegate methods , can any one send me s sample code for implementing.</p>
| iphone | [8] |
1,170,000 | 1,170,001 | How to convert NSDate to german Date? | <p>I have implemented one iphone application in which I want to convert NSDate to NSString but in german format.</p>
<p>Can you give me some idea about that.</p>
<p>I am using below code.</p>
<p>NSDate *date = [NSDate dateWithTimeIntervalSince1970:[[eventInfo valueForKey:@"startdat"] intValue]];</p>
<p>//2011-05-01 21:04:00 +0000(I am geeting this date)</p>
<pre><code> NSDateFormatter *formatter1 = [[NSDateFormatter alloc] init];
NSLocale *nl_NL = [[NSLocale alloc] initWithLocaleIdentifier:@"de_DE"];
[formatter1 setDateFormat:@"E,dd MMM yyyy"];
[formatter1 setLocale:nl_NL];
NSString *stringFromDate1 = [formatter1 stringFromDate:date];
[formatter1 release];
[nl_NL release];
</code></pre>
<p>//I am getting stringFromDate1 = "Mo.,02 Mai 2011" value.(wrong output)</p>
<p>Please give me idea</p>
| iphone | [8] |
3,562,655 | 3,562,656 | How to check whether the input text field contains only white spaces? | <p>What is the easiest way to check in Javascript whether the input text field is empty (contains nothing or white spaces only)?</p>
| javascript | [3] |
396,001 | 396,002 | split objects in a list separated by ',' in python | <p>I have a list of elements. for each element I want to split into 3 numbers separated by ',' and print them.</p>
<p>My code is not doing what I want. :S </p>
<pre><code>l = ['14,23,63\n','41,20,76\n','65,23,42\n']
for element in l:
element.split(',')
print element[0],element[1],element[2] #outcome should be e.g. 14,23,63
</code></pre>
| python | [7] |
2,220,548 | 2,220,549 | how to use mailing system in C# | <p>i want to have an email system , when user done an action after that someone recieve an email in C#
so now how I can do that ??</p>
| c# | [0] |
3,036,541 | 3,036,542 | android main layout and categories howto | <p>in main layout i would like to use something like </p>
<pre><code><PreferenceCategory
android:summary="@string/menu_language_settings"
android:title="@string/menu_language_settings" >
</code></pre>
<p>but here i only have</p>
<pre><code><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingTop="50dp" >
</code></pre>
<p>how can i use Categories in main layout? Is this even possible in main layout?</p>
| android | [4] |
5,361,443 | 5,361,444 | Necessity of getter methods | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1568091/why-use-getters-and-setters">Why use getters and setters?</a> </p>
</blockquote>
<p>This is a newbie question. Is it very much necessary to use getmethods to access property values? Once the value has been assigned, one can get the values directory. For example, in the below code, <code>displayName()</code> can display firstName value without the help of any getter method. Or it is a standard coding standards that one must have getter and setter method or any other methods which gives that value?</p>
<pre><code>class Test{
private String firstName;
public void setName(String fname){
firstName = fname;
}
public void displayName() {
System.out.println("Your name is " + firstName);
}
}
</code></pre>
| java | [1] |
4,488,053 | 4,488,054 | Substring in Java | <p>I have a string in format <code>/remove_this/I_want_this_onward/any_number_of_characters</code>.<br>
I want to remove <code>/remove_this</code> and want to get remaining string i.e. <code>/I_want_this_onward/any_number_of_characters</code>.<br>
Ex. Input String <code>/myApp/home/welcome</code> , I want to extract <code>/home/welcome</code>.<br>
What will be the the easiest way in Java to get it done ?</p>
<p><strong>EDIT:</strong> (extracted from comments)</p>
<p>I want it to extract <code>/home/welcome</code> from <code>redirect:/myapp/home/welcome</code>.</p>
| java | [1] |
1,113,978 | 1,113,979 | How to stop get errors by typing ' mark | <p>I have a dictionary page. when I search something the link showing as <code>index.php?word=(search word here)</code> but when I add ' mark to this link like <code>index.php?word=**name'**</code></p>
<p>then showing this error Warning: </p>
<pre><code>mysql_fetch_array(): supplied argument is not a valid MySQL result resource in...
</code></pre>
<p>how to stop this. and bypass ' mark</p>
| php | [2] |
1,356,782 | 1,356,783 | to move listview data to edit text, | <p>i cant get clearview in this...
i need reuse the listview datas for some purpose, i wish to how to move the listview data to a edittext.. kindly assist with sample code..</p>
| android | [4] |
3,772,361 | 3,772,362 | Please find mistake in my selector code | <p>I am trying to hide an array of elements but facing problem while writing selectors for Dynamic elements,Please someone help me </p>
<pre><code> for(var i=0;i<Codes.length;i++)
{
FinQid="";
FinQid=QID+"_"+Codes[i];
$("'input[id^='"+FinQid+"']").hide();
}
</code></pre>
| jquery | [5] |
1,235,606 | 1,235,607 | Inserting an element in a std::vector before element of certain value | <p>Can you suggest a nicer way of inserting a value before another value in an std::vector:</p>
<pre><code>template<class T>
void insert(std::vector<T>& container, const T& valueToInsertBefore, const T& valueToInsert)
{
std::vector<T>::iterator i = container.begin();
std::vector<T>::iterator end = container.end();
for(;i!=end;++i)
{
if(*i==valueToInsertBefore)
{
i = container.insert(i, valueToInsert);
i++;
end = container.end();
}
}
}
</code></pre>
<p><strong>UPDATE:</strong></p>
<p>Should insert for each instance of valueToInsertBefore found in the std::vector.</p>
| c++ | [6] |
4,712,679 | 4,712,680 | Replace HTML tag with a new tag | <p>How can I replace the <code>html</code> tag with a new tag using jQuery?</p>
<p>I have many <code>table</code> tags and I want to replace a specific table containing a class. All of its' child nodes should be replaced too.</p>
<pre><code><table class='replace_this'>
<tr>
<td>
All table, tr, and td tag are replaced with div tag
</td>
</tr>
</table>
</code></pre>
<p>Should be changed to:</p>
<pre><code><div class='replace_this'>
<div>
<div>
All table, tr, and td tag are replaced with div tag
</div>
</div>
</div>
</code></pre>
| jquery | [5] |
5,988,381 | 5,988,382 | what's the more elegant way to use an id already set? jQuery("#"+ t)? | <p>i'm kinda of a newbie in javascript, even though i built so far lots of working website and apps..</p>
<p>btu i feel naive the way i used to pass the variable id to jquery..
for instance i used to do like this epsecialy when i have to work with some old code
..
let's assume that i have all my website already coded with 'a' tags like this</p>
<pre><code><a id='myId' onclick='doSome(this.id)' > link </a>
</code></pre>
<p>and then in JS</p>
<pre><code>function doSome(id){
//old code removed and replaced by jquery
jQuery("#"+ id).show();
}
</code></pre>
<p>and the function in that way works flawless...</p>
<p>so, again, assuming that i cannot change anything else than the code inside the function what's the best way to use the variable id?
because as far as i know if I had used just</p>
<pre><code>jQuery(id).show();
</code></pre>
<p>instead of</p>
<pre><code>jQuery("#"+ id).show();
</code></pre>
<p>it wouldn't have worked...right?</p>
| jquery | [5] |
745,151 | 745,152 | Which of the following tasks dont always spent a consistent amount of time? | <p>I am trying to make the loading part of a C# program faster. Currently it takes like 15 seconds to load up.
On first glimpse, things that are done during the loading part includes constructing many 3rd Party UI components, loading layout files, xmls, DLLs, resources files, reflections, waiting for WndProc... etc.</p>
<p>I used something really simple to see the time some part takes,
i.e. breakpointing at a double which holds the total milliseconds of a TimeSpan which is the difference of a DateTime.Now at the start and a DateTime.Now at the end.
Trying that a few times will give me sth like,
11s 13s 12s 12s 7s 11s 12s 11s 7s 13s 7s.. (Usually 12s, but 7s sometimes)</p>
<p>If I add SuspendLayout, BeginUpdate like hell; call things in reflections once instead of many times; reduce some redundant redundant computation redundancy. The time are like 3s 4s 3s 4s 3s 10s 4s 4s 3s 4s 10s 3s 10s.... (Usually 4s, but 10s sometimes)</p>
<p>In both cases, the times are not consistent but more like, a bimodal distribution? It really made me unsure whether my correction of the code is really making it faster.
So I would like to know what will cause such result.
Debug mode?
The "C# hve to compile/interpret the code on the 1st time it runs, but the following times will be faster" thing?
The waiting of WndProc message?
The reflections? PropertyInfo? Reflection.Assembly?
Loading files? XML? DLL? resource file?
UI Layouts?
(There are surely no internet/network/database access in that part)</p>
<p>Thanks.</p>
| c# | [0] |
5,207,846 | 5,207,847 | Get date by position (ie. third Wednesday of January)? | <p>Can I get the third Wednesday in php with strtotime ("wed year-month +2 Weeks") or do I need a complex code like here: <a href="http://www.danielkassner.com/2010/05/22/get-date-by-position-ie-third-wednesday-of-january" rel="nofollow">http://www.danielkassner.com/2010/05/22/get-date-by-position-ie-third-wednesday-of-january</a>?</p>
| php | [2] |
883,823 | 883,824 | Python fetching webpage data | <p>I'm trying to create a program that fetches the html from the tv catchup website, then uses the split function to split up all the html data into just the channel name and the program that is currently on in a table, such as: BBC 1 - 'program name'. I just need help on what i do after my first split function if anyone can help that would be greatly appreciated. </p>
<pre><code>import urllib2
import string
proxy = urllib2.ProxyHandler({"http" : "http://c99.cache.e2bn.org:8084"})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
tvCatchup = urllib2.urlopen('http://www.TVcatchup.com')
html = tvCatchup.read()
firstSplit = html.split('<a class="enabled" href="/watch.html?c=')[1:]
for i in firstSplit:
print i
secondSplit = html.split ('1" title="BBC One"></a></li><li class="v-type" style="color:#6d6d6d;">')[1:]
for i in secondSplit:
print i
</code></pre>
| python | [7] |
1,419,800 | 1,419,801 | how to convert ctime to datetime | <pre><code>import time
t = time.ctime()
</code></pre>
<p>In my computer t is 'Sat Apr 21 11:58:02 2012'.</p>
<p>My question is: how to convert t to datetime in python?Is there any modules to to it?
I try to make a time dict and then covert t, but i didn't think it's a correct way in python. </p>
<p>May be i can desc my question clearly: I have a ctime list, such ['Sat Apr 21 11:56:48 2012', 'Sat Apr 21 11:56:48 2012'], i wan't to convert then to datetime and then store in db with timestamp</p>
| python | [7] |
5,957,055 | 5,957,056 | Forcing activity to run an activity in landscape in android 1.5 | <p>I have an application which is in portrait mode. However, I want to run a particular activity in landscape mode. I have tried the following with no success.</p>
<pre><code>1. android:screenOrientation="landscape" in AndroidManifest.xml
2. this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); in activity requiring landscape mode
</code></pre>
<p>as specified <a href="http://stackoverflow.com/questions/2150287/force-an-android-activity-to-always-use-landscape-mode">here</a>. Please help.
Thanks</p>
| android | [4] |
645,088 | 645,089 | How do I call a custom class in the cakephp framework | <p>I am new to cakePHP,</p>
<p>I have write a class in MODEL with name of myClass() and I have one function like func().</p>
<p><strong>CODE:</strong></p>
<pre><code>class myClass(){
function func(){
echo "test";
}
}
</code></pre>
<p>But I don't know how to call the "myClass class" and run the function func() in the controller file in the cakePHP framework. </p>
<p>Can any one help me.</p>
<p>Thanks...</p>
| php | [2] |
4,445,583 | 4,445,584 | Javascript Notification Pop-up? | <p>Looking for the best approach to perform a javascript notification pop-up if amount in field A is edited to a smaller amount that what is found in field B?</p>
<p>We aren't using any js frameworks but that option isn't ruled out.</p>
<p>Thanks.</p>
| javascript | [3] |
506,054 | 506,055 | Where did SBSetAirplaneModeEnabled function go in iOS 3.0+ | <p>Does anyone know how to enable/disable airplane mode in iPhone SDKs after 2.x?</p>
<p>I need to create an app that legitimately disables the radio for the duration of its execution. Is Apple likely to permit this soon.</p>
<p>I followed <a href="http://blogs.oreilly.com/iphone/2009/01/bring-airplane-mode-control-ba.html" rel="nofollow">http://blogs.oreilly.com/iphone/2009/01/bring-airplane-mode-control-ba.html</a></p>
<p>but setAPMode pointer is null.</p>
<p>Regards,</p>
<p>Steve</p>
| iphone | [8] |
2,252,098 | 2,252,099 | Filter out objects in ArrayList | <p>I have an ArrayList of Foo objects. Foo's properties are String name and int age.
I don't want more than one of the same name, so when the same name, keep only the greatest age.
I'm looking an idea to get me going in Java.</p>
| java | [1] |
274,249 | 274,250 | User Based Exception program not working | <p>This code does not work. Please tell what the error is....</p>
<pre><code>class Error(Exception):
def __init__(self,mssg):
self.mssg = mssg
class InputError(Error):
def __init__(self,val):
super("Input Error")
print val
</code></pre>
<p>Now I write in other part of my program</p>
<pre><code>a = raw_input("Enter a number from 0-9: ")
if (ord(a)>47 and ord(a)<58):
pass
else:
raise InputError(a)
</code></pre>
<p>Now when I pass 'a' I get <code>super expected a type but got a string</code> I just want to pass that message to the base class and display it along with the wrong value.</p>
<p>What am I doing wrong here</p>
| python | [7] |
3,450,644 | 3,450,645 | Python - Get class of type from imported module | <p>I am trying to import a class from a file with a dynamic name. Here is my file importer:</p>
<pre><code>def get_channel_module(app, method):
mod_name = 'channel.%s.%s' % (app, method)
module = __import__(mod_name, globals(), locals(), [method])
return module
</code></pre>
<p>This imports the specific python file, for example, some_file.py, which looks like this:</p>
<pre><code>class SomeClassA(BaseClass):
def __init__(self, *args, **kwargs):
return
class SomeClassB():
def __init__(self, *args, **kwargs):
return
</code></pre>
<p>What I want to do is return only the class which extends BaseClass from the imported file, so in this instance, SomeClassA. Is there any way to do this? </p>
| python | [7] |
3,693,042 | 3,693,043 | Java library inspector? | <p>I am currently working on a mantenance project that is written in Java. We are currently working to clean up the code some and try to provide a little more organization to the project overall.</p>
<p>The list of libraries that are included in the build have grown long, and honestly no one remains that knows/remembers what each library is used for or why? So I am looking for a tool that would be able to essentially find where the library is used in the code. Essentially like a find usage function in an IDE has for functions. </p>
<p>Does such a tool exist? I am curently using Netbeans and as mentioned our code is in java.</p>
<p>I know I could remove each library and compile the project for each library to find the usages, but it just seems there should be a better way. Any ideas?</p>
| java | [1] |
1,306,057 | 1,306,058 | Difference between == and === in JS | <blockquote>
<p><strong>Possible Duplicates:</strong><br>
<a href="http://stackoverflow.com/questions/523643/difference-between-and-in-javascript">Difference between == and === in JavaScript</a><br>
<a href="http://stackoverflow.com/questions/359494/javascript-vs-does-it-matter-which-equal-operator-i-use">Javascript === vs == : Does it matter which “equal” operator I use?</a> </p>
</blockquote>
<p>What's the difference between <code>==</code> and <code>===</code>? Also between <code>!==</code> and <code>!==</code>?</p>
| javascript | [3] |
4,091,892 | 4,091,893 | Java Web App for Multiple Devices | <p>I am asking this question after going through similar questions like </p>
<ol>
<li><p><a href="http://stackoverflow.com/questions/9897813/how-to-optimize-website-for-mobile-devices">Presentation technology for multiple devices</a></p></li>
<li><p><a href="http://stackoverflow.com/questions/1881547/presentation-technology-for-multiple-devices">How best to implement support for multiple devices in a web application</a></p></li>
<li><p><a href="http://stackoverflow.com/questions/2480139/how-best-to-implement-support-for-multiple-devices-in-a-web-application">How to optimize website for mobile devices?</a></p></li>
</ol>
<p>After reading the replies I understand it best to go for a very light weight web site without using many fancy frameworks</p>
<p>I have zeroed down on using Spring MVC in the backend and jsp for the front end.</p>
<p>Having done this I need to get down to more specifics.</p>
<p>Suppose I want to render a datatable do I use plain jsp or can I use some framework like</p>
<p><a href="http://jquerymobile.com/" rel="nofollow">Jquery Mobile</a> . Will a framework provide me ease of coding and maintainability,functionality and at the same time will it render reasonably fast on mobile phone devices ?</p>
<p>The data table must have the ability to filter,sort,paginate etc.</p>
<p>I have used datatable component as an example. There could be other components as well like say trees, charts etc</p>
| java | [1] |
5,063,021 | 5,063,022 | Binding an specific context to an event handler | <p>I am just learning JavaScript and reading from that Ninja Secrets book and this is how he has done it to bind a click event to a button. So as I am just a beginner and learning I wanted to do is it the best and final way of doing this ( adding click handler to a button ) or he has just used this as an example to demonstrate closures and this is NOT how in real world it is done.</p>
<pre><code> <body>
<button id="test">Click Me!</button>
<script>
function bind(context,name){ //#1
return function(){ //#1
return context[name].apply(context,arguments); //#1
}; //#1
} //#1
var button = {
clicked: false,
click: function(){
this.clicked = true;
assert(button.clicked,"The button has been clicked");
console.log(this);
}
};
var elem = document.getElementById("test");
elem.addEventListener("click",bind(button,"click"),false); //#2
</script>
</body>
</code></pre>
| javascript | [3] |
2,075,458 | 2,075,459 | Suggestion on treeview control that renders valid xhtml and works withou javascript | <p>I'm looking for an ASP.NET control that renders a tree structure, very much like the ASP.NET TreeView control, but filling the following requirements:</p>
<ul>
<li>Dont uses tables for rendering tree structure.</li>
<li>Markup Adhering to valid XHTML 1.0 Strict.</li>
<li>Works with AND without javascript.</li>
</ul>
<p>Also, if the control is licensed under a MIT och GPL licens that would be great, but commercial controls is also of interest.</p>
<p>Do anyone know of any such control? If not, well, then I'll simply have to write the control myself. More fun in my own opinion, but likely more time consuming.</p>
<p>Thanx!</p>
| asp.net | [9] |
5,235,343 | 5,235,344 | what is bus error ? when it comes? | <p>in my application bus error is showing and application crash ..i want to know when this error comes . what mean by bus error ?</p>
<p>in my application page on diffrent id i have to calling libxml parsing . in many times calling, ones it crash .</p>
| iphone | [8] |
3,012,392 | 3,012,393 | data storage in android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/5154328/data-store-in-sd-card">data store in sd card</a> </p>
</blockquote>
<p>how to access data for storing in sd card on android</p>
| android | [4] |
3,544,606 | 3,544,607 | Pass variable to external javascript? | <p>I have a plugin which shows posts from a certain city:</p>
<pre><code><div id='banner-root' style="height: 50px; width: 385px;"></div>
<script src="http://lujanventas.com/plugins/banner.js" type="text/javascript"></script>
</code></pre>
<p>I need to pass the cityID to the external javascript. I'm already getting height and width on the external .js by simply checking the banner-root element.</p>
<p>How do I pass the and ID? Also it would be nice if it was clear that you are passing the cityID</p>
| javascript | [3] |
2,959,849 | 2,959,850 | math functions with floor | <p>This bit of code:</p>
<pre><code>$hour = 2.2;
if (floor($hour) > 1) {
$str = $str . floor($hour) . " hours";
}
else if (floor($hour) === 1) {
$str = $str . floor($hour) . " hour";
}
echo $str;
</code></pre>
<p>Will output: <code>2 hours</code></p>
<p>However, this bit:</p>
<pre><code>$hour = 1.2;
if (floor($hour) > 1) {
$str = $str . floor($hour) . " hours, ";
}
else if (floor($hour) === 1) {
$str = $str . floor($hour) . " hour ";
}
echo $str;
</code></pre>
<p>Will <strong>not</strong> output <code>1 hour</code>, because the condition for the <code>else if</code> does not match for some reason. Why is that?</p>
| php | [2] |
2,731,692 | 2,731,693 | Show one input and hide another one | <p>I have in a page many inputs and i want to display just one until you press enter. When you press enter the current input disappears and a hidden input shows up.</p>
<pre><code><input type="text" value="Name" />
<input type="text" value="Password" />
</code></pre>
<p>And here is the jQuery code:</p>
<pre><code>$('input').each(function(){
$(this).fadeIn();
$(this).on('keyup', function(e) {
if (e.which == 13)
return true;
else return false;
});
$(this).fadeOut();
});
</code></pre>
<p>I made this piece of script but it does not work. It shows me both inputs in the same time , then disappear.</p>
<p>What should I change to get the desired results?</p>
| jquery | [5] |
3,954,149 | 3,954,150 | How to retrieve JFormattedTextField integer value? | <p>The problem is JFormattedTextField automatically changes the Integer to the formatted Integer (Eg: 5000000 to 5,000,000).
With JTextField, I can convert 5000000 to Integer using parseInt(). But how can I do that with JFormattedTextField when it's value is 5,000,000.</p>
| java | [1] |
4,225,181 | 4,225,182 | What is the difference between `void f1(const Class &c)` and `void f2(Class const &c)`? | <p>What is the difference between these below functions ( Look at keyword <code>const</code> ) ?</p>
<pre><code>void f1(const Class &c)
</code></pre>
<p>and</p>
<pre><code>void f2(Class const &c)
</code></pre>
| c++ | [6] |
2,082,444 | 2,082,445 | How does "&" operator work in PHP function? | <p>Please see this code.</p>
<pre><code>function addCounter(&$userInfoArray) {
$userInfoArray['counter']++;
return $userInfoArray['counter'];
}
$userInfoArray = array('id' => 'foo', 'name' => 'fooName', 'counter' => 10);
$nowCounter = addCounter($userInfoArray);
echo($userInfoArray['counter']);
</code></pre>
<p>This will show 11.</p>
<p>But! If you remove "&"operator in the function parameter, the result will be 10.</p>
<p>I don't know what's going on. Please explain it to me. Thank you.</p>
| php | [2] |
5,808,170 | 5,808,171 | Explode the results to add a nested tree to a database in PHP and order it | <p>I'm using a nestedsortable jQuery plugin that gives me the order/sort of the elements serialized.</p>
<p>And example of this serialitzation (root means parent_id=0):</p>
<pre><code>id[1]=root&id[5]=1&id[2]=1&id[3]=1&id[4]=3
</code></pre>
<p>First thing I'll do is explode by &:</p>
<pre><code>$serialized = "id[1]=root&id[5]=1&id[2]=1&id[3]=1&id[4]=3";
$exploded = explode("&", $serialized);
</code></pre>
<p>But I don't know then how to manage a <code>id[1]=root</code> or <code>id[3]=1</code>. How I can do it?</p>
<p>And another question. In this way I don't know which is how to store the order. When I've the exploded with in array like <code>array("id"=>1, "parent"=>"root");</code> I've to store the order. I will do it with an index, but how I recognise nested levels?</p>
<p>An example:</p>
<pre><code>$i = 0;
foreach($exploded as $explode)
{
//update every id in MySQL and set parent=$explode["parent"] and order=$i
$i++;
}
</code></pre>
<p>But if I've N levels, how I can have a index $i for every one of them?</p>
<p>Thank you in advance!</p>
| php | [2] |
5,894,521 | 5,894,522 | Highlight Active Class in Navigation with jQuery | <p>I have been trying multiple solutions for this, but I have not been able to get this to work.</p>
<p>I'm currently using a Coda-type slider to propagate the content on my website using the following navigation:</p>
<pre><code> <div class="navigation">
<ul>
<li id="home"><a href="#home">Home</a></li>
<li id="work"><a href="#work-showcase">Work Showcase</a></li>
<li id="offerings"><a href="#brand-offerings">Offerings</a></li>
<li id="about"><a href="#about">About</a></li>
<li id="reason"><a href="#wow-factor">Reason to Believe</a></li>
</ul>
</div>
</code></pre>
<p>I have a few pages on my website that fall outside of the slider content. I would like to be able to when on one of these "non-slider" pages -- to be able to click on one of the slider options at the top -- and have that content slide's navigation option highlighted with the .active or in my case ".there" class.</p>
<p>For example -- If I am on -- /packaged-brand-solutions.php (non-slider) and I click on: Work Showcase (/index.php#work-showcase) -- not only does that area of the slider load -- but its accompanying navigation option is highlighted.</p>
<p>Any help would be appreciated.</p>
| jquery | [5] |
3,721,669 | 3,721,670 | About c# if-else syntax | <p>In c# you can define an if statement without using braces, like this example</p>
<pre><code> if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
</code></pre>
<p>here the this.Exit(); is the statement associated with the if. But it's not in braces, so my question is, how is it associated with the if? </p>
<p>I learned that the compiler ignores white space, which does not logically make sense in this case. Is the answer simply that the IDE finds the indent and automatically puts it in braces when it compiles?</p>
| c# | [0] |
2,799,714 | 2,799,715 | $.getJson> $.each returns undefined | <pre><code>function getData(d){
Back = new Object();
$.getJSON('../do.php?',
function(response){
if(response.type == 'success'){
Back = { "type" : "success", "content" : "" };
$.each(response.data, function(data){
Back.content +='<div class="article"><h5>'+data.title+'</h5>'
Back.content +='<div class="article-content">'+data.content+'</div></div>';
});
}
else{
Back = {"type" : "error" };
}
return Back;
});
}
console.log(getData());
</code></pre>
<p>is returning undefined! why?</p>
| jquery | [5] |
2,416,119 | 2,416,120 | In my Application i want to perform Scaling and Translation together? | <p>i want to perform Scaling and Translation of image together so how its possible? </p>
| iphone | [8] |
5,156,390 | 5,156,391 | creating a folder without giving hardcore path in the code | <p>i need to create a folder named log after giving the path in a textbox like <code>D:\New Folder</code> without giving the hardcore path in the code like <code>var _logFolderPath = @"D:\New Folder\log";</code>
and after that i need to create two text files ba.txt and ra.txt in that log folder</p>
<p>This is my code</p>
<pre><code> DirectoryInfo Folder = new DirectoryInfo(textboxPath.Text);
var _logFolderPath =textboxPath.Text;
if (Folder.Exists)
if (!Directory.Exists(_logFolderPath)) Directory.CreateDirectory(_logFolderPath);
</code></pre>
<p>and</p>
<pre><code> using (var dest = File.CreateText(Path.Combine(_logFolderPath, line2 + ".txt")))
</code></pre>
<p>for reference
<a href="http://stackoverflow.com/questions/4253090/comparing-two-text-files">comparing two text files</a></p>
| c# | [0] |
545,219 | 545,220 | is it possible for delete file without new file instance in Java? | <p>I have a simple function used for file delete, </p>
<p>it will check the file size,</p>
<p>if small than a specific value, delete the file</p>
<p>however, this function will be called thousand times</p>
<p>and every time it will new file instance, </p>
<p>i think it will be expensive on file object creation issue, </p>
<p>is there any other way to fix this issue?</p>
<pre><code>public void checkFile(String filePath) {
File file = new File(filePath); //this is expensive
if (file.length() < 500) {
file.delete();
}
}
</code></pre>
| java | [1] |
68,725 | 68,726 | how to make keyboad with emot icons in android | <p>I want to make custom keyboard with emot icons but problem arise when user
type the message with my keyboard and then send the message to his/her friend.
now how my friend mobile will parse the message and replace my special code
with icon . so please provide some tutorial or any help to solve this </p>
| android | [4] |
5,407,977 | 5,407,978 | Onclick function not working on inserted HTML | <p>Im just new to jquery and while doing experimentations on jquery I encountered this problem -> It can insert the html to the div but the click function in not working on the inserted html. Anyone knows why? thanks in advance</p>
<pre><code>$(document).ready(function(){
$("#insertTest").click(function(){
$("#testDiv").html($("#testDiv").html() + '<p><a href="#" class="testClick">Click Me</a></p>');
});
$(".testClick").click(function(){
alert('Ahoy');
});
});
<a href="#" id="insertTest">Click to Insert</a>
<div id="testDiv">
</div>
</code></pre>
| jquery | [5] |
1,691,966 | 1,691,967 | How to avoid a web page that is being saved? | <p>I had displayed a pdf file in a web page,</p>
<p>using</p>
<pre><code> <object data=".<%=filename%>" type="application/pdf" width="1350" height="650">
alt : <a href=".<%=filename%>">test.pdf</a> </object>
</code></pre>
<p>i want to avoid that page from being saved</p>
<p>is that possible</p>
| javascript | [3] |
3,487,040 | 3,487,041 | jquery datepicker | <p>i have datepicker on my form. and then i am adding datepickers dynamically to the form. and when i make choose to any of this datepickers. the value of datepicker is setting to first datepicker. how fix it? </p>
| jquery | [5] |
126,855 | 126,856 | What does this operator <> mean in php? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php">Reference - What does this symbol mean in PHP?</a> </p>
</blockquote>
<p>What does the '<>' mean?</p>
<pre><code>if ($class->stuff <> 'specific')
</code></pre>
<p>Just working on a little project and came across a strange symbol.</p>
| php | [2] |
2,034,059 | 2,034,060 | Shorthand notation for class member initialization | <p>In a C# block, I can define and initialize a variable as follows:</p>
<pre><code>var xyz = new Xyz();
</code></pre>
<p>The type of <code>xyz</code> will be set accordingly.</p>
<p>However, at the class level, I have to specify the type twice:</p>
<pre><code>class Abc
{
Xyz xyz = new Xyz();
}
</code></pre>
<p>Is there a shorthand syntax that avoids typing out the type name twice?</p>
<p>This isn't such a big deal with short types like <code>Xyz</code> but a shorter notation would help with LongTypeNames.</p>
| c# | [0] |
4,439,833 | 4,439,834 | Which event can be used as an alternative for "Click" event in jquery? | <p>In the week view of a calendar(Similar to google caledar) on "Click event" i wrote a jquery function. I got the output as expected. (Id of the grids are "#week"). I tried the same function in month view, the id of the month grid is "#month". It also works fine for single click. <br></p>
<p>The problem occurs when i tried to select more number of cells<br>. </p>
<p>To overcome this problem i replaced the click event with "mouseup event". Now the problem solved only for week view. I'm not sure how to solve it for month view.</p>
<pre><code>$("#week").click(function(){
$.ajax({
url : 'testlink',
type : 'post',
....
});
</code></pre>
<p>Replaced this click with mouse up..</p>
<pre><code>$("#week").mouseup(function(){
$.ajax({
url : 'testlink',
type : 'post',
....
});
</code></pre>
| jquery | [5] |
1,546,058 | 1,546,059 | How to get Android Thread ID? | <p>This code throws a "Given thread does not exist" exception when I try to use it in a thread:</p>
<pre><code>android.os.Process.getThreadPriority((int) Thread.currentThread().getId()));
</code></pre>
<p>Ditto if I try to use Process.setThreadPriority, using the java class Thread id. I've also noticed that this does not match the thread id displayed in the debugger. How do I get the Android specific thread id, in order to use this API?</p>
| android | [4] |
2,320,347 | 2,320,348 | Script randomly cuts off | <p>I've made a VERY basic website which takes an array of image URLs, zips them, and returns the zip location. The problem is that the script cuts off at some point.</p>
<p>One of the following usually happens:</p>
<ul>
<li>not all the pictures are copied</li>
<li>not all pictures are copied and the last picture has 0 file size</li>
<li>sometimes the ajax call doesn't run the error or success callback</li>
</ul>
<p>Is this because the server is only allowing a certain amount of time for the script to execute? It does seem to work with less pictures. What can I do? </p>
<p>I have the following settings:</p>
<p>max_execution_time 10 10
max_file_uploads 20 20
max_input_nesting_level 64 64
max_input_time 10</p>
<p>also, set_time_limit is disabled. </p>
<p>I tried ini_set('max_execution_time', 300); and nothing changed</p>
<p>edit: Probably a REALLY stupid question, but would it change anything if I executed another PHP page after a certain amount of time if the script isn't going to finish before the limit?</p>
| php | [2] |
2,616,611 | 2,616,612 | how to change an imageView when a sound ends with threads | <p>I need to change an ImageView when a sound ends , but when I try to use a thread to use it whitout to freeze the screem the application closes;</p>
<pre><code>mp = MediaPlayer.create(this, R.raw.ave_maria);
mp.start();
im = (ImageView) findViewById(R.id.imag1);
Thread thread = new Thread() {
public void run() {
while (mp.isPlaying()) {
}
im.setImageResource(R.drawable.primeiro_misterio_gozoso07);
}
};
thread.start();
</code></pre>
| android | [4] |
3,495,829 | 3,495,830 | How to Use String as a ResourceID in Android | <p>I've several <code>TextView</code>s or another component, doesn't matter. And the views have iteration ids like: <code>textView1, textView2, textView3</code> etc.</p>
<p>Simply I want to iterate ids by using <strong>pre-string</strong> values. </p>
<p>Psuedo example:</p>
<pre><code>String pre_value = "textView";
for(int i = 0; i < size; i++) {
String usable_resource_id = pre_value + Integer.toString(pre_value);
// So how to use these id like R.id.textView1
// Cast or something similar
}
</code></pre>
<p>Any suggestions?</p>
| android | [4] |
4,180,913 | 4,180,914 | Android Activty To Mimic a Manual | <p>Can someone point me in the right direction - I'm trying to create an Android Activity that looks like a technical manual that ALSO can take some user input(I know how to do simple buttons etc.) and the user input part can wait until I have a few basic pages.</p>
<p>My goal (if possible) would be to create a text-heavy activity (like a technical manual) but I'm not sure what the best GENERAL method is for doing this.</p>
<p>To start - rather than having multiple activities I want one large activity that a User may be able to swipe through from left to right (Perhaps use ViewFlipper here??)</p>
<p>But how can I make an Activity that looks like a manual or is Text Heavy??</p>
<p>Thanks!</p>
| android | [4] |
4,279,752 | 4,279,753 | How does `operator delete` deallocate the memory block for node of LinkedList | <pre><code>struct node
{
node(int _value, node* _next) : value(_value), next(_next) {}
int value;
node* next;
};
node *p = new node(10, NULL);
delete p;
</code></pre>
<p>Based on my understanding, <code>operator delete</code> will first call the destructor of <code>node</code>, then deallocate the raw memory block originally allocated for <code>p</code>.</p>
<p>Since <code>struct node</code> doesn't provide a customized destructor, the compiler will provide a default one. </p>
<p><strong>Question1</strong>>what does the default destructor look like?
For example,</p>
<pre><code>node::~node()
{
next = NULL;
}
</code></pre>
<p><strong>Question2</strong>>should we define a destructor for <code>struct node</code> or not?
I assume that we don't have to explicitly provide such a destructor. The reason is that the member variable <code>next</code> doesn't own the pointed resource and it behaves as a <code>weak_ptr</code>. Is that correct?</p>
| c++ | [6] |
3,721,991 | 3,721,992 | Android cross compilation | <p>How can I use Nmap port scanner on Android SDK in Windows?</p>
| android | [4] |
3,670,957 | 3,670,958 | Activity base class? | <p>What is Activity base class: java.lang.Object or android.content.Context?</p>
<p>The class overview is not clear to me (see the image please).</p>
<p><img src="http://i.stack.imgur.com/yEiMl.png" alt=""></p>
| android | [4] |
2,199,818 | 2,199,819 | Why not Object.ToFloat or Object.ToInt() exist? | <p>Tostring() gives the string representation of the instance?
Is it because we didn't feel the need to do any conversion from object to int/float?</p>
| c# | [0] |
3,416,933 | 3,416,934 | finding referrer to current page/script | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/606288/php-html-http-referer">php/html - http_referer</a> </p>
</blockquote>
<p>I want to find which page/script get request to current page/script.</p>
<p><strong>For example</strong></p>
<p>I am on page "index.php"</p>
<p>I click on link that takes me to "about.php"</p>
<p>Now, on "about.php", I need to find referrer, i.e., "index.php"</p>
<p>I need solution, that works on any OS/Platform (Windows, Linux, Mac OS X)</p>
<p>Thank</p>
| php | [2] |
310,137 | 310,138 | How to check if picture is loaded? | <p>How can I check if a picture is already loaded?</p>
<pre><code>image.src = ay.url_static + 'uploads/apps/' + thumbnail.uid + '.png';
image.onload = function(e)
{
// [..]
};
</code></pre>
<p>I know how to trigger a callback upon image is loaded, but how do I check if picture is loaded at the moment?</p>
| javascript | [3] |
3,680,167 | 3,680,168 | mysql_query() expects parameter 2 to be resource error in connection with remote mysql DB | <p>My PHP code works well in connecting remote windows system mysql database and returns the output. But, when I'm using the same to connect remote linux system's mysql database, I got the following error:</p>
<blockquote>
<p>"mysql_query() expects parameter 2 to be resource, boolean given in
C:\wamp\www\mysqldb.php on line 88"</p>
<p>That line 88 have the following content "$this->resultQur =
mysql_query($query, $this->connID);"</p>
</blockquote>
<p>Help me to solve this.</p>
<p>yes. The resource is null in this case. But the same works in windows mysql connection. I got the error only in linux. Need to do any change for linux environment?</p>
<p>While putting "print mysql_error();" i got the following error</p>
<p>"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond."</p>
| php | [2] |
1,308,786 | 1,308,787 | Adding Reference Problem in Visual Studio 2010 | <p>I created my custom DLL "MongoDbExtensions". Now in a new project I add a reference to the "MongoDbExtensions" and then try to invoke a method inside the MongoDbExtensions called ToDocument. I use resharper to add the namespace at the top of the file but when I compile I still get the following error: </p>
<p>Error 1 The type or namespace name 'MongoDbExtensions' could not be found (are you missing a using directive or an assembly reference?) C:\Projects\HelpForum\DemoConsole\Program.cs 6 7 DemoConsole</p>
<p>What is going wrong? My DLL can be downloaded from here: </p>
<p><a href="http://github.com/azamsharp/MongoDbExtensions/downloads" rel="nofollow">http://github.com/azamsharp/MongoDbExtensions/downloads</a></p>
<p>UPDATE 1: </p>
<p>Here is the MongoExtensions class: </p>
<pre><code>namespace MongoDbExtensions
{
public static class MongoExtensions
{
public static List<T> ToList<T>(this IEnumerable<Document> documents)
{
var list = new List<T>();
var enumerator = documents.GetEnumerator();
while (enumerator.MoveNext())
{
list.Add(enumerator.Current.ToClass<T>());
}
return list;
}
}
}
</code></pre>
<p>ToDocument is an extension method that works on Object. </p>
| c# | [0] |
3,569,917 | 3,569,918 | JavaScript Object Literals: Property names as strings vs. "raw" | <p>Can there ever be a difference between:</p>
<pre><code>var x = {
hello: 'world'
};
</code></pre>
<p>and</p>
<pre><code>var x = {
'hello': 'world'
};
</code></pre>
<p>?</p>
<p>That is, under what conditions does giving a property name as a string have different results than giving it as a "raw" name? For example, I know that <code>var x = {}; x['@£$%'] = 'bling!';</code> is valid (since any string can be a property), but <code>x.@£$% = 'bling!'</code> won't work. Neither will language keywords or reserved keywords as property names (so <code>var x = {for: 'good', class: 'y'};</code> won't work.</p>
<p>Anything else?</p>
<p>For example, what if </p>
<pre><code>var hello = 'goodbye';
</code></pre>
<p>is defined in the above example? Or something else, like </p>
<pre><code>function hello() {
return 'goodbye';
}
</code></pre>
<p>?</p>
<p>Should I always make my property names strings, just to be safe?</p>
| javascript | [3] |
958,053 | 958,054 | Something wrong with enum | <p>I've something like: </p>
<pre><code>enum Direction{Forward,Backward};
template<Direction dir = Forward>
class X
{
private:
Direction my_direction_;
public:
void set_direction(Direction dir)//here I'm getting an error
{
my_direction_ = dir;
}
};
</code></pre>
<p><em>error: declaration of 'Direction dir'</em><br>
Any reason why? BTW, it does compile with VS2010.</p>
| c++ | [6] |
4,815,069 | 4,815,070 | Pros/Cons of Publishing iPhone Apps as Individual or Company (LLC, S-corp)? | <p>I'd like to eventually publish one of the iPhone projects I've been working on and I was wondering if I should really establish an LLC before joining the Apple Dev program and submitting apps under the company name, rather than just using my name for both. I'm looking for any legal or financial differences between the two options...as well as anecdotes. Thanks!</p>
| iphone | [8] |
1,654,568 | 1,654,569 | How do numbers work in Python? | <p>So, I open terminal.</p>
<pre><code>> python
> 1 / 3
0
> 1.0 / 3
0.33333333333333331
</code></pre>
<p>Could someone tell me what the rules are when it comes to decimals. Does it matter which number when being divided carries the decimal? Is there a best practice?</p>
<p>If I want more decimal points, or less for that matter, do I need to use a function?</p>
| python | [7] |
3,747,063 | 3,747,064 | how to retrieve the num value from image src? | <p>I have a src information from a image like "/images/slide1.jpg" just I want to swap the slide1 to slide2, any one give me the right way to find and replace img src ?</p>
| javascript | [3] |
1,003,117 | 1,003,118 | JavaScript - Is it possible to view all currently scheduled timeouts? | <p>So I was wondering, is there any feasible way in JavaScript to view information about scheduled timeouts and intervals that you don't explicitly know about (I know <code>setTimeout</code> and <code>setInterval</code> return a handle that can be used to refer to the scheduled instance, but say that this is unavailable for one reason or another)? For instance, is there a way to use a tool like Chrome's JavaScript console to determine what timeouts are currently active on an arbitrary page, when they will fire, and what code will be executed when they fire? More specifically, say a page has just executed the following JavaScript:</p>
<pre><code>setTimeout("alert('test');", 30000);
</code></pre>
<p>Is there some code I can execute at this point that will tell me that the browser will execute <code>alert('test');</code> 30 seconds from now?</p>
<p>It seems like there theoretically should be some way to get this information since pretty much everything in JavaScript is exposed as a publicly accessible property if you know where to look, but I can't recall an instance of ever doing this myself or seeing it done by someone else.</p>
| javascript | [3] |
2,077,207 | 2,077,208 | Extract multidimensional associative array in PHP | <p>I have an array in the following format: </p>
<pre><code>Array
(
[accountID] => Array
(
[0] => 412216
[1] => 396408
[2] => 522540
)
[mailBody] => Array
(
[0] => 'We are glad to have contact you'
[1] => 'Thank you for your cooperation'
[2] => 'One of our customer service representatives will contact you soon'
)
[mailAttachments] => Array
(
[0] => 'URL1'
[1] => 'URL1'
[2] => 'URL1'
)
)
</code></pre>
<p>This array pulls some information from a mailing box. I would like to extract each accountID with equivalent mailBody and mailAttachments as well.
Your response is highly appreciated.</p>
| php | [2] |
4,092,500 | 4,092,501 | How to test valid UUID/GUID? | <p>How to check if variable contains valid UUID/GUID identifier ?</p>
<p>I'm currently interested only in validating types 1 and 4, but it's not limit for your answer.</p>
| javascript | [3] |
1,068,828 | 1,068,829 | String fullname Split java | <p>I created a program which will parse the firstName, middleName and lastName. Here is the program and output. This program can definitely be improved and need some input on reducing my cumbersome ugly code and replace it with a better one. Any suggestions or example ? </p>
<pre><code>public class Test {
public static void main(String[] args) {
String fullName = "John King IV. Cena";
String[] tokens = fullName.split(" ");
String firstName = "";
String middleName = "";
String lastName = "";
if(tokens.length > 0) {
firstName = tokens[0];
middleName = tokens.length > 2 ? getMiddleName(tokens) : "";
lastName = tokens[tokens.length -1];
}
System.out.println(firstName);
System.out.println(middleName);
System.out.println(lastName);
}
public static String getMiddleName(String[] middleName){
StringBuilder builder = new StringBuilder();
for (int i = 1; i < middleName.length-1; i++) {
builder.append(middleName[i] + " ");
}
return builder.toString();
}
}
</code></pre>
<p>John
King IV.
Cena</p>
| java | [1] |
5,718,698 | 5,718,699 | Getting the list of distribution lists using ewp api in c# | <p>I want to get all distribution lists & the members of those lists using the ewp api in c#.
I made the connection to the outlook server and I can get the calendar information of mine using c#. But I couldn't find a way to get the distribution lists.</p>
| c# | [0] |
2,925,552 | 2,925,553 | Problem with dictionary key in Python | <p>For some project I have to make a dictionary in which the keys are urls,among which I have this url:</p>
<p><a href="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Guide&pver=6.2" rel="nofollow">http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Guide&pver=6.2</a></p>
<p>the url is too long to fit in here I guess in one single line.
I can build a dictionary without any errors this url is also a key. but for some reason when I want to extract the values associated to this key(url). I cannot, I get and error "error key:...."
Does someone know what is wrong with this url? Are dictionary keys sensitive to some stuff?
thanks</p>
<p>below is the code:</p>
<pre><code>def initialize_sumWTP_table(cursor):
cursor.execute( ''' SELECT url,tagsCount
FROM sumWTP''')
rows = cursor.fetchall ()
for url,tagsCount in rows:
sumWTP[url] = tagsCount
</code></pre>
| python | [7] |
5,708,656 | 5,708,657 | Small Straight - Method | <p>I've been stuck on this method for a couple of days now. This method checks to see if the roll of 5 dice == a small straight. It works for some numbers. If I roll a </p>
<blockquote>
<p>1, 2, 4, 3, 6</p>
</blockquote>
<p>it will work. However, if I roll a </p>
<blockquote>
<p>1, 2, 4, 3, 3</p>
</blockquote>
<p>it will not work. I think it's because of the duplicate 3 in there. I need to move it to the end somehow.</p>
<p>A small straight is when there are four consecutive die face values, such as 1, 2, 3, 4 or 3, 4, 5, 6. It can be in any order such as 2, 3, 1, 4</p>
<pre><code> int counter = 0;
int score = 0;
boolean found = false;
Arrays.sort(die);
for (int i = 0; i < die.length - 1; i++)
{
if (counter == 3)
found = true;
if (die[i + 1] == die[i] + 1)
{
counter++;
}
else if (die[i + 1] == die[i])
{
continue;
}
else
{
counter = 0;
}
}
if (found)
{
score = 30;
}
else
{
score = 0;
}
return score;
}
</code></pre>
| java | [1] |
1,184,944 | 1,184,945 | Write to text file problem in PHP | <p>I have this page called up.php that adds 1 to a txt file set with all permissions. </p>
<pre><code><?php
$name = file_get_contents("name.txt");
if(!file_exists('number.txt')){
file_put_contents('number.txt', ((int) file_get_contents('number.txt')) + 1);
header('Location: "$name.txt");
}
?>
</code></pre>
<p>I have a form action button that runs this php page, however the browser comes back with this:</p>
<p>Parse error: syntax error, unexpected $end in /up.php on line 10. </p>
<p>I am lost here. Any ideas on why this is happening?</p>
| php | [2] |
3,112,984 | 3,112,985 | Crash on loading large number of images | <p>I am creating an app in which I am loading 800 jpg images for the Imageview.On occurance of different enevts different set of images are to be loaded for animation.on fire of first event it works fine but on 2nd event it crashes on iPhone.Any help?
my part of code is as below</p>
<pre><code>for (int aniCount = 1; aniCount < 480; aniCount++){
UIImage *frameImage = [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: [NSString stringWithFormat: @"ani_soft_whimper_%i", aniCount] ofType: @"jpg"]];
[_arr_ImagesSoftWhimper addObject:frameImage];
}
imageView.animationImages = _arr_ImagesSoftWhimper;
</code></pre>
<p>and i m getting crash for these set of images.</p>
| iphone | [8] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.