qid int64 4 19.1M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
389,779 | <p>Let's consider a C++ class. At the beginning of the execution I want to read a set of values from an XML file and assign them to 7 of the data members of this class. Those values do not change during the whole execution and they have to be shared by all the objects / instances of the class in question. Are static data members the most elegant way to achieve this behavior? (Of course, I do not consider global variables)</p>
| [
{
"answer_id": 390355,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 1,
"selected": false,
"text": "class xml_stuff {\npublic:\n xml_stuff() {\n // 1. touch all members once\n // => 2. they ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48716/"
] |
389,788 | <p>so i've got this, roughly:</p>
<pre><code><div id="A">
<ul>
<li id="B">foo</li>
</ul>
</div>
<div id="C">
...
</div>
</code></pre>
<p>These are positioned so that B and C overlap.</p>
<p>A has a <code>z-index</code> of <code>90</code>, B has a <code>z-index</code> of <code>92</code>, and C has a <code>z-index</code> of <code>91</code>. But C shows up in front of B. What am i doing wrong? (Let me know if more detail is necessary.) </p>
| [
{
"answer_id": 389815,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 5,
"selected": true,
"text": "z-index"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/389788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56817/"
] |
389,797 | <p>Visual Studio compiles this code fine, but gcc only lets it compile without the Template operator. With the Template operator it gives the following errors:</p>
<p>Line 29: error: expected `;' before "itrValue"</p>
<pre><code>class Test
{
public:
Test& operator<<(const char* s) {return *this;} // not implemented yet
Test& operator<<(size_t s) {return *this;} // not implemented yet
Test& operator<< (const std::list<const char*>& strList)
{
*this << "count=" << strList.size() << "(";
for (std::list<const char*>::const_iterator itrValue = strList.begin();
itrValue != strList.end(); ++itrValue)
{
*this << " " << *itrValue;
}
*this << ")";
return *this;
}
template <class T>
Test& operator<< (const std::list<T>& listTemplate)
{
*this << "count=" << listTemplate.size() << "(";
// this is line 28, the next line is the offending line
for (std::list<T>::const_iterator itrValue = listTemplate.begin();
itrValue != listTemplate.end(); ++itrValue)
{
*this << " " << *itrValue;
}
*this << ")";
return *this;
}
};
</code></pre>
| [
{
"answer_id": 389811,
"author": "Pieter",
"author_id": 5822,
"author_profile": "https://Stackoverflow.com/users/5822",
"pm_score": 4,
"selected": false,
"text": "typename std::list<T>::const_iterator\n"
},
{
"answer_id": 390054,
"author": "David Rodríguez - dribeas",
"au... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
389,803 | <p>Is there a setting in SQL Server to have null = null evaluate to true?</p>
| [
{
"answer_id": 389810,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "SET ANSI_NULLS OFF\n 10 = NULL False\nNULL = NULL True\n 10 <> NULL True\nNULL <> NULL False\n SET ANSI_... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389803",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5232/"
] |
389,813 | <p>I need to sort some objects according to their contents (in fact according to one of their properties, which is NOT the key and may be duplicated between different objects).</p>
<p>.NET provides two classes (<a href="https://msdn.microsoft.com/en-us/library/f7fta44c(v=vs.110).aspx" rel="noreferrer">SortedDictionary</a> and <a href="https://msdn.microsoft.com/en-us/library/ms132319(v=vs.110).aspx" rel="noreferrer">SortedList</a>), and both are implemented using a binary tree. The only differences between them are</p>
<ul>
<li>SortedList uses less memory than SortedDictionary. </li>
<li>SortedDictionary has faster insertion and removal operations for unsorted data, O(log n) as opposed to O(n) for SortedList. </li>
<li>If the list is populated all at once from sorted data, SortedList is faster than SortedDictionary.</li>
</ul>
<p>I could achieve what I want using a <a href="https://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.110).aspx" rel="noreferrer">List,</a> and then using its <a href="https://msdn.microsoft.com/en-us/library/234b841s(v=vs.110).aspx" rel="noreferrer">Sort()</a> method with a custom implementation of <a href="https://msdn.microsoft.com/en-us/library/8ehhxeaf(v=vs.110).aspx" rel="noreferrer">IComparer</a>, but it would not be time-efficient as I would sort the whole List each time I want to insert a new object, whereas a good SortedList would just insert the item at the right position.</p>
<p>What I need is a SortedList class with a RefreshPosition(int index) to move only the changed (or inserted) object rather than resorting the whole list each time an object inside changes.</p>
<p>Am I missing something obvious ?</p>
| [
{
"answer_id": 389872,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 0,
"selected": false,
"text": "Key class UpdateableSortedList<K,V> {\n private SortedList<K,V> list = new SortedList<K,V>();\n public delegate K ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47341/"
] |
389,821 | <p>I'm still having a hard time not wanting to use Tables to do my Details View Layout in HTML. I want to run some samples by people and get some opinions.</p>
<p>What you would prefer to see in the html for a Details View? Which one has the least hurddles cross browser? Which is the most compliant? Which one looks better if a I have a static width label column that is right aligned?</p>
<p>By Details view i mean something similar to the following image.
<a href="https://i.stack.imgur.com/cWaVk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cWaVk.png" alt="alt text"></a>
</p>
<p>Table</p>
<pre><code><table>
<tr>
<td><label /></td>
<td><input type="textbox" /></td>
</tr>
<tr>
<td><label /></td>
<td><input type="textbox" /></td>
</tr>
</table>
</code></pre>
<p>Fieldset</p>
<pre><code><fieldset>
<label /><input type="textbox" /><br />
<label /><input type="textbox" /><br />
</fieldset>
</code></pre>
<p>Divs</p>
<pre><code><div class="clearFix">
<div class="label"><label /></div>
<div class="control"><input type="textbox" /></div>
</div>
<div class="clearFix">
<div class="label"><label /></div>
<div class="control"><input type="textbox" /></div>
</div>
</code></pre>
<p>List</p>
<pre><code><ul>
<li><label /><input type="textbox" /></li>
<li><label /><input type="textbox" /></li>
</ul>
</code></pre>
| [
{
"answer_id": 389947,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 3,
"selected": true,
"text": "<fieldset>\n <label for=\"name\">XXX <input type=\"text\" id=\"name\"/></label>\n <label for=\"email\">XXX <input type=\"t... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389821",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37881/"
] |
389,825 | <p>I am trying to recreate something similar to the popup keyboard used in safari.</p>
<p><img src="https://dl.getdropbox.com/u/22784/keyboardToolbar.png" alt="alt text"></p>
<p>I am able to visually reproduce it by placeing a toolbar over my view and the appropriate buttons, however i cant figure out any way to dismiss the keyboard once the user has touched the done button.</p>
| [
{
"answer_id": 389830,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 6,
"selected": true,
"text": "[viewReceivingKeys resignFirstResponder];\n viewReceivingKeys"
},
{
"answer_id": 389834,
"author": "frankodwy... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389825",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8918/"
] |
389,827 | <p>Is there a way to (ab)use the <strong>C</strong> preprocessor to emulate namespaces in <strong>C</strong>?</p>
<p>I'm thinking something along these lines:</p>
<pre><code>#define NAMESPACE name_of_ns
some_function() {
some_other_function();
}
</code></pre>
<p>This would get translated to:</p>
<pre><code>name_of_ns_some_function() {
name_of_ns_some_other_function();
}
</code></pre>
| [
{
"answer_id": 389838,
"author": "mmx",
"author_id": 33708,
"author_profile": "https://Stackoverflow.com/users/33708",
"pm_score": 4,
"selected": false,
"text": "#define FUN_NAME(namespace,name) namespace ## name\n void FUN_NAME(MyNamespace,HelloWorld)()\n"
},
{
"answer_id": 3899... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46450/"
] |
389,832 | <p>I would like to know if we can reuse the same Statement object for executing more than one query. Or, should we create a new statement for different queries.</p>
<p>For example,</p>
<pre><code>Connection con = getDBConnection();
Statement st1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
int i = st1.executeUpdate("update tbl_domu set domU_status=1 where domU_id=" + dom_U_id);
Statement st2 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
int j = st2.executeUpdate("insert into tbl_domU_action_history values('" + dom_U_name + "', 1, '" + date + "')");
</code></pre>
<p>In the above case, is there any harm in using the same statement st1 for both the executeUpdate() queries? Can I use the same Statement object st1 for another executeQuery()?</p>
| [
{
"answer_id": 389839,
"author": "Tom Hawtin - tackline",
"author_id": 4725,
"author_profile": "https://Stackoverflow.com/users/4725",
"pm_score": 4,
"selected": false,
"text": "PreparedStatement"
},
{
"answer_id": 389875,
"author": "Powerlord",
"author_id": 15880,
"a... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48725/"
] |
389,844 | <p>Is there any way to have a Windows batch file directly input SQL statements without calling a script? I want the batch file to login to SQL and then enter in the statements directly.</p>
<p><strong>EDIT:</strong> I'm using Oracle v10g</p>
| [
{
"answer_id": 389857,
"author": "Dave Costa",
"author_id": 6568,
"author_profile": "https://Stackoverflow.com/users/6568",
"pm_score": 3,
"selected": true,
"text": "echo select * from dual; | sqlplus user/pw@db\n"
},
{
"answer_id": 389864,
"author": "Bevan",
"author_id":... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1459442/"
] |
389,846 | <p>When using <code>.contains()</code> on an <code>ArrayCollection</code> in Flex, it will always look at the memory reference. It does not appear to look at an <code>.equals()</code> method or <code>.toString()</code> method or anything overridable. Instead, I need to loop through the <code>ArrayCollection</code> every time and check each individual item until I find what I'm looking for.</p>
<p>Does anyone know why Flex/ActionScript was made this way? Why not provide a way from people to use the <code>contains()</code> method the way they want?</p>
| [
{
"answer_id": 21670127,
"author": "Zjoia",
"author_id": 474109,
"author_profile": "https://Stackoverflow.com/users/474109",
"pm_score": 0,
"selected": false,
"text": "in_array($haystack, $arrayCollection->toArray());\n"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/389846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/738/"
] |
389,904 | <p>I have an ASP.NET web form which I am adding a variable number User Controls to. I have two problems:</p>
<ol>
<li><p>The User Controls are added to a PlaceHolder on the form in the first PageLoad event (I only add them when "(!this.IsPostback)", but then when the form is posted back, the controls are gone. Is this normal? Since other controls on the form keep their state, I would expect these dynamically added ones to stay on the form as well. Do I have to add them for every postback?</p></li>
<li><p>I also have a button and an event handler for the button click event, but this event handler is never called when I click on the button. Is there something special I have to do to catch events on dynamically added controls?</p></li>
</ol>
| [
{
"answer_id": 1137526,
"author": "Middletone",
"author_id": 35331,
"author_profile": "https://Stackoverflow.com/users/35331",
"pm_score": 0,
"selected": false,
"text": "Protected Overrides Sub LoadViewState(ByVal savedState As Object)\n MyBase.LoadViewState(savedState)\n If IsPost... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14101/"
] |
389,905 | <p>I've created a user control using WPF and I want to add it to window. I've done that, but I can't make my control have a height higher than the height it has in its own xaml file. My MaxWidth and MaxHeight are both infinity, but I can't make the control any taller than what it is in its xaml file.</p>
<p>To get around this, I have to make all my user control enormous so I'll be able to size them to whatever I want. This doesn't seem right, I have to be missing something.</p>
| [
{
"answer_id": 393860,
"author": "Jab",
"author_id": 29676,
"author_profile": "https://Stackoverflow.com/users/29676",
"pm_score": 2,
"selected": false,
"text": "xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\" \nxmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibi... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18927/"
] |
389,922 | <p>Why do we need both <code>using namespace</code> and <code>include</code> directives in C++ programs?</p>
<p>For example, </p>
<pre><code>#include <iostream>
using namespace std;
int main() {
cout << "Hello world";
}
</code></pre>
<p>Why is it not enough to just have <code>#include <iostream></code> or just have <code>using namespace std</code> and get rid of the other?</p>
<p>(I am thinking of an analogy with Java, where <code>import java.net.*</code> will import everything from <code>java.net</code>, you don't need to do anything else.)</p>
| [
{
"answer_id": 389944,
"author": "Tim",
"author_id": 10755,
"author_profile": "https://Stackoverflow.com/users/10755",
"pm_score": 6,
"selected": true,
"text": "C++ using"
},
{
"answer_id": 389949,
"author": "Motti",
"author_id": 3848,
"author_profile": "https://Stack... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/363902/"
] |
389,927 | <p>I found a bunch of scripts in the project I have been newly assigned to that are the "shutdown" scripts. They just do some basic searches and run the Unix <code>kill</code> command. Is there any reason they shouldn't shutdown the process this way? Does this ensure that dynamically allocated memory will return properly? Are there any other negative effects? I've operated under an intuition that this is a last resort way of terminating a process.</p>
| [
{
"answer_id": 389937,
"author": "Frank Krueger",
"author_id": 338,
"author_profile": "https://Stackoverflow.com/users/338",
"pm_score": 2,
"selected": false,
"text": "kill -9\n kill"
},
{
"answer_id": 389946,
"author": "Zan Lynx",
"author_id": 13422,
"author_profile"... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45581/"
] |
389,945 | <p>I've often seen people use Perl data structures in lieu of configuration files; i.e. a lone file containing only:</p>
<pre><code>%config = (
'color' => 'red',
'numbers' => [5, 8],
qr/^spam/ => 'eggs'
);
</code></pre>
<p>What's the best way to convert the contents of these files into Python-equivalent data structures, using pure Python? For the time being we can assume that there are no real expressions to evaluate, only structured data.</p>
| [
{
"answer_id": 390062,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 4,
"selected": true,
"text": "%config = (\n 'color' => 'red',\n 'numbers' => [5, 8],\n qr/^spam/ => 'eggs'\n);\n config = {\n 'color' : 'red',... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3594/"
] |
389,957 | <p>I'm trying to create proper header files which don't include too many other files to keep them clean and to speed up compile time.</p>
<p>I encountered two problems while doing this:</p>
<ol>
<li><p>Forward declaration on base classes doesn't work.</p>
<pre><code>class B;
class A : public B
{
// ...
}
</code></pre></li>
<li><p>Forward declaration on STD classes doesn't work.</p>
<pre><code>namespace std
{
class string;
}
class A
{
string aStringToTest;
}
</code></pre></li>
</ol>
<p>How do I solve these problems?</p>
| [
{
"answer_id": 389963,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 6,
"selected": true,
"text": "std::string std::string std::basic_string<char>"
},
{
"answer_id": 390124,
"author": "David Rodríguez ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47064/"
] |
389,993 | <p>Is there any straightforward way to get the mantissa and exponent from a double in c# (or .NET in general)?</p>
<p>I found <a href="https://jonskeet.uk/csharp/DoubleConverter.cs" rel="nofollow noreferrer">this example</a> using Google, but I'm not sure how robust it would be. Could the binary representation for a double change in some future version of the framework, etc?</p>
<p>The other alternative I found was to use System.Decimal instead of double and use the <a href="https://learn.microsoft.com/en-us/dotnet/api/system.decimal.getbits" rel="nofollow noreferrer">Decimal.GetBits()</a> method to extract them.</p>
<p>Any suggestions?</p>
| [
{
"answer_id": 390072,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 6,
"selected": true,
"text": "public static string ToExactString (double d)\n{\n …\n\n // Translate the double into sign, exponent and mantissa.\... | 2008/12/23 | [
"https://Stackoverflow.com/questions/389993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6219/"
] |
390,000 | <p>Whats the best way to separate the string, "Parisi, Kenneth" into "Kenneth" and "Parisi"?
<br>I am still learning how to parse strings with these regular expressions, but not too familiar with how to set vars equal to the matched string & output of the matched (or mismatched) string.</p>
| [
{
"answer_id": 390009,
"author": "codelogic",
"author_id": 43427,
"author_profile": "https://Stackoverflow.com/users/43427",
"pm_score": 2,
"selected": false,
"text": "my ($lname,$fname) = ($1,$2) if $var =~ /([a-z]+),\\s+([a-z]+)/i;\n ([a-z]+) , \\s+ ([a-z]+) i"
},
{
"answer_id"... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42229/"
] |
390,006 | <p>Is there a .NET API for OpenOffice?
<br /></p>
<p>EDIT: Is there a OpenOffice SDK for .NET?</p>
| [
{
"answer_id": 1408063,
"author": "Chris",
"author_id": 64257,
"author_profile": "https://Stackoverflow.com/users/64257",
"pm_score": 3,
"selected": false,
"text": "XComponentLoader xComponentLoader =\n (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class, desktop);\n XC... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443363/"
] |
390,017 | <p>I have a ListView inside another ListView, and I'd like to hide a table column in the inner ListView whenever a particular parameter is passed. Given the setup below, how would I hide the ID column (both the header and the data) if the URL contains "...?id=no"?</p>
<pre><code><asp:ListView ID="ProcedureListView" runat="server">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<h4>
<%#Eval("PROCEDURE_CODE") %>
</h4>
<asp:ListView ID="BenefitListView" runat="server" DataSource='<%#Eval("benefits") %>'>
<LayoutTemplate>
<table cellpadding="5" class="indent">
<tr class="tableHeader">
<td>
ID
</td>
<td>
Benefit
</td>
</tr>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<%#Eval("benefit_id")%>
</td>
<td>
<%#Eval("benefit_name")%>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:ListView>
</code></pre>
| [
{
"answer_id": 390065,
"author": "Victor",
"author_id": 42518,
"author_profile": "https://Stackoverflow.com/users/42518",
"pm_score": 0,
"selected": false,
"text": "<% if (Request.QueryString[\"id\"] != \"no\") { %>\n <td>\n <%#Eval(\"benefit_id\")%>\n </td>\n<% } %>\n <td>\n ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] |
390,033 | <p>Hey everyone, I'm working on a PHP application that needs to parse a .tpl file with HTML in it and I'm making it so that the HTML can have variables and basic if statements in it. An if statement look something like this:
`</p>
<pre><code><!--if({VERSION} == 2)-->
Hello World
<!--endif -->
</code></pre>
<p>To parse that, I've tried using <code>preg_replace</code> with no luck. The pattern that I tried was</p>
<p><code>
/<!--if\(([^\]*)\)-->([^<]*)<!--endif-->/e
</code></p>
<p>which gets replaced with </p>
<p><code>
if($1) { echo "$2"; }
</code></p>
<p>Any ideas as to why this won't work and what I can do to get it up and running?</p>
| [
{
"answer_id": 390055,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 2,
"selected": false,
"text": "endif -->"
},
{
"answer_id": 390058,
"author": "Bill Karwin",
"author_id": 20860,
"author_profile": "http... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390033",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29291/"
] |
390,051 | <p>I want to write an Exception to an MS Message Queue. When I attempt it I get an exception. So I tried simplifying it by using the XmlSerializer which still raises an exception, but it gave me a bit more info:</p>
<blockquote>
<p>{"There was an error reflecting type
'System.Exception'."}</p>
</blockquote>
<p>with InnerException: </p>
<blockquote>
<p>{"Cannot serialize member
System.Exception.Data of type
System.Collections.IDictionary,
because it implements IDictionary."}</p>
</blockquote>
<p>Sample Code:</p>
<pre><code> Exception e = new Exception("Hello, world!");
MemoryStream stream = new MemoryStream();
XmlSerializer x = new XmlSerializer(e.GetType()); // Exception raised on this line
x.Serialize(stream, e);
stream.Close();
</code></pre>
<p>EDIT:
I tried to keep this a simple as possible, but I may have overdone it. I want the whole bit, stack trace, message, custom exception type, and custom exception properties. I may even want to throw the exception again.</p>
| [
{
"answer_id": 390081,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 3,
"selected": false,
"text": "public class WireObject<T, E>\n{\n public T Payload{get;set;}\n public E Exception{get;set;}\n}\n"
},
{
"a... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16260/"
] |
390,052 | <p>I am displaying many rows of data in a list view that is bound to a list of a custom class. The custom class has a property called type. The number of allowable Types is limited and I would like to limit the user to making changes by selecting from a combobox. I tried adding a combobox to the base class but that did not display as a combobox in the list view.</p>
| [
{
"answer_id": 390081,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 3,
"selected": false,
"text": "public class WireObject<T, E>\n{\n public T Payload{get;set;}\n public E Exception{get;set;}\n}\n"
},
{
"a... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38349/"
] |
390,083 | <p>Have just started playing with ASP.NET MVC and have stumbled over the following situation. It feels a lot like a bug but if its not, an explanation would be appreciated :)</p>
<p>The View contains pretty basic stuff</p>
<pre><code><%=Html.DropDownList("MyList", ViewData["MyListItems"] as SelectList)%>
<%=Html.TextBox("MyTextBox")%>
</code></pre>
<p>When not using a model, the value and selected item are set as expected:</p>
<pre><code>//works fine
public ActionResult MyAction(){
ViewData["MyListItems"] = new SelectList(items, "Value", "Text"); //items is an ienumerable of {Value="XXX", Text="YYY"}
ViewData["MyList"] = "XXX"; //set the selected item to be the one with value 'XXX'
ViewData["MyTextBox"] = "ABC"; //sets textbox value to 'ABC'
return View();
}
</code></pre>
<p>But when trying to load via a model, the textbox has the value set as expected, but the dropdown doesnt get a selected item set.</p>
<pre><code>//doesnt work
public ActionResult MyAction(){
ViewData["MyListItems"] = new SelectList(items, "Value", "Text"); //items is an ienumerable of {Value="XXX", Text="YYY"}
var model = new {
MyList = "XXX", //set the selected item to be the one with value 'XXX'
MyTextBox = "ABC" //sets textbox value to 'ABC'
}
return View(model);
}
</code></pre>
<p>Any ideas? My current thoughts on it are that perhaps when using a model, we're restricted to setting the selected item on the SelectList constructor instead of using the viewdata (which works fine) and passing the selectlist in with the model - which would have the benefit of cleaning the code up a little - I'm just wondering why this method doesnt work....</p>
<p>Many thanks for any suggestions</p>
| [
{
"answer_id": 390339,
"author": "Todd Smith",
"author_id": 31624,
"author_profile": "https://Stackoverflow.com/users/31624",
"pm_score": 4,
"selected": true,
"text": "if (ViewData.ModelState.TryGetValue(key, out modelState))\n <%= Html.TextBox(\"MyTextBox\", ViewData.Model.MyTextBox) %>... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8262/"
] |
390,087 | <p>We are developing a WinForm application that we want to deploy to certain users machine. We would like to uniquely identify each application installed with some sort of "code" that we can define before installing on their system.</p>
<p>Right now we plan to put the unique code (that we type ourselves) in an xml or text file and have the application read it on install. The application would delete that file after installation and save it somewhere.</p>
<p>We want to be able to type that code ourselves so we can keep track, but is there a better of doing this instead of putting it in some sort of flat file and having the application delete it after install?</p>
| [
{
"answer_id": 390292,
"author": "Brody",
"author_id": 17131,
"author_profile": "https://Stackoverflow.com/users/17131",
"pm_score": 1,
"selected": false,
"text": "' Windows Installer utility to execute SQL statements against an installer database\n' For use with Windows Scripting Host, ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390087",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
390,095 | <p>Background: We are using VS 2008 and are in the process of upgrading from TFS 2005 to 2008.</p>
<p>We have a solution that contains several projects and overall have hundreds of code files. We want to add the same text as a comment to all of these files (a copyright message). Does anyone know of a quick/easy/efficient way to do this? Also, is there a way to do this via TFS so we don't have check out and check in every file? </p>
<p>I found some code on CodeProject on creating a macro which does this, but you have to open each file individually and then run the macro on each one, which we were hoping to avoid. </p>
<p>Thanks.</p>
| [
{
"answer_id": 390120,
"author": "Adam Rosenfield",
"author_id": 9530,
"author_profile": "https://Stackoverflow.com/users/9530",
"pm_score": 1,
"selected": false,
"text": "# Process all .cpp and .h files under the directory tree at $PROJECTROOT\n# To add other file types, add more \"-o -... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390095",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48747/"
] |
390,099 | <p>I am looking at uClinux system that builds the kernel with arm-linux-xxx, but builds the user apps with arm-elf-xxx.</p>
<p>If the apps are intended to run on linux, wouldn't it be better to build everything with arm-linux-xxx ?</p>
<p>Where does one set that option in the overall uClinux build config?</p>
| [
{
"answer_id": 9922177,
"author": "gfour",
"author_id": 671119,
"author_profile": "https://Stackoverflow.com/users/671119",
"pm_score": 2,
"selected": false,
"text": "arm-linux-gcc -v arm-elf-gcc -v"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/390099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2033811/"
] |
390,103 | <p>This is related to my <a href="https://stackoverflow.com/questions/390017/hide-a-table-column-in-a-nested-listview">earlier question</a>, but I thought I'd simplify it and make a challenge out of it. Given the code below, can you change the value of "ChangeThisLabel" from the code behind?</p>
<pre><code><asp:ListView ID="OuterListView" runat="server">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<%#Eval("outer_value")%> <br/>
<asp:ListView ID="InnerListView" runat="server" DataSource='<%#Eval("inner") %>'>
<LayoutTemplate>
<asp:Label ID="ChangeThisLabel" runat="server" />
<asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<%#Eval("inner_value")%> <br/>
</ItemTemplate>
</asp:ListView>
</ItemTemplate>
</asp:ListView>
</code></pre>
<p>I would suggest trying it yourself before submitting an answer, as I got a lot of suggestions in my earlier post that work fine for a single ListView, but fall down when going up against the nested ListView.</p>
| [
{
"answer_id": 390117,
"author": "Kon",
"author_id": 22303,
"author_profile": "https://Stackoverflow.com/users/22303",
"pm_score": 1,
"selected": false,
"text": "FindControl(\"ChangeThisLabel\") Label"
},
{
"answer_id": 390160,
"author": "Victor",
"author_id": 42518,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23935/"
] |
390,105 | <p>I've have finally got the datepicker to work on my MVC demo site. One thing though it doesn't work when browsing with IE7, I havn't testet with IE6 yet. Does anyone know how to fix this problem or can't I use jQuery if I want IE users to be able to pick dates?</p>
<p>It works like a charm on Safari and Firefox, except for it's position when dropping down.</p>
<p>Please try for yourself on my demo site: <a href="http://www.tarsius.se" rel="noreferrer">Demo site</a></p>
<p>Click the link "Boka plats" on the menu. then login with:
email: test@test.nu
password: tester</p>
| [
{
"answer_id": 390134,
"author": "SquidScareMe",
"author_id": 30921,
"author_profile": "https://Stackoverflow.com/users/30921",
"pm_score": 0,
"selected": false,
"text": "<script type=\"text/javascript\"> \n $(document).ready(function() { \n $(\"#Date\").datepi... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459417/"
] |
390,106 | <p>It seems to be a common requirement nowadays to have a search feature that can search almost anything you want. Can anyone give me samples or tips as to how to go about building a one stop search for an application?</p>
<p>For example: you have 3 tables customers, products, employees. The application has a master page that has a textbox at the right hand corner very similar to what you have on stackoverflow.</p>
<p>How do I have a search say for term say "Phoenix" and have results like </p>
<p>Customers</p>
<pre><code>Result 1
......
</code></pre>
<p>Products</p>
<pre><code>Result 1
......
</code></pre>
<p>Employees</p>
<pre><code>Result 1
......
</code></pre>
<p>Any tips, tutorials and hints would be really appreciated. My environment is Win2k3,.net3.5,C#,ASP.net.</p>
<p>EDIT: Looking specifically at performance and scalability.</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 390277,
"author": "Philippe Grondier",
"author_id": 11436,
"author_profile": "https://Stackoverflow.com/users/11436",
"pm_score": 2,
"selected": false,
"text": "'*823*' 'INV-0823456' 'INV-0880823'"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/390106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37494/"
] |
390,108 | <p>What are general guidelines on when user-defined implicit conversion could, should, or should not be defined?</p>
<p>I mean things like, for example, "an implicit conversion should never lose information", "an implicit conversion should never throw exceptions", or "an implicit conversion should never instantiate new objects". I am pretty sure the first one is correct, the third one is not (or we could only ever have implicit conversion to structs), and I don't know about the second one.</p>
| [
{
"answer_id": 390125,
"author": "Marc Gravell",
"author_id": 23354,
"author_profile": "https://Stackoverflow.com/users/23354",
"pm_score": 2,
"selected": false,
"text": "Nullable<T>"
},
{
"answer_id": 390158,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390108",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9204/"
] |
390,115 | <p>What have others done to get around the fact that the Commons Logging project (for both .NET and Java) do not support Mapped or Nested Diagnostic Contexts as far as I know?</p>
| [
{
"answer_id": 1680095,
"author": "tgeros",
"author_id": 4458,
"author_profile": "https://Stackoverflow.com/users/4458",
"pm_score": 1,
"selected": true,
"text": "public interface IDiagnosticContextHandler\n{\n void Set(string name, string value);\n}\n public class Log4NetDiagnosticCo... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4458/"
] |
390,118 | <p>I have the following 3 classes </p>
<pre><code>Book
Product
SpecialOptions
</code></pre>
<p>There are many Books, and there are many Products per Book. Likewise in a Product there are many SpecialOptions. There are other properties of each of these three classes so each class has the following interface</p>
<pre><code>Public Interface IBook
Private ProductList() as collection (of Products)
Private Somethingelse() as String
End Interface
Public Interface IProduct
Private SpecialOptionsList() as collection (of SpecialOptions)
Private Somethingelse() as String
End Interface
Public Interface ISpecialOptions
Private SpecialOptionsProperty() as String
End Interface
</code></pre>
<p>I want to create a collection of Books, which has each of the products under it, and under each of those Products I have want the associated SpecialOptions, when I pull the data out of a database. I can't decide which will be the best way to do this. </p>
<p>I have two methods. Either I go from the top down or from the bottom up. Meaning, I start with a book and then fill out the product information and then for each of those products fill out the detail information. OR I can get the details first, and then add them to the appropriate product and then do it again for products to books. Neither of these is very appealing.</p>
<p>Also, and because I suggested it to myself when proofreading, this is the structure that I need to capture the actual relationship, so reframing the problem with different structure is not going to work.</p>
| [
{
"answer_id": 1680095,
"author": "tgeros",
"author_id": 4458,
"author_profile": "https://Stackoverflow.com/users/4458",
"pm_score": 1,
"selected": true,
"text": "public interface IDiagnosticContextHandler\n{\n void Set(string name, string value);\n}\n public class Log4NetDiagnosticCo... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22777/"
] |
390,135 | <p>How do you search for a specific text inside a text run (in Docx using the OpenXML SDK 2.0) and once you find it how do you insert a comment surrounding the 'search text'. The 'search text' can be a sub string of an existing run. All example in the samples insert comments around the first paragraph or something simple like that... not what I'm looking for.</p>
<p>Thanks</p>
| [
{
"answer_id": 549807,
"author": "herskinduk",
"author_id": 63411,
"author_profile": "https://Stackoverflow.com/users/63411",
"pm_score": 2,
"selected": false,
"text": "<paragraph>\n <run>...</run>\n <commentRangeStart />\n <run>search text</run>\n <commentRangeEnd />\n <run>...</ru... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48753/"
] |
390,148 | <p>I have a web application that is generating hundreds of PDFs in batch, using ColdFusion 8 on a Windows/IIS server.</p>
<p>The process runs fine on my development and staging servers, but of course the client is cheap and is only paying for shared hosting, which isn't as fast as my dev/staging boxes. As a result, PDF generation threads are timing out.</p>
<p>The flow is something like this:</p>
<ol>
<li>Page is run to generate PDFs.</li>
<li>A query is run to determine which PDFs need to be generated, and a loop fires off an application-scoped UDF call for each PDF that will need to be generated.</li>
<li>That UDF looks up information for the given item, and then creates a thread for the PDF generation to work in, preventing generation from slowing down the page.</li>
<li>The thread simply uses CFDocument to create a PDF and save it to disk, then terminates.</li>
</ol>
<p>Threads do not re-join, and nothing is waiting for any of them to finish. The page that makes the UDF calls finishes in a few milliseconds; it's the threads themselves that are timing out.</p>
<p>Here is the code for the UDF (and thread creation):</p>
<pre><code><cffunction name="genTearSheet" output="false" returntype="void">
<cfargument name="partId" type="numeric" required="true"/>
<!--- saveLocation can be a relative or absolute path --->
<cfargument name="saveLocation" type="string" required="true"/>
<cfargument name="overwrite" type="boolean" required="false" default="true" />
<cfset var local = structNew() />
<!--- fix save location if we need to --->
<cfif left(arguments.saveLocation, 1) eq "/">
<cfset arguments.saveLocation = expandPath(arguments.saveLocation) />
</cfif>
<!--- get part info --->
<cfif structKeyExists(application, "partGateway")>
<cfset local.part = application.partGateway
.getByAttributesQuery(partId: arguments.partId)/>
<cfelse>
<cfset local.part = createObject("component","com.admin.partGateway")
.init(application.dsn).getByAttributesQuery(partId: arguments.partId)/>
</cfif>
<!--- define file name to be saved --->
<cfif right(arguments.saveLocation, 4) neq ".pdf">
<cfif right(arguments.saveLocation, 1) neq "/">
<cfset arguments.saveLocation = arguments.saveLocation & "/" />
</cfif>
<cfset arguments.saveLocation = arguments.saveLocation &
"ts_#application.udf.sanitizePartNum(local.part.PartNum)#.pdf"/>
</cfif>
<!--- generate the new PDF in a thread so that page processing can continue --->
<cfthread name="thread-genTearSheet-partid-#arguments.partId#" action="run"
filename="#arguments.saveLocation#" part="#local.part#"
overwrite="#arguments.overwrite#">
<cfsetting requestTimeOut=240 />
<cftry>
<cfoutput>
<cfdocument format="PDF" marginbottom="0.75"
filename="#attributes.fileName#" overwrite="#attributes.overwrite#">
<cfdocumentitem type="footer">
<center>
<font face="Tahoma" color="black" size="7pt">
pdf footer text here
</font>
</center>
</cfdocumentitem>
pdf body here
</cfdocument>
</cfoutput>
<cfcatch>
<cfset application.udf.errorEmail(application.errorEmail,
"Error in threaded PDF save", cfcatch)/>
</cfcatch>
</cftry>
</cfthread>
</cffunction>
</code></pre>
<p>As you can see, I've tried adding a <code><cfsetting requestTimeout=240 /></code> to the top of the thread to try and make it live longer... no dice. I also got a little excited when I saw that <a href="http://cfquickdocs.com/cf8/?getDoc=cfthread#cfthread" rel="nofollow noreferrer">the CFThread tag has a timeout parameter</a>, but then realized it only applies when joining threads (action=join).</p>
<p>Changing the default timeout in ColdFusion Administrator is not an option, as this is a shared host.</p>
<p>If anyone has any ideas on how to make these threads live longer, I would really appreciate them.</p>
| [
{
"answer_id": 428397,
"author": "Adam Tuttle",
"author_id": 751,
"author_profile": "https://Stackoverflow.com/users/751",
"pm_score": 2,
"selected": true,
"text": "localUrl CFDocument CFDocument <cfdocument format=\"PDF\" marginbottom=\"0.75\" \nfilename=\"#attributes.fileName#\" overwr... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/751/"
] |
390,150 | <p>I have a simple task of authenticating against Active Directory using Java. Just verifying credentials and nothing else. Let's say my domain is "fun.xyz.tld", OU path is unknown, and username/password is testu/testp. </p>
<p>I know there's a few Java libraries out there that simplify this task, but I wasn't successful at implementing them. Most examples that I've found addressed LDAP in general, not specifically Active Directory. Issuing LDAP request means sending an OU path in it, which I don't have. Also, the application that issues LDAP request should be already bound to Active Directory in order to access it... Insecure, since the credentials would have to be stored someplace discoverable. I would like a test bind with test credentials, if possible - this would mean that account is valid.</p>
<p>Last, if possible, is there a way to make such authentication mechanism encrypted? I know that AD uses Kerberos, but not sure if Java's LDAP methods do.</p>
<p>Does anyone has an example of working code? Thanks.</p>
| [
{
"answer_id": 390169,
"author": "Anthony",
"author_id": 48463,
"author_profile": "https://Stackoverflow.com/users/48463",
"pm_score": 2,
"selected": false,
"text": "kerberos LDAP"
},
{
"answer_id": 394193,
"author": "DV.",
"author_id": 18406,
"author_profile": "https... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18406/"
] |
390,164 | <p>Say I need to call a javascript file in the <code><head></code> of an ERb template.
My instinct is to do the usual:</p>
<pre><code><head>
<%= javascript_include_tag :defaults %> <!-- For example -->
</head>
</code></pre>
<p>in my application's layout. The problem of course becoming that these javascript files are loaded into every page in my application, regardless of whether or not they are needed for the page being viewed.</p>
<p>So what I'm wondering is if there's a good way of loading a javascript into the the headers of, for example, all ERb templates found only in a specific directory.</p>
| [
{
"answer_id": 390182,
"author": "Gareth",
"author_id": 31582,
"author_profile": "https://Stackoverflow.com/users/31582",
"pm_score": 1,
"selected": false,
"text": "<head>\n <%= javascript_include_tag :defaults %> <!-- For example -->\n <%= @extra_head_content %>\n</head>\n <% (@extra_... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390164",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2293/"
] |
390,174 | <p>I have a file with a bunch of lines. I have recorded a macro that performs an operation on a single line. I want to repeat that macro on all of the remaining lines in the file. Is there a quick way to do this?</p>
<p>I tried Ctrl+Q, highlighted a set of lines, and pressed @@, but that didn't seem to do the trick.</p>
| [
{
"answer_id": 390194,
"author": "Judge Maygarden",
"author_id": 1491,
"author_profile": "https://Stackoverflow.com/users/1491",
"pm_score": 10,
"selected": true,
"text": ":5,10norm! @a\n :5,$norm! @a\n :%norm! @a\n :g/pattern/norm! @a\n :norm! @a :'<,'>norm! @a\n"
},
{
"answer_i... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390174",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20133/"
] |
390,176 | <p>I know that the f# list is not the same at the c# List. What do I need to do to be able to pass a list of ints from a c# application to an f# library? I'd like to be able to use pattern matching on the data once it's in the f# code.</p>
| [
{
"answer_id": 390227,
"author": "Alexey Romanov",
"author_id": 9204,
"author_profile": "https://Stackoverflow.com/users/9204",
"pm_score": 3,
"selected": false,
"text": "Seq.toList : IEnumerable<'a> -> list<'a>\n IEnumerable<'a> seq System.Collections.Generic.List<'a>"
},
{
"ans... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26339/"
] |
390,181 | <p>I'm working on a project, written in Java, which requires that I build a very large 2-D sparse array. Very sparse, if that makes a difference. Anyway: the most crucial aspect for this application is efficency in terms of time (assume loads of memory, though not nearly so unlimited as to allow me to use a standard 2-D array -- the key range is in the billions in both dimensions).</p>
<p>Out of the kajillion cells in the array, there will be several hundred thousand cells which contain an object. I need to be able to modify cell contents VERY quickly.</p>
<p>Anyway: Does anyone know a particularly good library for this purpose? It would have to be Berkeley, LGPL or similar license (no GPL, as the product can't be entirely open-sourced). Or if there's just a very simple way to make a homebrew sparse array object, that'd be fine too.</p>
<p>I'm considering <a href="http://ressim.berlios.de/" rel="noreferrer">MTJ</a>, but haven't heard any opinions on its quality.</p>
| [
{
"answer_id": 391235,
"author": "eljenso",
"author_id": 30316,
"author_profile": "https://Stackoverflow.com/users/30316",
"pm_score": 2,
"selected": false,
"text": " SortedMap<Index, Object> entries = new TreeMap<Index, Object>();\n entries.put(new Index(1, 4), \"1-4\");\n entr... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47450/"
] |
390,187 | <p>When attempting to copy a framework into the Frameworks folder of my project in Xcode, I get the error</p>
<blockquote>
<p>Could not copy /Developer/Platforms/.../Frameworks/OpenAL.framework to /Users/.../OpenAL.framework</p>
</blockquote>
<p>I had accidentally copied the wrong framework with the same name into the project earlier and deleted it, but now I can't copy the correct one in? How do I get totally rid of the wrong version before copying the appropriate version in?</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 391235,
"author": "eljenso",
"author_id": 30316,
"author_profile": "https://Stackoverflow.com/users/30316",
"pm_score": 2,
"selected": false,
"text": " SortedMap<Index, Object> entries = new TreeMap<Index, Object>();\n entries.put(new Index(1, 4), \"1-4\");\n entr... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21293/"
] |
390,188 | <p>Is there a good, free telnet library available for C# (not ASP .NET)? I have found a few on google, but they all have one issue or another (don't support login/password, don't support a scripted mode).</p>
<p>I am assuming that MS still has not included a telnet library as part of .NET v3.5 as I couldn't find it if it was. I would loooooove to be wrong though.</p>
| [
{
"answer_id": 8827835,
"author": "Prakash",
"author_id": 1144302,
"author_profile": "https://Stackoverflow.com/users/1144302",
"pm_score": 3,
"selected": false,
"text": "using System;\nusing System.IO;\nusing System.Net;\nusing System.Net.Sockets;\nusing System.Text.RegularExpressions;\... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/757/"
] |
390,192 | <p>When I define an object of a class using new like this</p>
<pre><code>$blah = new Whatever();
</code></pre>
<p>I get autocomplete for $blah. <strong>But how do I do it when I have $blah as a function parameter?</strong> Without autocomplete I am incomplete.</p>
<p><strong>Edit</strong>: <strong>How do I do it if it's in an include and PDT or Netbeans can't figure it out?</strong> Is there any way to declare types for variables in PHP?</p>
| [
{
"answer_id": 390211,
"author": "maxnk",
"author_id": 45862,
"author_profile": "https://Stackoverflow.com/users/45862",
"pm_score": 3,
"selected": false,
"text": "function myFunction(Whatever $blah) {\n}\n"
},
{
"answer_id": 396041,
"author": "Alan Gabriel Bem",
"author_... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390192",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8047/"
] |
390,195 | <p>We have an old Classic ASP application that we have been using Visual Studio 6 to maintain. This has worked fine, but we're ready to step out of the stone age and I'd like to see if I can use Visual Studio 2008 (SP1) to maintain the application.</p>
<p>In the past, multiple developers could work on the application and it was under source control. We had FrontPage Server Extensions (FSE) installed on the web server and there was some sort of three-way integration between Visual Interdev on the client, FSE on the web server, and the SourceSafe database that let us check files in and out through Interdev. Files were checked out to the web server, not to the client. And when checking a file back in through Interdev, we could press a "Diff" button to review the changes to the file before checking it in.</p>
<p>Now I have installed Visual Studio 2008 (SP1) and I'm trying to get the same functionality. I used File/Open Web Site/Remote Site to bring the project up. This works fine and I am able to check files in and out. However, the option to view the differences is disabled. Also, when I enter a comment on the Check-In dialog window, the comment gets ignored. In other words, if you use the SourceSafe standalone client to look at the history of the file, the file gets checked in properly, but there is no comment.</p>
<p>In VS2008 after I check out a file, when I right-click on it, the "Compare" and "View History" options are disabled. Also, if I click on the Check-In option, the Compare Versions button in the Check-in dialog is disabled. Is there any trick to enabling the Compare option?</p>
| [
{
"answer_id": 390211,
"author": "maxnk",
"author_id": 45862,
"author_profile": "https://Stackoverflow.com/users/45862",
"pm_score": 3,
"selected": false,
"text": "function myFunction(Whatever $blah) {\n}\n"
},
{
"answer_id": 396041,
"author": "Alan Gabriel Bem",
"author_... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48760/"
] |
390,205 | <p>I'm trying to convert all instances of the > character to its HTML entity equivalent, >, within a string of HTML that contains HTML tags. The furthest I've been able to get with a solution for this is using a regex.</p>
<p>Here's what I have so far:</p>
<pre><code> public static readonly Regex HtmlAngleBracketNotPartOfTag = new Regex("(?:<[^>]*(?:>|$))(>)", RegexOptions.Compiled | RegexOptions.Singleline);
</code></pre>
<p>The main issue I'm having is isolating the single > characters that are not part of an HTML tag. I don't want to convert any existing tags, because I need to preserve the HTML for rendering. If I don't convert the > characters, I get malformed HTML, which causes rendering issues in the browser.</p>
<p>This is an example of a test string to parse:</p>
<pre><code>"Ok, now I've got the correct setting.<br/><br/>On 12/22/2008 3:45 PM, jproot@somedomain.com wrote:<br/><div class"quotedReply">> Ok, got it, hope the angle bracket quotes are there.<br/>><br/>> On 12/22/2008 3:45 PM, > sbartfast@somedomain.com wrote:<br/>>> Please someone, reply to this.<br/>>><br/>><br/></div>"
</code></pre>
<p>In the above string, none of the > characters that are part of HTML tags should be converted to >. So, this:</p>
<pre><code><div class"quotedReply">>
</code></pre>
<p>should become this:</p>
<pre><code><div class"quotedReply">&gt;
</code></pre>
<p>Another issue is that the expression above uses a non-capturing group, which is fine except for the fact that the match is in group 1. I'm not quite sure how to do a replace only on group 1 and preserve the rest of the match. It appears that a MatchEvaluator doesn't really do the trick, or perhaps I just can't envision it right now. </p>
<p>I suspect my regex could do with some lovin'.</p>
<p>Anyone have any bright ideas?</p>
| [
{
"answer_id": 390233,
"author": "JB King",
"author_id": 8745,
"author_profile": "https://Stackoverflow.com/users/8745",
"pm_score": 0,
"selected": false,
"text": "> >"
},
{
"answer_id": 390256,
"author": "LarryF",
"author_id": 18518,
"author_profile": "https://Sta... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/769/"
] |
390,219 | <p>Okay, this is really kinda starting to bug me. I have a simple Web project setup located at: "C:\Projects\MyTestProject\". In IIS on my machine, I have mapped a virtual directory to this location so I can run my sites locally (I understand I can run it from Visual Studio, I like this method better). I have named this virtual directory "mtp" and I access it via <a href="http://localhost/mtp/index.aspx" rel="noreferrer">http://localhost/mtp/index.aspx</a>. All this is working fine.</p>
<p>However, whenever I try to create a cookie, it simply never gets written out? I've tried this in FF3 and IE7 and it just plain won't write the cookie out. I don't get it. I do have "127.0.0.1 localhost" in my hosts file, I can't really think of anything else I can do. Thanks for any advice.</p>
<p>James</p>
| [
{
"answer_id": 23918787,
"author": "Jason Eades",
"author_id": 1368050,
"author_profile": "https://Stackoverflow.com/users/1368050",
"pm_score": 4,
"selected": false,
"text": "<!-- Development -->\n<httpCookies httpOnlyCookies=\"true\" requireSSL=\"false\" />\n<!-- Production -->\n<!--<h... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39337/"
] |
390,238 | <p>I'm looking for ways to display a single row of data as a single column (with multiple rows). For example,</p>
<pre>
FieldA FieldB
------- ---------
1 Some Text [row]
Header Value [col]
------ ------
FieldA 1 [row1]
FieldB SomeText [row2]
</pre>
<p>Is there a way to do this with SQL Server 2005?</p>
| [
{
"answer_id": 390327,
"author": "fatbuddha",
"author_id": 28034,
"author_profile": "https://Stackoverflow.com/users/28034",
"pm_score": 2,
"selected": false,
"text": "Declare @tbl Table\n(\n c1 int,\n c2 int,\n c3 int\n)\n\nInsert into @tbl Values(1,2,3)\n\nSelect\n cname,\n cval\n... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28413/"
] |
390,242 | <p>I have a program that continually polls the database for change in value of some field. It runs in the background and currently uses a while(true) and a sleep() method to set the interval. I am wondering if this is a good practice? And, what could be a more efficient way to implement this? The program is meant to run at all times.</p>
<p>Consequently, the only way to stop the program is by issuing a kill on the process ID. The program could be in the middle of a JDBC call. How could I go about terminating it more gracefully? I understand that the best option would be to devise some kind of exit strategy by using a flag that will be periodically checked by the thread. But, I am unable to think of a way/condition of changing the value of this flag. Any ideas?</p>
| [
{
"answer_id": 390421,
"author": "Bombe",
"author_id": 43582,
"author_profile": "https://Stackoverflow.com/users/43582",
"pm_score": 0,
"selected": false,
"text": "public class Service implements Runnable {\n\n private boolean shouldStop = false;\n\n public synchronized stop() {\n ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48725/"
] |
390,250 | <p>When writing custom classes it is often important to allow equivalence by means of the <code>==</code> and <code>!=</code> operators. In Python, this is made possible by implementing the <code>__eq__</code> and <code>__ne__</code> special methods, respectively. The easiest way I've found to do this is the following method:</p>
<pre><code>class Foo:
def __init__(self, item):
self.item = item
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__dict__ == other.__dict__
else:
return False
def __ne__(self, other):
return not self.__eq__(other)
</code></pre>
<p>Do you know of more elegant means of doing this? Do you know of any particular disadvantages to using the above method of comparing <code>__dict__</code>s?</p>
<p><strong>Note</strong>: A bit of clarification--when <code>__eq__</code> and <code>__ne__</code> are undefined, you'll find this behavior:</p>
<pre><code>>>> a = Foo(1)
>>> b = Foo(1)
>>> a is b
False
>>> a == b
False
</code></pre>
<p>That is, <code>a == b</code> evaluates to <code>False</code> because it really runs <code>a is b</code>, a test of identity (i.e., "Is <code>a</code> the same object as <code>b</code>?").</p>
<p>When <code>__eq__</code> and <code>__ne__</code> are defined, you'll find this behavior (which is the one we're after):</p>
<pre><code>>>> a = Foo(1)
>>> b = Foo(1)
>>> a is b
False
>>> a == b
True
</code></pre>
| [
{
"answer_id": 390280,
"author": "Vasil",
"author_id": 7883,
"author_profile": "https://Stackoverflow.com/users/7883",
"pm_score": 3,
"selected": false,
"text": "__eq__ __ne__ __cmp__ is is True __cmp__"
},
{
"answer_id": 390335,
"author": "too much php",
"author_id": 288... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/38140/"
] |
390,260 | <p>I'm using the code that netadictos posted to the question <a href="https://stackoverflow.com/questions/333665/">here</a>. All I want to do is to display a warning when a user is navigating away from or closing a window/tab.</p>
<p>The code that netadictos posted seems to work fine in IE7, FF 3.0.5, Safari 3.2.1, and Chrome but it doesn't work in Opera v9.63. Does anyone know of way of doing the same thing in Opera?</p>
<p>Thx, Trev</p>
| [
{
"answer_id": 390315,
"author": "Blorgbeard",
"author_id": 369,
"author_profile": "https://Stackoverflow.com/users/369",
"pm_score": 1,
"selected": false,
"text": "history.navigationMode = 'compatible';\n"
},
{
"answer_id": 17452749,
"author": "wojo",
"author_id": 9022,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47121/"
] |
390,263 | <p>I am using python to read a currency value from excel. The returned from the range.Value method is a tuple that I don't know how to parse.</p>
<p>For example, the cell appears as $548,982, but in python the value is returned as (1, 1194857614).</p>
<p>How can I get the numerical amount from excel or how can I convert this tuple value into the numerical value?</p>
<p>Thanks!</p>
| [
{
"answer_id": 391076,
"author": "tzot",
"author_id": 6899,
"author_profile": "https://Stackoverflow.com/users/6899",
"pm_score": 3,
"selected": true,
"text": "import struct\ntry: import decimal\nexcept ImportError:\n divisor= 10000.0\nelse:\n divisor= decimal.Decimal(10000)\n\ndef... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
390,265 | <p>I always seem to see if a string (querystring value usually) has a value but first I have to check that it is not nothing first so I end up with 2 if then statements - am I missing somethign here - there has to be a better way to do this:</p>
<pre><code>If Not String.IsNullOrEmpty(myString) Then
If CBool(myString) Then
//code
End If
End If
</code></pre>
| [
{
"answer_id": 390296,
"author": "devio",
"author_id": 21336,
"author_profile": "https://Stackoverflow.com/users/21336",
"pm_score": 3,
"selected": true,
"text": "If Not String.IsNullOrEmpty(myString) AndAlso CBool(myString) Then \n ....\nEnd If\n"
},
{
"answer_id": 390440,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34548/"
] |
390,276 | <p>Here's a problem that I've been running into lately - a misconfigured apache on a webhost. This means that all scripts that rely on <code>$_SERVER['DOCUMENT_ROOT']</code> break. The easiest workaround that I've found is just set the variable in some global include files that is shared, but it's a pain not to forget it. My question is, how do I determine the correct document root programatically?</p>
<p>For example, on one host, the setup is like this:</p>
<pre><code>$_SERVER['DOCUMENT_ROOT'] == '/htdocs'
</code></pre>
<p>The real document roots are:</p>
<pre><code>test.example.com -> /data/htdocs/example.com/test
www.example.com -> /data/htdocs/example.com/www
</code></pre>
<p>And I'd like a script that's run from <code>www.example.com/blog/</code> (on the path <code>/data/htdocs/example.com/www/blog</code>) to get the correct value of <code>/data/htdocs/example.com/www</code>.</p>
<p>On another host, the setup is a bit different:</p>
<pre><code>$_SERVER['DOCUMENT_ROOT'] == '/srv'
test.example.com -> /home/virtual_web/example.com/public_html/test
www.example.com -> /home/virtual_web/example.com/public_html/www
</code></pre>
<p>Is there any solution to this? Or is the only way simply not to ever rely on <code>$_SERVER['DOCUMENT_ROOT']</code> and fix all the software that I'm running on my sites? Fixing this on the hosting's side doesn't seem to be an option, I've yet to encounter a host where this is was configured correctly. The best I got was a document root pointing to www.example.com, which was at least inside open_basedir - they used yet another naming scheme, www.example.com would point to <code>/u2/www/example_com/data/www/</code>.</p>
| [
{
"answer_id": 390295,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "$_SERVER['SCRIPT_FILENAME'] getcwd()"
},
{
"answer_id": 390356,
"author": "Eineki",
"author_id": 29125,
"a... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390276",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27610/"
] |
390,278 | <p>I'm setting up a new PC and I installed my project to work with. It is a .NET Remoting 2.0 application that uses the ASP.NET development server to host the server side while developing. I'm getting the following error when I make requests to the server:</p>
<p>"The remote server returned an error: (403) Forbidden. "</p>
<p>I've checked the credentials being passed in and everything seems to be correct. The call is all local to my dev box and to top it off. The code hasnt' changed and all of my colleagues are working fine. Any ideas?</p>
| [
{
"answer_id": 390318,
"author": "NotMe",
"author_id": 2424,
"author_profile": "https://Stackoverflow.com/users/2424",
"pm_score": 2,
"selected": false,
"text": "403 - Forbidden. IIS defines several different 403 errors that indicate a more specific cause of the error:\n• 403.1 - Execu... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31017/"
] |
390,284 | <p>Using Flex 3 with the ColdFusion plugin, can I not write a standalone ColdFusion class which I can invoke from my flex website (mxml)?</p>
<p>Thanks</p>
| [
{
"answer_id": 400548,
"author": "Brett",
"author_id": 47581,
"author_profile": "https://Stackoverflow.com/users/47581",
"pm_score": 2,
"selected": false,
"text": "<mx:Script>\n <![CDATA[\n private function callMethod():void\n {\n ro.MethodName;\n } \n\n private funct... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/32484/"
] |
390,286 | <p>I am trying to write a generic Parse method that converts and returns a strongly typed value from a NamedValueCollection. I tried two methods but both of these methods are going through boxing and unboxing to get the value. Does anyone know a way to avoid the boxing? If you saw this in production would you not like it, how bad is it for performance?</p>
<p>Usuage:</p>
<pre><code>var id = Request.QueryString.Parse<int>("id");
</code></pre>
<p>Attempt #1:</p>
<pre><code>public static T Parse<T>(this NameValueCollection col, string key)
{
string value = col[key];
if (string.IsNullOrEmpty(value))
return default(T);
if (typeof(T) == typeof(int))
{
//return int.Parse(value); // cannot convert int to T
//return (T)int.Parse(value); // cannot convert int to T
return (T)(object)int.Parse(value); // works but boxes
}
if (typeof(T) == typeof(long))
{
return (T)(object)long.Parse(value); // works but boxes
}
...
return default(T);
}
</code></pre>
<p>Attempt #2 (using reflection):</p>
<pre><code>public static T Parse<T>(this NameValueCollection col, string key)
{
string value = col[key];
if (string.IsNullOrEmpty(value))
return default(T);
try
{
var parseMethod = typeof(T).GetMethod("Parse", new Type[] { typeof(string) });
if (parseMethod == null)
return default(T);
// still boxing because invoke returns an object
var parsedVal = parseMethod.Invoke(null, new object[] { value });
return (T)parsedVal;
}
// No Proper Parse Method found
catch(AmbiguousMatchException)
{
}
return default(T);
}
</code></pre>
| [
{
"answer_id": 390312,
"author": "Robert C. Barth",
"author_id": 9209,
"author_profile": "https://Stackoverflow.com/users/9209",
"pm_score": 5,
"selected": false,
"text": "public static T Parse<T>(this NameValueCollection col, string key)\n{\n return (T)Convert.ChangeType(col[key], type... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37881/"
] |
390,289 | <p>I just refactored some code that was in a different section of the class I was working on because it was a series of nested conditional operators (?:) that was made a ton clearer by a fairly simple switch statement (C#). </p>
<p>When will you touch code that isn't directly what you are working on to make it more clear? </p>
| [
{
"answer_id": 390302,
"author": "Piskvor left the building",
"author_id": 19746,
"author_profile": "https://Stackoverflow.com/users/19746",
"pm_score": 1,
"selected": false,
"text": "if($something) {\n load_data($something);\n} else {\n load_data($something);\n echo \"Loaded\";\n do... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13100/"
] |
390,307 | <p>What are the cons and pros of windows services vs scheduled tasks for running a program repeatedly (e.g. every two minutes)?</p>
| [
{
"answer_id": 1744714,
"author": "Rebecca",
"author_id": 119624,
"author_profile": "https://Stackoverflow.com/users/119624",
"pm_score": 7,
"selected": true,
"text": "protected override void OnStart (string args) {\n\n // Create worker thread; this will invoke the WorkerFunction\n /... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390307",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2133/"
] |
390,326 | <p>I have a base class with a virtual method, and multiple subclasses that override that method.</p>
<p>When I encounter one of those subclasses, I would like to call the overridden method, but without knowledge of the subclass. I can think of ugly ways to do this (check a value and cast it), but it seems like there should be an in-language way to do it. I want the List to contain multiple subclasses within the same list, otherwise obviously I could just make a List.</p>
<p>EDIT: Fixed the comment in the code that was wrong, which lead to the very appropriate first answer I got :) </p>
<p>For instance:</p>
<pre><code>Class Foo
{
public virtual printMe()
{
Console.Writeline("FOO");
}
}
Class Bar : Foo
{
public override printMe()
{
Console.Writeline("BAR");
}
}
List<Foo> list = new List<Foo>();
// then populate this list with various 'Bar' and other overriden Foos
foreach (Foo foo in list)
{
foo.printMe(); // prints FOO.. Would like it to print BAR
}
</code></pre>
| [
{
"answer_id": 390349,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 4,
"selected": true,
"text": "class Foo \n{\n public virtual void virtualPrintMe()\n {\n nonVirtualPrintMe();\n }\n\n public ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6054/"
] |
390,354 | <p>I am using .NET 2.0 and SQL Server 2005. For historical reasons, the app code is using SQLTransaction but some of the stored procedures are also using T-SQL begin/commit/rollback tran statements. The idea is that the DBTransaction can span many stored procedures, which each individual sproc controls what's happening in its scope - in effect these are nested transactions. </p>
<p>The old behavior of the code was that if any of the sprocs failed, application logic would also cause the outer SQLTransaction to also rollback. But now we want to change the logic so that, even if there is a failure, the outer transaction should continue executing the remaining sprocs in its sequence, then at the end, since we know there were failures, we rollback the entire SQLTransaction.</p>
<p>The problem is that, at least as it is presently coded, is that if any of the sprocs does a ROLLBACK, the outer SQLTransaction appears to lose its connection, so any subsequent attempt at reusing the transaction fail. Is there a way I can rollback in T-SQL but still maintain the outer SQLTransaction? I was thinking that maybe savepoints might be helpful here, but I don't understand them very well yet.</p>
<p>What complicates this situation is that there is not always an outer transaction, so I can't just remove the T-SQL rollbacks, ie. sometimes a sproc is executed on its own; sometimes in the context of a transaction.</p>
<p>Would switching to TransactionScope make things easier?</p>
<p>Thanks for any suggestions...Mike</p>
| [
{
"answer_id": 390349,
"author": "Daniel Earwicker",
"author_id": 27423,
"author_profile": "https://Stackoverflow.com/users/27423",
"pm_score": 4,
"selected": true,
"text": "class Foo \n{\n public virtual void virtualPrintMe()\n {\n nonVirtualPrintMe();\n }\n\n public ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48776/"
] |
390,362 | <p>I've got a sproc (MSSQL 2k5) that will take a variable for a LIKE claus like so:</p>
<pre><code>DECLARE @SearchLetter2 char(1)
SET @SearchLetter = 't'
SET @SearchLetter2 = @SearchLetter + '%'
SELECT *
FROM BrandNames
WHERE [Name] LIKE @SearchLetter2 and IsVisible = 1
--WHERE [Name] LIKE 't%' and IsVisible = 1
ORDER BY [Name]
</code></pre>
<p>Unfortunately, the line currently running throws a syntax error, while the commented where clause runs just fine. Can anyone help me get the un-commented line working?</p>
| [
{
"answer_id": 390404,
"author": "JB King",
"author_id": 8745,
"author_profile": "https://Stackoverflow.com/users/8745",
"pm_score": 3,
"selected": false,
"text": "declare @SearchLetter2 char(2)\ndeclare @SearchLetter char(1)\nSet @SearchLetter = 'A'\nSet @SearchLetter2 = @SearchLetter+'... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42568/"
] |
390,368 | <p>Is there a way to stop Google from indexing a site? <br /></p>
| [
{
"answer_id": 390379,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 8,
"selected": true,
"text": "User-agent: *\nDisallow: /\n"
},
{
"answer_id": 13203384,
"author": "user1586214",
"author_id": 1586214,
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1443363/"
] |
390,375 | <p>In PHP, if you define a class, and then instantiate an object of that class, it's possible to later arbitrarily add new members to that class. For example:</p>
<pre><code>class foo {
public $bar = 5;
}
$A = new foo;
$A->temp = 10;
</code></pre>
<p>However, I'd like the ability to make it impossible to add new members this way. Basically I want the class to ONLY have the members that are specified in its definition; if you try to set any other members, it fatally errors. The intent here is that I want to define a class as a very specific set of properties, and ensure that ONLY those properties exist in the class, so that the class contents are well-defined and cannot change later on (the values of each member can change, but not the members themselves).</p>
<p>I realize I can do this with the __set method, and simply have it fatal error if you try to set a member which doesn't already exist, but that's annoying to have to include in every class definition (although I could define each of my classes to extend a base class with that method, but that's also annoying). E.g.:</p>
<pre><code>class foo {
public $bar = 5;
private function __set($var, $val) {
trigger_error("Cannot dynamically add members to a class", E_USER_ERROR);
}
}
</code></pre>
<p>Is there any other (preferably more convenient) way to do this? Aside from modifying PHP itself to disallow this behavior?</p>
| [
{
"answer_id": 390434,
"author": "Kornel",
"author_id": 27009,
"author_profile": "https://Stackoverflow.com/users/27009",
"pm_score": 3,
"selected": true,
"text": "__set"
}
] | 2008/12/23 | [
"https://Stackoverflow.com/questions/390375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20903/"
] |
390,381 | <p>I am writing a small applescript which retrieves all "unread" messages in the viewer and loops them.</p>
<p>I have two goals to complete:</p>
<ol>
<li><p>I need to get the subject of each message and perform a regular expression to see if it's suitable for step 2 (ex: get emails with subject {.*})</p></li>
<li><p>I need to open each message on a separate window and after 4 seconds, I need to close that window and proceed with the next message</p></li>
</ol>
<p>Do you know how to do these?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 390549,
"author": "e.James",
"author_id": 33686,
"author_profile": "https://Stackoverflow.com/users/33686",
"pm_score": 2,
"selected": false,
"text": "do shell script \non run\n tell application \"Mail\"\n set myInbox to mailbox \"INBOX\" of account 1\n se... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390381",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48780/"
] |
390,385 | <p>If I create a file:</p>
<p>test.cpp:</p>
<pre><code>void f(double **a) {
}
int main() {
double var[4][2];
f(var);
}
</code></pre>
<p>And then run:
g++ test.cpp -o test</p>
<p>I get</p>
<pre><code>test.cpp: In function `int main()':
test.cpp:8: error: cannot convert `double (*)[2]' to `double**' for argument `1'
to `void f(double**)'
</code></pre>
<p>Why is that I can't do this? </p>
<p>Isn't double var[4][2] is the same as doing double **var and then allocating the memory?</p>
| [
{
"answer_id": 390417,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author_profile": "https://Stackoverflow.com/users/34509",
"pm_score": 4,
"selected": false,
"text": "// same as void f(double (*a)[2]) {\nvoid f(double a[][2]) { \n\n}\n\nint main() {\n // note. this is no... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390385",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48782/"
] |
390,389 | <p>I only have 1 line of code, and this is:</p>
<pre><code>pcrecpp::RE re("abc");
</code></pre>
<p>inside a function <code>OnBnClickedButtonGo()</code>. And this function fails in Release mode, but it works OK in debug mode.</p>
<p>(I am using Visual Studio 8 on Windows XP.)</p>
<p>The error message is:</p>
<pre><code>A buffer overrun has occurred in testregex.exe which has corrupted the program's
internal state. Press Break to debug the program or Continue to terminate
the program.
For more details please see Help topic 'How to debug Buffer Overrun Issues'.
</code></pre>
<p>I suspect it is its destructor, which is invisible and implied... but I don't know really.</p>
<p>PS: I am statically linking to the PCRE lib version 7.8.
PS2: Not very relevant, but may help some people who have trouble linking to the PCRE library (it took me hours to sort it out): include the line <code>#define PCRE_STATIC</code>.</p>
| [
{
"answer_id": 2146963,
"author": "matheszabi",
"author_id": 260074,
"author_profile": "https://Stackoverflow.com/users/260074",
"pm_score": 2,
"selected": false,
"text": "native.dll mixed.dll typedef void ( *FunctionOnStartSend)();\n typedef void (__stdcall *FunctionOnStartSend)(); \n"
... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48778/"
] |
390,391 | <p>I am doing some significant refactoring and feature-adding on a project, and have just broken backwards compatibility with my data. I did it by creating a bunch of subclasses from the class that I used to house my data in, and loading in old serialized objects no longer works..</p>
<p>What kind of pre-engineering or strategies do you employ to avoid these types of situations? Should I forget about serialization completely? It seems particularly prone to these sorts of problems.</p>
| [
{
"answer_id": 390423,
"author": "dacracot",
"author_id": 13930,
"author_profile": "https://Stackoverflow.com/users/13930",
"pm_score": 2,
"selected": true,
"text": "<root>\n <something one=\"1\" two=\"2\"/>\n</root>\n <root>\n <something one=\"1\" two=\"2\" three=\"3\"/>\n <something... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6054/"
] |
390,409 | <p>So far I've found it impossible to produce usable tracebacks when Mako templates aren't coded correctly.</p>
<p>Is there any way to debug templates besides iterating for every line of code?</p>
| [
{
"answer_id": 536087,
"author": "Kenan Banks",
"author_id": 43089,
"author_profile": "https://Stackoverflow.com/users/43089",
"pm_score": 7,
"selected": true,
"text": "from mako import exceptions\n\ntry:\n template = lookup.get_template(uri)\n print template.render()\nexcept:\n ... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/853/"
] |
390,420 | <p>Hi I need to create a query in MSAccess 2003 through code (a.k.a. VB) -- how can I accomplish this?</p>
| [
{
"answer_id": 390439,
"author": "Fionnuala",
"author_id": 2548,
"author_profile": "https://Stackoverflow.com/users/2548",
"pm_score": 6,
"selected": true,
"text": "strSQL=\"SELECT * FROM tblT WHERE ID =\" & Forms!Form1!txtID \n\nSet qdf=CurrentDB.CreateQueryDef(\"NewQuery\",strSQL)\nDoC... | 2008/12/23 | [
"https://Stackoverflow.com/questions/390420",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/428190/"
] |
390,448 | <p>I have a single windows shell command I'd like to run (via EXEC master..xp_cmdshell) once for each row in a table. I'm using information from various fields to build the command output.</p>
<p>I'm relativity new to writing T-SQL programs (as opposed to individual queries) and can't quite get my head around the syntax for this, or if it's even possible/recommended. </p>
<p>I tried creating a single column table variable, and then populating each row with the command I want to run. I'm stifled at how to iterate over this table variable and actually run the commands. Googling around has proven unhelpful.</p>
<p>Thanks in advance for any help!</p>
| [
{
"answer_id": 390489,
"author": "jrcs3",
"author_id": 3819,
"author_profile": "https://Stackoverflow.com/users/3819",
"pm_score": 4,
"selected": true,
"text": "USE Northwind\n\nDECLARE @name VARCHAR(32)\nDECLARE @command VARCHAR(100)\n\nDECLARE shell_cursor CURSOR FOR \nSELECT LastName ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4668/"
] |
390,475 | <p>I have a problem that just started happening after I reinstalled my website's server.</p>
<p>In the past I could do do this:</p>
<p>Code:</p>
<pre><code><%
set msgSet = conn.execute("select * from base_scroller where scroller_num = 1"
%>
</code></pre>
<p>check if it's not empty or anything else</p>
<p>Code:</p>
<pre><code><% if msgSet("scroller_name") <> "" then %>
</code></pre>
<p>and if it is i could do anything with it (like showing it's value)</p>
<p>Code:</p>
<pre><code><%= msgSet("scroller_name") %>
<% end if %>
</code></pre>
<p>Now I can't do this, the "if" test doesn't work with the "msgSet("scroller_name")" and I have to redifine it first in another variable</p>
<p>Code:</p>
<pre><code><% scrollername = msgSet("scroller_name") %>
</code></pre>
<p>then and only then I can do tests on it...</p>
<p>Code:</p>
<pre><code><% if scrollername <> "" then %>
</code></pre>
<p>and show it too.</p>
<pre><code><%= scrollername %>
<% end if %>
</code></pre>
<p>I would just like to get back the option to do the operations on the mysql recordset variables like b4....</p>
<p>Has someone come across this problem ? what has changed, is it a falty mysql varsion or something ?</p>
<p>Thank you guys.</p>
| [
{
"answer_id": 390529,
"author": "AnonJr",
"author_id": 25163,
"author_profile": "https://Stackoverflow.com/users/25163",
"pm_score": 0,
"selected": false,
"text": " <%= cStr(msgSet(\"scroller_name\")) %>\n"
},
{
"answer_id": 395249,
"author": "Amadiere",
"author_id": 7... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
390,481 | <p>I often use this code pattern:</p>
<pre><code>while(true) {
//do something
if(<some condition>) {
break;
}
}
</code></pre>
<p>Another programmer told me that this was bad practice and that I should replace it with the more standard:</p>
<pre><code>while(!<some condition>) {
//do something
}
</code></pre>
<p>His reasoning was that you could "forget the break" too easily and have an endless loop. I told him that in the second example you could just as easily put in a condition which never returned true and so just as easily have an endless loop, so both are equally valid practices.</p>
<p>Further, I often prefer the former as it makes the code easier to read when you have multiple break points, i.e. multiple conditions which get out of the loop.</p>
<p>Can anyone enrichen this argument by adding evidence for one side or the other?</p>
| [
{
"answer_id": 390498,
"author": "Andrew G. Johnson",
"author_id": 428190,
"author_profile": "https://Stackoverflow.com/users/428190",
"pm_score": 7,
"selected": true,
"text": "while (true) goto do {\n //do something\n} while (!something);\n"
},
{
"answer_id": 390523,
"autho... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
390,491 | <p>I want to add a "Select One" option to a drop down list bound to a <code>List<T></code>. </p>
<p>Once I query for the <code>List<T></code>, how do I add my initial <code>Item</code>, not part of the data source, as the FIRST element in that <code>List<T></code> ? I have:</p>
<pre><code>// populate ti from data
List<MyTypeItem> ti = MyTypeItem.GetTypeItems();
//create initial entry
MyTypeItem initialItem = new MyTypeItem();
initialItem.TypeItem = "Select One";
initialItem.TypeItemID = 0;
ti.Add(initialItem) <!-- want this at the TOP!
// then
DropDownList1.DataSource = ti;
</code></pre>
| [
{
"answer_id": 390501,
"author": "x0n",
"author_id": 6920,
"author_profile": "https://Stackoverflow.com/users/6920",
"pm_score": 5,
"selected": false,
"text": "<asp:DropDownList ID=\"ddl\" runat=\"server\" AppendDataBoundItems=\"true\">\n <asp:ListItem Value=\"0\" Text=\"Please choose... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390491",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35615/"
] |
390,512 | <p>I want to add a new time-field to a an existing MySQL-table that is formated like this "MM:SS". The field is supposed to hold duration-data. What is the correct MySQL syntax to do this? Couldn't find anything that covers this on the MySQL-site.</p>
| [
{
"answer_id": 390501,
"author": "x0n",
"author_id": 6920,
"author_profile": "https://Stackoverflow.com/users/6920",
"pm_score": 5,
"selected": false,
"text": "<asp:DropDownList ID=\"ddl\" runat=\"server\" AppendDataBoundItems=\"true\">\n <asp:ListItem Value=\"0\" Text=\"Please choose... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390512",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24218/"
] |
390,534 | <p>Simply put, I have a table with, among other things, a column for timestamps. I want to get the row with the most recent (i.e. greatest value) timestamp. Currently I'm doing this:</p>
<pre><code>SELECT * FROM table ORDER BY timestamp DESC LIMIT 1
</code></pre>
<p>But I'd much rather do something like this:</p>
<pre><code>SELECT * FROM table WHERE timestamp=max(timestamp)
</code></pre>
<p>However, SQLite rejects this query:</p>
<pre><code>SQL error: misuse of aggregate function max()
</code></pre>
<p>The <a href="http://www.sqlite.org/lang_expr.html" rel="noreferrer">documentation</a> confirms this behavior (bottom of page):</p>
<blockquote>
<p>Aggregate functions may only be used in a SELECT statement.</p>
</blockquote>
<p>My question is: is it possible to write a query to get the row with the greatest timestamp without ordering the select and limiting the number of returned rows to 1? This seems like it should be possible, but I guess my SQL-fu isn't up to snuff.</p>
| [
{
"answer_id": 390542,
"author": "SquareCog",
"author_id": 15962,
"author_profile": "https://Stackoverflow.com/users/15962",
"pm_score": 5,
"selected": true,
"text": "SELECT * from foo where timestamp = (select max(timestamp) from foo)\n SELECT * from foo where timestamp in (select max(t... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/658/"
] |
390,554 | <p>I'm trying to install SQL Server 2005 Express SP3 on two of my machines. When I try to do this I get this error message: "None of the selected features can be installed or upgraded. Setup cannot proceed since no effective change is being made to the machine. To continue, click Back and then select features to install." And of course it won't let me go any further. When I get to the "Existing components" screen (which is before the error message), the only item that's listed is "SQL Server Database Services 9.2.3042.00" and it's grayed out (can't be checked). I'm assuming this is the "none of the selected features" it's talking about in the error message.</p>
<p>I tried this on two different computers, both running Windows Server 2003. Both also have MSDE (SQL server 2000), not sure if this matters. The reported SQL 2005 version is 9.0.3068 for both machines. The link I used to download the service pack is:</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=3181842a-4090-4431-acdd-9a1c832e65a6&displaylang=en" rel="nofollow noreferrer">http://www.microsoft.com/downloads/details.aspx?FamilyID=3181842a-4090-4431-acdd-9a1c832e65a6&displaylang=en</a></p>
<p>Any ideas? Thanks.</p>
<p>EDIT:</p>
<p>If I click on details, this is what I get:</p>
<p>Name: Microsoft SQL Server 2005 (SQLEXPRESS)
Reason: Your upgrade is blocked. For more information about upgrade support, see the "Version and Edition Upgrades" and "Hardware and Software Requirements" topics in SQL Server 2005 Setup Help or SQL Server 2005 Books Online.</p>
<p>Edition check:
Your upgrade is blocked because of edition upgrade rules. For more information about edition upgrades, see the Version and Edition Upgrades topic in SQL Server 2005 Setup Help or SQL Server 2005 Books Online.</p>
| [
{
"answer_id": 390542,
"author": "SquareCog",
"author_id": 15962,
"author_profile": "https://Stackoverflow.com/users/15962",
"pm_score": 5,
"selected": true,
"text": "SELECT * from foo where timestamp = (select max(timestamp) from foo)\n SELECT * from foo where timestamp in (select max(t... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29821/"
] |
390,565 | <p>I have been testing out the <code>yield return</code> statement with some of the code I have been writing. I have two methods:</p>
<pre><code>public static IEnumerable<String> MyYieldCollection {
get
{
wrapper.RunCommand("Fetch First From Water_Mains");
for (int row = 0; row < tabinfo.GetNumberOfRows() ; row++) //GetNumberOfRows
//will return 1000+ most of the time.
{
yield return wrapper.Evaluate("Water_Mains.col1");
wrapper.RunCommand("Fetch Next From Water_Mains");
}
}
}
</code></pre>
<p>and </p>
<pre><code>public static List<String> MyListCollection
{
get
{
List<String> innerlist = new List<String>();
wrapper.RunCommand("Fetch First From Water_Mains");
for (int row = 0; row < tabinfo.GetNumberOfRows(); row++)
{
innerlist.Add(wrapper.Evaluate("Water_Mains.col1"));
wrapper.RunCommand("Fetch Next From Water_Mains");
}
return innerlist;
}
}
</code></pre>
<p>then I use a <code>foreach</code> loop over each collection:</p>
<pre><code> foreach (var item in MyYieldCollection) //Same thing for MyListCollection.
{
Console.WriteLine(item);
}
</code></pre>
<p>The funny thing is for some reason I seem to be able to loop over and print out the full <code>MyListCollection</code> faster then the MyYieldCollection. </p>
<p>Results:</p>
<ul>
<li>MyYieldCollection -> 2062</li>
<li>MyListCollection -> 1847</li>
</ul>
<p>I can't really see a reason for this, am I missing something or is this normal?</p>
| [
{
"answer_id": 390635,
"author": "Nick",
"author_id": 44741,
"author_profile": "https://Stackoverflow.com/users/44741",
"pm_score": 1,
"selected": false,
"text": "public IEnumerable<int> YieldInts()\n{\n for (int i = 0; i < 1000; i++)\n {\n Thread.Sleep(1000) // or do some o... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6335/"
] |
390,575 | <p>I am fairly new to PHP. What is the best way to control access to a class throughout a PHP application and where is the best place to store these classes that will need to be accessed throughout the entire application? Example; I have a user class that is created on during the login process, but each time the page post it appears that the object is reinitialized.</p>
<p>I have tried to set property IsLoggedIn and then check that variable each time before creating the object as new again, but this doesn't seem work. I have also tried to use the isSet function in PHP to see if the class variable already exists </p>
| [
{
"answer_id": 390593,
"author": "UnkwnTech",
"author_id": 115,
"author_profile": "https://Stackoverflow.com/users/115",
"pm_score": 2,
"selected": false,
"text": "$username //username from db\n$name //name from db\n$_SESSION['username'] = $username;\n$_SESSION['name'] = $name;\n $_SESSI... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
390,578 | <p>Take the following class as an example:</p>
<pre><code>class Sometype
{
int someValue;
public Sometype(int someValue)
{
this.someValue = someValue;
}
}
</code></pre>
<p>I then want to create an instance of this type using reflection:</p>
<pre><code>Type t = typeof(Sometype);
object o = Activator.CreateInstance(t);
</code></pre>
<p>Normally this will work, however because <code>SomeType</code> has not defined a parameterless constructor, the call to <code>Activator.CreateInstance</code> will throw an exception of type <code>MissingMethodException</code> with the message "<em>No parameterless constructor defined for this object.</em>" Is there an alternative way to still create an instance of this type? It'd be kinda sucky to add parameterless constructors to all my classes.</p>
| [
{
"answer_id": 390596,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 8,
"selected": true,
"text": "FormatterServices.GetUninitializedObject() using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusin... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37472/"
] |
390,584 | <p>I have a question regarding a data binding(of multiple properties) for custom DataGridViewColumn.
Here is a schema of what controls that I have, and I need to make it bindable with DataGridView datasource. Any ideas or a link to an article discussing the matter? </p>
<p><strong>Controls</strong></p>
<ul>
<li>Graph Control(custom): Displayed in
the custrom DataGridView column. Has
properties like "Start Date",
"EndDate", Windows Chart control,
which is itself, bindable, etc. </li>
<li>Custom cell(DataGridViewCustomCell inherits
from DataGridViewCell) that holds
the Graph control and processes some
events(OnEnter event, for example,
passes the focus to the custom Graph
column for drag-n-drop type of
events, etc.)</li>
<li>Custom column(DataGridViewCustomColumn
inherits from DataGridViewColumn)
that defined the cell template type:
CellTemplate = new
DataGridViewCustomCell(); and also a
primary choice for data binding</li>
</ul>
<p><strong>Data Structure:</strong> </p>
<ul>
<li>Main table to be displayed in other DataGridView Columns</li>
<li>Graph table - related to the Main table via parent-child relationship. Holds graph data</li>
<li>Chart table related to the graph table via parent-child relationship. Holds data for the win-form chart, which is a part of my Graph control.</li>
</ul>
<p>So far I cannot even bind data from the Graph table to by Graph control or Graph-holding Column/Cell. </p>
| [
{
"answer_id": 485606,
"author": "Vera",
"author_id": 48802,
"author_profile": "https://Stackoverflow.com/users/48802",
"pm_score": 2,
"selected": false,
"text": "public partial class MyCell : DataGridViewCell \n {\n protected override void Paint(...)\n {...} // draws control\n... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48802/"
] |
390,595 | <p>I have an web application where I have a requirement to encrypt and store the connection string in the web.config. </p>
<p>What is the best way to retrieve this and use this connection string with IBATIS.NET instead of storing the connection string in the SqlMap.config?</p>
| [
{
"answer_id": 410215,
"author": "Nicholas Piasecki",
"author_id": 32187,
"author_profile": "https://Stackoverflow.com/users/32187",
"pm_score": 3,
"selected": true,
"text": "\n <database>\n <provider name=\"sqlServer2005\" />\n <dataSource name=\"TheDB\" connectionString=\"$... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10830/"
] |
390,602 | <p><strong>Question:</strong> How could I find out the M-x equivalent commands for doing GUI-based operations in Emacs, in those cases where my Emacs-variant uses OS-specific desktop functionality?</p>
<p><strong>Background:</strong> Conventional understanding states that everything in Emacs is a command, and that commands can be invoked via M-x, as long as you know the name of the command. Assuming this statement is correct, what is the way to find the name of the commands used to trigger the "GUI-style" menus in a "desktop" based Emacs variant?</p>
<p>For example, if I were to mouse-select the File menu to open a file, the OS-specific "GUI" style file-open dialog pops up, waiting for my input.</p>
<p>How could I find out the M-x equivalent command for doing the exact same thing?</p>
<p>I <em>thought</em> that describe-key would tell me what I needed to know, but it's indication to use:</p>
<pre><code>M-x menu-find-file-existing
</code></pre>
<p>doesn't invoke the "GUI" style file-open dialog. Instead, it uses the Emacs internal non-GUI-OS-neutral variant.</p>
| [
{
"answer_id": 390617,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": 2,
"selected": false,
"text": "C-h k menu-bar-el (defun menu-find-file-existing ()\n \"Edit the existing file FILENAME.\"\n (interactive)\n (le... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42223/"
] |
390,604 | <p>This is one of those little detail (and possibly religious) questions. Let's assume we're constructing a REST architecture, and for definiteness lets assume the service needs three parameters, <em>x</em>, <em>y</em>, and <em>z</em>. Reading the various works about REST, it would seem that this should be expressed as a URI like </p>
<blockquote>
<p><a href="http://myservice.example.com/service/" rel="nofollow noreferrer">http://myservice.example.com/service/</a> <em>x</em> / <em>y</em> / <em>z</em></p>
</blockquote>
<p>Having written a lot of CGIs in the past, it seems about as natural to express this </p>
<blockquote>
<p><a href="http://myservice.example.com/service?x=val,y=val,z=val" rel="nofollow noreferrer">http://myservice.example.com/service?x=val,y=val,z=val</a></p>
</blockquote>
<p>Is there any particular reason to prefer the all-slashes form?</p>
| [
{
"answer_id": 390616,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 4,
"selected": true,
"text": "http://myservice.example.com/resource/x/y/z/ /x/y/z/ http://myservice.example.com/service?x=val,y=val,z=val service"
},
... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390604",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/35092/"
] |
390,615 | <p>Is this a good way to implement a Finally-like behavior in standard C++?
(Without special pointers)</p>
<pre><code>class Exception : public Exception
{ public: virtual bool isException() { return true; } };
class NoException : public Exception
{ public: bool isException() { return false; } };
Object *myObject = 0;
try
{
// OBJECT CREATION AND PROCESSING
try
{
myObject = new Object();
// Do something with myObject.
}
// EXCEPTION HANDLING
catch (Exception &e)
{
// When there is an excepion, handle or throw,
// else NoException will be thrown.
}
throw NoException();
}
// CLEAN UP
catch (Exception &e)
{
delete myObject;
if (e.isException()) throw e;
}
</code></pre>
<ol>
<li>No exception thrown by object -> NoException -> Object cleaned up</li>
<li>Exception thrown by object -> Handled -> NoException -> Object cleaned up</li>
<li>Exception thrown by object -> Thrown -> Exception -> Object cleaned up -> Thrown</li>
</ol>
| [
{
"answer_id": 390623,
"author": "David Norman",
"author_id": 34502,
"author_profile": "https://Stackoverflow.com/users/34502",
"pm_score": 6,
"selected": true,
"text": "try {\n // Some work\n}\nfinally {\n // Cleanup code\n}\n class Cleanup\n{\npublic:\n ~Cleanup()\n {\n ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/47064/"
] |
390,632 | <p>Suppose I have the following class:</p>
<pre><code>public class TestBase
{
public bool runMethod1 { get; set; }
public void BaseMethod()
{
if (runMethod1)
ChildMethod1();
else
ChildMethod2();
}
protected abstract void ChildMethod1();
protected abstract void ChildMethod2();
}
</code></pre>
<p>I also have the class</p>
<pre><code>public class ChildTest : TestBase
{
protected override void ChildMethod1()
{
//do something
}
protected override void ChildMethod2()
{
//do something completely different
}
}
</code></pre>
<p>I'm using Moq, and I'd like to write a test that verifies ChildMethod1() is being called when I call BaseMethod() and runMethod1 is true. Is it possible to create an implemention of TestBase with Moq, call BaseMethod() and verify that ChildMethod was called on the Moq implementation?</p>
<pre><code>[Test]
public BaseMethod_should_call_correct_child_method()
{
TestBase testBase;
//todo: get a mock of TestBase into testBase variable
testBase.runMethod1 = true;
testBase.BaseMethod();
//todo: verify that ChildMethod1() was called
}
</code></pre>
| [
{
"answer_id": 392023,
"author": "Lance Fisher",
"author_id": 571,
"author_profile": "https://Stackoverflow.com/users/571",
"pm_score": 2,
"selected": false,
"text": "[Test]\npublic BaseMethod_should_call_correct_child_method()\n{\n //strict mocks will make sure all expectations are met... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/571/"
] |
390,641 | <p>In erlang, there are bitwise operations to operate on integers, for example:</p>
<pre><code>1> 127 bsl 1.
254
</code></pre>
<p>there is also the ability to pack integers into a sequence of bytes</p>
<pre><code><< 16#7F, 16#FF >></code></pre>
<p>is it possible, or are there any operators or BIFs that can perform bitwise operations (eg AND, OR, XOR, SHL, SHR) on binary packed data?</p>
<p>for example (if bsl worked on binary packages - which it does not):</p>
<pre><code>1> << 16#7F, 16#FF >> bsl 1.
<< 255, 254 >></code></pre>
| [
{
"answer_id": 390714,
"author": "Mike Hamer",
"author_id": 42050,
"author_profile": "https://Stackoverflow.com/users/42050",
"pm_score": 0,
"selected": false,
"text": "1> Bits = <<16#0FFFFFFF:(4*8)>>.\n<<15,255,255,255>>\n\n2> size(Bits).\n4\n\n3> Size=size(Bits)*8.\n32\n\n4> <<Num:Size... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390641",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42050/"
] |
390,648 | <p>What is the difference between using ToString and ToString() in VB.NET?</p>
| [
{
"answer_id": 30263308,
"author": "Grantly",
"author_id": 1491278,
"author_profile": "https://Stackoverflow.com/users/1491278",
"pm_score": 1,
"selected": false,
"text": "Dim sbrBuilder as New StringBuilder\n\n...\n\nsbrBuilder.ToString()\nreturn sbrBuilder.ToString\n"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/390648",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48581/"
] |
390,693 | <p>I've been fiddling with ASP.NET MVC since the CTP, and I like a lot of things they did, but there are things I just don't get.</p>
<p>For example, I downloaded beta1, and I'm putting together a little personal site/resume/blog with it. Here is a snippet from the ViewSinglePost view:</p>
<pre><code> <%
// Display the "Next and Previous" links
if (ViewData.Model.PreviousPost != null || ViewData.Model.NextPost != null)
{
%> <div> <%
if (ViewData.Model.PreviousPost != null)
{
%> <span style="float: left;"> <%
Response.Write(Html.ActionLink("<< " + ViewData.Model.PreviousPost.Subject, "view", new { id = ViewData.Model.PreviousPost.Id }));
%> </span> <%
}
if (ViewData.Model.NextPost != null)
{
%> <span style="float: right;"> <%
Response.Write(Html.ActionLink(ViewData.Model.NextPost.Subject + " >>", "view", new { id = ViewData.Model.NextPost.Id }));
%> </span> <%
}
%>
<div style="clear: both;" />
</div> <%
}
%>
</code></pre>
<p>Disgusting! <strong>(Also note that the HTML there is temporary placeholder HTML, I'll make an actual design once the functionality is working)</strong>.</p>
<p>Am I doing something wrong? Because I spent many dark days in classic ASP, and this tag soup reminds me strongly of it.</p>
<p>Everyone preaches how you can do cleaner HTML. Guess, what? 1% of all people look at the outputted HTML. To me, I don't care if Webforms messes up my indentation in the rendered HTML, as long as I have code that is easy to maintain...This is not!</p>
<p>So, convert me, a die hard webforms guy, why I should give up my nicely formed ASPX pages for this?</p>
<p><strong>Edit:</strong> Bolded the "temp Html/css" line so people would stfu about it.</p>
| [
{
"answer_id": 390747,
"author": "tvanfosson",
"author_id": 12950,
"author_profile": "https://Stackoverflow.com/users/12950",
"pm_score": 4,
"selected": false,
"text": "<%= %> <%\n var PreviousPost = ViewData.Model.PreviousPost;\n var NextPost = ViewData.Model.NextPost;\n\n // ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1965/"
] |
390,702 | <p>I have to following code:</p>
<p><a href="http://www.nomorepasting.com/getpaste.php?pasteid=22987" rel="nofollow noreferrer">http://www.nomorepasting.com/getpaste.php?pasteid=22987</a></p>
<p>If <code>PHPSESSID</code> is not already in the table the <code>REPLACE INTO</code> query works just fine, however if <code>PHPSESSID</code> exists the call to execute succeeds but sqlstate is set to 'HY000' which isn't very helpful and <code>$_mysqli_session_write->errno</code> and
<code>$_mysqli_session_write->error</code> are both empty and the data column doesn't update.</p>
<p>I am fairly certain that the problem is in my script somewhere, as manually executing the <code>REPLACE INTO</code> from mysql works fine regardless of whether of not the <code>PHPSESSID</code> is in the table.</p>
| [
{
"answer_id": 391085,
"author": "Zoredache",
"author_id": 20267,
"author_profile": "https://Stackoverflow.com/users/20267",
"pm_score": 1,
"selected": false,
"text": "REPLACE INTO session (phpsessid, data) VALUES(?, ?)\n mysql> select count (*);\nERROR 1064 (42000): You have an error in... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13834/"
] |
390,703 | <p>While looking at online code samples, I have sometimes come across an assignment of a String constant to a String object via the use of the new operator.</p>
<p>For example:</p>
<pre><code>String s;
...
s = new String("Hello World");
</code></pre>
<p>This, of course, compared to</p>
<pre><code>s = "Hello World";
</code></pre>
<p>I'm not familiar with this syntax and have no idea what the purpose or effect would be.
Since String constants typically get stored in the constant pool and then in whatever representation the JVM has for dealing with String constants, would anything even be allocated on the heap?</p>
| [
{
"answer_id": 390722,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": -1,
"selected": false,
"text": "int q;\nfor(q=0;q<MAX;q++){\n String s;\n int ix;\n // other stuff\n s = new String(\"Hello, there!\")... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23072/"
] |
390,723 | <p>I am trying to install an app inside of another web app. I have my .aspx pages and some code that I was putting into the main app's app_code folder. I've added my own web.config file for my connection string and such but I think there's a conflict. So my question is a two parter. First, what is the best way to install an app inside of another app, i.e should I use the main apps app_code folder or add my own, and second, would there be a conflict with the two web.config files. I was under the impression that the files pulled from the most specific web.config file. It appears there is a problem with my security and I am unable to access my file. I was attributing this to the two web.config files,</p>
<p>thanks.</p>
| [
{
"answer_id": 390722,
"author": "Charlie Martin",
"author_id": 35092,
"author_profile": "https://Stackoverflow.com/users/35092",
"pm_score": -1,
"selected": false,
"text": "int q;\nfor(q=0;q<MAX;q++){\n String s;\n int ix;\n // other stuff\n s = new String(\"Hello, there!\")... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/45429/"
] |
390,727 | <p>I'm just finishing a web page for our sales guy to quickly go through a list of contacts. </p>
<p>Is it possible to initiate a call from our Vonage line via a Hyperlink?</p>
<p>They offer an application called "Click-2-Call" but I hope it's possible to initiate it using only a Hyperlink.</p>
| [
{
"answer_id": 390791,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 2,
"selected": true,
"text": "Call <a href=\"phone: 123-456-7890\">123-456-7890</a>\n"
}
] | 2008/12/24 | [
"https://Stackoverflow.com/questions/390727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3747/"
] |
390,730 | <p>I'm quite new to database design and have some questions about best practices and would really like to learn.
I am designing a database schema, I have a good idea of the requirements and now its a matter of getting it into black and white.</p>
<p>In this pseudo-database-layout, I have a table of customers, table of orders and table of products.</p>
<p><strong>TBL_PRODUCTS:</strong><BR>
ID<BR>
Description<BR>
Details<BR></p>
<p><strong>TBL_CUSTOMER:</strong><BR>
ID<BR>
Name<BR>
Address<BR></p>
<p><strong>TBL_ORDER:</strong><BR>
ID<BR>
TBL_CUSTOMER.ID<BR>
prod1<BR>
prod2<BR>
prod3<BR>
etc<BR></p>
<p>Each 'order' has only one customer, but can have any number of 'products'.</p>
<p>The problem is, in my case, the products for a given order can be any amount (hundreds for a single order) on top of that, each product for an order needs more than just a 'quantity' but can have values that span pages of text for a specific product for a specific order.
My question is, how can I store that information?</p>
<p>Assuming I can't store a variable length array as single field value, the other option is to have a string that is delimited somehow and split by code in the application.
An order could have say 100 products, each product having either only a small int, or 5000 characters or free text (or anything in between), unique only to that order.</p>
<p>On top of that, each order must have it's own audit trail as many things can happen to it throughout it's lifetime.
An audit trail would contain the usual information - user, time/date, action and can be any length.
Would I store an audit trail for a specific order in it's own table (as they could become quite lengthy) created as the order is created?</p>
<p>Are there any places where I could learn more about techniques for database design?</p>
| [
{
"answer_id": 390745,
"author": "dtc",
"author_id": 32892,
"author_profile": "https://Stackoverflow.com/users/32892",
"pm_score": 3,
"selected": false,
"text": "TBL_ORDER:\nID\nTBL_CUSTOMER.ID\n\nTBL_ORDER_ITEM:\nID\nTBL_ORDER.ID\nTBL_PRODUCTS.ID\nQuantity\nUniqueDetails\n TBL_ORDER_AUD... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/29820/"
] |
390,736 | <p>How do you open a file from a java application when you do not know which application the file is associated with. Also, because I'm using Java, I'd prefer a platform independent solution.</p>
| [
{
"answer_id": 390779,
"author": "RealHowTo",
"author_id": 25122,
"author_profile": "https://Stackoverflow.com/users/25122",
"pm_score": 6,
"selected": true,
"text": "java.awt.Desktop public static void open(File document) throws IOException {\n Desktop dt = Desktop.getDesktop();\n ... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/36858/"
] |
390,748 | <p>let's say that I have an XML file containing this :</p>
<pre><code><description><![CDATA[
<h2>lorem ipsum</h2>
<p>some text</p>
]]></description>
</code></pre>
<p>that I want to get and parse in ActionScript 2 as HTML text, and setting some CSS before displaying it. Problem is, Flash takes those whitespaces (line feed and tab) and display it as it is.</p>
<pre><code><some whitespace here>
lorem ipsum
some text
</code></pre>
<p>where the output I want is</p>
<pre><code>lorem ipsum
some text
</code></pre>
<p>I know that I could remove the whitespaces directly from the XML file (the Flash developer at my workplace also suggests this. I guess that he doesn't have any idea on how to do this [sigh]). But by doing this, it would be difficult to read the section in the XML file, especially when lots of tags are involved and that makes editing more difficult.</p>
<p>So now, I'm looking for a way to strip those whitespaces in ActionScript. I've tried to use PHP's <code>str_replace</code> equivalent (got it from <a href="http://snipplr.com/view/3369/strreplace/" rel="nofollow noreferrer">here</a>). But what should I use as a needle (string to search) ? (I've tried to put in <code>"\t"</code> and <code>"\r"</code>, don't seem to be able to detect those whitespaces).</p>
<p>edit :</p>
<p>now that I've tried to throw in <code>newline</code> as a needle, it works (meaning that newline successfully got stripped).</p>
<pre><code>mystring = str_replace(newline, '', mystring);
</code></pre>
<p>But, newlines only got stripped once, meaning that in every consecutive newlines, (eg. a newline followed by another newline) only one newline can be stripped away.</p>
<p>Now, I don't see that this as a problem in the <code>str_replace</code> function, since every consecutive character other than newline get stripped away just fine.</p>
<p>Pretty much confused about how stuff like this is handled in ActionScript. :-s</p>
<p>edit 2: </p>
<p>I've tried str_replace -ing everything I know of, \n, \r, \t, newline, and tab (by pressing tab key). Replacing \n, \r, and \t seem to have no effect whatsoever.</p>
<p>I know that by successfully doing this, my content can never have real line breaks. That's exactly my intention. I could format the XML the way I want without Flash displaying any of the formatting stuff. :)</p>
| [
{
"answer_id": 392307,
"author": "gltovar",
"author_id": 2855,
"author_profile": "https://Stackoverflow.com/users/2855",
"pm_score": 1,
"selected": false,
"text": "someXML = new XML();\nsomeXML.ignoreWhite = true;\n"
},
{
"answer_id": 393391,
"author": "fenomas",
"author_... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390748",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26721/"
] |
390,789 | <p>I am working on a c++ win32 program that involves a keyboard hook. The application is a win32 project with no user interface whatsoever. I need to keep the application from closing without using causing the hook to not work or use up a bunch of system resources. I used to use a message box but I need the application to be completely invisible.</p>
<p>Any help would be appreciated!</p>
<p>If you have any questions just ask.</p>
| [
{
"answer_id": 390917,
"author": "Lodle",
"author_id": 23339,
"author_profile": "https://Stackoverflow.com/users/23339",
"pm_score": -1,
"selected": false,
"text": "bool shouldExit = false;\n\ndo\n{\n //some code to handle events\n shouldExit = handleEvents();\n\n //sleep for a sma... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37875/"
] |
390,797 | <p>After some stupid musings about Klingon languages, that came from this <a href="https://stackoverflow.com/questions/304564/is-there-a-good-k-kode-editor-for-klingon">post</a> I began a silly hobby project creating a Klingon programming language that compiles to Lua byte-code. During the initial language design phase I looked up information about <a href="http://gradha.sdf-eu.org/textos/klingon_programmer.en.html" rel="nofollow noreferrer">Klingon programmers</a>, and found out about this Klingon programming rule:</p>
<blockquote>
<p><strong>A TRUE Klingon Warrior does not comment his code!</strong></p>
</blockquote>
<p>So I decided my language would <strong>not support commenting</strong>, as any good Klingon would never use them.</p>
<p>Now many of the Klingon ways don't seem reasonable to us Human programmers, however while dabbling with the design and implementation of my hobby language I came to realize that this Klingon rule about commenting is indeed very reasonable, if not great.</p>
<p>Removing the ability to comment from a programming language meant I <strong>HAVE</strong> to write <strong>literate code</strong>, no exceptions. </p>
<p>So it got me wondering if there are any languages out there that don't support comments? </p>
<p>Is there are any really good arguments to not remove commenting from a language?</p>
<p>Edit: Any good examples of comments required?</p>
<hr>
<p>P.S.> My hobby language above is partially silly anyways, so don't focus too much on my implementation, as much as the concept of comments required in general</p>
| [
{
"answer_id": 390980,
"author": "Daniel Daranas",
"author_id": 96780,
"author_profile": "https://Stackoverflow.com/users/96780",
"pm_score": 3,
"selected": false,
"text": "HelperFunctionDoesNothing(\"This is a comment! Blah Blah Blah...\");\n"
},
{
"answer_id": 391019,
"auth... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15124/"
] |
390,798 | <p>I have a business case whereby I need to be able to specify my own calling convention when using P/Invoke. Specifically, I have a legacy dll which uses a non-standard ABI, and I need to able to specify the calling convention for each function. </p>
<p>For example, one function in this dll accepts its first two arguments via EAX and EBX, with the rest via stack. Another function accepts one argument via ECX, with the rest on the stack. I have a few hundred of these functions, and would like to avoid writing my own intermediate bridge DLL in order to access these functions.</p>
<p>My other option would be to hand-roll my own custom P/Invoke, which is undesirable for obvious reasons.</p>
<p>Any help is appreciated, thanks,</p>
| [
{
"answer_id": 393761,
"author": "erikkallen",
"author_id": 47161,
"author_profile": "https://Stackoverflow.com/users/47161",
"pm_score": 3,
"selected": true,
"text": "int RealFunction(int param1, const char * param2, char param 3);\n\nint MyFunction(int param1, int param2, int param3) {... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390798",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48821/"
] |
390,800 | <p>Create a class (call it FormElement). That class should have some properties like the metadata they have with data elements (name, sequence number, value—which is just a string, etc).</p>
<p>This class has as attributes of type Validation Application Block Validation classes.</p>
<p>I want to serialize it to xml and deserialize it. Verify that all properties of the class including the validation application block attributes survive serialization.</p>
<p>some suggestion? </p>
| [
{
"answer_id": 393929,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": 2,
"selected": false,
"text": "// This code serializes a class instance to an XML file:\nXmlSerializer xs = new XmlSerializer(typeof(objectToSerialize));\n... | 2008/12/24 | [
"https://Stackoverflow.com/questions/390800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48824/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.