qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
177,558 | <p>Something like this is on my mind: I put one or a few strings in, and the algorithm shows me a matching regex.</p>
<p>Is there an "<em>easy</em>" way to do this, or does something like this already exist?</p>
<p><strong><em>Edit 1</em></strong>: Yes, I'm trying to find a way to generate regex. </p>
<p><strong><em>Edit 2</em></strong>: Regulazy is not what I am looking for. The common use for the code I want is to find a correct RegEx; for example, article numbers:<br/></p>
<ul>
<li>I put in <em>123456</em>, the regex should be <code>\d{6}</code></li>
<li>I put in <em>nb-123456</em>, the regex should be <code>\w{2}-\d{6}</code></li>
</ul>
| [
{
"answer_id": 177592,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 2,
"selected": false,
"text": "regexp-opt"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25730/"
] |
177,559 | <p>This is something that's been bothering me a while and there just has to be a solution to this. Every time I call ShellExecute to open an external file (be it a document, executable or a URL) this causes a very long lockup in my program before ShellExecute spawns the new process and returns. Does anyone know how to solve or work around this?</p>
<p>EDIT: And as the tags might indicate, this is on Win32 using C++.</p>
| [
{
"answer_id": 177571,
"author": "1800 INFORMATION",
"author_id": 3146,
"author_profile": "https://Stackoverflow.com/users/3146",
"pm_score": 3,
"selected": false,
"text": "CreateProcess"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25731/"
] |
177,569 | <p>I have Eclipse 3.3.2 with PDT doing PHP development.
All projects that I create, even SVN projects have code completion.
Now I just opened another SVN project and it has no code completion or PHP templates (CTRL-space does nothing in that project).
However, I can open the other projects and code completion all work in them.</p>
<p>Why would code completion and templates be "off" in just one project and how can I turn it back on?</p>
| [
{
"answer_id": 177601,
"author": "Guido",
"author_id": 12388,
"author_profile": "https://Stackoverflow.com/users/12388",
"pm_score": 6,
"selected": true,
"text": " <natures>\n <nature>org.eclipse.php.core.PHPNature</nature>\n </natures>\n"
},
{
"answer_id": 178097,
"author":... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4639/"
] |
177,606 | <p>I am running windows XP with ruby 1.8.6 patchlevel 111. I am using HTTP to connect to a remote server and it has been running fine. All of a sudden it started to through the exception listed below (I did not change any code since the last time I ran it successfully). Does anybody know what is going on?</p>
<pre>
c:/ruby/lib/ruby/1.8/timeout.rb:54:in `rbuf_fill': execution expired (Timeout::E
rror)
from c:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from c:/ruby/lib/ruby/1.8/net/http.rb:2029:in `read_status_line'
from c:/ruby/lib/ruby/1.8/net/http.rb:2018:in `read_new'
from c:/ruby/lib/ruby/1.8/net/http.rb:1059:in `request'
... 19 levels...
from c:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:216:in `run'
from c:/ruby/lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'
from c:/ruby/lib/ruby/1.8/test/unit.rb:278
from c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader
.rb:5
rake aborted!
Command failed with status (3): [c:/ruby/bin/ruby -Ilib;test "c:/ruby/lib/r...]
</pre>
| [
{
"answer_id": 5054097,
"author": "Brian Armstrong",
"author_id": 76486,
"author_profile": "https://Stackoverflow.com/users/76486",
"pm_score": 0,
"selected": false,
"text": "rescue Timeout::Error => e"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004/"
] |
177,611 | <p>I am creating an Eclipse RCP application.</p>
<p>I am following Joel's advice in the following article "Daily Builds are your friend":</p>
<p><a href="http://www.joelonsoftware.com/articles/fog0000000023.html" rel="nofollow noreferrer">http://www.joelonsoftware.com/articles/fog0000000023.html</a></p>
<p>So, I've written a nice build script that creates an Eclipse RCP product and that runs unit tests on the code. All results are then distributed to the developer's list (after some grumbling). Now my next step, I want it to create the setup package that I normally create manually using the inno setup compiler.</p>
<p>The question is, how would I get around creating this package automatically? I guess I can generate the inno setup file automatically from ant, and then invoke the compiler from the command line, but I don't know if this is possible.</p>
<p>Any tips for this task? Maybe any other setup application that can be used from ant?</p>
| [
{
"answer_id": 178237,
"author": "Tom",
"author_id": 20979,
"author_profile": "https://Stackoverflow.com/users/20979",
"pm_score": 4,
"selected": true,
"text": "#include \"settings.txt\"\n"
},
{
"answer_id": 290148,
"author": "Oliver Giesen",
"author_id": 9784,
"autho... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2309/"
] |
177,613 | <p>My <code>Account</code> model has the following two associations:</p>
<pre><code>has_many :expenses,
:order => 'expenses.dated_on DESC',
:dependent => :destroy
has_many :recent_expenses,
:class_name => 'Expense',
:conditions => "expenses.dated_on <= '#{Date.today}'",
:order => 'dated_on DESC',
:limit => 5
</code></pre>
<p>In one of my views I'm rendering recent expenses like so:</p>
<pre><code><% @account.recent_expenses.each do |expense| %>
...
<% end %>
</code></pre>
<p>On my development machine, on the staging server (which runs in production mode) and also on the production console, <code>@account.recent_expenses</code> returns the correct list. However, on our live production server, the most recent expenses are not returned. </p>
<p>If I replace <code>@account.recent_expenses</code> with <code>@account.expenses</code> in the view, the most recent expenses <em>are</em> displayed, so my guess is that the <code>#{Date.today}</code> part of the conditions clause is somehow being cached the first time it is executed. If I restart the production Mongrel cluster, all the latest expenses are returned correctly.</p>
<p>Can anyone think why this would occur and how might I change the <code>:recent_expenses</code> query to prevent this from happening?</p>
<p>I'm using Rails 2.1.0.</p>
| [
{
"answer_id": 177794,
"author": "Andrew",
"author_id": 17408,
"author_profile": "https://Stackoverflow.com/users/17408",
"pm_score": 4,
"selected": true,
"text": "named_scope :recent, lambda { {:conditions => [\"expenses.dated_on <= ?\", Date.today], :order => 'dated_on DESC', :limit =>... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1174/"
] |
177,638 | <p>I had a little discussion with a friend about the usage of collections in return/input values of a method. He told me that we have to use
- the most derived type for return values.
- the least derived type for input parameters.</p>
<p>So, it means that, for example, a method has to get a ReadOnlyCollection as parameter, and as return a List.</p>
<p>Moreover, he said that we must not use List or Dictionary in publics API, and that we have to use, instead Collection, ReadOnlyCollection, ... So, in the case where a method is public, its parameters and its return values must be Collection, ReadOnlyCollection, ...</p>
<p>Is it right ?</p>
| [
{
"answer_id": 177647,
"author": "Joe",
"author_id": 13087,
"author_profile": "https://Stackoverflow.com/users/13087",
"pm_score": 4,
"selected": true,
"text": "public void ProcessCustomers(IEnumerable<Customer> customers)\n{\n ... implementation ...\n}\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12703/"
] |
177,673 | <p>I have a strongly-typed MVC View Control which is responsible for the UI where users can create and edit Client items. I'd like them to be able to define the <code>ClientId</code> on creation, but not edit, and this to be reflected in the UI.</p>
<p>To this end, I have the following line:</p>
<pre><code><%= Html.TextBox("Client.ClientId", ViewData.Model.ClientId, new
{ @readonly =
(ViewData.Model.ClientId != null && ViewData.Model.ClientId.Length > 0
? "readonly" : "false")
} )
%>
</code></pre>
<p>It seems that no matter what value I give the readonly attribute (even "false" and ""), Firefox and IE7 make the input read-only, which is annoyingly counter-intuitive. Is there a nice, ternary-operator-based way to drop the attribute completely if it is not required?</p>
| [
{
"answer_id": 178024,
"author": "Panos",
"author_id": 8049,
"author_profile": "https://Stackoverflow.com/users/8049",
"pm_score": 6,
"selected": true,
"text": "readonly"
},
{
"answer_id": 178047,
"author": "leppie",
"author_id": 15541,
"author_profile": "https://Stac... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/192/"
] |
177,677 | <p>I am trying to uncompress some data created in VB6 using the zlib API.</p>
<p>I have read this is possible with the qUncompress function:
<a href="http://doc.trolltech.com/4.4/qbytearray.html#qUncompress" rel="nofollow noreferrer">http://doc.trolltech.com/4.4/qbytearray.html#qUncompress</a></p>
<p>I have read the data in from QDataStream via readRawBytes into a char
array, which I then converted to a QByteArray for decompression. I
have the compressed length and the expected decompressed length but am not getting
anything back from qUncompress.</p>
<p>However I need to prepend the expected decompressed length in big endian format. Has anybody done this and have an example?</p>
| [
{
"answer_id": 177793,
"author": "Mike G.",
"author_id": 18901,
"author_profile": "https://Stackoverflow.com/users/18901",
"pm_score": 3,
"selected": true,
"text": "qArr(1) = int(Size/(256*256*256))\nqArr(2) = 255 And int(Size/256*256)\nqArr(3) = 255 And int(Size/256)\nqArr(4) = 255 And ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24459/"
] |
177,717 | <p>Please share you experiences regarding how you localized your WPF applications to support multiple languages and any resources that helped you in it?</p>
<p>Thanks for your feedbacks.</p>
| [
{
"answer_id": 640277,
"author": "Robert Macnee",
"author_id": 19273,
"author_profile": "https://Stackoverflow.com/users/19273",
"pm_score": 2,
"selected": false,
"text": "ResourceDictionary"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
177,719 | <p>I'm trying to get a case-insensitive search with two strings in JavaScript working.</p>
<p>Normally it would be like this:</p>
<pre><code>var string="Stackoverflow is the BEST";
var result= string.search(/best/i);
alert(result);
</code></pre>
<p>The <code>/i</code> flag would be for case-insensitive.</p>
<p>But I need to search for a second string; without the flag it works perfect:</p>
<pre><code>var string="Stackoverflow is the BEST";
var searchstring="best";
var result= string.search(searchstring);
alert(result);
</code></pre>
<p>If I add the <code>/i</code> flag to the above example it would search for searchstring and not for what is in the variable "searchstring" (next example not working):</p>
<pre><code>var string="Stackoverflow is the BEST";
var searchstring="best";
var result= string.search(/searchstring/i);
alert(result);
</code></pre>
<p>How can I achieve this?</p>
| [
{
"answer_id": 177724,
"author": "Dan",
"author_id": 17121,
"author_profile": "https://Stackoverflow.com/users/17121",
"pm_score": 10,
"selected": true,
"text": ".match"
},
{
"answer_id": 177775,
"author": "Sergey Ilinsky",
"author_id": 23815,
"author_profile": "https... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25741/"
] |
177,722 | <p>Perl has several built-in functions for accessing /etc/passwd on Unix systems (and elsewhere when supported) for user and group information. For instance,</p>
<pre><code>my $name = getpwuid($uid);
</code></pre>
<p>will return the user name given the user ID, or undef if there is no such user.</p>
<p>If a Perl script needs to be portable and run on Unices and Windows, how should one access user and group information? ActivePerl seems to support User::grent and User::pwent modules, which provide by-field access to /etc/passwd -- even in Windows. Curiously they do not support the built-in functions getpw* and getgr*. What other alternatives are there?</p>
| [
{
"answer_id": 177865,
"author": "David Webb",
"author_id": 3171,
"author_profile": "https://Stackoverflow.com/users/3171",
"pm_score": 3,
"selected": false,
"text": "Win32::NetAdmin"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
177,723 | <p>I'm currently working on a project that depends on me providing a path to a file (eg. <code>C:\Path.pth</code>). Now, I had everything working yesterday by calling my <code>std::string</code> with:</p>
<pre><code>std::string path(`"C:\\Path.pth`");
</code></pre>
<p>But now it doesn't work. It throws a <code>bad_alloc</code>. Seems like the '<code>\</code>' character is the problem. I even tried using <code>\x5C</code> as the ascii-value of it instead, but same result.</p>
<p>Now, my question is, is it possible that I have screwed up some <code>#define</code>, some compiler-option or something else "non-code" that could've caused this? I'm using VS 2005.</p>
<p>Any help would be much appreciated</p>
<hr>
<p>PierreBdR</p>
<p>.. That sounds very likely. Or at least, it have to :P</p>
<p>Since no one have mentioned some kind of /SetStringCharSize:2bit-compiler option, I think it's safe to assume that my code has to mess something up, somewhere, and that it's not just a silly compiler-option (or similar) that's wrong..</p>
| [
{
"answer_id": 177731,
"author": "user22044",
"author_id": 22044,
"author_profile": "https://Stackoverflow.com/users/22044",
"pm_score": 0,
"selected": false,
"text": "std::string path(\"c:\\\\path.pth\");\n"
},
{
"answer_id": 178180,
"author": "Meeh",
"author_id": 25745,... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25745/"
] |
177,725 | <p>I got a simple page with a HtmlInputHidden field. I use a javascript to update that value and when posting back the page i want to read the value of that HtmlInputHidden field.</p>
<p>The Value property of that HtmlInputHidden field is on postback the default value (the value it had when the page got created, not the value reflected through the javascript).</p>
<p>I also tried to Register the HtmlInputHidden field with ScriptManager.RegisterHiddenField(Page, "MyHtmlImputHiddenField", "initialvalue") but it still only lets me read the 'initialvalue' even though i (through javascript) can inspect that the value has changed.</p>
| [
{
"answer_id": 178095,
"author": "Robert Paulson",
"author_id": 14033,
"author_profile": "https://Stackoverflow.com/users/14033",
"pm_score": 1,
"selected": false,
"text": "<asp:HiddenField id=\"myHiddenField\" runat=\"server\" />\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177725",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11619/"
] |
177,727 | <p>When I add &nbsp; or &eacute; to a text value of a listitem, it display the code of the HTML entity instead of the result (a space or é).</p>
<p>I can add "physical" non-breaking spaces or special chars, but I would like to avoid that if possible. Sometimes the data stored in database is encoded, and I don't want to always process data before displaying it.</p>
<p>Any solution ?</p>
<p>Thanks</p>
<p>Edit note : previous description noted it was about a dropdownlist simulating a treeview, but it was merely an example ; I can't and don't want to replace the dropdownlist by anything else.</p>
| [
{
"answer_id": 177741,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "<optgroup>"
},
{
"answer_id": 177846,
"author": "martin",
"author_id": 8421,
"author_profile": "http... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6776/"
] |
177,747 | <p>We have a "master database structure", and need a routine to keep the database structure on client sites up-to-date.</p>
<p>A number of suggestions have been given <a href="https://stackoverflow.com/questions/115389/update-sql-sever-database-schema-with-software-update" title="here">to a related question</a>, but I am looking for a more specific solution, along these lines:</p>
<ol>
<li>I would like to generate a text file (XML or other readable format) which describes the entire database structure (this could go into version control). This routine will run in-house, to provide a database schema file to be distributed with the next version of our product.</li>
<li>Then I need a way to update the database structure on the client site so that it corresponds to the master database structure. (In other words, I don't want to have to keep track of numerous change scripts for different versions of the database structure, but a more general routine which can get the client database structure updated to the current master database structure.)</li>
</ol>
<p>So the main feature I'm looking for could be described as "database structure to text" and "text to database structure".</p>
| [
{
"answer_id": 177741,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 1,
"selected": false,
"text": "<optgroup>"
},
{
"answer_id": 177846,
"author": "martin",
"author_id": 8421,
"author_profile": "http... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177747",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18651/"
] |
177,750 | <p>I am trying to get some XML data with LINQ, but running into a problem.</p>
<p>I am using a schema, which is set in the attribute xmlns ...</p>
<pre><code><CarsForSale xmlns="http://schemas.sharplogic.net/CarSales.xsd">
<CarForSale>
</code></pre>
<p>There are many CarForSale elements.</p>
<p>When the schema is set and I do this...</p>
<pre><code>XElement doc = XElement.Load(HttpContext.Current.Server.MapPath("App_Data/XML/CarsForSale.xml"));
var cars2 = from d in doc.Descendants("CarForSale")
select d;
</code></pre>
<p>Then I get in the results i get Enumeration yielded no results </p>
<p>Strip the xmlns out of the XML file and the data comes back as expected??</p>
<p>Any ideas?</p>
<p>Thx</p>
| [
{
"answer_id": 177754,
"author": "Mark Cidade",
"author_id": 1659,
"author_profile": "https://Stackoverflow.com/users/1659",
"pm_score": 4,
"selected": true,
"text": "var ns = \"http://schemas.sharplogic.net/CarSales.xsd\";\nvar cars2 = from d in doc.Descendants(ns + \"CarForSale\") ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6125/"
] |
177,752 | <p>I'm migrating a TSQL stored procedure to PL/SQL and have encountered a problem - the lack of a CONTINUE keyword in Oracle 10g.</p>
<p>I've read that Oracle 11g has this as a new feature, but upgrading is not an option unfortunately.</p>
<p>Is there any alternative to CONTINUE in 10g? I don't believe it's practical to restructure the logic of the SP as a work-around, because I have an outer loop, an IF, then a nested IF, then the CONTINUE at the end of a statement block within that IF.</p>
<p>Any help would be greatly appreciated, cheers.</p>
| [
{
"answer_id": 177785,
"author": "jop",
"author_id": 11830,
"author_profile": "https://Stackoverflow.com/users/11830",
"pm_score": 7,
"selected": true,
"text": "DECLARE\n done BOOLEAN;\nBEGIN\n FOR i IN 1..50 LOOP\n IF done THEN\n GOTO end_loop;\n END IF;\n <<end... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5827/"
] |
177,762 | <p>Trying to perform a single boolean NOT operation, it appears that under MS SQL Server 2005, the following block does not work</p>
<pre><code>DECLARE @MyBoolean bit;
SET @MyBoolean = 0;
SET @MyBoolean = NOT @MyBoolean;
SELECT @MyBoolean;
</code></pre>
<p>Instead, I am getting more successful with</p>
<pre><code>DECLARE @MyBoolean bit;
SET @MyBoolean = 0;
SET @MyBoolean = 1 - @MyBoolean;
SELECT @MyBoolean;
</code></pre>
<p>Yet, this looks a bit a twisted way to express something as simple as a negation.</p>
<p>Am I missing something?</p>
| [
{
"answer_id": 177770,
"author": "Galwegian",
"author_id": 3201,
"author_profile": "https://Stackoverflow.com/users/3201",
"pm_score": 5,
"selected": false,
"text": "DECLARE @MyBoolean bit;\nSET @MyBoolean = 0;\nSET @MyBoolean = @MyBoolean ^ 1; \nSELECT @MyBoolean;\n"
},
{
"answe... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18858/"
] |
177,778 | <p>I am trying to set the background color for a double spin box, and I am not sure what function I should use.</p>
<p>I saw some function called <code>SetBackgroundRole</code> which accepts a <code>Qt::ColorRole</code>, but I am not sure how to use this one as well.</p>
<p>Kindly let me know, what's the simple way to change the background color of a <code>QComboBox</code> or <code>QDoubleSpinBox</code>?</p>
| [
{
"answer_id": 177802,
"author": "fhe",
"author_id": 4445,
"author_profile": "https://Stackoverflow.com/users/4445",
"pm_score": 0,
"selected": false,
"text": "QPalette pal = widget.palette();\npal.setColor(QPalette::Window, Qt::blue);\nwidget.setPalette(pal);\n"
},
{
"answer_id"... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177778",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11212/"
] |
177,814 | <p>During an ASP.NET page load I'm opening and closing multiple System.Data.SqlClient.SqlConnections inside multiple controls contained in the page. I thought it would be a good idea instead to create a "pool" of connections and when opening a connection check to see if the connection string matches that of an open connection in the pool, and return that connection. I was expecting to see a difference in the page load times, but I haven't seen any change. I know that with PHP if you attempt to open a new connection with a connection string that has already been used in that page request it won't attempt to open a new connection and will return the existing open connection instead. Is this true with .NET?</p>
| [
{
"answer_id": 177825,
"author": "JacquesB",
"author_id": 7488,
"author_profile": "https://Stackoverflow.com/users/7488",
"pm_score": 0,
"selected": false,
"text": "Open()"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177814",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2179408/"
] |
177,815 | <p>I am changing a GET to a POST. Currently I have .jsp?id=a,b,c,d. When changing this to a post I am still sitting the id parameter a,b,c,d . This is not working for me. Can I submit a comma separated list to a post parameter?</p>
| [
{
"answer_id": 177822,
"author": "Fionn",
"author_id": 21566,
"author_profile": "https://Stackoverflow.com/users/21566",
"pm_score": 4,
"selected": false,
"text": "string[] values = Request.Form.GetValues(\"param\");\n"
},
{
"answer_id": 177853,
"author": "Olvagor",
"auth... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
177,835 | <p>One of our unit tests is to populate properties within our business objects with random data.</p>
<p>These properties are of different intrinsic types and therefore we would like to use the power of generics to return data of the type you pass in. Something along the lines of:</p>
<pre><code>public static T GetData<T>()
</code></pre>
<p>How would you go about approaching this? Would a low level interface work? (IConvertible)</p>
| [
{
"answer_id": 177847,
"author": "Jon Skeet",
"author_id": 22656,
"author_profile": "https://Stackoverflow.com/users/22656",
"pm_score": 4,
"selected": false,
"text": "public static T GetData<T>()\n{\n object factory;\n if (!factories.TryGet(typeof(T), out factory))\n {\n ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17540/"
] |
177,856 | <p>I would like to be able to trap <kbd>Ctrl</kbd>+<kbd>C</kbd> in a C# console application so that I can carry out some cleanups before exiting. What is the best way of doing this?</p>
| [
{
"answer_id": 929717,
"author": "Jonas",
"author_id": 16047,
"author_profile": "https://Stackoverflow.com/users/16047",
"pm_score": 8,
"selected": false,
"text": "public static void Main(string[] args)\n{\n Console.CancelKeyPress += delegate {\n // call methods to clean up\n ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5932/"
] |
177,863 | <p>I am using the next class (simplified for the sake of understandability) to download images in a struts web application.
It is working fine in every browser but firefox, which cuts names containing spaces. That it is to say: <strong>file with spaces.pdf</strong> gets downloaded in firefox as: <strong>file</strong> while in chrome, IE7 IE6 is downloaded as <strong>file with spaces.pdf</strong>.</p>
<pre><code>public class Download extends Action {
private static final int BUFFER_SIZE = 4096;
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
String filename = "file with spaces.pdf";
File file = ... // variable containing the file;
response.setStatus(HttpServletResponse.SC_OK);
response.setContentType(getMimeType(request, file));
response.setHeader("Content-Type", getMimeType(request, file));
response.setHeader("Content-Disposition","attachment; filename="+ filename);
InputStream is = new FileInputStream(file);
sendFile(is, response);
return null;
}
protected String getMimeType(HttpServletRequest request, File file) {
ServletContext application = super.servlet.getServletContext();
return application.getMimeType(file.getName());
}
protected void sendFile(InputStream is, HttpServletResponse response) throws IOException {
BufferedInputStream in = null;
try {
int count;
byte[] buffer = new byte[BUFFER_SIZE];
in = new BufferedInputStream(is);
ServletOutputStream out = response.getOutputStream();
while(-1 != (count = in.read(buffer)))
out.write(buffer, 0, count);
out.flush();
} catch (IOException ioe) {
System.err.println("IOException in Download::sendFile");
ioe.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ioe) { ioe.printStackTrace(); }
}
}
}
}
</code></pre>
<p>Does anyone know about what is going on here? Note i am using firefox 3.0.3 under Windows Vista. </p>
| [
{
"answer_id": 177880,
"author": "Stephen Denne",
"author_id": 11721,
"author_profile": "https://Stackoverflow.com/users/11721",
"pm_score": 6,
"selected": true,
"text": "response.setHeader(\"Content-Disposition\",\"attachment; filename=\\\"\" + filename + \"\\\"\");\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2138/"
] |
177,867 | <p>I need to copy data values from one element to another, but jQuery's clone() method doesn't clone the data. And I can't iterate over the data either:</p>
<pre><code>element.data().each
</code></pre>
<p>because <code>data()</code> is a function and not a jQuery object. It seems I have to keep a separate list of attribute names and reference those but that seems too hacky. So how can I do either of these:</p>
<p>a) Iterate over data items<br>
OR<br>
b) <code>clone()</code> an element with its data.</p>
| [
{
"answer_id": 7805272,
"author": "simon",
"author_id": 76777,
"author_profile": "https://Stackoverflow.com/users/76777",
"pm_score": 1,
"selected": false,
"text": "\nfunction getOriginalElementData(domElementJQueryObject){\n var originalElementData = new Array();\n $.each(domEleme... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1896/"
] |
177,883 | <p>is it possible to include a servlet in a jsp page? if so how?</p>
| [
{
"answer_id": 7805272,
"author": "simon",
"author_id": 76777,
"author_profile": "https://Stackoverflow.com/users/76777",
"pm_score": 1,
"selected": false,
"text": "\nfunction getOriginalElementData(domElementJQueryObject){\n var originalElementData = new Array();\n $.each(domEleme... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24481/"
] |
177,885 | <p>I'm looking for a way to obtain offsets of data members of a C++ class which is of non-POD nature.</p>
<p>Here's why: </p>
<p>I'd like to store data in <a href="http://www.hdfgroup.org/HDF5/whatishdf5.html" rel="noreferrer">HDF5</a> format, which seems most suited for my kind of material (numerical simulation output), but it is perhaps a rather C-oriented library. I want to use it through the C++ interface, which would require me to declare storage types like so (following documentation from <a href="http://www.hdfgroup.org/HDF5/doc1.6/cpplus_RM/classH5_1_1CompType.html#a16" rel="noreferrer">here</a> and <a href="http://www.hdfgroup.org/HDF5/doc1.6/UG/11_Datatypes.html" rel="noreferrer">here</a> (section 4.3.2.1.1)): </p>
<pre><code>class example {
public:
double member_a;
int member_b;
} //class example
H5::CompType func_that_creates_example_CompType() {
H5::CompType ct;
ct.insertMember("a", HOFFSET(example, member_a), H5::PredType::NATIVE_DOUBLE);
ct.insertMember("b", HOFFSET(example, member_b), H5::PredType::NATIVE_INT);
return ct;
} //func_that_creates_example_CompType
</code></pre>
<p>where HOFFSET is a HDF-specific macro that uses offsetof.</p>
<p>The problem is of course, that as soon as the example-class becomes it little bit more featureful, it is no longer of POD-type, and so using offsetof will give undefined results.</p>
<p>The only workaround I can think of is to first export the data I want to store to a simpler struct, then pass that to HDF. That does however involve data copying, which is exactly what HDF is trying to avoid (and why they have this CompType which enables the library to reach into your objects to save their data to file).</p>
<p>So I was hoping you'd have better ideas. Ideally I'd be looking for a portable workaround for this problem, but if short of that you could give me an idea that works on x86 and x86_64 with GCC I'd already be immensely grateful.</p>
<p>----- appended later: -----</p>
<p>Greg Hewgill suggested below to store the data in a simple struct, then build the actual class by inheriting from that. For HDF specifically, I think that may not practically work. A more elaborate usage scenario than above:</p>
<pre><code>class base_pod {
public:
double member_a;
int member_b;
}; //class base_pod
class derived_non_pod : private base_pod {
public:
//the following method is only virtual to illustrate the problem
virtual double get_member_a() {return member_a; }
}; //class derived_non_pod
class that_uses_derived_non_pod {
public:
void whatever();
private:
derived_non_pod member_c;
}; //class that_uses_derived_non_pod
</code></pre>
<p>Now, when we're storing instances of the class that_uses_derived_non_pod, we cannot describe its memory layout as if it had a base_pod as member_c. This would get the offsets wrong because derived_non_pod adds funky stuff (like a virtual function table, I guess?).</p>
| [
{
"answer_id": 177887,
"author": "Greg Hewgill",
"author_id": 893,
"author_profile": "https://Stackoverflow.com/users/893",
"pm_score": 2,
"selected": false,
"text": "private"
},
{
"answer_id": 1234781,
"author": "Richard Corden",
"author_id": 11698,
"author_profile":... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25756/"
] |
177,910 | <p>I've produced a python egg using setuptools and would like to access it's metadata at runtime. I currently got working this:</p>
<pre><code>import pkg_resources
dist = pkg_resources.get_distribution("my_project")
print(dist.version)
</code></pre>
<p>but this would probably work incorrectly if I had multiple versions of the same egg installed. And if I have both installed egg and development version, then running this code from development version would pick up version of the installed egg. </p>
<p>So, how do I get metadata for <em>my</em> egg not some random matching egg installed on my system? </p>
| [
{
"answer_id": 177939,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 3,
"selected": true,
"text": "my_project"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5821/"
] |
177,911 | <p>I've got a WPF browser-like application with a few pages. When I switch between pages, I'd like to set the keyboard focus.</p>
<p>When a page is loaded the first time, this works by calling <code>Control.Focus()</code> in the constructor.</p>
<p>But when I switch between pages this does not work anymore - the focus is just on the first field, and ignores my attempts to change it to anything else :(</p>
<p>The pages have the attribute <code>KeepAlive=true</code> - it would be OK if that would keep the focus alive, too, but just setting the focus to the first field is annoying.</p>
<p>I tried to set the focus in the loaded event, but it did not work, too. It seems the default focus is set after reloading the page.</p>
<p>Is there any way to set the focus on entering a page the second time? <strong>When, how and where should I set the focus when switching between WPF pages in a browserlike application</strong>?</p>
| [
{
"answer_id": 221884,
"author": "Sam",
"author_id": 7021,
"author_profile": "https://Stackoverflow.com/users/7021",
"pm_score": 1,
"selected": true,
"text": "myControl.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, \n(System.Threading.SendOrPostCallback)d... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7021/"
] |
177,927 | <p>In JPA the Entities are nice annotated Plain Old Java Objects. But I have not found a good way to interact with them and the database.</p>
<p>In my current app, my basic design is always to have a sequence based id as primary key so I usually have to look up entities by other properties than PK.</p>
<p>And for each Entity I have a stateless EJB of </p>
<pre><code>@Stateless
public class MyEntApiBean implements MyEntApi {
@PersistenceContext(unitName = "xxx") @Inject EntityManager entityManager;
</code></pre>
<p>with query methods that all are some variation </p>
<pre><code>/**
* @return A List of all MyEnts that have some property
* @param someProp some property
*/
public List<MyEnt> getAllMyEntsFromProp(final String someProp) {
try {
final Query query = entityManager.createQuery("select me from MyEnt me where me.someProp = :someProp");
query.setParameter("someProp", someProp);
return query.getResultList();
} catch(final NoResultException nre) {
log.warn("No MyEnts found");
}
return new ArrayList<MyEnt>();
}
</code></pre>
<p>So:</p>
<ol>
<li><p>I really hate having these methods in an EJB because they seem to belong with the entities themselves, and the EJB local interfaces annoy the crap out of me.</p></li>
<li><p>I hate the duplication that I have in each method with "try, createQuery, getResultList,catch, log, return" (mostly a consequence of no closures or "with statement" or somesuch in Java).</p></li>
</ol>
<p>Does anyone have a suggestion for a better way to interact with the Entities and Database that addresses one or both of my issues?</p>
<p>I am currently thinking of doing some base methods with generics and reflection to get some generic query methods to reduce the duplication (issue 2) (I will put a prototype up for review later).</p>
<p>Thanks,
Anders</p>
| [
{
"answer_id": 178744,
"author": "cletus",
"author_id": 18393,
"author_profile": "https://Stackoverflow.com/users/18393",
"pm_score": 2,
"selected": false,
"text": "@SuppressWarnings(\"unchecked\")\npublic List<MyEnt> getAllMyEntsFromProp(final String someProp) {\n return entityManager.... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8805/"
] |
177,945 | <p>I would like to create XML Schema for this chunk of xml, I would like to restrict the values of "name" attribute, so that in output document on and only one instance of day is allowed for each week day:</p>
<pre><code><a>
<day name="monday" />
<day name="tuesday" />
<day name="wednesday" />
</a>
</code></pre>
<p>I have tried to use this:</p>
<pre><code> <xs:complexType name="a">
<xs:sequence>
<xs:element name="day" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="monday" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
<xs:element name="day" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="tuesday" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</code></pre>
<p>but XML Schema validator in eclipse says error "Multiple elements with name 'day', with different types, appear in the model group.".</p>
<p>Is there any other way?</p>
| [
{
"answer_id": 177954,
"author": "Micah",
"author_id": 17744,
"author_profile": "https://Stackoverflow.com/users/17744",
"pm_score": 0,
"selected": false,
"text": "<xs:schema attributeFormDefault=\"unqualified\" elementFormDefault=\"qualified\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10560/"
] |
177,956 | <p>What is the best way to convert an int or null to boolean value in an SQL query, such that:</p>
<ul>
<li>Any non-null value is <strong>TRUE</strong> in the results</li>
<li>Any null value is <strong>FALSE</strong> in the results</li>
</ul>
| [
{
"answer_id": 177967,
"author": "Torbjörn Gyllebring",
"author_id": 21182,
"author_profile": "https://Stackoverflow.com/users/21182",
"pm_score": 2,
"selected": false,
"text": "isnull(column - column + 1, 0) != 0\n"
},
{
"answer_id": 177978,
"author": "mattlant",
"author... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15985/"
] |
177,964 | <p>I have an application database and an aspnetdb database (generated from the ASP.Net 2.0 framework). I have restored both database from production onto my development environment but I am unable to log on with any of the users credentials that work on production.</p>
<p>So my question is is there anything that ties the aspnetdb database generated by ASP>NET 2.0 Framework to a specific machine?</p>
<p>If anyone has ever restored an aspnetdb database from one machine to another successfully please can they shed light on the variables that need to be the same in order to access all the previous users.</p>
<p>Many Thanks!</p>
<hr>
<p>Sure I have checked the connection string and double checked users and roles which I can confirm is working by being able to create new users on the development environment and log in with those credentials. </p>
<p>The problem is I am unable to logon with any of the user credentials I use on the live environment. This I feel is related to the difference in the machine.config files on both machines. If anyone knows a variable I should look for in the machine.config then I could make sure they are the same in both environments i.e both machines.</p>
| [
{
"answer_id": 178132,
"author": "test",
"author_id": 21004,
"author_profile": "https://Stackoverflow.com/users/21004",
"pm_score": 0,
"selected": false,
"text": " <add assembly=\"System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A\"/>\n </a... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21004/"
] |
177,965 | <p>I've got some code that uses the Component Categories manager to load all of the classes that implement a particular category.</p>
<p>Is there an easy way to get a description, path and version information from the loaded DLL or EXE?</p>
| [
{
"answer_id": 180047,
"author": "Tim Farley",
"author_id": 4425,
"author_profile": "https://Stackoverflow.com/users/4425",
"pm_score": 2,
"selected": true,
"text": "HKEY_CLASSES_ROOT\\CLSID\\{xxxxxxxxx-yyyyy-zzzz-aaaa-bbbbbbbbbbbbbb"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/177965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8446/"
] |
177,970 | <p>I need a select from table which does not have column that tells when row was inserted, only <code>timestamp</code> column (values like: 0x0000000000530278). Some data was imported to the table yesterday and now I need to find out what exactly was imported :(</p>
<p>Is there a way to do it using only <code>timestamp</code> info? <a href="http://www.sqlhacks.com/index.php/Dates/Timestamp" rel="noreferrer">Here</a> I found that:</p>
<ul>
<li>Timestamp is a 8 bytes sequential Hex number, that has nothing to do with neither the date nor the time.</li>
<li>To get the current value of timestamp, use: @@DBTS.</li>
</ul>
<p>Perhaps there is a way to find what was <code>timestamp</code> value around specific time? That would help to form a select. Or maybe there is a well known solution?</p>
| [
{
"answer_id": 178122,
"author": "kristof",
"author_id": 3241,
"author_profile": "https://Stackoverflow.com/users/3241",
"pm_score": 2,
"selected": false,
"text": "0x00000000000007D1\n0x00000000000007D2\n0x00000000000007D3\n0x00000000000007D4\n0x00000000000007D5\n"
},
{
"answer_i... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177970",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23436/"
] |
177,974 | <p>How can I test sending email from my application without flooding my inbox? </p>
<p>Is there a way to tell IIS/ASP.NET how to deliver email to a local folder for inspection?</p>
| [
{
"answer_id": 178072,
"author": "GEOCHET",
"author_id": 5640,
"author_profile": "https://Stackoverflow.com/users/5640",
"pm_score": 6,
"selected": true,
"text": " <configuration> \n <system.net> \n <mailSettings> \n <smtp deliveryMethod=\"SpecifiedPickupDirect... | 2008/10/07 | [
"https://Stackoverflow.com/questions/177974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10676/"
] |
178,016 | <p>I'm trying to select a specific HTML element in a document, for firefox i just use:</p>
<pre><code>xpathobj = document.evaluate(xpath, document, null,
XPathResult.FIRST_ORDERED_NODE_TYPE, null);
</code></pre>
<p>which works fine. However when I try the IE equivilent:</p>
<pre><code>xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(document);
xmlDoc.setProperty("SelectionLanguage", "XPath");
xpathobj = xmlDoc.selectNodes(xpath);
</code></pre>
<p>I get no object returned. So my question is there an easy way to use XPath to get to the element I want in IE?
The XPath I'm using looks like </p>
<pre><code>/HTML/BODY/DIV[9]/DIV[2]
</code></pre>
| [
{
"answer_id": 181704,
"author": "Tim C",
"author_id": 7585,
"author_profile": "https://Stackoverflow.com/users/7585",
"pm_score": 0,
"selected": false,
"text": "xmlDoc.load(document); \n"
},
{
"answer_id": 182471,
"author": "user11198",
"author_id": 11198,
"author_pr... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11198/"
] |
178,026 | <p>We noticed that lots of bugs in our software developed in C# (or Java) cause a NullReferenceException.</p>
<p>Is there a reason why "null" has even been included in the language?</p>
<p>After all, if there were no "null", I would have no bug, right?</p>
<p>In other words, what feature in the language couldn't work without null?</p>
| [
{
"answer_id": 178090,
"author": "Julien Hoarau",
"author_id": 12248,
"author_profile": "https://Stackoverflow.com/users/12248",
"pm_score": 8,
"selected": true,
"text": "static string AcceptNotNullObject(object! s)\n{\n return s.ToString();\n}\n"
},
{
"answer_id": 178092,
... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25781/"
] |
178,068 | <p>When stepping a program in Delphi 7, the CPU window sometimes pops up and then steps through that instructions. I find this an annoyance as I wish to only step Pascal Code. </p>
<p>Does anyone know how to disable this CPU pop-up? </p>
<p><strong><em>I would not be sorry if this window never ever shows.</em></strong> </p>
<p>It did not happen on Delphi 5 which was my previous IDE that I used for Delphi. I do use the Step-Over button mostly and only step-into when wanting to get into detail of a used (pascal) unit.</p>
| [
{
"answer_id": 271483,
"author": "Lars Truijens",
"author_id": 1242,
"author_profile": "https://Stackoverflow.com/users/1242",
"pm_score": 4,
"selected": true,
"text": "Run -> Run to Next Source Line"
},
{
"answer_id": 2114093,
"author": "Seth",
"author_id": 141203,
"... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3535708/"
] |
178,070 | <p>We're working on a rich client (written in Flex) that is connected to a Java backend, using both RMI and JMS. I was thinking about implementing the client in a DDD fashion so that it has Repositories for the CRUD operations on the domain objects.</p>
<p>The problem is however that all backend communication happens asynchronous and there is no way for me to force the client for waiting to continue untill it received a response. That means that, at a low level, I can call a method on a Remote Object and I get a AsyncToken as a return value. I can then listen to events on the asynctoken to see whether the call has passed or failed. This however breaks the main idea behind a repository, to hide the technical details from the client.</p>
<p>There might be 2 options I guess:</p>
<ol>
<li>have the methods on the repository return the asynctoken, which seems like a messy solution to me</li>
<li>have the methods return an empty collection (for a findAll for instance) that will get filled when the response is received.</li>
</ol>
<p>Both have pros and cons and I would like to get some input from you guys.</p>
<p>(taking this further, what would be good caching strategies? Dependind on the situation, I don't want the repository to call the server each time I request all entities from it. How would that affect the signature of the methods on the repository.)</p>
| [
{
"answer_id": 221946,
"author": "Richard Szalay",
"author_id": 3603,
"author_profile": "https://Stackoverflow.com/users/3603",
"pm_score": 2,
"selected": false,
"text": "public class CompleteAsyncToken : AsyncToken\n{\n public function CompleteAsyncToken(data : Object)\n {\n ... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17255/"
] |
178,114 | <p>Is there any easier solution in porting a windows manual-reset event to pthread,
than a pthread conditional-variable + pthread mutex + a flag if event is set or unset?</p>
| [
{
"answer_id": 178962,
"author": "ephemient",
"author_id": 20713,
"author_profile": "https://Stackoverflow.com/users/20713",
"pm_score": 4,
"selected": false,
"text": "pthread_cond__*"
},
{
"answer_id": 9490158,
"author": "Vincent",
"author_id": 137511,
"author_profil... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
178,128 | <p>Let's say I have to implement a piece of T-SQL code that must return a table as result. I can implement a table-valued function or else a stored procedure that returns a set of rows. What should I use?</p>
<p>In short, what I want to know is: </p>
<p><strong>Which are the main differences between functions and stored procedures?</strong> What considerations do I have to take into account for using one or the other?</p>
| [
{
"answer_id": 178150,
"author": "Ilya Kochetov",
"author_id": 15329,
"author_profile": "https://Stackoverflow.com/users/15329",
"pm_score": 3,
"selected": false,
"text": "SELECT function_name(field1) FROM table\n"
},
{
"answer_id": 228148,
"author": "6eorge Jetson",
"aut... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1679/"
] |
178,135 | <p>I have a UserControl (Composite control) that can be shown as the following pseudo XAML code:</p>
<pre><code><UserControl>
<DockPanel>
<TextBox />
<Button />
</DockPanel>
</UserControl>
</code></pre>
<p>I use this custom control in a bunch of places and style some of them with a WPF Style. This style sets the Background property of the UserControl to a color. But this background color is drawn on UserControl's background surface, but I want it to be drawn only on TextBox control's background. This is what I get (Color=Red):</p>
<p><a href="http://img261.imageshack.us/img261/8600/62858047wi3.png" rel="nofollow noreferrer">alt text http://img261.imageshack.us/img261/8600/62858047wi3.png</a></p>
<p>If I bind the Background property of the UserControl to my TextBox control's background property, I get the following one:</p>
<p><a href="http://img111.imageshack.us/img111/1637/30765795kw5.png" rel="nofollow noreferrer">alt text http://img111.imageshack.us/img111/1637/30765795kw5.png</a></p>
<p>Now it also paints the background of the inner TextBox control but the Background color of the UserControl still exists. Are there any ways to remove that painting of UserControl's background?</p>
| [
{
"answer_id": 178427,
"author": "Kent Boogaart",
"author_id": 5380,
"author_profile": "https://Stackoverflow.com/users/5380",
"pm_score": 3,
"selected": false,
"text": "<UserControl x:Name=\"_root\" ...>\n ...\n <Button Background=\"{Binding ButtonBackground, ElementName=_root}\"/... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39/"
] |
178,138 | <p>I fear this is probably a bit of a dummy question, but it has me pretty stumped.</p>
<p>I'm looking for the simplest way possible to pass a method of an object into a procedure, so that the procedure can call the object's method (e.g. after a timeout, or maybe in a different thread). So basically I want to:</p>
<ul>
<li>Capture a reference to an object's method.</li>
<li>Pass that reference to a procedure.</li>
<li>Using that reference, call the object's method from the procedure.</li>
</ul>
<p>I figure I could achieve the same effect using interfaces, but I thought there was another way, since this "procedure of object" type declaration exists.</p>
<p>The following <em>doesn't</em> work, but might it help explain where I'm confused...?</p>
<pre><code>interface
TCallbackMethod = procedure of object;
TCallbackObject = class
procedure CallbackMethodImpl;
procedure SetupCallback;
end;
implementation
procedure CallbackTheCallback(const callbackMethod: TCallbackMethod);
begin
callbackMethod();
end;
procedure TCallbackObject.CallbackMethodImpl;
begin
// Do whatever.
end;
procedure TCallbackObject.SetupCallback;
begin
// following line doesn't compile - it fails with "E2036 Variable required"
CallbackTheCallback(@self.CallbackMethodImpl);
end;
</code></pre>
<p>(Once the question is answered I'll remove the above code unless it aids the explanation somehow.)</p>
| [
{
"answer_id": 178174,
"author": "Roman Ganz",
"author_id": 17981,
"author_profile": "https://Stackoverflow.com/users/17981",
"pm_score": 5,
"selected": true,
"text": "procedure TCallbackObject.SetupCallback;\nbegin\n CallbackTheCallback(CallbackMethodImpl);\nend;\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11961/"
] |
178,144 | <p>Originally I thought to ask if there would be an easy way to provide an automatically managed last update field with MS Access.</p>
<p>After some googling I found following approach:</p>
<pre><code>Private Sub Form_Dirty(Cancel As Integer)
Me.Last_Update = Date()
End Sub
</code></pre>
<p>Which seems to do the job. I thought I'd share it with others too (and if somebody has some good points that should be considered, feel free to share them)</p>
| [
{
"answer_id": 178170,
"author": "tom.dietrich",
"author_id": 15769,
"author_profile": "https://Stackoverflow.com/users/15769",
"pm_score": 2,
"selected": false,
"text": "CREATE TRIGGER [Table_stampUpdates] ON [dbo].[Table]\n FOR Update \nAS \nBEGIN \nUPDATE Table\nSET \nmodified_by = ri... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178144",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/28482/"
] |
178,147 | <p>I have an application in C# (2.0 running on XP embedded) that is communicating with a 'watchdog' that is implemented as a Windows Service. When the device boots, this service typically takes some time to start. I'd like to check, from my code, if the service is running. How can I accomplish this?</p>
| [
{
"answer_id": 178162,
"author": "Carl",
"author_id": 951280,
"author_profile": "https://Stackoverflow.com/users/951280",
"pm_score": 10,
"selected": true,
"text": "System.ServiceProcess"
},
{
"answer_id": 24381150,
"author": "rhatwar007",
"author_id": 3248226,
"autho... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6399/"
] |
178,173 | <p>I'd like to calculate the age of the messages in an Exchange mailbox to make sure they sit there for at least a minute before our program (C++, MAPI) processes them. This way the <a href="http://www.cloudmark.com/server/" rel="nofollow noreferrer">spam filter we use</a> should have enough time to do its job.</p>
<p>Because the time on the PC where our program runs might be different from the time used by the Exchange server, our program has to read the server time via MAPI. </p>
<p>Is there an elegant solution to it? One way I can think of is to modify some Item and immediately read its <em>PR_LAST_MODIFICATION_TIME</em>, but I'd like to avoid that.</p>
<p><strong>Edit:</strong><br>
Our program is a batch job that runs every 10 minutes and reads the journal mailbox.</p>
| [
{
"answer_id": 178201,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 0,
"selected": false,
"text": "PR_MESSAGE_DELIVERY_TIME"
},
{
"answer_id": 181012,
"author": "Henk",
"author_id": 4613,
"author_profi... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4097/"
] |
178,187 | <p>I am designing a class for log entries of my mail server. I have parsed the log entries and created the class hierarchy. Now I need to save the in memory representation to the disk. I need to save it to multiple destinations like mysql and disk files. I am at a loss to find out the proper way to design the persistence mechanism. The challenges are:</p>
<ol>
<li><p>How to pass persistence
initialization information like
filename, db connection parameters
passed to them. The options I can
think of are all ugly for eg:</p>
<p>1.1 Constructor: it becomes ugly as I
add more persistence.</p>
<p>1.2 Method: Object.mysql_params(" "),
again butt ugly</p></li>
<li><p>"Correct" method name to call each
persistance mechanism: eg:
Object.save_mysql, Object.save_file,
or Object.save (mysql) and
Object.save(file)</p></li>
</ol>
<p>I am sure there is some pattern to solve this particular problem. I am using ruby as my language, with out any rails, ie pure ruby code. Any clue is much welcome.</p>
<p>raj</p>
| [
{
"answer_id": 178504,
"author": "Jon Wood",
"author_id": 25258,
"author_profile": "https://Stackoverflow.com/users/25258",
"pm_score": 3,
"selected": true,
"text": "class Object\n cattr_accessor :store\n\n def save\n @@store.save(self)\n end\nend\n\nclass MySQLObjectStore\n def i... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178187",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25453/"
] |
178,188 | <p>So, bitfields. Specifically, large bitfields. I understand how to manipulate individual values in a bitfield, but how would I go about doing this on a large set, such as say:</p>
<pre><code>uint[] bitfield = new uint[4] { 0x0080000, 0x00FA3020, 0x00C8000, 0x0FF00D0 };
</code></pre>
<p>The specific problem I'm having is doing left and right shifts that carry through across the whole array. So for instance, if I did a <code>>> 4</code> on the above array, I'd end up with:</p>
<pre><code>uint[4] { 0x0008000, 0x000FA302, 0x000C800, 0x00FF00D };
</code></pre>
<p>Now, an (overly) simplistic algorithm here might look something like (this is me writting code on the fly):</p>
<pre><code>int shift = 4;
for (int i = 0; i <= shift; i++) {
for (int j = bitfield.GetUpperBound(0); j > 0; j--) {
bitfield[j] = bitfield[j] >> 1;
bitfield[j] = bitfield[j] + ((bitfield[j-1] & 1) << (sizeof(uint)*8));
}
bitfield[0] = bitfield[0] >> 1;
}
</code></pre>
<p>Is there anything built in that might ease working with this sort of data? </p>
| [
{
"answer_id": 178623,
"author": "Christoffer Lette",
"author_id": 11808,
"author_profile": "https://Stackoverflow.com/users/11808",
"pm_score": 0,
"selected": false,
"text": "public static class BitArrayExtensions\n{\n public static void DownShift(this BitArray bitArray, int places)\... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15537/"
] |
178,199 | <p>In PHP I can name my array indices so that I may have something like:</p>
<pre><code>$shows = Array(0 => Array('id' => 1, 'name' => 'Sesame Street'),
1 => Array('id' => 2, 'name' => 'Dora The Explorer'));
</code></pre>
<p>Is this possible in Python?</p>
| [
{
"answer_id": 178211,
"author": "Lou Franco",
"author_id": 3937,
"author_profile": "https://Stackoverflow.com/users/3937",
"pm_score": 3,
"selected": false,
"text": "a = {\"id\": 1, \"name\":\"Sesame Street\"}\n"
},
{
"answer_id": 178213,
"author": "Michael Twomey",
"aut... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/115/"
] |
178,200 | <p>I have the following JSP code, that protects my web page and displays it only to know IP's</p>
<pre><code>String ip_h = request.getRemoteAddr();
String host_h = request.getRemoteHost();
String iplist[] = new String[1];
iplist[0] = "127.0.0.1";
iplist[1] = "10.217.106.248";
int count = iplist.length;
boolean flag = false;
int zz = 0;
//return;
System.out.println(host_h);
while ( (flag==false) && ( zz < count) )
{
if (ip_h.equals(iplist[zz]) || host_h.equals(iplist[zz]) )
{
flag = true;
}
zz++;
}
</code></pre>
<p>However, I would to rather check for subnet ranges, i.e. all users belonging to 10.217.0.0/16 are allowed.</p>
<p>How do I do this?</p>
| [
{
"answer_id": 178293,
"author": "Bruno De Fraine",
"author_id": 6918,
"author_profile": "https://Stackoverflow.com/users/6918",
"pm_score": 0,
"selected": false,
"text": "Subnet"
},
{
"answer_id": 178339,
"author": "Lazarin",
"author_id": 24124,
"author_profile": "ht... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
178,210 | <p>We are building a multi-tenant website in ASP.NET, and we must let each customer configure their own security model. They must be able to define their own roles, and put users in those roles. What is the best way to do this?</p>
<p>There are tons of simple examples of page_load events that have code like:</p>
<pre><code> if (!user.InGroup("Admin")
Response.Redirect("/NoAccess.aspx");
</code></pre>
<p>But that hard codes the groups and permissions in the code. How can I make it user configurable?</p>
| [
{
"answer_id": 178238,
"author": "ullmark",
"author_id": 23044,
"author_profile": "https://Stackoverflow.com/users/23044",
"pm_score": 0,
"selected": false,
"text": "foreach(var group in ThisPageConfiguration.AcceptedRoleNames)\nif (user.IsInRole(group))\n...\n"
},
{
"answer_id":... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681/"
] |
178,215 | <p>We are using log4j behind a selfmade wrapper. We plan to use much more features of it now. </p>
<p>Should we update to logback ?</p>
<p>(I mean the framework not a facade like SLF4J)</p>
| [
{
"answer_id": 22115384,
"author": "Christian",
"author_id": 690771,
"author_profile": "https://Stackoverflow.com/users/690771",
"pm_score": 6,
"selected": false,
"text": "logger.debug(\"Temperature set to {}. Old temperature was {}.\", t, oldT);"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
178,216 | <p>In Informix, how can I cast a <code>char(8)</code> type into a <code>money</code> type, so that I can compare it to another <code>money</code> type?</p>
<p>Using "<code>tblAid.amt::money as aid_amt</code>" did not work.
Using "<code>(tblAid.amt * 1) AS aid_amt</code>" did not work.</p>
| [
{
"answer_id": 185890,
"author": "SKapsal",
"author_id": 24721,
"author_profile": "https://Stackoverflow.com/users/24721",
"pm_score": 4,
"selected": true,
"text": "select (disb_amt::NUMERIC) disb_amt from tmp_kygrants;\n"
},
{
"answer_id": 188635,
"author": "Jonathan Leffler... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13832/"
] |
178,233 | <p>Does anyone know how to use the credential cache or network credential to get the user's personal info from the Active Directory using C# or VB? I need to get personal info such as name, telephone ID and so on.</p>
| [
{
"answer_id": 217013,
"author": "benPearce",
"author_id": 4490,
"author_profile": "https://Stackoverflow.com/users/4490",
"pm_score": 1,
"selected": false,
"text": "DirectorySearcher ds = new DirectorySearcher(\"LDAP://DC=test,dc=com\");\nds.Filter = String.Format(\"&(samaccountname={0}... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178233",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/23491/"
] |
178,247 | <p>I have minified my javascript and my css.</p>
<p>Now, Which is better?</p>
<pre><code><script type="text/javascript">
<?
$r = file_get_contents('min.js');
if($r) echo $r;
?>
</script>
</code></pre>
<p>OR</p>
<pre><code><script type="text/javascript" src="min.js"></script>
</code></pre>
<p>Same question for CSS.</p>
<p>If the answer is 'sometimes because browsers fetch files simultaneously?' Which browsers, and what are examples of the times in either scenario.</p>
| [
{
"answer_id": 178269,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 6,
"selected": true,
"text": "<script type=\"text/javascript\" src=\"min.js\"></script>\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/144/"
] |
178,255 | <p>I'm talking about c# <del>3.5</del> 3.0.
I know how to do it when cache or ServiceProvider can have only one instance for the whole application. In this case ServiceProvider can look like this</p>
<pre><code>public static class Service<T>
{
public static T Value {get; set;}
}
</code></pre>
<p>and can be used for different types like this:</p>
<pre><code>Service<IDbConnection>.Value = new SqlConnection("...");
Service<IDesigner>.Value = ...;
//...
IDbCommand cmd = Service<IDbConnection>.Value.CreateCommand();
</code></pre>
<p>Static cache is also easy:</p>
<pre><code>public static class Cache<T>
{
private static Dictionary<int, T> cache = new Dictionary<int, T>();
public static void Add(int key, T value)
{
cache.Add(key, value);
}
public static T Find(int key)
{
return cache[key];
}
}
</code></pre>
<p>and can be used like this:</p>
<pre><code>Cache<string>.Add(1, "test");
Cache<DateTime>.Add(2, DateTime.Now);
//...
string found = Cache<string>.Find(1);
</code></pre>
<p><br>
<strong>My question is</strong>: how can I create similiar cache or service provider when I want to have 2 or more different instances of each. Here is example code, how I want to use service provider:</p>
<pre><code>ServiceProvider provider = new ServiceProvider();
provider.Add<IDbConnection>(new SqlConnection("..."));
provider.Add<IDesigner>(...);
//...
ServiceProvider provider1 = new ServiceProvider();
provider1.Add<IDbConnection>(new SqlConnection("..."));
//...
//...
IDbCommand cmd1 = provider.GetService<IDbConnection>().CreateCommand();
IDbCommand cmd2 = provider1.GetService<IDbConnection>().CreateCommand();
</code></pre>
<p>The only implementation that I have in my head is using <strong>casting which I want to avoid</strong>.</p>
<pre><code>public class ServiceProvider
{
private Dictionary<Type, object> services = new Dictionary<Type, object>();
public void Add<T>(T value)
{
services.Add(typeof(T), value);
}
public T GetService<T>()
{
return (T) services[typeof (T)];
}
}
</code></pre>
| [
{
"answer_id": 186847,
"author": "James Hart",
"author_id": 5755,
"author_profile": "https://Stackoverflow.com/users/5755",
"pm_score": 1,
"selected": false,
"text": " public class TypeDictionary \n { \n private class InnerTypeDictionary<T>\n {\n static Weak... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22569/"
] |
178,257 | <p>Huge files take forever to load and work with in vim, due to syntax-highlighting.</p>
<p>I'm looking for a way to limit size of highlighted files, such that files larger than (say) 10MB will be colorless.</p>
| [
{
"answer_id": 559052,
"author": "Paul Oyster",
"author_id": 38193,
"author_profile": "https://Stackoverflow.com/users/38193",
"pm_score": 6,
"selected": true,
"text": "autocmd BufWinEnter * if line2byte(line(\"$\") + 1) > 1000000 | syntax clear | endif\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6984/"
] |
178,263 | <p>I am testing a web app that writes cookies to subdomain.thisdomain.com and several subfolders within that. I'm looking for JavaScript that I can put into a bookmarklet that will delete all cookies under that subdomain, regardless of the folder in which they exist.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 179535,
"author": "Robert J. Walker",
"author_id": 4287,
"author_profile": "https://Stackoverflow.com/users/4287",
"pm_score": 6,
"selected": true,
"text": "javascript:new function(){var c=document.cookie.split(\";\");for(var i=0;i<c.length;i++){var e=c[i].indexOf(\"=\");v... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/335036/"
] |
178,265 | <p>Today at work we came across the following code (some of you might recognize it):</p>
<pre><code>#define GET_VAL( val, type ) \
{ \
ASSERT( ( pIP + sizeof(type) ) <= pMethodEnd ); \
val = ( *((type *&)(pIP))++ ); \
}
</code></pre>
<p>Basically we have a byte array and a pointer. The macro returns a reference to a variable of type and advance the pointer to the end of that variable.</p>
<p>It reminded me of the several times that I needed to "think like a parser" in order to understand C++ code.</p>
<p>Do you know of other code examples that caused you to stop and read it several times till you managed to grasp what it was suppose to do?</p>
| [
{
"answer_id": 178308,
"author": "Simon",
"author_id": 24039,
"author_profile": "https://Stackoverflow.com/users/24039",
"pm_score": 2,
"selected": false,
"text": "ihi = y[0]>y[1] ? (inhi=1,0) : (inhi=0,1);\n"
},
{
"answer_id": 178361,
"author": "Ma99uS",
"author_id": 203... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11361/"
] |
178,320 | <p>When you're passing variables through your site using GET requests, do you validate (regular expressions, filters, etc.) them before you use them?</p>
<p>Say you have the URL <a href="http://www.example.com/i=45&p=custform" rel="nofollow noreferrer">http://www.example.com/i=45&p=custform</a>. You know that "i" will always be an integer and "p" will always contain only letters and/or numbers. Is it worth the time to make sure that no one has attempted to manipulate the values and then resubmit the page?</p>
| [
{
"answer_id": 178371,
"author": "Treb",
"author_id": 22114,
"author_profile": "https://Stackoverflow.com/users/22114",
"pm_score": 0,
"selected": false,
"text": "IsInt(i), IsString(p)"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1444511/"
] |
178,325 | <p>How do I toggle the visibility of an element using <code>.hide()</code>, <code>.show()</code>, or <code>.toggle()</code>?</p>
<p>How do I test if an element is <code>visible</code> or <code>hidden</code>?</p>
| [
{
"answer_id": 178344,
"author": "Mote",
"author_id": 24789,
"author_profile": "https://Stackoverflow.com/users/24789",
"pm_score": 10,
"selected": false,
"text": "if ( $(element).css('display') == 'none' || $(element).css(\"visibility\") == \"hidden\"){\n // 'element' is hidden\n}\n"... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178325",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21709/"
] |
178,326 | <p>I have an MFC app which I have been working on for a few weeks now, I want to manually set the dimensions of the main frame when it is loaded, can someone give me a hand with this, specifically where to put the code as well?</p>
<p>Thanks!</p>
| [
{
"answer_id": 178349,
"author": "IanW",
"author_id": 3875,
"author_profile": "https://Stackoverflow.com/users/3875",
"pm_score": 2,
"selected": false,
"text": "CRect rect;\nSystemParametersInfo(SPI_GETWORKAREA,0,&rect,0);\nscreen_x_size=rect.Width(); \nscreen_y_size=rect.Height();\n"
... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18664/"
] |
178,328 | <p>In PHP, function parameters can be passed by reference by prepending an ampersand to the parameter in the function declaration, like so:</p>
<pre><code>function foo(&$bar)
{
// ...
}
</code></pre>
<p>Now, I am aware that this is <i>not</i> designed to improve performance, but to allow functions to change variables that are normally out of their scope.</p>
<p>Instead, PHP seems to use Copy On Write to avoid copying objects (and maybe also arrays) until they are changed. So, for functions that do not change their parameters, the effect should be the same as if you had passed them by reference.</p>
<p>However, I was wondering if the Copy On Write logic maybe is shortcircuited on pass-by-reference and whether that has any performance impact.</p>
<p><i>ETA: To be sure, I assume that it's not faster, and I am well aware that this is not what references are for. So I think my own guesses are quite good, I'm just looking for an answer from someone who really knows what's definitely happening under the hood. In five years of PHP development, I've always found it hard to get quality information on PHP internals short from reading the source.</i></p>
| [
{
"answer_id": 3845530,
"author": "ikary",
"author_id": 464550,
"author_profile": "https://Stackoverflow.com/users/464550",
"pm_score": 7,
"selected": false,
"text": "pass by value: 0.12065005 seconds\npass by reference: 1.52171397 seconds\n"
},
{
"answer_id": 6577819,
... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] |
178,333 | <p>Since multiple inheritance is bad (it makes the source more complicated) C# does not provide such a pattern directly. But sometimes it would be helpful to have this ability.</p>
<p>For instance I'm able to implement the missing multiple inheritance pattern using interfaces and three classes like that:</p>
<pre><code>public interface IFirst { void FirstMethod(); }
public interface ISecond { void SecondMethod(); }
public class First:IFirst
{
public void FirstMethod() { Console.WriteLine("First"); }
}
public class Second:ISecond
{
public void SecondMethod() { Console.WriteLine("Second"); }
}
public class FirstAndSecond: IFirst, ISecond
{
First first = new First();
Second second = new Second();
public void FirstMethod() { first.FirstMethod(); }
public void SecondMethod() { second.SecondMethod(); }
}
</code></pre>
<p>Every time I add a method to one of the interfaces I need to change the class <em>FirstAndSecond</em> as well.</p>
<p>Is there a way to inject multiple existing classes into one new class like it is possible in C++?</p>
<p>Maybe there is a solution using some kind of code generation?</p>
<p>Or it may look like this (imaginary c# syntax):</p>
<pre><code>public class FirstAndSecond: IFirst from First, ISecond from Second
{ }
</code></pre>
<p>So that there won't be a need to update the class FirstAndSecond when I modify one of the interfaces.</p>
<hr />
<h3>EDIT</h3>
<p>Maybe it would be better to consider a practical example:</p>
<p>You have an existing class (e.g. a text based TCP client based on ITextTcpClient) which you do already use at different locations inside your project. Now you feel the need to create a component of your class to be easy accessible for windows forms developers.</p>
<p>As far as I know you currently have two ways to do this:</p>
<ol>
<li><p>Write a new class that is inherited from components and implements the interface of the TextTcpClient class using an instance of the class itself as shown with FirstAndSecond.</p>
</li>
<li><p>Write a new class that inherits from TextTcpClient and somehow implements IComponent (haven't actually tried this yet).</p>
</li>
</ol>
<p>In both cases you need to do work per method and not per class. Since you know that we will need all the methods of TextTcpClient and Component it would be the easiest solution to just combine those two into one class.</p>
<p>To avoid conflicts this may be done by code generation where the result could be altered afterwards but typing this by hand is a pure pain in the ass.</p>
| [
{
"answer_id": 178368,
"author": "Chris Wenham",
"author_id": 5548,
"author_profile": "https://Stackoverflow.com/users/5548",
"pm_score": 8,
"selected": false,
"text": "ISteerable"
},
{
"answer_id": 178413,
"author": "Amy B",
"author_id": 8155,
"author_profile": "http... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25782/"
] |
178,396 | <p>OK, another road bump in my current project.</p>
<p>I have never had form elements in <strong>both</strong> my master and content pages, I tend to have all the forms in the content where relevant.</p>
<p>In the current project however, we have a page where they want both. <strong>A login form at the top right, and a questions form in the content.</strong></p>
<p>Having tried to get this in, I have run in to the issue of ASP.NET moaning about the need for a single form element in a master page. TBH, I really dont get why this is a requirement on ASP.NET's part, but hey ho.</p>
<p><strong>Does anyone know if/how I can get the master and content pages to contain form elements that work independantly?</strong></p>
<p>If not, can you offer advice on how to proceed to get the desired look/functionality?</p>
| [
{
"answer_id": 178525,
"author": "John Rudy",
"author_id": 14048,
"author_profile": "https://Stackoverflow.com/users/14048",
"pm_score": 2,
"selected": false,
"text": "asp:ContentPlaceHolder"
},
{
"answer_id": 240608,
"author": "Rob Cooper",
"author_id": 832,
"author_... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] |
178,398 | <p>Generally, MVC frameeworks have a structure that looks something like:</p>
<pre><code>/models
/views
/controllers
/utils
</code></pre>
<p>However, in a web application suite, I've decided that clumping all models, views, and controllers together probably wouldn't be the best for clarity, unless I treated the system as one application instead of an application suite. However, some things tie every "application" together, like the notion of users and user roles.</p>
<p>So I have three possible solutions:</p>
<p>(1) Do what I don't really want to do, and keep every model, view, and controller together, regardless of which app it belongs to. This is treating the suite as a single application, since they are tied together by several common threads, including users.</p>
<p>(2) Group the code by application.</p>
<pre><code>/app1
/models
/views
/controllers
/utils
/app2
/models
/views
/controllers
/utils
</code></pre>
<p>(3) Group the code by type, letting utility code be shared among all of the applications.</p>
<pre><code>/models
/app1
/app2
/views
/app1
/app2
/controllers
/app1
/app2
/utils
</code></pre>
<p>Is there an option I missed? What would be the most logical scheme for future developers? I personally prefer 2 and 3, but perhaps most people would expect 1.</p>
| [
{
"answer_id": 178436,
"author": "Szymon Rozga",
"author_id": 7583,
"author_profile": "https://Stackoverflow.com/users/7583",
"pm_score": 3,
"selected": false,
"text": "/app1\n /models\n /views\n /controllers\n /utils\n/app2\n /models\n /views\n /controllers\n /utils\n/co... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] |
178,401 | <p>Can MySql 5.0 views use tables that are located on another server? What is the syntax for creating such a view?</p>
| [
{
"answer_id": 178438,
"author": "Noah Goodrich",
"author_id": 20178,
"author_profile": "https://Stackoverflow.com/users/20178",
"pm_score": 0,
"selected": false,
"text": "USE localhost.myDB;\n\nSELECT * FROM host2.db.tableName; \n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17583/"
] |
178,407 | <p>Say I have the following:</p>
<pre><code><ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
</code></pre>
<p>How would I select all the child elements after the first one using jQuery? So I can achieve something like:</p>
<pre><code><ul>
<li>First item</li>
<li class="something">Second item</li>
<li class="something">Third item</li>
</ul>
</code></pre>
| [
{
"answer_id": 178422,
"author": "Jonny Buchanan",
"author_id": 6760,
"author_profile": "https://Stackoverflow.com/users/6760",
"pm_score": 4,
"selected": false,
"text": "$(\"li\").slice(1).addClass(\"something\");\n"
},
{
"answer_id": 178425,
"author": "twernt",
"author_... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5802/"
] |
178,434 | <p>Objective-C has no namespaces; it's much like C, everything is within one global namespace. Common practice is to prefix classes with initials, e.g. if you are working at IBM, you could prefix them with "IBM"; if you work for Microsoft, you could use "MS"; and so on. Sometimes the initials refer to the project, e.g. Adium prefixes classes with "AI" (as there is no company behind it of that you could take the initials). Apple prefixes classes with NS and says this prefix is reserved for Apple only.</p>
<p>So far so well. But appending 2 to 4 letters to a class name in front is a very, very limited namespace. E.g. MS or AI could have an entirely different meanings (AI could be Artificial Intelligence for example) and some other developer might decide to use them and create an equally named class. <em>Bang</em>, namespace collision.</p>
<p>Okay, if this is a collision between one of your own classes and one of an external framework you are using, you can easily change the naming of your class, no big deal. <strong>But what if you use two external frameworks, both frameworks that you don't have the source to and that you can't change?</strong> Your application links with both of them and you get name conflicts. How would you go about solving these? What is the best way to work around them in such a way that you can still use both classes?</p>
<p>In C you can work around these by not linking directly to the library, instead you load the library at runtime, using dlopen(), then find the symbol you are looking for using dlsym() and assign it to a global symbol (that you can name any way you like) and then access it through this global symbol. E.g. if you have a conflict because some C library has a function named open(), you could define a variable named myOpen and have it point to the open() function of the library, thus when you want to use the system open(), you just use open() and when you want to use the other one, you access it via the myOpen identifier.</p>
<p>Is something similar possible in Objective-C and if not, is there any other clever, tricky solution you can use resolve namespace conflicts? Any ideas?</p>
<hr />
<h3>Update:</h3>
<p>Just to clarify this: answers that suggest how to avoid namespace collisions in advance or how to create a better namespace are certainly welcome; however, I will not accept them as <strong>the answer</strong> since they don't solve my problem. I have two libraries and their class names collide. I can't change them; I don't have the source of either one. The collision is already there and tips on how it could have been avoided in advance won't help anymore. I can forward them to the developers of these frameworks and hope they choose a better namespace in the future, but for the time being I'm searching a solution to work with the frameworks right now within a single application. Any solutions to make this possible?</p>
| [
{
"answer_id": 180674,
"author": "Barry Wark",
"author_id": 2140,
"author_profile": "https://Stackoverflow.com/users/2140",
"pm_score": 7,
"selected": false,
"text": "@compatibility_alias"
},
{
"answer_id": 10670578,
"author": "wcochran",
"author_id": 398461,
"author_... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15809/"
] |
178,456 | <p>Is it better to do this:</p>
<pre><code>try
{
...
}
catch (Exception ex)
{
...
throw;
}
</code></pre>
<p>Or this:</p>
<pre><code>try
{
...
}
catch (Exception ex)
{
...
throw ex;
}
</code></pre>
<p>Do they do the same thing? Is one better than the other?</p>
| [
{
"answer_id": 178464,
"author": "Torbjörn Gyllebring",
"author_id": 21182,
"author_profile": "https://Stackoverflow.com/users/21182",
"pm_score": 11,
"selected": true,
"text": "throw;\n"
},
{
"answer_id": 178486,
"author": "RB.",
"author_id": 15393,
"author_profile":... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13913/"
] |
178,458 | <p>I am in a project where we are starting refactoring some massive code base. One problem that immediately sprang up is that each file imports a lot of other files. How do I in an elegant way mock this in my unit test without having to alter the actual code so I can start to write unit-tests?</p>
<p>As an example: The file with the functions I want to test, imports ten other files which is part of our software and not python core libs.</p>
<p>I want to be able to run the unit tests as separately as possible and for now I am only going to test functions that does not depend on things from the files that are being imported.</p>
<p>Thanks for all the answers. </p>
<p>I didn't really know what I wanted to do from the start but now I think I know. </p>
<p>Problem was that some imports was only possible when the whole application was running because of some third-party auto-magic. So I had to make some stubs for these modules in a directory which I pointed out with sys.path</p>
<p>Now I can import the file which contains the functions I want to write tests for in my unit-test file without complaints about missing modules.</p>
| [
{
"answer_id": 178582,
"author": "S.Lott",
"author_id": 10661,
"author_profile": "https://Stackoverflow.com/users/10661",
"pm_score": 1,
"selected": false,
"text": "PYTHONPATH"
},
{
"answer_id": 178603,
"author": "Alex Coventry",
"author_id": 1941213,
"author_profile"... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12126/"
] |
178,462 | <p>I'm trying to setup an Apache/PHP/Postgresql server locally on my machine. I'm using Windows vista business 32bit. I tried to install everything manually (one thing at a time, apache, postgresql and php (all the latest stable releases)) and after I get everything up and running.</p>
<p>Whenever I try to run a script on my machine, I get a "What do you want to do with the *.php file?" dialog. The dialog is the browser's open/save dialog</p>
<p>I'm just trying to get the output of phpinfo() to make sure everything is up and running...</p>
<p>I already tried to mess around a bit with the Apache conf file, but since I don't know much about what I'm doing, I reinstalled everything again and the problem is still there. I kinda get the feeling it must have something to do with the PHP thingy isn't correctly installed.</p>
<p>When i try to get the output of phpinfo as in:</p>
<pre><code><pre><?php
phpinfo();
?></pre>
</code></pre>
<p>I get the browser's "Open/Save" dialog for the *.php file.</p>
| [
{
"answer_id": 178487,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": true,
"text": "LoadModule php5_module \"c:/php/php5apache2_2.dll\"\nAddType application/x-httpd-php .php\nPHPIniDir \"c:/php\"\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24098/"
] |
178,473 | <p>I have three TextBox controls on the page</p>
<pre><code><asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"
OnTextChanged="TextBox_TextChanged" TabIndex="1">
<asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"
OnTextChanged="TextBox_TextChanged" TabIndex="2">
<asp:TextBox ID="TextBox3" runat="server" AutoPostBack="True"
OnTextChanged="TextBox_TextChanged" TabIndex="3">
</code></pre>
<p>and an event handler</p>
<pre><code>protected void TextBox_TextChanged(object sender, EventArgs e)
{
WebControl changed_control = (WebControl)sender;
var next_controls = from WebControl control in changed_control.Parent.Controls
where control.TabIndex > changed_control.TabIndex
orderby control.TabIndex
select control;
next_controls.DefaultIfEmpty(changed_control).First().Focus();
}
</code></pre>
<p>The meaning of this code is to automatically select TextBox with next TabIndex after page post back (see <a href="https://stackoverflow.com/questions/173810/autopostback-with-textbox-loses-focus-question-made-clearer">Little JB's problem</a>). In reality I receive InvalidCastException because it's impossible to cast from System.Web.UI.LiteralControl (WebControl.Controls contains actually LiteralControls) to System.Web.UI.WebControls.WebControl. </p>
<p>I am interested is it possible to modify this aproach somehow to receive working solution? Thank you!</p>
| [
{
"answer_id": 178507,
"author": "Paul Nearney",
"author_id": 24071,
"author_profile": "https://Stackoverflow.com/users/24071",
"pm_score": 1,
"selected": false,
"text": "var nextcontrols = from WebControl control in \n Changed_control.Parent.Controls.OfType<TextBox... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11256/"
] |
178,479 | <p>What are the best workarounds for using a SQL <code>IN</code> clause with instances of <code>java.sql.PreparedStatement</code>, which is not supported for multiple values due to SQL injection attack security issues: One <code>?</code> placeholder represents one value, rather than a list of values.</p>
<p>Consider the following SQL statement:</p>
<pre><code>SELECT my_column FROM my_table where search_column IN (?)
</code></pre>
<p>Using <code>preparedStatement.setString( 1, "'A', 'B', 'C'" );</code> is essentially a non-working attempt at a workaround of the reasons for using <code>?</code> in the first place. </p>
<p>What workarounds are available?</p>
| [
{
"answer_id": 178517,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "PreparedStatement"
},
{
"answer_id": 178635,
"author": "stjohnroe",
"author_id": 2985,
"author_p... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15816/"
] |
178,482 | <p>For a school project, I need to create a way to create personnalized queries based on end-user choices.<br />
Since the user can choose basically any fields from any combination of tables, I need to find a way to map the tables in order to make a join and not have extraneous data (This may lead to incoherent reports, but we're willing to live with that).</p>
<p>For up to two tables, I already managed to design an algorithm that works fine. However, when I add another table, I can't find a way to path through my database. All tables available for the personnalized reports can be linked together so it really all falls down to finding which path to use.</p>
| [
{
"answer_id": 178517,
"author": "Adam Bellaire",
"author_id": 21632,
"author_profile": "https://Stackoverflow.com/users/21632",
"pm_score": 2,
"selected": false,
"text": "PreparedStatement"
},
{
"answer_id": 178635,
"author": "stjohnroe",
"author_id": 2985,
"author_p... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25818/"
] |
178,516 | <p>Answers to a recent post (Any chances to imitate times() Ruby method in C#?) use the <b>=></b> operator in the usage examples. What does this operator do? I can't locate it in my C# book, and it is hard to search for symbols like this online. (I couldn't find it.)</p>
| [
{
"answer_id": 178529,
"author": "Mark Ingram",
"author_id": 986,
"author_profile": "https://Stackoverflow.com/users/986",
"pm_score": 1,
"selected": false,
"text": "MyControl.OnMouseDown += (sender, e) =>\n{\n // Do something in the mouse down event\n};\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19274/"
] |
178,519 | <p>I'm just starting with CodeIgniter, and I am not sure where things such as css, js, and images should go. Outside the whole system folder seems ok, but that means everything is seperate. Inside means the filepaths are longer, and I'm worried that it might mess things up. What's the best practice on this issue?</p>
| [
{
"answer_id": 178534,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 5,
"selected": true,
"text": "/system\n/css\n/js\n/img\n"
},
{
"answer_id": 180835,
"author": "Click Online Design",
"author_id": 25695,
... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178519",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16511/"
] |
178,524 | <p>I recently read this Phil Haack post (<a href="http://haacked.com/archive/2007/06/13/the-most-useful-.net-utility-classes-developers-tend-to-reinvent.aspx" rel="nofollow noreferrer">The Most Useful .NET Utility Classes Developers Tend To Reinvent Rather Than Reuse</a>) from last year, and thought I'd see if anyone has any additions to the list.</p>
| [
{
"answer_id": 178544,
"author": "RB.",
"author_id": 15393,
"author_profile": "https://Stackoverflow.com/users/15393",
"pm_score": 5,
"selected": false,
"text": "return \"£\" & iSomeValue\n"
},
{
"answer_id": 178552,
"author": "James Curran",
"author_id": 12725,
"auth... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6624/"
] |
178,530 | <p>In our web-app we use PHP5.2.6 + PDO to connect to a SQL Server 2005 database and store Russian texts.</p>
<p>Database collation is <code>Cyrillic_General_CI_AS</code>, table collation is <code>Cyrillic_General_CI_AS</code>, column type is <code>NVARCHAR(MAX)</code>.</p>
<p>We tried connecting to a database using two following schemes, both causing different problems.</p>
<ol>
<li><p><em>PDO mssql:</em></p>
<pre><code>$dbh = new PDO ('mssql:host='.$mssql_server.';dbname='.$mssql_db, $mssql_login, $mssql_pwd);
</code></pre>
<p>in which case a result of a simple query like that:</p>
<pre><code>SELECT field1 FROM tbl1 WHERE id=1
</code></pre>
<p>shows <code>field1</code> data truncated to 255 bytes.</p></li>
<li><p><em>PDO odbc:</em> </p>
<pre><code>$dbh = new PDO ('odbc:DSN=myDSN;UID='.$mssql_login.';PWD='.$mssql_pwd);
</code></pre>
<p>in which case a result of the same query shows full not truncated data but with question marks instead of Russian symbols. </p></li>
</ol>
<hr>
<p>Notes:</p>
<ul>
<li>In the SQL Management Studio data is not truncated and Russian symbols are displayed properly as well.</li>
<li>We have Windows 2003 Enterprise Edition SP2</li>
</ul>
<p>So what should we choose as a connection method and how to fix corresponding issues?</p>
| [
{
"answer_id": 197395,
"author": "Greg",
"author_id": 24181,
"author_profile": "https://Stackoverflow.com/users/24181",
"pm_score": 3,
"selected": true,
"text": "SET NAMES \"charset\""
},
{
"answer_id": 2344628,
"author": "Liam Morland",
"author_id": 282357,
"author_p... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6647/"
] |
178,532 | <p>I have a rather large and complex set of programs to port from VC8 to VC9. One of the modules has a number of layered typedefs, which cause the compiler to generate a C4503 warning (decorated name truncated). The generated LIB file will not properly link to other modules in the project. VC8 had no trouble with this, leading me to conclude that either the decoration process has changed to generate even longer names, or the internal limit for the length of a decorated name has decreased. What's the best way to get over this?</p>
<p>For legacy code reasons, the MSDN suggestion of replacing typedefs with structs is not practical.</p>
<p>The typedefs in question are (sanitized code): </p>
<pre><code>enum Type{
TYPE_COUNT,
TYPE_VALUE
};
typedef MyVector< Container*, CriticalSectionLock > Containers;
typedef MyVector< MyClassType*, CriticalSectionLock >::const_iterator const_iterator_type;
typedef MyVector< stl::pair< string, Type > >::const_iterator const_iterator_def;
typedef MyVector< Container** >::const_iterator const_iterator_container;
typedef MyVector< stl::pair < MyBase*, MyVector< stl::pair< Container**, Containers* > > > >::const_iterator const_iterator;
</code></pre>
| [
{
"answer_id": 218959,
"author": "Howard Lee Harkness",
"author_id": 25823,
"author_profile": "https://Stackoverflow.com/users/25823",
"pm_score": 2,
"selected": false,
"text": "enum Type{\n TYPE_COUNT,\n TYPE_VALUE\n };\n\n struct Containers \n {\n MyVector<Container*, Critical... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25823/"
] |
178,539 | <p>How can I round a decimal number (floating point) to the nearest integer? </p>
<p>e.g.</p>
<pre><code>1.2 = 1
1.7 = 2
</code></pre>
| [
{
"answer_id": 178550,
"author": "EvdB",
"author_id": 5349,
"author_profile": "https://Stackoverflow.com/users/5349",
"pm_score": 6,
"selected": false,
"text": "use Math::Round;\nmy $rounded = round( $float );\n"
},
{
"answer_id": 178551,
"author": "Vinko Vrsalovic",
"aut... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12850/"
] |
178,561 | <p>I have the following VB.net interface that I need to port to C#. C# does not allow enumerations in interfaces. How can I port this without changing code that uses this interface?</p>
<pre><code>Public Interface MyInterface
Enum MyEnum
Yes = 0
No = 1
Maybe = 2
End Enum
ReadOnly Property Number() As MyEnum
End Interface
</code></pre>
| [
{
"answer_id": 178573,
"author": "Alexander Kojevnikov",
"author_id": 712,
"author_profile": "https://Stackoverflow.com/users/712",
"pm_score": 4,
"selected": false,
"text": "public enum MyEnum\n{\n Yes = 0,\n No = 1,\n Maybe = 2\n}\n\npublic interface IMyInterface\n{\n MyEnu... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25825/"
] |
178,572 | <p>A large international company deploys a new web and MOTO (Mail Order and Telephone Order) handling system. Among other things you are tasked to design format for both order and customer identification numbers.</p>
<p>What would be the best format in your opinion? Please list any assumptions and considerations.</p>
<hr>
<p><strong>Accepted Answer</strong></p>
<p>Michael Haren's answer selected due to the most up votes, but please do read other answers and comments as they make Michael's answer more complete.</p>
| [
{
"answer_id": 178706,
"author": "Kevin",
"author_id": 6386,
"author_profile": "https://Stackoverflow.com/users/6386",
"pm_score": 3,
"selected": false,
"text": "ddmmyyyy-####-####\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/22088/"
] |
178,578 | <p>I'm using Webbrowser control to login to HTTPS site with "untrusted certificate".
but I get popup such standart window "Security Alert" about untrusted certificate:</p>
<p><img src="https://i.stack.imgur.com/U01dp.jpg" alt="Security Alert window"></p>
<p>I have to find this window by title and send it <kbd>Alt</kbd>+<kbd>Y</kbd> to press <em>Yes</em>:</p>
<pre><code>int iHandle = NativeWin32.FindWindow(null, "Security Alert");
NativeWin32.SetForegroundWindow(iHandle);
System.Windows.Forms.SendKeys.Send("Y%");
</code></pre>
<p>but user can see a flickering of this window.</p>
<p>How can I ignore this alert?<br>
Or disable this "untrusted certificate" check in Webbrowser control?</p>
| [
{
"answer_id": 178595,
"author": "bobwienholt",
"author_id": 24257,
"author_profile": "https://Stackoverflow.com/users/24257",
"pm_score": 3,
"selected": true,
"text": "public static bool ValidateServerCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErro... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25826/"
] |
178,580 | <p>We are trying to bind a Linux machine (debian 4.0) to W2k3 AD. We have configured kerberos properly so that we can get TGTs. And users authenticate properly. However, PAM seems to be the sticky wicket. For example when we try to SSH to the linux machine as one of the AD users, the authentication succeeds (as per the auth.log) but I never get shell. The default environment is configured properly and PAM even creates the Homedir properly. As a reference we were loosely following:</p>
<p><a href="https://help.ubuntu.com/community/ActiveDirectoryHowto" rel="nofollow noreferrer">https://help.ubuntu.com/community/ActiveDirectoryHowto</a></p>
| [
{
"answer_id": 181906,
"author": "Pontus",
"author_id": 23483,
"author_profile": "https://Stackoverflow.com/users/23483",
"pm_score": 1,
"selected": false,
"text": "getent passwd avalidusername\n"
},
{
"answer_id": 296169,
"author": "csexton",
"author_id": 19839,
"aut... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
178,600 | <p>The project is ASP.NET 2.0, I have never been able to reproduce this myself, but I get emails informing me it happens to clients many times a week, often a few times in a row.</p>
<p>Here is the full error:</p>
<p>Exception Details: </p>
<blockquote>
<p>Microsoft.Reporting.WebForms.AspNetSessionExpiredException: ASP.NET session has expired</p>
</blockquote>
<p>Stack Trace: </p>
<blockquote>
<p>[AspNetSessionExpiredException: ASP.NET session has expired]
at Microsoft.Reporting.WebForms.ReportDataOperation..ctor()
at Microsoft.Reporting.WebForms.HttpHandler.GetHandler()
at Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Session Objects:75de8e1d65ff40d1ba666d940af5b118: Microsoft.Reporting.WebForms.ReportHierarchy
5210064be1fa4d6abf5dd5e56b262974: Microsoft.Reporting.WebForms.ReportHierarchy</p>
</blockquote>
| [
{
"answer_id": 178812,
"author": "Jon Adams",
"author_id": 2291,
"author_profile": "https://Stackoverflow.com/users/2291",
"pm_score": 5,
"selected": true,
"text": "protected void Application_Error(object sender, EventArgs e)\n{\n Exception exc = Server.GetLastError().GetBaseException... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21367/"
] |
178,601 | <pre><code><div spry:region="ds1" spry:repeatchildren="ds1">
<b spry:if=" '{title}'!='' ">
<!-- this is the first if -->
<a href="#" spry:if=" '{author}'!='' ">{author}
<!-- this is the second if -->
</a>
</b>
</div>
</code></pre>
<p><br><br>
I wonder if there is any method as simple as </p>
<pre><code>if(x==y && i>j)
</code></pre>
<p>in </p>
<pre><code><b>spry</b>
</code></pre>
<p>region.
I can't find any information in spry docs (labs.adobe.com/technologies/spry/)</p>
| [
{
"answer_id": 2810735,
"author": "porges",
"author_id": 10311,
"author_profile": "https://Stackoverflow.com/users/10311",
"pm_score": 1,
"selected": false,
"text": "spry:if"
},
{
"answer_id": 3352414,
"author": "loali",
"author_id": 404265,
"author_profile": "https:/... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24439/"
] |
178,611 | <p>When Instantiating a class, Windsor by default treats all public properties of the class as optional dependencies and tries to satisfy them. In my case, this creates a rather complicated circular dependency which causes my application to hang. </p>
<p>How can I explicitly tell Castle Windsor that it should not be trying to satisfy a public property? I assume there must be an attribute to that extent. I can't find it however so please let me know the appropriate namespace/assembly.</p>
<p>If there is any way to do this without attributes (such as Xml Configuration or configuration via code) that would be preferable since the specific library where this is happening has to date not needed a dependency on castle.</p>
| [
{
"answer_id": 182002,
"author": "Bittercoder",
"author_id": 4843,
"author_profile": "https://Stackoverflow.com/users/4843",
"pm_score": 4,
"selected": false,
"text": "kernel.GetHandler(typeof(MyComponent)).ComponentModel.Dependencies.RemoveAll(d => d.DependencyKey == \"PropertyThatShoul... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056/"
] |
178,645 | <p>There is some magic going on with WCF deserialization. How does it instantiate an instance of the data contract type without calling its constructor?</p>
<p>For example, consider this data contract:</p>
<pre><code>[DataContract]
public sealed class CreateMe
{
[DataMember] private readonly string _name;
[DataMember] private readonly int _age;
private readonly bool _wasConstructorCalled;
public CreateMe()
{
_wasConstructorCalled = true;
}
// ... other members here
}
</code></pre>
<p>When obtaining an instance of this object via <code>DataContractSerializer</code> you will see that the field <code>_wasConstructorCalled</code> is <code>false</code>.</p>
<p>So, how does WCF do this? Is this a technique that others can use too, or is it hidden away from us?</p>
| [
{
"answer_id": 179486,
"author": "Jason Jackson",
"author_id": 13103,
"author_profile": "https://Stackoverflow.com/users/13103",
"pm_score": 8,
"selected": true,
"text": "FormatterServices.GetUninitializedObject()"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178645",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/24874/"
] |
178,667 | <p>I have the following code:</p>
<pre><code>import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
public class ScratchPad {
public static void main(String args[]) throws Exception {
String html ="<html>"+
"<head>"+
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/>"+ // this is the problem right here
"<title>Error 400 BAD_REQUEST</title>"+
"</head>"+
"<body>"+
"<h2>HTTP ERROR: 400</h2><pre>BAD_REQUEST</pre>"+
"<p>RequestURI=null</p>"+
"<p><i><small><a href=\"http://jetty.mortbay.org\">Powered by jetty://</a></small></i></p>"+
"</body>"+
"</html>";
JFrame f = new JFrame();
JEditorPane editor = new JEditorPane();
editor.setEditable( false );
editor.getDocument().putProperty( "Ignore-Charset", "true" ); // this line makes no difference either way
editor.setContentType( "text/html" );
editor.setText( html );
f.add( new JScrollPane(editor, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) );
f.pack();
f.setVisible( true );
}
}
</code></pre>
<p>If you run it, you'll notice the frame is blank. However, if I remove the "; charset=ISO-8859-1" from the meta tag, the HTML shows up. Any ideas why and what I can do to prevent this (other than manually hacking the HTML string over which I have no control...).</p>
<p><strong>Edit #1</strong> - putProperty( "Ignore-Charset", "true" ) makes no difference unfortunately.</p>
| [
{
"answer_id": 1421097,
"author": "Horcrux7",
"author_id": 12631,
"author_profile": "https://Stackoverflow.com/users/12631",
"pm_score": 5,
"selected": true,
"text": "editor.getDocument().putProperty(\"IgnoreCharsetDirective\", Boolean.TRUE);\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6583/"
] |
178,669 | <p>How can i make my flash applications in a browser in full screen mode? I know that the stage can be put in that mode, but when i run the application in any browser this doesn't work. So, this can be done, but how?</p>
| [
{
"answer_id": 178709,
"author": "John Chuckran",
"author_id": 25511,
"author_profile": "https://Stackoverflow.com/users/25511",
"pm_score": -1,
"selected": false,
"text": " fscommand( \"fullscreen\" , \"true\" ) \n"
},
{
"answer_id": 178892,
"author": "Raleigh Buckner",
... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178669",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20601/"
] |
178,675 | <p>Is it possible to split large ASP.NET-pages into pieces? JSP has the <a href="http://java.sun.com/products/jsp/tags/11/syntaxref1112.html" rel="nofollow noreferrer">jsp:include</a> directive. Is there any equivivalent in ASP.NET</p>
<p>I'm not interested in reusing the pieces. I just want to organize the HTML/ASP code.</p>
<p>Isn't User Controls and Master Pages overkill for doing this?</p>
| [
{
"answer_id": 178779,
"author": "liggett78",
"author_id": 19762,
"author_profile": "https://Stackoverflow.com/users/19762",
"pm_score": 3,
"selected": true,
"text": "<!--#include file=\"inc_footer.aspx\"-->\n"
}
] | 2008/10/07 | [
"https://Stackoverflow.com/questions/178675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/25833/"
] |
178,696 | <p>I've got the following JavaScript on my web page...</p>
<pre><code>64 var description = new Array();
65 description[0] = "..."
66 description[1] = "..."
...
78 function init() {
79 document.getElementById('somedivid').innerHTML = description[0];
80 }
81
82 window.onload = init();
</code></pre>
<p>In Microsoft Internet Explorer it causes the following error...</p>
<blockquote>
<p>A Runtime Error has occurred.<br>
Do you wish to debug?</p>
<p>Line: 81<br>
Error: Not implemented</p>
</blockquote>
<p><img src="https://i.stack.imgur.com/n06sz.gif" alt="javascript runtime error"></p>
<p>Line 79 executes as expected.</p>
<p>If line 79 is commented out, it still throws the error.</p>
<p>If I comment out line 82, then the function does not execute and there is no error.</p>
| [
{
"answer_id": 178719,
"author": "Tomalak",
"author_id": 18771,
"author_profile": "https://Stackoverflow.com/users/18771",
"pm_score": 1,
"selected": false,
"text": "<body onload=\"init()\">"
},
{
"answer_id": 178727,
"author": "Ates Goral",
"author_id": 23501,
"autho... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] |
178,700 | <p>While simple, interface-driven event notification frameworks in Java have been around since pre-Cambrian times (e.g. java.beans.PropertyChangeSupport), it is becoming increasingly popular for frameworks to use annotation-driven event notification instead. </p>
<p>For an example, see <a href="http://www.jboss.org/file-access/default/members/jbosscache/freezone/docs/2.2.0.GA/userguide_en/html_single/index.html#api.listener" rel="noreferrer">JBossCache 2.2</a>. The listener class has its listener methods annotated, rather than conforming to a rigid interface. This is rather easier to program to, and easier to read, since you don't have to write empty implementations of listener callbacks that you're not interested in (and yes, I know about listener adapter superclasses).</p>
<p>Here's a sample from the JBossCache docs:</p>
<pre><code>@CacheListener
public class MyListener {
@CacheStarted
@CacheStopped
public void cacheStartStopEvent(Event e) {
switch (e.getType()) {
case Event.Type.CACHE_STARTED:
System.out.println("Cache has started");
break;
case Event.Type.CACHE_STOPPED:
System.out.println("Cache has stopped");
break;
}
}
@NodeCreated
@NodeRemoved
@NodeVisited
@NodeModified
@NodeMoved
public void logNodeEvent(NodeEvent ne) {
log("An event on node " + ne.getFqn() + " has occured");
}
</code></pre>
<p>}</p>
<p>The problem with this, is that it's very much more of an involved process writing the framework to support this sort of thing, due to the annotation-reflection nature of it.</p>
<p>So, before I charge off down the road of writing a generic framework, I was hoping someone had done it already. Has anyone come across such a thing?</p>
| [
{
"answer_id": 179056,
"author": "oxbow_lakes",
"author_id": 16853,
"author_profile": "https://Stackoverflow.com/users/16853",
"pm_score": 2,
"selected": false,
"text": "if (event instanceof NodeCreatedEvent)"
},
{
"answer_id": 179156,
"author": "Scott Stanchfield",
"auth... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21234/"
] |
178,712 | <p>I am reading an XML file into a DataSet and need to get the data out of the DataSet. Since it is a user-editable config file the fields may or may not be there. To handle missing fields well I'd like to make sure each column in the DataRow exists and is not DBNull. </p>
<p>I already check for DBNull but I don't know how to make sure the column exists without having it throw an exception or using a function that loops over all the column names. What is the best method to do this?</p>
| [
{
"answer_id": 178755,
"author": "Phillip Wells",
"author_id": 3012,
"author_profile": "https://Stackoverflow.com/users/3012",
"pm_score": 5,
"selected": false,
"text": "DataSet.Tables(0).Columns.Contains(name)"
},
{
"answer_id": 178766,
"author": "John Chuckran",
"author... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21186/"
] |
178,730 | <p>I have to lock user accounts in Active Directory programmatically in C#. </p>
<p>Unfortunately it doesn't work via the userAccountControl attribute. Every time I set userAccountControl to 528 (=normal account w/ lockout flag), Active Directory won't accept the value and resets it without further notice to 512 (=normal account).</p>
<p>Now I tried to lock the account by providing incorrect credentials (see below), but this doesn't work either.</p>
<pre><code>int retries = 0;
while (!adsUser.IsAccountLocked && retries < MAX_LOCK_RETRIES)
{
retries++;
try
{
new DirectoryEntry(userPath, logonName, incorrectPassword).RefreshCache();
}
catch (Exception)
{
/* ... */
}
adsUser.GetInfo();
}
</code></pre>
<p>Any ideas?</p>
| [
{
"answer_id": 6389998,
"author": "Robert Seitz",
"author_id": 803729,
"author_profile": "https://Stackoverflow.com/users/803729",
"pm_score": 0,
"selected": false,
"text": "DirectoryEntry de = result.GetDirectoryEntry();\nint val = (int)de.Properties[\"userAccountControl\"].Value;\nde.P... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178730",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/830/"
] |
178,738 | <p>Is there a way to catch a click on a cell in VBA with Excel? I am not referring to the <code>Worksheet_SelectionChange</code> event, as that will not trigger multiple times if the cell is clicked multiple times. <code>BeforeDoubleClick</code> does not solve my problem either, as I do not want to require the user to double click that frequently.</p>
<p>My current solution does work with the <code>SelectionChange</code> event, but it appears to require the use of global variables and other suboptimal coding practices. It also seems prone to error.</p>
| [
{
"answer_id": 180695,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 3,
"selected": false,
"text": "Private Sub Worksheet_SelectionChange(ByVal Target As Range)\n 'put your code here to process the selection, then..\n Active... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12002/"
] |
178,740 | <p>Trying to use an excpetion class which could provide location reference for XML parsing, found an interesting behavior - compiler could not choose between overload which consumes an interface and one which needs System.Exception when I trying to pass XmlReader as a parameter.</p>
<p>Detais are following:</p>
<pre><code>//exception overloads:
public FilterXmlParseException(string message, Exception innerException)
: base(message, innerException) { }
public FilterXmlParseException(string message, IXmlLineInfo lineInfo) {...}
//Usage:
XmlReader reader = ...
IXmlLineInfo lineinfo = (IXmlLineInfo)reader;
//fails
throw new FilterXmlParseException("<Filter> element expected", reader);
//ok
throw new FilterXmlParseException("<Filter> element expected", lineinfo);
</code></pre>
<p>And it fails since it could not select correct overload.But why? We see that XmlReader supports an interface and it is not inherited from System.Exception</p>
| [
{
"answer_id": 178764,
"author": "Grzenio",
"author_id": 5363,
"author_profile": "https://Stackoverflow.com/users/5363",
"pm_score": 2,
"selected": true,
"text": "//fails\nthrow new FilterXmlParseException(\"<Filter> element expected\", reader);\n"
},
{
"answer_id": 178798,
"... | 2008/10/07 | [
"https://Stackoverflow.com/questions/178740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/21603/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.