qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
281,380
<p>I am trying to format a date with: </p> <pre><code>&lt;fmt:formatDate value="${newsletter.createdOn}" pattern="MM/dd/yyyy"/&gt; </code></pre> <p>newsletter is an object with a <code>createdOn</code> property which is <code>java.util.Date</code>.</p> <p>When I invoke the previous sentence I get: </p> <p>According to the TLD, the attribute value does not accept expressions. </p> <p>I am importing fmt with </p> <pre><code>&lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %&gt; </code></pre> <p>Does anyone know how can I work around this problem?</p> <p>I am using the jstl.jar coming with tomcat. </p> <p>Under jstl.jar/META-INF/MANIFEST.MF stays: </p> <pre><code>Manifest-Version: 1.0 Ant-Version: Apache Ant 1.5.3 Created-By: 1.4.2-b28 (Sun Microsystems Inc.) Specification-Title: JavaServer Pages Standard Tag Library (JSTL) Specification-Version: 1.1 Implementation-Title: JavaServer Pages Standard Tag Library API Refere nce Implementation Implementation-Version: 1.1.0-D13 Implementation-Vendor: Sun Microsystems, Inc. Implementation-Vendor-Id: com.sun Extension-Name: javax.servlet.jsp.jstl </code></pre> <p>I am using Apache Tomcat Version 6.0.14</p>
[ { "answer_id": 281422, "author": "lucas", "author_id": 31172, "author_profile": "https://Stackoverflow.com/users/31172", "pm_score": 5, "selected": false, "text": "<%@ taglib prefix=\"fmt\" uri=\"http://java.sun.com/jsp/jstl/fmt\" %>\n" }, { "answer_id": 281425, "author": "to...
2008/11/11
[ "https://Stackoverflow.com/questions/281380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2138/" ]
281,383
<p>As the title suggests, I am having trouble maintaining my code on postback. I have a bunch of jQuery code in the Head section and this works fine until a postback occurs after which it ceases to function! </p> <p>How can I fix this? Does the head not get read on postback, and is there a way in which I can force this to happen? </p> <p>JavaScript is:</p> <pre class="lang-html prettyprint-override"><code> &lt;script type="text/javascript"&gt; $(document).ready(function() { $('.tablesorter tbody tr').tablesorter(); $('.tablesearch tbody tr').quicksearch({ position: 'before', attached: 'table.tablesearch', stripeRowClass: ['odd', 'even'], labelText: 'Search:', delay: 100 }); }); &lt;/script&gt; </code></pre>
[ { "answer_id": 281463, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackoverflow.com/users/22303", "pm_score": 1, "selected": false, "text": "alert('test');" }, { "answer_id": 1462930, "author": "Russ Cam", "author_id": 1831, "author_profile": "htt...
2008/11/11
[ "https://Stackoverflow.com/questions/281383", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35454/" ]
281,398
<p>I have an existing web app that allows users to "rate" items based on their difficulty. (0 through 15). Currently, I'm simply taking the average of each user's opinion and presenting the average straight from MySQL. However, it's becoming clear to me (and my users) that weighting the numbers would be more appropriate.</p> <p>Oddly enough, a few hours of Google-ing hasn't turned up much. I did find two articles that showed site-wide ratings systems based off of "Bayesian filters" (which I partially understand). <a href="http://v3.siteframe.org/document.php?id=595" rel="nofollow noreferrer">Here</a>'s one example:</p> <blockquote> <p>The formula is:</p> <p>WR=(V/(V+M)) * R + (M/(V+M)) * C</p> <p>Where:</p> <pre><code>* WR=Weighted Rating (The new rating) * R=Average Rating (arithmetic mean) so far * V=Number of ratings given * M=Minimum number of ratings needed * C=Arithmetic mean rating across the whole site </code></pre> </blockquote> <p>I like the idea here of ramping up the weighting based on the total number of votes per item...however, because the difficulty levels on my site can range drastically from item to item, taking "C" (arithmetic mean rating across the whole site) is not valid. </p> <p>so, a restate of my question:</p> <p>Using MySQL, PHP, or both, I'm try to get from aritmetic mean:</p> <pre><code>(5 + 5 + 4)/3 = 4.67 (rounded) </code></pre> <p>...to a weighted mean:</p> <pre><code>rating / weight 5 / 2 (since it was given 2 times) 5 / 2 4 / 1 (sum[(rate * weight)])/(sum of weights) (5 * 2) + (5 * 2) + (4 * 1) / (2 + 2 + 1) (24)/(5) = 4.8 </code></pre>
[ { "answer_id": 281499, "author": "Dave DuPlantis", "author_id": 8174, "author_profile": "https://Stackoverflow.com/users/8174", "pm_score": 0, "selected": false, "text": "select sum(response*ct*ct)/sum(ct*ct) from\n( select response, count(response) as ct from your_table group by respons...
2008/11/11
[ "https://Stackoverflow.com/questions/281398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/24708/" ]
281,418
<p>I am using the standard .Net 2.0 DataGridView with sort mode of automatic on the column. It is very very slow (which should probably be another question on how to speed it up) but I can't seem to find an event or combination of events that will maintain a WaitCursor while this sort operation is being performed.</p> <p>Ideas?</p>
[ { "answer_id": 67243965, "author": "DerpyNerd", "author_id": 1536027, "author_profile": "https://Stackoverflow.com/users/1536027", "pm_score": 0, "selected": false, "text": "CellMouseDown" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36614/" ]
281,436
<p>I have a SSRS 2005 report that has a number of images in it. The way that I have the images included is I have an image object with the URL set in the value property. The actual images are hosted by an IIS virtual directory on the same server. I'm doing it this way because I need to dynamically change the image source using an expression depending on the data within the report. </p> <p>The problem is that the images work great when previewing the report in Visual Studio but do not display when the report is deployed. When I look at the HTML rendered by SSRS the SRC attribute of the image tag is an empty string.</p>
[ { "answer_id": 12333827, "author": "Syed", "author_id": 696799, "author_profile": "https://Stackoverflow.com/users/696799", "pm_score": 0, "selected": false, "text": "< location path=\"Images\" >\n < system.web >\n < authorization >\n < allow users=\"*\" / >\n < /aut...
2008/11/11
[ "https://Stackoverflow.com/questions/281436", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16980/" ]
281,440
<pre> create table person ( name varchar(15), attr1 varchar(15), attr2 varchar(1), attr3 char(1), attr4 int ) </pre> <p>How I can use basic ORM in Perl by taking a simple table like the one above and mapping it to Perl objects? Next I'd like to perform basic operations like select results using some criteria system Perl like syntax. eg.:</p> <pre><code>@myResults = findAll(attr1 == 3 &amp;&amp; attr2 =~ /abc/); </code></pre>
[ { "answer_id": 665195, "author": "singingfish", "author_id": 36499, "author_profile": "https://Stackoverflow.com/users/36499", "pm_score": 0, "selected": false, "text": "#!/usr/bin/perl\nuse warnings;\nuse strict;\nuse DBIx::Class::Schema::Loader qw/ make_schema_at /;\n\nmake_schema_at(\...
2008/11/11
[ "https://Stackoverflow.com/questions/281440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,443
<p>The following source code alerts the following results:</p> <p><strong>Internet Explorer 7</strong>: 29<br> <strong>Firefox 3.0.3</strong>: 37 (correct)<br> <strong>Safari 3.0.4 (523.12.9)</strong>: 38<br> <strong>Google Chrome 0.3.154.9</strong>: 38 </p> <p>Please ignore the following facts: </p> <ul> <li>Webkit (Safari/Chrome) browsers insert an extra text node at the end of the body tag</li> <li>Internet Explorer doesn't have new lines in their whitespace nodes, like they should.</li> <li>Internet Explorer has no beginning whitespace node (there is obvious whitespace before the &lt;form&gt; tag, but no text node to match) </ul> <p>Of the tags in the test page, the following tags have no whitespace text nodes inserted in the DOM after them: <code>form</code>, <code>input[@radio]</code>, <code>div</code>, <code>span</code>, <code>table</code>, <code>ul</code>, <code>a</code>.</p> <p>My question is: <strong>What is it about these nodes that makes them the exception in Internet Explorer?</strong> Why is whitespace not inserted after these nodes, and is inserted in the others? </p> <p>This behavior is the same if you switch the tag order, switch the doctype to XHTML (while still maintaining standards mode).</p> <p>Here's a <a href="http://www.howtocreate.co.uk/wrongWithIE/?chapter=Empty+Space" rel="noreferrer">link that gives a little background information</a>, but no ideal solution. There might not be a solution to this problem, I'm just curious about the behavior.</p> <p>Thanks Internet, Zach</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;script type="text/javascript"&gt; function countNodes() { alert(document.getElementsByTagName('body')[0].childNodes.length); } &lt;/script&gt; &lt;/head&gt; &lt;body onload="countNodes()"&gt; &lt;form&gt;&lt;/form&gt; &lt;input type="submit"/&gt; &lt;input type="reset"/&gt; &lt;input type="button"/&gt; &lt;input type="text"/&gt; &lt;input type="password"/&gt; &lt;input type="file"/&gt; &lt;input type="hidden"/&gt; &lt;input type="checkbox"/&gt; &lt;input type="radio"/&gt; &lt;button&gt;&lt;/button&gt; &lt;select&gt;&lt;/select&gt; &lt;textarea&gt;&lt;/textarea&gt; &lt;div&gt;&lt;/div&gt; &lt;span&gt;&lt;/span&gt; &lt;table&gt;&lt;/table&gt; &lt;ul&gt;&lt;/ul&gt; &lt;a&gt;&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 281592, "author": "scunliffe", "author_id": 6144, "author_profile": "https://Stackoverflow.com/users/6144", "pm_score": 0, "selected": false, "text": "<table>\n <thead>\n </thead>\n <tbody>\n </tbody>\n <tfoot>\n </tfoot>\n</table>\n" }, { "answer_id": 289083...
2008/11/11
[ "https://Stackoverflow.com/questions/281443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16711/" ]
281,456
<p>I need to convert several Java classes to C#, but I have faced few problems.</p> <p>In Java I have following class hierarchy:</p> <pre><code>public abstract class AbstractObject { public String getId() { return id; } } public class ConcreteObject extends AbstractObject { public void setId(String id) { this.id= id; } } </code></pre> <p>There are implementation of AbstractObject which do not need to have setId() defined, so I cannot move it up in the hierarchy.</p> <p>How to convert this to C# using properties? Is that possible?</p>
[ { "answer_id": 281469, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 2, "selected": false, "text": "get" }, { "answer_id": 281505, "author": "Ant", "author_id": 11529, "author_profile": "https://Sta...
2008/11/11
[ "https://Stackoverflow.com/questions/281456", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22062/" ]
281,468
<p>I want ajax application to process a simple form with textinput and submit button only , and without validation , i want to add this with a php script . I ask this because i don't know how to program with ajax or javascript .</p>
[ { "answer_id": 281691, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 0, "selected": false, "text": "$(document).ready(function () {\n $('form').ajaxSubmit('#result');\n});\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22634/" ]
281,488
<p>I have a circular, statically allocated buffer in C, which I'm using as a queue for a <strike>depth</strike> breadth first search. I'd like have the top N elements in the queue sorted. It would be easy to just use a regular qsort() - except it's a circular buffer, and the top N elements might wrap around. I could, of course, write my own sorting implementation that uses modular arithmetic and knows how to wrap around the array, but I've always thought that writing sorting functions is a good exercise, but something better left to libraries.</p> <p>I thought of several approaches:</p> <ol> <li>Use a separate linear buffer - first copy the elements from the circular buffer, then apply qsort, then copy them back. Using an additional buffer means an additional O(N) space requirement, which brings me to <ul> <li>Sort the "top" and "bottom" halve using qsort, and then merge them using the additional buffer</li> <li>Same as 2. but do the final merge in-place (I haven't found much on in-place merging, but the implementations I've seen don't seem worth the reduced space complexity)</li> </ul></li> </ol> <p>On the other hand, spending an hour contemplating how to elegantly avoid writing my own quicksort, instead of adding those 25 (or so) lines might not be the most productive either...</p> <p><strong>Correction:</strong> Made a stupid mistake of switching DFS and BFS (I prefer writing a DFS, but in this particular case I have to use a BFS), sorry for the confusion.</p> <p><strong>Further description of the original problem:</strong></p> <p>I'm implementing a <strong>breadth</strong> first search (for something not unlike the <a href="http://en.wikipedia.org/wiki/Fifteen_puzzle" rel="nofollow noreferrer">fifteen</a> puzzle, just more complicated, with about O(n^2) possible expansions in each state, instead of 4). The "bruteforce" algorithm is done, but it's "stupid" - at each point, it expands all valid states, in a hard-coded order. The queue is implemented as a circular buffer (unsigned queue[MAXLENGTH]), and it stores integer indices into a table of states. Apart from two simple functions to queue and dequeue an index, it has no encapsulation - it's just a simple, statically allocated array of unsigned's.</p> <p>Now I want to add some heuristics. The first thing I want to try is to sort the expanded child states after expansion ("expand them in a better order") - just like I would if I were programming a simple best-first DFS. For this, I want to take part of the queue (representing the most recent expanded states), and sort them using some kind of heuristic. I could also expand the states in a different order (so in this case, it's not really important if I break the FIFO properties of the queue).</p> <p>My goal is not to implement <a href="http://en.wikipedia.org/wiki/A*_search_algorithm" rel="nofollow noreferrer">A*</a>, or a depth first search based algorithm (I can't afford to expand all states, but if I don't, I'll start having problems with infinite cycles in the state space, so I'd have to use something like <a href="http://en.wikipedia.org/wiki/Iterative_deepening_depth-first_search" rel="nofollow noreferrer">iterative deepening</a>).</p>
[ { "answer_id": 281737, "author": "Brian Ensink", "author_id": 1254, "author_profile": "https://Stackoverflow.com/users/1254", "pm_score": 2, "selected": false, "text": "qsort" }, { "answer_id": 281748, "author": "dmckee --- ex-moderator kitten", "author_id": 2509, "au...
2008/11/11
[ "https://Stackoverflow.com/questions/281488", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27610/" ]
281,490
<p>I currently have Apache HTTP Server, but I'm guessing I'll need Tomcat (and then have to configure it in a way that makes it not open to the public), a Java JDK (which I already have, but should probably update), and an IDE (I have Eclipse). But what else should I have or know before starting?</p>
[ { "answer_id": 281494, "author": "Bogdan", "author_id": 24022, "author_profile": "https://Stackoverflow.com/users/24022", "pm_score": 0, "selected": false, "text": "mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp\n" }...
2008/11/11
[ "https://Stackoverflow.com/questions/281490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
281,500
<p>I'm trying to connect to an MDF. I've even gone to the lengths of re-installing sql server express entirely (it is now the only flavor of SQL installed on my box, where previously I had 05 dev and express). I've verified that the paths are all correct, and thus far my google-fu hasn't helped.</p> <p>The Full exception message is: </p> <blockquote> <p>Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.</p> </blockquote> <p>The Connection string is:</p> <pre><code>&lt;add name= "CustomerEntities" connectionString="metadata=res://*/Data.CustomerModel.csdl|res://*/Data.CustomerModel.ssdl|res://*/Data.CustomerModel.msl; provider=System.Data.SqlClient; provider connection string='Data Source=.\SQLEXPRESS; AttachDbFilename=\App_Data\CustomerDb.mdf; Integrated Security=True; User Instance=True'" providerName="System.Data.EntityClient" /&gt; </code></pre> <h3>Additional info:</h3> <p>Several of the references to this error I've found online do not apply to me. For example, one I've seen is where this error occurs when trying to start the user instance over remote desktop (I'm doing this locally). While another suggests that it has to do with leftover files from an old express installation ... I've looked in the prescribed locations and not found those artifacts. I also tried running <code>sp_configure 'user instances enabled', '1'</code>, but it said that it was already set to 1.</p>
[ { "answer_id": 281626, "author": "Joel Martinez", "author_id": 5416, "author_profile": "https://Stackoverflow.com/users/5416", "pm_score": 7, "selected": true, "text": "AttachDbFilename=|DataDirectory|CustomerDb.mdf;" }, { "answer_id": 17092017, "author": "Hamid Shahid", ...
2008/11/11
[ "https://Stackoverflow.com/questions/281500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5416/" ]
281,503
<p>I am having trouble creating a mapping when the List type is an interface. It looks like I need to create an abstract class and use the discriminator column is this the case? I would rather not have to as the abstract class will just contain an abstract method and I would rather just keep the interface.</p> <p>I have an interface lets call it Account</p> <pre><code>public interface Account { public void doStuff(); } </code></pre> <p>Now I have two concrete implementors of Account OverSeasAccount and OverDrawnAccount</p> <pre><code>public class OverSeasAccount implements Account { public void doStuff() { //do overseas type stuff } } </code></pre> <p>AND</p> <pre><code>public class OverDrawnAccount implements Account { public void doStuff() { //do overDrawn type stuff } } </code></pre> <p>I have a class called Work with a List</p> <pre><code>private List&lt;Account&gt; accounts; </code></pre> <p>I am looking at discriminator fields but I seem to be only able do this for abstract classes. Is this the case? Any pointers appreciated. Can I use discriminators for interfaces? </p>
[ { "answer_id": 281900, "author": "Andrea Francia", "author_id": 36131, "author_profile": "https://Stackoverflow.com/users/36131", "pm_score": 1, "selected": false, "text": "// not an entity\npublic interface Account {\n public void doStuff();\n}\n\n@Entity\npublic abstract class BaseA...
2008/11/11
[ "https://Stackoverflow.com/questions/281503", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3050/" ]
281,507
<p>Can a Silverlight 2 enabled web page be managed from an Apache server? (I'm not actually interested in doing this but trying to understand Silverlight 2 a bit more.)</p> <p>Assuming that I have IIS6 and Server 2003 what are the .NET version requirements to host a web site with Silverlight 2? Are .NET 3.0 and 3.5 required on the server? My thinking is not because this is a client side technology.</p>
[ { "answer_id": 281519, "author": "Galwegian", "author_id": 3201, "author_profile": "https://Stackoverflow.com/users/3201", "pm_score": 0, "selected": false, "text": "* Windows\n o Operating System: Windows Vista; Windows XP Service Pack 2\n o Intel® Pentium® III 450MHz or faste...
2008/11/11
[ "https://Stackoverflow.com/questions/281507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463/" ]
281,512
<p>I am having issues converting a png to tiff. The conversion goes fine, but the image is huge. I think the issue is that I am not doing the compression correctly? Anyone have any suggestions??</p> <p>Here is the code sample</p> <pre><code>public static void test() throws IOException { // String fileName = "4958813_1"; String fileName = "4848970_1"; String inFileType = ".PNG"; String outFileType = ".TIFF"; ImageIO.scanForPlugins(); File fInputFile = new File("I:/HPF/UU/" + fileName + inFileType); InputStream fis = new BufferedInputStream(new FileInputStream( fInputFile)); PNGImageReaderSpi spi = new PNGImageReaderSpi(); ImageReader reader = spi.createReaderInstance(); ImageInputStream iis = ImageIO.createImageInputStream(fis); reader.setInput(iis, true); BufferedImage bi = reader.read(0); TIFFImageWriterSpi tiffspi = new TIFFImageWriterSpi(); ImageWriter writer = tiffspi.createWriterInstance(); //Iterator&lt;ImageWriter&gt; iter = ImageIO.getImageWritersByFormatName("TIFF"); //ImageWriter writer = iter.next(); ImageWriteParam param = writer.getDefaultWriteParam(); param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); param.setCompressionType("LZW"); param.setCompressionQuality(0.5f); File fOutputFile = new File("I:\\HPF\\UU\\" + fileName + outFileType); ImageOutputStream ios = ImageIO.createImageOutputStream(fOutputFile); writer.setOutput(ios); writer.write(bi); } </code></pre>
[ { "answer_id": 281612, "author": "Lou Franco", "author_id": 3937, "author_profile": "https://Stackoverflow.com/users/3937", "pm_score": 2, "selected": false, "text": "tiffWriteParam.setTilingMode(ImageWriteParam.MODE_EXPLICIT);\ntiffWriteParam.setTiling(imageWidth, imageHeight, 0, 0);\n"...
2008/11/11
[ "https://Stackoverflow.com/questions/281512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36641/" ]
281,515
<p>I would like to customize the background (and maybe the border too) of all of the UITableViewCells within my UITableView. So far I have not been able to customize this stuff, so I have a bunch of white background cells which is the default.</p> <p>Is there a way to do this with the iPhone SDK?</p>
[ { "answer_id": 290228, "author": "Vladimir Grigorov", "author_id": 22764, "author_profile": "https://Stackoverflow.com/users/22764", "pm_score": 6, "selected": false, "text": "UIView *backgroundView = [ [ [ UIView alloc ] initWithFrame:CGRectZero ] autorelease ];\nbackgroundView.backgrou...
2008/11/11
[ "https://Stackoverflow.com/questions/281515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35478/" ]
281,527
<p>Like any other hard disk, virtual hard discs (*.vhd) will suffer from fragmentation. </p> <p>So to keep good performance i guess i have to defrag first the virtual hard disc from within the virtual machine and also the (physical) hard disc the .vhd is stored on.</p> <p>First, are these assumption correct? And second, is there a way to defrag both (virtual and physical hard disc) at once?</p> <p>Thanks in advance!</p>
[ { "answer_id": 282466, "author": "John Baughman", "author_id": 26923, "author_profile": "https://Stackoverflow.com/users/26923", "pm_score": 3, "selected": false, "text": "jkDefrag -q -a2\njkDefrag -q -a6 C:\\PathToVirtualDisks\\VDiskToDefrag.vhd\njkDefrag -q -a3 -e C:\\PathToVirtualDisk...
2008/11/11
[ "https://Stackoverflow.com/questions/281527", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4531/" ]
281,531
<p>Most of my PHP apps have an ob_start at the beginning, runs through all the code, and then outputs the content, sometimes with some modifications, after everything is done.</p> <pre><code>ob_start() //Business Logic, etc header-&gt;output(); echo apply_post_filter(ob_get_clean()); footer-&gt;output(); </code></pre> <p>This ensures that PHP errors get displayed within the content part of the website, and that errors don't interfere with <code>header</code> and <code>session_*</code> calls.</p> <p>My only problem is that with some large pages PHP runs out of memory. How do I stop this from happening?</p> <p>Some ideas:</p> <ol> <li>Write all of the buffered content to a temporary file and output that.</li> <li>When the buffers reaches a certain size, output it. Although this might interfere with the post filter.</li> <li>Raise the memory limit (thanx @troelskn).</li> </ol> <p>Whats the drawbacks on each of these approaches? Especially raising the memory limit?</p>
[ { "answer_id": 283413, "author": "J.D. Fitz.Gerald", "author_id": 11542, "author_profile": "https://Stackoverflow.com/users/11542", "pm_score": 1, "selected": false, "text": "ini_set('memory_limit','64M');\n" }, { "answer_id": 15505603, "author": "Haravikk", "author_id": ...
2008/11/11
[ "https://Stackoverflow.com/questions/281531", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6681/" ]
281,534
<p>Grasping at straws here... I work with a VB6 desktop system using several 2003-style Access databases (.MDB). Recently, I changed the first function from VB6 to VB.NET, still using an Access database. This is more than a conversion, but a rewrite with additional functionality. It is still fairly simple functionality, with a low-volume database. We have 1400 customers, small businesses with varying machine qualities. Most customers are happy with the new screen and functionality. A very few of those customers have experienced EXTREME slowness loading the datagridview. Customer Service tells us that 1) the machines have at least 1 GB of RAM, and 2) rebooting always solves the problem. </p> <p>I wrote an app to severely slow down my machine, and it STILL runs better for me than it does for those few customers. Also, my Access database has never been trashed by this application. </p> <p>Any suggestions?</p> <p>Thanks!!</p>
[ { "answer_id": 281773, "author": "bruceatk", "author_id": 791, "author_profile": "https://Stackoverflow.com/users/791", "pm_score": 3, "selected": true, "text": "\n@echo off\nSystemInfo >c:\\systeminfo.log\ntasklist /v >>c:\\systeminfo.log\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12897/" ]
281,538
<p>Are there major advantages to <a href="https://web.archive.org/web/20090207080811/http://www.innodb.com:80/hot-backup/features/" rel="nofollow noreferrer">InnoDB hot backup</a> vs ZRM <a href="https://www.zmanda.com/zrm-enterprise/" rel="nofollow noreferrer">snapshots</a> in terms of disruption to the running site, the size of compressed backup files, and speed of backup/restore on a medium-sized to largish all-InnoDB database?</p> <p>My understanding is that InnoDB's approach is more reliable, faster, does not cause a significant outage when running, etc.</p>
[ { "answer_id": 281773, "author": "bruceatk", "author_id": 791, "author_profile": "https://Stackoverflow.com/users/791", "pm_score": 3, "selected": true, "text": "\n@echo off\nSystemInfo >c:\\systeminfo.log\ntasklist /v >>c:\\systeminfo.log\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/556/" ]
281,563
<p>I'm currently using AntLR to parse some files with a proprietary language. I have a need of highlighting sections of it on an editor (think of highlighting a method in a Java class, for instance).</p> <p>Does anyone has a hint on how to get them? Say I have this code:</p> <pre><code>function test(param1, param2) { } </code></pre> <p>as function is a keyword, the first position I get in the parser is the one of the identifier "test". How can I get the positions from there up to the ending curly brace? The parameters list is dynamic, as one would expect, so you don't know in advance its length.</p> <p>Thank you!</p>
[ { "answer_id": 905885, "author": "fglez", "author_id": 33622, "author_profile": "https://Stackoverflow.com/users/33622", "pm_score": 2, "selected": true, "text": "func: FUNCTION ID '(' ID (',' ID)* ')' {\n System.out.println(\"Position = \" + $FUNCTION.pos);\n}\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7277/" ]
281,579
<p>I'm trying to do Ruby password input with the <a href="http://highline.rubyforge.org/" rel="noreferrer">Highline gem</a> and since I have the user input the password twice, I'd like to eliminate the duplication on the blocks I'm passing in. For example, a simple version of what I'm doing right now is:</p> <pre><code>new_pass = ask("Enter your new password: ") { |prompt| prompt.echo = false } verify_pass = ask("Enter again to verify: ") { |prompt| prompt.echo = false } </code></pre> <p>And what I'd like to change it to is something like this:</p> <pre><code>foo = Proc.new { |prompt| prompt.echo = false } new_pass = ask("Enter your new password: ") foo verify_pass = ask("Enter again to verify: ") foo </code></pre> <p>Which unfortunately doesn't work. What's the correct way to do this?</p>
[ { "answer_id": 281620, "author": "Lucas Oman", "author_id": 6726, "author_profile": "https://Stackoverflow.com/users/6726", "pm_score": -1, "selected": false, "text": "def foo(prompt)\n prompt.echo = false\nend\nnew_pass = ask(\"Enter your new password: \") { |prompt| foo(prompt) }\nver...
2008/11/11
[ "https://Stackoverflow.com/questions/281579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/422/" ]
281,584
<p>Using an ORM approach in applications can often lead to the scenario where you have a collection of objects you've retrieved and would like to display them in a tabular view using a DataGridView.</p> <p>In my (limited) experience, binding collections of objects using a custom BindingList to a DataGridView results in poor performance and unsatisfactory sorting. I'm looking for a generic solution to this problem such that it's straightforward to populate a DataGridView and also extract the underlying objects later.</p> <p>I will describe a good solution I've found, but I'm looking for alternatives.</p>
[ { "answer_id": 281620, "author": "Lucas Oman", "author_id": 6726, "author_profile": "https://Stackoverflow.com/users/6726", "pm_score": -1, "selected": false, "text": "def foo(prompt)\n prompt.echo = false\nend\nnew_pass = ask(\"Enter your new password: \") { |prompt| foo(prompt) }\nver...
2008/11/11
[ "https://Stackoverflow.com/questions/281584", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3406/" ]
281,586
<p>I want to make custom control which has couple of <code>&lt;input type='checkbox' /&gt;</code> controls which I render in Render method. Is it possible to retain ViewState (e.g. checked or not) on these Controls? </p> <p>There is a way of doing this by using ASP.NET server CheckBox control, adding them in OnLoad event with this.Controls.Add(), and giving them same Ids everytime, but I don't wat to do this :)</p>
[ { "answer_id": 281617, "author": "Frank Krueger", "author_id": 338, "author_profile": "https://Stackoverflow.com/users/338", "pm_score": 1, "selected": false, "text": "bool checked = (bool)(ViewState[\"ThisControlCheckState\"] ?? false);\nif (checked) {\n write(\"<input ... >\");\n}\n...
2008/11/11
[ "https://Stackoverflow.com/questions/281586", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36648/" ]
281,606
<p>Why does UDP have a length field in the header and TCP does not?</p> <p>I am guessing that the length of the segment in TCP is inferred from the IP header but one should be able to do the same for a UDP datagram</p>
[ { "answer_id": 281630, "author": "Brian R. Bondy", "author_id": 3153, "author_profile": "https://Stackoverflow.com/users/3153", "pm_score": 1, "selected": false, "text": " +--------+--------+--------+--------+\n | Source Address |\n +--------+--------+--...
2008/11/11
[ "https://Stackoverflow.com/questions/281606", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,618
<p>I need my database to be secure in case of the hard drive being stolen.</p> <p>I have not seen many databases (even mainstream ones) claiming to support encryption. </p> <ul> <li>Do you guys know of any databases that support encryption?</li> <li>If I'm using a database that doesn't support encryption, is it a bad idea to encrypt data natively (using java encryption libraries, for example)? Would this potentially cause a problem for databases with strongly typed fields? </li> <li>What other solutions are available for encrypting my database?</li> </ul>
[ { "answer_id": 41123787, "author": "userAndroid", "author_id": 2427218, "author_profile": "https://Stackoverflow.com/users/2427218", "pm_score": 0, "selected": false, "text": "SQLiteDatabase.loadLibs(context);\nSQLiteOpenHelper.getWritableDatabase(“yourSecretKey”):\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,627
<p>I have a flex client that makes service calls to a tomcat server running BlazeDS. I would like to gracefully handle server session timeouts in this environment.</p> <p>I do have security constraints on the service, so the client authenticates against a remote object by initializing a ChannelSet based on the destination, and then logging in using that ChannelSet.</p> <p>After the user is authenticated, if they go get a (long) cup of coffee, their session will inevitably time out.</p> <p>I would like the client to detect the timeout, and return the user back to the login page, with the appropriate informational messages.</p> <p>But I am having difficulty finding the best way to detect this timeout from the client. Is it possible, or must I have the server throw an error when the timeout occurs?</p> <p>Thanks!</p>
[ { "answer_id": 6540057, "author": "RJ Owen", "author_id": 210603, "author_profile": "https://Stackoverflow.com/users/210603", "pm_score": 1, "selected": false, "text": "if(faultEvent.fault.faultCode == \"Client.Error.RequestTimeout\"){\n trace(\"TIMEOUT ERROR\");\n}\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2885/" ]
281,640
<p>How do I get a human-readable file size in bytes abbreviation using .NET?</p> <p><strong>Example</strong>: Take input 7,326,629 and display 6.98 MB</p>
[ { "answer_id": 281665, "author": "TcKs", "author_id": 20382, "author_profile": "https://Stackoverflow.com/users/20382", "pm_score": 4, "selected": false, "text": "int size = new FileInfo( filePath ).Length / 1024;\nstring humanKBSize = string.Format( \"{0} KB\", size );\nstring humanMBSi...
2008/11/11
[ "https://Stackoverflow.com/questions/281640", "https://Stackoverflow.com", "https://Stackoverflow.com/users/337/" ]
281,652
<p>Is there a tsql command on sqlserver 2008 which can be run in order to enable Database Diagramming instead of this dialog appearing:</p> <p>This database does not have one or more of the support objects required to use database diagramming. Do you wish to create them? </p>
[ { "answer_id": 36057298, "author": "HarrySolsem", "author_id": 261271, "author_profile": "https://Stackoverflow.com/users/261271", "pm_score": 1, "selected": false, "text": "IF OBJECT_ID(N'dbo.sp_upgraddiagrams') IS NULL and IS_MEMBER('db_owner') = 1\nBEGIN\n EXEC sp_executesql N'\n ...
2008/11/11
[ "https://Stackoverflow.com/questions/281652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28717/" ]
281,664
<p>Imagine the following scenario - we have Page1 which contains controls Control A and Control B.</p> <p>Say Control A has a button, and on the click of this button we want Control B to react. But we want to do this in an abstract fashion, i.e. we can't have Control B knowing anything about Control A, and vice versa.</p> <p>That way we can develop these controls in isolation, and drive them by unit-testing.</p> <p>Now, I thought I had the solution, just want to know what you guys think of it.</p> <p>On Control A's button click, I put a 'message' on the Session, i.e. Session["MESSAGES"] = "ControlA_Click".</p> <p>In Page1, on the Page_LoadComplete(), I put a call to ProcessMessages, which looks like this:</p> <pre><code> List&lt;Message&gt; messages = SessionMessages.GetMessageList(Page); foreach(Message m in messages) { //Get Controls ControlA controlA = FindControl("controlA") as ControlA; controlA .ProcessMessage(m); ControlB controlB = FindControl("controlB") as ControlB; controlB.ProcessMessage(m); } </code></pre> <p>in ControlB's ProcessMessage() method, we can react to the messages that ControlB is interested in, like so:</p> <pre><code> if (m.MessageName == SessionMessages.C_MESSAGE_SEARCH) { this.Visible = true; } </code></pre> <p>To me, this seems to work. It allows us to develop these controls completely separately from eachother, while still allowing for inter-control-communication at an abstract level.</p> <p>The only thing I can think of that might bring this crashing down is <em>perhaps</em> the ASP.NET life-cycle in relation to Pages and User Controls. The way I figure it though is that ALL events should have been processed on the controls before Page_LoadComplete() is called on the owning Page.</p> <p>Thoughts?</p>
[ { "answer_id": 281728, "author": "user7375", "author_id": 7375, "author_profile": "https://Stackoverflow.com/users/7375", "pm_score": 1, "selected": false, "text": "public interface IHandle<T> where T:IMessage\n{\n void Process(T message)\n}\n" }, { "answer_id": 281729, "...
2008/11/11
[ "https://Stackoverflow.com/questions/281664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7140/" ]
281,682
<p>I am trying to set the innerxml of a xmldoc but get the exception: Reference to undeclared entity</p> <pre><code>XmlDocument xmldoc = new XmlDocument(); string text = "Hello, I am text &amp;alpha; &amp;nbsp; &amp;ndash; &amp;mdash;" xmldoc.InnerXml = "&lt;p&gt;" + text + "&lt;/p&gt;"; </code></pre> <p>This throws the exception: </p> <blockquote> <p>Reference to undeclared entity 'alpha'. Line 2, position 2.. </p> </blockquote> <p>How would I go about solving this problem?</p>
[ { "answer_id": 281686, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": false, "text": " &#913;\n" }, { "answer_id": 281739, "author": "Fernando Miguélez", "author_id": 34880, "author_profile...
2008/11/11
[ "https://Stackoverflow.com/questions/281682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6201/" ]
281,694
<p>I want to set up an ASP.NET custom control such that it has a custom name, specifically, with a hyphen within it, so it might look like this in markup:</p> <pre><code>&lt;rp:do-something runat="server" id="doSomething1" /&gt;</code></pre> <p>I don't mind if this syntax requires setting up a tag mapping in web.config or something to that effect, but the <a href="http://msdn.microsoft.com/en-us/library/ms164641.aspx" rel="nofollow noreferrer" title="tagMapping Element">tagMapping element</a> doesn't quite match up for what I'd like to do.</p>
[ { "answer_id": 281686, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": false, "text": " &#913;\n" }, { "answer_id": 281739, "author": "Fernando Miguélez", "author_id": 34880, "author_profile...
2008/11/11
[ "https://Stackoverflow.com/questions/281694", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34224/" ]
281,697
<p>I used code like this to find the remote user name:</p> <pre><code>banner_label.Text = "Welcome, &lt;B&gt;" + User.Identity.Name + "&lt;/B&gt;!" </code></pre> <p>I'd also like to find the remote host name. My production environment will be a corporate intranet with active directory.</p>
[ { "answer_id": 281732, "author": "John Boker", "author_id": 2847, "author_profile": "https://Stackoverflow.com/users/2847", "pm_score": 0, "selected": false, "text": "Request.UserHostName\n" }, { "answer_id": 281742, "author": "hugoware", "author_id": 17091, "author_p...
2008/11/11
[ "https://Stackoverflow.com/questions/281697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,698
<p>I just don't get it. Tried on VC++ 2008 and G++ 4.3.2</p> <pre><code>#include &lt;map&gt; class A : public std::multimap&lt;int, bool&gt; { public: size_type erase(int k, bool v) { return erase(k); // &lt;- this fails; had to change to __super::erase(k) } }; int main() { A a; a.erase(0, false); a.erase(0); // &lt;- fails. can't find base class' function?! return 0; } </code></pre>
[ { "answer_id": 281707, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 6, "selected": true, "text": "erase(int, bool)" }, { "answer_id": 281738, "author": "jalf", "author_id": 33213, "author_profile": "h...
2008/11/11
[ "https://Stackoverflow.com/questions/281698", "https://Stackoverflow.com", "https://Stackoverflow.com/users/21704/" ]
281,706
<p>I'm having an issue dragging a file from Windows Explorer on to a Windows Forms application. </p> <p>It works fine when I drag text, but for some reason it is not recognizing the file. Here is my test code:</p> <pre><code>namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_DragDrop(object sender, DragEventArgs e) { } private void Form1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.Text)) { e.Effect = DragDropEffects.Copy; } else if (e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.None; } } } } </code></pre> <p>AllowDrop is set to true on Form1, and as I mentioned, it works if I drag text on to the form, just not an actual file.</p> <p>I'm using Vista 64-bit ... not sure if that is part of the problem.</p>
[ { "answer_id": 281770, "author": "arul", "author_id": 15409, "author_profile": "https://Stackoverflow.com/users/15409", "pm_score": 0, "selected": false, "text": "string formats = string.Join( \"\\n\", e.Data.GetFormats(false) );\nMessageBox.Show( formats );\n" }, { "answer_id": ...
2008/11/11
[ "https://Stackoverflow.com/questions/281706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1768/" ]
281,714
<p>Do you have any ideas how to call DoEvents from a C# DLL</p>
[ { "answer_id": 281730, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 2, "selected": false, "text": "System.Windows.Forms.Application.DoEvents()" }, { "answer_id": 283208, "author": "Marc Gravell", "autho...
2008/11/11
[ "https://Stackoverflow.com/questions/281714", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28207/" ]
281,719
<p>I am quantitatively studying various metrics associated with automated tests. Chrome seems to have a reasonable set, so I wanted to add it to my data set. I downloaded the Chrome source code and tried to build it with VisualStudio but got several hundred errors--types not defined, identifiers not defined, etc. Has anyone out there succeeded in building Chrome under Windows? Are there tricks I need to know?</p>
[ { "answer_id": 281736, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 3, "selected": true, "text": "3>Error in tempfile() using /tmp/dftables-XXXXXXXX.in: Parent directory (/tmp/) is not writable\n3> at /cygdrive/c/b/slave/WE...
2008/11/11
[ "https://Stackoverflow.com/questions/281719", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13842/" ]
281,724
<p>From my experiments, it does not appear to do so. If this is indeed true, what is the best method for removing line breaks? I'm currently experimenting with the parameters that TRIM accepts of the character to remove, starting with trimming <code>\n</code> and <code>\r</code>.</p>
[ { "answer_id": 281740, "author": "LeppyR64", "author_id": 16592, "author_profile": "https://Stackoverflow.com/users/16592", "pm_score": 2, "selected": false, "text": "select trim(both '\\n' from FIELDNAME) from TABLE;\n" }, { "answer_id": 281778, "author": "Peter Crabtree", ...
2008/11/11
[ "https://Stackoverflow.com/questions/281724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/572/" ]
281,725
<p>I want to make this specialized w/o changing main. Is it possible to specialize something based on its base class? I hope so.</p> <p>-edit-</p> <p>I'll have several classes that inherit from SomeTag. I don't want to write the same specialization for each of them.</p> <pre><code>class SomeTag {}; class InheritSomeTag : public SomeTag {}; template &lt;class T, class Tag=T&gt; struct MyClass { }; template &lt;class T&gt; struct MyClass&lt;T, SomeTag&gt; { typedef int isSpecialized; }; int main() { MyClass&lt;SomeTag&gt;::isSpecialized test1; //ok MyClass&lt;InheritSomeTag&gt;::isSpecialized test2; //how do i make this specialized w/o changing main() return 0; } </code></pre>
[ { "answer_id": 281795, "author": "Konrad Rudolph", "author_id": 1968, "author_profile": "https://Stackoverflow.com/users/1968", "pm_score": 2, "selected": false, "text": "MyClass" }, { "answer_id": 281830, "author": "Jesse Beder", "author_id": 112, "author_profile": "...
2008/11/11
[ "https://Stackoverflow.com/questions/281725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,743
<p>I have a client which is shipping via UPS, and therefore cannot deliver to Post Office boxes. I would like to be able to validate customer address fields in order to prevent them from entering addresses which include a PO box. It would be best if this were implemented as a regex so that I could use a client-side regex validation control (ASP.NET).</p> <p>I realize there's probably no way to get a 100% detection rate, I'm just looking for something that will work most of the time.</p>
[ { "answer_id": 281753, "author": "Bill the Lizard", "author_id": 1288, "author_profile": "https://Stackoverflow.com/users/1288", "pm_score": 3, "selected": true, "text": "\"^P\\.?\\s?O\\.?\\sB[Oo][Xx].\"\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13583/" ]
281,744
<p>Can someone explain how exactly prepared connection pooling using dbcp can be used? (with some example code if possible). I've figured out how to turn it on - passing a KeyedObjectPoolFactory to the PoolableConnectionFactory. But how should the specific prepared statements be defined after that? Right now I'm only using a PoolingDataSource to get connections from the pool. How do I use the prepared statements from the pool?</p>
[ { "answer_id": 282135, "author": "Georgy Bolyuba", "author_id": 4052, "author_profile": "https://Stackoverflow.com/users/4052", "pm_score": 4, "selected": true, "text": "* public PreparedStatement prepareStatement(String sql)\n* public PreparedStatement prepareStatement(String sql, int r...
2008/11/11
[ "https://Stackoverflow.com/questions/281744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12649/" ]
281,758
<p>I'm working on a Spring MVC project, and I have unit tests for all of the various components in the source tree.</p> <p>For example, if I have a controller <code>HomeController</code>, which needs to have a <code>LoginService</code> injected into it, then in my unit test <code>HomeControllerTest</code> I simply instantiate the object as normal (outside of Spring) and inject the property:</p> <pre><code>protected void setUp() throws Exception { super.setUp(); //... controller = new HomeController(); controller.setLoginService( new SimpleLoginService() ); //... } </code></pre> <p>This works great for testing each component as an isolated unit - except now that I have a few dozen classes in the project, after writing a class and writing a successful unit test for it, I keep forgetting to update my Spring MVC context file that does the actual wiring-up in the deployed application. I find out that I forgot to update the context file when I deploy the project to Tomcat and find a bunch of NullPointers from non-wired-up beans.</p> <p>So, here are my questions:</p> <ol> <li><p>This is my first Spring project - is it normal to create unit tests for the individual beans, as I have done, and then create a second suite of tests (integration tests) to test that everything works as expected with the actual application context? Is there an established best practice for this?</p></li> <li><p>In addition, how do you separate the unit tests from the integration tests? I have all of the source code in <code>src</code>, the unit tests in <code>test</code> - should there be a 2nd test folder (such as <code>test-integration</code>) for integration test cases?</p></li> </ol> <p>Since this is my first Spring project, I'm curious how others usually go about doing this sort of thing - and rather than re-invent the wheel I rather ask the rest of the community.</p>
[ { "answer_id": 281841, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 6, "selected": true, "text": "test" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4249/" ]
281,787
<p>What's the best way to output the public contents of an object to a human-readable file? I'm looking for a way to do this that would not require me to know of all the members of the class, but rather use the compiler to tell me what members exist, and what their names are. There have to be macros or something like that, right?</p> <p>Contrived example: </p> <pre><code>class Container { public: Container::Container() {/*initialize members*/}; int stuff; int otherStuff; }; Container myCollection; </code></pre> <p>I would like to be able to do something to see output along the lines of "myCollection: stuff = value, otherStuff = value". But then if another member is added to Container, </p> <pre><code>class Container { public: Container::Container() {/*initialize members*/}; int stuff; string evenMoreStuff; int otherStuff; }; Container myCollection;</code></pre> <p>This time, the output of this snapshot would be "myCollection: stuff = value, evenMoreStuff=value, otherStuff = value"</p> <p>Is there a macro that would help me accomplish this? Is this even possible? (Also, I can't modify the Container class.) Another note: I'm most interested about a potential macros in VS, but other solutions are welcome too.</p>
[ { "answer_id": 281832, "author": "ReaperUnreal", "author_id": 4218, "author_profile": "https://Stackoverflow.com/users/4218", "pm_score": 0, "selected": false, "text": "char *buffer = new char[sizeof(Container)];\nmemcpy(buffer, containerInstance, sizeof(Container));\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281787", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22724/" ]
281,791
<p>I want to set the background of an <code>NSBox</code> to be a gradient. In Interface Builder it is possible to set the background color of an <code>NSBox</code> to <code>selectedMenuColor</code> which is a gradient. </p> <p><code>NSBox</code> only has a <code>setFillColor</code> method so how is Interface Builder filling it with a gradient? </p> <p>How do I programmatically fill an <code>NSBox</code> without subclassing it? It would be trivial to subclass <code>NSBox</code> but the workings of Interface Builder suggest there may be better solution.</p>
[ { "answer_id": 281984, "author": "Ben Gottlieb", "author_id": 6694, "author_profile": "https://Stackoverflow.com/users/6694", "pm_score": 0, "selected": false, "text": "colorWithPatternImage:" }, { "answer_id": 284076, "author": "Dave Dribin", "author_id": 26825, "aut...
2008/11/11
[ "https://Stackoverflow.com/questions/281791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,811
<p>How do I test if two dates are within a certain tolerance in NUnit?</p>
[ { "answer_id": 281853, "author": "Rob Prouse", "author_id": 30827, "author_profile": "https://Stackoverflow.com/users/30827", "pm_score": 1, "selected": false, "text": "long ticks = mydate.Ticks;\nlong tolerance = 1000;\nAssert.That( ticks, Is.LessThan( ticks + tolerance ) & Is.GreaterTh...
2008/11/11
[ "https://Stackoverflow.com/questions/281811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/549/" ]
281,818
<p>I'm currently working on some logging code that supposed to - among other things - print information about the calling function. This should be relatively easy, standard C++ has a <code>type_info</code> class. This contains the name of the typeid'd class/function/etc. but it's mangled. It's not very useful. I.e. <code>typeid(std::vector&lt;int&gt;).name()</code> returns <code>St6vectorIiSaIiEE</code>.</p> <p>Is there a way to produce something useful from this? Like <code>std::vector&lt;int&gt;</code> for the above example. If it only works for non-template classes, that's fine too.</p> <p>The solution should work for gcc, but it would be better if I could port it. It's for logging so it's not so important that it can't be turned off, but it should be helpful for debugging.</p>
[ { "answer_id": 281860, "author": "CesarB", "author_id": 28258, "author_profile": "https://Stackoverflow.com/users/28258", "pm_score": 1, "selected": false, "text": "__cxa_demangle" }, { "answer_id": 281876, "author": "KeithB", "author_id": 2298, "author_profile": "htt...
2008/11/11
[ "https://Stackoverflow.com/questions/281818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9232/" ]
281,831
<p>I am porting an MFC application to .NET WinForms. In the MFC application, you can right click on a menu or on a context menu item and we show another context menu with diagnostic and configuration items. I am trying to port this functionality to .NET, but I am having trouble.</p> <p>I have been able to capture the right click, disable the click of the underlying menu and pop up a context menu at the right location, but the original menu disappears as soon as it loses focus.</p> <p>In MFC, we show the new context menu by calling <strong>TrackPopupMenuEx</strong> with the <strong>TPM_RECURSE</strong> flag.</p> <p><strong>ContextMenu</strong> and the newer <strong>ContextMenuStrip</strong> classes in .NET only have a <em>Show</em> method. Does anyone know how to do this in .NET?</p> <p><strong>EDIT</strong></p> <p>I have tried using <strong>TrackPopupMenuEx</strong> through a p/invoke, but that limits you to using a ContextMenu instead of a ContextMenuStrip which looks out of place in our application. It also still does not work correctly. It doesn't work with the new <strong>MenuStrip</strong> and <strong>ContextMenuStrip</strong>.</p> <p>I have also tried subclassing ToolStripMenuItem to see if I can add a context menu to it. That is working for <strong>MenuStrip</strong>, but <strong>ContextMenuStrip</strong> still allows the right click events to pass through as clicks.</p>
[ { "answer_id": 281883, "author": "Jason Diller", "author_id": 2187, "author_profile": "https://Stackoverflow.com/users/2187", "pm_score": 2, "selected": false, "text": "[DllImport(\"user32.dll\")]\nstatic extern bool TrackPopupMenuEx(IntPtr hmenu, uint fuFlags, int x, int y,\nIntPtr hwnd...
2008/11/11
[ "https://Stackoverflow.com/questions/281831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30827/" ]
281,837
<p>I would like to parse HTML document and replace action attribute of all the forms and add some hidden fields with XSL. Can someone show some examples of XSL that can do this?</p>
[ { "answer_id": 281848, "author": "andy.gurin", "author_id": 22388, "author_profile": "https://Stackoverflow.com/users/22388", "pm_score": 0, "selected": false, "text": "XSLT" }, { "answer_id": 281932, "author": "Fernando Miguélez", "author_id": 34880, "author_profile"...
2008/11/11
[ "https://Stackoverflow.com/questions/281837", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,843
<p>I realize you can't get the target entity in the Attribute itself, but what about in an associated Permission object when using a CodeAccessSecurityAttribute? The Permission object gets called at runtime so it seems there should be a way but I'm at a loss.</p> <pre><code>public sealed class MySecurityAttribute : CodeAccessSecurityAttribute { public override IPermission CreatePermission() { MySecurityPermission permission = new MySecurityPermission(); //set its properties permission.Name = this.Name; permission.Unrestricted = this.Unrestricted; return permission; } } public class MySecurityPermission : IPermission, IUnrestrictedPermission { public MySecurityPermission(PermissionState state) { // what method was the attribute decorating that // created this MySecurityPermission? } public void Demand() { // Or here? } } </code></pre>
[ { "answer_id": 343463, "author": "Miral", "author_id": 43534, "author_profile": "https://Stackoverflow.com/users/43534", "pm_score": 0, "selected": false, "text": "this" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36668/" ]
281,855
<p>For what I can read, it is used to dispatch a new thread in a swing app to perform some "background" work, but what's the benefit from using this rather than a "normal" thread?</p> <p>Is not the same using a new Thread and when it finish invoke some GUI method using SwingUtilities.invokeLater?... </p> <p>What am I missing here?</p> <p><a href="http://en.wikipedia.org/wiki/SwingWorker" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/SwingWorker</a></p> <p><a href="http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html" rel="nofollow noreferrer">http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html</a></p>
[ { "answer_id": 281871, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 2, "selected": false, "text": "update(int status)" }, { "answer_id": 283223, "author": "Daniel Hiller", "author_id": 16193...
2008/11/11
[ "https://Stackoverflow.com/questions/281855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20654/" ]
281,864
<p>I have a function that checks if a cookie (by name) exists or not:</p> <pre><code>Private Function cookieExists(ByVal cName As String) As Boolean For Each c As HttpCookie In Response.Cookies If c.Name = cName Then Return True Next Return False End Function </code></pre> <p>I have a class that handles cookies in an application-specific manner, and I want to consolidate all the cookie-related functions to this class. However, I cannot use this code if I simply move it from the aspx page (where it currently resides) to the aforementioned class because I get the error: <code>'Name' Response is not declared.</code> I modified the class to allow the passing of a reference to the <strong><code>Response</code></strong> object:</p> <pre><code>Public Function cookieExists(ByVal cName As String, ByRef Response As HttpResponse) As Boolean For Each c As HttpCookie In Response.Cookies If c.Name = cName Then Return True Next Return False End Function </code></pre> <p>My question is: Is there a better way?</p>
[ { "answer_id": 281872, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 5, "selected": true, "text": "HttpContext.Current.Response\nHttpContext.Current.Request\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25515/" ]
281,866
<p>Often you need to show a list of database items and certain aggregate numbers about each item. For instance, when you type the title text on Stack Overflow, the Related Questions list appears. The list shows the titles of related entries and the single aggregated number of quantity of responses for each title.</p> <p>I have a similar problem but needing multiple aggregates. I'd like to display a list of items in any of 3 formats depending on user options:</p> <ul> <li>My item's name (15 total, 13 owned by me)</li> <li>My item's name (15 total)</li> <li>My item's name (13 owned by me)</li> </ul> <p>My database is:</p> <ul> <li><strong>items</strong>: itemId, itemName, ownerId</li> <li><strong>categories</strong>: catId, catName</li> <li><strong>map</strong>: mapId, itemId, catId</li> </ul> <p>The query below gets: category name, count of item ids per category</p> <pre><code>SELECT categories.catName, COUNT(map.itemId) AS item_count FROM categories LEFT JOIN map ON categories.catId = map.catId GROUP BY categories.catName </code></pre> <p>This one gets: category name, count of item ids per category for this owner_id only</p> <pre><code>SELECT categories.catName, COUNT(map.itemId) AS owner_item_count FROM categories LEFT JOIN map ON categories.catId = map.catId LEFT JOIN items ON items.itemId = map.itemId WHERE owner = @ownerId GROUP BY categories.catId </code></pre> <p>But how do i get them at the same time in a single query? I.e.: category name, count of item ids per category, count of item ids per category for this owner_id only</p> <p>Bonus. How can I optionally only retrieve where catId count != 0 for any of these? In trying "WHERE item_count &lt;> 0" I get:</p> <pre><code>MySQL said: Documentation #1054 - Unknown column 'rid_count' in 'where clause' </code></pre>
[ { "answer_id": 281894, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 4, "selected": true, "text": "SUM()" }, { "answer_id": 281908, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "h...
2008/11/11
[ "https://Stackoverflow.com/questions/281866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/356/" ]
281,881
<p>I am trying to keep track of something and using the SessionID as they key to that object</p> <p>However the SessionID every 2-3 reqiests changes shouldn't it remain the same?</p> <pre><code>HttpContext.Session.SessionID </code></pre> <p>Is the code I am using.</p>
[ { "answer_id": 458694, "author": "robnardo", "author_id": 56774, "author_profile": "https://Stackoverflow.com/users/56774", "pm_score": 3, "selected": false, "text": "Session[\"myVar\"] = \"1234\";\n" }, { "answer_id": 5835631, "author": "javierlinked", "author_id": 65629...
2008/11/11
[ "https://Stackoverflow.com/questions/281881", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22093/" ]
281,884
<p>Can someone suggest a small webserver implementation that will illustrate the concepts of what a webserver does? It should be in a language that is easily read, and understood, and should implement security and cgi, maybe javascript? </p>
[ { "answer_id": 10630612, "author": "mikera", "author_id": 214010, "author_profile": "https://Stackoverflow.com/users/214010", "pm_score": 0, "selected": false, "text": "(ns my-app\n (:use noir.core)\n (:require [noir.server :as server]))\n\n(defpage \"/welcome\" []\n \"Welcome to No...
2008/11/11
[ "https://Stackoverflow.com/questions/281884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/23599/" ]
281,888
<p>In Python, how do I jump to a file in the Windows Explorer? I found a solution for jumping to folders:</p> <pre><code>import subprocess subprocess.Popen('explorer "C:\path\of\folder"') </code></pre> <p>but I have no solution for files.</p>
[ { "answer_id": 281911, "author": "Blair Conrad", "author_id": 1199, "author_profile": "https://Stackoverflow.com/users/1199", "pm_score": 8, "selected": true, "text": "import subprocess\nsubprocess.Popen(r'explorer /select,\"C:\\path\\of\\folder\\file\"')\n" }, { "answer_id": 272...
2008/11/11
[ "https://Stackoverflow.com/questions/281888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25705/" ]
281,890
<p>There are Hibernate tools for mapping files to ddl generation; ddl to mapping files and so on, but I can't find any command line tools for simple DDL generation from JPA annotated classes.</p> <p>Does anyone know an easy way to do this? (Not using Ant or Maven workarounds)</p>
[ { "answer_id": 497798, "author": "Kariem", "author_id": 12039, "author_profile": "https://Stackoverflow.com/users/12039", "pm_score": 3, "selected": false, "text": "<target name=\"schemaexport\" description=\"Export schema to DDL file\"\n depends=\"compile-jpa\"> <!-- compile model cl...
2008/11/11
[ "https://Stackoverflow.com/questions/281890", "https://Stackoverflow.com", "https://Stackoverflow.com/users/450527/" ]
281,891
<p>I'm using ASP.NET Membership and noticed there isn't a method in the <a href="http://msdn.microsoft.com/en-us/library/system.web.security.roles_members.aspx" rel="nofollow noreferrer">Roles class</a> to <em>modify</em> a role (its name for instance), only to create and delete them.</p> <p>Is it possible or it's not supported?</p> <p>EDIT: @CheGueVerra: Yes, nice workaround. </p> <p>Do you know (for extra credit :) ) why it's not possible?</p>
[ { "answer_id": 281935, "author": "CheGueVerra", "author_id": 17787, "author_profile": "https://Stackoverflow.com/users/17787", "pm_score": 5, "selected": true, "text": "public void RenameRoleAndUsers(string OldRoleName, string NewRoleName)\n{\n string[] users = Roles.GetUsersInRole(Ol...
2008/11/11
[ "https://Stackoverflow.com/questions/281891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1782/" ]
281,909
<p>let's say I have a excel spread sheet like below:</p> <pre> col1 col2 ------------ dog1 dog dog2 dog dog3 dog dog4 dog cat1 cat cat2 cat cat3 cat </pre> <p>I want to return a range of cells (dog1,dog2,dog3,dog4) or (cat1,cat2,cat3) based on either "dog" or "cat"</p> <p>I know I can do a loop to check one by one, but is there any other method in VBA so I can "filter" the result in one shot? </p> <p>maybe the Range.Find(XXX) can help, but I only see examples for just one cell not a range of cells.</p> <p>Please advice</p> <p>Regards</p>
[ { "answer_id": 282141, "author": "Mike Woodhouse", "author_id": 1060, "author_profile": "https://Stackoverflow.com/users/1060", "pm_score": 0, "selected": false, "text": "=CHAR(RANDBETWEEN(65,90))\n" }, { "answer_id": 282170, "author": "Mike Woodhouse", "author_id": 1060,...
2008/11/11
[ "https://Stackoverflow.com/questions/281909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36674/" ]
281,912
<p>I need a distinct sound to play when a error occurs. The error is the result of a problem with one of perhaps two hundred barcodes that are being inputted in rapid fire. The event queue seems to handle keyboard input (which the barcode scanner emulates) first, and playing of my sound second. So if the barcodes are scanned quickly, the error sound stays in the queue, being bumped by the next scan.</p> <p>Can I manipulate the priority of the queue?</p>
[ { "answer_id": 281915, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 1, "selected": false, "text": "keyup" }, { "answer_id": 281947, "author": "Kon", "author_id": 22303, "author_profile": "https://Stackov...
2008/11/11
[ "https://Stackoverflow.com/questions/281912", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13930/" ]
281,913
<p>I need to execute a SQL Server system stored procedure, programmatically, and since it executes in the current schema, I need to change it on the fly.</p> <p>Like this</p> <p>Statement st = connection.createStatement(); st.execute("EXEC SP_ADDUSER ' ', ' '");</p> <p>But SP_ADDUSER only executes on the current schema set for the connection, so if I wanted to create users in various schemas, I'd need to change it, and that's what I am looking for.</p>
[ { "answer_id": 282065, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 0, "selected": false, "text": "EXEC <DatabaseName>..sp_adduser" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281913", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,922
<p>I'm building a program that has a class used locally, but I want the same class to be used the same way over the network. This means I need to be able to make synchronous calls to any of its public methods. The class reads and writes files, so I think XML-RPC is too much overhead. I created a basic rpc client/server using the examples from twisted, but I'm having trouble with the client.</p> <pre><code>c = ClientCreator(reactor, Greeter) c.connectTCP(self.host, self.port).addCallback(request) reactor.run() </code></pre> <p>This works for a single call, when the data is received I'm calling reactor.stop(), but if I make any more calls the reactor won't restart. Is there something else I should be using for this? maybe a different twisted module or another framework?</p> <p>(I'm not including the details of how the protocol works, because the main point is that I only get one call out of this.)</p> <p>Addendum &amp; Clarification:</p> <p>I shared a google doc with notes on what I'm doing. <a href="http://docs.google.com/Doc?id=ddv9rsfd_37ftshgpgz" rel="nofollow noreferrer">http://docs.google.com/Doc?id=ddv9rsfd_37ftshgpgz</a></p> <p>I have a version written that uses fuse and can combine multiple local folders into the fuse mount point. The file access is already handled within a class, so I want to have servers that give me network access to the same class. After continuing to search, I suspect pyro (<a href="http://pyro.sourceforge.net/" rel="nofollow noreferrer">http://pyro.sourceforge.net/</a>) might be what I'm really looking for (simply based on reading their home page right now) but I'm open to any suggestions.</p> <p>I could achieve similar results by using an nfs mount and combining it with my local folder, but I want all of the peers to have access to the same combined filesystem, so that would require every computer to bee an nfs server with a number of nfs mounts equal to the number of computers in the network.</p> <p><strong>Conclusion:</strong> I have decided to use rpyc as it gave me exactly what I was looking for. A server that keeps an instance of a class that I can manipulate as if it was local. If anyone is interested I put my project up on Launchpad (<a href="http://launchpad.net/dstorage" rel="nofollow noreferrer">http://launchpad.net/dstorage</a>).</p>
[ { "answer_id": 281991, "author": "eswald", "author_id": 21229, "author_profile": "https://Stackoverflow.com/users/21229", "pm_score": 2, "selected": false, "text": "import socket\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.connect((self.host, self.port))\ns.send(output)\nda...
2008/11/11
[ "https://Stackoverflow.com/questions/281922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35247/" ]
281,928
<p>I often find myself writing simple for loops to perform an operation to many files, for example:</p> <pre><code>for i in `find . | grep ".xml$"`; do bzip2 $i; done </code></pre> <p>It seems a bit depressing that on my 4-core machine only one core is getting used.. is there an easy way I can add parallelism to my shell scripting?</p> <p>EDIT: To introduce a bit more context to my problems, sorry I was not more clear to start with!</p> <p>I often want to run simple(ish) scripts, such as plot a graph, compress or uncompress, or run some program, on reasonable sized datasets (usually between 100 and 10,000). The scripts I use to solve such problems look like the one above, but might have a different command, or even a sequence of commands to execute.</p> <p>For example, just now I am running:</p> <pre><code>for i in `find . | grep ".xml.bz2$"`; do find_graph -build_graph $i.graph $i; done </code></pre> <p>So my problems are in no way bzip specific! (Although parallel bzip does look cool, I intend to use it in future).</p>
[ { "answer_id": 281952, "author": "Tom Ritter", "author_id": 8435, "author_profile": "https://Stackoverflow.com/users/8435", "pm_score": 1, "selected": false, "text": "for i in `find . | grep \".xml$\"`; do bzip2 $i&; done\n" }, { "answer_id": 281967, "author": "Peter Crabtree...
2008/11/11
[ "https://Stackoverflow.com/questions/281928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27074/" ]
281,933
<p>Given a word, I've to replace some specific alphabets with some specific letters such as 1 for a, 5 for b etc. I'm using regex for this. I understand that StringBuilder is the best way to deal with this problem as I'm doing a lot of string manipulations. Here is what I'm doing:</p> <pre><code>String word = "foobooandfoo"; String converted = ""; converted = word.replaceAll("[ao]", "1"); converted = converted.replaceAll("[df]", "2"); converted = converted.replaceAll("[n]", "3"); </code></pre> <p>My problem is how to rewrite this program using StringBuilder. I tried everything but I can't succeed. Or using String is just fine for this?</p>
[ { "answer_id": 281956, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 0, "selected": false, "text": "Matcher.replaceAll()" }, { "answer_id": 281958, "author": "Konrad Rudolph", "author_id": 1968, "author_p...
2008/11/11
[ "https://Stackoverflow.com/questions/281933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33203/" ]
281,945
<p>Does anyone know of a way to store values as NVARCHAR in a manually created query in ColdFusion using the querynew() function? I have multiple parts of a largish program relying on using a query as an input point to construct an excel worksheet (using Ben's POI) so it's somewhat important I can continue to use it as a query to avoid a relatively large rewrite.</p> <p>The problem came up when a user tried storing something that is outside of the VARCHAR range, some Japanese characters and such.</p> <p>Edit: If this is not possible, and you are 100% sure, I'd like to know that too :)</p>
[ { "answer_id": 282260, "author": "Adam Tuttle", "author_id": 751, "author_profile": "https://Stackoverflow.com/users/751", "pm_score": 1, "selected": false, "text": "<cfset x = QueryNew(\"foobar\")/>\n<cfset queryAddRow(x) />\n<cfset querySetCell(x, \"foobar\", chr(163)) />\n<cfdump var=...
2008/11/11
[ "https://Stackoverflow.com/questions/281945", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16631/" ]
281,951
<p>We're using the following command line from within a Windows Service developed with C# .Net Framework 1.1:</p> <pre><code>net use z: \\myComputer\c$ </code></pre> <p>The service is running under a domain account that is a local administrator on "myComputer". After debugging the code we can see that it does not return any errors but the "z:" drive is never mapped. We've tried the exact same code from a console application and it works properly. What is it that we need to add to the Service to make this work?</p> <p>The code we're using is included below.</p> <p>Regards,<br> Sergio</p> <pre><code>startInfo.FileName = "net"; startInfo.Arguments = string.Format(@"use {0}: \\{1}\{2}", driveLetter, computerName, folder).Trim(); startInfo.UseShellExecute = false; startInfo.RedirectStandardError = true; proc.EnableRaisingEvents = false; proc.StartInfo = startInfo; proc.Start(); // If there is an error during the mapping of the drive, it will be read // from the StandardError property which is a StreamReader object and // be fed into the error output parameter. using(StreamReader errorReader = proc.StandardError) { string standardError = string.Empty; while((standardError = errorReader.ReadLine()) != null) { error += standardError + " "; } } proc.WaitForExit(); </code></pre>
[ { "answer_id": 281959, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 0, "selected": false, "text": "net use /?" }, { "answer_id": 11656869, "author": "Gary", "author_id": 393004, "author_profile": "...
2008/11/11
[ "https://Stackoverflow.com/questions/281951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
281,960
<p>I would like the value of the input text box to be highlighted when it gains focus, either by clicking it or tabbing to it.</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;script&gt; function focusTest(el) { el.select(); } &lt;/script&gt; &lt;input type="text" value="one" OnFocus="focusTest(this); return false;" /&gt; &lt;br/&gt; &lt;input type="text" value="two" OnFocus="focusTest(this); return false;" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When either input field is clicked in Firefox or IE, that field is highlighted. However, this doesn't work in Safari. (NOTE: it works when tabbing between fields.)</p>
[ { "answer_id": 282015, "author": "Pat", "author_id": 238, "author_profile": "https://Stackoverflow.com/users/238", "pm_score": 4, "selected": true, "text": "function focusTest(el)\n{\n setTimeout (function () {el.select();} , 50 );\n}\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/281960", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2749/" ]
281,979
<p>Do you generate your data dictionary? If so, how?</p> <p>I use extended procedures in SQL Server 2005 to hold onto table and field information. I have some queries that create a dictionary out of them, but it's ... meh. Do you have a particular query or tool you use? Do you generate it off of your database diagrams?</p> <p>Googling for "data dictionary sql server" comes up with many queries, but they're all about equally as attractive. Which is to say, good starting off points, but not production ready.</p>
[ { "answer_id": 282085, "author": "Cade Roux", "author_id": 18255, "author_profile": "https://Stackoverflow.com/users/18255", "pm_score": 1, "selected": false, "text": "INFORMATION_SCHEMA" }, { "answer_id": 283813, "author": "Philippe Grondier", "author_id": 11436, "au...
2008/11/11
[ "https://Stackoverflow.com/questions/281979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11947/" ]
282,002
<p>In developing search for a site I am building, I decided to go the cheap and quick way and use Microsoft Sql Server's Full Text Search engine instead of something more robust like Lucene.Net.</p> <p>One of the features I would like to have, though, is google-esque relevant document snippets. I quickly found determining "relevant" snippets is more difficult than I realized. </p> <p>I want to choose snippets based on search term density in the found text. So, essentially, I need to find the most search term dense passage in the text. Where a passage is some arbitrary number of characters (say 200 -- but it really doesn't matter).</p> <p>My first thought is to use .IndexOf() in a loop and build an array of term distances (subtract the index of the found term from the previously found term), then ... what? Add up any two, any three, any four, any five, sequential array elements and use the one with the smallest sum (hence, the smallest distance between search terms).</p> <p>That seems messy.</p> <p>Is there an established, better, or more obvious way to do this than what I have come up with?</p>
[ { "answer_id": 284083, "author": "CleverPatrick", "author_id": 22399, "author_profile": "https://Stackoverflow.com/users/22399", "pm_score": 1, "selected": false, "text": "private static string FindRelevantSnippets(string infoText, string[] searchTerms)\n {\n List<int> termLoca...
2008/11/11
[ "https://Stackoverflow.com/questions/282002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22399/" ]
282,007
<p>I want to programmatically disable the notification I get when I connect to a wireless network. I know there is a way to disable ALL notifications (see <a href="http://www.howtogeek.com/howto/windows/disable-notification-balloons-in-xp/" rel="nofollow noreferrer">here</a>) but is there a way to only disable the one issued by Windows wireless Manager (i.e. wlanapi.dll).</p> <p>Many thanks!</p>
[ { "answer_id": 10386235, "author": "Arasch", "author_id": 1366133, "author_profile": "https://Stackoverflow.com/users/1366133", "pm_score": 0, "selected": false, "text": "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced\nNew \\ DWORD\nEnableBalloonTips\...
2008/11/11
[ "https://Stackoverflow.com/questions/282007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
282,014
<p>I have an object that starts a thread, opens a file, and waits for input from other classes. As it receives input, it writes it to disk. Basically, it's a thread safe data logging class...</p> <p>Here's the weird part. When I open a form in the designer (Visual&nbsp;Studio&nbsp;2008) that uses the object the file gets created. It's obviously running under the design time vhost process...</p> <p>The odd thing is I've not been able to reproduce the issue in another project. I'm not sure what the rules are for code that gets executed in the designer and code that does not. For example, creating a file in a Windows Forms constructor doesn't actually create the file at design time...</p> <p>What is the explanation? Is there a reference?</p>
[ { "answer_id": 282031, "author": "Tigraine", "author_id": 21699, "author_profile": "https://Stackoverflow.com/users/21699", "pm_score": 0, "selected": false, "text": "Form_Load" }, { "answer_id": 282277, "author": "Community", "author_id": -1, "author_profile": "https...
2008/11/11
[ "https://Stackoverflow.com/questions/282014", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36693/" ]
282,016
<p>I need to make a piece of C# code interact through COM with all kinds of implementations.</p> <p>To make it easeier for users of that integration, I included the interacted interfaces in IDL (as part of a relevant existing DLL, but without coclass or implementation), then got that into my C# code by running Tlbimp to create the types definition.</p> <p>I implemented my C#, creating COM objects based on Windows registry info and casting the object into the interface I need.</p> <p>I then created a C# implementation of the interface in a seperate project and registered it. The main program creates the testing COM object correctly but fails to cast it into the interface (gets a null object when using C# 'as', gets an InvalidCastException of explicit cast).</p> <p>Can someone suggest why the interface is not identified as implemented by the testing object?</p> <p>This is the interface defition in IDL (compiled in C++ in VS 2005):</p> <pre><code> [ object, uuid(B60C546F-EE91-48a2-A352-CFC36E613CB7), dual, nonextensible, helpstring("IScriptGenerator Interface"), pointer_default(unique) ] interface IScriptGenerator : IDispatch{ [helpstring("Init the Script generator")] HRESULT Init(); [helpstring("General purpose error reporting")] HRESULT GetLastError([out] BSTR *Error); }; </code></pre> <p>This is the stub created for C# by Tlbimp:</p> <pre><code>[TypeLibType(4288)] [Guid("B60C546F-EE91-48A2-A352-CFC36E613CB7")] public interface IScriptGenerator { [DispId(1610743813)] void GetLastError(out string Error); [DispId(1610743808)] void Init(); } </code></pre> <p>This is part of the main C# code, creating a COM object by its ProgID and casting it to the IScriptGenerator interface:</p> <pre><code>public ScriptGenerator(string GUID) { Type comType = Type.GetTypeFromProgID(GUID); object comObj = null; if (comType != null) { try { comObj = Activator.CreateInstance(comType); } catch (Exception ex) { Debug.Fail("Cannot create the script generator COM object due to the following exception: " + ex, ex.Message + "\n" + ex.StackTrace); throw ex; } } else throw new ArgumentException("The GUID does not match a registetred COM object", "GUID"); m_internalGenerator = comObj as IScriptGenerator; if (m_internalGenerator == null) { Debug.Fail("The script generator doesn't support the required interface - IScriptGenerator"); throw new InvalidCastException("The script generator with the GUID " + GUID + " doesn't support the required interface - IScriptGenerator"); } } </code></pre> <p>And this is the implementing C# code, to test it's working (and it's not):</p> <pre><code> [Guid("EB46E31F-0961-4179-8A56-3895DDF2884E"), ProgId("ScriptGeneratorExample.ScriptGenerator"), ClassInterface(ClassInterfaceType.None), ComSourceInterfaces(typeof(SOAAPIOLELib.IScriptGeneratorCallback))] public class ScriptGenerator : IScriptGenerator { public void GetLastError(out string Error) { throw new NotImplementedException(); } public void Init() { // nothing to do } } </code></pre>
[ { "answer_id": 282325, "author": "Juan Zamudio", "author_id": 15058, "author_profile": "https://Stackoverflow.com/users/15058", "pm_score": 0, "selected": false, "text": "[InterfaceType(ComInterfaceType.InterfaceIsDual)]\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/282016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36694/" ]
282,018
<p>I'm doing some maintenance on a private svn server. Authentication is handled through Apache basic HTTP+mod_authz_svn. I need to have it so every user has read/write access, except for a single read-only user. The read-only user still needs to be authenticated, though. I setup my authz config file like this:</p> <pre>[/] * = rw read-only = r</pre> <p>But this doesn't work. The user "read-only" can still commit changes. I can make things read-only for everyone, but the * bit seems to override what I'm trying to set for "read-only."</p> <p>FWIW, relevant piece of the Apache conf is:</p> <pre> &lt;Location /repos&gt; DAV svn SVNPath ... SVNIndexXSLT "/svnindex.xsl" AuthzSVNAccessFile ... AuthType Basic AuthName ... AuthUserFile ... Require valid-user &lt;/Location&gt; </pre>
[ { "answer_id": 282052, "author": "Martin v. Löwis", "author_id": 33006, "author_profile": "https://Stackoverflow.com/users/33006", "pm_score": 3, "selected": false, "text": "[groups]\nall-but-ro = harry, sally, ...\n\n[/]\n@all-but-ro = rw\nread-only = r\n" }, { "answer_id": 2820...
2008/11/11
[ "https://Stackoverflow.com/questions/282018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36683/" ]
282,019
<p>I would like to declare a record in Delphi that contains the same layout as it has in C.</p> <p>For those interested : This record is part of a union in the Windows OS's LDT_ENTRY record. (I need to use this record in Delphi because I'm working on an Xbox emulator in Delphi - see project Dxbx on sourceforge).</p> <p>Anyway, the record in question is defined as:</p> <pre><code> struct { DWORD BaseMid : 8; DWORD Type : 5; DWORD Dpl : 2; DWORD Pres : 1; DWORD LimitHi : 4; DWORD Sys : 1; DWORD Reserved_0 : 1; DWORD Default_Big : 1; DWORD Granularity : 1; DWORD BaseHi : 8; } Bits; </code></pre> <p>As far as I know, there are no bit-fields possible in Delphi. I did try this:</p> <pre><code> Bits = record BaseMid: Byte; // 8 bits _Type: 0..31; // 5 bits Dpl: 0..3; // 2 bits Pres: Boolean; // 1 bit LimitHi: 0..15; // 4 bits Sys: Boolean; // 1 bit Reserved_0: Boolean; // 1 bit Default_Big: Boolean; // 1 bit Granularity: Boolean; // 1 bit BaseHi: Byte; // 8 bits end; </code></pre> <p>But alas: it's size becomes 10 bytes, instead of the expected 4. I would like to know how I should declare the record, so that I get a record with the same layout, the same size, and the same members. Preferrably without loads of getter/setters.</p> <p>TIA.</p>
[ { "answer_id": 282275, "author": "Toon Krijthe", "author_id": 18061, "author_profile": "https://Stackoverflow.com/users/18061", "pm_score": 3, "selected": false, "text": "type\n TBits = record\n private\n FBaseMid : Byte;\n FTypeDplPres : Byte;\n FLimitHiSysEa: Byte;\n ...
2008/11/11
[ "https://Stackoverflow.com/questions/282019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12170/" ]
282,024
<p>So I'm generating a random number using Rnd and Randomize to set a seed that looks like this:</p> <pre><code>Randomize lSeed Response.Write Rnd </code></pre> <p>I'm noticing that it's returning the same result for two values in a row for lSeed (e.g. 123, 124) but then on say 125 it will return a new value but 126 will be the same as the on for 125. Why would this be?</p> <p>Edit:</p> <p>I have tried something like this</p> <pre><code>Randomize Randomize lSeed Response.write Rnd </code></pre> <p>And I get the same results I described above.</p>
[ { "answer_id": 282033, "author": "Gordon Bell", "author_id": 16473, "author_profile": "https://Stackoverflow.com/users/16473", "pm_score": 0, "selected": false, "text": "' For ASP, you can create a function like:\nPublic Function RandRange(ByVal low As Integer, ByVal high As Integer) As ...
2008/11/11
[ "https://Stackoverflow.com/questions/282024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12261/" ]
282,035
<p>How does one lock the focus of a .net application to a specific control? For example, if I have a form with 5 text boxes, and I want them filled out in a specific order, how can I stop someone who is in box 1 from tabbing/clicking to box 2, or hitting OK or Cancel or anything else? Is there an easy way, or do I have to manually disable/enable each other control at the appropriate time? </p> <p>The trouble with the obvious solution (Reset Focus when Focus is Lost) is that MSDN says you can lock up your machine that way:</p> <p>(Source:<a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.leave.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.windows.forms.control.leave.aspx</a>)</p> <p>Caution:</p> <p>Do not attempt to set focus from within the Enter, GotFocus, Leave, LostFocus, Validating, or Validated event handlers. Doing so can cause your application or the operating system to stop responding. For more information, see the WM_KILLFOCUS topic in the "Keyboard Input Reference" section, and the "Message Deadlocks" section of the "About Messages and Message Queues" topic in the MSDN library at <a href="http://msdn.microsoft.com/library" rel="nofollow noreferrer">http://msdn.microsoft.com/library</a>. </p>
[ { "answer_id": 282060, "author": "Serhat Ozgel", "author_id": 31505, "author_profile": "https://Stackoverflow.com/users/31505", "pm_score": 2, "selected": false, "text": "private void textBox1_Leave(object sender, EventArgs e)\n{\n if string.isNullOrEmpty(textBox1.Text)\n {\n ...
2008/11/11
[ "https://Stackoverflow.com/questions/282035", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
282,061
<p>I have a bit of a problem. I wrote an API a long time ago for our production system, and it used Apache XML Beans. The schema was homogeneous (ie no imports, everything was from within the same schema), and everything worked just fine, even if the code for API handling was incredibly verbose. I've since written a far simpler and more elegant restful API using JAXB, with parts of the old one in mind, ie different schema, but some of the elements are identical. In the hopes of cleaning up and simplifying my binding code in the old API, I've replaced some of the parts by deleting them and importing the new schema and using those elements instead. However, whenever I try to parse documents that use the new mixture of schema, I get a validation error from XML Beans :</p> <pre><code>error: cvc-complex-type.2.4a: Expected element 'redundant-element@http://www.my.com/old/xmlns' instead of 'redundant-element@http://www.my.com/new/xmlns' here in element redundant-element-list@http://www.my.com/old/xmlns </code></pre> <p>Has anybody encountered this before ? Have any solutions or ideas ? I'd really appreciate it. Thank you kindly.</p>
[ { "answer_id": 282060, "author": "Serhat Ozgel", "author_id": 31505, "author_profile": "https://Stackoverflow.com/users/31505", "pm_score": 2, "selected": false, "text": "private void textBox1_Leave(object sender, EventArgs e)\n{\n if string.isNullOrEmpty(textBox1.Text)\n {\n ...
2008/11/11
[ "https://Stackoverflow.com/questions/282061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32232/" ]
282,062
<p>I have a class like this:</p> <pre><code>public class Stretcher : Panel { public static readonly DependencyProperty StretchAmountProp = DependencyProperty.RegisterAttached("StretchAmount", typeof(double), typeof(Stretcher), null); public static void SetStretchAmount(DependencyObject obj, double amount) { FrameworkElement elem = obj as FrameworkElement; elem.Width *= amount; obj.SetValue(StretchAmountProp, amount); } } </code></pre> <p>I can set the stretch amount property in XAML using the attribute syntax:</p> <pre><code>&lt;UserControl x:Class="ManagedAttachedProps.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:map="clr-namespace:ManagedAttachedProps" Width="400" Height="300"&gt; &lt;Rectangle Fill="Aqua" Width="100" Height="100" map:Stretch.StretchAmount="100" /&gt; &lt;/UserControl&gt; </code></pre> <p>and my rectangle is stretched, but I can't use property element syntax like this:</p> <pre><code>&lt;UserControl x:Class="ManagedAttachedProps.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:map="clr-namespace:ManagedAttachedProps" Width="400" Height="300"&gt; &lt;Rectangle Fill="Aqua" Width="100" Height="100"&gt; &lt;map:Stretcher.StretchAmount&gt;100&lt;/map:Stretcher.StretchAmount&gt; &lt;/Rectangle&gt; &lt;/UserControl&gt; </code></pre> <p>with the property element syntax my set block seems to be totally ignored (I can even put invalid double values in there), and the SetStretchAmount method is never called.</p> <p>I know it's possible to do something like this, because VisualStateManager does it. I've tried using types other than double and nothing seems to work.</p>
[ { "answer_id": 282410, "author": "Bryant", "author_id": 10893, "author_profile": "https://Stackoverflow.com/users/10893", "pm_score": 3, "selected": true, "text": "public class Stretch\n{\n public double StretchAmount { get; set; }\n}\n" }, { "answer_id": 284264, "author":...
2008/11/11
[ "https://Stackoverflow.com/questions/282062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6803/" ]
282,084
<p>Help!</p> <p>I have a PHP (PHP 5.2.5) script on HOST1 trying to connect to an MySql database HOST2. Both hosts are in Shared Host environments controlled through CPanel.</p> <p>HOST2 is set to allow remote database connections from HOST1.</p> <p>The PHP connect I'm using is:- $h2 = IPADDRESS; $dbu = DBUSER; $dbp = DBPASS;</p> <pre><code>$DBlink = mysql_connect($h2, $dbu, $dbp); </code></pre> <p>This always fails with:-</p> <pre><code>Access denied for user '&lt;dbusername&gt;'@'***SOMESTRING***' (using password: YES) </code></pre> <p>nb: <strong><em>SOMESTRING</em></strong> looks like it could be something to do with the shared host environment.</p> <p>Any ideas???</p> <p>BTW: I can make remote connections to HOST2 from my laptop using OpenOffice via ODBC, and SQLyog. The SQLyog and ODBC settings are exactly the same as the PHP script is trying to use.</p>
[ { "answer_id": 282136, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 2, "selected": false, "text": "mysql_connect()" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/282084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/27200/" ]
282,091
<p>I am instantiating a local COM server using CoCreateInstance. Sometimes the application providing the server takes a long time to start. When this happens, Windows pops a dialog box like this:</p> <p><strong>Server Busy</strong></p> <p>The action cannot be completed because the other program is busy. Choose 'Switch To' to activate the busy program and correct the problem.</p> <p>[Switch To...] [Retry] [Cancel]</p> <p>I have found mention of a Visual Basic property on the Application object, OleRequestPendingTimeout, that can be used to control the time before this dialog comes up. I can't find any good documentation on this or an equivalent that is useful from C++. Can anyone point me in the right direction?</p>
[ { "answer_id": 282309, "author": "Sunlight", "author_id": 33650, "author_profile": "https://Stackoverflow.com/users/33650", "pm_score": 2, "selected": false, "text": "IMessageFilter" }, { "answer_id": 282442, "author": "John Dibling", "author_id": 241536, "author_prof...
2008/11/11
[ "https://Stackoverflow.com/questions/282091", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36699/" ]
282,093
<p>I want my php script to create an output file in a folder based on the date. The way I'm doing this is that its supposed to get the foldername/filename from a text file outputted by another program which I am unable to edit.</p> <p>So the file its grabbing the data from looks like this:</p> <pre><code>data/newfolder/10302008/log_for_Today.txt | 24234234 </code></pre> <p>Only with multiple lines, I just need the script to go through it line by line, grab the folder/filename and create an empty file with that name in that location.</p> <p>The directories are all 777. Now I know how to create a new empty exe file in a folder but can't seem to figure out how to create the folder first then the exe inside of it, any ideas?</p>
[ { "answer_id": 282137, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 2, "selected": false, "text": "$directories = explode( '/', $path );\n" }, { "answer_id": 282140, "author": "gnud", "author_id": 27204, ...
2008/11/11
[ "https://Stackoverflow.com/questions/282093", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
282,099
<p>What's the Hi/Lo algorithm?</p> <p>I've found this in the <a href="http://en.wikipedia.org/wiki/NHibernate" rel="noreferrer">NHibernate</a> documentation (it's one method to generate unique keys, section 5.1.4.2), but I haven't found a good explanation of how it works.</p> <p>I know that Nhibernate handles it, and I don't need to know the inside, but I'm just curious.</p>
[ { "answer_id": 18440926, "author": "Thomas W", "author_id": 768795, "author_profile": "https://Stackoverflow.com/users/768795", "pm_score": 5, "selected": false, "text": "create table KEY_ALLOC (\n SEQ varchar(32) not null,\n NEXT bigint not null,\n primary key (SEQ)\n);\n" },...
2008/11/11
[ "https://Stackoverflow.com/questions/282099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36703/" ]
282,105
<p>I've used a Continuous Integration server in the past with great success, and hadn't had the need to ever perform a code freeze on the source control system. </p> <p>However, lately it seems that everywhere I look, most shops are using the concept of code freezes when preparing for a release, or even a new test version of their product. This idea runs even in my current project.</p> <p>When you check-in early and often, and use unit tests, integration tests, acceptance tests, etc., are code freezes still needed?</p>
[ { "answer_id": 282121, "author": "FlySwat", "author_id": 1965, "author_profile": "https://Stackoverflow.com/users/1965", "pm_score": 2, "selected": false, "text": "Development\n ||\n \\/\n QAT \n ||\n \\/\n UAT => Freeze until deploy date => Deploy => Merge and repeat\n ...
2008/11/11
[ "https://Stackoverflow.com/questions/282105", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5619/" ]
282,118
<p>Is it possible to create a toggle button in C# WinForms? I know that you can use a CheckBox control and set it's Appearance property to "Button", but it doesn't look right. I want it to appear sunken, not flat, when pressed. Any thoughts?</p>
[ { "answer_id": 3776945, "author": "Simon Sabin", "author_id": 281338, "author_profile": "https://Stackoverflow.com/users/281338", "pm_score": 7, "selected": false, "text": "CheckBox" }, { "answer_id": 8457321, "author": "legendJSLC", "author_id": 816077, "author_profi...
2008/11/11
[ "https://Stackoverflow.com/questions/282118", "https://Stackoverflow.com", "https://Stackoverflow.com/users/343/" ]
282,127
<p>I've got three (relevant) models, specified like this:</p> <pre><code>class User &lt; ActiveRecord::Base has_many :posts has_many :comments has_many :comments_received, :through =&gt; :posts, :source =&gt; :comments end class Post &lt; ActiveRecord::Base belongs_to :user has_many :comments end class Comment &lt; ActiveRecord::Base belongs_to :user belongs_to :post end </code></pre> <p>I'd like to be able to reference all the <code>comments_received</code> for a <code>user</code> with a route - let's say it's for batch approval of comments on all posts. <em>(note that you can also get <code>comments</code> made by the <code>user</code>, but users can't comment on their own posts, so the <code>comments</code> through a <code>post</code> are different and mutually exclusive)</em>. Logically, this should work with:</p> <pre><code>map.resources :users, :has_many =&gt; [:posts, :comments, :comments_received] </code></pre> <p>This should give me routes of</p> <pre><code>user_posts_path user_comments_path user_comments_received_path </code></pre> <p>The first two work, the last one doesn't. I've tried it without the <code>_</code> in <code>comments_received</code> to no avail. I'm looking to get a URL like</p> <pre><code>http://some_domain.com/users/123/comments_received </code></pre> <p>I've also tried nesting it, but maybe I'm doing that wrong. In that case, I'd think the map would be:</p> <pre><code>map.resources :users do |user| user.resources :comments user.resources :posts, :has_many =&gt; :comments end </code></pre> <p>and then the url might be:</p> <pre><code>http://some_domain.com/users/123/posts/comments </code></pre> <p>Maybe this is the right way to do it, but I have the syntax wrong?</p> <p>Am I thinking about this the wrong way? It seems reasonable to me that I should be able to get a page of all the <code>comments</code> added to all of a user's posts. </p> <p>Thanks for your help!</p>
[ { "answer_id": 282443, "author": "Cameron Price", "author_id": 35526, "author_profile": "https://Stackoverflow.com/users/35526", "pm_score": 0, "selected": false, "text": "map.resources :users do |user|\n user.resources :awards\n user.resources :contest_entries do |contest_entry|\n ...
2008/11/11
[ "https://Stackoverflow.com/questions/282127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
282,129
<p>I know about using a -vsdoc.js file for <a href="http://en.wikipedia.org/wiki/IntelliSense" rel="nofollow noreferrer">IntelliSense</a>, and the one for jQuery is easy to find. What other JavaScript, Ajax, and DHTML libraries have them and where can I find those files? Also, is there a document which outlines the specifications for -vsdoc.js files?</p>
[ { "answer_id": 311874, "author": "Adam", "author_id": 1341, "author_profile": "https://Stackoverflow.com/users/1341", "pm_score": 5, "selected": true, "text": "<summary locid=\"descriptionID\">Description</summary>\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/282129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22777/" ]
282,132
<p>I'm probably going to be using Tomcat and the Apache Axis webapp plugin, but I'm curious as to any other potential lightweight solutions.</p> <p>The main goal of this is to connect to MySQL database for doing some demos.</p> <p>Thanks, Todd</p>
[ { "answer_id": 285897, "author": "dshaw", "author_id": 32595, "author_profile": "https://Stackoverflow.com/users/32595", "pm_score": 2, "selected": false, "text": "mvn jetty:run\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/282132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8531/" ]
282,139
<p>I'm creating a batch file to make multiple directories from a list in a text file however after the directory is listed sometimes a filename is as well. Is there an easy way to have it ignore all data after the last \ on a line?</p>
[ { "answer_id": 285897, "author": "dshaw", "author_id": 32595, "author_profile": "https://Stackoverflow.com/users/32595", "pm_score": 2, "selected": false, "text": "mvn jetty:run\n" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/282139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
282,146
<p>I have been given the task of modifying a VB6 project. Nothing incredibly serious, adding a couple forms and fixing a few bugs for the most part. The project uses SQL Server (if that is of any relevance).</p> <p>My background in programming has been VB/C# .NET, PHP, C++ and mostly MySQL although I have used SQL Server on a much smaller scale. What kind of advice can anyone give me or resources for VB6 programming. It's been a few years since I've done any VB .NET work and while I can read the VB6 code and understand what is going on, I'm not sure how well I'm going to be able to start writing and/or modifying without a chance of breaking anything. </p> <p>What kind of advice can others offer? Any resources and/or stories would be great. Feel free to contribute things you may feel relevant yet I neglected to mention.</p> <p>Thanks!</p>
[ { "answer_id": 282205, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 4, "selected": false, "text": "On Error Resume Next" }, { "answer_id": 282250, "author": "Svante Svenson", "author_id":...
2008/11/11
[ "https://Stackoverflow.com/questions/282146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1444511/" ]
282,150
<p>I've read everywhere about how great they are, but for some reason I can't seem to figure out how exactly I'm supposed to test something. Could someone perhaps post a piece of example code and how they would test it? If it's not too much trouble :)</p>
[ { "answer_id": 282709, "author": "Till", "author_id": 2859, "author_profile": "https://Stackoverflow.com/users/2859", "pm_score": 5, "selected": false, "text": "<?php\nfunction foo($bar)\n{\n return $bar;\n}\n?>\n" }, { "answer_id": 292305, "author": "Kris", "author_id":...
2008/11/11
[ "https://Stackoverflow.com/questions/282150", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36712/" ]
282,157
<p>Assuming one has an abstract base class <code>foo</code> with <code>__get()</code> defined, and a child class <code>bar</code> which inherits from <code>foo</code> with a private variable <code>$var</code>, will the parent <code>__get()</code> be called when trying to access the private <code>$var</code> from outside the class? </p>
[ { "answer_id": 282167, "author": "Electronic Zebra", "author_id": 1742702, "author_profile": "https://Stackoverflow.com/users/1742702", "pm_score": 4, "selected": true, "text": "<?php\n abstract class foo\n {\n public function __get($var)\n {\n echo \"Paren...
2008/11/11
[ "https://Stackoverflow.com/questions/282157", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1742702/" ]
282,161
<p>I just found out that by converting PNG32 to PNG8 via Photoshop will fix the PNG transparency bug in IE&lt;=6. </p> <p>So I had this thought that instead of serving PNG32 to all browser, why not serve PNG8 if the client is using IE&lt;=6. </p> <p>I'm not really an expert when it comes to htaccess/httpd directives so I'm here for help. </p> <p>The title is the psuedocode itself.</p>
[ { "answer_id": 282174, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": 0, "selected": false, "text": "RewriteEngine on\nRewriteRule ^/(.*)\\.png$ /$18.png [L,QSA]\n" }, { "answer_id": 282219, "author": "cjm", ...
2008/11/11
[ "https://Stackoverflow.com/questions/282161", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20300/" ]
282,171
<p>How do I write the CC logo in HTML, is there something like <code>&amp;copy;</code> (which gives &copy;)?</p> <p>(CC stands for Creative Commons).</p>
[ { "answer_id": 282413, "author": "Alastair", "author_id": 31038, "author_profile": "https://Stackoverflow.com/users/31038", "pm_score": 1, "selected": false, "text": "&#nnnn;" }, { "answer_id": 5215916, "author": "Ori", "author_id": 582542, "author_profile": "https://...
2008/11/11
[ "https://Stackoverflow.com/questions/282171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/34109/" ]
282,176
<p>Imagine I have a process that starts several child processes. The parent needs to know when a child exits.</p> <p>I can use <code>waitpid</code>, but then if/when the parent needs to exit I have no way of telling the thread that is blocked in <code>waitpid</code> to exit gracefully and join it. It's nice to have things clean up themselves, but it may not be that big of a deal.</p> <p>I can use <code>waitpid</code> with <code>WNOHANG</code>, and then sleep for some arbitrary time to prevent a busy wait. However then I can only know if a child has exited every so often. In my case it may not be super critical that I know when a child exits right away, but I'd like to know ASAP...</p> <p>I can use a signal handler for <code>SIGCHLD</code>, and in the signal handler do whatever I was going to do when a child exits, or send a message to a different thread to do some action. But using a signal handler obfuscates the flow of the code a little bit.</p> <p>What I'd really like to do is use <code>waitpid</code> on some timeout, say 5 sec. Since exiting the process isn't a time critical operation, I can lazily signal the thread to exit, while still having it blocked in <code>waitpid</code> the rest of the time, always ready to react. <em>Is there such a call in linux? Of the alternatives, which one is best?</em></p> <hr> <p>EDIT:</p> <p>Another method based on the replies would be to block <code>SIGCHLD</code> in all threads with <code>pthread</code> \ <code>_sigmask()</code>. Then in one thread, keep calling <code>sigtimedwait()</code> while looking for <code>SIGCHLD</code>. This means that I can time out on that call and check whether the thread should exit, and if not, remain blocked waiting for the signal. Once a <code>SIGCHLD</code> is delivered to this thread, we can react to it immediately, and in line of the wait thread, without using a signal handler.</p>
[ { "answer_id": 290025, "author": "geocar", "author_id": 37507, "author_profile": "https://Stackoverflow.com/users/37507", "pm_score": 5, "selected": false, "text": "alarm()" }, { "answer_id": 7824046, "author": "ony", "author_id": 230744, "author_profile": "https://St...
2008/11/11
[ "https://Stackoverflow.com/questions/282176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5963/" ]
282,178
<p>So I have a User model that :has_many other models like Documents, Videos, Posts and the like. My question arises when I execute a "do" block from the User model like so:</p> <pre><code>has_many :posts do def recent find(:all, :order =&gt; 'created_at desc', :limit =&gt; 12) end end </code></pre> <p>This just lets me call something like user.posts.recent to find only those posts associated with the User. With this in place, how can I still add a :dependent => :destroy or :dependent => :delete_all to this association? Everything I have tried so far has errored out on me.</p>
[ { "answer_id": 283020, "author": "Cameron Booth", "author_id": 14873, "author_profile": "https://Stackoverflow.com/users/14873", "pm_score": -1, "selected": false, "text": "has_many :posts, :dependent => :destroy do\n def recent\n find(:all, :order => 'created_at desc', :limit =>...
2008/11/11
[ "https://Stackoverflow.com/questions/282178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36715/" ]
282,184
<p>Javascript usage has gotten remarkably more sophisticated and powerful in the past five years. One aspect of this sort of functional programming I struggle with, esp with Javascript’s peculiarities, is how to make clear either through comments or code just what is happening. Often this sort of code takes a while to decipher, even if you understand the prototypal, first-class functional Javascript way. Any thoughts or techniques for making perfectly clear what your code does and how in Javascript?</p> <p>I've asked this question elsewhere, but haven't gotten much response.</p>
[ { "answer_id": 282216, "author": "Jason Bunting", "author_id": 1790, "author_profile": "https://Stackoverflow.com/users/1790", "pm_score": 2, "selected": false, "text": "// comments are not included *on purpose* for illustrating \n// my point about the need for language knowledge\nfuncti...
2008/11/11
[ "https://Stackoverflow.com/questions/282184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4440/" ]
282,191
<p>in my flex application, I created a Tilelist. In this Tilelist, I am using an ItemRenderer to create a box consisting of an image and an VSlider in each tile. </p> <p>The tile need to be dragable when you click on the image, but not dragable when you slide the slider. How can I achieve this ? I have been scratching my head searching on Google for one day and I have really no idea.</p> <p>I look forward to your help. Thank you.</p>
[ { "answer_id": 284779, "author": "Blizter", "author_id": 387920, "author_profile": "https://Stackoverflow.com/users/387920", "pm_score": 1, "selected": false, "text": " public var overImage:Boolean = false;\n\n public function checkAllow(evt:DragEvent):void {\n\n ...
2008/11/11
[ "https://Stackoverflow.com/questions/282191", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387920/" ]
282,192
<p>I'm trying to auto-generate a plain text email with a trademark symbol in it. I've tried everything I can think of but it's still not going through.</p> <pre><code>&lt;cfmail from="#x#" to="#y#" subject="test" charset="UTF-8"&gt; ™ &amp;trade; #Chr(153)# &lt;/cfmail&gt; </code></pre>
[ { "answer_id": 282381, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 4, "selected": true, "text": "Chr(153)" } ]
2008/11/11
[ "https://Stackoverflow.com/questions/282192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8724/" ]
282,194
<p>I am trying to find out how much memory my application is consuming from within the program itself. The memory usage I am looking for is the number reported in the "Mem Usage" column on the Processes tab of Windows Task Manager.</p>
[ { "answer_id": 282220, "author": "Charlie", "author_id": 18529, "author_profile": "https://Stackoverflow.com/users/18529", "pm_score": 7, "selected": true, "text": "GetCurrentProcess()" }, { "answer_id": 8500024, "author": "Ronin", "author_id": 1091608, "author_profil...
2008/11/11
[ "https://Stackoverflow.com/questions/282194", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3114/" ]
282,198
<p>I want to select a bunch of <code>span</code>s in a <code>div</code> whose CSS contains a particular background color. How do I achieve this?</p>
[ { "answer_id": 282208, "author": "okoman", "author_id": 35903, "author_profile": "https://Stackoverflow.com/users/35903", "pm_score": -1, "selected": false, "text": "#id_of_the_div span[background-color=rgb(255,255,255)]\n" }, { "answer_id": 282595, "author": "Owen", "aut...
2008/11/11
[ "https://Stackoverflow.com/questions/282198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
282,222
<p>I just want ask the steps when trying to create a simple SQL select statement in UNIX inside/within IF..THEN..FI statement.</p> <p>I know how to use the 'select' and 'if..then' statements in SQL*Plus, but I'm having a difficulties having a UNIX script to point to variables: If 'ABC' to 'Select...'</p> <h2>Example:</h2> <p>if [ "$?" = 'ABC' ] then SELECT employid, name, age FROM tablename; else exit 1 fi</p> <p>if [ "$?" = 'XYZ' ] then SELECT employid, name, age FROM tablename; else exit 1 fi</p> <p>How do I put it in a UNIX script more correctly syntax wise and right to the point?</p> <p>Thanks.</p>
[ { "answer_id": 282253, "author": "ConcernedOfTunbridgeWells", "author_id": 15401, "author_profile": "https://Stackoverflow.com/users/15401", "pm_score": 2, "selected": false, "text": "if [ $? -eq ABC ]; then\nSQLPLUS /S USER/PASS@Instance <<EOF\nSET echo off;\nSET pagesize 0;\nSET headin...
2008/11/11
[ "https://Stackoverflow.com/questions/282222", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]