Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
3,105,794 | 3,105,795 | CS0016: Could not write to output file 'c:\..\..\App_Web_XXXX.aspx..dll' -- 'The directory name is invalid. ' | <p>This problem is driving me nuts.</p>
<blockquote>
<p>CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework<64>\vX.X.XXXX\Temporary ASP.NET Files\root\XXXXXX\XXXXXX\App_Web_XXXX.aspx.XXXXXXXX.XXXXXXXX.dll' -- 'The directory name is invalid. '</p>
</blockquote>
<p>I've tried to give full access to the network service on C:\windows\temp and the temp folder in v4.0.xxx folder.</p>
<p>The server is Windows Server 2008 R2; SQL Server 2008 R2 is installed on the same server.</p>
<p>I believe that it could have something to do with SQL Server being installed after the .NET Framework 4.0 was installed, but I ran <code>aspnet_regiis.exe -u</code> and then <code>-i</code> to reinstall. I've tried from both the Framework folder and Framework64 folder but to no avail.</p>
<p>Has anyone else had this problem? If so, how did you fix it?</p>
| asp.net | [9] |
3,477,020 | 3,477,021 | Find greatest of three values in PHP | <p>With three numbers, <code>$x</code>, <code>$y</code>, and <code>$z</code>, I use the following code to find the greatest and place it in <code>$c</code>. Is there a more efficient way to do this?</p>
<pre><code>$a = $x;
$b = $y;
$c = $z;
if ($x > $z && $y <= $x) {
$c = $x;
$a = $z;
} elseif ($y > $z) {
$c = $y;
$b = $z;
}
</code></pre>
| php | [2] |
3,776,856 | 3,776,857 | Database on Android | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1510840/where-does-android-emulator-store-sqlite-database">Where does Android emulator store SQLite database?</a> </p>
</blockquote>
<p>I am doing database application in android.i need to know where the data base is store,whether in Emulator or in our application.</p>
<p>Thanks in advance...</p>
| android | [4] |
3,317,106 | 3,317,107 | Stop JavaScript from truncating leading 0 | <p>I normally use the following code to get PHP variables into JavaScript:</p>
<pre><code>echo("var zipCode = " . $zipCode . ";");
</code></pre>
<p>This works fine but on zip codes that start with a 0 it is truncating it.</p>
<p>I am trying to figure out a way to keep the leading 0.</p>
<p>Any help would be great.</p>
<p>Thanks</p>
| javascript | [3] |
5,019,033 | 5,019,034 | Andrioid How to cache data | <pre><code> Android How to cache the data for 2 days.
</code></pre>
<p>Thanks
Ramachandran</p>
| android | [4] |
1,699,554 | 1,699,555 | Why is this code not drawing a line? | <p>I am not sure why my code is not working but it is driving me crazy.</p>
<p>This is my class that should draw the button and creates the area to draw on:</p>
<p>The second set of code is the driver program I need to make 4 canvas's that when I make two mouse clicks it draws a line between the two clicks and then repaints if I try and click on a canvas again.</p>
<p>I get the following errors:
error: invalid method declaration; return type required
addMouseListener(this);
^
error: illegal start of type
addMouseListener(this);
^</p>
<pre><code>public class Scribble extends JPanel implements MouseListener
{
addMouseListener(this);
int x, x1, y, y1;
boolean flag = false;
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawLine(x, y, x1, y1);
}
public void mouseReleased(MouseEvent e)
{
if (!flag){
x = e.getX();
y = e.getY();
flag = true;
}
else{
x1 = e.getX();
y1 = e.getY();
flag = false;
repaint();
}
}
public void mouseExited(MouseEvent e){}
public void mouseClicked(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseMoved(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
}
public class Lab8Draw extends JFrame{
public Lab8Draw(){
Color c = new Color(100, 10, 200);
setTitle("Lab 8 - Application #1");
setLayout(new GridLayout(2,2));
Scribble s = new Scribble();
s.setBackground(Color.WHITE);
add(s);
Scribble s1 = new Scribble();
s1.setBackground(Color.RED);
add(s1);
Scribble s2 = new Scribble();
s2.setBackground(c);
add(s2);
Scribble s3 = new Scribble();
s.setBackground(Color.BLUE);
add(s3);
}
public static void main (String[] args){
Lab8Draw frame = new Lab8Draw();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 800);
frame.setVisible(true);
}
}
</code></pre>
| java | [1] |
2,670,444 | 2,670,445 | Cryptography in java bytes to bits | <p>I wrote server and client and I would like to send some file which will be encrypted. So I have to operate on bits, not bytes, because my cryptography metod is like that: I send my file in parts of about 8 bits and I add to them some specific MAC. (its: winnowing and Chaffing metod)</p>
<p>In my program I read file into byte array. But I need byte to bits to add MAC adress to each part of file and send them in parts. </p>
<p>My question is:
Is there any posibility to operate on bits in Java, or if not how would you solve this problem? </p>
| java | [1] |
1,602,712 | 1,602,713 | Android Hierarchy Viewer is not showing performance indicators for a view | <p>I am working with Android 2.2. While checking the views using HierarchyViewer, no performance indicators are being displayed. It shows 'n/a' agianst each of the three measures. Why is this happening?</p>
| android | [4] |
2,434,992 | 2,434,993 | Get a file from a URL | <pre><code>$vars='https://www.googleapis.com/latitude/v1/currentLocation?key=AIzaSyB2hw658V7RSzEYgwSHwYkaLm_505gqLhs';
$content = file_get_contents( $vars );
</code></pre>
<p>I am using this function for retrieving a file from a url but <code>file_get_contents()</code> is not working. Please suggest me a function for the same work.</p>
| php | [2] |
2,248,044 | 2,248,045 | validation conflicts with routing | <p>I have a trouble with asp.net validations. At first my validation worked successfully. But when I began to routing, my clientside validations didn't work. There is successful and unsuccessfull codes:</p>
<p><em><strong>Unsuccessful example :</em></strong> </p>
<pre><code>void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add("Pages", new Route("{PageName}/", new PageRouteHandler("~/Page.aspx")));
}
</code></pre>
<p><em><strong>Successful example :</em></strong></p>
<pre><code>void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.Add("Pages", new Route("PageName/", new PageRouteHandler("~/Page.aspx")));
}
</code></pre>
<p>How can I overcome this problem? </p>
| asp.net | [9] |
4,133,716 | 4,133,717 | Can someone please explain .map() in laymans terms? | <p><strong>UPDATE 1:</strong></p>
<p>Here is more of the script:</p>
<pre><code>$(".favorites").sortable(
{update:function() {
var that = this;
var urls = "";
var texts = "";
$.map($(".favorites a"), function(elt) {
urls += "url=" + elt.href + "&";
texts += "text=" + $(elt).html() + "&";
});
$.ajax({
url: 'favorites.asmx/save',
type: 'POST',
data: { strItems:$(that).sortable("serialize",{key:'item'}), strURLs:urls.substr(0,urls.length - 1), strTexts:texts.substr(0,texts.length - 1) },
error: function(xhr, status, error) {
console.log(xhr.responseText);
},
success: function() {
console.log("Values sent:- strURLs: " + urls.substr(0,urls.length - 1));
}
});
</code></pre>
<p><strong>ORIGINAL QUESTION:</strong></p>
<p>I have the following script which works, but I don't understand it:</p>
<pre><code>$.map($(".favorites a"), function(elt) {
urls += "url=" + elt.href + "&";
texts += "text=" + $(elt).html() + "&";
});
</code></pre>
<p>I understand the basic examples in this link: <a href="http://api.jquery.com/jQuery.map/" rel="nofollow">http://api.jquery.com/jQuery.map/</a>, but I don't understand the script I have posted above.</p>
| jquery | [5] |
5,013,329 | 5,013,330 | How to kill other applications in android | <p>Can any body tel1 me how to kill other applications when i open my application.For example i am playing some music and i opened my application and trying to kill the other applications using below code.I couldnot stop the music playing.`ActivityManager activityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);</p>
<pre><code> for(RunningAppProcessInfo info:activityManager.getRunningAppProcesses()){
activityManager.killBackgroundProcesses(String.valueOf(info.pid));
activityManager.killBackgroundProcesses(String.valueOf(info.processName));
}`.
</code></pre>
<p>I have given permissions in manifest file also. I am not getting any errors aslo.
Plz help me .Thanks in advance</p>
| android | [4] |
3,879,878 | 3,879,879 | Question regarding SDK object / method call: public abstract SharedPreferences.Editor putString (String key, String value) | <p>When I try to use this in Eclipse (3.6) I get:
The method putStringSet(String, HashSet) is undefined for the type SharedPreferences.Editor</p>
<p>If I cast the HashSet to a Set I get this:
The method putStringSet(String, Set) is undefined for the type SharedPreferences.Editor</p>
<p>However it's clearly defined in the documentation.
<a href="http://developer.android.com/reference/android/content/SharedPreferences.Editor.html#putStringSet%28java.lang.String,%20java.util.Set%3Cjava.lang.String%3E%29" rel="nofollow">http://developer.android.com/reference/android/content/SharedPreferences.Editor.html#putStringSet%28java.lang.String,%20java.util.Set%3Cjava.lang.String%3E%29</a></p>
<p>The documentation says "Since API Level 1"</p>
<p>And the 'Quick Fixes' offered aren't helpful.</p>
<p>I don't think I'm missing any imports but that could make sense too...</p>
<p>I freely admit that I'm not up to speed on Java or Eclipse, so there's good odds I'm missing something obvious...</p>
<p>Anyone care to point out the obvious?</p>
<p>Thank you.</p>
<p>Gary Lucas</p>
| android | [4] |
5,404,022 | 5,404,023 | Android: Where do I find startSubActivity()? | <p>I'm trying to use the function [context].startSubActivity([intent i]) but that won't compile. Apparently startSubActivity() doesn't exist in Android 2.01? I <em>do</em> see a bunch of startActivity(...) functions, but no startSubActivity, which so many examples provide. Would someone please tell me if it's been deprecated, or maybe I'm just not including some library Eclipse isn't helping me find? :)</p>
<p>What I'm trying to do is launch a subactivity inside of a TimerTask inside my app.</p>
<p>Thanks!</p>
<p>-Auri</p>
| android | [4] |
1,605,119 | 1,605,120 | create superglobal variables in php? | <p>is there a way to create my own custom superglobal variables like $_POST and $_GET?</p>
| php | [2] |
864,838 | 864,839 | Count the no of Visitors | <p>I have stored resumes in my database and i have retrive it from asp.net web page by creating linkbutton...i can view ,download the resumes which i stored in my database.My issuse is when i view one resume example (domnic resume)then no of visitor for domnic resume should be count .if again i view that resume no of visitor should be 2...how can i do that in asp.net?</p>
| asp.net | [9] |
5,519,975 | 5,519,976 | Customizing AutoCompleteTextView | <p>I have got <code>AutoCompleteTextView</code> that works well if I fill it's adapter with <code>String</code> objects. </p>
<p>But what methods should I override if I want to pass to it's adapter another kind of objects contains from strings, that should be displayed in popup window after user inputs a text into editbox, and some other info that I need?</p>
| android | [4] |
3,771,368 | 3,771,369 | Java: How do I achieve a pointer effect without method calls? | <p>I am trying to make some sort of integer (be it <code>int</code> or <code>Integer</code>), <code>x</code>, that equals the sum of two other integers: <code>a</code> and <code>b</code>. <code>a</code> and <code>b</code> will change on occasion, so I want <code>x</code> to always be up-to-date.</p>
<p>Is there a way to do this without calling a <code>getX()</code>-like method that returns <code>a</code> + <code>b</code>?</p>
| java | [1] |
2,792,725 | 2,792,726 | Instruct the browser not to wait for more content while processing continues | <p>How do I instruct the browser not to expect any more content to be coming down the line? Kinda like the server saying “I got what I need, you don’t need to wait while I finish the processing of the page”.</p>
<p>I have a server-side task, which is initiated when a certain page is hit. The task may be time-consuming, but the rendered HTML will always be the same, i.e. like a “Thank you for starting the task” message.</p>
<p>I’m considering starting a new thread to handle the task, but I believe there must be a more elegant solution, where you just send the right headers/instructions to the browser and then continue processing.</p>
<p>Any ideas?</p>
| asp.net | [9] |
1,380,070 | 1,380,071 | Python: Help with new line character | <p>I read in a text file that is tab delimited, i then have a list for each line, i then index out the first entry of each list, i then write this to a file. code below:</p>
<pre><code>import csv
z = csv.reader(open('output.blast'), delimiter='\t')
k = open('output.fasta', 'w')
for row in z:
print row[1:12]
for i in row[1:12]:
k.write(i+'\t')
</code></pre>
<p>When writing to the file it writes it as one long line, i would like a new line to be started after the 11th (last) entry in each list. But i cannot figure out where to put the new line charater</p>
| python | [7] |
3,474,302 | 3,474,303 | Convert query to parametrized asp.net query | <p>How would I make this parametrized ?!</p>
<pre><code>string query = "";
query += " SELECT DistID FROM Distributor";
query += " WHERE Username = '" + username_id.Text + "'";
query += " AND Password = '" + password.Text + "'";
GeneralFunctions.GetData( query );
</code></pre>
<p>Can it be done here or would it have to be done inside the GetData method?</p>
<p>Here are the two methods:</p>
<pre><code>public static DataTable GetData ( string query )
{
SqlDataAdapter dataAdapter;
DataTable table;
try
{
dataAdapter = new SqlDataAdapter( query, GetConnectionString() );
table = new DataTable();
dataAdapter.Fill( table );
return table;
}
catch ( Exception ex )
{
}
finally
{
dataAdapter = null;
table = null;
}
return table;
}
public static string GetConnectionString ()
{
string connectionString = ConfigurationManager.ConnectionStrings[ "CAPortalConnectionString" ].ConnectionString;
return connectionString;
}
</code></pre>
| asp.net | [9] |
4,984,461 | 4,984,462 | question about getting value from class | <p>consider following code</p>
<pre><code>#include <iostream>
using namespace std;
class MyClass{
int a;
public:
MyClass(int j) {a = j;}
int geta(void) {return a;}
};
int main(void)
{
MyClass ob = 99;
cout << ob.geta();
}
</code></pre>
<p>output of this code is 99
my question is following statement MyClass ob is declare object of class MyClass and is allowed such kind of declaration that object is equal some number?maybe more specific declaration would be MyClass ob(99) what do you think?</p>
| c++ | [6] |
3,917,683 | 3,917,684 | ASP.net - ValidationSummary output to pop-up page - or as plain html onto the same page | <p>I have an ASP.net page with asp validators and afew custom validators.</p>
<p>When I click submit on the page I want to put the output of the Validation summary on to a new page(pop-up) and leave the old page in the background.</p>
<p>OR</p>
<p>put the validation summary in plain html on the same page</p>
<p>Is it possible to do this? </p>
<p>Any and all help will be usfull.</p>
<p>cheers</p>
| asp.net | [9] |
4,397,165 | 4,397,166 | Different input name's | <p>I have a form with input fields like:</p>
<p>post_1a ; post_1b ; post_1c</p>
<p>post_2a ; post_2a ; post_2a</p>
<p>post_3a ; post_3a ; post_3a</p>
<pre><code><table>
<tbody>
<tr>
<td><input id="new_post_a" name="post_1a" type="text"></td>
<td><input id="new_post_b" name="post_1b" type="text"></td>
<td><input id="new_post_c" name="post_1c" type="text"></td>
<td><button id="add_row_btn">Toevoegen</button></td>
</tr>
</tbody>
</table>
</code></pre>
<p>i want to catch with the post, but because this field are generate with javascript, i have tried to catch with preg_match/explode but results, i need the value of the input.</p>
<p>I cannot change the input name's because of the javascript.</p>
<p>does somebody has an idea becuase i have no ideas anymore?</p>
| php | [2] |
1,337,442 | 1,337,443 | why does my dialog box only work one time? | <p>i have a dialog box and in it, it has two buttons, one that continues and one that cancels. </p>
<pre><code>$(document).ready(function(){
$("[name=resetPwd]").click(function(){
var id = $(this).attr("userid");
var email = $("[field=emailAddress].[userid="+id+"]").text();
var name = $("[field=firstName].[userid="+id+"]").text();
var message = $('<div></div>')
.html('You are about to reset the password for:<br/>'+name+'.<br/>This will send an e-mail to:<br/>'+
email+'<br/><br/><input id="_continue" type="button" value="Continue" /> <input id="_cancel" type="button" value="Cancel" />')
.dialog({
title: 'Reset Password'
});
message.dialog('open');
$("#_cancel").click(function(){
message.dialog('close');
});
});
</code></pre>
<p>it works just fine, (the first time) all my data is there, when i click cancel, it closes, but if i try again cancel doesnt do anything anymore. does anyone know what im doing wrong? please and thanks</p>
| jquery | [5] |
5,775,055 | 5,775,056 | Can I add timeout for ftpslib connection? | <p>Can I add timepout for ftps connection and each command on ftp server ?</p>
<pre>
r = ftpslib.FTP_TLS()
...
</pre>
| python | [7] |
2,845,063 | 2,845,064 | the type or namespace name 'Management' does not exist in the namespace 'MicrosoftSqlServer' are you missing an assembly reference | <p><strong>using Microsoft.SqlServer.Management.Smo;
Using Microsoft.SqlServer.Management.Common;</strong></p>
<p>I am using the above namespaces for restore database from c# window form, but the compiler tell me <strong>"the type or namespace name 'Management' does not exist in the namespace 'MicrosoftSqlServer' are you missing an assembly reference"</strong> </p>
<p>And i follow some advice from google, found DLL in.... C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies</p>
<p>Microsoft.SqlServer.Smo.dll;</p>
<p>Microsoft.SqlServer.ConnectionInfo.dll</p>
<p>I got them now, and i copy them and paste them to all the location in my project, but i still have error message from compiler, could anyone where i can put the reference to ? Thanks</p>
| c# | [0] |
2,608,801 | 2,608,802 | Evenly divide in c# | <p>In c# how do I evenly divide 100 into 7?</p>
<p>So the result would be </p>
<ol>
<li>16</li>
<li>14</li>
<li>14</li>
<li>14</li>
<li>14</li>
<li>14</li>
<li>14</li>
</ol>
<p>The code below is incorrect as all 7 values are set to 15 (totalling 105).</p>
<pre><code> double [] vals = new double[7];
for (int i = 0; i < vals.Length; i++)
{
vals[i] = Math.Ceiling(100d / vals.Length);
}
</code></pre>
<p>Is there an easy way to do this in c#?</p>
<p>Thanks</p>
| c# | [0] |
2,088,639 | 2,088,640 | Fetching tab tilte in viewpager | <p>I have implemented ViewPageIncicator and is running fine. I have 3 tabs with name "Tab1","Tab2", "Tab3". what i want is, the tab name when i scroll the tab.</p>
<p>Could anyone let me know how to fetch the tab title of the current tab that is being displayed?</p>
| android | [4] |
3,319,648 | 3,319,649 | UINavigationItem back problem | <p>i have a UINavigationController in my viewcontroller,and after pushing another viewcontroller from current viewcontroller,when i press the back button on navigation bar, it return to previous view,however the previous data in the first view still there, how can i reset the first view data as like call the viewDidLoad function again when i press the back button?</p>
| iphone | [8] |
2,453,388 | 2,453,389 | Properly use Return Keyword | <p>I'm fairly new to programming and I have a question. I want to get a list of computers on the network, I have done this successfully, then I have been able to get how many computers there are by using .Count()...The issue is, I have several places in my full code where I would like to reference that number, and everytime I try to use c, it tells me that variable doesn't exist in its context. I tried to make my own public method but then it asks me to put in a proper return, and after searching. I still can't figure it out.. Can anyone point me in the correct direction? Thank you. </p>
<pre><code>public void ComputersOnNetwork()
{
List<string> list = new List<string>();
using (DirectoryEntry root = new DirectoryEntry("WinNT:"))
{
foreach (DirectoryEntry computer in computers.Children)
{
if ((computer.Name != "Schema"))
{
list.Add(computer.Name);
}
}
foreach (string s in list)
{
int c = list.Count();
return c;
}
</code></pre>
| c# | [0] |
1,483,784 | 1,483,785 | Returning two variables in a C++ function | <p>I would like to return two double variables: when calling a function that I have created.
According to some tutorials (which deal with the basics of the C++), I would be unable to do that.</p>
<p>Is there a way to do so?</p>
| c++ | [6] |
1,423,368 | 1,423,369 | Loading into appropriate child with jQuery | <p>I use drop-down selector to load matching section from an external file into the table cell in a row below selector. I can't seem to be able to target it properly. I thought that nextAll() would do the trick but it doesn't. What else shall I try? </p>
<pre><code>$('.mySelector').change(function(){
var $selectForm = '#' + $(this).val();
$(this).nextAll('.fLoad').load('formParts.html ' + $selectForm );
});
<table>
<tr>
<td>
<select class="mySelector">
<option value="o1">Car details</option>
<option value="o2">Bike details</option>
<option value="o3">Boat details</option>
</select>
</td>
</tr>
<tr>
<td class='fLoad'>&nbsp;</td>
</tr>
<tr>
<td>
<select class="mySelector">
<option value="o1">Car details</option>
<option value="o2">Bike details</option>
<option value="o3">Boat details</option>
</select>
</td>
</tr>
<tr>
<td class='fLoad'>&nbsp;</td>
</tr>
</table>
</code></pre>
| jquery | [5] |
1,051,644 | 1,051,645 | how to place validation for phone number in android,"starts with +"? | <pre><code> Pattern p = Pattern.compile("^\\+(?:[0-9] ?){6,14}[0-9]$");
//Match the given string with the pattern
Matcher m = p.matcher(numberstr);
//check whether match is found
boolean numberFound = m.matches();
</code></pre>
| android | [4] |
4,749,335 | 4,749,336 | New-ing string types | <p>From <a href="http://www.apress.com/9781590598849/" rel="nofollow">Pro C#</a> </p>
<p>Referring to "New-ing" Intrinsic data types...</p>
<blockquote>
<p>All intrinsic data types support what is known as a default constructor. It allows you to create a variable using the new keyword.</p>
<p>[...] Object references (including strings) are set to null.</p>
</blockquote>
<p>In C#, strings do not have a public default constructor. My guess is that due to string's immutability, they have a private default constructor. But, the context here is talking about Object references and string's as a whole while using <code>new</code>.</p>
<p>Because one cannot do</p>
<p><code>String myString = new String();</code></p>
<p>So,</p>
<p><code>String a;</code></p>
<p>referencing string doesn't result in a "default value". Instead, it's a compiler error to access a.</p>
<p>Though</p>
<pre><code>public class StringContainer
{
public static string myString { get; set; }
}
</code></pre>
<p>Results in a legally accessible string (defaulted to null). This doesn't use <code>new</code>. It performs some kind of magical construction. </p>
<p>What is occurring in the <code>StringContainer</code> scenerio? Because there appears to be no new-able default constructor in string, is this an error in the C# book?</p>
| c# | [0] |
286,983 | 286,984 | string and class are both reference type, then why the comparasion returns different result? | <p>I'm comparing 2 strings and 2 class objects, then why string one comparison gives results "TRUE", whereas objects comparison give "FALSE"? Please explain whats going in term of memory locations in both teh case?</p>
<pre><code>class Program
{
public class Person
{
public string Name { get; set; }
}
static void Main(string[] args)
{
string s1 = "xyz";
string s2 = "xyz";
bool b = s1 == s2;
Person p1 = new Person();
Person p2 = new Person();
bool x = p1 == p2;
}
}
</code></pre>
| c# | [0] |
3,697,015 | 3,697,016 | ifstream not working | <p>I'm trying to open a file using ifstream, but no matter what solutions I find that I've tried, nothing seems to work; my program always outputs "unable to open". Below is my code in its entirety. Any help at all is appreciated!</p>
<pre><code>#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char ** argv)
{
string junk;
ifstream fin;
fin.open("somefile.txt");
if(fin.is_open())
{
fin >> junk;
cout << junk;
}
else
{
cout << "unable to open" << endl;
}
fin.close();
return 0;
}
</code></pre>
<p>Also, the contents of somefile.txt, which is in the same directory as the created executable is the following:</p>
<pre><code>SOME
FILE
</code></pre>
| c++ | [6] |
2,597,848 | 2,597,849 | jQuery Custom Scroll Plugin | <p>I want to develop a jQuery plugin that instead of having scrollbars, it instead has scroll "buttons" on the top and button of a container. The container itself is just an unordered list as a menu on the left hand side of the page, but I also need to calculate when it needs to scroll. The user can resize the browser, but the menu is fixed. If they resize then I need to show the scroll options, otherwise I don't.</p>
<p>Another option was adapting <a href="http://valums.com/vertical-scrolling-menu/" rel="nofollow">this example</a> so that it works for dynamic height dependent on the height of the current window. Basically the menu on the left is always visible in the current position of the entire window. No scrolling of the page should be required to see the menu. It's silly I know, but it's a requirement.</p>
<p><strong>EDIT</strong></p>
<p><a href="http://www.naterkane.com/blog/jquery-scrollable-plugin/#" rel="nofollow">Much like this</a>, but with mouseover as opposed to click, and it just needs to scroll instead of moving specfic amounts.</p>
| jquery | [5] |
3,900,738 | 3,900,739 | EWS SOAP message | <p>I want to send a SOAP message which update an existing appointment at outlook account ,
I found the SOAP message (from MSDN) which do it , but It can update only the subject,date and
attends , <strong>I want to update the task body ... How can i do it?</strong></p>
| c# | [0] |
5,512,968 | 5,512,969 | How do I implement word count in Python? | <pre><code>x="I use computers"
print (x)
y=x[0:1]
y1=x[2:5]
y2=x[6:15]
n=(y+y1+y2)
print len(n)
</code></pre>
<p>I know this counts the number of letters but how do I count the number of words in the sentence?</p>
| python | [7] |
539,723 | 539,724 | how i can replace style with new one using jquery | <p>i am inserting below css using jquery into head tag but problem is everytime i change the color using user interface it add another style tang and than css how can i remove already added and replace with new css please help.</p>
<pre><code><style charset="utf-8" type="text/css">div.contentMid2{background:#000;}div.module{background:#fff;}</style>
</code></pre>
<p>want to add couple of css on runtime but replacing with already added. </p>
| jquery | [5] |
4,520,807 | 4,520,808 | month regex problem in php. validation problem | <pre><code>function preveriDatum($string)
{
if (preg_match("^(3)?(?(1)[0-1]|(0)?(?(2)[1-9]|[12][0-9]))\.(0)?(?(3)[1-9]|1[0-2])\.[1-9][0-9]{3}$^", $string))
return true;
else
return false;
}
</code></pre>
<p>is valid for 13.01.2010 but not for 13.1.2010. Can i aso make it valid for 13.1.2010?</p>
| php | [2] |
4,887,613 | 4,887,614 | A simple question about Javascript functions, differences in invocation/definition | <p>Can someone please explain the difference between the following function definitions?</p>
<pre><code>var alertMessage = function alertMessage(message) {
alert(message);
}
var alertMessage = function(message) {
alert(message);
}
</code></pre>
<p>What are the implications of each? Thanks!</p>
| javascript | [3] |
5,796,662 | 5,796,663 | Java Package Error while compiling the following code | <p>Hi I ve created the following code and the first file called "Draggable.java" is compiled. and the second file "Circle.java" shows me an error.... Please aneswer</p>
<p>In the Draggable.java file</p>
<pre><code>package graphics;
public interface Draggable {
}
</code></pre>
<p>In the Circle.java file</p>
<pre><code>package graphics;
public class Circle implements Draggable {
}
</code></pre>
<p>Note: I ve put the above files in a folder called "graphics".</p>
| java | [1] |
4,410,273 | 4,410,274 | Clear a collection or re-initialize? | <p>I'm working on a .net app and I'm using an object that is composed of 5 Lists and 1 Hashtable. This object is used within a loop that iterates atleast 500 times to run some analysis. On each loop this object should start empty, so I was wondering if it's more efficent to call clear on all Lists and Hashtable or should I just re-initialize the object?</p>
<p>I know I could write code to benchmark this, but I'm wondering if someone has already been down this path?</p>
<p>Thanks,</p>
| c# | [0] |
4,172,920 | 4,172,921 | Warning! Unknown device API version | <p>I am new to Android programming. I have created an app and I am deploying it on my android device with version 4.0.3. I have connected the device properly. Eventhough I get this warning. I have deployed successfully on previous occassions. I am really not able to understand why my device version is not getting detected now. Has my device cable got loose? plz help. Its urgent</p>
| android | [4] |
5,940,652 | 5,940,653 | C++ methods which take templated classes as argument | <p>I have a templated class</p>
<pre><code>Vector<class T, int N>
</code></pre>
<p>Where T is the type of the components (double for example) and n the number of components (so N=3 for a 3D vector)</p>
<p>Now I want to write a method like</p>
<pre><code>double findStepsize(Vector<double,2> v)
{..}
</code></pre>
<p>I want to do this also for three and higher dimensional vectors. Of course I could just introduce further methods for higher dimensions, but the methods would have a lot of redundant code, so I want a more generic solution. Is there a way to create a method which takes a templated class without further specializing it (in this case without specifying T or N)? Like</p>
<pre><code>double findStepsize(Vector<T,N> v)
</code></pre>
<p>?</p>
| c++ | [6] |
4,625,462 | 4,625,463 | iPhone, how to fire a button event in programmatically | <p>I want fire a button event(or maybe method) in code,the button was generate by iPhone SDK , I can not update it, so I add the action to the button, the code likes as follows:</p>
<pre><code>[theButton addTarget:self action:@selector(onButtonEvent:)
forControlEvents:UIControlEventAllTouchEvents];
-(void) onButtonEvent:(id)sender
{
AppTrace2(self, @"onButtonEvent", sender);
}
</code></pre>
<p>and when I tap the button, the app will execute a function that was produce by iPhone sdk, also the new method 'onButtonEvent' will be executed, and then I try to add some code as follows:</p>
<pre><code>[theButton sendActionsForControlEvents: UIControlEventTouchDown];
[theButton sendActionsForControlEvents: UIControlEventTouchDownRepeat];
[theButton sendActionsForControlEvents: UIControlEventTouchDragInside];
[theButton sendActionsForControlEvents: UIControlEventTouchDragOutside];
[theButton sendActionsForControlEvents: UIControlEventTouchDragEnter];
[theButton sendActionsForControlEvents: UIControlEventTouchDragExit];
[theButton sendActionsForControlEvents: UIControlEventTouchDragInside];
[theButton sendActionsForControlEvents: UIControlEventTouchDragOutside];
[theButton sendActionsForControlEvents: UIControlEventTouchUpInside];
[theButton sendActionsForControlEvents: UIControlEventTouchUpOutside];
[theButton sendActionsForControlEvents:UIControlEventTouchDown];
[theButton sendActionsForControlEvents:UIControlEventAllEvents];
</code></pre>
<p>but it does not call the original functions which was produced by iphone sdk, although the new method 'onButtonEvent' also was executed when above sendActionsForControlEvents executed ....
my goal is to invoke the original function ... sdk does not provide tip on this , so I have to simulate the tap event to invoke the function to executed .... </p>
<p>any one can give a tip on this problem ?</p>
<p>Thanks for your time!</p>
<p>Regards</p>
| iphone | [8] |
895,121 | 895,122 | Read entire XML file and store in memory java | <p>Here is what I am trying to do.</p>
<ol>
<li>Read entire XML file (I do not care the name of element or attribute,etc..).</li>
<li>Save the read XML file into memory.</li>
<li>Update some values of read xml file.</li>
<li>Write back to a XML file.</li>
</ol>
<p>I am trying to use XMLStreamReader to read a XML file, however all the examples I see so far, it looks like i have to provide element name. But, I do not care about element names, just want to read entier XML file into memory. And, I am not sure how datatype I should be storing as I am reading. I am thinking to store them into Document datatype.</p>
<p>Any suggestions on how to read entire XML file and store read contents in memeory?</p>
<p>Thanks.</p>
| java | [1] |
2,189,684 | 2,189,685 | Is static variables are Thread specific in java? | <p>Is static variables are Thread specific, means</p>
<pre><code>class A {
public static int i = 10;
}
Class B {
A.i = 20;
}
Class C {
A.i = 30;
}
Class D {
System.out.println(A.i);
}
</code></pre>
<p>Above classes I am calling from my web application, i.e. in first request I Call Class B, in second request I call Class B and in third request I have called Class D. Now what it will print 10/20/30?</p>
<p>Thank You.</p>
| java | [1] |
239,798 | 239,799 | removing value from the list | <p>I have a query I have a Map like this</p>
<pre><code> Map ppvValidatedinfo = new HashMap<String, List<String>>();
</code></pre>
<p>and it contains the value like this </p>
<pre><code> 1 22 23 24 25
</code></pre>
<p>so 1 is the key(patient id) and the values(scriptinfo) are 22,23,24,25</p>
<p>Now I am getting this value from back end as shown below</p>
<pre><code>String ScriptInfo = ((IItemPluRx)item).getScriptInfo();
</code></pre>
<blockquote>
<p>Now suppose the value of the script info is 24</p>
</blockquote>
<p>I want to know whether in my Map in the values section that is in list, does it contain 24 and if it contains then I want to remove it from list please advise how to achieve it</p>
| java | [1] |
4,682,900 | 4,682,901 | I'm having an issue with the following code and haven't been able to debug it | <p>Error says something about <code>eZip</code> not being recognized or something</p>
<pre><code>public class Address
{
private String name;
private String street;
private String city;
private String state;
private String zip;
public Address(String aName, String aStreet,
String aCity, String aState, String aZip)
{
name = aName;
street = aStreet;
city = aCity;
state = aState;
zip = eZip;
}
}
</code></pre>
| java | [1] |
4,272,402 | 4,272,403 | Is there any way to forbid the son class to call the public method of super class in java? | <p>Is there any way to forbid the son class to call the public method of super class in java?</p>
<p>For example</p>
<pre><code>public abstract class TObject{
abstract public void quark();
}
public class Animal extends TObject{
public void quark(){
System.out.println("this is the animal");
}
}
public class Dog extends Animal{
@overide
public void quark(){
System.out.println("this is the animal");
**super.quark();**
}
}
In this example, The Dog call the **super.quark();** in it's quark method.
</code></pre>
<p>But I don't want the Dog could call <strong>super.quark();</strong> and I also don't want to change the </p>
<p>modifier of quark method in Animal to private. Is there any way to prevent this in compile?</p>
<p>I have be confused couple of days, who can help me........ </p>
<p>The reason I do that is I met the similar problem in developing <strong>hudson scm plugin</strong>.I </p>
<p>created the class which extends the SubversionSCM(the offical class). I just wanted to </p>
<p>override the public method of super class, then call super's public method back like </p>
<p>example. but the compile gave error.I don't konw why, how could it do? Dose java have </p>
<p>something like *<em>reflect way</em>*s to prevent this?</p>
| java | [1] |
4,447,270 | 4,447,271 | PHP Search and remove numeric array value | <p>I have a php array with strings and I'd like to delete the keys that have a string containing only numbers.</p>
<p>How can I do that?</p>
| php | [2] |
2,484,676 | 2,484,677 | How to pass string variable to javascript function using php | <p>I have a problem about to passing a string parameter to java-script function using PHP. I have an anchor tag as View Live. Here $website contains web URL. On click of link I am opening a popup window. and function to open popup I have a function popup() in javascript. When I click on link I getting error of undefined variable. Can any one help me to solve this problem?</p>
<p>anchor tag is mention in question and javascript function is as follows...</p>
<pre><code>function RankPopup(website)
{
var left = (screen.width/5);
var top = (screen.height/5);
newwindow=window.open('abc.php?web='+website,'name',"height=300, width=850,toolbar=no,scrollbars=1,menubar=no,top="+top+",left="+left);
if (window.focus) {newwindow.focus()}
return false;
}
</code></pre>
<p>Thank You In advance</p>
| php | [2] |
4,847,235 | 4,847,236 | Overriding a parent method | <p>I have a class A
private method 1</p>
<p>class B extends A
private method 1 (Same name)</p>
<p>When I instantiate B and method 1 gets called from class A. I made them both protected and that solved it. Is there a way to keep both private and still get class B's method 1 to be called?</p>
| java | [1] |
5,725,929 | 5,725,930 | Equality of two structs in C# | <p>I look for an equality between two instances of this struct.</p>
<pre><code>public struct Serie<T>
{
T[] X;
double[] Y;
public Serie(T[] x, double[] y)
{
X = x;
Y = y;
}
public override bool Equals(object obj)
{
return obj is Serie<T> && this == (Serie<T>)obj;
}
public static bool operator ==(Serie<T> s1, Serie<T> s2)
{
return s1.X == s2.X && s1.Y == s2.Y;
}
public static bool operator !=(Serie<T> s1, Serie<T> s2)
{
return !(s1 == s2);
}
</code></pre>
<p>This doesn't work. What am I missing?</p>
<pre><code> double[] xa = { 2, 3 };
double[] ya = { 1, 2 };
double[] xb = { 2, 3 };
double[] yb = { 1, 2 };
Serie<double> A = new Serie<double>(xa, ya);
Serie<double> B = new Serie<double>(xb, yb);
Assert.AreEqual(A, B);
</code></pre>
| c# | [0] |
3,797,811 | 3,797,812 | Will Titanium 1.7.2 work properly on XCode 4.0.2? | <p>The Titanium module works great with Titanium 1.5.1 and XCode 3, but the module does not properly work with Titanium 1.7.1 and XCode 4.0.2. I got the following error:</p>
<blockquote>
<p>Error: Traceback (most recent call last):File "/Library/Application Support/Titanium/mobilesdk/osx/1.7.0/iphone/builder.py", line 1139, in main execute_xcode("iphonesimulator%s" % link_version,["GCC_PREPROCESSOR_DEFINITIONS=<strong>LOG__ID</strong>=%s DEPLOYTYPE=development TI_DEVELOPMENT=1 DEBUG=1 TI_VERSION=%s %s" % (log_id,sdk_version,debugstr)],False)File "/Library/Application Support/Titanium/mobilesdk/osx/1.7.0/iphone/builder.py", line 1057, in execute_xcode output = run.run(args,False,False,o)File "/Library/Application Support/Titanium/mobilesdk/osx/1.7.0/iphone/run.py" line 39, in ru sys.exit(rc)</p>
</blockquote>
<p>Why is this type of error occurring?</p>
| iphone | [8] |
997,996 | 997,997 | Does Minecraft use any open source Java libraries apart from the JDK? | <p>I'm interested in writing games in Java and wondered if Minecraft is written purely using the standard JDK or whether it uses open source (or commercial for that matter) libraries.</p>
| java | [1] |
4,006,015 | 4,006,016 | Can you get more information about the online file? | <p>I have a online file: <a href="http://dl_dir.qq.com/qqfile/tm/TM2009Beta_chs.exe" rel="nofollow">http://dl_dir.qq.com/qqfile/tm/TM2009Beta_chs.exe</a> ,please donot download it, i want to determine the software version whether is changed, so i want more information about it. for example, using python,i can get this:</p>
<pre><code>import urllib2,urllib
req = urllib2.Request('http://dl_dir.qq.com/qqfile/tm/TM2009Beta_chs.exe')
response = urllib2.urlopen(req)
print response.info()
print response.geturl()
Content-Length: 16868680
Server: qqdlsrv(1.84 for linux)
Connection: close
Content-Disposition: attachment; filename=TM2009Beta_chs.exe
Accept-Ranges: bytes
Content-Type: application/octet-stream
http://dl_dir.qq.com/qqfile/tm/TM2009Beta_chs.exe
</code></pre>
<p>Can you get more imformation to let me determine the software version is changed?</p>
| python | [7] |
283,478 | 283,479 | Determine if Python is running as 32 or 64 bit? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1405913/how-do-i-determine-if-my-python-shell-is-executing-in-32bit-or-64bit-mode">How do I determine if my python shell is executing in 32bit or 64bit mode?</a> </p>
</blockquote>
<p>just a q and a thing i thought i'd add here, as i cannot find this easily.</p>
<p>Sometimes you need to know what version your python is bit-wise!</p>
<p>It is easy to check your python version:</p>
<pre><code>python -V
</code></pre>
<p>(run the above from the command prompt/bash terminal)</p>
| python | [7] |
2,294,548 | 2,294,549 | Facing Facebook place checkin issue when adding my own places | <p>I have added my own places in places class for check-in but getting this error</p>
<p><code>**API response: {"error": { "message":"(#) Requires a valid Place Page ID:,"type: "OAuthException", "code:100}}**</code> </p>
<p>how do I get the <code>PageID</code> of my own places?.I am unable to find any solution .I have studied the Facebook document but unable to understand what exactly I need to do.even I have tried </p>
<pre><code>this code in FQL Query class
**SELECT page_id,latitude,longitude FROM place WHERE distance(latitude, longitude, "76.8036676", "30.7323298")<250**
</code></pre>
<p>but not getting any solution.</p>
<p>Any help will be highly appreciated.</p>
| android | [4] |
2,814,636 | 2,814,637 | how to select a certain clone of lists using jquery? | <p>How to select a certain clone of list using jquery?</p>
<pre><code> <ul id=testList>
<li><input type=checkbox" /><p> Test A </p></li>
<li><input type=checkbox" /><p> Test B </p></li>
<li><input type=checkbox" /><p> Test C </p></li>
<li><input type=checkbox" /><p> Test D </p></li>
<li><input type=checkbox" /><p> Test E </p></li>
</ul>
var $cloneList = $("#testList").clone();
$cloneList.find("li input:checked")each(function()
{
alert($(this.outerHTML);
});
</code></pre>
<p>The output I'm trying to accomplish with this jquery code above is listed below by only selecting the checkboxs that has been selected and remove input tags:</p>
<pre><code> <li><p> Test E </p></li>
</code></pre>
| jquery | [5] |
1,840,707 | 1,840,708 | Finding all checkboxes are checked in jQuery | <p>I have a collection of checkboxes</p>
<pre><code> <input id="1" class="paid" type="checkbox" />
<input id="2" class="paid" type="checkbox" />
<input id="3" class="paid" type="checkbox" />
<input id="4" class="paid" type="checkbox" />
</code></pre>
<p>I would like to write some jQuery to check if all checkboxes are checked then perform an action but how?</p>
| jquery | [5] |
2,132,330 | 2,132,331 | Hot to use the second parameter of lastIndexOf() method in javascript string object? | <pre><code>"This apple is my apple".lastIndexOf("apple"); // returns value of 17
"This apple is my apple".lastIndexOf("apple",12); // returns value of 5
"This apple is my apple".lastIndexOf("apple", 3); // returns value of -1, not found
</code></pre>
<p>Hi guys!</p>
<p>I understand the first two examples,but why the third doesn't return 5?</p>
<p>Like indexOf, lastIndexOf also takes an optional second parameter, which is an index
value of where to start the search, counted from the right</p>
<p>so the string 'apple' should match the position 5. But I still got the result of -1?</p>
<p>what's the problem?</p>
| javascript | [3] |
2,006,156 | 2,006,157 | Problem with multiple image selection in android | <p>I have a problem in selecting image from image gallery. In my view there are two Buttons and two EditTexts. On clicking each button I want to choose and image from gallery and the path of the image needs to copied into the respective EditText. In my code image selection is working but the path is entered into only one EditText for both buttons. Please help me.</p>
<p>My Code:</p>
<pre><code>private String imageType;
public void browsePositionImage(View button)
{
imageType = "POSITION";
startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI), SELECT_IMAGE );
}
public void browseObjectImage(View button)
{
imageType = "OBJECT";
startActivityForResult(new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI), SELECT_IMAGE );
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SELECT_IMAGE)
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = data.getData();
if(imageType == "POSITION")
{
final EditText txtPImage = (EditText) findViewById(R.id.EditTextPositionImage);
txtPImage.setText(getRealPathFromURI(selectedImage));
}
else
{
final EditText txtPImage = (EditText) findViewById(R.id.EditTextObjectImage);
txtPImage.setText(getRealPathFromURI(selectedImage));
}
}
}
</code></pre>
| android | [4] |
3,925,432 | 3,925,433 | Thinning or skeletonization with java | <p>How to thin or skeletonization the image with java?
I mean I want to get the skeleton of the character image, and this need to implement with java for the OCR process. Thanks for your interest and give me some suggestion and direction.
Thanks in advance</p>
| java | [1] |
5,120,454 | 5,120,455 | what is the difference between having exit() and having not in a header function? | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/3553698/php-should-i-call-exit-after-calling-location-header">php - Should I call exit() after calling Location: header?</a> </p>
</blockquote>
<p>I dont know how to title this question but here it goes.</p>
<p>what is the difference between the two code snippets below:</p>
<p>script1 - without <code>exit()</code>:</p>
<pre><code>if($var = true){
header('Location: anotherpage.php');
}
</code></pre>
<p>script2 - with <code>exit()</code>:</p>
<pre><code>if($var = true){
header('Location: anotherpage.php');
exit();
}
</code></pre>
<p>from what I understand, <code>header()</code> exits the current page and jumps to another page if the condition is true therefore having <code>exit()</code> after <code>header()</code> is pointless - am I right?</p>
| php | [2] |
3,877,503 | 3,877,504 | limit one area and browse other people are using the same app | <p>When my app is triggered, it takes the current position of the user through the GPS (this function already implemented).</p>
<p>My question is: I want to know for example if I have users who are using my app in a given radius (1km for example). Is it possible?</p>
| android | [4] |
4,307,369 | 4,307,370 | Custom cursor image with javascript | <p>I need to change my mouse cursor to a custom image.</p>
<p>If possible I would like to do it on a spritesheet.
I can't do it from the css because I'm using it in a game. I already know how to decide when etc.</p>
<p>What I need to know is how do I change the cursor to an image, and deciding the image position and size?
Is there any easy solution similar to the drawImage's image position?</p>
| javascript | [3] |
3,177,935 | 3,177,936 | How to getline() from specific line in a file? C++ | <p>I've looked around a bit and have found no definitive answer on how to read a specific line of text from a file in C++. I have a text file with over 100,000 English words, each on its own line. I can't use arrays because they obviously won't hold that much data, and vectors take too long to store every word. How can I achieve this?</p>
<p>P.S. I found no duplicates of this question regarding C++</p>
<pre><code>while (getline(words_file, word))
{
my_vect.push_back(word);
}
</code></pre>
<p>EDIT:</p>
<p>A commenter below has helped me to realize that the only reason loading a file to a vector was taking so long was because I was debugging. Plainly running the .exe loads the file nearly instantaneously. Thanks for everyones help.</p>
| c++ | [6] |
5,617,895 | 5,617,896 | javascript- want to set li innerHTML of ul | <p>I'm writing a javascript function where I get a ul object from my HTML and want to set the text of one of the li elements in the ul. I'm doing:</p>
<pre><code>list = document.getElementById('list_name');
</code></pre>
<p>Then I want to access the ith li element of list using a loop.
I have:</p>
<pre><code>for (i = 0; i < 5; i++) {
list[i].innerHTML = "<a>text</a>";
}
</code></pre>
<p>but this is not working. What is the proper way to do it?</p>
| javascript | [3] |
4,993,103 | 4,993,104 | Convert multiple DataTables to columns in a single datagridview | <p>I have three DataTables in C# called MIT, Oracle and Difference. Could you please let me know how to add these three tables to a gridview as seperate columns? I know how to bind a DataTable to a gridview as given below. But i need the same to be done for several DataTables.Please help</p>
<pre><code>dataGridView1.DataSource = MIT;
</code></pre>
<p><a href="http://i.stack.imgur.com/VkxgP.png" rel="nofollow">Here</a>'s an image of the GridView.</p>
| c# | [0] |
4,098,366 | 4,098,367 | PHP "backspace" character during output possible? | <p>I have a feeling the answer is "it's not possible," but thought I'd ask to satisfy my curiosity.</p>
<p>I have some code that's echoed where the \n is unavoidable:</p>
<pre><code>echo "Hello \n";
echo "World!";
</code></pre>
<p>I'd like the line to simply read (in the code output):</p>
<blockquote>
<p>Hello World!</p>
</blockquote>
<p>... thus removing the \n.</p>
<p>So I was wondering if it's possible to execute a "backspace" character during PHP's output?</p>
<p>Something simple like <code>str_replace( "\n", 'backspace-character', $str );</code></p>
| php | [2] |
1,965,200 | 1,965,201 | Class def not found in new connected application | <p>Using eclipse and the google plugin I have created a connected app. Hello world.</p>
<p>When i run the app, with no modifications, i get a <code>class def not found error</code> for <code>MyRequestFactory</code>.</p>
<p>Everything compiles fine but when I click the "say hello button" it crashes with the above error.</p>
| android | [4] |
5,530,170 | 5,530,171 | Difference between $(Parent Child) and $(Parent).find(Child) (in jQuery) | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/6230266/jquery-single-selector-vs-find">jQuery single selector vs .find()</a> </p>
</blockquote>
<p>Is there any difference between $(Parent Child) and $(Parent).find(Child) in jQuery?</p>
<p>You may have multiple children like:</p>
<p><code>$("div").find("span")</code> which will return all the children spans. But isn't it the same with <code>$("div span")</code>?</p>
| jquery | [5] |
4,113,586 | 4,113,587 | 32 bit long vs 64 bit long | <p>I am working on project (c++ integration with Python) which has migrated to 32 bit machine to 64 bit machine. In Python, C long is mapped with Python Integer.
SO I can not change in Python Interface(client interface) and always gets overflow error from python client. it was working fine in 32 bit machine</p>
<p>So I have following solution</p>
<p>1)convert all long to int in 64 bit machine.</p>
<p>2)Declare 32 bit long in 64 bit machine.</p>
<p>Do we have any general solution/header file which give me option to declare 32 bit
datatype always So I can handle this issue in more general way.</p>
<p>I know it may be small issue but I am not able to find general solution.</p>
| c++ | [6] |
1,787,313 | 1,787,314 | How I can read an xml file with limited memory? | <pre><code> var q = from n in XElement.Load(Application.StartupPath + "..\\..\\..\\2.xml").Elements()
select n;
foreach (var q0 in q)
{
string str = q0.ToString();
}
</code></pre>
<p>the problem is my xml file is so big so how I can manage this code to load it gradually not completely. now I traced by c# it loads all file completely in "q" and then loads some big nodes in "str". I have limited memory and I need loading from file a little by little. I dont know how many nodes I have but I know general structure of file.</p>
| c# | [0] |
2,198,741 | 2,198,742 | Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError on object initialization | <p>I have an instance variable, like so:</p>
<pre><code>PathFinder finder;
</code></pre>
<p>(this is using Kevin Glass' A* tutorial, so the PathFinder class is in the same file, link here: <a href="http://cokeandcode.com/index.html?page=tutorials/tilemap2" rel="nofollow">http://cokeandcode.com/index.html?page=tutorials/tilemap2</a>)</p>
<p>Anyways, when I do</p>
<pre><code>finder = new AStarPathFinder(currentMap, 1000, true);
</code></pre>
<p>I get a Exception in thread ""AWT-EventQueue-0" java.lang.ExceptionInInitializerError".</p>
<p>currentMap is an instance of my Map class, and yes it is initialized. 1000 represents the maximum tile distance that will be searched, and the boolean represents diagonal movement true/false. Oh well I'll just throw the constructor at you:</p>
<pre><code>public AStarPathFinder(TileBasedMap map, int maxSearchDistance, boolean allowDiagMovement) {
this(map, maxSearchDistance, allowDiagMovement, new ClosestHeuristic());
}
</code></pre>
<p>I know it has something to do with static initializers, but I'm not too sure what else. Oh, and I tried to initialize an instance of the same AStarPathFinder class in another class, and I got the same result.</p>
| java | [1] |
1,997,636 | 1,997,637 | Require override of parent virtual function | <p>I'm working on a serialization system, and all my serializable classes implement</p>
<pre><code>virtual void serialize(Buffer buffer);
</code></pre>
<p>When a pointer is going to be serialized, I need to call the serialize() function of the class itself, and not that of any of its parents, even if the pointer is a parent type, and I've been running into a lot of bugs because I don't notice that a child class doesn't even have serialize() at all so the parent serialize() class is just being called</p>
<p>ie</p>
<pre><code>class A
{
virtual void serialize();
}
class B:public A
{
virtual void serialize();
}
class C:public B
{
virtual void serialize();
}
void doSerialization(A *a)
{
a->serialize();
}
C *c=new C();
doSerialization(c);
</code></pre>
<p>right now, if C didn't have a serialize function, B::serialize() would be silently called. I'd prefer an error message, or anything else that will at least point it out to me. Is there any keyword in C++ (even '11) that would do this?</p>
| c++ | [6] |
620,178 | 620,179 | How can I limit the number of instances of a class? | <p>As an exercise, I wish to make a class that can't have more than N instances. How can I do that?</p>
<p>Suppose, for example, you want to limit number of connection to database so that no more than N users can connect at the same time. I understand how to make a singleton:</p>
<pre><code>class Singleton {
private:
Singleton(const Singleton&);
Singleton();
public :
static Singleton Instance() {
static Singleton p;
if(!p) {
p = new Singleton;
}
};
</code></pre>
<p>But if there N > 1 objects, I need help.</p>
| c++ | [6] |
1,101,313 | 1,101,314 | what is meant by that in a servlet (private static final long serialVersionUID = 1L)? | <p>Can any one tell me that what is the meaning of</p>
<pre><code>private static final long serialVersionUID = 1L
</code></pre>
| java | [1] |
769,179 | 769,180 | Clear val on toggle with boolean | <p>I have a hidden div with form elements in it that I toggle on a radio select option (Think yes/no as the options)</p>
<p>If they select yes, display the div and require the fields, else hide div and clear the fields (if they have entered any value).</p>
<p>I can do all of this except clear the value with passing a boolean flag to the toggle function</p>
<p>Example:</p>
<pre><code>$("[name=nameOfElement]").change(function() {
var show = $('input[name=nameOfElement]:checked').val() == "true";
$('#hiddenForm').toggle(show);
$('#hiddenInput').toggleClass('required',show);
});
</code></pre>
<p>Is there something that clears the value on passed boolean option?</p>
<pre><code>$("[name=nameOfElement]").change(function() {
var show = $('input[name=nameOfElement]:checked').val() == "true";
$('#hiddenForm').toggle(show);
$('#hiddenInput').toggleClass('required',show).valClear(show);
});
</code></pre>
<p>UPDATE: Not looking for a plugin just wanted to know if I could do this without the if/else condition</p>
| jquery | [5] |
2,345,770 | 2,345,771 | How can I store an int array into a number array? | <p>Integer extends Number so in that sense Number becomes the superclass of int. I want to store an int array into a Number array..
I have the following code.However, it seems it is not allowed in java.</p>
<pre><code> int[] b = {1,2};
Number[] a = b;
</code></pre>
<p>Why java does not allow me to store an int array in number array and how do I store this out ?</p>
| java | [1] |
5,723,794 | 5,723,795 | how to fix this, JavaScript Error : document.forms. is null not an Object | <p>in my jsp page, I am getting script error. <strong>error message is : document.forms[0] is null not an object.</strong>when i click to SignOut . sign Out works fine and it is redirect to default.jsp. but my default.jsp doesn't show anything just a blank page. I checked view Source of default.jsp page.The whole page is not loaded. it has loaded only till <strong>1st line of body tag.</strong> Below is the code for <strong>default.jsp .</strong></p>
<pre><code> <! doctype html>
<html language="en">
<%@ page language="java" contentType="text/html" %>
<%@ session ="false" %>
<head>
<script type="text/javascript">
function closeWarning(){
document.forms[0].reset();
}
</script>
</head>
<body onLoad="closeWarning();" class="page-design">// page loaded till here
<jsp:include flush="true" page="/myCart/header.jsp"/>
//---other component of body----
</body>
</code></pre>
<p>please suggest something how to resolve this. Thanks .</p>
| javascript | [3] |
771,055 | 771,056 | Identifying the id of current visible div | <p>I am working with 3 divs at the moment - on pageLoad the default is viewed but when the user clicks on a button the div is hidden and the selected div appears in its place. </p>
<p>How would I write an if statement to identify the div currently selected by the user? For example:</p>
<pre><code>if selected_div is 'dpara' then ....
else if selected_div is dtab then ....
</code></pre>
<p>Thanks in advance!</p>
<pre><code> <script type='text/javascript'>
function arrange(div_id) {
// First make all the divs hidden...
divs = document.getElementsByTagName('div');
for( var i = 0; i < divs.length; i++ ) {
divs[i].style.display = 'none';
}
// Now make the one we want to be visible visible...
document.getElementById(div_id).style.display = 'block';
}
</script>
<form>
<input type='button' value='dpara' onclick='arrange(this.value);' />
<input type='button' value='dtab' onclick='arrange(this.value);' />
<input type='button' value='ddl' onclick='arrange(this.value);' />
</form>
<div id='dpara'>
</div>
<div id='dtab' style='display: none'>
</div>
<div id='ddl' style='display: none'>
</div>
</code></pre>
| javascript | [3] |
1,506,532 | 1,506,533 | Python: catch exceptions inside a class | <p>Is it possible to write an exception handler to catch the run-time errors generated by ALL the methods in class? I can do it by surrounding each one with try/except:</p>
<pre class="lang-py prettyprint-override"><code>class MyError(Exception):
def __init__(self, obj, method):
print 'Debug info:', repr(obj.data), method.__name__
raise
class MyClass:
def __init__(self, data):
self.data = data
def f1(self):
try:
all method code here, maybe failing at run time
except:
raise MyError(self, self.f1)
</code></pre>
<p>I wonder if is there a more general way to achieve the same - for any error raising anywhere in the class. I would like to be able to access the class data to print some debug info.
Also, how do I get the failing method name (f1 in the example)?</p>
<p><strong>Update</strong>: thanks to all for the insighful answers, the decorator idea looks like the way to go.
About the risk of trapping ALL the exceptions: a <code>raise</code> statement in the <code>except</code> branch should re-raise the exception without losing any information, doesn't it? That's why I put it in MyError also...</p>
| python | [7] |
5,173,079 | 5,173,080 | create label on fly and display error message | <p>how to create label on fly and assign some error message to that label using jquery. I want display this message on the top. How to achieve this using jquery?</p>
| jquery | [5] |
2,159,643 | 2,159,644 | Strange problem with NSMutableArray - Possibly some memory corruption | <p>I am trying to update data in a table view using a NSMutableArray. Quite simple :(</p>
<p>What is happening is that I get my data from a NSURLConnection Callback, which I parse and store it in an array and call reload data on the table view. The problem is that when cellForRowAtIndexPath is called back by the framework. The array still shows the correct count of the elements but all string objects I had stored earlier are shown as invalid.</p>
<p>Any pointers</p>
| iphone | [8] |
273,185 | 273,186 | Alias function in javascript | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8773579/if-javascript-has-first-class-functions-why-doesnt-this-work">If Javascript has first-class functions, why doesn’t this work?</a> </p>
</blockquote>
<p>When I try to make an alias function for <code>document.getElementById</code> as below:</p>
<pre><code>f = document.getElementById;
</code></pre>
<p>But, when I try to call:</p>
<pre><code>var e_fullname = f(“fullname”);
</code></pre>
<p>It was rised an error: <code>Could not convert JavaScript argument</code></p>
<p>And below is OK:</p>
<pre><code>var e_fullname = f.call(document, “funname”);
</code></pre>
<p>Can you tell me why?</p>
| javascript | [3] |
1,863,164 | 1,863,165 | how to display string in mobile number format | <p>i have a string of mobile number eg:919999999999.</p>
<p>i need to display this number in this format (+91)999-999-9999;</p>
<p>here 91 is country code.</p>
<p>how can i done this,can any one please post some code.</p>
<p>Thank u in advance. </p>
| iphone | [8] |
3,266,923 | 3,266,924 | Please explain why and how +new Date(); works as 'workaround' for Date.now() in IE8 or below | <p>(I'm reading the book "<em>Professional JavaScript for Web Developers</em>" to give a context about this question, specifically Chapter 5 on Reference Types) </p>
<p>I'm wondering why and how
<code>var start = +new Date();</code> works to get the current millisecond representation of now as a work-around to browsers (e.g.: IE8) that don't support ECMAScript 5's <code>Date.now()</code>?</p>
<p>What does the <code>+</code> operator do here compared to just plain old <code>new Date()</code> which also gets the current date and time?</p>
| javascript | [3] |
856,346 | 856,347 | How can I use jQuery to move an <option> to be the second element? | <p>How can I use jQuery to move a specific <code><option></code> to be the second option?</p>
<pre><code><select class="comestibles">
<option>apple</option>
<option>banana</option>
<option>cantaloupe</option>
<option>date</option>
<option>eggplant</option>
<option>fig</option>
</select>
<select class="comestibles">
<option>apple</option>
<option>banana</option>
<option>cantaloupe</option>
<option>date</option>
<option>eggplant</option>
<option>fig</option>
</select>
</code></pre>
<p>This code will make <code>eggplant</code> the first option... close but no cigar.</p>
<pre><code>jQuery('select.comestibles').each(function(){
$('option[value=eggplant]',this).prependTo(this);
});
</code></pre>
| jquery | [5] |
1,628,610 | 1,628,611 | What is one-level deep copy in JavaScript? | <p>What is one-level deep copy in JavaScript?</p>
<p>Thank you!</p>
| javascript | [3] |
66,618 | 66,619 | How to set gujarati for textview in the android application? | <p>I want to make a application in which i needs to show the textview in gujarati language.</p>
<p>I tried with </p>
<pre><code>Typeface tf = Typeface.createFromAsset(getAssets(), "G-SARAL1.TTF");
text.setTypeFace(tf);
</code></pre>
<p>but this is not working, I set the gujarati text in string.xml file and then i set that string in the textview, but when i run the application, it display square boxs instead of gujarati character,</p>
<p>can anyone help me , how can i implement this task.</p>
| android | [4] |
473,853 | 473,854 | How to use less code for this situation | <p>Currently, I have code like this:</p>
<pre><code> static void Main()
{
int whichClass = 0;
if (whichClass == 0)
{
//repeat code
TestAbstract clTest = new ClassA();
clTest.MainFunc();
}
else if (whichClass == 1)
{
//repeat code
TestAbstract clTest = new ClassB();
clTest.MainFunc();
}
else if (whichClass == 10)
{
//repeat code
TestAbstract clTest = new ClassX();
clTest.MainFunc();
}
}
</code></pre>
<p>As you see, I have to write code 3 times for initial and call function at 3 different classes. </p>
<p>What I want is we just call 1 time with dynamic class. How can it is possible?</p>
| c# | [0] |
2,371,051 | 2,371,052 | javascript split | <pre><code><script language="javascript">
function frompost()
{
var string=$('#indexsearch').val();
var url=string.split('=');
if(url==""){
var url=string.split('video/');
}
var finalurl='http://watchvideos.tv/watch/'+url[1];
window.location = finalurl;
//$('#srchFrm').attr('action',finalurl);
//document.srchFrm.submit();
}
</script>
</code></pre>
<p>I have a problem with this script - it's Ok as long as indexsearch field contains <code>=</code> and fails when it's supposed to work as well - with <code>video/</code> in the field</p>
| javascript | [3] |
1,955,420 | 1,955,421 | PHP - call function in object with set_error_handler() | <p>I am trying to use this in my page class. I only just started using objects in PHP so I'm still a little clueless (but learning as much as I can). This is in my <code>page()</code> function (so called when there is a new instance of page)</p>
<pre><code>set_error_handler('$this->appendError');
</code></pre>
<p>This is causing an error</p>
<blockquote>
<p>Warning: set_error_handler() expects the argument (appendError) to be a valid callback</p>
</blockquote>
<p>Now how do I set a class internal function whilst passing the function as a string. Is this not possible? Should I use a normal function which then calls the class function and sends through all arguments? This sounds a little cumbersome to me.</p>
<p>Or have I missed the problem? I've tried making my appendError return a string, and echo.. but it still isn't playing nice.</p>
<p>Any help would be greatly appreciated.</p>
<p>Thank you!!</p>
| php | [2] |
1,817,279 | 1,817,280 | specific number formater to a phone number | <p>I want to display the the number in the following format </p>
<p>and the format is "123-456-7890"</p>
<p>I am using </p>
<pre><code>NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterNoStyle];
[formatter setPositiveFormat:@"###-###-####"];
[formatter setLenient:YES];
amountField.text =[formatter stringFromNumber:[NSNumber numberWithDouble:[rxAlertResponse.rxPhoneNo doubleValue]]];
NSLog(@"%@",amountField.text);
</code></pre>
<p>i am using the above code to do that but the code is not reflecting ..... and the out put appear as 1234567890 only can any body help how to do that.</p>
| iphone | [8] |
1,496,557 | 1,496,558 | Scenario - How to improve user experience using preload of pages and delayed save of web pages in ASP.NET | <p>I have a ASP.NET website and say it has 2 pages. I am displaying these 2 pages as 2 tabs. Both pages have some input fields like check boxes, radio buttons, dropdowns.</p>
<p>When I move from tab-1 to tab-2, I have to perform the following operations.</p>
<ol>
<li><p>I need to save the data entered on tab-1. This is currently handled in tab-1's PageLoad when user clicks tab-2 on the screen. I have made a DataSave() method, which is called in the PageLoad for IsPagePostBack equals true.</p></li>
<li><p>Once the DataSave is completed, I exit from tab-1 page and call the PageLoad of tab-2.</p></li>
<li><p>In tab-2, I created a DataLoad() method, which brings all the data for controls on tab-2.</p></li>
<li><p>Now when I enter all the data on tab-2 and click tab-1, the same steps 1 to step 3 are completed for tab-2 and tab-1.</p></li>
</ol>
<p>This process takes a lot of time. The user is shown saving of first tab and then loading of second tab everytime.</p>
<p>Is there a way, that I can load the controls of second tab (or as many secondary tabs I have) in the background when the user is working on tab-1. And when the user clicks the second tab, he is displayed the second tab instantly while the tab-1 data is saved in the background.</p>
<p>I hope I was able to explain my problem.</p>
| asp.net | [9] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.