Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
2,345,020 | 2,345,021 | $.post not working in firefox | <p>Here's my code it works fine in IE and Chrome, but not in FF</p>
<pre><code><script type="text/javascript">
function get() {
$.post(
'regAuth.php',
{usrName: login.usrName.value, password: login.password.value},
function (output) {
$('#error').html(output).show();
}
);
}
</script>
</code></pre>
| jquery | [5] |
5,391,001 | 5,391,002 | Dynamic Array Java program converted to C# | <p>The folowing program was orignally in java. But i still get 1 error with the program in C#.<br>
(the eror is listed in comment in the 2nd block of code).</p>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DynArray
{
public class DynArrayTester
{
static void Main(string[] args)
{
DynArray da = new DynArray(5);
for (int i = 1; i <= 7; i++)
{
da.setData(i, i);
//da.put(0, 0);
//da.put(6, 6);
}
Console.WriteLine(da);
}
}/*DynArrayTester*/
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DynArray
{
public class DynArray
{
//toestand
private int[] data;
//gedrag
public DynArray(int size)
{
data = new int[size];
}
public int getData(int index)
{
return data[index - 1];
}
private void expand(int size)
{
int[] tmp = data;
data = new int[size];
for (int i = 0; i < tmp.Length; i++)
{
data[i] = tmp[i];
}
}/*expand*/
public void setData(int index, int data)
{
if (0 < index)
{
if (index > this.data.length) // ***error, does not contain definition for "lenght" and no exetension method "lenght"***
expand(index);
this.data[index - 1] = data;
}
}
public override string ToString()
{
StringBuilder buf = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
buf.Append("[" + i + "]");
buf.Append(data[i]);
buf.Append('\n');
}
return buf.ToString();
}
}/*DynArray*/
</code></pre>
<p>}</p>
| c# | [0] |
351,129 | 351,130 | A way to override the constructor on HTMLElement so I can add custom code | <p>I'm trying to somehow override the constructor of HTMLElement (specifically HTMLDivElement), so that whenever any are created by whatever means, I can run some custom logic.</p>
<p>Obviously this doesn't work:</p>
<p><code><pre>
HTMLDivElement.prototype.constructor = function()
{
alert('div created!');
}
</pre></code></p>
<p>Is there a way to pull this off? Even if there was a way to get some sort of event/trigger when new elements where created (ones not part of the page's source HTML), that would be helpful.</p>
<p>EDIT: Maybe there is something we could do with Mozilla's watch/unwatch methods to watch for a change?</p>
| javascript | [3] |
2,998,221 | 2,998,222 | Call Show windows side by side in C# | <p>Dumb question is there an easy way to clear to the desktop and then open two explorer windows and call the "Show windows side by side" task bar call ? Just wondering if there is an api in an MS library way to do this.</p>
| c# | [0] |
4,056,913 | 4,056,914 | Jaxb2marshaller - using contextPath and classesToBeBound | <p>Is this possible? I have a service that may need to marshal objects from a significant number of projects, each with several object factories. I currently only specify a few specific classes that need to be marshalled on a regular basis. Can I add a list of contexts for the other projects, as well as keep my current list of classes? Or do I have to do one or the other?</p>
<p>With so many individual classes that may need to be marshalled, is it smarter to just simply use a list of contextpaths?</p>
| java | [1] |
4,400,149 | 4,400,150 | C# Accessing object properties indexer style | <p>Is there any tool,library that would allow me to access my objects properties indexer style ?</p>
<pre><code>public class User
{
public string Name {get;set;}
}
User user = new User();
user.Name = "John";
string name = user["Name"];
</code></pre>
<p>Maybe the dynamic key word could help me here ?</p>
| c# | [0] |
906,354 | 906,355 | Is it a reference to a function or what? | <p>What does the following declaration mean?</p>
<pre><code>typedef int (&rifii) (int,int);
</code></pre>
<p>Is it a reference to a function? If yes, shouldn't it be initialized?</p>
| c++ | [6] |
1,029,498 | 1,029,499 | Finding multiple words and print next line using Python | <p>I have huge text file. It looks as follows</p>
<pre><code>> <Enzymologic: Ki nM 1>
257000
> <Enzymologic: IC50 nM 1>
n/a
> <ITC: Delta_G0 kJ/mole 1>
n/a
> <Enzymologic: Ki nM 1>
5000
> <Enzymologic: EC50/IC50 nM 1>
1000
.....
</code></pre>
<p>Now i want to create python script to find words like (<code>> <Enzymologic: Ki nM 1></code>, <code>> <Enzymologic: EC50/IC50 nM 1></code>) and print next line to each word in tab delimited format as follows</p>
<pre><code>> <Enzymologic: Ki nM 1> > <Enzymologic: EC50/IC50 nM 1>
257000 n/a
5000 1000
....
</code></pre>
<p>I tried following code</p>
<pre><code>infile = path of the file
lines = infile.readlines()
infile.close()
searchtxt = "> <Enzymologic: IC50 nM 1>", "> <Enzymologic: Ki nM 1>"
for i, line in enumerate(lines):
if searchtxt in line and i+1 < len(lines):
print lines[i+1]
</code></pre>
<p>But it doesnt work can any body suggest some code...to acheive it.</p>
<p>Thanks in advance</p>
| python | [7] |
2,290,440 | 2,290,441 | C++, fastest method of getting angle into a specified range? | <p>what's the fastest way of getting a variable into a given range? For example, make sure that an angle "double alpha" is always within (0.0, 2*Pi).</p>
<p>I found two solutions myself, one of them is much slower and the other looks way to complicated for such an easy task. There must be a better way, or not?</p>
<pre><code>//short, but very slow (so it's a no-go);
return asin(sin(alpha));
//much faster, but seems ugly (two while loops to change a variable? come on!)
while (alpha < 0.0)
{
alpha += 2.0 * M_PI;
}
while (alpha >= 2.0 * M_PI)
{
alpha -= 2.0 * M_PI;
}
return alpha;
</code></pre>
| c++ | [6] |
3,063,215 | 3,063,216 | Basic Authentication | <p>I have one VS application named Dotnetpanel, which provides a lot of webservices.</p>
<p>I created another another VS application say TestModule in which I need to create the webservice client. But when I try to create a client and call the webservice in TestModule, an error occured"The request failed with HTTP status 401: Unauthorized." From one of articles I have read that</p>
<p>DotNetPanel API implemented as a set of SOAP Web Services.</p>
<p>Requirements:
WSE 3.0 or Basic Authentication
<strong>**Each API call should have user’s credentials provided**</strong></p>
<p>Basic Authentication:
For interacting with DotNetPanel API you should use Basic Authentication. DotNetPanel recognizes “Authorization” header with the user credentials provided in the following format: username:password.</p>
<p>So my question is I have a user credentials which can pass to the TestModule and after that how can I call the DotnetPanel webservices from the TestModule with Basic Authentication.</p>
<p>Regards</p>
<p>Fenix</p>
| asp.net | [9] |
1,449,142 | 1,449,143 | ASP.NET username/password security | <p>I'm using VS2010,C#,SQL Server to develop my ASP.NET web app, although this is not my first ASP.NET experience, but this time my project is more attack-prone and I should consider better security polices. I have a login screen as my first page, users enter their user name and password and a page specific to them is showed, in my last project, I used query strings (a userid) along with sessions for security purposes, but this time I've used just query strings, it means that at the moment one can enter myaddress.com?userid=1 and visit a page in my site!!!
I know this is not good, but what are my approaches, of courses I'm not working with banking or financial systems but I'm going to have an standard security policy, I should use sessions? cookies? can you suggest me an easy-to-develop and meanwhile secure way of implementing protection policies? any sample code or tips?</p>
<p>thanks</p>
| asp.net | [9] |
4,338,898 | 4,338,899 | Is it possible to add instance methods to all "classes" in JavaScript? | <p>This is more of an exploratory question, seeing how the core JavaScript stuff works. I realize the convention is to not override any core JavaScript classes, but I just can't seem to wrap my head around this one.</p>
<p>You can create what acts like "class methods" in JavaScript by adding to the core <code>Function</code> prototype like this:</p>
<pre><code>Function.prototype.class_method = function() {
console.log("class method called")
}
var User;
User = (function() {
function User() {}
return User;
})();
User.class_method(); // "class method called"
</code></pre>
<p>My question is, is there a way to add "instance methods" in a similar way? Something crazy like this, but what's below doesn't work (or make any sense):</p>
<pre><code>alias = Function.prototype.constructor;
Function.prototype.constructor = function() {
child = this;
child.prototype.instance_method = function() {
console.log("instance method called");
}
alias.apply(child);
}
var user = new User();
user.instance_method(); // method doesn't exist
</code></pre>
<p>It's almost like you'd need to override the <code>Function</code> class' <code>constructor</code> method and access the <code>prototype</code> from there. Is this possible?</p>
<p>It does work if you add to the <code>Object.prototype</code> like this:</p>
<pre><code>Object.prototype.instance_method = function() {
console.log("instance method");
}
var user = new User();
user.instance_method(); // "instance method called"
</code></pre>
<p>But that doesn't seem right either, mainly because seeing the output in the node.js console from <code>console.log({});</code> change is confusing:</p>
<pre><code>console.log({});
// {};
Object.prototype.instance_method = function() {
console.log("instance method");
}
console.log({});
// {"instance_method": [Function]}
</code></pre>
| javascript | [3] |
3,204,882 | 3,204,883 | convert image sequence using ffmpeg | <p>I have been using ffmpeg to convert a sequence of jpegs to a video using the following syntax</p>
<pre><code>ffmpeg -f image2 -i frame%d.jpg -vcodec mpeg4 -b 800k video.avi
</code></pre>
<p>it works a treat, however if the filenames dont start at 0 and then pursue in accending order I get weird results. for example the first file in the directory is frame1 and last file is fram 61.I should point out that im always using a list of jpegs which accend in incrental order. for example a list of files called frame1, fram2, fram3 etc.</p>
<p>the following works fine</p>
<pre><code>frame1.jpg to frame9.jpg
</code></pre>
<p>frame1.jpg to frame10.jpg
frame2.jpg to frame8.jpg
frame2.jpg to frame10.jpg
frame2.jpg to frame11.jpg
frame2.jpg to frame17.jpg
frame2.jpg to frame20.jpg
frame2.jpg to frame30.jpg
frame2.jpg to frame61.jpg </p>
<p>the following doesnt work</p>
<pre><code>26 to 57 fail
</code></pre>
<p>11 to 61 fail
10 to 61 fail
20 to 61 fail
24 to 61 fail</p>
<p>Can I modify the arguments for ffmpeg so that it will make the video regardless of the filenames? (frame%d) </p>
| c# | [0] |
175,954 | 175,955 | How to select the first item in an array | <p>I am having an array for example a <code>['global','flexible','testing']</code> in a JSON response. But on the HTML page i might be having 50 global terms, 20 flexible terms and 100 testing terms. But how to highlight only the first global, first flexible and first testing. I tried with each loop, but getting script error issue. How todo it?</p>
<p>Here is the code...</p>
<pre><code> response= {"glossary":{"errorFlag":"false","terms":"global,flexible,testing","description":"tetestst setwe wetwet tewtw"}};
glossaryterms=response.glossary.terms.split(',');
//console.log(glossaryterms);
$(glossaryterms).each(function(i,term){
$('#contentId').highlight(term, { wordsOnly: true, className: 'terms' + i });
var clss="." + "terms" + i;
$("#contentId").find(clss).eq(0).addClass("gloss_highlight");
var gloss_content = $('#contentId .gloss_highlight');
$(gloss_content).each(function(i,obj){
if($(obj).html().toLowerCase()==term.toLowerCase()){
$(obj).bind('click',function(e) {
$('.glossary').remove();
gloss.glossary.getglossarydesc(term,$(obj));
});
}
});
});
</code></pre>
| jquery | [5] |
5,936,124 | 5,936,125 | "is" not working in python IDE but working in command line | <p>I couldn't understand why this is happening actually..</p>
<p>Take a look at this python code :</p>
<pre><code> word = raw_input("Enter Word")
length = len(word)
if word[length-1:] is "e" :
print word + "d"
</code></pre>
<p>If I give input "love", its output must be "loved". So, when I wrote this in PyScripter IDE, its neither showing error nor the output. But I tried the same code in python shell, its working! </p>
<p>I'd like to know why this is happening.</p>
| python | [7] |
2,517,962 | 2,517,963 | Using reflection to update embedded resource in an assembly? | <p>I have an exe file that has embedded resource inside. I'd need to write another application that would open the exe, update it's resource and save it back as a valid executable. (I can't recompile it because machine where it'll be run may not have it's source available).</p>
<p>Is that possible and how (I need an idea or possibly a link, not asking for a full solution)?</p>
<p>Edit: Assembly I need to update is a .NET 3.5 assembly.</p>
| c# | [0] |
1,550,514 | 1,550,515 | I'm creating a page that uses Linqfor data access and I'm using DataList to display data. How can I use Linq to do data paging in asp.net using C#? | <p>I'm creating a page that uses Linqfor data access and I'm using DataList to display data.How can I use Linq to do data paging in asp.net?can anyone plz show both the aspx part aspx.cs part?can anyone plz show both the aspx part aspx.cs part?</p>
| c# | [0] |
4,816,216 | 4,816,217 | Jquery - Get the latest element in a div | <pre><code><div class="content">
<div class="tlcontent">
<div class="sideon" id="sideline0">
somethings
</div>
<div class="trackon" id="trackline0">
somethings
</div>
<div class="sideon" id="sideline1">
somethings
</div>
<div class="trackon" id="trackline1">
somethings
</div>
<div class="sideon" id="sideline2">
somethings
</div>
</div>
</div>
</code></pre>
<p>How can select (with jquery) the latest element of this div with classname trackon? (in this case, the #trackline1)
cheers</p>
| jquery | [5] |
3,569,820 | 3,569,821 | How to post Imageview image to server? | <p>Hi all I have an imageview where I am setting image and on click that image send to server please suggest me how I can do it</p>
| android | [4] |
4,099,642 | 4,099,643 | C++ Templated Virtual Function | <p>Templated virtual member functions are not supported in C++ but I have a scenario where it would be ideal. Im wondering if someone has ideas for ways to accomplish this.</p>
<pre><code>#include <iostream>
class Foo {
public:
virtual void bar(int ){}
// make a clone of my existing data, but with a different policy
virtual Foo* cloneforDB() = 0;
};
struct DiskStorage {
static void store(int x) { std::cout << "DiskStorage:" << x << "\n"; }
};
struct DBStorage {
static void store(int x) { std::cout << "DBStorage:" << x << "\n"; }
};
template<typename Storage>
class FooImpl : public Foo {
public:
FooImpl():m_value(0) {}
template<typename DiffStorage>
FooImpl(const FooImpl<DiffStorage>& copyfrom) {
m_value = copyfrom.m_value;
}
virtual void bar(int x) {
Storage::store(m_value);
std::cout << "FooImpl::bar new value:" << x << "\n";
m_value = x;
}
virtual Foo* cloneforDB() {
FooImpl<DBStorage> * newfoo = new FooImpl<DBStorage>(*this);
return newfoo;
}
int m_value;
};
int main()
{
Foo* foo1 = new FooImpl<DiskStorage>();
foo1->bar(5);
Foo* foo2 = foo1->cloneforDB();
foo2->bar(21);
}
</code></pre>
<p>Now if I want to clone the Foo implmemetation, but with a different Storagepolicy, I have to explicitly spell out each such implementation:</p>
<pre><code>cloneforDB()
cloneforDisk()
</code></pre>
<p>A template parameter would have simplified that.
Can anyone think of a cleaner way to do this?
Please focus on the idea and not the example, since its obviously a contrived example.</p>
| c++ | [6] |
4,519,891 | 4,519,892 | WebView Failed error in iPhone | <p>I am trying to load website in webview.But i am getting error. Please correct me where i am wrong </p>
<p>URL : <a href="http://www.facebook.com/pages/Fresh-Caesar/144860502248864" rel="nofollow">http://www.facebook.com/pages/Fresh-Caesar/144860502248864</a>
Error : The operation couldn’t be completed. (WebKitErrorDomain error 101.)</p>
| iphone | [8] |
2,670,493 | 2,670,494 | jQuery toggle functions only assign a css to an element for a second (then removes it)? | <p>I have this HTML:</p>
<pre><code> <div class="user-contribution">
<p class="user-review"> Review</p> 2. Animate this
<a class="user-review-toggle" href="#">Read more...</a> // 1. Clicking this
</code></pre>
<p>this CSS:</p>
<pre><code> .user-contribution {
overflow: hidden;
img {
float: left;
margin: 0 15px 0 0;
overflow: hidden;
}
.user-review {
font-size: 12px;
line-height: 14px;
overflow: hidden;
}
</code></pre>
<p>and this JS:</p>
<pre><code> $(".user-review-toggle").toggle(function(){
$(this).css("backgroundPosition", "0 -12px");
$(this).prev('.user-review').animate({height:150},200);
$(this).prev('.user-review').css("overflow", "visible");
},function(){
$(this).css("backgroundPosition", "0 0");
$(this).prev('.user-review').animate({height:98},200);
$(this).prev('.user-review').css("overflow", "hidden");
});
</code></pre>
<p>For some reason, when I click the <code>.user-review-toggle</code> link the <code>overflow: visible</code> is only applied to the <code>user-review</code> div for a seconds then it returns to hidden (I should stay visible).</p>
<p>Any suggestions to fix this?</p>
| jquery | [5] |
2,894,652 | 2,894,653 | How to add effects on bitmap in android? | <p>I am creating an android Application that will add effect on Bitmap.
Is there any library for generating effects on bitmap?</p>
<p>Please provide me a sample or a link .I search on google and also on stackOverflow but i
couldn't find any thing helpfull.</p>
<p>thankx in advance</p>
| android | [4] |
1,135,917 | 1,135,918 | Please explain this e-mail validation regular expression: | <p>I have this script uses regular expressions to check that a form field contains a valid email address.Please explain me from declare</p>
<pre><code>var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i;
</code></pre>
<p>Thank you</p>
<p>Source:</p>
<pre><code><script type="text/javascript">
/***********************************************
* Email Validation script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}
</script>
<form>
<input name="myemail" type="text" style="width: 270px"> <input type="submit" onClick="return checkmail(this.form.myemail)" value="Submit" />
</form>
</code></pre>
| javascript | [3] |
898,371 | 898,372 | how do i change this code for videos? | <p>This is my code below which takes a picture from gallery to save in database. How do I change this piece of code for videos? What I write instead of bitmap? Please help me how do I change??? I want change this code to take video from gallery safe in internal memory and safe is path in database is work fine for photos now I want to change for videos.</p>
<pre><code> public void SelecedtPhotos()
{
final int len = thumbnailsselection.length;
// int cnt = 0;
for (int i =0; i<len; i++)
{
if (thumbnailsselection[i])
{
//cnt++;
BitmapFactory.Options options = new
BitmapFactory.Options();
options.inSampleSize = 8;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile(arrPath[i],
options);
}
try {
File photos=new File(getFilesDir(), "photos");
FileOutputStream outputStream=new FileOutputStream(new File(photos,
FileName(arrPath[i])));
outputStream.write(getBitmapAsByteArray(bitmap));
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
db = new DataBase(getBaseContext());
try {
db.createDataBase();
} catch (IOException e1) {
e1.printStackTrace();
}
db.insert_update("INSERT INTO Photos(name,ext,path) VALUES
('"+FileName(arrPath[i])+"','"+fileExt(arrPath[i])+"','"+arrPath[i]+"')");
db.close();
File file = new File(arrPath[i]);
boolean t = file.delete();
}
</code></pre>
| android | [4] |
3,432,499 | 3,432,500 | Use MakeCert to Authenticate | <p>I am doing a project on Verifying/Authenticating School Certificates to make sure that its real. Anyone has any ideas how to do it using MakeCert.exe in C#</p>
| c# | [0] |
3,012,079 | 3,012,080 | Is there any way to convert plain text into HTML with line breaks? | <p>I have a PHP script which retrieves the contents of a raw / plain-text file and I'd like to output this raw text in HTML, however when it's outputted in HTML all the line breaks don't exist anymore. Is there some sort of PHP function or some other workaround that will make this possible?</p>
<p>For example, if the raw text file had this text:</p>
<p>hello<br />
my name is</p>
<p>When outputted in HTML, it will say:</p>
<p>hello my name is</p>
<p>Is there any way to preserve these line breaks in HTML? Thank you.</p>
<p>(If it helps, my script gets the contents of the raw text file, puts it inside a variable, and I just echo out the variable.)</p>
| php | [2] |
4,324,489 | 4,324,490 | Python text search question | <p>I wonder, if you open a text file in Python. And then you'd like to search of words containing a number of letters. </p>
<p>Say you type in 6 different letters (a,b,c,d,e,f) you want to search.
You'd like to find words matching at least 3 letters.
Each letter can only appear once in a word.
And the letter 'a' always has to be containing. </p>
<p>How should the code look like for this specific kind of search?</p>
| python | [7] |
1,848,489 | 1,848,490 | Brackets around 0 in "return (0);" statement in 'main' function - what are they for? | <p>Usually auto-generated c++ "main" function has at the end</p>
<pre><code>return (0);
</code></pre>
<p>or</p>
<pre><code>return (EXIT_SUCCESS);
</code></pre>
<p>But why there are parentheses in above statements? Is it related to C language or something?</p>
<p>// EDIT</p>
<p>I know this is correct, but someone put these brackets for a reason. What's the reason?!</p>
| c++ | [6] |
2,422,901 | 2,422,902 | NSUSERDefaults class HAVE PROBLEM OR NOT? | <pre><code>NSString *string = @"Hardwork";
NSUserDefaults* defs111 = [NSUserDefaults standardUserDefaults];
[defs111 setObject:string forKey:@"first_name_textfield"];
</code></pre>
<p>Hi,
In my code I'm unable to set this value string for key first_name_textfield.
Why is it,so?</p>
| iphone | [8] |
3,856,521 | 3,856,522 | How can i display stringBuilder objects as well as Arraystring in alert box in asp.net | <p>when we store more than one string in arraystring or in stringbuilder class objects.then how can we print it on alert box in asp.net</p>
| asp.net | [9] |
3,797,537 | 3,797,538 | Android how to create activity only if it wasn't created yet | <p>I have a problem cause when I go to different activities using startActivity function,
they always get created from scratch. Even if activity A was visited before, when I go to activity B and then A again, activity A is created again.</p>
<p>The problem is with back button, cause if I go to Activity A then B then A and then B,
in order to close the application I have to press back button 4 times.
I guess that it shouldn't act like it and user should be able to go to activity A when first pressed back button and the second press should close the application.</p>
<p>How to solve this issue?
Greetings</p>
| android | [4] |
1,022,507 | 1,022,508 | Root Path Problem in asp.net? | <p>in my application a link button is there when i click on it it redirect to another page. But when i click on that page it is giving error like this...</p>
<p>Cannot use a leading .. to exit above the top directory.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
<p>Exception Details: System.Web.HttpException: Cannot use a leading .. to exit above the top directory.</p>
| asp.net | [9] |
2,592,699 | 2,592,700 | If all input fields are dirty return true, How? | <p>If <strong>all</strong> fields in the form are dirty return true if not then return false.
Here is my code.</p>
<pre><code>function getHasChanges() {
var hasChanges = false;
$(":input:not(:button):not([type=hidden])").each(function () {
if ((this.type == "text" || this.type == "textarea" || this.type == "hidden") && this.defaultValue != this.value) {
hasChanges = true;
return false; }
else {
if ((this.type == "radio" || this.type == "checkbox") && this.defaultChecked != this.checked) {
hasChanges = true;
return false; }
else {
if ((this.type == "select-one" || this.type == "select-multiple")) {
for (var x = 0; x < this.length; x++) {
if (this.options[x].selected != this.options[x].defaultSelected) {
hasChanges = true;
return false;
}
}
}
}
}
});
return hasChanges;
}
</code></pre>
<p>I used this code and tried to manipulate it but I couldn't figure it out.</p>
<p><strong>My question is:</strong> How to check if all fields on the form are dirty?</p>
| jquery | [5] |
3,878,569 | 3,878,570 | Form Submission in Pop Up Window using Javascript | <p>I have a requirement that i have to submit a form with values in javascript.
That method is "POST" type.</p>
<p>The form submission should be in new pop up window.
The current window will have to remains the same.....</p>
| javascript | [3] |
3,044,546 | 3,044,547 | Sending Data in Aeroplane Mode | <p>I am developing a chronometer app for iPhone which will used by the drivers in races. There will be a countdown. If user receives any call, in that case, the countdown will be paused. so I thought if user run his iPhone in Aeroplane mode, then he will not receive any call. But my problem is that, User will also have to send the data to the server during the race. But in aeroplane mode, it can't be done. I thought that user can divert the calls, it may work but is there any other better way for this or this is the only way? If I am not clear please let me know. </p>
| iphone | [8] |
1,369,045 | 1,369,046 | Access denied error | <p>i created a web application on (Machine 1) and published it in IIS 7 (this machine running windows server 2008),from another machine (machine 2) running windows 2008 i send url string to create local windows account on the other machine (i.e machine1) but i always get access denied error.</p>
<p>here th code snippet of create user account on machine1</p>
<pre><code> protected void Page_Load(object sender, EventArgs e)
{
try
{
if (Request.QueryString["UserName"] != null)
{
if (createUserAccount(Decrypt(HttpUtility.UrlDecode(Request.QueryString["UserName"].ToString())), Decrypt(HttpUtility.UrlDecode(Request.QueryString["Password"].ToString())), Convert.ToDateTime(HttpUtility.UrlDecode(Request.QueryString["ExpireDate"].ToString()))))
Response.Write("user created successfuly");
else
Response.Write("failed");
}
else if (Request.QueryString["Account"] != null)
{
if(ChangeExpirationDate(Decrypt(HttpUtility.UrlDecode(Request.QueryString["Account"].ToString())),Convert.ToDateTime(HttpUtility.UrlDecode(Request.QueryString["newExpireDate"].ToString()))))
Response.Write("expiration date was updated successfuly");
else
Response.Write("failed");
}
}
catch (Exception)
{
Response.Redirect("AccessDeniedPage.aspx");
}
}
Boolean createUserAccount(String User, String Pass,DateTime expirationDate)
{
try
{
String currentuser=Environment.UserName;//IUSER
DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntry NewUser = AD.Children.Add(User, "user");
NewUser.Invoke("SetPassword", new object[] { Pass });
NewUser.Invoke("Put", new object[] { "Description", "Virtual account to connect to PLC LAB" });
NewUser.Invoke("Put", new object[] { "AccountExpirationDate", expirationDate });
NewUser.CommitChanges();
DirectoryEntry grp;
grp = AD.Children.Find("Administrators", "group");
if (grp != null)
{
grp.Invoke("Add", new object[] { NewUser.Path.ToString() });
}
return true;
}
catch (Exception exception)
{
return false;
}
}
</code></pre>
<p>please help</p>
| asp.net | [9] |
5,947,940 | 5,947,941 | Access instance variable name within class | <p>A little background - I am playing around with pygame, and want to create a dictionary of all Mob class instances' positions.</p>
<p>The way I see it:</p>
<pre><code>human = Mob(pos)
mob_positions = {human : pos}
</code></pre>
<p>So every time I call <code>Mob.__init__()</code> I wanted to add a <code>pos</code> to <code>mob_positions</code> dict.</p>
<p>How do I access current instance variable name? Or is it extremely wrong approach?</p>
| python | [7] |
388,825 | 388,826 | Code equivalent for android:password="false" | <p>I'd like to ask a simple question, what is the equivalent <strong>android code</strong> for <strong>android:password="false"</strong> on the xml layout file. (I googled it but can't find the result:) )</p>
<p>Thank you</p>
| android | [4] |
84,577 | 84,578 | Download specific file from FTP using python | <p>quick and simple:</p>
<p>I have the following function, works well if i specify the file name.</p>
<pre><code>import os
import ftplib
def ftpcon(self, host, port, login, pwd, path):
ftp = ftplib.FTP()
ftp.connect(host, port, 20)
try:
ftp.login(login, pwd)
ftp.cwd(path)
for files in ftp.nlst():
if files.endswith('.doc') or files.endswith('.DOC'):
ftp.retrbinary('RETR ' + files, open(file, 'wb').write)
print files
</code></pre>
<p>But when i use the for loop with ftp.nlst() to try to match an specific type of file, i receive the error:</p>
<blockquote>
<p>coercing to Unicode: need string or buffer, type found</p>
</blockquote>
<p>Since im not sure if this is the best way to do it, what could the "correct" way to download a file ? </p>
| python | [7] |
2,657,189 | 2,657,190 | Have any Professional course (certification program) for iPhone developer? | <p>Have any Professional course (certification program) for iPhone developer? Like MCAD for Microsoft .NET developer and Zend for PHP developer.</p>
| iphone | [8] |
3,221,356 | 3,221,357 | Populating a TextBox from a text file | <p>Im trying to get specific lines from a file and put them in a another string or maybe if we can put it in anothe textbox it wont be a prob :P</p>
<pre><code>string[] msglines;
msglines = System.IO.File.ReadAllLines(@"C:\\Users\xA\Desktop\MESSAGES.txt");
for (int x = 0; x < msglines.Length; x++)
{
this.textBox5.Text = msglines[c];
c = c + 2;
}
</code></pre>
<p>I get a :
Index was outside the bounds of the array.</p>
| c# | [0] |
4,952,800 | 4,952,801 | Sort by two values prioritizing on one of them | <p>How would I sort this data by <code>count</code> and <code>year</code> values in ascending order prioritizing on the <code>count</code> value? </p>
<pre><code>//sort this
var data = [
{ count: '12', year: '1956' },
{ count: '1', year: '1971' },
{ count: '33', year: '1989' },
{ count: '33', year: '1988' }
];
//to get this
var data = [
{ count: '1', year: '1971' },
{ count: '12', year: '1956' },
{ count: '33', year: '1988' },
{ count: '33', year: '1989' },
];
</code></pre>
| javascript | [3] |
5,262,941 | 5,262,942 | Setting only a setter property | <p>I have an object model that has a property like this:</p>
<pre><code>public class SomeModel
{
public string SomeString { get; set; }
public void DoSomeWork()
{
....
}
}
</code></pre>
<p>I want the <code>DoSomeWork</code> function to execute automatically after the <code>SomeString</code> property changes. I tried this but it's not working:</p>
<pre><code>public string SomeString { get; set { DoSomeWork(); } }
</code></pre>
<p>What's the correct syntax?</p>
| c# | [0] |
2,245,911 | 2,245,912 | Mastering C++ to prepare for my second year: How? | <p>I'm going to my second year of Computer Science at a local University, in which C++ is a large part of the education, but as they only give an introductory course in the first year (basics, pointers, creating a linked list and an implementation of a game like Mastermind), I'd like to program a bit in my free time to crank up my knowledge about the language.</p>
<p>Is there a site that shows little problems or projects to make, to crank up my knowledge? As reading in "The C++ programming language", or saying "I'm going to crank up my knowledge about x" isn't quite as handy to learn from, compared to saying "I'm going to create a mastermind game", which can be extended quite far, and those are the kind of projects that they give in School classes that are excellent to master the language from.</p>
<p>So in short: Are there any sites which offer little problems and projects like this?</p>
<p>Thanks!</p>
| c++ | [6] |
932,252 | 932,253 | opening a pcap file in python | <p>I'm trying to open a .pcap file in python. can anyone help with this? each time I try this, it gives an error message that <code>"IOError: [Errno 2] No such file or directory: 'test.pcap'"</code></p>
<pre><code>import dpkt
f = open('test.pcap')
pcap = dpkt.pcap.Reader(f)
</code></pre>
| python | [7] |
1,171,663 | 1,171,664 | Repetitive sequence constructor | <p>Can I build a </p>
<pre><code>vector<vector<int> >
</code></pre>
<p>using Repetitive sequence constructor?</p>
<p>I know I can build one like </p>
<pre><code>vector<int> v(10, 0);
</code></pre>
<p>but I dont know how to build a vector of vector using this same method. Thank you!</p>
| c++ | [6] |
1,493,041 | 1,493,042 | using datatype in php is possible? | <p>i have seen this in php (symfony):</p>
<pre><code> public function executeShow(sfWebRequest $request)
{
// logic
}
</code></pre>
<p>i didnt know that you could declare a datatype in php?</p>
<p>have i missed something?</p>
<p>could someone explain this.</p>
<p>thanks</p>
| php | [2] |
2,983,864 | 2,983,865 | jQuery: find multiple element types having a certain attribute | <p>I currently have the following code:</p>
<pre><code>$('input[data-geo], select[data-geo]').doSomething()
</code></pre>
<p>Ideally I'd like to only declare the <code>[data-geo]</code> attribute once. Not sure if this is possible, but something along the lines of:</p>
<pre><code>$('(input, select)[data-geo]')
</code></pre>
<p>Any ideas?</p>
| jquery | [5] |
5,899,975 | 5,899,976 | PHP exec Failing with Status = 3 | <p>I have the following code snippet:</p>
<pre><code>$app = '"' . getcwd() . "\\prog.exe" . '"';
exec("$app param1 param2", $output, $status);
</code></pre>
<p>It runs fine locally on EasyPHP-12.1, but when I uploaded it to the deployment server, it failed with $status==3. I tried leaving out the path like so:</p>
<pre><code>exec("prog.exe param1 param2", $output, $status)
</code></pre>
<p>Again, it ran fine locally, but failed on the server.</p>
<p>Can you think of anything that I could be doing wrong? </p>
| php | [2] |
3,633,406 | 3,633,407 | Android,CustomListView | <p>How could i decide size of each line in a ListView?</p>
<p>My problem is that i have a list of text and now each text (each line) is different in length but the size of the text is the same, so the problem is if the text is big my ListView will not be adjust for the text and will cut part of it.</p>
<p>I use this class to build the ListView:</p>
<pre><code> private class ListAdapter extends ArrayAdapter<Medicaments> { // --CloneChangeRequired
private ArrayList<Med> mList; // --CloneChangeRequired
private Context mContext;
public ListAdapter(Context context, int textViewResourceId,ArrayList<Med> list) { // --CloneChangeRequired
super(context, textViewResourceId, list);
this.mList = list;
this.mContext = context;
}
public View getView(int position, View convertView, ViewGroup parent)
{
View view = convertView;
try{
if (view == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = vi.inflate(R.layout.singleresult, null); // --CloneChangeRequired(list_item)
}
final Med listItem = mList.get(position); // --CloneChangeRequired
String Res=listItem.getMed().substring(0, 1).toUpperCase()+listItem.getMed().substring(1).toLowerCase();
Res=WordUtils.capitalize(Res);
if (listItem != null) {
( (TextView) view.findViewById(R.id.resultTextView) ).setText( Res+"\n");
}}catch(Exception e){
Log.i(ResultView.ListAdapter.class.toString(), e.getMessage());
}
return view;
}
}
</code></pre>
<p>Thanks for helping!!</p>
| android | [4] |
3,140,632 | 3,140,633 | Application has stopped unexpectedly. Please try again | <p>My android app gives the following when I try to run it....</p>
<p>The application OxfordApp has stopped unexpectedly. Please try again.</p>
<p>My code is as follows:</p>
<pre><code>package oxfordlife.com.android;
public class OxfordApp extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.array_name, android.R.layout.simple_spinner_item );
adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
Spinner s = (Spinner)findViewById(R.id.spinner1);
s.setAdapter(adapter);
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
</code></pre>
<p>I am populating the spinner from the string.xml file as follows:</p>
<pre><code><string-array name="array_name">
<item>Array Item One</item>
<item>Array Item Two</item>
<item>Array Item Three</item>
</string-array>
</code></pre>
<p>The app works fine if I dont try to bind the data to the spinner but as soon as I try to populate it the error is thrown. Can anyone see what I may be doing wrong here ??</p>
| android | [4] |
220,160 | 220,161 | Various Ways Of Declaring Functions In JavaScript | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname">JavaScript: var functionName = function() {} vs function functionName() {}</a> </p>
</blockquote>
<p>I was doing some reading up in JavaScript and came to know that there are three ways of declaring a JavaScript function.</p>
<pre><code>var someFunction = function someFunction () {
};
var someFunction = function () {
};
function someFunction() {
}
</code></pre>
<p>Could anybody explain to me the difference between those various ways of declaring functions, and if any is preferred over the other?</p>
| javascript | [3] |
5,861,902 | 5,861,903 | map view is struck in android | <p>i am developing android applicaiton disply user overlays on map.user values getting from webservices for disply overlays.when i tap on map and move it is calling draw method and connecting to webservices while connecting webservice and getting data my apps is struck</p>
<p>show force close error .how can i resolve this problem</p>
| android | [4] |
4,867,320 | 4,867,321 | A Python gotcha: Stray comma at end of simple assignment | <p>I just spent the better part of a day finding a bug caused by a stray comma at the end of an assignment statement. The difficulty in finding my bug was exacerbated by a third-party callback library that was trapping exceptions but it made me wonder why Python (2.x) doesn't raise a syntax error instead of creating a tuple. Consider the following</p>
<pre><code>>>> a = 1,
>>> a
(1,)
</code></pre>
<p>As you can see, the trailing comma creates a singleton tuple. It's not a violation of the Python grammar (see <a href="http://docs.python.org/reference/expressions.html#grammar-token-expression_list" rel="nofollow">http://docs.python.org/reference/expressions.html#grammar-token-expression_list</a>) but it can certainly lead to some unexpected results, e.g. </p>
<pre><code>>>> a == 1,
(False,)
</code></pre>
<p>vs</p>
<pre><code>>>> (1,) == a
True
</code></pre>
<p>Although I now understand what's going on, I'm puzzled about why Python permits this syntax instead of requiring explicit parentheses to create a tuple. <strong>Is there some case where this behavior is necessary, or at least advantageous?</strong> I've been programming almost exclusively in Python for the past 7 years and I've never needed to create a singleton this way. Python is, in most respects, a wonderfully readable and explicit language. This particular "feature" seems, well, un-Pythonic. </p>
| python | [7] |
1,697,359 | 1,697,360 | php shows code only sometimes | <p>I'm studying PHP (so I'm a rookie). I'm working on a PC (windows 7) with XAMPP, Apache.</p>
<p>I have two files exampleform.html:</p>
<pre><code><html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html>
</code></pre>
<p>and welcome.php:</p>
<pre><code><html>
<body>
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html>
</code></pre>
<p>I created those 2 files and worked well. On Monday I encountered the problem that upon clicking the buttom summit query it would show me the code instead the result. I searched few forums and found I need to add the following lines to httpd.conf (xampp/apache/conf/):</p>
<p>AddType application/x-httpd-php-source .phps</p>
<p>AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .php</p>
<p>Then it worked.
Today when I try again it shows me the code once more.
Please help. It can't be so complicated!</p>
| php | [2] |
4,170,128 | 4,170,129 | Why import when you need to use the full name? | <p>In python, if you need a module from a different package you have to import it. Coming from a Java background, that makes sense.</p>
<pre><code>import foo.bar
</code></pre>
<p>What doesn't make sense though, is why do I need to use the full name whenever I want to use bar? If I wanted to use the full name, why do I need to import? Doesn't using the full name immediately describe which module I'm addressing?</p>
<p>It just seems a little redundant to have <code>from foo import bar</code> when that's what <code>import foo.bar</code> should be doing. Also a little vague why I had to import when I was going to use the full name.</p>
| python | [7] |
5,082,995 | 5,082,996 | Should jQuery .on() work on mobile (iPhone Safari)? | <p>I'm using the following:</p>
<pre><code>$('#container').on('click', 'a', function() {
//bla
});
</code></pre>
<p>and what happens is that the whole <code>#container</code> gets highlighted by the click and not the <code>a</code> and the event doesn't work.<br> Any ideas why?</p>
| jquery | [5] |
965,595 | 965,596 | Run a method thats name was passed as a string | <p>I have a C# method that takes a string as an argument, that string contains the name of a static method e.g</p>
<pre><code>"MyClass.GetData"
</code></pre>
<p>Is it possible to run that method from the value passed in the string?</p>
| c# | [0] |
2,339,608 | 2,339,609 | Navigation Bar at Bottom | <p>Can we have NavigationBar at the bottom of the screen.As i have to display a image at the top of the screen.</p>
| iphone | [8] |
5,146,875 | 5,146,876 | An expression that's equivalent to the return keyword | <pre><code>void Foo()
{
var xMaybeNull = GetX();
if (xMabyeNull == null) return; // Some way to get rid of this extra
// sentence without loosing the check
// do stuff
}
</code></pre>
<p>The easy way would be this, but the compiler expects an expression.</p>
<pre><code>void Foo()
{
List<Disc[,]> xNeverNull = GetX() ?? return;
// do stuff
}
</code></pre>
<p>The question is, is there any way to write the <code>someSortOfReturnExpression</code> (I guess not) or another solution, that can do what I'm looking for on one line?</p>
<pre><code>void Foo()
{
List<Disc[,]> xNeverNull = GetX() ?? someSortOfReturnExpression;
// do stuff
}
</code></pre>
| c# | [0] |
4,739,017 | 4,739,018 | 32 Bit Com Server on 64 Bit System | <p>i developed a Com Server and on windows XP 32 bit. To Test the Com Server i created a Client with C# to call the Functions via Interop.
Everything works fine, but now i need to get the ComServer run on a Windows 7 64 bit System.
I took the ComServer DLL and the C# EXE to the 64 bit Computer, registered the ComServer DLL with regsrv32 and started the C# Program.
Wen i first tried to access a ComServer Function all i get is the Error:</p>
<blockquote>
<p>System.Runtime.InteropServices.COMException (0x80040154): Die COM-Klassenfactory für die Komponente mit CLSID {BA4D7F46-A47E-4CB9-A153-2B4657C4DD29} konnte aufgrund des folgenden Fehlers nicht abgerufen werden: 80040154.</p>
</blockquote>
<p>in English:</p>
<blockquote>
<p>System.Runtime.InteropServices.COMException (0x80040154): The COM-Classfactory for the Component with the CLSID {BA4D7F46-A47E-4CB9-A153-2B4657C4DD29} was not able to be called due to the Error: 80040154.</p>
</blockquote>
<p>Whhat is going wrong here? Isn't it possible to call a 32 Bit DLL on a 64 Bit System? If yes, how do all the other 32 bit Programs work?</p>
<p>regards
camelord</p>
| c++ | [6] |
3,750,084 | 3,750,085 | How to eliminate unused arguments in an opacity fade? | <p><code>element</code> is called but never used, they are just passed back to a another function call. This seems like a waste is there a better way to do this?</p>
<p><strong>Initial Call</strong></p>
<pre><code>fadeUp( document.getElementById( 'test' ), 3000 );
</code></pre>
<p><strong>Fades the opacity of an element up for 3000 ms</strong></p>
<pre><code>function fadeUp( element, max_time )
{
var opacity = 0;
if( fadeUp.elapsed === undefined )
{
fadeUp.elapsed = 0;
}
fadeUp.elapsed += 10;
opacity = fadeUp.elapsed / max_time;
setTimeout(function(){callBack( element, max_time, fadeUp.elapsed, opacity );},fadeUp.elapsed);
}
function callBack( element, max_time, elapsed, opacity )
{
element.style.opacity = opacity;
if( elapsed <= max_time )
{
fadeUp( element, max_time );
}
else
{
fadeUp.elapsed = undefined;
}
}
</code></pre>
<p><strong>Related</strong></p>
<p><a href="http://stackoverflow.com/questions/9145809/how-can-i-vary-the-opacity-over-time">How to create an opacity fade()? ( improvement over jQuery)</a></p>
| javascript | [3] |
825,915 | 825,916 | Rounding a number off to certain number of places Java | <p>Good afternoon</p>
<p>Would just like to know what the easiest way would be of rounding a value of to a certain number of decimal places in Java.</p>
<p>With C#.</p>
<pre><code>double answer;
double numberOne;
double numberTwo;
Console.WriteLine("Enter the numbers for your calculation");
numberOne = Double.Parse(Console.ReadLine());
numberTwo = Double.Parse(Console.ReadLine());
answer = numberOne / numberTwo;
Console.WriteLine(answer);
Console.WriteLine(Math.Round(answer, 3));
</code></pre>
<p>Kind regards</p>
| java | [1] |
3,220,204 | 3,220,205 | Remove all styles from dynamic label in asp.net | <p>I have a label and I got some text from database.
text format like: Windows Server 2008 ...etc
But sometimes there are different fonts or something like style. How can I remove all of them quickly?</p>
<p>I know I can make it with replace command. But is there any quick way for it?</p>
| asp.net | [9] |
1,400,045 | 1,400,046 | Retrieve values from a pop up window to the parent window | <p>I have a pop up window that contains some selections. Once the user selects options, the selected options need to be displayed in the main window. The main window doesn't need to be refreshed when options are selected from the pop up window. I'm using javascript for this, but I cannot figure out how to access the <code>checkbox</code> item of the pop up window from the main window.</p>
<p>Example:</p>
<pre><code><input type="checkbox" name="vehicle[]" value="Bike" />
<input type="checkbox" name="vehicle[]" value="car" />
var chbox = document.getElementById("vehicle[]").value;
</code></pre>
<p>But this doesn't work.</p>
| javascript | [3] |
5,802,988 | 5,802,989 | error: expected primary-expression before X token | <p>Can you explain what the title error usually means?</p>
<p>I get it sometimes and I always eventually manage to fix it by accident, but I still don't have a clue what it means.</p>
<p>Here's an example from my current error:</p>
<pre><code>Lca<RankVec, VertexVec> lca(graphList[0], dset, ss&);
</code></pre>
<blockquote>
<p>error: expected primary-expression before ')' token</p>
</blockquote>
| c++ | [6] |
2,183,747 | 2,183,748 | Passing a variable through next and previous pages | <p>I start the page with the: </p>
<pre><code>$selectedMenu = $_GET['selectedMenu'];
</code></pre>
<p>Then I have next and previous functions </p>
<pre><code><?php if ($prev) { ?>
<a href='?AID=<?=$prev?>&selectedMenu=$selectedMenu' style='background-image:url(/images/navDivider.png); background-position:right center; background-repeat: no-repeat; padding-bottom:4px; padding-top:4px;'>back&nbsp;&nbsp;</a>
<?php } else { ?>
<a href='gallery.php?CID=<?=$CID?>&SCID=<?=$SCID?>&selectedMenu=$selectedMenu' style='background-image:url(/images/navDivider.png); background-position:right center; background-repeat: no-repeat; padding-bottom:4px; padding-top:4px;'>back&nbsp;&nbsp;</a>
<?php } ?>
<?php if ($next){ ?>
<a href='?AID=<?=$next?>&selectedMenu=$selectedMenu'>&nbsp;next</a>
<?php } ?>
</code></pre>
<p>There is a query that pulls the AID, CID, and SCID</p>
<p>But what happens is that the $selectedMenu won't stay after the fist page even though I am passing it in the url. Any clues why it's dropping out?</p>
| php | [2] |
3,585,063 | 3,585,064 | Compare unsigned char = 0x00 and signed char = '00' | <p>How do i compare the following:</p>
<pre><code>unsigned char a = 0x00;
char b = '0'; // signed char
</code></pre>
<p>how do i write a comparison/conversion that matches a and b?</p>
<p>thanks!</p>
| c++ | [6] |
4,741,086 | 4,741,087 | Display Content div onclick of nav item | <p>Question : Beginner Level
Code: Pure Javascript</p>
<p>I had created a web page in which i am rendering the main nav items via a for loop in javascript. Below the main nav i had created some content assigned each main content div with different ids. </p>
<p>Now i want onclick of any nav item, respective content div should be displayed. please find the jsfiddle link : <a href="http://jsfiddle.net/shabirgilkar/GKLJz/1/" rel="nofollow">http://jsfiddle.net/shabirgilkar/GKLJz/1/</a></p>
<p>May i know how to do that in pure javascript. Any help will be highly appreciated.</p>
| javascript | [3] |
5,831,071 | 5,831,072 | Executing a script | <p>I need to execute a script within php, i tried almost everything..</p>
<pre><code>http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username=user&password=******&sendername=Vfup&mobileno= '.$f.' &message='.$message1.''
</code></pre>
<p>I tried java script, but i $f and $message1 are variables, so i cant use <strong>echo</strong> twice </p>
<p>Is there any function in php, which automatically opens the above link in a new window and i need the remaining part of the php code to execute normally without being affected. Will provide more details if required..</p>
<p>Regards,</p>
| php | [2] |
4,033,092 | 4,033,093 | Validate Boolean Query - java | <p>I need the java code snippet for the below logic:</p>
<p>Following is a string and I need to validate the string based on the below condition :</p>
<p>"<strong>100</strong> or <strong>200</strong> and <strong>345</strong> not <strong>550</strong> " - Valid string </p>
<p>"<strong>abc</strong> or <strong>200</strong> and <strong>345</strong> SAME <em>*</em>* 550 " - Not a Valid String</p>
<p>1 . the operands(eg 100,200 ..) should be positive numbers
2 . the operator should be and/or/not </p>
<p>Thx</p>
| java | [1] |
6,012,748 | 6,012,749 | jQuery event.target and is(":checked") not working | <p>Just a simple question.</p>
<p>I'm using</p>
<pre><code>console.log(jQuery(event.target).is(":checked"));
</code></pre>
<p>and it returns false everytime.</p>
<p>If I do a <code>console.log(jQuery(event.target))</code> is prints out the input box, so I know event.target is correct.</p>
<p>I can't use <code>this</code> here because the jQuery event is bound to a parent div.</p>
<p>Any ideas why this wouldn't work? Seems easy enough.</p>
<p>EDIT#########################################
Rest of code:</p>
<pre><code>jQuery(".core-create-install-pkg-parent").live("click", function(event){
var cls = jQuery(event.target).attr("type");
if(cls != "checkbox"){
event.stopPropagation();
jQuery(".core-create-install-pkg-child:first", this).toggle();
}else{
console.log(event.target);
if(jQuery(event.target).is(":checked")){
console.log("it's checked");
jQuery("input[type=checkbox]", this).removeAttr('checked');
}else{
console.log("not checked");
jQuery("input[type=checkbox]", this).attr("checked", true);
}
}
});
</code></pre>
<p>And the html looks like:</p>
<pre><code><div class="core-create-install-pkg-parent">
<div class="core-create-install-pkg-title">
<input type="checkbox" value="" checked>
plugins
</div>
</div>
</code></pre>
| jquery | [5] |
3,548,321 | 3,548,322 | not understanding this javascript equation | <p>Em. I'm looking at the easing equation here:</p>
<pre><code>var easing = function( t, b, c, d ) {
return c * ( t /= d ) * t * t * t + b;
}
</code></pre>
<p>So presumably one can write it like this:</p>
<pre><code>var easing = function( t, b, c, d ) {
return c * ( t = (t/d) ) * t * t * t + b;
}
</code></pre>
<p>or like this ? mmm.. not sure about this one: </p>
<pre><code>var easing = function( t, b, c, d ) {
return c * t = c * (t/d) * t * t * t + b;
}
</code></pre>
<p>How exactly is this equation being parsed by javascript, I mean, we get:</p>
<p>return number = number;</p>
<p>wtf? How is this being handled.</p>
| javascript | [3] |
606,262 | 606,263 | fixing many of headers and cookies problems | <p>i am still beginner in PHP but i found that one of the good things when you want to Avoid scripting headache is to turn output buffering on, specially that the script may work well in localhost but you face some troubles when you upload it to your site</p>
<p>simply at the top of your code before any HTML code you have to write</p>
<pre><code><?php ob_start(); ?>
</code></pre>
<p>and in the bottom of your code end it using</p>
<pre><code><?php ob_end_flush(); ?>
</code></pre>
<p>i hope it can save many of scripting headache </p>
| php | [2] |
5,154,439 | 5,154,440 | Using Javac in C#? | <p>Okay, so I've been working on this a while (and I've gone through multiple questions to get this far in the project).</p>
<p>Here's the C# code I'm using:</p>
<pre><code> Process p = new Process();
p.StartInfo.RedirectStandardError = true;
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "javac";
Directory.CreateDirectory(Path.Combine(Application.StartupPath + @"\TempJavaalfgwaepfgawe"));
p.StartInfo.Arguments = "-d " + Path.Combine(Application.StartupPath + @"\TempJavaalfgwaepfgawe") + " " + files;
p.Start();
p.WaitForExit();
MessageBox.Show(p.StandardError.ReadToEnd());
</code></pre>
<p>In essence, I am trying to invoke the Java compiler (javac) from a C# application. </p>
<p>Now, when I do this, it wasn't compiling the java code correctly, so I inserted the RedirectStandardError and UseShellExecute as well as the WaitForExit and MessageBox at the end to see the error that was occurring. </p>
<p>Anyways, the error is as follows:</p>
<blockquote>
<p>javac: invalid flag: 2010\Projects\Java</p>
<p>Usage: javac [options] [source files]</p>
<p>use -help for a list of possible options</p>
</blockquote>
<p>So, what's wrong with my code?</p>
<p>To me, the error looks like part of the location of one of the file paths.</p>
| c# | [0] |
2,348,710 | 2,348,711 | Why is StringBuilder final - versus having all final methods? | <p>The motivation for this was my answer ("Wishful thinking") to an <a href="http://stackoverflow.com/questions/7446994/what-are-the-pros-and-cons-of-having-private-methods-return-string-instead-of-pas/7447512#7447512">earlier question on StringBuilder best-practices</a>. If StringBuilder was extensible, then domain-specific subclasses could extend its fluent interface, which would tighten up code where a StringBuilder gets passed around to a lot of methods that build parts of a larger string. </p>
<p>I'm considering suggesting something - maybe a StringBuilder delegate - to the Guava folks.</p>
<p>What additional purpose does it serve for StringBuilder to be final, as opposed to just having final methods?</p>
| java | [1] |
5,041,388 | 5,041,389 | Gzip and Cache PHP Code | <p>Here is my PHP Code</p>
<pre><code>$phpver = phpversion();
$useragent = (isset($_SERVER["HTTP_USER_AGENT"]) ) ? $_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT;
$do_gzip_compress = FALSE;
if ($phpver >= '4.0.4pl1' && (strstr($useragent,'compatible') || strstr($useragent,'Gecko'))) {
if (extension_loaded('zlib')) {
ob_start('ob_gzhandler');
}
}
header('Content-type: text/javascript;charset=utf-8');
header('Expires: '.gmdate("D, d M Y H:i:s", time() + 3600*24*365).' GMT');
echo "TEST";
</code></pre>
<p>I basically want to cache the content (on client side) forever as well as gzip it. However I am not sure if the above is the best way. I do not want to use any third party scripts. Is my client side caching headers enough? Do I need to add more? Also, will this interfere with Apache's native gzipping (which is turned on the server)- will it gzip twice?</p>
<p>Thank you for your time.</p>
| php | [2] |
1,656,788 | 1,656,789 | PHP loop position | <p>Can someone help me on this. I'm made an image uploader and i want the image to make another tr if it reach to 5 pics so it will not overflow. Here is my code:</p>
<pre><code>$dbc = mysql_connect("localhost" , "root" , "") or die (mysql_error());
mysql_select_db('blog_data') or die (mysql_error());
$sql = "SELECT * FROM img_uploaded";
$result = mysql_query($sql);
while($rows=mysql_fetch_array($result))
{
if ($rows)
{
echo "<tr><td><img src='user_images/".$rows['img_name'] . "' width='100' height='100'></td></tr>";
}
else
{
echo "<td><img src='user_images/".$rows['img_name'] . "' width='100' height='100'></td>";
}
}
mysql_close();
</code></pre>
| php | [2] |
454,442 | 454,443 | Closing a sub form using MDI parent/child forms? | <p>I'm trying to close a MDI child form inside a parent form with a button click..</p>
<p>I'm using Visual C++</p>
<p>ive try the following</p>
<pre><code> newMDIChild->Close();
newMDIChild->Cancel = true;
newMDIChild->Hide();
newMDIChild->Visible = false;
</code></pre>
<p>None of which work... </p>
<p>Any ideas?</p>
| c++ | [6] |
864,786 | 864,787 | Retrieving selected text from textarea when span is clicked in IE | <p>I want to get the selected text within the text area when 'span' is clicked. When I click button the selection works but not when I click on span.<br>
Maybe because the selection is lost when span is clicked, but it's not happening when button is clicked?
How to fix it?</p>
<pre><code>function Copy() {
var theSelection = document.selection.createRange();
alert(theSelection.text);
}
<div>
<span class="Icon" onclick="Copy();"></span> <input type="button" value="Copy" onclick="Copy();" style="float:left;" />
</div>
<div style="clear:both;">
<textarea rows="2" cols="20" style="height:370px;width:800px;"></textarea>
</div>
</code></pre>
<hr>
<p><strong>IE only!</strong></p>
<p><a href="http://www.webdevout.net/test?0V&raw" rel="nofollow">Online Example</a></p>
<p>Update:</p>
<p>This is how I do it in firefox:</p>
<pre><code>if (window.getSelection){ // Firefox, Opera, Safari
var textbox = document.getElementById("box");
textbox.focus();
theSelection = document.activeElement.value.substring(document.activeElement.selectionStart, document.activeElement.selectionEnd);
alert(theSelection);
}
</code></pre>
| javascript | [3] |
1,147,370 | 1,147,371 | How do I configure PHP to have permission to create directories and make files? | <p>I have a PHP script that receives uploads and it works fine in mamp, creating directories and receiving files as necessary, but when I move it to the server it errors out saying it can't do either.</p>
<p>[EDIT]
To be clear, the script will received a file and before storing it, it may need to create a directory for that file beneath itself. So the pseudo code would be...</p>
<pre><code>$path = getNewPath();
mkdir("./$path", RECURSIVE);
fwrite($path/$newFile);
</code></pre>
<p>I've chowned the file to apache and given it 777 permissions, but no dice. I'm assuming that there must be some PHP configuration that designates this, but can't figure out where that is. httpd.conf is lengthy and, having skimmed it, I don't see anything relevant. </p>
<p>I'm sure I'm missing something obvious, but can't figure out what it is.</p>
<p>TIA</p>
| php | [2] |
5,231,468 | 5,231,469 | Introduce per-customer personalization in java application | <p>I've searched on internet and here on SO, but couldn't wrap my mind around the various options.</p>
<p>What I need is a way to be able to introduce customer specific customization in any point of my app, in an "external" way, external as in "add drop-in jar and get the customized behavior".</p>
<p>I know that I should implement some sort of plugin system, but I really don't know where to start.</p>
<p>I've read some comment about spring, osgi, etc, can't figure out what is the best approach.</p>
<p>Currently, I have a really simple structure like this:</p>
<pre><code>com.mycompany.module.client.jar // client side applet
com.mycompany.module.server.jar // server side services
</code></pre>
<p>I need a way of doing something like:</p>
<p>1) extend com.mycompany.module.client.MyClass as com.mycompany.module.client.MyCustomerClass</p>
<p>2) jar it separately from the "standard" jars: com.mycompany.customer.client.jar</p>
<p>3) drop in the jar</p>
<p>4) start the application, and have MyCustomerClass used everywhere the original MyClass was used.</p>
<p>Also, since the existing application is pretty big and based on a custom third-party framework, I can't introduce devastating changes.</p>
<p>Which is the best way of doing this? </p>
<p>Also, I need the solution to be doable with java 1.5, since the above mentioned third-party framework requires it.</p>
| java | [1] |
18,241 | 18,242 | I want to develop a android app based on fbreader, but I don't know how to use it | <p>For example, a obvious question is,
How to launch the mainview by a filePath="/mmt/sdcard/ebook/aaa.txt"?
Where is the function?
Thank you!
If there are some blog or bbs where I can learn many things about fbreader, please tell me. ^_^</p>
| android | [4] |
685,200 | 685,201 | Help split the string | <p>I have the string array:</p>
<pre><code>string[] data = new string[] {"1B", "2C", "01", "11", "3F", "5F", "02", "01", "06","12", "1C"};
</code></pre>
<p>Need to find a "01" and then find the next element of the "01". Copying what is between them, including the first "01", and etc. I need to get a new array(or List):</p>
<pre><code>string[] arr;
arr[0] = "01113F5F02";
arr[1] = "0106121C"
</code></pre>
<p>OR</p>
<pre><code>List<string> arr;
arr[0] = "01113F5F02";
arr[1] = "0106121C"
</code></pre>
<p>Thanks.</p>
| c# | [0] |
2,682,644 | 2,682,645 | How to access object prototype in javascript? | <p>In all the articles it is written that JavaScript is a prototype-based language, meaning that every object has a prototype (or, more precisely, prototype chain).</p>
<p>So far, I've tried the following code snippet:</p>
<pre><code>var F = function();
F.prototype.member1 = 1;
var object1 = new F();
console.log(object1.member1); // prints 1
</code></pre>
<p>How can I access the prototype object of <code>object1</code>? Is there a browser-neutral way to do that (I mean, not relying on <code>__proto__</code> property? Seen <a href="http://stackoverflow.com/questions/2242518/how-can-i-see-a-javascript-objects-prototype-chain">this</a> link, but maybe there are new developments since 2010) If I can't, could you share please the rationale behind the hood?</p>
| javascript | [3] |
2,085,631 | 2,085,632 | How to get values from unaligned memory in a standard way? | <p>I know C++11 has some standard facilities which would allow to get integral values from unaligned memory. How could something like this be written in a more standard way?</p>
<pre><code>template <class R>
inline R get_unaligned_le(const unsigned char p[], const std::size_t s) {
R r = 0;
for (std::size_t i = 0; i < s; i++)
r |= (*p++ & 0xff) << (i * 8); // take the first 8-bits of the char
return r;
}
</code></pre>
<p>To take the values stored in litte-endian order, you can then write:</p>
<pre><code>uint_least16_t value1 = get_unaligned_le<uint_least16_t > (&buffer[0], 2);
uint_least32_t value2 = get_unaligned_le<uint_least32_t > (&buffer[2], 4);
</code></pre>
| c++ | [6] |
2,153,107 | 2,153,108 | What does '@' at beginning of a variable mean? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/429529/what-does-the-symbol-before-a-variable-name-mean-in-c">What does the @ symbol before a variable name mean in C#?</a> </p>
</blockquote>
<p>I've seen this a couple of times in code that has been passed onto me:</p>
<pre><code>try {
//Do some stuff
}
catch(Exception @exception)
{
//Do catch stuff
}
</code></pre>
<p>Can anyone please explain the purpose of the '@' at the beginning of the Exception variable?</p>
| c# | [0] |
4,678,465 | 4,678,466 | Android In-App-Billing RESTORE_TRANSACTIONS with empty JSON! | <p>Hey folks,
I am slightly modified the dungeons example for the Android In-App-Billing SDK article. I am having trouble with the RESTORE_TRANSACTIONS request. I first make a legitimate purchase and that goes fine, I get a call to onPurchaseStateChange with no issue. However, when I try to use RESTORE_TRANSACTIONS request, I was expecting to get a constructed verified list of purchases, but when I trace it, the JSON returned is verified just fine, but contains no transactions! Within Security.java in the Dungeons example you see this code in the verifyPurchase method:</p>
<pre><code> if (Consts.DEBUG) {
Log.d(TAG, "Parsing JSON object");
}
JSONObject jObject;
JSONArray jTransactionsArray = null;
int numTransactions = 0;
long nonce = 0L;
try {
jObject = new JSONObject(signedData);
// The nonce might be null if the user backed out of the buy page.
nonce = jObject.optLong("nonce");
jTransactionsArray = jObject.optJSONArray("orders");
if (jTransactionsArray != null) {
numTransactions = jTransactionsArray.length();
}
if (Consts.DEBUG) {
Log.d(TAG, "JSON Array has " + numTransactions + " transactions");
}
} catch (JSONException e) {
if (Consts.DEBUG) {
Log.d(TAG, e.getMessage());
}
return null;
}
</code></pre>
<p>Am I misunderstanding the purpose of the RESTORE_TRANSACTIONS? Isn't it supposed to return a verified list of purchases just like REQUEST_PURCHASE through the onPurchaseStateChange?</p>
| android | [4] |
5,366,138 | 5,366,139 | HTML treat code within brackets as PHP code | <p>I am building my website completely in PHP. I am trying to make it as much flexible as possible.</p>
<p>I have seen there are some softwares made in PHP that are able to get a HTML page, and before showing it, the PHP code recognizes the code inside brackets <code>{PHP Code}</code> as PHP code, runs it and only then shows the final page.</p>
<pre><code><h1>Hi My Name is {echo $name}</h1>
</code></pre>
<p>How can I achieve the same? I know there is Smarty Code. But I do not want to learn Smarty, I just want to know how to check a HTML page with PHP, find every bracket and threat that as PHP before showing the page..?</p>
<p>Can you point me somewhere?</p>
| php | [2] |
3,182,330 | 3,182,331 | How to Add/Show Leading "00" instead of "0" in NumericUpdown in C#? | <p>How to Add/Show Leading "00" instead of "0" in NumericUpdown in C# ?</p>
<p>Any help/ideas are appreciated.
Thanks.</p>
| c# | [0] |
1,899,938 | 1,899,939 | CheckBox Style in Android? | <p>I want to do make my check box small than the actual size. How to do it? Any Idea?</p>
<p>for Example we can set the button as small size using the attribute </p>
<pre><code>style="?android:attr/buttonStyleSmall"
</code></pre>
<p>ThanX</p>
| android | [4] |
4,120,530 | 4,120,531 | How to change the value of a 'public static string | <p>Here is my code:</p>
<pre><code>public static String currentStudent = "";
public void login() {
boolean studentLoggedOn = false;
Student student = new Student();
PC_Dialog dialog = new PC_Dialog("Enter Login Information", "Student ID, Password-", "OK");
dialog.choice();
String studentID = dialog.getField(1);
String password = dialog.getField(2);
student = (Student) projectSystem.studentFile.retrieve(studentID);
if (studentID != null) {
if (password.equals(student.password)) {
currentStudent = studentID;
studentLoggedOn = true;
studentRun();
}
}
if (!studentLoggedOn) {
JOptionPane.showMessageDialog(null, "Either the user name or the password were incorrect");
login();
}
}
</code></pre>
<p>Basically after all of that, the "<code>currentStudent = studentID;</code>" doesn't seem to have any effect on the currentStudent <code>String</code>? any help/suggestions?</p>
| java | [1] |
4,357,819 | 4,357,820 | Android big concern for me "force close" | <p>my app is getting "force close" randomly. And every time error can not be same. Is there a way to pop up "error message" with that "force close" to determine what is the cause of it. How to I handle "force close" properly?</p>
<p>Appreciate your help.</p>
| android | [4] |
5,961,164 | 5,961,165 | Representing 2d space of indeterminate size with JS arrays - negative indexes? | <p>I'd like to represent 2d cartesian cordinates in a 2d JS array. The 2d space is of indeterminate size (can extend into -x and -y space too). This is fine for positive x and y values, but with a minimum index of 0 in JS arrays I can't extend into negative x and y space.</p>
<p>I have read some short information about the possibility of using negative indexes in JS, and that apparently these are technically possible, though not properly supported (e.g. array functions moght not work properly). </p>
<p>I'm sure others must have had a similar requirement, so I'd like to ask - what's the recommended way of modelling this in JS? Are negative array indexes a workable solution?</p>
| javascript | [3] |
287,840 | 287,841 | Search the text inside a variable for a certain term, php | <ol>
<li><p>I am pulling profiles which mention the word "fitness" from a database like so:</p>
<pre><code>$result = mysql_query("SELECT profile FROM ".$table." WHERE profile LIKE ('fitness')");
</code></pre></li>
<li><p>I am doing a basic retrieval of the <code>$profile</code> variable and echo it.</p>
<pre><code>while($slice = mysql_fetch_assoc($result)) {
$profile = $slice['profile'];
echo $profile;
}
</code></pre></li>
</ol>
<p>What I'd like is a way to search the text inside <code>$profile</code> for the word "fitness" and highlight the found word using maybe CSS.</p>
<p>Any ideas how?</p>
<p><strong>UPDATE:</strong></p>
<p>Ty very much, and I have one more problem.</p>
<p>In the sql query I will have:</p>
<pre><code>$result = mysql_query("SELECT profile FROM ".$table." WHERE $profile_rule");
$profile_rule = 'profile LIKE ('fitness') AND profile LIKE ('pets')';
</code></pre>
<p>Is there a way to s**trip the $profile_rule** and get just the <strong>words fitness and pets</strong>? Maybe strip everything which isn't encased by '' ?</p>
<p>Ty</p>
| php | [2] |
5,978,618 | 5,978,619 | Removing duplicates from a list collection | <p>Hope someone can help me. I am using c# and I am somewhat new to it.
I am loading a text file into my app and splitting the data on "," I am reading part of string into a <code><list></code> when the data is read there is a lot of duplicates that vary depending on the txt file that I load. Can someone tell me how to check the and remove any and all duplicates that come up. There is no way of knowing what duplicates will show up as there is infinite possibilities that it could be.</p>
<p>Thanks for the help in advance</p>
| c# | [0] |
4,926,438 | 4,926,439 | Is there any way to open .doc file in Android? | <p>I have created a app that displays all the content from res/raw folder.</p>
<p>I need that when i click on .doc file it should open and I can view its content.</p>
<p>please help me.</p>
<p>I have ThinkFree.</p>
<pre><code>enter code here
public class FileList extends ListActivity {
public static final Field[] fields = R.raw.class.getFields();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<Field>(this, R.layout.row, R.id.weekofday, fields));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
//super.onListItemClick(l, v, position, id);
String selection = l.getItemAtPosition(position).toString();
Toast.makeText(this, selection, Toast.LENGTH_SHORT).show();
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
startActivity(i);
}
</code></pre>
<p>}</p>
| android | [4] |
483,282 | 483,283 | javascript getElementById() for loop (empty textbox validation) | <p>i have the following <a href="http://jsfiddle.net/pmv7W/" rel="nofollow">code</a> that validate against empty textboxes. If there are empty ones, the form will not be able to submit successfully.</p>
<p>However,I cannot seem to get the alert to popup after clicking submit looping through the elements to find if there are any empty boxes to fill in.</p>
<p>any advice/correction on the looping?</p>
| javascript | [3] |
4,817,085 | 4,817,086 | Disable JavaScript input in address bar - Firefox only | <p>I am looking for a way of doing this because my PC is used by more people. Just in case they need to see my saved passwords, they can just type some JavaScript in the address bar and voila..they can see the values of some of my login forms..</p>
<p>I googled and googled but found nothing that can help me customize Firefox by disabling the javascript: pseudo-protocol.</p>
<p>Any ideas?</p>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.