instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I have 3 PDF documents that are generated on the fly by a legacy library that we use, and written to disk. What's the easiest way for my JAVA server code to grab these 3 documents and turn them into one long PDF document where it's just all the pages from document #1, followed by all the pages from document #2, etc....
<p>@J D OConal, thanks for the tip, the article you sent me was very outdated, but it did point me towards iText. I found this page that explains how to do exactly what I need: <a href="http://java-x.blogspot.com/2006/11/merge-pdf-files-with-itext.html" rel="nofollow noreferrer">http://java-x.blogspot.com/2006/11/merge...
<p><a href="http://pdfbox.apache.org/" rel="nofollow">PDFBox</a> is by far the easiest way to achieve this, there is a utility called PDFMerger within the code which makes things very easy, all it took me was a for loop and 2 lines of code in it and all done :)</p>
11,571
<p>A poorly-written back-end system we interface with is having trouble with handling the load we're producing. While they fix their load problems, we're trying to reduce any additional load we're generating, one of which is that the back-end system continues to try and service a form submission even if another submiss...
<p>If you've got jQuery handy, attach a click() event that disables the button after the initial submission -</p> <pre><code>$('input[type="submit"]').click(function(event){ event.preventDefault(); this.click(null); }); </code></pre> <p>that sort of thing.</p>
<p>Submit the form with AJAX, and the GIF will animate.</p>
12,343
<p>The current (as of Dec 2008) iPhone SDK allows me to pick between 3 versions when I want to build an app: 2.0, 2.1, 2.2. -- I'll ignore 2.1 below.</p> <p>My assumptions:</p> <ul> <li>2.2 has more API functions available than 2.0,</li> <li>2.2 has fixed bugs since 2.0,</li> <li>2.2 is backward-compatible with 2.0 (...
<p>You can use the iPhone OS 2.2 SDK and still compile for iPhone OS 2.0; the way you do this is the same as for Mac OS X. The <strong>SDK</strong> you use determines the <em>most recent</em> version of the OS you want to <em>use API from</em>, while the <strong>Deployment Target</strong> you use determines the <em>le...
<p>In my testing, if you use 2.0 you can't make use of the application badge functionality - that appears in 2.1 (so you may need to at least use that level)</p> <p>Tim</p>
49,816
<p>I am looking for an addin that will allow me to click a button on the VS toolbar and the following actions should happen.</p> <ol> <li>On the highlighted project/folder/item from either Source Control Explorer or Solution Explorer, do a 'Get Specific Version'</li> <li>Click those 2 checkboxes, hit the 'Get' button ...
<p>I assume that you just want to make sure developers are starting their changes on the most recent version?</p> <p>If that is the case, and you are using VSTS 2008 and TFS 2008, then using the "<a href="http://www.vitalygorn.com/blog/post/2007/12/TFS-Get-Latest-Version-on-Check-Out-in-VS2008.aspx" rel="nofollow nore...
<p>Not the answer to your question, but why do you find you are needing to do a Get Specific all the time? Are you editing or deleting files locally outside of Visual Studio without check-ing the files out first?</p> <p>If you have both of these options checked then you will be downloading all the latest versions of ...
22,815
<p>I used the method</p> <pre><code>$("#dvTheatres a").hover(function (){ $(this).css("text-decoration", "underline"); },function(){ $(this).css("text-decoration", "none"); } ); </code></pre> <p>Is there a more elegant method?(single line)</p>
<p>You might be having issues with other CSS rules overriding the one you want. Even if it is declared last in the file, other declarations might have more importance and hence your will be ignored. eg:</p> <pre><code>#myDiv .myClass a { color: red; } #myDiv a { color: blue; } </code></pre> <p>Because the fir...
<p>Give this a try</p> <pre><code>$('.my-awesome div a').hover().css('text-decoration', 'none'); </code></pre>
31,881
<p>We have a multi threaded java program. Multiple-threads will write to a file, and one thread will read from that file. I am looking for some design ideas. Is synchronization necessary?</p>
<p>I would consider synchronization in this case. Imagine that 2 threads (t1 and t2) open the file at the same time and start writing to it. The changes performed by the first thread are overwrited by the second thread because the second thread is the last to save the changes to the file. When a thread t1 is writing to...
<p>Once multiple Threads access shared data then Synchronization is necessary. If multiple threads write to the same file without some form of locking, then potentially you will end up with a lost update problem.</p> <p>Reading is not as big an issue in all circumstances so you need to consider...if a thread is readin...
38,892
<p>I work in the embedded world, using mainly C and no GUI at all (because there is no display screen).</p> <p>Moving over to the non-embedded world, in which I have nearly no experience, what is the best programming environment (langauge/IDE/etc) for me to build a simple window-form application that will run on all t...
<p>I like <a href="http://www.gtk.org/" rel="nofollow noreferrer">GTK+</a> personally but that or any of the ones you mentioned should be OK. I don't know which is the best in terms of least RAM usage.</p>
<p>I think you should try Html Application.It is something like web page it contain DHTML,java script,ActiveX but it is execute like .exe .</p> <p><strong>Edit:</strong> Sorry for advice you html application.I just know it can run on windows only.</p>
13,828
<p>My Sunhokey Prusa i3 arrived with a corrupted disc. I'm awaiting a new one and finished the mechanical build via YouTube videos. </p> <p>I've no clue which motor controls the X, Y, and Z, axes. I"m not even positive which axis is which. YouTube vids don't show the origin of all the wires/cables/cords they connect. ...
<p>X-axis is right-to-left (Carriage motor)</p> <p>Y-axis is front-to-back (Base/Bed motor)</p> <p>Z-axis is up-and-down (lead screws)</p> <p>There are several videos on YouTube. This <a href="https://www.youtube.com/watch?v=meKht2ObOWw&amp;list=PLEHodQXu836zPQmIkCwLAE2ze_qOxoOvY" rel="nofollow noreferrer">playlist<...
<p>This diagram would appear to show the connections to the controller board. Taken from <a href="https://hackaday.io/page/1569-3d-printer-sunhokey-prusa-i3-2015-review" rel="nofollow noreferrer">3D Printer: Sunhokey prusa i3 2015 review</a></p> <blockquote> <p><a href="https://i.stack.imgur.com/6iKdC.png" rel="nofo...
780
<p>I created a vbscript custom action which checks for some registry keys and alters them if neccessary. In case a key could not be written or something like that, the setup should be aborted.</p> <p>In order to achieve this, I set a property which I tried to use as a condition for the next step within the execute seq...
<p>If you search on <a href="http://community.installshield.com" rel="nofollow noreferrer">http://community.installshield.com</a> you'll find an article by Robert Dickau entitled "Exiting an MSI Installation from a Custom Action". It's at the following link:</p> <p><a href="http://community.installshield.com/showthre...
<p>You should need return 3 from your function for a fail and 0 or 1 for success. </p> <p>Here is a msdn article on the topic : <a href="http://msdn.microsoft.com/en-us/library/aa371254(VS.85).aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/aa371254(VS.85).aspx</a></p> <p>Make sure you put yo...
43,322
<p>I have recently been exposed to naked objects. It looks like a pretty decent framework. However I do not see it in widespread use like say, Spring. So why is this framework not getting any mainstream application credit. What are its shortcomings as you see?</p>
<p>From my experience using NOF 3.0.3...</p> <p>The good:</p> <ul> <li>Automagically generates an DnD UI for your domain objects, like what db4o does for persistence.</li> <li>This is what MVC was always meant to be, according to the MVC pattern creator.</li> <li>The framework only asks your domain objects (POJOs) to...
<ul> <li>widespread use of technology has no strong correlation to technological quality.</li> <li>The nakedobject system is difficult to use in combination with type objects: if I'm selling different kinds of products and need different data for different products, it is difficult to constrain the data on the product ...
20,234
<p>Here we go again, the old argument still arises... </p> <p>Would we better have a business key as a primary key, or would we rather have a surrogate id (i.e. an SQL Server identity) with a unique constraint on the business key field? </p> <p>Please, provide examples or proof to support your theory.</p>
<p>Both. Have your cake and eat it.</p> <p>Remember there is nothing special about a primary key, except that it is labelled as such. It is nothing more than a NOT NULL UNIQUE constraint, and a table can have more than one.</p> <p>If you use a surrogate key, you still want a business key to ensure uniqueness accord...
<p>In the case of point in time database it is best to have combination of surrogate and natural keys. e.g. you need to track a member information for a club. Some attributes of a member never change. e.g Date of Birth but name can change. So create a Member table with a member_id surrogate key and have a column for DO...
8,863
<p>We have an application that works with MS Office and uses Microsoft.mshtml.dll. We use ClickOnce to deploy the application. The application deploys without issues on most machines, but sometimes we get errors saying "System Update Required, Microsoft.mshtl.dll should be in the GAC". </p> <p>We tried installing the ...
<p>Do you know which version of MS Office you are targeting? These PIAs are very specific to the version of Office. I remember when we were building a smart client application, we used to have Build VM machines, each one targeting a specific version of Outlook.</p> <p>Another hurdle was not being able to specify these...
<p>You can <a href="http://msdn.microsoft.com/en-us/library/h4k032e1.aspx" rel="nofollow noreferrer">set up prerequisites in a clickonce app</a>, which would check for specific assemblies in the GAC before allowing users to install. You would still need to manually install an app that includes the required office dll ...
7,838
<p>I’m having an issue where a drop down list in IE 6/7 is behaving as such:</p> <p><img src="https://i488.photobucket.com/albums/rr249/djfloetic/ie7.jpg" alt="alt text"></p> <p>You can see that the drop down <code>width</code> is not wide enough to display the whole text without expanding the overall drop down list....
<p><a href="http://www.dougboude.com/blog/1/2008/05/Viewing-Option-Text-in-IE7-thats-Wider-than-the-Select-List.cfm" rel="nofollow noreferrer">This guy</a> had the same problem as you and he came up with a solution. It is a bit of a hack and depends on how you have your UI setup, but it is an option. I hope it helps.</...
<p>How are you populating the DropDownList. I am using the following code to populate the DropDownList and it adjusts the width according to the largest text displayed: </p> <pre><code>private void BindData() { List&lt;Foo&gt; list = new List&lt;Foo&gt;(); list.Add(new Foo("Hello")); ...
26,127
<p>In my application I have a number of panes from m_wndspliter classes. What I want to do is at run time show and hide one of these panes. Whilst with the following code I can show and hide the view associated with the pane, I can't temporarily remove the pane itself. </p> <pre><code>CWnd * pCurView = m_wndSplitter2....
<p>You need to call CSplitterWnd::DeleteView to do this, which basically means that you have to save your CView elsewhere if you intend to restore it. Usually this is not a problem as all data should be stored in the CDocument rather than CView, but in practice this may not be the case.</p> <p>The way I have handled ...
<p>Only the <code>CExtSplitter</code> class from the CodeProject article <a href="https://www.codeproject.com/Articles/2707/A-Static-Splitter-with-the-Ability-to-Hide-Show-Mu" rel="nofollow noreferrer">https://www.codeproject.com/Articles/2707/A-Static-Splitter-with-the-Ability-to-Hide-Show-Mu</a> worked for me.</p> <p...
25,654
<p>I have a Spring Interceptor which attempts to add an HTTP header in the postHandle() method.</p> <pre><code>public void postHandle(HttpServletRequest req, HttpServletResponse resp, Object obj1, ModelAndView mv) throws Exception { response.setHeader("SomeHeaderSet", "set"); resp...
<p>Well, I figured it out...Kinda...</p> <p>Turns out, same issue with Jetty and Tomcat (figured MAYBE it was a container issue). So...</p> <p>Debugged to ensure that the response object contained the correct header value up until Spring returned back to the container. Result: The HttpServletResponse instance still...
<p>I had a similar problem, it works when I have the following in the web.xml (haven't figured out why)</p> <pre><code>&lt;filter&gt; &lt;filter-name&gt;etagFilter&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.ShallowEtagHeaderFilter&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mappi...
30,632
<p>On IBM DB2 v.9 windows, when someone connect to database by Server\Administrator user DB2 database will automatically accept and grant all the permissions to this user? But, in some case environment Administrator of server does not need to see every data in the database. So how to prevent Administrator use connect t...
<p>On 9.5 and older this would not be possible because the account under which your instance runs is SYSADM. Also Administrator can reset at least local account passwords and gain access to them, making changing the instance owner account useless.</p> <p>However on 9.7 and onwards the instance owner will not have acce...
<p>By default, DB2 databases are created with <code>CONNECT</code> authority granted to public. If you want to restrict some users from connecting, you need to do</p> <pre><code>GRANT CONNECT ON DATABASE TO &lt;user1&gt;, &lt;user2&gt;, ... </code></pre> <p>Then revoke the CONNECT authority from PUBLIC</p> <pre><co...
33,547
<p>What are the most common 3D printing file formats, and which one is more effective or used more than others?</p>
<h1>3D-Model Exchange Files</h1> <p>The <a href="https://all3dp.com/3d-file-format-3d-files-3d-printer-3d-cad-vrml-stl-obj/" rel="nofollow noreferrer">most common file formats</a> to exchange models for 3D printing are STL, OBJ, FBX, COLLADA, 3DS, IGES, STEP, and VRML/X3D.</p> <p>Of these, STL, OBJ, AMF, and 3MF are th...
<p><a href="https://en.wikipedia.org/wiki/STL_(file_format)" rel="nofollow noreferrer">STL</a> is the standard for pretty much everything out there.</p> <p>EDIT: This is for models to be sliced and printed. Gcode is what would actually be executed, after slicing, to create the print.</p>
1,085
<p>We have a discussion going on in my team at the moment, and I'd be interested in other views. Suppose we have a RESTful web service whose role is to annotate documents by applying a variety of analysis algorithms and services. The basic interaction in clear: we have a resource which is the document collection; the ...
<p>I would implement it the following way:</p> <p>1) client requests metadata<br> 2) server returns either actual data (if it's already available) or NotReady marker<br> 3) client asks server when data will be available (this step can be merger with previous)<br> 4) server returns time interval (there might be some h...
<p>"just having GET return whatever is available at the time" makes a ton of sense. Except, when they're polling, you don't want to keep returning stuff they already know. The answers get longer each time they poll.</p> <p>You need them to provide you with their "what I've seen so far" in the GET request. This give...
14,615
<p>I have seen this problem arise in many different circumstances and would like to get the best practices for fixing / debugging it on StackOverflow.</p> <p>To use a real world example this occurred to me this morning:</p> <pre><code>expected announcement.rb to define Announcement </code></pre> <p>The class worked ...
<p>That is a tricky one. </p> <p>What generally works for me is to run "script/console production" on the production server, and type in:</p> <p><code>Announcement</code></p> <p>That will usually give you a better error message. But you said you already tried that?</p>
<p>in my case, I am getting this error in the development console but I can load the class in irb</p>
11,950
<p>I want to float a div to the right at the top of my page. It contains a 50px square image, but currently it impacts on the layout of the top 50px on the page.</p> <p>Currently its:</p> <pre><code>&lt;div style="float: right;"&gt; ... &lt;/div&gt; </code></pre> <p>I tried z-index as I thought that would be the a...
<p>What do you mean by impacts? Content will flow around a float. That's how they work.</p> <p>If you want it to appear above your design, try setting:</p> <pre><code>z-index: 10; position: absolute; right: 0; top: 0; </code></pre>
<p>Try setting its <code>position</code> to absolute. That takes it out of the flow of the document.</p>
39,743
<p>In the 'DBUtility' project of Petshop 4.0,the abstract class SqlHelper has a method 'GetCachedParameters':</p> <pre><code> public static SqlParameter[] GetCachedParameters(string cacheKey) { SqlParameter[] cachedParms = (SqlParameter[])parmCache[cacheKey]; if (cachedParms == null) ...
<p>If cachedParms were returned directly, the caller could then change the elements of the array. The contents of the cache would then be effectively corrupted - the next caller to fetch the parameters from the cache with the same cache key would get unexpected results.</p> <p>EDIT: Cloning the array itself prevents t...
<p>To add to what Jon Skeet said, if the return'd Cache'd values are used internally for then you don't want the user to be using values which could change without them being aware.</p>
21,431
<p><a href="https://i.stack.imgur.com/tcLgq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tcLgq.jpg" alt="damage" /></a></p> <p><a href="https://i.stack.imgur.com/Hyr7P.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hyr7P.jpg" alt="damage" /></a></p> <p>Just got an Ender 3 a wee...
<h1>Your print surface is destroyed</h1> <p>So, you managed to rip off your print surface in the center. Happened to me too. the corners of my scraper were too sharp, cutting the surface. Another time I did pierce the surface with my nozzle. Damage happens. Replacement surfaces for the Ender3 start at about 5 bucks a p...
<p>PETG sticks to the bed much easier than PLA or ABS. I've found it harder to release from the bed. Note this reference indicates PETG can cause bed damage.</p> <p><a href="https://www.matterhackers.com/news/how-to-succeed-when-printing-with-petg-filament#:%7E:text=Other%20Print%20Bed%20Surfaces&amp;text=It%27s%20no...
1,692
<p>I wanted to make Map of Collections in Java, so I can make something like </p> <pre><code>public void add(K key, V value) { if (containsKey(key)) { get(key).add(value); } else { Collection c = new Collection(); c.add(value); put(key, value); } } </code></pre> <p>I've ...
<p>If <code>map</code> is a <code>Map&lt;K, Collection&lt;V&gt;&gt;</code>, use the idiom <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Map.html#computeIfAbsent-K-java.util.function.Function-" rel="noreferrer"><code>computeIfAbsent(...).add(...)</code>,</a> like this:</p> <pre><code>map.computeIfAbsent(k...
<p>There is a problem with your code:</p> <p>Collection c = new Collection();</p> <p>Cannot be instantiated.</p> <p>I think the next piece of code will solve your problem:</p> <pre><code>public class CollectionMap&lt;K, V&gt; extends HashMap&lt;K, Collection&lt;V&gt;&gt; { ... ... ... public voi...
31,729
<p>Testing my new Wanhao i3+. PLA plastic(Wanhao), basic normal quality settings in Cura (I guess 0.1 mm layer, 40 mm/s speed, 60c bed temp, 200c extruder temp). After 1.5 hours of printing quality degraded, it makes some loose structure. </p> <p>Edit: After finish I noticed that problem exists only in layers where it...
<p><strong>It definitely looks like under extrusion.</strong> </p> <ol> <li>First thing I would check is the filament feeder to make sure it has a good grip in the filament.</li> <li>After that I would do another print to see if the problem is repeatable.</li> </ol> <p>If it doesn't repeat, it may have been </p> <u...
<p><strong>It definitely looks like under extrusion.</strong> </p> <ol> <li>First thing I would check is the filament feeder to make sure it has a good grip in the filament.</li> <li>After that I would do another print to see if the problem is repeatable.</li> </ol> <p>If it doesn't repeat, it may have been </p> <u...
649
<p>I have a Java application that monitors a folder for incoming XML files. When a new file is detected I need to test the file that it is not currently being updated and is closed. My thought is to use <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#canWrite()" rel="noreferrer">File.canWrite()</a>...
<p>No, canWrite is not suitable for this purpose. In general the file will be writable even if another process is writing.</p> <p>You need a higher level protocol to coordinate the locking. If you plan to use this code on a single platform, you may be able to use <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/n...
<p>If you control both the reader and writer, then a potential locking technique would be to create a lock <strong>directory</strong> -- which is typically an atomic operation -- for the read and the write process duration. If you take this type of approach, you have to manage the potential failure of a process resulti...
14,874
<p>Problem with dynamic controls</p> <p>Hello all,</p> <p>I'm wanting to create some dynamic controls, and have them persist their viewstate across page loads. Easy enough, right? All I have to do is re-create the controls upon each page load, using the same IDs. HOWEVER, here's the catch - in my PreRender event, ...
<p>ViewState-backed properties are only persisted to ViewState if the control is currently tracking ViewState. This is by design to keep ViewState as small as possible: it should only contain data that is truly dynamic. The upshot of this is that:</p> <p>ViewState propeties set during the Init event are <em>not</em>...
<p>Thank you for your help, but I tried that and it didn't make a difference. Besides, OnLoad works just as well for dynamic controls as OnInit, as long as you give your controls the same IDs every time.</p>
23,875
<p>I'm just looking for different opinions. Do you consider OpenID a good "Single Sign On" solution?</p> <p>The way it works seems to be a little bit confusing for an average user and there could be problems related to "putting all your eggs in the same basket".</p> <p>Anyway, have anyone tried to implement his own O...
<p>Also, SSO (as you mentioned) usually implies that I only have to login once (presumably to my workstation) and then from there on, I don't need to sign-in anywhere.</p> <p>OpenID of course doesn't solve that problem. For example, if I use OpenID to sign in to StackOverflow, it doesn't mean I don't need to sign in t...
<p>Actually, in the case of StackOverflow, a separate account would have saved me a lot of trouble. I decided to use my WordPress.com OpenID, since that's where I'm hosting my blog, but it turned out that WordPress.com have serious problems with their OpenID service, and most of the time I am not able to log on to Stac...
4,206
<p>Safari on iPhone automatically creates links for strings of digits that appear to the telephone numbers. I am writing a web page containing an IP address, and Safari is turning that into a phone number link. Is it possible to disable this behavior for a whole page or an element on a page?</p>
<p>This seems to be the right thing to do, according to the <a href="https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Introduction.html" rel="noreferrer">Safari HTML Reference</a>:</p> <pre><code>&lt;meta name="format-detection" content="telephone=no"&gt; </code></pre...
<p>Break the number down into separate blocks of text</p> <pre><code>301 &lt;div style="display:inline-block"&gt;441&lt;/div&gt; 3909 </code></pre>
27,956
<p>Can you recommend any tool to migrate sources (with history) from TFS to SVN?</p>
<p>Have you looked at <a href="http://sourceforge.net/projects/tfs2svn/" rel="noreferrer">tfs2svn</a>?</p> <blockquote> <p>tfs2svn is a Windows application that converts a Team Foundation Server (TFS) repository into a Subversion (SVN) repository, preserving the history, branches, and commit information.</...
<p>We are migrating TFS 2010 collections into svn. To make it work for us I needed to download and modify the source of TFS2SVN so that it understood the collections we had made. </p> <p>At the moment I just hard coded the values because we are only going to use this twice. We modified tfs2svn\trunk\Colyar.SourceContr...
48,509
<p>I have an Ender 3 Pro with upgraded Bowden capricorn tube. The tube will move approximately 1-2&nbsp;mm during normal operation, though it will not come out of the coupler at all. I have read that the movement if unchanging (constant movement of 1-2&nbsp;mm) can be compensated for with settings adjustment to avoid r...
<p>The slipping does result in lost retraction distance. It does not result in underextrusion, lost material (except possibly via having insufficient retraction after the reduction), or anything like that.</p> <p>If your retraction is set to 6 mm, but the bowden pulls 2 mm into the coupler when you retract, those firs...
<p>This is happening to my E3 pro. When the Bowden tube slips back filament fills up the gap causing a heat creep issue. This of course causes clogged nozzle. If retracting I have had the swollen filament lodge in the tube to the point I had to remove tube and heat high enough with heat gun to soften filament for a rev...
1,494
<p>Which are the most advanced frameworks and tools there are available for python for practicing Behavior Driven Development? Especially finding similar tools as rspec and mocha for ruby would be great.</p>
<p><a href="http://blog.ianbicking.org/behavior-driven-programming.html" rel="nofollow noreferrer">Ian Bicking</a> recommends using <a href="http://docs.python.org/library/doctest.html?highlight=doctest#module-doctest" rel="nofollow noreferrer">doctest</a> for behavior driven design:</p> <p>I personally tend to use <a...
<p>I am probably completely missing the point, but what I retained of the <a href="http://dannorth.net/introducing-bdd" rel="nofollow noreferrer">original BDD paper</a> was that BDD was just <a href="http://c2.com/cgi/wiki?TestDrivenDevelopment" rel="nofollow noreferrer">TDD</a> repackaged to emphasize some best practi...
28,643
<p>I am thinking about using Microsoft Unity for my Dependency Injection tool in our User Interface.</p> <p>Our Middle Tier already uses Castle Windsor, but I am thinking I should stick with Microsoft.</p> <p>Does anyone have any thoughts about what the best Dependency Injection tool is? </p> <ul> <li><a href="http:...
<p>Having recently spiked the use of 6 of these (<a href="http://www.castleproject.org/" rel="nofollow noreferrer">Windsor</a>, <a href="http://www.codeplex.com/unity" rel="nofollow noreferrer">Unity</a>, <a href="http://www.springframework.net/" rel="nofollow noreferrer">Spring.Net</a>, <a href="http://code.google.com...
<p>Unless you already have experience and a personal preferance for a particular sub-technology utilized by one of the possible IoC container solutions, they all function well and I don't see any one in particular with a "killer function" that makes it stand out from the others. Unity is probably the best fit for solu...
17,944
<p>MSDN says</p> <blockquote> <p>If the function fails, the return value is WAIT_FAILED. To get extended error information, call GetLastError.</p> </blockquote> <p>The code is:</p> <pre><code>HANDLE m_mutex_handle; /**&lt; m_mutex_handle. The handle to the created mutex. */ m_mutex_handle = ::CreateMutex( ...
<p>If you lack the SYNCHRONIZE privilege on the object, then you cannot wait. WAIT_FAILED will be returned.</p>
<p>Closing a handle while the handle is being waited on can also cause undefined behaviour.</p>
25,878
<p>If I am writing a library and I have a function that needs to return a sequence of values, I could do something like:</p> <pre><code>std::vector&lt;int&gt; get_sequence(); </code></pre> <p>However, this requires the library user to use the std::vector&lt;> container rather than allowing them to use whatever contai...
<p>Have get_sequence return a (custom) <code>forward_iterator</code> class that generates the sequence on-demand. (It could also be a more advanced iterator type like <code>bidirectional_iterator</code> if that's practical for your sequence.)</p> <p>Then the user can copy the sequence into whatever container type the...
<p><code>std::list&lt;int&gt;</code> is slightly nicer, IMO. Note that this would not require an extra copy of the data in the list, as it's only pointers being copied.</p> <p>It depends entirely on your consumers. If you can expect them to be C++ developers, give them one of the <code>std</code> container classes, ...
12,293
<p>How do you implement a last-modified column in SQL?</p> <p>I know for a date-created column you can just set the default value to <code>getdate()</code>. For last-modified I have always used triggers, but it seems like there must be a better way.</p> <p>Thanks.</p>
<p>Triggers are the best way, because this logic is intimately associated with the table, and not the application. This is just about the only obvious proper use of a trigger that I can think of, apart from more granular referential integrity.</p> <p>But I think "last-modified" dates are a flawed concept anyway. What ...
<p>Using a trigger to update the last modified column is the way to go. Almost every record in the system at work is stamped with an add and change timestamp and this has helped me quite a bit. Implementing it as a trigger will let you stamp it whenever there is any change, no matter how it was initiated.</p> <p>Ano...
44,403
<p>I've got two models: Message and Attachment. Each attachment is attached to a specific message, using a ForeignKey on the Attachment model. Both models have an auto_now DateTimeField called updated. I'm trying to make it so that when any attachment is saved, it also sets the updated field on the associated message t...
<p>You would also need to then save the message. Then it that should work.</p>
<p>DateTime fields with auto_now are automatically updated upon calling <code>save()</code>, so you do not need to update them manually. Django will do this work for you.</p>
4,131
<p>I'd like to use the newer <code>&lt;button&gt;</code> tag in an ASP.NET website which, among other things, allows CSS-styled text and embedding a graphic inside the button. The asp:Button control renders as <code>&lt;input type="button"&gt;</code>, is there any way to make a preexisting control render to <code>&lt;b...
<p>This is an old question, but for those of us unlucky enough still having to maintain ASP.NET Web Forms applications, I went through this myself while trying to include Bootstrap glyphs inside of built-in button controls.</p> <p>As per Bootstrap documentation, the desired markup is as follows:</p> <pre class="lang-...
<p>I've been struggling all day with this -- my custom <code>&lt;button/&gt;</code> generated control not working:</p> <blockquote> <p>System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client</p> </blockquote> <p>What happens is that .Net adds a <code>name</...
22,706
<p>I'm using Castle ActiveRecord, but this question applies to NHibernate, too, since a solution that works with NHibernate should work for ActiveRecord. Anyway, what I have is an underlying table structure like this:</p> <p>TableA -hasMany-> TableB</p> <p>I have corresponding objects EntityA and EntityB. EntityA h...
<p>Lazy loading is exactly what you want - and it's not a hack either, it's a well tested and baked in part of NHIbernate and an important tool when performance tuning any substantial NHibernate app.</p> <p>If you were to mark your "parent" EntityA as lazy loaded, referring to EntityB.Parent.Id would not load EntityA ...
<p>Just this:</p> <pre><code>[Property] public int ParentId { get; set; } </code></pre> <p>...assuming <code>ParentId</code> is the actual column name.</p> <p>A couple of other comments. </p> <p>First, you should consider lazy loading many-to-one properties anyway. If you eagerly load them, you must be aware of ...
30,633
<h2>Question</h2> <p>What is PLA+? How is it different than PLA? I'm looking for science, composition, formula, safety concerns (or lack thereof), etc.</p> <h2>Background</h2> <p>I picked up a roll of PLA+ at Microcenter (their in-house Inland brand) because it was on clearance. I didn't even notice the "+" until ...
<p>Disclaimer: I am not affiliated with any linked brand or company, I just link to them for reference of the suggested print settings.</p> <h1>What is PLA?</h1> <p>PLA is, by its definition PolyLacticAcid, a polymer of entwined lactic acids. It is commonly made from fermenting starch - not via Type I (alcohol) but Typ...
<p>Adding this as a new answer since it doesn't seem to be covered in existing ones:</p> <p>Despite &quot;PLA+&quot; being a marketing term without a specific definition, I've found that many (most?) filament vendors don't seem to be doing their own secret-sauce blending to make it, and most premium filament vendors wh...
746
<p>I have a collection of unmanaged dlls with a C# wrapper around them that I'm calling from a C# project. I've added a build event line that looks like:</p> <pre><code>mkdir ..\Release mkdir ..\Debug copy ..\..\Includes\*.dll ..\Release\*.dll copy ..\..\Includes\*.dll ..\Debug\*.dll </code></pre> <p>Problem is, whe...
<p>And the answer is: don't publish this, use the windows installer instead, <a href="http://msdn.microsoft.com/en-us/library/e2444w33(VS.80).aspx" rel="nofollow noreferrer">as described here.</a></p>
<p>I'm currently investigating the same issue. The literature on the topic is very sparse indeed!</p> <p>The only solution I can see is to embed the unmanaged DLL as an embedded resource inside the assembly, and programatically extract it out to the executing path before calling any functions.</p>
33,912
<p>I don't understand, why does the following regular expression:</p> <pre><code>^*$ </code></pre> <p>Match the string "127.0.0.1"? Using <code>Regex.IsMatch("127.0.0.1", "^*$");</code></p> <p>Using Expresso, it does not match, which is also what I would expect. Using the expression <code>^.*$</code> does match the ...
<p>Well, theoretically you are right, it should not match. But this depends on how the implementation works internally. Most regex impl. will take your regex and strip ^ from the front (taking note that it must match from start of the string) and strip $ from the end (noting that it must to the end of the string), what...
<p>Using <a href="http://www.sellsbrothers.com/tools/#regexd" rel="nofollow noreferrer">RegexDesigner</a>, I can see it's matching on a 'null' token after '127.0.0.1'. Seems that because you haven't specified a token and the plus matches zero or more times, it matches on the 'null' token.</p> <p>The following regex sh...
27,308
<p>There's a lot of people today who sell unittesting as bread-and-butter of development. That might even work for strongly algorithmically-oriented routines. However, how would you unit-test, for example, a memory allocator (think malloc()/realloc()/free()). It's not hard to produce a working (but absolutely useless...
<p>Highly testable code tends to be structured differently than other code.</p> <p>You describe several tasks that you want an allocator to do:</p> <ul> <li>coalescing free blocks</li> <li>reusing free blocks on next allocations</li> <li>returning excess free memory to the system</li> <li>asserting that the allocatio...
<p>Personally I find most of the unit tests like someone else's desire rather than mine. I think that any unit test should be written just like a normal program except the fact that it doesn't do anything other than testing a library/algorithm or any part of code.</p> <p>My unit tests usually don't use tools like <a h...
14,524
<p>Lately I noticed that there is a new type of nozzles (called airbrush nozzles?!?) available; typically found on those online overseas vendor sites. The nozzles are advertised for usage in E3D hardware, but are not found amongst the <a href="https://e3d-online.com/nozzles-for-3d-printer" rel="noreferrer">E3D genuine ...
<p>An obvious drawback is the lack of a flat surface around the opening, resulting in a severe limitation of the extrusion width to exactly the nozzle width (plus some percent). This nozzle cannot efficiently push the filament against the nearby perimeters because it cannot constrain its height and it cannot flatten th...
<p>They are used for nonplaner 3d printing.</p> <p><div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/gmePlcU0TRw?start=0"></iframe> </div></div></p> <p><a href="https://all3dp.com/4/nonplanar-3d-printing-gives-the-smoothest-top-layer...
1,577
<p>Our team (5-10 developers) plans to <strong>adopt Subversion</strong> for our .NET (Visual Studio) projects/solutions (VisualSVN Server, TortoiseSVN / VisualSVN).</p> <p>What is the best way to <strong>organize a new repository tree</strong>? Is it okay to use <em>one big repository</em> or is it better to create ...
<p>Generally, you want to use a separate repository in any case where you are expecting different access permissions (i.e. some developers should have commit access to one project, but not another, or one project has a public read-only anonymous interface but another doesn't).</p> <p>You want everything in one reposit...
<p>I am using one repository and many projects as below:</p> <pre><code>Projects Project Name trunk branches tags </code></pre> <p>My only concern is the backup and restore. The SVN backup is done at the repository level, so the restore will restore all projects instead of just one.</p> <p>Jiron...
20,167
<p>I want to create a trigger to check what is being deleted against business rules and then cancel the deletion if needed. Any ideas?</p> <p>The solution used the Instead of Delete trigger. The Rollback tran stopped the delete. I was afraid that I would have a cascade issue when I did the delete but that didn't seem ...
<p>Use an <code>INSTEAD OF DELETE</code> (see <a href="http://msdn.microsoft.com/en-us/library/ms191208.aspx" rel="noreferrer">MSDN</a>) trigger and decide within the trigger what you really want to do.</p>
<p>The trigger can roll back the current transaction, which will have the effect of cancelling the deletion. As the poster above also states, you can also use an instead of trigger.</p>
30,572
<p>How, under Windows and Linux, given a thread handle can I determine the beginning and end of its corresponding static thread local storage block?</p>
<p>You can find this information in the <a href="http://en.wikipedia.org/wiki/Win32_Thread_Information_Block" rel="nofollow noreferrer">Thread Information Block</a>. Please note, however, that doing so is accessing undocumented structures and is thus <strong>highly non-portable and likely to break in future version of...
<p>See <a href="http://msdn.microsoft.com/en-us/library/6yh4a9k1(VS.80).aspx" rel="nofollow noreferrer">MSDN</a> for more info about the various thread-local storage-related functions. You can use <a href="http://msdn.microsoft.com/en-us/library/ms686812(VS.85).aspx" rel="nofollow noreferrer">TlsGetValue()</a> to get ...
44,873
<p>how is it advisable to control the cpu utilization during run time ?</p> <p>poll the cpu load and insert sleeps ?</p>
<p>I'd recommend OS functionality. There are performance counters and WinAPI functions for this on Windows.</p> <p>Here is an example using <strong>performance counters</strong> from <a href="http://blogs.msdn.com/bclteam/archive/2006/06/06/619284.aspx" rel="nofollow noreferrer">BCL Team Blog</a>:</p> <pre><code>fore...
<p>The easiest way would be to modify your main loop to either wait on input - the classic event driven model - or to periodically sleep for a short period of time.</p> <p>If putting the application to sleep I would only use a very short timeout, somewhere within 10-100ms range as any more and some user input would be...
32,643
<p>My application is developped in C++ using Qt and is using signals and slots.</p> <p>Let's say I have the following classes (pseudo-C++ code) :</p> <pre><code>class Ball { Color m_Color; int m_Size; }; class Player { public: setBall(Ball* pBall) { if (pBall != m_pBall) { ...
<blockquote> <p>Ball will be deleted if not used anymore by other players</p> </blockquote> <p>As i can see - it<code>s the source of your doubts. Certainly undo() command shouldn't recreate an object nor have it</code>s own deleting mechanism. How does your GeneralHandler.isNotUsedAnymore() work? If it counts ref...
<ol> <li>Save ball in command's constructor.</li> <li>Put it in/out when needed.</li> <li>Use QSharedPointer for ball everywhere to prevent memory leaks.</li> </ol>
45,942
<p>For example:</p> <pre><code>root.Nodes.Add(new TNode() { Foo1 = bar1, Foo2 = bar2, Foo3 = bar3 }); </code></pre> <p>or:</p> <pre><code>root.Nodes.Add(new TNode() { Foo1 = bar1, Foo2 = bar2, Foo3 = bar3 }); </code></pre>
<p>I've done it both ways.. IMO it depends on the complexity of the initialization.</p> <p>If it is simple 2 or 3 properties I will initialize on one line generally, but if i'm setting up an object with values for insertion into a database or something that has alot of properties i'll break it out like your second exa...
<p>For longer stuff I do it this way:</p> <pre><code>root.Nodes.Add(new TNode() { Foo1 = bar1, Foo2 = bar2, Foo3 = bar3 }); </code></pre>
13,700
<p>Say I have a git repository and I've been working on master, can I retroactively create a branch. For example:</p> <p>A - B - C - A1 - D - A2 - E</p> <p>I want to make it look like this:</p> <pre><code>A - A1 - A2 \ \ B - C - D - E </code></pre> <p>The specific use case is when I've cherry-picke...
<p>If you want all the commits after revision XXX to have happened in a branch, I find this a lot easier than the other proposed methods.</p> <pre><code>$ git branch fixes # copies master to new branch $ git reset --hard XXX # resets master to XXX </code></pre> <p>The commits are now only in the &quot;fixes&quo...
<p>What you want to do is to actually <strong>rewrite</strong> history. The identifiers of commits would change, and in some cases the changeset given by commits would change. So if there is a chance that somebody could have based work on old version of the branch you want to change, better to not do this. But if you d...
47,632
<p>I've seen several responses to questions asking for IDEs where text editors were suggested and vice-versa. That makes me think that people treat them as the same thing, where I draw clear distinctions.</p> <ol> <li>How do you define "text editor" and "IDE"?</li> <li>Do you see a difference between the two tools?</l...
<p>I use both and I suggest you do too. Sometimes an IDE can make development faster - like code completion and refactoring support. Fast find of files and symbols, functions, classes in project not to mention project management features. Sometimes they'll manage the build for you. Maybe it has a built in debugger (a g...
<p>If you look at <a href="http://kate-editor.org/" rel="nofollow noreferrer">Kate</a>, the text editor and <a href="http://www.kdevelop.org" rel="nofollow noreferrer">Kdevelop</a>, the IDE the main difference is that Kdevelop supports project management (CVS/Subversion) and build scripts, whereas Kate does not.</p>
24,285
<p>I have an html file with an unordered list. I want to show the list items horizontally but still keep the bullets. No matter what I try, whenever I set the style to inline to meet the horizontal requirement I can't get the bullets to display.</p>
<p>The best option I saw in other answers was to use <code>float:left;</code>. Unfortunately, it doesn't work in IE7 which is a requirement here<sup>*</sup> &mdash; you still lose the bullet. I'm not really keen on using a background image either.</p> <p>What I'm gonna do instead (that no one else suggested, hence the...
<p>You can use following code</p> <pre class="lang-css prettyprint-override"><code>li { background-image: url(img.gif) no-repeat center left; padding-left: 20px; display: inline; } </code></pre>
5,463
<p>I have a ASP.NET 1.1 application, and I'm trying to find out why when I change a ComboBox which value is used to fill another one (parent-child relation), two postbacks are produced.</p> <p>I have checked and checked the code, and I can't find the cause.</p> <p>Here are both call stacks which end in a page_load</p...
<p>It's a very specific problem with this code, I doubt it will be useful for someone else, but here it goes:</p> <p>A check was added to the combo's <code>onchange</code> with an if, if the condition was met, an explicit call to the postback function was made. If the combo was set to <code>AutoPostback</code>, asp.ne...
<p>First thing I would look for is that you don't have the second ComboBox's AutoPostBack property set to true. If you change the value in the second combo with that property set true, I believe it will generate a postback on that control.</p>
4,070
<p>I'm setting up some Virtual PC images. I want to customize the machine with some pre-installed tools and then use this as a base for creating new machines.</p> <p>What's the best practice for prepping the machine for use? </p> <p>Should I use SysPrep or NewSid? When's the appropriate time for use and the contra...
<p>Sysprep includes the functionality of NewSID. It 'preps' the WIndows installation for imaging by stripping machine-specific things like the Machine name and SID from the installation. If you were not using Sysprep, you definitely would need to run a program like NewSID on each PC after deployment of the image.</p>...
<p>NewSid seems to have some issues. I am aware that with Windows Sharepoint Services 3.0 and with technologies that built on them (Sharepoint Server 2007, Project Server 2007), you can run into issues outlined here:</p> <p><a href="http://forum.sysinternals.com/forum_posts.asp?TID=6260" rel="nofollow noreferrer">NewS...
39,350
<p>Will users who do not have admin rights on their computers be able to upgrade to new Flash player version by themselves?</p> <p>This would be interesting to know for: Windows 98 Windows XP/2000/Vista Macs Unix/Linux</p>
<p>Take a look at <a href="http://www.adobe.com/products/flashplayer/productinfo/instructions/" rel="nofollow noreferrer">the Adobe instructions</a> for more clarification...</p> <p>I know on Linux, at least, you do not need admin privs. Flash is installed in <code>~/.mozilla/plugins</code> when you use the <code>.tar...
<p><strong>For Windows:</strong> yes you need admin rights for the system to install flash player. which installs through an exe file</p>
22,578
<p>I have two questions :</p> <ol> <li><p>While doing source level debugging (using any debugger) does any debugger save state of some iteration/for-loop/any code executed and allow the user to go back to that previously executed code/data state at a later point of time during debugging? The need for this is some vari...
<p>It sounds an awful lot like you will want to grab a copy of Visual Studio 2010.</p> <p>They are implementing almost exactly what you're describing in #1 - there is a screencast about the new "The Historical Debugger" in Visual Studio Team System 2010 on <a href="http://channel9.msdn.com/posts/VisualStudio/Historica...
<p>I believe the latest version of OCaml has this. This seems like quite a new fad, but IIRC this is on the wishlist of the future version of Visual Studio.</p> <p>A feature in VS I have not used, can track objects (make object id or something).</p>
27,347
<p>I have a Python script that needs to execute an external program, but for some reason fails.</p> <p>If I have the following script:</p> <pre><code>import os; os.system("C:\\Temp\\a b c\\Notepad.exe"); raw_input(); </code></pre> <p>Then it fails with the following error:</p> <blockquote> <p>'C:\Temp\a' is not r...
<p><a href="http://docs.python.org/2/library/subprocess.html#using-the-subprocess-module" rel="noreferrer"><code>subprocess.call</code></a> will avoid problems with having to deal with quoting conventions of various shells. It accepts a list, rather than a string, so arguments are more easily delimited. i.e.</p> <pre>...
<p>Suppose we want to run your Django web server (in Linux) that there is space between your path (path=<code>'/home/&lt;you&gt;/&lt;first-path-section&gt; &lt;second-path-section&gt;'</code>), so do the following:</p> <pre><code>import subprocess args = ['{}/manage.py'.format('/home/&lt;you&gt;/&lt;first-path-sectio...
24,958
<p>I am working with an SVN repository with many projects. I need to move a few of the projects out of that repository into individual repositories, one for each project, keeping the history.</p> <p>I've been able to use <code>svnadmin dump</code> to dump the entire repository and <code>svnadmin load</code> it into an...
<p>You can use the <a href="http://svnbook.red-bean.com/en/1.8/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svndumpfilter" rel="noreferrer">svndumpfilter</a> utility to do this. The SVN book has a <a href="http://svnbook.red-bean.com/en/1.8/svn.reposadmin.maint.html#svn.reposadmin.maint.filtering" rel="noreferrer"...
<p>Just an small addition to @Avi answer and @Kit comment.</p> <p>If you use <code>svndumpfilter</code>, you may lose a commit that is necessary for loading the repository (<a href="http://www.celticwolf.com/blog/2010/05/03/subversion-svnadmin-load-error-file-not-found-transaction-0-1-path/comment-page-1/" rel="nofoll...
43,726
<p>Simply put, MVC is the pattern for separating contents (model) from presentation (view), and having a mechanism in place (controller) defining how to gather both.</p> <p>If you already see where I am going at, I am very interested to hear your opinion on the matter. Of course, MVC applies to serverside mechanics and...
<p>I would agree, although one can argue about the controller.</p> <p>Jeff illustrates that <a href="http://www.codinghorror.com/blog/archives/001112.html" rel="nofollow noreferrer">point in his post</a>, with <a href="http://www.csszengarden.com/" rel="nofollow noreferrer">ZenGarden</a></p> <p>With:</p> <ul> <li>Mo...
<p>CSS is definietely not the view. Rather the rendering by the browser (which combines HTML/DOM and CSS input into a 2d layout) is the view. The HTML/DOM is the model. The controller is halfway built into the browser UI, but can be extended with javascript.</p> <p>It is true that CSS is considered the <em>presentatio...
33,609
<p>I know how to disable <a href="https://stackoverflow.com/questions/303488/in-php-how-can-you-clear-a-wsdl-cache">WSDL-cache</a> in PHP, but what about force a re-caching of the WSDL? </p> <p>This is what i tried: I run my code with caching set to disabled, and the new methods showed up as espected. Then I activated...
<p>I guess when you disable caching it will also stop writing to the cache. So when you re-enable the cache the old cached copy will still be there and valid. You could try (with caching enabled)</p> <pre><code>ini_set('soap.wsdl_cache_ttl', 1); </code></pre> <p>I put in a time-to-live of one second in because I thin...
<p>I'd try </p> <pre><code>$limit = ini_get('soap.wsdl_cache_limit'); ini_set('soap.wsdl_cache_limit', 0); ini_set('soap.wsdl_cache_limit', $limit); </code></pre> <p>Or possibly set <code>soap.wsdl_cache_ttl</code> to 0 and back</p>
41,886
<p>i made another post</p> <p><a href="https://stackoverflow.com/questions/326885/a-loop-to-create-neighbor-nodes-in-3d-space">here</a> where I asked how to create the 26 neighbors of a cubic-voxel-node in 3-d space. I got a very good answer and implemented it. </p> <p>To that I added some MIN MAX Position checking.<...
<p>First, get rid of the if statements. There's no need for them. You can merge them into the loop condition. Second, avoid recomputing the loop condition every iteration. Yes, the compiler may optimize it away, but it's generally very conservative with floating-point optimizations (and it may treat fp values read from...
<p>I haven't tried to figure it out, but you may be able to do some nifty things with SSE2/Altivec/other vector instructions to do multiple compares at once.</p>
42,446
<p>I have PDF documents from a scanner. This PDF contain forms filled out and signed by staff for a days work. I want to place a bar code or standard area for OCR text on every form type so the batch scan can be programatically broken apart into separate PDF document based on form type. </p> <p>I would like to do th...
<p>Not a free or open source option, but you might also look at <a href="http://www.webgoo.com/abcpdf-1.htm" rel="nofollow noreferrer">ABCPdf by webSuperGoo</a> as another alternative to Adobe.</p>
<p>check out the <a href="http://www.pixel-technology.com/freeware/tessnet2/" rel="nofollow noreferrer">Tesseract .NET wrapper (v 2.04.0)</a> around the c++ ocr engine by the same name developed by hp in the late 90's, it won awards for its ingenuity</p>
43,877
<p>Got into a situation where in a schema i have a table, say table ACTION , while i got a synonym called ACTION as well which refers to another table to another schema.</p> <p>Now, when i run the query</p> <p>select * from ACTION</p> <p>it will select the records from the table, but not the synonym.</p> <p>Anyway ...
<p>I don't think that your ACTION synonym resides in the same schema as your ACTION table, as that isn't allowed in Oracle. Most likely your ACTION synonym resides in other schema, perhaps it's a PUBLIC synonym. If that's the case you can use </p> <pre><code>select * from ACTION union select * from public.ACTION </co...
<p>Tables and private synonyms do indeed share the same name space, so that is a public synonym: <a href="http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements008.htm#sthref723" rel="nofollow noreferrer">http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements008.htm#sthref723</...
34,219
<p>I can get rootmenuitemlefthtml and rootmenuitemrighthtml to emit but not separator. Tried CDATA wrapping and setting SeparatorCssClass. I just want pipes between root menu items.</p> <pre><code>&lt;dnn:SOLPARTMENU runat="server" id="dnnSOLPARTMENU" Separator="&lt;![CDATA[|]]&gt;" SeparatorCssClass="MainMenu_Separat...
<p>While not a direct answer - you might want to shift to the DotNetNuke menu rather than using SolPart. SolPart is no longer officially supported and development work on this menu ceased almost two years ago. Jon Henning, the author of SolPart, wrote the DotNetNuke menu from the ground up and tried to address many o...
<p>Check this for Solpartmenu:</p> <pre><code>&lt;dnn:SOLPARTMENU runat="server" ID="dnnHorizontalSolpart" ProviderName="SolpartMenuNavigationProvider" ClearDefaults="True" MenuBarCssClass="Hmain_dnnmenu_bar" MenuContainerCssClass="Hmain_dnnmenu_container" MenuItemCssClass="Hmain_dnnmenu_rootitem" MenuItemSelC...
18,749
<p>I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item at the bottom.</p> <p>So I need a <code>tail()</code> method that can read <code>n</code> lines from the bottom and support an offset. Thi...
<p>Assumes a unix-like system on Python 2 you can do:</p> <pre><code>import os def tail(f, n, offset=0): stdin,stdout = os.popen2("tail -n "+n+offset+" "+f) stdin.close() lines = stdout.readlines(); stdout.close() return lines[:,-offset] </code></pre> <p>For python 3 you may do:</p> <pre><code>import subproc...
<p>On second thought, this is probably just as fast as anything here.</p> <pre><code>def tail( f, window=20 ): lines= ['']*window count= 0 for l in f: lines[count%window]= l count += 1 print lines[count%window:], lines[:count%window] </code></pre> <p>It's a lot simpler. And it does se...
16,481
<p>I am trying to run my Django sites with mod_wsgi instead of mod_python (RHEL 5). I tried this with all my sites, but get the same problem. I configured it the standard way everyone recommends, but requests to the site simply time out.</p> <p>Apache conf:</p> <pre><code>&lt;VirtualHost 74.54.144.34&gt; Document...
<p>The problem is that mod_python doesn't go well together with mod_wsgi. I got into similar issue few weeks ago and everything started working for me shortly after I commented out mod_python inclusion.</p> <p>Try to search <a href="http://modwsgi.org" rel="nofollow noreferrer">modwsgi.org</a> wiki for "mod_python", I...
<p><a href="http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango" rel="nofollow noreferrer">Here</a> is very detailed description on how to integrate django with mod_wsgi.</p>
38,877
<p>When copying large files using <code>shutil.copy()</code>, you get no indication of how the operation is progressing..</p> <p>I have put together something that works - it uses a simple ProgressBar class (which simple returns a simple ASCII progress bar, as a string), and a loop of <code>open().read()</code> and <c...
<p>Two things:</p> <ul> <li>I would make the default block size a <em>lot</em> larger than 512. I would start with 16384 and perhaps more.</li> <li>For modularity, it might be better to have the <code>copy_with_prog</code> function not output the progress bar itself, but call a callback function so the caller can deci...
<p>If you want an overall progress, you can use something like this (made for another script). Note that in this case, the 'threading.Thread' that calls the progress bar was placed outside the 'for' loop. Also, the measures need be taken in a different way. This is the third example (non utf-8) from the gif image in th...
34,581
<p>Currently I have to uninstall the old version of my service before I install the new version. I am pretty sure this has something to do with it not being smart enough to update or remove the old service entries before adding the new ones.</p> <p>Is there a way to have the installer skip registering the service if it...
<p>I've done this with WiX, which generates .MSI files using the ServiceInstall &amp; SeviceControl commands:</p> <pre><code>&lt;Component Id='c_WSService' Guid='*'&gt; &lt;File Id='f_WSService' Name='WSService.exe' Vital='yes' Source='..\wssvr\release\wsservice.exe' KeyPath="yes" /&gt; &lt;ServiceInstall Id='...
<p>You can make separate DLL which service would load and call every time it does its work. Make sure that service unloads DLL after use.</p> <p>Use should load it into separate Application Domain.</p> <p><a href="http://msdn.microsoft.com/en-us/library/c5b8a8f9.aspx" rel="nofollow noreferrer">SO http://msdn.microsof...
42,507
<p>i want to get an ending html tag like <code>&lt;/EM&gt;</code> only if somewhere before it i.e. before any previous tags or text there is no starting <code>&lt;EM&gt;</code> tag my sample string is </p> <pre><code>ddd d&lt;STRONG&gt;dfdsdsd dsdsddd&lt;EM&gt;ss&lt;/EM&gt;r and&lt;/EM&gt;and strong&lt;/STRONG&gt; </c...
<p>I am not sure regex is best suited for this kind of task, since tags can always be nested.</p> <p>Anyhow, a C# regex like:</p> <pre><code>(?&lt;!&lt;EM&gt;[^&lt;]+)&lt;/EM&gt; </code></pre> <p>would only bring the second <code>&lt;/EM&gt;</code> tag</p> <p>Note that:</p> <ul> <li><code>?!</code> is a negative l...
<p>You need a <a href="http://en.wikipedia.org/wiki/Pushdown_automaton" rel="nofollow noreferrer">pushdown automaton</a> here. Regular expressions aren't powerful enough to capture this concept, since they are equivalent to <a href="http://en.wikipedia.org/wiki/Finite_state_automaton" rel="nofollow noreferrer">finite-s...
43,193
<p>I have an ARM kit beside me and a Linux kernel source code patched with Xenomai on my machine. I understand I can send data to the kit through an USB cable and a (windows-based, of course) software, but I'm stumped as to exactly <em>what</em> I should be sending that would make the kit run Linux.</p> <p>(clarificat...
<p>In short ... no. See this question on <a href="https://stackoverflow.com/questions/168396/capturing-method-state-using-reflection#168421">capturing method state</a> for some reasons.</p>
<p>The built in framework ArgumentOutOfRangeException (which you should throw in a method if the incoming parameters are... out of range... has private field and public property for the method parameter that caused the error... When you create this exception, you pass the parameter value in the ctor... </p> <pre><co...
39,846
<p>How do you detect the number of physical processors/cores in .net?</p>
<pre><code>System.Environment.ProcessorCount </code></pre> <p>returns the number of logical processors</p> <blockquote> <p><a href="http://msdn.microsoft.com/en-us/library/system.environment.processorcount.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/system.environment.processorcount.aspx...
<p>Don't have enough rep for the wiki, but note that in addition to XPSP2, Windows 2003 Server SP1 and SP2 also need a hotfix to enable this functionality:</p> <p><a href="http://support.microsoft.com/kb/932370" rel="nofollow noreferrer">http://support.microsoft.com/kb/932370</a></p>
22,858
<p>How do I programmatically force an onchange event on an input?</p> <p>I've tried something like this:</p> <pre><code>var code = ele.getAttribute('onchange'); eval(code); </code></pre> <p>But my end goal is to fire any listener functions, and that doesn't seem to work. Neither does just updating the 'value' attri...
<p>Create an <code>Event</code> object and pass it to the <code>dispatchEvent</code> method of the element:</p> <pre><code>var element = document.getElementById('just_an_example'); var event = new Event('change'); element.dispatchEvent(event); </code></pre> <p>This will trigger event listeners regardless of whether the...
<p>if you're using jQuery you would have:</p> <pre><code>$('#elementId').change(function() { alert('Do Stuff'); }); </code></pre> <p>or MS AJAX:</p> <pre><code>$addHandler($get('elementId'), 'change', function(){ alert('Do Stuff'); }); </code></pre> <p>Or in the raw HTML of the element:</p> <pre><code>&lt;input ty...
16,532
<p>Is it a bad idea to use exception chaining when throwing RemoteExceptions? We have an RMI server that does something like this:</p> <pre><code>public Object doSomething() throws RemoteException { try { return getData(); } catch (CustomException ex) { throw new RemoteException(ex...
<p>Rather than wrapping CustomException in RemoteException, you might modify your remote interface like this:</p> <pre><code>interface Foo extends Remote { Object doSomething() throws CustomException, RemoteException; } </code></pre> <p>The principle here is that only the RMI runtime should be raising RemoteExcep...
<p>We capture the message + entire stack trace from the source exception and passed that on as the remote exception's contents. That way you get all of the stack details, but you don't have to worry about any of ANY of the internal exceptions being non serializable.</p> <p>You never know what other objects might be i...
45,717
<p>So basically I am looking for good templates for writing both technical and functional specs on a project or work request.</p> <p>What do you use? How deep do you get while writing the specs? Any additional general tips you could provide would be appreciated.</p> <p>My company needs these badly. I work for a contr...
<p>On general tips;</p> <p>We are implementing a process of </p> <p>1) Business Requirements Statement (BRS)</p> <p>2) Functional Specification</p> <p>3) Technical specification</p> <p>The BRS covers what the business problems are, and what the requirements are around solutions, testing, security, reliability and ...
<p>Start off simple, and work your way from there. Since this is your first experience working with this, use a word document with bullet points. Write it, re-read it and provide enough detail that it makes sense. For technical specifications, you may want to lead the developer toward a solution, but for functional ...
7,552
<p>I want to allow users to paste <code>&lt;embed&gt;</code> and <code>&lt;object&gt;</code> HTML fragments (video players) via an HTML form. The server-side code is PHP. How can I protect against malicious pasted code, JavaScript, etc? I could parse the pasted code, but I'm not sure I could account for all variations....
<p>I'm not really sure what parameters <code>EMBED</code> and <code>OBJECT</code> take as I've never really dealt with putting media on a page (which is actually kind of shocking to think about) but I would take a BB Code approach to it and do something like <code>[embed url="http://www.whatever.com/myvideo.whatever" ....
<p>Here's an example of pasted code from blip.tv:</p> <pre><code>&lt;embed src="http://blip.tv/play/AZ_iEoaIfA" type="application/x-shockwave-flash" width="640" height="510" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt; </code></pre> <p>Here's an example of what you might get from YouTube:...
26,576
<p>SPListItem.GetFormattedValue seems to have a strange behavior for DateTime fields. It retrieves the DateTime value through SPListItem's indexer which according to this <a href="http://msdn.microsoft.com/en-us/library/ms197282.aspx" rel="noreferrer">MSDN article</a> returns <em>local</em> time. Here's a snippet from ...
<p>Converting the date back to universal time before calling GetFieldValueAsHtml works just fine.</p> <pre><code>DateTime localTime = (DateTime)item["DueDate"]; // this is local time but if you do localDateTime.Kind it returns Unspecified // treats the date as universal time.. // let's give it the universal time :) D...
<p>I have had a recognised bug with the date conversion from UTC in SharePoint. It was fixed in SP1.</p>
35,043
<p>I'm extending the Gridview Web Control as my first attempt at creating a custom control.</p> <p>As part of the extension I am encapsulating the localization of the grid column headers within the control. Among others, I'm exposing a couple of properties to enable this feature:</p> <p>bool AutoLocalizeColumnHeaders...
<p>I think I've found the solution now.</p> <p>Running the following from inside a Page_Load event gave me the Resource class names:</p> <pre><code>String[] resourceClassNames = (from type in assembly.GetTypes() where type.IsClass &amp;&amp; type.Namespace.Equals("Resources") select type.Name).ToArray(); </code...
<p>Interesting idea. I imagine that your property is currently set as a string? i wonder if you set your property as an Enum, then create an Enum with the strongly typed resource classes, will it be smart enough to show those in the property window. it is smart enough to show it in the code behind, cant see why it cou...
43,949
<p>Often WinDbg will enter a state where it is <strong>*Busy*</strong> performing an operation. </p> <p>Often this is due to some mistake I made trying to <em>dt some_variable_itll_never_find</em> or setting a break point somewhere without symbols or the 1000's of other mistakes I make fumbling around this tool.</p> ...
<p>I don't have the tool now, but as far as I remember it should be Ctrl+Break.</p>
<p>You probably had "<a href="http://msdl.microsoft.com/download/symbols" rel="noreferrer">http://msdl.microsoft.com/download/symbols</a>" in the symbol path. Windbg will try to locate all your PDBs on Microsoft site :-(.<br> Pressing Ctrl+Break is not fast enough. What I usually do is to unplug the network cable, unti...
23,220
<p>Is there a way my program can determine when it's running on a Remote Desktop (Terminal Services)?</p> <p>I'd like to enable an "inactivity timeout" on the program when it's running on a Remote Desktop session. Since users are notorious for leaving Remote Desktop sessions open, I want my program to terminate after...
<p>GetSystemMetrics(SM_REMOTESESSION) (as described in <a href="http://msdn.microsoft.com/en-us/library/aa380798.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/aa380798.aspx</a>)</p>
<p>The following works if you want to know about YOUR application which is running in YOUR session:</p> <pre><code>BOOL IsRemoteSession(void) { return GetSystemMetrics( SM_REMOTESESSION ); } </code></pre> <p>But not in general for any process ID.</p> <hr> <p>If you want to know about any arbitrary process which ...
19,339
<p>I have a source XML file that is used to create C# files that are then compiled as part of a project.<br> Currently I have a BeforeBuild target that runs my XML to C# converter.<br> The problem is that by the time the BeforeBuild step is run the old files appear to have been stored by the build system so the new fil...
<p>I guess your "stored by the build system" can be translated as the ItemGroup containing the .cs files you wish to compile is generated when the msbuild file is read, as opposed to when your compile target is executed. You have several options: </p> <ol> <li><code>&lt;CreateItem&gt;</code> see <a href="http://msdn.m...
<p>Well we have something similar-ish here. We gen a .cs off an xml file using a .tt. Both files are part of a specific csproj. Going properties->BuildEvents on the csproj gives this little snippet in the Pre-build event command line:</p> <pre><code>del "$(ProjectDir)MyCsFile.cs" copy /b /y "$(ProjectDir)\MyXmlFile.xm...
32,410
<p>I'm trying to construct a find command to process a bunch of files in a directory using two different executables. Unfortunately, <code>-exec</code> on find doesn't allow to use pipe or even <code>\|</code> because the shell interprets that character first. </p> <p>Here is specifically what I'm trying to do (whic...
<p>Try this</p> <pre><code>find /path/to/jpgs -type f -exec sh -c 'jhead -v {} | grep 123' \; -print </code></pre> <p>Alternatively you could try to embed your exec statement inside a sh script and then do:</p> <pre><code>find -exec some_script {} \; </code></pre>
<p>There is kind of another way you can do it but it is also pretty ghetto.</p> <p>Using the shell option extquote you can do something similar to this in order to make find exec stuff and then pipe it to sh.</p> <pre><code>root@ifrit findtest # find -type f -exec echo ls $"|" cat \;|sh filename </code></pre> <p><br...
8,739
<p>Recently I made a bunch of changes to my local svn config file. Mainly I corrected svn:mime-type properties of about 15 different file types. Now I need reset all previously checked in files according to this new configuration. SVN seems to trigger auto-prop only for ADDs and IMPORTs. So how do I do this without goi...
<p>There is no way to get svn to do this out of the box. The <a href="http://svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/svn_apply_autoprops.py" rel="nofollow noreferrer">svn_apply_autoprops.py</a> script should help though.</p>
<p>Thanks clawrence! It worked! </p> <p>For others FYI, I traced up the source of this script and I found more client scripts: <a href="http://subversion.tigris.org/tools_contrib.html" rel="nofollow noreferrer">http://subversion.tigris.org/tools_contrib.html</a></p>
29,383
<p>I've had success with <a href="http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/" rel="nofollow noreferrer">LuaSocket</a>'s TCP facility, but I'm having trouble with its FTP module. I always get a timeout when trying to retrieve a (small) file. I can download the file just fine using Firefox or ftp in p...
<p>Hm. It looks like the problem is that LuaSocket uses "pasv" in lower case. I'm going try to figure out a work-around.</p> <hr> <p>Hm. Nope, it looks quite elegantly welded shut. The easiest thing to do is probably to copy <em>that particular file</em> to its equivalent place in a hierarchy in an earlier path in LU...
<p>Note that the server is failing to follow the FTP specification, which states commands are case-insensitive. See RFC959, section 5.3 "The command codes are four or fewer alphabetic characters. Upper and lower case alphabetic characters are to be treated identically. Thus, any of the following may represen...
25,819
<p>I'm creating a networked server for a boggle-clone I wrote in python, which accepts users, solves the boards, and scores the player input. The dictionary file I'm using is 1.8MB (the ENABLE2K dictionary), and I need it to be available to several game solver classes. Right now, I have it so that each class iterates...
<p>If you create a dictionary.py module, containing code which reads the file and builds a dictionary, this code will only be executed the first time it is imported. Further imports will return a reference to the existing module instance. As such, your classes can:</p> <pre><code>import dictionary dictionary.words[wh...
<p>Depending on what your dict contains, you may be interested in the 'shelve' or 'anydbm' modules. They give you dict-like interfaces (just strings as keys and items for 'anydbm', and strings as keys and any python object as item for 'shelve') but the data is actually in a DBM file (gdbm, ndbm, dbhash, bsddb, dependin...
19,179
<p>If I have the following:</p> <pre><code>Public Class Product Public Id As Integer Public Name As String Public AvailableColours As List(Of Colour) Public AvailableSizes As List(Of Size) End Class </code></pre> <p>and I want to get a list of products from the database and display them on a page alon...
<p>You're probably best off benchmarking both and finding out. I've seen situations where just doing multiple queries (MySQL likes this) is faster than JOINs and one big slow query that takes a lot memory and causes the DB server to thrash. I say benchmark because it's going to depend on your database server, how much ...
<p>Personally, I'd get more data from the database through fewer methods and then bind the UI against only those parts of the data set that I currently want to display. Managing lots of small methods that get out specific chunks of data is harder than getting out large chunks and using only those parts you need.</p>
9,708
<p>I recently <a href="https://stackoverflow.com/questions/353912/functional-programming-state-vs-reassignment">asked a question</a> about functional programming, and received (good!) answers that prompted more questions (as seems to be the case with learning, sometimes). Here are a couple examples:</p> <ol> <li><p>On...
<p>Answer to part 1: Immutable objects don't by themselves support anything like "merging" to allow the results of two thread's updates to be combined. There are two major strategies for that: the pessimistic and the optimistic. If you're pessimistic, you assume it's quite likely that two threads will want to update th...
<p>"Immutable" means exactly that: it doesn't change.</p> <p>The way functional programs do updates is by passing around new things. An existing value never changes: you just build a new value and pass that instead. Very often the new value shares state with the old one; good examples of the technique are lists compos...
47,119
<p>I'm writing a function to find <a href="http://projecteuler.net/index.php?section=problems&amp;id=12" rel="noreferrer">triangle numbers</a> and the natural way to write it is recursively:</p> <pre><code>function triangle (x) if x == 0 then return 0 end return x+triangle(x-1) end </code></pre> <p>But attempti...
<p>I bet something like this should work with variable argument lists in Lua:</p> <pre><code>local function varg_tostring(...) local s = select(1, ...) for n = 2, select('#', ...) do s = s..","..select(n,...) end return s end local function memoize(f) local cache = {} return function (...
<p>Extending the idea, it's also possible to memoize functions with two input parameters:</p> <pre><code>function memoize2 (f) local cache = {} return function (x, y) if cache[x..','..y] then return cache[x..','..y] else local z = f(x,y) c...
15,773
<p>So I got the SKR mini E3 for my Ender 5 after hearing all the positive reviews.</p> <p>When it arrives I plug everything in, make sure it's secure and test the axis... they all worked correctly.</p> <p>I then tested auto home... everything worked.</p> <p>I then tested the heating... everything worked again.</p> <p>F...
<p>This issue is related to the way Creality has defined the origin of the printer. Usually, the origin of the printer is at the front left when facing the printer. Creality has chosen to set the origin in their default Creality configuration at the back right.</p> <p>Vanilla Marlin (Ender 5 configuration) has the orig...
<p>So I found an answer on Reddit when I asked the same question: It actually had to do with the homing -- basically, it was starting at 220, 220 instead of 0,0, which resulted in when the print started for it to head straight into the corner. In order to counter this, I had to change some of the firmware. Everything w...
1,787
<p>We've been using selenium with great success to handle high-level website testing (in addition to extensive python doctests at a module level). However now we're using extjs for a lot of pages and its proving difficult to incorporate Selenium tests for the complex components like grids. </p> <p>Has anyone had succ...
<p>The biggest hurdle in testing ExtJS with Selenium is that ExtJS doesn't render standard HTML elements and the Selenium IDE will naively (and rightfully) generate commands targeted at elements that just act as decor -- superfluous elements that help ExtJS with the whole desktop-look-and-feel. Here are a few tips and ...
<p>For complex UI that is not formal HTML, xPath is always something you can count on, but a little complex when it comes to different UI implementation using ExtJs.</p> <p>You can use Firebug and Firexpath as firefox extensions to test an certain element's xpath, and simple pass full xpath as parameter to selenium.</...
13,283
<p>I'm trying to wrap my head around the best way to use IoC within my application for dependency injection, however I have a little issue.</p> <p>I am using a loose implementation of the MVP pattern with a WPF app. Essentially, a presenter class is instantiated, and a view and task (e.g. IEmployeeView and IEmployeeTa...
<p>You might want to do something like this (if you're in java 5 &amp; up)</p> <pre><code>Scanner scanner = new Scanner(new File("tall.txt")); int [] tall = new int [100]; int i = 0; while(scanner.hasNextInt()){ tall[i++] = scanner.nextInt(); } </code></pre>
<pre><code>File file = new File("E:/Responsibility.txt"); Scanner scanner = new Scanner(file); List&lt;Integer&gt; integers = new ArrayList&lt;&gt;(); while (scanner.hasNext()) { if (scanner.hasNextInt()) { integers.add(scanner.nextInt()); } else { scanner.next(); ...
39,050
<p>I'm writing some cross-platform code between Windows and Mac.</p> <p>If list::end() "returns an iterator that addresses the location succeeding the last element in a list" and can be checked when traversing a list forward, what is the best way to traverse backwards?</p> <p>This code workson the Mac but not on Win...
<p>Use <code>reverse_iterator</code> instead of <code>iterator</code>. Use <code>rbegin()</code> &amp; <code>rend()</code> instead of <code>begin()</code> &amp; <code>end()</code>.</p> <p>Another possibility, if you like using the <a href="http://www.boost.org/doc/libs/1_36_0/doc/html/foreach.html" rel="nofollow norefe...
<p>As already mentioned by Ferruccio, use reverse_iterator:</p> <pre><code>for (std::list&lt;int&gt;::reverse_iterator i = s.rbegin(); i != s.rend(); ++i) </code></pre>
22,918
<p>I decided to teach myself assembly language.</p> <p>I have realized that my program will not compile if I attempt to change the value of any segment register.</p> <p>Every article that I have found says that I can indeed change the value of at least 4 segment registers, so what gives? </p> <p>I am really only in...
<p>You said you were interested in why, so:</p> <p>In real mode, a segment is a 64K "window" to physical memory and these windows are spaced 16 bytes apart. In protected mode, a segment is a window to either physical or virtual memory, whose size and location is determined by the OS, and it has many other properties, ...
<p>Are you writing windows executables?</p> <p>In protected-mode (Win32), segment registers are not used any more.</p> <p><a href="http://www.codebreakers-journal.com/content/view/141/104/" rel="nofollow noreferrer">Reference</a>:</p> <blockquote> <p>Memory model is also drastically different from the old days o...
15,259
<p>I'm new to unit testing and I'm trying to figure out if I should start using more of <code>internal</code> access modifier. I know that if we use <code>internal</code> and set the assembly variable <code>InternalsVisibleTo</code>, we can test functions that we don't want to declare public from the testing project. T...
<p>Internal classes need to be tested and there is an assembly attribute:</p> <pre><code>using System.Runtime.CompilerServices; [assembly:InternalsVisibleTo(&quot;MyTests&quot;)] </code></pre> <p>Add this to the project info file, e.g. <code>Properties\AssemblyInfo.cs</code>, for the project under test. In this case &...
<p>Add <code>InternalsVisibleTo.cs</code> file to project's root folder where <code>.csproj</code> file present.</p> <p>Content of <code>InternalsVisibleTo.cs</code> should be following</p> <pre class="lang-cs prettyprint-override"><code>using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo(&quot;Assemb...
46,709
<p>I have a query that originally looks like this:</p> <pre><code>select c.Id, c.Name, c.CountryCode, c.CustomerNumber, cacc.AccountNumber, ca.Line1, ca.CityName, ca.PostalCode from dbo.Customer as c left join dbo.CustomerAddress as ca on ca.CustomerId = c.Id left join dbo.CustomerAccount as cacc on cacc.CustomerId = ...
<p>You've asked for the canonical reason why Boost::MultiIndex was made: list insertion order with fast lookup by key. <a href="http://www.boost.org/doc/libs/1_36_0/libs/multi_index/doc/tutorial/basics.html#list_fast_lookup" rel="nofollow noreferrer">Boost MultiIndex tutorial: list fast lookup</a></p>
<p>@wesc: STL has std::map... so what's the difference with unordered_map? I don't think STL would implement twice the same thing and call it differently.</p>
5,656
<p>We use Telerik's RadEditor for our content management system's WYSIWYG editor. We need the find &amp; replace functionality that is in the WYSIWYG editor to also be in the HTML editor. The editor is pretty customizable, anyone know if there is a way to enable this or hack it in?</p>
<p>There is no built-in functionality for what you are looking for. But using the clientside API and some javascript you could hook up your own button that does a find and replace using the <code>editor.get_html()</code> and <code>editor.set_html()</code> functions. You could then consider using some RegEx or just a ...
<p>There is an <a href="http://demos.telerik.com/ASPNET/Prometheus/Editor/Examples/ClientsideAPI/DefaultCS.aspx" rel="nofollow noreferrer">example on their demo site for RadEditor ASP.NET Ajax</a>. </p> <p>Just click on the 3rd button of the toolbar in order to test "Find and Replace".</p> <p>Take a look at <a href="...
30,703
<p>I've been asked to evaluate a new vendor's computing system and management has requested that I do NOT use any of our existing software to evaluate the platform (believe it or not, they have some valid reasons).</p> <p>Anyways, I've started trying to read up on meaningful benchmark programs for server-grade compute...
<p><a href="http://www.phoronix.com" rel="noreferrer" title="Phoronix">Phoronix</a> has a benchmark suite for Linux. Maybe it is sufficent for you.</p>
<p>Have a look at the Transaction Processing Council for ideas. They may have a result for your machines already.</p> <p>Unfortunately you need to be a member to get hold of the software which is proced up to tier 1 hardware vendor levels.</p>
48,108
<p>I have a page that allows users to enter a lot of information about them (metadata) they can then click on a icon which opens a modal window containing a googlemap which allows them to add locations, and a title for that location.</p> <p>Using mootools I can pass the value of a form field back to the original form,...
<p>I would suggest that you use an object to maintain all of the location data while the user is making their selections. When, when the form is submitted, serialize that data into a hidden field as a JSON object.</p> <p>So, when the user clicks in the map window, you record the info in the object, in addition to the ...
<p>are you looking for something like this?</p> <pre><code>usersLocations.locations[0]["name"] = document.getElementById("location0name").value; </code></pre>
44,766
<p><a href="http://www.ietf.org/rfc/rfc1738.txt" rel="noreferrer">RFC 1738</a> specifies the syntax for URL's, and mentions that</p> <blockquote> <p>URLs are written only with the graphic printable characters of the<br> US-ASCII coded character set. The octets 80-FF hexadecimal are not<br> used in US-ASCII, ...
<p>As per your quote, URLs are ASCII. That's all.</p> <p>URIs OTOH, allow for bigger charsets; usually UTF-8 as you said yourself.</p> <p>The point to remember is that URLs are a subset of URIs. Therefore, the real question is, which of these is what you write in a browser?</p> <p>I'd guess you can write an URI, and...
<p>I believe the specification you are looking for is <a href="https://www.rfc-editor.org/rfc/rfc3987" rel="nofollow noreferrer">RFC 3987</a>, which describes IRIs - Internationalized Resource Identifiers.</p>
16,990
<p>Can every possible value of a <code>float</code> variable can be represented exactly in a <code>double</code> variable?</p> <p>In other words, for all possible values <code>X</code> will the following be successful:</p> <pre><code>float f1 = X; double d = f1; float f2 = (float)d; if(f1 == f2) System.out.println...
<p>Yes.</p> <p>Proof by enumeration of all possible cases:</p> <pre><code>public class TestDoubleFloat { public static void main(String[] args) { for (long i = Integer.MIN_VALUE; i &lt;= Integer.MAX_VALUE; i++) { float f1 = Float.intBitsToFloat((int) i); double d = (double) f1; ...
<p><strong>Snark:</strong> <code>NaN</code>s will compare differently after (or indeed before) conversion.</p> <p>This does not, however, invalidate the answers already given.</p>
32,344
<p>I currently use this function to wrap executing commands and logging their execution, and return code, and exiting in case of a non-zero return code.</p> <p>However this is problematic as apparently, it does double interpolation, making commands with single or double quotes in them break the script.</p> <p>Can you...
<pre><code>"$@" </code></pre> <p>From <a href="http://www.gnu.org/software/bash/manual/bashref.html#Special-Parameters" rel="noreferrer">http://www.gnu.org/software/bash/manual/bashref.html#Special-Parameters</a>:</p> <blockquote> <p>@</p> <p>Expands to the positional parameters, starting from one. When the ...
<p>Additional to <code>"$@"</code> what Douglas says, i would use </p> <pre><code>return $? </code></pre> <p>And not <code>exit</code>. It would exit your shell instead of returning from the function. If in cases you want to exit your shell if something went wrong, you can do that in the caller:</p> <pre><code>do_cm...
48,640