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 |
|---|---|---|---|---|---|
3,540,319 | 3,540,320 | Get content from another site | <p>I saw here similar questions but I didn't find any answer about Javascript.</p>
<p>I'm building a web site (lets call it 'A'), and I want to get content from another web site ('B') that requires a user-name and password.
I want a function at my site that get the content from a certain page at B. I'm always login manually to site B at my computer so I don't need the function to do the login (so I link it directly to the correct page of the info at B).
A and B are not in the same domain. Is there a way in Javascript to get content from B?</p>
| javascript | [3] |
3,780,076 | 3,780,077 | JavaScript in multiple files | <p>I Have created two JavaScript files.One file is "validators.js" and other is "UserValidations.js". </p>
<p>Here is the code for validators.js</p>
<pre><code>function isBlankString(value) {
if (value.replace(/\s/g, "") == "") {
return true;
} else {
return false;
}
}
</code></pre>
<p>In other js file I have defined function for validating user name like this.</p>
<pre><code>function validateUsername(element) {
var username = element.value;
if(value.replace(/\s/g, "") == ""){
//nothing to validate
return;
}else{
//validation logic
}
}
</code></pre>
<p>Now as it is obvious i should have used isBlankString(value) method to check string length. But I am clue less about how can i use the function defined in other file?</p>
| javascript | [3] |
4,851,154 | 4,851,155 | Can I prevent the user from stopping my Android application? | <p>The requirement is for an enterprise application. The application will be started on device boot. It will be running in the background and the user should not be able to disable or Stop the application. In Android a user can go to Settings->Application->Manage Application and stop my application. Is there any way to prevent this from happening?</p>
| android | [4] |
3,498,044 | 3,498,045 | inserting elements using jquery | <p>I have created a div in my div with id=main_area using JQuery append function now what i want to do is to add some elements like input fields and button in the div with id=this_one how can this be done? </p>
<pre><code>$('#main_area').append('<div id="this_one">first div</div>');
</code></pre>
| jquery | [5] |
5,117,338 | 5,117,339 | Dependencies and respective roles of the JavaScript libraries | <p>SharePoint 2010 pages contain a bunch of JavaScript libraries (core.js, init.js, ribbon.js, etc.). Where can I find a high level description of their respective roles and dependencies?</p>
<p>The objective is to create lighter page templates by removing the unnecessary libraries. For example on some pages I don't need context menus, on others I don't need the ribbon, etc.</p>
| javascript | [3] |
5,931,100 | 5,931,101 | Dynamically pass parameter to jQuery validate function | <p>i want to assign value to email_i dynamically.......</p>
<pre><code>var v = $("#email_address").validate({
rules: { activation_code: {
required: true,
alphanumeric: true,
remote: "mail.php?action=activation_code&email="+**email_i**
}
},
messages: {
activation_code: {
required: "Please input your activation code.",
alphanumeric: "Only latin characters, numbers and _ sign are allowed.",
remote: "Sorry, activation code is incorrect."
}
},
success: function(label) {
label.addClass( "formSuccess" );
label.html('<img src="HelpOneAnother/giveNet/themes/givearang_1001/gfx/icons/ok.gif" border="0" \>') ;
}
});
</code></pre>
| jquery | [5] |
3,423,077 | 3,423,078 | defining 'reference' to an object | <p>When an object is created, a reference is returned, and not the object.</p>
<p>What does this mean?</p>
<pre><code>object a = new object();
</code></pre>
<p>Here <code>a</code> holds the reference.</p>
<p>It would be helpful if someone explains the creation of the object, creation of references.</p>
| c# | [0] |
3,051,139 | 3,051,140 | Interpreting field type to activate checkboxes in c# | <p>I have some trouble building a good algorithm. Here is my criteria: I am reading a field in an xml file as a string and trying to interpret it in order to activate some gui component. More specifically, the field i read in as a string is a "Allowed Characters" field and the gui components are checkboxes that activate based on the contents of the field. For example, in the xml i have the tag </p>
<pre><code><Allowed Field>ABCDEFGHIJKLMNOPQRSTUVWXYZ</Allowed Fields>.
</code></pre>
<p>When i read in this field as a string, the program should know that the field content type is ALPHA and check the checkbox named alpha. Likewise if the field had alphanumeric contents or any special characters. I have three checkboxes that the algorithm should interpret: Alpha, alphanumeric and special characters. How can i build the algorithm that interprets the meaning of the string i read from the xml to mean the mentioned field types?</p>
<p>Thanks</p>
| c# | [0] |
4,044,660 | 4,044,661 | How do I add photos to the iPhone Simulator for OSX? | <p>I have photos on my Mac that I would like to add to the iPhone Simulator to test my application.</p>
<p>In other words: how do I add photos to the iPhone Simulator?</p>
<p>Edit : What about iphone Simulator 4.0 ? iphone Simulator 3.0 & 4.0 both working differently.</p>
<p>Thanks in advance for helping me...</p>
| iphone | [8] |
5,539,853 | 5,539,854 | Best way to use PHP to run another remote php script | <p>I am wanting to create a web-based cronjob system for my userbase, and would need to know the best way to open a php script on a remote server, and ensure the script runs (could take 3 minutes), and use the least ammount of resources on my own side. </p>
<p>There is the possibility of having hundreds of connections open at one time. </p>
<p>Any advice on how I should go about doing this?</p>
<p>Thanks allot,
Hudson</p>
| php | [2] |
2,405,250 | 2,405,251 | I can't see any trace output in ASP.NET | <p>In Visual Studio 2010 I added Trace to Page_Load as explained here <a href="http://www.asp101.com/articles/robert/tracing/default.asp" rel="nofollow">http://www.asp101.com/articles/robert/tracing/default.asp</a> but I can't see any Trace output, why ?</p>
<pre><code>public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
Trace.IsEnabled = true;
Trace.Write("Hello World");
}
}
</code></pre>
| asp.net | [9] |
5,278,652 | 5,278,653 | How to read arguments from target | <p>When you right click on a program in windows(such as starcraft.exe) and look at its properties there is a text field called "target" which contains the full path of the binary. I have seen programs able to parse flags added to the target such as "C:\programfiles\myprogram\myprogram.exe -x 1280 -y 360" and the program would start up in the specified resolution. My question is how to read those arguments, if it is done by argv[] please just inform me of my stupidity.</p>
<p>C++ is the language, VS express 2012 desktop is the environment.</p>
| c++ | [6] |
3,258,405 | 3,258,406 | Which method of creating javascript objects is better? | <p>I've seen objects defined in two different ways, which function similarly, but are, of course, fundamentally different. You can do it either like this:</p>
<pre><code>var myobject = {property: 'hello',
act: function() {
this.property += ' world';
}};
</code></pre>
<p>and like this:</p>
<pre><code>function myobject() {
this.property = 'hello';
this.act = function() {
this.property += 'world';
}
}
</code></pre>
<p>The second method could create objects like so</p>
<pre><code>var newobj = new myobject();
</code></pre>
<p>but you could do something similar using the first notation by making the object the return value of a function. The new keyword has the advantage of being able to pass parameters that can be used to initialize the properties of the object, but you could just as easily add an init function to the first kind of object.</p>
<p>Just wondering if besides these two differences, if there was a fundamental difference that made one method definitely better than the other method.</p>
| javascript | [3] |
5,710,551 | 5,710,552 | Permanently disabling Android Lock | <p>I want to permanently disable the lock in Android screen. i.e even after power reset, lock should not appear </p>
<p>Can I do this ?</p>
| android | [4] |
1,504,796 | 1,504,797 | python: function that will call itself | <p>i was wondering if i can get your help with the stucture.logic of a function that will need to call itself</p>
<pre><code>def populate_frequency5(d,data,total_compare):
freq=[]
prev = None
for row in d:
if prev is None or prev==row[11]:
freq.append(row[16])
doctor=row[10]
drug=row[11][:row[11].find(' ')].capitalize()
else:
make_image_url_doctor(freq,doctor,drug,data)
total_compare=True
del freq[:]
prev=row[11]
if total_compare:
(b1,bla,bla1)=medications_subset2(data,[drug.upper()])
data1=calculate_creat_conc4(b1)
populate_frequency5(data1,['a'],total_compare=True)
total_compare=False
</code></pre>
<ol>
<li><p>the first time the function is called i need it to run this:</p>
<pre><code>def populate_frequency5(d,data,total_compare):
freq=[]
prev = None
for row in d:
if prev is None or prev==row[11]:
freq.append(row[16])
doctor=row[10]
drug=row[11][:row[11].find(' ')].capitalize()
else:
make_image_url_doctor(freq,doctor,drug,data)
(b1,bla,bla1)=medications_subset2(data,[drug.upper()])
data1=calculate_creat_conc4(b1)
del freq[:]
prev=row[11]
</code></pre></li>
<li><p>then somehow the second time when i call it, i need it to run this way:</p>
<pre><code>def populate_frequency5(d,data,total_compare):
freq=[]
prev = None
for row in d:
if prev is None or prev==row[11]:
freq.append(row[16])
doctor=row[10]
drug=row[11][:row[11].find(' ')].capitalize()
run_another_function()
</code></pre></li>
</ol>
| python | [7] |
1,267,580 | 1,267,581 | Javascript to grab Javascript comments within <head> | <p>I have a page that begins as follows:</p>
<pre><code><html>
<head>
<!-- 12036,2011-11-29/11:02 -->
<title>Products & Services</title>
</code></pre>
<p>I would like to grab the 12036 number here and to display it within an absolutely positioned DIV at the bottom right of my screen. My intention here is to either to use it as a bookmarklet or as a Greasemonkey script. </p>
<p>The purpose of this is that the number represents a PAGE ID that we use reference internally. </p>
<p>I started off using: </p>
<pre><code>var x = document.getElementsByTagName('head').innerHTML;
</code></pre>
<p>But I could not progress any further. </p>
<p>Can anyone assist here?</p>
| javascript | [3] |
3,368,730 | 3,368,731 | Function return type validation by compiler | <p>I read in Thinking in C++ by Bruce Eckel that when a C++ compiler encounters a function it decorates it's name using it's name and arguments.
For a function, int func(char ch); it would decorate it's name as _func_char It doesn't use the return type.</p>
<p>In that case,
In the below program how does the compiler complain "invalid conversion from int to const char*" when it has not stored the return type during function name decoration? Can anyone please clarify?</p>
<pre><code>#include <iostream>
using namespace std;
int func()
{
int i = 5;
return i;
}
int main()
{
string str = func();
}
</code></pre>
| c++ | [6] |
5,662,152 | 5,662,153 | comparing a char to a const char * | <pre><code>string line = "blerdy blah";
for (int i = 0; i < string.size(); i++)
{
line[i] != "n";
}
</code></pre>
<p>With this I get the error "cannot convert from char to const char *"</p>
<p>If I replace the last line with</p>
<pre><code>line[i] != *"n";
</code></pre>
<p>It works. I get why in one sense, I'm dereferencing a pointer. What I don't get is why it's a pointer in the first place. Is any char written like this actually a pointer to one char somewhere? Like the program has one set of every symbol somewhere and this is what I'm pointing to?</p>
<p>If this is the case, can I do silly things like make the 'n' pointer point to something else?</p>
| c++ | [6] |
4,029,758 | 4,029,759 | How to loop a simple JQuery function? | <p>I'm trying to do something very simple: continuously loop a background image. I'm doing this via the <a href="http://plugins.jquery.com/project/backgroundPosition-Effect" rel="nofollow">"Background Position Animations" plugin</a>.</p>
<p>My current code:</p>
<pre><code>$(function skyloop() {
$('#header').animate ({backgroundPosition:"(-250 0)"}, {duration:1000});
});
</code></pre>
<p>I need a way to call the 'skyloop' function at the end of the animation, which would cause it to loop, but I can't seem to find the way to do that.</p>
<p><strong>[EDIT]</strong>
I've read all of the replies and I can't figure it out; nothing seems to work. It simply refuses to run again. The only thing I can think of is that the issues is caused by the plugin as I'm modifying a background image. I'll try to find another way to move a background image continuously (I'm trying to simulator a sky, by the way).</p>
| jquery | [5] |
1,421,310 | 1,421,311 | object.jquery attribute | <p>what does this code performs?</p>
<pre><code>if(object.jquery){
....
}
</code></pre>
<p>I don't know what jQuery attribute does. I think it checks if 'object' is a valid jQuery object, but I'm not really sure.</p>
<p>Thanks in advance.</p>
<p>Esteve</p>
| jquery | [5] |
3,214,709 | 3,214,710 | Jquery - multiple selectors - get elements in sequence | <p>I have a form like this</p>
<pre><code><form id="myform">
<input type="hidden" name="a" value="a1"/>
<input type="hidden" name="b" value="b2"/>
<select name="c"><option value="c3" selected="true"/></select>
<input type="text" name="d" value="d4"/>
</form>
</code></pre>
<p>Now, I want to get list of all input and select elements in the form</p>
<pre><code> var mydata = new Array();
$('#myform').find('input, select').each(function ()
{
mydata.push($(this).val());
});
</code></pre>
<p>Result I am getting is: a1, b2, d4, c3
But what I want to get is: a1,b2,c3,d4 (in the same sequence as displayed in UI).</p>
<p>Note: I can give some dummy class (say: mydatafields) to all the input and select elements and use:</p>
<pre><code>$('mydatafields').forEach()
</code></pre>
<p>something like, but I am checking if there is a better solution.</p>
<p>Thanks in advance.</p>
| jquery | [5] |
5,467,905 | 5,467,906 | Check if Internet Page is opened in Internet Explorer | <p>is there a way to look up if there is a running IExplore.exe process with a specified uri opened in c#?</p>
<p>Best regards</p>
| c# | [0] |
1,663,350 | 1,663,351 | How to retrieve current route info from Google Navigation in Android | <p>Is there anyway to get the current route information from android google navigation?</p>
<p>For instance people might choose alternative route, avoid tolls, etc. My requirement is to replicate the current route a user has customised and try replicate that on another android device as close as possible.</p>
| android | [4] |
421,581 | 421,582 | Issues with inheritance (java) | <p>I was reading about how java avoids the deadly diamond of death, but i still have some questions. What if a class inherits a class and implements an interface and they each have a method with the same prototype? Or a method with the same name, same arguments, but different return types?</p>
<p>Thank you!</p>
| java | [1] |
2,572,932 | 2,572,933 | Using arrays to record number of clicks on a button | <p>last night I was coding a little piece of JS code that records the number of mouse clicks on a keypad (akin to a mobile phone) and with each successive press a new value would be entered into a textbox. This is how I've got so far.</p>
<p>The difficulty last night was that I set count as a global variable which was carried across meant if a user clicked on 1 and 2 they would get 1D in the text box when they should be getting 12:</p>
<p><a href="http://jsfiddle.net/JNCCW/7/" rel="nofollow">http://jsfiddle.net/JNCCW/7/</a></p>
<p>In my most recent code I've tried to create an array so initially we have:</p>
<pre><code>[0,0,0,0]
</code></pre>
<p>And each time the user clicks a button then e.g 1 and then 2 - the array updates to:</p>
<pre><code>[1,1,0,0]
</code></pre>
<p>The values at 1 in array 1,2 are then added to the text box.</p>
<p>When the array element equals 4 then the array element resets to 0.</p>
<p><a href="http://jsfiddle.net/JNCCW/9/" rel="nofollow">http://jsfiddle.net/JNCCW/9/</a></p>
<p>I've been having difficulty achieving this and feel that the logic behind my coding is awkward. I would appreciate any help!</p>
| javascript | [3] |
4,612,120 | 4,612,121 | Where should Android PopupWindow event handlers go? | <p>I'm using an Android PopupWindow in an application so I want to be sure I understand what "best practice" is for handing events from it. </p>
<p>My PopupWindow has a button and currently the onClick handler for that button is in the same Activity thats launched the popup.</p>
<p>But I've seen an example where someone created a class which extend PopupWindow. That's the class they create when they need a PopUpWindow, but they still put the onClick handler in the Activity that launched it. </p>
<p>If I had a separate class like that, extending PopupWindow, would it be better to put the button handler in that class, and if so how would I do it? </p>
<p>Thanks in advance! </p>
| android | [4] |
5,085,230 | 5,085,231 | Java csv file unable to write string like 012365479 | <p>Hi write a java code to write the output into a csv file. This is the sample code:</p>
<pre><code>File downloadPlace = new File(realContextPathFile, "general");
File gtwayDestRateFile = new File(downloadPlace, (new StringBuilder("ConnectionReport")).append(System.currentTimeMillis()).append(".csv").toString());
PrintWriter pw = new PrintWriter(new FileWriter(gtwayDestRateFile));
pw.print("Operator name,");
pw.print("Telephone Number,");
pw.print("Op1");
pw.print("012365479");
pw.print("Op2");
pw.print("09746");
pw.close();
p_response.setContentType("application/octet-stream");
p_response.setHeader("Content-Disposition", (new StringBuilder("attachment; filename=\"")).append(gtwayDestRateFile.getName()).append("\"").toString());
FileInputStream fis = new FileInputStream(gtwayDestRateFile);
byte buf[] = new byte[4096];
ServletOutputStream out = p_response.getOutputStream();
do
{
int n = fis.read(buf);
if(n == -1)
break;
out.write(buf, 0, n);
} while(true);
fis.close();
out.flush();
</code></pre>
<p>In both case the output is like this: 12365479 instead of 012365479<br>
And 9746 instead of 09746<br>
Can anyone tell me how can i solve this problem?</p>
| java | [1] |
4,834,783 | 4,834,784 | C#: Thread safe function | <p>which of the following code is more appropriate situation where multiple threads access the function</p>
<pre><code>public ArrayList CallMe1()
{
ArrayList al = new ArrayList();
lock(al.SyncRoot)
{
al.Add("33");
al.Add("45");
return al;
}
}
public ArrayList CallMe2()
{
ArrayList al = new ArrayList();
Monitor.Enter(al);
al.Add("33");
al.Add("45");
Monitor.Exit(al);
return al;
}
</code></pre>
| c# | [0] |
4,102,765 | 4,102,766 | Selectlist text value not changing c# | <p>I am creating a new selectlist using c# and i am trying to change the TextValue of the option in the selectlist . But the text value is not changing :</p>
<pre><code> var txt = new SelectList(db.Ceremonies, "Id", "Name");
for (int i = 0; i < txt.Count(); i++)
{
txt.ElementAt(i).Text += "_" + "Done";
}
ViewBag.CeremonyId = txt;
</code></pre>
<p>Help me out please ?</p>
| c# | [0] |
5,425,999 | 5,426,000 | Searching text for (potentially) tens of thousands of tokens | <p>I am maintaining a simple php-based in-house cms. I'd like to search the text of articles as they are saved into the system for what will eventually be tens of thousands of different tokens, in order to automatically apply links to those tokens and also to establish a relationship in an association table between the article and the entity the token represents.</p>
<p>What is the best way to do this? Is there a faster/more efficient way to do it than to retrieve a list of all of the tokens and their relevant entity/id every time an article is saved?</p>
<p>I'm less interested in the replacement of the tokens than the best way to establish the list of tokens to search - they will come from several different tables, and I would think that on a per-request basis the data set which needs to be queried would be quite a burden on both the DB and the memory load of the script</p>
<p>Edit: I think I've posed the question incorrectly.</p>
<p>Consider the following text:</p>
<p>Steve McMuffin ate seventeen Fabulous Furry Fajitas at The Stinking Bean, while Johnson Fatlumps ate thirty-two.</p>
<p>I've got two people in there who are both in the 'person' table, one restaurant which is in the 'restaurant' table and one restaurant menu item which is in the 'restaurant_menu_item' table.</p>
<p>I want to know the best way, after that text is saved, to automatically go through and identify what is a person, what is a restaurant, and what is a restaurant menu item <em>without</em> resorting to custom markup as the intended audience has virtually no chance of ever getting that right.</p>
| php | [2] |
3,951,609 | 3,951,610 | How to use jquery Attr() to select only first attribute? | <p>I have a div as follows:</p>
<pre><code><DIV CLASS="variable productPopup"></DIV>
</code></pre>
<p>When assigning it to a var, how do I only select variable? Please note that variable changes, so it needs to select the first item, not literally the words "variable"</p>
<pre><code>var ID = $(this).attr("class");
</code></pre>
| jquery | [5] |
4,723,400 | 4,723,401 | How to publish paid android app in market and authorize people to download | <p>I've developed one android application well.I need to publish my app as paid one into market.i'm from india.How could i publish my paid app on android market & i need to make my app can able to download by some authorized people(not all people). How could i do this too?</p>
<p>Thanks.</p>
| android | [4] |
5,106,982 | 5,106,983 | Why is this not outputting my selection? | <p>The radio buttons have numeric values which will be added and displayed in the div: <code>sub-total-t</code></p>
<h1>JS</h1>
<pre><code>$(document).ready(function() {
$('label').click(function() {
var total = 0;
$('.option:checked').each(function() {
total += parseFloat($(this).data('number'))
});
$('.sub-total-t').html('$' + total.toFixed(2));
});
});
</code></pre>
<h1>HTML</h1>
<pre><code><label><input type="radio" name="print" class="option" data-number="25" value="p10"/> Starter 500 </label>
<div id="sub-pricing">
<h3> Sub-Total </h3>
<div class="sub-total-t">$</div>
</div>
</code></pre>
<p>Why is this not displaying my value?</p>
| jquery | [5] |
1,657,374 | 1,657,375 | Captch Integration | <p>Is there any particular way to integrate Captch code validation in iPhone application?</p>
<p>is this possible to create captcha? (with or without web-service / any API)</p>
<p>If any kind of external library or any source is required to be imported, then also please let me know.</p>
<p>Any kind of link or source code is available then please suggest me.</p>
<p>Also suggest from where to start to do this, if possible.</p>
<p>Thanks in advance.</p>
| iphone | [8] |
2,204,630 | 2,204,631 | Not-disabled Read-only checkbox in Jquery? | <p>I have a page with a form on it. I would like to make all the checkboxes and radio buttons on the page read-only (non-editable) without making them have the "disabled" appearance. I just want to prevent the user from easily changing the value of the checkbox. How can this be done? </p>
| jquery | [5] |
3,061,761 | 3,061,762 | What is the best way to start learning how to program? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/335063/whats-the-easiest-way-to-learn-programming">What’s the Easiest Way to Learn Programming?</a> </p>
</blockquote>
<p>I'm very new to programming, but it has always interested me. I've tried to learn a couple of times except I don't know where to begin. What's a good language to learn first? What is a good website that can help me learn it?</p>
<p>I once partitioned my hard drive and installed Ubuntu in an attempt to learn Python, but I was overwhelmed. I didn't know where to start or what to do.</p>
<p>All suggestions, feedback, comments are welcome.</p>
| python | [7] |
4,414,080 | 4,414,081 | Can anyone explain this method signature? What does <K> and K... represent? | <p>Howdy, I am trying to understand this method signature:</p>
<pre><code> public <K> Map<K, String> getMulti(Serializer<K> keySerializer, K... keys)
</code></pre>
<p>For the following code block:</p>
<pre><code>public <K> Map<K, String> getMulti(Serializer<K> keySerializer, K... keys) {
MultigetSliceQuery<K, String, String> q = createMultigetSliceQuery(keyspace, keySerializer, serializer, serializer);
q.setColumnFamily(CF_NAME);
q.setKeys(keys);
q.setColumnNames(COLUMN_NAME);
QueryResult<Rows<K, String, String>> r = q.execute();
Rows<K, String, String> rows = r.get();
Map<K, String> ret = new HashMap<K, String>(keys.length);
for (K k : keys) {
HColumn<String, String> c = rows.getByKey(k).getColumnSlice().getColumnByName(COLUMN_NAME);
if (c != null && c.getValue() != null) {
ret.put(k, c.getValue());
}
}
return ret;
}
</code></pre>
<p>I am not sure what <code><K></code> in the method declaration represents, or what <code>K...</code> is suppose to mean. Can anyone shed some light on these?</p>
| java | [1] |
2,752,787 | 2,752,788 | Form Validation | <pre><code>validate document.forms()
if document.forms[0].userAge.value ==""
alert("Age field cannot be empty."
return false;
if document.forms[0].userAge.value<5
alert"Your age input is not correct."
return false;
if userage==isNumber
alert"Your age input is not correct."
return false;
alert"Name and Age are valid."
return true
<label for="userAge">Age:</label>
<input type="text" name="userAge" id="userAge" />
</div>
</code></pre>
<p>If this is the code I have, how would I make it so that if someone were to enter a non number in the age text box an alert would come up saying " Your input is not correct"?</p>
| javascript | [3] |
1,248,587 | 1,248,588 | change file extension in php? | <p>How do I change a files file-extension name in php?</p>
<p>example: $filename='234230923_picture.bmp'
and I want the extension to change to 'jpg'.</p>
<p>Thanks</p>
| php | [2] |
3,179,474 | 3,179,475 | how do I get the number hours between two times? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4235635/operation-between-hours">Operation between hours.</a> </p>
</blockquote>
<p>I have 2 buttons if you press each one will come out time picker and return the time chosen in the button. How do I subtract the two times?
I try to explain it with and example:
I press button one, and I have time picker coming out, I choose lets say 6:00pm. 6:00pm will return in my button1.
I do the same thing with button two. I choose a time lets say 8:00pm. 8:00pm will return in my button2.
I would like to know how can I subtract them to find how many hours I have between button1 and button2. In this case would be 2 hours.</p>
<p>Here is a piece of code where I press the done button to return the time chosen in the button.</p>
<pre><code>- (IBAction)doneButtonPressed2:(id)sender
{
if ([self.delegate respondsToSelector:@selector(datePickerViewController2:didChooseDate:)]) {
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSString *dateString = [dateFormatter stringFromDate:[datePicker date]];
[self.delegate datePickerViewController2:self didChooseDate:dateString];
[self dismissModalViewControllerAnimated:YES];
}
</code></pre>
<p>I believe I have to use this to have what I want:</p>
<pre><code>//NSTimeInterval secondsBetween = [firstTime timeIntervalSinceDate:secondTime];
</code></pre>
<p>but I am not quite sure how to use it. </p>
<p>Thank you very much for your help!</p>
| iphone | [8] |
581,521 | 581,522 | C# ambiguous call DataColumnCollection.Add(System.Data.DataColumn)' and 'System.Data.DataColumnCollection.Add(string) | <p>below is the code i'm using and i've used this 100x's before. And now it's throwing an error, basically i'm trying to dynamically create the Columns based on the first row of an excel file. The error that i'm receiving now is:</p>
<p><code>The call is ambiguous between the following methods or properties: 'System.Data.DataColumnCollection.Add(System.Data.DataColumn)' and 'System.Data.DataColumnCollection.Add(string)'</code></p>
<pre><code>DataTable excel_Holding_Table = new DataTable();
DataRow row;
Microsoft.Office.Interop.Excel.Range range = workSheet.UsedRange;
for (int i = 1; i <= range.Columns.Count; i++)
{
excel_Holding_Table.Columns.Add(Convert.ToString(((Microsoft.Office.Interop.Excel.Range)workSheet.Cells[1, i]).Value2));
}
</code></pre>
<p>What do I need to do to prevent this from happening, this has never appeared.</p>
<p>here is my using:</p>
<pre>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
</pre>
| c# | [0] |
4,848,659 | 4,848,660 | C# - Practical example - rigidness of abstract class | <p>I understand that</p>
<p><i>
"Abstract classes can be modified without breaking the API ".
</i></p>
<p>once a version (say 1.0.0.0) of class library is supplied to the party,when i design the another version (say 1.1.0.0) with modification,won't it break the code ?</p>
<p>can you give very simple example ,how is it possible ?</p>
| c# | [0] |
4,948,091 | 4,948,092 | in Java the arguments are passed by value? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/40480/is-java-pass-by-reference">Is Java pass by reference?</a> </p>
</blockquote>
<p>Hi guys,</p>
<p>I have a question about the arguments passing in Java, I read it from a book <em>"In Java the arguments are always passed by value"</em>, what does this mean? </p>
<p>I have no experience of C++ and C, so it is a little bit hard for me to understand it.
Can anyone explain me? </p>
| java | [1] |
4,552,766 | 4,552,767 | preg_match in php | <p>How do I use preg_match in php to match a whole word on its own and not when it's part of another word.</p>
<p>ie.</p>
<p>151 : 151-220 - should be a match.
51 : 151-220 - should not be a match.</p>
<p>Help!</p>
| php | [2] |
781,669 | 781,670 | iPhone: How do I add layers to UIView's root layer to display an image with the content property? | <p>According to the Mac Dev Center docs, you should be able to set the contents property of a CALayer and have that render automatically. However, I still can't get a simple image to show up by adding a sublayer to the UIView's root later. I've tried multiple different variations; here's what I have so far:</p>
<p>(Note: I know there are other ways of rendering images; for my purposes I'd like to use CALayer's for some of the more complicated stuff I'm going to get into).</p>
<p>(in viewDidDisplay() of the ViewController):</p>
<pre><code> CALayer *theLayer = [CALayer layer];
[[[self view] layer] addSublayer:theLayer];
theLayer.contents = (id)[[UIImage imageNamed:@"mypic.png"] CGImage];
theLayer.contentsRect = CGRectMake(0.0f, 0.0f, 300.0f, 300.0f);
theLayer.bounds = CGRectMake(0.0f, 0.0f, 300.0f, 400.0f);
</code></pre>
<p>Anyone know what I'm doing wrong?</p>
<p>Thanks!</p>
| iphone | [8] |
4,305,953 | 4,305,954 | add line breaks to paragraph from textarea | <p>I have a <code>textarea</code> box where the user types in a message then it outputs into a <code>paragraph</code> markup.<br/>
I am successful capturing the text but cannot seem to capture the line breaks.<br/>
<a href="http://jsfiddle.net/nalagg/9a68r/1/" rel="nofollow">heres my fiddle</a><br/>
<br/>
Ideally a string substitution such as <code><br/></code> or <code>\n</code> is what i was looking for.<br/>
any help would be appreciated, thanks.</p>
<pre><code>var txtBox = $('#myTextArea');
var txt = txtBox.val();
txtBox.keyup(function(){
txt = txtBox.val();
$('p.msg').html(txt);
});
txtBox.keydown(function (e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 13) {
$('p.msg').append('<br />');//ApplyLineBreaks(txt);
}
});
</code></pre>
<p>and the markup</p>
<pre><code><textarea id="myTextArea" class="form_0" name="Enter your message" type="text"></textarea>
<p class="msg" style="text-align: center;">msg here</p>
</code></pre>
| jquery | [5] |
3,534,340 | 3,534,341 | Question about DispatcherUnhandledException | <p>The problem in this code is that when it's run and I push "Yes" button, This is shown:</p>
<p><img src="http://i.stack.imgur.com/6JKxW.png" alt="alt text"></p>
<p>This means that my application stopped working, I just want it to end.</p>
<pre><code>private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
string message = "An unhandled exception has ocurred, do you want close the app?";
MessageBoxResult currentMB = MessageBox.Show(message, "SomeTitleApp", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
if (currentMB == MessageBoxResult.Yes)
{ Application.Current.Shutdown(); }
else
{ e.Handled = true; }
}
</code></pre>
| c# | [0] |
1,121,722 | 1,121,723 | System.out.println("Hi"+6+10); prints Hi610? | <p>Why does it do this? So confuuuusing.</p>
| java | [1] |
2,583,918 | 2,583,919 | How to open a hyperlink on the same page with javascript? | <p>I am using this to open on a new window:</p>
<pre><code><div class="backbutton" OnClick="javascript: window.open('http://www.goesback.com')">Go back</div>
</code></pre>
<p>How to amend this if I want onclick to open a hyperlink on the same page?</p>
<p>thanks.</p>
| javascript | [3] |
327,388 | 327,389 | oDesk API integration with C#.net | <p>How to authenticate an oDesk user against oDesk APIs using C#.net ? I am trying to make a windows service to download the working hours of a user periodically between two dates. I tried to accomplish it through
<a href="https://github.com/daniel-sim/oDesk-API-C--library" rel="nofollow">https://github.com/daniel-sim/oDesk-API-C--library</a>
but haven't achieved anything yet.</p>
<p>Kindly suggest few clues.</p>
<p>Thanks</p>
| c# | [0] |
4,040,153 | 4,040,154 | About the space in iPhone app name when upload | <p>In the targets settings, I set the "Product Name" to be "My first app" (for instance), and this name will be displayed on the iPhone.</p>
<p>But when I upload the app, apple complains that the name the name of app can't contain the space. Can I just rename the app from "My first app.app" to "Myfirstapp.app"? Will that impact on the name displayed on the iPhone?</p>
<p>Thanks!</p>
| iphone | [8] |
5,544,186 | 5,544,187 | Saving data from activity(A) and reading in another Activity(history) | <p>I have an activity that contain a list of data (TextView), i need to save this data that have been choose (onClick) in the list and been able to get and read it in another activity(history) </p>
<p>I understand that is exist a possibility with the "serializable" but i did not success to understand how it could help me.</p>
<p>i will be happy if someone can clarify this subject for me,example?.</p>
<p>Thank you for helping!! </p>
| android | [4] |
5,315,218 | 5,315,219 | How to print a list in Python "nicely" | <p>In PHP, I can do this:</p>
<pre><code>echo '<pre>'
print_r($array);
echo '</pre>'
</code></pre>
<p>In Python, I currently just do this:</p>
<pre><code>print the_list
</code></pre>
<p>However, this will cause a big jumbo of data. Is there any way to print it nicely into a readable tree? (with indents)?</p>
| python | [7] |
189,132 | 189,133 | Which devices do and do not support USB Host mode? | <p>Could someone please provide a comprehensive list of which devices do and do not support USB Host mode out of the box with no rooting, OS rebuilding, or cable hacking required? I've read that only tablets support it. Then I've read that the Droid supports it. Many posts are a couple years old so not sure what is applicable now in March, 2012. I've read that Windows phones support it? Maybe its time to switch to that. Does iPhone 4s support it?</p>
| android | [4] |
1,067,010 | 1,067,011 | spl_autoload_register with non static class method as autoloader function? | <p>I'm trying to use spl_autoload_register to use an instantiated object as the autoloader. Is it possible? I have seen in a couple of places where people have used a classes static function as the autoloader, but not an object. </p>
<p>Example:</p>
<pre><code>class loadFile{
function loadObject($object){
//load object here
}
}
$loadmefiles = new loadFile();
//use $loadmefiles->loadObject() as autoloader
spl_autoload_register();
$goat = new Animal('goat');
</code></pre>
<p>Hopefully you understand what I am getting at. </p>
| php | [2] |
2,456,676 | 2,456,677 | How to access to checked items from another form? | <p>I have two forms:form1 and form2. </p>
<p><strong>form1</strong>:</p>
<p>contains <code>button1</code> and <code>listbox1</code>.</p>
<p><strong>form2</strong>:</p>
<p>contains <code>button2</code> and <code>checkedlistbox1</code>.</p>
<p>When click to the <strong>button1</strong> must open <strong>form2</strong> and check items for <strong>checkedlistbox1</strong>. Then click <strong>button2</strong> so <strong>form2</strong> closed and <strong>listbox1</strong> must show checked items from <strong>checkedlistbox1</strong>. But the problem that I can't copy checked items from <strong>checkedlistbox1</strong> to <strong>listbox1</strong>. How can i do that, please help.</p>
| c# | [0] |
4,644,667 | 4,644,668 | Python: split float after 3rd decimal place | <p>I have a series of strings, which are two numbers:</p>
<pre><code>1.782-100.799
-18.107-102.016
-17.504104.059
</code></pre>
<p>How do I split my string after the 3rd decimal place of the first number in each string? so it looks as follows:</p>
<pre><code>1.782 -100.799
-18.107 -102.016
-17.504 104.059
</code></pre>
| python | [7] |
3,679,689 | 3,679,690 | Why am i getting infinity loop? | <p>I'm trying to resize the container and set for it width and height. It is not all the part of code, but infinity loop appears then i call
<strong>$.fn.imageScale.resizeContainer</strong> function, I can't find why?</p>
<pre><code>$( window ).load(function(){
$( '#scalable_images' ).imageScale();
});
(function($){
$.fn.imageScale = function(){
thisCallback = $( this ); // for usage in inner other function
images = $( this ).find( 'img' ); // images
imagesHolder = $( this ).find( '.item' ); // image holder
frameSize = 34; // frame size
sizingCof = 1.5; // image size cofficient to scale, 1.5 = 150% normal state
speed = 600; // speed in ms
$.fn.imageScale.resizeContainer();
$.fn.imageScale.resize();
OldContainerW = imagesHolder.width();
OldOffsetL = offsetL;
$( window ).bind( 'resize', function(){
$.fn.imageScale.resizeContainer();
$.fn.imageScale.resize();
OldContainerW = imagesHolder.width();
OldOffsetL = offsetL;
});
}
$.fn.imageScale.resizeContainer = function(){
var windowW = $( window ).width();
var windowH = $( window ).height();
var scaleImgH = windowH - frameSize * 2;
var scaleImgW = windowW - frameSize * 2;
$( this ).height( scaleImgH );
$( this ).width( scaleImgW );
}
})(jQuery);
</code></pre>
| jquery | [5] |
3,444,137 | 3,444,138 | Trying to center a div --- missing : after property id | <p>I'm trying to center an appended div, however I keep on getting this error:</p>
<blockquote>
<p>SyntaxError: missing : after property id</p>
</blockquote>
<p>specifically after the <code>10)</code>.
Here's my code:</p>
<pre><code>$("#infobox").css({marginTop:parseInt(($("#content").height() / 2) -("#infobox").height() / 2), 10) + 'px'});
</code></pre>
<p>I tried doing <code>10);</code> but haven't gotten rid of it.</p>
<p>Thanks!</p>
| jquery | [5] |
5,381,243 | 5,381,244 | jQuery -given a div, extend the div's height to reach the bottom | <p>Given a div on a page like <code><div id="rightRail>xxx</div></code></p>
<p>Is it possible to some how magically make that div's height resize on broswer load/resize so that the height reaches the bottom of the window? It would be easier if the div was at the top of the page, but it isnt. thanks</p>
| jquery | [5] |
3,174,540 | 3,174,541 | Simple PHP function and variable confusion | <p>I have a couple of simple PHP functions I am using. One to detect wether the user is on an iPhone, and one to resize images if they are.</p>
<pre><code><?php
/* User agent function */
function userAgent(){
$browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
if ($browser == true) { $var = 1; }
return $var;
}
/* Image resize function */
function imageResize($width, $height) {
$var = userAgent($var);
if($var == 1){
$width = round($width / 2);
$height = round($height / 2);
}else{
$width = round($width);
$height = round($height);
}
echo "width=\"$width\" height=\"$height\"";
}
?>
</code></pre>
<p>The problem is, if I manually change the $var to 0 or 1 in the userAgent() function, the images do not resize, but if I change the $var to == 0 in the imageResize() function, they do. </p>
<p>Why is the variable not carrying across from the first, to the second function, or am I doing something else wrong?</p>
| php | [2] |
2,936,833 | 2,936,834 | How to set the real region time (PHP)? | <p>I would like to find real time in some region in order to send it to the database. I tried to do something like this:</p>
<pre><code>date_default_timezone_set('Asia/Jerusalem');
$date = date('Y-m-d H-i-s');
</code></pre>
<p>Is it possible? If yes - how?</p>
| php | [2] |
5,796,523 | 5,796,524 | how to access bytecode of some file/function in android | <p>I want to access bytecode of some file/function from dex file in Android. Please suggest me the suitable way.
Thanks!</p>
| android | [4] |
1,167,542 | 1,167,543 | Cut top part of an ImageView | <p>I have an image view that has the height smaller than it's image height. The resulted image must be cut at the top and the width must remain the same. How can I do this?</p>
<p>Thank you,</p>
<p>Gratzi</p>
| android | [4] |
5,033,016 | 5,033,017 | MANIFEST issue - JAR package | <p>I'm using JDK 1.5 and IntelJ 8.1.4 on window XP, and using Ant to build and generate my .jar pachage. The problem is, the MANIFEST.MF of .jar package file doesn't have Main-Class and path information. Here is the info of MANIFEST.MF:</p>
<hr>
<p>Manifest-Version: 1.0</p>
<p>Ant-Version: Apache Ant 1.7.1</p>
<p>Created-By: 1.5.0_22-b03 (Sun Microsystems Inc.)</p>
<hr>
<p>Here is the iws file of my project, it does have the main class:</p>
<hr>
<pre><code><configuration default="true" type="Application" factoryName="Application" enabled="false" merge="false" sample_coverage="true" runner="emma">
<option name="MAIN_CLASS_NAME" value="cms.client.gui.CMT" />
<option name="VM_PARAMETERS" value="" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<module name="" />
<envs />
<method>
<option name="Make" value="true" />
</method>
</configuration>
</code></pre>
<hr>
<p>Any comments?</p>
| java | [1] |
3,430,414 | 3,430,415 | jQuery: Selecting a option value and make the checkbox name follow | <p>This is my goal, this is only static though:</p>
<p><a href="http://jsfiddle.net/ySu7q/" rel="nofollow">http://jsfiddle.net/ySu7q/</a></p>
<p>I wish to make this dynamic, so the related checkbox below follow what value you have chosen in the select box.</p>
<p>I would like to do when you select in the current '18:00' select box, and change it to another e.g 19:00 - then the checkbox below should follow and change to 1900 both the display text and the name should be changed from <code>copyTime[1][1800]</code> to <code>copyTime[1][1900]</code></p>
<p>How can I do this? I have no clue where to start, maybe the structure of the current code should be rewritten to make it possible?</p>
<p>Thanks alot</p>
| jquery | [5] |
4,430,974 | 4,430,975 | Can I run vb script from C# application ? | <p>Can I run vb script from C# application.Can anybody provide me vb script with exam
like on button click show message,if perticular panel is visible.</p>
| asp.net | [9] |
5,297,489 | 5,297,490 | Java library to read/write Map<String, String> via bean | <p>I'm looking for a library that provides type type-safe read and write access to a <code>Map<String, String></code> via a proxied Java bean. For example:</p>
<pre><code>interface Person {
String getName();
void setName(String name);
int getAge();
void setAge(int age);
}
Map<String, String> data = new HashMap<String, String>() {{
put("name", "juni");
put("age", "4");
}}
Person p = HypotheticalLibrary.bind(Person.class, data);
p.getName(); // returns "juni"
p.setAge(5); // calls data.put("age", "5") --- notice the implicit type conversion
</code></pre>
<p>Is there such a thing?</p>
| java | [1] |
5,616,674 | 5,616,675 | How to refresh the multi-line output dynamically | <p>I want to refresh some info dynamically(just like progress bar), I can do it with following code</p>
<pre><code>#! /usr/bin/env python
import sys
import time
print "start the output"
def loop():
i = 0
while 1:
i += 1
output = "\rFirst_line%s..." % str(i)
sys.stdout.write(output)
sys.stdout.flush()
time.sleep(1)
loop()
</code></pre>
<p>It could only output single_line info dynamically, When add '\n' into output, It couldn't work as expect.</p>
<pre><code>output = "\rFirst_line%s...\n" % str(i)
</code></pre>
<p>Any way could help it to refresh multi_line content?</p>
| python | [7] |
4,566,333 | 4,566,334 | How to calulate how long it takes to download a file | <p>I have written scripts to download XML data via HTTP. I would like to record (in a database) how long it takes to download the XML file. Does PHP have a built in function for timing the length of a download?</p>
| php | [2] |
3,382,690 | 3,382,691 | why my code run wrong ,it is about '@property' | <p>i used python 2.5,i want to know how can change the next code when the Platform is python2.5 or python2.6</p>
<pre><code>class C(object):
def __init__(self):
self._x = None
@property
def x(self):
"""I'm the 'x' property."""
return self._x
@x.setter
def x(self, value):
self._x = value
@x.deleter
def x(self):
del self._x
a=C()
print a.x#error
</code></pre>
<p>thanks</p>
<p><hr /></p>
<p>thanks ,alex,i think property must be 3 arguments in your example</p>
<p>but ,i have seen a code which with 'property' only use 1 argumennt ,why,can it work</p>
<pre><code>class SortingMiddleware(object):
def process_request(self, request):
request.__class__.field = property(get_field)
request.__class__.direction = property(get_direction)
</code></pre>
| python | [7] |
655,391 | 655,392 | How download with php google trends/insign cvs file? | <p>How download with php google trends/insign cvs file?</p>
<p>reproduce:</p>
<ol>
<li><p>go to :
<a href="http://www.google.com/trends?q=london%2C+paris&ctab=0&geo=all&date=all&sort=0" rel="nofollow">http://www.google.com/trends?q=london%2C+paris&ctab=0&geo=all&date=all&sort=0</a></p></li>
<li><p>in this page exist option to download cvs file that have all query result data by click.
I need to that by php.</p></li>
</ol>
<p>Thanks,</p>
<p>Yosef</p>
| php | [2] |
4,423,977 | 4,423,978 | solaris 8 vs solaris 10 | <p>I have a program that i compiled and ran using third party lib on solaris 8. after it ran successfully I ported it to solaris 10 without issues. Do i really need to compile/link and create a new exe on solaris 10? despite me testing the executable I made on solaris 8? Seems weird that I would need to. can someone shed some light on this matter?</p>
<p>thanks</p>
| c++ | [6] |
4,672,161 | 4,672,162 | Universal Set Class - Copy Constructor | <p>Afternoon, guys and gals. </p>
<p>So I'm working on a universal set at the moment, trying to get my copy constructor to work. I have a node class finished. I'm at the point where everything seems to make sense to me, but it's still not working..</p>
<p><em>Granted, I'm still having issues wrapping my head around linked lists.</em></p>
<pre><code>template<class T>
set<T>::set(const set<T> & other) {
if(other.head == NULL) { head = NULL; }
else {
node <T> * s_ptr;
node <T> * d_ptr;
head = new node;
head -> get_data() = other.head -> get_data();
s_ptr = other.head -> set_link();
d_ptr = head;
while (s_ptr != NULL) {
d_ptr -> set_link() = new node;
d_ptr = d_ptr -> set_link();
d_ptr -> data = s_ptr -> get_data();
s_ptr = s_ptr -> link();
} //end while
d_ptr -> set_link() = NULL;
} //end else
}
</code></pre>
<p>Thanks in advance for any help. You guys are awesome.</p>
<p>Edit:
This is the code to set the link:
<code>void set_link(node * n){link = n;}</code></p>
<p>This is the code to get the data:
<code>T get_data(){return data;}</code></p>
<p>Edit 2:
It's not compiling for me. On the lines that declare a <code>new node</code> I am getting the error:
<code>expected type specifier before node</code>
<code>expected ';' before node</code></p>
<p>Am I missing a <code><T></code> somewhere?</p>
| c++ | [6] |
1,402,861 | 1,402,862 | Split a string "aabbcc" -> ["aa", "bb", "cc"] without re.split | <p>I would like to split a string according to the title in a single call. I'm looking for a simple syntax using list comprehension, but i don't got it yet:</p>
<pre><code>s = "123456"
</code></pre>
<p>And the result would be:</p>
<pre><code>["12", "34", "56"]
</code></pre>
<p>What i don't want:</p>
<pre><code>re.split('(?i)([0-9a-f]{2})', s)
s[0:2], s[2:4], s[4:6]
[s[i*2:i*2+2] for i in len(s) / 2]
</code></pre>
<p><strong>Edit</strong>:</p>
<p>Ok, i wanted to parse a hex RGB[A] color (and possible other color/component format), to extract all the component.
It seem that the fastest approach would be the last from sven-marnach:</p>
<ol>
<li><p>sven-marnach xrange: 0.883 usec per loop</p>
<pre><code>python -m timeit -s 's="aabbcc";' '[int(s[i:i+2], 16) / 255. for i in xrange(0, len(s), 2)]'
</code></pre></li>
<li><p>pair/iter: 1.38 usec per loop</p>
<pre><code>python -m timeit -s 's="aabbcc"' '["%c%c" % pair for pair in zip(* 2 * [iter(s)])]'
</code></pre></li>
<li><p>Regex: 2.55 usec per loop</p>
<pre><code>python -m timeit -s 'import re; s="aabbcc"; c=re.compile("(?i)([0-9a-f]{2})");
split=re.split' '[int(x, 16) / 255. for x in split(c, s) if x != ""]'
</code></pre></li>
</ol>
| python | [7] |
5,775,941 | 5,775,942 | java uses unchecked or unsafe operations recompile with xlint error? | <p>I'm getting a message that says I have unchecked and unsafe operations when I try to compile this binary search program. I looked at other posts on stackoverflow, but I couldn't figure out how to fix my code. Thanks!</p>
<pre><code>public binarySearch()
{
ArrayList<Integer> list = new ArrayList<Integer>();
for (int i=0;i<10;i++)
{
int rand = (int)(Math.random()*10);
list.add(rand);
System.out.print(list.get(i)+"\t");
if ((i+1)%10==0) System.out.println();
}
System.out.println("\n"+search(sort(list),0));
}
public ArrayList sort(ArrayList<Integer> listNum)
{
for (int i=0;i<listNum.size()-1;i++)
{
int min=10000;
int index=0;
for (int j=i;j<listNum.size();j++)
if (listNum.get(j)<min)
{
min=listNum.get(j);
index=j;
}
int temp = listNum.get(i);
listNum.set(i,listNum.get(index));
listNum.set(index,temp);
}
return listNum;
}
public boolean search(ArrayList<Integer> listNum, int num)
{
//need to sort list
int low = 0;
int high = listNum.size()-1;
while (low<=high)
{
int mid = (low+high)/2;
int midValue = listNum.get(mid);
if (num<midValue)
high = mid-1;
if (num>midValue)
low = mid+1;
if (num==midValue)
return true;
}
return false;
}
public static void main (String args[])
{
binarySearch app = new binarySearch();
}
</code></pre>
| java | [1] |
3,899,969 | 3,899,970 | another way to suggest combobox item | <p>Is there any way to let combobox suggest elements which not only start with combobox text?</p>
<p>I mean even if the combobox text has space between it's characters,
for example if combobox has these items </p>
<ul>
<li>hello </li>
<li>hi</li>
<li>hellothere</li>
</ul>
<p>when we try to type "he" or "h e" or "h e", the combobox would suggest <strong>hello</strong> and <strong>hellothere</strong></p>
| c# | [0] |
3,508,881 | 3,508,882 | Find changed properties of a class | <p>I am using asp.net 3.5</p>
<p>I have a license class containing 10 properties and not marked as serializable. I have to log property changes to the database. License is an entity class,and it is not in my scope to modify it. So I cannot mark it as serializabel neither i can use IpropertyChanged Interface.</p>
<p>Now i cannot store it in viewstate as it is not serializable. I wanted to store it so that i can compare it with new values and see which value has changed.</p>
<p>How to proceed with this.</p>
| c# | [0] |
1,445,778 | 1,445,779 | How to add new Column to contacts to make contacts groups(Friends,Family) | <p>I trying to modify the contact application to add column like groups in contacts application, can any one give an idea how to add it.
Thanks in Advance
Ranganath.T.M</p>
| android | [4] |
5,560,572 | 5,560,573 | Prevent form from refreshing the page | <p>Hey I am trying to use a form to submit data via JavaScript but it keeps refreshing the page when I don't want it to.</p>
<p>My form is like this:</p>
<pre><code><form name="myForm" method="post">
<input type="text" name="name"/>
<input type="submit" name="add" value="Add Resource" onclick="insert(); return false;"/>
</form>
</code></pre>
<p>My JS function has:</p>
<pre><code>function insert(e){
e.preventDefault();
var name = document.myForm.name;
console.log(name);
}
</code></pre>
<p>I was told prevent default is how you stop the default action of the form but it still happens for me. How do I fix it ?</p>
| javascript | [3] |
172,067 | 172,068 | Python math module doesn't have abs | <p>Hi this is a piece of code that is supposed to create a function that returns the absolute value of the inputted integer or float.
Can't seem to figure out what's wrong with it, here's the code and the error. Any help is appreciated!</p>
<p>here is the code for the function:</p>
<pre><code>import math
def distance_from_zero(num):
type_entry = type(num)
if type_entry == int:
return math.abs(num)
elif type_entry == float:
return math.abs(num)
else:
return "Not an integer or float!"
</code></pre>
<p>here is where I tested out the code by printing the result</p>
<pre><code>print distance_from_zero(4)
</code></pre>
<h3>here is the error that occurs</h3>
<pre><code>Traceback (most recent call last):
File "python", line 12, in <module>
File "python", line 5, in distance_from_zero
AttributeError: 'module' object has no attribute 'abs'
</code></pre>
| python | [7] |
391,390 | 391,391 | How to calculate value for a expression in a string, then return a new string? | <p>i read data from my config file like this:</p>
<pre><code>ip_vlan1 = "10.10.($id+100).5"
ip_vlan2 = "10.11.($id*2+1).6"
v.v...
</code></pre>
<p>And for each vlan, I want calculate vlan address for it, based on ID and vlan-expression:</p>
<pre><code>def calculate_vlan_id(id, vlan_exp):
...
return ip_addr # string
</code></pre>
<p><strong>Example:</strong></p>
<pre><code>def(3, ip_vlan1) --> result: "10.10.103.5"
def(5, ip_vlan2) --> result: "10.11.11.6"
</code></pre>
<p>Do you have a solution for this?</p>
<p>Thanks in advance, folks!</p>
| python | [7] |
4,918,367 | 4,918,368 | Why does updating an app clear its defaults? | <p>Let's say you have an app that declares itself able to handle a system intent like Phone and that the user selects it as the default app. When the market updates the app, why does it clear the defaults? Is there a way to prevent that, so if I wanted Dialer 1.0 to handle the phone button, Dialer 2.0 will still do it without me having to re-select it.</p>
| android | [4] |
2,565,607 | 2,565,608 | How to convert line breaks in input form in ASP.NET? | <p>How do you usually convert line breaks in a form textbox or input=text element to html line breaks?</p>
<p>Thanks</p>
<p>Edit: Is it always \r\n with all browsers?</p>
| asp.net | [9] |
3,419,351 | 3,419,352 | Browser overrides text on warning dialog using jQuery 1.4 | <p>I'm working on a requirement to show a warning box if the user is about to leave a page with unsaved changes. This is the code:</p>
<pre><code>$(function() {
$(':input',document.myForm).change(function() {
window.onbeforeunload = function() {
return "Are you sure you want to leave this page? You have unsaved changes!";
}
});
$('form').submit(function() {
window.onbeforeunload = function() { };
});
});
</code></pre>
<p>Everything functions fine, however, the text and the popup box get overridden by the browser. I've tried IE and Firefox, but they both seem to override my text and use their built-in warning popup. Is there a way around this to display a popup with my text and a jQuery dialog that I can configure?</p>
| jquery | [5] |
2,123,168 | 2,123,169 | How do you implement trees using vectors or arraylist? | <p>if possible please post some sample codes. Because we have a project wherein we need to set up locations within a map, and connect those locations with a line. Other than we also need to have a starting and end point in which we need to find a path going from the designated starting to the end point. </p>
| java | [1] |
124,098 | 124,099 | Applying a method to members of a class | <p>Say I have a C# class:</p>
<pre><code>public class Node
{
public double A { get; set; }
public double B { get; set; }
}
</code></pre>
<p>...and another class that includes a list of objects of that type:</p>
<pre><code>public Buffer
{
private List<Node> _nodes;
...
}
</code></pre>
<p>Now, say I need to calculate the sum of the values of A for the Node objects in the _nodes list. Then (separately) calculate the sum of B. Is there a way to do this using a 'generic' Sum() method, without having to duplicate code?</p>
<p>For example, one approach could be:</p>
<pre><code>public class Buffer
{
...
private double SumA()
{
double sum;
foreach (Node node in _nodes)
{
sum += node.A;
}
return sum;
}
private double SumB()
{
double sum;
foreach (Node node in _nodes)
{
sum += node.B;
}
return sum;
}
}
</code></pre>
<p>The problem here is that the basic algorithm implemented by SumA() and SumB() is the same but in the case above is duplicated. This is compounded if Node has more properties, which needs summing, or if Sum() is a much more complicated process (both of which are true in the case I'm currently refactoring).</p>
<p>So to put the question another way, is there a way I can have a single Sum() method but have it operate on whichever member(s) of class Node within the list that I need to sum?</p>
| c# | [0] |
4,841,650 | 4,841,651 | How to create such a PHP array in JavaScript? | <p>How to create such a PHP array in JavaScript?</p>
<pre><code>$arr = array('oneKey' => array('key1' => 'value1',
'key2' => 'value2'),
'anotherKey' => array('key1' => 'value1',
'key2' => 'value2'));
</code></pre>
<p><b>EDIT:</b> Guys, I forgot to mention that I would then need a simple way to sort those array('key1' => 'value1', 'key2' => 'value2') lexicographically by its keys.</p>
<p><b>EDIT2:</b> Actually I won't "convert" it. It's a way I explain things. I am more of a php guy.</p>
| javascript | [3] |
295,071 | 295,072 | Load Activities from external dex | <p>Is it possible to load activities from an external dex-file? I'm thinking of some plug-in style-architecture, where an application can be extended by downloading dex-files with activities and classes containing extra functionality.</p>
<p>I've managed to load and invoke methods on a class from a downloaded dex-file using DexClassLoader and reflection. But could I somehow use this technique to present download and present an Activity? Is it possible to register this new Activity programmatically so that I can invoke it using an Intent?</p>
<p>I know that it's possible (and the recommended way is) to install the other Activity through the normal procedure with an APK, and then load it from my main activity using Intents or simply update the installed application, but I want to extend my already installed application by downloading some extra classes and execute everything in the same VM, same sandbox.</p>
<p>Hm, let me know if you don't understand what I mean, cause this got a bit messy.. :)</p>
| android | [4] |
3,630,624 | 3,630,625 | Using jQuery delay() with css() | <p>Why does delay() work here:</p>
<pre><code>$('#tipper').mouseout(function() {
$('#tip').delay(800).fadeOut(100);
});
</code></pre>
<p>But this fails to delay:</p>
<pre><code>$('#tipper').mouseout(function() {
$('#tip').delay(800).css('display','none');
});
</code></pre>
<p>// EDIT - here's a working solution</p>
<pre><code>$('#tipper').mouseleave(function() {
setTimeout( function(){
$('#tip').css('display','none');
},800);
});
</code></pre>
| jquery | [5] |
606,154 | 606,155 | JQuery - Add a mouse-event listener to a class | <pre><code><div class="teamMain">
<div class="teamScroll">
PRIMO
</div>
<div class="teamScroll">
SECONDO
</div>
<div class="teamScroll">
TERZO
</div>
</div>
</code></pre>
<p>And i'd like to add a sort of listener (such mouseover or mouseout) for each of this div, by taking the class <em>teamScroll</em> as reference.</p>
<p>I know there is <em>delegate</em> method, but it works only with <strong>jquery-1.4.2</strong> version (which, as posted time ago for another <a href="http://forum.jquery.com/topic/jquery-problem-with-last-version-and-ie" rel="nofollow">problem</a>) broke some functions with IE6.</p>
<p>There is other way to do this without put N listener for N div?</p>
<p>Cheers</p>
| jquery | [5] |
2,261,027 | 2,261,028 | android: delete file from internal storage | <p>I'm trying to delete images stored in internal storage.
Looked through other similar questions on Stack, I've come up with this:</p>
<pre><code> File dir = getFilesDir();
File file = new File(dir, id+".jpg");
boolean deleted = file.delete();
</code></pre>
<p>from another question, which was answered with:</p>
<pre><code> File dir = getFilesDir();
File file = new File(dir, "my_filename");
boolean deleted = file.delete();
</code></pre>
<p>My example always returns false. I can see the file fx 2930.jpg in DDMS in eclipse.</p>
| android | [4] |
4,676,529 | 4,676,530 | How to format a phone number using PhoneNumberUtils? | <p>How can I format a phone number using <a href="http://developer.android.com/reference/android/telephony/PhoneNumberUtils.html" rel="nofollow">PhoneNumberUtils</a>?</p>
<p>E.g.: <code>1234567890</code> → <code>(123) 456-7890</code></p>
| android | [4] |
5,838,941 | 5,838,942 | Regex to test string in javascript | <p>I want to create regex for javascript to test string contain word like M.C.A or ACA etc.Regex should return true when these words entered like M.C.A, USD etc.
Regex should return false when enter string in textbox like</p>
<pre><code> .M.C.A
..MM
M..........A
M.C.A..
</code></pre>
<p>I can enter any word with dot or without dot but didn't want to enter string in textbox which
1: start with dot
2: contain more than one dot between each letter
3: not contain any number
4: start with letter only </p>
| javascript | [3] |
5,964,285 | 5,964,286 | How to dynamically switch between comparing Less Than, Greater Than, or Equal To? | <p>Basically I am giving the user an option to filter a set of files based on thier size.</p>
<p>The user picks a comparison type (Greater Than, Less Than, Equal To) from a drop down list, and then enters a size, in bytes, to compare to. This is what I have so far:</p>
<pre><code>switch (cmboCompareType.SelectedText)
{
case "Greater Than":
fileOK = fi[i].Length > int.Parse(txtByteValue.Text);
break;
case "Less Than":
fileOK = fi[i].Length < int.Parse(txtByteValue.Text);
break;
case "Equal To":
fileOK = fi[i].Length == int.Parse(txtByteValue.Text);
break;
}
</code></pre>
<p>Is there a more elegant way to do this sort of comparison without repeating so much code in C#?</p>
| c# | [0] |
1,361,776 | 1,361,777 | When and why is longjmp used in C++? | <p>I have read the following tutorial, but I don't understand it well. When is longjmp used and why it is necessary to know?</p>
<p><a href="http://www.cplusplus.com/reference/clibrary/csetjmp/longjmp/" rel="nofollow">http://www.cplusplus.com/reference/clibrary/csetjmp/longjmp/</a></p>
| c++ | [6] |
524,817 | 524,818 | Error - The import com.google can not be resolved | <p>I am new to android development. I got an error when I wrote the code </p>
<pre><code>import com.google.android.maps.MapView;
</code></pre>
<p>in eclipse. The error is <code>The import com.google can not be resolved.</code> </p>
<p>Please anybody give suggestion to fix this problem.</p>
| android | [4] |
1,270,835 | 1,270,836 | Java application launcher | <p>I have written a very simple Java application. Can anyone tell me how to create a launcher like icon to run that application both in Ubuntu and Windows ??</p>
<p>Thanks in advance..!!</p>
| java | [1] |
5,920,467 | 5,920,468 | Runs in IDE but not on Server | <p>I have a program which runs well on IDE and echo's successful with no errors.</p>
<p>But if the same program when run on a browser like firefox or chrome doesn't show up anything.</p>
<p>Its just a blank page.</p>
<p>Is there anything that i need to add in script to run on Browser or i am doing anything wrong?</p>
| php | [2] |
2,966,402 | 2,966,403 | clearing a link with javascript only works for the first link | <p>Found a bit of javascript that clears the link to current page. So far so good. It worked until there were more than one link.</p>
<pre><code>/*
CLCP v2.1 Clear Links to Current Page
Jonathan Snook
This code is offered unto the public domain
http://www.snook.ca/jonathan/
*/
window.onload = clearCurrentLink;
setTimeout("clearCurrentLink()",50);
function clearCurrentLink(){
var a = document.getElementsByTagName("A");
for(var i=0;i<a.length;i++)
if(a[i].href == window.location.href.split("#")[0])
removeNode(a[i]);
}
function removeNode(n){
if(n.hasChildNodes())
for(var i=0;i<n.childNodes.length;i++)
n.parentNode.insertBefore(n.childNodes[i].cloneNode(true),n);
n.parentNode.removeChild(n);
}
</code></pre>
<p>Thing is I can't figure out why it only clears the first link it finds.</p>
<p>I'm generating pages through node / expresss / jade / stylus. Any other ides on how to eliminate links to the current page? </p>
<p>Thanks!</p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.