qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
27,405 | <p>On an 8-bit micro controller I would like to do the following:</p>
<pre><code>16bit_integer = another_16bit_integer * 0.997;</code></pre>
<p>with the least possible number of instructions.</p>
| [
{
"answer_id": 27415,
"author": "T Percival",
"author_id": 954,
"author_profile": "https://Stackoverflow.com/users/954",
"pm_score": 2,
"selected": false,
"text": "16bit_integer = (int16_t) (another_16bit_integer * (int32_t) 997 / 1000);\n"
},
{
"answer_id": 27418,
"author": ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/609/"
] |
27,407 | <p>Virtual memory from a computer size perspective is </p>
<blockquote>
<p>[a way to make the program] think it
has a large range of contiguous
addresses; but in reality the parts it
is currently using are scattered
around RAM, and the inactive parts are
saved in a disk file. (<a href="http://en.wikipedia.org/wiki/Virtual_memory" rel="noreferrer">Wikipedia</a>)</p>
</blockquote>
<p>I would interpret VM Size in the Windows Task manager as either the total addressable virtual memory space or the amount of memory the process is currently using in the virtual memory space. </p>
<p>But in the Task Manager the WM Size is in many cases less than Mem Usage, which should be amount of RAM the process is using. Therefor I guess that WM Size means something else?</p>
| [
{
"answer_id": 27426,
"author": "T Percival",
"author_id": 954,
"author_profile": "https://Stackoverflow.com/users/954",
"pm_score": 1,
"selected": false,
"text": "cat"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1918/"
] |
27,435 | <p>I am working on a web application using Python (Django) and would like to know whether MySQL or PostgreSQL would be more suitable when deploying for production.</p>
<p>In one <a href="https://blog.stackoverflow.com/2008/06/podcast-8/">podcast</a> Joel said that he had some problems with MySQL and the data wasn't consistent.</p>
<p>I would like to know whether someone had any such problems. Also when it comes to performance which can be easily tweaked?</p>
| [
{
"answer_id": 27440,
"author": "Josh",
"author_id": 257,
"author_profile": "https://Stackoverflow.com/users/257",
"pm_score": 8,
"selected": true,
"text": "count"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1448/"
] |
27,442 | <p>Is there a rake task for backing up the data in your database? </p>
<p>I already have my schema backed up, but I want to make a backup of the data. It's a small MySQL database. </p>
| [
{
"answer_id": 27448,
"author": "thelsdj",
"author_id": 163,
"author_profile": "https://Stackoverflow.com/users/163",
"pm_score": 4,
"selected": true,
"text": "set :dbuser \"user\"\nset :dbhost \"host\"\nset :database \"db\"\n\nnamespace :db do\n desc \"Get the database password from us... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1632/"
] |
27,472 | <p>I have a long running SQL statement that I want to run, and no matter what I put in the "timeout=" clause of my connection string, it always seems to end after 30 seconds. </p>
<p>I'm just using <code>SqlHelper.ExecuteNonQuery()</code> to execute it, and letting it take care of opening connections, etc.</p>
<p>Is there something else that could be overriding my timeout, or causing sql server to ignore it? I have run profiler over the query, and the trace doesn't look any different when I run it in management studio, versus in my code.</p>
<p>Management studio completes the query in roughly a minute, but even with a timeout set to 300, or 30000, my code still times out after 30 seconds.</p>
| [
{
"answer_id": 27477,
"author": "Ishmaeel",
"author_id": 227,
"author_profile": "https://Stackoverflow.com/users/227",
"pm_score": 4,
"selected": false,
"text": "SqlCommand command = new SqlCommand(sqlQuery, _Database.Connection);\ncommand.CommandTimeout = 0;\nint rows = command.ExecuteN... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/489/"
] |
27,474 | <p>I need to send hundreds of newsletters, but would like to check first if email exists on server. It's called <a href="http://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol" rel="noreferrer">SMTP</a> validation, at least I think so, based on my research on Internet. </p>
<p>There's several libraries that can do that, and also a page with open-source code in <a href="http://en.wikipedia.org/wiki/Active_Server_Pages" rel="noreferrer">ASP Classic</a> (<a href="http://www.coveryourasp.com/ValidateEmail.asp#Result3" rel="noreferrer">http://www.coveryourasp.com/ValidateEmail.asp#Result3</a>), but I have hard time reading ASP Classic, and it seems that it uses some third-party library... </p>
<p>Is there some code for SMTP validation in C#, and/or general explanation of how it works?</p>
| [
{
"answer_id": 2795865,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "\n // Create a new instance of the EmailValidator class.\n EmailValidator em = new EmailValidator();\n em.MessageLoggin... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1407/"
] |
27,482 | <p>Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to be able to send my generated pdf file to people and they should be able to write comments.
It seems like commenting is not allowed by default, how do I change this?</p>
<p>I am using straight to PDF with pdflatex and acrobat reader 9 to read and comment on the files</p>
| [
{
"answer_id": 27513,
"author": "onnodb",
"author_id": 1037,
"author_profile": "https://Stackoverflow.com/users/1037",
"pm_score": 2,
"selected": false,
"text": "pdflatex"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27482",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2450/"
] |
27,499 | <p>Recently Jeff has <a href="http://blog.codinghorror.com/deadlocked/" rel="noreferrer">posted</a> regarding his trouble with database deadlocks related to reading. <a href="https://en.m.wikipedia.org/wiki/Multiversion_concurrency_control" rel="noreferrer">Multiversion Concurrency Control (MVCC)</a> claims to solve this problem. What is it, and what databases support it?</p>
<p>updated: these support it (which others?)</p>
<ul>
<li>oracle</li>
<li>postgresql </li>
</ul>
| [
{
"answer_id": 952122,
"author": "John Greeley",
"author_id": 62209,
"author_profile": "https://Stackoverflow.com/users/62209",
"pm_score": 3,
"selected": false,
"text": "SET READ_COMMITTED_SNAPSHOT ON"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] |
27,509 | <p>How do I check if an object property in JavaScript is undefined?</p>
| [
{
"answer_id": 27510,
"author": "tslocum",
"author_id": 1662,
"author_profile": "https://Stackoverflow.com/users/1662",
"pm_score": -1,
"selected": false,
"text": "if (somevariable == undefined) {\n alert('the variable is not defined!');\n}\n"
},
{
"answer_id": 27517,
"autho... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] |
27,532 | <p>Given 2 rgb colors and a rectangular area, I'd like to generate a basic linear gradient between the colors. I've done a quick search and the only thing I've been able to find is <a href="http://jtauber.com/blog/2008/05/18/creating_gradients_programmatically_in_python/" rel="noreferrer">this blog entry</a>, but the example code seems to be missing, or at least it was as of this posting. Anything helps, algorithms, code examples, whatever. This will be written in Java, but the display layer is already taken care of, I just need to figure out how to figure out what to display.</p>
| [
{
"answer_id": 27536,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 6,
"selected": true,
"text": "R = firstCol.R * p + secondCol.R * (1 - p)\n"
},
{
"answer_id": 27553,
"author": "David Crow",
"author_... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/85/"
] |
27,559 | <p>The ones that stick out and make life usefull.</p>
| [
{
"answer_id": 27563,
"author": "chrissie1",
"author_id": 2936,
"author_profile": "https://Stackoverflow.com/users/2936",
"pm_score": 1,
"selected": false,
"text": "\n Imports Nunit.FrameWork\n\n Namespace $NAMESPACE$\n ''' \n ''' A TestClass\n ''' \n ''' \n _\n ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2936/"
] |
27,562 | <p>I am running oracle and have a query which pulls some results from the database. I would like to write the results as a text file. How would I go about doing this?</p>
<p>My prefered way would be by using UTL_FILE. Would some one have an example of how to do this?</p>
| [
{
"answer_id": 39409,
"author": "Andrew Wood",
"author_id": 1095,
"author_profile": "https://Stackoverflow.com/users/1095",
"pm_score": 2,
"selected": false,
"text": "\n create directory logfile as 'd:\\logfile'; -- must have priv to do this\n\ndeclare\n vFile utl_file.file_type;\nbegi... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
27,568 | <p>I'd like to learn how to program in Assembler. I've done a bit of assembly before (during my A-Level Computing course) but that was very definitely a simplified 'pseudo-assembler'. I've borrowed my Dad's old Z80 Assembler reference manual, and that seems quite interesting so if possible I'd like to have a go with Z80 assembler.</p>
<p>However, I don't have a Z80 processor to hand, and would like to do it on my PC (I have windows or linux so either is good). I've found various assemblers around on the internet, but I'm not particularly interested in assembling down to a hex file, I want to just be able to assemble it to something that some kind of simulator on the PC can run. Preferably this simulator would show me the contents of all the registers, memory locations etc, and let me step through instructions. I've found a few bits of software that suggest they might do this - but they either refuse to compile, or don't seem to work properly. Has anyone got any suggestions? If there are good simulator/IDE things available for another type of assembler then I could try that instead (assuming there is a good online reference manual available).</p>
| [
{
"answer_id": 27626,
"author": "Nic Wise",
"author_id": 2947,
"author_profile": "https://Stackoverflow.com/users/2947",
"pm_score": 2,
"selected": false,
"text": "<%@ page language=\"Asm80386\" %>\n<%\nStr: DB \"Testing...\", 0\n\n mov eax, -2\n cmp eax, 2\n jle Label1\n xor eax, e... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1912/"
] |
27,570 | <p>Is there a way to find the number of files of a specific type without having to loop through all results inn a Directory.GetFiles() or similar method? I am looking for something like this:</p>
<pre><code>int ComponentCount = MagicFindFileCount(@"c:\windows\system32", "*.dll");
</code></pre>
<p>I know that I can make a recursive function to call Directory.GetFiles , but it would be much cleaner if I could do this without all the iterating.</p>
<p><strong>EDIT:</strong> If it is not possible to do this without recursing and iterating yourself, what would be the best way to do it?</p>
| [
{
"answer_id": 27584,
"author": "Jon Limjap",
"author_id": 372,
"author_profile": "https://Stackoverflow.com/users/372",
"pm_score": 6,
"selected": true,
"text": "string[] files = directory.GetFiles(@\"c:\\windows\\system32\", \"*.dll\", SearchOption.AllDirectories);\n\nreturn files.Leng... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2257/"
] |
27,578 | <p>In Java (or any other language with checked exceptions), when creating your own exception class, how do you decide whether it should be checked or unchecked?</p>
<p>My instinct is to say that a checked exception would be called for in cases where the caller might be able to recover in some productive way, where as an unchecked exception would be more for unrecoverable cases, but I'd be interested in other's thoughts.</p>
| [
{
"answer_id": 73355,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 5,
"selected": false,
"text": "/**\n * Build a folder. <br />\n * Folder located under a Parent Folder (either RootFolder or an existing Folder)\n * @param aFo... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] |
27,581 | <p>What issues / pitfalls must be considered when overriding <code>equals</code> and <code>hashCode</code>?</p>
| [
{
"answer_id": 27609,
"author": "Antti Kissaniemi",
"author_id": 2948,
"author_profile": "https://Stackoverflow.com/users/2948",
"pm_score": 12,
"selected": true,
"text": "equals()"
},
{
"answer_id": 32223,
"author": "Ran Biron",
"author_id": 931,
"author_profile": "h... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/797/"
] |
27,598 | <p>I've deployed some Managed Beans on WebSphere 6.1 and I've managed to invoke them through a standalone client, but when I try to use the application "jconsole" distributed with the standard JDK can can't make it works.</p>
<p>Has anyone achieved to connect the jconsole with WAS 6.1?</p>
<p>IBM WebSphere 6.1 it's supossed to support JSR 160 JavaTM Management Extensions (JMX) Remote API. Furthermore, it uses the MX4J implementation (<a href="http://mx4j.sourceforge.net" rel="nofollow noreferrer">http://mx4j.sourceforge.net</a>). But I can't make it works with neither "jconsole" nor "MC4J".</p>
<p>I have the Classpath and the JAVA_HOME correctly setted, so the issue it's not there.</p>
| [
{
"answer_id": 922409,
"author": "Flueras Bogdan",
"author_id": 83843,
"author_profile": "https://Stackoverflow.com/users/83843",
"pm_score": 1,
"selected": false,
"text": " 1) Change the config.xml and start the server. \n"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2937/"
] |
27,599 | <p>(<strong>Updated a little</strong>)</p>
<p>I'm not very experienced with internationalization using PHP, it must be said, and a deal of searching didn't really provide the answers I was looking for.</p>
<p>I'm in need of working out a reliable way to convert only 'relevant' text to Unicode to send in an SMS message, using PHP (just temporarily, whilst service is rewritten using C#) - obviously, messages sent at the moment are sent as plain text.</p>
<p>I could conceivably convert everything to the Unicode charset (as opposed to using the standard GSM charset), but that would mean that <em>all</em> messages would be limited to 70 characters (instead of 160).</p>
<p>So, I guess my real question is: <em>what is the most reliable way to detect the requirement for a message to be Unicode-encoded, so I only have to do it when it's</em> <strong><em>absolutely necessary</em></strong> <em>(e.g. for non-Latin-language characters)?</em></p>
<h2>Added Info:</h2>
<p>Okay, so I've spent the morning working on this, and I'm still no further on than when I started (certainly due to my complete lack of competency when it comes to charset conversion). So here's the revised scenario:</p>
<p>I have text SMS messages coming from an external source, this external source provides the responses to me in plain text + Unicode slash-escaped characters. E.g. the 'displayed' text:</p>
<blockquote>
<p>Let's test öäü éàè אין תמיכה בעברית</p>
</blockquote>
<p>Returns:</p>
<blockquote>
<p>Let's test \u00f6\u00e4\u00fc \u00e9\u00e0\u00e8 \u05d0\u05d9\u05df \u05ea\u05de\u05d9\u05db\u05d4 \u05d1\u05e2\u05d1\u05e8\u05d9\u05ea</p>
</blockquote>
<p>Now, I can send on to my SMS provider in plaintext, GSM 03.38 or Unicode. Obviously, sending the above as plaintext results in a lot of missing characters (they're replaced by spaces by my provider) - I need to adopt relating to what content there is. What I want to <em>do</em> with this is the following:</p>
<ol>
<li><p>If all text is within the <a href="http://www.dreamfabric.com/sms/default_alphabet.html" rel="nofollow noreferrer">GSM 03.38 codepage</a>, send it as-is. (All but the Hebrew characters above fit into this category, but need to be converted.)</p></li>
<li><p>Otherwise, convert it to Unicode, and send it over multiple messages (as the Unicode limit is 70 chars not 160 for an SMS).</p></li>
</ol>
<p>As I said above, I'm stumped on doing this in PHP (C# wasn't much of an issue due to some simple conversion functions built-in), but it's quite probable I'm just missing the obvious, here. I couldn't find any pre-made conversion classes for 7-bit encoding in PHP, either - and my attempts to convert the string myself and send it on seemed futile.</p>
<p><strong>Any help would be greatly appreciated.</strong></p>
| [
{
"answer_id": 27603,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 0,
"selected": false,
"text": "mb_convert_encoding"
},
{
"answer_id": 27623,
"author": "Magnus Westin",
"author_id": 2957,
"author_profile"... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2951/"
] |
27,607 | <p>Let's say I have a list of server names stored in a vector, and I would like to contact them one at a time until one has successfully responded. I was thinking about using STL's find_if algorithm in the following way:</p>
<pre><code>find_if(serverNames.begin(), serverNames.end(), ContactServer());
</code></pre>
<p>Where ContactServer is a predicate function object.<br>
On one hand, there's a problem since the predicate will not always return the same result for the same server name (because of server downtime, network problems, etc...). However, the same result will be returned regardless of which copy of the predicate is used (<em>i.e.</em> the predicate has no real state), so the original problem with state-keeping predicates is not relevant in this case.</p>
<p>What do you say?</p>
| [
{
"answer_id": 27614,
"author": "Magnus Hoff",
"author_id": 2971,
"author_profile": "https://Stackoverflow.com/users/2971",
"pm_score": 2,
"selected": false,
"text": "ContactServer"
},
{
"answer_id": 27619,
"author": "Daren Thomas",
"author_id": 2260,
"author_profile"... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27607",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2150/"
] |
27,610 | <p>I want to introduce some tracing to a C# application I am writing. Sadly, I can never really remember how it works and would like a tutorial with reference qualities to check up on every now and then. It should include:</p>
<ul>
<li>App.config / Web.config stuff to add for registering TraceListeners</li>
<li>how to set it up in the calling application</li>
</ul>
<p>Do you know the über tutorial that we should link to?</p>
<hr/>
<p>Glenn Slaven pointed me in the right direction. Add this to your App.config/Web.config inside <code><configuration/></code>:</p>
<pre><code><system.diagnostics>
<trace autoflush="true">
<listeners>
<add type="System.Diagnostics.TextWriterTraceListener" name="TextWriter"
initializeData="trace.log" />
</listeners>
</trace>
</system.diagnostics>
</code></pre>
<p>This will add a <code>TextWriterTraceListener</code> that will catch everything you send to with <code>Trace.WriteLine</code>, etc.</p>
<p>@DanEsparza pointed out that you should use <code>Trace.TraceInformation</code>, <code>Trace.TraceWarning</code> and <code>Trace.TraceError</code> instead of <code>Trace.WriteLine</code>, as they allow you to format messages the same way as <code>string.Format</code>.</p>
<p><strong>Tip:</strong> If you don't add any listeners, then you can still see the trace output with the Sysinternals program <a href="https://learn.microsoft.com/en-us/sysinternals/downloads/debugview" rel="nofollow noreferrer">DebugView</a> (<code>Dbgview.exe</code>):</p>
| [
{
"answer_id": 35034967,
"author": "Shaun",
"author_id": 276874,
"author_profile": "https://Stackoverflow.com/users/276874",
"pm_score": 3,
"selected": false,
"text": "TraceSource.TraceEvent(TraceEventType, Int32, String)"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2260/"
] |
27,621 | <p>On the UNIX bash shell (specifically Mac OS X Leopard) what would be the simplest way to copy every file having a specific extension from a folder hierarchy (including subdirectories) to the same destination folder (without subfolders)?</p>
<p>Obviously there is the problem of having duplicates in the source hierarchy. I wouldn't mind if they are overwritten.</p>
<p>Example: I need to copy every .txt file in the following hierarchy</p>
<pre><code>/foo/a.txt
/foo/x.jpg
/foo/bar/a.txt
/foo/bar/c.jpg
/foo/bar/b.txt
</code></pre>
<p>To a folder named 'dest' and get:</p>
<pre><code>/dest/a.txt
/dest/b.txt
</code></pre>
| [
{
"answer_id": 27625,
"author": "Magnus Hoff",
"author_id": 2971,
"author_profile": "https://Stackoverflow.com/users/2971",
"pm_score": 7,
"selected": true,
"text": "find /foo -iname '*.txt' -exec cp \\{\\} /dest/ \\;\n"
},
{
"answer_id": 27747,
"author": "Stephen Darlington"... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2954/"
] |
27,622 | <p>The <strong><a href="http://msdn.microsoft.com/en-us/library/4wyz8787(VS.80).aspx" rel="noreferrer">TRACE macro</a></strong> can be used to output diagnostic messages to the debugger when the code is compiled in <strong>Debug</strong> mode. I need the same messages while in <strong>Release</strong> mode. Is there a way to achieve this?</p>
<p>(Please do <strong>not</strong> waste your time discussing why I should not be using TRACE in Release mode :-)</p>
| [
{
"answer_id": 27628,
"author": "Mark Ingram",
"author_id": 986,
"author_profile": "https://Stackoverflow.com/users/986",
"pm_score": 1,
"selected": false,
"text": "#define ATLTRACE __noop\n"
},
{
"answer_id": 41046,
"author": "Ferruccio",
"author_id": 4086,
... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1630/"
] |
27,643 | <p>On a web page I want to dynamically render very basic flow diagrams, i.e. a few boxes joined by lines. Ideally the user could then click on one of these boxes (<code>DIVs</code>?) and be taken to a different page. Resorting to Flash seems like an overkill. Is anyone aware of any client-side (i.e. <code>server agnostic</code>) Javascript or <code>CSS library/technique</code> that may help achieve this?</p>
| [
{
"answer_id": 16935309,
"author": "bluish",
"author_id": 505893,
"author_profile": "https://Stackoverflow.com/users/505893",
"pm_score": 2,
"selected": false,
"text": "/**Draw an arrow made of 3 lines. \n * Requires wz_jsGraphics (http://www.walterzorn.de/en/jsgraphics/jsgraphics_e.htm)... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2966/"
] |
27,674 | <p>In our project, <a href="http://sharpwired.sourceforge.net/" rel="nofollow noreferrer">SharpWired</a>, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not.</p>
<p>The requirements are that there should be one single list, with one element on each row. Each element must be a custom control. The whole list should be dynamically re-sizable, so that when you make it longer / shorter the list adds a scroll bar when needed and when you make it thinner / wider the custom controls should resize to the width of the list.</p>
<p>We've tried using a <code>FlowLayoutPanel</code> but haven't gotten resizing to work the way we want to. Preferably we should only have to set anchoring of the custom controls to Left & Right. We've also thought about using a <code>TableLayoutPanel</code> but found adding rows dynamically to be a too big overhead so far.</p>
<p>This must be quite a common use case, and it seems a bit weird to me that the <code>FlowLayoutPanel</code> has no intuitive way of doing this. <em>Has anyone done something similar or have tips or tricks to get us under way?</em></p>
<p>Cheers!<br>
/Adam</p>
| [
{
"answer_id": 619685,
"author": "SLaks",
"author_id": 34397,
"author_profile": "https://Stackoverflow.com/users/34397",
"pm_score": 3,
"selected": true,
"text": "DataRepeater"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27674",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2457/"
] |
27,695 | <p>It happens to me all the time. I accidentally version a file, I do not want to be versioned (i.e. developer/machine specific config-files).</p>
<p>If I commit this file, I will mess up the paths on all the other developer machines - they will be unhappy.</p>
<p>If I do delete the file from versioning, it will be deleted from the other developers machines - they will be unhappy.</p>
<p>If I choose to never commit the file, I always have a "dirty" checkout - I am unhappy.</p>
<p>Is a clean way to "unversion" a file from revision-control, that will result in no-one being unhappy?</p>
<p>edit: trying to clarify a bit: I have already commited the file to the repository and I want to only remove it from versioning - I specifically do not want it to be physically deleted from everyone doing a checkout. I initially wanted it to be ignored.</p>
<p>Answer: If I could accept a second answer, it would be <a href="https://stackoverflow.com/questions/27695/how-to-unversion-a-file-in-either-svn-andor-git#27727">this</a>. It answers my question with respect to git - the accepted answer is about svn.</p>
| [
{
"answer_id": 27701,
"author": "Sergio Acosta",
"author_id": 2954,
"author_profile": "https://Stackoverflow.com/users/2954",
"pm_score": 2,
"selected": false,
"text": "git rm <filename>\n"
},
{
"answer_id": 27707,
"author": "Greg Hewgill",
"author_id": 893,
"author_p... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870/"
] |
27,711 | <p>I'm having a problem obtaining the total row count for items displayed in a Gridview using Paging and with a LinqDataSource as the source of data.</p>
<p>I've tried several approaches:</p>
<pre><code>protected void GridDataSource_Selected(object sender, LinqDataSourceStatusEventArgs e)
{
totalLabel.Text = e.TotalRowCount.ToString();
}
</code></pre>
<p>returns -1 every time.</p>
<pre><code>protected void LinqDataSource1_Selected(object sender, LinqDataSourceStatusEventArgs e)
{
System.Collections.Generic.List<country> lst = e.Result as System.Collections.Generic.List<country>;
int count = lst.Count;
}
</code></pre>
<p>only gives me the count for the current page, and not the total.</p>
<p>Any other suggestions?</p>
| [
{
"answer_id": 3347416,
"author": "Nick Kahn",
"author_id": 275390,
"author_profile": "https://Stackoverflow.com/users/275390",
"pm_score": 0,
"selected": false,
"text": " protected void LinqDataSource1_Selecting(object sender, LinqDataSourceStatusEventArgs e)\n {\n Sys... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2841/"
] |
27,726 | <p>I completely understand the concept of expression trees, but I am having a hard time trying to find situations in which they are useful. Is there a specific instance in which expression trees can be applied? Or is it only useful as a transport mechanism for code? I feel like I am missing something here. Thanks!</p>
| [
{
"answer_id": 27736,
"author": "Fredrik Kalseth",
"author_id": 1710,
"author_profile": "https://Stackoverflow.com/users/1710",
"pm_score": 3,
"selected": false,
"text": "myMock.Verify(m => m.SomeMethod(someObject)); // tells moq to verify that the method\n ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27726",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2993/"
] |
27,743 | <p>My RubyOnRails app is set up with the usual pack of mongrels behind Apache configuration. We've noticed that our Mongrel web server memory usage can grow quite large on certain operations and we'd really like to be able to dynamically do a graceful restart of selected Mongrel processes at any time.</p>
<p>However, for reasons I won't go into here it can sometimes be <em>very</em> important that we don't interrupt a Mongrel while it is servicing a request, so I assume a simple process kill isn't the answer.</p>
<p>Ideally, I want to send the Mongrel a signal that says "finish whatever you're doing and then quit before accepting any more connections".</p>
<p>Is there a standard technique or best practice for this?</p>
| [
{
"answer_id": 27787,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 0,
"selected": false,
"text": "mongrel_cluster_ctl stop\n"
},
{
"answer_id": 31556,
"author": "AndrewR",
"author_id": 2994,
"author_... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27743",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2994/"
] |
27,745 | <p>Given the URL (single line):<br>
<a href="http://test.example.com/dir/subdir/file.html" rel="noreferrer">http://test.example.com/dir/subdir/file.html</a></p>
<p>How can I extract the following parts using regular expressions:</p>
<ol>
<li>The Subdomain (test)</li>
<li>The Domain (example.com)</li>
<li>The path without the file (/dir/subdir/)</li>
<li>The file (file.html)</li>
<li>The path with the file (/dir/subdir/file.html)</li>
<li>The URL without the path (<a href="http://test.example.com" rel="noreferrer">http://test.example.com</a>)</li>
<li>(add any other that you think would be useful)</li>
</ol>
<p>The regex should work correctly even if I enter the following URL: </p>
<pre><code>http://example.example.com/example/example/example.html
</code></pre>
| [
{
"answer_id": 27755,
"author": "hometoast",
"author_id": 2009,
"author_profile": "https://Stackoverflow.com/users/2009",
"pm_score": 8,
"selected": true,
"text": "^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)((\\/\\w+)*\\/)([\\w\\-\\.]+[^#?\\s]+)(.*)?(#[\\w\\-]+)?$"
},
{
"answer_id": ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] |
27,757 | <p>I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this:</p>
<pre><code>Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png");
</code></pre>
<p>The file, named "file.png" is stored in the "Resources" folder (within Visual Studio), and is marked as an embedded resource.</p>
<p>The code fails with an exception saying: </p>
<blockquote>
<p>Resource MyNamespace.Resources.file.png cannot be found in class MyNamespace.MyClass</p>
</blockquote>
<p>I have identical code (in a different assembly, loading a different resource) which works. So I know the technique is sound. My problem is I end up spending a lot of time trying to figure out what the correct path is. If I could simply query (eg. in the debugger) the assembly to find the correct path, that would save me a load of headaches.</p>
| [
{
"answer_id": 27769,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": false,
"text": "ProjectNamespace.Properties.Resources.file\n"
},
{
"answer_id": 27773,
"author": "John",
"author_id": ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1006/"
] |
27,758 | <p>OK, I know what you're thinking, "why write a method you do not want people to use?" Right?</p>
<p>Well, in short, I have a class that needs to be serialized to XML. In order for the <a href="https://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28v=vs.110%29.aspx" rel="noreferrer"><code>XmlSerializer</code></a> to do its magic, the class must have a default, empty constructor:</p>
<pre><code>public class MyClass
{
public MyClass()
{
// required for xml serialization
}
}
</code></pre>
<p>So, I need to have it, but I don't want people to <em>use</em> it, so <strong>is there any attribute that can be use to mark the method as "DO NOT USE"?</strong></p>
<p>I was thinking of using the <em>Obsolete</em> attribute (since this can stop the build), but that just seems kinda "wrong", is there any other way of doing this, or do I need to go ahead and bite the bullet? :)</p>
<h2>Update</h2>
<p>OK, I have accepted Keith's answer, since I guess in my heart of hearts, I totally agree. This is why I asked the question in the first place, I don't like the notion of having the <em>Obsolete</em> attribute.</p>
<h3>However...</h3>
<p>There <em>is</em> still a problem, while we are being notified in intellisense, ideally, we would like to break the build, so is there any way to do this? Perhaps create a custom attribute?</p>
<p><strong>More focused question has been created <a href="https://stackoverflow.com/questions/28150/create-an-attribute-to-break-the-build">here</a>.</strong></p>
| [
{
"answer_id": 27763,
"author": "hometoast",
"author_id": 2009,
"author_profile": "https://Stackoverflow.com/users/2009",
"pm_score": 2,
"selected": false,
"text": " /// <summary>\n /// do not use\n /// </summary>\n /// <param name=\"item\">don't pass it anything -- you shoul... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] |
27,774 | <p>Effectively I want to give numeric scores to alphabetic grades and sum them. In Excel, putting the <code>LOOKUP</code> function into an array formula works:</p>
<pre><code>{=SUM(LOOKUP(grades, scoringarray))}
</code></pre>
<p>With the <code>VLOOKUP</code> function this does not work (only gets the score for the first grade). Google Spreadsheets does not appear to have the <code>LOOKUP</code> function and <code>VLOOKUP</code> fails in the same way using:</p>
<pre><code>=SUM(ARRAYFORMULA(VLOOKUP(grades, scoresarray, 2, 0)))
</code></pre>
<p>or</p>
<pre><code>=ARRAYFORMULA(SUM(VLOOKUP(grades, scoresarray, 2, 0)))
</code></pre>
<p>Is it possible to do this (but I have the syntax wrong)? Can you suggest a method that allows having the calculation in one simple cell like this rather than hiding the lookups somewhere else and summing them afterwards?</p>
| [
{
"answer_id": 29690,
"author": "Sam Brightman",
"author_id": 2492,
"author_profile": "https://Stackoverflow.com/users/2492",
"pm_score": 1,
"selected": true,
"text": "MATCH"
},
{
"answer_id": 14738977,
"author": "HHains",
"author_id": 2048572,
"author_profile": "http... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2492/"
] |
27,818 | <p>We've embedded an OSGi runtime (Equinox) into out custom client-server application to facilitate plugin development and so far things are going great. We've been using Eclipse to build plugins due to the built-in manifest editor, dependency management, and export wizard. Using Eclipse to manager builds isn't very conducive to continuous integration via Hudson.</p>
<p>We have OSGi bundles which depend on other OSGi bundles. I'd really hate to hardcode build order in a custom ANT build. We've done this is the past and it's pretty horrible. Is there any build tool that can EASILY manage OSGi dependencies, if not automatically resolve them? Are there any DECENT examples of how to this?</p>
<p>CLARIFICATION:</p>
<p>The generated build scripts are only usable via Eclipse. They require manually running pieces of Eclipse. We've also got some standard targets which the Eclipse build won't have, and I don't want to modify the generated file since I may regenerate (I know I can do includes, but I want to avoid the Eclipse gen file all together)</p>
<p>Here is my project layout:</p>
<pre><code>/
-PluginA
-PluginB
-PluginC
.
.
.
</code></pre>
<p>In using the Eclipse PDE, each plugin has a Manifest, but no build.xml as the PDE does that for me. Hard to automate a gui driven process w/ Hudson. I'd like to setup my own build.xml to build each, BUT there are dependencies and build order issues. These issues are driven by the Manifest files (which describe OSGi imports). For example, PluginC depends on PluginB which depends on PluginA. They must be built in the correct order. I realize that I can manually control the build order, I'm looking for a tool to help automate the build order dependency management.</p>
| [
{
"answer_id": 5155085,
"author": "mike",
"author_id": 639398,
"author_profile": "https://Stackoverflow.com/users/639398",
"pm_score": 0,
"selected": false,
"text": "select 252 - osgi-archetype\nmvn idea:idea\n"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/287/"
] |
27,832 | <p>I have a DirectShow graph to render MPEG2/4 movies from a network stream. When I assemble the graph by connecting the pins manually it doesn't render. But when I call Render on the GraphBuilder it renders fine. </p>
<p>Obviously there is some setup step that I'm not performing on some filter in the graph that GraphBuilder is performing. </p>
<p>Is there any way to see debug output from GraphBuilder when it assembles a graph?</p>
<p>Is there a way to dump a working graph to see how it was put together?</p>
<p>Any other ideas for unraveling the mystery that lives in the DirectShow box?</p>
<p>Thanks!
-Z</p>
| [
{
"answer_id": 27858,
"author": "Timbo",
"author_id": 1810,
"author_profile": "https://Stackoverflow.com/users/1810",
"pm_score": 5,
"selected": true,
"text": "void AddToRot( IUnknown *pUnkGraph, DWORD *pdwRegister ) \n{\n IMoniker* pMoniker;\n IRunningObjectTable* pROT;\n GetRu... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2587612/"
] |
27,835 | <p>Recently, I started changing some of our applications to support <code>MS SQL Server</code> as an alternative back end. </p>
<p>One of the compatibility issues I ran into is the use of MySQL's CREATE TEMPORARY TABLE to create in-memory tables that hold data for very fast access during a session with no need for permanent storage.</p>
<p>What is the equivalent in MS SQL?</p>
<p>A requirement is that I need to be able to use the temporary table just like any other, especially <code>JOIN</code> it with the permanent ones.</p>
| [
{
"answer_id": 27842,
"author": "Matt Hamilton",
"author_id": 615,
"author_profile": "https://Stackoverflow.com/users/615",
"pm_score": 2,
"selected": false,
"text": "declare @foo table (\n Id int,\n Name varchar(100)\n);\n"
},
{
"answer_id": 27848,
"author": "JamesSugr... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] |
27,846 | <p>What is the configuration setting for modifying the default homepage in a Grails application to no longer be appName/index.gsp? Of course you can set that page to be a redirect but there must be a better way.</p>
| [
{
"answer_id": 17335212,
"author": "Rashedul.Rubel",
"author_id": 1632305,
"author_profile": "https://Stackoverflow.com/users/1632305",
"pm_score": 4,
"selected": false,
"text": "class UrlMappings {\n\n static mappings = {\n\n \"/$controller/$action?/$id?\"{\n constr... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3014/"
] |
27,850 | <p>So far I have encountered adjacency list, nested sets and nested intervals as models for storing tree structures in a database. I know these well enough and have migrated trees from one to another.</p>
<p>What are other popular models? What are their characteristics? What are good resources (books, web, etc) on this topic?</p>
<p>I'm not only looking for db storage but would like to expand my knowledge on trees in general. For example, I understand that nested sets/intervals are especially favorable for relational database storage and have asked myself, are they actually a <i>bad</i> choice in other contexts?</p>
| [
{
"answer_id": 27863,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 2,
"selected": false,
"text": "C:\\\n Temp\n Windows\n System32\n"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2077/"
] |
27,894 | <p>In SQL Server 2005, we can create temp tables one of two ways:</p>
<pre><code>declare @tmp table (Col1 int, Col2 int);
</code></pre>
<p>or</p>
<pre><code>create table #tmp (Col1 int, Col2 int);
</code></pre>
<p>What are the differences between these two? I have read conflicting opinions on whether @tmp still uses tempdb, or if everything happens in memory. </p>
<p>In which scenarios does one out-perform the other? </p>
| [
{
"answer_id": 64891,
"author": "Rory",
"author_id": 8479,
"author_profile": "https://Stackoverflow.com/users/8479",
"pm_score": 10,
"selected": true,
"text": "SELECT"
},
{
"answer_id": 8204184,
"author": "Martin Smith",
"author_id": 73226,
"author_profile": "https://... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1219/"
] |
27,899 | <p>Is there a way to make S3 default to an index.html page? E.g.: My bucket object listing:</p>
<pre><code>/index.html
/favicon.ico
/images/logo.gif
</code></pre>
<p>A call to <strong>www.example.com/<em>index.html</em></strong> works great! But if one were to call <strong>www.example.com/</strong> we'd either get a 403 or a REST object listing XML document depending on how bucket-level ACL was configured.</p>
<p>So, the question: Is there a way to have index.html functionality with content hosted on S3?</p>
| [
{
"answer_id": 5040105,
"author": "Alex Jasmin",
"author_id": 162407,
"author_profile": "https://Stackoverflow.com/users/162407",
"pm_score": 6,
"selected": true,
"text": "index.html"
},
{
"answer_id": 24377823,
"author": "fiatjaf",
"author_id": 973380,
"author_profil... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2961/"
] |
27,910 | <p>The <a href="http://doi.org/" rel="noreferrer">DOI</a> system places basically no useful limitations on what constitutes <a href="http://doi.org/handbook_2000/enumeration.html#2.2" rel="noreferrer">a reasonable identifier</a>. However, being able to pull DOIs out of PDFs, web pages, etc. is quite useful for citation information, etc.</p>
<p>Is there a reliable way to identify a DOI in a block of text without assuming the 'doi:' prefix? (any language acceptable, regexes preferred, and avoiding false positives a must)</p>
| [
{
"answer_id": 29639,
"author": "Silas Snider",
"author_id": 2933,
"author_profile": "https://Stackoverflow.com/users/2933",
"pm_score": 1,
"selected": false,
"text": "/(10\\.\\d+\\/\\d+)/\n"
},
{
"answer_id": 1876427,
"author": "rgcb",
"author_id": 8178,
"author_prof... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2963/"
] |
27,921 | <p>Story: The user uploads an image that will be added to a photo gallery. As part of the upload process, we need to A) store the image on the web server's hard drive and B) store a thumbnail of the image on the web server's hard drive.</p>
<p>"Best" here is defined as </p>
<ul>
<li>Relatively easy to implement, understand, and maintain</li>
<li>Results in a thumbnail of reasonable quality</li>
</ul>
<p>Performance and high-quality thumbnails are secondary.</p>
| [
{
"answer_id": 27938,
"author": "Huppie",
"author_id": 1830,
"author_profile": "https://Stackoverflow.com/users/1830",
"pm_score": 5,
"selected": true,
"text": "// Example in C#, should be quite alike in ASP.NET\n// Assuming filename as the uploaded file\nusing ( Image bigImage = new Bit... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/308/"
] |
27,928 | <p>How do I calculate the distance between two points specified by latitude and longitude?</p>
<p>For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches available.</p>
| [
{
"answer_id": 27943,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 11,
"selected": true,
"text": "function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) {\n var R = 6371; // Radius of the earth in km\n var dLat = deg2rad(l... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1456/"
] |
27,952 | <p>Basically what I want to do it this: a pdb file contains a location of source files (e.g. <code>C:\dev\proj1\helloworld.cs</code>). Is it possible to modify that pdb file so that it contains a different location (e.g. <code>\more\differenter\location\proj1\helloworld.cs</code>)?</p>
| [
{
"answer_id": 28174,
"author": "Matt Dillard",
"author_id": 863,
"author_profile": "https://Stackoverflow.com/users/863",
"pm_score": 3,
"selected": false,
"text": "subst"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/27952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2822/"
] |
27,983 | <p>I have a table of tags and want to get the highest count tags from the list.</p>
<p>Sample data looks like this</p>
<pre><code>id (1) tag ('night')
id (2) tag ('awesome')
id (3) tag ('night')
</code></pre>
<p>using</p>
<pre><code>SELECT COUNT(*), `Tag` from `images-tags`
GROUP BY `Tag`
</code></pre>
<p>gets me back the data I'm looking for perfectly. However, I would like to organize it, so that the highest tag counts are first, and limit it to only send me the first 20 or so.</p>
<p>I tried this...</p>
<pre><code>SELECT COUNT(id), `Tag` from `images-tags`
GROUP BY `Tag`
ORDER BY COUNT(id) DESC
LIMIT 20
</code></pre>
<p>and I keep getting an "Invalid use of group function - ErrNr 1111"</p>
<p>What am I doing wrong?</p>
<p>I'm using MySQL 4.1.25-Debian</p>
| [
{
"answer_id": 27992,
"author": "Lasse V. Karlsen",
"author_id": 267,
"author_profile": "https://Stackoverflow.com/users/267",
"pm_score": 6,
"selected": false,
"text": "SELECT COUNT(id), `Tag` from `images-tags`\nGROUP BY `Tag`\nORDER BY 1 DESC\nLIMIT 20\n"
},
{
"answer_id": 279... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1477/"
] |
27,998 | <p>Most of my C/C++ development involves monolithic module files and absolutely no classes whatsoever, so usually when I need to make a <strong>DLL</strong> with accessible functions I just export them using the standard <code>__declspec(dllexport)</code> directive. Then access them either dynamically via <code>LoadLibrary()</code> or at compile time with a header and lib file. </p>
<p>How do you do this when you want to export an entire class (and all it's public methods and properties)?</p>
<p>Is it possible to dynamically load that class at runtime and if so, how?</p>
<p>How would you do it with a header and lib for compile time linking?</p>
| [
{
"answer_id": 28018,
"author": "crashmstr",
"author_id": 1441,
"author_profile": "https://Stackoverflow.com/users/1441",
"pm_score": 4,
"selected": false,
"text": "#define ISDLL"
},
{
"answer_id": 28022,
"author": "Graeme Perrow",
"author_id": 1821,
"author_profile":... | 2008/08/26 | [
"https://Stackoverflow.com/questions/27998",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194/"
] |
28,002 | <p>I've been writing C and C++ code for almost twenty years, but there's one aspect of these languages that I've never really understood. I've obviously used regular casts i.e.</p>
<pre><code>MyClass *m = (MyClass *)ptr;
</code></pre>
<p>all over the place, but there seem to be two other types of casts, and I don't know the difference. What's the difference between the following lines of code?</p>
<pre><code>MyClass *m = (MyClass *)ptr;
MyClass *m = static_cast<MyClass *>(ptr);
MyClass *m = dynamic_cast<MyClass *>(ptr);
</code></pre>
| [
{
"answer_id": 28020,
"author": "Inisheer",
"author_id": 2982,
"author_profile": "https://Stackoverflow.com/users/2982",
"pm_score": 4,
"selected": false,
"text": "dynamic_cast"
},
{
"answer_id": 1255015,
"author": "Johannes Schaub - litb",
"author_id": 34509,
"author... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1821/"
] |
28,003 | <p>I have a large database and would like to select table names that have a certain column name. I have done something like this in MySQL, but can't find any info on SQL Server.</p>
<p>I want to do something like:</p>
<pre><code>select [table]
from [db]
where table [has column 'classtypeid']
</code></pre>
<p>How can I do something like this?</p>
| [
{
"answer_id": 28008,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 4,
"selected": true,
"text": "select table_name \nfrom information_schema.columns \nwhere column_name = 'classtypeid'\n"
},
{
"answer_id": 28012,
... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1638/"
] |
28,011 | <p>Working with dates in ruby and rails on windows, I'm having problems with pre-epoch dates (before 1970) throwing out of range exceptions. I tried using both <a href="http://ruby-doc.org/core-2.2.0/Time.html" rel="nofollow noreferrer"><code>Time</code></a> and <a href="http://ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/DateTime.html" rel="nofollow noreferrer"><code>DateTime</code></a> objects, but still have the same problems.</p>
| [
{
"answer_id": 28148,
"author": "Mo.",
"author_id": 1870,
"author_profile": "https://Stackoverflow.com/users/1870",
"pm_score": 2,
"selected": true,
"text": "Date"
},
{
"answer_id": 28517,
"author": "John Duff",
"author_id": 3041,
"author_profile": "https://Stackoverf... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3041/"
] |
28,029 | <p>How can I have it so Visual Studio doesn't keep re-creating this folder that I never use. It's annoying ot keep looking and unnecessary.</p>
| [
{
"answer_id": 29442,
"author": "FlySwat",
"author_id": 1965,
"author_profile": "https://Stackoverflow.com/users/1965",
"pm_score": -1,
"selected": true,
"text": "Tools->Options->Addin/Macro Security\n"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2993/"
] |
28,051 | <p>Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX controls that you want to share across these 2 applications.</p>
<p>What's the best way to create a "user control library", so that you can use the same control implementation in the 2 applications, withuot having to duplicate code?</p>
<p>Controls have ASCX with HTML + code behind.</p>
<hr>
<p>Composite controls will be difficult, because we work with designers who use the HTML syntax in the ASCX files to style the controls.</p>
<p>Tundey, we use SVN here. Do you have an example on how to implement your suggestion? How can SVN share the ASP.NET controls?</p>
<p>Thanks!</p>
| [
{
"answer_id": 28142,
"author": "EndangeredMassa",
"author_id": 106,
"author_profile": "https://Stackoverflow.com/users/106",
"pm_score": 1,
"selected": false,
"text": "<DefaultProperty(\"Text\"), ToolboxData(\"<{0}:BreadCrumb runat=server />\")> _\nPublic Class BreadCrumb\n WebContro... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2868/"
] |
28,080 | <p>We often hear/read that one should avoid dynamic casting. I was wondering what would be 'good use' examples of it, according to you?</p>
<p>Edit:</p>
<p>Yes, I'm aware of <a href="https://stackoverflow.com/questions/28002/regular-cast-vs-staticcast-vs-dynamiccast">that other thread</a>: it is indeed when reading one of the first answers there that I asked my question!</p>
| [
{
"answer_id": 117185,
"author": "rlerallut",
"author_id": 20055,
"author_profile": "https://Stackoverflow.com/users/20055",
"pm_score": 1,
"selected": false,
"text": "template<class T>\nclass MyVector : public ContainerInterface\n...\n"
},
{
"answer_id": 303260,
"author": "C... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2638/"
] |
28,092 | <p>I have a ListBox that has a style defined for ListBoxItems. Inside this style, I have some labels and a button. One that button, I want to define a click event that can be handled on my page (or any page that uses that style). How do I create an event handler on my WPF page to handle the event from my ListBoxItems style?</p>
<p>Here is my style (affected code only):</p>
<pre><code><Style x:Key="UsersTimeOffList" TargetType="{x:Type ListBoxItem}">
...
<Grid>
<Button x:Name="btnRemove" Content="Remove" Margin="0,10,40,0" Click="btnRemove_Click" />
</Grid>
</Style>
</code></pre>
<p>Thanks! </p>
| [
{
"answer_id": 28187,
"author": "Jas",
"author_id": 777,
"author_profile": "https://Stackoverflow.com/users/777",
"pm_score": 0,
"selected": false,
"text": "Public Event btnRemove()\n"
},
{
"answer_id": 28252,
"author": "Arcturus",
"author_id": 900,
"author_profile": ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3047/"
] |
28,098 | <p>How do I convert the value of a PHP variable to string?</p>
<p>I was looking for something better than concatenating with an empty string:</p>
<pre><code>$myText = $myVar . '';
</code></pre>
<p>Like the <code>ToString()</code> method in Java or .NET.</p>
| [
{
"answer_id": 28101,
"author": "Mark Biek",
"author_id": 305,
"author_profile": "https://Stackoverflow.com/users/305",
"pm_score": 4,
"selected": false,
"text": "$myText = \"$myVar\";\n"
},
{
"answer_id": 28104,
"author": "Joel Coehoorn",
"author_id": 3043,
"author_p... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2680/"
] |
28,110 | <p>I have a large table with 1 million+ records. Unfortunately, the person who created the table decided to put dates in a <code>varchar(50)</code> field.</p>
<p>I need to do a simple date comparison -</p>
<pre><code>datediff(dd, convert(datetime, lastUpdate, 100), getDate()) < 31
</code></pre>
<p>But it fails on the <code>convert()</code>:</p>
<pre><code>Conversion failed when converting datetime from character string.
</code></pre>
<p>Apparently there is something in that field it doesn't like, and since there are so many records, I can't tell just by looking at it. How can I properly sanitize the entire date field so it does not fail on the <code>convert()</code>? Here is what I have now:</p>
<pre><code>select count(*)
from MyTable
where
isdate(lastUpdate) > 0
and datediff(dd, convert(datetime, lastUpdate, 100), getDate()) < 31
</code></pre>
<hr>
<p><a href="https://stackoverflow.com/questions/28110/ms-sql-datetime-conversion-failure#28209">@SQLMenace</a></p>
<p>I'm not concerned about performance in this case. This is going to be a one time query. Changing the table to a datetime field is not an option.</p>
<p><a href="https://stackoverflow.com/questions/28110/ms-sql-datetime-conversion-failure#28139">@Jon Limjap</a></p>
<p>I've tried adding the third argument, and it makes no difference.</p>
<hr>
<p><a href="https://stackoverflow.com/questions/28110/ms-sql-datetime-conversion-failure#28209">@SQLMenace</a></p>
<blockquote>
<p>The problem is most likely how the data is stored, there are only two safe formats; ISO YYYYMMDD; ISO 8601 yyyy-mm-dd Thh:mm:ss:mmm (no spaces)</p>
</blockquote>
<p>Wouldn't the <code>isdate()</code> check take care of this?</p>
<p>I don't have a need for 100% accuracy. I just want to get most of the records that are from the last 30 days.</p>
<hr>
<p><a href="https://stackoverflow.com/questions/28110/ms-sql-datetime-conversion-failure#28209">@SQLMenace</a></p>
<pre><code>select isdate('20080131') -- returns 1
select isdate('01312008') -- returns 0
</code></pre>
<hr>
<p><a href="https://stackoverflow.com/questions/28110/ms-sql-datetime-conversion-failure#28209">@Brian Schkerke</a></p>
<blockquote>
<p>Place the CASE and ISDATE inside the CONVERT() function.</p>
</blockquote>
<p>Thanks! That did it.</p>
| [
{
"answer_id": 28135,
"author": "SQLMenace",
"author_id": 740,
"author_profile": "https://Stackoverflow.com/users/740",
"pm_score": 0,
"selected": false,
"text": "WHERE datediff(dd, convert(datetime, lastUpdate), getDate()) < 31\n"
},
{
"answer_id": 28184,
"author": "Skerkles... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/357/"
] |
28,150 | <p>OK, this kind of follows on from <a href="https://stackoverflow.com/questions/27758/notify-developer-of-a-do-not-use-method">my previous question</a>.</p>
<p>What I would really like to do is create some sort of attribute which allows me to decorate a method that will <strong>break the build</strong>. Much like the <em>Obsolete("reason", true)</em> attribute, but without falsely identifying obsolete code.</p>
<p><strong>To clarify</strong>: I dont want it to break the build on <em>ANY</em> F6 (Build) press, I only want it to break the build if a method decorated with the attribute is called somewhere else in the code. Like I said, <em>similar</em> to obsolete, but not the same.</p>
<p>I know I am not alone in this, since <a href="https://stackoverflow.com/questions/27758/notify-developer-of-a-do-not-use-method#27796">other users want to use it for other reasons</a>. I have never created custom attributes before so it is all new to me!</p>
| [
{
"answer_id": 28191,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "https://Stackoverflow.com/users/35",
"pm_score": -1,
"selected": false,
"text": "[MyMadeUpAttributeThatBreaksTheBuildForSure]\npublic class NotDoneYet {}\n"
},
{
"answer_id": 28242,
"author": ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/832/"
] |
28,160 | <p>For whatever reason, our company has a coding guideline that states:</p>
<p><code>Each class shall have it's own header and implementation file.</code></p>
<p>So if we wrote a class called <code>MyString</code> we would need an associated <strong>MyStringh.h</strong> and <strong>MyString.cxx</strong>.</p>
<p>Does anyone else do this? Has anyone seen any compiling performance repercussions as a result? Does 5000 classes in 10000 files compile just as quickly as 5000 classes in 2500 files? If not, is the difference noticeable?</p>
<p>[We code C++ and use GCC 3.4.4 as our everyday compiler]</p>
| [
{
"answer_id": 105329,
"author": "paercebal",
"author_id": 14089,
"author_profile": "https://Stackoverflow.com/users/14089",
"pm_score": 6,
"selected": false,
"text": "A.def.hpp"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1881/"
] |
28,165 | <p>Python has this wonderful way of handling string substitutions using dictionaries:</p>
<pre><code>>>> 'The %(site)s site %(adj)s because it %(adj)s' % {'site':'Stackoverflow', 'adj':'rocks'}
'The Stackoverflow site rocks because it rocks'
</code></pre>
<p>I love this because you can specify a value once in the dictionary and then replace it all over the place in the string.</p>
<p>I've tried to achieve something similar in PHP using various string replace functions but everything I've come up with feels awkward.</p>
<p>Does anybody have a nice clean way to do this kind of string substitution in PHP?</p>
<p><strong><em>Edit</em></strong><br>
Here's the code from the sprintf page that I liked best. </p>
<pre><code><?php
function sprintf3($str, $vars, $char = '%')
{
$tmp = array();
foreach($vars as $k => $v)
{
$tmp[$char . $k . $char] = $v;
}
return str_replace(array_keys($tmp), array_values($tmp), $str);
}
echo sprintf3( 'The %site% site %adj% because it %adj%', array('site'=>'Stackoverflow', 'adj'=>'rocks'));
?>
</code></pre>
| [
{
"answer_id": 28247,
"author": "Marius",
"author_id": 1585,
"author_profile": "https://Stackoverflow.com/users/1585",
"pm_score": 4,
"selected": true,
"text": "function subst($str, $dict){\n return preg_replace(array_map(create_function('$a', 'return \"/%\\\\($a\\\\)s/\";'), array_ke... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28165",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/305/"
] |
28,196 | <p>This is a very specific question regarding <strong>MySQL</strong> as implemented in <strong>WordPress</strong>.</p>
<p>I'm trying to develop a plugin that will show (select) posts that have specific '<strong>tags</strong>' and belong to specific '<strong>categories</strong>' (both multiple)</p>
<p>I was told it's impossible because of the way categories and tags are stored:</p>
<ol>
<li><code>wp_posts</code> contains a list of posts, each post have an "ID"</li>
<li><code>wp_terms</code> contains a list of terms (both categories and tags). Each term has a TERM_ID</li>
<li><code>wp_term_taxonomy</code> has a list of terms with their TERM_IDs and has a Taxonomy definition for each one of those (either a Category or a Tag)</li>
<li><code>wp_term_relationships</code> has associations between terms and posts</li>
</ol>
<p>How can I join the tables to get all posts with tags "Nuclear" <strong>and</strong> "Deals" that also belong to the category "Category1"?</p>
| [
{
"answer_id": 28233,
"author": "Matt Rogish",
"author_id": 2590,
"author_profile": "https://Stackoverflow.com/users/2590",
"pm_score": 2,
"selected": false,
"text": "SELECT *\n FROM wp_posts p\n WHERE EXISTS( SELECT *\n FROM wp_term_relationship tr\n WHER... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1011/"
] |
28,202 | <p>Every time I create a new project I copy the last project's ant file to the new one and make the appropriate changes (trying at the same time to make it more flexible for the next project). But since I didn't really thought about it at the beginning, the file started to look really ugly.</p>
<p>Do you have an Ant template that can be easily ported in a new project? Any tips/sites for making one?</p>
<p>Thank you.</p>
| [
{
"answer_id": 28448,
"author": "Peter Hilton",
"author_id": 2670,
"author_profile": "https://Stackoverflow.com/users/2670",
"pm_score": 4,
"selected": true,
"text": "<project name=\"myapp\">\n ...\n <target name=\"jar\">\n ...\n <jar jarfile=\"${ant.project.name}.jar\" ...... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28202",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2644/"
] |
28,212 | <p>I'm using two different libraries in my project, and both of them supply a basic rectangle <code>struct</code>. The problem with this is that there seems to be no way to insert a conversion between the types, so I can't call a function in one library with the result from a function in the other. If I was the author of either of these, I could create conversions, from the outside, I can't.</p>
<p>library a:</p>
<pre><code>typedef struct rectangle { sint16 x; sint16 y; uint16 w; uint16 h; } rectangle;
</code></pre>
<p>library b:</p>
<pre><code>class Rect {
int x; int y; int width; int height;
/* ... */
};
</code></pre>
<p>Now, I can't make a converter <code>class</code>, because C++ will only look for a conversion in one step. This is probably a good thing, because there would be a lot of possibilities involving creating new objects of all kinds of types.</p>
<p>I can't make an operator that takes the <code>struct</code> from <code>a</code> and supplies an object of the <code>class</code> from <code>b</code>:</p>
<pre>foo.cpp:123 error: ‘operator b::Rect(const rectangle&)’ must be a nonstatic member function</pre>
<p>So, is there a sensible way around this?</p>
<h2>edit:</h2>
<p>I should perhaps also point out that I'd really like some solution that makes working with the result seamless, since I don't expect to be that coder. (Though I agree, old-school, explicit, conversion would have been a good choice. The other branch, <a href="http://en.cppreference.com/w/cpp/language/reinterpret_cast" rel="nofollow noreferrer"><code>reinterpret_cast</code></a> has the same problem..)</p>
<h2>edit2:</h2>
<p>Actually, none of the suggestions really answer my actual question, <a href="https://stackoverflow.com/users/1968/konrad-rudolph">Konrad Rudolph</a> seems to be correct. C++ actually can't do this. Sucks, but true. (If it makes any difference, I'm going to try subclassing as suggested by <a href="https://stackoverflow.com/users/90/codingthewheel">CodingTheWheel</a>.</p>
| [
{
"answer_id": 28226,
"author": "Stu",
"author_id": 414,
"author_profile": "https://Stackoverflow.com/users/414",
"pm_score": 0,
"selected": false,
"text": "struct"
},
{
"answer_id": 28232,
"author": "mmattax",
"author_id": 1638,
"author_profile": "https://Stackoverfl... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1421/"
] |
28,219 | <p>Can I get a 'when to use' for these and others? </p>
<pre><code><% %>
<%# EVAL() %>
</code></pre>
<p>Thanks</p>
| [
{
"answer_id": 28227,
"author": "Brian Warshaw",
"author_id": 1344,
"author_profile": "https://Stackoverflow.com/users/1344",
"pm_score": 2,
"selected": false,
"text": "<%= Class.Method() %>"
},
{
"answer_id": 28263,
"author": "chakrit",
"author_id": 3055,
"author_pro... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1293/"
] |
28,224 | <p>Is there a way to run a regexp-string replace on the current line in the bash?</p>
<p>I find myself rather often in the situation, where I have typed a long commandline and then realize, that I would like to change a word somewhere in the line.</p>
<p>My current approach is to finish the line, press <kbd>Ctrl</kbd>+<kbd>A</kbd> (to get to the start of the line), insert a # (to comment out the line), press enter and then use the <code>^oldword^newword</code> syntax (<code>^oldword^newword</code> executes the previous command after substituting oldword by newword).</p>
<p>But there has to be a better (faster) way to achieve this. (The mouse is not possible, since I am in an ssh-sessions most of the time).</p>
<p>Probably there is some emacs-like key-command for this, that I don't know about.</p>
<p>Edit: I have tried using vi-mode. Something strange happened. Although I am a loving vim-user, I had serious trouble using my beloved bash. All those finger-movements, that have been burned into my subconscious suddenly stopped working. I quickly returned to emacs-mode and considered, giving emacs a try as my favorite editor (although I guess, the same thing might happen again).</p>
| [
{
"answer_id": 113250,
"author": "Zak Johnson",
"author_id": 17052,
"author_profile": "https://Stackoverflow.com/users/17052",
"pm_score": 2,
"selected": true,
"text": "~/.inputrc"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1870/"
] |
28,235 | <p>Using <a href="http://www.oracle.com/technology/products/jdev" rel="noreferrer">JDeveloper</a>, I started developing a set of web pages for a project at work. Since I didn't know much about JDev at the time, I ran over to Oracle to follow some tutorials. The JDev tutorials recommended doing <a href="http://www.fileinfo.net/extension/jspx" rel="noreferrer">JSPX</a> instead of <a href="https://java.sun.com/products/jsp" rel="noreferrer">JSP</a>, but didn't really explain why. Are you developing JSPX pages? Why did you decide to do so? What are the pros/cons of going the JSPX route? </p>
| [
{
"answer_id": 28472,
"author": "Peter Hilton",
"author_id": 2670,
"author_profile": "https://Stackoverflow.com/users/2670",
"pm_score": 7,
"selected": true,
"text": "<script type=\"text/javascript\">\n if (number < 0) {\n"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
28,243 | <p>I'm trying to install some Ruby Gems so I can use Ruby to notify me when I get twitter messages. However, after doing a <code>gem update --system</code>, I now get a zlib error every time I try and do a <code>gem install</code> of anything. below is the console output I get when trying to install ruby gems. (along with the output from <code>gem environment</code>).</p>
<pre><code>C:\data\ruby>gem install twitter
ERROR: While executing gem ... (Zlib::BufError)
buffer error
C:\data\ruby>gem update --system
Updating RubyGems
ERROR: While executing gem ... (Zlib::BufError)
buffer error
C:\data\ruby>gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.2.0
- RUBY VERSION: 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32]
- INSTALLATION DIRECTORY: c:/ruby/lib/ruby/gems/1.8
- RUBY EXECUTABLE: c:/ruby/bin/ruby.exe
- EXECUTABLE DIRECTORY: c:/ruby/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mswin32-60
- GEM PATHS:
- c:/ruby/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
</code></pre>
| [
{
"answer_id": 109708,
"author": "srboisvert",
"author_id": 6805,
"author_profile": "https://Stackoverflow.com/users/6805",
"pm_score": 3,
"selected": true,
"text": "gem update --system\n"
},
{
"answer_id": 110496,
"author": "Asaf Bartov",
"author_id": 7483,
"author_p... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1726/"
] |
28,256 | <p>I've developed an equation parser using a simple stack algorithm that will handle binary (+, -, |, &, *, /, etc) operators, unary (!) operators, and parenthesis.</p>
<p>Using this method, however, leaves me with everything having the same precedence - it's evaluated left to right regardless of operator, although precedence can be enforced using parenthesis.</p>
<p>So right now "1+11*5" returns 60, not 56 as one might expect.</p>
<p>While this is suitable for the current project, I want to have a general purpose routine I can use for later projects.</p>
<p><strong>Edited for clarity:</strong></p>
<p>What is a good algorithm for parsing equations with precedence?</p>
<p>I'm interested in something simple to implement and understand that I can code myself to avoid licensing issues with available code.</p>
<p><strong>Grammar:</strong></p>
<p>I don't understand the grammar question - I've written this by hand. It's simple enough that I don't see the need for YACC or Bison. I merely need to calculate strings with equations such as "2+3 * (42/13)".</p>
<p><strong>Language:</strong></p>
<p>I'm doing this in C, but I'm interested in an algorithm, not a language specific solution. C is low level enough that it'll be easy to convert to another language should the need arise.</p>
<p><strong>Code Example</strong></p>
<p>I posted the <a href="http://web.archive.org/web/20171012060859/http://www.ubasics.com/simple_c_equation_parser" rel="noreferrer">test code for the simple expression parser</a> I was talking about above. The project requirements altered and so I never needed to optimize the code for performance or space as it wasn't incorporated into the project. It's in the original verbose form, and should be readily understandable. If I do anything further with it in terms of operator precedence, I'll probably choose <a href="https://stackoverflow.com/questions/28256/equation-expression-parser-with-precedence/783132#783132">the macro hack</a> because it matches the rest of the program in simplicity. If I ever use this in a real project, though, I'll be going for a more compact/speedy parser.</p>
<p><strong>Related question</strong></p>
<blockquote>
<p><a href="https://stackoverflow.com/questions/114586/smart-design-of-a-math-parser">Smart design of a math parser?</a></p>
</blockquote>
<p>-Adam</p>
| [
{
"answer_id": 28272,
"author": "OysterD",
"author_id": 2638,
"author_profile": "https://Stackoverflow.com/users/2638",
"pm_score": 4,
"selected": false,
"text": "<Exp> ::= <Exp> + <Term> |\n <Exp> - <Term> |\n <Term>\n\n<Term> ::= <Term> * <Factor> |\n <Term>... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28256",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2915/"
] |
28,293 | <p>I have an XML document with a DTD, and would love to be able to access the XML model, something like this:</p>
<pre><code>title = Thing.Items[0].Title
</code></pre>
<p>Is there a way, in Ruby, to generate this kind of object model based on a DTD? Or am I stuck using REXML?</p>
<p>Thanks!</p>
| [
{
"answer_id": 1462093,
"author": "David Richards",
"author_id": 177363,
"author_profile": "https://Stackoverflow.com/users/177363",
"pm_score": 1,
"selected": false,
"text": "require 'rubygems'\nrequire 'activesupport' # For xml-simple\nrequire 'ostruct' \n\nh = Hash.from_xml File.read(... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/722/"
] |
28,301 | <p>I'm unsure whether the following code would ensure all conditions given in Comparator's Javadoc. </p>
<pre><code>class TotalOrder<T> implements Comparator<T> {
public boolean compare(T o1, T o2) {
if (o1 == o2 || equal(o1, o2)) return 0;
int h1 = System.identityHashCode(o1);
int h2 = System.identityHashCode(o2);
if (h1 != h2) {
return h1 < h2 ? -1 : 1;
}
// equals returned false but identity hash code was same, assume o1 == o2
return 0;
}
boolean equal(Object o1, Object o2) {
return o1 == null ? o2 == null : o1.equals(o2);
}
}
</code></pre>
<p>Will the code above impose a total ordering on all instances of any class, even if that class does not implement Comparable?</p>
| [
{
"answer_id": 28394,
"author": "Cem Catikkas",
"author_id": 3087,
"author_profile": "https://Stackoverflow.com/users/3087",
"pm_score": 0,
"selected": false,
"text": "System.identityHashCode(Object)"
},
{
"answer_id": 28439,
"author": "nlucaroni",
"author_id": 157,
"... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3071/"
] |
28,353 | <p>We have a couple of mirrored SQL Server databases.</p>
<p>My first problem - the key problem - is to get a notification when the db fails over. I don't <em>need</em> to know because, erm, its mirrored and so it (almost) all carries on working automagically but it would useful to be advised and I'm currently getting failovers when I don't think I should be so it want to know when they occur (without too much digging) to see if I can determine why.</p>
<p>I have services running that I could fairly easily use to monitor this - so the alternative question would be "How do I programmatically determine which is the principal and which is the mirror" - preferably in a more intelligent fashion than just attempting to connect each in turn (which would mostly work but...).</p>
<p>Thanks, Murph</p>
<p>Addendum: </p>
<p>One of the answers queries why I don't need to know when it fails over - the answer is that we're developing using ADO.NET and that has automatic failover support, all you have to do is add <code>Failover Partner=MIRRORSERVER</code> (where MIRRORSERVER is the name of your mirror server instance) to your connection string and your code will fail over transparently - you may get some errors depending on what connections are active but in our case very few.</p>
| [
{
"answer_id": 37116,
"author": "Murph",
"author_id": 1070,
"author_profile": "https://Stackoverflow.com/users/1070",
"pm_score": 3,
"selected": true,
"text": "using System;\nusing System.Data.SqlClient;\n\nnamespace FailoverMonitorConcept\n{\n class Program\n {\n static voi... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1070/"
] |
28,369 | <p>I'm looking for a "safe" eval function, to implement spreadsheet-like calculations (using numpy/scipy).</p>
<p>The functionality to do this (the <a href="http://docs.python.org/lib/module-rexec.html" rel="nofollow noreferrer">rexec module</a>) has been removed from Python since 2.3 due to apparently unfixable security problems. There are several third-party hacks out there that purport to do this - the most thought-out solution that I have found is
<a href="http://code.activestate.com/recipes/496746/" rel="nofollow noreferrer">this Python Cookbok recipe</a>, "safe_eval". </p>
<p>Am I reasonably safe if I use this (or something similar), to protect from malicious code, or am I stuck with writing my own parser? Does anyone know of any better alternatives?</p>
<p>EDIT: I just discovered <a href="http://pypi.python.org/pypi/RestrictedPython" rel="nofollow noreferrer">RestrictedPython</a>, which is part of Zope. Any opinions on this are welcome.</p>
| [
{
"answer_id": 32028,
"author": "Aaron Maenpaa",
"author_id": 2603,
"author_profile": "https://Stackoverflow.com/users/2603",
"pm_score": 3,
"selected": true,
"text": ">>> names['f'] = open('foo', 'w+')\n>>> safe_eval.safe_eval(\"baz = type(f)('baz', 'w+')\", names)\n>>> names['baz']\n<o... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3002/"
] |
28,377 | <p>In Visual Basic, is there a performance difference when using the <code>IIf</code> function instead of the <code>If</code> statement?</p>
| [
{
"answer_id": 28421,
"author": "Tom Mayfield",
"author_id": 2314,
"author_profile": "https://Stackoverflow.com/users/2314",
"pm_score": 6,
"selected": false,
"text": "IIf()"
},
{
"answer_id": 28435,
"author": "rjzii",
"author_id": 1185,
"author_profile": "https://Sta... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28377",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/299/"
] |
28,380 | <p>Has anybody managed to get the Android Emulator working behind a proxy that requires authentication?</p>
<p>I've tried setting the -http-proxy argument to</p>
<pre><code>http://DOMAIN/USERNAME:PASSWORD@IP:PORT
</code></pre>
<p>but am having no success.</p>
<p>I've tried following the docs to no avail. I've also tried the <code>-verbose-proxy</code> setting but this no longer seems to exist.</p>
<p>Any pointers?</p>
| [
{
"answer_id": 28406,
"author": "dlamblin",
"author_id": 459,
"author_profile": "https://Stackoverflow.com/users/459",
"pm_score": 2,
"selected": false,
"text": "http://$USER:password@www-proxy.company.com:80"
},
{
"answer_id": 40189,
"author": "Naseer",
"author_id": 907,... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1281/"
] |
28,395 | <p>How do you pass <code>$_POST</code> values to a page using <code>cURL</code>?</p>
| [
{
"answer_id": 28411,
"author": "Ross",
"author_id": 2025,
"author_profile": "https://Stackoverflow.com/users/2025",
"pm_score": 8,
"selected": true,
"text": "$data = array('name' => 'Ross', 'php_master' => true);\n\n// You can POST a file by prefixing with an @ (for <input type=\"file\"... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2863/"
] |
28,428 | <p>I want to bring up a file dialog in Java that defaults to the application installation directory.</p>
<p>What's the best way to get that information programmatically?</p>
| [
{
"answer_id": 28454,
"author": "Rich Lawrence",
"author_id": 1281,
"author_profile": "https://Stackoverflow.com/users/1281",
"pm_score": 4,
"selected": true,
"text": "System.getProperty(\"user.dir\") \n"
},
{
"answer_id": 28726,
"author": "McDowell",
"author_id": 304,
... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1288/"
] |
28,478 | <p>I recently asked a question about <a href="https://stackoverflow.com/questions/28377/iif-vs-if">IIf vs. If</a> and found out that there is another function in VB called <strong>If</strong> which basically does the same thing as <strong>IIf</strong> but is a short-circuit.</p>
<p>Does this <strong>If</strong> function perform better than the <strong>IIf</strong> function? Does the <strong>If</strong> statement trump the <strong>If</strong> and <strong>IIf</strong> functions?</p>
| [
{
"answer_id": 28498,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 5,
"selected": true,
"text": "If"
},
{
"answer_id": 23395769,
"author": "BateTech",
"author_id": 2054866,
"author_profile": "http... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/299/"
] |
28,529 | <p>When using <a href="http://jquery.com/" rel="nofollow noreferrer">jQuery</a>'s <a href="http://docs.jquery.com/Ajax/jQuery.ajax#options" rel="nofollow noreferrer">ajax method</a> to submit form data, what is the best way to handle errors?
This is an example of what a call might look like:</p>
<pre><code>$.ajax({
url: "userCreation.ashx",
data: { u:userName, p:password, e:email },
type: "POST",
beforeSend: function(){disableSubmitButton();},
complete: function(){enableSubmitButton();},
error: function(xhr, statusText, errorThrown){
// Work out what the error was and display the appropriate message
},
success: function(data){
displayUserCreatedMessage();
refreshUserList();
}
});
</code></pre>
<p>The request might fail for a number of reasons, such as duplicate user name, duplicate email address etc, and the ashx is written to throw an exception when this happens.</p>
<p>My problem seems to be that by throwing an exception the ashx causes the <code>statusText</code> and <code>errorThrown</code> to be <strong>undefined</strong>.</p>
<p>I can get to the <code>XMLHttpRequest.responseText</code> which contains the HTML that makes up the standard .net error page.</p>
<p>I am finding the page title in the responseText and using the title to work out which error was thrown. Although I have a suspicion that this will fall apart when I enable custom error handling pages.</p>
<p>Should I be throwing the errors in the ashx, or should I be returning a status code as part of the data returned by the call to <code>userCreation.ashx</code>, then using this to decide what action to take?<br>
How do you handle these situations?</p>
| [
{
"answer_id": 28545,
"author": "travis",
"author_id": 1414,
"author_profile": "https://Stackoverflow.com/users/1414",
"pm_score": 4,
"selected": false,
"text": "<div id=\"error\"></div>"
},
{
"answer_id": 29915,
"author": "AidenMontgomery",
"author_id": 1403,
"author... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1403/"
] |
28,542 | <p>My C code snippet takes the address of an argument and stores it in a volatile memory location (preprocessed code):</p>
<pre><code>void foo(unsigned int x) {
*(volatile unsigned int*)(0x4000000 + 0xd4) = (unsigned int)(&x);
}
int main() {
foo(1);
while(1);
}
</code></pre>
<p>I used an SVN version of GCC for compiling this code. At the end of function <code>foo</code> I would expect to have the value <code>1</code> stored in the stack and, at <code>0x40000d4</code>, an address pointing to that value. When I compile without optimizations using the flag <code>-O0</code>, I get the expected ARM7TMDI assembly output (commented for your convenience):</p>
<pre><code> .align 2
.global foo
.type foo, %function
foo:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
sub sp, sp, #8
str r0, [sp, #4] @ 3. Store the argument on the stack
mov r3, #67108864
add r3, r3, #212
add r2, sp, #4 @ 4. Address of the stack variable
str r2, [r3, #0] @ 5. Store the address at 0x40000d4
add sp, sp, #8
bx lr
.size foo, .-foo
.align 2
.global main
.type main, %function
main:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
stmfd sp!, {r4, lr}
mov r0, #1 @ 1. Pass the argument in register 0
bl foo @ 2. Call function foo
.L4:
b .L4
.size main, .-main
.ident "GCC: (GNU) 4.4.0 20080820 (experimental)"
</code></pre>
<p>It clearly stores the argument first on the stack and from there stores it at <code>0x40000d4</code>. When I compile with optimizations using <code>-O1</code>, I get something unexpected:</p>
<pre><code> .align 2
.global foo
.type foo, %function
foo:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 8
@ frame_needed = 0, uses_anonymous_args = 0
@ link register save eliminated.
sub sp, sp, #8
mov r2, #67108864
add r3, sp, #4 @ 3. Address of *something* on the stack
str r3, [r2, #212] @ 4. Store the address at 0x40000d4
add sp, sp, #8
bx lr
.size foo, .-foo
.align 2
.global main
.type main, %function
main:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
stmfd sp!, {r4, lr}
mov r0, #1 @ 1. Pass the argument in register 0
bl foo @ 2. Call function foo
.L4:
b .L4
.size main, .-main
.ident "GCC: (GNU) 4.4.0 20080820 (experimental)"
</code></pre>
<p>This time the argument is never stored on the stack even though <em>something</em> from the stack is still stored at <code>0x40000d4</code>.</p>
<p>Is this just expected/undefined behaviour? Have I done something wrong or have I in fact found a Compiler Bug™?</p>
| [
{
"answer_id": 28651,
"author": "Will Dean",
"author_id": 987,
"author_profile": "https://Stackoverflow.com/users/987",
"pm_score": 1,
"selected": false,
"text": "void foo(unsigned int x) \n{\n volatile unsigned int* pArg = &x;\n *(volatile unsigned int*)(0x4000000 + 0xd4) = (unsig... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/616/"
] |
28,559 | <p>What's the best Python idiom for this C construct?</p>
<pre><code>while ((x = next()) != END) {
....
}
</code></pre>
<p>I don't have the ability to recode next().</p>
<p>update: and the answer from seems to be:</p>
<pre><code>for x in iter(next, END):
....
</code></pre>
| [
{
"answer_id": 28563,
"author": "Blair Conrad",
"author_id": 1199,
"author_profile": "https://Stackoverflow.com/users/1199",
"pm_score": 2,
"selected": false,
"text": "x = next()\nwhile x != END:\n do_something_with_x\n x = next()\n"
},
{
"answer_id": 28566,
"author": "... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28559",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/116/"
] |
28,577 | <p>I need to store products for an e-commerce solution in a database. Each product should have descriptive information, such as name, description etc.</p>
<p>I need any product to be localized to x number of languages.</p>
<p>What I've done so far, is to make any column that should be localized and <code>nvarchar(MAX)</code> and then i store an XML string like this:</p>
<pre><code><cultures>
<culture code="en-us">Super fast laptop</culture>
<culture code="da-dk">Super hurtig bærbar</culture>
</cultures>
</code></pre>
<p>And when I load it from the database, into my business logic objects, I parse the XML string to a <code>Dictionary<string, string></code> where the key is the culture/language code.</p>
<p>So when I want to display the name of a product, I do this:</p>
<pre><code>lblName.Text = product.Name["en-us"];
</code></pre>
<p>Does anyone have a better solution?</p>
| [
{
"answer_id": 28871,
"author": "Luke",
"author_id": 327,
"author_profile": "https://Stackoverflow.com/users/327",
"pm_score": 3,
"selected": true,
"text": "public class Product\n{\n private idType id;\n public string Name\n {\n get\n {\n return Localizer.Instance.GetLocalS... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2972/"
] |
28,588 | <p>I want to log onto Stack Overflow using OpenID, but I thought I'd set up my own OpenID provider, just because it's harder :) How do you do this in Ubuntu?</p>
<p>Edit: Replacing 'server' with the correct term OpenID provider (Identity provider would also be correct according to <a href="http://en.wikipedia.org/wiki/Openid#Using_OpenID" rel="noreferrer">wikipedia</a>).</p>
| [
{
"answer_id": 35659,
"author": "tonygambone",
"author_id": 3344,
"author_profile": "https://Stackoverflow.com/users/3344",
"pm_score": 3,
"selected": false,
"text": "<link rel=\"openid.server\" href=\"http://openid.claimid.com/server\" />\n<link rel=\"openid.delegate\" href=\"http://ope... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3102/"
] |
28,637 | <p>I need to find a bottleneck and need to accurately as possible measure time.</p>
<p>Is the following code snippet the best way to measure the performance?</p>
<pre><code>DateTime startTime = DateTime.Now;
// Some execution process
DateTime endTime = DateTime.Now;
TimeSpan totalTimeTaken = endTime.Subtract(startTime);
</code></pre>
| [
{
"answer_id": 28648,
"author": "Markus Olsson",
"author_id": 2114,
"author_profile": "https://Stackoverflow.com/users/2114",
"pm_score": 10,
"selected": true,
"text": "System.Diagnostics"
},
{
"answer_id": 28649,
"author": "rp.",
"author_id": 2536,
"author_profile": ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2469/"
] |
28,642 | <p>Having a heckuva time with this one, though I feel I'm missing something obvious. I have a control that inherits from <code>System.Web.UI.WebControls.Button</code>, and then implements an interface that I have set up. So think...</p>
<pre><code>public class Button : System.Web.UI.WebControls.Button, IMyButtonInterface { ... }
</code></pre>
<p>In the codebehind of a page, I'd like to find all instances of this button from the ASPX. Because I don't really know what the <em>type</em> is going to be, just the <em>interface</em> it implements, that's all I have to go on when looping through the control tree. Thing is, I've never had to determine if an object uses an interface versus just testing its type. <strong>How can I loop through the control tree and yank anything that implements <code>IMyButtonInterface</code> in a clean way</strong> (Linq would be fine)?</p>
<p>Again, know it's something obvious, but just now started using interfaces heavily and I can't seem to focus my Google results enough to figure it out :)</p>
<p><strong>Edit:</strong> <code>GetType()</code> returns the actual class, but doesn't return the interface, so I can't test on that (e.g., it'd return "<code>MyNamespace.Button</code>" instead of "<code>IMyButtonInterface</code>"). In trying to use "<code>as</code>" or "<code>is</code>" in a recursive function, the <em><code>type</code></em> parameter doesn't even get recognized within the function! It's rather bizarre. So</p>
<pre><code>if(ctrl.GetType() == typeToFind) //ok
if(ctrl is typeToFind) //typeToFind isn't recognized! eh?
</code></pre>
<p>Definitely scratching my head over this one.</p>
| [
{
"answer_id": 28662,
"author": "bdukes",
"author_id": 2688,
"author_profile": "https://Stackoverflow.com/users/2688",
"pm_score": 1,
"selected": false,
"text": "foreach (Control c in this.Page.Controls) {\n IMyButtonInterface myButton = c as IMyButtonInterface;\n if (myButton != n... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1212/"
] |
28,675 | <p>I'm using <code>ByteBuffers</code> and <code>FileChannels</code> to write binary data to a file. When doing that for big files or successively for multiple files, I get an <code>OutOfMemoryError</code> exception.
I've read elsewhere that using <code>Bytebuffers</code> with NIO is broken and should be avoided. Does any of you already faced this kind of problem and found a solution to efficiently save large amounts of binary data in a file in java?</p>
<p>Is the jvm option <code>-XX:MaxDirectMemorySize</code> the way to go?</p>
| [
{
"answer_id": 28690,
"author": "Marcin",
"author_id": 3105,
"author_profile": "https://Stackoverflow.com/users/3105",
"pm_score": 1,
"selected": false,
"text": "java.io.FileOutputStream"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2612/"
] |
28,708 | <p>My code needs to determine how long a particular process has been running. But it continues to fail with an access denied error message on the <code>Process.StartTime</code> request. This is a process running with a User's credentials (ie, not a high-privilege process). There's clearly a security setting or a policy setting, or <em>something</em> that I need to twiddle with to fix this, as I can't believe the StartTime property is in the Framework just so that it can fail 100% of the time.</p>
<p>A Google search indicated that I could resolve this by adding the user whose credentials the querying code is running under to the "Performance Log Users" group. However, no such user group exists on this machine.</p>
| [
{
"answer_id": 31792,
"author": "TheSmurf",
"author_id": 1975282,
"author_profile": "https://Stackoverflow.com/users/1975282",
"pm_score": 3,
"selected": false,
"text": "using System.Management;\nString queryString = \"select CreationDate from Win32_Process where ProcessId='\" + ProcessI... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1975282/"
] |
28,709 | <p>In Eclipse 3.2.2 on Linux content assist is not finding classes within the same project. Upgrading above 3.2 is not an option as SWT is not available above 3.2 for Solaris.</p>
<p>I have seen suggestions to clean the workspace, reopen the workspace, run eclipse with the <code>-clean</code> command, none of which has worked.</p>
| [
{
"answer_id": 549032,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "package FG::CatalogueFichier;\nuse FG::Catalogue;\nour @ISA = qw(FG::Catalogue);\nuse strict;\n"
},
{
"answer_id": 4280... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28709",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1539/"
] |
28,713 | <p>Is there a simple way of getting a HTML textarea and an input type="text" to render with (approximately) equal width (in pixels), that works in different browsers?</p>
<p>A CSS/HTML solution would be brilliant. I would prefer not to have to use Javascript.</p>
<p>Thanks
/Erik</p>
| [
{
"answer_id": 28728,
"author": "Re0sless",
"author_id": 2098,
"author_profile": "https://Stackoverflow.com/users/2098",
"pm_score": 5,
"selected": true,
"text": ".mywidth {\n width: 100px; \n}"
},
{
"answer_id": 28730,
"author": "James B",
"author_id": 2951,
"auth... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28713",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/276/"
] |
28,723 | <p>In handling a form post I have something like</p>
<pre><code> public ActionResult Insert()
{
Order order = new Order();
BindingHelperExtensions.UpdateFrom(order, this.Request.Form);
this.orderService.Save(order);
return this.RedirectToAction("Details", new { id = order.ID });
}
</code></pre>
<p>I am not using explicit parameters in the method as I anticipate having to adapt to variable number of fields etc. and a method with 20+ parameters is not appealing.</p>
<p>I suppose my only option here is mock up the whole HttpRequest, equivalent to what Rob Conery has done. Is this a best practice? Hard to tell with a framework which is so new.</p>
<p>I've also seen solutions involving using an ActionFilter so that you can transform the above method signature to something like</p>
<pre><code>[SomeFilter]
public Insert(Contact contact)
</code></pre>
| [
{
"answer_id": 35299,
"author": "Joseph Kingry",
"author_id": 3046,
"author_profile": "https://Stackoverflow.com/users/3046",
"pm_score": 2,
"selected": true,
"text": " public ActionResult Insert(Contact contact)\n {\n\n if (this.ViewData.ModelState.IsValid)\n {\n ... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3046/"
] |
28,739 | <p>I recently ran out of disk space on a drive on a FreeBSD server. I truncated the file that was causing problems but I'm not seeing the change reflected when running <code>df</code>. When I run <code>du -d0</code> on the partition it shows the correct value. Is there any way to force this information to be updated? What is causing the output here to be different?</p>
| [
{
"answer_id": 447740,
"author": "Dave C",
"author_id": 55504,
"author_profile": "https://Stackoverflow.com/users/55504",
"pm_score": 2,
"selected": false,
"text": "cp /bin/cat /tmp/cat-test\n/tmp/cat-test &\nrm /tmp/cat-test\n"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/72/"
] |
28,756 | <p>Whats the best/easiest way to obtain a count of items within an IEnumerable collection without enumerating over all of the items in the collection?</p>
<p>Possible with LINQ or Lambda?</p>
| [
{
"answer_id": 28761,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_profile": "https://Stackoverflow.com/users/1968",
"pm_score": 4,
"selected": false,
"text": "Count"
},
{
"answer_id": 28762,
"author": "Greg Hurlman",
"author_id": 35,
"author_profile": "http... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2993/"
] |
28,765 | <p>I recently upgraded a VS2005 web deployment project to VS2008 - and now I get the following error when building:</p>
<pre><code>The specified task executable location "bin\aspnet_merge.exe" is invalid.
</code></pre>
<p>Here is the source of the error (from the web deployment targets file):</p>
<pre><code><Target Name="AspNetMerge" Condition="'$(UseMerge)' == 'true'" DependsOnTargets="$(MergeDependsOn)">
<AspNetMerge
ExePath="$(FrameworkSDKDir)bin"
ApplicationPath="$(TempBuildDir)"
KeyFile="$(_FullKeyFile)"
DelaySign="$(DelaySign)"
Prefix="$(AssemblyPrefixName)"
SingleAssemblyName="$(SingleAssemblyName)"
Debug="$(DebugSymbols)"
Nologo="$(NoLogo)"
ContentAssemblyName="$(ContentAssemblyName)"
ErrorStack="$(ErrorStack)"
RemoveCompiledFiles="$(DeleteAppCodeCompiledFiles)"
CopyAttributes="$(CopyAssemblyAttributes)"
AssemblyInfo="$(AssemblyInfoDll)"
MergeXmlDocs="$(MergeXmlDocs)"
ErrorLogFile="$(MergeErrorLogFile)"
/>
</code></pre>
<p>What is the solution to this problem?</p>
<p>Note - I also created a web deployment project from scratch in VS2008 and got the same error.</p>
| [
{
"answer_id": 28822,
"author": "Adam",
"author_id": 1341,
"author_profile": "https://Stackoverflow.com/users/1341",
"pm_score": 4,
"selected": true,
"text": "SET FrameworkSDKDir=\"C:\\Program Files\\Microsoft SDKs\\Windows\\v6.1\"\n"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1341/"
] |
28,817 | <p>There is a legacy CVS repository, which contains a large number of directories, sub-directories, and paths. There is also a large number of branches and tags that do not necessarilly cover all paths & files - usually a subset. How can I find out, which branch / tag covers, which files and paths?</p>
<p>CVS log already provides the list of tags per file. The task requires me to transpose this into files per tag. I could not find such functionality in current WinCVS (CVSNT) implementation. Given ample empty cycles I can write a Perl script that would do that, the algorithm is not complex, but it needs to be done.</p>
<p>I would imagine there are some people who needed such information and solved this problem. Thus, I think should be a readily available (open source / free) tool for this.</p>
| [
{
"answer_id": 34953,
"author": "John Meagher",
"author_id": 3535,
"author_profile": "https://Stackoverflow.com/users/3535",
"pm_score": 4,
"selected": true,
"text": "cvs log <filename>\n"
},
{
"answer_id": 268124,
"author": "Oliver Giesen",
"author_id": 9784,
"author... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2877/"
] |
28,832 | <p>If I call <code>finalize()</code> on an object from my program code, will the <strong>JVM</strong> still run the method again when the garbage collector processes this object?</p>
<p>This would be an approximate example:</p>
<pre><code>MyObject m = new MyObject();
m.finalize();
m = null;
System.gc()
</code></pre>
<p>Would the explicit call to <code>finalize()</code> make the <strong>JVM</strong>'s garbage collector not to run the <code>finalize()</code> method on object <code>m</code>?</p>
| [
{
"answer_id": 28856,
"author": "John Topley",
"author_id": 1450,
"author_profile": "https://Stackoverflow.com/users/1450",
"pm_score": 2,
"selected": false,
"text": "public void cleanUp() {\n .\n .\n .\n}\n\nmyInstance.cleanUp();\n"
},
{
"answer_id": 28906,
"author": "Tim... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28832",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2697/"
] |
28,858 | <p>Saw a post about hidden features in C# but not a lot of people have written linq/lambdas example so... I wonder...</p>
<blockquote>
<p>What's the coolest (as in the most elegant) use of the C# LINQ and/or Lambdas/anonymous delegates you have ever saw/written?</p>
</blockquote>
<p>Bonus if it has went into production too!</p>
| [
{
"answer_id": 28973,
"author": "Chris Ammerman",
"author_id": 2729,
"author_profile": "https://Stackoverflow.com/users/2729",
"pm_score": 4,
"selected": false,
"text": "public static class Functionals\n{\n // One-argument Y-Combinator.\n public static Func<T, TResult> Y<T, TResult... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28858",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3055/"
] |
28,878 | <p>I'm translating my C# code for YouTube video comments into PHP. In order to properly nest comment replies, I need to re-arrange XML nodes. In PHP I'm using DOMDocument and DOMXPath which closely corresponds to C# XmlDocument. I've gotten pretty far in my translation but now I'm stuck on getting the parent node of a DOMElement. A DOMElement does not have a parent_node() property, only a DOMNode provides that property.</p>
<p>After determining that a comment is a reply to a previous comment based in the string "in-reply-to" in a link element, I need to get its parent node in order to nest it beneath the comment it is in reply to:</p>
<pre><code>// Get the parent entry node of this link element
$importnode = $objReplyXML->importNode($link->parent_node(), true);
</code></pre>
| [
{
"answer_id": 28998,
"author": "Marius",
"author_id": 1585,
"author_profile": "https://Stackoverflow.com/users/1585",
"pm_score": 1,
"selected": false,
"text": "$link->parent_node()"
},
{
"answer_id": 49586651,
"author": "Dimas Lanjaka",
"author_id": 6404439,
"author... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2601/"
] |
28,881 | <p>Using the same <strong>sort</strong> command with the same input produces different results on different machines. How do I fix that?</p>
| [
{
"answer_id": 28893,
"author": "Jon Ericson",
"author_id": 1438,
"author_profile": "https://Stackoverflow.com/users/1438",
"pm_score": 3,
"selected": false,
"text": "$ echo 'CO2_\nCO_' | env LC_ALL=C sort\nCO2_\nCO_\n\n\n$ echo 'CO2_\nCO_' | env LC_ALL=en_US sort\nCO_\nCO2_\n"
},
{
... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1438/"
] |
28,894 | <p>For years I have been using the DEBUG compiler constant in VB.NET to write messages to the console. I've also been using System.Diagnostics.Debug.Write in similar fashion. It was always my understanding that when RELEASE was used as the build option, that all of these statements were left out by the compiler, freeing your production code of the overhead of debug statements. Recently when working with Silverlight 2 Beta 2, I noticed that Visual Studio actually attached to a RELEASE build that I was running off of a public website and displayed DEBUG statements which I assumed weren't even compiled! Now, my first inclination is to assume that that there is something wrong with my environment, but I also want to ask anyone with deep knowledge on System.Diagnostics.Debug and the DEBUG build option in general what I may be misunderstanding here.</p>
| [
{
"answer_id": 28913,
"author": "juan",
"author_id": 1782,
"author_profile": "https://Stackoverflow.com/users/1782",
"pm_score": 1,
"selected": false,
"text": "public void Debug(string s)\n{\n#if DEBUG\n System.Diagnostics.Debug(...);\n#endif\n}\n"
},
{
"answer_id": 28934,
... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3059/"
] |
28,896 | <p>I'm currently designing a program that will involve some physics (nothing too fancy, a few balls crashing to each other)</p>
<p>What's the most exact datatype I can use to represent position (without a feeling of discrete jumps) in c#?</p>
<p>Also, what's the smallest ammount of time I can get between t and t+1? One tick?</p>
<p>EDIT: Clarifying: What is the smallest unit of time in C#? <code>[TimeSpan].Tick</code>?</p>
| [
{
"answer_id": 28917,
"author": "tghw",
"author_id": 2363,
"author_profile": "https://Stackoverflow.com/users/2363",
"pm_score": 4,
"selected": true,
"text": "decimal"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1782/"
] |
28,922 | <p>I have an SQL server database that I am querying and I only want to get the information when a specific row is null. I used a where statement such as:</p>
<pre><code>WHERE database.foobar = NULL
</code></pre>
<p>and it does not return anything. However, I know that there is at least one result because I created an instance in the database where 'foobar' is equal to null. If I take out the where statement it shows data so I know it is not the rest of the query.</p>
<p>Can anyone help me out?</p>
| [
{
"answer_id": 28929,
"author": "Farinha",
"author_id": 2841,
"author_profile": "https://Stackoverflow.com/users/2841",
"pm_score": 1,
"selected": false,
"text": "IS NULL"
},
{
"answer_id": 28966,
"author": "Mark Harrison",
"author_id": 116,
"author_profile": "https:/... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2486/"
] |
28,932 | <p>What is the the best JavaScript compressor available? I'm looking for a tool that:</p>
<ul>
<li>is easy to use</li>
<li>has a high compression rate</li>
<li>Produce reliable end results (doesn't mess up the code)</li>
</ul>
| [
{
"answer_id": 3541878,
"author": "mishoo",
"author_id": 154985,
"author_profile": "https://Stackoverflow.com/users/154985",
"pm_score": 8,
"selected": true,
"text": "Node.js"
}
] | 2008/08/26 | [
"https://Stackoverflow.com/questions/28932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363/"
] |
28,949 | <p>After reading <a href="https://stackoverflow.com/questions/28832/java-and-manually-executing-finalize">this question</a>, I was reminded of when I was taught Java and told never to call finalize() or run the garbage collector because "it's a big black box that you never need to worry about". Can someone boil the reasoning for this down to a few sentences? I'm sure I could read a technical report from Sun on this matter, but I think a nice, short, simple answer would satisfy my curiosity.</p>
| [
{
"answer_id": 30567,
"author": "Derek Park",
"author_id": 872,
"author_profile": "https://Stackoverflow.com/users/872",
"pm_score": 2,
"selected": false,
"text": "finalize()"
},
{
"answer_id": 5388006,
"author": "Leo",
"author_id": 665792,
"author_profile": "https://... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/572/"
] |
28,950 | <p>Does anyone have links to documentation or guides on making the decision between REST vs. SOAP? I understand both of these but am looking for some references on the key decision points, eg, security, which may make you lean towards one or the other.</p>
| [
{
"answer_id": 19463563,
"author": "kapil das",
"author_id": 2041542,
"author_profile": "https://Stackoverflow.com/users/2041542",
"pm_score": 2,
"selected": false,
"text": "REST uses standard HTTP so it is simplerto creating clients, developing APIs \nREST permits many different data fo... | 2008/08/26 | [
"https://Stackoverflow.com/questions/28950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.