instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>What is a good crawler (spider) to use against HTML and XML documents (local or web-based) and that works well in the Lucene / Solr solution space? Could be Java-based but does not have to be.</p>
<p>In my opinion, this is a pretty significant hole which is keeping down the widespread adoption of Solr. The new DataImportHandler is a good first step to import structured data, but there is not a good document ingestion pipeline for Solr. Nutch does work, but the integration between Nutch crawler and Solr is so...
<p>Did anyone tried Xapian? It seams much quicker than solr and written in c++.</p>
35,803
<p>How can I blur a whole page using CSS? Other elements such as images are allowed.</p>
<p>This is working in Firefox and WebKit using the <code>filter: blur(radius)</code>. See <a href="http://caniuse.com/#feat=css-filters" rel="noreferrer">Can I Use: CSS filters</a> for which browsers can support this.</p> <pre><code>.blurredElement { /* Any browser which supports CSS3 */ filter: blur(1px); ...
<p>On the height 100% question, there is no CSS solution, even in CSS3, but there is a JQuery way of doing it. If the element is #modal, define all other properties in the CSS file and do not even mention the height property in the CSS. Then put the following JQuery code in your HTML as follows:</p> <pre><code>&lt;s...
48,511
<p>How to I configure click-once to install apps for all users. On another forum I got to 'use MSI' - thanks - but how. Also, the first installing user may not be admin - which may be a problem. And I want all users to trigger an update check. No local storage, it's a WPF client to a WCF service.</p> <p>We're XP, inte...
<p>If you need to install / upgrade for all users on a PC, Clickonce is not an option. Clickonce is meant for installing an application for a single user without administrative rights. </p> <p>You will need to create a MSI installer to distribute an application to multiple users on the same machine. There are multiple...
<p>check out WIX <a href="http://wix.sourceforge.net/" rel="nofollow noreferrer">http://wix.sourceforge.net/</a></p>
34,932
<p>I am a little confused about null values and variables in .NET. (VB preferred)</p> <p>Is there any way to check the "nullness" of ANY given variable regardless of whether it was an object or a value type? Or does my null check have to always anticipate whether it's checking a value type (e.g. System.Integer) or an ...
<p>Normal value types (booleans, ints, longs, float, double, enum and structs) are not nullable.</p> <p>The default value for all value types is 0.</p> <p>The CLR won't let you access variables unless they have been set. You may think this isn't always the case, but sometimes the CLR steps in and initializes them for...
<p>Value type variables can't contain null, that's because what null means, null means that the references points nowhere. I don't know on VB.net but on c# you can wrap value types to be nullables using the "?", like:</p> <pre><code>int? a = null; </code></pre>
19,907
<p>I have a problem with maintaining state in an ASP.NET AJAX page. Short version: I need some way to update the page ViewState after an async callback has been made, to reflect any state changes the server made during the async call. </p> <p>This seems to be a common problem, but I will describe my scenario to help e...
<p>If you're already shuffling the ViewState around anyway, you might as well use an UpdatePanel. Its partial postbacks <strong>will</strong> update the page's ViewState automatically.</p>
<p>I actually found both of those links you provided, but as noted they are simply describing the problem, not solving it. The author of the blog post suggests a workaround by using a different ViewState provider, but unfortunately that isn't a possibility in this case...I really need to leave the particulars of the Vi...
2,449
<p>I'm designing some VB based ASP.NET 2.0, and I am trying to make more use of the various ASP tags that visual studio provides, rather than hand writing everything in the code-behind. I want to pass in an outside variable from the Session to identify who the user is for the query.</p> <pre><code>&lt;asp:sqldatasour...
<p>I believe Oracle uses the colon ":", not the at-symbol "@". <hr> "user" is probably a reserved word. Change it to "userID", or something similar.</p>
<p>Using ASP.NET's SessionParameter is definitely the way to go here - that's why we have it :)</p> <p>Using ASP.NET parameters you can easily include in your queries values from static sources, session state, query string, control property values, form post data, cookies, and user profile.</p>
24,275
<p>I have a web application using JPA and JTA with Spring. I would like to support both JBoss and Tomcat. When running on JBoss, I'd like to use JBoss' own TransactionManager, and when running on Tomcat, I'd like to use JOTM.</p> <p>I have both scenarios working, but I now find that I seem to need two separate Spring ...
<p>I think you have missed the point of JNDI. JNDI was pretty much written to solve the problem you have!</p> <p>I think you can take it up a level, so instead of using the "userTransaction" or "transactionManager from JNDI" depending on your situation. Why not add the "JtaTransactionManager" to JNDI. That way you pus...
<p>Just adding my experience here so I don't have to re-suffer the experience again.</p> <p>As bmatthews68, Chochos and <a href="https://stackoverflow.com/questions/1783540/spring-jta-configuration-how-to-set-transactionmanager">these posters</a> have said, use <code>&lt;tx:jta-transaction-manager/&gt;</code> in your ...
14,334
<p>Looking to <strong>improve</strong> my IF statement, and I want to keep my code <b>looking pretty</b></p> <p>This is what I am currently doing, is it <b>readable</b>, any room for <b>improvement</b>?</p> <pre><code>SomeObject o = LoadSomeObject(); if( null == o || null == o.ID || null == o.Title || ...
<p>Your verbosity is leading to a less readable code, I think the following format is best:</p> <pre><code>if ( null == o || null == o.ID || null.Title || 0 == o.ID.Length || 0 == o.Title.Length ) { // do stuff } </code></pre> <p>We all have high resolution/widescreen displays for a reason, there's no reason to loc...
<p>I usually do something like:</p> <pre><code>if(x &lt; 0 || x &gt;= width || y &lt; 0 || y &gt;= height) { /* Coordinate out of range ... */ } </code></pre> <p>The first y and x line up in a monospace font, which is nice, and I'm not confused by half-indentions.</p> <p>This method works best when doing similar...
41,685
<p>Instead of using the <code>&lt;input type="file"&gt;</code> tag I'd like to have a button that launches a file browser dialog.</p> <p>My first thought was to have a hidden file input tag and a button. I'd use the button click on the button to fire the onclick of the hidden file input, but I haven't been able to ge...
<p>Yes, it's possible (in most browsers) via opacity. <a href="http://www.quirksmode.org/dom/inputfile.html" rel="noreferrer">Here's a tutorial</a>.</p>
<p>You can do it without any security issues. Just code that on onmouseenter will promote the zindex of the real upload button (you can use opacity on it or make it transparent) and then you will not need to trigger a click but just use the click from the user.</p>
25,713
<p>I feel like this is a dumb question and I'm missing something, but I haven't even figured out how to search for this one :(</p> <p>Can an application written to target the .Net 3.5 Framework utilize libraries that were written in the 2.0 Framework?</p> <p>Additional information in the answer such as the "why" and/...
<p>Yes you can. The underlying runtime hasn't changed, it's still CLR v2.0 and c#3 still compiles to 2.0 MSIL which is executed on the 2.0 CLR. Also ASP.NET is still effectively at version 2.0 because the core underpinnings of that haven't changed (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll). </p> ...
<p>Yes, it can, .Net framework 2.0, 3.0 and 3.5 all under the cover share the same CLR 2.0, which means the assemblies are all loaded by the same CLR and are binary compatible.</p>
38,848
<p>I read some information about Java layout managers and the recommendation was <a href="http://www.miglayout.com/" rel="nofollow noreferrer">MigLayout</a>. My problem is, that I didn't found any tutorial or easy step-by-step documentation.</p> <p>So I want to know how this all works, but I don't know how.</p>
<p>Bombe is right... and wrong. I find this whitepaper tends to show off all great features of MiGLayout, entering in nitty gritty details that we would rarely, if ever, use... The paper hesitates between being a tutorial and a reference.</p> <p>Now, the provided demo applications (at <a href="http://www.migcalendar.c...
<p>Another help for those coming here now...</p> <p>I find the <a href="http://www.miglayout.com/QuickStart.pdf" rel="nofollow">Quick Start</a> for MigLayout to be a good place to start, especially when I haven't used it for a while and need to get back up to speed.</p>
45,950
<p>I reloaded an old project, and tried to run it only to run into the Binding Failure MDA Assistant:</p> <pre> BindingFailure was detected Message: The assembly with display name 'SoapTest.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: Sys...
<p>actually yes , i went to the propensities window and set the option of "Generate serialization assembly" to "on" , by this you insure every time you build the project , i guess that error happens when you edit the assmbly info of the class library you are referencing without re building it </p>
<p>I also encountered this issue. The problem was that the project causing the Exception was created in another folder than the .exe file. I easily resolved it by changing the Deployment Path from Properties/Build settings page. No other change on "Generate serialization assembly" was necessary.</p>
29,029
<p>Does thread-safety of SQLite3 mean different threads can modify the same table of a database concurrently?</p>
<p>No - SQLite does not support concurrent write access to the same database file. SQLite will simply block one of the transactions until the other one has finished.</p>
<p>Not necessarily. If sqlite3 is compiled with the thread safe macro (check via the <pre>int sqlite3_threadsafe(void)</pre> function), then you can try to access the same DB from multiple threads without the risk of corruption. Depending on the lock(s) required, however, you may or may not be able to actually modify d...
46,311
<p>Conventional wisdom states that stored procedures are always faster. So, since they're always faster, use them <strong>ALL THE TIME</strong>.</p> <p>I am pretty sure this is grounded in some historical context where this was once the case. Now, I'm not advocating that Stored Procs are not needed, but I want to know...
<blockquote> <p><strong>NOTE</strong> that this is a general look at stored procedures not regulated to a specific DBMS. Some DBMS (and even, different versions of the same DBMS!) may operate contrary to this, so you'll want to double-check with your target DBMS before assuming all of this still holds.</p> ...
<p>Reduced network traffic -- SP are generally worse then Dynamic SQL. Because people don't create a new SP for every select, if you need just one column you are told use the SP that has the columns they need and ignore the rest. Get an extra column and any less network usage you had just went away. Also you tend to...
8,464
<p>I have an Ender 5 Pro with a flexible build plate (The factory default one).</p> <p>There are multiple extremely thin tracks of melted PLA all over it. Too thin to easily peal off when cooled. Thin enough that you can run your finger over them and barely know that they are there.</p> <p>What is the best way to clean...
<h2>TL;DR:</h2> <p>Print more PLA on top of them, and pull it off together.</p> <h2>Preparation</h2> <p>First, of course, clean it well with IPA. This will both ensure there's no oil or other material on top of the PLA that will prevent it from bonding well with new PLA, and start to work underneath it to get it loose....
<p>If you can feel it with your finger, then you can scrape it off. Just be careful. Keep the scraper closer to horizontal and don't dig in. It doesn't really need much effort.</p> <p>If you can't feel it with your finger then it doesn't matter. Just clean as normal and carry on printing over it.</p>
2,116
<p>If you know the Index, Value or Text. also if you don't have an ID for a direct reference.</p> <p><a href="https://stackoverflow.com/questions/149573/check-if-option-is-selected-with-jquery-if-not-select-a-default#149820">This</a>, <a href="https://stackoverflow.com/questions/196684/jquery-get-select-option-text#19...
<p>A selector to get the middle option-element by value is</p> <pre><code>$('.selDiv option[value="SEL1"]') </code></pre> <p>For an index:</p> <pre><code>$('.selDiv option:eq(1)') </code></pre> <p>For a known text:</p> <pre><code>$('.selDiv option:contains("Selection 1")') </code></pre> <p><strong>EDIT</strong>: ...
<p>There are a few suggestions why you should use <code>prop</code> instead of <code>attr.</code> Definitely use <code>prop</code> as I've tested both and <code>attr</code> will give you weird results except for the simplest of cases.</p> <p>I wanted a solution where selecting from an arbitrarily grouped <code>select</...
40,605
<p>I have a ASP.NET 3.5 App and trying to update a Update Panel which has a nested custom control. In that custom control is a ComponentArt Gird, which gets filled by almost 13MB of Data (Yes, I could chunck that...) at this Update.</p> <p>I have a hidden button wihtin the update Panel, which I trigger by JS from clie...
<p>Dude, 1 mb of data is too much - why the heck do you need 13?</p> <p>I really think you need to refactor your ui. I dont care how fast your network is, that is just crazy stuff!</p>
<p>I agree absolutely the UI and DataAccess layer need a refactor, but for a short-term I was just looking for a simple and quick solution to help my client until the next update of the software comes out.</p>
35,445
<p>When coding, what in your experience is a better approach? </p> <ol> <li>Break the problem down into small enough pieces and then implement each piece.</li> <li>Break the problem down, but then implement using a top-down approach.</li> <li>Any other?</li> </ol>
<p>Here's what I do:</p> <p>Understand the domain first. Understand the problem to be solved. Make sure you and the customer (even if that customer is you!) are on the same page as to what problem is to be solved.</p> <p>Then a high level solution is proposed to the problem and from that, the design will turn into ...
<p>Outside-in design.</p> <p>You start with what you're trying to achieve at the top end, and you know what you've got to work with at the bottom end. Keep working both ends until they meet in the middle.</p>
15,901
<p>This is somewhat of a follow-up question to this <a href="https://stackoverflow.com/questions/267045/is-there-a-benefit-to-having-both-an-abstract-class-and-an-interface">question</a>.</p> <p>Suppose I have an inheritance tree as follows:</p> <pre><code>Car -&gt; Ford -&gt; Mustang -&gt; MustangGT </code></pre> <...
<p>In my experience, interfaces are best used when you have several classes which each need to respond to the same method or methods so that they can be used interchangeably by other code which will be written against those classes' common interface. The best use of an interface is when the protocol is important but t...
<p>Only inherit from Interfaces and abstract classes.</p> <p> If you have a couple of classes wich are almost the same, and you need to implement the majority of methods, use and Interface in combination with buying the other object. <br> If the Mustang classes are so different then not only create an interface ICar, ...
33,728
<p>I have an RDLC report that I'm having problems with page breaks. The report has a group that has a number of records that do not fit on one page. This report renders fine in Normal Mode, but when I switch to Print Mode, "extra" page breaks that were not there before appear. This is causing the report to print on mor...
<p>Make sure you check your margin settings on the report properties dialogue. I think the default is 1 inch on all sides. That could be throwing off the printing.</p>
<p>Try tweaking the width of the elements. You have to make sure that they are within the margins of the print layout, or you'll get extra pages. Make sure your margins aren't really wide (I think they are by default). </p>
22,359
<p>I have a dict, that looks like this:</p> <pre><code>{ 'foo': { 'opt1': 1, 'opt2': 2, }, 'foo/bar': { 'opt3': 3, 'opt4': 4, }, 'foo/bar/baz': { 'opt5': 5, 'opt6': 6, } } </code></pre> <p>And I need to get it to look like:</p> <...
<p>Like this:</p> <pre><code>def nest(d): rv = {} for key, value in d.iteritems(): node = rv for part in key.split('/'): node = node.setdefault(part, {}) node.update(value) return rv </code></pre>
<p>Got this lib to print your dict in a better way. <code>pprint</code>. <code>https://docs.python.org/3.2/library/pprint.html</code></p>
14,933
<p>I have a WCF Service decorated with WebInvoke attributes and WebHttp binding for JSON enabling. The service can be accessed from JavaScript until we try to make it working cross domain. Can you please recommend how to get this to work cross domain?</p> <p>We've tried to create proxy web handler but it gives "Bad Re...
<p>For a ridiculously short value ( Ie: values &lt; 64 characters ), MD5 as a hash becomes ineffective due to rainbow table attacks, and as the value you're sending will be shared over the wire, all they have to do is brute force the shared secret ( and they have a known product to work with ) </p> <p>As such, thats ...
<p>Wow</p> <p>Pretty hard solutions 8). </p> <p>I implemented system like this once. Although it won`t work for every game out there...</p> <p>You should replay the game on server. When user play -- you store "state changes" and then simply feed it to you game in some kind of "replay" mode.</p>
38,963
<p>I want to create a Rails (2.1 and 2.2) model with ActiveRecord validations, but without a database table. What is the most widely used approach? I've found some plugins that claim to offer this functionality, but many of them don't appear to be widely used or maintained. What does the community recommend I do? R...
<p>There is a better way to do this in Rails 3: <a href="http://railscasts.com/episodes/219-active-model" rel="noreferrer">http://railscasts.com/episodes/219-active-model</a></p>
<p>Do like Tiago Pinto said and just don't have your model inherit from ActiveRecord::Base. It'll just be a regular Ruby class that you stick in a file in your app/models/ directory. If none of your models have tables and you're not using a database or ActiveRecord at all in your app, be sure to modify your environme...
40,784
<p>I have recently learned the Ruby programming language, and all in all it is a good language. But I was quite surprised to see that it was not as simple as I had expected. More precisely, the "rule of least-surprise" did not seem very respected to me (of course this is quite subjective). For example:</p> <pre><co...
<p><a href="http://en.wikipedia.org/wiki/Ruby_(programming_language)#.22Gotchas.22" rel="noreferrer">Wikipedia Ruby gotchas</a></p> <p>From the article:</p> <ul> <li>Names which begin with a capital letter are treated as constants, so local variables should begin with a lowercase letter.</li> <li>The characters <code...
<pre><code>1..5.each {|x| puts x} </code></pre> <p>doesn't work. You have to put the range into parentheses, like</p> <pre><code>(1..5).each {|x| puts x} </code></pre> <p>so it doesn't think you're calling <code>5.each</code>. I think this is a precedence issue, just like the <code>x = true and false</code> gotcha.<...
48,710
<p>How to create a windows toolbar-dockable application - like <a href="http://www.winamp.com/plugins/details/82271" rel="nofollow noreferrer">Winamp Desk Band</a> - in .NET?</p>
<p>As other people have said, by default there is a 10 simultaneous connection limit for IIS 5 in Win XP. This can be increased to a maximum of 40 via the metabase variable setting script.</p> <pre><code> cd \inetpub\adminscripts cscript adsutil.vbs set w3svc/MaxConnections 40 iisreset </code></pre> <p>...
<p>There is also a limit to one site. Note that a site != to a Virtual Diretory/Application, so it's rarely an issue for a programmer.</p>
38,245
<p>I know that the #warning directive is not standard <strong>C</strong>/C++, but several compilers support it, including gcc/g++. But for those that don't support it, will they silently ignore it or will it result in a compile failure? In other words, can I safely use it in my project without breaking the build for ...
<p>It is likely that if a compiler doesn't support #warning, then it will issue an error. Unlike #pragma, there is no recommendation that the preprocessor ignore directives it doesn't understand.</p> <p>Having said that, I've used compilers on various different (reasonably common) platforms and they have all supported...
<p>Actually most compilers that I know about ignore unknown #pragma directives, and output a warning message - so in the worst case, you'll still get a warning.</p>
20,668
<p>The Benchy looks good for the most part except for some boogers on the chimney</p> <p><a href="https://i.stack.imgur.com/fV2oD.jpg" rel="nofollow noreferrer" title="Photo of a printed Benchy with zits on the chimney"><img src="https://i.stack.imgur.com/fV2oD.jpg" alt="Photo of a printed benchy with zits on the chimn...
<p>The application doesn't look to be demanding at all from a material point of view. Operation below 40 °C and 70-90% RH is not that special.</p> <p>Once taken out PLA for creep, most rigid filaments would work. Nylon deform under constant stress, so screws may get loose over time.</p> <p>PETG, ABS, ABS+ (TitanX/niceA...
<p>My first choice for this would be PET. Not PETG, which is a mess of blobbing, stringing, warping, creep under load, etc., but real PET, also known as BPET (bottle PET) or HTPET (high temperature PET, because it needs high temperatures to print and has high HDT)</p> <p>Unlike ASA, PC, and nylon, PET is easy to print....
2,196
<p>Can you do a better code? I need to check/uncheck all childs according to parent and when an child is checked, check parent, when all childs are unchecked uncheck parent.</p> <pre><code> $(".parent").children("input").click(function() { $(this).parent().siblings("input").attr("checked", this.checked); }); $...
<pre><code>$(".parent").children("input").click(function() { $(this).parent().siblings("input").attr("checked", this.checked); }); $(".parent").siblings("input").click(function() { $(this).siblings("div").children("input").attr("checked", this.checked || $(this).siblings("input[checked]").length&gt;0 ...
<p>This is a lovely little thread that has got me nearly where I need to be. I've slightly adapted Nickf's code. The aim is that checking a child would also check the parent, and unchecking a parent would also uncheck all children. </p> <p>$("input[type='checkbox']").click(function() { if (!$(this.checked)) {</p> ...
19,178
<p>As far as I can tell, this is isn't possible, so I'm really just hoping for a left field undocumented allocation hook function.<br> I want a way to track allocations like in <a href="http://msdn.microsoft.com/en-us/library/cy8c7wz5.aspx" rel="nofollow noreferrer">_CrtSetAllocHook</a>, but for <code>C#/.NET</code>.<b...
<p>The CLR has a 'profiling API' that hooks into pretty much everything - it is what the commercial .NET memory profiling products use, I believe. Here is an MSDN link to the top level of the documentation: <a href="http://msdn.microsoft.com/en-us/library/bb384547.aspx" rel="noreferrer">.NET Framework General Reference...
<p>I would just use Red Gate's ANTS Profiler. It will tell you a lot about what's going on in memory without you having to learn the profiling API yourself.</p>
7,318
<p>I'm having an odd problem with my vs debugger. When running my program under the vs debugger, the debugger does not break on an unhandled exception. Instead control is returned to VS as if the program exited normally. If I look in the output tab, There is a first-chance exeption listed just before the thread term...
<p>If you're on a 64-bit OS, there's a pretty good chance you're being bitten by an OS-level behavior that causes exceptions to disappear. The most reliable way to reproduce it is to make a new WinForm application that simply throws an exception in OnLoad; it will appear to not get thrown. Take a look at these:</p> <o...
<p>There are two checkboxes in the "Exceptions..." box, I usually have to have them both checked to get it to break on unhandled exceptions. Regardless that it only reads like you need to have one checked.</p>
12,862
<p>I have a photo website and i want to support tags as my original category bucketing is starting to fail (some pictures are family and vacations, or school and friends). Is there an agreed tagging db schema? </p> <p>I still want to support having photos as part of an album.</p> <p>Right now i have a few tables:</...
<p>There are various schemas which are effective, each with their own performance implications for the common queries you'll need as the number of tagged items grows:</p> <ul> <li><a href="http://howto.philippkeller.com/2005/04/24/Tags-Database-schemas/" rel="noreferrer">http://howto.philippkeller.com/2005/04/24/Tags-...
<p>In my app BugTracker.NET, I make an assumption that there won't be TOO many bugs. Maybe tens of thousands, but not tens of millions. That assumption allows me to cache the tags and the ids of the items they reference.</p> <p>In the database, the tags are stored as they are entered, with the bugs, in a comma deli...
20,801
<p>I'm looking for something that can copy (preferably only changed) files from a development machine to a staging machine and finally to a set of production machines.</p> <p>A "what if" mode would be nice as would the capability to "rollback" the last deployment. Database migrations aren't a necessary feature.</p...
<p><strong>@Sean Carpenter</strong> can you tell us a little more about your environment? Should the solution be free? simple?</p> <p>I find robocopy to be pretty slick for this sort of thing. Wrap in up in a batch file and you are good to go. It's a glorified xcopy, but deploying my website isn't really hard. Just co...
<p>We used <a href="http://www.eworldui.net/unleashit/" rel="nofollow noreferrer">UnleashIt</a> (unfortunate name I know) which was nicely customizable and allowed you to save profiles for deploying to different servers. It also has a "backup" feature which will backup your production files before deployment so rollbac...
6,438
<p>Is there a way to use a <code>foreach</code> loop to iterate through a collection backwards or in a completely random order?</p>
<p>As other answers mention, the <a href="http://msdn.microsoft.com/en-us/library/bb358497.aspx" rel="noreferrer"><code>Reverse()</code> extension method</a> will let you enumerate a sequence in reverse order.</p> <p>Here's a random enumeration extension method:</p> <pre><code>public static IEnumerable&lt;T&gt; Order...
<p>you can do it backwards:</p> <pre><code>for (int i=col.count-1; i&gt;0; i--){ DoSomething ( col.item[i]) ; } </code></pre> <p>Not certain about the exact syntax, but that's the paradigm. </p> <p>As for completely random order, you can access a collection element via it's index. To ensure you hit every it...
31,760
<p>It seems like a standard requirement: next time the user launches the application, open the window in the same position and state as it was before. Here's my wish list:</p> <ul> <li>Window position same as it was <ul> <li>Unless the screen has resized and the old position is now off screen.</li> </ul></li> <li>Spl...
<p>My other option is to write more custom code around the application settings and execute it on formLoad and formClosed. This doesn't use data binding.</p> <p>Drawbacks:</p> <ul> <li>More code to write.</li> <li>Very fiddly. The order you set the properties on formLoad is confusing. For example, you have to make su...
<p>A hack you can use Settings to store that information. All you have to do is bind the desired property (ex. form.Size and form.Location) to a specific setting and it get saved and updated automatically. </p>
13,142
<p>Recently, when porting some STL code to VS2008 I wanted to disable warnings generated by <code>std::copy</code> by defining the new <code>_SCL_SECURE_NO_WARNINGS</code> flag. You can do this in two ways:</p> <ul> <li>Using the <strong>/D</strong> compiler switch, which can be specified in the project properties. Y...
<p>The /D option is generally used when you want to define it differently on different builds (so it can be changed in the makefile)</p> <p>If you will "always" want it set the same way, use #define.</p>
<p>If you do put them in your code, remember to ifdef them properly:</p> <pre><code>#ifdef _MSC_VER #define _SCL_SECURE_NO_WARNINGS #endif </code></pre> <p>This will keep your code portable.</p>
37,933
<p>How can the XOR operation (on two 32 bit ints) be implemented using only basic arithmetic operations? Do you have to do it bitwise after dividing by each power of 2 in turn, or is there a shortcut? I don't care about execution speed so much as about the simplest, shortest code.</p> <p><strong>Edit:</strong> This is...
<p>I'm sorry i only know the straight forward one in head:</p> <pre><code>uint32_t mod_op(uint32_t a, uint32_t b) { uint32_t int_div = a / b; return a - (b * int_div); } uint32_t xor_op(uint32_t a, uint32_t b) { uint32_t n = 1u; uint32_t result = 0u; while(a != 0 || b != 0) { // or just: r...
<p>It's easier if you have the AND because</p> <p>A OR B = A + B - (A AND B)</p> <p>A XOR B = A + B - 2(A AND B)</p> <pre><code>int customxor(int a, int b) { return a + b - 2*(a &amp; b); } </code></pre>
48,814
<p>I've got two ListBox'es that are databound to the same BindingList.</p> <p>The issue is that when changing the selected item from the GUI it's changing the position in the BindingList and then the BindingList signals the other ListBox to change its selected item.</p> <p>So I've got the two ListBoxes Selected Item ...
<p>Add this line to <code>Form_Load</code>:</p> <pre><code>this.listBox1.BindingContext = new BindingContext(); </code></pre>
<p>My solution for this issue is to use a normal List instead of the BindingList and just call (before the change) on the Form object: this.BindingContext[Your List].SuspendBinding(); and after the change to the List this.BindingContext[Your List].ResumeBinding(); This updates all the bounded controls.</p> <p>...
33,807
<p>I am trying to make IBM jre to use PCF fonts from default X11 installation on my linux box. In particular adobe-helvetica font. I have toyed to modify fontconfig.properties in jre/lib folder but no matter what I do Java seams to use some other fonts. I guess there is some algorithm how java VM tries to link java log...
<p>Your verbosity is leading to a less readable code, I think the following format is best:</p> <pre><code>if ( null == o || null == o.ID || null.Title || 0 == o.ID.Length || 0 == o.Title.Length ) { // do stuff } </code></pre> <p>We all have high resolution/widescreen displays for a reason, there's no reason to loc...
<p>I usually do something like:</p> <pre><code>if(x &lt; 0 || x &gt;= width || y &lt; 0 || y &gt;= height) { /* Coordinate out of range ... */ } </code></pre> <p>The first y and x line up in a monospace font, which is nice, and I'm not confused by half-indentions.</p> <p>This method works best when doing similar...
41,686
<p>Start a new Silverlight application... and in the code behind (in the "Loaded" event), put this code:</p> <pre><code>// This will *NOT* cause an error. this.LayoutRoot.DataContext = new string[5]; </code></pre> <p>But...</p> <pre><code>// This *WILL* cause an error! this.LayoutRoot.DataContext = this; </code></pr...
<p>You can't currently use visual elements as a data source for data binding in Silverlight 2. I think this is slated to be added for Silverlight v.Next.</p>
<p>You can use visual elements as data source if you create binding directly in the code, but trying to assign visual element to DataContext will throw ArgumentException. It doesn't make much sense, but silverlight is just on version 2. </p>
37,360
<p>I read that PTFE starts to deteriorate past 260&nbsp;&deg;C. Does that mean heating to 250&nbsp;&deg;C is no problem at all, or will that destroy the PTFE material over time to?</p>
<p>Degradation starts at 260&nbsp;&deg;C and shifts towards full blown decomposition towards 350&nbsp;&deg;C. 250&nbsp;&deg;C is technically fine, but you should keep in mind that you've got little to no wiggle room for error at that temperature. Your thermistor and board may not be accurate enough to guarantee you'll ...
<p>High temperature rated PTFE tape is rated for up to 288°C (550°F).</p>
1,337
<p>Often when making changes to a VS2008 ASP.net project we get a message like:</p> <p>BC30560: 'mymodule_ascx' is ambiguous in the namespace 'ASP'.</p> <p>This goes away after a recompile or sometimes just waiting 10 seconds and refreshing the page. </p> <p>Any way to get rid of it?</p>
<p>I recently came across this problem and it was only happening on one server even though all were running the same code. I thoroughly investigated the problem to make sure there were no user controls with clashing names, temp files were cleared out, etc.</p> <p>The only thing that solved the problems (it seems perma...
<p>Also ran into this with MasterPages on projects that were originally .net 1.1 and 2.0 projects and later converted. In both cases, the @MasterType directive referenced the virtualpath. I changed to &lt;%@ MasterType TypeName="MasterPages_MasterPage" %>, cleaned the solution and the problem went away. HTH</p>
21,943
<p>I run a feed aggregator (<a href="http://planetdb2.com/" rel="nofollow noreferrer">http://planetdb2.com/</a>) and I need to aggregate both prolific (many posts a day) and less prolific (one post a day at most) feeds.</p> <p>Creating a daily digest -- one post summary of the day's posts -- seems like the best solut...
<p>Maybe <a href="http://www.tabbloid.com/" rel="nofollow noreferrer">Tabbloid</a> would do what you need. This service reads given RSS feeds, combines new items into a PDF and e-mails the pdf to given address on schedule.</p>
<p>Try yahoo pipes.</p> <p><a href="http://pipes.yahoo.com/pipes/" rel="nofollow noreferrer">http://pipes.yahoo.com/pipes/</a></p>
36,675
<p>Is it possible in PHP to do something like this? How would you go about writing a function? Here is an example. The order is the most important thing.</p> <pre><code>$customer['address'] = '123 fake st'; $customer['name'] = 'Tim'; $customer['dob'] = '12/08/1986'; $customer['dontSortMe'] = 'this value doesnt need to...
<p>Just use <a href="https://www.php.net/manual/en/function.array-merge.php" rel="noreferrer"><code>array_merge</code></a> or <a href="https://www.php.net/manual/en/function.array-replace.php" rel="noreferrer"><code>array_replace</code></a>. <code>array_merge</code> works by starting with the array you give it (in the ...
<p>If you have arrays like this, and you need to sort your array based on order, you can easily use this code:</p> <pre class="lang-php prettyprint-override"><code>$order = ['a', 'b', 'c', 'd', 'e']; $needToSortArray = ['d', 'c', 'e']; uksort($needToSortArray, function($key1, $key2) use ($order, $needToSortArray) { ...
45,332
<p>I have some global variables in a Python script. Some functions in that script call into C - is it possible to set one of those variables while in C and if so, how?</p> <p>I appreciate that this isn't a very nice design in the first place, but I need to make a small change to existing code, I don't want to embark o...
<p>I'm not a python guru, but I found this question interesting so I googled around. <a href="https://mail.python.org/pipermail/python-list/2007-September/427041.html" rel="nofollow noreferrer">This</a> was the first hit on "python embedding API" - does it help?</p> <blockquote> <p>If the attributes belong to the gl...
<p>I recommend using <a href="http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/" rel="nofollow noreferrer"><code>pyrex</code></a> to make an extension module you can store the values in in python, and cdef a bunch of functions which can be called from C to return the values there.</p> <p>Otherwise, much depend...
36,236
<p>I'm learning objective-c and keep bumping into the @ symbol. It is used in different scenarios, for example at the start of a string or to synthesise accessor methods. </p> <p>What's does the @ symbol mean in objective-c?</p>
<p>The <code>@</code> character isn't used in C or C++ identifiers, so it's used to introduce Objective-C language keywords in a way that won't conflict with the other languages' keywords. This enables the "Objective" part of the language to freely intermix with the C or C++ part.</p> <p>Thus with very few exceptions...
<p>As other answers have noted, the <code>@</code> symbol was convenient for adding Objective-C's superset of functionality to C because <code>@</code> is not used syntactically by C.</p> <p>As to what it represents, that depends on the context in which it is used. The uses fall roughly into two categories (keywords an...
4,533
<p>I have a few databases that I always use SQL Server Management Studio with. I'd like to be able to create a toolbar button or keyboard shortcut that automatically opens a new query window (in the current SSMS instance) and connects to a given (registered, perhaps) database. That's it. That's all I need. And this ...
<p>I am developer of <strong><a href="http://www.ssmsboost.com" rel="nofollow noreferrer">SSMSBoost</a></strong> add-in and it has exactly what you need: is allows to manage the <strong>list of preferred servers/databases</strong> and quickly switch between them via custom Combobox on the toolbar, you can also say, if ...
<p>You could create a shortcut to launch SQL Server Management studio using command line parameters, as follows:</p> <blockquote> <p><strong>SQLWB.EXE</strong> - launches SQL Server Management Studio from the Command Prompt or Start -> Run text box. Through its switches, you can specify which type of server (-t S, -...
21,194
<p>I recently finished building my first printer. The only problem that I'm having is that the hotend is not getting hot enough to start printing with PLA (180 to 230 degrees celsius), the hotend getting hotter stops at 170 degrees. Please help I've been stuck on this problem for days. Thanks in advance.</p>
<p>Usually, this kind of problem is due to an issue with the control loop of the temperature. You can try to do <a href="http://reprap.org/wiki/PID_Tuning" rel="noreferrer">PID Tuning</a> by running the command <code>M303 E0 S200 C8</code>. This will heat up the hot end and cycle it around 200C a few times, and afterwa...
<p>There are software limits that might be set low by default depending on the software you are using. I know there is with Marlin.</p>
385
<p>Does anyone know a simple load balance algorithm (formula) that relates users connected, cpu load, network load and memory usage? This will be used to compare various servers and assign to a new user the best at the moment. Thank You.</p>
<p>If you are using Apache Web Server to proxy the application servers, I recommend that you use <code>mod_proxy</code> and <code>mod_proxy_balancer</code>. You can find a quick introduction about mod_proxy <a href="http://docs.codehaus.org/display/JETTY/Configuring+mod_proxy" rel="nofollow noreferrer">here</a>. This i...
<p>Have a look at <a href="http://nginx.org/" rel="nofollow">nginx</a>. It is easy do configure, very fast and handles load balancing between servers.</p> <p>Distributed session handling is needed accordingly (see kgiannakakis) for details.</p>
46,884
<p>I've been interested in 3D printing for the past month however, I have noticed that it's sort of a "reserved" topic. Meaning that everyone who talks about it, has already some basic knowledge about the topic. What are some good resources for someone who wants to start learning from zero? My main goal is to acquire e...
<p>You can learn a lot just by reading the forums. I'll just list a few that are quite popular...</p> <p><a href="http://forums.reprap.org/" rel="nofollow">Reprap Forums</a> - Has a ton of information on DIY printers including build logs and posts dealing with many issues.</p> <p><a href="http://www.soliforum.com" r...
<p>ADDITIVE MANUFACTURING TECHNOLOGIES 3D Printing, Rapid Prototyping, and Direct Digital Manufacturing</p> <p>Springer</p> <p>I think its a perfect book. A lot of details to all technologies. *Beware there is math and physics involved.</p> <p><a href="https://i.stack.imgur.com/52f1O.jpg" rel="nofollow noreferrer"><...
271
<p>A bit of a neophyte haskell question, but I came across this example in Haskell's <a href="http://www.haskell.org/haskellwiki/99_questions/1_to_10" rel="noreferrer">tutorial examples</a>. For "find the last element of a list" there are some obvious versions, like </p> <pre><code>last' [x] = x last' (_:xs) = last' ...
<p>The definition of <code>const</code> is</p> <pre><code>const x = \_ -&gt; x </code></pre> <p>Hence, <code>(const id)</code> is a function which takes one argument and always returns <code>id</code> and</p> <pre><code>const id 1 2 = (\_ -&gt; id) 1 2 = id 2 = 2 </code></pre> <p>The defin...
<p>I rely heavily on <code>:t</code> when trying to understand Haskell. In this case:</p> <pre><code>Prelude> :t const id const id :: b -> a -> a</code></pre> <p>might have helped you see what was going on.</p>
44,584
<p>I use the <a href="http://oss.coresecurity.com/projects/pcapy.html" rel="nofollow noreferrer">pcapy</a>/<a href="http://oss.coresecurity.com/projects/impacket.html" rel="nofollow noreferrer">impacket</a> library to decode network packets in Python. It has an IP decoder which knows about the syntax of IPv4 packets bu...
<p>Scapy, recommended by the Impacket maintainers, has no IPv6 decoding at this time. But there is an <a href="http://namabiiru.hongo.wide.ad.jp/scapy6/" rel="nofollow noreferrer">unofficial extension</a> to do so.</p> <p>With this extension, it works:</p> <pre><code>for packet in traffic: if packet.type == ETH_P_I...
<p>I have never used pcapy before, but I do have used libpcap in C projects. As the pcapy page states it is not statically linked to libcap, so you can upgrade to a newer one with IPv6 support.</p> <p>According to <a href="http://www.tcpdump.org/libpcap-changes.txt" rel="nofollow noreferrer">libpcap changelog</a>, ver...
48,296
<p>Is it possible to store encrypted connection string so it can be used from server-side vbscript? Was there an equivalent of web.config in 'the good old days'?</p>
<p>As I dust off the ol' memory banks...</p> <p>I recall that in classic ASP systems, we would put the connection string (and most other config settings) in the Windows registry, in a custom registry key for the web app. We'd use a COM DLL to read the settings.</p> <p>You can encrypt the connection string that is st...
<p>.Net has all the encryption and decryption code built in so the easiest way to encrypt the string is to use the .Net encryption/decryption functions. Create a .Net component that does the decription and a COM callable wrapper for it which should register it. Then call it from your ASP page.</p>
43,816
<p>I know it is a good practice to declare virtual destructors for base classes in C++, but is it always important to declare <code>virtual</code> destructors even for abstract classes that function as interfaces? Please provide some reasons and examples why.</p>
<p>It's even more important for an interface. Any user of your class will probably hold a pointer to the interface, not a pointer to the concrete implementation. When they come to delete it, if the destructor is non-virtual, they will call the interface's destructor (or the compiler-provided default, if you didn't spec...
<p>The answer is simple, you need it to be virtual otherwise the base class would not be a complete polymorphic class.</p> <pre><code> Base *ptr = new Derived(); delete ptr; // Here the call order of destructors: first Derived then Base. </code></pre> <p>You would prefer the above deletion, but if the base cla...
34,056
<p>We are in the process of selecting BI stack for our data warehouse. The top contenders are OBIEE = Oracle BI Enterprise Edition (formerly Siebel Analytics) and Microstrategy.</p> <p>Has anyone worked with OBIEE? Lessons learned? General impressions? Flaws, strengths?</p>
<p>I've been involved in 20 OBIEE projects for the past 6 years. It's a good ROLAP product. It has a flexible, mostly intuitive UI that end users typically like. HTML, Javascript, and some Flash (charts) is used for presentation. There is a presentation server that runs under a web server (or app server) and the co...
<p>I have used it in the past. I really like the architecture, but you could have a look around this link to see some more detailed descriptions on how people work with it: <a href="http://www.rittmanmead.com/blog/" rel="nofollow noreferrer">http://www.rittmanmead.com/blog/</a> </p>
32,517
<p>I have an input file that I want to sort based on timestamp which is a substring of each record. I want to store multiple attributes of the </p> <p>The list is currently about 1000 records. But, I want it to be able to scale up a bit just in case.</p> <p>When I did it with a Linked List by searching the entire l...
<p>Sorting a linked-list will inherently be either O(N^2) or involve external random-access storage.</p> <p>Vectors have random access storage. So do arrays. Sorting can be O(NlogN).</p> <p>At 1000 elements you will begin to see a difference between O(N^2) and O(NlogN). At 1,000,000 elements you'll definitely noti...
<p>Rich -- To answer you more recent question (and not your original question), it's probably best/simplest to just parse out the date with sscanf(). Ideally you want to store it numerically to begin with.</p> <p>With a <em>"YYYY/MM/DD-HH:MM"</em> string, you can just compare the strings. All the strings are the sam...
42,999
<p>If you have an <code>NSMutableArray</code>, how do you shuffle the elements randomly?</p> <p>(I have my own answer for this, which is posted below, but I'm new to Cocoa and I'm interested to know if there is a better way.)</p> <hr> <p>Update: As noted by @Mukesh, as of iOS 10+ and macOS 10.12+, there is an <code>...
<p>I solved this by adding a category to NSMutableArray.</p> <p><strong>Edit:</strong> Removed unnecessary method thanks to answer by Ladd.</p> <p><strong>Edit:</strong> Changed <code>(arc4random() % nElements)</code> to <code>arc4random_uniform(nElements)</code> thanks to answer by Gregory Goltsov and comments by mi...
<pre><code>NSUInteger randomIndex = arc4random() % [theArray count]; </code></pre>
8,063
<p>When I try to create a Excel 2007 Workbook project, in Visual Studio 2008, I get the following errormessage:</p> <blockquote> <p>Project cannot be created because the "Excel Visual Studio Design-Time Adaptor Add-in" is not working correctly. Excel might have disabled the add-in or made it inactive, or all add-ins...
<p>Just in case you haven't checked the trust settings, this <a href="http://msdn.microsoft.com/en-us/library/bb386131.aspx" rel="noreferrer">MSDN page</a> describes how to.</p> <p>I came across this on a MSDN forum:</p> <blockquote> <p>For the repair to work, you'll have to run the VS Command Prompt with Admin ...
<p>I'd set Excel 2003 to open XLS files by default. I saw the same error message you got until I repaired Office 2007 from the Add/Remove Programs menu.</p>
34,602
<p>If I create an HTTP <code>java.net.URL</code> and then call <code>openConnection()</code> on it, does it necessarily imply that an HTTP post is going to happen? I know that <code>openStream()</code> implies a GET. If so, how do you perform one of the other HTTP verbs without having to work with the raw socket laye...
<p>If you retrieve the <code>URLConnection</code> object using <code>openConnection()</code> it doesn't actually start communicating with the server. That doesn't happen until you get the stream from the <code>URLConnection()</code>. When you first get the connection you can add/change headers and other connection pr...
<p>No it does not. But if the protocol of the URL is HTTP, you'll get a <a href="http://java.sun.com/javase/6/docs/api/java/net/HttpURLConnection.html" rel="nofollow noreferrer"><code>HttpURLConnection</code></a> as a return object. This class has a <code>setRequestMethod</code> method to specify which HTTP method you ...
6,042
<p>After changing the output directory of a visual studio project it started to fail to build with an error very much like: </p> <pre><code>C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\sgen.exe /assembly:C:\p4root\Zantaz\trunk\EASDiscovery\EASDiscoveryCaseManagement\obj\Release\EASDiscoveryCaseManagement....
<p>If you are having this problem while building your VS.NET project in Release mode here is the solution:</p> <p>Go to the project properties and click on the Build tab and set the value of the "Generate Serialization Assembly" dropdown to "Off".</p> <p>Sgen.exe is "The XML Serializer Generator creates an XML serial...
<p>I've not seen this particular problem, but recently for us a "C1001: An internal error has occurred in the compiler" type crash from cl.exe was fixed after installing some random and unrelated (or so we thought) Windows security updates.</p> <p>We knew the code didn't crash the compiler on other machines using the ...
2,834
<p>I'm writing a WCF service for the first time. The service and all of its clients (at least for now) are written in C#. The service has to do a lot of input validation on the data it gets passed, so I need to have some way to indicate invalid data back to the client. I've been reading a lot about faults and except...
<p>If you are doing validation on the client and should have valid values once they are passed into the method (the web service call) then I would throw an exception. It could be an exception indicating that a parameters is invalid with the name of the parameter. (see: ArgumentException)</p> <p>But you may not want to...
<p>you might want to take a look at the MS Patterns and Practices Enterprise Library Validation block in conjunction with the policy injection block <a href="http://www.codeplex.com/entlib" rel="nofollow noreferrer">link text</a> it allows you to decorate your data contract members with validation attributes and also d...
12,279
<p>Is there any way to down-format a Subversion repository to avoid messages like this:</p> <pre> svn: Expected format '3' of repository; found format '5' </pre> <p>This happens when you access repositories from more than one machine, and you aren't able to use a consistent version of Subversion across all of those m...
<p>If you can't use the same version of Subversion across all machines, then you should set up a server process (either svnserve or Apache) and access the repository only through the server. The server can mediate between different versions of Subversion; it's only when you're using direct repository access that you r...
<p>If you downgrade to v1.4x, here's another way that may help you: <a href="https://www.admon.org/scripts/downgrade-svn-from-1-6-to-1-4/" rel="nofollow noreferrer">https://www.admon.org/scripts/downgrade-svn-from-1-6-to-1-4/</a></p>
14,904
<p>Can we programatically login to Yahoo services with our ID, send instant message, use webcam service and so on directly from our program?</p>
<p>You could look at <a href="http://developer.pidgin.im/wiki/WhatIsLibpurple" rel="nofollow noreferrer">libpurple</a>, although I'm not sure what its webcam support is like.</p>
<p>Yahoo Messenger has a <a href="http://developer.yahoo.com/messenger/" rel="nofollow noreferrer">plug-in SDK</a>. It is hard to know if this meets your needs, since you are not very clear.</p> <p>If you are looking to access Yahoo messenger services through Java for instance, you could try an <a href="http://jymsg9....
34,606
<p>There is probably is simple fix for this but I currently have code similar to </p> <pre><code>dim dr as dbDataReader try dr = connection.getDataReader(sql_str) Catch ex as sqlClientException log.error(ex) finally if not IsNothing(dr) then dr.close end if end try </code></pre> <p>However Visua...
<p>Explicitly initialize the dr declaration to Nothing as such:</p> <pre><code>Dim dr As DbDataReader = Nothing </code></pre> <p>And the warning will disappear.</p>
<p>Your code is correct. In the <code>finally</code> statement, as long as you check to make sure your objects are not null, it won't throw a null reference exception based on what happens in your code.</p>
18,420
<p>What is the best way to upload a file to a Document Library on a SharePoint server through the built-in web services that version WSS 3.0 exposes?</p> <p><strong>Following the two initial answers...</strong></p> <ul> <li><p>We definitely need to use the Web Service layer as we will be making these calls from remot...
<p>Example of using the WSS "Copy" Web service to upload a document to a library...</p> <pre><code>public static void UploadFile2007(string destinationUrl, byte[] fileData) { // List of desination Urls, Just one in this example. string[] destinationUrls = { Uri.EscapeUriString(destinationUrl) }; // Empty ...
<p>From a colleage at work:</p> <blockquote> <p>Lazy way: your Windows WebDAV filesystem interface. It is bad as a programmatic solution because it relies on the WindowsClient service running on your OS, and also only works on websites running on port 80. Map a drive to the document library and get with the file copyin...
5,179
<p>What is the best way to block certain input keys from being used in a TextBox with out blocking special keystrokes such as <kbd>Ctrl</kbd>-<kbd>V</kbd>/<kbd>Ctrl</kbd>-<kbd>C</kbd>?</p> <p>For example, only allowing the user to enter a subset of characters or numerics such as A or B or C and nothing else.</p>
<p>I would use the keydown-event and use the e.cancel to stop the key if the key is not allowed. If I want to do it on multiple places then I would make a user control that inherits a textbox and then add a property AllowedChars or DisallowedChars that handle it for me. I have a couple of variants laying around that I ...
<p>You could use the TextChanged event for the textbox.</p> <pre><code> private void txtInput_TextChanged(object sender, EventArgs e) { if (txtInput.Text.ToUpper() == "A" || txtInput.Text.ToUpper() == "B") { //invalid entry logic here } } </code></pre>
37,606
<p>During a complicated update I might prefer to display all the changes at once. I know there is a method that allows me to do this, but what is it?</p>
<p>I think this.SuspendLayout() &amp; ResumeLayout() should do it</p>
<p>SuspendLayout will help performance if the updates involve changes to controls and layout: <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.suspendlayout.aspx" rel="nofollow noreferrer">MSDN</a></p>
15,437
<p>I'd like to install Gentoo. I need it to develop GUI C++ applications using wxWidgets, so I need:</p> <ul> <li>build tools: make, automake, autoconf, etc.</li> <li>C++ compiler (GCC)</li> <li>X Window System for testing (Fluxbox or something minimal would be enough)</li> </ul> <p>Now, I have two options:</p> <ul>...
<p>Gentoo is ultraminimalist by default. </p> <p>The install CD gets you a basic working system, a basic compile environment ( Some version of the GCC suite ), and package management. </p> <p>Its up to you then to install what you want to use. </p> <p>Its not like many other distributions where theres a big set of "...
<p>Use network install. It does save you something and even if you do multiple installations you'll probably want the newest packages anyway. And no the network installer will not download the 600MB without asking you that would make no sense.</p>
12,008
<p>I installed a BLTouch bed leveling probe on my printer which uses Marlin 2.0.5.3.</p> <p>Now the printer seems to be of two minds when it comes to finding the origin. Homing XY moves to the lower left as it always has, but homing Z moves not only to Z=0, but also to the center of the build plate. The printer knows ...
<p>This is a consequence of enabling <code>Z_SAFE_HOMING</code>:</p> <blockquote> <p>Z Safe Homing prevents Z from homing when the probe (or nozzle) is outside bed area by moving to a defined XY point (by default, the middle of the bed) before Z Homing when homing all axes with <code>G28</code>. As a side-effect, X and...
<p>I had the same problem, solved it by inserting</p> <pre><code>// Move X and Y to 0 after homing process_subcommands_now_P(&quot;G1 X0 Y0 F5000&quot;); </code></pre> <p>at the end of <code>G28.cpp</code>, just before <code>ui.refresh();</code></p> <p>This moves the print head to X0, Y0 and leaves Z untouched after th...
1,686
<p>How do I mask the address of another site using HTML?</p> <p>For example, I'd like:</p> <p><a href="http://www.example.com/source.html" rel="nofollow noreferrer">http://www.example.com/source.html</a></p> <p>To point to another page:</p> <p><a href="http://www.example.com/dest.html" rel="nofollow noreferrer">htt...
<p>A frameset seems to be what I was looking for:</p> <pre><code>&lt;frameset rows="100%"&gt; &lt;frame src="http://www.example.com/dest.html"/&gt; &lt;/frameset&gt; </code></pre>
<p>If you are using Apache, you can use REWRITE mod, but it must be in the same domain. In .NET there rewrite libraries done. People will see in the address bar: source.html but the code will be that of dest.html.</p> <p>Any other thing is simple redirects.</p>
40,786
<p>I'm sure this is a relatively simple question, and there must be a good sensible rails way of doing it, but I'm not sure what it is.</p> <p>Basically I'm adding books to a database, and I want to store the Author in a separate table. So I have a table called authors which is referenced by the table books.</p> <p>I...
<p>I suggest you watch the <strong>Complex Forms Series</strong> of Railscasts <a href="http://railscasts.com/episodes/73-complex-forms-part-1" rel="noreferrer">here</a>.</p>
<p>This will eventually be automatic (according to this post, in Rails 2.2): <a href="http://ryandaigle.com/articles/2008/7/19/what-s-new-in-edge-rails-nested-models" rel="nofollow noreferrer">http://ryandaigle.com/articles/2008/7/19/what-s-new-in-edge-rails-nested-models</a></p>
30,329
<p>Out style:</p> <pre><code>bool result; if(something.TryParse(val, out result)) { DoSomething(result); } </code></pre> <p>Nullable style:</p> <pre><code>bool? result = something.TryParse2(val); if(result.HasValue) { DoSomething(result.Value); } </code></pre>
<p>TryParse(val, out result) is a idiom established by the .NET framework in int.TryParse, DateTime.TryParse, etc. It is likely that people that read the code will be familiar with this idiom, so you should stick to it, unless you find a very good reason not to.</p>
<p>I would probably use the second example. Although I see both as perfectly acceptable.</p>
26,591
<p>Our software must be able to run on SQL Server 2000 and 2005. To simplify development, we're running our SQL Server 2005 databases in compatibility level 80. However, database performance seems slower on SQL 2005 than on SQL 2000 in some cases (we have not confirmed this using benchmarks yet). Would upgrading the...
<p>I think i read somewhere, that the SQL Server 2005 database engine should be about 30% faster than the SQL Server 2000 engine. It might be, that you have to run your database in compatibility mode 90 to get these benefits.</p> <p>But i stumbled on two scenarios, where performance can drop dramatically when using ms...
<p>Also a FYI, if you run compatibility level 90 then some things are not supported anymore like old style outer joins <code>(*= and =*)</code></p>
2,885
<p>We don't teach children calculus first. We first teach them arithmetic, then algebra, then geometry, the analytical geometry, then finally calculus.</p> <p>Why then, do we teach our computer scientists frameworks and IDE first. Some curriculum do force students to learn computer science fundamentals, but the vast...
<p>I think the analogy is a bit off. A better analogy would be "We don't teach our kids to use calculators to add and subtract, why teach programmers to use an IDE to program?"</p>
<p>Learning the abstraction is easier than learning the details when it comes to programming. It's harder to teach someone to hand-code assembler to print "Hello World" than it is to have them throw together a form with a button on it that shows a "Hello World" message when the button is clicked.</p> <p>You didn't kno...
33,893
<p>What would be the best way to write Objective-C on the Windows platform?</p> <p>Cygwin and gcc? Is there a way I can somehow integrate this into Visual Studio?</p> <p>Along those lines - are there any suggestions as to how to link in and use the Windows SDK for something like this. Its a different beast but I know...
<p>Expanding on the two previous answers, if you just want Objective-C but not any of the Cocoa frameworks, then gcc will work on any platform. You can use it through Cygwin or get MinGW. However, if you want the Cocoa frameworks, or at least a reasonable subset of them, then GNUStep and Cocotron are your best bets.</p...
<p>If you are comfortable with Visual Studio environment, </p> <p>Small project: jGRASP with gcc Large project: Cocotron </p> <p>I heard there are emulators, but I could find only Apple II Emulator <a href="http://virtualapple.org/" rel="nofollow">http://virtualapple.org/</a>. It looks like limited to games. </p>
8,076
<p>How do I add new record to DataGridView control in VB.Net?</p> <p>I don't use dataset or database binding. I have a small form with 3 fields and when the user clicks OK they should be added to the DataGridView control as a new row.</p>
<p>If you want to add the row to the end of the grid use the <strong>Add()</strong> method of the Rows collection...</p> <pre><code>DataGridView1.Rows.Add(New String(){Value1, Value2, Value3}) </code></pre> <p>If you want to insert the row at a partiular position use the <strong>Insert()</strong> method of the Rows c...
<p>When I try to cast data source from datagridview that used bindingsource it error accor cannot casting:</p> <p>----------Solution------------</p> <p>'I changed casting from bindingsource that bind with datagridview</p> <p>'Code here</p> <pre><code>Dim dtdata As New DataTable() dtdata = CType(bndsData.DataSource...
41,016
<p>I'm using memcache to design a cache for the model layer of a web application, one of my biggest problems is data consistency. It came to my mind caching data like this: (key=query, value=list of object ids result of the query) for each id of the list: (key=object.id, value=object)</p> <p>So, every time a query is...
<p>Caching is one of those topics where there is no one right answer - it depends on your domain.</p> <p>The caching policy that you describe may be sufficient for your domain. However, you don't appear to be worried about stale data. Often I would expect to see a timestamp against some of the entities - if the cached...
<p>Welcome to the world of concurrency programming. You'll want to learn a bit about <a href="http://en.wikipedia.org/wiki/Mutual_exclusion" rel="nofollow noreferrer">mutual exclusion</a>. If you tell us what language/platform you are developing for we can describe more specifically your options.</p>
11,843
<p>I have a ListView that has several columns. </p> <p>One of them contains "Names", the other contains "Amount". I would like to allow the user to click the Names column in the listview and have it sort alphabetically and also allow the user to click the "Amount" and have it sort numerically (higher/lower - lower/h...
<p>It is partially implemented but not completely. Microsoft have a description of how to approach this problem at <a href="http://support.microsoft.com/kb/319401" rel="nofollow noreferrer">http://support.microsoft.com/kb/319401</a>.</p>
<p>To solve this, I wrote my own ListViewItemComparer which implemented the IComparer interface. Then, based on whether the column was numeric or string, I did the appropriate comparison.</p>
17,025
<p>Let's say I have a class:</p> <pre><code>class Foo { public string Bar { get { ... } } public string this[int index] { get { ... } } } </code></pre> <p>I can bind to these two properties using "{Binding Path=Bar}" and "{Binding Path=[x]}". Fine.</p> <p>Now let's say I want to implement INotif...
<p>Thanks to Cameron's suggestion, I've found the correct syntax, which is:</p> <pre><code>Item[] </code></pre> <p>Which updates everything (all index values) bound to that indexed property.</p>
<p>Don't know for sure if this'll work, but reflector shows that the get and set methods for an indexed property are called get_Item and set_Item. Perhaps you could try Item and see if that works.</p>
11,629
<p>After reading <a href="http://www.javaworld.com/javaworld/javatips/jw-javatip130.html?page=2" rel="noreferrer">this old article</a> measuring the memory consumption of several object types, I was amazed to see how much memory <code>String</code>s use in Java:</p> <pre><code>length: 0, {class java.lang.String} size =...
<h1>With a Little Bit of Help From the JVM...</h1> <p><em><strong>WARNING:</strong> This solution is now obsolete in newer Java SE versions. See other ad-hoc solutions further below.</em></p> <p>If you use an HotSpot JVM, since Java 6 update 21, you can use this command-line option:</p> <pre><code>-XX:+UseCompressed...
<p>Out of curiosity, is the few bytes saved really worth it?</p> <p>Normally, I suggest ditching strings for performance reasons, in favor of StringBuffer (Remember, Strings are immutable).</p> <p>Are you seriously exhausting your heap from string references?</p>
28,597
<p>Visual Studio has certainly gone from strength to strength since humble Visual Studio 6 (and previous renditions). There seems to be a lot more coming in Visual Studio 2010 (based on blogs, the PDC and the more recent CTP virtual machines).</p> <p>The recent Service Pack 1 seemed to introduce some really intriguin...
<p>IntelliSense</p>
<p>For me the best thing in VS 2008 is that such tools like VS.PHP can be build upon that. So that you can write a PHP website inside VS with all this goodies like intellisense an so on.</p> <p>And the worst feature is DataSet designer that is "by design" full of bugs and other filthy stuff. It's just a pain in the as...
43,357
<p>Currently I have:</p> <pre><code>&lt;system.net&gt; &lt;mailSettings&gt; &lt;smtp from="me@mydomain.com"&gt; &lt;network host="localhost" port="25" /&gt; &lt;/smtp&gt; &lt;/mailSettings&gt; &lt;/system.net&gt; </code></pre> <p>How can I change it...
<p>Well, in code you need to put the sender's name in quotes, followed by the e-mail address.</p> <pre><code>new SmtpClient(...).Send("\"John Smith\" jsmith@somewhere.com", ...); </code></pre> <p>And...it looks like you can encode it into the attribute too...</p> <pre><code>&lt;smtp from="&amp;quot;John Smith&amp;qu...
<pre><code>&lt;system.net&gt; &lt;mailSettings&gt; &lt;smtp from ="XYZ&amp;lt;xyz@xyz.com&amp;gt;"&gt; &lt;network host="smtp.gmail.com" port="25" userName="xyz@xyz.com" password="******" enableSsl="true"/&gt; &lt;/smtp&gt; &lt;/mailSettings&gt; &lt;/system.net&gt; </code></pre> <p>1)Please Use these setting in app...
31,448
<p>The following code will not compile:</p> <pre><code>string foo = "bar"; Object o = foo == null ? DBNull.Value : foo; </code></pre> <p>I get: <em>Error 1 Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DBNull' and 'string'</em></p> <p>To fix this, I must ...
<p>The compiler requires that either the types of second and third operands are the same, or that one is implicitly convertible to the other. In your case, the types are DBNull and string, neither of which is implicitly convertible to the other. Casting either of them to object solves that.</p> <p>EDIT: Looks like it ...
<p>By the way, your code is a special case that doesn't have to use the conditional operator at all. Instead, the null coalesce operator is more appropriate (but still requires casting):</p> <pre><code>object result = (object)foo ?? DBNull.Value; </code></pre>
24,725
<p>What is the best way to password protect quicktime streaming videos using php/.htaccess. They are being streamed using rtsp, but I can use other formats if necessary.</p> <p>I know how to do authentication with php, but I'm not sure how to setup authentication so that will protect the streaming files urls so that a...
<p>Both nginx and lighttpd web servers have X-Send-File headers you can return from PHP. So you can do your checks in PHP and then conditionally server out the file.</p> <pre><code>if (check_user_can_access()){ header('X-sendfile: /path/to/file'); } else { header('HTTP/1.1 403 Fail!'); } </code></pre> <p>Ligh...
<p>First off, it is very easy to spoof a referer. This information is stored in the user's browser, so a user can simply telnet into your server and provide his own referer which matches your domain.</p> <p>A couple things you could try:</p> <p>First, more secure, but still spoofable. mod_rewrite provides the ability...
36,376
<p>I would like to be able to obtain all the parameter values from the stack frame in .NET. A bit like how you're able to see the values in the call stack when in the Visual Studio debugger. My approach has concentrated on using the <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.stackframe%28v=vs.7...
<p>It seems it can't be done that way. It will only provide meta information about the method and its parameters. Not the actual value at the time of the callstack. </p> <p>Some suggest deriving your classes from <a href="http://msdn.microsoft.com/en-us/library/system.contextboundobject.aspx" rel="noreferrer">ContextB...
<p>I am quite sure this is possible somehow, but I am not competent enough to give you the answer you wish. I am suggesting a different approach, less flexible but still useful if you have a stack trace in advance and you would like to see the arguments passed to each frame.</p> <p>Typically you would scatter log messa...
10,068
<p>When you are monitoring the TFS build from Visual Studio (2008 or 2005), you can see where it is up to.</p> <p>The issue is that I have some Post-Build custom steps I would like the developer to be able to see directly throught the UI. Those steps take some times and we can also get a "timing" of the build step.</p...
<p>This is the pattern that I normally use for adding steps to the build report in TFS 2008. (See <a href="http://code.msdn.microsoft.com/buildwallboard/" rel="nofollow noreferrer">http://code.msdn.microsoft.com/buildwallboard/</a> for the full example that I usually use in my Team Build talks)</p> <p>Basically, the m...
<p>Note that in @Martin Woodward's great example, PackageBinaries is one of the existing <a href="http://msdn.microsoft.com/en-us/library/aa337604%28v=VS.90%29.aspx" rel="nofollow">TFS build targets</a>. If you want to use your own targets, you can use the <a href="http://msdn.microsoft.com/en-us/library/ms229474%28v=V...
28,042
<p>I have this web application that has grown to an unmanageable mess. </p> <p>I want to split it into a common "framework" part (that still includes web stuff like pages and images) and several modules that add extra functionality and screens. I want this refactoring to also be useful as a plugin system for third-par...
<p>I have been tinkering with the idea of using OSGi to solve the same problem you are describing. In particular I am looking at using <a href="http://www.springframework.org/osgi" rel="nofollow noreferrer">Spring Dynamic Modules</a>. </p>
<p>Depending on the complexity of the plugin functionality I would also be considering a web service, for instance implemented with Axis.</p> <p>Your main appplication is then configured with the URL to the web application (plugin) which provides the service.</p> <p>The advantage,as I see it, is twofold:</p> <ul> <l...
20,439
<p>The common sense tells that the Doxygen comment blocks have to be put in the header files where the classes, structs, enums, functions, declarations are. I agree that this is a sound argument for a libraries that are mean to be distributed without its source (only headers and libs with object code).</p> <p>BUT...I'...
<p>Put the documentation where people will read and write it as they are using and working on the code.</p> <p>Class comments go in front of classes, method comments in front of methods.</p> <p>That is the best way to make sure things are maintained. It also keeps your header files relatively lean and avoids the <em>...
<p>In c++ sometimes implementation can be split between header and .cpp modules. Here it seems cleaner to put it documentation into the header file as that is the only place that all public functions and methods are guaranteed.</p>
46,351
<p>I need to store an array in a custom content type in MOSS. This will always be hidden, only used programmatically. Throughout the lifecycle of the list item, I will be adding values to the array. My array may look like this after a while:</p> <pre> value1,1 | value1,2 | value1,3 | value1,4 value2,1 | value2,2 | ...
<p>There is no out of the box field in which you can store a 2-dimensional array.<br> Usually, you either store each row in a different item, or you serialize your value in a simpler field (like multiline text).</p>
<p>Serializing it is probably your best solution for small arrays. Or you can store it in a separate list. And remember there's no law against creating your own custom table. </p>
38,753
<p>I'm curious, is there a way to tell the SQL Server that a specific group has access to the database only from a single location/application. I have an SQL Server and a Web Server. Our applications use stored procedures and access for each stored procedure is based on the role that is allowed to access it. Then us...
<p>Simplest thing seems to be to just add the JPA libraries to EJB project and be done with it. It seems that Workshop has no specific support for JPA in EJB projects. Not that it is needed.</p>
<p>Simplest thing seems to be to just add the JPA libraries to EJB project and be done with it. It seems that Workshop has no specific support for JPA in EJB projects. Not that it is needed.</p>
37,822
<p>When retrieving a lookup code value from a table, some folks do this...</p> <pre><code>Dim dtLookupCode As New LookupCodeDataTable() Dim taLookupCode AS New LookupCodeTableAdapter() Dim strDescription As String dtLookupCode = taLookupCode.GetDataByCodeAndValue("EmpStatus", "FULL") strDescription = dtLookupCode.Ite...
<p>Those two lines would compile down to the same thing. I would pick whichever one is easier for you read. Inlining normally refers to something <a href="http://en.wikipedia.org/wiki/Inline_function" rel="nofollow noreferrer">a bit different</a>.</p>
<p>The structure is still created, you just do not have a reference for it.</p>
13,095
<p>We should do some tag maintenance, especially regarding printers to make them easier to read. Use an answer to propose a change, merge or split. Discussions for each change should go into the comments of each change.</p> <p>Some things are easier than others: </p> <ul> <li><strong>Renaming</strong> a tag can be do...
<h1>Laundry list:</h1> <h2>Open</h2> <ul> <li><a href="https://3dprinting.meta.stackexchange.com/a/438">e3d</a></li> <li><a href="https://3dprinting.meta.stackexchange.com/a/436">Creality</a></li> <li><a href="https://3dprinting.meta.stackexchange.com/a/434">Filled PLA</a></li> </ul> <h2>Done</h2> <ul> <li><a href=...
<h1>Manufacturer: Monoprice</h1> <p>Status: <strong>Done</strong></p> <p>This tag (<a href="https://3dprinting.stackexchange.com/questions/tagged/monprice" class="post-tag" title="show questions tagged &#39;monprice&#39;" rel="tag">monprice</a>) is used for tagging questions regarding various printer types while the ta...
70
<p>I have replaced the stock extruder on my Ender 3 with one of these:</p> <p><a href="https://i.stack.imgur.com/wDmXL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wDmXL.jpg" alt="New Extruder"></a></p> <p>The grip gear has a smaller diameter, so I calibrated the esteps as per the top google sea...
<p>Consider that the extruder is skipping because it is unable to push filament at the rate you are requesting. By reducing the steps to ninety percent, you are reducing the rate by that much as well.</p> <p>Typically, a skipping extruder is an indication of clogging, but it does not have to be clogging caused by part...
<p>I have this same extruder on my Voxelab Aquila. Default E-steps are 93. Using the printer menu to feed 100 mm of eSun black PETG filament I measured a feed length of 66 mm, so 34 mm under extruded.</p> <p>Using the formula 100 / 66 * 93 gave me a new E-step value of 140.9. Upon re-testing, I found I was now over ext...
1,469
<p>I'm trying to create a "workflow" bar on a web page.</p> <p>The items in the workflow might be of different lengths.</p> <p>There might be enough items to fill the width of the screen, hence the flow needs to wrap onto the next line.</p> <p>I'm using left floating divs to do this. </p> <p>However, I'd like the d...
<p>just a couple of other pointers. You should not have empty li tags, that is not semantically correct. Also in an ideal world you should <a href="http://nate.koechley.com/blog/2006/12/22/note_on_structural_and_semantic_meaning/" rel="nofollow noreferrer">not give id attributes layout names</a>.</p> <p>Personally I...
<p>Don't waste your time just go here:</p> <p><a href="http://www.cssmenubuilder.com/build-breadcrumb-menu" rel="nofollow noreferrer">http://www.cssmenubuilder.com/build-breadcrumb-menu</a></p>
42,241
<p>The .NET garbage collector will eventually free up memory, but what if you want that memory back immediately? What code do you need to use in a class <code>MyClass</code> to call</p> <pre><code>MyClass.Dispose() </code></pre> <p>and free up all the used space by variables and objects in <code>MyClass</code>?</p>
<p>IDisposable has nothing to do with freeing memory. IDisposable is a pattern for freeing <em>unmanaged</em> resources -- and memory is quite definitely a managed resource.</p> <p>The links pointing to GC.Collect() are the correct answer, though use of this function is generally discouraged by the Microsoft .NET doc...
<p>In answer to the original question, with the information given so far by the original poster, it is 100% certain that he does not know enough about programming in .NET to even be given the answer: use GC.Collect(). I would say it is 99.99% likely that he really doesn't need to use GC.Collect() at all, as most poster...
3,341
<p>I want my website to have a checkbox that users can click so that they will not have to log in each time they visit my website. I know I will need to store a cookie on their computer to implement this, but what should be contained in that cookie? </p> <p>Also, are there common mistakes to watch out for to keep thi...
<h2>Improved Persistent Login Cookie Best Practice</h2> <p>You could use this strategy described <a href="https://web.archive.org/web/20180819014446/http://jaspan.com/improved_persistent_login_cookie_best_practice" rel="noreferrer">here as best practice</a> (2006) or <a href="https://paragonie.com/blog/2015/04/secure-...
<p>I would store a user ID and a token. When the user comes back to the site, compare those two pieces of information against something persistent like a database entry.</p> <p>As for security, just don't put anything in there that will allow someone to modify the cookie to gain extra benefits. For example, don't stor...
30,373
<p>I need to be able to contribute to a relatively large Adobe AIR project and I'm starting from scratch with this technology. What's the best way to go about it?</p> <p>I usually get a good book/tutorial and work my way through it but this time it seems there's just too much to learn for this to be feasible within a ...
<p>I just had to do something similar. If you can afford it (or, get your company to pay for it), try doing a training class. I did one by Figleaf software a couple months ago and it really helped.</p> <p>As for books, I hear the Essential Actionscript 3 book is good (I have the one for AS2 and it's quite good). Fl...
<p>I usually find online tutorials are the best way to go. They are more to the point than books, so it's usually quicker to get up to speed. And don't limit yourself to a single resource. I've never had problems finding enough tutorials through our friend google.</p> <p>I have no knowledge about Adobe AIR though. I a...
26,953
<p>Joe Van Dyk <a href="http://www.zenspider.com/pipermail/ruby/2008-August/004223.html" rel="noreferrer">asked the Ruby mailing list</a>:</p> <blockquote> <p>Hi,</p> <p>In Ruby, I guess you can't marshal a lambda/proc object, right? Is that possible in lisp or other languages?</p> <p>What I was trying ...
<p>You cannot marshal a Lambda or Proc. This is because both of them are considered closures, which means they close around the memory on which they were defined and can reference it. (In order to marshal them you'd have to Marshal all of the memory they could access at the time they were created.)</p> <p>As Gaius poi...
<p>If proc is defined into a file, U can get the file location of proc then serialize it, then after deserialize use the location to get back to the proc again</p> <blockquote> <p>proc_location_array = proc.source_location</p> </blockquote> <p>after deserialize:</p> <blockquote> <p>file_name = proc_location_arra...
4,377
<p>I have defined a Java function:</p> <pre><code>static &lt;T&gt; List&lt;T&gt; createEmptyList() { return new ArrayList&lt;T&gt;(); } </code></pre> <p>One way to call it is like so:</p> <pre><code>List&lt;Integer&gt; myList = createEmptyList(); // Compiles </code></pre> <p>Why can't I call it by explicitly pa...
<p>When the java compiler cannot infer the parameter type by itself for a static method, you can always pass it using the full qualified method name: Class . &lt; Type > method();</p> <pre><code>Object list = Collections.&lt;String&gt; emptyList(); </code></pre>
<p>@pauldoo Yes, you are quite right. It is one of the weaknesses with the java generics imho.</p> <p>I response to Cheekysoft I'd like to propose to also look at how it is done by the Java people themselves, such as T[] <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/AbstractCollection.html" rel="nofollow ...
4,463
<p>I am unit testing a .NET application (.exe) that uses an app.config file to load configuration properties. The unit test application itself does not have an app.config file. </p> <p>When I try to unit test a method that utilizes any of the configuration properties, they return <em>null</em>. I'm assuming this is...
<p>The simplest way to do this is to add the <code>.config</code> file in the deployment section on your unit test.</p> <p>To do so, open the <code>.testrunconfig</code> file from your Solution Items. In the Deployment section, add the output <code>.config</code> files from your project's build directory (presumably <...
<p>Your unit tests are considered as an environment that runs your code to test it. Just like any normal environment, you have i.e. staging/production. You may need to add a <code>.config</code> file for your test project as well. A workaround is to create a class library and convert it to Test Project by adding necess...
44,752
<p>In a C++ project I'm working on, I have a <em>flag</em> kind of value which can have four values. Those four flags can be combined. Flags describe the records in database and can be:</p> <ul> <li>new record</li> <li>deleted record</li> <li>modified record</li> <li>existing record</li> </ul> <p>Now, for each record...
<p>Combine the strategies to reduce the disadvantages of a single approach. I work in embedded systems so the following solution is based on the fact that integer and bitwise operators are fast, low memory &amp; low in flash usage.</p> <p>Place the enum in a namespace to prevent the constants from polluting the global...
<p>I would rather go with</p> <pre><code>typedef enum { xNew = 1, xDeleted, xModified = 4, xExisting = 8 } RecordType; </code></pre> <p>Simply because: </p> <ol> <li>It is cleaner and it makes the code readable and maintainable. </li> <li>It logically groups the constants.</li> <li>Programmer's time is more importan...
13,750