qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
356,294
<p>Say you have a class who's job it is to connect to a remote server. I want to abstract this class to provide two versions, one that connects through UDP and the other through TCP. I want to build the leanest runtime code possible and instead of using polymorphism I am considering templates. Here is what I'm envisioning but I'm not sure it's the best way of doing this:</p> <pre><code>class udp {}; class tcp {}; template&lt;class T,typename X&gt; class service { private: // Make this private so this non specialized version can't be used service(); }; template&lt;typename X&gt; class service&lt;udp, X&gt; { private: udp _udp; X _x; }; template&lt;typename X&gt; class service&lt;tcp, X&gt; { private: tcp _tcp; X _x; }; </code></pre> <p>So the end benefit is that the genericness of T is still available, but the very different code required to setup a UDP or TCP connection has been specialized. I suppose you could put it both into one class, or provide another class that adheres to some pure virtual interface for setting up the network connection, like IConnectionManager.</p> <p>But this does leave the problem of the code for the generic T now having to be written in and maintained in both specialized versions, where they are ultimately the same. How best to address this? I have a feeling I am going about this all wrong.</p>
[ { "answer_id": 356318, "author": "Edouard A.", "author_id": 41363, "author_profile": "https://Stackoverflow.com/users/41363", "pm_score": 2, "selected": false, "text": "template <typename Underlying>\nclass Transmit\n{\npublic:\n void send(...)\n {\n _U.send(...)\n };\n\npriva...
2008/12/10
[ "https://Stackoverflow.com/questions/356294", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44996/" ]
356,297
<p>I've read a lot of comments mention in passing that the BlackBerry threading model deviates from the Java standard and can cause issues, but no amount of googling has enlightened me on what this means exactly.</p> <p>I've been developing a fairly large business application for the BlackBerry and, although I don't really have any previous experience with Java multi-threaded applications, haven't come across any issue that we've been able to blame on threading, other than what we caused ourselves.</p> <p>Can someone describe exactly how the BlackBerry threading model is different, and how I as a developer should take that into account? Obviously any links on the topic would also be great.</p>
[ { "answer_id": 807729, "author": "kozen", "author_id": 98649, "author_profile": "https://Stackoverflow.com/users/98649", "pm_score": 4, "selected": false, "text": "LabelField.setText(\"foo\");" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/270/" ]
356,298
<p>I am using GWT (Google Web Toolkit) 1.5.3 et GXT (ExtJS) 1.2 I just want to create a simple form with some radio buttons generated after a RPC call, to get some values</p> <p>Code:</p> <pre><code>final FormPanel simple = new FormPanel(); simple.setFrame(true); simple.setWidth(350); simple.setHeaderVisible(false); DateField date = new DateField(); date.setFieldLabel("Date"); simple.add(date); ListFluxServiceAsync service = (ListFluxServiceAsync) GWT.create(ListFluxService.class); ServiceDefTarget target = (ServiceDefTarget)service; String url = GWT.getModuleBaseURL() + "flux.rpc"; target.setServiceEntryPoint(url); final RadioGroup radioGroup = new RadioGroup("RadioGroup"); radioGroup.setFieldLabel("Flux"); radioGroup.setOrientation(Orientation.VERTICAL); service.getAllFlux(new AsyncCallback&lt;List&lt;FluxModelData&gt;&gt;(){ public void onFailure(Throwable caught) { GWT.log("flux.rpx::onFailure", caught); MessageBox.alert("what?", "onFailure :" + caught.getMessage(), null); } public void onSuccess(List&lt;FluxModelData&gt; result) { Iterator&lt;FluxModelData&gt; it = result.iterator(); while ( it.hasNext() ){ FluxModelData fmd = it.next(); Radio radio = new Radio(); radio.setName("flux"); radio.setValue(true); //radio.setRawValue("my very long value"); radio.setBoxLabel(fmd.getDescription()); radioGroup.add(radio); } simple.add(radioGroup); simple.layout(); //we need it to show the radio button } }); simple.setButtonAlign(HorizontalAlignment.CENTER); Button button = new Button("Récupérer"); button.addSelectionListener(new SelectionListener&lt;ButtonEvent&gt;(){ @Override public void componentSelected(ButtonEvent ce) { MessageBox.alert("what?", radioGroup.getValue().getRawValue() , null); }}); simple.addButton(button); RootPanel.get().add(simple); </code></pre> <p>My problem is I can't set/get radio button value. If I try the setRawValue("xxxxxxx"), I will get some null errors, while setting setValue(boolean) is working but I was expecting getting the radio value and not the label value.</p> <p>Any Idea?</p>
[ { "answer_id": 1687944, "author": "user204877", "author_id": 204877, "author_profile": "https://Stackoverflow.com/users/204877", "pm_score": 0, "selected": false, "text": "radio.setAttributeValue()" }, { "answer_id": 5900218, "author": "juanm", "author_id": 740231, "a...
2008/12/10
[ "https://Stackoverflow.com/questions/356298", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18714/" ]
356,321
<p>I'm about to be forced to write a script to download some number of files under Windows XP. The machines the script will be run at are all behind a proxy, and the proxy settings are entered into the IE configuration.</p> <p>What came to my mind was either to somehow call IE from the command line, and using its configuration download files I'd need. Is it even possible using some shell-techniques? </p> <p>Other option would be to use <code>wget</code> under Win, but I'd need to pass the proxy-settings to it. How to recover those settings from IE configuration?</p>
[ { "answer_id": 1687944, "author": "user204877", "author_id": 204877, "author_profile": "https://Stackoverflow.com/users/204877", "pm_score": 0, "selected": false, "text": "radio.setAttributeValue()" }, { "answer_id": 5900218, "author": "juanm", "author_id": 740231, "a...
2008/12/10
[ "https://Stackoverflow.com/questions/356321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4172/" ]
356,323
<p>I want to add all the files in the current directory to git:</p> <pre><code>git add . error: open(".mysql_history"): Permission denied fatal: unable to index file .mysql_history </code></pre> <p>That's fine. That file happens to be in this directory and owned by root. I want to add all <em>other</em> files. Is there a way to do that without having to manually add each file by hand?</p> <p>I know that I could add the file to exclude or .gitignore, but I'd like to have it just ignore things based on permissions (there's a good chance other files like this will end up in the directory, and adding them to .gitignore all the time is a pain).</p>
[ { "answer_id": 356333, "author": "mipadi", "author_id": 28804, "author_profile": "https://Stackoverflow.com/users/28804", "pm_score": 2, "selected": false, "text": ".mysql_history" }, { "answer_id": 359696, "author": "matli", "author_id": 23896, "author_profile": "htt...
2008/12/10
[ "https://Stackoverflow.com/questions/356323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8611/" ]
356,330
<p>I'm currently using msbuild for a solution of over 600 projects. </p> <p>Imagine I change the code for 1 library that is used by 10 projects. Instead of providing all 600 projects to msbuild and let it compile all of them and figure out the dependencys. I was wondering if there was a program or library I could use that would analyse the dependencys of all 600 projects, and allow me to only compile the 11 that are necessary.</p> <p>In other words given the input of all 600 projects to scan, and BaseLibrary.csproj as a project that has been modified parameter, provide me only the 11 projects I need to compile as output.</p> <p>I'm experienced in writing custom tasks, I'd just rather use a third party library to do the dependency analysis if there is already one out there.</p> <p>My company does incremental releases to production every 3-4 months. As an experiment I wrote a custom task that looks at the previous releases "Subversion tag" and evaluates all the compiled files that have changed since then and maps them to a project. </p> <p>The only use case I can think of that doesn't work is the one I mentioned where a base library is changed and the system doesn't know about all the projects that depend on it.</p>
[ { "answer_id": 356513, "author": "Alberto Sciessere", "author_id": 43500, "author_profile": "https://Stackoverflow.com/users/43500", "pm_score": 4, "selected": true, "text": "digraph G { \n size=\"100,69\"\n center=\"\"\n ratio=All\n node[width=.25,hight=.375,fontsize...
2008/12/10
[ "https://Stackoverflow.com/questions/356330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45005/" ]
356,336
<p>A few years ago I worked on a system where a numeric primary key was stored in a [SQL Server] varchar column, so I quickly came unstuck when querying with a BETWEEN operator:</p> <pre><code>SELECT ID FROM MyTable WHERE ID BETWEEN 100 AND 110; </code></pre> <p>Results:</p> <pre><code>100 102 103 109 110 11 </code></pre> <p>This was simply bad design. However, I'm working on an 3rd-party ERP system, which as you can imagine needs to be generic and flexible; thus we have various tables where alphanumeric fields are provided where the business only uses numerics - so similar problems can occur.</p> <p>I'm guessing that this is a common enough issue; I have a simple enough solution, but I'm curious as to how others approach such problems.</p> <p>My simple solution is:</p> <pre><code>SELECT ID FROM MyTable WHERE ID BETWEEN iStartValue AND iEndValue AND (LENGTH(ID) = LENGTH(iStartValue) OR LENGTH(ID) = LENGTH(iEndValue)); </code></pre> <p>As you can possibly tell, this is an Oracle system, but I'm usually working in SQL Server - so perhaps database-agnostic solutions are preferable.</p> <p>Edit 1: Scratch that - I don't see why proprietary solutions aren't welcomed as well.</p> <p>Edit 2: Thanks for all the responses. I'm not sure whether I'm disappointed there is not an obvious, sophisticated solution, but I'm correspondingly glad that it doesn't appear that I've missed anything obvious!</p> <p>I think I still prefer my own solution; it's simple and it works - is there any reason why I shouldn't use it? I can't believe it is much, if any, less efficient that the other solutions offered.</p> <p>I realise that in an ideal world, this problem wouldn't exist; but unfortunately, I don't work in an ideal world, and often it's a case of making the best of a bad situation.</p>
[ { "answer_id": 356349, "author": "RB.", "author_id": 15393, "author_profile": "https://Stackoverflow.com/users/15393", "pm_score": 3, "selected": false, "text": "WHERE CAST(ID as int) BETWEEN iStartValue AND iEndValue\n" }, { "answer_id": 356359, "author": "Vincent Ramdhanie"...
2008/12/10
[ "https://Stackoverflow.com/questions/356336", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6898/" ]
356,337
<p>I have a Perl script that sets up variables near the top for directories and files that it will use. It also requires a few variables to be set as command-line arguments. Example:</p> <pre><code>use Getopt::Long; my ($mount_point, $sub_dir, $database_name, $database_schema); # Populate variables from the command line: GetOptions( 'mount_point=s' =&gt; \$mount_point, 'sub_dir=s' =&gt; \$sub_dir, 'database_name=s' =&gt; \$database_name, 'database_schema=s' =&gt; \$database_schema ); # ... validation of required arguments here ################################################################################ # Directory variables ################################################################################ my $input_directory = "/${mount_point}/${sub_dir}/input"; my $output_directory = "/${mount_point}/${sub_dir}/output"; my $log_directory = "/${mount_point}/${sub_dir}/log"; my $database_directory = "/db/${database_name}"; my $database_scripts = "${database_directory}/scripts"; ################################################################################ # File variables ################################################################################ my $input_file = "${input_dir}/input_file.dat"; my $output_file = "${output_dir}/output_file.dat"; # ... etc </code></pre> <p>This works fine in my dev, test, and production environments. However, I was trying to make it easier to override certain variables (without going into the debugger) for development and testing. (For example, if I want to set my input_file = "/tmp/my_input_file.dat"). My thought was to use the GetOptions function to handle this, something like this:</p> <pre><code>GetOptions( 'input_directory=s' =&gt; \$input_directory, 'output_directory=s' =&gt; \$output_directory, 'database_directory=s' =&gt; \$database_directory, 'log_directory=s' =&gt; \$log_directory, 'database_scripts=s' =&gt; \$database_scripts, 'input_file=s' =&gt; \$input_file, 'output_file=s' =&gt; \$output_file ); </code></pre> <p>GetOptions can only be called once (as far as I know). The first 4 arguments in my first snippit are required, the last 7 directly above are optional. I think an ideal situation would be to setup the defaults as in my first code snippit, and then somehow override any of them that have been set if arguments were passed at the command line. I thought about storing all my options in a hash and then using that hash when setting up each variable with the default value unless an entry exists in the hash, but that seems to add a lot of additional logic. Is there a way to call GetOptions in two different places in the script?</p> <p>Not sure if that makes any sense.</p> <p>Thanks!</p>
[ { "answer_id": 356442, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 2, "selected": false, "text": "input_directory" }, { "answer_id": 356592, "author": "xdg", "author_id": 11800, "author_profile": "...
2008/12/10
[ "https://Stackoverflow.com/questions/356337", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40619/" ]
356,340
<p>I am looking for a regex statement that will let me extract the HTML content from just between the body tags from a XHTML document.</p> <p>The XHTML that I need to parse will be very simple files, I do not have to worry about JavaScript content or <code>&lt;![CDATA[</code> tags, for example.</p> <p>Below is the expected structure of the HTML file is that I have to parse. Since I know exactly all of the content of the HTML files that I am going to have to work with, this HTML snippet pretty much covers my entire use case. If I can get a regex to extract the body of this example, I'll be happy.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt; &lt;/title&gt; &lt;/head&gt; &lt;body contenteditable="true"&gt; &lt;p&gt; Example paragraph content &lt;/p&gt; &lt;p&gt; &amp;nbsp; &lt;/p&gt; &lt;p&gt; &lt;br /&gt; &amp;nbsp; &lt;/p&gt; &lt;h1&gt;Header 1&lt;/h1&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Conceptually, I've been trying to build a regex string that matches everything BUT the inner body content. With this, I would use the C# <code>Regex.Split()</code> method to obtain the body content. I thought this regex:</p> <pre class="lang-none prettyprint-override"><code>((.|\n)*&lt;body (.)*&gt;)|((&lt;/body&gt;(*|\n)*) </code></pre> <p>...would do the trick, but it doesn't seem to work at all with my test content in RegexBuddy.</p>
[ { "answer_id": 356376, "author": "VonC", "author_id": 6309, "author_profile": "https://Stackoverflow.com/users/6309", "pm_score": 6, "selected": true, "text": "((?:.(?!<body[^>]*>))+.<body[^>]*>)|(</body\\>.+)\n" }, { "answer_id": 356380, "author": "Kev", "author_id": 167...
2008/12/10
[ "https://Stackoverflow.com/questions/356340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/506/" ]
356,347
<p>I'm writing a Greasemonkey script to connect two company-internal webpages. One is SSL, and the other is insecure and can only be accessed via a POST request. If I create a hidden form on the secure page and submit it via an <code>onclick()</code> in an <code>&lt;a&gt;</code>, it works fine, but FF gives a warning:</p> <blockquote> <p>Although this page is encrypted, the information you have entered is to be sent over an unencrypted connection and could easily be read by a third party.</p> <p>Are you sure you want to continue sending this information?&quot;</p> </blockquote> <p>The insecure page can't be accessed via SSL and the other one can't be accessed w/o it, and I can't modify either server =\ Is there any way to avoid this warning by doing some kind of JavaScript/Greasemonkey redirect magic? Thanks!</p> <p>EDIT: The warning can't be disabled (for rather good reasons, since it's hard to tell if what you're about to send is secure, otherwise). I'm mostly wondering if there's a way to POST in JavaScript without looking like you're submitting a form.</p>
[ { "answer_id": 358751, "author": "Athena", "author_id": 17846, "author_profile": "https://Stackoverflow.com/users/17846", "pm_score": 2, "selected": false, "text": "GM_xmlhttpRequest({\n method: 'POST',\n url: 'http://your.insecure.site.here',\n onload: function(details) {\n\n //...
2008/12/10
[ "https://Stackoverflow.com/questions/356347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,371
<p>I was wondering what I could do to improve the performance of Excel automation, as it can be quite slow if you have a lot going on in the worksheet...</p> <p>Here's a few I found myself:</p> <ul> <li><p><code>ExcelApp.ScreenUpdating = false</code> -- turn off the redrawing of the screen</p></li> <li><p><code>ExcelApp.Calculation = Excel.XlCalculation.xlCalculationManual</code> -- turning off the calculation engine so Excel doesn't automatically recalculate when a cell value changes (turn it back on after you're done)</p></li> <li><p>Reduce calls to <code>Worksheet.Cells.Item(row, col)</code> and <code>Worksheet.Range</code> -- I had to poll hundreds of cells to find the cell I needed. Implementing some caching of cell locations, reduced the execution time from ~40 to ~5 seconds.</p></li> </ul> <p>What kind of interop calls take a heavy toll on performance and should be avoided? What else can you do to avoid unnecessary processing being done?</p>
[ { "answer_id": 356399, "author": "Treb", "author_id": 22114, "author_profile": "https://Stackoverflow.com/users/22114", "pm_score": 3, "selected": false, "text": "find" }, { "answer_id": 369283, "author": "Jon Fournier", "author_id": 5106, "author_profile": "https://S...
2008/12/10
[ "https://Stackoverflow.com/questions/356371", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39259/" ]
356,373
<p>Assuming following definition:</p> <pre><code>/// &lt;summary&gt; /// Replaces each occurrence of sPattern in sInput with sReplace. This is done /// with the CLR: /// new RegEx(sPattern, RegexOptions.Multiline).Replace(sInput, sReplace). /// The result of the replacement is the return value. /// &lt;/summary&gt; [SqlFunction(IsDeterministic = true)] public static SqlString FRegexReplace(string sInput, string sPattern, string sReplace) { return new Regex(sPattern, RegexOptions.Multiline).Replace(sInput, sReplace); } </code></pre> <p>Passing in a <code>nvarchar(max)</code> value for <code>sInput</code> with a length > 4000 will result in the value being truncated (i.e. the result of calling this UDF is <code>nvarchar(4000)</code> as opposed to <code>nvarchar(max)</code>.</p>
[ { "answer_id": 356383, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://Stackoverflow.com/users/2260", "pm_score": 6, "selected": true, "text": "/// <summary>\n/// Replaces each occurrence of sPattern in sInput with sReplace. This is done \n/// with the CLR: \n/// ...
2008/12/10
[ "https://Stackoverflow.com/questions/356373", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2260/" ]
356,382
<p>Example: an Order object (aggregate root) has a collection of OrderLine objects (child entities). What's the URL add an OrderLine to an Order? Take into consideration the difference between using the aggregate roots' controller and having a separate controller for the child entity.</p> <p>1: <a href="http://example.com/orders/details/42/add-orderline?product-id=12&amp;quantity=2" rel="nofollow noreferrer">http://example.com/orders/add-orderline?order-id=42&amp;product-id=12&amp;quantity=2</a></p> <p>or</p> <p>2: <a href="http://example.com/order-lines/add?order-id=42&amp;product-id=12&amp;quantity=2" rel="nofollow noreferrer">http://example.com/order-lines/add?order-id=42&amp;product-id=12&amp;quantity=2</a></p> <p>Thanks!</p>
[ { "answer_id": 356383, "author": "Daren Thomas", "author_id": 2260, "author_profile": "https://Stackoverflow.com/users/2260", "pm_score": 6, "selected": true, "text": "/// <summary>\n/// Replaces each occurrence of sPattern in sInput with sReplace. This is done \n/// with the CLR: \n/// ...
2008/12/10
[ "https://Stackoverflow.com/questions/356382", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4830/" ]
356,390
<p>I have a div with two nested divs inside, the (float:left) one is the menu bar, and the right (float:right) should display whatever content the page has, it works fine when the window is at a maximum, but when i resize it the content is collapsed until it can no longer has any space, at which it is forced to be displayed BELOW the left menu bar, how can I make the width fixed so that the user may scroll when resized? (css width didn't work, i alternated between floating the right content and not), here is the code: </p> <pre><code>&lt;div style="width:100%"&gt; &lt;div style="float:left; background:#f5f5f5; border-right:1px solid black; height:170%; width:120px;"&gt;&lt;/div&gt; &lt;div style="margin-right:2px;margin-top:15px; margin-bottom:5px; width:100%; border:1px solid #f5f5f5"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I only need to have this working on Interner Explorer for now. </p>
[ { "answer_id": 356400, "author": "mat", "author_id": 42083, "author_profile": "https://Stackoverflow.com/users/42083", "pm_score": 1, "selected": false, "text": "width" }, { "answer_id": 356425, "author": "bezmax", "author_id": 43677, "author_profile": "https://Stacko...
2008/12/10
[ "https://Stackoverflow.com/questions/356390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45016/" ]
356,411
<p>I have a stack panel inside of an expander panel that I programaticaly adds check boxes to. Currently the exanpander stops at the bottom of the form, but the stack panel keeps growing. I would like the stack panel to be bounded by the expander and scroll to display the check boxes. Do I need house the check boxes in a list box to get the scroll functionality?</p> <pre><code>&lt;Grid&gt; &lt;Expander Header="Expander1" Margin="0,0,0,2" Name="Expander1" VerticalAlignment="Top" Background="Coral"&gt; &lt;StackPanel Name="StackScroll" Margin="0,0,0,2" Background="Aqua"&gt;&lt;/StackPanel&gt; &lt;/Expander&gt; &lt;/Grid&gt; </code></pre> <p>");</p>
[ { "answer_id": 356457, "author": "Guy Starbuck", "author_id": 2194, "author_profile": "https://Stackoverflow.com/users/2194", "pm_score": 5, "selected": true, "text": " <Grid> \n <Expander Header=\"Expander1\" Margin=\"0,0,0,2\" Name=\"Expander1\" VerticalAlignment=\"Top\" Backgrou...
2008/12/10
[ "https://Stackoverflow.com/questions/356411", "https://Stackoverflow.com", "https://Stackoverflow.com/users/38349/" ]
356,418
<p>With SMO objects using Server.JobServer.jobs to get a list of jobs, I can find the status of each job. For those that are currently executing I would like to find the SPID it is executing on. I can also get a list of the server's processes using Server.EnumProcesses(). This gives me a list of currently active SPIDs. I want to match the two. </p> <p>The best I've been able to come up with is to convert the jobid to a string and substring the jobId out of the program string in the EnumProcesses table (which, at least on my system, embeds the jobId in this description). It's really ugly for a couple of reasons not the least of which is that the Guid in the program description and the guid for jobID have their bytes switched in the first 3 pieces of the string representation. Yuck.</p> <p>Is there a better way to do that using SMO?</p>
[ { "answer_id": 356457, "author": "Guy Starbuck", "author_id": 2194, "author_profile": "https://Stackoverflow.com/users/2194", "pm_score": 5, "selected": true, "text": " <Grid> \n <Expander Header=\"Expander1\" Margin=\"0,0,0,2\" Name=\"Expander1\" VerticalAlignment=\"Top\" Backgrou...
2008/12/10
[ "https://Stackoverflow.com/questions/356418", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3854/" ]
356,437
<p>I'm trying to create a jsp tag file but it fails to compile when I try to use <code>pageContext.getServletConfig().getInitParameter("myInitParam")</code></p> <p>I'm using tomcat and when I try to view a page including the file I get a jasper compile error pageContext cannot be resolved. I've also tried just using <code>getInitParameter</code> but it fails also. I can use the request object so I know everything else is fine.</p> <p>Does anyone know a way to access init parameters set in the web.xml from a jsp tag file, preferably from within a scriptlet?</p>
[ { "answer_id": 356472, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 0, "selected": false, "text": "getInitParameter(\"myInitParam\");\n" }, { "answer_id": 356479, "author": "matt b", "author_id": 4249, "...
2008/12/10
[ "https://Stackoverflow.com/questions/356437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45023/" ]
356,460
<p>I'm trying to create a LINQ to SQL class that represents the "latest" version of itself.</p> <p>Right now, the table that this entity represents has a single auto-incrementing ID, and I was thinking that I would add a version number to the primary key. I've never done anything like this, so I'm not sure how to proceed. I would like to be able to abstract the idea of the object's version away from whoever is using it. In other words, you have an instance of this entity that represents the most current version, and whenever any changes are submitted, a new copy of the object is stored with an incremented version number.</p> <p>How should I proceed with this?</p>
[ { "answer_id": 356917, "author": "Corbin March", "author_id": 7625, "author_profile": "https://Stackoverflow.com/users/7625", "pm_score": 4, "selected": true, "text": "CREATE TRIGGER tr_TheTrigger\nON [YourTable]\nFOR INSERT, UPDATE, DELETE \nAS\n IF EXISTS(SELECT * FROM inserted)\n ...
2008/12/10
[ "https://Stackoverflow.com/questions/356460", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18866/" ]
356,464
<p>I am looking for a way to localize properties names displayed in a PropertyGrid. The property's name may be "overriden" using the DisplayNameAttribute attribute. Unfortunately attributes can not have non constant expressions. So I can not use strongly typed resources such as: </p> <pre><code>class Foo { [DisplayAttribute(Resources.MyPropertyNameLocalized)] // do not compile string MyProperty {get; set;} } </code></pre> <p>I had a look around and found some suggestion to inherit from DisplayNameAttribute to be able to use resource. I would end up up with code like: </p> <pre><code>class Foo { [MyLocalizedDisplayAttribute("MyPropertyNameLocalized")] // not strongly typed string MyProperty {get; set;} } </code></pre> <p>However I lose strongly typed resource benefits which is definitely not a good thing. Then I came across <a href="http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.modeling.design.displaynameresourceattribute.aspx" rel="noreferrer">DisplayNameResourceAttribute</a> which may be what I'm looking for. But it's supposed to be in Microsoft.VisualStudio.Modeling.Design namespace and I can't find what reference I am supposed to add for this namespace.</p> <p>Anybody know if there's a easier way to achieve DisplayName localization in a good way ? or if there is as way to use what Microsoft seems to be using for Visual Studio ?</p>
[ { "answer_id": 356493, "author": "configurator", "author_id": 9536, "author_profile": "https://Stackoverflow.com/users/9536", "pm_score": 1, "selected": false, "text": "Microsoft.VisualStudio.Modeling.Sdk.dll" }, { "answer_id": 356525, "author": "Marc Gravell", "author_id...
2008/12/10
[ "https://Stackoverflow.com/questions/356464", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37706/" ]
356,465
<p>Each month I get new CMYK and RGB images that shall be used on the web.</p> <p>I had a script using a patched up ImageMagick doing this, but it got deleted. So I need to do it again, but it was hard last time.</p> <p>How do you <em>easily</em> and quickly convert CMYK image files to RGB?</p>
[ { "answer_id": 660407, "author": "davethegr8", "author_id": 12930, "author_profile": "https://Stackoverflow.com/users/12930", "pm_score": 1, "selected": false, "text": "convert CMYK.tiff -profile \"RGB.icc\" RGB.tiff\n" }, { "answer_id": 11482147, "author": "Kurt Pfeifle", ...
2008/12/10
[ "https://Stackoverflow.com/questions/356465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,480
<p>I want to extract 'James\, Brown' from the string below but I don't always know what the name will be. The comma is causing me some difficuly so what would you suggest to extract James\, Brown?</p> <p>OU=James\, Brown,OU=Test,DC=Internal,DC=Net</p> <p>Thanks</p>
[ { "answer_id": 356491, "author": "xan", "author_id": 15667, "author_profile": "https://Stackoverflow.com/users/15667", "pm_score": 0, "selected": false, "text": "string line = GetStringFromWherever();\n\nint start = line.IndexOf(\"=\") + 1;//+1 to get start of name\nint end = line.IndexO...
2008/12/10
[ "https://Stackoverflow.com/questions/356480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,484
<p>How do you even look at the web.config file? I don't know where to go to turn custom errors off...help! </p> <p>I tried command prompt and java script....can any one help me?</p>
[ { "answer_id": 356529, "author": "tvanfosson", "author_id": 12950, "author_profile": "https://Stackoverflow.com/users/12950", "pm_score": 3, "selected": false, "text": "Off" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356484", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,502
<p>I often get a PDF from our designer (built in Adobe InDesign) which is supposed to be sent out to thousands of people.</p> <p>I've got the list with all the people, and it's easy doing a mail merge in OpenOffice.org. However, OpenOffice.org doesn't support the advanced PDF. I just want to output some text onto each page and print it out.</p> <p>Here's how I do it now: print out 6.000 copies of the PDF, then put all of them into the printer again and just print out name, address and other information on top of it. But that's expensive.</p> <p>Sadly, I can't make the PDF to an image and use that in OpenOffice.org because it grinds the computer to a halt. It also takes extremely long time to send this job to the printer.</p> <p>So, is there an easy way to do this mail merge (preferably in Python) without paying for third party closed solutions?</p>
[ { "answer_id": 356833, "author": "rhanekom", "author_id": 37605, "author_profile": "https://Stackoverflow.com/users/37605", "pm_score": 1, "selected": false, "text": "PdfContentByte cb= ...;\ncb.BeginText();\ncb.SetFontAndSize(font, fontSize);\nfloat x = ...;\nfloat y = ...;\ncb.SetTextM...
2008/12/10
[ "https://Stackoverflow.com/questions/356502", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,506
<p>I have created a windows service that uses Windows Messaging System. When I test the app from the debugger the Messages go through nicely but when I install it my messag … asked 14 mins ago</p> <p>vladimir 1tuga </p>
[ { "answer_id": 356702, "author": "Mick", "author_id": 12458, "author_profile": "https://Stackoverflow.com/users/12458", "pm_score": 3, "selected": false, "text": "while(GetMessage(&Msg, NULL, 0, 0) > 0)\n{\n TranslateMessage(&Msg);\n DispatchMessage(&Msg);\n}\n" }, { "answe...
2008/12/10
[ "https://Stackoverflow.com/questions/356506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,543
<p>I was just wondering how I could <em>automatically</em> increment the build (and version?) of my files using Visual Studio (2005). </p> <p>If I look up the properties of say <code>C:\Windows\notepad.exe</code>, the Version tab gives "File version: 5.1.2600.2180". I would like to get these cool numbers in the version of my dll's too, not version 1.0.0.0, which let's face it is a bit dull.</p> <p>I tried a few things, but it doesn't seem to be out-of-box functionality, or maybe I'm just looking in the wrong place (as usual).</p> <p>I work with mainly web projects....</p> <p>I looked at both:</p> <ol> <li><a href="http://www.codeproject.com/KB/dotnet/Auto_Increment_Version.aspx" rel="noreferrer">http://www.codeproject.com/KB/dotnet/Auto_Increment_Version.aspx</a></li> <li><a href="http://www.codeproject.com/KB/dotnet/build_versioning.aspx" rel="noreferrer">http://www.codeproject.com/KB/dotnet/build_versioning.aspx</a></li> </ol> <p>and I couldn't believe it so much effort to do something is standard practice.</p> <p>EDIT: <strong>It does not work in VS2005 as far I can tell (<a href="http://www.codeproject.com/KB/dotnet/AutoIncrementVersion.aspx" rel="noreferrer">http://www.codeproject.com/KB/dotnet/AutoIncrementVersion.aspx</a>)</strong></p>
[ { "answer_id": 356555, "author": "Bob", "author_id": 45, "author_profile": "https://Stackoverflow.com/users/45", "pm_score": 4, "selected": false, "text": " System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();\n System.Reflection.AssemblyName assemblyN...
2008/12/10
[ "https://Stackoverflow.com/questions/356543", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31765/" ]
356,547
<p>MS SQL Server 2000</p> <p>I have a column in Table A called Name. I wish to sort the Name field. Many but not all of the records for Name start will KL and are followed by a number (KL 1234, KL 2, KL 323, etc).</p> <h2>Table A</h2> <h2>Name</h2> <p>Able<br> Bravo<br> KL 2<br> KL 323<br> KL 1234<br> Zebra</p> <p>If I use</p> <pre><code>Select Name from A Order by Name </code></pre> <p>I get</p> <p>Able<br> Bravo<br> KL 1234<br> KL 2<br> KL 323<br> Zebra </p> <p>I want</p> <p>Able<br> Bravo<br> KL 2<br> KL 323<br> KL 1234<br> Zebra </p> <p>If they all started with KL I could use</p> <pre><code>Select Name from A Order by cast(replace(name, 'KL', '') as big int) </code></pre> <p>but this generates an "unble to cast name as big int" error for values that do not start with KL</p> <p>Thanks for any help.</p>
[ { "answer_id": 356625, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": true, "text": "Order By \n Case When Left(name, 2) = 'KL' \n Then 'KL' + Replace(Str(Cast(replace(name, 'KL', '') as Big...
2008/12/10
[ "https://Stackoverflow.com/questions/356547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45042/" ]
356,548
<p>I am trying to respond back to a client with a PDF stored in a MSSQL varbinary(MAX) field. The response works on my localhost and a test server over http connection, but does not work on the production server over https connection. I am using just a simple BinaryWrite (code below).</p> <pre><code> byte[] displayFile = DatabaseFiles.getPdfById(id); Response.ContentType = "application/pdf"; Response.BinaryWrite(displayFile); </code></pre> <p>Nothing fancy here. Just grab the binary data, set the content type, and write back to client. Is there anything special that needs to be done in order to respond back over https in this way?</p> <p><strong>Edit:</strong> By doesn't work, I mean that I get a blank document in the browser. Acrobat does not load in browser.</p> <p><strong>Edit:</strong> I just noticed that this problem is only occurring in IE 7. The PDF loads correctly in Firefox 3. Our client uses IE 7 exclusively (better than IE 6 which I persuaded them upgrade from...lol).</p> <p><strong>Edit:</strong> Tried to add the header "content-disposition" to make the file act as an attachment. Browser failed to loaded under SSL with the IE error "Internet Explorer cannot download displayFile.aspx from ProductionServer.net." (Code Below)</p> <pre><code> byte[] displayFile = DatabaseFiles.getPdfById(id); Response.Clear(); Response.AddHeader("content-disposition", String.Format("attachment;filename={0}", fileName)); Response.ContentType = "application/pdf"; Response.BinaryWrite(displayFile); </code></pre> <p><strong>Edit:</strong> If the file is viewed over http on the Production Server, the browser displays the code for the PDF like it was being viewed through NotePad. (e.g. %PDF-1.4 %âãÏÓ 6 0 obj &lt;> endobj xref 6 33 ...etc)</p>
[ { "answer_id": 357031, "author": "Eddie", "author_id": 576, "author_profile": "https://Stackoverflow.com/users/576", "pm_score": 0, "selected": false, "text": "GET /displayFile.aspx?id=128 HTTP/1.1\nAccept: */*\nAccept-Language: en-us\nUA-CPU: x86\nAccept-Encoding: gzip, deflate\nUser-Ag...
2008/12/10
[ "https://Stackoverflow.com/questions/356548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/576/" ]
356,550
<p>I need a Java library to convert PDFs to TIFF images. The PDFs are faxes, and I will be converting to TIFF so that I can then do barcode recognition on the image. Can anyone recommend a good free open source library for conversion from PDF to TIFF? </p>
[ { "answer_id": 356582, "author": "Alnitak", "author_id": 6782, "author_profile": "https://Stackoverflow.com/users/6782", "pm_score": 3, "selected": false, "text": "#!/bin/sh\n\n/opt/local/bin/gs -q -dLastPage=1 -dNOPAUSE -dBATCH -dSAFER -r300 \\\n -sDEVICE=pnmraw -sOutputFile=- $* |\n...
2008/12/10
[ "https://Stackoverflow.com/questions/356550", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39430/" ]
356,551
<p>I'm researching this for a project and I'm wondering what other people are doing to prevent stale CSS and JavaScript files from being served with each new release. I don't want to append a timestamp or something similar which may prevent caching on every request. </p> <p>I'm working with the Spring 2.5 MVC framework and I'm already using the google api's to serve prototype and scriptaculous. I'm also considering using Amazon S3 and the new Cloudfront offering to minimize network latency.</p>
[ { "answer_id": 356574, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 1, "selected": false, "text": "conditional get" }, { "answer_id": 356622, "author": "Eran Galperin", "author_id": 10585, "autho...
2008/12/10
[ "https://Stackoverflow.com/questions/356551", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22436/" ]
356,557
<p>I have created a class library in VB .NET. Some code in the library connects to the database. I want to create a config file that would hold the connection string. <br /><br /> I have created a "Settings.settings" file and stored the connection string in there. <br /><br /> When a class library having a settings file is built, it generates a ".dll.config" file which has the key value pairs defined in the settings file. <br /><br /> Problem with this is when i change the connection string in the ".dll.config" file, the library does not references these changes. I would still need to recompile the class library which would then overwrite my changes in the .dll.config file. <br /><br /> I need to be able to change the connection strings on the fly without having to recompile the library. <br /><br /> Is there a mechanism in VB.NET class library (.NET 2.0) that would let me do this? <br /><br /> Passing the connection string to the class library from the web page that uses its method is not a option. <br /> <br> I have listed a sample below, this is how i would access the string.</p> <pre> Public Function getsettings(ByVal Setting As String) As String If Setting = "Demo" Then Return My.Settings.Demo Else Return My.Settings.Live End If End Function </pre>
[ { "answer_id": 356571, "author": "RB.", "author_id": 15393, "author_profile": "https://Stackoverflow.com/users/15393", "pm_score": 3, "selected": true, "text": "If GetApplicationSetting(\"connectionString\") Is Nothing Then\n Throw New Exception(\"Could not retrieve connection string ...
2008/12/10
[ "https://Stackoverflow.com/questions/356557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1443363/" ]
356,570
<p>We have a query that selects rows depending on the value of another, ie. the max. I don't think that really makes much sense, so here is the query:</p> <pre><code>var deatched = DetachedCriteria.For&lt;Enquiry&gt;("e2") .SetProjection(Projections.Alias(Projections.Max("Property"), "maxProperty")) .Add(Restrictions.EqProperty("e2.EnquiryCode", "e.EnquiryCode")); session.CreateCriteria(typeof(Enquiry), "e") .Add(Subqueries.PropertyEq("Property", deatched)) .AddOrder(Order.Asc("EnquiryCode")); </code></pre> <p>My question is, is this the best way? Can anyone suggest a better way?</p>
[ { "answer_id": 11565591, "author": "Tony Wolfango", "author_id": 1535227, "author_profile": "https://Stackoverflow.com/users/1535227", "pm_score": 0, "selected": false, "text": "(from e in NHibernateSession().Query<Enquiry>()\n where e.Property == (\n (\n from e2 NHibernateS...
2008/12/10
[ "https://Stackoverflow.com/questions/356570", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5802/" ]
356,578
<p>Is there an easy way to run a MySQL query from the Linux command line and output the results in <a href="http://en.wikipedia.org/wiki/Comma-separated_values" rel="noreferrer">CSV</a> format?</p> <p>Here's what I'm doing now:</p> <pre class="lang-none prettyprint-override"><code>mysql -u uid -ppwd -D dbname &lt;&lt; EOQ | sed -e 's/ /,/g' | tee list.csv select id, concat(&quot;\&quot;&quot;,name,&quot;\&quot;&quot;) as name from students EOQ </code></pre> <p>It gets messy when there are a lot of columns that need to be surrounded by quotes, or if there are quotes in the results that need to be escaped.</p>
[ { "answer_id": 356605, "author": "Paul Tomblin", "author_id": 3333, "author_profile": "https://Stackoverflow.com/users/3333", "pm_score": 12, "selected": true, "text": "SELECT order_id,product_name,qty\nFROM orders\nWHERE foo = 'bar'\nINTO OUTFILE '/var/lib/mysql-files/orders.csv'\nFIELD...
2008/12/10
[ "https://Stackoverflow.com/questions/356578", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1094969/" ]
356,583
<p>Is it possible to reflectively instantiate a generic type in Java? Using the technique described <a href="http://www.velocityreviews.com/forums/t149816-generics-and-forname.html" rel="noreferrer">here</a> I get an error because class tokens cannot be generic. Take the example below. I want to instantiate some subclass of Creator that implements Creator. The actual class name is passed in as a command line argument. The idea is to be able to specify an implementation of Creator at runtime. Is there another way to accomplish what I'm trying to do here?</p> <pre><code>public interface Creator&lt;T&gt; { T create(); } public class StringCreator implements Creator&lt;String&gt; { public String create() { return new String(); } } public class FancyStringCreator implements Creator&lt;String&gt; { public String create() { return new StringBuffer().toString(); } } public static void main(String[] args) throws Exception { Class&lt;?&gt; someClass = Class.forName(args[0]); /*ERROR*/Class&lt;? extends Creator&lt;String&gt;&gt; creatorClass = someClass.asSubclass(Creator.class); Constructor&lt;? extends Creator&lt;String&gt;&gt; creatorCtor = creatorClass.getConstructor((Class&lt;?&gt;[]) null); Creator&lt;String&gt; creator = creatorCtor.newInstance((Object[]) null); } </code></pre> <p>Edit: I like Marcus' approach as being the most simple and pragmatic without circumventing the whole generics thing. I can use it in my situation because I can specify that the class passed must be a subclass of StringCreator. But as Ericson pointed out the generic information is still there at the type level, just not at the runtime level so it is still possible to reflectively examine whether a given class implements the correct generic type.</p>
[ { "answer_id": 356596, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 2, "selected": false, "text": "public static void main(String[] args) throws Exception {\n Class<?> someClass = Class.forName(args[0]);\n Cre...
2008/12/10
[ "https://Stackoverflow.com/questions/356583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16399/" ]
356,585
<p>I have a program that needs to run as a separate NT user to connect to a SQL Server databases. For running a program itself, this isn't a big deal as I can just right click on it in windows explorer and select run as. Is there any way to run my tests as a different user as well? (it would be nice if I could do so in Visual Studio)</p> <p><strong>Update</strong>: As of right now, I'm just unit testing using the integrated unit testing framework in Visual Studio 2008 Pro. I'm running them just using the "run all tests in current solution" menu option.</p>
[ { "answer_id": 356596, "author": "sblundy", "author_id": 4893, "author_profile": "https://Stackoverflow.com/users/4893", "pm_score": 2, "selected": false, "text": "public static void main(String[] args) throws Exception {\n Class<?> someClass = Class.forName(args[0]);\n Cre...
2008/12/10
[ "https://Stackoverflow.com/questions/356585", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2147/" ]
356,598
<p>Is there a way for me to delete items from calendar by using iCalendar import?</p> <p>I know that there is a METHOD:CANCEL, however when I tried it, it didn't do anything to the calendar event.</p> <p>Here is what is in my iCalendar file. When I try to import it to Outlook, it just adds these events.</p> <pre><code>BEGIN:VCALENDAR VERSION:2.0 PRODID:-//DDay.iCal//NONSGML ddaysoftware.com//EN METHOD:CANCEL BEGIN:VEVENT CREATED:20081210T155315Z DESCRIPTION: DTEND:20081213T093000 DTSTAMP:20081210T155315Z DTSTART:20081213T093000 LOCATION: ORGANIZER:MAILTO:user@domain.com SEQUENCE:1 SUMMARY:From FCS 13th UID:20367b86-2123-4930-87ef-5c2a6626bd9f BEGIN:VALARM ACTION:DISPLAY SUMMARY: Event 13th TRIGGER:-PT30M END:VALARM END:VEVENT BEGIN:VEVENT CREATED:20081210T155315Z DESCRIPTION: DTEND:20081211T093000 DTSTAMP:20081210T155315Z DTSTART:20081211T093000 LOCATION:7 West ORGANIZER:MAILTO:user@domain.com SEQUENCE:1 SUMMARY:Event 11th UID:f212ab15-86c3-46c8-8592-af0716a40ea2 BEGIN:VALARM ACTION:DISPLAY SUMMARY:Event on 11th TRIGGER:-PT30M END:VALARM END:VEVENT END:VCALENDAR </code></pre>
[ { "answer_id": 357641, "author": "dev.e.loper", "author_id": 37759, "author_profile": "https://Stackoverflow.com/users/37759", "pm_score": 5, "selected": true, "text": "STATUS:CANCELLED" }, { "answer_id": 6941023, "author": "Marc", "author_id": 878534, "author_profile...
2008/12/10
[ "https://Stackoverflow.com/questions/356598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37759/" ]
356,616
<p>In my Java application I would like to download a JPEG, transfer it to a PNG and do something with the resulting bytes.</p> <p>I am almost certain I remember a library to do this exists, I cannot remember its name.</p>
[ { "answer_id": 356635, "author": "bezmax", "author_id": 43677, "author_profile": "https://Stackoverflow.com/users/43677", "pm_score": 4, "selected": false, "text": "File file = new File(\"newimage.png\");\nImageIO.write(myJpegImage, \"png\", file);\n" }, { "answer_id": 356637, ...
2008/12/10
[ "https://Stackoverflow.com/questions/356616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33604/" ]
356,645
<p>I have a dynamic query that returns around 590,000 records. It runs successfully the first time, but if I run it again, I keep getting a <code>System.OutOfMemoryException</code>. What are some reasons this could be happening?</p> <p>The error is happening here:</p> <pre><code> public static DataSet GetDataSet(string databaseName,string storedProcedureName,params object[] parameters) { //Creates blank dataset DataSet ds = null; try { //Creates database Database db = DatabaseFactory.CreateDatabase(databaseName); //Creates command to execute DbCommand dbCommand = db.GetStoredProcCommand(storedProcedureName); dbCommand.CommandTimeout = COMMAND_TIMEOUT; //Returns the list of SQL parameters associated with that stored proecdure db.DiscoverParameters(dbCommand); int i = 1; //Loop through the list of parameters and set the values foreach (object parameter in parameters) { dbCommand.Parameters[i++].Value = parameter; } //Retrieve dataset and set to ds ds = db.ExecuteDataSet(dbCommand); } //Check for exceptions catch (SqlException sqle) { throw sqle; } catch (Exception e) { throw e; // Error is thrown here. } //Returns dataset return ds; } </code></pre> <p>Here is the code the runs on the button click:</p> <pre><code>protected void btnSearchSBIDatabase_Click(object sender, EventArgs e) { LicenseSearch ls = new LicenseSearch(); DataTable dtSearchResults = new DataTable(); dtSearchResults = ls.Search(); Session["dtSearchResults"] = dtSearchResults; Response.Redirect("~/FCCSearch/SearchResults.aspx"); } else lblResults.Visible = true; } </code></pre>
[ { "answer_id": 356798, "author": "Juliet", "author_id": 40516, "author_profile": "https://Stackoverflow.com/users/40516", "pm_score": 6, "selected": true, "text": "GC.Collect()" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356645", "https://Stackoverflow.com", "https://Stackoverflow.com/users/33690/" ]
356,666
<p>Is there a "win64" identifier in Qmake project files? <a href="http://doc.trolltech.com/4.4/qmake-advanced-usage.html" rel="noreferrer">Qt Qmake advanced</a> documentation does not mention other than unix / macx / win32.</p> <p>So far I've tried using:</p> <pre><code>win32:message("using win32") win64:message("using win64") amd64:message("using amd64") </code></pre> <p>The result is always "using win32".</p> <p>Must I use a separate project-file for x32 and x64 projects, so they would compile against correct libraries? Is there any other way to identify between 32-bit and 64-bit environments?</p>
[ { "answer_id": 404803, "author": "Tuminoid", "author_id": 40657, "author_profile": "https://Stackoverflow.com/users/40657", "pm_score": 2, "selected": false, "text": "CONFIG(myX64, myX64|myX32) {\n LIBPATH += C:\\Coding\\MSSDK60A\\Lib\\x64\n} else {\n LIBPATH += C:\\Coding\\MSSDK60...
2008/12/10
[ "https://Stackoverflow.com/questions/356666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40657/" ]
356,671
<p>The <code>JFileChooser</code> seems to be missing a feature: a way to suggest the file name when saving a file (the thing that usually gets selected so that it would get replaced when the user starts typing).</p> <p>Is there a way around this?</p>
[ { "answer_id": 356706, "author": "bruno conde", "author_id": 31136, "author_profile": "https://Stackoverflow.com/users/31136", "pm_score": 8, "selected": true, "text": "setSelectedFile" }, { "answer_id": 6652416, "author": "Aaron Digulla", "author_id": 34088, "author_...
2008/12/10
[ "https://Stackoverflow.com/questions/356671", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15187/" ]
356,674
<p>I'm developing my first ASP.NET MVC application. This application tracks events, users, donors, etc. for a charitable organization. In my events controller I support standard CRUD operations with New/Edit/Show views (delete is done via a button on Show view). But I also want to list all of the events.</p> <p>Is it better to have a List view that you navigate to from an Index view or have the "List" view be the Index view. The Index view is my default view for the controller. If you keep Index/List separate, what would you put in the Index view?</p> <p>Right now I'm leaning toward keeping them separate and putting basic help information on the Index view. Should I consider changing this and have the List view become the default view and rename Index to Help?</p> <p>TIA for the collective wisdom of SO.</p>
[ { "answer_id": 357002, "author": "Todd Smith", "author_id": 31624, "author_profile": "https://Stackoverflow.com/users/31624", "pm_score": 0, "selected": false, "text": "<body>\n <% RenderPartial(\"List\", \"Events\") %>\n</body>\n" }, { "answer_id": 586211, "author": "tvan...
2008/12/10
[ "https://Stackoverflow.com/questions/356674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12950/" ]
356,675
<p>I have a query which is meant to show me any rows in table A which have not been updated recently enough. (Each row should be updated within 2 months after "month_no".):</p> <pre><code>SELECT A.identifier , A.name , TO_NUMBER(DECODE( A.month_no , 1, 200803 , 2, 200804 , 3, 200805 , 4, 200806 , 5, 200807 , 6, 200808 , 7, 200809 , 8, 200810 , 9, 200811 , 10, 200812 , 11, 200701 , 12, 200702 , NULL)) as MONTH_NO , TO_NUMBER(TO_CHAR(B.last_update_date, 'YYYYMM')) as UPD_DATE FROM table_a A , table_b B WHERE A.identifier = B.identifier AND MONTH_NO &gt; UPD_DATE </code></pre> <p>The last line in the WHERE clause causes an "ORA-00904 Invalid Identifier" error. Needless to say, I don't want to repeat the entire DECODE function in my WHERE clause. Any thoughts? (Both fixes and workarounds accepted...)</p>
[ { "answer_id": 356699, "author": "Tomalak", "author_id": 18771, "author_profile": "https://Stackoverflow.com/users/18771", "pm_score": 8, "selected": true, "text": "SELECT * FROM\n(\n SELECT A.identifier\n , A.name\n , TO_NUMBER(DECODE( A.month_no\n , 1, 200803 \n , 2, 2...
2008/12/10
[ "https://Stackoverflow.com/questions/356675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1019/" ]
356,693
<p>I was curious if there's a .Net API that would allow me to identify what updates are pending for "Windows Update,"</p> <p>failing that, is there a windows powershell command that can get it?</p>
[ { "answer_id": 361722, "author": "Andy Schneider", "author_id": 45571, "author_profile": "https://Stackoverflow.com/users/45571", "pm_score": 2, "selected": false, "text": "PS C:\\> $updateSession = new-object -com Microsoft.update.Session\nPS C:\\> $updateSession | get-member\n\n\n Ty...
2008/12/10
[ "https://Stackoverflow.com/questions/356693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32238/" ]
356,705
<p>I wish to send a header to my Apache server on a Linux box. How can I achieve this via a cURL call?</p>
[ { "answer_id": 356714, "author": "Tader", "author_id": 30700, "author_profile": "https://Stackoverflow.com/users/30700", "pm_score": 11, "selected": false, "text": "man curl" }, { "answer_id": 356716, "author": "Greg", "author_id": 24181, "author_profile": "https://St...
2008/12/10
[ "https://Stackoverflow.com/questions/356705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
356,718
<p>Is there a way in Python, to have more than one constructor or more than one method with the <em>same name</em>, who differ in the <em>number of arguments</em> they accept or the <em>type(s) of one or more argument(s)</em>?</p> <p>If not, what would be the best way to handle such situations?</p> <p>For an example I made up a color class. <em>This class should only work as a basic example to discuss this</em>, there is lot's of unnecessary and/or redundant stuff in there.</p> <p>It would be nice, if I could call the constructor with different objects (a list, an other color object or three integers...) and the constructor handles them accordingly. In this basic example it works in some cases with * args and * * kwargs, but using class methods is the only general way I came up with. What would be a "<strong>best practice</strong>" like solution for this?</p> <p>The constructor aside, if I would like to implement an _ _ <strong>add</strong> _ _ method too, how can I get this method to accept all of this: A plain integer (which is added to all values), three integers (where the first is added to the red value and so forth) or another color object (where both red values are added together, etc.)?</p> <p><strong>EDIT</strong></p> <ul> <li><p>I added an <em>alternative</em> constructor (initializer, _ _ <strong>init</strong> _ _) that basicly does all the stuff I wanted.</p></li> <li><p>But I stick with the first one and the factory methods. Seems clearer.</p></li> <li><p>I also added an _ _ <strong>add</strong> _ _, which does all the things mentioned above but I'm not sure if it's <em>good style</em>. I try to use the iteration protocol and fall back to "single value mode" instead of checking for specific types. Maybe still ugly tho.</p></li> <li><p>I have taken a look at _ _ <strong>new</strong> _ _, thanks for the links.</p></li> <li><p>My first quick try with it fails: I filter the rgb values from the * args and * * kwargs (is it a class, a list, etc.) then call the superclass's _ _ new _ _ with the right args (just r,g,b) to pass it along to init. The call to the 'Super(cls, self)._ _ new _ _ (....)' works, but since I generate and return the same object as the one I call from (as intended), all the original args get passed to _ _ init _ _ (working as intended), so it bails. </p></li> <li><p>I could get rid of the _ _ init _ _ completly and set the values in the _ _ new _ _ but I don't know... feels like I'm abusing stuff here ;-) I should take a good look at metaclasses and new first I guess.</p></li> </ul> <p>Source:</p> <pre><code>#!/usr/bin/env python # -*- coding: UTF-8 -*- class Color (object): # It's strict on what to accept, but I kinda like it that way. def __init__(self, r=0, g=0, b=0): self.r = r self.g = g self.b = b # Maybe this would be a better __init__? # The first may be more clear but this could handle way more cases... # I like the first more though. What do you think? # #def __init__(self, obj): # self.r, self.g, self.b = list(obj)[:3] # This methods allows to use lists longer than 3 items (eg. rgba), where # 'Color(*alist)' would bail @classmethod def from_List(cls, alist): r, g, b = alist[:3] return cls(r, g, b) # So we could use dicts with more keys than rgb keys, where # 'Color(**adict)' would bail @classmethod def from_Dict(cls, adict): return cls(adict['r'], adict['g'], adict['b']) # This should theoreticaly work with every object that's iterable. # Maybe that's more intuitive duck typing than to rely on an object # to have an as_List() methode or similar. @classmethod def from_Object(cls, obj): return cls.from_List(list(obj)) def __str__(self): return "&lt;Color(%s, %s, %s)&gt;" % (self.r, self.g, self.b) def _set_rgb(self, r, g, b): self.r = r self.g = g self.b = b def _get_rgb(self): return (self.r, self.g, self.b) rgb = property(_get_rgb, _set_rgb) def as_List(self): return [self.r, self.g, self.b] def __iter__(self): return (c for c in (self.r, self.g, self.b)) # We could add a single value (to all colorvalues) or a list of three # (or more) values (from any object supporting the iterator protocoll) # one for each colorvalue def __add__(self, obj): r, g, b = self.r, self.g, self.b try: ra, ga, ba = list(obj)[:3] except TypeError: ra = ga = ba = obj r += ra g += ga b += ba return Color(*Color.check_rgb(r, g, b)) @staticmethod def check_rgb(*vals): ret = [] for c in vals: c = int(c) c = min(c, 255) c = max(c, 0) ret.append(c) return ret class ColorAlpha(Color): def __init__(self, r=0, g=0, b=0, alpha=255): Color.__init__(self, r, g, b) self.alpha = alpha def __str__(self): return "&lt;Color(%s, %s, %s, %s)&gt;" % (self.r, self.g, self.b, self.alpha) # ... if __name__ == '__main__': l = (220, 0, 70) la = (57, 58, 61, 255) d = {'r': 220, 'g': 0, 'b':70} da = {'r': 57, 'g': 58, 'b':61, 'a':255} c = Color(); print c # &lt;Color(0, 0, 0)&gt; ca = ColorAlpha(*la); print ca # &lt;Color(57, 58, 61, 255)&gt; print '---' c = Color(220, 0, 70); print c # &lt;Color(220, 0, 70)&gt; c = Color(*l); print c # &lt;Color(220, 0, 70)&gt; #c = Color(*la); print c # -&gt; Fail c = Color(**d); print c # &lt;Color(220, 0, 70)&gt; #c = Color(**da); print c # -&gt; Fail print '---' c = Color.from_Object(c); print c # &lt;Color(220, 0, 70)&gt; c = Color.from_Object(ca); print c # &lt;Color(57, 58, 61, 255)&gt; c = Color.from_List(l); print c # &lt;Color(220, 0, 70)&gt; c = Color.from_List(la); print c # &lt;Color(57, 58, 61, 255)&gt; c = Color.from_Dict(d); print c # &lt;Color(220, 0, 70)&gt; c = Color.from_Dict(da); print c # &lt;Color(57, 58, 61, 255)&gt; print '---' print 'Check =', Color.check_rgb('1', 0x29a, -23, 40) # Check = [1, 255, 0, 40] print '%s + %s = %s' % (c, 10, c + 10) # &lt;Color(57, 58, 61)&gt; + 10 = &lt;Color(67, 68, 71)&gt; print '%s + %s = %s' % (c, ca, c + ca) # &lt;Color(57, 58, 61)&gt; + &lt;Color(57, 58, 61, 255)&gt; = &lt;Color(114, 116, 122)&gt; </code></pre>
[ { "answer_id": 356782, "author": "kender", "author_id": 4172, "author_profile": "https://Stackoverflow.com/users/4172", "pm_score": -1, "selected": false, "text": "def __init__(self, r = 0, g = 0, b = 0):\n # if r is a list\n if (type(r) == type([1,2,3])):\n r, g, b = r[0], ...
2008/12/10
[ "https://Stackoverflow.com/questions/356718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11666/" ]
356,722
<p>I have a defunct process on my system:</p> <pre><code>abc 22093 19508 0 23:29 pts/4 00:00:00 grep ProcA abc 31756 1 0 Dec08 ? 00:00:00 [ProcA_my_collect] &lt;defunct&gt; </code></pre> <p>How can I kill the above process, without a reboot of the machine? I have tried with</p> <pre><code>kill -9 31756 sudo kill -9 31756 </code></pre>
[ { "answer_id": 356899, "author": "curtisk", "author_id": 17651, "author_profile": "https://Stackoverflow.com/users/17651", "pm_score": 5, "selected": false, "text": "ps -ef --forest" }, { "answer_id": 357018, "author": "Bill Karwin", "author_id": 20860, "author_profil...
2008/12/10
[ "https://Stackoverflow.com/questions/356722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/35416/" ]
356,724
<p>I've used Emacs for years on Linux, and I have lots of personally useful keybindings I've put under <kbd>Hyper</kbd> and <kbd>Super</kbd>. Nowadays I'm using Emacs on Windows and am missing those extra keybindings.</p> <p>Is there some way in Windows to get modifier keys other than <kbd>Ctrl</kbd> and <kbd>Meta</kbd>?</p>
[ { "answer_id": 364137, "author": "Michael Paulukonis", "author_id": 41153, "author_profile": "https://Stackoverflow.com/users/41153", "pm_score": 5, "selected": true, "text": "; setting the PC keyboard's various keys to Super or Hyper\n(setq w32-pass-lwindow-to-system nil\n w32-pass...
2008/12/10
[ "https://Stackoverflow.com/questions/356724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39683/" ]
356,726
<p>I got this doubt while writing some code. Is 'bool' a basic datatype defined in the C++ standard or is it some sort of extension provided by the compiler ? I got this doubt because Win32 has 'BOOL' which is nothing but a typedef of long. Also what happens if I do something like this:</p> <pre><code>int i = true; </code></pre> <p>Is it "always" guaranteed that variable i will have value 1 or is it again depends on the compiler I am using ? Further for some Win32 APIs which accept BOOL as the parameter what happens if I pass bool variable?</p>
[ { "answer_id": 356728, "author": "Johannes Schaub - litb", "author_id": 34509, "author_profile": "https://Stackoverflow.com/users/34509", "pm_score": 7, "selected": true, "text": "true" }, { "answer_id": 356730, "author": "hazzen", "author_id": 5066, "author_profile":...
2008/12/10
[ "https://Stackoverflow.com/questions/356726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39742/" ]
356,759
<p>I can never remember the order of the shorthand property for setting the margin or padding in one declaration. That is:</p> <pre><code>margin-top: 2px; margin-bottom: 4px; margin-left: 3px; margin-right: 8px; </code></pre> <p>may be written as</p> <pre><code>margin: 2px 8px 4px 3px; </code></pre> <p>Yes I understand that one can visualise the order by thinking of a clock, starting at midday and moving clockwise. But I keep forgetting about that. I need to recall the order top, right, bottom, left textually.</p> <p>Hence, <code>T R B L</code>.</p> <p>Something like This [R-noun] [B-verb] [L-nouns] is perhaps the way to go but I feel myself lacking inspiration. If anyone has come across a useful mnemonic for this I'd love to hear it. Like a good meme, I'm sure once I get something lodged in my brain I will be unlikely to forget it.</p>
[ { "answer_id": 356766, "author": "Ian G", "author_id": 31765, "author_profile": "https://Stackoverflow.com/users/31765", "pm_score": 1, "selected": false, "text": "top\nright \nbottom \nleft\n" }, { "answer_id": 356810, "author": "Stein G. Strindhaug", "author_id": 26115,...
2008/12/10
[ "https://Stackoverflow.com/questions/356759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18625/" ]
356,763
<p>I have a huge mbox file, with maybe 500 emails in it. </p> <p>It looks like the following:</p> <pre><code>From x@blah.com Fri Aug 12 09:34:09 2005 Message-ID: &lt;42FBEE81.9090701@blah.com&gt; Date: Fri, 12 Aug 2005 09:34:09 +0900 From: me &lt;x@blah.com&gt; User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: someone &lt;someone@hotmail.com&gt; Subject: Re: (no subject) References: &lt;BAY101-F9353854000A4758A7E2CCA9BD0@phx.gbl&gt; In-Reply-To: &lt;BAY101-F9353854000A4758A7E2CCA9BD0@phx.gbl&gt; Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Status: RO X-Status: X-Keywords: X-UID: 371 X-Evolution-Source: imap://x+blah.com@blah.com/ X-Evolution: 00000002-0010 Hey the actual content of the email someone wrote: &gt; lines of quotedtext </code></pre> <p>I would like to know how I can remove all of the quoted text, strip most of the headers except the To, From and Date lines, and still have it somewhat continuous.</p> <p>My goal is to be able to print these emails as a book sort of format, and at the moment every program wants to print one email per page, or all of the headers and quoted text. Any suggestions for where to start on whipping up a small program using shell tools?</p>
[ { "answer_id": 356871, "author": "Hudson", "author_id": 14105, "author_profile": "https://Stackoverflow.com/users/14105", "pm_score": 4, "selected": true, "text": " #!/usr/bin/perl\n use warnings;\n use strict;\n use Mail::Box::Manager;\n\n my $file = shift || $ENV{MAIL};\...
2008/12/10
[ "https://Stackoverflow.com/questions/356763", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1246613/" ]
356,775
<p>I was recently trying to explain to a programmer why, in ASP.Net, they should create HTMLControls instead of creating HTML strings to create Web pages.</p> <p>I know it is a better way of doing things, but I really couldn't give concrete reasons, other than, "This way is better."</p> <p>If you had to answer this question, what would your answer be?</p> <p>Why is <pre>Dim divA as New HtmlControls.HtmlGenericControl("div") Dim ulList1 as New HtmlControls.HtmlGenericControl("ul") Dim liObj1, liObj2, liObj3 as New HtmlControls.HtmlGenericControl("li") liObj1.innerText = "List item 1" liObj2.innerText = "List item 2" liObj3.innerText = "List item 3" ulList1.Controls.Add(liObj1) ulList1.Controls.Add(liObj2) ulList1.Controls.add(liObj3) divA.Controls.add(ulList1)</pre></p> <p>"better" than: </p> <pre><code>Dim strHTML as String strHTML = "&lt;div&gt;&lt;ul&gt;&lt;li&gt;List item 1&lt;/li&gt;&lt;li&gt;List item 2&lt;/li&gt;&lt;li&gt;List item 3&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;" </code></pre> <p>? It doesn't look better. Look at all that code! And, this is a very simplistic example, to save space. I don't think I would ever actually create a list manually like that, but would be iterating through a collection or using a more advanced Web control, but I'm trying to illustrate a point.</p>
[ { "answer_id": 356840, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 3, "selected": true, "text": ".ToString()" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356775", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13449/" ]
356,778
<p>I have a function that looks something like this:</p> <pre><code>//iteration over scales foreach ($surveyScales as $scale) { $surveyItems = $scale-&gt;findDependentRowset('SurveyItems'); //nested iteration over items in scale foreach ($surveyItems as $item) { //retrieve a single value from a result table and do some stuff //depending on certain params from $item / $scale } } </code></pre> <p><strong>QUESTION</strong>: is it better to do a db query for every single value within the inner foreach or is it better to fetch all result values into an array and get the value from there?</p>
[ { "answer_id": 356869, "author": "Bill Karwin", "author_id": 20860, "author_profile": "https://Stackoverflow.com/users/20860", "pm_score": 3, "selected": false, "text": "findDependentRowset()" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356778", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11995/" ]
356,779
<p>I have a small form inside a table. POSTing that form creates a new entity. I then want users to see that new entity, but it should open in a new window so that the original view isn't lost.</p> <p>(How) can I open the result of the form submission in a new window?</p>
[ { "answer_id": 356789, "author": "Grant Wagner", "author_id": 9254, "author_profile": "https://Stackoverflow.com/users/9254", "pm_score": 4, "selected": true, "text": "<form ... target=\"windowName\">\n" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356779", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4937/" ]
356,791
<p>It could be part of the model because it's part of the business logic of the game.</p> <p>It could be part of the controller because it could be seen as simulating player input, which would be considered part of the controller, right? Or would it?</p> <p>What about a normal enemy, like a goomba in Mario?</p> <p>UPDATE: Wow, that's really not the answer I was expecting. As far as I could tell, A.I. is an internal part of the autonomous game system, hence model. I'm still not convinced.</p>
[ { "answer_id": 356806, "author": "jdmichal", "author_id": 12275, "author_profile": "https://Stackoverflow.com/users/12275", "pm_score": 1, "selected": false, "text": "Goomba.move()\n{\n /* Move Goomba forward one unit. */\n}\n" }, { "answer_id": 357133, "author": "Nick Van...
2008/12/10
[ "https://Stackoverflow.com/questions/356791", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11911/" ]
356,794
<p>I've got a JScript error on my page. I know where the error's happening, but I'm attempting to decipher the JScript on that page (to figure out where it came from -- it's on an ASPX page, so any number of user controls could have injected it).</p> <p>It'd be easier if it was indented properly. Are there any free JScript reformatters for Windows?</p>
[ { "answer_id": 356808, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 1, "selected": false, "text": "ctrl + a" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8446/" ]
356,796
<p>I have been using the ASP.NET AJAX UpdatePanel control a lot lately for some intranet apps I've been working on, and for the most part, I have been using it to dynamically refresh data or hide and show controls on a form based on the user's actions.</p> <p>There is one place where I have been having a bit of trouble, and I'm wondering if anyone has any advice. My form is using a pretty typical table based layout where the table is used to display a grid of labels and fields for the user to fill out. (I already know table based layouts are eschewed by some people, and I understand the pros and cons. But that's the choice I've made, so please don't answer with "Don't use a table based layout".)</p> <p>Now my problem is that there are times when I would <em>like</em> to wrap an UpdatePanel around a set of rows so that I can hide and show them dynamically, but the UpdatePanel doesn't really let you do that. The basic problem is that it wraps a div around them, and as far as I know, you cannot wrap a div around table rows. It is not valid HTML.</p> <p>So the way I have been dealing with it is to make my dynamic rows part of a whole new table entirely, which is OK, but then you have to deal with aligning all the columns manually with the table above it, and that is a real pain and pretty fragile.</p> <p>So, the question is... does anyone know of any technique for dynamically generating or refreshing rows using either an UpdatePanel or something similar? Hopefully, the solution would be almost as easy as dropping an UpdatePanel on the page, but even if not, I'd still like to hear it.</p>
[ { "answer_id": 356827, "author": "Rob Allen", "author_id": 149, "author_profile": "https://Stackoverflow.com/users/149", "pm_score": 3, "selected": false, "text": "<tr style=\"display: <%= visible %>\">\n <td></td>\n</tr>\n" }, { "answer_id": 361435, "author": "Astra", ...
2008/12/10
[ "https://Stackoverflow.com/questions/356796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1436/" ]
356,807
<p>I wrote a class that tests for equality, less than, and greater than with two doubles in Java. My general case is comparing price that can have an accuracy of a half cent. 59.005 compared to 59.395. Is the epsilon I chose adequate for those cases?</p> <pre><code>private final static double EPSILON = 0.00001; /** * Returns true if two doubles are considered equal. Tests if the absolute * difference between two doubles has a difference less then .00001. This * should be fine when comparing prices, because prices have a precision of * .001. * * @param a double to compare. * @param b double to compare. * @return true true if two doubles are considered equal. */ public static boolean equals(double a, double b){ return a == b ? true : Math.abs(a - b) &lt; EPSILON; } /** * Returns true if two doubles are considered equal. Tests if the absolute * difference between the two doubles has a difference less then a given * double (epsilon). Determining the given epsilon is highly dependant on the * precision of the doubles that are being compared. * * @param a double to compare. * @param b double to compare * @param epsilon double which is compared to the absolute difference of two * doubles to determine if they are equal. * @return true if a is considered equal to b. */ public static boolean equals(double a, double b, double epsilon){ return a == b ? true : Math.abs(a - b) &lt; epsilon; } /** * Returns true if the first double is considered greater than the second * double. Test if the difference of first minus second is greater then * .00001. This should be fine when comparing prices, because prices have a * precision of .001. * * @param a first double * @param b second double * @return true if the first double is considered greater than the second * double */ public static boolean greaterThan(double a, double b){ return greaterThan(a, b, EPSILON); } /** * Returns true if the first double is considered greater than the second * double. Test if the difference of first minus second is greater then * a given double (epsilon). Determining the given epsilon is highly * dependant on the precision of the doubles that are being compared. * * @param a first double * @param b second double * @return true if the first double is considered greater than the second * double */ public static boolean greaterThan(double a, double b, double epsilon){ return a - b &gt; epsilon; } /** * Returns true if the first double is considered less than the second * double. Test if the difference of second minus first is greater then * .00001. This should be fine when comparing prices, because prices have a * precision of .001. * * @param a first double * @param b second double * @return true if the first double is considered less than the second * double */ public static boolean lessThan(double a, double b){ return lessThan(a, b, EPSILON); } /** * Returns true if the first double is considered less than the second * double. Test if the difference of second minus first is greater then * a given double (epsilon). Determining the given epsilon is highly * dependant on the precision of the doubles that are being compared. * * @param a first double * @param b second double * @return true if the first double is considered less than the second * double */ public static boolean lessThan(double a, double b, double epsilon){ return b - a &gt; epsilon; } </code></pre>
[ { "answer_id": 356825, "author": "Alex B", "author_id": 6180, "author_profile": "https://Stackoverflow.com/users/6180", "pm_score": 4, "selected": false, "text": "1E-6" }, { "answer_id": 356865, "author": "Michael Borgwardt", "author_id": 16883, "author_profile": "htt...
2008/12/10
[ "https://Stackoverflow.com/questions/356807", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,809
<p>Best way to center a <code>&lt;div&gt;</code> element on a page both vertically and horizontally?</p> <p>I know that <code>margin-left: auto; margin-right: auto;</code> will center on the horizontal, but what is the best way to do it vertically, too?</p>
[ { "answer_id": 356829, "author": "Andreas Grech", "author_id": 44084, "author_profile": "https://Stackoverflow.com/users/44084", "pm_score": 4, "selected": false, "text": "var centerIt = function (el /* (jQuery element) Element to center */) {\n if (!el) {\n return;\n }\n ...
2008/12/10
[ "https://Stackoverflow.com/questions/356809", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,830
<p>I'm doing a Python script where I need to spawn several ssh-copy-id processes, and they need for me to type in a password, so i'm using PExpect.</p> <p>I have basically this:</p> <pre><code>child = pexpect.spawn('command') child.expect('password:') child.sendline('the password') </code></pre> <p>and then I want to spawn another process, I don't care about this one anymore, whether it ended or not.</p> <pre><code>child = pexpect.spawn('command2') child.expect('password:') child.sendline('the password') </code></pre> <p>And the code is hanging at the second "spawn"</p> <p>However, if I comment out the first call, the second one works, so i'm guessing that the fact that the first one is still running or something is keeping it from working.</p> <p>Now, the other thing I haven't been able to do is wait until the first one stops. I've tried:<br> child.close() - it hangs (both with True and False as parameters) child.read(-1) - it hangs<br> child.expect(pexpect.EOF) - it hangs.<br> child.terminate() - it hangs (both with True and False as parameters)</p> <p>Any ideas on what could be happening?<br> NOTE: I'm not a Python expert, and i have never used pexpect before, so ANY idea is more than welcome.</p> <p>Thanks!</p> <hr> <p>UPDATE: This is definitely related to ssh-copy-id, because with other processes, spawn works well even if they don't return. Also, apparently ssh-copy-id never returns an EOF.</p>
[ { "answer_id": 357021, "author": "rob", "author_id": 43927, "author_profile": "https://Stackoverflow.com/users/43927", "pm_score": 0, "selected": false, "text": "child = pexpect.spawn('command')\nchild.expect('password:')\nchild.sendline('the password')\nchild.close(True)\n" }, { ...
2008/12/10
[ "https://Stackoverflow.com/questions/356830", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3314/" ]
356,831
<p>I'm very excited about the new "local F specs" coming in V6R1 - see:</p> <p><a href="http://www.mcpressonline.com/programming/rpg/v6r1-rpg-enhancements.html" rel="nofollow noreferrer">http://www.mcpressonline.com/programming/rpg/v6r1-rpg-enhancements.html</a></p> <p>Does anyone know a way to simulate this in V5R4 in a SRVPGM procedure?</p>
[ { "answer_id": 357021, "author": "rob", "author_id": 43927, "author_profile": "https://Stackoverflow.com/users/43927", "pm_score": 0, "selected": false, "text": "child = pexpect.spawn('command')\nchild.expect('password:')\nchild.sendline('the password')\nchild.close(True)\n" }, { ...
2008/12/10
[ "https://Stackoverflow.com/questions/356831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,835
<p>OK, if anyone could help me with this I'd be much appreciative. If you copy and paste the following and open up in IE or Firefox</p> <pre><code>&lt;div style="border: solid 1px navy; float: left;"&gt; &lt;ul&gt; &lt;li&gt;Item 1&lt;/li&gt; &lt;li&gt;Item 2&lt;/li&gt; &lt;li&gt;Item 3&lt;/li&gt; &lt;li&gt;Item 4&lt;/li&gt; &lt;li&gt;Item 5&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div style="background-color: blue;"&gt; &lt;p&gt;Some Text&lt;/p&gt; &lt;p&gt;Another paragraph&lt;/p&gt; &lt;/div&gt; </code></pre> <p>Why does the second div which has a blue background expand to be behind the first div that contains the list of items? How do I get it to really float next to the first div?</p>
[ { "answer_id": 356872, "author": "Diodeus - James MacFarlane", "author_id": 12579, "author_profile": "https://Stackoverflow.com/users/12579", "pm_score": 3, "selected": true, "text": "<div style=\"border: solid 1px navy; float: left;\">\n<ul>\n <li>Item 1</li>\n <li>Item 2</li>\n ...
2008/12/10
[ "https://Stackoverflow.com/questions/356835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44702/" ]
356,839
<p>I've inherited a legacy application that is supposed to grab an on the fly pdf from a reporting services server. Everything works fine up until the point where you try to open the pdf being returned and adobe acrobat tells you:</p> <blockquote> <p>Adobe Reader could not open 'thisStoopidReport'.pdf' because it is either not a supported file type or because the file has been damaged(for example, it was sent as an email attachment and wasn't correctly decoded).</p> </blockquote> <p>I've done some initial troubleshooting on this. If I replace the url in the WebRequest.Create() call with a valid pdf file on my local machine ie: @"C:temp/validpdf.pdf") then I get a valid PDF.</p> <p>The report itself seems to work fine. If I manually type the URL to the reporting services report that should generate the pdf file I am prompted for user authentication. But after supplying it I get a valid pdf file.</p> <p>I've replace the actual url,username,userpass and domain strings in the code below with bogus values for obvious reasons.</p> <pre><code> WebRequest request = WebRequest.Create(@"http://x.x.x.x/reportServer?/reports/reportNam&amp;rs:format=pdf&amp;rs:command=render&amp;rc:parameters=blahblahblah"); int totalSize = 0; request.Credentials = new NetworkCredential("validUser", "validPass", "validDomain"); request.Timeout = 360000; // 6 minutes in milliseconds. request.Method = WebRequestMethods.Http.Post; request.ContentLength = 0; WebResponse response = request.GetResponse(); Response.Clear(); BinaryReader reader = new BinaryReader(response.GetResponseStream()); Byte[] buffer = new byte[2048]; int count = reader.Read(buffer, 0, 2048); while (count &gt; 0) { totalSize += count; Response.OutputStream.Write(buffer, 0, count); count = reader.Read(buffer, 0, 2048); } Response.ContentType = "application/pdf"; Response.Cache.SetCacheability(HttpCacheability.Private); Response.CacheControl = "private"; Response.Expires = 30; Response.AddHeader("Content-Disposition", "attachment; filename=thisStoopidReport.pdf"); Response.AddHeader("Content-Length", totalSize.ToString()); reader.Close(); Response.Flush(); Response.End(); </code></pre>
[ { "answer_id": 357947, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": 1, "selected": false, "text": "request.Method = WebRequestMethods.Http.Post;\n" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
356,846
<p>Earlier I asked a question about <a href="https://stackoverflow.com/questions/335682/mvc-examples-use-of-var">why I see so many examples use the <code>var</code>keyword</a> and got the answer that while it is only necessary for anonymous types, that it is used nonetheless to make writing code 'quicker'/easier and 'just because'.</p> <p>Following <a href="http://www.interact-sw.co.uk/iangblog/2005/09/23/varisntobject" rel="noreferrer">this link ("C# 3.0 - Var Isn't Objec")</a> I saw that <code>var</code> gets compiled down to the correct type in the IL (you will see it about midway down article).</p> <p>My question is how much more, if any, IL code does using the <code>var</code> keyword take, and would it be even close to having a measurable level on the performance of the code if it was used everywhere?</p>
[ { "answer_id": 356855, "author": "Joel Coehoorn", "author_id": 3043, "author_profile": "https://Stackoverflow.com/users/3043", "pm_score": 9, "selected": true, "text": "var" }, { "answer_id": 356862, "author": "Michael Burr", "author_id": 12711, "author_profile": "htt...
2008/12/10
[ "https://Stackoverflow.com/questions/356846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40814/" ]
356,851
<p>I have been given a DLL ("InfoLookup.dll") that internally allocates structures and returns pointers to them from a lookup function. The structures contain string pointers:</p> <pre><code>extern "C" { struct Info { int id; char* szName; }; Info* LookupInfo( int id ); } </code></pre> <p>In C#, how can I declare the structure layout, declare the Interop call, and (assuming a non-null value is returned) utilize the string value? In other words, how do I translate the following into C#?</p> <pre><code>#include "InfoLookup.h" void foo() { Info* info = LookupInfo( 0 ); if( info != 0 &amp;&amp; info-&gt;szName != 0 ) DoSomethingWith( info-&gt;szName ); // NOTE: no cleanup here, the DLL is caching the lookup table internally } </code></pre>
[ { "answer_id": 356874, "author": "TheSmurf", "author_id": 1975282, "author_profile": "https://Stackoverflow.com/users/1975282", "pm_score": -1, "selected": false, "text": "using System.Runtime.InteropServices;\n\n[DllImport(\"mydll.dll\")]\npublic static extern Info LookupInfo(int val);\...
2008/12/10
[ "https://Stackoverflow.com/questions/356851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4540/" ]
356,882
<p>I've looked at every question so far and none seem to actually answer this question.</p> <p>I created a UITabBarController and added several view controllers to it. Most of the views are viewed in portrait, but one should be viewed in landscape. I don't want to use the accelerometer or detect when the user rotates the device, I just want to display the view in landscape mode when they choose that view from the tab at the bottom.</p> <p>I want the regular animations to occur, such as the tab dropping out, the view rotating, etc., when they choose that item, and the opposite to happen when they choose a different view.</p> <p>Is there not a built-in property or method to tell the system what orientation to display the view as?</p> <p>Overriding the shouldautorotate... method does absolutely nothing so far as I can tell.</p> <p>The type of answer I would NOT appreciate is "RTFM" because I already have, and anybody who's developed for the iPhone so far knows that there is very little useful M to F-ing R.</p>
[ { "answer_id": 356903, "author": "JamesSugrue", "author_id": 1075, "author_profile": "https://Stackoverflow.com/users/1075", "pm_score": 4, "selected": true, "text": "CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));\nlandscapeTransform = CGAffine...
2008/12/10
[ "https://Stackoverflow.com/questions/356882", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36007/" ]
356,883
<p>Is there any way to change the taskbar icon of a browser in windows?</p> <p>I open alot of browser windows, and I like to group similar websites (in tabs) by window. So I was wondering if there was a way to assign a taskbar icon to them so that you can more easily differentiate between them. </p>
[ { "answer_id": 357177, "author": "w4g3n3r", "author_id": 36745, "author_profile": "https://Stackoverflow.com/users/36745", "pm_score": 4, "selected": true, "text": "[DllImport(\"user32.dll\", CharSet=CharSet.Auto)]\npublic static extern IntPtr FindWindow(string strClassName, string strWi...
2008/12/10
[ "https://Stackoverflow.com/questions/356883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18149/" ]
356,886
<p>I'm using CFHTTP to post data to my payment gateway (Protx).</p> <p>Protx requires that I whitelist the IP that will send this request.</p> <p>I am hosted on a shared server running Windows 2008.</p> <p>This morning, my hosting company assigned a new IP to this server for a customer who required an SSL certificate. Since then, my CFHTTP post appears to be coming from this new IP (which was not on the Protx whitelist).</p> <p>My hosting company, being the worst imaginable, doesn't know why this is and aren't willing to look into it further.</p> <p>Does anyone have any idea how I can specify which referring IP address CFHTTP will use to post data?</p>
[ { "answer_id": 357177, "author": "w4g3n3r", "author_id": 36745, "author_profile": "https://Stackoverflow.com/users/36745", "pm_score": 4, "selected": true, "text": "[DllImport(\"user32.dll\", CharSet=CharSet.Auto)]\npublic static extern IntPtr FindWindow(string strClassName, string strWi...
2008/12/10
[ "https://Stackoverflow.com/questions/356886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/22113/" ]
356,928
<p>I am writing a key record look up where the I have an index between the key and the rec number. This is sorted on the key. Is there away to do this better that what I have for speed optimization?</p> <pre><code>typedef struct { char key[MAX_KEYLEN]; int rec; } KeyRecPair; typedef struct { KeyRecPair *map; int numRecs; } KeyRecMap; int GetRecFromKey(char *key, KeyRecMap *theMap) { int cmpValue, bottom = 0; int half = theMap-&gt;numRecs / 2; int top = theMap-&gt;numRecs - 1; while (bottom != top) { cmpValue = strncmp(key, theMap-&gt;map[half].key, MAX_KEY_LEN); if (cmpValue &gt; 0) { /*top stays*/ bottom = half + 1; half = bottom + (top - bottom) / 2; continue; } if (cmpValue &lt; 0) { /*bottom stays*/ top = half - 1; half = bottom + (top - bottom) / 2; continue; } return theMap-&gt;map[half].rec; } if (0 == strncmp(key, theMap-&gt;map[half].key, MAX_KEY_LEN)) return theMap-&gt;map[half].rec; return 0; } </code></pre>
[ { "answer_id": 356944, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 2, "selected": false, "text": "bsearch" }, { "answer_id": 358906, "author": "dmityugov", "author_id": 3232, "author_profile": "https...
2008/12/10
[ "https://Stackoverflow.com/questions/356928", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2064/" ]
356,929
<p>I have following situation. A main table and many other tables linked together with foreign keys. Now when I would like to delete a row in the main table a ConstraintsViolation will occur, which is intended and good.</p> <p>Now I want to be able to check if the ConstraintsViolation will occur before I trigger the delete row event. </p> <p>Is this possible?</p>
[ { "answer_id": 356943, "author": "Charles Bretana", "author_id": 32632, "author_profile": "https://Stackoverflow.com/users/32632", "pm_score": 2, "selected": true, "text": "If Exists ( Select * From OtherTable\n Where OtherTableFKColumn = MainTablePrimaryKey) \n Begin\n ...
2008/12/10
[ "https://Stackoverflow.com/questions/356929", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6482/" ]
356,938
<p>When writing fairly typical Mac code in an OS X 10.5+ environment, what are the disadvantages to using garbage collection?</p> <p>So far everything else I've written has been either 10.4 compatible or on the iPhone, so I've become fairly comfortable with retain/release, but now that I'm working on a larger project that's 10.5 only I'm wondering if there are any downsides to just going ahead and using the Objective-C 2.0 garbage collector.</p> <p>What do you guys think?</p>
[ { "answer_id": 358910, "author": "Chris Hanson", "author_id": 714, "author_profile": "https://Stackoverflow.com/users/714", "pm_score": 5, "selected": true, "text": "-retain" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512/" ]
356,947
<p>Can someone help me identify what the purpose of this unidentified syntax is. It is an extra little something in the constructor for this object. What I'm trying to figure out is what is the "&lt; IdT >" at the end of the class declaration line? I think that this is something I would find useful, I just need to understand what it is why so many people seem to do this.</p> <pre><code>using BasicSample.Core.Utils; namespace BasicSample.Core.Domain { /// &lt;summary&gt; /// For a discussion of this object, see /// http://devlicio.us/blogs/billy_mccafferty/archive/2007/04/25/using-equals-gethashcode-effectively.aspx /// &lt;/summary&gt; public abstract class DomainObject&lt;IdT&gt; { /// &lt;summary&gt; /// ID may be of type string, int, custom type, etc. /// Setter is protected to allow unit tests to set this property via reflection and to allow /// domain objects more flexibility in setting this for those objects with assigned IDs. /// &lt;/summary&gt; public IdT ID { get { return id; } protected set { id = value; } } </code></pre>
[ { "answer_id": 356971, "author": "gcores", "author_id": 40256, "author_profile": "https://Stackoverflow.com/users/40256", "pm_score": 3, "selected": true, "text": "new DomainObject<string>(); \n" }, { "answer_id": 357009, "author": "tvanfosson", "author_id": 12950, "a...
2008/12/10
[ "https://Stackoverflow.com/questions/356947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42987/" ]
356,948
<p>I'm building a .NET 3.5 application and have the need to evaluate JS code on the server - basically a user provided rule set that can work within a browser or on the server. Managed JS is not an option, because the JS code would be provided at runtime. Aptana's Jaxer is also not an option. So I was looking into using a build of the V8 engine within my app.</p> <p>I built the source successfully into a DLL, but that DLL is not not a managed library and is not COM either. V8 is just plain C++.</p> <p>Any ideas as to how to interop with this type of DLL in C#? Also, I'm open to other suggestions for SpiderMonkey or another JS engine.</p> <p>Thanks in advance.</p> <p><strong>UPDATE:</strong></p> <p>I was able to use Ryan's solution. I just updated the references to the build for the latest from trunk. It worked great. Thanks Ryan.</p>
[ { "answer_id": 357284, "author": "Ryan Cook", "author_id": 43029, "author_profile": "https://Stackoverflow.com/users/43029", "pm_score": 6, "selected": true, "text": "V8DotNet.Shell shell = new V8DotNet.Shell();\n\nshell.ExecuteScript(@\"print('V8 version is: ' + version());\");\n" }, ...
2008/12/10
[ "https://Stackoverflow.com/questions/356948", "https://Stackoverflow.com", "https://Stackoverflow.com/users/30544/" ]
356,950
<p>I keep hearing a lot about functors in C++. Can someone give me an overview as to what they are and in what cases they would be useful?</p>
[ { "answer_id": 356992, "author": "James Curran", "author_id": 12725, "author_profile": "https://Stackoverflow.com/users/12725", "pm_score": 7, "selected": false, "text": "operator()" }, { "answer_id": 356993, "author": "jalf", "author_id": 33213, "author_profile": "ht...
2008/12/10
[ "https://Stackoverflow.com/questions/356950", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18664/" ]
356,957
<p>Here's the basic idea:</p> <p>There is a java window (main) that opens another java window (child). When the child is created, part of the initialization sets the focus in the appropriate text field in the child window:</p> <pre><code>childTextField.requestFocusInWindow(); childTextField.setCaretPosition(0); </code></pre> <p>The child is generally opened through a serious of keystrokes via a command line type interface. When the window is requested, 90%ish of the time, the focus correctly goes to the child window text field and the user can type in the box. If the command to open the child is sent off (with a press of the enter key) and the user immediately starts typing before the new window is created, the text is correctly buffered and appears in the new textfield after the window opens. </p> <p>However, every once in a while when the user requests the child window to open and then starts typing, their text does NOT appear in the text field. Only after they click with the mouse in the field does the text they have typed appear. It's like it's being stored somewhere and doesn't come out until they click.</p> <p>The real frustrating thing here is that I can't seem to reliably reproduce the issue at all. It definitely happens, but not regularly enough to debug nicely.</p> <p>There is of course all kinds of other mojo going on behind the scenes, including communication with a server app, but I'm not convinced it's related.</p> <p>Any thoughts or ideas would be very much appreciated.</p>
[ { "answer_id": 357019, "author": "Chris Mattmiller", "author_id": 43712, "author_profile": "https://Stackoverflow.com/users/43712", "pm_score": 1, "selected": false, "text": "init()" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356957", "https://Stackoverflow.com", "https://Stackoverflow.com/users/45077/" ]
356,972
<p>How do you format the date time to just date? </p> <p>For example, this is what I retrieved from the database: 12/31/2008 12:00:00 AM, but I just want to show the date and no time.</p>
[ { "answer_id": 357349, "author": "Rick", "author_id": 1752, "author_profile": "https://Stackoverflow.com/users/1752", "pm_score": 4, "selected": false, "text": " Dim d As DateTime = Now\n Debug.WriteLine(d.ToLongDateString)\n Debug.WriteLine(d.ToShortDateString)\n Debug.WriteLine...
2008/12/10
[ "https://Stackoverflow.com/questions/356972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28647/" ]
356,974
<p>I have a mystery on my hands. I am trying to learn managed C++ coming from a C# background and have run into a snag. If I have a project which includes two classes, a base class <strong>Soup</strong> and a derived class <strong>TomatoSoup</strong> which I compile as a static library (.lib), I get unresolved tokens on the virtual methods in <strong>Soup</strong>. Here is the code:</p> <hr> <h2>Abstracts.proj</h2> <p><strong>Soup.h</strong></p> <pre><code>namespace Abstracts { public ref class Soup abstract { public: virtual void heat(int Degrees); }; } </code></pre> <p><strong>TomatoSoup.h</strong></p> <pre><code>#include "Soup.h" namespace Abstracts { public ref class TomatoSoup : Abstracts::Soup { public: virtual void heat(int Degrees) override; }; } </code></pre> <p><strong>TomatoSoup.cpp</strong></p> <pre><code>#include "TomatoSoup.h" void Abstracts::TomatoSoup::heat(int Degrees) { System::Console::WriteLine("Soup's on."); } </code></pre> <h2>Main.proj</h2> <p><strong>Main.cpp</strong></p> <pre><code>#include "TomatoSoup.h" using namespace System; int main(array&lt;System::String ^&gt; ^args) { Abstracts::TomatoSoup^ ts = gcnew Abstracts::TomatoSoup(); return 0; } </code></pre> <hr> <p>I get this link-time error on <strong>Main.proj</strong>:</p> <pre><code>1&gt;Main.obj : error LNK2020: unresolved token (06000001) Abstracts.Soup::heat </code></pre> <ol> <li><p>I've tried setting </p> <pre><code>virtual void heat(int Degrees)=0; </code></pre></li> <li><p>I've tried implementing heat in the base class </p> <pre><code>virtual void heat(int Degrees){} </code></pre> <p>and get an unreferenced formal parameter warning treated as an error.</p></li> <li>I've tried both 1 and 2 with and without the abstract keyword on the Soup class</li> </ol> <p>This issue is driving me crazy and I hope to prevent it from driving other developers nuts in the future.</p> <p><strong>UPDATE:</strong> This worked with Greg Hewgill's argument-name commenting method when the TomatoSoup::heat was implemented in the header file, but the error came back when I moved the implementation to TomatoSoup.cpp. I've modified the question to reflect that.</p>
[ { "answer_id": 357003, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 3, "selected": true, "text": "Abstracts.Soup::heat" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/356974", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2831/" ]
356,980
<p>I have an Access Database that outputs a report in Excel format.</p> <p>The report is dependent on a date parameter chosen by the user. This parameter is selected via a textbox (text100) that has a pop up calendar.</p> <p>I would like to use the date in the text box (text100) in the filename.</p>
[ { "answer_id": 357039, "author": "DJ.", "author_id": 10492, "author_profile": "https://Stackoverflow.com/users/10492", "pm_score": 3, "selected": true, "text": "Some Module\n\nDim vParam1 as variant\nDim vParam1 as variant\n\nPublic Sub ParameterSet(byval pParamName as String, byval pPar...
2008/12/10
[ "https://Stackoverflow.com/questions/356980", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44685/" ]
356,982
<p>I'm creating a multi-tenancy web site which hosts pages for clients. The first segment of the URL will be a string which identifies the client, defined in Global.asax using the following URL routing scheme:</p> <pre><code>"{client}/{controller}/{action}/{id}" </code></pre> <p>This works fine, with URLs such as /foo/Home/Index.</p> <p>However, when using the [Authorize] attribute, I want to redirect to a login page which also uses the same mapping scheme. So if the client is foo, the login page would be /foo/Account/Login instead of the fixed /Account/Login redirect defined in web.config.</p> <p>MVC uses an HttpUnauthorizedResult to return a 401 unauthorised status, which I presume causes ASP.NET to redirect to the page defined in web.config.</p> <p>So does anyone know either how to override the ASP.NET login redirect behaviour? Or would it be better to redirect in MVC by creating a custom authorization attribute?</p> <p><strong>EDIT - Answer:</strong> after some digging into the .Net source, I decided that a custom authentication attribute is the best solution:</p> <pre><code>public class ClientAuthorizeAttribute: AuthorizeAttribute { public override void OnAuthorization( AuthorizationContext filterContext ) { base.OnAuthorization( filterContext ); if (filterContext.Cancel &amp;&amp; filterContext.Result is HttpUnauthorizedResult ) { filterContext.Result = new RedirectToRouteResult( new RouteValueDictionary { { "client", filterContext.RouteData.Values[ "client" ] }, { "controller", "Account" }, { "action", "Login" }, { "ReturnUrl", filterContext.HttpContext.Request.RawUrl } }); } } } </code></pre>
[ { "answer_id": 358554, "author": "Nicholas Piasecki", "author_id": 32187, "author_profile": "https://Stackoverflow.com/users/32187", "pm_score": 6, "selected": true, "text": "FormsAuthentication.RedirectToLoginPage()" }, { "answer_id": 1098132, "author": "user134936", "au...
2008/12/10
[ "https://Stackoverflow.com/questions/356982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/43649/" ]
357,033
<p>I'm trying to do a Data Binding in the C# code behind rather than the XAML. The XAML binding created in Expression Blend 2 to my CLR object works fine. My C# implementation only updates when the application is started after which subsequent changes to the CLR doesn't update my label content. </p> <p>Here's the working XAML binding. First a ObjectDataProvider is made in my Window.Resources.</p> <pre><code>&lt;ObjectDataProvider x:Key="PhoneServiceDS" ObjectType="{x:Type kudu:PhoneService}" d:IsDataSource="True"/&gt; </code></pre> <p>And the label content binding:</p> <pre><code>&lt;Label x:Name="DisplayName" Content="{Binding Path=MyAccountService.Accounts[0].DisplayName, Mode=OneWay, Source={StaticResource PhoneServiceDS}}"/&gt; </code></pre> <p>Works great. But we want this set up in C# so we can independently change the XAML (ie. new skins). My one time working C# as follows:</p> <pre><code> Binding displayNameBinding = new Binding(); displayNameBinding.Source = PhoneService.MyAccountService.Accounts[0].DisplayName; displayNameBinding.Mode = BindingMode.OneWay; this.DisplayName.SetBinding(Label.ContentProperty, displayNameBinding); </code></pre> <p>This is inside my MainWindow after InitializeComponent();</p> <p>Any insight why this only works on startup?</p>
[ { "answer_id": 357158, "author": "devios1", "author_id": 238948, "author_profile": "https://Stackoverflow.com/users/238948", "pm_score": 3, "selected": true, "text": "Binding displayNameBinding = new Binding( \"MyAccountService.Accounts[0].DisplayName\" );\ndisplayNameBinding.Source = ne...
2008/12/10
[ "https://Stackoverflow.com/questions/357033", "https://Stackoverflow.com", "https://Stackoverflow.com/users/36234/" ]
357,041
<p>I have LINQ statement that looks like this:</p> <pre><code>return ( from c in customers select new ClientEntity() { Name = c.Name, ... }); </code></pre> <p>I'd like to be able to abstract out the select into its own method so that I can have different "mapping" option. What does my method need to return?</p> <p>In essence, I'd like my LINQ query to look like this:</p> <pre><code>return ( from c in customers select new Mapper(c)); </code></pre> <p><strong>Edit:</strong></p> <p>This is for LINQ to SQL.</p>
[ { "answer_id": 357091, "author": "bdukes", "author_id": 2688, "author_profile": "https://Stackoverflow.com/users/2688", "pm_score": 1, "selected": false, "text": "Expression" }, { "answer_id": 357417, "author": "Daniel Earwicker", "author_id": 27423, "author_profile":...
2008/12/10
[ "https://Stackoverflow.com/questions/357041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/781/" ]
357,046
<p>i have a Sharepoint feature that essentially extends Lists with a new feature, using a List receiver. For each list the feature is attached to, i need to store some configuration.</p> <p>Now, the first thing that came into my mind is the obvious solution: Have a global list. That works of course, but I wonder if there is some way to store feature-specific configuration in a hidden place? Not that it's sensitive information, but I don't want to clutter the Users Display with too many lists. I believe I can hide lists, but at the same time I wonder if sharepoint allows me to use it's database?</p> <p>I am not talking about just using ADO.net to access the db directly (which is a big no-no with Sharepoint), I am thinking about some officially supported mechanism.</p>
[ { "answer_id": 357083, "author": "Pascal Paradis", "author_id": 1291, "author_profile": "https://Stackoverflow.com/users/1291", "pm_score": 1, "selected": false, "text": "string sAdminEmail = ConfigStore.GetValue(\"MyApplication\", \"AdminEmail\");\n" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/357046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91/" ]
357,048
<p>I have two tables, we'll call them <code>Foo</code> and <code>Bar</code>, with a one to many relationship where <code>Foo</code> is the parent of <code>Bar</code>. Foo's primary key is an integer automatically generated with a sequence. </p> <p>Since <code>Bar</code> is fully dependent on <code>Foo</code> how would I setup the primary key of <code>Bar</code> given the following constraints:</p> <ul> <li>Records for Bar are programatically generated so user input can not be relied upon for an identifier.</li> <li>Multiple processes are generating Bar records so anything involving a <code>Select Max()</code> to generate an <code>ID</code> would present a race condition.</li> </ul> <p>I have come up with two possible solutions that I am not happy with:</p> <ul> <li>Treat the tables as if they are a many to many relationship with a third table that maps their records together and have the application code handle inserting records so that the mapping between the records is created correctly. I don't like this as it makes the database design misleading and errors in application code could result in invalid data.</li> <li>Give Bar two colunms: <code>FooID</code> and <code>FooBarID</code> and generate a value for <code>FooBarID</code> by selecting the <code>max(FooBarID)+1</code> for some <code>FooID</code>, but as previously stated this creates a race condition.</li> </ul> <p>I appreciate any ideas for an alternative table layout.</p>
[ { "answer_id": 357080, "author": "Steven A. Lowe", "author_id": 9345, "author_profile": "https://Stackoverflow.com/users/9345", "pm_score": 0, "selected": false, "text": "create table SystemCounter \n( \n SystemCounterId int identity not null, \n BarIdAllocator int \n)\n--initializ...
2008/12/10
[ "https://Stackoverflow.com/questions/357048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9940/" ]
357,049
<p>I have a simple email address sign up form as follows:</p> <pre><code>&lt;form action="" id="newsletterform" method="get"&gt; &lt;input type="text" name="email" class="required email" id="textnewsletter" /&gt; &lt;input type="submit" id="signup" /&gt; &lt;/form&gt; </code></pre> <p><strong>Here's what I want to be able to do:</strong></p> <ul> <li>Validate the form to look for an empty string or a incorrectly filled out email address one the user clicks submit or hits enter.</li> <li>If one of the above happens (empty string etc), I would like to generate an error to let the user know.</li> <li>Then once the user fills out a correctly formed email address and hits submit (or enter) I want the form to send the email address to wherever I specify in the jQuery code and then generate a little "Thank you for signing up notice", all without reloading the browser.</li> </ul> <p>I have looked at too many tutorials and my eyes are pretty much aching at this stage, so please don't point me to any urls (I most likely have been there).</p> <p>If someone could provide a barebone outline of what to do It would be so much appreciated. </p>
[ { "answer_id": 357075, "author": "MrChrister", "author_id": 24229, "author_profile": "https://Stackoverflow.com/users/24229", "pm_score": 4, "selected": true, "text": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.d...
2008/12/10
[ "https://Stackoverflow.com/questions/357049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/37418/" ]
357,068
<p>Is there a way to use the C sprintf() function without it adding a '\0' character at the end of its output? I need to write formatted text in the middle of a fixed width string.</p>
[ { "answer_id": 357081, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 7, "selected": true, "text": "sprintf()" }, { "answer_id": 357391, "author": "Doug T.", "author_id": 8123, "author_profile": "https:...
2008/12/10
[ "https://Stackoverflow.com/questions/357068", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39702/" ]
357,076
<p>I've been a .NET developer for several years now and this is still one of those things I don't know how to do properly. It's easy to hide a window from the taskbar via a property in both Windows Forms and WPF, but as far as I can tell, this doesn't guarantee (or necessarily even affect) it being hidden from the <kbd>Alt</kbd>+<kbd>↹Tab</kbd> dialog. I've seen <em>invisible</em> windows show up in <kbd>Alt</kbd>+<kbd>↹Tab</kbd>, and I'm just wondering what is the best way to guarantee a window will <em>never</em> appear (visible or not) in the <kbd>Alt</kbd>+<kbd>↹Tab</kbd> dialog.</p> <p><strong>Update:</strong> Please see my posted solution below. I'm not allowed to mark my own answers as the solution, but so far it's the only one that works.</p> <p><strong>Update 2:</strong> There's now a proper solution by Franci Penov that looks pretty good, but haven't tried it out myself. Involves some Win32, but avoids the lame creation of off-screen windows.</p>
[ { "answer_id": 357270, "author": "Philipp Schmid", "author_id": 33272, "author_profile": "https://Stackoverflow.com/users/33272", "pm_score": 1, "selected": false, "text": "<Window x:Class=\"WpfApplication5.Window1\"\n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\...
2008/12/10
[ "https://Stackoverflow.com/questions/357076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/238948/" ]
357,084
<p>I do my php work on my dev box at home, where I've got a rudimentary LAMP setup. When I look at my website on my home box, any numbers I echo are automatically truncated to the least required precision. Eg 2 is echoed as 2, 2.2000 is echoed as 2.2.</p> <p>On the production box, all the numbers are echoed with at least one unnecessary zero, eg 100 becomes 100.0. On both boxes, the PHP version is 5.2.5. Does anyone know offhand if there is a setting I can change which will force PHP to automatically remove any unnecessary zeroes? I don't want to have to go to every place in my code where I output a number and replace echo with printf or something like that.</p> <p>Muchas gracias.</p>
[ { "answer_id": 357128, "author": "TravisO", "author_id": 35116, "author_profile": "https://Stackoverflow.com/users/35116", "pm_score": 4, "selected": true, "text": "// displays 3.14 as 3 and 4.00 as 4 \nprint number_format($price, 0); \n// display 4 as 4.00 and 1234.56 as 1,234.56 aka...
2008/12/10
[ "https://Stackoverflow.com/questions/357084", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42387/" ]
357,095
<p>I would like to use JConsole to monitor my Websphere application, but I am not sure how to enable JMX.</p>
[ { "answer_id": 358814, "author": "eljenso", "author_id": 30316, "author_profile": "https://Stackoverflow.com/users/30316", "pm_score": 5, "selected": false, "text": "service:jmx:iiop://<host>:<port>/jndi/JMXConnector\n" }, { "answer_id": 1545542, "author": "Alan Chan", "a...
2008/12/10
[ "https://Stackoverflow.com/questions/357095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
357,104
<p>How do I prevent a form that is posted a second time because of a page reload in a browser from being added to my database again with C# Asp.Net.</p> <p>Thanks, Steven</p>
[ { "answer_id": 357144, "author": "orip", "author_id": 37020, "author_profile": "https://Stackoverflow.com/users/37020", "pm_score": 2, "selected": false, "text": "Page_Load" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/357104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/42588/" ]
357,121
<p>In my mock class, I'm mocking method foo(). For some test cases, I want the mock implementation of foo() to return a special value. For other test cases, I want to use the real implementation of foo(). I have a boolean defined in my mock class so that I can determine in the mock method whether I want to return the special value, or use the "real" method. The problem is, I can't seem to figure out how to call the real method from the mocked method.</p> <p>I found that you can define a special member within the mock object named "it" (with type of the object being mocked). This allows you to reference the real class from the mock implementation. So, my plan was, if I needed to invoke the "real" implementation of foo(), the mock method would call it.foo(). However, this doesn't work, because calling it.foo() just calls the mock version again, not the real version, so I end up with infinite recursion.</p> <p>Is there some way to make this work?</p> <p>EDIT: it might be clearer with a code example, here's what my current mocked method implementation looks like:</p> <pre><code>private RealClass it; ... public SomeClass foo() { if(fakeIt) { return new SomeClass("fakevalue"); } else { // doesn't work, just keeps calling the mock foo // in infinite recursion return it.foo(); } } </code></pre> <p>EDIT 2: Also, for most of my test cases I do <em>NOT</em> want the mock implementation. So my initial attempt at this was to only call Mockit.redefineMethods() within those test cases where I needed the mock object. But this didn't work - it seems you can only do this within setup/teardown ... my mock implementation never got called when I tried that.</p> <p>NOTES ON SOLUTION:</p> <p>At first I didn't think the answer given worked, but after playing with it some more, it seems the problem is that I was mixing JMockit "core" methods with the "annotation" driven methods. Apparently when using the annotation you need to use Mockit.setupMocks, not Mockit.redefineMethods(). This is what finally worked:</p> <pre><code>@Before public void setUp() throws Exception { Mockit.setUpMocks(MyMockClass.class); } </code></pre> <p>Then, for the mock class:</p> <pre><code>@MockClass(realClass = RealClass.class) public static class MyMockClass { private static boolean fakeIt = false; private RealClass it; @Mock(reentrant = true) public SomeClass foo() { if(fakeIt) { return new SomeClass("fakevalue"); } else { return it.foo(); } } } </code></pre>
[ { "answer_id": 357424, "author": "ebo", "author_id": 13226, "author_profile": "https://Stackoverflow.com/users/13226", "pm_score": 1, "selected": false, "text": "RealClass toTest = new RealClass(){\n public String foo(){\n return \"special value\";\n }\n}\n\n//use toTe...
2008/12/10
[ "https://Stackoverflow.com/questions/357121", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20437/" ]
357,122
<p>Coming from <a href="https://stackoverflow.com/questions/356778/php-query-single-value-per-iteration-or-fetch-all-at-start-and-retrieve-from-ar">another question of mine</a> where I learnt not to EVER use db queries within loops I consequently have to learn how to fetch all the data in a convenient way before I loop through it.</p> <p>Let's say I have two tables 'scales' and 'items'. Each item in items belongs to one scale in scales and is linked with a foreign key (scaleID). I want to fetch all that data into an array structure in one query such that the first dimension are all the scales with all the columns and nested within, all items of one scale all columns.</p> <p>Result would be something like that:</p> <pre><code>scale 1, scaleParam1, scaleParam2, ... ....item1, itemParam1, itemParam2, ... ....item2, itemParam1, itemParam2, ... scale 2, scaleParam2, scaleParam2, ... ....item1, itemParam1, itemParam2, ... ....item2, itemParam1, itemParam2, ... </code></pre> <p>So far I've done mainly left joins for one-to-one relationships. This is a one-to-many and I just can't wrap my mind around it. </p> <p>Is it a right join, could it also be done with a subquery, how to get the full outer rows into it as well...</p> <p>later I would like to iterate through it with to nested foreach loops.</p> <p>Maybe it's just that I have a headache...</p>
[ { "answer_id": 357241, "author": "OIS", "author_id": 36175, "author_profile": "https://Stackoverflow.com/users/36175", "pm_score": 1, "selected": false, "text": "//first get scales\nwhile ($row = fetchrowfunctionhere()) {\n $scale = $scales->createFromArray($row);\n}\n\n//then get ite...
2008/12/10
[ "https://Stackoverflow.com/questions/357122", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11995/" ]
357,138
<p>I want to add an ajax:TabContainer to my webpage. I don't get any build errors, but when I try to browse to the page, it gives me the error: "The Controls collection cannot be modified because the control contains code blocks (i.e. &lt;% ... %>).".</p> <p>I re-downloaded the Ajax Control Toolkit for the sample sites, opened the solution in VS, ran the sample for the TabContainer, and it worked fine. I thought it was perhaps a different version of the Ajax Control Toolkit - but no. The AjaxControlToolkit.dll files being referenced by the two sites are identical. Why can't I get the TabContainer to work on my site?</p> <p>There is one more issue, but I don't know whether it's related. I just recently installed Visual Studio 2008. As soon as I opened my website, VS automatically created the tab "AJAX Controls" in the toolbox and filled it with all the ajax controls. In the source code, all controls are prefixed with "ajax" - i.e., "&lt; ajax:TabContainer runat="server" ... >".</p> <p>However, when I opened the sample website, Visual studio created another tab in the toolbox - "AjaxControlToolkit Components", filled with all the same controls as in "AJAX Controls". I don't know why it added the same controls twice (but, strangely enough, with different icons for them in the toolbox). In the source code, all controls are prefixed with "ajaxToolkit" - i.e., "&lt; ajaxToolkit:TabContainer runat="server" ... >". What's going on here? I just want the darn TabContainer to work on my site.</p>
[ { "answer_id": 357592, "author": "Cybis", "author_id": 32998, "author_profile": "https://Stackoverflow.com/users/32998", "pm_score": 1, "selected": false, "text": "<head>" }, { "answer_id": 1058263, "author": "Keith", "author_id": 905, "author_profile": "https://Stack...
2008/12/10
[ "https://Stackoverflow.com/questions/357138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/32998/" ]
357,170
<p>I have a project and it needs to access a large amount of proprietary data in ASP.NET. This was done on the Linux/PHP by loading the data in shared memory. I was wondering if trying to use Memory Mapped Files would be the way to go, or if there is a better way with better .NET support. I was thinking of using the Data Cache but not sure of all the pitfalls of size of data being saved in the Cache.</p>
[ { "answer_id": 357217, "author": "Steven Behnke", "author_id": 42588, "author_profile": "https://Stackoverflow.com/users/42588", "pm_score": 1, "selected": false, "text": "byte[] fileBytes = Cache[\"fileBytes\"];\nif (null == fileBytes) {\n // reload the file and add it to the cache.\n...
2008/12/10
[ "https://Stackoverflow.com/questions/357170", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11907/" ]
357,190
<p>I'm trying to find the file size of a file on a server. The following code I got from <a href="http://www.thejackol.com/2005/06/11/aspnet-get-file-size/" rel="nofollow noreferrer">this guy</a> accomplishes that for your own server:</p> <pre><code>string MyFile = "~/photos/mymug.gif"; FileInfo finfo = new FileInfo(Server.MapPath(MyFile)); long FileInBytes = finfo.Length; long FileInKB = finfo.Length / 1024; Response.Write("File Size: " + FileInBytes.ToString() + " bytes (" + FileInKB.ToString() + " KB)"); </code></pre> <p>It works. However, I want to find the filesize of, for example:</p> <pre><code>string MyFile = "http://www.google.com/intl/en_ALL/images/logo.gif"; FileInfo finfo = new FileInfo(MyFile); </code></pre> <p>Then I get a pesky error saying <code>URI formats are not supported.</code></p> <p>How can I find the file size of Google's logo with ASP.NET?</p>
[ { "answer_id": 357220, "author": "mmx", "author_id": 33708, "author_profile": "https://Stackoverflow.com/users/33708", "pm_score": 4, "selected": true, "text": "WebRequest" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/357190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/557/" ]
357,203
<p>Because I am a newbie I am trying to log out any errors that may occur with stored procedures I write. I understand Try/Catch in SQL 2005 and error_procedure(), ERROR_MESSAGE() and the other built in functions. What I can't figure out how to do is capture what record caused the error on an update.</p> <p>I could probably use a cursor and loop through and update a row at a time. Then in the loop set a value and report on that value. But that seems to defeat the purpose of using SQL.</p> <p>Any ideas or pointer on where to research this issue greatly appreciated. I do not fully understand RowNumber() could I use that somehow? Kind of grasping at straws here.</p> <p>cheers and thanks </p> <p>Bob </p> <p>I am using SQL 2005.</p> <p>Edit</p> <p>I really do not want to use transactions for most of this, as it is just for reporting purposes. So an example of what I am doing is:</p> <pre><code>/****************************************************************************** Now get update the table with the current worker. That depends on the current status of the loan. ******************************************************************************/ UPDATE #table SET currWorker = tblUser.UserLogonName FROM tblUser JOIN tblLoanInvolvement ON tblLoanInvolvement.invlUnderwriterDeptID = tblUser.userID WHERE tblLoanInvolvement.LOANid = #table.loanid AND #table.currstatus in('R_UW_Approved','R_Submitted to Underwriting') UPDATE #table SET currWorker = tblUser.UserLogonName FROM tblUser JOIN tblLoanInvolvement ON tblLoanInvolvement.invlProcessorID = tblUser.userID WHERE tblLoanInvolvement.LOANid = #table.loanid AND #table.currstatus in('R_UW Approved With Conditions','R_Loan Resubmitted','R_UW_Suspended','R_Submitted to Processing') UPDATE #table SET currWorker = tblUser.UserLogonName FROM tblUser JOIN tblLoanInvolvement ON tblLoanInvolvement.invlCloserID = tblUser.userID WHERE tblLoanInvolvement.LOANid = #table.loanid AND #table.currstatus in('R_Docs Out','R_Ready to Close','R_Scheduled to Close and Fund','Scheduled To Close') </code></pre> <p>So if one row does not update correctly I do not want to loose the whole thing. But it would be very handy to know the value of #table.loanid that caused the problem. </p> <p>Thanks for your time.</p>
[ { "answer_id": 357345, "author": "rlb.usa", "author_id": 449902, "author_profile": "https://Stackoverflow.com/users/449902", "pm_score": -1, "selected": false, "text": "DECLARE @problemClientID INT\nBEGIN TRANSACTION\n\n UPDATE ... --etc\n\n IF @@ERROR <> 0\n BEGIN\n ROLL...
2008/12/10
[ "https://Stackoverflow.com/questions/357203", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18068/" ]
357,212
<p>What is the best and easiest way of taking HTML and converting it into a PDF, similar to use CFDOCUMENT on ColdFusion?</p> <p><strong>UPDATE:</strong> I really appreciate all the comments and suggestions that people have given so far, however I feel that people leaving their answers are missing the point.</p> <p>1) the solution has to be free or open sourced. one person suggested using pricexml and the other pd4ml. both of these solutions costs money (pricexml costing an arm and a leg) which i'm not about the fork over.</p> <p>2) they must be able to take in html (either from a file, url or a string variable) and then produce the pdf. libraries like prawn, rprf, rtex are produced using their own methods and not taking in html.</p> <p>please don't think i'm ungrateful for the suggestions, it's just that pdf generation seems like a really problem for people like me who use ColdFusion but want to convert to Rails.</p>
[ { "answer_id": 375689, "author": "Community", "author_id": -1, "author_profile": "https://Stackoverflow.com/users/-1", "pm_score": -1, "selected": false, "text": " String content = nextPage.generateResponse().contentString();\n\n content = content.replace(\"Print\", \"\");\n con...
2008/12/10
[ "https://Stackoverflow.com/questions/357212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/31278/" ]
357,243
<p>I am inputting a 200mb file in my application and due to a very strange reason the memory usage of my application is more than 600mb. I have tried vector and deque, as well as std::string and char * with no avail. I need the memory usage of my application to be almost the same as the file I am reading, any suggestions would be extremely helpful. Is there a bug that causes so much memory consumption? Could you pinpoint the problem or should I rewrite the whole thing?</p> <p>Windows Vista SP1 x64, Microsoft Visual Studio 2008 SP1, 32Bit Release Version, Intel CPU</p> <p>The whole application until now:</p> <pre><code>#include &lt;string&gt; #include &lt;vector&gt; #include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;fstream&gt; #include &lt;sstream&gt; #include &lt;iterator&gt; #include &lt;algorithm&gt; #include &lt;time.h&gt; static unsigned int getFileSize (const char *filename) { std::ifstream fs; fs.open (filename, std::ios::binary); fs.seekg(0, std::ios::beg); const std::ios::pos_type start_pos = fs.tellg(); fs.seekg(0, std::ios::end); const std::ios::pos_type end_pos = fs.tellg(); const unsigned int ret_filesize (static_cast&lt;unsigned int&gt;(end_pos - start_pos)); fs.close(); return ret_filesize; } void str2Vec (std::string &amp;str, std::vector&lt;std::string&gt; &amp;vec) { int newlineLastIndex(0); for (int loopVar01 = str.size(); loopVar01 &gt; 0; loopVar01--) { if (str[loopVar01]=='\n') { newlineLastIndex = loopVar01; break; } } int remainder(str.size()-newlineLastIndex); std::vector&lt;int&gt; indexVec; indexVec.push_back(0); for (unsigned int lpVar02 = 0; lpVar02 &lt; (str.size()-remainder); lpVar02++) { if (str[lpVar02] == '\n') { indexVec.push_back(lpVar02); } } int memSize(0); for (int lpVar03 = 0; lpVar03 &lt; (indexVec.size()-1); lpVar03++) { memSize = indexVec[(lpVar03+1)] - indexVec[lpVar03]; std::string tempStr (memSize,'0'); memcpy(&amp;tempStr[0],&amp;str[indexVec[lpVar03]],memSize); vec.push_back(tempStr); } } void readFile(const std::string &amp;fileName, std::vector&lt;std::string&gt; &amp;vec) { static unsigned int fileSize = getFileSize(fileName.c_str()); static std::ifstream fileStream; fileStream.open (fileName.c_str(),std::ios::binary); fileStream.clear(); fileStream.seekg (0, std::ios::beg); const int chunks(1000); int singleChunk(fileSize/chunks); int remainder = fileSize - (singleChunk * chunks); std::string fileStr (singleChunk, '0'); int fileIndex(0); for (int lpVar01 = 0; lpVar01 &lt; chunks; lpVar01++) { fileStream.read(&amp;fileStr[0], singleChunk); str2Vec(fileStr, vec); } std::string remainderStr(remainder, '0'); fileStream.read(&amp;remainderStr[0], remainder); str2Vec(fileStr, vec); } int main (int argc, char *argv[]) { std::vector&lt;std::string&gt; vec; std::string inFile(argv[1]); readFile(inFile, vec); } </code></pre>
[ { "answer_id": 357327, "author": "Edouard A.", "author_id": 41363, "author_profile": "https://Stackoverflow.com/users/41363", "pm_score": 4, "selected": true, "text": " HANDLE heaps[1025];\n DWORD nheaps = GetProcessHeaps((sizeof(heaps) / sizeof(HANDLE)) - 1, heaps);\n\n for (DWORD i ...
2008/12/10
[ "https://Stackoverflow.com/questions/357243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/28954/" ]
357,244
<p>One of my columns type is DateTime (Date Registered). I cannot create a query that filters all the data for eg. All registrations who registered on the 22/10/2008 between 18:00 and 20:00.</p> <p>Thanks</p>
[ { "answer_id": 357271, "author": "Mitchel Sellers", "author_id": 13279, "author_profile": "https://Stackoverflow.com/users/13279", "pm_score": 4, "selected": true, "text": "SELECT *\nFROM YourTable\nWHERE DateRegistered BETWEEN '10/22/2008 18:00:00' AND '10/22/2008 20:00:00'\n" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/357244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/44973/" ]
357,297
<p>The site I'm working on is done in Classic ASP, and I'm trying to do it as best as possible. I've abstracted it out into a Rails-like directory structure:</p> <pre> app_name - app - includes - helpers - lib - partials - public - stylesheets - images - javascripts </pre> <p>I've created some Rails-like helpers, for example:</p> <pre><code>Function ImageTag(ByVal imageFileName, ByVal altText) path = Server.MapPath(IMAGE_ROOT &amp; imageFileName &amp; ".jpg") ImageTag = "&lt;img src=""" &amp; path &amp; """ title=""" &amp; altText &amp; """ alt=""" &amp; altText &amp; """ /&gt;" End Function </code></pre> <p>Which is used thusly:</p> <pre><code>&lt;%= ImageTag("my_pic") %&gt; </code></pre> <p>With "IMAGE_ROOT" defined as "../public/images/" in a config file. I'm doing development on XP so the site is set as a virtual directory. However, the image won't load on the webpage at all. It's displaying the right path to it, because I can copy/paste it into my browser and view the image - it just won't display on the page for some reason. The same thing goes for my CSS stylesheet - the path is right but the page isn't rendering it at all.</p> <p>Any suggestions?</p>
[ { "answer_id": 357326, "author": "Jonathan Lonowski", "author_id": 15031, "author_profile": "https://Stackoverflow.com/users/15031", "pm_score": 2, "selected": false, "text": "Server.MapPath" } ]
2008/12/10
[ "https://Stackoverflow.com/questions/357297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40667/" ]
357,307
<p>How do I call the parent function from a derived class using C++? For example, I have a class called <code>parent</code>, and a class called <code>child</code> which is derived from parent. Within each class there is a <code>print</code> function. In the definition of the child's print function I would like to make a call to the parents print function. How would I go about doing this?</p>
[ { "answer_id": 357312, "author": "Greg Hewgill", "author_id": 893, "author_profile": "https://Stackoverflow.com/users/893", "pm_score": 8, "selected": false, "text": "Parent" }, { "answer_id": 357325, "author": "Andrew Rollings", "author_id": 40410, "author_profile": ...
2008/12/10
[ "https://Stackoverflow.com/questions/357307", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17337/" ]
357,314
<p>I am using Cygwin with a dll version of 1.5.19 (yes, out-of-date, I know, but we're doing it for configuration control reasons). All my files (existing and newly created) show up with permissions 644, despite a umask of 022. Also, using chmod doesn't change the permissions. I have ntsec set in the CYGWIN environment variable. I need to be able to add execute permissions; is there anything I can try to fix this or is it a lost cause?</p> <hr> <p>A much later note: I realized that a key part of the problem is that the files I was trying to chmod were in a ClearCase dynamic view, which uses MVFS. I still have not found way to successfully set the execute permissions, though.</p>
[ { "answer_id": 357572, "author": "Ken Gentle", "author_id": 8709, "author_profile": "https://Stackoverflow.com/users/8709", "pm_score": 2, "selected": false, "text": "/etc/passwd" }, { "answer_id": 1599607, "author": "Community", "author_id": -1, "author_profile": "ht...
2008/12/10
[ "https://Stackoverflow.com/questions/357314", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5241/" ]
357,315
<p>I'd like to find a Windows batch counterpart to Bash's <code>$@</code> that holds a list of all arguments passed into a script. </p> <p>Or I have to bother with <code>shift</code>?</p>
[ { "answer_id": 357338, "author": "dancavallaro", "author_id": 42891, "author_profile": "https://Stackoverflow.com/users/42891", "pm_score": 7, "selected": false, "text": "%*" }, { "answer_id": 382312, "author": "matt wilkie", "author_id": 14420, "author_profile": "htt...
2008/12/10
[ "https://Stackoverflow.com/questions/357315", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15647/" ]