instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>In my ASP.Net 1.1 application, i've added the following to my Web.Config (within the System.Web tag section):</p> <pre><code>&lt;httpHandlers&gt; &lt;add verb="*" path="*.bcn" type="Internet2008.Beacon.BeaconHandler, Internet2008" /&gt; &lt;/httpHandlers&gt; </code></pre> <p>This works fine, and the HTTPHandler ...
<p>It sounds like it as an inherant &lt;clear /&gt; in it although I don't know if I've seen this behaviour before, you could just add the general handler back, let me find you the code.</p> <pre><code>&lt;add verb="*" path="*.asmx" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services" val...
<p>It sounds like it as an inherant &lt;clear /&gt; in it although I don't know if I've seen this behaviour before, you could just add the general handler back, let me find you the code.</p> <pre><code>&lt;add verb="*" path="*.asmx" type="System.Web.Services.Protocols.WebServiceHandlerFactory, System.Web.Services" val...
15,961
<p>I am using a bat file on a Windows 2000 SP4 server to copy database files while the database is shut down. Once the bat file hits the xcopy command, it does the copy, but never returns to the bat file to continue with the other commands (start up the database, etc). I should mention that the xcopy takes several ho...
<p>Batch files don't timeout. It sounds like you might be running into a prompt from XCOPY, like an "Are you sure" prompt.</p> <p>Make sure you've added the necessary command-line switches to XCOPY to make it silent.</p> <p>The ones I'm aware of are:</p> <pre><code>-Y to suppress prompts about overwriting files -C...
<p>There's no timeout that I'm aware of on .bat or .cmd files. However, there may be on the process that's launching it? How are you launching it?</p>
32,298
<p>How can you round <em>any</em> number (not just integers > 0) to N significant digits?</p> <p>For example, if I want to round to three significant digits, I'm looking for a formula that could take:</p> <p>1,239,451 and return 1,240,000</p> <p>12.1257 and return 12.1</p> <p>.0681 and return .0681</p> <p>5 and re...
<p>Here's the same code in Java without the 12.100000000000001 bug other answers have</p> <p>I also removed repeated code, changed <code>power</code> to a type integer to prevent floating issues when <code>n - d</code> is done, and made the long intermediate more clear</p> <p>The bug was caused by multiplying a large...
<pre><code>public static double roundToSignificantDigits(double num, int n) { return Double.parseDouble(new java.util.Formatter().format("%." + (n - 1) + "e", num).toString()); } </code></pre> <p>This code uses the inbuilt formatting function which is turned to a rounding function</p>
24,731
<p>Any links/Turorials avalable? I want to write a simple ISAPI plugin for IIS6.0.</p> <p>Prefered language c++</p>
<p>Below is a quick (and simple) ISAPI Filter example. I found it very useful when trying to write my first ISAPI plugin. <a href="http://blogs.msdn.com/rakkimk/archive/2007/03/01/writing-a-simple-isapi-filter.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/rakkimk/archive/2007/03/01/writing-a-simple-isapi-filter...
<p>Visual Studio used to have an ISAPI wizard which was great for writing plugins. If you have 6.0, it might still be there. VS 2003 has one under MFC for ISAPI with MFC support (not hard to remove if you don't want it).</p> <p>If you are doing an Extension (not a filter) -- here is the minimal code you need:</p> <...
30,111
<p>We are currently working with Flex creating a web application. We are having trouble taking Arabic text from the user and displaying correctly (like in a chat feature). While presumably Flash 10 will solve this problem, we don't want to force our users to upgrade.</p> <p>Flash flips the order of the sentence's word...
<p>You may also want to check FlarabyAS3Flex <a href="http://www.arabicode.com/en/flaraby/as3/flex/" rel="nofollow noreferrer">here</a></p>
<p>This would appear to be a Unicode issue, and so a quick talaash via Google gave me <a href="http://polygeek.com/110_flex_unicode-in-flash" rel="nofollow noreferrer">Unicode in Flash</a>, but probably more to the point is <a href="http://www.blog.lessrain.com/flash-ltr-left-to-right-and-rtl-right-to-left/" rel="nofol...
37,299
<p>Is it possible to get a list of all files modified/added/deleted by a particular user?</p> <p>The goal is to get an idea of what a user did for the day (or date range).</p>
<p>Here's an example, using the <a href="http://svnbook.red-bean.com/en/1.5/svn.ref.svn.c.log.html" rel="noreferrer">svn log command</a> and <a href="http://www.google.com/search?hl=en&amp;q=linux+sed+command" rel="noreferrer">linux sed command</a>, with your username, 'blankman':</p> <pre><code>svn log | sed -n '/bla...
<p>In order to see the list all files changed by a particular user in subversion for a particular directory structure, then first you need go to the that directory structure and on the right side of directory panel do a right click.. then, go to Show Log-->on top most left corner we get filter option.</p> <p>hencefort...
44,358
<p>I found a lot of info about how to debug simple Python programs with Emacs. But what if I want to debug a Django application? I run the development server and I would like to somehow attach to the process from Emacs and then set breakpoints, etc. Similar to Visual Studio's "attach to process". How to do that?</p>
<p>Start pdb like this:</p> <p><kbd>M-x</kbd> <code>pdb</code></p> <p>Then, start the Django development server:</p> <pre><code>python manage.py runserver --noreload </code></pre> <p>Once you have the (Pdb) prompt, you need to do this:</p> <pre><code>import sys sys.path.append('/path/to/directory/containing/views....
<p>I don't really know anything about it, but putting "debugging Python with emacs" into Google gave me this page about <a href="http://twistedmatrix.com/projects/core/documentation/howto/debug-with-emacs.html" rel="nofollow noreferrer">debugging twisted with emacs</a>, so it seems to be possible.</p>
35,905
<p>I am going to design and build a 3D printer. I want the highest quality and accuracy so nothing except that is important for me. Which cartesian design has the highest quality and accuracy? CoreXY, Prusa, or Gantry (Ultimaker)?</p> <p>Also, is it better to have a nozzle that moves in just direction &quot;X&quot;, di...
<p>The tradeoffs in these systems are all about quality achievable at particular speed and acceleration profiles. If you really don't care about speed at all and want maximum accuracy, you probably want some type of Cartesian setup with no belts, only rigid lead screws which you can take to as fine a pitch as you like,...
<p>The tradeoffs in these systems are all about quality achievable at particular speed and acceleration profiles. If you really don't care about speed at all and want maximum accuracy, you probably want some type of Cartesian setup with no belts, only rigid lead screws which you can take to as fine a pitch as you like,...
1,717
<p>When stepping a program in Delphi 7, the CPU window sometimes pops up and then steps through that instructions. I find this an annoyance as I wish to only step Pascal Code. </p> <p>Does anyone know how to disable this CPU pop-up? </p> <p><strong><em>I would not be sorry if this window never ever shows.</em></stron...
<p>Delphi does not, by default, step into the CPU window. So the answer to your question is not that it can not be done. Maybe the question should be: What did I do that causes this.</p> <p><strong>EDIT</strong>:<br> From the comments I understand that it happens when you press pause to break in the debugger.<br> It i...
<p>You fall into the CPU-Window when there are no Debug-Informations for the current Unit.</p> <p>Try to enable the Debug-DCU's (in Project/Options.../Compiler). If you haven't checked the other debug options, activate them also.</p>
21,457
<p>I need to be able to embed and control the playback of an AVI file in a WinForms app, using C#. The video needs to be embedded in the form, not launched in a separate media player window.</p> <p>What's the best approach to do this? I found the System.Media namespace, which sounded promising, but it appears that i...
<p>You can use <a href="http://msdn.microsoft.com/en-us/library/bb249260(VS.85).aspx" rel="noreferrer">Media Player</a> inside your Winform. This would been an easy way to do it.</p>
<p>I would <strong>consider</strong> using the WPF media controls and just use the ElementHost to put your WPF control inside your WinForms app. I think you will get a much more rich experience.</p> <p>See <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.aspx" rel="nofollow noreferrer...
43,023
<p>I have the following code that won't compile and although there is a way to make it compile I want to understand why it isn't compiling. Can someone enlighten me as to specifically why I get the error message I will post at the end please?</p> <pre><code>public class Test { public static void main(String args[]...
<p>The reason is that Test.class is of the type Class&lt;Test&gt;. You cannot assign a reference of type Class&lt;Test&gt; to a variable of type Class&lt;T&gt; as they are not the same thing. This, however, works:</p> <pre><code>Class&lt;? extends Test&gt; testType = type == null ? Test.class : type; </code></pre> <p...
<p>Remove the conditional and the error is a little nicer...</p> <pre><code>public class Test { public static void main(String args[]) { Test t = new Test(); t.testT(null); } public &lt;T extends Test&gt; void testT(Class&lt;T&gt; type) { Class&lt;T&gt; testClass = Test.class; ...
19,748
<p>I'm searching for a free ASP.NET profiler, and I stumbled upon <a href="http://www.eqatec.com/tools/profiler" rel="noreferrer">EQATEC Profiler for .NET</a>, but I can't find any instructions on how to profile ASP.NET projects with it. Please post step-by-step instructions or a link with sufficient info.</p> <p>I'm ...
<p>It looks like they have changed their user interface since Pavel's instructions were posted. Here are the instructions I wrote up for my team. They replace steps 4-8 in Pavel's post.</p> <p>To profile an ASP.NET application using EQATEC, just select the application’s bin folder in the App Path setting.</p> <p>Then...
<p>You may need to get a compiled version of your site (is there a dll for the site in the bin folder or just the dependencies?). The easiest way to do this is to publish it. (Just right hand click the site in Visual Studio). Then Pavel's answer will work just fine.</p>
49,594
<p>is there a free set of controls to be used for representing the OLAP cubes in aspx pages? something like the ones from Dundas, but free and (if possible) cross-browser.</p> <p>Thanks, Lucian</p>
<p>Let me assume some things that are left out in the question:</p> <ol> <li>You have a dynamic library called <strong>flubber.dll</strong></li> <li>The library exports the function <code>bool GetFlubber(Flubber* flubber)</code>.</li> <li>The function and the type <code>Flubber</code> (which just happens to be a <code...
<p>As other responses have suggested it's hard to tell what's being asked here, but I'll throw in a response for another interpretation of the question. I'm not sure if it's "officially supported", but you can have a DLL export a global variable and then dynamically access it via GetProcAddress.</p> <p>For instance, ...
43,674
<p>How would you call the constructor of the following class in these three situations: Global objects, arrays of objects, and objects contained in another class/struct?</p> <p>The class with the constructor (used in all three examples):</p> <pre><code>class Foo { public: Foo(int a) { b = a; } privat...
<h3>Global objects</h3> <p>Yours is the only way. On the other hand, try to avoid this. It’s better to use functions (or even other objects) as factories instead. That way, you can control the time of creation.</p> <h3>Arrays of objects</h3> <p>There’s no way to do this directly. Non-POD objects will always be defau...
<p>Construction of arrays of objects:</p> <p>You can modify your original example by using default parameters.</p> <p>Currently only the default constructor is supported.<br> This is something that is being addressed by the next version (because everybody asks this question)</p>
37,563
<p>I would like to have a reference for the pros and cons of using include <strong>files vs objects(classes)</strong> when developing PHP applications.</p> <p>I know I would benefit from having one place to go for this answer...I have a few opinions of my own but I look forward to hearing others.</p> <p><strong>A Sim...
<p>These are not really opposite choices. You will have to include the checking code anyway. I read your question as procedural programming vs. OO programming.</p> <p>Writing a few lines of code, or a function, and including it in your page header was how things were done in PHP3 or PHP4. It's simple, it works (that's...
<p>Can you be a bit more specific? For the example you give you need to use include in both ways. In case 1 you only include a file, in case 2 you need to include the class file (for instance user.class.php) to allow instantiation of the User class.</p> <p>It depends how the rest of the application is built, is it OO?...
4,258
<p>Do you know what may cause memory leaks in JavaScript? I am interested in browsers: IE 7, FireFox 3, Safari 3</p>
<p>There is a nice article about <a href="http://www.javascriptkit.com/javatutors/closuresleak/index.shtml" rel="noreferrer"><strong>JavaScript and memory leaks</strong></a>. It does not specific about on browser, it rather describes the whole problematic of memory leaks and JavaScript.</p> <ul> <li><a href="http://ww...
<p>You can check <a href="http://msdn.microsoft.com/en-us/library/bb250448(VS.85).aspx" rel="nofollow noreferrer">this</a> MSDN article for Internet Explorer memory leak patterns. Also there are some tools for detecting memory leaks:</p> <ul> <li><a href="http://home.wanadoo.nl/jsrosman/" rel="nofollow noreferrer">sIE...
20,560
<p>I'm relatively new to jQuery, but so far what I've seen I like. What I want is for a div (or any element) to be across the top of the page as if "position: fixed" worked in every browser.</p> <p>I do not want something complicated. I do not want giant CSS hacks. I would prefer if just using jQuery (version 1.2.6) i...
<p>Using this HTML:</p> <pre><code>&lt;div id="myElement" style="position: absolute"&gt;This stays at the top&lt;/div&gt; </code></pre> <p>This is the javascript you want to use. It attaches an event to the window's scroll and moves the element down as far as you've scrolled.</p> <pre><code>$(window).scroll(function...
<p>In a project, my client would like a floating box in another div, so I use margin-top CSS property rather than top in order to my floating box stay in its parent.</p>
32,097
<p>I've heard it said that the Entity Framework is overkill or that it's difficult to learn compared to LinqToSql.</p> <p>I am wondering in what way? I used LinqToSql and like it. So, I am trying the EF and for the things I'm doing they seem almost exactly the same. Namespaces and method names are different but so ...
<p>Correct me if I'm wrong, but the entity framework should only come into play when you need to transform the back-end objects, like when you're combining tables from different data sources, splitting tables, etc. It adds the entity layer so you can hide all the plumbing and just deal with your cleaned up entities. If...
<p>Before you dive in to Linq To SQL, check out <a href="http://blogs.msdn.com/adonet/archive/2008/10/31/clarifying-the-message-on-l2s-futures.aspx" rel="nofollow noreferrer">this article</a> by its program manager. He poses a straightforward question "Is LINQ to SQL Dead?" The answer is not as straightforward. It's...
33,533
<p>I try get the <a href="http://flash-mp3-player.net/players/js/" rel="nofollow noreferrer">mp3 flash player</a> to work with my javascript on all browsers. All went well for first, but fast realized that my code doesn't work on MSIE.</p> <p>After trying to find out I found this in the reference code:</p> <pre><cod...
<p>That syntax, with the &lt;script> tag with the "event" and "for" attributes is an Internet Explorer-only way of setting up an event handler on an DOM object. Here, it adds a FSCommand event handler to the myFlash object. This is needed because code running inside the Flash object may want to run JavaScript in the ...
<p>Thanks everyone for the above. I'll just drop a few lines that were handy for me.</p> <p>To re-use code across browsers, do:</p> <pre><code>&lt;script type="text/javascript"&gt; function mySwf_DoFSCommand(command, args) { // do stuff } &lt;/script&gt; &lt;!--[if IE]&gt; &lt;script type="text/javas...
35,479
<p>I create a DropDown with the Html.DropDownList(string NameSelectListInViewData) method. This generates a valid Select input with the correct values. And all is well.</p> <p>Upon submit however, the value in the source SelectList is not bound. </p> <p><em>Case:</em> ViewData.SearchBag.FamilyCodes:</p> <pre><code>...
<p>No. You will need to use SQL Profiler. A standard trace with the <strong>Lock Timeout</strong> event and <strong>Deadlock Graph</strong> events should do it.</p> <ul> <li><p><a href="http://msdn.microsoft.com/en-us/library/ms189107.aspx" rel="noreferrer">Lock:Timeout Event Class</a></p></li> <li><p><a href="http://...
<p>You could also use Event Notifications that get raised on the timeout and deadlock events. After it fires, you can write it to a table and or send yourself an email.</p> <p>I've shown the general technique here:</p> <blockquote> <h2><a href="http://weblogs.sqlteam.com/mladenp/archive/2008/07/18/Immediate-deadloc...
37,734
<p>I have, for my game, a Packet class, which represents network packet and consists basically of an array of data, and some pure virtual functions</p> <p>I would then like to have classes deriving from Packet, for example: StatePacket, PauseRequestPacket, etc. Each one of these sub-classes would implement the virtual...
<p>For copying you need to write a clone function, since a constructor cannot be virtual:</p> <pre><code>virtual Packet * clone() const = 0; </code></pre> <p>Which each Packet implementation implement like this:</p> <pre><code>virtual Packet * clone() const { return new StatePacket(*this); } </code></pre> <p>fo...
<p>You need to look up the Factory Pattern.</p> <p>The factory looks at the incomming data and created an object of the correct class for you.</p>
42,729
<p>I am having trouble deleting orphan nodes using JPA with the following mapping</p> <pre><code>@OneToMany (cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "owner") private List&lt;Bikes&gt; bikes; </code></pre> <p>I am having the issue of the orphaned roles hanging around the database.</p> <p>I can ...
<p>If you are using it with Hibernate, you'll have to explicitly define the annotation <code>CascadeType.DELETE_ORPHAN</code>, which can be used in conjunction with JPA <code>CascadeType.ALL</code>. </p> <p>If you don't plan to use Hibernate, you'll have to explicitly first delete the child elements and then delete th...
<p>I was using one to one mapping , but child was not getting deleted JPA was giving foreign key violation </p> <p>After using orphanRemoval = true , issue got resolved</p>
39,383
<p>Is there a possible htaccess directive that can transparently forward request from index.php to index_internal.php if the request is coming from an internal ip range?</p>
<pre><code>RewriteEngine on RewriteCond %{REMOTE_ADDR} ^192\.168\.1\. [OR] RewriteCond %{REMOTE_ADDR} ^10\.15\. RewriteRule ^index\.php$ index_internal.php [R,NC,QSA,L] </code></pre> <p>What this does: </p> <p>start mod_rewrite engine (you may have that already)</p> <p>if (client IP address starts with "192.168.1."...
<p>Something like this should do it (obviously change the IP address to match your network):</p> <pre><code>RewriteCond %{REMOTE_ADDR} ^192\.168\. RewriteRule index.php index_internal.php </code></pre> <p>If you want an actual header then make it <code>RewriteRule index.php index_internal.php [L,R,QSA]</code></p>
32,291
<p>Okay, here is the 411 - I have the following event handler in my Global.asax.cs file:</p> <pre><code>private void Global_PostRequestHandlerExecute(object sender, EventArgs e) { if (/* logic that determines that this is an ajax call */) { // we want to set a cookie Response.Cookies.Add(new HttpCook...
<p>you have to delete your cookie at the same path where you created it. so create your cookie with path=/ and delte it with path=/ as well..</p>
<p>Are we sure there's no code that sets the Cookie to HttpOnly (we're not missing anything above)? The HttpOnly property will stop (modern) browsers from modifying the cookie. I'd be interested to see if you can kill it server side like Rob suggests.</p>
7,970
<p>I have the following html.erb code that I'm looking to move to Haml:</p> <pre><code>&lt;span class="&lt;%= item.dashboardstatus.cssclass %&gt;" &gt;&lt;%= item.dashboardstatus.status %&gt;&lt;/span&gt; </code></pre> <p>What it does is associate the CSS class of the currently assigned status to the span.</p> <p>Ho...
<p>Not sure. Maybe:</p> <pre><code>%span{:class =&gt; item.dashboardstatus.cssclass }= item.dashboardstatus.status </code></pre>
<p>This worked.</p> <p>Where ever the link is to the page do something like this</p> <pre><code> %div{"data-turbolinks" =&gt; "false"} = link_to 'Send payment', new_payments_manager_path(sender_id: current_user.id, receiver_id: @collaboration.with(current_user).id, collaboration_id: params[:id]), class: 'button'...
2,808
<p>If you had to iterate through a loop 7 times, would you use:</p> <pre><code>for (int i = 0; i &lt; 7; i++) </code></pre> <p>or:</p> <pre><code>for (int i = 0; i &lt;= 6; i++) </code></pre> <p>There are two considerations:</p> <ul> <li>performance</li> <li>readability </li> </ul> <p>For performance I'm assuming...
<p>The first is more <a href="http://en.wiktionary.org/wiki/idiomatic" rel="noreferrer">idiomatic</a>. In particular, it indicates (in a 0-based sense) the number of iterations. When using something 1-based (e.g. JDBC, IIRC) I might be tempted to use &lt;=. So:</p> <pre><code>for (int i=0; i &lt; count; i++) // For 0-...
<p>I think either are OK, but when you've chosen, stick to one or the other. If you're used to using &lt;=, then try not to use &lt; and vice versa. </p> <p>I prefer &lt;=, but in situations where you're working with indexes which start at zero, I'd probably try and use &lt;. It's all personal preference though. </p>
22,068
<p>I need to write a unit test for a method that will print a document. Is there an easy way to send the output to the Windows equivalent of /dev/null? I'm guessing that having our build server print a document on every check in is going to get expensive quickly. ;)</p> <p>Ideally, this would work on both our build...
<p>I do this by creating a Windows printer that prints to the NUL device. This is pretty straightforward though the specifics differ a bit between Windows versions: just create a local printer and specify NUL as the local port, "Generic" as the Manufacturer and "Generic / Text Only" as the printer model.</p>
<p>You should use a mocking framework to mock out the print method so that it is never actually executed.</p> <p>Check out TypeMock or RhinoMocks for something that will help you do this.</p> <p>This is how it would look using TypeMock:</p> <pre><code>Mock mock = MockManager.Mock&lt;PrintManager&gt;(); mock.ExpectCa...
49,015
<p>I'm sure this sounds like a n00b question, but how do I add sub items programmically while populating a TreeView list in VB.NET 3.5? I have the following code, but haven't been able to figure out how to add the sub items for each of the folders/files I'm populating the TreeView with:</p> <pre><code>Private Sub Add...
<p>Q1 - the GDR has a pre-requisite of VS2008 SP1, so switch those last two around.</p> <p>Q2 - I believe that each dev should be working with their own sandboxed database instance, yes. If you don't want to install instances of SQL Server on your workstations, then using multiple instances of SQL on a development ser...
<p>I would put the DB on the development machine. You can change the service so that it doesn't start by default and start it manually whenever you want to use it, if you don't want it running all the time. I prefer this so that I'm not dependent on the availability of another system while developing. If you go thi...
47,771
<p>I am developing a Tool in vb.net and need find out Activex Controls from MS Access DB forms. I am able to conut number of controls in form, but unable to get the Activex Controls only from the form. Can any one have any idea how to achieve this, please suggest. </p>
<p>Can you access the controltype property? If so, I cannot help with vb.net, but here is some VBA that may help.</p> <pre><code>ActiveXCount = 0 For Each ctl In Screen.ActiveForm If ctl.ControlType = 119 Then 'Custom control' 'Debug.Print ctl.Class' ActiveXCount = ActiveXCount + 1 End If Next...
<p>I am not sure what your are wanting is possible.<br> Try this: go into MS access and create new property that is the count of controls on the form. In VBA, me.Countrols.Count. Open the form using Access automation. OnFOrmLoad() write the number of controls to text file along with name of the form and then close ...
46,762
<p>I am looking for a simple way to get a mime type where the file extension is incorrect or not given, something similar to <a href="https://stackoverflow.com/questions/51438/getting-a-files-mime-type-in-java">this question</a> only in .Net.</p>
<p>I did use urlmon.dll in the end. I thought there would be an easier way but this works. I include the code to help anyone else and allow me to find it again if I need it.</p> <pre><code>using System.Runtime.InteropServices; </code></pre> <p>...</p> <pre><code> [DllImport(@"urlmon.dll", CharSet = CharSet.Auto)]...
<p>When working with Windows Azure Web role or any other host that runs your app in Limited Trust do not forget that you will not be allowed to access registry or unmanaged code. Hybrid approach - combination of try-catch-for-registry and in-memory dictionary looks like a good solution that has a bit of everything. </p...
8,285
<p>Evaluate:</p> <pre><code>((((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4) 5) </code></pre> <p>This is what I did:</p> <ul> <li><p>evaluate <code>((((lambda (x) (lambda (y) (lambda (x) (+ x y)))) 3) 4) 5)</code></p> <ul> <li>evaluate <code>5 -&gt; 5</code></li> </ul></li> <li><p>evaluate <code>(((lambda (x...
<p>I suggest you break this down into individual 'defined' procedures.</p> <pre><code>(define part1 (lambda (y) (lambda (x) (+ x y)))) ; basically an adder (define part2 (lambda (x) part1)) ; just return part1, x has no effect </code></pre> <p>Now call <code>(((part2 3) 4) 5) =&gt; 9</code></p>
<pre><code>-substitute 3 -&gt; x in (lambda (y) (lambda (x) (+ x y)) -(lambda (y) (lambda (x) (+ 3 y)) </code></pre> <p>First, this is wrong. You don't substitute <code>3</code> for all occurrences of <code>x</code>, only for the free ones. The <code>x</code> you're replacing here is bound by the inner lambda expres...
31,021
<p>Whilst analysing some legacy code with FXCop, it occurred to me is it really that bad to catch a general exception error within a try block or should you be looking for a specific exception. Thoughts on a postcard please.</p>
<p>Obviously this is one of those questions where the only real answer is "it depends."</p> <p>The main thing it depends on is where your are catching the exception. In general libraries should be more conservative with catching exceptions whereas at the top level of your program (e.g. in your main method or in the t...
<p>For my IabManager class, which I used with in-app billing (from the TrivialDrive example online), I noticed sometimes I'd deal with a lot of exceptions. It got to the point where it was unpredictable.</p> <p>I realized that, as long as I ceased the attempt at trying to consume an in-app product after one exception...
4,195
<p>In MSVC, <a href="http://msdn.microsoft.com/en-us/library/ms679297.aspx" rel="noreferrer">DebugBreak()</a> or <a href="http://msdn.microsoft.com/fr-fr/library/f408b4et.aspx" rel="noreferrer">__debugbreak</a> cause a debugger to break. On x86 it is equivalent to writing "_asm int 3", on x64 it is something different....
<p>A method that is portable to most POSIX systems is:</p> <pre><code>raise(SIGTRAP); </code></pre>
<p>Instead of using 'normal' debug breaks, why not use one of the following, like a divide by zero:</p> <pre><code>int iCrash = 13 / 0; </code></pre> <p>or dereference a NULL pointer:</p> <pre><code>BYTE bCrash = *(BYTE *)(NULL); </code></pre> <p>At least this is portable accross many platforms/architectures.</p> ...
20,917
<p>I would like to implement a data access object pattern in C++, but preferably without using multiple inheritance and/or boost (which my client does not like). </p> <p>Do you have any suggestions?</p>
<p>OTL (otl.sourceforge.net) is an excellent C++ database library. It's a single include file so doesn't have all the complexity associated (rightly or wrongly!) with Boost.</p> <p>In terms of the DAO itself, you have many options. The simplest that hides the database implementation is just to use C++ style interfac...
<p>My preferred data access abstraction is the <a href="http://martinfowler.com/eaaCatalog/repository.html" rel="nofollow noreferrer">Repository Pattern</a>.</p>
14,213
<p>What's the best way to store timezone information with dates/times in a uniform way so people can enter times from anywhere in the world in their own local time? Other users would then have the ability to view the times in their own local time and the original localtime on the web page.</p>
<p>Store the time data as GMT. Display it using local time. This requires a simple offset from GMT. Now if the politicians would leave the starting and end date for Day light savings time alone...</p>
<p>My view has always been to store exact numeric timestamps (seconds or milliseconds since midnight 1st january 1970 GMT), as that's a format that is easily converted to an actual date and time in any timezone.</p> <p>The downside of this is that the data isn't as immediately viewable through normal SQL tools. The my...
35,097
<p>I want to be able to write a lambda/Proc in my Ruby code, serialize it so that I can write it to disk, and then execute the lambda later. Sort of like...</p> <pre><code>x = 40 f = lambda { |y| x + y } save_for_later(f) </code></pre> <p>Later, in a separate run of the Ruby interpreter, I want to be able to say...<...
<p><strong>Use Ruby2Ruby</strong></p> <pre><code>def save_for_later(&amp;block) return nil unless block_given? c = Class.new c.class_eval do define_method :serializable, &amp;block end s = Ruby2Ruby.translate(c, :serializable) s.sub(/^def \S+\(([^\)]*)\)/, 'lambda { |\1|').sub(/end$/, '}') end x = 40...
<p>Ruby has the Marshal class that has a dump method that you can call.</p> <p>Take a look here:</p> <p><a href="http://rubylearning.com/satishtalim/object_serialization.html" rel="nofollow noreferrer">http://rubylearning.com/satishtalim/object_serialization.html</a></p>
24,329
<p>I'm looking at some open source Java projects to get into Java and notice a lot of them have some sort of 'constants' interface.</p> <p>For instance, <a href="http://www.processing.org" rel="noreferrer">processing.org</a> has an interface called <a href="http://dev.processing.org/source/index.cgi/tags/processing-1....
<p>It's generally considered bad practice. The problem is that the constants are part of the public "interface" (for want of a better word) of the implementing class. This means that the implementing class is publishing all of these values to external classes even when they are only required internally. The constant...
<p>This came from a time before Java 1.5 exists and bring enums to us. Prior to that, there was no good way to define a set of constants or constrained values.</p> <p>This is still used, most of the time either for backward compatibility or due to the amount of refactoring needed to get rid off, in a lot of project.</...
41,477
<p>I'm doing some PHP work recently, and in all the code I've seen, people tend to use few methods. (They also tend to use few variables, but that's another issue.) I was wondering why this is, and I found this note "A function call with one parameter and an empty function body takes about the same time as doing 7-8 $l...
<p>I think Joomla and Wordpress are not the greatest examples of <em>good</em> PHP code, with no offense. I have nothing personal against the people working on it and it's great how they enable people to have a website/blog and I know that a lot of people spend all their free time on either of those projects but the co...
<p>If you develop web applications with a MVC architectural pattern, you can greatly benefit from caching and serialization. You can cache views, or portions of it, and you can serialize models.</p> <p>From experience, models often parse and generate most of the data that's being displayed. If you know a certain model...
22,728
<p>My Visual Studio 2005 is storing the info about which projects and solutions go with which source control repositories in the .sln and .csproj files. Is it possible to make it store that binding information in some external file instead?</p> <p>The reason I wish the info were stored outside the solution/project fil...
<p>VisualSVN does not use the native source control ecosystem plugin (SCC) so thus does not pollute your solution or project file. It is commercial licensed but very reasonable &lt; $50. Thus allowing you to continue to use the nasty VSS (although ideally exclude .svn directories)</p>
<p>A coworker wrote this NAnt task for removing bindings</p> <p><a href="http://www.atalasoft.com/cs/blogs/jake/archive/2008/05/21/2custom-nant-task-for-removing-tfs-bindings.aspx" rel="nofollow noreferrer">http://www.atalasoft.com/cs/blogs/jake/archive/2008/05/21/2custom-nant-task-for-removing-tfs-bindings.aspx</a></...
15,832
<p>Is there a way to tell SQL Server 2008 Express to log every query (including each and every SELECT Query!) into a file?</p> <p>It's a Development machine, so the negative side effects of logging Select-Queries are not an issue.</p> <p>Before someone suggests using the SQL Profiler: This is not available in Express...
<p>SQL Server Profiler: </p> <ul> <li>File → New Trace</li> <li>The "General" Tab is displayed.</li> <li>Here you can choose "Save to file:" so its logged to a file.</li> <li>View the "Event Selection" Tab</li> <li>Select the items you want to log. </li> <li>TSQL → SQL:BatchStarting will get you sql selects</li> <li>...
<p>I would either use triggers or use a third party software such as Red Gate to check out your SQL log files.</p>
15,054
<p>Given a username and a password for a domain user, what would be the best way to authenticate that user programatically?</p>
<p>It appears that .NET 3.5 added a new namespace to deal with this issue - System.DirectoryServices.AccountManagement. Code sample is below:</p> <pre><code>Private Function ValidateExternalUser(ByVal username As String, ByVal password As String) As Boolean Using context As PrincipalContext = New PrincipalContext(...
<p>You can use some hacks to <strong>authenticate</strong> only.</p> <pre><code>Try Dim directoryEntry as New DirectoryEntry("LDAP://DomainController:389/dc=domain,dc=suffix", "username", "password") Dim temp as Object = directoryEntry.NativeObject return true Catch return false End Try </code></pre> ...
5,072
<p>I am building a utility page for a web app that I am working on. I have an element that I want to use as a "console" of sorts.</p> <p>I get entries for the console via Ajax calls (using prototype's <code>Ajax.PeriodicalUpdater</code>).</p> <p>The problem I'm having is that when I insert new lines to the bottom o...
<pre><code>new Ajax.PeriodicalUpdater(container, url, { onComplete: function() { (function() { container.scrollTop = container.scrollHeight; }).defer(); } }); </code></pre>
<p>Heh, I was building almost exactly the same thing (an Ajax console) and had issues with my overflowed div not scolling all the way to the bottom.</p> <p>And Stack Overflow helped me solve it! Hope it helps you too!</p> <p><a href="https://stackoverflow.com/questions/13362/scrolling-overflowed-divs-with-javascript"...
30,997
<p>I am running blazeds on the server side. I would like to filter http requests using an http header. My goal is to send extra parameters to the server without changing the signatures of my blazeds services.</p> <p>On the client side, I am using Flex <strong>RemoteObject</strong> methods. </p> <p>With Flex WebServic...
<p>I couldnt modify http request from flex, instead I can add custom headers to the <code>mx.messaging.messages.IMessage</code> that <code>RemoteObject</code> sends to the server and there, extending <code>flex.messaging.services.remoting.adapters.JavaAdapter</code> (used for accessing Spring beans), it's posible to re...
<p>You can debug the $GLOBALS in PHP to see that. I think this is in the </p> <pre><code>$GLOBALS['HTTP_RAW_POST_DATA']; </code></pre> <p>or you can simple do </p> <pre><code>file_get_contents('php://input'); </code></pre>
10,724
<p>I am using the RSA Algorithm for encryption/decryption, and in order to decrypt the files you have to deal with some pretty big values. More specifically, things like </p> <pre><code>P = C^d % n = 62^65 % 133 </code></pre> <p>Now that is really the only calculations that ill be doing. I have tried using Matt McC...
<p>I'd suggest using <a href="http://gmplib.org/" rel="noreferrer">gmp</a>, it can handle arbitrarily long ints and has decent C++ bindings.</p> <p>afaik on current hardware/sofware long longs are 64bit, so unsigned can handle numbers up to (2**64)-1 == 18446744073709551615 which is quite a bit smaller than numbers yo...
<p>The fact, that you have a problem using some biginteger library doesn't mean, that it's a bad approach. </p> <p>Using long long is definitely a bad approach. </p> <p>As others said already using a biginteger library is probably a good approach, but You have to post more detail on haw you use mentioned library fo...
15,131
<p>I have an object that implements <a href="http://www.php.net/~helly/php/ext/spl/interfaceArrayAccess.html" rel="nofollow noreferrer">ArrayAccess</a>, <a href="http://www.php.net/~helly/php/ext/spl/interfaceIterator.html" rel="nofollow noreferrer">Iterator</a> and <a href="http://www.php.net/~helly/php/ext/spl/interf...
<p>Recent changes in PHP prevent ArrayIterators form being manipulated using the standard array functions (reset, next, etc).</p> <p>This should be restored soon: <a href="http://news.php.net/php.internals/42015" rel="nofollow noreferrer">http://news.php.net/php.internals/42015</a></p>
<p>Is <a href="http://www.php.net/~helly/php/ext/spl/classArrayIterator.html" rel="nofollow noreferrer">ArrayIterator</a> not what you're looking for? Or what about <a href="http://www.php.net/~helly/php/ext/spl/classArrayObject.html" rel="nofollow noreferrer">ArrayObject</a>, which seems to be SPL's interface for wha...
40,727
<p>Is there a Entity Attribute Value framework out there for PHP/MySQL? I'm starting to write my own, but I feel like its been done already. Any suggestions?</p>
<p>I think <a href="http://www.magentocommerce.com/wiki/" rel="nofollow noreferrer">Magento</a> makes use of an EAV style architecture, might be worth having a look in there. Magento is an ecommerce platform based on the Zend Framework.</p>
<p>There does not currently appear to be an EAV Framework in PHP / MySQL; however, I did find these two links that might be of some assistance:</p> <p><a href="http://www.planetmysql.org/entry.php?id=14025" rel="nofollow noreferrer"><a href="http://www.planetmysql.org/entry.php?id=14025" rel="nofollow noreferrer">http...
27,681
<p>Do you have any sugestions of tools to ease the task of understanding C/C++ code? We just inherited a large piece of software written by others and we need to quickly get up to speed on it. Any advice on tools that might simplify this task?</p>
<p><a href="http://sourceinsight.com" rel="noreferrer">SourceInsight</a> and <a href="http://www.scitools.com" rel="noreferrer">Understand for C++</a> are the best tools you can get for c/c++ code analysis including flow charts.</p>
<p><a href="http://www.doxygen.nl/" rel="nofollow noreferrer">doxygen</a> is a free doc-generating tool (similar to Javadoc) that will also produce relationship graphs as well.</p>
18,474
<p>In adobe Flex datagrid height is equally to fix height . I want to make datagrid height is depend data . </p>
<p>You can set each row of the datagrid to fit based on the contents of a particular column of that row by setting the "variableRowHeight" attribute to true on the datagrid and setting the "wordWrap" attribute to true on the dataGridColumn that will contain the variable height content.</p>
<p>Thanks Brat for your answer, that worked for me(in a way). There is just a little modification,when we calculate the height using above calculation a vertical scroll appears, we also need to set <strong><code>verticalScrollPolicy = "off"</code></strong> so that it never shows</p>
34,093
<p>I have some assembly that references NUnit and creates a single test class with a single test method. I am able to get the file system path to this assembly (e.g. "C:...\test.dll"). I would like to programmatically use NUnit to run against this assembly.</p> <p>So far I have:</p> <pre><code>var runner = new Simple...
<p>If you want to open in a <em>console mode</em>, add <strong>nunit-console-runner.dll</strong> reference and use:</p> <pre><code>NUnit.ConsoleRunner.Runner.Main(new string[] { System.Reflection.Assembly.GetExecutingAssembly().Location, }); </code></pre> <p>If you want to open in a <em>gui mode</em>, ad...
<p>"What is the secret to getting Assembly.Load to work?"</p> <p>System.Reflection.Assembly.Load takes an string containing an assembly name, not a path to a file.</p> <p>If you want to load an assembly from a file use:</p> <pre><code>Assembly a = System.Reflection.Assembly.LoadFrom(pathToFileOnDisk); </code></pre> ...
23,695
<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>
<p><a href="http://docs.oracle.com/javase/6/docs/api/javax/imageio/ImageIO.html" rel="noreferrer">ImageIO</a> can be used to load JPEG files and save PNG files (also into a <code>ByteArrayOutputStream</code> if you don't want to write to a file).</p>
<pre><code>BufferedImage bufferGambar; try { bufferGambar = ImageIO.read(new File("ImagePNG.png")); // pkai type INT karna bertipe integer RGB bufferimage BufferedImage newBufferGambar = new BufferedImage(bufferGambar.getWidth(), bufferGambar.getHeight(), BufferedImage.TYPE_INT_RGB); newBufferGambar.c...
46,500
<p>We use an IBM database known as Universe that holds all of our user id's, passwords, and profile information in a table called USERINFO. </p> <p>Can I use the Membership Provider to connect to this database and authenticate the user? </p> <p>The database access is actually through a web service since we don't hav...
<p>As mentioned above, you'll need to create a custom membership provider which a fairly straightforward. You'll create a .NET class that inherits from System.Web.Security.MembershipProvider. There are several methods that need to be overriden in your class, but most are not even used by the MVC account controller. The...
<p>You'll have to create a custom provider for that. It isn't very hard, as long as you can access the web service without an issue.</p>
9,718
<p>I am working on some code coverage for my applications. Now, I know that code coverage is an activity linked to the type of tests that you create and the language for which you wish to do the code coverage.</p> <p>My question is: Is there any possible way to do some generic code coverage? Like in, can we have a set...
<p>I'm not sure that generic coverage tools are the holy grail, for a couple of reasons:</p> <ol> <li>Coverage is not a goal, it's an instrument. It tells you which parts of the code are not entirely hit by a test. It does not say anything about how good the tests are.</li> <li>Generated tests can not guess the semant...
<p>This is usually achieved by combining static code analysis (Coverity, Klockwork or their free analogs) with dynamic analysis by running a tests against instrumented application (profiler + memory checker). Unfortunately, this is hard to automate test algorythms, most tools are kind of "recorders" able to record traf...
45,692
<p>Should you always check parameters and throw exceptions in .NET when the parameters are not what you expected? E.g. null objects or empty strings?</p> <p>I started doing this, but then thought that this will bloat my code a lot if it’s done on every single method. Should I check parameters for both private and publ...
<p>My two cents: All your public methods should always check the validity of the parameters being passed in. This is typically called "programming by contract" and is a great way to catch errors quickly and avoid propagating them through your private functions which many would argue (including myself) shouldn't be unit...
<p>Well, it depends. If your code is going to pick up the null anyway, and throw an exception then, it probably makes more sense to ensure that you have sensible clean-up code. If it might not be detected otherwise, or clean-up may be long running, or there might be an out-of-process call (e.g. database) you are probab...
27,190
<p>What are the real overhang limits? I see a lot online about 45 %, then up to 60 %, but I'm routinely doing them at up to 90 % for &quot;shortish&quot; distances and 80%+ for several centimeters at a time. I haven't tried to see how far I can do it, since I don't have filament to waste on that sort of thing.</p> <p>I...
<p>It is very difficult to determine a definitive number/value for the overhang angle, this is very dependent on the temperature, speed, material, nr. of walls amount of cooling fan percentage and the effectivity of the fan duct and your object geometry. Probably more settings are applicable.</p> <p>You could find out ...
<p>From my limited experience there is very little in the way of overhangs that won't print for a short distance. Depending what you're printing and what it's end use will be.</p> <p>In this case it needs to be robust enough for daily use holding napkins and toothpicks and cutlery at a restaurant.</p> <p>The model in t...
2,127
<p>I'm processing a file, line-by-line, and I'd like to do an inverse match. For instance, I want to match lines where there is a string of six letters, but only if these six letters are not '<em>Andrea</em>'. How should I do that?</p> <p>I'm using <a href="https://en.wikipedia.org/wiki/RegexBuddy" rel="noreferrer">Re...
<pre><code>(?!Andrea).{6} </code></pre> <p>Assuming your regexp engine supports negative lookaheads...</p> <p>...or maybe you'd prefer to use <code>[A-Za-z]{6}</code> in place of <code>.{6}</code></p> <p>Note that lookaheads and lookbehinds are generally not the right way to &quot;inverse&quot; a regular expression mat...
<p>In Perl you can do:</p> <pre><code>process($line) if ($line =~ !/Andrea/); </code></pre>
19,880
<p>Say you have 100 directories and for each directory you have a file named .pdf stored somewhere else. If you want to move/copy each file into the directory with the same name, can this be done on the Windows command line?</p>
<p>You can do it using the <a href="http://technet.microsoft.com/en-us/library/bb490909.aspx" rel="nofollow noreferrer">FOR command</a>. Something in the line of:</p> <pre><code>for /f %%f in ('dir /s /b c:\source\*.pdf') do copy "%%f" c:\target </code></pre> <p>If you have a list of the file names w/ full path in a ...
<p>You would need to write a script to iterate through each file (and its path), extract the filename-'.pdf' and then move the file to the directory of the same name</p>
22,577
<p>We are replacing the exception handling system in our app in order to conform to Vista certification, but the problem is how to force certain exceptions to be thrown, so that we can check the response.</p> <p>Unfortunately the whole app was written without taking into consideration proper layering, abstraction or i...
<p>Introduce this code:</p> <pre><code>throw new Exception("test"); </code></pre> <p>If you need the exception to always be there (i.e., not just test code), then hide it behind a command-line parameter.</p> <pre><code>C:\Users\Dude&gt; myapp.exe /x </code></pre>
<p>I might not have a clue about this but my first thought was to use aspect oriented programming to throw exceptions when certain code is run. spring.net has <a href="http://www.springframework.net/docs/1.2.0-RC1/reference/html/aop.html" rel="nofollow noreferrer">support</a> for this, though I don't know how well it w...
29,645
<p>It looks like all the methods for loading SQLite involve loading from a named file using a string. I would like to load SQlite database from memory.</p> <p>The database is already loaded into memory.</p>
<p>Use a special file name, <code>:memory:</code></p> <pre><code>sqlite3_open(":memory:", &amp;db); </code></pre> <p><code>libsqlite</code> must have been compiled <strong>without</strong> <code>SQLITE_OMIT_MEMORYDB</code> defined, as pointed out in <a href="http://www.sqlite.org/compile.html" rel="noreferrer">SQLite...
<p>There is a memvfs implementation at</p> <p><a href="http://article.gmane.org/gmane.comp.db.sqlite.general/46450" rel="nofollow noreferrer">article.gmane.org/gmane.comp.db.sqlite.general/46450</a></p>
35,028
<p>Learning a little about T-SQL, and thought an interesting exercise would be to generate a Mandelbrot set with it.</p> <p>Turns out someone already has (and recently, it appears). I'll let someone else post it as an answer, but I'm curious what optimizations can be made.</p> <p>Alternately, what would you do to ma...
<p>From <a href="http://thedailywtf.com/Articles/Stupid-Coding-Tricks-The-TSQL-Madlebrot.aspx" rel="nofollow noreferrer">thedailywtf.com</a></p> <pre><code>-- AUTHOR: GRAEME JOB -- CREATED: 12-OCT-2008 -- BECAUSE: SINGLE SQL COMMAND &lt; 50 LINES. JUST BECAUSE. WITH XGEN(X, IX) AS ( -- X DIM GENERA...
<pre><code>with points (x1,y1,x2,y2,depth) as ( select convert(float,-2.40), convert(float,-2.40), convert(float,2.40), convert(float,2.40), 8 union all select x1,y1,(x1+x2)/2,(y1+y2)/2,depth-1 from points where depth&gt;0 union all select (x1+x2)/2,y1,x2,(y1+y2)/2,depth-1 from points where depth&gt;0 u...
40,645
<p>With very large amounts of ram these days I was wondering, it is possible to allocate a single chunk of memory that is larger than 4GB? Or would I need to allocate a bunch of smaller chunks and handle switching between them?</p> <p>Why??? I'm working on processing some openstreetmap xml data and these files are hug...
<p>Short answer: Not likely</p> <p>In order for this to work, you absolutely would <strong>have</strong> to use a 64-bit processor. Secondly, it would depend on the Operating System support for allocating more than 4G of RAM to a single process.</p> <p>In theory, it would be possible, but you would have to read the ...
<p>Like everyone else said, getting a 64bit machine is the way to go. But even on a 32bit machine intel machine, you can address bigger than 4gb areas of memory if your OS and your CPU support <a href="http://en.wikipedia.org/wiki/Physical_Address_Extension" rel="nofollow noreferrer">PAE</a>. Unfortunately, 32bit WinXP...
21,845
<p>WCF is Microsoft's replacement for .Net Remoting and Web services. It's critical to understand if you are a .NET component developer. </p> <p>The best reference for WCF appears to be (by word of mouth, blogs and Amazon) Juval Lowy's "Programming WCF Services," published by O'Reilly.</p> <p>This book is advertise...
<p>The latest version is maintained on IDesign's site here:</p> <p><a href="http://idesign.net/Downloads/GetDownload/1887" rel="nofollow noreferrer">http://idesign.net/Downloads/GetDownload/1887</a></p> <p>Older version are available on the O'Reilly site.</p> <p>Programming WCF Services 3rd Edition (PWSTE) Samples: ...
<p>I went through the same process. But, luckily, I needed to download InProc Factory project from Idesign's site and there it was, the ServiceModelEx is bundled with InProc Factory example.</p> <p>It is stored under <a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;tabid=11#WCFEssentials" rel...
42,563
<p>I get a 404 response from .Net MVC when I try to make a request where my search term ends with a <code>.</code> (period). This is the route that I'm using:</p> <pre><code>routes.MapRoute( "Json", "Remote.mvc/{action}/{searchTerm}/{count}", new { controller="Remote", c...
<p>I have solved a similar issue (I had trouble with paths like /music/R.E.M.) I've added the following line into the system.webServer/handlers section (adjusted for your case):</p> <pre><code> &lt;add name="UrlRoutingHandler" type="System.Web.Routing.UrlRoutingHandler, System.Web, Version=4.0.0.0, Culture=neutral, Pu...
<p>If you are using .NET 4.0, you can set this flag in the system.web section of your web.config and it will be allowed:</p> <pre><code>&lt;httpRuntime relaxedUrlToFileSystemMapping="true" /&gt; </code></pre> <p>I've tested it and it works. <a href="http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in...
43,119
<p>I need to validate an XML string (and not a file) against a DTD description file. </p> <p>How can that be done in <code>python</code>?</p>
<p>Another good option is <a href="http://lxml.de/validation.html" rel="noreferrer">lxml's validation</a> which I find quite pleasant to use.</p> <p>A simple example taken from the lxml site:</p> <pre><code>from StringIO import StringIO from lxml import etree dtd = etree.DTD(StringIO("""&lt;!ELEMENT foo EMPTY&gt;""...
<p>from the examples directory in the libxml2 python bindings:</p> <pre><code>#!/usr/bin/python -u import libxml2 import sys # Memory debug specific libxml2.debugMemory(1) dtd="""&lt;!ELEMENT foo EMPTY&gt;""" instance="""&lt;?xml version="1.0"?&gt; &lt;foo&gt;&lt;/foo&gt;""" dtd = libxml2.parseDTD(None, 'test.dtd')...
3,661
<p>Recently, I found myself having to write up some concerns I have about race conditions in an application that is in development (not by me). This will likely be brought to the attention of stakeholders who are non-technical and with whom I do not have a direct line of communication, so my explanation needs to be in...
<p>Company X has $1,000 in the bank. X pays a rent of $2,000 and received a payment of $10,000 for services rendered to company Y. However, due to a race condition, X is in deficit of $1,000 and is now applying for bankruptcy. =(</p> <p>You might want to explain how the bank handles company X's account in this way: Ba...
<p>Send them to <a href="http://en.wikipedia.org/wiki/Race_condition" rel="nofollow noreferrer">Race Condition</a> on Wikipedia. </p> <p>The first part will make some sense, and the rest (not shown below) will make you look smart since they will assume you understand it.</p> <p>"A race condition or race hazard is a f...
39,979
<p>We're all familiar with the horror that is C# event declaration. To ensure thread-safety, <a href="http://blogs.msdn.com/brada/archive/2005/01/14/353132.aspx" rel="noreferrer">the standard is to write something like this</a>:</p> <pre><code>public event EventHandler SomethingHappened; protected virtual void OnSome...
<p>It will still work with events that have an explicit add/remove - you just need to use the delegate variable (or however you've stored the delegate) instead of the event name.</p> <p>However, there's an easier way to make it thread-safe - initialize it with a no-op handler:</p> <pre><code>public event EventHandler...
<p>To take the above answers a step further you could protect yourself against one of your handlers throwing an exception. If this were to happen then the subsequent handlers wouldn't be called.</p> <p>Likewise, you could taskify the handlers to prevent a long-running handler from causing an excessive delay for the la...
28,659
<p>I have a home-spun 2000 lines VBScript script, that has become progressively slow with each additional code I add. It was created as a private debugging aid and now that it has become really useful. I want to polish it and ship it along with our product.</p> <p>I thought I could speed it up by compiling it and maki...
<p>I would recommend downloading Visual Basic Express Edition (<a href="http://www.microsoft.com/express/vb/" rel="nofollow noreferrer">http://www.microsoft.com/express/vb/</a>) and port your tool to VB.Net. However, that approach has one drawback - your program will be dependent on .Net. For the most part that shouldn...
<p>It's hard to say without knowing more of what the program is doing or how much data it's processing.</p> <p>I agree with Franci - VB6 is no longer sold or supported so VB.Net would be the way to go for compiled code. (Express is free.) VBScript is not very much like VB.Net, so that might be a good bit of work to ...
17,513
<p>I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holding down the alt key at startup.</p> <p>Unfortunately, there is no obvi...
<pre><code>import java.awt.*; import java.awt.event.*; import javax.swing.JFrame; public class LockingKeyDemo { static Toolkit kit = Toolkit.getDefaultToolkit(); public static void main(String[] args) { JFrame frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { pub...
<p>I don't know much about Java (mostly code in C#) but what about having a small loader program written in C or something that then launches your Java app with some parameters (like whether or not a certain key is down)?</p>
19,388
<p>Is it ever acceptable to have a <a href="http://en.wikipedia.org/wiki/Memory_leak" rel="noreferrer">memory leak</a> in your C or C++ application?</p> <p>What if you allocate some memory and use it until the very last line of code in your application (for example, a global object's destructor)? As long as the memory...
<p>No.</p> <p>As professionals, the question we should not be asking ourselves is, "Is it ever OK to do this?" but rather "Is there ever a <em>good</em> reason to do this?" And "hunting down that memory leak is a pain" isn't a good reason.</p> <p>I like to keep things simple. And the simple rule is that my program ...
<p>As long as your memory utilization doesn't increase over time, it depends. If you're doing lots of complex synchronization in server software, say starting background threads that block on system calls, doing clean shutdown may be too complex to justify. In this situation the alternatives may be:</p> <ol> <li>Your...
34,411
<p>Some e-Marketing tools claim to choose which web page to display based on where you were before. That is, if you've been browsing truck sites and then go to Ford.com, your first page would be of the Ford Explorer.</p> <p>I know you can get the immediate preceding page with HTTP_REFERRER, but how do you know where t...
<p>Javascript this should get you started: <a href="http://www.dicabrio.com/javascript/steal-history.php" rel="noreferrer">http://www.dicabrio.com/javascript/steal-history.php</a><br /> There are more nefarius means to: <a href="http://ha.ckers.org/blog/20070228/steal-browser-history-without-javascript/" rel="noreferre...
<p>The browser history can't be directly accessed, but you can compare a list of sites with the user's history. This can be done because the browser attributes a different CSS style to a link that hasn't been visited and one that has.</p> <p>Using this style difference you can change the content of you pages using pu...
7,126
<p>I want to model a heart shape in 3D with as little code needed as possible and without using external model files.</p> <p>In 2D, I can use some Bézier curves to draw a heart shape, and I could extrude this to get a simple 3D heart shape, but this doesn't look like the shape I want. The bottom of the heart should be...
<p><a href="http://mathworld.wolfram.com/HeartCurve.html" rel="nofollow noreferrer">This page at MathWorld</a> had some nice material. Although mostly in 2D it did show a couple of 3D shapes too. It has a link to <a href="http://mathworld.wolfram.com/HeartSurface.html" rel="nofollow noreferrer">this page</a>, which see...
<p>I think your direction is good.</p> <p>Model a 2D heart and extrude it to the maximal width you want.</p> <p>You can now apply additional transformation that will scale the width differently along the height.</p> <p>You can do that using a Bézier curve to form the desired scale for each location along the height....
41,892
<p>I have gone through their developer guide but haven't been able to find a way to print the value at points (in case of line charts) or after bars (bar charts).Is there a way to do it?</p>
<p>You can achieve this with a label, it's <a href="https://developers.google.com/chart/interactive/docs/gallery/barchart#Labels" rel="nofollow noreferrer">in the documentation</a> - it has an example with a bar chart.</p>
<p>I think that's not possible at the moment. I looked at the Google Chart API myself few days ago. Instead I found (and probably will use) FusionCharts Free pacakge. </p> <p>It has the features you need, plus those points can be interactive.</p>
17,870
<p>Just wondering what people think is the best practice when implementing an IValueConverter which does not have a meaningfull ConvertBack implementation (or one that is only to be used as OneWay)?</p> <p>Should it throw (and in that case what exception), return null or return some default value. </p> <p>Thoughts?</...
<p>The documentation for <a href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.data.ivalueconverter.convertback" rel="noreferrer"><code>IValueConverter.ConvertBack</code></a> recommends returning <a href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.dependencyproperty.unsetvalue" rel="nore...
<p>According Microsoft, you should return <code>DependencyProperty.UnsetValue</code></p>
33,280
<p>How do you enumerate the fields of a certificate help in a store. Specifically, I am trying to enumerate the fields of personal certificates issued to the logged on user.</p>
<p>See <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509store.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.x509store.aspx</a></p> <pre><code>using System.Security.Cryptography.X509Certificates; .....
<p>You also must use <strong>store.open()</strong> before you can access the store.</p>
12,874
<p>I cannot find an elegant way to get the return value from a stored procedure when using TableAdapters.</p> <p>It appears the TableAdapter does not support SQL stored procedure return values when using a non-scalar stored procedure call. You'd expect the return value from the auto-generated function would be the ret...
<p><a href="http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/smartclientdata/archive/2006/08/09/693113.aspx</a></p>
<p>I cannot say for certain because I have do not use TableAdapters, but you might need to look at your stored procedure and include the following around your procedure.</p> <pre><code>SET ROWCOUNT OFF BEGIN &lt;Procedure Content&gt; END SET ROWCOUNT ON </code></pre>
10,701
<p>I was looking into GWT. It seems nice, but our software have the must work without JS requirement. Is it possible?</p>
<p>No, it isn't. GWT provides a windowing toolkit that is specifically designed to run on the client, not on the server. Degraded (e.g. non-javascript) code would need to deliver complete HTML to the browser, which GWT simply does not do. It compiles your java code to a javascript file that is delivered to the client a...
<p>You could degrade gracefully by creating an html structure that is just 'good enough' (with form posts, linked menus, etc) and then have GWT attach to each part of that structure, augmenting its behavior. For example, make an HTML drop down dynamic, replace a link to another page with a component that opens a light...
42,306
<p>I'm currently looking for a possibility in Java to identify a font as symbolic like OpenOffice does. Characters with the font Windings or Webdings and so on should be rendered with the correct "pictures".</p> <p>Anyone an idea how to distinguish between normal fonts and fonts with symbols?</p>
<p>The bug <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4549043" rel="nofollow noreferrer">Java doesn't display all characters in the windows symbol font</a> gives a clue regarding a characteristic which is unique to symbol fonts.</p> <p>They are part of <a href="http://java.sun.com/j2se/1.4.2/docs/guid...
<p>I don't see any <code>SYMBOL_CHARSET</code> in my font properties file per VonC's answer.</p> <p>A simple test seems to be <a href="http://download.oracle.com/javase/6/docs/api/java/awt/Font.html#canDisplay%28char%29" rel="nofollow"><code>if( !java.awt.Font#canDisplay('a') )</code></a>. On my Windows box I get a li...
27,813
<p>What is the correct way to implement the "find as you type" behavior on a TComboBox descendant component whose style is csOwnerDrawFixed?</p>
<ol> <li>Use a TTimer (let's call it timIncSearch). Set (at design time) the following properties: Enabled:=False;<br> Interval:=400; //empirically found - it's the delay used in Windows Explorer</li> </ol> <p>...and in OnTimer you'll wrote your searching engine. Be sure that the first line here will be timIncSearch.E...
<p>First you need to decide whether you need "*my_string*" or "my_string*" functionality, meaning deciding if you would search inside the strings or just from the beginning. When you have figured that out, then you would have to buld the index of all the words entered in the combo box and search it after every keystro...
19,364
<p>I want to assign a hotkey to a function, but the keys are already used in some other functions' combination. How can I easely remove this hotkey from all these entries so I free it up and am able to asign it to the function I want?</p>
<p>I am using Visual Studio C# Express 2008, but you can go into <strong>Tools/Options/Environment/Keyboard</strong>. If you put your cursor in the <strong>Press shortcut keys</strong> field and type the key you want to remap, it will show you what commands use that key and let you clear or change the assignments.</p>
<p>Some key shortcuts are layered. So for instance while editing text the Text Editor keys override the Global ones. If you set your shortcut for the priority layer you can ignore whatever is assigned on a lower layer. So for text editing keys assign them under Text Editing and not Global to avoid them being ignored...
42,534
<p>I want to insert say 50,000 records into sql server database 2000 at a time. How to accomplish this?</p>
<p>You can use the SELECT TOP clause: in MSSQL 2005 it was extended allowing you to use a variable to specify the number of records (older version allowed only a numeric constant)</p> <p>You can try something like this: (untested, because I have no access to a MSSQL2005 at the moment)</p> <pre><code>begin declare @n ...
<p>Do you mean for a test of some kind?</p> <pre><code>declare @index integer set @index = 0 while @index &lt; 50000 begin insert into table values (x,y,z) set @index = @index + 1 end </code></pre> <p>But I expect this is not what you mean.</p> <p>If you mean the best way to do a bulk insert, use <code>BULK...
16,174
<p>In Firefox and Safari, pages that are centered move a few pixels when the page is long enough for the scrollbar to appear. If you navigate through a site that has long and short pages, the page seems to "jump" around.</p> <p>IE7 tends to leave the scroll bar visible all of the time but disables it when the page is...
<p>You could simply always enable the scrollbar:</p> <pre><code>html{ overflow: scroll; } </code></pre> <p>but that would give you the horizontal scrollbar too, this is better:</p> <pre><code>html{ overflow-y:scroll; overflow-x:auto; } </code></pre> <p>That will give you only the vertical scroll and the hori...
<p>This site contains a javascript to fix the problem which is a better solution IMO than the current one (a permanent scrollbar):</p> <p><a href="http://www.johnpezzetti.com/2011/01/31/removing-vertical-scrollbar-jump-shift-problem-a-javascript-fix-for-all-browsers" rel="nofollow">http://www.johnpezzetti.com/2011/01/...
40,143
<p>I've got a menu that contains, among other things, some most-recently-used file paths. The paths to these files can be long, so the text sometimes gets clipped like "C:\Progra...\foo.txt"</p> <p>I'd like to pop a tooltip with the full path when the user hovers over the item, but this doesn't seem possible with the...
<p>If you are creating your menu items using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.menuitem.aspx" rel="noreferrer" title="MenuItem Members">System.Windows.Forms.MenuItem</a> class you won't have a "ToolTipText" property.</p> <p>You should use the <a href="http://msdn.microsoft.com/e...
<p>Maybe you forgot to associate the tooltip with the control using <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tooltip.settooltip.aspx" rel="nofollow noreferrer">SetToolTip</a>.</p>
8,262
<p>I was wondering if it is possible to use Mono static compilation on Windows. If so, what should I do? </p>
<p>Yes it is possible,</p> <p><a href="http://www.mono-project.com/AOT#Supported_Platforms" rel="nofollow noreferrer">http://www.mono-project.com/AOT#Supported_Platforms</a></p>
<p>Yes it is possible,</p> <p><a href="http://www.mono-project.com/AOT#Supported_Platforms" rel="nofollow noreferrer">http://www.mono-project.com/AOT#Supported_Platforms</a></p>
42,777
<p>I have created a PHP-script to update a web server that is live inside a local directory. I'm migrating the script into Python. It works fine for the most part, but after a PUT command, the size of the file appears to change. Thus, the size of the file is different from that of the file on the server. </p> <p>Once ...
<p>Do you need to open the locfile in binary using <code>rb</code>?</p> <pre><code>f = open (locfile, "rb") </code></pre>
<p>Small files take up a whole node on the file system whatever the size is.</p> <p>My host tends to report all small files as 4KB in ftp but gives an accurate size in a shell so it might be a 'feature' common to ftp clients.</p>
2,448
<p>I'm looking for a word processing component for .NET that would act like an embedded MS Word in my WinForm/WPF .NET app. The main goal being for users to be able to create rich formatted text. I don't really want to have to write a highly custom RichTextBox component. Any suggestions?</p>
<p>We're using the TXTextControl release 14 for .Net and we're very happy about it. It has all the positive things you can ask: cheap, well supported, up to date with latest Word releases, fast and not really hungry for memory or resources. The included word processor sample is very good code and we converted it in a p...
<p>if you use WPF, you can check on <a href="http://www.wpftexteditor.com" rel="nofollow noreferrer">http://www.wpftexteditor.com</a></p>
20,485
<p>Can anyone recommend a lightweight JavaScript XML-RPC library?</p> <p>After researching this a while ago, I couldn't find anything I was comfortable with, so I kinda ended up writing my own. However, maybe that was stupid, as there must be something suitable out there!?</p> <p>My own pseudo-library is mainly missi...
<p>I know this two libraries, that you can basically use to convert your XML-RPC responses to JSON:</p> <ul> <li><a href="http://www.thomasfrank.se/xml_to_json.html" rel="nofollow noreferrer">XML to JSON Converter</a></li> <li><a href="http://goessner.net/download/prj/jsonxml/" rel="nofollow noreferrer">xml2json.js</a...
<p>I could use this too. Generic XML to Json is rather unconvenient for XML-RPC.</p>
28,288
<p>Is it possible to use AIX's mksysb and savevg to create a bootable tape with the rootvg and then append all the other VGs?</p>
<p>Answering my own question:</p> <p>To backup, use a script similar to this one:</p> <pre> tctl -f/dev/rmt0 rewind /usr/bin/mksysb -p -v /dev/rmt0.1 /usr/bin/savevg -p -v -f/dev/rmt0.1 vg01 /usr/bin/savevg -p -v -f/dev/rmt0.1 vg02 /usr/bin/savevg -p -v -f/dev/rmt0.1 vg03 ...etc... tctl -f/dev/rmt0 rewind </pre>...
<p>First, use savevg to backup any extra volume groups to a file system on the rootvg:</p> <pre><code>savevg -f /tmp/vgname </code></pre> <p>Compress it if it will be too large, or use the -i option to exclude files. The easiest way is to exclude all files on the volume group and restore those off of the regular bac...
15,662
<p>In a corporate development environment writing mostly administrative software, should every developer use their own database instance, or should they use a central database instance during development? What are the advantages and disadvantages of each approach? What about other environments and other products?</p>
<p>If you all share the same database, you might have some issues if someone make a structure change to the database and that the code is not "Synchronized" with it.</p> <p>I highly recommend one DB per developer for the only reason that you don't want to do "write" test to see someone else override you right after. A...
<p>I'd suggest to use one instance of the database. You don't want your database to be a moving target.</p>
29,035
<p>I have a buddy that's having a hard time with the language barrier. I tried to think of any IDEs that are also available in Spanish, but couldn't think of any. Any ideas?</p>
<p>Microsoft Visual Studio is avaible in spanish<br> <a href="http://en.wikipedia.org/wiki/Microsoft_Visual_Studio" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Microsoft_Visual_Studio</a><br> <a href="http://msdn.microsoft.com/en-gb/vstudio/default.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en...
<p>Visual Studio is available in most "tier one" languages, including Spanish and Japanese. However, not all documentation is translated.</p>
24,648
<p>On <a href="http://andrew.hedges.name/blog/" rel="nofollow noreferrer">my blog</a>, I display in the right nav the 10 most popular articles in terms of page hits. Here's how I get that:</p> <pre><code>SELECT * FROM entries WHERE is_published = 1 ORDER BY hits DESC, created DESC LIMIT 10 </code></pre> <p>What I wou...
<p>I'm not entirely sure you can by using the table structure you suggest in your query. The only way I can think of is to get the top 10 by way of highest <em>average</em> hits per day. By doing that, your query becomes:</p> <pre><code>SELECT *, AVG(hits / DATEDIFF(NOW(), created)) as avg_hits FROM entries WHERE is_p...
<p>I guess you could have a hits_day_count column, which is incremented on each view, and a hits_day_current.</p> <p>On each page-view, you check if the hits_day_current column is today. If not, reset the hit count.. Then you increment the hits_day_count column, and set hits_day_current to the current datetime.</p> <...
31,981
<p>I have a WebApplication project, a business logic project, and a WebDeployment project for the web app. </p> <p>When I build solution, the deployment "Release" bin contains 1 dll for each of the projects - so I get one for MyWeb.dll, MyWebBusiness.dll, and MyWebDeploy.dll. </p> <p>When I try to run the site, it ...
<p>Some reasons I can think of:</p> <ul> <li>You have an <em>App_Code</em> directory in your project</li> <li>You have a <em>CodeFile</em> page directive in the some page markup instead of <em>CodeBehind</em></li> </ul>
<p>There's a great forum post on this at: <a href="http://forums.asp.net/t/980517.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/980517.aspx</a></p> <p>Seems that all it takes is the right bit of code in the Web Application project and and VS says 'Oh, this is a website project so I'd better autocompile it', ...
46,075
<p>I've made a custom DataGridViewCell that displays a custom control instead of the cell; but if the DataGridView uses shared rows, then the custom control instance is also shared, so you get strange behaviour (for example, hovering over buttons highlights all the buttons). Also, I can't access the DataGridViewCell.S...
<p>Try to set a Tooltip Text in one cell of the Row</p> <p>A row cannot be shared in any of the following situations: The row contains a single selected cell that is not in a selected column. The row contains a cell with its ToolTipText or ContextMenuStrip properties set. The row contains a DataGridViewComboBoxC...
<pre><code>DataGridViewRowCollection.AddRange(params DataGridViewRow[] dataGridViewRows) </code></pre> <p>with</p> <pre><code>new[]{someDataGridviewRow} </code></pre> <p>worked for me.</p>
28,403
<p>Is there any chance to get this work? I want my tests to be run by nunit2 task in NAnt. In addition I want to run NCover without running tests again. </p>
<p>I figured it out. You change the path of the NUnit launcher to that of TeamCity's own. Here is an example:</p> <pre><code> &lt;mkdir dir="${build}/coverage" failonerror="false"/&gt; &lt;!-- run the unit tests and generate code coverage --&gt; &lt;property name="tools.dir.tmp" value="${tools.dir}"/&gt; ...
<p>I am having to do the same thing. I think the best we can hope for is to break open the NUnit jar file that comes with TeamCity and writing a custom task that integrates NUnit2 and NCover. I wish this wasn't so, but the NUnit2 task does not produce any visible output, so TeamCity is obviously not reading StdOut for ...
6,564
<p>I have made a Windows client application where I use the AxAcroPDF control to display a pdf-file on a form.</p> <p>It seems to me that after I have upgraded my Acrobat reader from version 8 to version 9 the LoadFile method returns true when the file is opened correctly, where version 8 returned false. Is this a cor...
<p>I realize this thread is a little old, but I made the same observation and I had to change my code for the 9.0 version. </p>
<p>Not at all! The version of Acrobat doesn't influence in the way AxAcroPDF control works. You must debug to see what happens</p>
43,704
<p>How to calculate the length (in pixels) of a string in Java?</p> <p>Preferable without using Swing.</p> <p>EDIT: I would like to draw the string using the drawString() in Java2D and use the length for word wrapping.</p>
<p>If you just want to use AWT, then use <a href="http://docs.oracle.com/javase/6/docs/api/java/awt/Graphics.html#getFontMetrics()" rel="noreferrer"><code>Graphics.getFontMetrics</code></a> (optionally specifying the font, for a non-default one) to get a <code>FontMetrics</code> and then <a href="http://docs.oracle.com...
<p>I personally was searching for something to let me compute the multiline string area, so I could determine if given area is big enough to print the string - with preserving specific font.</p> <pre><code>private static Hashtable hash = new Hashtable(); private Font font; private LineBreakMeasurer lineBreakMeasurer; p...
32,272
<p>Currently I have a custom tool which generates vanilla-SQL (only using standard SQL), from our Data-models that sets up database schemas and initial data for our new databases, and do version patches, etc... This part is all fine and dandy right now.</p> <p>However running these SQL scripts against all the differen...
<p>I use <a href="http://www.oracle.com/technology/products/database/sql_developer/index.html" rel="nofollow noreferrer">SQL Developer</a>, it's really cool.</p> <p>It runs in any plataform (is a Java application), you could connect to any database vendor and it's free.</p>
<p>I use <a href="http://www.squirrelsql.org/" rel="nofollow noreferrer"><strong>Squirrel</strong></a>, like SQL Developer it is a java application which is free.</p> <p><strong>Description</strong></p> <blockquote> <p>SQuirreL SQL Client is a graphical Java program that will allow you to view the structure of ...
36,809
<p>I have a virtual machine (VMware) with Mercury Quick Test Professional 9.2 installed. I have a script to test an application, written in VB.NET using the Infragistics library.</p> <p>If I access this virtual machine using my laptop (using Remote Desktop), everything works fine, the script completes without a proble...
<p>OK. I've found the problem. In fact, the script was failing silently because that's what the person who wrote the script told it to do. It couldn't validate something which was off screen, so the script failed.</p> <p>The problem was the QTP definition of 'off screen'. I have two screens attached to my laptop, the ...
<p>QTP does <strong>not</strong> use screen coordinates except as a last resort, if the objects are identified as high level objects (<code>SwfTable</code> in this case) you should be OK, if however QTP doesn't recognise the object it falls back to <code>WinObject</code> and screen coordinates. </p> <p>If you're usin...
11,680
<p>I want to create basic line, bar, pie and area charts for .NET 3.5 WinForms and I'm interested in finding a free, mature, open-source .NET (preferably C# based) project to help me accomplish that. I would consider a WPF based project, however I'm more comfortable in GDI+ so I'd rather it used System.Drawing and/or ...
<p><a href="http://zedgraph.org/" rel="nofollow noreferrer">ZedGraph</a>. 'Nuff said.</p>
<p>This one's quite nice: <a href="http://zedgraph.org" rel="nofollow noreferrer">zed graph</a></p>
12,507
<p>I have a single HW interface I want to use from two applications (processes) on the same workstation. The HW requires a single initialization call then either app uses the same function (in the same library) to do many transactions with the HW. </p> <p>So each app should act like this:</p> <pre><code>main() /...
<p><a href="http://linux.die.net/man/7/sem_overview" rel="noreferrer">POSIX semaphore</a> is the way to go. Since you want to share the same semaphore across processes, you need to use a named semaphore.:</p> <blockquote> <p>A named semaphore is identified by a name of the form /somename. Two processes can opera...
<p>I assume that </p> <blockquote> <p>...that is shared between two applications?</p> </blockquote> <p>means that you want these two things to be running as separate processes? If that's not true, and they are running as a single process (with multiple threads), then the suggestions of semaphores and mutexes are th...
30,934
<p>I'm trying to configure my WAR project build to fail if the line or branch coverage is below given thresholds. I've been using the configuration provided on page 455 of the excellent book <a href="http://oreilly.com/catalog/9780596527938/" rel="noreferrer">Java Power Tools</a>, but with no success. Here's the releva...
<p>To my knowledge, <em>if the <code>&lt;haltOnFailure&gt;</code> element is set to true and any of the specified checks fails, then Cobertura will cause the build to fail</em> which is what you're asking for. But actually, this element defaults to <code>true</code> if you do not specify it so you <strong>don't have to...
<p>mvn clean install -Dcobertura.skip=true</p>
23,899
<p>Could someone explain why this works in C#.NET 2.0:</p> <pre><code> Nullable&lt;DateTime&gt; foo; if (true) foo = null; else foo = new DateTime(0); </code></pre> <p>...but this doesn't:</p> <pre><code> Nullable&lt;DateTime&gt; foo; foo = true ? null : new DateTime(0); </code></pr...
<p>The compiler is telling you that it doesn't know how convert <code>null</code> into a <code>DateTime</code>.</p> <p>The solution is simple:</p> <pre><code>DateTime? foo; foo = true ? (DateTime?)null : new DateTime(0); </code></pre> <p>Note that <code>Nullable&lt;DateTime&gt;</code> can be written <code>DateTime?</co...
<p>Another solution similar to the accepted is to use C#'s <a href="http://msdn.microsoft.com/en-us/library/xwth0h0d%28v=vs.100%29.aspx" rel="nofollow noreferrer"><code>default</code></a> keyword. While defined using generics, it is actually applicable to any type.</p> <p>Example usage applied to the OP's question:</p...
37,825