instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have a laptop running Ubuntu to which I connect an external monitor when I'm at the office. Usually this requires me to run <code>xrandr --auto</code> in order for the laptop to re-size the display to match the external monitor. It would be nice if this could be done automatically, either triggered when the monito...
<p>I guees that the problem is that the script is being run as root, with no access to your xauth data. Depending on your setup, something like this could work:</p> <pre><code>xauth merge /home/your_username/.Xauthority export DISPLAY=:0.0 xrandr --auto </code></pre> <p>You could use something more clever to find out...
<p>Have you tried to set the DISPLAY variable in the script correctly and granted access for other users to your DISPLAY with xhost + localhost? Don't know if that helps, but it's worth a try.</p>
15,720
<p>MS SQL Server and Oracle, which one is better in terms of scalability?<br> For example, if the data size reach 500 TB etc.</p>
<p>Both Oracle and SQL Server are shared-disk databases so they are constrained by disk bandwidth for queries that table scan over large volumes of data. Products such as <a href="http://www.teradata.com/enterprise-data-warehouse" rel="nofollow noreferrer">Teradata</a>, <a href="http://www.netezza.com/products/dwa.asp...
<p>Oracle like a high-quality manual film camera, which needs the best photographer to take the best picture while MS SQL like an automatic digital camera. In old days, of course, all professional photographers will use film camera, now think about how many professional photographers use automatic digital camera.</p>
15,348
<p>My boss thinks the VS 2008 IDE Window Manager(autohiding, docking of Solution Explorer, Properties, etc) is the best thing since sliced bread. I can't find a control that resembles that functionality in the Toolbox. Is there a control like that available that you know of? Or should I go ahead and implement it mys...
<p>You don't have to create something that looks <em>like</em> the VS window manager - you can use the actual VS one with the <a href="http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx" rel="nofollow noreferrer">Visual Studio Shell</a>.</p> <p>I believe it's aimed at creating developer tools, but I see no...
<p>You should check out <a href="http://www.divil.co.uk/net/controls/sanddock/" rel="nofollow noreferrer">SandDock</a>. The older versions were freely licenced (dunno if they are still available) and the newer versions are relatively cheap, especially considering the amount of time/money/sanity they would save you.</p>...
22,520
<p>I was reading <em><a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html" rel="nofollow noreferrer">Java Platform Performance</a></em> (sadly the link seems to have disappeared from the internet since I originally posed this question) and section A.3.3 worried me.</p> <p>I had been wor...
<p>This code should clear it up:</p> <pre><code>public class TestInvisibleObject{ public static class PrintWhenFinalized{ private String s; public PrintWhenFinalized(String s){ System.out.println(&quot;Constructing from &quot;+s); this.s = s; } protected void finalize() throws Throwable { ...
<p>Would you really have that much code to analyse? Basically I can only see this being a significant problem for very long-running methods - which are typically just the ones at the top of each thread's stack.</p> <p>I wouldn't be at all surprised if it's unfixed at the moment, but I don't think it's likely to be as ...
34,165
<p>I've found this piece of code on <a href="http://www.koders.com/csharp/fidACD7502AA845419FF59B7DA804D3C8FCA0E40138.aspx?s=basecodegeneratorwithsite#L76" rel="nofollow noreferrer">Koders</a>:</p> <pre><code>private ServiceProvider SiteServiceProvider { get { if (serviceProvider == null) { ...
<p>It's possible that the ServiceProvider overrides the !=/== operator, so that for an <em>invalid</em> state the comparison to null returns true.</p> <p>Looks strange anyway.</p>
<p>I agree. If the normal != operator (inherited from Object) is being used, this can never happen. A constructor always returns an object reference and, as you have pointed out, if an exception was thrown in the constructor the execution point would leave the property entirely.</p> <p>I would check what this code is ...
48,516
<p>Should I have background color for a form input? Or this is really a subjective matter?</p> <p>For me personally I thought having background color for a form, kind of makes it more organized and clean.</p> <p>What are your views on this?</p>
<p>Two techniques that I don't see often enough are highlighting input fields with a background color <a href="http://www.dhtmlgoodies.com/index.html?whichScript=highlight-active-input" rel="nofollow noreferrer">when they are focused while filling out a form</a> and <a href="http://blog.jc21.com/staging/jsvalidate_yui....
<p>It really depends on the layout of the rest of the site. In my opinion it's good to have the form offset somehow, even if just with top/bottom borders - often you can make the whole thing a small box within the page. For something like a registration system, though, you might as well make the entire page the form - ...
28,773
<p>In the context of a Google App Engine Webapp framework application:</p> <p>I want to changed the request verb of a request in the case a parameter _method is provided, for example if a POST request comes in with a parameter _method=PUT, I need to change the request to call the put method of the handler. This is to ...
<p>Calling the handler from initialize isn't the right way anyway - if you do that, the webapp will then call the original handler as well.</p> <p>Instead, you have a couple of options:</p> <ul> <li>You can subclass webapp.WSGIApplication and override <strong>call</strong> to select the method based on _method when i...
<p>Calling the handler from initialize isn't the right way anyway - if you do that, the webapp will then call the original handler as well.</p> <p>Instead, you have a couple of options:</p> <ul> <li>You can subclass webapp.WSGIApplication and override <strong>call</strong> to select the method based on _method when i...
31,837
<p>I'd like to add a method to my existing server's CORBA interface. Will that require recompiling all clients?</p> <p>I'm using TAO.</p>
<p>Recompilation of clients is not required (and should not be, regardless of the ORB that you use). As Adam indicated, lookups are done by operation name (a straight text comparison).</p> <p>I've done what you're describing with our ACE/TAO-based system, and encountered no issues (servers were in ACE/TAO C++, clients...
<p>It depends on usage of new idl method. If Corba invocation is static(SII), meaning your client is linked with stub, you have to recompile a stub if you want to use your new added method interface. </p> <p>If corba invocation is dynamic(DII), there is no stub required for client. None of recompilation is required. ...
5,750
<p>I'm code reviewing a change one of my co-workers just did, and he added a bunch of calls to <code>Date.toMonth()</code>, <code>Date.toYear()</code> and other deprecated <code>Date</code> methods. All these methods were deprecated in JDK 1.1, but he insists that it's ok to use them because they haven't gone away yet...
<p>Regarding the APIs, ... it is not specified they will be removed anytime soon.</p> <p><a href="http://java.sun.com/j2se/1.5.0/compatibility.html" rel="nofollow noreferrer">Incompatibilities in J2SE 5.0 (since 1.4.2)</a>:</p> <p>Source Compatibility</p> <blockquote> <p>[...]<br> In general, the policy is as fo...
<p>Sun tend to be extremely paranoid when it comes to changes that impact backwards compatibility, so I wouldn't expect to see the methods go away any time soon.</p> <p>But deprecated methods <strong>could</strong> go away at any time in the future, and are normally deprecated for a reason - either because they're unr...
40,586
<p>Is there a way to take over the Entity Framework class builder? I want to be able to have my own class builder so i can make some properties to call other methods upon materialization or make the entity classes partial.</p>
<p>Actually they are already in partial classes. See <a href="http://msdn.microsoft.com/en-us/library/bb738612.aspx" rel="nofollow noreferrer">MSDN</a></p>
<p>I'll add that not only can you can tack on your own class <strong>partial classes</strong> to those emitted by the Entity Framework, but you can also write out all the <strong>partial methods</strong> created by the generated code.</p> <p>IE. There'll be a lot of partial method code which get called but the method ...
6,046
<p>Robocopy is the best reliable and feature rich way to batch copy files on Windows. However, it is a command line tool.</p> <p>I am looking for a library/API that I could do the same in my program. I tried to use Process.Start(), but then I have to capture and to parse stdout for progress bar and no way to the overw...
<p>I realize that this is a very old post, but just in case someone stumbles upon it...</p> <p>I wrote a wrapper for robocopy in c# called RoboSharp. It does exactly what the OP originally requested.</p> <p><a href="https://github.com/tjscience/RoboSharp" rel="nofollow noreferrer">https://github.com/tjscience/RoboSha...
<p>There seems to be some stuff out there which puts a GUI on it, e.g. <a href="http://www.microsoft.com/downloads/details.aspx?familyid=50FA5932-0685-4FE3-9605-536F39BD6C86&amp;displaylang=en" rel="nofollow noreferrer">Synchronizing Images and Files in Windows Vista and XP Using Microsoft SyncToy</a> (forum <a href="h...
47,688
<p>I recently wrote a webservice to be used with Silverlight which uses the ASP.net membership and roles.</p> <p>To validate the client in the service I look at the HTTPContext.Current.User (Which works when the service is called from Silverlight)</p> <p>However, I've been trying to call the same service from an asp....
<p>I have solved it!</p> <p>Looks like by default the Silverlight application was sending all the browsers cookies to the service. One of these cookies is the ".ASPXAUTH" cookie to authenticate against the membership and roles.</p> <p>The asp.net application however was not sending the cookies to the service. To send...
<p>Not sure how it is working from Silverlight but not ASP.Net, but for starters here is a good <a href="http://nayyeri.net/blog/use-asp-net-membership-and-role-providers-in-windows-communication-foundation/" rel="nofollow noreferrer">blog post on how to setup WCF to work with ASP.Net membership providers</a>. There ar...
35,316
<p>Before I get flamed and down-voted without mercy, my company will not allow the install of .NET3.5 on non-dev machines yet (others are currently on 3.0).</p> <p>I have a managed exe on network share that needs to be able to run from there. This is a common problem with pre-.NET3.5SP1, but I cannot figure out how t...
<p>Pre 3.5 and without access to the machine itself or machine/domain policy, I think you're out of luck.</p> <p>The brute force approach is to go to Control Panel > Administrative Tools > MS .NET Framework X.X Wizards > Adjust .NET Security on each machine and set the security level for the Local Intranet zone to Ful...
<p>You could create an unmanaged bootstrapper that copies your .net code locally and launches it. Or you can use click once and create a shortcut in another directory to hide you other files.</p>
28,997
<p>What is the best way to refactor the attached code to accommodate multiple email addresses?</p> <p>The attached HTML/jQuery is complete and works for the first email address. I can setup the other two by copy/pasting and changing the code. But I would like to just refactor the existing code to handle multiple email...
<p>Instead of using IDs for your email fields, you can give them each a class:</p> <pre><code>&lt;div&gt; &lt;label for="Email_Address_1"&gt;Friend #1&lt;/label&gt;&lt;/div&gt; &lt;input type="text" class="email"&gt; &lt;span&gt;&lt;/span&gt; &lt;/div&gt; &lt;div&gt; &lt;label for="Email_Address_2"&gt;...
<p>Thanks! Here is the completed refactor with your suggested changes.</p> <pre><code>&lt;script language="javascript"&gt; $(document).ready(function() { $('#Email_Address_1').keyup(function(){Update_Email_Validate_Status(this)}); $('#Email_Address_2').keyup(function() { Update_Email_Va...
9,456
<p>Does anyone have any T4 example Templates (or links to same) that can be used to generate a Webservice?</p> <p>I'm thinking of the fact that I guess the Webservice is not just the Vb or Cs field but also requires an appropriate asmx file.</p> <p>I'm really not sure how to achieve this</p>
<p><a href="http://www.olegsych.com/2008/03/how-to-generate-multiple-outputs-from-single-t4-template/" rel="nofollow noreferrer">Oleg Sych: How to generate multiple outputs from single T4 template</a>; create another method that generates your asmx - should be pretty simple, as it's one line - and renders it to a file....
<p>Perhaps <a href="http://www.codeplex.com/servicefactory" rel="nofollow noreferrer">Web Service Software Factory</a> will do what you need right out of the box. As I understand, it generates code with T4 templates you can extend.</p>
28,849
<p>Is there any way to generate project docs during automated builds? </p> <p>I'd like to have a single set of source files (HTML?) with the user manual, and from them generate:</p> <ul> <li>PDF document</li> <li>CHM help </li> <li>HTML version of the help</li> </ul> <p>The content would be basically the same in all...
<p>Yes!</p> <ul> <li>Use <a href="http://www.codeplex.com/SHFB" rel="nofollow noreferrer">SandCastle</a> to build CHM/HTM documentation of the APIs.</li> <li>Use <a href="http://www.docbook.org/" rel="nofollow noreferrer">DocBook</a> + <a href="http://xmlgraphics.apache.org/fop/" rel="nofollow noreferrer">FOP</a> and ...
<p>I've had an experience with Doxygen. It is nice and easy, but it makes you want overcommenting the code to ease later documetation work. </p>
13,929
<p>Last time I create WAS profile and WASService then I try to config and run many script for learn how to config WAS, Finally it crash so i use wasprofile delete this profile and forgot delete WASService.</p> <p>Now I found IBM Webphere Application Server service display in services.msc list, so I tried to delete it ...
<p>make sure the service is stopped, the services control panel is closed, and no open file handles are open by the service. </p> <p>Also make sure ProcessExplorer is not running.</p>
<p>One situation where this can also happen is if there is some other service or application that is holding open a service handle obtained with OpenService. For example, a monitoring service that starts and stops services based on some external event can keep open handles to each of the services it monitors. In this c...
39,225
<p>I'm looking for a pre-written component (w/source) for a Delphi project that I'm working on, to generate mind-maps / concept-maps similar to these:</p> <p><a href="http://en.wikipedia.org/wiki/Image:MindMeister_screenshot_OS_X.jpg" rel="noreferrer">http://en.wikipedia.org/wiki/Image:MindMeister_screenshot_OS_X.jpg<...
<p>As a former Delphi developer, I sympathize. It used to be that you could find a free component with source for just about anything. You probably know about the <a href="http://delphi.icm.edu.pl/" rel="nofollow noreferrer">Delphi Super Page</a> (my old go-to source for everything Delphi). I looked; no mind-mapping...
<p>JVCL : Demo called JvDesignerDemo</p>
3,440
<p>When using one's own iPhone for development it's easy enough to access any crash logs via XCode->Organizer->Crash Logs.</p> <p>How does one access crash logs on another person's phone if they don't have it set up for development in XCode, as would likely be the case if you were distributing your app to them via ad ...
<p>Two ways:</p> <ul> <li><p>iTunes syncs all crash reports during a regular sync. They can be found in Library/Logs/CrashReporter/MobileDevice on a Mac and probably somewhere in %APPDATA% on Windows.</p></li> <li><p><strike> You can use the <a href="http://www.apple.com/downloads/macosx/apple/application_updates/ipho...
<p>On an iPhone 5, you do not need to connect the iPhone to iTunes to see the logs. Not sure about other iPhone versions but you can get to the logs by opening up Settings and then navigating to:</p> <p>Settings -> General -> About -> Diagnostics &amp; Usage -> Diagnostics &amp; Usage Data</p> <p>For the app you are...
20,694
<p>I noticed that there is one change about ASP.NET Routing. I cannot understand why such change.</p> <p>In ASP.NET MVC Preview, the routing setting in Global.ascx is like "[controller]/[action]/[id]". Now, it is changed to be "{controller}/{action}/{id}". Why change [] to {} ? Is there some necessity to do that?</p>
<p>Wow, that happened a long while ago. Someday, I hope that the string class itself is augmented with named formats. Then this move will look like a very prescient move. We liked its similarity and consistency with string.format. Also, it is consistent with the UriTemplate format string.</p>
<p>In a route, you define placeholders (referred to as URL parameters) by enclosing them in braces ( { and } ). The / character is interpreted as a delimiter when the URL is parsed. </p> <p>So now why they changed their code for parsing placeholders from [ ] to { } is something which the developers would know better...
44,095
<p>Is it possible to build a .dmg file (for distributing apps) from a non-Mac platform? And if yes, how?</p>
<p>Yep, mkfs.hfsplus does it.</p> <pre><code>dd if=/dev/zero of=/tmp/foo.dmg bs=1M count=64 mkfs.hfsplus -v ThisIsFoo /tmp/foo.dmg </code></pre> <p>This creates a dmg file (in this case 64M) that can be mounted on a mac. It can also be mounted on linux, with something like</p> <pre><code>mount -o loop /tmp/foo.dmg /...
<p>If you're distributing Mac apps, then surely you have a Mac to write and test them. Why not simply use that same Mac to create the disk image?</p> <p>[Edit] Alternatively, if you're distributing a portable app, for example a Java .jar file, why bother with a disk image? Macs understand .zip and .tar.gz archives jus...
36,396
<p>There are Hibernate tools for mapping files to ddl generation; ddl to mapping files and so on, but I can't find any command line tools for simple DDL generation from JPA annotated classes.</p> <p>Does anyone know an easy way to do this? (Not using Ant or Maven workarounds)</p>
<p>I'm not sure, whether this is considered a workaround, because you already referred to it in your question. You can use <a href="http://tools.hibernate.org/" rel="noreferrer">Hibernate Tools</a> to generate DDL from JPA annotated classes. You just need hibernate tools and its dependencies on the classpath and should...
<p>Here's an explaination of how to use the hibernate SchemaExport class to do what you want. Similar to the anttask method mentioned before, but not everyone uses ant. You can execute this example code right from the commandline.</p> <p><a href="http://jandrewthompson.blogspot.com/2009/10/how-to-generate-ddl-scripts...
35,681
<p>Has anyone managed to get subsonic or a variant working on Windows Mobile? We cant get it to work as it has a dependency on System.Configuration.</p> <p>Any suggestions on an alternate ORMs that would work on a windows mobile device?</p>
<p>A colleague of mine used <a href="http://www.entityspaces.net" rel="nofollow noreferrer">EntitySpaces</a> on a Windows Mobile project and was pretty pleased with it.</p>
<p>You could look at something like <a href="http://www.llblgen.com/pages/features.aspx" rel="nofollow noreferrer">LLBLGEN</a> which shows support for the compact framework.</p>
31,561
<p>I am trying to format some bad html to output into a pop window. The html is stored in a field in a mysql database.</p> <p>I have been performing json_encode and htmlspecialchars on the row in the php like so:</p> <pre><code>$html = htmlentities(json_encode($row2['ARTICLE_DESC'])); </code></pre> <p>and calling my...
<p>You shouldn't have the single quotes in the function call. It should look like this:</p> <pre><code>&lt;p&gt;&lt;a href='#' onclick=\"makewindows(" . $html . "); return false;\"&gt;Click for full description &lt;/a&gt;&lt;/p&gt; </code></pre> <p>Then the output will look like</p> <pre><code>&lt;p&gt;&lt;a href='...
<p>Try it the following way:</p> <pre><code>$html = htmlentities(json_encode($row2['ARTICLE_DESC']),ENT_QUOTES); </code></pre> <p>I think the single quotation marks are not escaped by default. Nevertheless I recommend you saving the html in a JavaScript variable before opening the window.</p>
48,928
<p>Has anyone found a good method of mocking out ADO.Net Data Service calls from a Silverlight application? </p> <p>The power of Data Services seems to be the use of linq, client side, over entities. However when testing the objects that do the data access how can you mock out the service?</p> <p>One way is to create...
<p>I understand, but one of the advantages of using ADO.Net Data Services appears to be that you get your entity objects for free. But if you can't mock the service it's calling this doesn't help.</p> <p>Maybe one way is to pass in a different uri, but it would presumably still not all the same objects?</p> <p>If you...
<p>I understand, but one of the advantages of using ADO.Net Data Services appears to be that you get your entity objects for free. But if you can't mock the service it's calling this doesn't help.</p> <p>Maybe one way is to pass in a different uri, but it would presumably still not all the same objects?</p> <p>If you...
39,205
<p>I work in VBA, and want to parse a string eg</p> <pre><code>&lt;PointN xsi:type='typens:PointN' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema'&gt; &lt;X&gt;24.365&lt;/X&gt; &lt;Y&gt;78.63&lt;/Y&gt; &lt;/PointN&gt; </code></pre> <p>and get the X &amp; Y...
<p>This is a bit of a complicated question, but it seems like the most direct route would be to load the XML document or XML string via MSXML2.DOMDocument which will then allow you to access the XML nodes.</p> <p>You can find more on MSXML2.DOMDocument at the following sites:</p> <ul> <li><a href="https://web.archive...
<p>Often it is easier to parse without VBA, when you don't want to enable macros. This can be done with the replace function. Enter your start and end nodes into cells B1 and C1.</p> <pre><code>Cell A1: {your XML here} Cell B1: &lt;X&gt; Cell C1: &lt;/X&gt; Cell D1: =REPLACE(A1,1,FIND(A2,A1)+LEN(A2)-1,"") Cell E1: =RE...
3,245
<p>I understand how the implementation of dynamic binding works and also the difference between static and dynamic binding, I am just having trouble wrapping my brain around the definition of dynamic binding. Basically other than it is a run-time binding type.</p>
<p>Basically, dynamic binding means that the address for a function call is not hard-coded into the code segment of your program when it's translated into assembly language, and is instead obtained from elsewhere, i.e. stack variables, array lookups, etc.</p> <p>At a higher level, if you have a line of code:</p> <pre...
<p>I understand it being evident in polymorphism. Typically when creating multiple classes that derive from a base class. If each one of the derived classes contains a function that each one uses. The base class can be used to execute a function of the derived classs and it will be properly call the correct function...
32,130
<p>Does anyone know if it is possible to embed a file open dialog inside your own form?</p> <p>We have a tabbed dialog and on one of the tabs we want the user to be able to browse for a file with the same functionality as the the standard open dialog e.g. 'Look in' combobox, places bar, shell file list, file name com...
<p>I don't want to say it's impossible but considering the amount of ugly winapi hacks you'd probably involve I suggest "recreating the dialog with some 3rd party components" but with <strike><a href="http://www.mustangpeak.net/" rel="nofollow noreferrer">VirtualShellTools</a></strike>.<br> VirtualShellTools can be dow...
<p>I would re-create it: it shouldn't take long with the VCL Components. The autocomplete is not hard, and you can get the rest of the data if you look through the windows docs long enough.</p> <p>You can try and cheat by detecting the tab change and displaying the open dialog as if it were the tab page. You will have...
34,294
<p>In our office, we regularly enjoy some rounds of foosball / table football after work. I have put together a small java program that generates random 2vs2 lineups from the available players and stores the match results in a database afterwards.</p> <p>The current prediction of the outcome uses a simple average of a...
<p>Use the TrueSkill algorithm, it is very good at this. I've implemented it for foosball and chess and it works very well. Coworkers have told me that it's almost <em>too</em> good at this.</p> <p>For complete details on how it works as well as a link to my implementation, see my "<a href="http://www.moserware.com/20...
<p>Try applying Naive Bayes classifier.</p> <blockquote> <p>Bayesian learning is a probabilistic approach which is based on an assumption that the quantities of interest are governed by probability distributions and that optimal decisions can be made by reasoning about these probabilities together with...
32,756
<p>In most of the commercial jobs I've had to date, my role has mostly been confined to "writing the code", whereas the reason I wanted to get into development in the first place was because I enjoyed usability and design aspect of software.</p> <p>I feel a bit dissalusioned now, because now, pretty much all my workin...
<p>Yes, the jobs exist; and they're not that hard to get into. The thing that I've found is that those opportunities, though, are at the smaller companies.</p> <p>In general, larger companies have more of a "structure" in place, where the senior people do the design, and then the implementation trickles down. Genera...
<p>It sounds like you might be happiest starting your own software company, or at least working on your own projects in your spare time.</p>
39,046
<p>I have a script that needs to extract data temporarily to do extra operations on it, but then doesn't need to store it any further after the script has run. I currently have the data in question in a series of temporary local tables (CREATE TABLE #table), which are then dropped as their use is completed. I was con...
<p>Temporary tables are a big NO in SQL Server.</p> <ul> <li>They provoke query plan recompilations which is costly.</li> <li>Creating and dropping the table are also costly operations that you are adding to your process.</li> <li>If there is a big amount of data going to the temporary data your operations will be slo...
<p>For MySql at least, the only time savings you are going to get is the time savings of actually creating the temporary table. AFAIK all the tables are treated the same on disk, they just happen to go away at the end of your session. This is what I have seen in practice as well. Again, this is mysql 4.x and 5.x</p>
27,106
<p>In my current environment, we have a "clean" build machine, which has an exact copy of all committed changes, nothing more, nothing less.</p> <p>And of course I have my own machine, with dozens of files in an "in-progress" state.</p> <p>Often I need to build my application with only one change in place. For examp...
<p>So you are asking how to handle working on multiple "tasks" at once, right? Except branching.</p> <p>You can have multiple checkouts of the source on the local machine, suffixing the directory name with the name of the ticket you are working on. Just make sure to make changes in the right directory, depending on th...
<p>I prefer to make and test builds on my local machine/environment before committing or promoting any changes. </p> <p>For your specific example, I would have checked out a clean copy of the source before starting task ABC, and after implementing ABC, created a build locally with that in it.</p>
7,608
<p>I would like to get a green tombow PITS adhesive stick. On Rakuten, it costs \$1 (USD). On my 3d printer's (XYZ) retailer's site, it costs \$20 (USD). Due to the costs and the fact that Rakuten does not ship to my country, I need an alternative. I am currently using Davinci 1.0 for my bed, which I believe is a glass...
<p>As mentioned by Matt - PVA glues work perfect for both filaments. It works well because it's softening temperature is between 45..85C so it's more or less temperature of HB.</p> <p>Advantages:</p> <ul> <li>cheap</li> <li>easy to apply on HB</li> <li>can be applied on cold as same as on hot HB</li> <li>sticks model...
<p>Most PVA glue works well for both (Poly Vinyl Acetate).<br> There are different brands in every country.</p>
280
<p>I have a session class that needs to store session information in a MySQL database. Obviously I will need to query the database in the methods of this class. In general I may need to connect more than one database simultaneously and may or may not be connected to that database already. </p> <p>Given that, what's...
<p>I'd advise to check out this presentation, among other things it talks about best practices when accessing database:</p> <p><a href="http://laurat.blogs.com/talks/best_practices.pdf" rel="nofollow noreferrer">http://laurat.blogs.com/talks/best_practices.pdf</a></p>
<p>Database Connections are a prime example of when and where you can safely use a Singleton pattern; however, if you know that the Session Object will be a global object and it will be the only place that you need to create Database Connections, you could pretty safely store the db connections as instance members of t...
31,166
<p>I have two collections of the same object, <code>Collection&lt;Foo&gt; oldSet</code> and <code>Collection&lt;Foo&gt; newSet</code>. The required logic is as follow:</p> <ul> <li>if <code>foo</code> is in(*) <code>oldSet</code> but not <code>newSet</code>, call <code>doRemove(foo)</code></li> <li>else if <code>foo<...
<p>Apache's commons.collections library has a CollectionUtils class that provides easy-to-use methods for Collection manipulation/checking, such as intersection, difference, and union.</p> <p>The org.apache.commons.collections.CollectionUtils API docs are <a href="http://commons.apache.org/proper/commons-collections/j...
<p>For a set that small is generally not worth it to convert from an Array to a HashMap/set. In fact, you're probably best off keeping them in an array and then sorting them by key and iterating over both lists simultaneously to do the comparison.</p>
4,341
<p>What options are available for receiving instant alerts from web applications? </p> <p>I have a time sensitive web application I need to tend to (approving expediated purchase order requests). I have thought of being notified by e-mail and SMS. </p> <p>Are there any programs to let my website send a popup window d...
<p>If you have your application open and you want a popup to appear, you could have a javascript timer that does an ajax style poll of your server every so often to see if there is a notification it needs to post. You could then throw up a pop up with the notification?</p>
<p>You could also have an RSS feed tying into the application that would publish an update as soon as something occurred. Granted that would require you to have an RSS reader constantly pinging the application.</p> <p>Similarly, if you use the log4j/log4net framework, you can log a "fatal" or other special event for t...
13,032
<p>I'm writing some RSS feeds in PHP and stuggling with character-encoding issues. Should I utf8_encode() before or after htmlentities() encoding? For example, I've got both ampersands and Chinese characters in a description element, and I'm not sure which of these is proper:</p> <pre><code>$output = utf8_encode(htmle...
<p>It's important to pass the character set to the htmlentities function, as the default is ISO-8859-1:</p> <pre><code>utf8_encode(htmlentities($source,ENT_COMPAT,'utf-8')); </code></pre> <p>You should apply htmlentities first as to allow utf8_encode to encode the entities properly.</p> <p>(EDIT: I changed from my o...
<p>After much trial &amp; error, I finally found a way to properly display a string from a utf8-encoded database value, through an xml file, to an html page:</p> <pre><code>$output = '&lt;![CDATA['.utf8_encode(htmlentities($string)).']]&gt;'; </code></pre> <p>I hope this helps someone.</p>
39,594
<p>Has anyone else run into this problem before? I've got a method that calls a generic method with a delegate, inside of a generic class. I've marked the class as Serializable, and it serializes without complaint. But, when I try to deserialize an object of this class, it pegs the CPU and hangs the machine.</p> <p>Co...
<p>This is the code I currently have, which works fine?</p> <pre><code> [Serializable] public class SDictionary&lt;TKey, TValue&gt; : Dictionary&lt;TKey, TValue&gt; { public SDictionary() : base() { } protected SDictionary(SerializationInfo info, StreamingContext...
<p>First of all, Dictionary&lt;> already implements ISerializable, so you don't need to specify that explicity!</p> <p>Second, you override GetObjectData(), but you don't seem to call Dictionary.GetObjectData(), so the dictionary may not be getting deserialised? Hence, when you access this.Keys, you end up with "an is...
34,048
<p>Why are the lists <code>list1Instance</code> and <code>p</code> in the <code>Main</code> method of the below code pointing to the same collection? </p> <pre><code>class Person { public string FirstName = string.Empty; public string LastName = string.Empty; public Person(string firstName...
<p>In fact, <code>IEnumerable&lt;T&gt;</code> <b>is already readonly</b>. It means you cannot replace any items in the underlying collection with different items. That is, you cannot alter the <em>references</em> to the <code>Person</code> objects that are held in the collection. The type <code>Person</code> is not rea...
<p><code>IEnumerable&lt;T&gt;</code> <em>is</em> readonly</p> <p><code>p</code> is a new collection which doesn't depend on <code>list1instance</code>. The mistake you made, is that you thought that this line <code>list[0].FirstName = "uf1";</code><br> would only modify one of the lists, when on fact you're modifying...
46,895
<p>When working on developing new software i normally get stuck with the redundancy vs dependencies problem. That is, to either accept a 3rd party library that i have a huge dependencies to or code it myself duplicate all the effect but reduce the dependencies.</p> <p>Though I've recently been trying to come up with a...
<p>I would definitely recommend reading Joels essay on this:</p> <p><a href="http://www.joelonsoftware.com/articles/fog0000000007.html" rel="nofollow noreferrer">"In Defense of Not-Invented-Here Syndrome"</a></p> <p>For a dependency, the best metric I can think of would be "would the world grind to a halt if this dis...
<p>A possible alternative is to use the external software if it provides a lot of value to your project, but hide this behind a simplified (and more consistent to your project) interface.</p> <p>This allows you to leverage the power of a third party library, but with much reduced complexity (and as such redundancy) in...
19,947
<p>Newer ARM processors include the PLD and PLI instructions.</p> <p>I'm writing tight inner loops (in C++) which have a non-sequential memory access pattern, but a pattern that naturally my code fully understands. I would anticipate a substantial speedup if I could prefetch the next location whilst processing the cu...
<p>There should be some Compiler-specific Features. There is no standard way to do it for C/C++. Check out you compiler Compiler Reference Guide. For RealView Compiler see <a href="http://www.keil.com/support/man/docs/armccref/armccref_cjagadac.htm" rel="noreferrer">this</a> or <a href="http://www.keil.com/support/man/...
<p>At the risk of asking the obvious: have you verified the compiler's target architecture? For example (humor me), if by default the compiler is targeted to ARM7, you're <em>never</em> going to see the PLD instruction.</p>
10,814
<p>Suppose I want to to print several copies of a large, flat object, such as a hollow frame. If I make an STL file consisting of several copies floating just above each other then my 3D printer's software happily generates supports for the upper objects to sit on, as shown below:</p> <p><a href="https://i.stack.imgur...
<p>According to the RepRap.org <a href="http://reprap.org/wiki/G-code" rel="nofollow noreferrer">list of G-Code commands</a>, see <strong><a href="http://reprap.org/wiki/G-code#G0_.26_G1:_Move" rel="nofollow noreferrer">G0 &amp; G1: Move</a></strong>:</p> <blockquote> <p>The <code>Ennn</code> command is <em>The amou...
<p>Is the hotend temperature set correctly? If you only preheat the hotend but then turn it off, it will behave exactly as you described (while you're above <code>EXTRUDE_MINTEMP</code> it will behave normally, but once the temperature drops too low it will continue doing the XYZ-moves, but stop extruding). Perhaps you...
232
<p>I need to fire an event when the mouse is above a PictureBox with the mouse button already clicked and held down.</p> <p>Problems: </p> <p>The MouseDown and MouseEnter event handlers do not work together very well.</p> <p>For instance once a mouse button is clicked and held down, C# will fire the MouseDown event ...
<p>When the mouse is pressed down most controls will then <em>Control.Capture</em> the mouse input. This means that all <em>MouseMove</em> events are sent to the original control that captured rather than the control the mouse happens to be over. This continues until the mouse loses capture which typically happens on t...
<p>set a flag or a state on mouse down. release it on mouse up. When on mouse over fires for the picture box check your state. Now you can detect when a person is dragging something.</p>
20,473
<p>I've noticed that some sites (usually banks) suppress the ability to paste text into text fields. How is this done? I know that JavaScript can be used to swallow the keyboard shortcut for paste, but what about the right-click menu item?</p>
<p>Probably using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.onpaste" rel="nofollow noreferrer"><code>onpaste</code></a> event, and either <code>return false</code> from it or use <code>e.preventDefault()</code> on the Event object.</p> <p>Note that <code>onpaste</code> is <em>non standa...
<p>Even if it is somewhat possible to intercept the paste event in many browsers (but not all as shown at the link on the previous answer), that is quite unreliable and posible not complete (depending on the browser / OS it may be possible to do the paste operation in different ways that may not be trappable by javascr...
5,309
<p>I have trouble using Perl grep() with a string that <em>may</em> contain chars that are interpreted as regular expressions quantifiers. </p> <p>I got the following error when the grep pattern is "g++" because the '+' symbols are interpreted as quantifiers. Here is the output of for program that follows:</p> <pre><...
<p>The standard way is to use the <code>\Q</code> escape indicator before your variable, to tell Perl not to parse the contents as a regular expression:</p> <pre><code>return grep (!/\Q$filter/, @output); </code></pre> <p>Altering that line in your code yields:</p> <pre> 1..3 ok 1 - grep, pattern not found ok 2 - gr...
<blockquote> <p>PS: in addition to the answer question above, I welcome any feedback on Perl usage in the above as I'm still learning.</p> </blockquote> <p>The best advice I can give for Perl coding advice in general is to install <a href="http://search.cpan.org/perldoc?Perl::Critic" rel="nofollow noreferrer">...
25,026
<p>I need to spawn a process in Java (under Linux exclusively) that will continue to run after the JVM has exited. How can I do this? </p> <p>Basically the Java app should spawn an updater which stops the Java app, updates files and then starts it again.</p> <p>I'm interested in a hack &amp; slash method to just get...
<p>If you're spawning the process using <a href="http://java.sun.com/javase/6/docs/api/java/lang/Process.html" rel="noreferrer"><code>java.lang.Process</code></a> it should "just work" - I don't believe the spawned process will die when the JVM exits. You might find that the Ant libraries make it easier for you to cont...
<p>If you're looking at making an updater on Linux, you're probably barking up the wrong tree. I believe all major linux distros have a package manager built in. You should use the package manager to do your updating. Nothing frustrates me more than programs that try to self-update... (I'm looking at you, Eclipse)</...
37,807
<p>In one of my VB6 forms, I create several other Form objects and store them in member variables.</p> <pre><code>Private m_frm1 as MyForm Private m_frm2 as MyForm // Later... Set m_frm1 = New MyForm Set m_frm2 = New MyForm </code></pre> <p>I notice that I'm leaking memory whenever this (parent) form is created and ...
<p>@Matt Dillard - Did setting these to nothing fix your memory leak?</p> <p>VB6 doesn't have a formal garbage collector, more along the lines of what @Konrad Rudolph said.</p> <p>Actually calling unload on your forms seems to me to be the best way to ensure that the main form is cleaned up and that each subform clea...
<p>Strictly speaking never, but it gives the garbage collector a strong hint to clean things up.</p> <p>As a rule: <strong>do it every time you're done with an object that you've created</strong>.</p>
5,028
<p>I need to add multiple empty divs to a container element using jQuery.</p> <p>At the moment I am generating a string containing the empty html using a loop</p> <pre><code>divstr = '&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;...&lt;div&gt;&lt;/div&gt;'; </code></pre> <p>and then injecting that into my container...
<p>If you want IE to be fast - or generally consider speed, then you'll want to build up a DOM fragment first before inserting it.</p> <p>John Resig explains the technique and includes a performance benchmark:</p> <p><a href="http://ejohn.org/blog/dom-documentfragments/" rel="noreferrer">http://ejohn.org/blog/dom-doc...
<p>You can use a regular loop with the Jquery <a href="http://docs.jquery.com/Manipulation/append#content" rel="nofollow noreferrer">append</a> function.</p> <pre><code>for(i=0;i&lt;10; i++){ $('#container').append("&lt;div&gt;&lt;/div&gt;"); } </code></pre>
24,612
<p>I'm looking for the .NET/C# way of performing <a href="http://msdn.microsoft.com/en-us/library/aa363801(VS.85).aspx" rel="nofollow noreferrer">Change Journal Operations</a> (without importing unmanaged code).</p> <p>Any hints or RTM-links?</p>
<p>This looks promising (and in C#):</p> <p><a href="http://mchangejournal.codeplex.com/" rel="nofollow">http://mchangejournal.codeplex.com/</a></p> <p>You have to download the Source code as there are no official Releases. I was able to run the demo (on Windows 7), but not able to see which Files were changed. Thi...
<p>This might be useful</p> <p><a href="http://www.codeproject.com/KB/files/Eyes_on_NTFS.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/files/Eyes_on_NTFS.aspx</a></p>
32,090
<p>I know Java well. Which caveats and resources will help me cross to the other side (C#) as painlessly as possible.</p>
<p>Biggest tip: go with the <a href="http://msdn.microsoft.com/en-us/library/ms229045.aspx" rel="noreferrer">.NET naming conventions</a> from the word go. That way you'll constantly be reminded about which language you're in. (Sounds silly, but it really is helpful.) Embrace the idioms of the language as far as possibl...
<p>The language syntax is vary similar, so I should only read a small reference of the C# syntax. Like a simple book (for experienced programmers) or maybe wikipedia (<a href="http://en.wikipedia.org/wiki/Comparison_of_Java_and_C_Sharp" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Comparison_of_Java_and_C_Sha...
26,091
<p>I have VB6 application , I want to put some good error handling finction in it which can tell me what was the error and exact place when it happened , can anyone suggest the good way to do this </p>
<p>First of all, go get <a href="http://www.mztools.com/v3/mztools3.aspx" rel="noreferrer">MZTools for Visual Basic 6</a>, its free and invaluable. Second add a custom error handler on every function (yes, every function). The error handler we use looks something like this:</p> <pre><code>On Error GoTo {PROCEDURE_NA...
<p>Use the On Error statement and the Err object.</p>
14,168
<p>I am trying to print a <a href="https://www.thingiverse.com/thing:2755765" rel="nofollow noreferrer">12 hole Ocarina</a> I found on thingiverse. When printing I have to stop it around 25-30 layers because the edge of the shell is higher then the infill. </p> <p><a href="https://i.stack.imgur.com/kMrn5.jpg" rel="nof...
<p>Did you verify the Cura z-offset actually changed the corresponding G-Codes? </p> <p>I had the opposite problem on my RF1000. To fix the problem I added the following 2 lines to my start G-Codes:</p> <pre><code>M3001 ; Activate Z-Compensation M206 Z-0.3 ; Set z offset 0.3mm closer to the nozzle </code></pre> <p>...
<p>Did you verify the Cura z-offset actually changed the corresponding G-Codes? </p> <p>I had the opposite problem on my RF1000. To fix the problem I added the following 2 lines to my start G-Codes:</p> <pre><code>M3001 ; Activate Z-Compensation M206 Z-0.3 ; Set z offset 0.3mm closer to the nozzle </code></pre> <p>...
1,438
<p>Has anyone got a working solution without some Java/COM-bridge? E.g. process the Email as a file (.msg) rather than locating the data that is referenced in the Clipboard?</p>
<p>Maybe this is a solution for your problem: <a href="http://sourceforge.net/projects/javaoutlookdd/" rel="nofollow">http://sourceforge.net/projects/javaoutlookdd/</a> It allows to handle outlook items like File objects during drag&amp;drop.</p>
<p>I assume that you've already ruled out the tools in "org.eclipse.swt.dnd" for some reason? There are some examples <a href="http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Clipboard.htm" rel="nofollow noreferrer">here</a> on how to go about using them, in case you haven't. If what you really want to do is drag&a...
4,281
<p>There are too many method for embedding flash in html, which way is the best? Requirements are:</p> <ul> <li>Cross-browser support</li> <li>Support for alternative content (if flash is not supported by the browser)</li> <li>Possibility to require a specific version of the flash player</li> </ul> <p>I have been rea...
<p>In a project I work on we use SWFobject which works like a charm, it allows you to check for a specific version and also display alternative content if flash is not supported.</p> <pre><code>var fn = function() { if(swfobject.hasFlashPlayerVersion("9.0.115")) { var att = { data:"flash.swf", width:"y...
<p>I use SWFObject myself, in combination with the &lt;embed&gt; and &lt;object&gt; tags. The reason I include the HTML embeds, is that SWFObject and flashembed rely on Javascript to update the DOM. Not every user who has Flash installed also has Javascript enabled.</p>
40,907
<p>How could I setup a nice indice on <code>cap:deploy</code>?</p> <p>I want the remote server to nice the <code>cp</code> commands like so: </p> <pre><code>nice -n 19 cp ... </code></pre>
<p>This seems to be doing exactly what you want. It's just your code with some typos fixed.</p> <pre><code> var reportXML:XML = &lt;Report&gt; &lt;prop1&gt;4&lt;/prop1&gt; &lt;prop2&gt;2255&lt;/prop2&gt; &lt;prop3&gt;true&lt;/prop3&gt; ...
<p>Using E4X syntax in ActionScript 3 I guess that would be something like:</p> <pre><code>report.prop5[0] = false; </code></pre>
37,839
<p>I want to read and write from serial using events/interrupts. Currently, I have it in a while loop and it continuously reads and writes through the serial. I want it to only read when something comes from the serial port. How do I implement this in C++?</p> <p>This is my current code:</p> <pre> while(true) ...
<p>Hmm i like the Interface idea suggested by digiguru but i would use the interface on the container Control1 instead of the sub controls as it seems like the more logical place for the code to live. Heres my take on it:</p> <pre><code>public interface IValidatableControl { bool IsValidControl(); } </code><...
<p>One method you could try is creating and maintaining a simple xml structure that represents your custom control hierarchy. Insert or delete from this structure any time you create or destroy a custom user control. Upon save, validate that the control hierarchy represented in the xml structure is correct. You could...
31,857
<p>i get a Keyword not supported: '192.168.1.1;initial catalog'. error when trying to do this </p> <p><code>Dim cn As New SqlConnection(str)</code> </p> <p>where str is the connection string starts with '192.168.1.1;initial catalog' ... I have not specified the provider in the connection string</p>
<p>you need to provide a properly formatted connectionstring such as:</p> <pre><code>Dim str As String str = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;" Dim cn As New SqlConnection(str) </code></pre>
<p>You have to specify the database with the keyword "Data Source" or "Server". Here's an example:</p> <pre><code>Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI; </code></pre>
39,521
<p>I'm well aware of Java tools for manipulating, generating, decompiling JVM bytecode (ASM, cglib, jad, etc). What similar tools exist for the CLR bytecode? Do people do bytecode manipulation for the CLR? </p>
<p>Reflector is always good, but Mono.Cecil is the best tool you can possibly ask for overall. It's invaluable for manipulating CIL in any way.</p>
<p><a href="http://ndepend.com/" rel="nofollow noreferrer">NDepend</a> allows you to do .NET assemblies static analysis (code metrics, dependency analysis, etc.). NDepend is very useful to get an overview of the structure of your .NET assemblies using dependency matrix, dependency graphs and treemap metrics <a href="ht...
15,047
<p>I would like to write all meta data (including advanced summary properties) for my files in a windows folder to a csv file. Is there a way to collect all the attributes? I see mp3 files have a different set of attributes compared to jpg files. (c#)</p> <p>This can also be a script (vb, perl)</p> <p>Update: by lo...
<p>If you can cope w/ VB.Net: <a href="http://www.codeproject.com/KB/vb/mp3id3v1.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/vb/mp3id3v1.aspx</a></p> <p>If you can cope w/ C++/.Net: <a href="http://www.codeproject.com/KB/audio-video/mp3fileinfo.aspx" rel="nofollow noreferrer">http://www.codeproject.c...
<p>It may not be worth it to add all of the data from a jpeg file (exif data). I would hand pick what attributes I wanted from those files.</p>
11,376
<p>I'm not that familiar with WCF, but I thought I'll learn while trying to consume an existing service.</p> <p>One of the REST APIs I thought of was the <a href="http://apiwiki.twitter.com/REST+API+Documentation" rel="noreferrer">Twitter API</a>. I thought of developing a WPF client that will just output to the scree...
<p>Check out Kirk Evans <a href="http://blogs.msdn.com/kaevans/archive/2008/07/26/creating-a-rest-twitter-client-with-wcf.aspx" rel="nofollow noreferrer">Creating a REST Twitter Client With WCF</a>. The latest improvements to WCF in .NET 3.5 SP1 make many RESTful interfaces easier.</p> <p>Also check out the <a href="...
<p>There is no benefit to using WCF to consume an Http based API like the Twitter API. System.Net.HttpWebRequest is more than sufficient. In fact I suspect that you will have some difficulty. WCF is much easier to get working when you have WCF at both ends of the wire.</p> <p>However, if the REST API is returning A...
34,350
<p>We have an InnoDB database that is about 70 GB and we expect it to grow to several hundred GB in the next 2 to 3 years. About 60 % of the data belong to a single table. Currently the database is working quite well as we have a server with 64 GB of RAM, so almost the whole database fits into memory, but we’re concern...
<p>You will definitely start to run into issues on that 42 GB table once it no longer fits in memory. In fact, as soon as it does not fit in memory anymore, performance will degrade extremely quickly. One way to test is to put that table on another machine with less RAM and see how poor it performs.</p> <blockquote> ...
<p>First of all, it doesn't matter as much splitting out tables unless you also move some of the tables to a separate physical volume. </p> <p>Secondly, it's not necessarily the table with the largest physical size that you want to move. You may have a much smaller table that gets more activity, while your big table...
6,788
<p>What is the best way to create a DataTable with the same structure as a table in my SqlServer database? At present, I am using SqlDataAdapter.Fill() with a query that brings back the columns but no rows. That's works fine, but it seems klutzy. </p> <p>Is there a better way?</p>
<p>Well, if you use Linq2Sql, you can reflect over the entity class, and create the datatable based on the properties name and datatype.</p> <pre><code> Type type = typeof(Product); //or whatever the type is DataTable table = new DataTable(); foreach(var prop in type.GetProperties())...
<p>Well, don't you already know the structure?</p> <p>The "SET FMT_ONLY ON", or "WHERE 1 = 0" tricks are both very tested (with different results).</p> <p>Is the query here dynamic? I can't help thinking you should know the schema already...</p>
48,288
<p>I have a Hash like this</p> <pre><code>{ 55 =&gt; {:value=&gt;61, :rating=&gt;-147}, 89 =&gt; {:value=&gt;72, :rating=&gt;-175}, 78 =&gt; {:value=&gt;64, :rating=&gt;-155}, 84 =&gt; {:value=&gt;90, :rating=&gt;-220}, 95 =&gt; {:value=&gt;39, :rating=&gt;-92}, 46 =&gt; {:value=&gt;97, :rating=&gt;-237}, ...
<p>I would change the data structure to an array of hashes:</p> <pre><code>my_array = [ {:id =&gt; 78, :value=&gt;64, :rating=&gt;-155}, {:id =&gt; 84, :value=&gt;90, :rating=&gt;-220}, {:id =&gt; 95, :value=&gt;39, :rating=&gt;-92} ] </code></pre> <p>You can sort this kind of structure easily with</p> <pre><c...
<p>Simple</p> <pre class="lang-rb prettyprint-override"><code>Hash[result_hash.sort_by {|key, value| value[:rating] }] </code></pre> <p>NB: <code>result_hash</code> is your hash</p>
47,259
<p>For example, when I'm dividing two ints and want a float returned, I superstitiously write something like this:</p> <pre><code>int a = 2, b = 3; float c = (float)a / (float)b; </code></pre> <p>If I do not cast <code>a</code> and <code>b</code> to floats, it'll do integer division and return an int.</p> <p>Similar...
<h3>Question 1: Float division</h3> <pre><code>int a = 2, b = 3; float c = static_cast&lt;float&gt;(a) / b; // need to convert 1 operand to a float </code></pre> <h3>Question 2: How the compiler works</h3> <p>Five rules of thumb to remember:</p> <ul> <li>Arithmetic operations are always performed on values of the ...
<p>Do you need to cast one or two sides? The answer isn't dictated by the compiler. It has to know the exact, precse rules. Instead, the answer should be dictated by the person who will read the code later. For that reason alone, cast both sides to the same type. Implicit truncation might be visible enough, so that cas...
30,484
<p>While working on an existing project I suddenly got the following error when trying to compile the solution:</p> <p><em>error MSB3105: The item "[filename]" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.</em></p> <p>Now, as far as I'm awar...
<p>Did you try showing all files in the Solution Explorer? You could have a duplicate .rsx file somewhere in there.</p>
<p>In my case, this problem happened because a file had the same name but not the same case in the GIT repository. For example <code>MyFile.cs</code> and <code>myFile.cs</code>.</p> <p>If you do a checkout on windows, one of the files is overwritten by the other (no message, no warning). So, it is compiling, and we d...
40,446
<p>I need a member of my class to be a Control, and for it to implement an interface we define.</p> <p>If I declare it like this...</p> <pre><code>public class MyClass { public Control MyMember; } </code></pre> <p>... then I don't get the interface methods, but if I declare it like this...</p> <pre><code>public...
<p>You can use generics with constraints:</p> <pre><code>public interface MyClass { public T GetMyControl() where T : Control, IMyInterface { /* ........ */ } } </code></pre>
<p>Use the power of inheritance on the interface </p> <pre><code>public interface IMyInterface : Control { .. } </code></pre> <p>Now you say you want a control with some special methods.</p> <hr> <p><strong>EDIT:</strong> TcKs is of course right.. you can't inherit an interface from a concrete class. </p> <p>One...
36,425
<p>I really want to be able to have a way to take an app that currently gets its settings using <strong>ConfigurationManager.AppSettings["mysettingkey"]</strong> to actually have those settings come from a centralized database instead of the app.config file. I can make a custom config section for handling this sort of...
<p>If you don't mind hacking around the framework and you can reasonably assume the .net framework version the application is running on (i.e. it's a web application or an intranet application) then you could try something like this:</p> <pre><code>using System; using System.Collections.Specialized; using System.Confi...
<p>It appears there is a way to do this in .NET 3.5 by setting the allowOverride attribute in the appSettings definition section of machine.config. This allows you to override the entire section in your own app.config file and specify a new type to handle it.</p>
19,209
<p>I've been using Window Home Server for my backups here at home for most of a year now, and I'm really pleased with it. It's far better than the software I was using previously (Acronis). I'm thinking about a backup strategy for my work machine and I'd like to know how WHS compares with Vista's built-in backup and ...
<p>Chris, </p> <p>They're different beasts. WHS backup is pretty much automatic and uses deltas - Vista's is manual and I don't believe offers incremental updates.</p> <p>While your solution (Vista + network copy) would preserve your data it has two problems I an see;</p> <ol> <li>Your documents will only have the l...
<p>WHS is such a quick, simple, robust way to get your stuff backed up. Plug it in to the network; install the client software; done. I'd hate to live without it.</p> <p>However, as a programmer, I also set up scripts to run each night and back up my pending changes to another machine. For example, when using TFS, ...
5,620
<p>So I am writing a registration form and I need the display name to be only numbers, letters and underscores. </p> <p>Have a look at my code and tell me what I'm doing wrong.</p> <pre><code>&lt;form method="post" action="/" onsubmit="return check_form()"&gt; &lt;input type="text" id="display-name" name="display...
<p>Your regex</p> <pre><code>/^([a-zA-Z0-9_])+/ </code></pre> <p>Looks for </p> <ol> <li>Start of string(check), followed by</li> <li>1 or more letters, numbers, or underscore (check)</li> </ol> <p>And then whatever comes after it doesn't matter. This regex will match anything at all so long as it begins with a let...
<p>By 'not working' I take it you mean it is letting invalid entries through (rather than not letting valid entries through).</p> <p>As @Annan has said, this would probably be due to the lack of the <code>$</code> character at the end of the expression, as currently it only requires a single valid character at the sta...
3,938
<p>When I goto view the property page for my CSharp test application I get the following error.</p> <p>"An error occurred trying to load the page. COM object that has been seperated from its underlying RCW cannot be used."</p> <p>The only thing that seems to fix it is rebooting my PC!</p>
<p>This is usually caused by a 'rogue' add-in.</p> <p>Try disabling them all, and then re-enabling them checking for the error - so that you can narrow down the culprit.</p>
<p>It seems Microsoft Style Cop was causing the issue.</p> <p>It was not registered as an Add-in, but was integrated into VS2005 on some deeper level.</p>
3,749
<p>I am looking for a good menu to use in an ASP.NET. I am currently using the asp menu. I need it to work in IE 6,7,8, Firefox and Safari. I also need it to not add a lot of overhead to the page client-side. I need to be able to load it from the database.</p>
<p>Write your own Server Control which implements the asp.net menu control but go one step further and implement the CSS friendly adapters which will give you standards compliant code instead of the usual garbage html tables that asp:menu creates.</p> <p>You can read more here: <a href="http://www.asp.net/cssadapters/...
<p>You can use this code as inspiration: <a href="http://trac2.assembla.com/GiusCms/browser/trunk/Controls/Controls/Menu.cs" rel="nofollow noreferrer">http://trac2.assembla.com/GiusCms/browser/trunk/Controls/Controls/Menu.cs</a></p> <p>This control is able to use any SiteMapDataSource. Or you can simply customize it a...
39,894
<p>I have a table in a SQL Server 2005 database with a trigger that is supposed to add a record to a different table whenever a new record is inserted. It seems to work fine, but if I execute an Insert Into on the master table that uses a subquery as the source of the values, the trigger only inserts one record in the ...
<p>Your trigger is only using the first row from 'Inserted'. This is a common misunderstanding when dealing with SQL triggers for the first time. The trigger fires per update not per row.</p> <p>For example if you do the following:-</p> <p>update products set title = 'geoff de geoff'</p> <p>this would update all the...
<p>I just want to second @Gordon Bell on his answer...</p> <p>"Catch" the values the very moment they are being inserted. You do not really need the cursor in this situation (or maybe you have a reason?).</p> <p>A simple TRIGGER might be all you need:</p> <p><a href="http://dbalink.wordpress.com/2008/06/20/how-to-sq...
3,882
<p>I have just installed Windows Server 2003 Standard Edition and therefore IIS6 (comes as standard). I have also install the windows component that enable the administration of IIS from the browser (<a href="https://server:8098/" rel="nofollow noreferrer">https://server:8098/</a>). The problem I have is that I have to...
<p>Here are a couple ideas:</p> <ul> <li><p>Take a look at the security log on the server for clues.</p></li> <li><p>Look at the "Directory Security" tab on the properties of the admin site and ensure "Enable anonymous access" is unchecked. You will need to use "Integrated Windows authentication" or "Basic authentica...
<p>I'm not so sure now, haven't set up a Win 2003 box in a while but as far as I remember you have to activate remote desktop first and then you can use a RDP client to access the server. I recommend that over the ActiveX RDP client.</p>
14,623
<p>Sparked by <a href="https://3dprinting.stackexchange.com/questions/1245/running-12v-on-a-24v-heater-cartridge">this question</a>, I wanted to discuss the most efficient and also the easiest ways of thermally insulating the heat block of the hotend.</p> <p>I have seen <a href="http://numbersixreprap.blogspot.fr/2013...
<p>The "quick and dirty" approach is to just slap a bunch of Kapton tape on there. The more the better! (Until you need to dismantle for maintenance, anyway.)</p> <p>I find pre-cut ceramic tape + kapton tape "blankets" to be easy and effective. E3Dv6 and Replicator 1/2 style hot blocks should be compatible. Or you can...
<p>After having seen <a href="https://3dprinting.stackexchange.com/questions/4026/how-can-i-insulate-my-thermistor/4035#4035">this answer</a> to this question, <a href="https://3dprinting.stackexchange.com/questions/4026/how-can-i-insulate-my-thermistor">How can I insulate my thermistor?</a>, I ordered these, from eBay...
301
<p>I'm using the <a href="http://docs.python.org/library/subprocess.html" rel="noreferrer">subprocess module</a> to start a subprocess and connect to its output stream (standard output). I want to be able to execute non-blocking reads on its standard output. Is there a way to make .readline non-blocking or to check if ...
<p><a href="https://stackoverflow.com/questions/375427/non-blocking-read-on-a-stream-in-python/4025909#4025909"><code>fcntl</code></a>, <a href="https://stackoverflow.com/questions/375427/non-blocking-read-on-a-stream-in-python/375511#375511"><code>select</code></a>, <a href="https://stackoverflow.com/questions/375427/...
<p>Here is a module that supports non-blocking reads and background writes in python:</p> <p><a href="https://pypi.python.org/pypi/python-nonblock" rel="nofollow">https://pypi.python.org/pypi/python-nonblock</a></p> <p>Provides a function,</p> <p>nonblock_read which will read data from the stream, if available, othe...
49,131
<p>I am writing a dhtml application that creates an interactive simulation of a system. The data for the simulation is generated from another tool, and there is already a very large amount of legacy data.</p> <p>Some steps in the simulation require that we play "voice-over" clips of audio. I've been unable to find an...
<p>You will have to include a plug-in like Real Audio or QuickTime to handle the .wav file, but this should work...</p> <pre><code>//====================================================================== var soundEmbed = null; //====================================================================== function soundPlay(...
<p>For a cross browser solution with wav files I would suggest to make an <code>&lt;audio&gt;</code> tag default and then go for the <code>&lt;embed&gt;</code> solution that @dacracot suggested before <a href="https://stackoverflow.com/a/187415/3214497">here</a> if the user is in IE, you can check it easily with a litt...
22,653
<p>I was a C++ developer (mostly ATL/COM stuff) until, as many of us, I switched to C# in 2001. I didn't do much C++ programming since then.</p> <p>Do you have any tips on how to revive my C++ skills? What has changed in C++ in the last years? Are there good books, articles or blogs covering the language. The problem ...
<p>I personally find that syntax is where i mostly need to catch up when i wander back to a language i havent used in a long time. But the concepts and what the language is about stays the same in memory. </p> <p>Assuming its the same with you, i would say its a good idea to relook at the texts you remember to have be...
<p>To sharpen your C++ skills I'd suggest going over some of your old C++ code if you still have access to it. Revisiting it will hopefully trigger those parts of your brain that have laid dormant after switching to C# :)</p> <p>For libraries STL is good, then boost. I don't think there is too much new stuff going o...
17,232
<p>In my just-completed project, I was working getting distributed transactions working.</p> <p>We implemented this using JBoss's Arjuna Transaction Manager, and Spring's declarative transaction boundaries.</p> <p>Our request sequence looked like:</p> <pre><code>browser -&gt; secured servlet -&gt; 'wafer-thin' SLSB ...
<p>Jeremiah Morrill has recently released a <a href="http://www.codeplex.com/WPFMediaKit" rel="nofollow noreferrer">specialized WPF library</a> that supports displaying HD Media (among other features)</p>
<p>It sure doesn't seem to work correctly. It may be that testing for the opacity of other layers slows it down too much. Have you tried running the test with Aero turned off?</p> <p>It has been suggested that hosting Windows Media Player may be the way to go.</p> <p><a href="http://msdn.microsoft.com/en-us/library...
18,092
<p>I accidentally coded <code>SELECT $FOO..</code> and got the error "Invalid pseudocolumn "$FOO".</p> <p>I can't find any documentation for them. Is it something I should know?</p> <p>Edit: this is a MS SQL Server specific question.</p>
<p>Pseudocolumns are symbolic aliases for actual columns, that have special properties, for example, $IDENTITY is an alias for the column that has the IDENTITY assigned, $ROWGUID for the column with ROWGUIDCOL assigned. It's used for the internal plumbing scripts.</p>
<p>A simple Google search brings up <a href="http://www.lorentzcenter.nl/awcourse/oracle/server.920/a96540/sql_elements6a.htm" rel="nofollow noreferrer">this</a> from Oracle's reference:</p> <blockquote> <p>A pseudocolumn behaves like a table column, but is not actually stored in the table. You can select from ...
23,754
<p>What I want to do is set the focus to a specific control (specifically a <code>TextBox</code>) on a tab page when that tab page is selected.</p> <p>I've tried to call <code>Focus</code> during the Selected event of the containing tab control, but that isn't working. After that I tried to call focus during the <code...
<p>I did this and it seems to work:</p> <p>Handle the <code>SelectedIndexChanged</code> for the <code>tabControl</code>. Check if <code>tabControl1.SelectedIndex</code> == the one I want and call <code>textBox.Focus();</code></p> <p>I'm using VS 2008, BTW.</p> <hr> <p>Something like this worked:</p> <pre><code>pr...
<p>Try the TabPage.Enter something like</p> <pre> private void tabPage1_Enter(object sender, EventArgs e) { TabPage page = (TabPage)sender; switch (page.TabIndex) { case 0: textBox1.Text = "Page 1"; if (!textBox...
21,643
<p>I'm trying to call the OpenThemeData (see msdn <a href="http://msdn.microsoft.com/en-us/library/bb759821%28v=VS.85%29.aspx" rel="noreferrer">OpenThemeData</a>) function but I couldn't determine what are the acceptable Class names to be passed in by the <code>pszClassList</code> parameter.</p> <pre><code>HTHEME Open...
<p>You can look in "AeroStyle.xml" as a previous poster noted, which gives an exact list for Vista/Aero. However, if you want to play safe (and you probably do) the class names should, in general, be Windows class names of Windows common controls. For example, push buttons and check boxes use the class name "Button", t...
<p>It has nothing to do with Aero, which even doesn't exits on XP ! See the source code of OpenThemeData()..</p>
26,733
<p>I'm trying to add a new node to an jQuery <a href="http://news.kg/wp-content/uploads/tree/" rel="nofollow noreferrer">SimpleTree</a>, but all I seem to be able to get is "sTC.addNode is not a function"... </p> <pre><code>var simpleTreeCollection = $('.simpleTree').simpleTree({ animate:true, drag:false, ...
<p>Maybe take a look at <a href="http://www.jstree.com/jsTree/examples/" rel="nofollow noreferrer">jsTree</a> </p>
<p>FYI the above code works in the firebug console on their demo page. On your tree ake sure you use a correct selector to highlight the node</p>
36,003
<p>I' trying to use a Linq query to find and set the selected value in a drop down list control.</p> <pre><code> Dim qry = From i In ddlOutcome.Items _ Where i.Text.Contains(value) Dim selectedItem As ListItem = qry.First ddlOutcome.SelectedValue = selectedItem.Value </code></pre> <p>Even though the d...
<p>I can give you an answer in C#, and i hope it helps you.</p> <p>The easiest way it to use the methods of DropDownlist, better than linq query:</p> <pre><code>DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText("2")); </code></pre> <p>If you want the linq query it would...
<p>simple way to select using following code</p> <pre><code>foreach (ListItem i in DropDownList1.Items) { DropDownList1.SelectedValue = i.Value; if (DropDownList1.SelectedItem.Text=="text of your DropDownList") { break; } } </code></pre>
40,773
<p>I know that it does in PHP, and I'm pretty sure it does in Java. I haven't used the latest versions of .NET, so I won't speak for them. It seems very awkward, but I was wondering if there was an underlying reason for this.</p>
<p>One reason is compatibility - anyone who has done 'check for existence' knows to exclude directories; changing that behaviour may confuse those who rely on that behaviour.</p> <p>Secondly, the underlying code often does a check on the operating system for existence in a catlog of filesystem entries - to the OS, a d...
<p>Part of the Unix philosophy is that "<a href="http://www.cs.bgu.ac.il/~arik/usail/concepts/filesystems/everything-is-a-file.html" rel="nofollow">everything is a file</a>". This has influenced other environments as well to some degree.</p>
7,282
<p>I was wondering what I could do to improve the performance of Excel automation, as it can be quite slow if you have a lot going on in the worksheet...</p> <p>Here's a few I found myself:</p> <ul> <li><p><code>ExcelApp.ScreenUpdating = false</code> -- turn off the redrawing of the screen</p></li> <li><p><code>Excel...
<p>When using C# or VB.Net to either get or set a range, figure out what the total size of the range is, and then get one large 2 dimensional object array...</p> <pre><code>//get values object[,] objectArray = shtName.get_Range("A1:Z100").Value2; iFace = Convert.ToInt32(objectArray[1,1]); //set values object[,] objec...
<p>Another big thing you can do in VBA is to use Option Explicit and avoid Variants wherever possible. Variants are not 100% avoidable in VBA, but they make the interpreter do more work at runtime and waste memory.</p> <p>I found this article very helpful when I was starting with VBA in Excel.<br> <a href="http://www...
46,463
<p>I've explored python for several years, but now I'm slowly learning how to work with c. Using the <a href="http://www.python.org/doc/2.5.2/ext/intro.html" rel="nofollow noreferrer">python documentation</a>, I learned how to extend my python programs with some c, since this seemed like the logical way to start playi...
<p>Please read up on distutils. Specifically, the section on <a href="http://www.python.org/doc/2.5.2/dist/describing-extensions.html" rel="nofollow noreferrer">Extension Modules</a>.</p> <p>Making assumptions about compilers is bad policy; your instinct may not have all the facts. You could do some marketplace surv...
<p>S. Lott is right. You should first look at distutils. After you've learned what you need from distutils, look at <a href="http://peak.telecommunity.com/DevCenter/setuptools" rel="nofollow noreferrer">setuptools</a>. Setuptools is built on top of distutils and makes installation easy for your users. Have you ever ...
37,628
<p>The title is pretty much self explanatory. Given two dates what is the best way of finding the number of week days using PHP? Week days being Monday to Friday.</p> <p>For instance, how would I find out that there are 10 week days in between <code>31/08/2008</code> and <code>13/09/2008</code>?</p>
<pre><code> $datefrom = strtotime($datefrom, 0); $dateto = strtotime($dateto, 0); $difference = $dateto - $datefrom; $days_difference = floor($difference / 86400); $weeks_difference = floor($days_difference / 7); // Complete weeks $first_day = date("w", $datefrom); ...
<p>One way would be to convert the dates to unix timestamps using strtotime(...), subtracting the results and div'ing with 86400 (24*60*60):</p> <pre><code>$dif_in_seconds = abs(strtotime($a) - strtotime($b)); $daysbetween = $dif_in_seconds / 86400; </code></pre> <p>ETA: Oh.. You meant weekdays as in Mon-Fri.. Didn't...
10,599
<p>I'm trying to traverse through all the subdirectories of the current directory in Perl, and get data from those files. I'm using grep to get a list of all files and folders in the given directory, but I don't know which of the values returned is a folder name and which is a file with no file extention. </p> <p>How ...
<p>You can use a <code>-d</code> file test operator to check if something is a directory. Here's some of the commonly useful file test operators</p> <pre> -e File exists. -z File has zero size (is empty). -s File has nonzero size (returns size in bytes). -f File is a plain file. -d File is a di...
<p>It would be easier to use <code>File::Find</code>.</p>
25,277
<p>i'm trying to use the GeoKit plugin to calculate the distance between 2 points. So the idea is, i do a search for an article, and the results i want to order by distance. So i have a form where I enter the article (that im looking for) and my address. Then rails must find all articles that match with my query and or...
<p>I'm not really an SQL expert, and I find joins very hard to wrap my head around (even more than figuring out multiple NOT's like <code>if(!(foo != !bar &amp; (!baz)))</code> ) but I do feel that either the <code>:joins</code> line or the <code>:include</code> line is redundant, or even wrong.</p> <p>(I cleaned up y...
<p>I didnt want to put the sql generated in the first post otherwise it would be too much thing :-)</p> <p>I was using just include, that works, but i dont know why, include makes a left join, and i need a inner join. If i remove the include i cannot access the user information thru the article object (like for exampl...
41,945
<p>I wrote a raw TCP client for HTTP/HTTPS requests, however I'm having problems with chunked encoding responses. HTTP/1.1 is requirement therefore I should support it.</p> <p><em>Raw TCP is a business requirement that I need to keep, therefore I can't switch to .NET HTTPWebRequest/HTTPWebResponse</em> However if ther...
<p>The best place to start is the <a href="ftp://ftp.isi.edu/in-notes/rfc2616.txt" rel="nofollow noreferrer">http 1.1 specification</a>, which lays out how chunking works. Specifically section 3.6.1.</p> <blockquote> <p>3.6.1 Chunked Transfer Coding</p> <p>The chunked encoding modifies the body of a message i...
<p>For the future reference also I found this :</p> <pre><code> length := 0 read chunk-size, chunk-extension (if any) and CRLF while (chunk-size &gt; 0) { read chunk-data and CRLF append chunk-data to entity-body length := length + chunk-size read chunk-size and CRLF } read entity-h...
41,159
<p>I have a page generated by php which includes two drop-down lists (SELECTs) which contain a lot of items (about 2,000 each). The page is fine, but when it loads in Firefox, there's a delay during the load, and then it seems to refresh the entire page. If a user tries to click on anything before the "reload" occurs, ...
<p>Can you explain what you mean when you say it gets a bit "messy"? Any particular symptoms?</p> <p>Anyway looking at this from a clean sheet I'd say you want to throttle the number of concurrent uploads you're performing at one time otherwise you're likely to hit some kind of limit in terms of the number of connecti...
<p>ipworks FTP class is thread safe. And you <strong>must</strong> read Java Concurrency in Practice by Brian Goetz ... </p> <pre><code>public class ServerConnection extends Thread { // the connection to the ftp server private final Ftp connection; </code></pre> <p>or you can implement Runnable and use an <a href=...
49,081
<p>I'm converting some Windows batch files to Unix scripts using sh. I have problems because some behavior is dependent on the %~dp0 macro available in batch files.</p> <p>Is there any sh equivalent to this? Any way to obtain the directory where the executing script lives?</p>
<p>The problem (for you) with <code>$0</code> is that it is set to whatever command line was use to invoke the script, not the location of the script itself. This can make it difficult to get the full path of the directory containing the script which is what you get from <code>%~dp0</code> in a Windows batch file.</p> ...
<p>I have tried $0 before, namely:</p> <blockquote> <p>dirname $0</p> </blockquote> <p>and it just returns "." even when the script is being sourced by another script: </p> <blockquote> <p>. ../somedir/somescript.sh</p> </blockquote>
25,497
<p>Not too practical maybe, but still interesting.</p> <p>Having some abstract question on matrix multiplication I have quickly implemented a matrix for ints, then tested my assumptions.</p> <p>And here I noticed that just int matrix is not good, if I occasionally want to use it with decimal or double. Of course, I <...
<p>For this you need generic maths. Luckily <a href="http://www.yoda.arachsys.com/csharp/genericoperators.html" rel="nofollow noreferrer">I have done this</a>. Usage would be similar to this "complex" (i.e. x+iy) <a href="http://csharpindepth.com/ViewNote.aspx?NoteID=50" rel="nofollow noreferrer">example</a>. The Opera...
<p>Well, there is a less tech-heavy way to do just that. You cannot add a new interface for "int" or "double". But you can declare an interface for an object that can multiply and add values of some generic type. And then you can implement the interface for all the types you need:</p> <pre><code>public interface ICalc...
20,094
<p>I wanting to show prices for my products in my online store. I'm currently doing:</p> <pre><code>&lt;span class="ourprice"&gt; &lt;%=GetPrice().ToString("C")%&gt; &lt;/span&gt; </code></pre> <p>Where GetPrice() returns a decimal. So this currently returns a value e.g. "£12.00"</p> <p>I think the correct HTML...
<p>The £ symbol (U+00A3), and the html entities &amp; #163; and &amp; pound; should all render the same in a browser. </p> <p>If the browser doesn't recognise £, it probably won't recognise the entity versions. It's in ISO 8859-1 (Latin-1), so I'd be surprised if a Mozilla browser can't render it (my FF certainly can)...
<p>If you need to explicity state the localisation you can use the CultureInfo and pass that to the string formatter.</p>
11,417
<p>After many years of using make, I've just started using jam (actually ftjam) for my projects. </p> <p>In my project workspaces, I have two directories:</p> <ul> <li><code>src</code> where I build executables and libraries</li> <li><code>test</code> where my test programs are</li> </ul> <p>I'm trying to set up a d...
<p>Ok this seems to be not an as easy question as I thought so I worked out a solution on my own. It uses a script to achieve the end result so I still hope that a Jam guru will have a jam-only solution.</p> <ul> <li><p>Create a Jamrules in the root directory of the project with the common definitions.</p></li> <li><p...
<p>I'm using Jam in <a href="http://github.com/Andromeda-OS/LLVM" rel="nofollow">one of my projects</a>, and I am encountering your very situation. I have my executable programs in the <code>bin</code> subdirectory, and my static libraries are kept in the <code>lib</code> subdirectory.</p> <p>In my top-level Jamfile, ...
24,222
<p>How do you disable autocomplete in the major browsers for a specific input (or form field)?</p>
<p>Firefox 30 ignores <code>autocomplete=&quot;off&quot;</code> for passwords, opting to prompt the user instead whether the password should be stored on the client. Note the following <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=956906#c100" rel="noreferrer">commentary</a> from May 5, 2014:</p> <blockquote> <...
<p>I was having trouble on a form which included input fields for username and email with email being right after username. Chrome would autofill my current username for the site into the email field and put focus on that field. This wasn't ideal as it was a form for adding new users to the web application.</p> <p>It...
2,466
<p>What is the most efficient way to create a <strong>constant</strong> (never changes at runtime) mapping of <code>string</code>s to <code>int</code>s? </p> <p>I've tried using a <a href="https://stackoverflow.com/questions/268064/c-how-can-dictionarykv-implement-icollectionkeyvaluepairkv-without-having-addke">const ...
<p>Creating a truly compile-time generated constant dictionary in C# is not really a straightforward task. Actually, none of the answers here really achieve that.</p> <p>There is one solution though which meets your requirements, although not necessarily a nice one; remember that according to the C# specification, swi...
<p>Why not:</p> <pre><code>public class MyClass { private Dictionary&lt;string, int&gt; _myCollection = new Dictionary&lt;string, int&gt;() { { "A", 1 }, { "B", 2 }, { "C", 3 } }; public IEnumerable&lt;KeyValuePair&lt;string,int&gt;&gt; MyCollection { get { return _myCollection.AsEnumerable&lt;Key...
33,636
<p>I am working on an application, implemented in VC++ 2008 that needs to use sftp through libCurl. In order for this to happen, libCurl needs to be built with ssh support. The problem is that, unlike the mingw makefile, the makefile for vc8 does not have target configurations to build with SSH support. Does anyone ...
<p>Solve the realm problem that you mentioned is easy. Just set the realm to *.mysite.com instead of just mysite.com. If you're using one of the ASP.NET controls included in the library, you just set a property on the control to set the realm. If you're doing it programmatically, you set the property on the IAuthent...
<p>I dunno how OpenID works, but LiveID gives you a token based on the combination of user and domain. I just would have forwarded www to mysite.com.</p>
34,453
<p>I have the following scenario:</p> <pre> public class CarManager { .. public long AddCar(Car car) { try { string username = _authorizationManager.GetUsername(); ... long id = _carAccessor.AddCar(username, car.Id, car.Name, ....); if(id == 0) { ...
<p>There are two issues here:</p> <ul> <li>Unit tests should do more than test methods one at a time. They should be designed to prove that your class can do the job it was designed for when integrated with the rest of the system. So you should mock out the dependencies and then write a test for each way in which you ...
<p>Unit Test should focus only to its corresponding class under testing. All attributes of class that are not of same type should be mocked.</p> <p>Suppose you have a class (CarRegistry) that uses some kind of data access object (for example CarPlatesDAO) which loads/stores car plate numbers from Relational database.<...
12,652
<p>I am using Zend_Db to insert some data inside a transaction. My function starts a transaction and then calls another method that also attempts to start a transaction and of course fails(I am using MySQL5). So, the question is - how do I detect that transaction has already been started? Here is a sample bit of code...
<p>The framework has no way of knowing if you started a transaction. You can even use <code>$db-&gt;query('START TRANSACTION')</code> which the framework would not know about because it doesn't parse SQL statements you execute.</p> <p>The point is that it's an application responsibility to track whether you've started...
<p>In web-facing PHP, scripts are almost always invoked during a single web request. What you would really like to do in that case is start a transaction and commit it right before the script ends. If anything goes wrong, throw an exception and roll back the entire thing. Like this:</p> <pre><code>wrapper.php: try { ...
41,354