instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I'm inspired by the <a href="https://stackoverflow.com/questions/153074/tool-to-visualise-code-flow-cc">C/C++</a> question for a code flow visualization tool.</p> <p>Is there such a thing for Java servlets or applications?</p>
<p>Maybe <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>H</kbd> in Eclipse / IntelliJ IDEA ? (albo present in NB somewhere) Or "data flow from/to" in IntelliJ IDEA?</p>
<p>In UML 2 there are two basic categories of diagrams: structure diagrams and behavior diagrams. Every UML diagram belongs to one these two diagram categories. The purpose of structure diagrams is to show the static structure of the system being modeled. They include the class, component, and or object diagrams. Behav...
18,517
<p>I have an ASP.NET program where i am downloading a file from web using DownloadFile method of webClient Class and the do some modifications on it. then i am Saving it to another folder with a unique name.When I am getting this error</p> <blockquote> <p>The process cannot access the file 'D:\RD\dotnet\abc\abcimage...
<p>Generally, I think your code should looking something like this.</p> <pre><code>WebClient wc = new WebClient(); wc.DownloadFile("http://stackoverflow.com/Content/Img/stackoverflow-logo-250.png", "Foo.png"); FileStream fooStream; using (fooStream = new FileStream("foo.png", FileMode.Open)) { // do stuff } File.M...
<p>Are you explicitly closing the file stream after you make your changes?</p>
41,541
<p>I have an MSBuild project where within it I have a task that calls multiple projects where I set BuildInParallel = "true"</p> <p>Example:</p> <p></p> <pre><code> &lt;Message Text="MSBuild project list = @(ProjList)" /&gt; &lt;!-- Compile in parallel --&gt; &lt;MSBuild Projects="@(ProjList)" Targe...
<p>The <a href="http://www.developerfusion.com/tools/convert/vb-to-csharp/" rel="noreferrer">Developer Fusion VB.Net to C# converter</a> says that the equivalent C# code is:</p> <pre><code>System.Random rnd = new System.Random(); IEnumerable&lt;int&gt; numbers = Enumerable.Range(1, 100).OrderBy(r =&gt; rnd.Next()); </...
<p>Best I can do off the top of my head without access to Visual Studio (crosses fingers):</p> <pre><code>System.Random rnd = New System.Random(); IEnumerable&lt;int&gt; numbers = Enumerable.Range(1, 100).OrderBy(rnd =&gt; rnd.Next); </code></pre>
31,794
<p>I have a pair of Sun web servers (iws6) sitting behind a load balancer. It likes to know if the web servers are up and continually asks for /alive.html. That is fine but how do I not log that in my access log?</p> <p>Failing that, how could I have the archiver strip out that accesses when it roles the file over?</p...
<p>You can give Apache rules about what logs to suppress. Maybe IWS has something similar?</p> <p><a href="http://httpd.apache.org/docs/1.3/logs.html#conditional" rel="nofollow noreferrer">http://httpd.apache.org/docs/1.3/logs.html#conditional</a> </p>
<p>Logs are usually one line per entry so that you can grep for what you want. The idea is to have everything in the file, but to use grep in order to read the parts you care about. Grep for everything but load balancer stuff when you read them.</p>
13,049
<p>I'm using Fedex's web services and getting an annoying error right up front before I can actually get anywhere.</p> <p>There was an error in serializing body of message addressValidationRequest1: 'Unable to generate a temporary class (result=1). error CS0030: Cannot convert type 'FedEx.InterOp.AddressValidationServ...
<p>You only need change the [][], not the single [].</p> <p>In Reference.cs change </p> <pre><code>private ParsedElement[][] parsedStreetLineField; to private ParsedElement[] parsedStreetLineField; and public ParsedElement[][] ParsedStreetLine { to public ParsedElement[] ParsedStreetLine { </code></pre>
<p>Turns out Fedex's own documentation covers this specifically!</p> <p><strong>I am using wsdl.exe from Microsoft to generate code and I get an error CS0029: Cannot implicitly convert type 'fedexreq.ParsedElement' to 'fedexreq.ParsedElement[]'.</strong></p> <p>This is an error generated by Web Services Description L...
44,942
<p>When do we use client side reporting and when do we use server side reporting?</p> <p>Which reporting is best practice (client/server)?</p> <p>This pertains to SSRS reporting.</p>
<p>Well... client side reporting you'd use if you've got something like a winforms client that you can't guarantee will have constant access to the data source. It might have a set of data cached on the client side which you need to report on even if the connection to the server is unavailable.</p> <p>Server side repo...
<p>It depends what you call "server" in this case. As you mention SSRS I am assuming you consider the database (SQL Server) as the server.</p> <p>It all depends on the application/project structure and requirements. If you have a database that contains also the business logic (store procedures) and you simply want to ...
16,623
<p>I am building a web application using .NET 3.5 (ASP.NET, SQL Server, C#, WCF, WF, etc) and I have run into a major design dilemma. This is a uni project btw, but it is 100% up to me what I develop.</p> <p>I need to design a system whereby I can take an image and automatically crop a certain object within it, withou...
<p>This is one of the problems that needed to be solved to finish the <a href="http://www.darpagrandchallenge.com/" rel="nofollow noreferrer">DARPA Grand Challenge</a>. Google video has a <a href="http://video.google.com/videoplay?docid=8594517128412883394" rel="nofollow noreferrer">great presentation by the project l...
<p>If I'm reading this right... This is where AI shines.</p> <p>I think the "simplest" solution would be to use a neural-network based image recognition algorithm. Unless you know that the car will look the <em>exact</em> same in each picture, then that's pretty much the only way.</p> <p>If it IS the exact same, then...
26,424
<p>I have a form, when I click on submit button, I want to communicate with the server and get something from the server to be displayed on the same page. Everything must be done in AJAX manner. How to do it in Google App Engine? If possible, I want to do it in JQuery.</p> <p>Edit: The example in <a href="http://group...
<p>You can use <a href="http://www.malsup.com/jquery/form/" rel="noreferrer">jquery Form plugin</a> to submit forms using ajax. Works very well.</p> <pre><code>$('#myFormId').submit(function() { // submit the form $(this).ajaxSubmit(); return false; }); </code></pre>
<p>I'd add that in Firebug, you should see your ajax call pop up in the console. If you're getting the exception when you open that address, there's something up with your Python code. Maybe you're not correctly mapping your urls?</p>
26,014
<p>Is it "acceptable" to have an <strong>ASP.Net 2.0</strong> application without the BLL (Business Logic Layer) as the following?</p> <ol> <li>SQL Server Data Storage &amp; Stored Procedures</li> <li>Data Link Layer (Strongly Typed Table Adapters) connecting to Stored Procs</li> <li>Presentation Layer ASPX Pages with...
<p>It's acceptable as long as you understand the consequences. The main reason you'd have a BLL is to re-use that logic elsewhere throughout your application.</p> <p>If you have all that validation logic in the presentation code, you're really making it difficult to re-use elsewhere within your application.</p>
<p>If the application is a general one, then the business logic layer can be used in complete other applications too. Like, I normally use my CMS related BLL classes in other applications.</p>
2,634
<p>I would like to put a link to a webpage in an alert dialog box so that I can give a more detailed description of how to fix the error that makes the dialog box get created. </p> <p>How can I make the dialog box show something like this:</p> <pre><code>There was an error. Go to this page to fix it. wwww.TheWebPag...
<p>You could try asking them if they wish to visit via window.prompt:</p> <pre><code>if(window.prompt('Do you wish to visit the following website?','http://www.google.ca')) location.href='http://www.google.ca/'; </code></pre> <p>Also, Internet Explorer supports modal dialogs so you could try showing one of those:</...
<p>Or use window.open and put the <a href="http://qa.techinterviews.com/q/20060809080754AAs7gKM" rel="nofollow noreferrer">link there</a>.</p>
8,141
<p>Typically I develop my websites on trunk, then merge changes to a testing branch where they are put on a 'beta' website, and then finally they are merged onto a live branch and put onto the live website.</p> <p>With a Facebook application things are a bit tricky. As you can't view a Facebook application through a n...
<p>The way I and my partner did it was we each made our own private Facebook applications, that pointed to our IP address where we worked on it. Since we worked in the same place, we each picked a different port, and had our router forward that port to our local IP address. It was kinda slow to refresh a page, but it w...
<p>Another solution is NGROK</p> <p><a href="https://ngrok.com/" rel="nofollow">https://ngrok.com/</a></p> <p>It opens a public tunnel to your local app</p> <p>Example on my rails application by simply typing</p> <pre><code>./ngrok 3000 </code></pre> <p>I get</p> <pre><code>http://630066fe.ngrok.com -&gt; 127.0.0...
6,038
<p>There are 3 parts to the page. </p> <ol> <li><p>Header, which has unknown content at design time as it is populated with text at runtime. All the text must be displayed, no scroll bars.( I think <code>height: 100%</code> does this) </p></li> <li><p>Content, the content should fill the page below the bottom of the h...
<p>GUID technically stands for globally unique identifier. What it is, actually, is a 128 bit structure that is <em>unlikely</em> to ever repeat or create a collision. If you do the maths, the domain of values is in the <a href="https://en.wikipedia.org/wiki/Names_of_large_numbers#Standard_dictionary_numbers" rel="nor...
<p>To actually see what it looks like on a windows computer, go to cmd or powershell.</p> <ol> <li><p>Powershell =&gt; <code>[guid]::NewGuid()</code></p> </li> <li><p>CMD =&gt; <code>powershell [guid]::NewGuid()</code></p> </li> </ol> <p><a href="https://i.stack.imgur.com/LMEoD.png" rel="nofollow noreferrer"><img src=...
48,595
<p>Given an HTML link like</p> <pre><code>&lt;a href="urltxt" class="someclass" close="true"&gt;texttxt&lt;/a&gt; </code></pre> <p>how can I isolate the url and the text? </p> <p><strong>Updates</strong></p> <p>I'm using Beautiful Soup, and am unable to figure out how to do that. </p> <p>I did </p> <pre><code>sou...
<p>Use <a href="http://crummy.com/software/BeautifulSoup" rel="noreferrer">Beautiful Soup</a>. Doing it yourself is harder than it looks, you'll be better off using a tried and tested module.</p> <p><strong>EDIT:</strong></p> <p>I think you want:</p> <pre><code>soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(url)...
<p>Though I suppose the others <em>might</em> be correct in pointing you to using Beautiful Soup, they <em>might</em> not, and using an external library might be massively over-the-top for your purposes. Here's a regex which will do what you ask.</p> <pre><code>/&lt;a\s+[^&gt;]*?href="([^"]*)".*?&gt;(.*?)&lt;\/a&gt;/ ...
36,321
<p>Something else perhaps? I am already using nHibernate, but I get occasional issues where a lazy initialized proxy object won't actually initialize. I'm thinking of trying something else. The site has user accounts, user posts and photos, and filtering of those to certain location names and title/description matches....
<p>SubSonic is currently used in all our webform applications with great success. In a matter of minutes your entire database can be generated from scratch ready to use in your application. Rob Conery, SubSonic creator, has some great webcasts up detailing the process to get SubSonic bits setup in a web application a...
<p>LINQ is a great choice. It is used here on Stackoverflow, and on my current project we are using LINQ for our data access. </p>
22,875
<p>My web application has a login page that submits authentication credentials via an AJAX call. If the user enters the correct username and password, everything is fine, but if not, the following happens:</p> <ol> <li>The web server determines that although the request included a well-formed Authorization header, the...
<p>I encountered the same issue here, and the backend engineer at my company implemented a behavior that is apparently considered a good practice : when a call to a URL returns a 401, if the client has set the header <code>X-Requested-With: XMLHttpRequest</code>, the server drops the <code>www-authenticate</code> heade...
<p>For those unsing C# here's <code>ActionAttribute</code> that returns <code>400</code> instead of <code>401</code>, and 'swallows' Basic auth dialog.</p> <pre><code>public class NoBasicAuthDialogAuthorizeAttribute : AuthorizeAttribute { protected override void HandleUnauthorizedRequest(AuthorizationContext filte...
11,160
<p>Why does this happen (circled in red), and how can I fix it? It is making my prints come out horrible.</p> <p>Not shown in the picture, but the option "Coasting" was Enabled:</p> <ul> <li>Coasting Volume 0.064 mm<sup>3</sup></li> <li>Minimum Volume Before Coasting: 0.8</li> <li>Coasting Speed 90%</li> </ul> <hr> ...
<p>If you enable the option "Coasting", the extruder will follow the extrusion path at the end of switching to the next layer or the next section, but will not deposit any material as it uses the build up pressure in the nozzle to deposit the final bits. This shows up in your G-code representation by empty (non-deposit...
<p>I have had a similar thing happen when slicing a large piece that has - in real life - walls of about 2 cm. By scaling it down to 1.5%, this become less than the wall thickness, and the wall was simply omitted by CURA.</p> <p>In my experience, a model showing gaps <em>can</em> have in these locations a thickness le...
951
<p>I am trying to make a copy of a database to a new database on the same server. The server is my local computer running SQL 2008 Express under Windows XP. Doing this should be quite easy using the SMO.Transfer class and it almost works!</p> <p>My code is as follows (somewhat simplified):</p> <pre><code>Server serv...
<p>Well, after contacting Microsft Support I got it working properly, but it is slow and more or less useless. Doing a backup and then a restore is much faster and I will be using it as long as the new copy should live on the same server as the original. </p> <p>The working code is as follows:</p> <pre><code>ServerCo...
<p>Here is my solution:</p> <ol> <li>I have a Database named is Olddatabase</li> <li><p>I backup it to E:\databackup\Old.bak</p></li> <li><p>If you want to create a Duplicate Database from Olddatabase in the same server with name NewDatabase</p></li> </ol> <p>3.1 You can use command in query tool : EXEC OldDatabase....
33,676
<p>How can I make a major upgrade to an installation set (MSI) built with <a href="http://en.wikipedia.org/wiki/WiX" rel="noreferrer">WiX</a> install into the same folder as the original installation?</p> <p>The installation is correctly detected as an upgrade, but the directory selection screen is still shown and wit...
<p>There's an example in the WiX tutorial: <a href="https://www.firegiant.com/wix/tutorial/getting-started/where-to-install/" rel="nofollow noreferrer">https://www.firegiant.com/wix/tutorial/getting-started/where-to-install/</a></p> <pre><code>&lt;Property Id="INSTALLDIR"&gt; &lt;RegistrySearch Id='AcmeFoobarRegistr...
<p>You don't really need to separate RegistryKey from RegistryValue in a simple case like this. Also, using HKMU instead of HKLM takes care of it whether you're doing a machine or user install.</p> <pre><code>&lt;RegistryValue Root="HKMU" Key="Software\[Manufacturer]\[ProductName]" Name="InstallDir" Type="str...
7,983
<p>I have a need to create a "transactional" process using an external API that does not support COM+ or .NET transactions (Sharepoint to be exact)</p> <p>What I need to do is to be able to perform a number of processes in a sequence, but any failure in that sequence means that I will have to manually undo all of the ...
<p>If your changes are done to the SharePoint object model, you can use the fact that changes are not committed until you call the <code>Update()</code> method of the modified object, such as <code>SPList.Update()</code> or <code>SPWeb.Update()</code>.</p> <p>Otherwise, I would use the <em>Command</em> Design Pattern....
<p>You might want to have a look at the Compensating Resource Manager:</p> <p><a href="http://msdn.microsoft.com/en-us/library/8xkdw05k(VS.80).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/8xkdw05k(VS.80).aspx</a></p>
4,217
<p>I'm considering the following: I have some data stream which I'd like to protect as secure as possible -- does it make any sense to apply let's say AES with some IV, then Blowfish with some IV and finally again AES with some IV?</p> <p>The encryption / decryption process will be hidden (even protected against debug...
<p>I'm not sure about this specific combination, but it's generally a bad idea to mix things like this unless that specific combination has been extensively researched. It's possible the mathematical transformations would actually counteract one another and the end result would be easier to hack. A single pass of eithe...
<p>I agree with what has been said above. Multiple stages of encryption won't buy you much. If you are using a 'secure' algorithm then it is practically impossible to break. Using AES in some standard streaming mode. See <a href="http://csrc.nist.gov/groups/ST/toolkit/index.html" rel="nofollow noreferrer">http://cs...
14,613
<p>I set up a simple event handler as mentioned <a href="https://stackoverflow.com/questions/49510/how-do-you-set-your-cocoa-application-as-the-default-web-browser">here</a>, but it appears that the selector isn't called. I put the code in my AppDelegate class and wired up the delegate in IB. Tried putting in some NSLo...
<p>Well, I can't help but notice that you're <code>-init</code> method is mis-declared. If should have return type <code>id</code> and have a <code>return self;</code> at the end. </p> <pre><code>- (id)init { self = [super init]; if (self) { [[NSAppleEventManager sharedAppleEventManager] setEventHand...
<p>The big question is: Where are you calling NSAppleEventManager's -setEventHandler:...? You need to call this before your app finishes launching if you want to catch a URL that started your app. If your app delegate is created in your MainMenu.nib, then either its -init or -awakeFromNib methods will work, but, for ...
43,815
<p>I've played around with GTK, TK, wxPython, Cocoa, curses and others. They are are fairly horrible to use.. GTK/TK/wx/curses all seem to basically be direct-ports of the appropriate C libraries, and Cocoa basically mandates using both PyObjC and Interface Builder, both of which I dislike..</p> <p>The Shoes GUI libra...
<p>Have you looked at <a href="http://qt.io" rel="nofollow noreferrer">Qt</a>/<a href="http://www.riverbankcomputing.co.uk/software/pyqt/intro" rel="nofollow noreferrer">PyQt</a>? Although PyQt <em>is</em> a direct port from the C++ library, I find it much more pythonic and nice to program with compared to the others y...
<p>I've used <a href="http://glade.gnome.org/" rel="nofollow noreferrer">Glade</a> with some success, though I didn't manage to wrap my head around creating anything really complex. It has a nice GUI builder and stores the forms as xml files that are loaded dynamically. Kind of like XAML afiak.</p>
5,652
<p>I assumed that the C# margin property had a meaning like in CSS - the spacing around the outside of the control. But Margin values seem to be ignored to matter what values I enter.</p> <p>Then I read on the SDK: </p> <blockquote> <p>Setting the Margin property on a docked control has no effect on the distanc...
<p>The margin property is used by whatever layout engine your control host (Panel, for example) is using, in whatever way that layout engine sees fit. However, it is best used for spacing just as you assume. Just read the documentation for that specific layout engine.</p> <p>It can be very handy when using a FlowL...
<p>Control.Margin property could be also useful at design time if you do not use layout container, but rather place controls manually.</p> <p>It affects the distance between manually dragged controls at which <a href="https://stackoverflow.com/questions/1376622/change-spacing-of-snaplines-in-visual-studio#answer-15649...
10,143
<p>I've been reading up on this subject for a while. Suddenly the day has come where this solution is a necessity, not just a dream.</p> <p>Through my reading, I've seen the popular differences being (file based, memcached, shared memory (mm), sql table, and custom).</p> <p>The original idea we thought of was using a...
<p>John Campbell's answer here should help</p> <p><a href="https://stackoverflow.com/questions/76712">What is the best way to handle sessions for a PHP site on multiple hosts?</a></p> <p>The point he makes about NOT using only Memcached is important.</p> <p>Also, as I mentioned in that question, you may want to cons...
<p>I think storing your sessions in a database (like MySQL or PostgreSQL) will involve the least headaches, especially if you already have a DB for whatever it is your app does.</p> <p>Memcached may also help, since it can store data across multiple machines, but I don't have any experience with it.</p>
28,001
<p>Like any responsible developer, I'd like to make sure that the sites I produce are accessible to the widest possible audience, and that includes the significant fraction of the population with some form of colour blindness.</p> <p>There are many websites which offer to filter a URL you feed it, either by rendering ...
<p>I came across <a href="http://colororacle.org/" rel="noreferrer">Color Oracle</a> and thought it might help. Here is the short description:</p> <blockquote> <p>Color Oracle is a colorblindness simulator for Windows, Mac and Linux. It takes the guesswork out of designing for color blindness by showing you in real ...
<p>I found <a href="http://www.coloursimulations.com/" rel="nofollow noreferrer">Colour Simulations</a> easy to use on Windows 10. This software can apply a color-blind filter to a part of the screen or the whole screen. And what's great is it allows me to interact with my PC normally as if it doesn't exist in fullscre...
24,872
<p>I've been developing a few JSF applications lately and am disturbed with the inconsistency in the web component APIs. </p> <p>I've noticed that there is extremely unpredictable behavior when calling .getValue() or .getSubmittedValue() on a JSF component object in server side code. Sometimes when I call .getValue() ...
<p>Since this is the #1 result in Google for searching on getValue vs. getSubmittedValue I'd just like to add that the difference between these is critical in validation (i.e. when writing a custom validator)</p> <p>To quote the API documentation for getSubmittedValue():</p> <blockquote> <p>This is non-null only be...
<p>I work on xpages which are based on JSF so.. it could be the same...</p> <p>Anyway, getSubmittedValue(); always returns what you see in firebug/chrome develepers network tab. That is value within sent packet. I have it shown (chrome) in headers tab, in form data section, named $$xspsubmitvalue.</p> <p>On the other...
32,502
<p>Is there a way to turn off the automatic selection of the first row in the built-in DataGrid in Silverlight?</p> <p>We build a lot of functionality based off the user selecting a row in a data grid. The automatic firing of SelectionChanged when databinding or sorting is really causing us issues. We have tried to ...
<p>Have you tried setting a boolean field (ex. bool dataGridFirstLoad) which you set to false in your User Control's constructor.</p> <p>Then on the SelectionChanged event of the DataGrid, check if dataGridFirstLoad is false. If false set to true and set the SelectedItem to null.</p> <p>Hope this helps.</p>
<p>The code below should do it (set JustRefreshed to true whenever you update/refresh the grid):</p> <pre><code> int LastSelectedIndex = -1; bool JustRefreshed = false; private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (JustRefreshed) { ...
38,301
<p>I'm migrating a TSQL stored procedure to PL/SQL and have encountered a problem - the lack of a CONTINUE keyword in Oracle 10g.</p> <p>I've read that Oracle 11g has this as a new feature, but upgrading is not an option unfortunately.</p> <p>Is there any alternative to CONTINUE in 10g? I don't believe it's practical...
<p>You can simulate a continue using <a href="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/controlstructures.htm#BCGFGDAA" rel="noreferrer">goto and labels</a>.</p> <pre><code>DECLARE done BOOLEAN; BEGIN FOR i IN 1..50 LOOP IF done THEN GOTO end_loop; END IF; &lt;&lt;en...
<p>In Oracle there is a similar statement called EXIT that either exits a loop or a function/procedure (if there is no loop to exit from). You can add a WHEN to check for some condition.</p> <p>You could rewrite the above example as follows:</p> <pre><code>DECLARE done BOOLEAN; BEGIN FOR i IN 1..50 LOOP ...
21,419
<p>I'm considering Altova MapForce (or something similar) to produce either XSLT and/or a Java or C# class to do the translation. Today, we pull data right out of the database and manually build an XML string that we post to a webservice. </p> <p>Should it be db -> (internal)XML -> XSLT -> (External)XML? What do you f...
<p>I would use one of the out-of-the-box XML serialization classes to do your internal XML generation, and then use XSLT to transform to the external XML. You might generate a schema as well to enforce that the translation code (whatever will drive your XSLT translation) continues to get the XML it is expecting for tr...
<p>What database are you using? Oracle has some nice XML mapping tools. There are some Java binding tools (one is <a href="http://java.sun.com/developer/technicalArticles/WebServices/jaxb" rel="nofollow noreferrer">http://java.sun.com/developer/technicalArticles/WebServices/jaxb</a>). However, if you have the luxory co...
10,501
<p>I have a function which gets a key from the user and generates a Hashtable (on a pattern specified by the key). After creating a Hashtable, I would like to populate a JTable so that each each column represents a key and every rows represents the values associated with the key. I tried everything but couldn't get thi...
<p>See <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data" rel="nofollow noreferrer">How to Use Tables: Creating a Table Model</a>.</p> <blockquote> <p>The JTable constructor used by SimpleTableDemo creates its table model with code like this:</p> </blockquote> <pre><code>new Ab...
<p>Firstly, avoid <code>Hashtable</code>, go straight for <code>Map</code>. In this case there two potential standard implementations you mights want: <code>LinkedHashMap</code> can retain the order that the entries were added; <code>TreeMap</code>, a <code>SortedMap</code>/<code>NavigableMap</code>, will sort the resu...
37,293
<p>When working with window handles, is it <em>good</em> enough to use the plain <strong>IntPtr</strong> or should I subclass <strong>SafeHandle</strong>?</p> <p>Are there any significant pros/cons?</p> <p>Thanks.</p>
<p>That depends :)</p> <p>If the handle is returned in such a way that you must eventually call a version of ::CloseHandle on them then you should always subclass SafeHandle. SafeHandle makes the strongest guarantee possible in the .Net Framework that a handle will be freed. Not freeing an IntPtr will lead to a reso...
<p>That depends :)</p> <p>If the handle is returned in such a way that you must eventually call a version of ::CloseHandle on them then you should always subclass SafeHandle. SafeHandle makes the strongest guarantee possible in the .Net Framework that a handle will be freed. Not freeing an IntPtr will lead to a reso...
37,631
<p>I am looking for ways to keep track of simultaneous users within an application. I cannot use IIS logs due to a load balancer that abstracts the users IP address. I am looking for a .NET code based solution or a configuration item, possibly with health monitoring to be able to track the "true" simultaneous user co...
<p>There is a similiar question here: <a href="https://stackoverflow.com/questions/259105/tools-and-methods-for-live-monitoring-aspnet-web-applications">Tools and methods for live-monitoring ASP.NET web applications?</a></p> <p>I found an advanced logging tool for debugging and monitoring .NET applications: <a href="h...
<p>You just want to know the number of active users at a particular time? An easy option that omits inactive users as well as most bots would be to register the user as active through a JavaScript AJAX call on page load along with their SessionID. You can then purge old records from the log as you see fit. *Be careful ...
48,191
<p>So I have a User model that :has_many other models like Documents, Videos, Posts and the like. My question arises when I execute a "do" block from the User model like so:</p> <pre><code>has_many :posts do def recent find(:all, :order =&gt; 'created_at desc', :limit =&gt; 12) end end </code></pre> <...
<p>It looks like you should take a look at using <a href="http://railscasts.com/episodes/108" rel="nofollow noreferrer">named_scope</a>.</p> <p>There's no reason why you should have a do block against your association.</p> <p>You you should turn that recent method into a named scope and you can then tack on :dependen...
<p>This should work just fine AFAIK:</p> <pre><code>has_many :posts, :dependent =&gt; :destroy do def recent find(:all, :order =&gt; 'created_at desc', :limit =&gt; 12) end end </code></pre>
35,729
<p>Using 3D printing I'd like to create a text oversized keycap that uses several strong LEDs to make the text light as red or green, depending on status. It's quite similar to what are called annunciators on aircraft:</p> <p><a href="https://i.stack.imgur.com/6B1lY.jpg" rel="noreferrer"><img src="https://i.stack.imgu...
<p>There are a few possible ways you could go about this:</p> <ol> <li>If you have a multi-material printer, you may be able to print with both a transparent or translucent material for the internal structure of the print and an opaque material for the external parts of the print. PET(G) may be suitable for this purpos...
<p>Cut the letters out of the key, so they print as holes all the way to the light source. Print in black.</p> <p>fill the holes with clear silicon caulk or leave empty.</p>
2,007
<p>I am sorry, my question is stupid, but I am not able to answer it, as a java illiterate. I run a tomcat (5) on CentOS5 (for a CAS server), and when I try to open this URL <a href="http://192.168.1.17:8080/cas-server-webapp-3.3.1/login" rel="nofollow noreferrer">http://192.168.1.17:8080/cas-server-webapp-3.3.1/login<...
<p>It is important to keep two or three different exceptions strait in our head in this case:</p> <ol> <li><p><strong><code>java.lang.ClassNotFoundException</code></strong> This exception indicates that the class was not found on the classpath. This indicates that we were trying to load the class definition, and the...
<p>If this appeared suddenly and unlogically to what you've been constructing, try renaming and renaming back classes that are referenced in an error log. This helped me in Netbeans several times.</p>
49,114
<p>Can you suggest some ways/tips to decrease Resharper memory usage in VS 2008. Working set memory for my VS with 50 projects is around 650mb+ </p> <p><strong>Edit:</strong> Now that 4.5 is out, this question is no longer relevant.</p>
<p>That doesn't sound like a completely unreasonable amount of memory when you've got <em>50</em> projects, Do they really all need to be in the same solution? If so, can you not just get more memory? While there may be ways of decreasing the R# memory use (disable its code analysis?) I suspect it won't make <em>that</...
<p>650mb+ isn't abnormal, i have solution with 15 projects and 1k files and VS+ReSharper use 500mb (only ReSharper use 153mb)</p> <p>Try this for show how much memory ReSharper use ReSharper -> Options -> General -> Show managed memory usage in status bar</p>
26,374
<p>I quite often see on the Internet various complaints that other peoples examples of currying are not currying, but are actually just partial application.</p> <p>I've not found a decent explanation of what partial application is, or how it differs from currying. There seems to be a general confusion, with equivalent...
<p>Currying is converting a single function of <em>n</em> arguments into <em>n</em> functions with a single argument each. Given the following function:</p> <pre><code>function f(x,y,z) { z(x(y));} </code></pre> <p>When curried, becomes:</p> <pre><code>function f(x) { lambda(y) { lambda(z) { z(x(y)); } } } </code></...
<p>In writing this, I confused currying and uncurrying. They are inverse transformations on functions. It really doesn't matter what you call which, as long as you get what the transformation and its inverse represent.</p> <p>Uncurrying isn't defined very clearly (or rather, there are "conflicting" definitions that ...
26,812
<p>I am working on modifying an existing spell check plugin for TinyMCE. </p> <p>This is what is supposed to happen: 1. User hits "space" and the spell check runs. 2. If the word is spelled wrong the word gets wrapped with a span and gets a red underline</p> <p>what I find happening is that when the user hits space ...
<p>try incrementing the bookmark start/end by 2 instead of 1 if you haven't already. since the underline adds a tag around the mispelled words, that's an additional 2 places that need to be accounted for in the bookmark: 1 for each side of the span.</p>
<p>Can you get yourself out of the element by grabbing its parent?</p> <pre><code>this.parentNode.moveToBookmark(b); </code></pre> <p>Or something like that.</p>
37,058
<p>If I check out a tagged version of my source code without creating a branch, Git indicates that I'm not associated with any branch at all. It's happy to let me make changes and check them in though. Where do those changes go? If I switch back to 'master' they disappear (overwritten by what was in master) and I can't...
<p>Because your <strong>commit isn't on any branch</strong>, you can't see it in the working directory unless you checkout that specific commit, using its SHA1. You can find the commit by looking at the <code>reflog</code> which tracks changes in what you have checked out from the repo. If your tag was <code>XXX</code...
<p>To answer the second question you'd use git reset --hard yourtagname </p> <p>As for what would happen you essentially forked your branch at the tagname and stayed on the same branch. Your commits in the old fork are still there... they're just hard to see. You might have to use the reflog to find the old fork. </p...
47,786
<p>I've been a PHP developer for many years now, with many tools under my belt; tools that I've either developed myself, or free-to-use solutions that I have learned to trust.</p> <p>I looked into CodeIgniter recently, and discovered that they have many classes and helper routines to aid with development, yet saw noth...
<p>Frameworks have several advantages:</p> <ul> <li><p>You don't have to write everything. In your case, this is less of a help because you have your own framework which you have accumulated over the years.</p></li> <li><p>Frameworks provide standardized and tested ways of doing things. The more users there are of a g...
<p>Advantages are that it's already written and tested by multiple people therefore less likely to be bug prone. </p> <p>Disadvantages are that it's not built specifically for your application and therefore will most likely perform worse.</p> <p>All in all, I can't really see much reason to use one considering you a...
35,235
<p>I have a form in which people will be entering dollar values.</p> <p>Possible inputs:<br> $999,999,999.99<br> 999,999,999.99<br> 999999999<br> 99,999<br> $99,999<br></p> <p>The user can enter a dollar value however they wish. I want to read the inputs as doubles so I can total them.</p> <p>I tried just typecastin...
<p>A regex won't convert your string into a number. I would suggest that you use a regex to validate the field (confirm that it fits one of your allowed formats), and then just loop over the string, discarding all non-digit and non-period characters. If you don't care about validation, you could skip the first step. ...
<p><a href="http://p2p.wrox.com/topic.asp?TOPIC_ID=3099" rel="nofollow noreferrer">http://p2p.wrox.com/topic.asp?TOPIC_ID=3099</a></p> <p>goes through it step by step</p> <p>[edit] typical...the site seems to be down now... :(</p>
16,269
<p>The SQL-LDR documentation states that you need to do a convetional Path Load:</p> <blockquote> <p>When you want to apply SQL functions to data fields. SQL functions are not available during a direct path load</p> </blockquote> <p>I have TimeStamp data stored in a CSV file that I'm loading with SQL-LDR by des...
<p>As blowdart said, simple IP Address logging is handled by IIS already. Simply right-click on the Website in Internet Information Services (IIS) Manager tool, go to the Web Site tab, and check the Enable Logging box. You can customize what information is logged also. </p> <p>If you want to restrict the site or even ...
<p>A little more information please; do you want to log IPs or lock access via IP? Both those functions are built into IIS rather than ASP.NET; so are you looking for how to limit access via IP programatically?</p>
13,035
<p>Is there a way to change the use of an extruder port on a 3D printer motherboard to move stepper motors (on y axis) on a 3D printer?</p> <p>This is for a school project, and we have replaced the extruder with a laser for cutting material.</p> <p>We were tasked with converting a 3D printer into LOM 3D printer, the ...
<p>This has nothing to do with the infill overlap, the image you've added looks as if the issue is related to non-bonding perimeters (it looks as if it is in between the 2<sup>nd</sup> and the 3<sup>rd</sup> perimeter), hence infill overlap doesn't apply here. If that is the case look into <a href="/q/6067">this questi...
<p>I had absolutely the same issue. And after some research I finally found that this is because of wrong pressure advance setting (In case of Marlin - linear advance) in the firmware. Without pressure advance (linear advance) will be more plastic at the end of the travel rather than at the start. As result the fast fu...
1,277
<p>I have the following regex that does a great job matching urls: </p> <pre><code>((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&amp;]*)` </code></pre> <p>However, it does not handle urls without a prefix, ie. <strong>stackoverflow.com</strong> or <strong>www.google.com</stron...
<p>The below regex is from the wonderful <a href="http://www.amazon.co.uk/Mastering-Regular-Expressions-Jeffrey-Friedl/dp/0596528124/ref=sr_1_1/279-4458937-3540756?ie=UTF8&amp;s=books&amp;qid=1224694042&amp;sr=8-1" rel="nofollow noreferrer">Mastering Regular Expressions</a> book. If you are not familiar with the <a hr...
<p>Just use:</p> <pre><code>.* </code></pre> <p>i.e. match everything. </p> <p>The things you want to match are just hostnames, not URL (technically). </p> <p>There's no structure you can use to definitively identify hostnames. Perhaps you could look for things that end in ".com" but then you'll miss any .co.uk, n...
28,011
<p>I need to copy some records from our SQLServer 2005 test server to our live server. It's a flat lookup table, so no foreign keys or other referential integrity to worry about.</p> <p>I could key-in the records again on the live server, but this is tiresome. I could export the test server records and table data in...
<p>If your production SQL server and test SQL server can talk, you could just do in with a SQL insert statement.</p> <p>first run the following on your test server:</p> <pre><code>Execute sp_addlinkedserver PRODUCTION_SERVER_NAME </code></pre> <p>Then just create the insert statement:</p> <pre><code>INSERT INTO [PR...
<p>I would just script to sql and run on the other server for quick and dirty transferring. If this is something that you will be doing often and you need to set up a mechanism, SQL Server Integration Services (SSIS) which is similar to the older Data Transformation Services (DTS) are designed for this sort of thing. Y...
18,603
<p>What is the highest port number one can use?</p>
<p>The port number is an unsigned 16-bit integer, so 65535.</p>
<p>It should be 65535.</p>
13,831
<p>What would be a good tag to use for doing business/making profit with a 3D printer?</p>
<p>I'd suggest two different tags:</p> <ul> <li><p>[monetization]: For selling, or profiting from printing, or from printing machines</p></li> <li><p>[financing] (or [costs]): For calculating the cost of materials and machines, including operational expenses.</p></li> </ul>
<p>I would propose something as [business] or [commercial-use] as opposed to [personal-use] to differentiate between these posibilites.</p>
11
<p>I'm a keyboard junkie. I love having a key sequence to do everything. What are your favorite keyboard shortcuts?</p> <p>I'll start by naming a couple of mine:</p> <p>1 - <kbd>Alt</kbd>-<kbd>Space</kbd> to access the windows menu for the current window</p> <p>2 - <kbd>F2</kbd> to rename a file in Windows Explore...
<p><strong><kbd>Win</kbd> + <kbd>1</kbd> .. <kbd>9</kbd></strong> -- Start quick launch shortcut at that index (Windows&nbsp;Vista).</p> <p><strong><kbd>Ctrl</kbd> + <kbd>Scroll Lock</kbd>, <kbd>Scroll Lock</kbd></strong> -- Crash your computer: <em><a href="http://support.microsoft.com/kb/244139" rel="noreferrer">Win...
<p>I don't have favorites among keyboard shortcuts -- they are all utility entities to me...</p> <p>Except for <kbd><img src="https://farm6.staticflickr.com/5214/5472803412_953823394a_o.jpg" width="15"/></kbd>+<kbd>L</kbd>, which means another coffee break!</p>
7,593
<p>I have one action I want to perform when a TSpeedButton is pressed and another I want to perform when the same button is "unpressed". I know there's no onunpress event, but is there any easy way for me to get an action to execute when a different button is pressed? </p> <pre><code>procedure ActionName.ActionNameEx...
<p>Yes, you do. You're defining a self-contained piece of work which the NSOperationQueue will execute on "some" thread, so you're responsible for managing memory in that work piece.</p>
<p>yes, you need to.</p> <pre><code>- (void) main { NSAutoreleasePool *thePool = [[NSAutoreleasePool alloc] init]; //your code here //more code [thePool release]; } </code></pre> <p>if you don't create an autorelease pool, any convinience class-initializer (like [NSString stringWithFormat:]) will leak as thes...
22,297
<p>I have a system in which different server processes are handling requests passed as JMS messages from various clients via a JMS broker.</p> <p>I am trying to identify the source of the messages. Is there a way to get the IP or some identifying information about the origin ?</p> <p>Clarification: I already have the...
<p>There is an optional JMS header mentioned in the JMS specification called <em>JMSXUserID</em> which which identifies the user sending a message (which the broker validates and ensures is correct to avoid spoofing) which some JMS providers support.</p> <p>For example here is <a href="http://activemq.apache.org/jmsxu...
<p>Short answer: NO</p>
34,042
<p>I have a number of application settings (in user scope) for my custom grid control. Most of them are color settings. I have a form where the user can customize these colors and I want to add a button for reverting to default color settings. How can I read the default settings?</p> <p>For example:</p> <ol> <li>I ha...
<p>@ozgur,</p> <pre><code>Settings.Default.Properties["property"].DefaultValue // initial value from config file </code></pre> <p>Example:</p> <pre><code>string foo = Settings.Default.Foo; // Foo = "Foo" by default Settings.Default.Foo = "Boo"; Settings.Default.Save(); string modifiedValue = Settings.Default.Foo; //...
<blockquote> <p>How do I go back to Color.White?</p> </blockquote> <p>Two ways you can do:</p> <ul> <li>Save a copy of the settings before the user changes it.</li> <li>Cache the user modified settings and save it to Properties.Settings before the application closes.</li> </ul>
7,178
<p>Does anyone know of a freely available java 1.5 package that provides a list of ISO 3166-1 country codes as a enum or EnumMap? Specifically I need the "ISO 3166-1-alpha-2 code elements", i.e. the 2 character country code like "us", "uk", "de", etc. Creating one is simple enough (although tedious), but if there's a...
<p>Now an implementation of country code (<a href="http://en.wikipedia.org/wiki/ISO_3166-1" rel="nofollow noreferrer">ISO 3166-1</a> <a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" rel="nofollow noreferrer">alpha-2</a>/<a href="http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3" rel="nofollow noreferrer">alpha-3...
<p>This still does not answer the question. I was also looking for a kind of enumerator for this, and did not find anything. Some examples using hashtable here, but represent the same as the built-in get</p> <p>I would go for a different approach. So I created a script in python to automatically generate the list in J...
16,920
<p>What is a recommended architecture for providing storage for a dynamic logical database schema?</p> <p>To clarify: Where a system is required to provide storage for a model whose schema may be extended or altered by its users once in production, what are some good technologies, database models or storage engines th...
<p>What you are proposing is not new. Plenty of people have tried it... most have found that they chase "infinite" flexibility and instead end up with much, much less than that. It's the "roach motel" of database designs -- data goes in, but it's almost impossible to get it out. Try and conceptualize writing the code f...
<p>sql already provides a way to change your schema: the ALTER command.</p> <p>simply have a table that lists the fields that users are not allowed to change, and write a nice interface for ALTER.</p>
9,190
<p>I was recently trying to explain to a programmer why, in ASP.Net, they should create HTMLControls instead of creating HTML strings to create Web pages.</p> <p>I know it is a better way of doing things, but I really couldn't give concrete reasons, other than, "This way is better."</p> <p>If you had to answer this q...
<p>I don't do either. Instead, I:</p> <ol> <li>Create a custom control that encapsulates the desired construct</li> <li>or (very similar) create a simple class with the properties I want and override the <code>.ToString()</code> method to create the desired HTML.</li> </ol> <p>But of your two choices, a couple reason...
<p>Building up controls like you have is The Single Worst Thing About ASP.NET. An MVC or approach with Partials are a much better(more easily maintained) way to construct HTML.</p>
46,519
<p>Any other tweaks for making emacs as vim-like as possible would be appreciated as well.</p> <p>Addendum: The main reason I don't just use vim is that I love how emacs lets you open a file in two different frames [ADDED: sorry, this was confusing: I mean separate <em>windows</em>, which emacs calls "frames"]. It's ...
<p>You could run VIM in <a href="http://www.vim.org/htmldoc/remote.html#clientserver" rel="nofollow noreferrer">client server mode</a>, then you could have two windows connecting to one instance, hence removing the need for Emacs.</p>
<p>You could always start vim in a shell buffer and resize it so it filled the whole frame?</p>
12,371
<p>I understand the value of the three-part service/host/client model offered by WCF. But is it just me or does it seem like WCF took something pretty direct and straightforward (the ASMX model) and made a mess out of it? </p> <p>Is there an alternative to using SvcUtil's command line step back in time to generate the...
<p>Okay, here we go. First, Michele Leroux Bustamante's book has been updated for VS2008. The website for the book is not gone. It's up right now, and it has tons of great WCF info. On that website she provides updated code compatible with VS2008 for all the examples in her book. If you order from Amazon, you will...
<p>MSDN? I usually do pretty well with the Library reference itself, and I usually expect to find valuable articles there.</p>
7,275
<p>I have a team of junior developers and they want to have better understanding and usages of generics. Anyone recommend good tutorial or articles samples that are good places to start.</p>
<p>A few links:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms379564(vs.80).aspx" rel="noreferrer">An Introduction to C# Generics</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/512aeb7t(VS.80).aspx" rel="noreferrer">Generics (C# Programming Guide)</a></li> </ul> <p>Recommended books:<...
<p><a href="http://srtsolutions.com/blogs/billwagner/default.aspx" rel="nofollow noreferrer">Bill Wagner's</a> <a href="https://rads.stackoverflow.com/amzn/click/com/0321485890" rel="nofollow noreferrer" rel="nofollow noreferrer">More Effective C#</a> has some really good content on Generics.</p>
37,275
<p>I have a class with two methods defined in it.</p> <pre><code>public class Routines { public static method1() { /* set of statements */ } public static method2() { /* another set of statements.*/ } } </code></pre> <p>Now I need to call method1() from method2()</p> <p>Which one th...
<p>While I agree with the existing answers that this is primarily a style issue, it is enough of a style issue that both Eclipse and IntelliJ's code critics will flag "non-static references to static methods" in code that does not use the <code>Classname.method()</code> style.</p> <p>I made it a habit to emphasize <em...
<p>I do</p> <pre><code>public static method2() { Routines.method1(); } </code></pre> <p>No guessing. It is very clear if I call static method from parent class. I don't like static import for same reason. </p>
45,467
<p>We all know how to use <code>&lt;ctrl&gt;-R</code> to reverse search through history, but did you know you can use <code>&lt;ctrl&gt;-S</code> to forward search if you set <code>stty stop ""</code>? Also, have you ever tried running bind -p to see all of your keyboard shortcuts listed? There are over 455 on Mac OS...
<pre><code>cd - </code></pre> <p>It's the command-line equivalent of the back button (takes you to the previous directory you were in).</p>
<p>Some useful mencoder commands I found out about when looking for some audio and video editing tools:</p> <p>from .xxx to .avi</p> <pre><code>mencoder movie.wmv -o movie.avi -ovc lavc -oac lavc </code></pre> <p>Dump sound from a video:</p> <pre><code>mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile fileou...
9,388
<p>I'm using Java for accessing Alfresco content server via it's web service API for importing some content into it. Content should have some NamedValue properties set to UTF-8(cyrillic) string. I keep getting the Sax parser exception:</p> <pre><code>org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x...
<p>The problem was that <code>alfresco-web-service-client.jar</code> library I used was from 2.9B distribution (I am hitting 2.9B community content server), and dependency libs <code>bcprov-jdk15-136.jar</code> and <code>xmlsec-1.4.0.jar</code> were not adequate (remained old from 2.1 verison). I should have used <code...
<p>The easiest way to get around it is I think to escape cyrillicString, for instance with <a href="http://commons.apache.org/lang/api-release/org/apache/commons/lang/StringEscapeUtils.html#escapeXml(java.lang.String)" rel="nofollow noreferrer">escapeXml</a> from Jakarta Commons, or by converting the whole string to XM...
23,122
<p>What are some helpful things that ASP.NET MVC developers could suggest that would help us ASP.NET WebForms developers to write better code/web apps?</p> <p>I'm a WebForms guy but with all the new hype around MVC I'd value some comments on helpful tips, tricks and strategies that might be able to be used in a webfor...
<p>Something that occurred to me a while ago when learning about the new MVC framework, is that WebForms was, I think, an attempt at MVC in many ways. The markup and code-behind comprise View and Controller, and you're left to write your own Model.</p> <p>This idea goes hand in hand with the important design considera...
<p>I'm also coming from webforms, but have been learning asp.net MVC since around preview 3.</p> <p>I'm not exactly sure how to bring anything from MVC into webforms, they are two entirely different frameworks. I'm probably too new with it to understand how any of it could be applied to webforms, but right now it see...
34,466
<p><strong>Background</strong></p> <p>We have a web application in which several developers have written several .js files that manipulate the DOM and the problem of duplicate function names has crept into our application.</p> <p><strong>Question</strong></p> <p>Can anyone recommend a tool that will warn us when we ...
<p>Well, using a parser may not always be ideal as it requires an extra step of copying and pasting your code, and everyone else's, into the parser and even then I'm not sure it would catch what you want. The time tested solution to collaborative Javascript development is to namespace your code. </p> <pre><code>var my...
<p>My solution would be a simple HTML parser for Java (I just hacked one with regexps; you may want to try <a href="http://java-source.net/open-source/html-parsers/jtidy" rel="nofollow noreferrer">http://java-source.net/open-source/html-parsers/jtidy</a>) and the Apache Rhino library (<a href="http://www.mozilla.org/rh...
37,823
<p>Here's what I did:</p> <ol> <li>I've opened a C++ Builder 6 - project in C++ Builder 2009.</li> <li>Auto-converted it to a C++ Builder 2009 project.</li> <li>Told it (<em>C++ Builder 2009</em>) to build everything.</li> </ol> <p>Here's what <em>it</em> did:</p> <ol> <li>Successfully compiled everything.</li> <li>...
<p>It looks like a Code Guard error. Try deleting all the object (.obj) files and rebuilding the entire project.</p> <p>If this still does not work, then turn off the Code Guard option in C++Builder 6 and try importing the project again.</p> <p>You may also want to try the <a href="https://forums.codegear.com/catego...
<p>Never let the IDE auto-upgrade a project from an old version. It never works correctly. Instead, always create a new project fresh and add your existing source files to it as needed.</p>
48,998
<p>I'm new to windows programming and I'm trying to get notified of all changes to the file system (similar to the information that FileMon from SysInternals displays, but via an API). Is a FindFirstChangeNotification for each (non-network, non-substed) drive my best bet or are there other more suitable C/C++ APIs?</p>...
<p><code>FindFirstChangeNotification</code> is fine, but for slightly more ultimate power you should be using <code>ReadDirectoryChangesW.</code> (In fact, it's even recommended in the documentation!)</p> <p>It doesn't require a function pointer, it does require you to manually decode a raw buffer, it uses Unicode fil...
<p>You can use FileSystemWatcher class. Very efficient but cannot work with Network shared drives.</p>
3,733
<p>Is it possible to get the originating port from an ActionExecutingContext object? If so, how?</p>
<p>Yes, look at ActionExecutingContext.HttpContext.Request.Url.Port;</p>
<p>ActionExecutionContext.HttpContextBase.Url.Port should work for you.</p>
35,063
<p>The bugzilla (perl-based) system has a feature to login automatically by using a http server environment variable. If you fill in the right ID or username, you are automatically logged in.</p> <p>My server runs Joomla (PHP-based) and has all the information about who is logged in. It runs bugzilla within a sub-fram...
<p>What you need is the DECIMAL datatype:</p> <pre><code>declare @val decimal(10,2) select @val = 10.155 select @val </code></pre> <p>When you input values, you can either rely on the built in rounding, or explicitly decide which rounding you want:</p> <pre><code>select val = round(10.155, 2, 0) -- rounded select va...
<p>Decimal - it is the simplest, however any of mentined will do the job</p>
44,204
<pre><code>SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY hrl.Frn) as Row, hrl.unq, hrl.LcnsId, hc.Business,hc.Name,hc.Phone, hrl.Frn,hrl.CallSign, hrl.gsamarkettypeid, gmt.[Market Type Code] + ' - ' + gmt.gsamarkettype, hrl.gsalatitude,hrl.gsalongitude, rsc.RadioServiceCode ...
<p>Move your Row criteria into the outer select</p> <pre><code>SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY hrl.Frn) as Row, ... WHERE hc.Entity_Type = 'L' AND hrl.LicenseStatusId IN (1) ) T WHERE T.Row &gt;=1 and T.Row &lt;= 20) </code></pre>
<p>You can't use an alias for a column in a where clause, because the where clause is processed before the Select Clause. </p> <p>EDITED: </p> <p>You could also just add the subquery in the where clause</p> <pre><code>Where ((SELECT ROW_NUMBER() OVER (ORDER BY hrl.Frn)) &lt; 20, </code></pre> <p>or without usingt R...
46,629
<p>I'm investigating SUDS as a SOAP client for python. I want to inspect the methods available from a specified service, and the types required by a specified method.</p> <p>The aim is to generate a user interface, allowing users to select a method, then fill in values in a dynamically generated form.</p> <p>I can g...
<p>Okay, so SUDS does quite a bit of magic.</p> <p>A <code>suds.client.Client</code>, is built from a WSDL file:</p> <pre><code>client = suds.client.Client("http://mssoapinterop.org/asmx/simple.asmx?WSDL") </code></pre> <p>It downloads the WSDL and creates a definition in <code>client.wsdl</code>. When you call a me...
<p>i needed an example of using suds with objects. beside the answers found here, i found a very good <a href="https://webkul.com/blog/python-suds-client/" rel="nofollow noreferrer">article</a> that answered my question even further.</p> <p>here is a short summary:</p> <p>first, print the client to see an overview o...
29,943
<p>This is a GUI application (actually MFC). I need a command window with the ability to display a prompt like such:</p> <blockquote> <p>Name of favorite porn star:</p> </blockquote> <p>The user should be able to enter text after the prompt like such:</p> <blockquote> <p>Name of favorite porn star: <strong>Raven...
<p>I think you'd be better off creating a subclass of CEdit and limiting filtering key-presses. I suppose the hard part is not letting the user move the caret to the prompt area, but you can probably write some code to make sure the caret always get sent back to where it belongs (the input part).</p> <p>Anyway, if you...
<p>I had a very similar requirement and did exactly what davidg suggested; subclassed a edit control and filtered key presses. This was actually using Qt not MFC but the principle will be exactly the same. </p> <p>You need to remember to filter keys such as home as well as left and backspace. I just checked to see if...
20,117
<p>I have a need to display many numerical values in columns. These values need to be easily editable so I cannot just display them in a table. I am using textboxes to display them. Is there a way for me to right-justify the text displayed in a textbox? It would also be nice if when the user is entering data for it to ...
<p>Did you try setting the style:</p> <pre><code>input { text-align:right; } </code></pre> <p>Just tested, this works fine (in FF3 at least):</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Blah&lt;/title&gt; &lt;style type="text/css"&gt; input { text-align:right; } &lt;...
<p>Apply <code>style="text-align: right"</code> to the input tag. This will allow entry to be right-justified, and (at least in Firefox 3, IE 7 and Safari) will even appear to flow from the right.</p>
20,169
<p>All,</p> <p>Our application requires data on ISO countries and currencies (where the data must be up to date). We did purchase country/currency data from ISO themselves, however we still needed to perform alot of manual manipulation of the data, as well as write our own tool to read and process the data into our da...
<p>The <a href="http://msdn.microsoft.com/en-us/library/ky2chs3h.aspx" rel="nofollow noreferrer">.NET CultureInfo</a> class provides formatting for currencies (as well as dates, times, numbers, etc). I would never have even considered buying the data from ISO when it's available for free in the .NET runtime.</p>
<p>You might be interested by IBM's <a href="http://www.icu-project.org/" rel="nofollow noreferrer" title="International Component for Unicode (ICU)">International Component for Unicode (ICU)</a> library.</p> <p>Open source, well known, supports "numbers, dates, times and currency amounts" formatting.</p> <p>Not sure...
30,589
<p>Obviously having whitespace in css, aspx and html pages is a great advantage at design time. But is there a way to (a tool that will) clear all the whitespace from all the files and possibly merge javascript and css files in a more optimal way. </p> <p>I am using asp.net themes so there are quite a lot of separate ...
<p><a href="http://nadeausoftware.com/articles/2007/03/don_t_use_html_white_space_removal_speed_web_site" rel="nofollow noreferrer">An empirical study on the effect of removing white space</a> from a not-untypical website (Drupal) showed minimal effects. (site also contains some links to non .net html white space remov...
<p>i found this:</p> <p><a href="http://msdn.microsoft.com/en-us/library/aa719805(VS.71).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa719805(VS.71).aspx</a></p> <p>greets!</p>
45,152
<p>i have scenario where i have to provide my own control template for a few WPF controls - i.e. GridViewHeader. when you take a look at control template for GridViewHEader in blend, it is agregated from several other controls, which in some cases are styled for that control only - i.e. this splitter between columns. ...
<p>Referencing internal resources that are 100% subject to change isn't serviceable - better to just copy it. </p>
<p>It is possible to reference them, but as paulbetts said, its not recommended as they could change. Also consider if what you are doing is truely 'correct'. Can you edit your question to explain why you need to do this exactly?</p>
9,478
<p>In Sharepoint designer's workflow editor I wish to retrieve the username/name of the work flow initiator (i.e. who kicked it off or triggered the workflow) - this is relatively easy to do using 3rd party products such as Nintex Workflow 2007 (where I would use something like {Common:Initiator}) - but I can't seem to...
<p>I don't think this is possible to do in SharePoint Designer out of the box. You could probably write a custom action to get the originator, but I don't believe it is exposed through the SPD workflow interface at all. </p> <p>The best you could probably do is get the user who created or modified the item in the li...
<p>The custom activity solution only work if you are working with moss, if you only have wss 3.0 you can put one step more in your workflow and set a custom comment field with any information, this make the last modified person to change and become the same as the workflow initiator, then you can use the ModifiedBy fie...
15,935
<p>Is there a tool or a way to find out how much memory consumed by each DLL or object in .NET? The more detail it analyzes the better. Thanks.</p>
<p>You could try <a href="http://www.microsoft.com/downloads/details.aspx?familyid=a362781c-3870-43be-8926-862b40aa0cd0&amp;displaylang=en" rel="nofollow noreferrer">CLR Profiler</a> which is free, or maybe the trial version of <a href="http://www.red-gate.com/Products/ants_profiler/index.htm" rel="nofollow noreferrer"...
<p>I always liked the <a href="http://www.jetbrains.com/profiler/index.html" rel="nofollow noreferrer">dot.Trace profiler</a> from Jetbrains (as well as Resharper)</p>
13,508
<p>How can instantiated classes <strong>access the Document class?</strong></p> <p>Even after I <strong>name the Document class</strong> using the Properties bar in Flash, attempting to access it from other classes usually fails, saying <em>"attempting to access an undefined property...</em></p> <p>One solution is al...
<p>You can use a singleton for your document class (<code>Main</code>, in your example), which allows you to access the instance from anywhere.</p> <pre><code>public class Main extends Sprite { private static var _instance:Main; public static function get instance():Main { return _instance; } public funct...
<p>The document class is not inherently a globally accessible object. If you want to call methods that are in the document class, you'll always have to pass a reference from Main to any other classes/objects that want to call its methods. A more object oriented approach would be to dispatch events from your other class...
48,361
<p>I have an ASP.NET application that will host multiple tenants (Software-as-a-Service style). Each tenant will have their own domain name (www.mydomain.com, www.yourdomain.com) and their own SSL certificate.</p> <p><strong>Is there a way to host the application such that all of the tenants are on the same applicatio...
<p>The problem is that classic SSL requires the certificate to be presented before the web browser has indicated which host it wants to use. You can therefore only configure one certificate per IP/port combination.</p> <p>There is an extension to TLS called <a href="http://en.wikipedia.org/wiki/Server_Name_Indication"...
<p>You constrained to only IIS - or could putting soft/hard proxies or content-switching hardware also be an option? </p> <p>Thinking that you could terminate the SSL at a proxy or content-switch - then transform the request into your own internal url.</p> <p>e.g. foo.com/x and bar.com/y get translated into myapp/x ...
14,365
<p>I'm using castle windsor for a pet-project I'm working on. I'm starting to notice that I need to call the IoC container in different places in my code to create new objects. This dependency on the container makes my code harder to maintain.</p> <p>There are two solutions I've used to solve this problem</p> <p>I tr...
<p>Please, do not ever ever use static classes like IoC.Container.Resolve or ContainerFactory.GetContainer!</p> <p>This makes the code more complicated, harder to test to maintain, to reuse and to read. </p> <p>Normally any single component or a service has only one single point of injection - that's the constructor ...
<p>That's a really comon problem. Windsor's built in <a href="http://docs.castleproject.org/Windsor.Typed-Factory-Facility-interface-based-factories.ashx" rel="nofollow">Typed Factory Facility</a> will give you the benefits of using a factory, without the mentioned drawbacks.</p>
13,490
<p>I have a table ("venues") that stores all the possible venues a volunteer can work, each volunteer is assigned to work one venue each.</p> <p>I want to create a select drop down from the venues table.</p> <p>Right now I can display the venue each volunteer is assigned, but I want it to display the drop down box, w...
<pre class="lang-php prettyprint-override"><code>$query = &quot;SELECT volunteers_2009.id, volunteers_2009.comments, volunteers_2009.choice1, volunteers_2009.choice2, volunteers_2009.choice3, volunteers_2009.lname, volunteers_2009.fname, volunteers_2009.venue_id, venues.venue_name FROM volunteers_2009 AS volunteers_200...
<pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;table binding&lt;/title&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="mydiv" style="width:100px;height:100px;background-color:yellow"&gt;...
24,328
<p>Most applications only have "Restore, Move, Size, Minimize, Maximize and Close", however <i>MS SQL</i> offers extra options "Help, Customize view". Along those lines, is it possible to add to the right click menu of an application in the task bar? </p> <p>Note: I'm <b>not</b> referring to an icon in the notificati...
<p>This is a simpler <a href="http://bytes.com/forum/thread529258.html" rel="nofollow noreferrer">answer</a> I found. I quickly tested it and it works. </p> <p>My code:</p> <pre><code> private const int WMTaskbarRClick = 0x0313; protected override void WndProc(ref Message m) { switch (m.Msg) ...
<p>The menu on right click of the minimized program or Alt+Space or right click of the window icon in the title bar is called the SysMenu.</p> <p>Here's an option for WPF:</p> <pre><code>// License MIT 2019 Mitch Gaffigan // https://stackoverflow.com/a/58160366/138200 public class SysMenu { private readonly Windo...
18,525
<p>I am displaying a list of items using a SAP ABAP column tree model, basically a tree of folder and files, with columns.</p> <p>I want to load the sub-nodes of folders dynamically, so I'm using the EXPAND_NO_CHILDREN event which is firing correctly.</p> <p>Unfortunately, after I add the new nodes and items to the tre...
<p>It's been a while since I've played with SAP, but I always found the SAP Library to be particularly helpful when I got stuck...</p> <p>I managed to come up with this one for you: <a href="http://help.sap.com/saphelp_nw04/helpdata/en/47/aa7a18c80a11d3a6f90000e83dd863/frameset.htm" rel="nofollow noreferrer">http://he...
<p>Your code looks fine,</p> <p>I would use the method <code>ADD_NODES_AND_ITEMS</code> myself if I were to add nodes and items ;)</p> <p>Beyond that, try to call <code>EXPAND_NODE</code> after you added the items/nodes and see if that helps.</p>
2,911
<p>For a report in MS Access (2007) I need to put data of some columns on all odd pages and other columns on all even pages. It is for printing out double sided card files onto sheets of paper.</p> <p>Does somebody have an idea how to do that?</p>
<p>Your question is too general. I would suggest you have all columns in all pages, and then add some code to the page header section (or even in the detail section) "On Format" to change the .Visible property of your Detail text boxes depending on the page number.</p> <p>I think you'll need to have a Text Box in the ...
<p>You could alternatively use a pair of queries, printing the first to side A, and the second to side B, perhaps?</p>
15,381
<p>I am implementing NHibernate into an existing web application. However, we have some other processes that do bulk inserting and updating on the database. How can I make NHibernate aware that changes are occurring on the backend db that were not initiated through NHibernate?</p> <p>Most of the info that I have read ...
<p>You shouldn't. NHibernate sessions are there to help you work in an ACID environment, which means that one transaction is not aware of any concurrent transactions. You should be using short sessions which do small sets of actions. You should not be holding sessions open for long periods of time. If you do need long ...
<p>You should not store the Session over multiple requests. Bad, bad idea.</p> <p>There is little to no overhead with recreating it on every call. It should use database connection pooling - which is where the bulk of the overhead would be.</p>
30,727
<p>I've just built my first 3D printer. It uses a Bowden setup. </p> <p>When I try to print the extruder starts fine, but after a few seconds the extruder motor start skipping and the nozzle is jammed. </p> <p>I tried a cold pull, but it didn't help. I removed the PTFE tube and tried to push the filament with my hand...
<p>Extruder clogging is, at its root, a matter of too much backpressure at the hotend. There are a number of more specific causes, but it very simply comes down to the fact that the printer cannot feed the filament through the hotend as fast as the extruder is pushing it in.</p> <p>Things to check, pretty much in the ...
<p>It is useful to diagnose your problem if you provide more information, specifically what material you are using and what temperature you are using on your hot end.</p> <p>Even without the above information, it is likely that the hot end temperature is too low. At a low setting, the filament in the nozzle will softe...
1,542
<p>What's the best way to get user input in a C program where the choices are of a limited number?</p> <p>Say for example the choices are:</p> <p>A) Print the list. B) Add 99 to the end of the list. C) Delete all duplicates. 5) Reset 5 times.</p> <p>Entering &quot;A&quot; and then Enter is OK. Or, just a single keystro...
<p><code>getchar()</code>, or <code>cgetc()</code>, depending on the platform</p>
<p>I have used something simple like the following:</p> <pre><code>int intput() { char input = 0; int ret_val = 0; read(0, &amp;input, 1); switch(input) { case 'c': // Do c break; case 'p': // Do p break; case 'd': /...
6,424
<p>I am dealing with MySQL tables that are essentially results of raytracing simulations on a simulated office room with a single venetian blind. I usually need to retrieve the simulation's result for a unique combination of time and blind's settings. So I end up doing a lot of</p> <pre><code>SELECT result FROM result...
<p>The answer is most definately a yes. If you define a unique index on timestamp, opening and slatangle MySQL should be able to find your row with very few disc seeks.</p> <p>You might experiment with creating an index on timestamp, opening, slateangle and result. MySQL may be able to fetch your data from the index w...
<p>I wouldn't suggest adding 3 indexes. An index using all three columns may be better and even setting the primary key unique on that combination would be best - only if you're sure that it unique.</p>
24,017
<p>I am wondering if someone can put a bit of an authoritative reference summary of when the !important declaration in CSS does <strong>not</strong> work to override inline styles.</p>
<p>There are many factors involved in determining which styles override one another. The lower a style declaration appears in the <strong>cascade</strong>, and the <strong>more specific</strong> it is in targeting the element, the more it will weigh against other styles.</p> <p>This is the <a href="http://www.w3.org/...
<p>I'm pretty sure not all browsers recognise the !important declaration. But can't remember which ones do off the top of my head. Will check and get back to you.</p> <p>[EDIT] I can confirm IE6 and earlier do not recognise !important (unless the browser is in standards compliance mode - not the default).</p> <p>You ...
23,003
<p>Every now and then, I bump into syntax that I've seen before, but never used. This is one of those times.</p> <p>Can someone explain the purpose of ":this" or ":base" following a C# constructor method?</p> <p>For example:</p> <pre><code>public MyClass(SomeArg arg) : this(new SomethingElse(), arg) { } </code></pre...
<p>You're basically right. <code>this()</code> calls a constructor on the current instance, <code>base()</code> calls the supertype's constructor on current instance. They're generally used to handle constructor overloads so you can add additional options without breaking things out into a separate method.</p>
<p>You're right.</p> <p><strong>: base(...)</strong> calls a constructor of the base class. </p> <p><strong>: this(...)</strong> calls another constructor of the defining class. Most of the time it works merely as a facade.</p>
43,922
<p>I am using the following code to check if a variable is not nil and not zero</p> <pre><code>if(discount != nil &amp;&amp; discount != 0) ... end </code></pre> <p>Is there a better way to do this?</p>
<pre> unless discount.nil? || discount == 0 # ... end </pre>
<p>I believe the following is good enough for ruby code. I don't think I could write a unit test that shows any difference between this and the original.</p> <pre><code>if discount != 0 end </code></pre>
31,421
<p>Good morgning,</p> <p>I would like to be able to analyze text where I am writting whatever the application I am. Example, If I am here, typing in this TextArea, I would like to be able to get the text, same way if I were in the Subject Textbox in my Outlook.</p> <p>I have search Google without success, maybe it's ...
<p>CodingTheWheels series on building a poker bot goes into detail on how to capture window events from other applications. Its not exactly what your looking for, but it has some good info.</p> <p><a href="http://www.codingthewheel.com/archives/how-i-built-a-working-poker-bot" rel="nofollow noreferrer">http://www.codi...
<p>This tool works perfectly fine even for non-managed processess.</p> <p><a href="http://www.codeproject.com/KB/cs/RuntimeObjectEditor.aspx" rel="nofollow noreferrer">Runtime Object Editor</a></p>
19,612
<p>I have a problem with Gridview sorting that is similar to others but I'm binding to a collection object as opposed to a data table.</p> <p>The existing business rules and data access layers of an application follow the pattern of having an object and, if you need a collection of objects of that type, to have anothe...
<p>Have you considered client side sorting instead? </p> <p>I have used the jquery tablesorter plugin in the past with ASP Gridviews.</p> <p><a href="http://tablesorter.com/" rel="nofollow noreferrer">http://tablesorter.com/</a></p>
<p>I had a similar issue and i needed to implement IComparable on the objects. Basically to sort a collection of objects you need a way to distinguish their order. The IComparable interface has one method called Compare which allows the .Net framework to work out the order of the objects when you sort them. You need...
32,919
<p>I've been tasked to develop a web application to cover one of our business functions. It needs to have external access from outside our network. At the same time, it needs to be done fairly quickly. I don't have any experience in extranet applications so I'm not exactly sure what all is involved. Learning about ...
<p>You can take many things for granted when you are developing for local network:</p> <ol> <li><p>Highspeed network</p></li> <li><p>Trusted user base </p></li> <li><p>Same timezone for all users (this makes maintenance jobs easier to schedule among other things)</p></li> <li><p>Control over which browsers and version...
<p>to consider:<br> How are you going to authenticate?<br> How important is it to not be broken into? </p>
23,294
<p>I've recently begun evaluating a few project management projects for the company I work for. It's the classic case - growing company looking for the right solution (meaning, free or really cheap). It's a combination shop - Windows, Macs, and Linux on the desktop. The tech savviness, of course, ranges from newbie ...
<p>Read through Edward Tufte's long-running Ask E.T. topic Project Management Graphics (or Gantt Charts). There is no consensus answer, but a lot of things have been evaluated.</p> <p><a href="http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=000076&amp;topic_id=1&amp;topic=Ask%20E%2eT%2e" rel="nofollow noref...
<p>I looked hard at Alfresco and Joomla.</p> <p>None met my needs because I wanted the ultimate in simplicity. But, you seem to prefer having the kitchen sink included (while keeping it easy to use, I guess), so either one of these might be right for you.</p> <p>Currently, I'm throwing together my own using Django, k...
25,150
<p>I see that the SML/NJ includes a queue structure. I can't figure out how to use it. How do I use the additional libraries provided by SML/NJ?</p>
<p>The <a href="http://www.smlnj.org/doc/smlnj-lib/Manual/queue.html" rel="nofollow noreferrer"><code>Queue</code> structure</a> is not specified by SML '97, but it is present in SML/NJ's top-level environment.</p> <pre> $ sml Standard ML of New Jersey v110.69 [built: Fri Mar 13 16:02:47 2009] - Queue.mkQueue (); [aut...
<p>I don't have a complete answer for you but I could point you in the right direction. You should look up using the compilation manager (CM) which is built in to SML/NJ. You can think of it as Make for SML.</p> <p>To use a library from the SML/NJ library you then add smlnj-lib.cm to the CM description file of your ap...
23,856
<p>Is using a handrolled POCO queue class using pseudo code</p> <pre><code>T Dequeue() { lock(syncRoot) { if(queue.Empty) Thread.Wait(); } } void Enqueue(T item) { queue.Enqueue(item); Thread.Notify(); } </code></pre> <p>For WCF is request queueing a scalable approach?</p>
<p>And also don't forget to add namespaces like below to the web config, I think preview 5 default web.config does not have System.Web.Mvc.Html in it:</p> <pre><code>&lt;namespaces&gt; &lt;add namespace="System.Web.Mvc"/&gt; &lt;add namespace="System.Web.Mvc.Ajax"/&gt; &lt;add namespace="System.Web.Mvc.Html"/&gt; ...
<p>In addition to adding the assembly reference I also had to add the line</p> <pre><code> &lt;add namespace="System.Web.Mvc.Html"/&gt;" </code></pre> <p>to the pages/namespaces section in web.config file.</p>
25,992
<p>How do you manipulate GUID's when doing Windows programming in C or C++?</p>
<p>Under Win32 if you want to manipulate GUID's you can use the UuidXXX() Network/RPC functions:</p> <ul> <li><p>UuidCompare()</p></li> <li><p>UuidCreate()</p></li> <li><p>UuidCreateNil()</p></li> <li><p>UuidCreateSequential()</p></li> <li><p>UuidEqual()</p></li> <li><p>UuidFromString()</p></li> <li><p>UuidHash()</p><...
<p>I use boost::uuid : <a href="http://www.boost.org/doc/libs/1_43_0/libs/uuid/index.html" rel="nofollow noreferrer">http://www.boost.org/doc/libs/1_43_0/libs/uuid/index.html</a> That way it is guaranteed to still work if I port my application on another plaftorm.</p>
17,012
<p>I found in a bug in an old C++ MFC program we have that calculates an offset (in days) for a given date from a fixed base date. We were seeing results that were off by one for some reason, and I tracked it down to where the original programmer had used the CTimeSpan.GetDays() method. According to the <a href="http...
<p>Your fix works fine to get the number of whole 24-hour periods between two times - as long as the events occur at the same time each day. Otherwise that "+1" in the expression could lead to an off-by-one error.</p> <p>Sometimes you don't care what time of day the event occured, you just want to know which day. In...
<p>A minor change to what Mark suggested and it works without any reliance on rounding: Just add one more parameter of zero to the <code>CTime</code> constructor. This forces both times to be in standard time (not daylight savings). The default value for that parameter is -1 which means "Automatically compute if day...
30,175
<p>I want to log to the console when I'm using un-minimized JavaScript files.</p> <p>Comments are taken out already when I minimize JavaScript. I'm wondering if there's a way I can write a command that isn't commented out but will still be taken out when I minimize the JavaScript file. </p>
<p>I think I'd be pretty upset if a Javascript minimizer changed the behaviour of my code based on some funny/clever/odd code construct. How could you ever be sure that code construct isn't there intentionally?</p> <p>As has been suggested, have a variable that disables logging. Then as part of your minimize script or...
<p>Unless whatever you're using to minimize your JS supports conditional statements I don't think you can do this.</p> <p>Why not just log things if a certain variable is set? </p>
19,300
<p>I have nant set up to build my ASP.NET MVC project and it works fine locally. I add nant to a tools folder and add it to version control. TeamCity picks up my changes and starts the build but it fails.</p> <p>I believe I'm using the latest version of Nant and I have added the .net framework 3.5 to the nant.exe.co...
<p>If you're using the beta version of NAnt (which currently is the only way you'll get support for targeting anything greater than the 2.0 framework), you maybe running into a registry problem. A similar problem was <a href="http://www.timbarcz.com/blog/NantSetupForVisualStudio2008AndNet35.aspx" rel="nofollow noreferr...
<p>I've run into similar issues with NAnt. I know this isn't the <em>Best</em> solution, but it is one that works if you need to get your project moving. </p> <p>I've found that installing a development environment (C# Express didn't work for me, but VS 2008 did) on the server makes this issue go away. (Yes, I realize...
29,827
<p>Some years ago I was told about a study into code reuse. Apparently it was found that, on average, programmers have a 7 minute window when searching for code to reuse. If they don't find code that suits their needs within that window they'll write their own.</p> <p>This was presented in the context of needing to ca...
<p>A complex question:</p> <ul> <li><p>Some parts of the code can be generalized as libraries or APIs. We have a common library which is kept up to date with solutions to common problems. Typically: validation, caching, data access classes, logging, etc...</p></li> <li><p>Some parts are application specific. They cann...
<blockquote> <p>How do you (individuals and organisations) manage your source to make it easier to reuse? Do you specifically maintain a reuse library? And if so, how do you index it to maximise your hit rate?</p> </blockquote> <p>I don't and I have an admittedly controversial opinion here but I find the idea of...
17,565