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 |
|---|---|---|---|---|---|
5,487,264 | 5,487,265 | Hide Registration And Login Form When User Is Logged In? | <p>Hide Registration And Login Link When User Is Logged In?</p>
<p>I am new at PHP and I am having some difficulties.I have downloaded a login/register code. I also created a login/register link on my index page. What I want to do is to hide the Login/register links when I am logged on. How do I go about it?</p>
<p>Thank you</p>
| php | [2] |
697,012 | 697,013 | String to jQuery object, how to remove elements | <p>I'm trying to manipulate some html which is in a textarea (not part of the page) but I want to be able to perform jQuery functions on it.</p>
<p>Here I am trying to remove the div with the attr 'my_id' of 1234, but the resulting data remains the same?</p>
<pre><code>var data = "<div>something<div my_id='1224'>blah</div><div my_id='1234'>xx123</div></div>";
var id = '1234';
$(data).remove('[my_id="'+id+'"]');
alert($(data).html());
</code></pre>
<p>Obviously just using alert for debugging.</p>
| jquery | [5] |
828,288 | 828,289 | I was able to open a command prompt from my Java program, How to run some exe in this command prompt using java code? | <p>I tried open a command prompt using java program, how to execute the some exe file in this command prompt using java code.</p>
| java | [1] |
4,525,441 | 4,525,442 | When does the C++ default assignment operator become unaccessible? | <p>If I define an own assignment operator, which has a different signature than the normally generated default assignment operator:</p>
<pre><code>struct B;
struct A {
void operator = (const B& b) {
// assign something
}
};
</code></pre>
<p>does the default assignment operator, in this case <code>operator = (A&)</code> (or the like, correct me if wrong) become undefined/unaccessible?</p>
<p>AFAIK this is true for the default constructor, which doesn't exist, if we define some other constructor.
But I am really not sure if this is the case for the other "magic" defaults.</p>
<p>The reason I ask: I want to avoid that the default copy constructor is accidently called via a implicit type conversion. If it doesn't exist, it could never happen.</p>
| c++ | [6] |
3,767,432 | 3,767,433 | Filtering text files in C# | <p>How do I just open files with the .txt extension, I want to my program to pop up an error message if the file is not a .txt file I want a code that can modify this code below</p>
<pre><code>private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog of = new OpenFileDialog();
of.ShowDialog();
textBox1.Text = of.FileName;
}
</code></pre>
<p>Can someone help let's say I want to put this loop</p>
<pre><code>if fileextension is .txt then
OpenFileDialog of = new OpenFileDialog();
of.ShowDialog();
textBox1.Text = of.FileName;
else show error message(like can not open this file)
</code></pre>
| c# | [0] |
2,032,800 | 2,032,801 | What is quick way to check if ImageView has bitmap assigned? | <p>I need to quickly and safely check if an android.widget.ImageView currently has a Bitmap of non zero value attached. What is a quick way to do this. </p>
<p>Update my image view is set initially drawable set to "logo.png" so if I know that it is currently set to logo.png than I know that the bitmap has not yet been set. So how can I check if background drawable is currently logo.png</p>
<p>Thanks</p>
| android | [4] |
5,302,381 | 5,302,382 | Get the name of a calling class without the use of Exceptions | <p>Yes, getting the class name by using an exception is a plausible solution, but I'm looking for something that is a bit more elegant. </p>
<pre><code>String className = new Exception().getStackTrace()[1].getClassName();
</code></pre>
<p>This will be used mainly for logging purposes and making sure my cache keywords are component/caller-class specific. </p>
| java | [1] |
3,779,323 | 3,779,324 | Reading a series of input / output in Python | <p>For my app, I need to print out a series of outputs and then accepts inputs from the user. What would be the best way of doing this?</p>
<p>Like:</p>
<pre><code>print '1'
x = raw_input()
print '2'
y = raw_input()
</code></pre>
<p>Something like this, but it would go on for at least 10 times. My only concern with doing the above is that it would make up for poor code readability. </p>
<p>How should I do it? Should I create a function like this:</p>
<pre><code>def printOut(string):
print string
</code></pre>
<p>Or is there a better way?</p>
| python | [7] |
1,652,905 | 1,652,906 | How to print DateTime object in yyyy-MM-ddThh:mm:ssZ format? | <blockquote>
<p><strong>Please see also:</strong><br>
<a href="http://stackoverflow.com/questions/1728404/date-format-yyyy-mm-ddthhmmssz">date format yyyy-MM-ddTHH:mm:ssZ</a> </p>
</blockquote>
<p>Could anybody help me to find a formatter to print DateTime object in the following way:</p>
<pre><code>2012-09-30T16:53:46Z
</code></pre>
<p>What does "Z" postfix mean?</p>
| c# | [0] |
5,956,358 | 5,956,359 | session_write_close equivalent for asp.net (Disable and Enable Sessions programmatically) | <p>I'm looking for a way to turn on and off session in asp.net in code programmatically.</p>
<p>In php this can easily achieved by using: <code>session_write_close</code> and then <code>session_start</code> function to enable it again.</p>
| asp.net | [9] |
4,401,497 | 4,401,498 | jQuery selector help | <p>Good Morning,</p>
<p>I am trying to write a selector that would select all rows that contain a span element that has a class of "cancelMenu".</p>
<p>Is either of these better than the other? Or is there an even better way to write it?</p>
<pre><code> $("span.cancelMenu").closest("tr");
$("tr > span.cancelMenu");
</code></pre>
<p>Any thoughts or ideas? I am using the first one and it works but it seems like I am only targeting one row. I really want all rows at once. </p>
<p>Thanks,
~ck</p>
| jquery | [5] |
2,432,057 | 2,432,058 | How do I simulate ctrl-F5 with jQuery? | <p>So the refresh should discard the cache, how to do it with jQuery?</p>
| jquery | [5] |
4,773,926 | 4,773,927 | getApplicationContext issue | <p>I have VideoApplication class which extends Application class. I have created my other java class's object in this class so that I can pass it through activities.</p>
<pre><code>public class VideoApplication extends Application {
private Client client;
public Client getClient(){
return client;
}
public void setClient(Client client){
this.client = client;
}
}
</code></pre>
<p>I have added following line in androidManifest file:
<code>android.name=".VideoApplication"</code>.</p>
<p>But when I add the following line to my code(MainActivity.java), the application throws a ClassCastException exception. </p>
<pre><code>VideoApplication appInstance = (VideoApplication)getApplicationContext();
</code></pre>
<p>Where am I going wrong? Please help.</p>
| android | [4] |
2,750,866 | 2,750,867 | android application delete only one sms in the inbox | <p>hi friends
I am create delete sms
It will delete sms successfully but i want to delete only one sms.
It can possible if possible than how can do it.
If its code available please send me.
Please help me.</p>
<p>Thanks in advance.</p>
| android | [4] |
5,713,535 | 5,713,536 | How to programmatically set the length of a function | <p>The <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/length" rel="nofollow"><code>length</code> property of functions</a> tells how long the 'expected' argument list is:</p>
<pre><code>console.log((function () {}).length); /* 0 */
console.log((function (a) {}).length); /* 1 */
console.log((function (a, b) {}).length); /* 2 etc. */
</code></pre>
<p>However, it is a readonly method:</p>
<pre><code>f = function (a) {};
alert(f.length); // 1
f.length = 3;
alert(f.length); // 1
</code></pre>
<p>Is there a way to programmatically set that length? The closest I've come so far is to use the Function constructor:</p>
<pre><code>f = new Function("a,b,c", "/* function body here */");
f.length; // 3
</code></pre>
<p>However, using Function is essentially the same as <code>eval</code> and we all know how bad that is. What other options do I have here?</p>
| javascript | [3] |
1,079,234 | 1,079,235 | how to represent negative number to array of integers? | <p>I must convert string of 1324312321 to array of integers in java</p>
<p>this is fine. I could use integer parseint and string substring method </p>
<p>but how do I repesent -12312312 to my original array of integer.. </p>
<p>the fact that - is a char / string and convert to array of integer would alter the value ( even though I convert - to integer-equivalent , it would change the rest of 12312312)</p>
<p>it must be an array of integers and how should I convert negative numbers and still keeep the same value</p>
<p>somehow reminding me of two complements trick but i dont think i need to go down to binary level in my program.. </p>
<p>any other trick for doing this?</p>
<p>thanks!</p>
| java | [1] |
5,194,498 | 5,194,499 | Pythonic way to fetch all elements in a dictionary, falling between two keys? | <p>I have a dictionary object, and I want to extract a subset of the dictionary (i.e. return another dictionary), which contains all elements of the parent dictionary where the key matches a certain criteria. </p>
<p>For example:</p>
<pre><code>parent_dict = {1: 'Homer',
2: 'Bart',
3: 'Lisa',
4: 'Marge',
5: 'Maggie'
}
def filter_func(somedict, key_criteria_func):
pass
</code></pre>
<p>I want to write (in a pythonic way), <code>filter_func</code>, so that I can call it like this:</p>
<pre><code>filter_func(parent_dict, ">2 and <4")
</code></pre>
<p>which will return the new dict:</p>
<pre><code>{ 3: 'Lisa' }
</code></pre>
<p>What is the most pythonic way to write <code>filter_func?</code></p>
<p>To keep things simple, I will limit the criteria to simple boolean operations.</p>
<p><strong>[[Edit]]</strong></p>
<p>This is the output when I try the following command:</p>
<pre><code>>>> {key:val for key,val in parent_dict.iteritems() if 2 < key < 4 }
File "<stdin>", line 1
{key:val for key,val in parent_dict.iteritems() if 2 < key < 4 }
^
SyntaxError: invalid syntax
</code></pre>
<p>BTW, I'm running Python 2.6.5</p>
| python | [7] |
2,182,289 | 2,182,290 | Convert a string into a double, and a int. How to? | <p>I'm having trouble converting a string into a double.
My string has been declared using the "string" function, so my string is:</p>
<pre><code>string marks = "";
</code></pre>
<p>Now to convert it to a double I found somewhere on the internet to use word.c_str(), and so I did. I called it and used it like this:</p>
<pre><code>doubleMARK = strtod( marks.c_str() );
</code></pre>
<p>This is similar to the example I found on the web: </p>
<pre><code>n1=strtod( t1.c_str() );
</code></pre>
<p>Apparently, that's how it's done. But of course, it doesn't work. I need another parameter. A pointer I believe? But I'm lost at this point as to what I'm suppose to do. Does it need a place to store the value or something? or what? </p>
<p>I also need to convert this string into a integer which I have not begun researching as to how to do, but once I find out and if I have errors, I will edit this out and post them here.</p>
| c++ | [6] |
4,581,754 | 4,581,755 | Problem in enabling APC on PHP 5.3.6 | <p>I am having a problem in enabling the APC Cache. Here is my configuration.</p>
<pre><code>PHP 5.3.6
Apache 2.2.19
Windows 7
</code></pre>
<p>I have downloaded the php_apc.dll from below URl:
<a href="http://downloads.php.net/pierre/php_apc-20110109-5.3-nts-vc9-x86.zip" rel="nofollow">http://downloads.php.net/pierre/php_apc-20110109-5.3-nts-vc9-x86.zip</a></p>
<p>I have placed that dll in php's extension folder and placed the below code in php.ini</p>
<pre><code>extension=php_apc.dll
</code></pre>
<p>Next anything remain to be enable the APC cache? Because when I place above line in PHP.ini then apache is not restarting.</p>
<p>Any help much appreciated.</p>
<p><strong>Edit:</strong></p>
<pre><code>[Tue Sep 06 14:22:28 2011] [notice] Parent: Received restart signal -- Restarting the server.
[Tue Sep 06 14:22:33 2011] [warn] NameVirtualHost *:80 has no VirtualHosts
rocess is ending.
[Tue Sep 06 14:22:29 2011] [notice] Child 4212: Released the start mutex
[Tue Sep 06 14:23:00 2011] [notice] Child 4212: Waiting 270 more seconds for 1 worker threads to finish.
[Tue Sep 06 14:23:04 2011] [notice] Child 4212: All worker threads have exited.
[Tue Sep 06 14:23:04 2011] [notice] Child 4212: Child process is exiting
</code></pre>
| php | [2] |
623,770 | 623,771 | Class method returns object from a class that uses methods/properties from the higher class. How? | <p>I'm trying to achieve a simple behavior in my code, but i can't think of a decent way of doing it. Take a look at what i'm trying to do: </p>
<pre><code>$db = new Database('mydb');
$db->createTable('sample');
$myTable = $db->getTable('test');
$myTable->insert($data);
$myTable->insert($data);
$myTable->edit('2', $data2);
$myTable->remove('1');
</code></pre>
<p>getTable is a method of the <strong>Database</strong> class, that returns an object of the <strong>Table</strong> class. The <strong>Table</strong> class has table-operation-specific methods, such as insert, edit and remove. The <strong>Database</strong> class has important methods that <strong>Table</strong> should be able to use, such as exec and query. It also should be able to access properties from <strong>Database</strong>, such as $this->pdo.</p>
<p>Should <strong>Table</strong> extend <strong>Database</strong> or should <strong>Database</strong> have static methods? <strong>Table</strong> uses several methods from <strong>Database</strong>. Is there a design pattern i can use to implement this? A Factory? </p>
| php | [2] |
696,452 | 696,453 | What would the equivalent of this be in jQuery? | <p>Hello just wondering if anyone knows what this would be in jQuery. Thanks in advance.</p>
<pre><code>function remix(random_num){
var limit = images.length;
var random_num1 = Math.floor(limit * Math.random());
var random_num2 = Math.floor(limit * Math.random());
var random_num3 = Math.floor(limit * Math.random());
document.getElementById("layer1").src = images[random_num1];
document.getElementById("layer2").src = images[random_num2];
document.getElementById("layer3").src = images[random_num3];
}
</code></pre>
| jquery | [5] |
3,869,150 | 3,869,151 | Display WordPress Post Content in 3 Columns | <p>How can I display WordPress Post Content in 3 Columns and in order using WP_Query(); ?</p>
<p>For example,</p>
<pre><code><div class="1column">
Post-1
Post-4
</div>
<div class="2column">
Post-2
Post-5
</div>
<div class="3column">
Post-3
Post-6
</div>
</code></pre>
<p>Any help is appreciated! Thanks.</p>
| php | [2] |
5,936,366 | 5,936,367 | Android - Signing an apk | <p>Hi<br />
I have written a little program, by default, it is signed with debug certificate.
I checked the documentation at Android developer site, I don't know how to get the certificate and key, could someone advice me?</p>
<p>Thanks</p>
| android | [4] |
2,098,645 | 2,098,646 | JQuery hover addclass not working | <p>I am trying to use JQuery to change a picture inside of a nested li with an id of "logotest"</p>
<p>The classes I want applied are logotest1 and logotest2. Basically when the user hovers over the button, the picture is changed to a different one so the colors match. Here's a fiddle. Obviously the pictures aren't there, but maybe I am doing something wrong.</p>
<p><a href="http://jsfiddle.net/b9XHe/" rel="nofollow">http://jsfiddle.net/b9XHe/</a></p>
<p>I don't have the classes logotest1 and 2 in the fiddle - can it not dynamically changed the background image of the li?</p>
| jquery | [5] |
4,049,679 | 4,049,680 | Python string representation of binary data | <p>I'm trying to understand the way Python displays strings representing binary data.</p>
<p>Here's an example using <a href="http://docs.python.org/library/os.html#os.urandom" rel="nofollow">os.urandom</a></p>
<pre><code>In [1]: random_bytes = os.urandom(4)
In [2]: random_bytes
Out[2]: '\xfd\xa9\xbe\x87'
In [3]: random_bytes = os.urandom(4)
In [4]: random_bytes
Out[4]: '\r\x9eq\xce'
</code></pre>
<p>In the first example of <code>random_bytes</code>, after each \x there seem to be values in hexadecimal form: fd a9 be 87.</p>
<p>In the second example, however, I don't understand why <code>'\r\x9eq\xce'</code> is displayed.</p>
<p>Why does Python show me these random bytes in this particular representation? How should I interpret <code>'\r\x9eq\xce'</code>?</p>
| python | [7] |
1,994,951 | 1,994,952 | Click and drag to another button | <p>There is an app call DurionLite (free on iPhone) which plays a word game where letters are clicked and dragged into word construction slots to create words. As the dragged letter gets near the construction slots, the borders of the nearest construction slot is highlighted and if you then release the letter, it goes into the highlighted construction slot. You can also then click and drag letters from the construction slots (although not back to their original locations). I'm trying to do a similar thing but can't figure out how that can be done. Can anyone enlighten me?</p>
| iphone | [8] |
629,496 | 629,497 | GPS current location | <p>I've been working on this code for some time,everything seems ok but my editor,eclipse keeps telling me to cast myManager. The code is as below,</p>
<pre><code>package com.gps.project;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.content.Context;
import android.widget.Button;
/*LOcation based API*/
import android.location.LocationManager;
public class GpsActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/*Create ab ttuon we are to use in our GPS*/
final Button gpsButton=(Button) findViewById(R.id.gpsButton);
gpsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
LoadCoords();
}
});
}
public void LoadCoords(){
/*Create two textfields that will contain information as latitudes and longitudes*/
TextView latText=(TextView) findViewById(R.id.latText);
TextView lngText=(TextView) findViewById(R.id.lngText);
/*Creation of a location manager from which we are to pull the location values*/
LocationManager myManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE);
/*To pull the coordinates from myManager, we use the getCurrentLocation( ) method.*/
Double latPoint = myManager.getCurrentLocation("gps").getLatitude();
Double lngPoint = myManager.getCurrentLocation("gps").getLongitude();
/*Finally, take the new Double values and pass them to your TextViews:*/
latText.setText(latPoint.toString());
lngText.setText(lngPoint.toString());
}
}
</code></pre>
<p>Will be glad if someone helps me rectify my the error. I intend to get the longitude and the latitude.</p>
| android | [4] |
1,919,820 | 1,919,821 | C# virtual automatic properties omit get / set | <p>Is it ok to omit get or set in an automatic property when it is declared virtual?</p>
<p>I am referring a book on C# which shows the members of System.Exception as follows : </p>
<pre>
// Properties
public virtual IDictionary Data { get; }
public virtual string HelpLink { get; set; }
public Exception InnerException { get; }
public virtual string Message { get; }
public virtual string Source { get; set; }
public virtual string StackTrace { get; }
public MethodBase TargetSite { get; }
</pre>
<p>If automatic properties need to have both get and set, then why is it ok here?</p>
<p>Thanks.</p>
| c# | [0] |
1,105,443 | 1,105,444 | How to generate an random 8 character string that won't occur twice in jQuery? | <p>How do I generate a random string that is only 8 characters long, that will not occur twice in jQuery.</p>
| jquery | [5] |
3,852,047 | 3,852,048 | Keep only first n characters in a string? | <p>Is there a way in JavaScript to remove the end of a string?</p>
<p>I need to only keep the first 8 characters of a string and remove the rest. </p>
| javascript | [3] |
3,778,746 | 3,778,747 | What's the difference between == and ===? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/589549/php-vs-operator">php == vs === operator</a><br>
<a href="http://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php">Reference - What does this symbol mean in PHP?</a> </p>
</blockquote>
<p>In PHP, what is the difference between <code>==</code> and <code>===</code>? Also, what's the difference between <code>!=</code> and <code>!==</code>? Appreciate the help!</p>
<p>Okay, for people that are flaming me about this, I DID try searching it, but something about the query doesn't return relevant results.</p>
| php | [2] |
4,635,083 | 4,635,084 | I want to know about this javascript function pattern | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4043647/what-does-this-function-a-function-inside-brackets-mean-in-javascript">What does this “(function(){});”, a function inside brackets, mean in javascript?</a><br>
<a href="http://stackoverflow.com/questions/7779818/javascript-anonymous-function">javascript anonymous function</a> </p>
</blockquote>
<p>(function())()</p>
<p>this is used in many js library like jquery,YUi</p>
| javascript | [3] |
342,223 | 342,224 | Python string list to string | <p>I am doing something painfuly simple, and rather than looping over the list, and += everything, I was wondering if there was a "sleezier" way to do it.</p>
<p>Simple concept I have something like:</p>
<pre><code>some_string_array = [ "s", "t", "a", "c", "k", " ", "o", "v", "e", "r", "f", "l", "o","w" ]
some_string = some_string_array.--sleezy built-in flatten--()
print(some_string)
</code></pre>
<p>And the result would be simply <code>stack overflow</code></p>
<p>I am sure it is painfuly simple, but I couldn't find a good way to search for this online.</p>
<p>Thanks.</p>
| python | [7] |
4,405,065 | 4,405,066 | Where can I store User Permissions for my website? | <p>Hai,
i am trying to store the user permissions for my web site.But I am little bit confused with xml and Database. For each user in site have different permissions. Have u ever faced this issue? for Example , if my site is a shopping site , for a local user , the report menu need not to display. A sales man need not to display the purchase page. and so on ..</p>
<p>I think you understood my problem .I have done this user management using a xml file . For each user a new node will create according to the menu and keep in the xml file . Next time the user login ,checks the permissions and and show only the allowed menus. </p>
<p>My boss tell me to do the same thing using the Database. by using XmlDataSource it is quite simple to bind data to the treeview (for setting permission) and binding to the menustrip also.
He is pointing the security problem . i don't think like so. </p>
<p>Which is better ? DB or XML </p>
| asp.net | [9] |
820,340 | 820,341 | How to pick a key with the highest value | <p>heres an example code of what I have</p>
<pre><code>my_dict = {'a':2, 'b':5, 'c':3, 'd':8, 'e':3}
</code></pre>
<p>How could i make it print the key that has the highest value. For example in the above code it would print:</p>
<pre><code>d
</code></pre>
<p>thats all i would want to be printed, just the key that had the highest value.
help would be appreciated thanks!</p>
| python | [7] |
4,128,377 | 4,128,378 | Dismiss modal view causes issue with ShareKit Email and Twitter | <p>I have a pop up game view and then a Sharekit on top of that.
When I send mail through ShareKit Email or Twitter and then did dismiss the game view
through [self dismissModalViewControllerAnimated:YES], next time the game view brought up again, then sharekit Email and Twitter view have issue popping up.</p>
<p>I think the dissmodalviewcontroller messed the sharekit up, but I need that to dismiss my game view through dismissModalViewController.</p>
<p>any ideas to make those two compatible. </p>
| iphone | [8] |
37,658 | 37,659 | Am i evaluating the right way? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4176328/undefined-behavior-and-sequence-points">Undefined Behavior and Sequence Points</a><br>
<a href="http://stackoverflow.com/questions/949433/could-anyone-explain-these-undefined-behaviors-i-i-i-i-i-etc">Could anyone explain these undefined behaviors (i = i++ + ++i , i = i++, etc…)</a> </p>
</blockquote>
<p>This is a snippet :</p>
<pre><code>int a = 3;
int y = ++a-a++*a++/++a;
cout << y << endl;
int z = y++*a++;
cout << z << endl;
</code></pre>
<p>Upon compiling this the result is 0,0 and i too evaluated the same. But i may be evaluating the wrong way.
Here is what i did:</p>
<ol>
<li>starting from the left : ++a returns 4.</li>
<li>a++ returns 4 </li>
<li>4-4 = 0</li>
<li>0*(5/7) = 0</li>
</ol>
<p>If that is true,then the second evaluation is obvious ! </p>
<p>But have i evaluated the right way ?</p>
<p>I've used <strong>microsoft visual c++ 2010 express edition</strong> to compile this and get the same result everytime. Upon compiling the same in turbo c++ i get 5,35 respectively.!!</p>
| c++ | [6] |
3,404,769 | 3,404,770 | httpsessionstate in firefox | <p>I have an ashx file (http handler) with my asp.net app. Now it seems like that every time I store a value in session state it does not really get stored, meaning if I click a button then check for the session it always returns null. However it is working fine in IE8. can anyone please suggest?</p>
| asp.net | [9] |
5,444,857 | 5,444,858 | Directions in mapView | <p>In my mapView I have an overlay in my current location but I need to insert a direction to an editText and that my map add an overlay there. </p>
<p>Is this possible?</p>
| android | [4] |
4,119,960 | 4,119,961 | javascript regular expression validation for domain name? | <p>how to check a valid domain name and username with regular expression in javascript?</p>
<pre><code>-<script>
function validate()
{
var patt1=new RegExp(/^[a-zA-Z0-9._-]+\\[a-zA-Z0-9.-]$/);
var text= document.getElementById('text1').value;
alert(patt1.test(text));
}
</code></pre>
<p>but it does not work for me.</p>
| javascript | [3] |
27,412 | 27,413 | Writing file to remote PC | <p>I am running some experiments on an embedded platform. The problem is, that the memory ressources are limited; hence, I am thinking of writing the output into a file on a remote
machine. I am wondering what is the best way to realise that? I am using C++ on the embedded platform. I was thinking of communicating over a TCP/IP socket with the host machine where I wanna store my file. Obviously, I would then also need to write a socket application for the host PC that handles the incoming data stream. But I am wondering if maybe WIN XP or Linux offers some kind of support for my needs so that I do not need to write a socket application for the host. </p>
<p>Thanks for some guideline in this matter.</p>
| c++ | [6] |
5,983,489 | 5,983,490 | PHP rename function problem | <p>I'm trying to move a file on my server from one folder to another using the php rename function, but I'm getting this error</p>
<blockquote>
<p>Warning: rename(/home/pramiro/public_html/new/cipri/adauga/tmp/Koala.jpg, /home/pramiro/public_html/new/images/memo/Koala.jpg) [function.rename]: No such file or directory in /home/pramiro/public_html/new/cipri/adauga/categorie.php on line 13</p>
</blockquote>
<p>The paths are good, the folders exist and the file to be copied is in the tmp folder.What could I be doing wrong?</p>
<p>This is the code:</p>
<pre><code>$filename=$_POST['poza_conv'];
$filename=substr($filename,37);
$old_path='/home/pramiro/public_html/new/cipri/adauga/tmp/'.$filename;
$new_path=' /home/pramiro/public_html/new/images/';
switch($_POST['categorie_conv'])
{
case 'memo': $filename=$new_path.'memo/'.$filename;
break;
case 'ort_sup': $filename=$new_path.'ort_sup/'.$filename;
break;
}
rename($old_path,$filename);
</code></pre>
| php | [2] |
513,758 | 513,759 | argv listing directory files | <p>this very simple code is driving me nuts.</p>
<pre><code>import sys,string,socket
maquina = sys.argv[1]
texto = string.join(sys.argv[2:], " ")
print '['+maquina+']'
print '['+texto+']'
mysock = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
if maquina == '*':
for ip in range(18,254):
mysock.sendto( texto, ('192.168.0.'+str(ip),8090) )
else:
mysock.sendto( texto, (maquina,8090))
mysock.close()
</code></pre>
<p>When I type </p>
<pre><code>python send.py 192.168.0.135 several strings
</code></pre>
<p>the output is:</p>
<pre><code>[192.168.0.135]
[several strings]
</code></pre>
<p>But if I type </p>
<pre><code>python send.py * several strings
</code></pre>
<p>I got:</p>
<pre><code>[ajax]
[ajustaprofile.py build dia2django.py djangoajax django-cube django-evolution django_excel_templates-0.1 Doc google_appengine httpd.conf imagens jre1.5.0_08 lib list_mailbackup.py luma models.py netsend.py pip-log.txt reverse.py share testparamet.py tnsnames.ora util virttool-0.1 xlrd-0.7.1 xlutils-1.4.1 xlwt-0.7.2 several lines]
</code></pre>
<p>This is the file list that I have on current directory!
Python translates somehow '*' to the files of current directory.</p>
<p>I tried to do the homework using this link but I got no clue.</p>
<p><a href="http://docs.python.org/library/sys.html" rel="nofollow">http://docs.python.org/library/sys.html</a>
<a href="http://www.faqs.org/docs/diveintopython/kgp_commandline.html" rel="nofollow">http://www.faqs.org/docs/diveintopython/kgp_commandline.html</a></p>
<p>How can I use "*" on argv ?</p>
| python | [7] |
3,531,185 | 3,531,186 | How to decode eval( gzinflate( base64_decode( | <p>I have this code injected in my site. How can I decode the trailing string? I need to know what happened and what is the code behind it.</p>
| php | [2] |
5,672,162 | 5,672,163 | How do I get PHP to display a user picture if you have one within a blog post? | <p>I have a script that can disply user pictures but I want to have it now so if you don't have a picture it displays a default one.</p>
<p><strong>CODE</strong></p>
<pre><code>if (file_exists($displayuserimage)) {
$displayuserimage = '<img src="upic/'. $posts['userid'].'.jpg" width="50px" height="50px" border="2" />';
} else {
$displayuserimage = '<img src="upic/default.jpg" width="50px" height="50px" border="2"/>';
}
</code></pre>
<p>That's what im guessing, but this is the working script, that shows images if you have one:</p>
<pre><code>$displayuserimage = '<img src="upic/'. $posts['userid'].'.jpg" width="50px" height="50px" border="2"/>';
</code></pre>
| php | [2] |
2,965,362 | 2,965,363 | help with error | <p>I am reading a row from a data table and trying to insert into a database. In the row, some cells/columns doesn't contain a value. So, I am trying to check initially whether the row contains a value or not and then insert into database. Here is my code,</p>
<pre><code>string barcode = null;
string itemName = null;
double cost = 0;
double price = 0;
double Stock = 0;
string dept = null;
double tax = 0;
barcode = Convert.ToString(dr[0]);
if (dr[1] != string.Empty || dr[1] != null)
itemName = Convert.ToString(dr[1]);
if (dr[2] != string.Empty || dr[2] != null)
cost = Convert.ToDouble(dr[2]);
if (dr[3] != string.Empty || dr[3] != null)
price = Convert.ToDouble(dr[3]);
Stock = Convert.ToDouble(dr[4]);
if (dr[5] != string.Empty || dr[5] != null)
dept = Convert.ToString(dr[5]);
if (dr[6] != string.Empty || dr[6] != null)
tax = Convert.ToDouble(dr[6]);
</code></pre>
<p>But, I am getting an error:</p>
<blockquote>
<p>possible unintended reference comparison to get a value comparison.</p>
</blockquote>
<p>How can I correct this problem?</p>
| c# | [0] |
782,916 | 782,917 | Android SQLiteDatabase.delete method wouldn't delete using where args | <p>Watch how i call the <code>db.delete</code> method; if I do the following a record is successfully deleted:</p>
<pre><code>public void deteleProfile(Long id) throws SQLException {
SQLiteDatabase db = helper.getWritableDatabase();
Integer i = db.delete(ProlificDatabase.TABLE, "_id=?", new String[] {id.toString()});
Log.d(TAG, i + " records deleted where id is " + id);
</code></pre>
<p>however if I do this:</p>
<pre><code>public void deteleProfile(Long id) throws SQLException {
SQLiteDatabase db = helper.getWritableDatabase();
Integer i = db.delete(ProlificDatabase.TABLE, "?=?", new String[] {BaseColumns._ID,id.toString()});
Log.d(TAG, i + " records deleted where id is " + id);
</code></pre>
<p>no records are deleted. also no exceptions or warnings are raised to say something has gone wrong.</p>
<p>in case you didn't catch it, the difference between the two calls were:</p>
<p><code>..."_id=?", new String[] {id.toString()});</code></p>
<p>vs</p>
<p><code>..."?=?", new String[] {BaseColumns._ID,id.toString()});</code></p>
<p>documentation for BaseColumns._ID is:</p>
<p><code>public static final String _ID</code> with a <code>Constant Value: "_id"</code></p>
<p>The latter way seems to make for neater code, but why doesn't it work?</p>
<p><strong>EDIT:</strong>
I suspect the <code>whereargs</code> parameter only applies to the right side of an expression.</p>
<p>Can someone confirm this?</p>
| android | [4] |
3,900,336 | 3,900,337 | Programatically add view one below other in relative layout | <p>I want something like this programatically:</p>
<pre><code>view1 | view2
view3 | view4
----------------
view1 | view2
view3 | view4
----------------
view1 | view2
view3 | view4
---------------
...........
......
which keeps repeating
--------------
</code></pre>
<p>I don't want to use ListView.</p>
| android | [4] |
5,028,930 | 5,028,931 | jQuery - Wrap div to a specific element | <pre><code><div id="last"></div>
<p id="text">text</p>
<a id="link" href="xxx">link</a>
</code></pre>
<p>Suppose I have the code above, how can I wrap a <code><div></div></code> to the a element, and insert it after div element, the result should be:</p>
<pre><code><div id="last"></div>
<div><a id="link" href="xxx">link</a></div>
<p id="text">text</p>
</code></pre>
<p>Tried the code below, but not works</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>
</head>
<body>
<div id="last"></div>
<p id="text">text</p>
<a id="link" href="xxx">link</a>
<script>
$('#link').wrap('<div></div>').detach().insertAfter('#last');
</script>
</body>
</html>
</code></pre>
<p>Thanks you</p>
| jquery | [5] |
3,996,220 | 3,996,221 | calculate number 3 places ahead when at the end of looped sequence | <p>Lets say I have a sequence of 8 items, these loop such that after 8 comes 1.</p>
<p>1, 2, 3, 4, 5, 6, 7, 8</p>
<p>If the selected item is number 7 how do I get the number three places ahead, ie: 2 ?</p>
<p>I have:</p>
<pre><code>var total; // (total number in sequence)
var pos; // (current position number)
if ( pos < total) {
threeIncrement = pos+3;
} else {
threeIncrement = ??????
}
</code></pre>
| javascript | [3] |
4,044,592 | 4,044,593 | How do I get the current URL and then get the last words | <p>I want to get the url I'm on and then get what's after the =</p>
<p>For example if I were on:
<a href="http://chusmix.com/?s=pizza" rel="nofollow">http://chusmix.com/?s=pizza</a></p>
<p>It should echo pizza</p>
| php | [2] |
2,020,615 | 2,020,616 | jquery prevent the onclick event of a tags with specified class name | <p>this is the code I have:</p>
<pre><code> $('a').on('click', function(e) {
e.preventDefault();
});
</code></pre>
<p>but this stops every link from working, I need it to be specific to the link that have a class of the name : "prevent"</p>
<p>for example : <code><a class="prevent" href="#link"> </a><a href="#link1"> </a></code>
in this case I want #link1 to work normally and #link will trigger <code>e.preventDefault();</code></p>
<p>any ideas please? thank you</p>
| jquery | [5] |
3,055,897 | 3,055,898 | charCodeAt to return correct code for custom charcodes | <p>Would this be good way to return correct code for custom charcodes</p>
<pre><code>String.prototype._charCodeAt = String.prototype.charCodeAt;
String.prototype.charCodeAt = function( i , keycodes ) {
if( keycodes !== 'undefined' ) {
for( var j = 0; j < keycodes.length; j++ ) {
if( this[i] === keycodes[j].char ) {
return keycodes[j].code;
}
}
} else {
return this._charCodeAt( i );
}
}
</code></pre>
<p>Keycodes is array where values stored like this</p>
<pre><code>[
...
{ "char" : "ä" , "code" : 132 },
{ "char" : "à" , "code" : 133 },
{ "char" : "å" , "code" : 134 },
...
];
</code></pre>
<p>By default the javascript returns wrong values for the "special characters".<br>
Is this code sufficient for this?</p>
| javascript | [3] |
475,181 | 475,182 | Scroll to new content inserted | <p>Let's say I made an insertion of a post to a database, then, I don't want to reload the page to show it, so I append it, with jQuery..now...how could I do to scroll down to that post and do like an animate to show the user that's the new post inserted. Something like Facebook, when you open a notification of a comment, it scrolls down to the comment and puts the div on yellow then deletes that class, so that the background is white again</p>
<p>I hope I explain myself crearly! Thanks everyone!</p>
| jquery | [5] |
4,403,648 | 4,403,649 | Disable the save option from downloading window? In Asp.net? | <p>In web application, i am trying to disable or remove the save dialog , when user click the download option. Can you help me. Thank you. LIke Do You want to Open or save this file?
in this option i want only Open option not save option.</p>
| asp.net | [9] |
3,603,156 | 3,603,157 | Does it matter whether PHP code is in header or footer? | <p>Does PHP send over code as it processes the file, or does it compose the whole HTML response and then send it over? For example would it make any difference to move expensive PHP functions into the file footer on the server? </p>
<p>Also, would it make any difference if you were using <code>Transfer-Encoding: chunked</code>?</p>
| php | [2] |
2,823,703 | 2,823,704 | Which jQuery selector is more efficient? | <p>I was just wondering if there is a reason why I should prefer this</p>
<pre><code><div class="identifying-class">bla bla</div>
<div class="identifying-class">bla bla</div>
var interestingElements = $("div.identifying-class);
</code></pre>
<p>over this</p>
<pre><code><div data-identifying-attr="true">bla bla</div>
<div data-identifying-attr="true">bla bla</div>
var interestingElements = $("div[data-identifying-attr]");
</code></pre>
<p>Are attribute based selectors quicker /slower/the same speed as class based selectors?
Is one method deemed better practice than the other - if so why?</p>
| jquery | [5] |
4,484,901 | 4,484,902 | is startsWith faster than indexOf | <p>I am writing some java code where I branch off based on whether a string starts with certain characters while looping through a dataset and my dataset is expected to be large. </p>
<p>I was wondering whether startsWith is faster than indexOf. I did experiment with 2000 records and did find any difference.</p>
| java | [1] |
4,734,512 | 4,734,513 | How to Go to home screen when pressed on navbar button | <p>I want to add a rightbar button on navigation bar as home button..</p>
<p>When ever i tap on that button i want to go to firstcontroller,that is my home screen</p>
<p>Please help me in this</p>
<p>Thanks in advance</p>
| iphone | [8] |
3,333,208 | 3,333,209 | Change href value for a hyperlink | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/179713/how-to-change-the-href-for-a-hyperlink-using-jquery">How to change the href for a hyperlink using jQuery</a> </p>
</blockquote>
<p>I have a link that is being generated by a database that I need to change. </p>
<p>I was wondering if I can use jQuery to find the required id and change the href value?</p>
| jquery | [5] |
2,104,067 | 2,104,068 | PHP: Get the Latest File Addition in a Directory | <p>How to get the latest file name, or the file path that is added into a directory?</p>
| php | [2] |
3,075,646 | 3,075,647 | How i can convert this (′) character to html entities using php? | <p>i want to make this character (′) html entity for storing in my database using php. I am using MySQL databse. I use
<br /><br /></p>
<pre><code>$string = "HTML5′s placeholder Attribute";
$newStr = htmlspecialchars($string, ENT_QUOTES);
echo $newStr;
</code></pre>
<p>the above code prints the following</p>
<pre><code>HTML5&acirc;?&sup2;s placeholder Attribute
</code></pre>
<p>Please tell me how i can make this (′) character an HTML entity </p>
| php | [2] |
4,690,526 | 4,690,527 | Python: line break in a textfile after specific word | <p>I have a textfile and there's just one line with 10.000 words.
Now I want to add a line break before a specific word ("Comment") appears and I also want to write this in a new textfile:</p>
<p>The textfile looks like: "Comment: Yeah, you're right Comment: That's very interesting Comment: really?</p>
<p>And the new file should looks like:</p>
<pre><code> Comment: Yeah, you're right
Comment: That's very interesting
Comment: really?
</code></pre>
<p>I tried this code below but there's something wrong. I'm a beginner and until now, I wasn't able to find a solution. Thanks for your help</p>
<pre><code> -*- coding: utf-8 -*-
d = file('test.txt','r')
text=d.read()
e = file('output.txt','w')
x=raw_input("Insert word:")
# -> Comment
for line in d.readlines():
if line.startswith(x):
word.append(+"\n")
e.write()
e.close()
d.close()
</code></pre>
| python | [7] |
4,981,860 | 4,981,861 | c++ error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘secret’ | <p>I do not understand where this error is located. I've spent a few hours on just trying to figure this out but no luck. Using g++ My compiler highlights class secret. </p>
<pre><code>#ifndef ENEMIES_H
#define ENEMIES_H
class secret {
private:
int damage;
int accuracy;
int hlth;
public:
int attack(int x);
int health(int x);
};
#endif
</code></pre>
| c++ | [6] |
4,052,674 | 4,052,675 | How to send mail only through email clients in my android application | <p>How to send mail through only email clients from my android application.</p>
<p>I am using the below code in my application but its <code>opeing messeges</code> and <code>bluetooth</code> also. I need only Email clients like <code>Gmail</code> or <code>yahoo</code>.</p>
<pre><code> Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/rfc822");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "mailto@gmail.com");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My subject");
startActivity(Intent.createChooser(emailIntent, "Email:"))
</code></pre>
| android | [4] |
55,585 | 55,586 | Java String attribute | <p>I came across this statement and i have never seen it before:</p>
<pre><code>String caseTag = tag.toLowerCase(), attrib;
</code></pre>
<p>I see that there is an Attribute class but i don't understand what the above statement does.</p>
| java | [1] |
1,991,244 | 1,991,245 | Java code not compiling with a SQL statement | <p>I am trying to delete a record from a database using the following code in Java</p>
<pre><code>try {
Statement st = db.con.createStatement();
con.stmt = st.executeUpdate("DELETE FROM item, WHERE Name=" + textField_name.getText());
</code></pre>
<p>however "stmt", (which is my PreparedStatement initialized in my connection class), is underlined and the code doesn't compile. </p>
| java | [1] |
5,585,711 | 5,585,712 | js get radio label text | <p><br>
i have this code : </p>
<pre><code><input type=radio name="vote_x" value="5">
<label for="vote_x">blabla</label><br>
</code></pre>
<p>how can i get the label value for radio with id of <code>vote_x</code> [using JS] ??</p>
<p>thanks</p>
| javascript | [3] |
1,207,014 | 1,207,015 | Inserting code in forums | <p>If we insert code in asp.net forums we have to put any additional tags in code for displaying??because so many sides my code is not coming in questions but if we are going to edit question the code is coming</p>
| asp.net | [9] |
4,796,099 | 4,796,100 | Add node to jQuery selection | <p>I have a function that applies a wrap to different elements (and does some other stuff that is not relevant for this question). I would like the function to return the globality of the wrap element as jQuery selection. I dont want to have to reselect them.</p>
<p>i have tried something like this:</p>
<pre><code>myfunction(){
return $mythings.each(function(){
$wrap = $("div.wrap");
$(this).wrap($wrap);
//do some other stuff
return $wrap;
});
};
</code></pre>
<p>but this was returning $mythings.</p>
<p>So i tried this:</p>
<pre><code>myfunction(){
var $returnOfTheWrap = $();
$mythings.each(function(){
$wrap = $("div.wrap");
$(this).wrap($wrap);
//some different actions
return $returnOfTheWrap.push($wrap);
});
return $returnOfTheWrap;
};
</code></pre>
<p>returns $($(wrap)); </p>
<p>Any idea how i could solve this? I would like to get $(wrap0, wrap1, wrap2) back</p>
| jquery | [5] |
274,376 | 274,377 | FileDescriptor to open a file in Java | <p>I want to have a method whose purpose is this :</p>
<p><code>fileDescriptor openFile (filename)</code> : will open a file with a specific name (it will erase the content if it already exists) and put a “Beginning of Process” as a first line); return a file descriptor</p>
<pre><code>public FileDescriptor openFile(String fileName){
}
</code></pre>
<p>Can anybody help me wd this?</p>
| java | [1] |
1,503,064 | 1,503,065 | PHP script ending early, no evidence of an error and timeout set to 0 | <p>time for another brain teaser of something I guess is quite rare.</p>
<p>Is there a hard limit in PHP? Or in Apache? I had a script running last night which lasted around 20 hours. Then it just stopped, mid script on a random line with no errors that I could find.</p>
<p>set_time_limit(0); was set in the script but I'm starting to wonder if there is another limit somewhere else for around 20 hours...</p>
<p>any ideas?</p>
<p>Many thanks in advance.</p>
<p>edit: this is run as a wget.</p>
<p>edit2: I am going to look at the memory issue and get back to you, thanks for the help thus far!</p>
<p>edit3: Oh I should point out this script is gathering data and storing it in an array, the longer it is running the more it is storing so yeah, I'm kinda palm facing on the "used up all the memory" answers here...</p>
<p><strong>SOLUTION: Setting a larger memory for the operation fixed this. Thank you everyone.</strong></p>
| php | [2] |
3,272,858 | 3,272,859 | getting variable value from inside a callback function | <p>I am trying to pull a variable's value from a callback function.
What am I doing wrong here?</p>
<pre><code>var storyList = [];
var storyTemp ={};
// get list of all stories
db.getAllStoriesSet(function(err, reply) {
if (err) throw err;
else {
storyList = reply;
console.log("storylist inner: " + storyList);
};
});
console.log("storylist outer: " + storyList);
</code></pre>
<p>in the above code, I am expecting the inner and outer storylist values to be same.
however the outer storyList value still comes as a null list.</p>
<p>EDIT: to add to the question.
I have initialized a variable storyList outside the async function. i am then taking the reply from the async function and putting it in the variable storyList. I was hoping to cheat my way out of the async pit of slow and brutal death that I have apparently dug for myself.
shouldnt it have worked?</p>
| javascript | [3] |
97,065 | 97,066 | jquery .append() not working | <p>I am trying to append some text to the dynamically created div. I am doing this inside the .each() fucntion. The problem the text is not getting appended. Can someone please help me with this. Here it is what I am trying to do</p>
<pre><code> $('<div class="window" id="window'+i+'" />')
.append($('<p id="country'+i+'">').text($(this).find('COUNTRY').text()))
.appendTo('body');
var j = 0;
$(this).find('TO').each(function(){
var $name = $(this).text();
alert("@@@@@@@@@@@@@@@@@@@@::::"+$name);
j +=1;
$('<#id="window'+i+'" />').append($('<p id="to'+j+'">Test</p>'));
});
</code></pre>
<p>Please help me by letting me know where I am going wrong with this</p>
| jquery | [5] |
5,691,636 | 5,691,637 | PHP parsing XML with invalid character | <p>I am getting an xml file from a webservice.</p>
<p>Unfortunately the file contains character code 2 (\u0002), which breaks the parser.</p>
<p>So I'm trying to remove all character code 2's, but I get wierd results just when trying to do a simple string replace.</p>
<p>To test this, I created a php file named test.php with the following content:</p>
<pre><code><?
$aaa="Hi"+chr(2)+"There"+chr(2)+"Rick";
$aaa = str_replace($aaa,chr(2),"");
echo $aaa;
?>
</code></pre>
<p>I'm running this from the command line:</p>
<p>php test.php</p>
<p>When I run this I get a blank string.</p>
<p>What am I doing wrong?</p>
| php | [2] |
3,881,471 | 3,881,472 | please can anybody help me out how to do the Spell check using jquery | <p>I need to implement Spell Check for my application using jquery,</p>
<p>Please can anyone help me out about this?</p>
<p>thanks</p>
| jquery | [5] |
3,946,734 | 3,946,735 | Change Content like google? | <p>I'm trying to make a help page with a similar layout as <a href="http://support.google.com/plus/?hl=en" rel="nofollow">http://support.google.com/plus/?hl=en</a>. Could someone please give me some advice or example of the best way to get the new content list to load without having to reload the page.</p>
<p>If you look at the link and press on for example, "circles and streams it changes the list on the right hand side. </p>
<p>thank you in advance </p>
| javascript | [3] |
393,131 | 393,132 | iPhone base64 encode image asynchronous download | <p>I have an app which requires downloading image asynchronously in base64 encoded string(server is returning the image in Base64 encoded format),I am using the AsyncImage view,but it seems that AsyncImageView library only accepts the url to download asynchronously.
Anyone having any idea how to go about this,if i will download all images at once an then i can pass that encoded string to </p>
<pre><code> [self.imageView loadImageFromURL:[NSURL URLWithString:[EncodedString]]];
</code></pre>
<p>but this dosesn't make sense as all the image will be downloaded still in UIThread.
Please help.
Thanks..!!</p>
| iphone | [8] |
6,007,031 | 6,007,032 | Detecting Mouse position in Firefox in javascript | <p>I'm trying to detect mouse position inside the element through on mouse move event but it does not work in Firefox.</p>
<pre><code>function mouseover_imageChange(imgid,imgArr) {
var x= event.pageX- jQuery("#"+imgid).offset().left;
var y= event.pageY- jQuery("#"+imgid).offset().top;
}
</code></pre>
<p>Any idea on how to make it work in all browsers, along with the parameters that are needed to be passed to the function?</p>
<p>Thanks,
Muhtu</p>
| javascript | [3] |
127,849 | 127,850 | Currency CultureInfo | <p>I need to display currency in a culture specific way we are currently supporting only english speaking countires but that might expand to another countries. We are implementing this quickly so I need a way of displaying a universal currency format for the time being until I can implement a culture specific. </p>
<p>Does anyone know the best way to do this?</p>
| c# | [0] |
5,398,307 | 5,398,308 | invalid conversion from ‘int (*)(int)’ to ‘int’ error? | <p>I am learning C++ and one of the programs was for a random number generator.<br>
Once I wrote the program I got the following errors: </p>
<pre><code>dice.cpp: In function ‘int main()’:
dice.cpp:18: error: pointer to a function used in arithmetic
dice.cpp:18: error: invalid conversion from ‘int (*)(int)’ to ‘int’
</code></pre>
<p>Here is my code:</p>
<pre><code>#include<iostream>
#include<cmath>
#include<stdlib.h>
#include<time.h>
using namespace std;
int randn(int n);
int main()
{
int q;
int n;
int r;
srand(time(NULL));
cout<<"Enter a number of dice to roll: ";
cin>>n;
cout<<endl;
for (q=1; q<=n; q++)
{
r=randn+1; // <-- error here
cout<<r<<endl;
}
return 0;
}
int randn(int n)
{
return rand()%n;
}
</code></pre>
<p>What could be the problem?</p>
| c++ | [6] |
2,401,692 | 2,401,693 | Explicit template specialization issue | <pre><code>template <class T>
class Test
{
public:
template<class U> void f(); //generic function
template<> void f<char>(); //Specialization for char.
};
template <class T>
template<class U>
void Test<T>::f() //Definition of generic function
{
}
template<>
template<> void Test<char>::f<char>(){} //Definition of specialization.
int main()
{
Test<char> ob1;
ob1.f<char>(); //Works fine.
Test<int> ob2;
ob2.f<char>(); //Produces linker error.
}
</code></pre>
<p>Linker error is </p>
<pre><code>error LNK2019: unresolved external symbol "public: void __thiscall
Test<int>::f<char>(void)"
</code></pre>
<p>My requirement is: I should be able to pass any type to Test class and any type to function f(). I should be able to use all combinations of types like below.</p>
<blockquote>
<pre><code> Test f()
--------------
int char
char int
int int
</code></pre>
</blockquote>
<p>I can solve the error by defining another function like below.</p>
<pre><code>template<>
template<> void Test<int>::f<char>(){}
</code></pre>
<p>But then what is the use of making Test class as Template ? How to make it work for all combinations ?</p>
| c++ | [6] |
5,073,324 | 5,073,325 | Control '0' of type 'TextBox' must be placed inside a form tag with runat=server | <p>there is dynamic table that i created(on server-side), the cols is(irem,price, pic and textxbox),
when i try to add the textbox i getting the messege <strong>Control '0' of type 'TextBox' must be placed inside a form tag with runat=server</strong>
.</p>
<p>here is the code (case 4 is where i create the textbox ):</p>
<pre><code> protected void createTable()
{
int numberOfItems = mylist.Count;
// Create a new HtmlTable object.
HtmlTable table1 = new HtmlTable();
// Set the table's formatting-related properties.
table1.Border = 1;
table1.CellPadding = 1;
table1.CellSpacing = 1;
table1.BorderColor = "red";
// Start adding content to the table.
HtmlTableRow row;
HtmlTableCell cell;
for (int i = 0; i < numberOfItems; i++)
{
// Create a new row and set its background color.
row = new HtmlTableRow();
row.BgColor = "lightyellow";
row.Height = Convert.ToString(100);
name = mylist[i].Name;
price = mylist[i].Price;
image = mylist[i].ImagePath;
for (int j = 1; j <= 4; j++)
{
// Create a cell and set its text.
cell = new HtmlTableCell();
switch (j)
{
case 1:
cell.InnerHtml = name;
break;
case 2:
cell.InnerHtml = Convert.ToString(price);
break;
case 3:
cell.InnerHtml = image;
break;
case 4:
TextBox txt = new TextBox();
txt.ID = Convert.ToString(i);
txt.TextMode = TextBoxMode.SingleLine;
txt.Attributes.Add("runat", "server");
cell.Controls.Add(txt);
break;
default:
break;
}
// Add the cell to the current row.
row.Cells.Add(cell);
}
// Add the row to the table.
table1.Rows.Add(row);
}
// Add the table to the page.
this.Controls.Add(table1);
}
</code></pre>
| asp.net | [9] |
1,803,214 | 1,803,215 | ASP.NET - Dynamically created button | <p>I have added a dynamically created button in my Webform. But its click event is not working. Can anyone please explain why?</p>
<p>This is my code:</p>
<pre><code> Button save = new Button();
save.ID = "btnSave";
save.Text = "Save";
save.Click += new System.EventHandler(this.Save_Click);
Webform.Controls.Add(save);
protected void Save_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}
</code></pre>
<p>Its coming back to the same page itself. It is not redirecting to Default.aspx.</p>
| asp.net | [9] |
3,483,284 | 3,483,285 | How do I provide a download for existing Excel with PHP? | <p>I have a generated xls file on my server that I would like to push to the client for download but can't seem to get it working. Here is what I have so far:</p>
<pre><code>$xlsFile = 'test.xls';
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=$xlsFile");
header("Content-Transfer-Encoding: binary ");
exit();
</code></pre>
<p>My excel file is correct and can be opened if I open it from the server but how can I push this file to the client for download?</p>
| php | [2] |
3,616,903 | 3,616,904 | how to write regular expression to validate a string using regex in C# | <p>I need to validate a user input based on condition. i wrote a regular expression to do so, but it's failing not sure why.
Can somebody point where i am making mistake?</p>
<pre><code>Regex AccuracyCodeHexRegex = new Regex(@"^[PTQA]((0|8)[01234567]){2}$");
</code></pre>
<p>This is what i am trying to validate(If the string is a subset of these strings then it is valid):</p>
<blockquote>
<p>Phh, Thh, Qhh, Ahh where 'h' is a hex digit in the set {00, 80, 01, 81, 02, 82, 03, 83, 04, 84, 05, 85, 06, 86, 07, 87}</p>
</blockquote>
<p>Ex: P00 is valid
P20 is not valid</p>
| c# | [0] |
5,100,007 | 5,100,008 | Response.Redirect and IFrames | <p>I have a Main.aspx page and a Sub.aspx page.</p>
<p>The Sub.aspx page resides in my Main.aspx page via IFrame. So the IFrame contains / loads the Sub.aspx</p>
<p>In another Third.aspx completely unrelated I've got some code that needs to redirect back to Main.aspx but then there are some querystrings that need to be passed to Sub.aspx (or put antoher way my Sub.aspx needs to get those values from the Main.aspx).</p>
<p>My Sub.aspx will check for that querystring flag and if set, run x JS scripts.</p>
| asp.net | [9] |
877,316 | 877,317 | Javascript to replace innerText and not if its an attribute | <p>How to use Javascript to selectively replace the word called Rindan in he below text ,
but not if its in some attribute like img alt=="Rindan"
I want to replace the word Rindans which is an inner text and not if it is in attribute .</p>
<pre><code>`"<a href="http://edition.cnn.com/video/?hpt=hp_t1#/video/bestoftv/2012/02/28/ac-marie-rindan-family-syria.cnn">Rindan's family on her legacy</a> &nbsp;<a href="http://edition.cnn.com/video/?hpt=hp_t1#/video/bestoftv/2012/02/28/ac-marie-Rindan-family-syria.cnn" target=""><img alt="Rindan's family on her legacy" border="0" class="cnnVideoIcon" height="10" src="http://i.cdn.turner.com/cnn/.e/img/3.0/global/icons/video_icon.gif" width="16" /></a>`"
</code></pre>
| javascript | [3] |
2,731,121 | 2,731,122 | Running a PHP in the background while displaying another PHP | <p>Currently I have 2 PHP files. 1 is the user interface and another fetches data from the backend and inserts into the database.</p>
<p>Currently if I use the following in the UI php:</p>
<pre><code><html>
<body>
<form action = "test.php" name="form" method="post">
<input type="text" name="text_box" size="50"/>
<input type="submit" id="search-submit" value="submit"/>
</form>
</body>
</html>
</code></pre>
<p>Upon clicking submit it goes to the test.php. If it possible to execute test.php in the background while remaining on the UI php?</p>
<p>Some of the previous posts talk about using ajax etc which I am not sure how to implement. Possible to do this in php?</p>
<p>Thanks in Advance.</p>
| php | [2] |
5,128,073 | 5,128,074 | Convert a PHP String to a Keycode String | <p>I need to take a string and convert each character in the string to it's Keyboard code using PHP.</p>
<p>So for an example <code>Dave</code> would turn into <code>68,61,76,65</code></p>
<p>I have a client who insist on using one of those JavaScript scramblers which converts an Email into the keycodes, then the JavaScript below re=creates the email address and add's it to the screen</p>
<p><code>emailriddlerarray</code> is the user's email address with each character converted to the keycode</p>
<pre><code>var emailriddlerarray=[68,97,118,105,100,67,64,87,101,98,114,97,103,101,111,117,115,46,99,111,109]
var encryptedemail_id50='' //variable to contain encrypted email
for (var i=0; i<emailriddlerarray.length; i++){
encryptedemail_id50+=String.fromCharCode(emailriddlerarray[i])
}
</code></pre>
| php | [2] |
5,124,750 | 5,124,751 | Speeding up Java Program | <p>Sorry for the non descriptive title, I couldn't think of a way to ask the question.</p>
<p>I wrote a java program which involves two long discrete processes. The first creates a hashmap from a text file with about 400,000 lines; so as you can imagine this takes some time to do. The thing is, this textfile never changes but I still have to generate the same hashmap every time the program runs. Is there some way of getting around this. Maybe using serialization or something to save this hashmap so that I can just use the already generated hashmap every time the program runs?</p>
<p>EDIT:
The text file maps strings to urls. The first part of the program builds the map from the 400,000 line text file. The other part of the program reads from another text file and replaces every string it finds that is also in the hashmap with it's respective URL (this is another long process because I have to iterate the entire hashmap looking for strings at every line of the program). Make sense?</p>
<p>EDIT 2 (per your request; a snippet of my code to populate the map):</p>
<pre><code>while( (line = mapFile.readLine() ) != null) {
String string = "";
String url = "";
int i = 0;
for(; line.charAt(i) != '\t'; i++) string += line.charAt(i);
i++;
for(; i < line.length(); i++) url += line.charAt(i);
methodMap.put(string, url);
}
</code></pre>
<p>Thanks.</p>
| java | [1] |
5,643,023 | 5,643,024 | How to detect no child xml node using XmlReader? | <p>How to differenciate between the two nodes</p>
<pre><code><Header Name="ABC" />
and
<Test Test="AA">
Hello
</Test>
</code></pre>
<p>using XmlReader? The problem is that I am not been able to know whether a node contains child or not using <code>XmlReader</code>.</p>
| c# | [0] |
301,530 | 301,531 | calling jquery function from a dropdown list | <p>I have the following dropdown list box:</p>
<pre><code> <select name="DDLConditional1" size="1">
<option selected="selected">is equal to</option>
<option>begins with</option>
<option onclick="ShowBetween();">is between</option>
<option>is not equal to</option>
<option>is greater than</option>
<option>is less than</option>
</select>
</code></pre>
<p>I want to show() a textbox and a label based on someone selecting the "is between" option of the dropdown list.
I have multiples of these dropdowns and all of them will have to do the same thing. In other words I have
DDLConditional1 2 3 4... infinite. I've already been able to make the button work that appends new conditionals.</p>
| jquery | [5] |
3,828,365 | 3,828,366 | Why loop overwriting my file instead of writing after text? | <pre><code>i = 1 # keep track of file number
directory = '/some/directory/'
for i in range(1, 5170): #number of files in directory
filename = directory + 'D' + str(i) + '.txt'
input = open(filename)
output = open('output.txt', 'w')
input.readline() #ignore first line
for g in range(0, 7): #write next seven lines to output.txt
output.write(input.readline())
output.write('\n') #add newline to avoid mess
output.close()
input.close()
i = i + 1
</code></pre>
<p>I have this code, and i am trying to get one file and rewrite it to output.txt, but when i want to attach next file, my code overwrite older file that has been attached. In result when code is complete i have something like this:</p>
<pre><code>dataA[5169]=26
dataB[5169]=0
dataC[5169]=y
dataD[5169]='something'
dataE[5169]=x
data_date[5169]=2012.06.02</code></pre>
<p>Instead of datas ranging from files 0 to 5169. Any tips how to fix it?</p>
| python | [7] |
1,066,788 | 1,066,789 | Check if value is multiple of 10 | <p>I want to check if a value is a multiple of a certain number, for example, multiples of 10, but I also want to be able to change it to whatever I want.</p>
<pre><code>if (directWinner == 10){
}
</code></pre>
| javascript | [3] |
3,149,770 | 3,149,771 | Why is __radd__ not working | <p>HI</p>
<p>Trying to understand how <code>__radd__</code> works. I have the code</p>
<pre><code>>>> class X(object):
def __init__(self, x):
self.x = x
def __radd__(self, other):
return X(self.x + other.x)
>>> a = X(5)
>>> b = X(10)
>>> a + b
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
a + b
TypeError: unsupported operand type(s) for +: 'X' and 'X'
>>> b + a
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
b + a
TypeError: unsupported operand type(s) for +: 'X' and 'X'
</code></pre>
<p>Why is this not working? What am I doing wrong here?</p>
| python | [7] |
5,775,662 | 5,775,663 | Find out client-side ID of HTML element created by .NET? | <p>How do I write some client-side script to access a HTML element when .NET has generated the element's ID at runtime?</p>
<p>At present I have this in my ASPX: </p>
<pre><code><asp:Content ContentPlaceHolderID="middle_area" runat="server">
<asp:Image ID="ImageBarChart" runat="server" />
</asp:Content>
<script>
var oImage = document.getElementById('ctl00_middle_area_ImageBarChart')
</script>
</code></pre>
<p>It it working at present, but I doubt it is reliable! </p>
| asp.net | [9] |
3,593,020 | 3,593,021 | Android RSS reader | <p>I'm trying to develop an Android RSS Reader. I would like to use android.sax to read some information from a rss but I'm not sure how to do it. I need a tutorial about android.sax or some example about it. Can somebody help me please?</p>
| android | [4] |
3,422,782 | 3,422,783 | jQuery Event Propagation: fadeIn get call multiple times | <p>Here is my base case. If I click on <code>Text</code>, a text box will fade in, and put a focus on that text box. When I press Esc, the text box will disappear and the <code>Text</code> will fade back in. <a href="http://jsfiddle.net/FDjUm/" rel="nofollow">http://jsfiddle.net/FDjUm/</a>. I have two questions. <strong>Please refer to the below jsfiddle for visual demonstration of my questions</strong></p>
<p>1) <a href="http://jsfiddle.net/FDjUm/4/" rel="nofollow">http://jsfiddle.net/FDjUm/4/</a>
I put in an alert box in the <code>focus</code>, and it get called infinitely. Why is that and how can I fix it?</p>
<p>2) <a href="http://jsfiddle.net/Zh8HR/13/" rel="nofollow">http://jsfiddle.net/Zh8HR/13/</a>
I put in an alert box in the <code>fadeIn</code>. The alert get called multiples times (not infinitely). So I put <code>return false</code> then the first time (the first click and press Esc), it work great (alert box only appear 1 time). But the more you click and esc, the more time the alert box appear? Why and how to fix it?</p>
<p>I am new to jQuery, so be criticized if the way I write jQuery is improper. And i want to learn and write good code. </p>
| jquery | [5] |
329,643 | 329,644 | Fail to launch Application | <p>error: failed to launch '/Users/imobdevtech/Library/Developer/Xcode/DerivedData/timesync-ajuwdrwsixqrnodrkmfmwjpptbmq/Build/Products/Debug-iphoneos/timesync.app/timesync' -- failed to send the qLaunchSuccess packet</p>
<p>This is the error I get First time installing app into Devic.
It installs Perfectly but could not launch.
In second try it works perfectly.
can anybody help with this issue...</p>
| iphone | [8] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.