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,211,075 | 1,211,076 | Insert spaces based on words/dictionary | <p>I'm looking for a way to take phrases with no spaces in (such as a trending topic on twitter) and put spaces in where appropriate based on the words in the phrase. Presumably some sort of comparison with a dictionary would work?</p>
<p>For example: I'd have a function that took the phrase 'septemberwish' (current trending on twitter) and it would return 'september wish'.</p>
| php | [2] |
1,290,571 | 1,290,572 | error while adding new value for dropdownlist in javascript | <p>i need to add same value for two dropdowns in js
code is as follows</p>
<pre><code> var opt1 = new Option("All", 0);
document.getElementById('ddlfromGroupCountry').optons[0] = opt1;
document.getElementById('ddlFromCountry').optons[0] = opt1;
</code></pre>
<p>i am using same Option variable i.e opt1 for adding value to both dropdowns</p>
<p>in second line getting following error</p>
<pre><code>htmlfile: Invalid argument.
</code></pre>
<p>any suggestions</p>
<p>thanks in advance</p>
| javascript | [3] |
4,133,130 | 4,133,131 | On limiting JavaScript global variables | <p>I am reading a book that encourages the reader for a few reasons, to limit global variables. The technique they recommend is to define a global object variable, like the following:</p>
<pre><code>var myapp = {};
var myapp.another_stooge = {
'first-name': 'Lenny',
'last-name': 'George'
};
var myapp.properties = [
'first-name',
'last-name'
];
for (i = 0; i < myapp.properties.length; i += 1) {
document.writeln(myapp.properties[i] + ': ' +
myapp.another_stooge[myapp.properties[i]] +
'<BR/>');
}
</code></pre>
<p>This does not write to my html file, but implemented without using myapp, it works:</p>
<pre><code>var another_stooge = {
'first-name': 'Lenny',
'last-name': 'George'
};
var properties = [
'first-name',
'last-name'
];
for (i = 0; i < properties.length; i += 1) {
document.writeln(properties[i] + ': ' + another_stooge[properties[i]] + '<BR/>');
}
</code></pre>
<p>I must be missing something simple but could not catch it; any direction would be appreciated. Thank you!</p>
| javascript | [3] |
2,390,854 | 2,390,855 | Waiting for a response in a thread | <p>I want to recycle my image , but since another thread is rendering them, I need to be sure that the rendering has stopped:</p>
<pre><code> private void unload() {
System.out.println("Unloading menu...");
loaded = false;
while(rendering) {
//wait
}
background.recycle();
button.recycle();
button_pushed.recycle();
}
</code></pre>
<p>But I dont think this is the best way , are their other ways to do this?</p>
| android | [4] |
2,801,094 | 2,801,095 | asp.net inline versus codebehind which do you use and why? | <p>I've done it both ways, and to be honest other than the ability to give the code and webform to two different people (which doesn't happen where I work), I see very little advantage of one method over the other. I can understand how it is nice to have your code in one file, and markup in the other, but I can also understand the ease of having both in a single file.</p>
<p>I don't see how using code-behind <em>enforces</em> any sort of "good" programming, because you can still write crappy code in code-behind, and I've seen some really clean stuff with in-line.</p>
<p>So my real questions, what method are you using? and is there <em>anything</em> you can do programatically with code-behind that simply cannot be done with in-line code? or does it all really come down to the simple matter of "personal preference". Microsoft seems to not take a real stand on one way or the other and performance wise, it seems a wash.</p>
<p>Opinions?</p>
| asp.net | [9] |
5,235,133 | 5,235,134 | How to setup ptp data transfer between android device and device such as camera? | <p>i would like to setup a connection between a android phone device and a external camera device. i would need to send and receive ptp data between these two devices.</p>
<p>do i use android mtp or use open accessory to achieve this? can anyone guide me in more details?</p>
<p>looking forward for any guides and suggestion possible. thanks!</p>
| android | [4] |
5,521,694 | 5,521,695 | How to find the number of declared functions in a Java program | <p>I am doing project in Core Java which identifies the similarity between two files, in that one part is to identify the declared functions length. I have tried the following code to find the declared methods in a given class.</p>
<pre><code>import java.lang.reflect.*;
import java.io.*;
import java.lang.String.*;
public class Method1 {
private int f1(
Object p, int x) throws NullPointerException
{
if (p == null)
throw new NullPointerException();
return x;
}
public static void main(String args[])throws Exception
{
try {
Class cls = Class.forName("Anu");
int a;
Method methlist[]= cls.getDeclaredMethods();
for (int i = 0; i &lt; methlist.length;i++) {
Method m = methlist[i];
System.out.println(methlist[i]);
System.out.println("name = " + (m.getName()).length());
}
}
catch (Throwable e) {
System.err.println(e);
}
}
}
</code></pre>
<p>But i have to find all the classes for a program. Shall i give input as a program since have to identify the declared methods in each class. Secondary it is working only if the given class is compiled, ie class file exist for given class.
Can any one help me for identifying the declared methods in the given program.</p>
<p>And i have to identify the comment lines in the program, please help me for that too.</p>
| java | [1] |
3,674,885 | 3,674,886 | Use jQuery to show/hide input based on another input's value | <p>I want to hide a specific input on a page unless a user types a Hotmail address into a different input. Whenever the user types in a hotmail address, I want to show the input. If the address is removed, I'd like it to disappear. How can this be accomplished with jQuery?</p>
<p>I know I'm going about this incorrectly, but here's what I have so far:</p>
<pre><code>$(function() {
if($("select#combobox").val() *= '@hotmail') {
$('#hotm').show();
}
else {
$('#hotm').hide();
}
});
</code></pre>
| jquery | [5] |
1,344,216 | 1,344,217 | saving recent searches to cookie | <p>I initially was saving the user's recent searches to a sessions array (php) which works but i am having a hard time getting around the (shared) server settings - to make it last 30 days. Since it's not sensitive data i thought I would retry this with jstorage/jquery instead. Is that possible across multiple pages?
This is what i have right now but it's not working :( :</p>
<pre><code>jQuery(document).ready(function() {
if (jQuery.jStorage.get('test') != '') {
jQuery.jStorage.set('test2', '<?php echo $_GET['s']; ?>' );
} else {
jQuery.jStorage.set('test', '<?php echo $_GET['s']; ?>' );
}
jQuery.jStorage.setTTL('test', 30000);
jQuery.jStorage.setTTL('test2', 30000);
var index = jQuery.jStorage.index();
for(i in index) {
var result = jQuery.jStorage.get(index[i]) + " ";
jQuery('#mysearches').append('<li>' + result + '</li>');
}
});
</code></pre>
<p>is this even possible to do what I explained? is there a better way? Any direction would be helpful.</p>
<p>thanks in advance.</p>
| jquery | [5] |
3,392,592 | 3,392,593 | how to hide a div on focus-out of child elements of that div(in java script) | <p>I want to hide a div on focusout of its child elements.say,</p>
<p>lets have username and password field in a div,it will be minimized initially, user will clicks opens the div then if user click anywhere outside the div should close the <code>mydiv</code> </p>
<pre><code><body>
<div id="mydiv" onblur="alert('hi');" tabindex="1" style="border: 1px solid black;">click off me to activate onblur
<br/>
username: <input type="text" name="username" onblur="alert('hi');" tabindex="1" />
<br/>
Password: <input type="text" name="password" />
</div>
</body>
</code></pre>
<p>(see the JS fiddle : <a href="http://jsfiddle.net/vC7Rb/1/" rel="nofollow">http://jsfiddle.net/vC7Rb/1/</a>)</p>
<p>I tried putting onblur for both div as well as text field but that require common function call from which I need to check if any of the element is still have focus and then only hide the div.thats seems too much, so is there any simple way to do this.</p>
<p>I want implement this in pure javascript code and it should be compatible in all browser(IE,firefox,chrome).</p>
| javascript | [3] |
4,187,203 | 4,187,204 | Multiple Text Box Validation | <p>I need to validate multiple text-boxes, which share a common name</p>
<p>Example</p>
<pre><code><input type="text" name="value[]" />
<input type="text" name="value[]" />
<input type="text" name="value[]" />
</code></pre>
<p>How can I validate each and every text box, using jQuery? I am using jQuery Validation Plugin</p>
<p>Please help</p>
| jquery | [5] |
3,877,890 | 3,877,891 | adding a picture to the middle of a drawn rectangle [iPhone] | <p>I have the following code that I am using to draw a simple rectangle inside the middle of a drawn circle, however I would like to be able to replace this rectangle with an UIImage, does anyone know how this can be done?</p>
<pre><code>CGContextSetRGBStrokeColor(context, 255.0/255.0, 255.0/255.0, 255.0/255.0, 1.0);
CGMutablePathRef path = [self newPathForRect:CGRectMake(center.x - kRoundedRectRadius, center.y - kRoundedRectRadius, kRoundedRectRadius * 2.0, kRoundedRectRadius * 2.0)];
CGContextAddPath(context, path);
CGContextDrawPath(context, kCGPathStroke);
CGPathRelease(path);
</code></pre>
| iphone | [8] |
5,366,899 | 5,366,900 | Check if an array contains an invalid value and return false? | <p>This is probably very simple but I guess I haven't had enough of coffee yet.</p>
<p>I have an array with four values and I want to check if any of them is invalid and then set a boolean value to false, else to true.</p>
<pre><code>bool validDecoding = false;
foreach (string decodedValue in arrayOfvalues)
{
if (decodedValue.Contains("invalid") || decodedValue.Contains("length") || decodedValue.Contains("bad"))
{
validDecoding = false;
}
else
{
validDecoding = true;
}
}
</code></pre>
<p>But if the last does not contain invalid, length or bad then validDecoding is set to true but I want it to be false if one or more values are invalid.</p>
<p>Please help?</p>
<p>Thanks in advance.</p>
| c# | [0] |
228,381 | 228,382 | unterminated string literal | <p>The following code:</p>
<pre><code>var str= "<strong>English Comprehension<\/strong>
<br\/>
<ul>
<li> Synonyms/Antonyms/Word Meaning (Vocabulary)<\/li>
<li> Complete the Sentence (Grammar)<\/li>
<li> Spot error/Correct sentence (Grammar/sentence construction)<\/li>
<li> Sentence Ordering (Comprehension skills)<\/li>
<li> Questions based on passage (Comprehension skills)<\/li>
<\/ul>
<br\/>";
</code></pre>
<p>Gives the error: "unterminated string literal". Whats the problem?</p>
| javascript | [3] |
4,205,227 | 4,205,228 | How to append and uniqify a tuple | <pre><code>d1 = ({'x':1, 'y':2}, {'x':3, 'y':4})
d2 = ({'x':1, 'y':2}, {'x':5, 'y':6}, {'x':1, 'y':6, 'z':7})
</code></pre>
<p>I have two tuple <code>d1</code> and <code>d2</code>. I know tuples are <code>immutable</code>. So I have to append another tuple using list. Is there any better solution.</p>
<p>Next question is How to uniqify a tuple on keys say 'x'. if 'x':1 in keys comes twice it is dulicate.</p>
<pre><code>append_tuple = ({'x':1, 'y':2}, {'x':5, 'y':6}, {'x':1, 'y':6, 'z':7}, {'x':1, 'y':2}, {'x':3, 'y':4})
unique_tuple = ({'x':1, 'y':2}, {'x':3, 'y':4}, {'x':5, 'y':6})
</code></pre>
<p><strong>Note</strong>:
I want to remove the duplicate element from a tuple of dict if key values say 'x' has save value in two dict then those are duplicate element. </p>
| python | [7] |
4,595,467 | 4,595,468 | How do you organize your Javascript code? | <p>When I first started with Javascript, I usually just put whatever I needed into functions and called them when I needed them. That was then. </p>
<p>Now, as I am building more and more complex web applications with Javascript; taking advantage of its more responsive user interaction, I am realizing that I need to make my code more readable - not only by me, but anyone who replaces me. Besides that, I would like the reduce the moments of 'what the heck, why did I do this' when I read my own code months later (<em>yes, I am being honest here, I do have what the heck was I thinking moments myself, although I try to avoid such cases</em>)</p>
<p>A couple weeks ago, I got into Joose, and so far, it has been good, but I am wondering what the rest do to make their chunk their codes into meaningful segments and readable by the next programmer.</p>
<p>Besides making it readable, what are your steps in making your HTML separated from your code logic? Say you need to create dynamic table rows with data. Do you include that in your Javascript code, appending the td element to the string or do you do anything else. I am looking for <strong>real world solutions and ideas</strong>, not some theoretical ideas posed by some expert. </p>
<p>So, in case you didnt't understand the above, do you use OOP practices. If you don't what do you use? </p>
| javascript | [3] |
794,043 | 794,044 | Solving a linear equation with jQuery | <p>I don't know how to solve the following linear equation with jQuery.</p>
<p>12.5x = 20 + x + (20 + x)/10
(Note that 12.5, 20, and 10 are numbers provided by user)</p>
<p>Is there a way in jQuery to get x?
Thank you very much</p>
| javascript | [3] |
2,538,867 | 2,538,868 | Jquery paralax effect functions | <p>Basically, what I'm asking for is opinions on the best way to do the following;</p>
<p>I basically have this already: <a href="http://jsfiddle.net/BnJ3G/1/" rel="nofollow">http://jsfiddle.net/BnJ3G/1/</a> which is more or less a background animation depending on the scroll event. Similar to a paralax type function.</p>
<p>I just wanted to know, the easiest way to tackle multiple axis with little coding, I have around 10 different things I need to apply this effect to, but at the moment I'm limited to the +x axis, where as I need (+X, -X, +Y and -Y). Is there someway this can be altered so that I can do something simple like this outside of the main function? </p>
<pre><code>$('#element1').animatePosX(percentage);
$('#element2').animateNegY(percentage);
</code></pre>
<p>Etc...</p>
<p>I'd love the help if possible! </p>
<p>Kind regards,
Shannon</p>
| jquery | [5] |
3,723,901 | 3,723,902 | benchmarking code in php | <p>I have some php code,</p>
<p>Something in the code (a large portion of code) is causing the page to take upwards of 30 seconds to load,</p>
<p>Is there an easy way to find out what part of the code is doing this?</p>
| php | [2] |
283,809 | 283,810 | Open Add Contact Screen with names already set | <p>I'm trying to open the 'Add Contact' screen via intent, and I want it with the names alread set, I mean, the first name and the family name.</p>
<p>For that, I'm trying to do this:</p>
<pre><code> Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.NAME, "My Name");
intent.putExtra(ContactsContract.Intents.Insert.PHONETIC_NAME, "Family Name");
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "12345"));
activity.startActivityForResult(intent, 2);
</code></pre>
<p>In this case, the second field in the 'Add Contact' screen keeps empty, and a new field appears with the string "Family Name", that's because I've set the PHONETIC_NAME.</p>
<p>What I want to know is, how do I add the family name value to the second field in 'Add Contact' screen?</p>
<p>Thanks in advance.</p>
<hr>
<p><strong>I've searched for this <a href="http://stackoverflow.com/questions/7545609/how-to-add-a-contact-with-first-name-and-last-name-via-intent">question</a> but it doesn't solve. It uses some kind of vCards. I dont know anything about it, if this is the right way to implement this, please explain me better how it works and how to use it.
Thanks</strong></p>
| android | [4] |
5,248,928 | 5,248,929 | destructor is never called | <p>sorry for my inattension, in short the <code>~CSArray()</code> is work, but interface and implementation of the class there was in different files, so mistake is here </p>
| c++ | [6] |
4,162,605 | 4,162,606 | How to draw a dynamic line graph in Android ? | <p>I've got a requirement for my application is to draw a line graph that can be changed on the fly. Eg. A heartbeat graph, a graph that represents the temperature etc..</p>
<p>How can I achieve this in a non-JS way on android?</p>
| android | [4] |
5,534,409 | 5,534,410 | How to get Interent speed in android? | <p>I am using SOAP Parser in my programme.But some time is Internet very slow.So i need to check the internet speed . Please can give me some code. Even i was use 2G and 3G and wifi also.</p>
| android | [4] |
1,730,727 | 1,730,728 | What does this Javascript code mean? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2851404/what-does-options-options-mean-in-javascript">What does “options = options || {}” mean in Javascript?</a> </p>
</blockquote>
<p>Looking at the YouTube source...</p>
<pre><code>var yt = yt || {};
</code></pre>
<p>Does that mean.. set <code>yt</code> to <code>yt</code> if <code>yt</code> exists, else create a new object?</p>
<p>If that's the case, I didn't think you can put a condition when declaring a variable.</p>
| javascript | [3] |
2,198,169 | 2,198,170 | What am I doing wrong with this simple javascript? | <p>I have the following code: <a href="http://jsfiddle.net/LvdcU/3/" rel="nofollow">http://jsfiddle.net/LvdcU/3/</a></p>
<p>I don't understand why I keep getting the following error:</p>
<blockquote>
<p>Uncaught ReferenceError: updatetotalorderCals is not defined</p>
</blockquote>
<p>I'm sure this has everything to do with my limited js knowledge.</p>
<p><strong>UPDATE:</strong></p>
<p>So the original example error has been resolved, but when applying it to my real-world code, the error returns. I've update jsFiddle with all of the applicable code: <a href="http://jsfiddle.net/LvdcU/8/" rel="nofollow">http://jsfiddle.net/LvdcU/8/</a>, (probably more than necessary this time) in hopes of getting this working. Thanks!</p>
| javascript | [3] |
1,622,889 | 1,622,890 | Function gets defined although code block is not executed | <p>I use the following code to use <a href="http://jsgettext.berlios.de/" rel="nofollow">JS Gettext</a> if the language is German.</p>
<pre><code>if (lang == "de") {
var gt = new Gettext({"domain": "tag_cloud", "locale_data": json_de_data});
function _(ident) {
console.debug('gt.gettext("'+ident+'")');
return gt.gettext(ident);
}
console.debug("Using Gettext.");
}
else {
function _(ident) {
console.debug('return "'+ident+'"');
return ident;
}
console.debug("Using no translation.");
}
</code></pre>
<p>In Firefox, the console shows:</p>
<pre><code>Using Gettext.
gt.gettext("Ubiqitous, but effective.")
</code></pre>
<p>In every other browser (Chromiun, Opera, IE, rekonq, Safari), I get this:</p>
<pre><code>Using Gettext.
return "Ubiqitous, but effective."
</code></pre>
<p>I tried to remove the <code>else</code> block and that worked in all browsers then, just not for English.</p>
<p>So is the latter <code>_()</code> defined although the <code>else</code> block is not executed? How can I make this work in all browsers?</p>
| javascript | [3] |
4,562,325 | 4,562,326 | android string gallery can't display from beginning of the screen | <p>i had creating string gallery but android string gallery can't display from beginning of the screen. it displayed. any solution?? </p>
<p>thanks inn advance.</p>
<pre><code>private Context cont;
private String [] stringid=new String[]{"Index-Nifty","Positional calls","Intraday calls","InvestmentIdea","Optional calls","BTST-STBT calls"};
public TabGallary(Context c) {
cont = c;
}
public int getCount(){
return stringid.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
TextView view = new TextView(cont);
//Fixing width & height for String to display
view.setLayoutParams(new Gallery.LayoutParams(125, 20));
view.setSoundEffectsEnabled(true);
view.setText(stringid[position]);
view.setSingleLine();
Intent intent = new Intent();
startActivity(intent);
return view;
}
private void startActivity(Intent intent) {
// TODO Auto-generated method stub
}
</code></pre>
| android | [4] |
5,475,233 | 5,475,234 | Is this illegal syntax? | <pre><code><script type="text/javascript" language="JavaScript">
<!--
alert('foo');
//-->
</script>
</code></pre>
<p>It's used all over in my company's grails app, but I know <code><</code> is an illegal javascript character...</p>
<p>Should the <code><!--</code> be like <code>//<!--</code> instead?</p>
| javascript | [3] |
2,325,509 | 2,325,510 | Fill ComboBox Dynamically in asp.net.. help required | <p>The Scenario which i have thought and which i want to do is that I have 2 combo boxes.. One of Country and One of Cities.. On Page Load, Country Combo box must be filled with the corresponding values present in the Database and at that time My Cities Combo box should be hidden.. By selecting the Country from the Filled Country Combo Box, the hidden Combo Box that is the Cities Combo Box visible to true and filled with those cities that the user selected the country from the country combo box... </p>
<p>Can any one help me with that? </p>
| asp.net | [9] |
4,236,660 | 4,236,661 | Strang behavior with Android ListView footer click - delayed and or misordered firing | <p>The click event associated with the ListView footer sometimes takes a long time to fire, especially after extensive scrolling has taken place. The regular list item clicks always fire immediately. Stranger still, when a regular item is clicked while the footer click is still waiting to process, it will fire immediately, and after it is done the footer click will immediately execute (the clicks execute in the wrong order).</p>
<p>Any feedback greatly appreciated.</p>
<pre><code>private void init()
{
...
// I attach a footer to this ListActivity instance like so...
LayoutInflater inflater = ((LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE));
mFooterView = inflater.inflate(R.layout.row_feed_footer, null, false);
// Add click handler to footer
mFooterView.findViewById(R.id.feed_footer_layout).setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
onFooterClick(v);
}
});
getListView().addFooterView(mFooterView);
// Register with my custom adapter
setListAdapter(mFeedData);
}
private void onFooterClick(View footerView)
{
// After extensive scrolling, this event will take a long time to fire (as long as 5 seconds).
// Unless onListItemClick, in which case it will fire immediately after
}
@Override
protected void onListItemClick(ListView l, View v, int position, long reportSeqNo)
{
// After extensive scrolling, this event will still fire immediately
}
</code></pre>
| android | [4] |
1,366,314 | 1,366,315 | Keeping only a certain line and deleting the rest in C# | <p>I was wondering if anyone could give me a quick example of how to do this. What I want to do is parse a .txt file and delete everything but lines containing "Type: Whisper", is there any way to achieve this with relative ease?</p>
| c# | [0] |
2,002,602 | 2,002,603 | Chat app vs REST app - use a thread in an Activity or a thread in a Service? | <p>In Virgil Dobjanschi's talk, "Developing Android REST client applications" (link <a href="http://code.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html#" rel="nofollow">here</a>), he said a few things that took me by surprise. Including:</p>
<ul>
<li><p>Don't run http queries in threads spawned by your activities. Instead, communicate with a service to do them, and store the information in a ContentProvider. Use a ContentObserver to be notified of changes.</p></li>
<li><p><em>Always</em> perform long running tasks in a Service, never in your Activity.</p></li>
<li><p>Stop your Service when you're done with it.</p></li>
</ul>
<p>I understand that he was talking about a REST API, but I'm trying to make it fit with some other ideas I've had for apps. One of APIs I've been using uses long-polling for their chat interface. There is a loop http queries, most of which will time out. </p>
<p>This means that, as long as the app hasn't been killed by the OS, or the user hasn't specifically turned off the chat feature, I'll never be done with the Service, and it will stay open forever. This seems less than optimal. </p>
<p>Long question short:</p>
<p><b>For a chat application that uses long polling to simulate push and immediate response, is it still best practice to use a Service to perform the HTTP queries, and store the information in a ContentProvider?</b></p>
| android | [4] |
2,752,145 | 2,752,146 | grouped table view like iphone contacts | <p>I'm new to Xcode and I'm trying to create an app which has a tableview. Ideally it should look pretty similar to the standard contacts app on iphone/ipod touch. So the tableview should show the names of my friends, and the detail view should show address, email, phone number and a picture etc. The only difference is that the user shouldn't be able to edit the adresses. So it's more like a directory. I would like to do this with a .plist-file as I don't want to create 200 detailviews......I've already watched a dozen tutorials on tableviews, but none of them is close enough to what I'm looking for.... Can anyone explain me how to do this? Or do you have a tutorial on this?</p>
| iphone | [8] |
4,699,561 | 4,699,562 | JQuery Qtip not working in IE | <p>I am using the QTIP plugin to create a tool tip over some text. It works great in firefox but not in IE. my code for the page looks like this</p>
<pre><code><script type="text/javascript">
$(document).ready( function() {
$("#label_PERSONAL").qtip({
content: 'this is a test!',
show: 'mouseover',
hide: 'mouseout'
});
});
</script>
<div id="main">
<label id="label_PERSONAL">Personal Inforamtion</label>
</div>
</code></pre>
| jquery | [5] |
2,264,554 | 2,264,555 | How can I create online support like this link (in Persian sayed سایت همسریابی)? | <p>How can I create online support like that of <a href="http://www.hamsaronline.com/contactus/default.aspx" rel="nofollow">this site</a>?</p>
| asp.net | [9] |
2,901,789 | 2,901,790 | How do I make a draggable appear in a div after some event? | <p>i am making a game like monopoly, there are some chess which are draggables on the game board,</p>
<p>when some event happens, they will be prisoners and needed to go to a div as jail.</p>
<p>Does anyone have an idea of how to do it? Sorry for my English.</p>
| jquery | [5] |
4,325,407 | 4,325,408 | When creating a model in Django why does the class inherit models.Model instead of just Model? | <p>I am having trouble understanding inheritance in django models</p>
<p>If I create a model in django:</p>
<pre><code>from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
</code></pre>
<p>Can't I just I write</p>
<pre><code>class Person(Model):
</code></pre>
<p>Since I already imported models and I am trying to inherit Model. Is Model a subclass of models? Also can I write the below, since I have imported models already.</p>
<pre><code> name = CharField(max_length=200)
</code></pre>
| python | [7] |
5,082,513 | 5,082,514 | Which is the first method called when Java executes a program? | <p>I am learning core Java and I have one question, "Which is the first method called when the program is executed?"</p>
| java | [1] |
1,261,066 | 1,261,067 | To return first on error or on success | <p>Every day I always come across this dilemma - is it best practice to check for an undesired state at the start of a function and return straight away or, is it best practice to check for a desired condition and continue else return false.</p>
<p>I understand that there wont be a 1 fits all solution and that this is really a style issue but I am just interested in what other developers would typically do.</p>
<p>I always find my self being indecisive every time this situation comes up.</p>
<p>As an example (coded in php):</p>
<p>Check for the undesired condition first...</p>
<pre><code>function myFunction($myVal)
{
if ($myVal != 'desiredVal') {
return false;
}
//Continue here with main function code
return true;
}
</code></pre>
<p>Or, check for the desired condition first...</p>
<pre><code>function myFunction($myVal)
{
if ($myVal == 'desiredVal') {
//continue here with main function code
return true;
}
return false;
}
</code></pre>
| php | [2] |
4,701,697 | 4,701,698 | Graphics on Android: path with smooth curves? | <p>I want to draw a chart for a function y=x^2 as follows:</p>
<p><img src="http://i.stack.imgur.com/c8fVa.png" alt="enter image description here"></p>
<p>but the curve is not smooth as it is a set of connected lines.</p>
<p>how can I make the curve smoother ?</p>
<p>thanks</p>
| android | [4] |
1,410,251 | 1,410,252 | Pass string value from broadcast receiver to a service | <p>I want to pass a string value from broadcast receiver to a service.If someone could please illustrate with an example.
thanks</p>
| android | [4] |
511,046 | 511,047 | assigning variables from $key and $value for all objects in the array | <p>I have a function that I need to pass 4 distinct variables to, and these variables values come from an array:</p>
<pre><code>$pagesArray = array(
'pre-file1.html' => 'blahblah1',
'post-file1.html' => 'blahblah2'
);
$file1 = 'blahblah1';
$file2 = 'blahblah2';
$file1Name = 'pre-file1.html';
$file2Name = 'post-file1.html';
</code></pre>
<p>How do I assign in a <code>foreach</code> loop when I'm calling the function in the loop too?</p>
<p>I've tried this</p>
<pre><code>foreach ($pagesArray as $fileName => $url)
{
$file1 = file($url);
$file2 = file($url);
$file1Name = $key;
$file2Name = $key;
compareFiles($file1, $file2, $file1Name, $file2Name);
}
</code></pre>
<p>But that doesn't work because it's calling the function in the loop and will only loop over after it's called every time.</p>
<p>NB: the above is only an example, there will be more objects in that array than the two currently shown.</p>
| php | [2] |
1,293,261 | 1,293,262 | jQuery how to select children elements the proper way | <p>If I have the following html</p>
<pre><code><div id="parent">
<div id="item1"></div>
<div id="item2"></div>
<div id="item3"></div>
</div>
</code></pre>
<p>What would be the proper way to select children of the parent div.</p>
<p>I have the following:</p>
<pre><code>var $parent = $('#parent'),
$item1 = $('#item1',$parent),
$item2 = $('#item2',$parent),
$item3 = $('#item3',$parent);
</code></pre>
<p>or if</p>
<pre><code>var $parent = $('#parent'),
$item1 = $parent.find('#item1'),
$item2 = $parent.find('#item2'),
$item3 = $parent.find('#item3');
</code></pre>
<p>is more correct. From my tests I think they both work, but just wondering what the standard convention is for this.</p>
<p>The reason I do not use a more direct single selector like $('#parent #item1') is the parent could change, or could be selected from a callback function, and I want to be able to select its children without directly knowing the id of the parent, but rather using a jquery object of the parent.</p>
| jquery | [5] |
4,637,033 | 4,637,034 | SharedPreferences from different activity | <p>I load from activity A the SharedPreferences in following way:</p>
<pre><code>private void SavePreferences(String key, String value){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(key, value);
editor.commit();
}
</code></pre>
<p>At activity B I want to load the SharedPreferences. Following was a NullPointerException:</p>
<pre><code> private void LoadPreferences(){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
data = sharedPreferences.getString("name", "08:00") ;
}
</code></pre>
<p>If I try following, I get this compilation error: "No enclosing instance of the type A is accessible in scope"</p>
<pre><code> private void LoadPreferences(){
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(A.this);
data = sharedPreferences.getString("name", "08:00") ;
}
</code></pre>
<p>How can I access the data?
Thanks in advance!</p>
| android | [4] |
2,413,594 | 2,413,595 | Tracking mouse motion during click with JQuery | <p>How do you track mouse motion after mousedown until mouseup using JQuery? Tracking should start when some target element is clicked and continue to mouseup, even when the mouse moves out of the target element.</p>
<pre><code><div id="some_elt">
<div id="target">
</div>
</div>
</code></pre>
<p>The only way I can think of is binding <code>mousemove</code> to the whole document and invoking my motion handler based on a global flag I set from <code>$("target").mousedown</code> and unset from<code>$("target").mouseup</code>.</p>
<p>Is there a more elegant approach than this?</p>
<p><b>Edit:</b> I think I need to add an extra bit... my target already has <code>draggable()</code> applied to it. I'm trying to make a decent image viewer. I have a viewport <code>div</code> containing a draggable <code>img</code>. I'm trying to do make the image zoomable with something like shift+middle-click, without interfering with the draggable for navigating. Am I going to have to piggyback on stuff that JQuery does under the hood to make draggable work?</p>
<p><b>Edit2:</b> To answer my edit: of course not! JQuery is awesome!</p>
| jquery | [5] |
5,348,821 | 5,348,822 | Zipping a byte[] from a txt file | <p>I need to read a txt file, convert it from UTF8 to ISO8859-1 and store the textfile into a zip.</p>
<p>This is what i got so far:</p>
<pre><code>Charset utf8charset = Charset.forName("UTF-8");
Charset iso88591charset = Charset.forName("ISO-8859-1");
File file_in = new File("Input/file1.txt");
File file_out = new File("Output/file_out.txt");
try {
FileInputStream fis = new FileInputStream(file_in);
BufferedInputStream bis = new BufferedInputStream(fis);
byte fileContent[] = new byte[(int)file_in.length()];
bis.read(fileContent);
ByteBuffer bb = ByteBuffer.wrap(fileContent);
CharBuffer data = utf8charset.decode(bb);
ByteBuffer outputBuffer = iso88591charset.encode(data);
byte outputData[] = outputBuffer.array();
FileOutputStream fos = new FileOutputStream(file_out);
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(outputData);
bos.close();
} catch ...
</code></pre>
<p>Do I have to create the txt file, read it again and zip it den with ZipOutputStream?
Or is there a way to use the byte[] of the txtfile to create the zip??</p>
| java | [1] |
5,678,060 | 5,678,061 | Python:: Turn string into operator | <p>How can I turn a string such as "+" into the operator plus? Thanks!</p>
| python | [7] |
3,213,202 | 3,213,203 | Data Sharing between android and personal computer | <p>I like to make an android app which helps the user to share and send data from application to pc. How i can start doing this. Please help</p>
<p>Regards
Mohammed Suhail.</p>
| android | [4] |
4,134,088 | 4,134,089 | iPhone - custom UIImagePickerController | <p>I am showing a UIImagePickerController in an app that just works with videos. So, it is nonsense to show pictures to users.</p>
<p>I have changed all properties I see on the controller but the picker shows like the next picture.</p>
<p>Two questions:</p>
<ol>
<li>How do I get rid of this choice and show just the Photo Library, without having to tap first to get there.</li>
<li>As far as I know, all videos shot with iPhone end on camera roll. Suppose the iPad gets a camera in the future. Does this Photo Library option include the camera roll or what?</li>
</ol>
<p>thanks in advance.</p>
<p><img src="http://i.stack.imgur.com/EDM4l.png" alt="enter image description here"></p>
| iphone | [8] |
5,395,934 | 5,395,935 | in which file can i change the value of magic_quotes_gpc = 0 in PHP | <p>In which file can I change the value of </p>
<pre><code>magic_quotes_gpc = 0
</code></pre>
<p>in PHP?</p>
<p>Thanks in advance.</p>
| php | [2] |
4,562,221 | 4,562,222 | Position views at specific location? | <p>Is there a way to place widgets / views on the screen at any specific position required?</p>
<p>Something like a calendar with daily events that could overlap.
e.g. if every hour in a day is represented by 1 hour and there are 2 appointments that overlap partially (say 12:00 - 12:30 and 12:20 - 01:00) this would be drawn in the same row but the 12:20 one positioned slightly below the first.</p>
<p>Also there may be views (Image/TextView) that need to span 2 rows (i.e. 12:30 - 1:30).</p>
<p>I think a SurfaceView is one option (is this efficient?) but am not sure if there is some better layout that could be used.</p>
<p>We could use a TableLayout for the hour rows but not sure if there is a way to place overlapping widgets on this?</p>
<p>TIA</p>
| android | [4] |
877,407 | 877,408 | Removing/Adding Querystring in Window.Location.Href using JQuery | <p>I am using JQuery and stuck with one issue and need your help and guidance.</p>
<p>I want to do below three points in my current <code>window.location.href</code>:</p>
<ol>
<li><p>I want to add <code>?mode=ssl</code>, if we don't have any querystring in my <code>window.location.href</code></p></li>
<li><p>I want to append <code>&mode=ssl</code>, if there is any querystring in my <code>window.location.href</code></p></li>
<li><p>I want to remove <code>logout</code> querystring from <code>window.location.href</code>, if present,
and then add <code>mode=ssl</code> to <code>window.location</code>.</p></li>
</ol>
| jquery | [5] |
1,350,329 | 1,350,330 | Is there any online python exercise? | <p>I am teaching a colleague Python and I think he should do some exercises.</p>
<p>Is there any online available other than python challenge? I feel that python challenge is puzzles, not exercises.</p>
| python | [7] |
1,801,161 | 1,801,162 | Why doesn't this throw a SyntaxError instead of silently interpreting it wrong? | <p>There is supposed to be a comma between these two strings</p>
<pre><code>foo = ['dumb'
'error']
</code></pre>
<p>But if you forget the comma, it just merges the strings together instead of producing a syntax error. Your result will be </p>
<pre><code>['dumberror']
</code></pre>
<p>I spent hours tracking this down. Why is the Python interpreter merging these strings?</p>
| python | [7] |
3,120,752 | 3,120,753 | Append hidden type of input tag within ASPX? | <p>I want to have a hidden <code>input</code> tag in my HTML page , so i tried the following:</p>
<p><code><input type=hidden runat=server id=currentItem value="runtime_determinted" /></code></p>
<p>But it won't got displayed on client , so I can't find it with javascript.</p>
<p>If the the tag isn't run at server side , I will have to append it to the end of the document , but which function should I use ?</p>
<p>Or is there any other solutions suitable ?</p>
| asp.net | [9] |
173,485 | 173,486 | jquery wait till previous function call ends | <p>Please refer the below called function in our project.</p>
<pre><code> var obj; // this will modified in A() function
function c()
{
A();
B(obj);
}
function A()
{
for(i=0;i < object.length; i++)
{
if(object.data.toString()=="remote data")
processRemoteData();
else
processData();
}
}
function processRemoteData()
{
$.ajax({
url://remote url
success:function(data)
{
// set this remote data in some object that will be passed in b function
}
});
}
function processData()
{
//process data
}
</code></pre>
<p>am going to pass the obj (object) in B() function which will be modified in A() function or which will be set in A() function. but A() function noting returned.</p>
<p>i want to wait A() function to fetch either remote data or normal data until B() function never going to start. because based on the object modified in A() function am going to process in B() function.</p>
<p>but in my scenario A() function never waits until its fetch the data from remote URL, it starts B() function immediately.</p>
<p>i have tried like that </p>
<pre><code>$.when(A()).done(function()
{
B();
});
</code></pre>
<p>this also not working and then i approached $.deferred that means </p>
<pre><code>function A()
{
var def= $.deferred();
//process
return def.promise();
}
</code></pre>
<p>but this kind of approach also not working fine for me since A() function never waits until it completes the callback function and then start B()</p>
<p>Thanks,</p>
<p>Siva</p>
| jquery | [5] |
4,229,454 | 4,229,455 | format-bar for UITextView | <p><img src="http://i.stack.imgur.com/AlVFp.jpg" alt=""></p>
<p>how can i add or program this format bar or kind of similar thing my code?? any one have idea about this?? </p>
| iphone | [8] |
5,898,084 | 5,898,085 | Remember me checkbox dont save the username and pass when open the app again | <p>remembered password means if i enter the username and password then enabled the remember password checkbox means it is successfully login.then i clicked logout means it is loggedout.
but again i open app the username and password is displayed on d edittext know...
but when i loggedout on my app is loggedout afterthat again i open d app means the username and password are not saved.
here's my code :</p>
<pre><code> myPrefs = this.getSharedPreferences("myPrefs",MODE_PRIVATE);
user=myPrefs.getString(PREF_USERNAME, "username");
pass=myPrefs.getString(PREF_PASSWORD, "password");
checked=myPrefs.getString(PREF_CHECKED, "TRUE");
SharedPreferences sp1=this.getSharedPreferences(PREFS_NAME,MODE_PRIVATE);
userName=sp1.getString(PREFS_NAME , null);
password = sp1.getString(PREF_PASSWORD, null);
loginButton.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(passwordEditText.getWindowToken(),
0);
Data.LANGUAGE = "1";
String username = ar_EditText.getText().toString().trim();
String password = passwordEditText.getText().toString().trim();
if(CBox.isChecked()){
getSharedPreferences(PREFS_NAME,MODE_PRIVATE).edit().putString(PREF_USERNAME,userName).putString(PREF_PASSWORD,password).putString(PREF_CHECKED,"TRUE")
.commit();
}else
{
getSharedPreferences(PREFS_NAME,MODE_PRIVATE).edit().clear().commit();
}
</code></pre>
| android | [4] |
5,551,386 | 5,551,387 | Redundant thumbnails are loaded when a video doesnt has a thumbnail using async tasks | <p>I am using async task for loading thumbnails. For videos which have thumbnails in database are loaded properly. But the video which doesnt have thumbnail are loaded with random thumbnails (the previous video thumbnail). </p>
<pre><code> final Bitmap immutableBMap =
MediaStore.Video.Thumbnails
.getThumbnail(mCr,
mContentId,
MediaStore.Video.Thumbnails.MICRO_KIND, null);
Bitmap mutableBMapOrig = Bitmap.createScaledBitmap(immutableBMap, 118, 90 ,
true);
</code></pre>
<p>The mutableBMapOrig iam setting on my thumbnailview. If it is null i am setting with a default image from my resources</p>
<pre><code> mImageView.setImageDrawable(r.getDrawable(R.drawable.default_image));
</code></pre>
<p>I hv tried generating thumbnail like below</p>
<pre><code> ThumbnailUtils.createVideoThumbnail(mContentPath,
MediaStore.Images.Thumbnails.MICRO_KIND);
</code></pre>
<p>Basically something is happening inside the thread only if iam correct ?</p>
<p>Please help me. </p>
| android | [4] |
386,668 | 386,669 | JQuery: tying to use .html() but the new content takes on link characteristics of the original selector/element | <p>I have four links and I would like content to appear in a div(.contentcont [name of div]) below the list of links for that particular link that was clicked. </p>
<pre><code>$('.link1').click(function(e){
$(this).clone().html('<h1>Text appear</h1>')
.appendTo('.contentcont')
e.preventDefault();
});
</code></pre>
<p>I am using .html() to provide the content to be entered into the div. If you take a look at the js fiddle provided( <a href="http://jsfiddle.net/jack2ky/K3FaY/2/" rel="nofollow">http://jsfiddle.net/jack2ky/K3FaY/2/</a>) you will be able to see that the new content is appearing in the div but it's taking on the characteristic of the link [no good]. Maybe it has to do with me using .clone(). The reason why I am using .clone() is because when ever I clicked on the link the link would disappear. maybe you can tell me if using .clone() was the right solution to use to prevent the link from disappearing. And if you could explain why the new content is taking on the link characteristic that would be greatly appreciated.
Thank you in advance for your help. </p>
| jquery | [5] |
3,632,324 | 3,632,325 | I want my app to be installed only in tablet | <p>I have an android application. I need to upload in the android market. I have developed this app in "Honeycomb".This app is only for android tablets. <em>I designed the layouts for tablets only (600x1024).</em> I want this app to install only in tablets from android market and not in android phones. I really don't know how to do this..? Do i have to check programmatically..? if so, how to do that..? <strong>My intention is that only tablets can install my app..! Please share your valuable suggestions..!</strong> </p>
| android | [4] |
5,420,507 | 5,420,508 | Nested quotes and variable concatenation | <p>I'm struggling with a complex nested quotes statement here :</p>
<pre><code>var name = "foo";
$("#list").append("<li data-theme='c'><a href='#details' onclick='sessionStorage.name=PRINT_VAR_NAME_HERE;' data-transition='slide'>PRINT_VAR_NAME_HERE</a></li>");
</code></pre>
<p>I am able to print the variable's value fine in the <strong>second</strong> position by using : "+name+"</p>
<p>But not sure how to get it done in the <strong>first</strong> position.</p>
<p>(I have used 'PRINT_VAR_NAME_HERE' as a placeholder for the first and second positions)</p>
<p>Any ideas ? Thanks.</p>
| javascript | [3] |
4,573,309 | 4,573,310 | Encoding Bytes in Python3 | <p>What type of codec is the best to encode binary files what are upload to an app write in Python 3?</p>
| python | [7] |
3,640,174 | 3,640,175 | The call sequence of the Constructors between Derived Class and base class | <p>I've known that if B is derived from A, then when I create a new object of B, for example b, the constructor of A will call first. When I destroy the object b, The destructor of B will call first. Then I have a question here, if there're more than one constructor in the Base class, which constructor will call ? and why?</p>
<p>I've write one test program below, I guess it will call the default constructor in the Base class, But I'm not sure if it is just a coincidence?</p>
<pre><code>#include <iostream>
using namespace std;
class A{
public:
A(int i){cout<<"A con with param"<<endl;}
A(){cout<<"A con"<<endl;}
~A(){}
};
class B : public A
{
public:
B(int i){cout<<"B con with param"<<endl;}
B(){cout<<"B con"<<endl;}
~B(){}
};
int main()
{
B b(5);
return 0;
}
</code></pre>
<p>I wonder if any boss can tell me the reason or any advise to figure out this problem?</p>
| c++ | [6] |
1,714,301 | 1,714,302 | Enter Event to move to another textbox | <p>how I can move cursor from textbox to another when I press Enter key.</p>
<p>I know how to do that by tab key.</p>
<p>I wish if someone help me.</p>
| c# | [0] |
3,056,210 | 3,056,211 | To get the index of the TR | <p>I need to find out the position of the TR.</p>
<p>actually i got the index of the TD which is 291,
But i need to get the index of the TR contains the TD.</p>
<p>We can get the innerHTML by document.getElementsByTagName("td")[291].parentNode.innerHTML..</p>
<p>How to get the index of that parentNode i mean the TR..</p>
<p>Please help me</p>
| javascript | [3] |
2,640,393 | 2,640,394 | How do I write my script for each link I want to redirect | <p>So I'm trying to redirect users from html links and element id tags, to other pages with javascript. I've figured out how to do one singular redirect but having trouble writing the code for multiple links heres what I have so far:</p>
<p>HTML:
</p>
<pre><code><head>
<script type = "text/javascript" src="script2.js"></script>
</head>
<body>
<a href="nickname.html" id="redirect1">NickName</a>
<a href="salestax.html" id="redirect">Salestax</a>
<a href="http://www.w3schools.com" id="redirect2">W 3 Schools</a>
</body>
</html>
</code></pre>
<p>My external script so far for just one link:</p>
<pre><code>window.onload = initAll;
function initAll() {
document.getElementById("redirect").onclick = initRedirect;
}
function initRedirect() {
confirm("Go to Salestax page?");
window.location="salestax.html";
return false;
{
</code></pre>
<p>Do I just crank out more functions and change the location value, getElementById value and the onclick value?</p>
| javascript | [3] |
5,698,274 | 5,698,275 | Get Substring - everything before certain char | <p>I'm trying to figure out the best way to get everything before the - character in a string. Some example strings are below. The length of the string before - varies and can be any length</p>
<pre><code>223232-1.jpg
443-2.jpg
34443553-5.jpg
</code></pre>
<p>so I need the value that's from the start index of 0 to right before -. So the substrings would turn out to be 223232, 443, and 34443553</p>
| c# | [0] |
5,097,558 | 5,097,559 | how to make a drawing buffer in java | <p>I'm new to java. and I want to create a game like snake. How can I make a drawing buffer java, where I can draw all the images? Like the background images, the objects such as the snake, etc.</p>
<p>Please advise.</p>
<p>Many thanks.</p>
| java | [1] |
628,811 | 628,812 | Java DecimalFormat.format does not format the number? | <p>I have the method below, but for some reason it is not formatting the area to have only one decimal. All help is appreciated.</p>
<pre><code>public double beraknaArea()
{
DecimalFormat formatter = new DecimalFormat("#0.0");
double area = 0;
area = radie*radie*3.14;
formatter.format(area);
return area;
}
</code></pre>
| java | [1] |
1,070,552 | 1,070,553 | Simple PHP help needed | <p>This is so simple, yet I cannot get my head into the logic.</p>
<p>Have a simple online form. Want to be able to adjust a variable after submitting. </p>
<p>If anyone can shed light on this one, would be really super appreciative!</p>
<pre><code>$chocolatebar = $HTTP_POST_VARS['chocolatebar'];
if $chocolatebar = "a" then we want to change the value to "snickers";
if $chocolatebar = "b" then we want to change the value to "mars";
if $chocolatebar = "c" then we want to change the value to "cherry ripe";
</code></pre>
| php | [2] |
1,679,453 | 1,679,454 | boost::static_visitor with multiple arguments | <pre><code>typedef boost::variant<int, double> Type;
class Append: public boost::static_visitor<>
{
public:
void operator()(int)
{}
void operator()(double)
{}
};
Type type(1.2);
Visitor visitor;
boost::apply_visitor(visitor, type);
</code></pre>
<p>Is it possible to change the visitor such that it receives extra data as follows:</p>
<pre><code>class Append: public boost::static_visitor<>
{
public:
void operator()(int, const std::string&)
{}
void operator()(double, const std::string&)
{}
};
</code></pre>
<p>This string value changes during the lifetime of the Append object. Passing the string in via the constructor is not an option in this case.</p>
| c++ | [6] |
746,756 | 746,757 | How to write a AVI decoder in a windows dialog using OpenGL,C++? | <p>How to show AVI files in a windows dialog using OpenGL,C++?</p>
| c++ | [6] |
361,501 | 361,502 | Last tweets within android activity | <p>I'm fairly new to android development and need to create an android app where in the bottom half of the screen it will be in list view displaying the last 2 tweets of a user.</p>
<p>As I'm new to android and API's I've looked everywhere for an easy to follow tutorial but none really do what I need. Any ideas?</p>
<p>Kind Regards</p>
<p>Ben</p>
| android | [4] |
3,264,066 | 3,264,067 | localscroll: How to fire event after scroll | <p>Hi I am using localscroll and it has an option to fire a function before the scroll takes place by using the onBefore parameter but there doesn't seem to be one for after the animation. Does anyone know how you can do it?</p>
| jquery | [5] |
3,150,489 | 3,150,490 | Add the elements of $b to the end of array $a in php | <p>I have 2 arrays.
I want to add the elements of $b to the end of $a. I checked google, nothing.</p>
<pre><code>$a=array(1,2,3);
$b=array(4,5,6);
array_push($a,$b);
print_r($a);
</code></pre>
<p>My goal is to make $a=(1,2,3,4,5,6) but the above doesn't work correctly...any ideas?</p>
| php | [2] |
1,769,900 | 1,769,901 | When I recieve a multipart data consisting of more than one image in HttpWebresponse. How do I parse the data to get the images? | <p>The data looks like --myboundary
Content-Type:image/jpeg
X-Status: 100
X-Timestamp: 1309285690
Content-Transfer-Encoding: BASE64
Content-length:25900</p>
<p>/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAB4AKADASIAAhEBAxEB/
--myboundary
Content-Type:image/jpeg
X-Status: 100
X-Timestamp: 1309285870
Content-Transfer-Encoding: BASE64
Content-length:25756</p>
<p>/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH
......</p>
<p>What is the best way to read this data.</p>
| c# | [0] |
1,661,700 | 1,661,701 | JavaScript function keyword appears to be preparsed when used declaratively? | <p>I just discovered that the following code executes without error (Chrome):</p>
<pre><code>console.log(fa);
function fa(){}
</code></pre>
<p>I was under the impression that:</p>
<pre><code>function fa(){}
</code></pre>
<p>was identical to:</p>
<pre><code>var fa = function(){};
</code></pre>
<p>My assumption had led me to believe that my code block above should have resulted in an error due to <code>fa</code> not having been declared before it was called. The second form however, when used in my code sample above, will produce an error because <code>fa</code> has not been defined yet when the first line runs.</p>
<p>Is there some documentation or information somewhere that covers the fact that the <code>function</code> keyword, when used declaratively, is preparsed, thus exposing said function in advance of the actual order of operation of the lines of code in a script?</p>
| javascript | [3] |
662,845 | 662,846 | How do I round 4.3 to 4.5 | <p>Given a value that has 1 decimal place, how do I round that decimal place up a half step? </p>
<p>If I have a value of, say, <code>4.3</code>, how do I round that in PHP to <code>4.5</code>?</p>
<p>Other examples would be:</p>
<pre><code>3.8 >> 4.0
2.1 >> 2.5
0.9 >> 1.0
</code></pre>
<p>Also I should mention that I am running PHP version 5.2.17</p>
<p>Thanks!</p>
| php | [2] |
4,555,845 | 4,555,846 | getting error for ambiguous symbol and need help to remove it | <p>i am getting this error which i unable to remove in visual studio 2010. i am using one third party library which uses its own definition for "string" Also visual studio's xstring file is there in the folder where it gets installed. now when i am trying to compile code i am getting following error</p>
<p>1>...\xyz.cpp(24): error C2872: 'string' : ambiguous symbol
1> could be 'third party library path\string.h(31)
1> or 'c:\program files (x86)\microsoft visual studio 10.0\vc\include\xstring(2063) : std::string'</p>
<p>compiler is not able to understand which string definition it should use. How can i remove this error in visual studi 2010. I want the code to use third party string definition.</p>
<p>i tried to set third party path in include directory but still i am seeing this error.
Please help me. Thanks in advance</p>
| c++ | [6] |
65,766 | 65,767 | C#, Component class | <p>In my current project I have been provided with a solution that contains 3 simple classes and 1 component class. There is some code in component class that i need to access in one of my simple class. I am trying to create an instance of component class but there is error that Component class does not exist. Please guide either i am going in wrong direction? If so then how can i solve my problem. How can i access code given in component class. I am working in Visual Studio 2010 and .NET 4.0 with C#.net</p>
<p>Thanks</p>
<p>Khizar</p>
| c# | [0] |
1,531,735 | 1,531,736 | What is the best way to get an image from URL to ImageView in Android | <p>I am using a method to get the Image from URL when a button is clicked but it gets too much time, about 4-5 seconds to show an image sized only 6 kb using 3G not wi-fi. </p>
<p>My method is this;</p>
<pre><code>public static Bitmap getBitmapFromURL(String src) {
try {
Log.e("src",src);
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
Log.e("Bitmap","returned");
return myBitmap;
} catch (IOException e) {
e.printStackTrace();
Log.e("Exception",e.getMessage());
return null;
}
}
</code></pre>
<p>and then;</p>
<pre><code> Bitmap bimage = getBitmapFromURL("http://www.replikler.net/test2.jpg");
ImageView image = (ImageView)findViewById(R.id.movie_image);
image.setImageBitmap(bimage);
</code></pre>
<p>do you know another way (faster) to get an image from url ?</p>
| android | [4] |
3,806,695 | 3,806,696 | How to assign velocities using a maxwell-boltzmann distribution in Java | <p>I am currently working on a model of gas particles in a container. When I initialise the particles I am currently giving them all the same magnitude of velocity (Varying +/- directions).. I need to find a way to change this so that the velocities follow a maxwell boltzmann distribution.</p>
<p>Does anyone have any idea how to go about this? </p>
| java | [1] |
2,814,325 | 2,814,326 | add something to nametuple | <p>I build</p>
<pre><code>Corpus = collections.namedtuple('Corpus', 'a, b, c, d')
</code></pre>
<p>Read all the files in the corpus and save the data,</p>
<pre><code>def compute(counters, tokens, catergory)
...
counters.stats[tokens][catergory] = Corpus(a, b, c, d)
</code></pre>
<p>Both tokens and catergory are collection.Counter(). After reading all the information in a, b, c, d in counters.stats, I do some calculation in another function and get 'e' for each token. How can I add e into counters.stats in this function?</p>
| python | [7] |
196,462 | 196,463 | How to get the checkboxes dynamically in android? | <p>In my project I need to <strong>display questions and its options</strong>. <strong>Here the options are at max 20 with multiple answers.</strong> The options are not fixed for each question. That means for each question the options may be 2 or 3 or 6 or 18 or 2o. <strong>Since the question contains multiple answers I need to create checkboxes to display options dynamically.</strong> Based on the number of options for the question we need to display the checkboxes. How can I do that? Please help me regarding this.</p>
<p>Thanks in Advance</p>
| android | [4] |
5,771,504 | 5,771,505 | Can't send attachments from application | <p>I am trying to send a PDF from my application but when I tap "Send" it does not get attached it seems. I can see the icon for the file in the mail application though.</p>
<pre><code>Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_SUBJECT, mailSubject);
intent.putExtra(Intent.EXTRA_TEXT, mailMessage);
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///android_asset/download_l.pdf"));
</code></pre>
| android | [4] |
2,321,868 | 2,321,869 | whats is happen to the number of comparisons for selection, insertion, bubble and quick algorithms if the list is already sorted | <p>whats is happen to the number of comparisons for selection, insertion, bubble and quick algorithms if the list is already sorted</p>
| java | [1] |
605,475 | 605,476 | Unsatisfied Link Error when using System.loadLibrary()? | <p>For some reason, I'm getting a pesky Unsatisfied Link Error in my java app.</p>
<p>This is the offender in question:</p>
<pre><code>System.loadLibrary("psjw");
</code></pre>
<p>Despite the library psjw.dll clearly being in the same source package as this class.</p>
<p>Please help.</p>
| java | [1] |
5,745,136 | 5,745,137 | How to return String in anonymous class for a method returning void | <p>I'm bit confused. I have the following:</p>
<pre><code>public static String showInputDialog() {
Form frm = new Form();
final Command cmd = new Command("Ok");
final TextField txt = new TextField("Enter the text", null, 1024, 0);
frm.addCommand(cmd);
frm.append(txt);
frm.setCommandListener(new CommandListener() {
public void commandAction(Command c, Displayable d) {
if (c == cmd) {
return txt.getString(); // Error !!
} else {
return null; // Error !!
}
}
});
}
</code></pre>
<p>As you can see, I want to return the input dialog string, while the anonymous class method should return void. How can I resolve this problem?</p>
| java | [1] |
2,914,062 | 2,914,063 | jQuery If DIV Doesn't Have Class "x" | <p>In jQuery I need to do an if statement to see if $this doesn't contain the class '.selected'.</p>
<pre><code>$(".thumbs").hover(function(){
$(this).stop().fadeTo("normal", 1.0);
},function(){
$(this).stop().fadeTo("slow", 0.3);
});
</code></pre>
<p>Basically when this function is run (on hover) I don't want to perform the fades if the class '.selected' has been appended to the div, this will mean that the image will be at full opacity to signify that it's selected. Searched on Google to no luck even though it's a simple question of how to use an IF statement...</p>
| jquery | [5] |
1,910,763 | 1,910,764 | Terminate child processes spawned by a ProcessBuilder on *nix | <p>I'm executing a shell pipeline from a java program - it'll be something like</p>
<pre><code>ProcessBuilder builder = new ProcessBuilder(
"sh", "-c", "program1 | program2 | program3");
builder.start();
</code></pre>
<p>In some cases this unit might need to be terminated. However</p>
<pre><code>process.destroy();
</code></pre>
<p>Will only destroy the "sh" command. The commands in the pipline will be orphaned and adopted by the init process.</p>
<p>Is there any way to easily terminate all these child processes - or execute a pipeline like the above in a way that makes it easier to terminate them . Altering progam 1/2/3 can't be done. Portability beyond linux is not a issue.</p>
| java | [1] |
295,865 | 295,866 | Storing all JS/CSS in PHP? | <p><strong>Background:</strong> I'm working on a single page web app that loads everything through AJAX and so started learning php a few days ago. I immediately thought of putting everything (html, css, javascript) in php files so that there is only one html file and one sprite request. For instance, external javascript could be stored in:</p>
<p><strong>main.js.php</strong> (adding the .js for organizational purposes only) which would look like:</p>
<pre><code><script>
...
</script>
</code></pre>
<p>or</p>
<pre><code><style>
...
</style>
</code></pre>
<p><strong>Question:</strong> Would storing everything in php be a bad idea? I have OCD and like to have related functions in separate files (and actually, folders too), so let's just say my project uses 100+ includes. These only get loaded exactly once, when the user visits (AJAX site). I want to reduce the number of Http Requests to just 1 html and 1 sprite (my app uses a custom font for images actually). My app will also be ran on mobile devices (using a different design, using far fewer includes but a similar method).</p>
<p><strong>Research:</strong> Here's what I know:</p>
<ul>
<li>You can have Apache handle js/css as php, but is not something I'm interested in (dangerous) - <a href="http://stackoverflow.com/questions/984148">link</a></li>
<li>This site gave me the idea, although I don't quite understand it - <a href="http://www.catswhocode.com/blog/3-ways-to-compress-css-files-using-php" rel="nofollow">3 Ways to Compress CSS</a></li>
<li>Caching with something like APC (not sure how it works, but out of the scope of this question) would improve php speeds (?)</li>
</ul>
| php | [2] |
118,354 | 118,355 | Directory junction in PHP | <p>I am trying to create a hard-link with PHP. I know there are three kinds of links: Symlinks, hard-links, and directory junctions (hard-links for directories).</p>
<p>In PHP a symlink is the <code>symlink()</code> function, a hard-link is <code>link()</code>, but what for a directory junction?</p>
<p>I need to use it for a web application, and a symlink is not enough for me.</p>
<p>Thanks</p>
| php | [2] |
3,687,077 | 3,687,078 | how to display my hidden submit button below softkeyboard android | <p>I have two <code>EditText</code>s and one submit button but when I enter text in the EditText then my submit button hides below the soft keyboard so how to make it above keyboard when the keyboard appears, i.e., The Button should be visible. I have set a background image in the layout and stuck only two TextBoxs and a button on the background image.
My xml is below.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="@drawable/user_id_bg2" >
<EditText
android:inputType="textNoSuggestions"
android:text=""
android:id="@+id/editText1"
android:singleLine="true"
android:hint="Enter Your User Id"
android:layout_marginTop="85dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:layout_height="40dip"
android:layout_width="fill_parent">
</EditText>
<EditText
android:inputType="text|textNoSuggestions"
android:password="true"
android:singleLine="true"
android:hint="Enter Your Password"
android:layout_marginTop="125dip"
android:layout_marginLeft="20dip"
android:layout_marginRight="20dip"
android:id="@+id/editText2"
android:imeOptions="actionDone"
android:layout_height="40dip"
android:layout_width="fill_parent"/>
<ImageView
android:id="@+id/buttonimg"
android:layout_marginTop="200dip"
android:layout_marginLeft="237dip"
android:layout_width="wrap_content"
android:layout_height="40dip"
android:background="@drawable/go_button"
/>
</RelativeLayout>
</code></pre>
| android | [4] |
605,168 | 605,169 | How to uncheck checkbox before change() event is triggered | <p>I have lots of input fields in my form and on every field change serialized form data is sent to the server.</p>
<p>Now I need to prevent some check-boxes to be selected (can't use <code>"disabled"</code> attribute, <code>alert()</code> has to be triggered when clicked on these check-boxes). </p>
<p>I tried it with binding to <code>click()</code> event, but it looks like <code>change()</code> event is triggered before <code>click()</code> and serialized data is sent as if check-box was selected. </p>
<p>Now I'm trying with <code>mousedown()</code> event, but <code>prop('checked', false)</code> doesn't seem to be working and actually has the opposite effect - check-box ends up always checked.</p>
<p>Here is JsFiddle test case - <a href="http://jsfiddle.net/F8x2X/19/" rel="nofollow">http://jsfiddle.net/F8x2X/19/</a></p>
<p>So how do I uncheck check-box before <code>change()</code> event?</p>
| jquery | [5] |
1,874,602 | 1,874,603 | Accessing DOM elements outside of $(this).each function() | <p>I have a div on a JSP that I want to populate when I mouse over items associated
with a particular css class but it looks like I'm hitting a scope issue. Any idea
what I'm doing wrong?</p>
<p>JSP:
$('.hoverTrigger').myFunc();</p>
Text goes here
<p>
<p>JavaScript .js file referenced by JSP:</p>
<pre><code>$.fn.myFunc = function(options) {
$(this).each(function() {
$this.hover(
function() {
// Want to set text in messageBox here but not working
$('#messageBox').after("Hover IN").remove();
},
function() {
// Want to set text in messageBox here but not working
$('#messageBox').after("Hover OUT").remove();
}
);
});
};
</code></pre>
| jquery | [5] |
4,221,019 | 4,221,020 | Getting iteration counter in nested for loop | <p>I want a counter to keep count how many iterations in total I have done.
I do:</p>
<pre><code>counter = 0;
for i, item in enumerate(items):
for j, anotheritem in enumerate(anotheritems):
counter += 1;
</code></pre>
<p>But I can't help asking is there a more pythonic way?</p>
| python | [7] |
2,208,153 | 2,208,154 | JavaScript syntax | <p>I keep finding some JavaScript that looks like the example below. Can someone explain this as I have not seen JavaScript written like this before.</p>
<p>What is "SomethingHere" and the colon represent? I'm used to seeing function myFunction() but not what is shown below.</p>
<pre><code> SomethingHere: function () {
There is code here that I understand.
}
</code></pre>
| javascript | [3] |
1,591,605 | 1,591,606 | How accurate is the reading for GPS in iPhone's SDK? | <p>Using iPhone's SDK GPS API, how accurate can I get? Is it within a few meters or kilometers? I'm interested in the accuracy when it is indoor. <strong>My software will only be used in door.</strong></p>
| iphone | [8] |
4,411,046 | 4,411,047 | Can we customize the camera activity which opens by default in android..? | <p>Can we customize the camera activity which opens by default in android..?e.g apply overlay on this ..without using surface view</p>
| android | [4] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.