instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>As a follow up to "<a href="https://stackoverflow.com/questions/105400/what-are-indexes-and-how-can-i-use-them-to-optimize-queries-in-my-database">What are indexes and how can I use them to optimise queries in my database?</a>" where I am attempting to learn about indexes, what columns are good index candidates? Spe...
<p>Indexes can play an important role in query optimization and searching the results speedily from tables. The most important step is to select which columns are to be indexed. There are two major places where we can consider indexing: columns referenced in the WHERE clause and columns used in JOIN clauses. In short, ...
<p>It should be even faster if you are using a GUID. Suppose you have the records</p> <ol> <li>100</li> <li>200</li> <li>3000</li> <li>....</li> </ol> <p>If you have an index(binary search, you can find the physical location of the record you are looking for in O( lg n) time, instead of searching sequentially O(n) t...
13,268
<p>I create a TCP socket without bothering about the port number to bind to [socket.sin_port = 0]. However later on if I want to print the port number of client how do I do that? The client C application (on Linux) creates many clients which get connected to server. To debug issues I capture the traffic on ethereal. I ...
<p>Use the getsockname() call to get the socket address and port after a successful connection.</p> <p>Edit: correct method name. Sometimes I can't copy a simple word from one window to another!</p>
<pre><code>lsof -p &lt;process id&gt; | grep TCP </code></pre>
45,242
<p>If I have a template function, for example like this:</p> <pre><code>template&lt;typename T&gt; void func(const std::vector&lt;T&gt;&amp; v) </code></pre> <p>Is there any way I can determine within the function whether T is a pointer, or would I have to use another template function for this, ie:</p> <pre><code>t...
<p>Indeed, templates can do that, with partial template specialization:</p> <pre><code>template&lt;typename T&gt; struct is_pointer { static const bool value = false; }; template&lt;typename T&gt; struct is_pointer&lt;T*&gt; { static const bool value = true; }; template&lt;typename T&gt; void func(const std::vector&...
<p>C++ 11 has a nice little pointer check function built in: <code>std::is_pointer&lt;T&gt;::value</code></p> <p>This returns a boolean <code>bool</code> value.</p> <p>From <a href="http://en.cppreference.com/w/cpp/types/is_pointer" rel="noreferrer">http://en.cppreference.com/w/cpp/types/is_pointer</a></p> <pre><co...
38,648
<p>We have an HttpHandler that deals directly with binary posts over HTTP from custom client software. The client software occasionally sends data which results in IIS 7 responding with a 400 - Bad Request. Since the "400 Bad Request" is special in that HTTP.SYS transparently handles it in kernel mode without notifying...
<p>If you know what is causing the 400, then you may be able to customise the behaviour of http.sys via the registry to deal with it:</p> <p><a href="http://support.microsoft.com/kb/820129" rel="nofollow noreferrer">http://support.microsoft.com/kb/820129</a></p> <p>However, you should be aware that there are potentia...
<p>If your custom client causes IIS to trigger HTTP 400, it's probably flawed and is not submitting valid HTTP requests according to the standard. If you can alter the client, it would be the right thing to do. Otherwise, what you're working with is not HTTP, and IIS is designed to handle HTTP requests. Therefore, you ...
44,489
<p>I'm working with LINQ to objects and have a function where in some cases I need to modify the underlying collection before calling <code>Aggregate(...)</code> and then return it to its original state before the funciton returns the results of <code>Aggregate(...)</code>. My current code looks something like this:</p...
<p>Just to check I understand you - you basically want to iterate through all of the results, just to force any side effects to take place?</p> <p>Side effects are generally a bad idea precisely because things are harder to understand with this kind of logic. Having said that, the easiest way to do it and force full e...
<p>I don't think there is a problem with your approach if you'll always use the result (since your result set is not large, it'll not consume much memory. By the way, if you do this and never use the result, it'll impose a performance loss). So, yes, this is the correct way to do it.</p>
40,511
<p>I recently started learning <a href="http://www.gnu.org/software/emacs/" rel="noreferrer">Emacs</a>. I went through the tutorial, read some introductory articles, so far so good.</p> <p>Now I want to use it for Python development. From what I understand, there are two separate Python modes for Emacs: python-mode.el...
<p>If you are using GNU Emacs 21 or before, or XEmacs, use python-mode.el. The GNU Emacs 22 python.el won't work on them. On GNU Emacs 22, python.el does work, and ties in better with GNU Emacs's own symbol parsing and completion, ElDoc, etc. I use XEmacs myself, so I don't use it, and I have heard people complain that...
<p><a href="http://www.rwdev.eu/articles/emacspyeng" rel="noreferrer">This site</a> has a description of how to get Python code completion in Emacs. <a href="http://rope.sourceforge.net/ropemacs.html" rel="noreferrer">Ropemacs</a> is a way to get Rope to work in emacs. I haven't had extensive experience with either, b...
19,001
<p>Is there any reason why I should pick JSON over XML, or vice-versa if both are available? Tips for optimizing performance when dealing with data feeds are also appreciated!</p>
<p>When it comes to PHP the one reason I choose XML over JSON is because even in PHP 5 there is no officially supported API for traversal. You can encode, and you can decode, and that is it. There is no validation, no efficient way to traverse key/value pairs, and all-in-all, very little support for it. Don't get me wr...
<p>Regarding the performance of file_get_contents() versus cURL, I believe that cURL will be slightly faster. For your application you could run some quick benchmarks to compare the two approaches.</p> <p>More importantly, I would prefer cURL because file_get_contents() will not work in PHP environments which have a h...
32,356
<p>We are seeing this error in a Winform application. Can anyone help on why you would see this error, and more importantly how to fix it or avoid it from happening.</p> <pre> System.ComponentModel.Win32Exception: Error creating window handle. at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) a...
<p>Have you run Process Explorer or the Windows Task Manager to look at the GDI Objects, Handles, Threads and USER objects? If not, select those columns to be viewed (Task Manager choose View->Select Columns... Then run your app and take a look at those columns for that app and see if one of those is growing really...
<p>The out of memory suggestion doesn't seem like a bad lead.</p> <p>What is your program doing that it gets this error?</p> <p>Is it creating a great many windows or controls? Does it create them programatically as opposed to at design time? If so, do you do this in a loop? Is that loop infinite? Are you consuming ...
27,471
<p>I have a radio button on my Windows Form. How can I determine if the CheckChanged event occurred due to a user clicking or selecting the radio button vs programatically setting the event with </p> <pre><code>this.radioButtonAdd.Checked = true; </code></pre> <p>I would like some code to take a different action depe...
<p>I think I found a pretty good answer.</p> <p>All Windows Forms controls have a property called "Tag". its value can be any object.</p> <p>So if I want to ingore any programatic changes I can do the following:</p> <pre><code>radioButton.Tag = "ignore" radioButton.Checked = true </code></pre> <p>then in the event ...
<p>You could also do something like changing a flag field value on MouseDown for the radio button, then reverting the flag value on MouseClick. Since the CheckedChanged event fires between the two, it can use the flag before it's reverted by the MouseClick event, and you don't have to worry about resetting its state.<...
29,347
<p>Anti aliasing <a href="http://forums.msdn.microsoft.com/en-US/wpf/thread/1ad9a62a-d1a4-4ca2-a950-3b7bf5240de5" rel="noreferrer">cannot be turned off</a> in WPF. But I want to remove the blurred look of WPF fonts when they are small. </p> <p>One possibility would be to use a .net 2.0 component. This looks like it wo...
<p>Have you tried putting a <a href="https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.integration.windowsformshost?redirectedfrom=MSDN&amp;view=net-5.0" rel="nofollow noreferrer">WindowsFormsHost</a> control on a WPF window/control? That will allow WPF to render a WinForms control.</p> <p><strong>UPDAT...
<p>Try using the <a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.snapstodevicepixels.aspx" rel="nofollow noreferrer">UIElement.SnapsToDevicePixels</a> property on the UI elements of your window. People tend to report it works best for <a href="http://blogs.msdn.com/seema/archive/2006/10/31/on...
4,201
<p>I've been having some bed adhesion problems that I have been trying to solve by leveling the bed. I think that it's pretty level now but when I start a print the lines seem pretty flat. Is this true? I used a feeler gauge to have a 0.2 mm gap between the bed and nozzle, but the center feels as though there's more sp...
<p><strong>No</strong>, the <strong>bed does not look too close to the nozzle</strong>, it could well be that it is <strong>too far</strong> from the nozzle. However, the brim looks okay, but the method you follow is questionable. </p> <p>Using a feeler gauge of 0.2&nbsp;mm is larger than the recommended paper method ...
<p>I cannot stress enough how much purple glue stick helps with this exact problem.</p> <p>I had a cheap XYZ printer that I used nearly half a spool of filament on trying to align and get prints to stick. After ten hours straight of hair pulling and desperation, I smeared some purple glue stick across the build plate ...
1,173
<p>I am making some plots in Perl using <a href="http://search.cpan.org/dist/GD-Graph" rel="nofollow noreferrer">GD::Graph</a> and some of the data is outside the area I would like to display, but instead of being truncated off the chart outside the graphing area, it is being drawn over the title, legend, and axis labe...
<p>If you know what your bounds are, filter the data and don't include those points in the data that you send to GD::Graph.</p>
<p>To clarify: are you declaring the <code>y_max_value</code> height and your data is overflowing that bound? Or is GD::Graph miscalculating the correct upper limit?</p> <p>If you're setting the value, you need to fix your values to that upper bound. GD::Graph is only doing what you're telling it to do. (Which is more...
37,416
<p>I am looking to find out the logic , if any , which shrinks hashtable in c# when elements are removed from it.</p> <p>Regards Harish</p>
<p>c# hashtables don't shrink; they only grow. The logic is important, because the rehashing algorithm is VERY expensive to run; for most situations, the space saved by rehashing into a smaller hashtable would be completely overrun by the cost of the rehashing. Particularly on an automatic basis, where any removals f...
<p>The only indication of size changes for a hashtable in the documentation is when the load factor is exceeded and the size of the hashtable is increased. There is no mention of a hastable ever shrinking.</p> <p>There is some further detail of the load factor on <a href="http://msdn.microsoft.com/en-us/library/ms379...
38,932
<p>I have several server processes that once in a while respond to messages from the clients and perform read-only transactions.</p> <p>After about a few days that the servers are running, they stop working correctly and when I check it turns out that there's a whole bunch of messages about the connection being closed...
<p>The MySQL JDBC driver times out after 8 hours of inactivity and drops the connection.</p> <p>You can set <code>autoReconnect=true</code> in your JDBC URL, and this causes the driver to reconnect if you try to query after it has disconnected. But this has side effects; for instance session state and transactions ca...
<p>I would suggest that, in almost any client/server set-up, it's a bad idea to leave connections open when they're not needed.</p> <p>I'm thinking specifically about DB2/z connections but it applies equally to all servers (database and otherwise). These connections consume resources at the server that could be best ...
34,045
<p>I'm absolutely stunned by the fact that MS just couldn't get it right to navigate to the definition of a method, when you're combining C# and VB projects in one solution. If you're trying to navigate from VB to C#, it brings up the "Object Explorer", and if from C# to VB, it generates a metadata file.</p> <p>Hones...
<p>This is general to both languages.</p> <ul> <li>F12 in VB.Net always takes you to the object browser</li> <li>F12 in C# always takes you to a meta-data definition</li> </ul> <p>This is a deliberate mechanism to try and match expected behaviour for upgrading users. The C# way gives you the right information, but th...
<p>Make sure that your reference is to the VB <em>project</em> and not just a DLL file.</p>
8,897
<p>I am inserting a column in a DataGridView programmatically (i.e., not bound to any data tables/databases) as follows:</p> <pre><code>int lastIndex = m_DGV.Columns.Count - 1; // Count = 4 in this case DataGridViewTextBoxColumn col = (DataGridViewTextBoxColumn)m_DGV.Columns[lastIndex]; m_DGV.Columns.RemoveAt(lastInd...
<p>I suspect this is because the order of the columns in the DataGridView do not necessarily dictate the display order, though without explicitly being assigned by default the order of the columns dictate the DisplayIndex property values. That is why there is a DisplayIndex property, so you may add columns to the coll...
<p>Thanks to cfeduke for excellent advice. I suspected <code>Insert</code> would be slower, but the provided link enlightened me on JUST HOW MUCH slower.</p> <p>This brings up the question of how to efficiently insert and remove columns dynamically on a DataGridView. It looks like the ideal design would be to add plen...
28,172
<p>In my application I have a window which I popup with small messages on it (think similar to tooltip). This window uses the layered attributes to draw alpha backgrounds etc.</p> <p>If I have several of these windows open at once, and I click one with my mouse, when they disappear they cause my application to lose fo...
<p>Multithreaded programming is hard to grasp in the beginning (and veterans still fail sometimes) and BackgroundWorker makes it a bit easier to use. I like the fact that BackgroundWorker has functionality which is easy to implement but even easier to wrongly implement in a subtle way, like cancellation. I use it if I ...
<p>My biggest issue with the background worker class is that there really is no way to know when the worker has finished due to cancellation. The BackgroundWorker does not expose the thread it uses so you can't use the standard techniques for synchronizing thread termination (join, etc.). You also can't just wait in a ...
7,241
<p>I need to connect to Outlook through ASP.NET web application using user credentials. What are my options? </p> <p>FYI: User logs into the web site by using Windows Authentication. I'm working with Outlook 2003. </p>
<p>Sounds like you actually want to connect to Exchange. For exchange earlier than 2007, WebDAV is the way to go. For Exchange 2007, they have webservices avaiable.</p> <p><a href="http://www.independentsoft.de/webdavex/index.html" rel="nofollow noreferrer">Independentsoft</a> make a good (and cheap) .NET library for ...
<p>I'm going to do something similar, and I don't see a reason it wouldn't work: write an <a href="http://www.outlookcode.com/" rel="nofollow noreferrer">Outlook Addin</a> that uses <a href="http://www.google.com/search?q=.net+object+remoting" rel="nofollow noreferrer">object remoting</a> to communicate with whatever o...
37,113
<p>Are there any UPS WorldShip integration APIS or Libraries out there for .net? I've been tasked with integrating our Sample Order application (A VB.Net/SQL Server app) with UPS, and having it write .xml files for the auto import feature though serialization has gotten my foot in the door- but some of the more advance...
<p>Check here:<br> <a href="http://www.ups.com/content/us/en/bussol/offering/technology/alliances/technology_tools.html" rel="nofollow noreferrer">http://www.ups.com/content/us/en/bussol/offering/technology/alliances/technology_tools.html</a></p> <p>Look at the NexxStatus and ShipRush products at the bottom. Hopefull...
<p>I found the small <a href="https://github.com/rlaneve/dotNETShipping" rel="nofollow noreferrer">dotnetshipping</a> library by Ryan LaNeve to be helpful in getting started with UPS integration.</p> <p>Granted, this is more geared towards using their Rates &amp; Service Selection service, as opposed to WorldShip. Mig...
34,407
<p>I am working on a simple portal application using the ASP.NET membership and login controls. I would like to use the PasswordRecovery control to send emails containing forgotten passwords, however my portal requires localization. I have an existing Content Management System that I am pulling the localized strings ou...
<p>Try handling the SendingMail event of the PasswordRecovery control. In that event, set the e.Message.Body and e.Message.Subject properties to your localized text.</p>
<p>Found this by googling "BodyFileName localization": </p> <p><a href="http://forums.asp.net/t/1118242.aspx" rel="nofollow noreferrer">http://forums.asp.net/t/1118242.aspx</a>:</p> <blockquote> <p>Just bind the property to a key in your page's localresource file. The page's local resource file is the file lo...
27,481
<p>We've trying to separate a big code base into logical modules. I would like some recommendations for tools as well as whatever experiences you might have had with this sort of thing. </p> <p>The application consists of a server WAR and several rich-clients distributed in JARs. The trouble is that it's all in one bi...
<p>Have a look a <a href="http://www.headwaysoftware.com/index.php" rel="noreferrer">Structure 101</a>. It is awesome for visualizing dependencies, and showing the dependencies to break on your way to a cleaner structure.</p>
<p>I would start with the various tasks that you need to accomplish.</p> <p>I was faced with a similar task recently, given a 15 year old code base that had been made by a series of developers who didn't have any communication with one another (one worked on the project, left, then another got hired, etc, with no cros...
37,393
<p>Using C# and the .Net framework 2.0. I have an MDI application and need to handle dragover/dragdrop events. I have a list docked to the left on my application and would like to be able to drag an item from the list and drop it in the MDI client area and have the correct MDI child for the item open. I can't seem to f...
<p>I have an application that implements the Infragistics MDI DockManager (not Tabbed MDI), but I think those are very similar. It should work when you handle the MDI form events.</p> <ul> <li>MDIForm.AllowDrop is set to true?</li> <li>Is the object you're trying to drag serializable?</li> <li>Try the DragEnter event ...
<p>This code worked for me. It opens a new MDI child on dropping some text on MDI parent form.</p> <pre><code>... using System.Linq; ... public partial class Form1 : Form { MdiClient mdi_client; public Form1() { InitializeComponent(); mdi_client = this.Controls.OfType&lt;MdiClient&gt;().F...
39,322
<p>In my Seam application, I have a Seam component that returns a (<code>@Datamodel</code>) list of items I want to transform into a set of <code>&lt;li&gt;</code> HTML elements. I have this working without a problem. </p> <p>But now, I want to split up the list according to an EL expression. So the EL expression dete...
<p>You can do this using the JSF <code>&lt;f:verbatim&gt;</code> tag, which isn't pretty but works:</p> <pre><code>&lt;f:verbatim rendered="#{action.isNewList(index)}"&gt; &amp;lt;ul&amp;gt; &lt;/f:verbatim&gt; &lt;!-- stuff that does the &lt;li&gt;'s goes here --&gt; &lt;f:verbatim rendered="#{action.isNewList(inde...
<p>I'm not familiar with the Seam Framework, but if I understand the problem correctly something like this might work.</p> <pre><code>&lt;!-- before your loop, open your first &lt;ul&gt; if the (@Datamodel) is not empty --&gt; &lt;s:fragment rendered="#{action.isNewList(index)}"&gt; &lt;/ul&gt; &lt;ul&gt; &lt;/s:...
34,239
<p>On the advice of a more experienced developer, I have always coded my web pages that require user input (form processing, database administration, etc.) as self-referential pages. For PHP pages, I set the action of the form to the <code>'PHP_SELF'</code> element of the <code>$_SERVER</code> predefined variable, and ...
<p>I would argue that self-referential pages, as you put it, do not follow an appropriate separation of concerns. You're doing 2 different things with the same page, where a cleaner separation of logic would have you do them in 2 different pages.</p> <p>This practice is emphasized by MVC (model-view-controller, <a hr...
<p>One potential option would be to set up mod_rewrite aliases that point at the same URL. For example:</p> <pre><code>RewriteEngine on RewriteRule ^form$ form.php [QSA] RewriteRule ^form/submit$ form.php [QSA] </code></pre> <p>This would allow you to track requests while maintaining the code in the same file.</p>
15,709
<p>We are getting new dev machines and moving up to Vista 64 Ultimate to take advantage of our 8gb ram. Our manager wants us to do all dev in 32bit virtual machines to make sure there will be no problems with our code moving into production. </p> <p>Is there any way to guarantee the resultant programs will work on 3...
<p>I do development on 64 bit machines for 32 bit Windows. It's not a problem. You should make sure that your projects are set to compile in x86 mode in order to be conservative. You'll want to go through each project in the solution and double check this. You could also use the AnyCPU setting but that's a little ri...
<p>yeah, like adam was saying. There's 3 options: MSIL (default), x64, and x86. You can target x64 and it will generate dll's specifically for 64-bit systems, or you can do x86 which will run on 32-bit and 64-bit, but will have the same restrictions as 32-bit on a 64-bit system.</p> <p>MSIL will basically let the JITe...
5,043
<p>The basics have already been answered <a href="https://stackoverflow.com/questions/257125/human-language-of-a-document">here</a>. But is there a pre-built PHP lib doing the same as Lingua::Identify from CPAN?</p>
<p>There's a PEAR package <a href="http://pear.php.net/package/Text_LanguageDetect" rel="nofollow noreferrer"><code>Text_LanguageDetect</code></a> that I've used before. Get's the job done well enough. I'm not sure of any other libs that are more mature.</p>
<p>1- You could do it yourself (the hard way) - detecting both language and codepage by looking at character and n-gram frequencies. You would need lots of "training" data, but it's doable.</p> <p>2- You could run a perl script to do the detection for you(much easier).</p>
37,086
<p>I am adding custom controls to a FlowLayoutPanel. Each control has a date property. I would like to sort the controls in the flowlayoutpanel based on the date property. I can't presort the controls before I add them because it is possible for the user to add more.</p> <p>My current thought is when the ControlAdded ...
<p>I doubt this is the best but is what I have so far:</p> <pre><code> SortedList&lt;DateTime,Control&gt; sl = new SortedList&lt;DateTime,Control&gt;(); foreach (Control i in mainContent.Controls) { if (i.GetType().BaseType == typeof(MyBaseType)) { MyBaseT...
<p>BringToFront affects the z-order not the x/y position, I suspect you want to sort the FlowLayoutPanel.Controls collection when someone adds or deletes controls in the panel. Probably use SuspendLayout and ResumeLayout around the sorting code.</p>
14,227
<p>Soo... F# no longer has IEnumerable.map_with_type... which is the way people <em>were</em> mapping over collections. How do I do that now?</p> <pre><code>let urlPat = "href\\s*=\\s*(?:(?:\\\"(?&lt;url&gt;[^\\\"]*)\\\")|(?&lt;url&gt;[^\\s]* ))";; let urlRegex = new Regex(urlPat) let matches = urlRegex.Matches(h...
<p>you would write the last line like this:</p> <pre><code>let urls = Seq.map matchToUrl (Seq.cast matches);; </code></pre> <p>And this can be written in a nicer way using pipelining operator:</p> <pre><code>let urls = matches|&gt; Seq.cast |&gt; Seq.map matchToUrl;; </code></pre> <p>F# automatically figures out wh...
<p>Is Seq.cast what you are looking for?</p>
38,966
<p>I have a CustomAction as part of an MSI.</p> <p>It MUST run as a domain account that is also a member of the local Administrators account.</p> <p>It can't use the NoImpersonate flag to run the custom action as NT Authority\System as it will not then get access to network resources.</p> <p>On Vista/2008 with UAC e...
<p>Answering my own question for any other poor s0d looking at this.</p> <ul> <li><p>You can't add a manifest to an MSI. You could add a SETUP.EXE or bootstrapper to shell the MSI and manifest that with requireAdministrator but that defeats some of the point of using an MSI.</p></li> <li><p>Adding a manifest to a Cust...
<p>You can creating a simple <strong>sfx archive file for msi</strong> file with Winrar and these options: </p> <ul> <li><p>Setup tab > <em>Run after execution input</em>: your msi file name</p></li> <li><p>Advanced tab > Mark <em>Request Administrative access</em> option checkbox</p></li> </ul>
39,105
<p>I'm trying to start a service as a user and things work fine, until I try a user that doesn't have a password. Then, it fails to start (due to log-on error).</p> <p>Am I doing something wrong or is this "by design"?</p> <p>The code to register this service:</p> <pre><code> SC_HANDLE schService = CreateService(...
<p>It may be due to an OS security requirement or security policy. Check the security policies to see if anything is relevant there.</p>
<p>You need to specify an empty string, not NULL if there is no password. NULL is not a valid empty string, "" is. Probably you should just pass <code>strPassword</code> for the last parameter.</p> <pre><code>SC_HANDLE schService = CreateService( schSCManager, strNameNoSpaces, ...
15,864
<p>In a piece of C# that I am writing at the moment I need to handle several methods with the same signature in the same way. Also there might be more of these methods in the future. Instead of repeating the same kind of logic over and over I thought up the following:</p> <pre><code>private delegate bool cleanStep(Bui...
<p>Why not use a foreach loop and just break? (I've renamed <code>cleanStep</code> to <code>CleanStep</code> here for conventionality - I suggest you do the same.)</p> <pre><code>foreach(CleanStep step in steps) { string failureText; if (!step(build, out failureText)) { logger.Write(LogTypes.Error,...
<p>Re obfuscated - well <code>foreach</code> with break might be clearer (plus it'll <code>Dispose()</code> the enumerator, which you aren't doing).</p> <p>Actually, a "params cleanStep[] targets" might help:</p> <pre><code>static bool RunTargets(params cleanStep[] targets) { // detail as per Jon's post } </code>...
35,066
<p>For example, the standard division symbol '/' rounds to zero:</p> <pre><code>&gt;&gt;&gt; 4 / 100 0 </code></pre> <p>However, I want it to return 0.04. What do I use?</p>
<p>There are three options:</p> <pre><code>&gt;&gt;&gt; 4 / float(100) 0.04 &gt;&gt;&gt; 4 / 100.0 0.04 </code></pre> <p>which is the same behavior as the C, C++, Java etc, or </p> <pre><code>&gt;&gt;&gt; from __future__ import division &gt;&gt;&gt; 4 / 100 0.04 </code></pre> <p>You can also activate this behavior ...
<p>Import division from future library like this: </p> <pre><code>from__future__ import division </code></pre>
14,280
<p>I got this síngleton cache object and it exposes an IEnumerable property which just returns a private IEnumerable variable.</p> <p>I have a static method on my singleton object that updates this member variable (that exists on the single 'Instance' instance of this cache object).</p> <p>Let's say some thread is c...
<p>Since the getter <code>{ return sektioner; }</code> is called before the new value is put in the field, the old value is returned. Then, the loop <code>foreach (Sektion s in cache.Sektioner)</code> uses the value that was received when the getter was called, i.e. the old value. That value will be used throughout the...
<p>First of all I can't see object locking, unused lockObject variable makes me sad. IEnumerable is not special. Each thread will have it's own copy of reference to some instance of sektioner object. You can't affect other threads that way. What would happen with old version of data pointed by sektioner field largely d...
13,937
<p>I'm new to using the NetBeans IDE. When I try to look at the documentation for say the java API (example, <code>System</code> class), it says that the javadoc is not installed. How do I install the documentation?</p>
<p>First you download the javadoc.</p> <p>Second go to Tools-->Java Platforms and select Javadoc tab from the Java Platform Manager. Click the Add ZIP/Folder.</p>
<p>Not sure, but you can reference it at: <a href="http://java.sun.com/javase/reference/api.jsp" rel="nofollow noreferrer">http://java.sun.com/javase/reference/api.jsp</a> until someone is able to answer your real question!</p>
28,538
<p>How would you run the Selenium process (thread) from a Java process so I don't have to start Selenium by hand?</p>
<p>The server:</p> <pre><code>import org.openqa.selenium.server.SeleniumServer; public class SeleniumServerControl { private static final SeleniumServerControl instance = new SeleniumServerControl(); public static SeleniumServerControl getInstance() { return instance; } private SeleniumServer server = null...
<p>Also there are some additional settings you can use:</p> <pre><code> RemoteControlConfiguration settings = new RemoteControlConfiguration(); File f = new File("/home/user/.mozilla/firefox/default"); settings.setFirefoxProfileTemplate(f); settings.setReuseBrowserSessions(true); settings.setSingleW...
41,547
<p>I have an ANET A2 Prusa - which I've setup and performed a few prints on and they have various problems with the quality. I'm after some specific experience on what the flow of filament should look like or if my decription triggers someone </p> <p>I've been adjusting settings - In particular the temperature - as ...
<p>From my experience with mk8 extruders lower than optimal nozzle temperature or clogged nozzle can lead to an extruder's stepper motor overheating and partial burning out of a stepper</p> <p>It looks like “Achilles' heel” of mk8 extruders. I had to change 4 stepper motors for 2 3d printers with mk8 due to that</p> ...
<p>From my experience with few printer, Sometime it's happen because of the filament. Solution- If your printer have unload function or if you don't have that funstion select a printerable file and change temperature to 205-210 C and try to use long and thin hex key like this to push the filament out. -Make sure you...
659
<p>I made a custom ValueObject class with properties (getters/setters) and I need this class for data binding of elements on form. So I want to drag it to "other components" on matisse editor so I can bind it - and nothing happens.... Any similar experiences? The same issue is happening both on NetBeans 6.5 and MyEclip...
<p>The usual method for adding components to the control palette is through the Palette Manager: right-click the palette (the 'other components' area for example) and select Palette Manager, then add it from the appropriate place (your current project by the sound of it.)</p> <p>Your project needs to compile cleanly t...
<p>yes, I've concluded this, you can add only compiled class, it was even successfull once, but now I have regular class (which implements one interface) compiled, it wouldn't drop in. I put it first on custom palette area as widget and from there it went onto form. </p> <p>Thanks, will try to find some workaround.. h...
32,691
<p>I am fetching an array of floats from my database but the array I get has converted the values to strings.</p> <p>How can I convert them into floats again without looping through the array?<br /> Alternatively, how can I fetch the values from the database without converting them to strings?</p> <hr /> <h3>EDIT:</h3>...
<p>You could use </p> <pre><code>$floats = array_map('floatval', $nonFloats); </code></pre> <p>There is the option <code>PDO::ATTR_STRINGIFY_FETCHES</code> but from what I remember, MySQL always has it as <code>true</code></p> <p>Edit: see <a href="http://bugs.php.net/bug.php?id=44341" rel="noreferrer">Bug 44341</a>...
<p>Not sure what you're asking here? You can cast a string to a float, using <code>(float) $string</code>, but since PHP is dynamically typed, that will happen anyway, when needed. There is no reason to do an explicit cast.</p> <p>What are you using floating point values for?</p>
47,075
<p>I'm using IntelliJ-Idea to write Java daemons. We use JUnit to unit test our code and want to have automated runs on check-in to subversion.</p> <p>Are there any tools available that can automatically run unit tests and then send reports in email and to <a href="http://hobbitmon.sourceforge.net/" rel="nofollow nore...
<p>I think you should look into continuous integration, as others have suggested. I've personally tried CruiseControl and Hudson, and prefer Hudson. You can just download it and run it to see if you like it, configuration is a breeze, just:</p> <ol> <li>Download hudson.war from <a href="http://hudson.dev.java.net" rel...
<p>We use CruiseControl to automatically build projects and run unit tests whenever a change is committed to subversion. It can be configured to send e-mail notifications if the build/unit tests fail.</p>
32,082
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects-in-c">How to properly clean up Excel interop objects in C#</a> </p> </blockquote> <p>Suppose a ASP.NET web application generates automated Excel Reports on ...
<p>Sorry to say this, and I'm not trying to be smart, but... <strong>don't put office on the server!!!</strong></p> <p>That's if I've understood correctly! :)</p> <p><strong>EDIT:</strong> Even though I've been marked down for this, I will never <em>ever</em> advocate running Office on the server - it has proven <str...
<p>You need safely dispose all COM interop objects after you end your work. By "all" I mean absolutely <strong>all</strong>: collections property values and so on. I've created stack object and pushed objects during their setup:</p> <pre><code>Stack&lt;object&gt; comObjectsToRelease = new Stack&lt;object&gt;(); ... Lo...
7,451
<p>This may be a painfully simply question for which I will be mocked but I am having difficulty in using filepaths in master pages. I believe this is because if a page in a sub-directory to using the master page then the filepath is incorrect.</p> <p>To fix this I need to get the filepath from the root but I can't see...
<p>I'm just assuming by filepath, you actually mean url (or uri, I forget which one is partial).</p> <p>Without the ~, the first example should work. <code>&lt;script type="text/javascript" src="/jQueryScripts/jquery.js"&gt;&lt;/script&gt;</code> would cause the browser to request <a href="http://www.example.com/jQue...
<p>I believe you need to have <code>runat=server</code> in the <code>&lt;head&gt;</code> tag of the <code>MasterPage</code> for this URL rebasing to work.</p> <pre><code>&lt;head runat="server"&gt; </code></pre>
36,016
<p>The MAPISendMail function is available on windows so that an application can request that an email be sent. Windows will route the request to whichever email client is configured as the default provider.</p> <p>How do I write an application so that it will act as an email client for the purpose of receiving the MAP...
<p>add some stuff in the registery to HKEY_LOCAL_MACHINE\Software\Clients\Mapi</p> <p>create a new key with your apps name add a REG_EXPAND_SZ and assign the path to your dll to it create a new key with name shell create a new key with name open create a new key with name command assign your exe name to it.</p> <p>P...
<p>If you're not using the Microsoft Exchange Transport Provider, you can implement a MAPI Spooler Hook Provider. The following Microsoft Knowledgebase sample shows how to create a MAPI Spooler Hook Provider:</p> <p><a href="http://support.microsoft.com/kb/224362" rel="nofollow noreferrer">http://support.microsoft.co...
33,519
<p>I have the Xming X Window Server installed on a laptop running Windows XP to connect to some UNIX development servers. </p> <p>It works fine when I connect directly to the company network in the office. However, it does not work when I connect to the network remotely over a VPN.</p> <p>When I start Xming when conn...
<p>Chances are it's either X authentication, the X server binding to an interface, or your DISPLAY variable. I don't use Xming myself but there are some general phenomenon to check for. One test you can do to manually verify the DISPLAY variable is correct is:</p> <ol> <li>Start your VPN. Run ipconfig to be sure you h...
<p>Haven't have the exact problem, but I think you need to look at the xhost and make sure that the vpn remote is allowed to send data to the x server. </p> <p>This link might help: <a href="http://www.straightrunning.com/XmingNotes/trouble.php" rel="nofollow noreferrer">http://www.straightrunning.com/XmingNotes/troub...
2,650
<p>What are the main differences between search engines (DtSearch , Lucene.net, Sphinx, Google etc) that should influence the decision as to which to use to search proprietary data?</p> <p>The data to be searched consists of presentation-free data that is marked up with metadata in the form of name/value pairs. We’re...
<p>I like Solr with the DataImportHandler. It supports most of your bullet points, and is not too difficult to set up, as long as you don't mind editing some XML configuration files. It's easier than many enterprise class search engines.</p> <p>There is nothing wrong with GSA (Google Search Appliance), but for the ...
<p>In relation to relevancy, the Google Search Appliance allows a little tweaking. They believe that allowing too much tweaking will give poor relevancy, and I do believe that Google knows relevancy.</p> <p>It is unlikely that users will find a search engine other than Google easier to use.</p>
35,173
<p>My ASP.NET web app needs to support the ability for users to create their own forms, complete with textboxes, dropdowns, radio buttons with some logic (required field, etc.). Is there some third party tool that's already geared towards this?</p>
<p><a href="http://www.dotnetnuke.com/" rel="nofollow noreferrer">DotNetNuke</a> has this functionality, you would, however, have to make your site a DNN site to utilize it directly. </p> <p>Their system is fairly well suited to the scenario you describe, though, since you build pages by placing existing modules (thi...
<p>I don't know how well it would integrate with your system (if at all), but take a look at <a href="http://www.formassembly.com/" rel="nofollow noreferrer">http://www.formassembly.com/</a> - it might give you an idea of what is involved, should you need to make one yourself.</p>
23,009
<p>In ASP.net Webforms how do you detect which Textbox someone pressed enter?</p> <p>Please no Javascript answers.</p> <p>I need to handle it all in the code behind using VB.NET.</p>
<p>Why do you need to determine the which TextBox was pressed? Are you looking to see which TextBox was being focused so that you can trigger the proper button click event?</p> <p>If you are looking to do something like this, one trick I've done was to "group" the appropriate form elements within their own panel and t...
<p>Without using Javascript, you just can't. That information is not conveyed from the client browser to the server.</p>
11,277
<p>Can anyone tell me why this code behaves the way it does? See comments embedded in the code...</p> <p>Am I missing something really obvious here?</p> <pre><code>using System; namespace ConsoleApplication3 { public class Program { static void Main(string[] args) { var c = new MyC...
<p>I don't have an answer yet, but I have what I believe to be a slightly clearer program to demonstrate the oddity:</p> <pre><code>using System; delegate void MyDelegate(); public class Program { static void Main(string[] args) { var c = new MyChild(); c.DisplayOddity(); Console.Read...
<p>Maybe not the answer you are looking for, but this seems to work:</p> <pre><code>ThreadPool.QueueUserWorkItem(x =&gt; md()); </code></pre> <p>or</p> <pre><code>new Thread(() =&gt; md()).Start(); </code></pre> <p>But you will need to do your own accounting :(</p>
28,410
<p>I have database with many tables. In the first table, I have a field called <code>status</code>.</p> <pre><code>table 1 idno name status 111 hjghf yes 225 hjgjj no 345 hgj yes </code></pre> <p>Other tables could have same <code>idno</code> with different fields.</p> <p>I want to check the s...
<p>Multi-table update syntax for MS Access:</p> <pre><code>UPDATE Table2 INNER JOIN Table1 ON Table2.idno = Table1.idno SET Table2.salary = 111111 WHERE Table1.status = 'yes' AND Table2.salary Is Null </code></pre> <p>You can go into SQL View for a query, paste this in, and then run the query, or assign it to a str...
<p>Here is some largely untested code. Hopefully it will give you a start.</p> <pre><code>Sub UpdateNulls() Dim strSQL As String Dim rs As DAO.Recordset For Each tdf In CurrentDb.TableDefs If Left(tdf.Name, 4) &lt;&gt; "Msys" And tdf.Name &lt;&gt; "Table1" Then strSQL = "Select * From [" &amp; tdf.Name &am...
29,604
<p>Consider the following subversion directory structure</p> <p>/dir1/file.txt</p> <p>/dir2/file.txt</p> <p>I want to move the file.txt in dir1 to replace the same file in dir2 and ensure that the history for the dir1 file is maintained. I don't care about the history of original dir2 file.</p> <p>Is this possible ...
<p>Firstly you should never consider hacking the backend - it negates the point of using SVN in the first place.</p> <p>I don't see why you couldn't just do </p> <pre><code>svn rm /dir2/file.txt svn mv /dir1/file.txt /dir2/file.txt </code></pre> <p>the history of the file will follow it after the move.</p>
<p>Try</p> <ol> <li>Delete dir2/file.txt and commit</li> <li>issue a svn move command to move dir1/file.txt to dir2/file.txt and commit - The history should be preserved.</li> </ol>
19,543
<p>Using SqlServer, and trying to update rows from within the same table. I want to use a table alias for readability. This is the way I am doing it at the moment:</p> <pre><code>UPDATE ra SET ra.ItemValue = rb.ItemValue FROM dbo.Rates ra, dbo.Rates rb WHERE ra.ResourceID = rb.ResourceID AND ra.PriceSched = 't8' AND r...
<pre><code>UPDATE ra SET ra.ItemValue = rb.ItemValue FROM dbo.Rates ra INNER JOIN dbo.Rates rb ON ra.ResourceID = rb.ResourceID WHERE ra.PriceSched = 't8' AND rb.PriceSched = 't9'; </code></pre> <p>This might help in improving performance.</p>
<p><strong>Table alias in Update Query in T-SQL( Microsoft SQL) . for MS SQL Server 2008 R2 it's work just fine</strong></p> <pre><code>UPDATE A_GeneralLedger set ScheduleId=g.ScheduleId from A_GeneralLedger l inner join A_AcGroup g on g.ACGroupID=l.AccountGroupID </code></pre>
5,149
<p>I'm listening to podcast #19 and Joel and Jeff are arguing about running SQL Server on the same machine as your IIS installation. I have to say that it sounds like Jeff folded to Joel, but then again I am only guessing which one is which. ;)</p> <p>What are the pros and cons of each? Which is better?</p> <p>I typi...
<p>For <strong>security purposes</strong> it is good to separate web and database machines, preferably having a firewall between the two. A web server is exposed to the world at large. Unfortunately there are people who take pleasure in stealing or damaging the information contained on those servers.</p> <p>Then there...
<p>For very sensitive sites, the advantage of separate servers with firewalls between them can be useful but it brings a number of issues. </p> <ol> <li>Performance of queries on split IIS - SQL servers can run very slow due to the need to pass data across the network, also DNS may still be a factor even with servers ...
34,632
<p>Particularly, what is the best snippets package out there?</p> <p>Features:</p> <ul> <li>easy to define new snippets (plain text, custom input with defaults)</li> <li>simple navigation between predefined positions in the snippet</li> <li>multiple insertion of the same custom input</li> <li>accepts currently select...
<p><a href="http://manual.macromates.com/en/snippets" rel="nofollow noreferrer">TextMate's snippets</a> is the most closest match but it is not a cross-platform solution and not for Emacs.</p> <p>The second closest thing is <a href="http://github.com/joaotavora/yasnippet/" rel="nofollow noreferrer" title="Yet Another S...
<p>You can try a lightweight solution <a href="https://github.com/jiahaowork/muban.el" rel="nofollow noreferrer">muban.el</a></p> <p>It is written completely in Elisp and has a very simple syntax.</p>
8,668
<p>It is easy to highlight a selected datagrid row, by for example using toggleClass in the tr's click event. But how best to later remove the highlight after a different row has been selected? Iterating over all the rows to unhighlight them could become expensive for larger datagrids. I'd be interested in the simp...
<p>This method stores the active row into a variable. The $ at the start of the variable is just my own hungarian notation for jQuery objects.</p> <pre><code>var $activeRow; $('#myGrid tr').click(function() { if ($activeRow) $activeRow.removeClass('active'); $activeRow = $(this).addClass('active'); }); </code...
<p>For faster performance, you could push your selected element's ID into a var (or an array for multiples), and then use that var/iterate over that array when toggling the classes off.</p>
18,443
<p><a href="http://www.nservicebus.com/" rel="nofollow noreferrer">NServiceBus</a> and <a href="http://code.google.com/p/masstransit/" rel="nofollow noreferrer">MassTransit</a> are two tools that can be used to implement messaging with MSMQ and other message queues.</p> <p>I find that once you start using messaging to...
<p><a href="http://activemq.apache.org/" rel="nofollow noreferrer">Apache ActiveMQ</a> is probably the most popular and powerful open source message broker out there with the most active open source community behind it as well as <a href="http://open.iona.com/products/enterprise-activemq/" rel="nofollow noreferrer">com...
<p>Rogue Wave is very popular [ <a href="http://roguewave.com/products/hydra/" rel="nofollow noreferrer">http://roguewave.com/products/hydra/</a> ]</p> <p>So are IBM's Websphere offerings [ <a href="http://en.wikipedia.org/wiki/Mqseries" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Mqseries</a> ]</p>
12,516
<p>Has anyone used <a href="http://versionsapp.com/" rel="nofollow noreferrer">Versions</a> for OSX? I'm mainly wondering if it does everything <a href="http://tortoisesvn.tigris.org/" rel="nofollow noreferrer">TortoiseSVN</a> does and if you can use both with the same checkout repo?</p> <p><strong>Edit:</strong> The ...
<p>Versions is a very good SVN client for OSX, it has all the features that TortoiseSVN has with a better and more pleasant graphic interface :)</p> <p>I especially like the timeline view, it's very useful.</p> <p>You can use it along Tortoise, but I don't know why you should need to, Tortoise is Windows-only.</p>
<p>Another graphic svn client for osx is <a href="http://www.zennaware.com/cornerstone/" rel="nofollow noreferrer">Cornerstone</a>. </p> <p>I haven't tried it yet, but from the screenshots and the features looks promising.</p>
40,024
<p>I am writing an application in C# which is going to do extensive calculations. Everything is going around basic struct - Value. It is basically double with some additional parameters (accuracy etc.) It has to be a struct, because there will be too many of them created to afford heap allocation. Now, I need to make s...
<p>I don't think C# allows you to create default constructors on value types. There are several questions related to your issue:</p> <ul> <li><a href="https://stackoverflow.com/questions/333829">Why can’t I define a default constructor for a struct in .NET?</a></li> <li><a href="https://stackoverflow.com/questions/341...
<p>Are you hoping to initialize the accuracy to -1 with a default constructor? I don't think you can stop someone from using <code>new Value()</code>, but you could add a constructor that lets you use <code>new Value(10)</code> and have the accuracy initialized the way you want.</p> <p>See the MSDN page about [Struct ...
45,096
<p>I've always had trouble getting prints to stick directly on my bed, but had great reliability when use rafts. This didn't present a problem when I was using PLA, but I recently got a roll of PETG and it is very hard to remove rafts, so I am once again trying to figure out whats wrong.</p> <p>I am printing the same ...
<p>You could experiment with the 'cleaning' part of the startup gcode shown <a href="http://reprap.org/wiki/Start_GCode_routines" rel="nofollow noreferrer">here</a></p> <pre><code>G1 X100 Y0 F4000 ; move half way along the front edge G1 Z1 ; move nozzle close to bed M109 S200 ; heat nozzle to 200 degC and wait until r...
<p>You could experiment with the 'cleaning' part of the startup gcode shown <a href="http://reprap.org/wiki/Start_GCode_routines" rel="nofollow noreferrer">here</a></p> <pre><code>G1 X100 Y0 F4000 ; move half way along the front edge G1 Z1 ; move nozzle close to bed M109 S200 ; heat nozzle to 200 degC and wait until r...
617
<p>So I just got my first 3D printer the Ender 3 Pro. My nozzle is a bit too high (first image) and this is what happened after my first test print (second image).</p> <p>I saved for a while to buy this and I’m really upset about this.</p> <p><a href="https://i.stack.imgur.com/x1wNg.jpg" rel="nofollow noreferrer" title...
<p>Your Z-endstop assembly is clearly too high. Referring to your own first foto you see that the switch on the Z-endstop mount is nearly touching the bottom of the X-Z mounting.</p> <p><a href="https://i.stack.imgur.com/GUPv9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GUPv9.png" alt="enter imag...
<p>Flash the firmware. If that doesn't fix it then you have a defective printer assuming everything else in your question and comments is correct.</p>
2,106
<p>So I have an SQL dump file that needs to be loaded using mysql_query(). Unfortunately, it's not possible to execute multiple queries with it.</p> <p>-> It cannot be assumed that the <strong>mysql command-line client</strong> (mysql --help) is installed -- for loading the SQL file directly</p> <p>-> It cannot be as...
<p>You have more problem cases than just semicolons within strings. </p> <ul> <li>Script <a href="http://dev.mysql.com/doc/refman/5.1/en/mysql-commands.html" rel="nofollow noreferrer">builtin</a> commands that cannot be executed by <code>mysql_query()</code>, like <code>USE</code>.</li> <li>Statements that are not te...
<pre><code>&lt;?php //STATIC QUERY $sql1 = " CREATE TABLE tblTable ( strOne VARCHAR(50) NOT NULL, strTwo VARCHAR(50) NOT NULL, strThree VARCHAR(50) NOT NULL ); INSERT INTO tblTable (strOne, strTwo, strThree) VALUES ('String 1', 'String 2', 'String 3'); UPDATE tblTable SET strOne = 'String One', strTwo = 'String Two' WH...
44,973
<p>Applications I am using: Visual Studio 2008 (C#/ASP.NET) Visual Source Safe 8.0 IIS 5.1</p> <p>I have two Web Apps both named the same but one is used for major releases and the other is for minor (trunk and branch). I am wondering if there is an option in Visual Studio that prevents it from creating an ASP.NET app...
<p>Instead of having HTTP based projects in your visual studio solution, add them as file projects, where the website will be accessed as c:\inetput\wwwroot\major_version (for example) in visual studio (and not <a href="http://localhost" rel="nofollow noreferrer">http://localhost</a>). That way you can have any kind o...
<p>You can manually create a new web application in IIS and let it point to your working directory. Visual Studio should honor these settings. </p>
44,902
<p>I can connect with the DataContext to the Oracle database however I get errors in running the query against the oracle database. I looked at the SQL generated and it is for MSSQL and not Oracle PSQL. </p> <p>Does anybody know of a decent easy to use wrapper to use LINQ against an Oracle Database?</p>
<p>No, LINQ to SQL is very much MS SQL only - think of it as a client driver.</p> <p><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1623471&amp;SiteID=1" rel="noreferrer">Microsoft is/was helping Oracle and DataDirect develop providers for Oracle and other non-MS database servers.</a></p>
<p>Not an easy way, at least until a good provider is produced.</p> <p>Really MS should provide at least an OLEDB Linq provider. After all, Linq to Sql is basically an implementation of IQueryable with designer support.</p>
5,065
<p>In <a href="https://stackoverflow.com/questions/226206/alternating-item-style">this question</a>, I was given a really cool answer to alternating an image and its description between left and right, respectively. Now I want to apply styling to both, e.g. padding-top, padding-bottom etc. How do I apply a style to bo...
<p>Here's how you do it:</p> <pre><code>.ProductAltItemStyle, .ProductItemStyle { // CSS Rules that apply to both go here }</code></pre>
<p>Alternatively you can do this:</p> <pre><code>&lt;AlternatingRowStyle CssClass="ProductAltItemStyle ProductCommonStyle" /&gt; &lt;RowStyle CssClass="ProductItemStyle ProductCommonStyle" /&gt; </code></pre> <p>ProductCommonStyle contains formatting that is common to both alternating and standard rows. </p> <p>E...
31,248
<p>I have an assembly, written in C++\CLI, which uses some of enumerations, provided by .Net. It has such kind of properties: </p> <pre><code>property System::ServiceProcess::ServiceControllerStatus ^ Status { ServiceControllerStatus ^ get() { return (ServiceControllerStatus)_status-&gt;dwCur...
<p>In C++/CLI <strong>^</strong> is like the analagous * in standard C++. Because enumerations are value types the <strong>^</strong> should not be included otherwise you will see them as <strong>System.Enum</strong>.</p> <p>Remove the ^ and you will see the correct enumeration on C# side.</p> <pre><code>property Sys...
<p>I think enums don't use the ^ -- try removing it from the property declaration and get().</p>
14,033
<p>I haven't kept up lately with the C++ world. Exactly where do things stand these days regarding the standard? </p> <p>Is TR1 adopted? </p> <p>Is there a TR2? </p> <p>How do these relate to C++0x? Are the subsumed?</p> <p>Has a decision been reached on threading yet?</p>
<p>You can find an extensive article about the upcoming C++0x on <a href="http://en.wikipedia.org/wiki/C%2B%2B0x" rel="nofollow noreferrer">wikipedia</a> and the current state of C++ evolution <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2705.html" rel="nofollow noreferrer">here</a>. It is also wor...
<p>I'd recommend you to visit <a href="http://www.open-std.org/jtc1/sc22/wg21/" rel="nofollow noreferrer">http://www.open-std.org/jtc1/sc22/wg21/</a></p>
17,405
<p>For example; with the old command prompt it would be:</p> <pre><code>cmd.exe /k mybatchfile.bat </code></pre>
<p>Drop into a cmd instance (or indeed PowerShell itself) and type this:</p> <pre><code>powershell -? </code></pre> <p>You'll see that powershell.exe has a "-noexit" parameter which tells it not to exit after executing a "startup command".</p>
<p>I am sure that you already figure this out but I just post it</p> <pre><code>$CreateDate = (Get-Date -format 'yyyy-MM-dd hh-mm-ss') $RemoteServerName ="server name" $process = [WMICLASS]"\\$RemoteServerName\ROOT\CIMV2:win32_process" $result = $process.Create("C:\path to a script\test.bat") $result | out-file -f...
3,507
<p>I would like to have a nice template for doing this in development. How do I reset an increment identity's starting value in SQL Server?</p>
<pre><code>DBCC CHECKIDENT('TableName', RESEED, 0) </code></pre>
<p>To set the identity to 100:</p> <pre><code>DBCC CHECKIDENT (MyTable, RESEED, 100) </code></pre>
3,769
<p>How do I specify the username and password in order for my program to open a file for reading? The program that needs to access the file is running from an account that does not have read access to the folder the file is in. Program is written in C# and .NET 2, running under XP and file is on a Windows Server 2003 m...
<p>You want to impersonate a user who does have the rights to access the file.</p> <p>I recommend using a class like this - <a href="http://www.codeproject.com/KB/cs/zetaimpersonator.aspx" rel="noreferrer">http://www.codeproject.com/KB/cs/zetaimpersonator.aspx</a>. It hides all the nasty implementation of doing impers...
<p>You can impersonate a user who has the necessary rights. There is an <a href="http://msdn.microsoft.com/en-us/library/b80a7e92.aspx" rel="nofollow noreferrer">article on MSDN</a> that describes how to do this.</p>
31,024
<p>If I create a function with jQuery that adds an empty div, performs some animation inside the blank space created by the div, then removes the div, the browser never makes room for the empty div (height and width are set).</p> <p>If I don't remove the empty div in my function, then the browser will create the neede...
<p>Some jQuery effects have callbacks, which will are run after the effect, for example:</p> <pre><code>$('#someDiv').slideDown(100, function() { $(this).remove(); }); </code></pre>
<p>Doesn't it work if you use a setTimeout ?-)</p>
19,553
<p>It appears that in PHP objects are passed by reference. Even assignment operators do not appear to be creating a copy of the Object.</p> <p>Here's a simple, contrived proof:</p> <pre><code>&lt;?php class A { public $b; } function set_b($obj) { $obj-&gt;b = "after"; } $a = new A(); $a-&gt;b = "before"; $c =...
<p>In PHP 5+ objects are passed by reference. In PHP 4 they are passed by value (that's why it had runtime pass by reference, which became deprecated).</p> <p>You can use the 'clone' operator in PHP5 to copy objects:</p> <pre><code>$objectB = clone $objectA; </code></pre> <p>Also, it's just objects that are passed b...
<p>If you want to fully copy properties of an object in a different instance, you may want to use this technique:</p> <p>Serialize it to JSON and then de-serialize it back to Object.</p>
22,489
<p>What tools are there for me to build a real, honest to goodness external DSL. And no, I'm not talking about abusing Ruby, Boo, XML or another existing language or syntax, I mean a REAL external DSL -- my own language for my own purposes.</p> <p>I know that there are a few language workbenches being developed and I'...
<p>I've written DSLs in Boo, Irony.NET and a toolkit called Grammatica. You say that a parser-generator is too complicated, but you may be being too hasty in your judgment, in fact they are quite simple to use once you get over a small learning curve, and open up a vast world of possibility that easily overrides the ef...
<p>For serious external DSLs, you can't avoid the parsing problem; ANTLR is the least of what you need. What you want to check is program transformation systems, which can be used to map arbitrary DSL syntax into target languages like Java. </p> <p>See <a href="http://en.wikipedia.org/wiki/Program_transformation" rel...
12,742
<p>In a comment on this <a href="https://stackoverflow.com/questions/306130/python-decorator-makes-function-forget-that-it-belongs-to-a-class#306277">answer to another question</a>, someone said that they weren't sure what <code>functools.wraps</code> was doing. So, I'm asking this question so that there will be a reco...
<p>When you use a decorator, you're replacing one function with another. In other words, if you have a decorator</p> <pre><code>def logged(func): def with_logging(*args, **kwargs): print(func.__name__ + " was called") return func(*args, **kwargs) return with_logging </code></pre> <p>then when...
<p>In short, <strong>functools.wraps</strong> is just a regular function. Let's consider <a href="https://docs.python.org/2/library/functools.html#functools.wraps" rel="nofollow noreferrer">this official example</a>. With the help of the <a href="https://github.com/python/cpython/blob/521995205a2cb6b504fe0e39af22a81f78...
39,815
<p>I'm looking for a good ASP.NET RichTextBox component that integrates fairly easily with .NET Framework 3.5 Ajax, specifically one that can easily provide its values from inside an UpdatePanel.</p> <p>I got burned by RicherComponents RichTextBox which still does not reference the Framework 3.5.</p> <p>thanks!</p>
<p>Look at FCKEditor for a free solution. I'm unsure if it's usable inside an update panel, but it's free and opensource.</p> <p><a href="http://www.fckeditor.net/" rel="nofollow noreferrer">http://www.fckeditor.net/</a></p>
<p>Googled based on craigmoliver's answer and found this: <a href="http://www.webcitation.org/5bFQaq7Wp" rel="nofollow noreferrer">http://www.webcitation.org/5bFQaq7Wp</a></p> <p>Basically, it's a solution to allow FCKEditor to work in an update panel, which I will try and post if it work.</p>
19,132
<p>We have an HTML page which displays a bunch of pretty bars using divs and repeating backgrounds. We are in the process of making a report out of this that can be printed nicely, but this may take some time because we don't have a reporting framework in place. As an interm solution we'd like to make the HTML version ...
<p>In general, with database optimization, you should write SQL which is conceptually correct first, and then tweak performance if profiling shows it to be necessary. When doing an inner join, it is better to use SQL-92, explicit INNER JOINs than Cartesian products. So I would begin by writing your SQL as follows:</p> ...
<p>Firstly, construct the query using an explicit JOIN syntax, rather than the cartesian product. It probably won't make any difference performance-wise for any modern optimiser, but it does make the information on how the JOINs work more accessible for the programmers.</p> <pre><code> SELECT Player.Name, Game.Date F...
49,248
<p>I want to create a file that only resides in memory... In looking through some documentation I saw a recommendation to use a shell extension as a virtual file. Im not sure that is a workable solution but I would like to know</p> <ol> <li>Is it a good approach (or should I be using a ramdisk instead)</li> <li>Wher...
<h2>Connecting to MYSQL with Python 2 in three steps</h2> <p><strong>1 - Setting</strong></p> <p>You must install a MySQL driver before doing anything. Unlike PHP, Only the SQLite driver is installed by default with Python. The most used package to do so is <a href="http://pypi.python.org/pypi/MySQL-python/" rel="n...
<p>First, install python-mysql connector from <a href="https://dev.mysql.com/downloads/connector/python/" rel="nofollow noreferrer">https://dev.mysql.com/downloads/connector/python/</a></p> <p>on Python console enter: </p> <pre><code>pip install mysql-connector-python-rf import mysql.connector </code></pre>
48,752
<p>I'm looking for an image editor that I can embed easily into an ASP.NET website. I need to be able to draw rectangles, lines and add some text. Additionally, images must not be uploaded to third-party servers.</p> <p>I've checked sites of the main ISVs that develop .NET controls but none of them provides a standalo...
<p>I think <a href="http://www.atalasoft.com/products/dotimage/thinclient/default.aspx" rel="nofollow noreferrer">AtalaSoft</a> has and editor that will do what you need.</p>
<pre><code>if (sense == 1) //Rotate 90 to right { img.RotateFlip(RotateFlipType.Rotate270FlipXY); } </code></pre>
40,655
<p>I'm looking to build an reusable control or custom helper for my MVC project. I'm sure there is a best practice for this. Any help is appreciated.</p>
<p>Sure, the best practices are encapsulated in the HtmlHelpers and other helpers in the MVC source code. You can get the source at <a href="http://www.codeplex.com/aspnet" rel="nofollow noreferrer">http://www.codeplex.com/aspnet</a></p>
<p>(Hate to disagree with you Scott) Using HtmlHelpers is not a best practice. It is not a practice that has been sharpened through use on real projects and is only one approach. I have recently written a <a href="http://mhinze.com/subcontrollers-in-aspnet-mvc/" rel="nofollow noreferrer">little post on using SubContr...
15,006
<p>In a C++ file, I have a code like this:</p> <pre><code>#if ACTIVATE # pragma message( "Activated" ) #else # pragma message( "Not Activated") #endif </code></pre> <p>I want to set this ACTIVE define to 1 with the msbuild command line.</p> <p>It tried this but it doesn't work:</p> <pre><code>msbuild /p:DefineC...
<p>I'm a little late to the party (only 4 years or so), but I just had to workaround this problem on a project, and stumbled across this question while searching for a fix. Our solution was to use an environment variable with <code>/D</code> defines in it, combined with the Additional Options box in visual studio.</p> ...
<p>It should probably be:</p> <pre><code>#ifdef ACTIVATE # pragma message( "Activated" ) #else # pragma message( "Not Activated") #endif </code></pre>
20,107
<p>We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this:</p> <p>Has anyone done server performance tests for simple echo services as well as serialization/deserialization for various messages sizes comparin...
<p>Latest comparison available here at the <a href="https://github.com/eishay/jvm-serializers/wiki/" rel="noreferrer">thrift-protobuf-compare</a> project wiki. It includes many other serialization libraries.</p>
<p>One of the things near the top of my "to-do" list for PBs is to port Google's internal Protocol Buffer performance benchmark - it's mostly a case of taking confidential message formats and turning them into entirely bland ones, and then doing the same for the data.</p> <p>When that's been done, I'd imagine you coul...
37,932
<p>A while ago I read the <a href="http://www.martinfowler.com/articles/mocksArentStubs.html" rel="nofollow noreferrer">Mocks Aren't Stubs</a> article by Martin Fowler and I must admit I'm a bit scared of external dependencies with regards to added complexity so I would like to ask:</p> <p>What is the best method to u...
<p>As the mantra goes 'Go with the simplest thing that can possibly work.'</p> <ol> <li>If fake classes can get the job done, go with them. </li> <li>If you need an interface with multiple methods to be mocked, go with a mock framework.</li> </ol> <p>Avoid using mocks <em>always</em> because they make tests brittle. ...
<p>Read Luke Kanies' discussion of exactly this question in <a href="http://www.madstop.com/ruby/jay_and_i_converge_on_testing.html" rel="nofollow noreferrer">this blog post</a>. He references <a href="http://blog.jayfields.com/2008/05/using-stubs-to-capture-test-essence.html" rel="nofollow noreferrer">a post from Jay ...
7,000
<p>I have a web API that returns python dictionaries or lists as a response that I eval() in python scripts that use the API, for completness I wanted to set a proper content-type but not sure what would be best to use "text/x-python" or maybe "application/python", or something else? </p> <p>[edit] I'm also outputting...
<p>I doubt there's an established MIME type. Have you considered using JSON instead, it is almost the same as a Python dict, and has a better established culture of tools and techniques.</p>
<p>I doubt there's an established MIME type. Have you considered using JSON instead, it is almost the same as a Python dict, and has a better established culture of tools and techniques.</p>
33,822
<p>I need to compare strings in shell:</p> <pre><code>var1="mtu eth0" if [ "$var1" == "mtu *" ] then # do something fi </code></pre> <p>But obviously the "*" doesn't work in Shell. Is there a way to do it?</p>
<h1><code>bash</code></h1> <p>Shortest fix:</p> <pre><code>if [[ "$var1" = "mtu "* ]] </code></pre> <p>Bash's <code>[[ ]]</code> doesn't get glob-expanded, unlike <code>[ ]</code> (which must, for historical reasons).</p> <hr> <h1><code>bash --posix</code></h1> <p>Oh, I posted too fast. Bourne shell, not Bash......
<p>Or, as an example of the <strong>=~</strong> operator:</p> <pre><code>if [[ "$var1" =~ "mtu *" ]] </code></pre>
22,205
<p>If I need a varchar(30) field, for example, that needs to contain several different foreign character sets, is there one particular language type that I can use in MySQL? For example, I have a field contains names in Chinese, Russian, English, Spanish and Portuguese, and possibly more in the future. How do I enabl...
<p>Unicode can contain every character in use worldwide.</p> <p>be sure to use UTF-8 for the field. (better yet, for the whole database).</p>
<p><strong>utf-8</strong> is your friend.</p>
33,748
<p>Can you use a Spring-WS WebserviceTemplate for calling a webservice and avoid that it generates a SOAP-envelope? That is, the message already contains an SOAP-Envelope and I don't want that the WebserviceTemplate wraps another one around it. :-)</p> <p>The reason I want this is that I'd like to call a webservice th...
<p>You're using ws-security in a strange way... I guess that you're trying to avoid ws-security dependancy by using pre-generated messages - for simple client might make sense, although it's definitely not by-the-book.</p> <p>You can configure WebServiceTemplate to use plain XML without SOAP by setting messageFactory ...
<p>Interceptors can come in handy for the sort of thing you are trying to do. Take a look at the Interceptor hierarchy here: <a href="http://static.springframework.org/spring-ws/docs/1.0-m1/api/org/springframework/ws/EndpointInterceptor.html" rel="nofollow noreferrer">http://static.springframework.org/spring-ws/docs/1....
46,911
<p>I’m trying to make the routing module works with default action or controller, but it doesn’t. I always face with 404 page not found. Did I forget to do something? I really like routing in ASP.NET MVC feature, but I’m not sure I could do the same in MR. I’m using IIS7 with the build from castle trunk for .NET 3.5.</...
<p>If you're on IIS7, you need the routing module registration in the system.webServer/httpModules node.</p> <p>The system.web/httpHandlers and httpModules are AFAIK ignored by IIS7.</p> <p>MonoRail routing definitely works; we have it up and running happily. Here're config and global.asax.cs snippets:</p> <pre><co...
<p>I've tried to register routing like this already but it still doesn't work.</p> <p>Here is my configuration file:</p> <pre><code>&lt;system.web&gt; &lt;httpHandlers&gt; &lt;add verb="*" path="*.rail" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework" /&gt; &lt;add verb="*" p...
36,961
<p>How to put a File path control in VBA front panel? I want the user to be able to select the browse button and select the file path rather than putting up dialog boxes all over the place. I need the user to select three or more file paths.</p>
<p>After re-re-reading your Q, it seams you want to steer away from dialog boxes!Oh well, I was going to say</p> <blockquote> <p>I could post the hack about using MSDIAG on VBA, that explains how you can patch your registry to enable its use under VBA, without having other MS-VB products installed... but I r...
<p>There is not direct VBA function for that. You can decide to combine a form (Access form, or a generic microsoft form) with 2 controls: (1) text box (2) browse button (which will finally use the fileDialog command or a windows API).</p>
33,177
<p>I'm hoping someone has seen this before because I can't for the life of me find the problem. </p> <p>I'm trying to do the old "fix the back button" thing in an application and I think i have a pretty decent approach, the problem is that it relies on the application not calling page_load when you hit back and instea...
<p>Check what the server is returning for the cache-control http header, then try setting Response.Cache.SetCacheability()/ use the output cache page directive on the pages and see if the server is saying that the pages should be cached.</p>
<p>if you are using ASP.NET AJAX why not using the History server control object?</p> <p>replacing History, the back button will go to the link you want.</p> <p><a href="http://quickstarts.asp.net/Futures/ajax/doc/history.aspx" rel="nofollow noreferrer">try this</a> </p>
24,795
<p>In an application I need to execute other programs with another user's credentials. Currently I use <strong><a href="http://msdn.microsoft.com/en-us/library/ed04yy3t.aspx" rel="nofollow noreferrer">System.Diagnostics.Process.Start</a></strong> to execute the program:</p> <pre><code>public static Process Start( s...
<p><a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.loaduserprofile.aspx" rel="noreferrer">System.Diagnostics.ProcessStartInfo.LoadUserProfile</a> </p>
<p>My solution (based on leppie's hint):</p> <pre><code> Process p = new Process(); p.StartInfo.FileName = textFilename.Text; p.StartInfo.Arguments = textArgument.Text; p.StartInfo.UserName = textUsername.Text; p.StartInfo.Domain = textDomain.Text; p.StartInfo.Password =...
43,745
<p>I have a file containing 250 million website URLs, each with an IP address, page title, country name, server banner (e.g. "Apache"), response time (in ms), number of images and so on. At the moment, these records are in a 25gb flat file.</p> <p>I'm interested in generating various statistics from this file, such as...
<p>Step 1: get the data into a DBMS that can handle the volume of data. Index appropriately.</p> <p>Step 2: use SQL queries to determine the values of interest.</p> <p>You'll still need to write a new query for each separate question you want answered. However, I think that is unavoidable. It should save you repli...
<p>25GB of flat file. I don't think writing any component on your own to read this file will be a good idea.</p> <p>I would suggest that you should go for SQL import and take all the data to SQL Server. I agree that it would take ages to get this data in SQL Server, but once it is there you can do any thing you want w...
26,977
<p><strong>Is there a way that I can configure Visual Studio 2008 to understand CamelCase?</strong> Specifically, I'd like to be able to get <code>Ctrl + right</code> or <code>left</code> cursor to take me to a subsection of a variable or type name.</p> <p>i.e., if my cursor was at the start of this line:</p> <pre cla...
<p>Thanks to those who suggested Resharper. This gives me another reason to love it even more. Just to be specific about where this lives - JetBrains call it <a href="http://www.jetbrains.com/resharper/features/navigation_search.html#CamelHumps" rel="nofollow noreferrer"><strong>CamelHumps</strong></a> (cute) and you c...
<p>I don't think Visual Studio supports this feature internally, as it seems to be using the normal way Ctrl+Right and Ctrl+Left work in Windows environment. But it's probably possible with some kind of extension or plugin.</p>
40,509
<p>I am looking for a way to have some control over the shape of a simple MessageBox in Winforms. I would like to control where the passed in text wraps so that the dialog rect is narrower. Windows seems to want to make the dialog as wide as possible before wrapping the text. Is there an easy way to control the maximum...
<p>You can embed newlines in the text to force it to wrap at a certain point. e.g.</p> <pre><code>"message text...\nmore text..." </code></pre> <p>update: I posted that thinking it was a win32 API question, but I think the principle should still apply. I assume WinForms eventually calls MessageBox().</p>
<p>What happens if you throw your own newlines in the string message you pass it? I'm pretty sure that will work if I recall correctly.</p>
12,824
<p>I'm adding avatars to a forum engine I'm designing, and I'm debating whether to do something simple (forum image is named .png) and use PHP to check if the file exists before displaying it, or to do something a bit more complicated (but not much) and use a database field to contain the name of the image to show.</p>...
<p>As well as what the other posters have said, the result of file_exists() is automatically cached by PHP to improve performance.</p> <p>However, if you're already reading user info from the database, you may as well store the information in there. If the user is only allowed one avatar, you could just store a singl...
<p>file_exists() is not slow per se. The real issue is how your system is configured and where the performance bottlenecks are. Remember, databases have to store things on disk too, so either way you're potentially facing disk activity. On the other hand, both databases and file systems usually have some form of tra...
40,886
<p>How do you insert invisible watermarks in images for copyright purposes? I'm looking for a python library.</p> <p>What algorithm do you use? What about performance and efficiency?</p>
<p>You might want to look into Steganography; that is hiding data inside of images. There are forms that won't get lost if you convert to a lossier format or even crop parts of the image out.</p>
<p>I was going to post an answer similar to Ugh. I would suggest putting a small TXT file describing the image source (and perhaps a small copyright statement, if one applies) into the image in a manner that is difficult to detect and break.</p>
6,575
<p>I have an application where every now and then I'm getting a strange error. This is the piece of code:</p> <pre><code>Dim XMLWriter As New System.Xml.XmlTextWriter(Me.Context.Response.OutputStream, Encoding.UTF8) XMLWriter.WriteStartDocument() XMLWriter.WriteStartElement("Status") Message.SerializeToXML(XMLWriter)...
<p>Reflector gives this:</p> <pre><code>private void BufferData(byte[] data, int offset, int size, bool needToCopyData) { int num; if (this._lastBuffer != null) { num = this._lastBuffer.Append(data, offset, size); size -= num; offset += num; } else if ((!needToCopyData &amp;...
<p>No, if it happens when you call Flush, that's way later than the only time <code>Context.Response.OutputStream</code> is actually referenced. The value is fetched in the call to the <code>XmlTextWriter</code> constructor, and then not looked at again.</p> <p>Do you have any more information from the stack trace?</p...
36,120
<p>I'm wondering how the concurrency in a web application actually works. Ive read several articles and to my understanding multiple instances of HttpApplication would be working at the same time. Now, I created a simple web app to test concurrency and put the following to global.asax:</p> <pre><code>protected void Ap...
<p>Each request that arrives is routed to a separate HttpApplication object. The HttpApplication object is either created from scratch or allocated from a pool. The maximum number of HttpApplication objects created is limited by the maximum number of threads available. In ASP.NET 1.x I think the default was 20 or so. U...
<p>Why don't you modify the sample to print the thread ID? That will tell you if multiple threads are serving the requests concurrently. I bet it is.</p>
39,650
<p>There has been a lot of sentiment to include a <code>nameof</code> operator in C#. As an example of how this operator would work, <code>nameof(Customer.Name)</code> would return the string <code>"Name"</code>.</p> <p>I have a domain object. And I have to bind it. And I need names of properties as strings then. And ...
<p>This code basically does that:</p> <pre><code>class Program { static void Main() { var propName = Nameof&lt;SampleClass&gt;.Property(e =&gt; e.Name); Console.WriteLine(propName); } } public class Nameof&lt;T&gt; { public static string Property&lt;TProp&gt;(Expression&lt;Func&lt;T, ...
<p>The answer from reshefm is pretty good, but this is a little bit simpler API IMO:</p> <p>Usage example: <code>NameOf.Property(() =&gt; new Order().Status)</code></p> <pre><code>using System; using System.Diagnostics.Contracts; using System.Linq.Expressions; namespace AgileDesign.Utilities { public static class Na...
38,738
<p>Does anyone have any advice for a consistent way to unit test a multithreaded application? I have done one application where our mock "worker threads" had a thread.sleep with a time that was specified by a public member variable. We would use this so we could set how long a particular thread would take to complete...
<p>My advice would be not to rely on unit tests to detect concurrency issues for several reasons:</p> <ul> <li>Lack of reproducibility: the tests will fail only once in a while, and won't be really helpful to pinpoint the problems.</li> <li>Erratic failing build will annoy everybody in the team - because the last comm...
<p>Not quite a unit test, but you could write some test code which repeatedly calls the code that will execute on different threads. Trying to create maximal interleaving between threads with a periodic or final consistency check. Of course this approach has the downside of not being reproducable, so you would need to ...
13,690
<p>I have a java back-end that needs to expose services to clients running in the following environments :</p> <ul> <li>J2ME</li> <li>Windows Mobile</li> <li>iPhone</li> </ul> <p>I am looking for the best tool for each platform.<br> I do not search a technology that works everywhere.<br> I need something "light" adap...
<p>Hessian. <a href="http://hessian.caucho.com" rel="nofollow noreferrer">http://hessian.caucho.com</a>. Implementations in multiple languages (including ObjC), super light weight, and doesn't require reliance on dom/xml parsers for translation from wire to object models. Once we found Hessian, we forgot we ever kne...
<p>How about plain old XML (somewhat unfortunately referred to as POX)?</p> <p>Another very useful option would be <a href="http://www.json.org/" rel="nofollow noreferrer">JSON</a>. There are libraries for every single programming language out there.</p> <p>Possibly, since you are working in an environment that is co...
10,837
<p>Is there any benefit on Windows to use the WSA winsock functions compared to the BSD-style ones?</p>
<p>The most significant difference is the availability of Asynchronous Event style APIs in Winsock.</p> <p>With Berkeley sockets, each time you <code>read</code> or <code>write</code> your application will "block" until the network is ready, which could make your application unresponsive (unless the network I/O is han...
<p>With respect to Alnitak's answer, I agree - I'd just add that you need not use a message loop to use asynch operations on sockets. Using I/O completion ports is a very scalable way to build a high-performance networked application.</p>
34,554
<p>We have a ftp system setup to monitor/download from remote ftp servers that are not under our control. The script connects to the remote ftp, and grabs the file names of files on the server, we then check to see if its something that has already been downloaded. If it hasn't been downloaded then we download the file...
<p><strong>“Damn the torpedoes! Full speed ahead!”</strong></p> <p>Just download the file. If it is a large file then after the download completes wait as long as is reasonable for your scenario and continue the download from the point it stopped. Repeat until there is no more stuff to download.</p>
<p>You can't know when the OS copy is done. It could slow down or wait.</p> <p>For absolute certainty, you really need two files.</p> <ul> <li>The massive file.</li> <li>And a tiny trigger file.</li> </ul> <p>They can mess with the massive file all they want. But when they touch the trigger file, you're downloadin...
49,162
<p>How cheap can MySQL be compared to MS SQL when you have tons of data (and joins/search)? Consider a site like stackoverflow full of Q&amp;As already and after getting dugg. </p> <p>My ASP.NET sites are currently on SQL Server Express so I don't have any idea how cost compares in the long run. Although after a quic...
<p>MSSQL Standard Edition (32 or 64 bit) will cost around $5K <em>per CPU socket</em>. 64 bit will allow you to use as much RAM as you need. Enterprise Edition is not really necessary for most deployments, so don't worry about the $20K you would need for that license.</p> <p>MySQL is only free if you forego a lot of...
<p>MySQL is extremely cheap when you have the distro (or staff to build) that carries MySQL Enterprise edition. This is a High Availability version which offers multi-master replication over many servers.</p> <p>Pros are low (license-) costs after initial purchase of hardware (Gigs of RAM needed!) and time to set up. ...
10,237