instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>Lets say you have a property like:</p> <pre><code>Person person1; public Person Captin{ get{ return person1; } set{ person1 = value; } } public void SomeFunction(){ Captin.name = "Hook" } </code></pre> <p>In this case if you set the name on the property we know that the new n...
<p>Each time you access your property Captin it will read from disk. But if you change the property 'name' it will not write to disk. It will only write to disk if you do something like</p> <pre><code>public void SomeFunction() { Person p = Captin; p.name = "Hook"; Captin = p; } </code></pre>
<p>The property's setter will only be called when someone actually assigns to it directly.</p> <p>As for whether your code is okay or not: it's a matter of documentation.</p> <p>Whenever you have a property which returns something mutable, you ought to indicate whether what mutations to it will do. Are you returning ...
39,357
<p>I'm developing a website which will be used in the corporate intranet which uses JCIFS and NTLM to automatically authenticate the users without asking them to log on. Everything seems to be working in IE 6, but some users are being prompted for their passwords in IE 7. </p> <p>We've had some success by getting th...
<p>If you access an intranet Web site by using an IP address or a fully qualified domain name , or a url with a dot in it the Web site may be identified as in the Internet zone instead of in the Local intranet zone.</p> <p><a href="http://support.microsoft.com/kb/303650" rel="nofollow noreferrer">http://support.micros...
<p>If you access an intranet Web site by using an IP address or a fully qualified domain name , or a url with a dot in it the Web site may be identified as in the Internet zone instead of in the Local intranet zone.</p> <p><a href="http://support.microsoft.com/kb/303650" rel="nofollow noreferrer">http://support.micros...
4,229
<p>I have to choose an online WYSIWYG editor. I'm pending between <a href="http://tinymce.moxiecode.com/" rel="nofollow noreferrer">TinyMCE</a> and <a href="http://trac.xinha.org/" rel="nofollow noreferrer">Xinha</a>. My application is developed in Asp.Net 3.5. Could you help me with with some pros and cons? </p>
<p>Haven't tried Xihna myself, but I have experience with TinyMCE and FCKeditor. In my company we switched to TinyMce (from FCKeditor) due to the superior support for pasting from word documents and the (relatively easy to work with) plugin architecture which we used to add some custom modules (links browser, simple fi...
<p>I've never used Xinha, but I can vouch for TinyMCE. It's fast, scales well, and is infinitely customizable. I particularly like the dynamic loading of functionality, which means you only take the performance hit for the stuff you use.</p> <p>It also includes language-specific <a href="http://wiki.moxiecode.com/inde...
7,124
<p>Exactly as the question states: How can you check if a variable in PHP contains a file pointer? Some like <code>is_string()</code> or <code>is_object()</code>.</p>
<p>You can use <code>get_resource_type()</code> - <a href="http://us3.php.net/manual/en/function.get-resource-type.php" rel="noreferrer">http://us3.php.net/manual/en/function.get-resource-type.php</a>. The function will return FALSE if its not a resource at all.</p> <pre><code>$fp = fopen("foo", "w"); ... if(get_reso...
<p>You can use <a href="http://www.php.net/manual/en/function.stream-get-meta-data.php" rel="nofollow noreferrer"><code>stream_get_meta_data()</code></a> for this.</p> <pre><code>&lt;?php $f = fopen('index.php', 'r'); var_dump(stream_get_meta_data($f)); ?&gt; array 'wrapper_type' =&gt; string 'plainfile' (length=9)...
41,678
<p>I am invoking an external process by using System.Diagonistics.Process and passing two filenames as parameters. Now some time this process terminates due to exceptions and it seems that files handle are not being released by the process. How can i release the resources occupied by the process.</p>
<p>What is making you think that file handles are not being released? Since you are starting a process which is external to your application you don't have much control over what the other process is going to do when it terminates abnormally.</p>
<p>How are you detecting that file handles are not being released by the dying process?</p> <p>All resources should be released by a process that dies for any reason. If they aren't, then it is a bug that should be filed with Microsoft.</p>
25,849
<p>HTML (or maybe just XHTML?) is relatively strict when it comes to non-standard attributes on tags. If they aren't part of the spec, then your code is considered non-compliant.</p> <p>Non-standard attributes can be fairly useful for passing along meta-data to Javascript however. For instance, if a link is suppose to...
<p>I am a big fan of the proposed HTML 5 solution (<code>data-</code> prefixed attributes). Edit: I'd add that there are probably better examples for the use of custom attributes. For instance, data that a custom application will use that have no analogue in standard attributes (eg. customization for event handlers bas...
<p>My personal feeling in your example is that the span route is more appropriate, as it meets the standards of the XHTML specification. However, i can see an argment for custom attributes, but I think they add a level of confusion that isn't needed.</p>
25,702
<p>I am looking to display an array from 128 to 512 bytes in size of hexadecimal data (0x00 to 0xFF) in a 16 X n grid-like display. It needs the capability of selecting a single element or group of elements and highlighting the data in some way. It also needs to allow editing. I'm writing this in C# 3,5 using Winform...
<p>Take a look at the DataGridView.</p> <p>You'd need to break this up into the constituent cells, but it definitely is great for putting together a grid of data (like Excel).</p>
<p>better approach will be to create a custom control like little label, with all the bells and whistles to show highlighted one and editing and putting all of these in custom container like panel. you can specify row and column for your custom label for easier layout.</p>
24,167
<p>Hey all I'm hoping someone has enough experience with Cake PHP to make this work. </p> <p>I'm working on something that at the moment could affectionately be called a twitter clone. Essentially I have a set up like this. </p> <p>Users have many friends. This is a many to many relationship to the user table. It is ...
<p>If all you need in the results of the query is a list of tips, I'd be tempted to do this in 2 queries. The first to find a list of user ids of this user and their friends, the second to find the tips that belong to any one of these ids. So, in your Tip model:</p> <pre><code>function findTipsByUserAndFriends($userId...
<p>In CakePHP speak, many to many is "Has And Belongs To Many" (HABTM). Assuming you've set up the relations properly, what you then need to do is have a two level recursive find, such that the friend you find on retrieves all of their friends, and those friends get their tips loaded. You may have to dynamically bind/u...
23,868
<p>I might be one anal programmer, but I like code that looks good from a distance. I just found myself lining up a CSS style so that instead of this:</p> <pre><code>#divPreview { text-align: center; vertical-align: middle; border: #779 1px solid; overflow: auto; width: 210px; height: 128px; ...
<p><b>Any code style that makes you reorder things when code changes is bad.</b></p> <p>It would screw up diffs. You are using a version control system right?</p> <p>There's a few other things that would make your code prettier, but screw up diffs.</p> <p>Imagine this code:</p> <pre><code>int foo = 42; int fooBar ...
<p>One small stylistic quirk that actually lends a hand in ensuring correctness is to put any constants on the left side of an if check. This completely prevents the accidental use of assignment-equals instead of comparison-equals.</p> <p>Saying</p> <pre><code>if (3.14159 == foo) { //Do stuff } </code></pre> <p>may...
37,083
<p>My Facebook application contains Javascript that works in Firefox and IE, but aborts in Chrome.</p> <p>In the Javascript console it gives several errors.including:</p> <pre><code>Uncaught TypeError: Object onloadhooks has no method 'replace' </code></pre> <p>There are similar errors complaining about a missing me...
<p>According to the Chrome developers (<a href="http://code.google.com/p/chromium/issues/detail?id=1717" rel="nofollow noreferrer">Issue 1717</a>), this is an issue with the Facebook FBJS library, and something they plan to escalate to Facebook.</p> <p>I don't have a workaround for this in the meantime.</p>
<p>Facebook itself has problems in Chrome. On some pages the buttons just don't work (like deleting a news entry on your own page).</p>
37,720
<p>Recently saw someone commending another user on their use of sizeof var instead of sizeof(type). I always thought that was just a style choice. Is there any significant difference? As an example, the lines with f and ff were considered better than the lines with g and gg:</p> <pre><code> typedef struct _foo {} foo;...
<p>If the type of the variable is changed, the sizeof will not require changing if the variable is the argument, rather than the type.</p> <p>Regarding @icepack's comment: the possibility or likelihood of change for type vs. variable name is not the issue. Imagine the variable name is used as the the argument to sizeo...
<p>Taking the sizeof a variable can have unexpected results. When the variable is an array, sizeof(array) will return the size of the array, not the size of an individual element or the size of a pointer. Taking the size of a pointer will return the size of a pointer. But since arrays are usually represented as poin...
48,809
<p>Are C++ enums signed or unsigned? And by extension is it safe to validate an input by checking that it is &lt;= your max value, and leave out >= your min value (assuming you started at 0 and incremented by 1)?</p>
<p>You shouldn't rely on any specific representation. Read the following <a href="http://www.parashift.com/c++-faq-lite/newbie.html#faq-29.19" rel="noreferrer">link</a>. Also, the standard says that it is implementation-defined which integral type is used as the underlying type for an enum, except that it shall not b...
<p>While some of the above answers are arguably proper, they did not answer my practical question. The compiler (gcc 9.3.0) emitted warnings for:</p> <pre><code>enum FOO_STATUS { STATUS_ERROR = (1 &lt;&lt; 31) }; </code></pre> <p>The warning was issued on use:</p> <pre><code>unsigned status = foo_status_get(); if (...
19,240
<p>Here is the problem: </p> <p>for your reference:</p> <p><img src="https://i.stack.imgur.com/mmrNH.jpg" alt="http://i.stack.imgur.com/mmrNH.jpg"></p> <p>database entries 1,2 and 3 are made using jython 2.2.1 using jdbc1.2. database entry 4 is made using vb the old to be replace program using odbc.</p> <p>We have ...
<p>It's a matter of practice.</p> <p>Here's an interesting read.</p> <ol> <li><p><a href="http://stevesmithblog.com/blog/codebehind-files-in-asp-net-mvc-are-evil/" rel="nofollow noreferrer">Codebehind files are evil</a></p></li> <li><p><a href="http://msmvps.com/blogs/luisabreu/archive/2008/09/19/codebehind-files-in-...
<p>You can use code behind as well. It is only a matter of style preference.</p>
46,284
<p>It's something that's bugged me in every language I've used, I have an if statement but the conditional part has so many checks that I have to split it over multiple lines, use a nested if statement or just accept that it's ugly and move on with my life.</p> <p>Are there any other methods that you've found that mig...
<p>Separate the condition in several booleans and then use a master boolean as the condition.</p> <pre><code>bool isOpaque = object.Alpha == 1.0f; bool isDrawable = object.CanDraw &amp;&amp; object.Layer == currentLayer; bool isHidden = hideList.Find(object); bool isVisible = isOpaque &amp;&amp; isDrawable &amp;&amp;...
<p>If you do this:</p> <pre><code>if (var1 == true) { if (var2 == true) { if (var3 == true) { ... } } } </code></pre> <p>Then you can also respond to cases where something isn't true. For example, if you're validating input, you could give the user a tip for how to properly format ...
2,793
<p>In programming we face various situations where we are required to make use of intermediate STL containers as the following example depicts:</p> <pre><code>while(true) { set &lt; int &gt; tempSet; for (int i = 0; i &lt; n; i ++) { if (m.size() == min &amp;&amp; m.size() &lt;= max) { ...
<p>The first version is correct. It is simpler in almost every way. Easier to write, easier to read, easier to understand, easier to maintain, etc....</p> <p>The second version <em>may</em> be faster, but then again it may not. You would need to show that it had a significant advantage before using it. In most non...
<p>I think you can preallocate a certain number of elements for STL containers, thus having a constant memory allocation cost if you know how many elements will be in the container.</p>
26,690
<p>I'm looking for a .NET regular expression extract all the URLs from a webpage but haven't found one to be comprehensive enough to cover all the different ways you can specify a link. </p> <p>And a side question:</p> <p>Is there <strong>one regex to rule them all</strong>? Or am I better off using a series of less ...
<pre><code>((mailto\:|(news|(ht|f)tp(s?))\://){1}\S+) </code></pre> <p>I took this from <a href="http://regexlib.com/Search.aspx?k=URL" rel="nofollow noreferrer">regexlib.com</a></p> <p>[editor's note: the {1} has no real function in this regex; <a href="https://stackoverflow.com/questions/13470/question-about-specif...
<p>URL's? As in images/scripts/css/etc.?</p> <blockquote> <p><code>%href="(.["]*)"%</code></p> </blockquote>
2,798
<p>We're using Perforce and Visual Studio. Whenever we create a branch, some projects will not be bound to source control unless we use "Open from Source Control", but other projects work regardless. From my investigations, I know some of the things involved:</p> <p>In our .csproj files, there are these settings:</p> ...
<h1>Introduction</h1> <p>I would disagree with the claim that Perforce integration in Visual Studio is "terrible". Rather, I'd define it as "out of the box experience is less than optimal" :-). The following sections discuss my understanding of the integration and recommendations for project/solution setup.</p> <p>If...
<p>This is not a Perforce issue, it is a Visual Studio issue. The ridiculous requirement that source files be modified to allow Visual Studio to understand that there is an SCM tool in use is idiotic.</p> <p>The simple answer is 'stop using the Visual Studio source control integration'. It just plain sucks. Even with ...
32,701
<p>Ok, so I'm binding a DataGridView to a BindingSource in a background thread while a little, "Please Wait" model window keeps the user entertained. No problem. </p> <p>However, I need to change some of the rows background colors based on the row's databounditem type. Like this:</p> <pre><code>for (int i = 0; i &lt...
<p>If it's just a simple value you need, I'd simple use Json (JQuery has a dedicated method for that : <a href="http://docs.jquery.com/Ajax/jQuery.getJSON" rel="nofollow noreferrer">$.getJSON()</a>).</p> <p>So no, you don't need your ASP page to return a full html page, just the value in simple JSON notation.</p>
<p>Using AJAX, you can return anything, even binary data. Although it was designed for XML, you can use it for anything you can transfer across a web server. However, HTTP Requests are expensive, so don't abuse them too much!</p>
32,458
<p>I know of <code>is</code> and <code>as</code> for <code>instanceof</code>, but what about the reflective <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#isInstance(java.lang.Object)" rel="noreferrer">isInstance()</a> method?</p>
<pre><code>bool result = (obj is MyClass); // Better than using 'as' </code></pre>
<p>just off the top of my head, you could also do:</p> <pre><code>bool result = ((obj as MyClass) != null) </code></pre> <p>Not sure which would perform better. I'll leave it up to someone else to benchmark :)</p>
35,770
<p>I'm writing a CESetup.dll for a Windows Mobile app. It must be unmanaged, which I have little experience with. So I'm unsure of whether I should free the memory I allocate and how I do it.</p> <p>Here's the function I've written:</p> <pre><code> Uninstall_Init( HWND hwndParent, LPCTSTR pszIns...
<p>I think you want to use this:</p> <pre><code>delete [] folderPath; </code></pre> <p>It looks like you're allocating an array of TCHARs, which makes sense since it's a string. When you allocate an array, you must delete using the array delete operator (which you get by including the brackets in the delete statemen...
<p>Yes, you should. By calling </p> <pre><code> delete[] folderPath; </code></pre> <p>at the end of your function. All memory assigned with <code>new</code> must be freed with <code>delete</code>.</p>
29,731
<p>My "Start debugging" button and element menu are greyed out... but only on one of my projects (an ASP.NET website). I have no idea what I have done to disable it.</p> <p>I already checked everything in the Property page of both the solution and project. I even compared it to another project, but nothing seems to do...
<p>It sounds like your startup projects are all set to "start without debugging", since that would cause the button and element to grey out.</p> <p>This can be fixed from Solution -> Set StartUp Projects.</p>
<p>Right click on the project and click properties. Then click on Start Options (or something similar) to see the settings. If it's an executable project, you probably want to choose the option that will start the project output.</p>
21,498
<p>I want my JTextPane to insert spaces whenever I press Tab. Currently it inserts the tab character (ASCII 9). </p> <p>Is there anyway to customize the tab policy of JTextPane (other than catching "tab-key" events and inserting the spaces myself seems an)?</p>
<p>You can set a javax.swing.text.Document on your JTextPane. The following example will give you an idea of what I mean :)</p> <pre><code>import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JTextPane; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import java...
<p>As far as I know, you'd have to catch key events, as you say. Depending on usage, you might also get away with waiting until the input is submitted, and changing tabs to spaces at that time.</p>
47,489
<p>I'm starting a new application and looking at using an ORM -- in particular, SQLAlchemy.</p> <p>Say I've got a column 'foo' in my database and I want to increment it. In straight sqlite, this is easy:</p> <pre><code>db = sqlite3.connect('mydata.sqlitedb') cur = db.cursor() cur.execute('update table stuff set foo ...
<p>SQLAlchemy's ORM is meant to be used together with the SQL layer, not hide it. But you do have to keep one or two things in mind when using the ORM and plain SQL in the same transaction. Basically, from one side, ORM data modifications will only hit the database when you flush the changes from your session. From the...
<p>Withough testing, I'd try:</p> <pre><code>for c in session.query(Stuff).all(): c.foo = c.foo+1 session.commit() </code></pre> <p>(IIRC, commit() works without flush()).</p> <p>I've found that at times doing a large query and then iterating in python can be up to 2 orders of magnitude faster than lots of quer...
34,053
<p>I want to make a prototype of a website. Is there any visio stencil which gives a hand drawn look to the prototype? I found one such template with few shapes, but these are not enough to easily create a prototype:</p> <p><a href="http://www.visguy.com/2008/08/20/indexed-shapes-for-that-hand-drawn-look/" rel="nofoll...
<p>You should check out <a href="http://www.balsamiq.com/products/mockups" rel="nofollow noreferrer">Balsamiq Mockups</a> - excellent!</p>
<p>Pencil, Paper, Scissors and Pritt-Stick and Scanner.</p> <p>Is this really what you should be spending your employer's money doing?</p>
46,480
<p><a href="https://pmd.github.io/" rel="noreferrer">PMD</a> would report a violation for:</p> <pre><code>ArrayList&lt;Object&gt; list = new ArrayList&lt;Object&gt;(); </code></pre> <p>The violation was "Avoid using implementation types like 'ArrayList'; use the interface instead".</p> <p>The following line would co...
<p>Using interfaces over concrete types is the key for good encapsulation and for loose coupling your code.</p> <p>It's even a good idea to follow this practice when writing your own APIs. If you do, you'll find later that it's easier to add unit tests to your code (using Mocking techniques), and to change the underly...
<p>Interface is exposed to the end user. One class can implement multiple interface. User who have expose to specific interface have access to some specific behavior which are defined in that particular interface.</p> <p>One interface also have multiple implementation. Based on the scenario system will work with diffe...
17,755
<p>I have used a static global variable and a static volatile variable in file scope, <p> both are updated by an ISR and a main loop and main loop checks the value of the variable. <p>here during optimization neither the global variable nor the volatile variable are optimized. So instead of using a volatile variable a ...
<p>They are different things. I'm not an expert in volatile semantics. But i think it makes sense what is described here.</p> <h3>Global</h3> <p>Global just means the identifier in question is declared at file-scope. There are different scopes, called function (where goto-labels are defined in), file (where globals r...
<p>volatile variable means that the value assinged to it is not constant, i.e if a function containing a volatile variable "a=10" and the function is adding 1 in each call of that function then it will always return updated value. <code>{ volatile int a=10; a++; }</code> when the above function is called again and agai...
45,061
<p>I need to come up with an analysis of simultaneus events, when having only starttime and duration of each event.</p> <p><strong>Details</strong></p> <p>I've a standard CDR call detail record, that contains among others:</p> <ul> <li>calldate (timedate of each call start</li> <li>duration (int, seconds of call dur...
<p>I would implement this on the database. Using a GROUP BY clause with DATEPART, you could get a list of simultaneous calls for whatever time period you wanted, by second, minute, hour, whatever.</p> <p>On the web side, you would only have to display the histogram that is returned by the query.</p>
<p>@eric-z-beard: I would really like to be able to implement this on the database. I like your proposal, and while it seems to lead to something, I dont quite fully understand it. Could you elaborate? Please recall that each call will span over several seconds, and each second need to count. If using DATEPART (or some...
7,339
<p>We are developing a number of games on multiple paltforms (DS/Wii/Xbox 360/PS3/PC/PSP). Each has their own compiler/linker and debugger. We want to use Visual Studio as the IDE and to manage the build process but use the platform specific compilers (and settings) to generate the appropriate output. We could manage t...
<p>CMake doesn't do what I'm after. To be clear - when I say "manage the build process" I mean, anyone can grab the project from the repository then from within VS select the platform, compile/run, add files, change settings, etc and it all work by magic ;) So to answer my own question, after a bit of digging this is w...
<p>Seconded the recommendation for CMake, with the caveat that you're not going to be able to manage projects in VS for <em>other</em> platforms. It's just not written to manage library paths, defines, etc etc for anything other than the current project/target/platform. You'll almost certainly need to say "platform X's...
41,442
<p>Does anyone have any idea what is wrong with this create statement for mysql? </p> <p>EDIT: now it states the error is near: revised VARCHAR(20), paypal_accept TINYINT, pre_terminat' at line 4</p> <p>Thanks for the help everyone</p> <p>Still errors after using sql beautifier though</p> <pre><code>CREATE TABLE A...
<pre><code>watch VARCHAR(20), **????** VARCHAR(20), auction_type VARCHAR(20), </code></pre> <p>Between watch and auction_type you have missed a column name. Only the varchar(20) is there, either delete that or add in missing column name.</p>
<p>The answer about the missing field name is correct (would vote it up if I had the rep) but I would also recommend placing the following line after 'cat_2_id VARCHAR(20)':</p> <pre><code>PRIMARY KEY (`article_no`) </code></pre>
30,670
<p>We're building a CMS. The site will be built and managed by the users in aspx pages, but we would like to create a static site of HTML's. The way we're doing it now is with code I found <a href="http://forums.asp.net/p/931180/1092188.aspx#1092188" rel="nofollow noreferrer">here</a> that overloads the Render method ...
<p>Calling the <code>Render</code> method is still pretty simple. Just create an instance of your page, create a stub <code>WebContext</code> along with the <code>WebRequest</code> object, and call the <code>Render</code> method of the page. You are then free to do whatever you want with the results.</p> <p>Alternativ...
<p>@ckarras: I would rather not use an external tool, because I want the HTML pages to be created programmatically and not manually.</p> <p>@jttraino: I don't have a time interval in which the site needs to be outputted- the uotput has to occur when a user creates a new site.</p> <p>@Frank Krueger: I don't really und...
8,017
<p>Can anyone point me in the right direction of some facial recognition libraries &amp; algorithms ? I've tried searching/googling but i mostly find thesises and very little real software. </p>
<p>How about <a href="http://www.owlnet.rice.edu/~elec301/Projects99/faces/index.html" rel="noreferrer">Eigenfaces</a>? Utilizes simple mathematics to store recognizable eigenvector of the face and reconstruct faces using multiple vectors.</p> <p>The code is all available in Python as well <a href="http://www.owlnet.r...
<p>I find <a href="http://www.luxand.com/" rel="nofollow">Luxand Facesdk</a> the best for Face recognition and identification.</p>
46,001
<p>I would like to rename files and folders recursively by applying a string replacement operation.</p> <p>E.g. The word "shark" in files and folders should be replaced by the word "orca".</p> <p><code>C:\Program Files\Shark Tools\Wire Shark\Sharky 10\Shark.exe</code> </p> <p>should be moved to:</p> <p><code>C:\Pro...
<p>So you would use recursion. Here is a powershell example that should be easy to convert to C#:</p> <pre><code>function Move-Stuff($folder) { foreach($sub in [System.IO.Directory]::GetDirectories($folder)) { Move-Stuff $sub } $new = $folder.Replace("Shark", "Orca") if(!(Test-Path($new))...
<pre><code>string oldPath = "\\shark.exe" string newPath = oldPath.Replace("shark", "orca"); System.IO.File.Move(oldPath, newPath); </code></pre> <p>Fill in with your own full paths</p>
3,765
<p>I'm giving a presentation to a Java User's Group on Groovy and I'm going to be doing some coding during the presentation to show some side-by-side Java/Groovy. I really like the GroovyConsole as it's simple and I can resize the text easily. </p> <p>I'm wondering if there is anything similar for Java? I know I co...
<p><a href="http://www.drjava.org/" rel="nofollow noreferrer">DrJava</a> is your best bet. It also has an <a href="http://www.drjava.org/eclipse.shtml" rel="nofollow noreferrer">Eclipse plugin</a> to use the interactions pane like GroovyConsole.</p>
<p>Why not use the GroovyConsole ? Groovy accepts the vast majority of Java syntax</p>
5,003
<p>Visual Studio 2008 w/Sp1</p> <p>To reproduce my problem I simply create a new .Net 2.0 web application and add a page with the following markup:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication5._Default" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//...
<p>Here's a UDF that will do the trick...</p> <pre><code>create function ProperCase(@Text as varchar(8000)) returns varchar(8000) as begin declare @Reset bit; declare @Ret varchar(8000); declare @i int; declare @c char(1); if @Text is null return null; select @Reset = 1, @i = 1, @Ret = ''; while (...
<p>I know the devil is in the detail (especially where people's personal data is concerned), and that it would be very nice to have properly capitalised names, but the above kind of hassle is why the pragmatic, time-conscious amongst us use the following: </p> <p><code>SELECT UPPER('Put YoUR O'So oddLy casED McWeird-n...
28,491
<p>A co-worker has a C program that fails in a predictable manner because of some corrupted memory. He'd like to use <code>dbx</code> to monitor the memory location once it's allocated in order to pinpoint the code that causes the corruption.</p> <p>Is this possible? If so what is the syntax to produce a breakpoint ...
<p>Having looked more deeply, it appears the solution on recent versions of <code>dbx</code> is something like:</p> <pre><code>stop access w &lt;address&gt;, &lt;size&gt; </code></pre> <p>Since <code>&lt;address&gt;</code> and <code>&lt;size&gt;</code> can be expressions, you can write commands like:</p> <pre><code>...
<p>I'm no Solaris dev, but you can do this with gdb and hardware breakpoints</p>
45,700
<p>I am working on a Customer Server Control that extends another control. There is no problem with attaching to other controls on the form.</p> <p>in vb.net: <code>Parent.FindControl(TargetControlName)</code></p> <p>I would like to pass a method to the control in the ASPX markup. </p> <p>for example: <code>&lt;c:...
<p>If you want to be able to pass a method in the ASPX markup, you need to use the <code>Browsable</code> attribute in your code on the event.</p> <p>VB.NET</p> <pre class="lang-vb prettyprint-override"><code>&lt;Browsable(True)&gt; Public Event InitializeStuffCallback </code></pre> <p>C#</p> <pre><code>[Browsable(...
<p>Your workaround is actually the better answer. If you have code that you must run at a certain part of your control's lifecycle, you <strong>should</strong> expose events to let the container extend the lifecycle with custom functionality.</p>
5,315
<p>When I use Build->Publish Web Site in Visual Studio 2008, most of the time it compiles the site, and then simply asks me "All files in the target folder will be deleted. Continue?" (or something to that effect). On occasion, however, when publishing a project in Visual Studio, I would get a dialog box that would giv...
<p><strong>John is right</strong>, the only difference is one of your projects is a <a href="http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx" rel="nofollow noreferrer">Web Site Project</a> and the other is a <a href="http://msdn.microsoft.com/en-us/library/aa730880(VS.80).aspx#wapp_topic5" rel="nofollow no...
<p><strong>The site has been updated from the site in the updated layer.</strong></p>
46,652
<p>Finding out what's selected in real browsers is as simple as:</p> <pre><code>var range = { start: textbox.selectionStart, end: textbox.selectionEnd } </code></pre> <p>But IE, as usual, doesn't understand. What's the best cross-browser way to do this?</p>
<p>I'll post this function for another time, seeing as this question got linked to from another one.</p> <p>The following will do the job in all browsers and deals with all new line problems without seriously compromising performance. I've arrived at this after <a href="https://stackoverflow.com/questions/3622818/ies-...
<p>From <a href="https://github.com/winmarkltd/BootstrapFormHelpers/blob/0d89ab451ded3a4c6a47acb0e4bf023504a94434/js/bootstrap-formhelpers-phone.js" rel="nofollow">BootstrapFormHelpers</a></p> <pre><code> function getCursorPosition($element) { var position = 0, selection; if (document.selection) { ...
29,143
<p>I am about to add a section to an ASP.NET app (VB.NET codebehind) that will allow a user to get data returned to them as an Excel file, which I will generate based on database data. While there are several ways of doing this, each has its own drawbacks. How would <em>you</em> return the data? I'm looking for some...
<h2>CSV</h2> <p>Pros: </p> <ul> <li>Simple</li> </ul> <p>Cons: </p> <ul> <li>It may not work in other locales or in different Excel configurations (i.e. List separator) </li> <li>Can't apply formatting, formulas, etc</li> </ul> <h2>HTML</h2> <p>Pros: </p> <ul> <li>Still pretty Simple </li> <li>Supports simple ...
<p>If you have to use Excel instead of a CSV file you will need to use OLE automation on an Excel instance one the server. The easiest way to do this is to have a template file and programatically fill it in with the data. You save it to another file.</p> <p>Tips:</p> <ul> <li>Don't do it interactively. Have the u...
18,116
<p>I have a Person object with two constructors - one takes an int (personId), the other a string (logonName). I would like another constructor that takes a string (badgeNumber). I know this can't be done, but seems it might be a common situation. Is there a graceful way of handling this? I suppose this would apply...
<p>You might consider using custom types.</p> <p>For example, create LogonName and BadgeNumber classes.</p> <p>Then your function declarations look like...</p> <pre><code>public Person(LogonName ln) { this.Load(ln.ToString()); } public Person(BadgeNumber bn) { //load logic here... } </code></pre> <p>Such a...
<p>How about ...</p> <pre><code>public Person(int personId) { this.Load(personId); } public Person(string logonName) { this.Load(logonName); } public Person(Object badgeNumber) { //load logic here... } </code></pre>
5,111
<p>I would like to generate a random floating point number between 2 values. What is the best way to do this in C#?</p>
<p>The only thing I'd add to <a href="https://stackoverflow.com/questions/44408/how-do-you-generate-a-random-number-in-c#44428">Eric</a>'s response is an explanation; I feel that knowledge of why code works is better than knowing what code works.</p> <p>The explanation is this: let's say you want a number between 2.5 ...
<p>How random? If you can deal with pseudo-random then simply:</p> <pre><code>Random randNum = new Random(); randNum. NextDouble(Min, Max); </code></pre> <p>If you want a "better" random number, then you probably should look at the Mersenne Twister algorithm. Plenty of people hav <a href="http://code.msdn.microsoft...
6,619
<p>We recently upgraded to Castor 1.2 from version 0.9.5.3 and we've noticed a dramatic drop in performance when calling unmarshal on XML. We're unmarshaling to java classes that were generated by castor in both cases. For comparison, using identical XML the time for the XML unmarshal call used to take about 10-20ms ...
<p>We had very serious performance issues by using castor 1.0.5, with .castor.cdr file (a few seconds to unmarshal, whereas it took milliseconds by the past).</p> <p>It appeared that the .castor.cdr generated file contained old/wrong values (inexisting types and descriptor). After deleting the incriminated lines in th...
<p>I too have this issue, when generating a basic customer/address set of XML it takes around 3s to generate a document including 74 customers.</p> <p>Reverting to 1.0.4 (for testing) sees this return to 1.4s,</p> <p>But hand rolling the XML sees the output at under 40ms.. I know the frameworks add some overhead, bu...
27,441
<p>Specifically, I want to listen to when programs are run and record information such as: timestamp, executable, windows name and user.</p>
<p>Alternatively, use the WMI interface to find out what's running and take appropriate action. In the VBScript code below the WMI subsystem is being queried with <code>Select * from Win32_Process</code> so as to change the process priority. Find out what other attributes are available for <code>Win32_Process</code> an...
<p>Look into using the Perfmon API's (check MSDN for references).</p>
22,503
<p>I have used Photoshop CS2's "Save for Web" feature to create a table of images for my site layout.</p> <p>This HTML appears fine in a web browser, however when imported into Visual Studio and viewed in the site designer, the metrics are wrong and there are horizontal gaps between images (table cells).</p> <p>The o...
<p>You can directly bind to the static object created by Visual Studio.</p> <p>In your windows declaration add:</p> <pre><code>xmlns:p="clr-namespace:UserSettings.Properties" </code></pre> <p>where <code>UserSettings</code> is the application namespace.</p> <p>Then you can add a binding to the correct setting:</p> ...
<p>Also read <a href="http://www.hanselman.com/blog/LearningWPFWithBabySmashConfigurationWithDataBinding.aspx" rel="nofollow noreferrer">this</a> article on how it is done in BabySmash</p> <p>You only need to back the Settings with DO (Like Alan's example) if you need the change notification! binding to the POCO Setti...
18,677
<p>I am curious if anyone has done a comparison between the different options out there. So far I am leaning towards using Moo.fx because loading prototype.js just to use scriptaculous seems a bit much. Does that make sense? Are there any other effects libraries worth trying? Thanks.</p>
<p>"Smart GWT" has interesting effects, especially to mimic desktop items. I pass the ShowCase: <a href="http://www.smartclient.com/smartgwt/showcase/#main" rel="nofollow">Smart GWT Showcase</a></p>
<p>I would recommend <a href="http://jquery.com/" rel="nofollow noreferrer">jquery</a>. It's small, accessible from Google as an <a href="http://code.google.com/apis/ajaxlibs/" rel="nofollow noreferrer">ajax library API</a>, and its speedy.</p>
23,276
<p>Due to continuing crash problems, I'm about to uninstall and reinstall my copy of Visual Studio 2005. I know that just running the uninstaller leaves a lot of resources and settings on my machine and would like to be able to reinstall from a pristine state.</p> <p>Is there any way to completely uninstall VS2k5 from...
<p>Visual Studio 2005 is known for not uninstalling so well (especially the Express editions). Use the technique found <a href="http://support.microsoft.com/kb/907965" rel="nofollow noreferrer">here</a> to manually uninstall all of Visual Studio.</p>
<p>A hell of a lot of luck. I have tried many times to pull this off and each time I ended up just restoring to before I installed it or doing a fresh install.</p>
16,497
<p>I would like to replace "&amp;gt" with ">" and "&amp;lt" with "&lt;" but only when they occur outside "&lt;pre>" and "&lt;/pre>". Is this possible?</p> <pre><code>$newText = preg_replace('&amp;gt', '&gt;', $text); </code></pre> <p>I would be using the preg_replace in PHP as above.</p>
<p>If you want to do this with a regex, the trick is to make your regex match the things you don't want to replace as well as the things you want to replace, and dynamically calculate the replacement depending on what was matched.</p> <pre><code>$new_text = preg_replace_callback('%&amp;lt;|&amp;gt;|&lt;pre&gt;.*?&lt;/...
<p>I'm not sure offhand if PHP's regex engine does negative lookarounds, but that's what you're interested in. The regex in other languages would look something like:</p> <pre><code>/(?&lt;!(&lt;pre&gt;[^(&lt;\/pre&gt;)]*))XXX(?!(.*&lt;\/pre&gt;))/ </code></pre> <p>(inhale - I <em>think</em> I have that right)</p> <...
38,716
<p>What's the most efficient way of getting the value of the SERIAL column after the INSERT statement? I.e. I am looking for a way to replicate <code>@@IDENTITY</code> or <code>SCOPE_IDENTITY</code> functionality of MS SQL</p>
<p>The value of the last SERIAL insert is stored in the SQLCA record, as the second entry in the sqlerrd array. Brian's answer is correct for ESQL/C, but you haven't mentioned what language you're using.</p> <p>If you're writing a stored procedure, the value can be found thus:</p> <pre><code>LET new_id = DBINFO('sqlc...
<p>I don't think "efficient" is the word you're looking for here. It's more of a question of accuracy. I'm not sure I can do a better job of explaining it than the SQL Books Online can, but generally, unless you really know what you're doing and have a specific reason for using @@IDENTITY, use SCOPE_IDENTITY. The mo...
30,671
<p>I'm getting some objects from an external library and I need to store those objects in a database. Is there a way to create the tables and relationships starting from the objects, or I have to dig into them and create migrations and models by hand?</p> <p>Thanks! Roberto</p>
<p>Even if you could dynamically create tables on the fly like that (not saying that you can). I wouldn't want to do that. There is so much potential for error there.</p> <p>I would create the migrations by hand and have the tables and fields pre-created and fill them in with rows as needed.</p>
<p>Try looking at some ORM solutions. Or store as XML.</p>
18,573
<p>Is there a way to determine in the child page's code behind that is was opened by the window.open() javascript command from the parent page?</p> <p>The pop-up page contains a user control that is used by other pages that are not spawned from a window.open() command and I want to dynamically add functionality to clo...
<p>Can you pass through a flag in the querystring which will indicate where the window was spawned from?</p>
<p>Might be wrong, but I don't think there's a simple direct way to do this. You could always try to identify it from a distinct url, e.g. "MyChildForm.aspx?from=winopen"</p> <p>--Edit-- Beaten to it by Galwegian</p>
49,106
<p>We recently upgraded an application that that contained web services using the WSE 2.0 to .NET 3.5. When we converted the project in Visual Studio 2008, It did not mention anything about the removing and/or modifying the WSE 2.0 namespaces. Here is the basic architecture of the web services in the .NET 1.1 project...
<p>As I <a href="https://stackoverflow.com/questions/185420/issues-with-client-consuming-a-net-web-service-upgraded-from-net-11-to-35#198806">answered</a> to the original question:</p> <p>WCF (.net 3.5) is said to be compatible with WSE3 (.net 2.0+), but not with WSE2 (.net 1.1+).</p> <p>So if you don't want to chang...
<p>the biggest problem I've found is in Javascript that had hardcoded the names of some of my server controls. in ASP.NET 2.0 with masterpages, the id's where changed to something like ctrl$_gridview1_checkbox1... Therefore, any hardcoded references needed to be changed and generated from the server side using the Cli...
22,809
<p>I'm preparing a class on Visual Basic 2005 targeting Visual Basic 6 programmers migrating to the .NET platform.</p> <p>My primary concern is to teach my students the best practices for developing in .NET, and I am wondering about whether to consider the use of the VB runtime functions VB.NET legitimate or not.</p> ...
<p>Where I'm at, I have to move back and forth between C# and VB.Net frequently. With that in mind, we really don't like the old VB functions, especially the strings functions: <code>Trim(), Replace(), Len(), UCase()</code>, etc. They just look odd in a .Net program, and I wouldn't want to see them in code I had t...
<p>If you're teaching VB, those functions are part of VB. If you're teaching the .Net Framework, those functions aren't part of the Framework. If you're trying to get your work done and you have tools available, use your tools.</p>
29,932
<p>How can I request a random row (or as close to truly random as is possible) in pure SQL?</p>
<p>See this post: <a href="http://www.petefreitag.com/item/466.cfm" rel="noreferrer">SQL to Select a random row from a database table</a>. It goes through methods for doing this in MySQL, PostgreSQL, Microsoft SQL Server, IBM DB2 and Oracle (the following is copied from that link):</p> <p>Select a random row with MySQ...
<p>I have to agree with CD-MaN: Using "ORDER BY RAND()" will work nicely for small tables or when you do your SELECT only a few times.</p> <p>I also use the "num_value >= RAND() * ..." technique, and if I really want to have random results I have a special "random" column in the table that I update once a day or so. T...
3,985
<p>I was looking into the possibility of using CouchDB. I heard that it was similar to Lotus Notes which everyone loves to hate. Is this true?</p>
<p>Development of Lotus Notes began over 20 years ago, with <a href="http://www.ibm.com/developerworks/lotus/library/ls-NDHistory/" rel="noreferrer">version 1 released in 1989</a>. It was developed by Ray Ozzie, currently Chief Software Architect for Microsoft.</p> <p>Lotus Notes (the client) and Domino (the server) ...
<p>It's similar to how Notes deals with data in that everything is a document of arbitrary structure, and you have views over those documents instead of tables and records like you'd have in a relational database. The replication etc also has some similarities.</p> <p>There isn't anything wrong with the Notes server a...
20,258
<p>Anyone know how to do picture overlay or appear on top of each other in HTML? The effect will be something like the marker/icon appear on Google Map where the user can specify the coordinate of the second picture appear on the first picture.</p> <p>Thanks.</p>
<p>You can use <code>&lt;div&gt;</code> containers to seperate content into multiple layers. Therefore the div containers have to be positioned absolutely and marked with a z-index. for instance:</p> <pre><code>&lt;div style="position: absolute; z-index:100"&gt;This is in background&lt;/div&gt; &lt;div style="positio...
<p><a href="http://www.echoecho.com/csslayers.htm" rel="nofollow noreferrer">css layers</a>. </p>
12,567
<p>After our Ruby on Rails application has run for a while, it starts throwing 500s with "MySQL server has gone away". Often this happens overnight. It's started doing this recently, with no obvious change in our server configuration.</p> <pre><code> Mysql::Error: MySQL server has gone away: SELECT * FROM `widgets` </...
<p>This is probably caused by the persistent connections to MySQL going away (time out is likely if it's happening over night) and Ruby on Rails is failing to restore the connection, which it should be doing by default:</p> <p>In the file vendor/rails/actionpack/lib/action_controller/dispatcher.rb is the code:</p> <p...
<p>I had this problem in a Ruby on Rails 3 application, using the <code>mysql2</code> gem. I copied out the offending query and tried running it in MySQL directly, and I got the same error, "MySQL server has gone away.".</p> <p>The query in question was very, very large. A very large insert (+1&nbsp;MB). The field I w...
12,590
<p>I am trying to do the following in <code>SQL*PLUS</code> in <code>ORACLE</code>.</p> <ul> <li>Create a variable</li> <li>Pass it as output variable to my method invocation</li> <li>Print the value from output variable</li> </ul> <p>I get</p> <blockquote> <p><em>undeclared variable</em></p> </blockquote> <p>err...
<p>It should be OK - check what you did carefully against this:</p> <pre><code>SQL&gt; create procedure myproc (p1 out number) 2 is 3 begin 4 p1 := 42; 5 end; 6 / Procedure created. SQL&gt; variable subhandle number SQL&gt; exec myproc(:subhandle) PL/SQL procedure successfully completed. SQL&gt; ...
<p>Please can you re-post, but formatting the code with the code tag.... (ie the 101 010 button) I think some extra "-" characters came through which means it more difficult to interpret.</p> <p>Might also be helpful to see SQL<em>Plus reporting the error if you could copy the contents of the SQL</em>Plus window inst...
15,599
<p>I'm about to start writing a .Net component which will be called from a VB COM+ service (the new component is a DLL which calls out to a webservice and returns based on the response). I'm not sure how to handle error conditions that might occur in the .Net code in the calling VB.</p> <p>The two types of errors I'm ...
<p>I am sure I have seen it done before, but it was in my previous job so I can't check the details. I think we inherited our exception classes from COMException and set the correct ErrorCode (which should be translated as HResult in unmanaged code). This is quite nice, because you can use HResult in unmanaged code as ...
<p>I ended up using the following method:</p> <ul> <li>have a big Dictionary that maps our application-specific VB error codes to our application-specific C# custom exceptions</li> <li>write a method that converts C# exceptions to VB error codes (and vice-versa)</li> <li>return an array of strings from the methods con...
33,769
<p>I have a web application that sometimes just hangs over heavy load. To make it come back I have to kill the "dllhost.exe" process. <strong>Does someone know what to do?</strong></p> <p>This is an Classic ASP (VBScript) app with lots of COM+ objects.</p> <p>The server has the following configuration:</p> <ul> <li>...
<p>Sounds like dodgy COM objects causing the problem .. do you load them into the "Application", if you do then are they threadsafe; or are they used and discarded on each request?</p> <p>Yes, recycling every few hours would help 'hide' the problem, but they ought to be debugged and fixed properly ... have you tried d...
<p>There is probably some errors in your eventlog under the Application and System categories. Try to find the origin of these errors or post them here we'll see what we can do :)</p> <p>Edit : @Daniel Silveira A memory leak is probable. What COM+ object do you use? I had some issues with Excel with an application I ...
3,970
<p>I visited few web sites in the past where they had a set of photo thumbnails and clicking on one of them created a cool effect of an expanding popup showing the full size image. Is there any available free JavaScript library that will do this?</p> <p>I'm interested mostly in the popup effect and less in the rest of...
<p>Lightbox is another popular one: <a href="http://www.lokeshdhakar.com/projects/lightbox2/" rel="nofollow noreferrer">Lightbox Project Page</a></p>
<p>check out jQuery <a href="http://jquery.com" rel="nofollow noreferrer">http://jquery.com</a> </p> <p>and then the LightBox plugin for jQuery: <a href="http://leandrovieira.com/projects/jquery/lightbox/" rel="nofollow noreferrer">http://leandrovieira.com/projects/jquery/lightbox/</a></p>
11,293
<p>I am working on implementing Zend Framework within an existing project that has a public marketing area, a private members area, an administration site, and a marketing campaign management site. Currently these are poorly organized with the controller scripts for the marketing area and the members area all being und...
<p>What I do is keep common classes in a "library" directory outside of the modules hierarchy. Then set my <code>INCLUDE_PATH</code> to use the "models" directory of the respective module, plus the common "library" directory.</p> <pre><code>docroot/ index.php application/ library/ &lt;-- common classes go ...
<p>I'm having the same problem. Bill's answer doesn't fit for me - cos i tend to divide my modules, not by 'who is seeing them', but by 'what they do'. E.g a 'forum module' might be managed by both admin and public. I'm trying to have front end modules, like admin, members , public - but these then use other modules li...
32,415
<p>I'm building a Silverlight application and one of my caveats from last time was that if you need anything done right in Silverlight/WPF way you'd need to model your objects as a DependecyObject and use DependencyProperty(ies) </p> <p>I find this model to be rather cumbersome, requiring static fields and initializer...
<p>Actually, in Silverlight you cannot inherit DependencyObjects, and so you should (and have to) implement INotifyPropertyChanged instead.</p> <p>Implementing INotifyPropertyChanged has many advantages over DependencyObjects (I will abbreviate this DO to make it easier) and using DependencyProperties (DPs):</p> <ul>...
<p>I agree with Richard that it depends on the purpose of your class, but as a note it seems that you CAN inherit from DependencyObject directly in Silverlight 2.0 Release, without having to inherit from UIElement or UserControl. At least, I'm doing that in my (SilverLight 2.0 RTW) app.</p> <p><a href="http://msdn.mi...
18,939
<p>I have written an application which has a modal form. How can I ensure that this form does not lose the focus even when an other application is started?</p>
<p>Actually, this is exactly the sort of thing you shouldn't be doing.</p> <p>There's too many programs around that assume they control the computer they're installed on. It is the user of your application that should be in control.</p> <p>That's why later versions of Windows disallowed stealing of focus instead ins...
<p>You must make the dialog system modal.</p>
17,334
<p>I'm looking for a key/value pair object that I can include in a web service.</p> <p>I tried using .NET's <a href="http://msdn.microsoft.com/en-us/library/5tbh8a42.aspx" rel="noreferrer"><code>System.Collections.Generic.KeyValuePair&lt;&gt;</code></a> class, but it does not properly serialize in a web service. In a ...
<p>Just define a struct/class.</p> <pre><code>[Serializable] public struct KeyValuePair&lt;K,V&gt; { public K Key {get;set;} public V Value {get;set;} } </code></pre>
<p>You can use <code>Tuple&lt;string,object&gt;</code></p> <p>see this for more details on <code>Tuple</code> usage : <a href="http://www.abhisheksur.com/2010/11/working-with-tuple-in-c-40.html" rel="nofollow">Working with Tuple in C# 4.0</a></p>
10,892
<p>What's the best way to shut down the computer from a C# program?</p> <p>I've found a few methods that work - I'll post them below - but none of them are very elegant. I'm looking for something that's simpler and natively .net.</p>
<p>Works starting with windows XP, not available in win 2000 or lower: </p> <p>This is the quickest way to do it:</p> <pre><code>Process.Start("shutdown","/s /t 0"); </code></pre> <p>Otherwise use P/Invoke or WMI like others have said.</p> <p>Edit: how to avoid creating a window</p> <pre><code>var psi = new Pro...
<p>There is no .net native method for shutting off the computer. You need to P/Invoke the ExitWindows or ExitWindowsEx API call.</p>
12,817
<p>I understand that we can use SMS Sender in command line mode. But i been getting this error same as this article <a href="http://www.oreillynet.com/pub/a/wireless/2003/10/10/sms.html" rel="nofollow noreferrer">http://www.oreillynet.com/pub/a/wireless/2003/10/10/sms.html</a></p> <p>The smssender.exe will use the las...
<p>You have to add a new registry under HKEY_Local_Machine-MMicrosoft-> SMSSender</p> <p>Copy registry to create from HKey_Current_User</p>
<p>From 'Options', check the "Enable Logging" check-box. it has worked for me that way. Also it can also be used windows 7 x64 ( under the compatibility mode for XP )</p>
18,940
<p>I am running my junit tests via ant and they are running substantially slower than via the IDE. My ant call is:</p> <pre><code> &lt;junit fork="yes" forkmode="once" printsummary="off"&gt; &lt;classpath refid="test.classpath"/&gt; &lt;formatter type="brief" usefile="false"/&gt; &lt;batchte...
<p>Here's a blind guess: try increasing the maximum heap size available to the forked VM by using a nested <code>&lt;jvmarg&gt;</code> tag to set the <code>-Xmx</code> option.</p>
<p>For the record, I found my problem. We have been using a code obfuscator for this project, and the string encryption portion of that obfuscator was set to "maximum". This slowed down any operation where strings were present.</p> <p>Turning down the string encryption to a faster mode fixed the problem.</p>
14,986
<p>Someone posted a great little function here the other day that separated the full path of a file into several parts that looked like this:</p> <pre><code>Function BreakDown(Full As String, FName As String, PName As String, Ext As String) As Integer If Full = "" Then BreakDown = False Exit Function End If If In...
<pre><code>Dot% = InStrRev(Full, ".") ' First . from end of string If Dot% &lt;&gt; 0 Then Ext = Mid$(Full, Dot%, 3) Else Ext = "" End If </code></pre> <p>Mid$ syntax: Mid(string, start[, length])</p>
<p>If you just have blank characters then just add this as the first line</p> <pre><code>Full = Trim(Full) </code></pre> <p>If you have other characters then</p> <p>Change: </p> <pre><code>Ext = Mid$(Full, Dot%) </code></pre> <p>to: </p> <pre><code>Ext = Mid$(Full, Dot%, 3) </code></pre>
37,208
<p>I came across <a href="http://www.ddj.com/cpp/184403758" rel="noreferrer">this article</a> written by Andrei Alexandrescu and Petru Marginean many years ago, which presents and discusses a utility class called ScopeGuard for writing exception-safe code. I'd like to know if coding with these objects truly leads to be...
<p>It definitely improves your code. Your tentatively formulated claim, that it's obscure and that code would merit from a <code>catch</code> block is simply not true in C++ because RAII is an established idiom. Resource handling in C++ <em>is</em> done by resource acquisition and garbage collection is done by implicit...
<p>My experience shows that usage of <code>scoped_guard</code> is far inferior to any of the short reusable RAII classes that you can write by hand.</p> <p>Before trying the <code>scoped_guard</code>, I had written RAII classes to</p> <ul> <li>set GLcolor or GLwidth back to the original, once I've drawn a shape</li> <l...
7,112
<p>I have installed VS 2008 SP1 on W2k3 OS. After I installed ASP.NET MVC beta and tried creating ASP.NET MVC type project I get the following error.</p> <p>"the project type is not supported by this installation"</p> <p>Let me know if you have fixed this issue.</p>
<p>I tried some of the solutions posted here but still no joy. Finally I replaced the ProjectTypeGuids to this one below in the project file and it loaded fine</p> <p><code>&lt;ProjectTypeGuids&gt;{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}&lt;/ProjectTypeGuids&gt;</code></p>
<p>I had to rebuild my development VM to solve this one. Clean install FTW.</p>
43,617
<p>This has me puzzled. This code worked on another server, but it's failing on Perl v5.8.8 with <a href="http://search.cpan.org/dist/Date-Manip" rel="nofollow noreferrer">Date::Manip</a> loaded from CPAN today.</p> <pre><code>Warning: Use of uninitialized value in numeric lt (&lt;) at /home/downside/lib/Date/Manip.pm...
<p>It's almost certain that your host doesn't have a definition for the timezone you're specifying, which is what's causing a value to be undefined.</p> <p>Have you checked to make sure a TZ definition file of the same name actually exists on the host?</p>
<p>Can you try single-stepping through the debugger to see what exactly is going wrong? It could easily be %Zone that is wrong - %tz may be set correctly on line 1 or 2, but then the lookup on line 3 fails, ending up with undef.</p> <p>Edit: %Date::Manip::Cnf and %Date::Manip::Zone are global variables, so you should ...
10,228
<p>What is the best option for a windows application that uses SQL server authentication? Should I create a single SQL account and manage the users inside the application (using a users table). Or should I create a SQL server account for each user. What is your experience? Thank you!</p>
<p>Depends on whether the username/password for the SQL server would be exposed to the user, and whether that would be a problem. Generally for internal apps (in smaller organisations), one would trust the users not too log in directly to the sql server. If you have a middleware layer (ie webservices) the password can ...
<p>What about having SQL accounts based on the level of permissions needed for the task. For example you could have a read only account just used for reporting if your system has a lot of reporting. You would also need an account what has write access for people to change their passwords and other user admin tasks.</p>...
33,539
<p>So I have a UML type chart that documents the classes and the hierarchy of a development. Just don't know what you'd call it?</p> <p>Any suggestions?</p>
<p><a href="http://www.developer.com/design/article.php/2206791" rel="nofollow noreferrer">Class diagram</a> is a nice start ;-).</p>
<p>Static Structure is another name for that entire suite of diagrams.</p>
39,265
<p>Is there some smart way to retreive the installation path when working within a dll (C#) which will be called from an application in a different folder?</p> <p>I'm developing an add-in for an application. My add-in is written in C#. The application that will use is written in C and needs to compile some stuff durin...
<p>I think what you want is <code>Assembly.GetExecutingAssembly().Location</code>.</p>
<p>Try this:</p> <pre><code>typeof(TypeInMyModule).Assembly.Location </code></pre>
43,269
<p>In previous applications, I was able to get TinyMCE to work just fine. But in this web app, I get the rich editor to show up okay, but for some reason I cannot type into the rich editor field and when I click a button like for bolding, I get this error:</p> <pre><code>Error: [Exception... "Component returned failur...
<p>The answer is <a href="http://tinymce.moxiecode.com/punbb/viewtopic.php?pid=45174#p45174" rel="noreferrer">here</a>.</p> <p>The deal is this. Ever use Facebook? We were trying to implement a similar interface where you click to edit a profile section, it collapses and re-expands with a progress bar, then collapses ...
<p>Are you executing this in Firefox ?</p> <p>Because according to <a href="http://qualityobsession.com/blog/archives/72" rel="nofollow noreferrer">this</a>, it comes up when you disable popups in firefox because of the way pop up blocking is implemented.</p> <p>Enable pop ups and you are good to go!</p>
36,380
<p>What arbitrary-precision integers (and or rationals) library are there for compilers running on Microsoft Windows, and which would you recommend?</p> <p>Please state license type / cost, supported compilers (i.e. GCC and or VC++) for the library.</p>
<p><a href="http://gmplib.org/" rel="nofollow noreferrer">GMP</a>.</p> <p>LGPL. Standard download from official website is designed for GCC. VC++ port is available from <a href="http://gladman.plushost.co.uk/oldsite/computing/gmp4win.php" rel="nofollow noreferrer">here</a>.</p>
<p><a href="https://stackoverflow.com/questions/1047203/best-bignum-library-to-solve-project-euler-problems-in-c">Best bignum library to solve Project Euler problems in C++ ?</a></p>
26,391
<p>I've got some XML, for example purposes it looks like this:</p> <pre><code>&lt;root&gt; &lt;field1&gt;test&lt;/field1&gt; &lt;f2&gt;t2&lt;/f2&gt; &lt;f2&gt;t3&lt;/f2&gt; &lt;/root&gt; </code></pre> <p>I want to transform it with XSLT, but I want to suppress the second f2 element in the output - how do ...
<p>It depends how system wide you want to be.</p> <p>i.e. Are you only concerned with elements that are children of the same parent, or all elements at the same level ('cousins' if you like) or elements anywhere in the document...</p> <p>In the first situation you could check the preceding-sibling axis to see if any ...
<p>To only check (and warn you of a duplicate), you may find an <a href="http://www.biglist.com/lists/lists.mulberrytech.com/xsl-list/archives/200807/msg00444.html" rel="nofollow noreferrer">example here</a></p> <p>Something along the lines of:</p> <pre><code>&lt;xsl:for-each-group select="collection(...)//@id" group...
19,070
<p>I'd like some advice on designing a REST API which will allow clients to add/remove large numbers of objects to a collection efficiently.</p> <p>Via the API, clients need to be able to add items to the collection and remove items from it, as well as manipulating existing items. In many cases the client will want to...
<p>You might want to think of the change task as a resource in itself. So you're really PUT-ing a single object, which is a Bulk Data Update object. Maybe it's got a name, owner, and big blob of CSV, XML, etc. that needs to be parsed and executed. In the case of CSV you might want to also identify what type of objects ...
<p>You could introduce meta-representation of existing collection elements that don't need their entire state transfered, so in some abstract code your update could look like this:</p> <pre>{existing elements 1-100} {new element foo with values "bar", "baz"} {existing element 105} {new element foobar with values "bar"...
39,398
<p>I'm running on win2003 server, PHP 526, via the cmd-line.</p> <p>I have a cmdline string:</p> <pre><code>$cmd = ' "d:\Prog Files\foo.exe" -p "d:\data path\datadir" '; </code></pre> <p>Trying to do this in php code</p> <pre><code>$out = `$cmd`; # note use of backticks AKA shell_exec </code></pre> <p>re...
<p>Use escapeshellarg() to escape your arguments, it should escape it with an appropriate combination of quotation marks and escaped spaces for your platform (I'm guessing you're on Windows).</p>
<p>This is an interesting problem. Apparently, PHP lets you put double quotes around the program or the arguments, but not both. It may be worth reporting this as a bug.</p> <p>A work around is to use the DOS 8.3 name instead of quotes. E.g., "C:\Program Files\" usually becomes "C:\Progra~1".</p>
49,573
<p>In my Python app, I have an XML document that I'd like to transform using my XSL file. I'm currently using xml.etree to generate the XML document, but I haven't found anything within Python 2.5 that will allow me to natively transform my XML document.</p> <p>I've already found one library (<a href="http://xmlsoft....
<p>There is no XSLT processor in Python 2.5.</p>
<p>There is no XSLT processor in Python 2.5.</p>
32,460
<p>Is it possible to set some image as title of Navigation bar?</p> <p>I think NYTimes application used a Navigation bar and title is look like image file (the reason why it's seems <code>UINavigationBar</code> is because they use right button to search).</p>
<p>You can use an <code>UIImageView</code> for the <code>UINavigationItem.titleView</code> property, something like:</p> <pre><code>self.navigationItem.titleView = myImageView; </code></pre>
<p>Just use</p> <pre><code>[navController.navigationBar insertSubview:myImage atIndex:0] ; </code></pre> <p>where myImage is of type UIImageView and navController is of type UINavigationController</p>
36,860
<p>Is it possible to programmatically force a full garbage collection run in ActionScript 3.0?</p> <p>Let's say I've created a bunch of Display objects with eventListeners and some of the DO's have been removed, some of the eventListeners have been triggered and removed etc... Is there a way to force garbage collectio...
<p>Yes, it's possible, but it is generally a bad idea. The GC should have a better idea of when is a good time to run than you should, and except for a very specific case, like you just used 500MB of memory and you need to get it back ASAP, you shouldn't call the GC yourself.</p> <p>In Flash 10, there is a <code>Syste...
<p>If you have to, calling the gargabe collector could be useful... so, you have to be carefull how and when you do it, but there is no doubt that there are times when is neccesary.</p> <p>for example, if you have an app that is modular, when you change from one view to the other, all the deleted objects could represe...
23,380
<p>[former title: Is there a way to force a relationship structure on a tag-based organizational methodology?]</p> <p>I have some entities, and they have a series of attributes. Some of the attributes affect what other attributes the entity can have, many of the attributes are organized into groups, and occasionally e...
<p><strong>edit</strong>: Your description of variable attributes that apply only depending on the values in other attributes is a non-relational, non-normalized design. RDBMS may not be the best solution for storing this kind of data. Probably RDF would be a good solution for data that requires this level of flexibi...
<p>There's no difference between using databases to enforce your rules or using source code elsewhere. Code is data. That's the esoteric Lisp answer.</p> <p>The real question you're asking is whether this is easier in a relational database or in (I assume) an Algol family language. You didn't specify a RDBMS, so I'...
36,624
<p>I have created a UserControl that has a <code>ListView</code> in it. The ListView is publicly accessible though a property. When I put the UserControl in a form and try to design the <code>ListView</code> though the property, the <code>ListView</code> stays that way until I compile again and it reverts back to the d...
<p>You need to decorate the ListView property with the DesignerSerializationVisibility attribute, like so:</p> <pre><code>[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public ListView MyListView { get { return this.listView1; } } </code></pre> <p>This tells the designer's code generator t...
<p>Just so I'm clear, you've done something like this, right?</p> <pre><code>public ListView MyListView { get { return this.listView1; } } </code></pre> <p>So then you are accessing (at design time) the MyListView property on your UserControl?</p> <p>I think if you want proper design-time support you're better off c...
3,653
<p>I'm recoding an old site that contains a chart similar to this:</p> <p><a href="http://dl.getdropbox.com/u/240752/rental-chart.gif" rel="nofollow noreferrer">alt text http://dl.getdropbox.com/u/240752/rental-chart.gif</a></p> <p>How would this chart be represented with pure HTML? I'm loathed to just include it as ...
<p>Whats wrong with the image?</p> <p>Most times when you see chart information on the Web its a generated .jpg or .png.</p> <p>Have all those designers got something wrong?</p> <p>Any attempt to draw the chart using tables and backgroud colours will not be intelligable to a sight impaired person, and, in all probab...
<p>You could also consider having just a table in your HTML &amp; then using Javascript to generate the table: <a href="http://www.wait-till-i.com/2008/01/08/generating-charts-from-accessible-data-tables-using-the-google-charts-api/" rel="nofollow noreferrer">http://www.wait-till-i.com/2008/01/08/generating-charts-from...
40,914
<p>I am putting together some ideas for our automated testing platform and have been looking at Selenium for the test runner.</p> <p>I am wrapping the recorded Selenium C# scripts in an MbUnit test, which is being triggered via the MbUnit NAnt task. The Selenium test client is created as follows:</p> <pre><code>selen...
<p>Thanks for the responses so far.</p> <p>Environment variables could work, however, we could be running parallel tests via a single test assembly so I wouldn't want settings to be overwritten during execution, which could break another test. Interesting line of thought though, thanks, I reckon I could use that in ot...
<p>Anytime I need to integrate with an external entity using NAnt I either end up using the <strong>exec task</strong> or writing a <strong>custom task</strong>. Given the information you posted it would seem that writing your own would indeed be a good solution, However you state you're not happy with it. Can you elab...
29,738
<p>Here's the code from the ascx that has the repeater:</p> <pre><code>&lt;asp:Repeater ID="ListOfEmails" runat="server" &gt; &lt;HeaderTemplate&gt;&lt;h3&gt;A sub-header:&lt;/h3&gt;&lt;/HeaderTemplate&gt; &lt;ItemTemplate&gt; [Some other stuff is here] &lt;asp:Button ID="removeEmail" runat="se...
<p>Controls nested inside of Repeaters do not intercept events. Instead you need to bind to the <code>Repeater.ItemCommand</code> Event.</p> <p><a href="https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.repeater.itemcommand" rel="nofollow noreferrer"><code>ItemCommand</code></a> contains <a href="...
<p>Here's an experiment for you to try:</p> <p>Set a breakpoint on ListOfEmails_ItemDataBound and see if it's being called for postbacks.</p>
6,385
<p>I've done quite a bit of searching on this and haven't had much luck finding something cohesive. I'm a relatively new developer and have just started in my first professional development position. I know that I have a great deal to learn even in the realm of the basics. Based on listening to PodCasts, reading blo...
<p>I was in the same situation and i bought these two books</p> <p>(The PDF version to print out) <a href="http://www.manning.com/osherove/" rel="nofollow noreferrer">http://www.manning.com/osherove/</a> and <a href="http://www.manning.com/prasanna/" rel="nofollow noreferrer">http://www.manning.com/prasanna/</a></p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa973811.aspx" rel="nofollow noreferrer">This article</a> by <a href="http://ayende.com/" rel="nofollow noreferrer">Ayende</a> is best introduction to IoC I have ever seen.</p>
38,830
<p>Are there any lists of default CSS stylesheets for different browsers? (browser stylesheets in tabular form)</p> <p>I want to know the default font of text areas across all browsers for future reference.</p>
<p>Not tabular, but the source CSS may be helpful if you're looking for something specific:</p> <ul> <li><a href="http://hg.mozilla.org/mozilla-central/file/tip/layout/style/res/html.css" rel="nofollow noreferrer">Firefox default HTML stylesheet</a></li> <li><a href="http://trac.webkit.org/browser/trunk/Source/WebCore...
<p>There was some discussion and testing done on www-style not too long ago:</p> <p><a href="http://lists.w3.org/Archives/Public/www-style/2008Jul/0124.html" rel="nofollow noreferrer">http://lists.w3.org/Archives/Public/www-style/2008Jul/0124.html</a></p> <p><a href="http://lists.w3.org/Archives/Public/www-style/2008...
5,287
<p>I'm trying to find the best way to use 'top' as semi-permanent instrumentation in the development of a box running embedded Linux. (The instrumentation will be removed from the final-test and production releases.)</p> <p>My first pass is to simply add this to init.d:</p> <pre><code>top -b -d 15 &gt;/tmp/toploop.ou...
<p>Look at <a href="http://collectd.org/" rel="noreferrer">collectd</a>. It's a very light weight system monitoring framework coded for performance.</p>
<p>You might find that vmstat and iostat with a delay and no repeat counter is a better option.</p>
22,273
<p>I'm working the the image upload piece of the <a href="http://www.fckeditor.net/" rel="nofollow noreferrer">FCKEditor</a> and I've got the uploading working properly but am stuck with the server file browser.</p> <p><img src="https://farm4.static.flickr.com/3184/3019956718_f7ab198c16.jpg?v=0" alt="FCKEditor Image P...
<p>Please read <a href="http://www.fckeditor.net/forums/viewtopic.php?f=6&amp;t=10432" rel="nofollow noreferrer">this post of mine</a> on FCKeditor forums. Are you having the same problem I had?</p>
<p>Is it this?</p> <p>ImageBrowserURL (string) Sets the URL of the page called when the user clicks the "Browse Server" button in the "Image" dialog window. In this way, you can create your custom Image Browser that is well integrated with your system.</p> <p>See <a href="http://www.clinicaestet.ro/FCKeditor/_docs...
35,190
<p>I have always been a very big fan of the DHTML calendar <a href="http://www.dynarch.com/projects/calendar/" rel="nofollow noreferrer">http://www.dynarch.com/projects/calendar/</a></p> <p>I was planning on using this for an upcoming project in ASP.NET, but I wouldn't mind finding a new calendar control that is speci...
<p>JQuery UI has a nice calendar/datepicker worth taking a look at. And most of all its FREE! <a href="http://jqueryui.com/demos/datepicker/" rel="nofollow noreferrer">click here</a></p>
<p>i have (besides the great JQuery UI) two other options:</p> <ul> <li><p>Ajax Control Toolkit (from codeplex.com): great, free, but no support for IE6 iFrame overlay bug</p></li> <li><p>oBout Calendar (<a href="http://www.obout.com/calendar/calendar_home.aspx" rel="nofollow noreferrer">http://www.obout.com/calendar/...
33,001
<p>When I write a class I always expose private fields through a public property like this:</p> <pre><code>private int _MyField; public int MyField { get{return _MyField; } </code></pre> <p>When is it ok to just expose a public field like this:</p> <pre><code>public int MyField; </code></pre> <p>I am creating a str...
<p>I only ever expose public fields when they're (static) constants - and even then I'd usually use a property.</p> <p>By "constant" I mean any readonly, immutable value, not just one which may be expressed as a "const" in C#.</p> <p>Even readonly <em>instance</em> variables (like Result and Message) should be encap...
<p>The answer I give is that Properties are more Refactor friendly.</p> <p>If you have an assembly with read-only fields, then change them to properties. If you have another assembly that I accessing the fields (now properties), they wont work without a compile. Fields and properties are not the same as far as the co...
49,654
<p>What are the fundamentals to accomplish data encryption with exactly two keys (which could be password-based), but needing only one (either one) of the two keys to decrypt the data?</p> <p>For example, data is encrypted with a user's password and his company's password, and then he or his company can decrypt the da...
<p>The way this is customarily done is to generate a single symmetric key to encrypt the data. Then you encrypt the symmetric key with each recipient's key or password to that they can decrypt it on their own. S/MIME (actually the Cryptographic Message Syntax on which S/MIME is based) uses this technique.</p> <p>This ...
<p>I think I thought of a solution that would work:</p> <pre><code>D = data to encrypt h1 = hash(userpassword) h2 = hash(companyPassword) k = h1 concat h2 E = function to encrypt //C is the encrypted data C = E_h1(h2) concat E_h2(h1) concat E_k(D) </code></pre> <p>Then either person can decrypt the hash of the other...
5,983
<p>I am using the Ajax Control Toolkit Calendar Extender control. In some fields though I want to display the time along with the date. I have tried just setting the Format to "dd/MM/yyyy hh:mm:ss" but the time section gets wiped off. If the user wants to change the time section they can do it manually, the calendar dr...
<p>I have a similar issue and I'm planning to use a Date field and an associated time dropdown (in 1/2 hour increments). User sets the date in the date field, optionally using the calendar control, and pulls down to a valid time. I plan to have one selection in the time drop down be a "don't care" in case it an "all ...
<p>The only way to add time component to the AjaxControlToolKit CalendarExtender, is to append it using OnClientDateSelectionChanged and JavaScript.</p> <pre><code>&lt;ajaxToolkit:CalendarExtender ID="ce1" runat="server" PopupButtonID="calImg" Enabled="true" Format="dd/MM/yyyy" TargetControlID="txtLeft" PopupPosition...
35,336
<p>Having difficulty articulating this correlated subquery. I have two tables fictitious tables, foo and bar. foo has two fields of foo_id and total_count. bar has two fields, seconds and id.</p> <p>I need to aggregate the seconds in bar for each individual id and update the total_count in foo. id is a foreign key in...
<pre><code>UPDATE foo f1 SET total_count = (SELECT SUM(seconds) FROM bar b1 WHERE b1.id = f1.foo_id) </code></pre> <p>You should have access to the appropriate foo id within the sub-query, so there is no need to join in the table.</p>
<p>I hope I understood your question right.</p> <p>You have the following tables:</p> <ul> <li>table <code>foo</code> - columns: <code>id</code> and <code>total_count</code></li> <li>table <code>bar</code> - columns: <code>foo_id</code> (references <code>foo.id</code>) and <code>seconds</code></li> </ul> <p>The foll...
27,541
<p>Using ASP.NET MVC there are situations (such as form submission) that may require a <code>RedirectToAction</code>. </p> <p>One such situation is when you encounter validation errors after a form submission and need to redirect back to the form, but would like the URL to reflect the URL of the form, not the action ...
<p>The solution is to use the TempData property to store the desired Request components.</p> <p>For instance:</p> <pre><code>public ActionResult Send() { TempData["form"] = Request.Form; return this.RedirectToAction(a =&gt; a.Form()); } </code></pre> <p>Then in your "Form" action you can go:</p> <pre><code>...
<p>TempData is the solution which keeps the data from action to action.</p> <pre><code>Employee employee = new Employee { EmpID = "121", EmpFirstName = "Imran", EmpLastName = "Ghani" }; TempData["Emp...
2,416
<p>Almost every new Java-web-project is using a modern MVC-framework such as Struts or Spring MVC for the web tier, Spring for the "Service"/business-logic-layer and an ORM mapper such as Hibernate for persistence. What is the equivalent in .NET? </p> <p>I guess ASP.NET is used for the web tier and ADO.NET for persist...
<p>The default approach is ADO.NET/Linq-to-Sql, ASP.NET and custom service layer that reinvents the wheel. Microsoft has Unity for autowiring, but I do not feel dependency injection is mainstream in .NET world yet.</p> <p>But if you go for the best practices, it is ASP.NET MVC for UI, any DI framework (Castle,Unity,Au...
<p>ASP.NET MVC + The data access that suits your job better.</p> <p>There are many other frameworks, tools and libs that can help such as Castle ones, Ninject, Nunit, NLog etc.</p> <p>But i believe that the better response to your question is "It depends".</p>
43,646
<p>My Windows/C++ application allocates ~1Gb of data in memory with the operator <code>new</code> and processes this data. After processing the data is deleted.</p> <p>I noticed that if I run the processing again without exiting the application, the second call to the operator<code>new</code> to allocate ~1Gb of data ...
<p>I don't think this is a Windows problem. Check if you used delete or delete[] correctly. Perhaps it would help if you post the code that is allocating/freeing the memory.</p>
<p>Since you are using very large memory blocks, you should consider using <a href="http://msdn.microsoft.com/en-us/library/aa366887(VS.85).aspx" rel="nofollow noreferrer">VirtualAlloc()</a> and <a href="http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx" rel="nofollow noreferrer">VirtualFree()</a>, as they a...
48,055
<p>I had data in XML that had line feeds, spaces, and tabs that I wanted to preserve in the output HTML (so I couldn't use &lt;p&gt;) but I also wanted the lines to wrap when the side of the screen was reached (so I couldn't use &lt;pre&gt;).</p>
<p>Another way of putting this is that you want to turn all pairs of spaces into two non-breaking spaces, tabs into four non-breaking spaces and all line breaks into <code>&lt;br&gt;</code> elements. In XSLT 1.0, I'd do:</p> <pre><code>&lt;xsl:template name="replace-spaces"&gt; &lt;xsl:param name="text" /&gt; &lt;...
<p>I and a co-worker (Patricia Eromosele) came up with the following solution: (Is there a better solution?)</p> <pre> &lt;p&gt;<br /> &lt;xsl:call-template name="prewrap"&gt;<br /> &lt;xsl:with-param name="text" select="text"/&gt;<br /> &lt;/xsl:call-temp...
11,265