instruction
stringlengths
21
27.8k
chosen
stringlengths
18
28.2k
rejected
stringlengths
18
33.6k
__index_level_0__
int64
0
50k
<p>I've cached a value using the ASP.NET Cache, with the following code:</p> <pre><code>Cache.Insert("TEST_VALUE", 150, null, Cache.NoAbsoluteExpiration, TimeSpan.FromSeconds(120)); </code></pre> <p>As I understand it, this should mean that if nothing accesses that object for 120 seconds, it will expire and return nu...
<p>Just a debugging tip: Set the value of the cached object to DateTime.Now when you insert it in order to see when it was inserted. That way you can easily determine if it was re-inserted somehow or if something somewhere keeps accessing and thus forcing it to stay in the cache.</p> <p>That combined with my suggestio...
<p>Dupe of your original question here:</p> <p><a href="https://stackoverflow.com/questions/337897/whats-the-reason-for-my-aspnet-cache-never-expiring-despite-having-a-sliding-ex">What&#39;s the reason for my ASP.NET Cache never expiring, despite having a sliding expiration time set?</a></p> <p>Suggest you supply mor...
44,199
<p>The <a href="http://en.wikipedia.org/wiki/Effect_system" rel="noreferrer">Wikipedia article on <em>Effect system</em></a> is currently just a short stub and I've been wondering for a while as to what is an effect system. </p> <ul> <li>Are there any languages that have an effect system in addition to a type system? ...
<p>A "type and effect system" describes not only the kinds of values in a program, but the changes in those values. "Typestate" checking is a related idea.</p> <p>An example might be a type system that tracks file handles: instead of having a function <code>close</code> with return type <code>void</code>, the type sys...
<p>(This is not an authoritative answer; just trying to trawl my memory.)</p> <p>In a sense, any time you code a 'state monad' in a language, you're using the type system as a potential effect system. So "State" or "IO" in Haskell capture this notion (IO captures a whole lot of other effects as well). I vaguely reme...
23,864
<p>I'm working on an upgrade for an existing database that was designed without any of the code to implement the design being considered. Now I've hit a brick wall in terms of implementing the database design in code. I'm certain whether its a problem with the design of the database or if I'm simply not seeing the corr...
<p>What you're looking for is <a href="http://www.dbazine.com/ofinterest/oi-articles/celko1" rel="nofollow noreferrer">relational division</a> Not implemented directly in SQL, but it can be done. Search google for other examples.</p>
<p>After a quick look at the schema I think one of the things you can do is create a 'to_be_certified' table. Populate it with user_id, product_id and seat_id when a product is assigned to a seat (when product_seat_rtab is populated).</p> <p>On adding a record to the certification_rtab table, delete the corresponding ...
19,752
<p>I'm getting zits or blobs in lithophanes while printing on my Ender 3 and 10S Pro. I tried a suggestion: change resolution in mesh fixes of Cura to 0.5 (from 0.05 default). That removed the zits.</p> <p>But now there are white patches as shown in the image. I reduced the resolution to 0.2 but to no avail.</p> <p>Any...
<p>In short, no. A 2D image has insufficient information to determine a 3D form.</p> <p>If you want to do this yourself, what you could do is start with the 2D outline in a program like Blender (as 0scar mentioned in a comment), extrude it to make a thin &quot;cardboard cutout&quot;, then begin shaping it into three di...
<p>If you only have a 2D photo then as others have already said its not really possible. However if you have the action figure itself you could try a technique called Photogrammetry where you use your phone to take multiple images of the object and then use software to build up a model. Search youtube for guides on Ph...
2,009
<p>How do I alternate HTML table row colors using JSP?</p> <p>My CSS looks something like:</p> <pre><code>tr.odd {background-color: #EEDDEE} tr.even {background-color: #EEEEDD} </code></pre> <p>I want to use <code>&lt;c:forEach&gt;</code> to iterate over a collection. </p> <pre><code>&lt;c:forEach items="${element}...
<p>Use the <code>varStatus</code> attribute on your <code>forEach</code> tag and JSTL will manage an instance of a <a href="http://java.sun.com/products/jsp/jstl/1.1/docs/api/javax/servlet/jsp/jstl/core/LoopTagStatus.html" rel="noreferrer"><code>javax.servlet.jsp.jstl.core.LoopTagStatus</code></a> for you in the variab...
<p>I don't use JSP, so I can't give you an answer in your language, but here's what I do (using pseudo code)</p> <pre><code>counter = 0 foreach (elements) counter = counter + 1 output: &lt;tr class="row{counter % 2}"&gt;...&lt;/tr&gt; </code></pre> <p>Personally, I name the classes "row0" and "row1", which le...
29,944
<p>I have two Tronxy 2.0 V5 Marlin boards that reboot whenever heat is applied to the bed. The bed has been swapped (because I thought that was the problem) for a new shiny one. The thermistors, too, of course. The same boards (both) work when the beds remain unheated (setpoint = 0&nbsp;&deg;C).</p> <p>Any ideas what...
<p>It sounds like a power-related problem. Always use an external MOSFET to drive a heated bed, and consider investing in a decent power supply. Inevitably, the Tronxy PSU will be barely adequate.</p> <p>Edit: I've just noticed the <a href="/questions/tagged/tronxy-x1" class="post-tag" title="show questions tagged &#3...
<p>First, check the power supply. Although it may be specified to deliver the required power, it is possible that the power supply has failed in a way that it can not deliver the rated power. At lower load, the voltage may be correct, but under higher load, it either droops or cuts out completely.</p> <p>To check th...
1,330
<p>Looking for a good rss/feed reader for windows or if there are any good cross platforms one i would be really amazed, or good web services (dont like the google one).</p> <p>I want something simplistic and minimalistic.</p>
<p>I like the NewsGator family of tools (<a href="http://newsgator.com" rel="nofollow noreferrer">http://newsgator.com</a>). I mostly use the Mac and web-based versions, but thought FeedDemon was good, too, for the Windows environment. All keep a common subscription list, so you can bounce back and forth as needed.</...
<p>If you have a Google account already, seriously consider Google Reader. It's available everywhere, with Gears installed it is available offline and binds well to Firefox and Chrome. </p>
14,826
<p>What is the best way to go about upgrading TFS 2005 to 2008? Also, what about the Team Build scripts ("Build Types"), are those compatible with Team Build 2008 or do they need converted/migrated somehow?</p>
<p>First and foremost - backup everything! The databases, the machine itself... You can never be too careful.</p> <p>I was able to upgrade the TFS installation at my company by using these resources:</p> <p><a href="http://olausson.net/blog/CommentView,guid,6f97b619-a5ac-41af-a908-f099d49a3b16.aspx" rel="nofollow nor...
<p>Simply, follow the guidance in the Install document for TFS 2008 - It has an upgrade section. It talks about backing up databases and so on already. The instructions are clear and layed out well. </p>
6,084
<p>I know I can compile individual source files, but sometimes -- say, when editing a header file used by many <code>.cpp</code> files -- multiple source files need to be recompiled. That's what Build is for.</p> <p>Default behavior of the "Build" command in VC9 (Visual C++ 2008) is to attempt to compile all files th...
<p>I came up with a better macro guys. It stops immediately after the first error/s (soon as build window is updated).</p> <p>Visual Studio -> Tools -> Macros -> Macro IDE... (or ALT+F11)</p> <pre><code>Private Sub OutputWindowEvents_OnPaneUpdated(ByVal pPane As OutputWindowPane) Handles OutputWindowEvents.PaneUpdate...
<p>There is <a href="http://old.stevenharman.net/blog/archive/2008/01/17/visual-studio-tip-kill-that-build.aspx" rel="nofollow noreferrer">this post</a> - not sure if it stops the build at the first error or the first failed project in a solution.</p> <p>Ctrl-break will also stop it manually.</p> <p>Now if there was ...
16,321
<p>I am trying to find a way to determine at run-time how much memory a given class is using in .NET. Using <code>Marshal.SizeOf()</code> is out, as it only works on value types. Is there a way to check exactly how much memory a class uses?</p>
<p>I've only recently started looking into this type of thing, but i have found that memory profilers can give quite detailed information regarding instances of objects within your application.</p> <p>Here are a couple that are worth trying:</p> <ul> <li><a href="http://www.red-gate.com/Products/ants_profiler/index.h...
<p>I agree that a memory profiler is the easiest way to get the information you are looking for. In addition to the two previously mentioned, I recommend JetBrains <a href="http://www.jetbrains.com/profiler/index.html" rel="nofollow noreferrer">dotTrace</a>, which is both a performance profiler and a memory profiler.</...
7,464
<p>Is there an efficient way of detecting if a jpeg file is corrupted? </p> <p>Background info:<br> &nbsp; solutions needs to work from within a php script<br> &nbsp; the jpeg files are on disk<br> &nbsp; manual checking is no option (user uploaded data) </p> <p>I know that <code>imagecreatefromjpeg(string $filenam...
<p>From the command line you can use jpeginfo to find out if a jpeg file is OK or not.</p> <blockquote> <p>$ jpeginfo -c test.jpeg</p> <p>test.jpeg 260 x 264 24bit JFIF N 15332 [OK]</p> </blockquote> <p>It should be trivial to call jpeginfo from php.</p>
<p>You may also try to generate file hash based on MD5 and use it as checksum to validate JPEG data on various steps. For example, after read from file, then after transfer, etc.</p>
24,171
<p>I just re-read <a href="https://rads.stackoverflow.com/amzn/click/com/020161622X" rel="nofollow noreferrer" rel="nofollow noreferrer">The Pragmatic Programmer</a> (my third time reading it...I get something new every time, too). It seems like the tips that they mention are related to many of the various Agile method...
<p>Much of what has been coined "Agile Development" are practices that have been used for years and you will find a lot of these ideas in "The Pragmatic Programmer" and "Code Complete", etc.. To some degree agile is a nice marketing spin that has been coined, but I do believe it has done us a lot of good to get some o...
<p><strong>Yes, the pragprog way is being agile.</strong> Many elements of the agile manifesto can be found in the pragmatic programmer book. Great examples of this include "there are no final decisions" and "code that glows in the dark".</p> <p>Andy Hunt and Dave Thomas (Ruby Dave) signed the agile manifesto.</p> <...
25,626
<p>I want to use <a href="http://alistapart.com/articles/sprites" rel="noreferrer">CSS sprites</a> on a web site instead of separate image files, for a large collection of small icons that are all the same size. How can I concatenate (tile) them into one big image using <a href="http://www.imagemagick.org/" rel="norefe...
<p>From the page you linked, <a href="http://www.imagemagick.org/script/montage.php" rel="nofollow noreferrer">'montage'</a> is the tool you want. It'll take a bunch of images and concatenate/tile them into a single output. Here's an example image I've made before using the tool: <a href="https://i.stack.imgur.com/8rCK...
<p>I like this script for automatical sprite/css generation. "<a href="http://jaymz.eu/2010/05/building-css-sprites-with-bash-imagemagick/" rel="nofollow noreferrer">Building CSS sprites with Bash &amp; Imagemagick</a>"</p> <ul> <li><p>article copy in Waybackmashine <a href="https://web.archive.org/web/20150529041037/...
11,437
<p>I'm porting an application from php to fastcgi (c). My host runs apache.</p> <p>Since the fastcgi app would be running in a loop, I could open a mysql connection, and leave it open for all incoming requests. Is this recommended?</p> <p>I think I've read about an equal number of opinions saying the connection is wa...
<p>I hate to say such an obvious answer, but...have you tried both ways and compared them? It's pretty easy to change a connect() to a pconnect() and just attempt it with both methods. Do some profiling, especially under load, and see what works best on your combination of hardware and software.</p> <p>On high-traffic...
<p>I would say if you have atleast 10-20 people using ur site at all times than persistent connections work the best. anything less is overkill</p>
35,465
<p>Recently I wrote an extremely basic Java Swing program with a couple of text fields and buttons. The program works fine for me on Ubuntu with Java 1.5. But when I try to run it on OSX (10.4), the main window is displayed correctly but the program seems unresponsive. Nothing seems to happen, no matter which button I ...
<p>Could it be that you are executing something off the Event-Dispatch Thread? For example, you might be creating, displaying and then modifying a <code>JTextArea</code> in the <code>main</code> thread.</p>
<p>Any chance you could put the code online somewhere so we could try it? I am actually using 10.4 as well so it would not be a problem.</p>
27,760
<p>I've got to write few words about C#, generally piece of cake? No! </p> <p>I've searched through various internet resources and books and what i got is kind of headache. For example <strong>Garbage Collector</strong> some sources says that this is C# feature, other that CLR got this feature and C# along with all ot...
<p>GC is provided by the CLR</p> <p>C# is everything that the language spec states, and no more.</p> <p>Some of the more-interesting things that are actually C# features:</p> <ul> <li>iterator blocks [yield return]</li> <li>anonymous methods / closures / lambdas [the syntax, not to be confused with expression trees]...
<p>The CLR is a development platform, a runtime environment, supporting managed code written in one of the .NET languages, of which C# is one. Garbage collection is a CLR feature. As are Code Access Security and Just In Time compilation of your managed code.</p>
38,708
<p>I recently "needed" a zip function in Perl 5 (while I was thinking about <a href="https://stackoverflow.com/questions/11/how-do-i-calculate-relative-time">How do I calculate relative time?</a>), i.e. a function that takes two lists and "zips" them together to one list, interleaving the elements.</p> <p>(Pseudo)exam...
<p>Assuming you have exactly two lists and they are exactly the same length, here is a solution originally by merlyn (Randal Schwartz), who called it perversely perlish:</p> <pre><code>sub zip2 { my $p = @_ / 2; return @_[ map { $_, $_ + $p } 0 .. $p - 1 ]; } </code></pre> <p>What happens here is that for a ...
<p>This is totally not an elegant solution, nor is it the best solution by any stretch of the imagination. But it's fun!</p> <pre><code>package zip; sub TIEARRAY { my ($class, @self) = @_; bless \@self, $class; } sub FETCH { my ($self, $index) = @_; $self-&gt;[$index % @$self][$index / @$self]; } s...
5,925
<p>In the process of learning <a href="https://en.wikipedia.org/wiki/TinyOS" rel="nofollow noreferrer">TinyOS</a> I have discovered that I am totally clueless about makefiles.</p> <p>There are many optional compile time features that can be used by way of declaring preprocessor variables.</p> <p>To use them you have to...
<p>CFLAGS is a variable that is most commonly used to add arguments to the compiler. In this case, it define macros. </p> <p>So the <code>-DPACKET_LINK</code> is the equivalent of putting <code>#define PACKET_LINK 1</code> at the top of all .c and .h files in your project. Most likely, you have code inside your projec...
<p>-D stands for <em>define</em> (in gcc) at least, which lets you #define on the command line instead of a file somewhere. A common thing to see would be -DDEBUG or -DNDEBUG which respectively activate or disable debugging code.</p>
10,618
<p>I am writing a Time Sheeting web application that involves users entering their tasks for the week. I would like not to have the page refresh so I am exploring ways to add/delete/edit tasks using JavaScript on the client browser. </p> <p>Currently I am using ASP.NET-MVC, Ajax, JQuery and LiveValidation and I am mak...
<p>I would suggest ExtJS. It is a library for more "application" like interfaces in web apps. Included is a <code>EditorGridPanel</code> class, which would be able to do what you're looking for fairly easily. And it looks GREAT.</p>
<p>Why don't you validate and add your data in a single request? If data doesn't validate, return false with error fields, if validates, return true with newly created task's id. You don't need to validate and add in seperate requests.</p>
22,008
<p>I would like to know if there is any way to add custom behaviour to the auto property get/set methods.</p> <p>An obvious case I can think of is wanting every set property method to call on any <code>PropertyChanged</code> event handlers as part of a <code>System.ComponentModel.INotifyPropertyChanged</code> implemen...
<p>No, you'll have to use "traditional" property definitions for custom behavior.</p>
<p>If it's a behavior you'll repeat a lot during development, you can create a custom code snippet for your special type of property.</p>
14,154
<p>If you had a 10 minute hands-on session to teach someone Emacs, what would you show them?</p> <pre> Start emacs: emacs ... Quit emacs: C-x C-c </pre> <p>What else would you have them do between starting and quitting Emacs, while you stood behind them?</p>
<p>If I had only 10 minutes, I would not teach them any shortcuts at all. All the common shortcuts are available next to the corresponding commands in the menus; those the users can discover for themselves.</p> <p>The most important things to teach are those that will enable the users to discover/learn by themselves:<...
<p>I think the first thing to ask before trying to teach them something is "what do they want to get out of learning Emacs?" AND, are you trying to sell them on the idea of learning Emacs or are they already committed.</p> <p>If they are a programmer and are looking for a new development environment, show them ECB, ho...
40,108
<p>I want to use lucene.net to index records in our database. The records are stored in several different tables and tied together through a records table. Would it be better to index each table separately and tie the search results together in code, or should I tie the records together coming out of the database and...
<p>If you make a Lucene index that corresponds to each table, then 1) you're going to have to do the work of performing the search against each index and 2) merging the search results in some magical fashion. Lucene is already set up to search documents with multiple fields (see MultiFieldQueryParser), and give you a u...
<p>Lucene isn't tied to database tables, you select the information you want in a Lucene document. I would likely be better to let Lucene handle the merging and ranking of results rather than doing it yourself. </p>
33,348
<p>I was at an interview for a C position in which they presented me with an idiom that I haven't previously encountered. This is a trick that simplifies implementation of various algorithms involving linked lists and I'm wondering if anybody else has encountered this.</p> <p>Say we have a linked list record defined s...
<p>I've used similar to this to insert into a binary tree. Because when iterating the tree, you usually stop when your pointer becomes <code>NULL</code> (you ran off the tree).</p> <p>So to insert, you have 3 options, </p> <p>1: use a variable which tracks the previous value of your iterating pointer.</p> <p>2: stop...
<p>I have also come up with this use of a double pointer, I have used it, but I don't really like it. The code that I came up with has this kernel to search for certain objects and remove them from the list:</p> <pre><code>Element** previous = &amp;firstElement, *current; while((current = *previous)) { if(shouldRe...
43,065
<p>Let me describe the problem in details:</p> <p>I want to show an absolute positioned div when hovering over an element. That's really simple with jQuery and works just fine. But when the mouse goes over one of the child elements, it triggers the mouseout event of the containing div. How do I keep javascript from tr...
<p>The question is a bit old, but I ran into this the other day.</p> <p>The simplest way to do this with recent versions of jQuery is to use the <code>mouseenter</code> and <code>mouseleave</code> events rather than <code>mouseover</code> and <code>mouseout</code>.</p> <p>You can test the behavior quickly with:</p> ...
<p>The way I've usually seen this handled is to have a delay of about 1/2 second between moving the mouse from the HoverMe element. When moving the mouse into the hovered element, you would want to set some variable which signals that you are hovering over element, and then basically stop the hovered part from hiding ...
45,642
<p>What code analysis tools do you use on your Java projects?</p> <p>I am interested in all kinds</p> <ul> <li>static code analysis tools (FindBugs, PMD, and any others)</li> <li>code coverage tools (Cobertura, Emma, and any others)</li> <li>any other instrumentation-based tools </li> <li>anything else, if I'm missin...
<p>For static analysis tools I often use CPD, <a href="http://pmd.sourceforge.net" rel="noreferrer">PMD</a>, <a href="http://findbugs.sourceforge.net" rel="noreferrer">FindBugs</a>, and <a href="http://checkstyle.sourceforge.net" rel="noreferrer">Checkstyle</a>.</p> <p><p>CPD is the PMD "Copy/Paste Detector" tool. I w...
<p>I am looking for many answers to learn about new tools and consolidate this knowledge in a one question/thread, so I doubt there will be 1 true answer to this question.</p> <p>My answer to my own question is that we use:</p> <ul> <li>Findbugs to look for common errors bad/coding - run from maven, and also integrat...
2,610
<p>Is it possible to change the natural order of columns in Postgres 8.1?</p> <p>I know that you shouldn't rely on column order - it's not <em>essential</em> to what I am doing - I only need it to make some auto-generated stuff come out in a way that is more pleasing, so that the field order matches all the way from p...
<p>You can actually just straight up change the column order, but I'd hardly recommend it, and you should be very careful if you decide to do it.</p> <p>eg.</p> <pre> # CREATE TABLE test (a int, b int, c int); # INSERT INTO test VALUES (1,2,3); # SELECT * FROM test; a | b | c ---+---+--- 1 | 2 | 3 (1 row) </pre> ...
<p>Unfortunately, no, it's not. Column order is entirely up to Postgres.</p>
15,380
<p>What are the available libraries for creating pretty charts and graphs in a Python application?</p>
<p>I'm the one supporting CairoPlot and I'm very proud it came up here. Surely matplotlib is great, but I believe CairoPlot is better looking. So, for presentations and websites, it's a very good choice.</p> <p>Today I released version 1.1. If interested, check it out at <a href="http://linil.wordpress.com/2008/09/16/...
<p>You could also consider <a href="http://code.google.com/apis/chart/" rel="nofollow noreferrer">google charts</a>.</p> <p>Not technically a python API, but you can use it from python, it's reasonably fast to code for, and the results tend to look nice. If you happen to be using your plots online, then this would be...
7,589
<p>In Mootools, I'd just run <code>if ($('target')) { ... }</code>. Does <code>if ($('#target')) { ... }</code> in jQuery work the same way?</p>
<p>As the other commenters are suggesting the most efficient way to do it seems to be: </p> <pre><code>if ($(selector).length ) { // Do something } </code></pre> <p>If you absolutely must have an exists() function - which will be slower- you can do:</p> <pre><code>jQuery.fn.exists = function(){return this.length...
<p>For me <code>.exists</code> doesn't work, so I use the index :</p> <pre><code>if ($("#elem").index() ! = -1) {} </code></pre>
38,424
<p>Greetings.</p> <p>I'm looking for a way to parse a number of XML files in a particular directory with ASP.NET (C#). I'd like to be able to return content from particular elements, but before that, need to find those that have a certain value between an element.</p> <p>Example XML file 1:</p> <pre><code>&lt;file&g...
<p>If you are using .Net 3.5, this is extremely easy with LINQ:</p> <pre><code>//get the files XElement xe1 = XElement.Load(string_file_path_1); XElement xe2 = XElement.Load(string_file_path_2); //Give me all XML that has a filter of 'filter'. var filter_elements1 = from p in xe1.Descendants("filter") select p; var f...
<p>Use XPath?<br> <a href="http://www.w3schools.com/XPath/default.asp" rel="nofollow noreferrer">http://www.w3schools.com/XPath/default.asp</a></p>
13,340
<p>We recently lost a database and I want to recover the data from de Production.log.</p> <p>Every request is logged like this:</p> <p>Processing ChamadosController#create (for XXX.XXX.XXX.40 at 2008-07-30 11:07:30) [POST] Session ID: 74c865cefa0fdd96b4e4422497b828f9 Parameters: {"commit"=>"Gravar", "action"=>"cr...
<p>Have you tried using <a href="http://corelib.rubyonrails.org/classes/Marshal.html" rel="nofollow noreferrer">Marshal#load</a>? I'm not sure how you're generating those session files, but it's quite possible Rails just uses Marshal.</p>
<p>Have you tried using <a href="http://corelib.rubyonrails.org/classes/Marshal.html" rel="nofollow noreferrer">Marshal#load</a>? I'm not sure how you're generating those session files, but it's quite possible Rails just uses Marshal.</p>
6,280
<p>Would the following make the objects fulfil all characteristics that enums have in JavaScript? Something like:</p> <pre class="lang-js prettyprint-override"><code>my.namespace.ColorEnum = { RED : 0, GREEN : 1, BLUE : 2 } // later on if(currentColor == my.namespace.ColorEnum.RED) { // whatever } </code></p...
<p>Since 1.8.5 it's possible to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze" rel="noreferrer">seal and freeze the object</a>, so define the above as:</p> <pre><code>const DaysEnum = Object.freeze({&quot;monday&quot;:1, &quot;tuesday&quot;:2, &quot;wednesday&qu...
<pre><code>var DaysEnum = Object.freeze ({ monday: {}, tuesday: {}, ... }); </code></pre> <p>You don't need to specify an <em>id</em>, you can just use an empty object to compare enums. </p> <pre><code>if (incommingEnum === DaysEnum.monday) //incommingEnum is monday </code></pre> <p><strong>EDIT:</strong> If you are...
36,635
<p>I want to create a list of methods to execute. Each method has the same signature. I thought about putting delegates in a generic collection, but I keep getting this error:</p> <blockquote> <p>'method' is a 'variable' but is used like a 'method'</p> </blockquote> <p>In theory, here is what I would like to do:</...
<p>You need to cast the <code>object</code> in the list to a <code>BinaryOp</code>, or, better, use a more specific type parameter for the list:</p> <pre><code>delegate int BinaryOp(int x, int y); List&lt;BinaryOp&gt; methodsToExecute = new List&lt;BinaryOp&gt;(); methodsToExecute.add(Add); methodsToExecute.add(Subt...
<p>Have them all implement of common interface, say IExecuteable, and then have a List&lt;IExecutable></p> <p>Also, using delegates:</p> <pre><code>class Example { public delegate int AddDelegate(int x, int y); public List&lt;AddDelegate&gt; methods = new List&lt;AddDelegate&gt;(); int Execute() { ...
16,406
<p>How can we find out that how many applications are there in a database?</p>
<p>Not entirely sure what you're asking for here. I'm assuming you mean "Applications written using SQL Server 2005 as the database.".</p> <p>If that's what you want to know, I don't know of any single place you could get that information by it's always a good idea to try starting <a href="http://en.wikipedia.org/wiki...
<p>Do you mean stored procedures? You can have multiple applications using the same login credentials accessing a given database from the same web server, so you can't simply count databases or tables to get that number.</p>
33,851
<p>I'm using a Flashforge Pro and attempting to print a wheel about 6mm thick to serve as a platform. In other words, the wheel doesn't have to be solid, but spokes won't do the job. I've experimented with different temperatures, but, because of ABS' thermal expansion, I don't think that will solve the problem. Also...
<p>If you can, set your slicer to do honeycomb fill. Depending on the weight requirement choose maybe 10% - 20% fill. That ought to do the trick. It won't be solid, but it should be strong enough.</p> <p>What are you going to put on the platform?</p>
<p>So you just want a short, wide cylinder? Just print that, with low density infill (20-30%) and 6-8 solid top layers, three bottom, and three perimeters, and you'll be fine. For bed adhesion with something this wide, use a 10mm brim, one layer thick. And a heated chamber will help a lot.</p>
484
<p>Everyone remembers google browser sync right? I thought it was great. Unfortunately Google decided not to upgrade the service to Firefox 3.0. Mozilla is developing a replacement for google browser sync which will be a part of the Weave project. I have tried using Weave and found it to be very very slow or totally in...
<p>Mozilla Weave is capable of running on personal servers. It uses WebDAV to communicate with HTTP servers and can be configured to connect to private servers. I've tried setting it up on my own servers but with no success (Mainly because I'm not very good at working with Apache to configure WebDAV)</p> <p>I'm hoping...
<p>I've been using the Firefox Scrapbook extension, sync'd via FolderShare. It takes a little setup, but the nice thing is that Scrapbook grabs a local copy of each page so it works offline or if the site goes away.</p>
3,444
<p>OK, struggling to get a definitive answer to this one...</p> <p>I have an application written in VB6 which requires MDAC (2.8 for this installation). MDAC is included in the installer for my application. When the software is removed and re-installed on the same machine MDAC seems to go awry and I receive the follow...
<p>Have you tried the <a href="http://support.microsoft.com/kb/307255" rel="nofollow noreferrer">MDAC Component Checker</a> from Microsoft? It is a tool for diagnosing problems and reconfiguring MDAC installations.</p>
<p>I have found removing MDAC 2.8 to be all but impossible. However, having run the component checker, changing the registry entries and putting a different version of MSDART the problem has been fixed.</p> <p>The MSDART I have put in place is not the one suggested by the component checker, but it works. The component...
35,992
<p>It was a long holiday weekend, so I got the coding bug again and started playing around:</p> <p><a href="http://gfilter.net/junk/tileengine.jpg" rel="nofollow noreferrer">Mario http://gfilter.net/junk/tileengine.jpg</a></p> <p>I wrote a basic tile engine, but having never attempted this before, I am really struggl...
<p>Download the FarseerPhysics engine, have a look at how it works <a href="http://www.codeplex.com/FarseerPhysics" rel="nofollow noreferrer">http://www.codeplex.com/FarseerPhysics</a> I think it's the best thing available for XNA/Silverlight!</p>
<p>Ever heard of <a href="http://gamemaker.nl" rel="nofollow noreferrer">GameMaker</a>?</p>
43,089
<p>UPDATED: I'm asking this from a <strong>development perspective</strong>, however to illustrate, a canoical <em>non-development</em> example that comes to mind is that if it costs, say, $10,000 to keep a uptime rate of 99%, then it theoretically can cost $100,000 to keep a rate of 99.9%, and possibly $1,000,000 to...
<p>There's no way to answer this without knowing <em>what happens when your application goes down</em>.</p> <ul> <li>If someone dies when your application goes down, uptime is worth spending millions or even billions of dollars on (aerospace, medical devices).</li> <li>If someone may be injured if your software goes d...
<p>To expand on what "17 of 26" said, the answer depends on value to the customer. In the case of critical software, like aircrafct controller applications, the value to the customer of a high quality rating by whatever measure they use is quite high. To the user of an RSS feed reader, the value of high quality is co...
7,833
<p>Is there a way to check to see if an Microsoft Office process (i.e. Word, Excel) has hung when using Office Automation? Additionally, if the process is hung, is there a way to terminate it?</p>
<p>Let me start off saying that I don't recommend doing this in a service on a server, but I'll do my best to answer the questions.</p> <p>Running as a service makes it difficult to clean up. For example with what you have running as a service survive killing a hung word or excel. You may be in a position to have to...
<p>I can answer the latter half; if you have a reference to the application object in your code, you can simply call "Quit" on it:</p> <pre><code>private Microsoft.Office.Interop.Excel.Application _excel; // ... do some stuff ... _excel.Quit(); </code></pre> <p>For checking for a hung process, I'd guess you'd want to...
3,122
<p>I have a number of code value tables that contain a code and a description with a Long id.</p> <p>I now want to create an entry for an Account Type that references a number of codes, so I have something like this:</p> <pre><code>insert into account_type_standard (account_type_Standard_id, tax_status_id, recipient_...
<p>Outter joins don't work "as expected" in that case because you have explicitly told Oracle you only want data if that criteria on that table matches. In that scenario, the outter join is rendered useless.</p> <p>A work-around</p> <pre><code>INSERT INTO account_type_standard (account_type_Standard_id, tax_status...
<pre><code>insert into received_messages(id, content, status) values (RECEIVED_MESSAGES_SEQ.NEXT_VAL, empty_blob(), ''); </code></pre>
15,929
<p>I would like to restrict access to my <code>/admin</code> URL to internal IP addresses only. Anyone on the open Internet should not be able to login to my web site. Since I'm using Lighttpd my first thought was to use <code>mod_rewrite</code> to redirect any outside request for the <code>/admin</code> URL back to ...
<p>Try this:</p> <pre><code>$HTTP["remoteip"] == "192.168.0.0/16" { /* your rules here */ } </code></pre> <p>Example from the <a href="http://redmine.lighttpd.net/wiki/lighttpd/Docs:Configuration" rel="nofollow noreferrer">docs</a>:</p> <pre><code> # deny the access to www.example.org to all user which # are...
<p>This worked for me:</p> <pre><code>$HTTP["remoteip"] != "192.168.1.1/254" { $HTTP["url"] =~ "^/intranet/" { url.access-deny = ( "" ) } } </code></pre> <p><code>!=</code> worked over <code>==</code>.</p>
47,605
<p>This caught my attention last night.</p> <p>On the latest <a href="http://altnetpodcast.com/episodes/10-oop-in-ruby" rel="nofollow noreferrer">ALT.NET Podcast</a> Scott Bellware discusses how as opposed to Ruby, languages like C#, Java et al. are not truly object oriented rather opting for the phrase &quot;class-ori...
<p>The duck typing comments here are more attributing to the fact that Ruby and Python are more <em>dynamic</em> than C#. It doesn't really have anything to do with it's OO Nature.</p> <p>What (I think) Bellware meant by that is that in Ruby, everything is an object. Even a class. A class definition is an instance ...
<p>I'll take a stab at this.</p> <p>Python and Ruby are duck-typed. To generate any maintainable code in these languages, you pretty much have to use test driven development. As such, it is very important for a developer to easily inject dependencies into their code without having to create a giant supporting framewor...
7,533
<p>I've tried to apply a sharp blade (the one that came witht he printer) to scrape the model off like I usually do but this model seems overly robust. What method can I do to take this off safely? </p> <p>See image <a href="https://i.stack.imgur.com/c9nIu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur...
<p>Unfortunately, you may have to destroy this part, or the build surface, just to get it off the plate. It looks really on there, and if you can't get under it even with a razor that further supports my gut instinct. It's happened to me before, just part of learning how to print with a particular material on a particu...
<p>Some comments assume that this is a PLA print. IS it PLA, or something more exotic?</p> <p>If PLA, then try softening the object by heating the print with a heat gun or hair drier. </p> <p>I assume that the bed is not easily removed and that you can not flex the bed. If you can remove the bed by unscrewing it, i...
1,556
<p>Suppose I have a method that takes an object of some kind as an argument. Now say that if this method is passed a null argument, it's a fatal error and an exception should be thrown. Is it worth it for me to code something like this (keeping in mind this is a trivial example):</p> <pre><code>void someMethod(Some...
<p>I prefer the <code>ArgumentNullException</code> over the <code>NullReferenceException</code> that not checking the argument would provide. In general, my preference is to always check for nullity before trying to invoke a method on a potentially null object.</p> <p>If the method is a constructor, then it would dep...
<p>You can use syntax like the following to not just throw an <code>ArgumentNullException</code> but have that exception name the parameter as part of its error text as well. E.g.;</p> <pre><code>void SomeMethod(SomeObject someObject) { Throw.IfArgNull(() =&gt; someObject); //... do more stuff } </code></pre> ...
48,142
<p>In most modern IDEs, you can have Debug and Release build configurations, and you can quickly switch between them.</p> <p>In Delphi 7, this does not seem to be possible. I have to go to Project Settings and toggle optimization and all the debug information stuff manually.</p> <p>It would be great if there was a pl...
<p>You can very easily add project configurations, similar to what other IDEs offer, using Andreas Hausladen's great <a href="http://andy.jgknet.de/blog/?page_id=10" rel="noreferrer">DDevExtensions</a> IDE expert. Just make sure to download the 1.6 version from the link I mentioned, since later versions only work with ...
<p>This feature was added only in Delphi 2009.</p> <p>For older versions of Delphi you can write two copies of .cfg file, one with debug options and one with release options, and compile your program calling <strong>dcc32.exe</strong> from within a batch file.</p> <p>Something like this:</p> <pre><code>rem release.b...
21,223
<p>Of course, there are a whole range of possible errors relating to document validity, but my immediate stumbling block occurs when changing a paragraph (<code>p</code>) into an <code>address</code> element. My current method is (more-or-less):</p> <pre><code>var p = $('p#test'); p.replaceWith('&lt;address&gt;' + p.h...
<pre><code>var p = $('p#test'); var a = $('&lt;address&gt;'). append(p.contents()); p.replaceWith(a); </code></pre> <p>Your solution is subject to all sorts of horrible HTML escaping issues and possibly injection attacks.</p>
<p>You'll could use a placeholder around the title:</p> <pre> &lt;span id="demo">&lt;h1>Title&lt;/h1>&lt;/span> </pre> <p>Then use JavaScript DOM to create new values for the innerHTML property.</p> <pre> &lt;script type="javascript"> setTitle = function(id, tag, title) { var container = document.getElementById(i...
29,768
<p>I have an Ender 3 and I'm experiencing an issue where it won't print on the edges. Near the outside of the bed plastic just peels away. Bed is level - verified multiple times.</p> <p>The nozzle appears to be dragging the freshly extruded filament away before it has a chance to cool. Straight lines and wide curves pr...
<p>I used to have the same problem. Put masking or scotch tape on the bed, it should help with adhesion. I think the problem is that the bed is very dirty with finger grease and other things.</p>
<p>It sounds like it may be due to uneven heating. Check with an IR thermometer to make sure. If you're sure the bed is clean and has even heating, you may want to try a different surface. G10 is cheap and almost always perfectly flat.</p>
2,038
<p>In what domains do each of these software architectures shine or fail?</p> <p>Which key requirements would prompt you to choose one over the other?</p> <p>Please assume that you have developers available who can do good object oriented code as well as good database development.</p> <p>Also, please avoid holy wars...
<p>Every one of these tools provides differing layers of abstraction, along with differing points to override behavior. These are architecture choices, and all architectural choices depend on trade-offs between technology, control, and organization, both of the application itself and the environment where it will be d...
<p>ORMs and code generators are kind of on one side of the field, and stored procedures are on another. Typically, it's easier to use ORMs and code generators in greenfield projects, because you can tailor your database schema to match the domain model you create. It's much more difficult to use them with legacy projec...
10,201
<p>3-Tier design has been my standard design philosophy for years for database driven applications, and it has never failed me. For those who practice it, describe your layers.</p> <p>I've found that many people muddle up the business tier and the data access tier, making it more like a 2.5-Tier design.</p> <p>I pref...
<p>I've been doing primarly web apps for a while now and have been following 3-Tier as well:</p> <p>UI: Pure ASPX pages. It is actually kind of hard to push your business layer down from here at times because doing a quick calculation or something seems so easy to do here. However, I've gotten disciplined enough to ma...
<p>We once approached it using the following: - UI Layer (where all the UI is) - Business layer (where all the business logic is) - Data layer (where all the DB access is)</p>
16,253
<p>This is probably pretty basic... but I don't seem to get it:</p> <p>How does </p> <pre><code>(2 &amp; 1) = 0 (3 &amp; 1) = 1 (4 &amp; 1) = 0 </code></pre> <p>etc..</p> <p>This pattern above seems to help find even numbers</p> <p>or </p> <pre><code>(0 | 1) = 1 (1 | 1) = 1 (2 | 1) = 3 (3 | 1) = 4 (4 | 1) = 5 (5 ...
<p>It works the same way in C# as it does in binary. </p> <p><code>2 | 1 = 3</code> and <code>4 | 1 = 5</code>. </p> <p>To understand this, you need to think about the binary representation of 1,2,3,4,and 5:</p> <p><code>010 | 001 = 011</code> and <code>100 | 001 = 101</code>.</p> <p>Similarly: </p> <p><code>010...
<p>It is doing bitwise operations on the integer. That it is doing a logical or/and of each bit in the first integer with the corresponding bit in the other integer. It then returns the result of all of these operations. For example, 4 = 0100 and 1 = 0001, a logical and of these would and bit the bits in order and g...
41,339
<p>I'm interested in using Functional MetaPost on Mac OS X:</p> <p><a href="http://cryp.to/funcmp/" rel="nofollow noreferrer">http://cryp.to/funcmp/</a></p> <p>I'm looking for a tutorial like:</p> <p><a href="http://haskell.org/haskellwiki/Haskell_in_5_steps" rel="nofollow noreferrer">http://haskell.org/haskellwiki/...
<p>the output of mpost is eps, which you can view in ghostview...</p>
<p>the output of mpost is eps, which you can view in ghostview...</p>
28,318
<p>This question intends to be technology-agnostic. Which kind of web framework do you prefer, and when: <em>Pure MVC or event-driven component-oriented?</em></p> <p>Just to make the point in "technology-agnosticism", here I name a few MVC vs. component web frameworks, in diverse technologies / languages:</p> <ul> <l...
<p>I'm a php dev by day; however, I strongly prefer Wicket and/or Lift, especially the latter. The problem with Prado seems to be that the controller is tied to the page, rather than the logical controls on the page, otherwise, it still seems better than most other options in PHP land. I think all boils down to reusabi...
<p>I loosely follow these guidelines:</p> <ul> <li>Web Forms/SQLDataSource- Quick and dirty app for internal use to show reporting or some other such data.</li> <li>MVC- Simple to complex business logic for a core product.</li> <li>MVC/REST Web Services/jQuery- HTML/Whatever type of client RIA's (when user experience ...
12,518
<p>I have an Access 2003 file that contains 200 queries, and I want to print out their representation in SQL. I can use Design View to look at each query and cut and paste it to a file, but that's tedious. Also, I may have to do this again on other Access files, so I definitely want to write a program to do it.</p> <p...
<p>Procedures are what you're looking for:</p> <pre><code>OleDbConnection conn = new OleDbConnection(connectionString); conn.Open(); DataTable queries = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Procedures, null); conn.Close(); </code></pre> <p>This will give you a DataTable with the following columns in it (among o...
<p>Not in C#, but may be a good place to start:</p> <p><a href="http://www.datastrat.com/Code/DocDatabase.txt" rel="nofollow noreferrer">http://www.datastrat.com/Code/DocDatabase.txt</a></p>
48,535
<p>How do I format a number in Java?<br /> What are the &quot;Best Practices&quot;?</p> <p>Will I need to round a number before I format it?</p> <blockquote> <p><code>32.302342342342343</code> =&gt; <code>32.30</code></p> <p><code>.7323</code> =&gt; <code>0.73</code></p> </blockquote> <p>etc.</p>
<p>From <a href="http://bytes.com/forum/thread16212.html" rel="noreferrer">this thread</a>, there are different ways to do this:</p> <pre><code>double r = 5.1234; System.out.println(r); // r is 5.1234 int decimalPlaces = 2; BigDecimal bd = new BigDecimal(r); // setScale is immutable bd = bd.setScale(decimalPlaces, B...
<p>There are two approaches in the standard library. One is to use java.text.DecimalFormat. The other more cryptic methods (String.format, PrintStream.printf, etc) based around java.util.Formatter should keep C programmers happy(ish).</p>
7,332
<p>I'm interested in assigning the tag name of the root element in an xml document to an xslt variable. For instance, if the document looked like (minus the DTD):</p> <pre><code>&lt;foo xmlns="http://....."&gt; &lt;bar&gt;1&lt;/bar&gt; &lt;/foo&gt; </code></pre> <p>and I wanted to assign the string 'foo' to an x...
<p>I think you want to retrieve the name of the outermost XML element. This can be done like in the following XSL sample:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:variable name="outermostElementName" se...
<p>you want <strong><a href="http://zvon.org/xxl/XSLTreference/Output/function_local-name.html" rel="nofollow noreferrer">local-name()</a></strong></p>
48,134
<p>How do you concatenate characters in java? Concatenating strings would only require a <code>+</code> between the strings, but concatenating chars using <code>+</code> will change the value of the char into ascii and hence giving a numerical output. I want to do <code>System.out.println(char1+char2+char3...</code> an...
<p>Do you want to make a string out of them?</p> <pre><code>String s = new StringBuilder().append(char1).append(char2).append(char3).toString(); </code></pre> <p>Note that</p> <pre><code>String b = "b"; String s = "a" + b + "c"; </code></pre> <p>Actually compiles to</p> <pre><code>String s = new StringBuilder("a")...
<pre><code>System.out.print(a + "" + b + "" + c); </code></pre>
42,538
<p>My understanding is that in unix, when memory is freed, the memory doesn't get returned back to the operating system, it stays in the process to be used again for the next call to malloc.</p> <p>On windows, I understand that the memory actually gets returned to the operating system.</p> <p>Is there any big differe...
<p>There isn't much difference between Windows and Unix with respect to that.</p> <p>In both, there are two levels of allocation. The operating system allocates memory to the process in large chunks (one page or more; on x86, the page size is usually 4096 bytes). The runtime libraries, running within the process, subd...
<p>The malloc function returns either a null pointer or a pointer to the allocated space."</p> <p>This suggests that any call to malloc may fail. It seems that the intent of the Standard is that memory is not returned to the OS.</p>
29,206
<p>I'm just wondering if there's a better way of doing this in SQL Server 2005.</p> <p>Effectively, I'm taking an originator_id (a number between 0 and 99) and a 'next_element' (it's really just a sequential counter between 1 and 999,999). We are trying to create a 6-character 'code' from them. </p> <p>The originator...
<p>Seeing as it's SQL Server 2005, any reason not to use a CLR stored procedure? You could use your CLR language of choice then and it'd probably be a relatively direct port of your existing Delphi code.</p>
<p>Although it can clearly be done in SQL Server 2005, I think that it's of sufficient 'non-database-ness' that some kind of precompiled, high-level language routine makese sense.</p> <p>I've written DLLs for Interbase/Firebird, and T-SQL sprocs for SQL Server, but never a CLR routine. It will be an interesting exerci...
7,907
<p>How can you get a <strong>raw</strong> socket in Perl, and then what's the best way to built a packet for use with it?</p>
<p>Perhaps searching <a href="http://search.cpan.org" rel="nofollow noreferrer">CPAN</a> might help? <a href="http://search.cpan.org/dist/IO" rel="nofollow noreferrer">IO::Socket</a> comes to mind.</p>
<p>Be aware that if you're trying to use raw sockets to send a pile of SYN packets, and you just "use Socket;" that's going to fill up your ARP tables and bomb out with "No buffer space available" and a stack of "CLOSE_WAIT" entries in "netstat" (which stops your machine doing any more connections of any kind until som...
24,244
<p>I have a web app with a web-based configuration UI. If the user accesses via HTTP, I want to alert the user that they should really use HTTPS and give them a link to click on to get to the HTTPS-prefixed URL.</p> <p>Now, this is pretty straightforward if we're on the default ports, but often, we're not - for exampl...
<p>You could transfer them automatically to https by using configuration only.</p> <p>in your web.xml:</p> <pre><code>&lt;user-data-constraint&gt; &lt;transport-guarantee&gt; CONFIDENTIAL &lt;/transport-guarantee&gt; &lt;/user-data-constraint&gt; </code></pre> <p>and in your server.xml in the HTTPConnector:<...
<p>In case you have a load balancer, usually it can be configured to perform that kind of redirect automatically.</p>
43,500
<p>I'm using a Prusa i3 MK3S printer. After ~8 months of printing PLA, PET-G, ABS I decided to buy some HIPS and print something with it. I cannot print >1 filaments at once, so I'm not using it as a support for ABS, <strong>I want to create some high durability working models, like gears, robot parts etc.</strong> </p...
<p>It might. If HIPS is a single material with consistent properties, it might have a narrower temperature range. Online references suggest up to 240&nbsp;&deg;C. Try that, then 245 and 250&nbsp;&deg;C. Maybe higher. </p>
<p>I've been using HIPS for nearly 2 years now to print the housings of EDF units for RC planes. They come out light and strong but have poor layer adhesion, especially on thin-wall parts.</p> <p>Normally I print at with a 260 °C nozzle and 100 °C bed but will try higher temperature when I upgrade my Ender 5 to a 32-bi...
1,543
<p>I'm working with jQuery and looking to see if there is an easy way to determine if the element has a specific CSS class associated with it.</p> <p>I have the id of the element, and the CSS class that I'm looking for. I just need to be able to, in an if statement, do a comparison based on the existence of that clas...
<p>Use the <code>hasClass</code> method:</p> <pre><code>jQueryCollection.hasClass(className); </code></pre> <p>or</p> <pre><code>$(selector).hasClass(className); </code></pre> <p>The argument is (obviously) a string representing the class you are checking, and it returns a boolean (so it doesn't support chaining li...
<p>Check the official jQuery FAQ page :</p> <p><a href="http://learn.jquery.com/using-jquery-core/faq/how-do-i-test-whether-an-element-has-a-particular-class/" rel="nofollow">How do I test whether an element has perticular class or not</a></p>
32,951
<p>Namely, how does the following code:</p> <pre><code>var sup = new Array(5); sup[0] = 'z3ero'; sup[1] = 'o3ne'; sup[4] = 'f3our'; document.write(sup.length + &quot;&lt;br /&gt;&quot;); </code></pre> <p>output '5' for the length, when all you've done is set various elements?</p> <p>My 'problem' with this code is that ...
<p>Everything in JavaScript is an object. In the case of an <code>Array</code>, the <code>length</code> property returns the size of the internal storage area for indexed items of the array. Some of the confusion may come into play in that the <code>[]</code> operator works for both numeric and string arguments. For...
<p>A JavaScript array is an object just like any other object, but JavaScript gives it special syntax.</p> <pre><code>arr[5] = "yo" </code></pre> <p>The above is <strong>syntactic sugar</strong> for</p> <pre><code>arr.insert(5,"yo") </code></pre> <p>which is how you would add stuff to a regular object. It's what is...
47,773
<p>So I've got a nice Java project, build with Ant to a /dist folder.<br> The whole project is under version control, so I can deploy the latest version just by 'svn export' on the path to the dist folder.<br> But my build keeps deleting the .svn folders inside my dist folder, and all its dependents, because it cleans ...
<p>To have dist in source control <em>can</em> be considered as good practice if you want your source control system to be a <strong><em>unique referential</em></strong> for all:</p> <ul> <li>developers</li> <li>assemblers (unit-testing)</li> <li>homologation testers (you query a bunch of dist on your integration plat...
<p>Simple. Don't check in /dist in to version control.</p> <p>Version Control really should not have any generated code/binaries/jars/what-have-you.</p>
27,219
<p>I'm just getting into creating some WCF services, but I have a requirement to make them backward compatible for legacy (.NET 1.1 and 2.0) client applications. </p> <p>I've managed to get the services to run correctly for 3.0 and greater clients, but when I publish the services using a basicHttpBinding endpoint (wh...
<p>OK, we needed to resolve this issue in the short term, and so we came up with the idea of a "interop", or compatibility layer.</p> <p>Baiscally, all we did was added a traditional ASMX web service to the project, and called the WCF service from that using native WCF calls. We were then able to return the appropria...
<p>You do have to use the XmlSerializer. For example:</p> <pre><code>[ServiceContract(Namespace="CentreServiceNamespace")] [XmlSerializerFormat(Style=OperationFormatStyle.Document, SupportFaults=true, Use=OperationFormatUse.Literal)] public interface ICentreService { [OperationContract(Action="CentreServiceNamespa...
2,770
<p>I'd like to set a cookie via Django with that has several different values to it, similar to .NET's <a href="http://msdn.microsoft.com/en-us/library/system.web.httpcookie_members(VS.80).aspx" rel="nofollow noreferrer">HttpCookie.Values</a> property. Looking at the <a href="http://docs.djangoproject.com/en/dev/ref/re...
<p>.NETs multi-value cookies work exactly the same way as what you're doing in django using a separator. They've just abstracted that away for you. What you're doing is fine and proper, and I don't think Django has anything specific to 'solve' this problem.</p> <p>I will say that you're doing the right thing, in not...
<p>Django does not support it. The best way would be to separate the values with arbitrary separator and then just split the string, like you already said.</p>
15,666
<p>I have an OpenGL ES game that I am hacking together. One part of it involves looking at a large "map-like" area and then double-tapping on one part to "zoom into" it. How would you use OpenGL ES to provide this effect (given that it may need to zoom in on different parts of the map). </p> <p>I've heard of glSc...
<p>The 2-D zooming you describe might be better achieved using Core Animation. NSView (and its NDA'd iPhone counterpart) provide implicit animation when you change their frame. All you'd need to do in this case would be to set the frame's origin.x and origin.y and size.width and size.height to such values to make the...
<p>Respectfully, the answer is to take a few days to learn the basics of OpenGL, and there are much better places for that on the net than here.</p>
12,914
<p>Simple example: I want to have some items on a page (like divs or table rows), and I want to let the user click on them to select them. That seems easy enough in jQuery. To save which items a user clicks on with no server-side post backs, I was thinking a cookie would be a simple way to get this done.</p> <ol> <li>...
<p>The default JavaScript "API" for setting a cookie is as easy as:</p> <pre><code>document.cookie = 'mycookie=valueOfCookie;expires=DateHere;path=/' </code></pre> <p>Use the jQuery cookie plugin like:</p> <pre><code>$.cookie('mycookie', 'valueOfCookie') </code></pre>
<p>It seems the jQuery cookie plugin is not available for download. However, you can download the same jQuery cookie plugin with some improvements described in <em><a href="http://jquery-howto.blogspot.com/2010/09/jquery-cookies-getsetdelete-plugin.html" rel="nofollow noreferrer">jQuery &amp; Cookies (get/set/delete &a...
12,083
<p>We recently started using maven for dependency management. Our team uses eclipse as it's IDE. Is there an easy way to get eclipse to refresh the maven dependencies without running mvn eclipse:eclipse?</p> <p>The dependencies are up to date in the local maven repository, but eclipse doesn't pick up the changes until...
<p>Have you tried using the <a href="http://m2eclipse.codehaus.org/" rel="noreferrer">m2eclipse</a> plugin? I use it with eclipse and it maintains the eclipse .classpath when I add dependencies. It'll also check for updated dependencies.</p>
<p>You generate the special eclipse files with <code>mvn eclipse:eclipse</code>, but once you've done that, you should let a <a href="http://maven.apache.org/eclipse-plugin.html" rel="nofollow noreferrer">plugin</a> handle the dependencies while inside eclipse.</p> <p>That's how we do it at my work place, and it gener...
16,499
<p>I want to make my .Net application display a notification in the system tray. So I want to show an icon for that, can anyone tell how to do that?</p>
<p>Open the main Form for your application, go to the Toolbox, open the All Windows Forms section and drop a NotifyIcon on your form. Then add the icon you want to the NotifyIcon.</p> <p>You may also want to change the ShowInTaskbar property of your form to false when the form is minimized and handle the double click ...
<p>In .Net apps you can specify the file to use as an icon - it can be a bitmap or png etc. so just use your favourite image editing program to create you icon.</p> <p>This <a href="http://www.developer.com/net/csharp/article.php/3336751" rel="nofollow noreferrer">article</a> gives advice on getting your app to put an...
38,832
<p>In our product we have a big utilities file that we require (with <code>do</code>) at the beginning of a lot of our files. Is there a reason <em>not</em> to turn this into a module? For example, instead of doing this:</p> <pre><code>do '../dbi_utilities.pl'; our ($db,$user,$pw,$attr); my $Data = DBI-&gt;connect($...
<p>The only reason not to do this is time.</p> <p>That is, it'll take time to clean up your interface, as well as all calling apps to use the new interface.</p> <p>What it'll cost you in time now will be more than made up when you start using proper tests ("make test" or "./Build test" or just "prove ...") and be abl...
<p>You get all of the cool module stuff, encapsulation, module specific functions, and so on.</p> <p>Notice though, by using <code>use</code> with your syntax. creating an object for the AppUtil namespace, and calling the connect subroutine. for your utilities.</p> <p>Also you must have 1; at the end of your file.</p...
22,329
<p>How do I post a form to an external site using an ASP.NET MVC controller?</p> <p><strong>EDIT:</strong> Ok... I have a view with some data on it. After the user completes the form I need to do a postback with a specified form format to an external site (like for paypal). After I posted the constructed form I need t...
<p>You have to do the POST on the server-side..</p> <p>of which this guy has written a helper class to do <a href="https://web.archive.org/web/20210123193021/http://geekswithblogs.net/rakker/archive/2006/04/21/76044.aspx" rel="nofollow noreferrer">Http Post in C#</a> (<a href="https://pastebin.com/f15346568" rel="nofol...
<p>How about sending a redirect to the browser.</p>
48,148
<p>Is there a way to convert a HTML string into a Image .tiff file?</p> <p>I am using C# .NET 3.5. The requirement is to give the user an option to fact a confirmation. The confirmation is created with XML and a XSLT. Typically it is e-mailed. </p> <p>Is there a way I can take the HTML string generated by the transf...
<p>Here are some free-as-in-beer possibilities:</p> <p>You can use the PDFCreator printer driver that comes with ghostscript and print directly to a TIFF file or many other formats.</p> <p>If you have MSOffice installed, the Microsoft Office Document Image Writer will produce a file you can convert to other formats.<...
<p>A starting point might be the software of <a href="http://www.websupergoo.com" rel="nofollow noreferrer">WebSuperGoo</a>, which provide rich image editing products, cheap or for free.</p> <p>I know for sure their PDF Writer can do basic HTML (<a href="http://www.websupergoo.com/helppdf6net/source/3-concepts/b-htmls...
7,752
<p>What is the best or most concise method for returning a string repeated an arbitrary amount of times?</p> <p>The following is my best shot so far:</p> <pre><code>function repeat(s, n){ var a = []; while(a.length &lt; n){ a.push(s); } return a.join(''); } </code></pre>
<blockquote> <p><strong>Note to new readers:</strong> This answer is old and and not terribly practical - it's just "clever" because it uses Array stuff to get String things done. When I wrote "less process" I definitely meant "less code" because, as others have noted in subsequent answers, it performs like a p...
<p>Recursive solution using divide and conquer:</p> <pre><code>function repeat(n, s) { if (n==0) return ''; if (n==1 || isNaN(n)) return s; with(Math) { return repeat(floor(n/2), s)+repeat(ceil(n/2), s); } } </code></pre>
24,776
<p>How do I configure SSRS/Windows Server 2003, so that I can setup email delivery via a remote SMTP server that requires username and password.</p> <p>I can configure SSRS with an SMTP address and other parameters, but nowhere is it possible to configure it with smtp username and password. </p> <p>I have hunted arou...
<p>Here are the steps to set this up using only Microsoft SSRS/Windows Server 2003 components.</p> <p>1) Install SMTP server in Add/Remove programs / App Server / IIS<br> <strong>In IIS Manager:</strong><br> 2) add the domain (as a remote type) you will be sending as such as <em>yourwebsite.com</em><br> 3) Under Defau...
<p>This might help you a little: C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\rsreportserver.config contains all of the configurations settings in the . I don't see exactly what you want so you'll probably have to perform some relay tricks.</p>
29,488
<p>So let's say I have an eBay-type application where only the seller can edit his/her listing. How do I go about restricting access to the Edit action based on the Id of the item we're editing and the currently logged in user?</p> <p>As far as I can tell, the Authorize attribute only allows you to restrict access to...
<p>A custom attribute deriving from IAuthorizeFilter.</p>
<p>This looks like a pretty good example of controlling actions based on users and roles. <a href="http://www.coderjournal.com/2008/03/securing-mvc-controller-actions/" rel="nofollow noreferrer">http://www.coderjournal.com/2008/03/securing-mvc-controller-actions/</a></p> <p>I'm brand-spanking new at MVC though, so I c...
26,348
<p>Looking for advice (perhaps best practice).</p> <p>We have a MS Word document (Office 2007) that we are extracting text from a cell.</p> <p>We can use the following:</p> <pre><code>string text = wordTable.cell(tablerow.index, 1).Range.Text; </code></pre> <p>The text is extracted; however we seem to get extra cha...
<p>I would break it out into a separate method but use the replace implementation since it's the simplest solution. You could always change the implementation later if you run into problem (like the text contains more than one <code>\r\a</code> and needs to be preserved)</p> <p>So:</p> <pre><code>private string strip...
<p>I would definitely opt for breaking it out into a separate method personally. it helps with code readability and makes it a lot easier to change if needed in the future.</p>
49,532
<p>I'm working on an asp.net web site. We have to use com interop to interact with legacy vb6 activex components. The components in many cases rely on receiving a context object (which is itself a vb6 activex component) as a parameter. The context object is fairly costly to construct.</p> <p>Therefore one idea is t...
<p>I think you will very rapidly get problems with one request blocking another.</p> <p>ASP.NET by default initialises COM on its threads to put the thread in a multi-threaded apartment. VB6 components were apartment-model at best. That means that when the MTA thread creates the component, it's put into the main STA i...
<p>I'd persist it in the cache, that way its not constructed once per user, unless that's the desired effect.</p>
22,353
<p>I need to take in a Date Range from the UI, retrieve the records within that range and plot a graph. This is the relevant section in my Rails view.</p> <pre><code>&lt;span&gt; &lt;%= check_box_tag :applyRange, @params[:applyRange]%&gt; From &lt;%= select_date Time.now, :prefix=&gt;"fromDate" %&gt; ...
<p>I don't know much about the appsettings architecture (I've never really used it), but you can define different values for constants using a bit of MSBuild magic.</p> <p>Create two .cs files, Constants1.cs and Constants2.cs (or name them after your configurations).</p> <p>In each file, define a class called Constan...
<p>You could add a prebuild or postbuild task to the proj, you have access to the ConfigurationName from there. Would be fairly easy to do something like "copy Web.config.debug Web.config"</p>
43,920
<p>Are there any IDE's for developing HLSL code? The three key features I want are:<br> 1) syntax highlighting<br> 2) auto-complete<br> 3) interaction debugging</p> <p>Visual Studio doesn't do any of these things, and it doesn't seem that RenderMonkey or FX Composer do either.</p> <p>Is there some IDE that I'm not a...
<p>Have you actually tried ATI's RenderMoney or NVidia's FX Composer?</p> <p>Both actually provide syntax highlighting. Futher more, NVidia's Cg toolkits actually allows you to enable syntaxhightling in Visual Studio with some custom setting.</p> <p>As for auto-completion, I don't think it's much needed as compare to...
<p>Now with Visual Studio 11 there is a "real hlsl ide and debugger". It was detailed at <a href="http://blogs.msdn.com/b/vcblog/archive/2011/11/08/10235150.aspx" rel="nofollow">Game Debugging in Visual Studio 11</a> and is available at <a href="http://blogs.msdn.com/b/chuckw/archive/2012/02/29/visual-studio-11-beta.as...
17,763
<p>I've trouble setting up Vim (7.1.xxx) for editing Python files (*.py). Indenting seems to be broken (optimal 4 spaces). I've followed some tutorials I found via Google. Still no effect :/ Please help.</p>
<p>I use this on my macbook:</p> <pre><code>" configure expanding of tabs for various file types au BufRead,BufNewFile *.py set expandtab au BufRead,BufNewFile *.c set expandtab au BufRead,BufNewFile *.h set expandtab au BufRead,BufNewFile Makefile* set noexpandtab " --------------------------------------------------...
<p>for more advanced python editing consider installing the <a href="http://eigenclass.org/hiki/simplefold" rel="nofollow noreferrer">simplefold</a> vim plugin. it allows you do advanced code folding using regular expressions. i use it to fold my class and method definitions for faster editing.</p>
9,081
<p>Is it possible to convert floating point exceptions (signals) into C++ exceptions on x86 Linux?</p> <p>This is for debugging purposes, so nonportability and imperfection is okay (e.g., if it isn't 100% guaranteed that all destructors are called).</p>
<p>If your C++ standard library implementation supports the TR1 functions <code>fetestexcept</code>, <code>feraiseexcept</code> and <code>feclearexcept</code> (mine doesn't yet so I can't test this) you can detect five kinds of floating point errors and then you can throw whatever exceptions you want.</p> <p>See <a hr...
<p>The basic idea will be for you to install the appropriate signal handlers for floating point exceptions. Inside your signal handler, you can throw an exception (or send a user-defined signal to another process which will raise the exception, or send a message to another thread for something similar, etc. etc. etc)....
11,126
<p>I want to wrap a piece of code that uses the Windows Impersonation API into a neat little helper class, and as usual, I'm looking for a way to go test-first. However, while WindowsIdentity is a managed class, the LogonUser call that is required to actually perform the logging in as another user is an unmanaged funct...
<p><em>Guideline: Don't test code that you haven't written.</em><br> You shouldn't be concerned with WinAPI implementation not working (most probably it works as expected). Your concern should be testing the 'Wiring' i.e. if your code makes the right WinAPI call. In which case, all you need is to mock out the interfac...
<p>I am not sure if I follow you.. You don't want to test the PInvoke yourself (you didn't write it) so you want to test that the wrapper class is performing as expected right?</p> <p>So, just create your interface in the wrapper class and test against that?</p> <p>In terms of needing to set up users etc, I think tha...
7,689
<p>I'm trying to configure Apache to allow read only access and ask for user to write to a SVN repository when you are coming from the local network (10.*) but not allow any access unless logged in when coming from external network.</p> <p>I sort of understand how the Order, Deny, Allow, and Limit directives work but ...
<p>Yes, you can write:</p> <pre><code>&lt;#if hot&gt; it's hot &lt;#else&gt; it's not &lt;/#if&gt; </code></pre> <p>And if you're doing lots of freemarker, I really can recommend IntelliJ IDEA 8, its freemarker support really helps...</p>
<p><em>iberck</em> had already pointed out the docs. But here is the exact documentation about <a href="http://freemarker.sourceforge.net/docs/ref_directive_if.html" rel="nofollow noreferrer">if-else in FreeMarker</a>. </p>
37,930
<p>I'm developing a SWT/JFace application using the libraries from Eclipse 3.4.1. I encounter the following problem on Windows (Vista 32bit) and Ubuntu 8.10 32bit:</p> <p>I create a menu bar in the createMenuManager method of the JFace ApplicationWindow. I add MenuManagers for file, edit and help.</p> <p>I then add a...
<p>Update: There is a duplicate bug of mine which also contains a workaround. The bug url is: <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=243758" rel="nofollow noreferrer">https://bugs.eclipse.org/bugs/show_bug.cgi?id=243758</a></p> <p>Basically the workaround is to call <code>create()</code> on the <code>A...
<p>AFAIK <code>setAccelerator(.)</code> does nothing else than adding the appropriate text to your <code>MenuItem</code>. You are responsible to register for an <code>KeyUp</code> event and react on it.</p> <p>You can use <code>Display.addFilter(SWT.KeyUp, myListener)</code> to register your <code>Listener</code> inde...
29,673
<p>I want to mount some internal and external NTFS drives in CentOS 5.2, preferably automatically upon boot-up. Doesn't matter if it's read/write or read-only, but read/write would be preferred, if it's safe.</p> <p>Edit: Thanks for all answers, I summarized them below =)</p>
<p>To answer my own question: PostMan and mgb led me to the right path, but their answers did not contain complete solution.</p> <p>Note: A short manual/wiki on this question is here: <a href="http://wiki.centos.org/TipsAndTricks/NTFSPartitions" rel="noreferrer">http://wiki.centos.org/TipsAndTricks/NTFSPartitions</a><...
<p>First enable the repository Epel</p> <pre><code>yum install epel-release </code></pre> <p>Then install ntfs</p> <pre><code>yum install ntfs-3g </code></pre>
17,508
<p>I have a <code>T-Mobile G1</code> and I'm going to download the developer SDK and see if I can create a few simple apps for my phone. If you've done similar development, please answer below and tell me about your experience. Please share any links you found especially useful.</p>
<p>I started from here</p> <p><a href="http://code.google.com/android/kb/commontasks.html" rel="noreferrer">http://code.google.com/android/kb/commontasks.html</a></p> <p>I got my environment and emulator up and running within about 15 minutes.</p> <p>First impressions are its fun to work with. </p> <p>Paul</p>
<p>I'm also beginning to get my feet wet with android development. Honestly, I think some of the books out there do a pretty good job of explaining the development framework and getting you started with using the tools quickly. Some of the books I'm reading include "Teach Yourself Android Application Development in 24 ...
34,899
<p>We mostly tend to following the above best practice.</p> <p>Have a look at <a href="https://stackoverflow.com/questions/73883/string-vs-stringbuilder">String vs StringBuilder</a></p> <p>But StringBuilder could throw <strong>OutOfMemoryException even when there is sufficient memory available</strong>. It throws OO...
<p>The underyling string you create will also need a contiguous block of memory because it is represented as an array of chars (arrays require contiguous memory) . If the StringBuilder throws an OOM exception you woludn't be able to build the underlying without it.</p> <p>If creating a string causes an OOM, there is ...
<p>I encountered this exception with very large strings built sucessively with different stringbuilders (which should not have caused a problem as they were declared within anonymous functions), and finally solved it by reusing a single StringBuilder, declared outside of the anonymous function.</p>
47,475
<p>What is the syntax and which namespace/class needs to be imported? Give me sample code if possible. It would be of great help.</p>
<p>Put the following where you need it:</p> <pre><code>System.Diagnostics.Debugger.Break(); </code></pre>
<p>You can use <code>System.Diagnostics.Debugger.Break()</code> to break in a specific place. This can help in situations like debugging a service.</p>
12,980
<p>I have a collection of custom entity objects one property of which is an <code>ArrayList</code> of byte arrays.</p> <p>The custom entity is serializable and the collection property is marked with the following attributes: <code>[XmlArray("Images"), XmlArrayItem("Image",typeof(byte[]))]</code></p> <p>So I serialize...
<p>Depending on exactly what you are doing, there are a variety of options... Investigate the Xml Attributes in System.Xml.Serialization namespace... In particular, check out </p> <p>[XmlArrayItem(ElementName = "")] </p> <p>This goes on the property of a class that is typed as a collection of some kind (I think it ne...
<p>Properties of serializable classes, that are to be serialized, must be Read/Write.</p> <p>In my case above, the ArrayList property to read only, It was returning byte arrays based on a separate function where file names were added to it.</p> <p>Once a setter was written for ArrayList property and the logic tweaked...
38,568
<p>I'm having trouble with this code:</p> <pre><code>NSRect itemFrame; id item; // code to assign item goes here. itemFrame.origin.y -= [item respondsToSelector:@selector(selectedHeight)] ? [item selectedHeight] : [self defaultSelectedHeight]; </code></pre> <p>This is the problematic bit:</p> <pre><code>[item sele...
<p>you want <code>[[item selectedHeight] floatValue]</code>, assuming that the selectedHeight returns an <code>NSNumber</code>.</p>
<p>You need to look at the declaration of your <code>selectedHeight</code> method. The problem is either that the method is returning a pointer to an object (id), or you haven't imported the header file for <code>item</code> in the file that contains the code snippet, so Xcode assumes it's a pointer by default.</p> <p...
39,524
<p>I know that LDAP is used to provide some information and to help facilitate authorization. </p> <p>But what are the other usages of LDAP? </p>
<p>I will focus on why using LDAP, not what is LDAP.</p> <p>The use model is similar like how people use library cards or phonebooks. When you have a task that requires “write/update once, read/query many times”, you might consider using LDAP. LDAP is designed to provide extremely fast read/query performance for a lar...
<p>LDAP is also used to store your credentials in a network security system and retrieve it with your password and decrypted key giving you access to the services.</p>
29,617
<p>What do I need to do to save an image my program has generated (possibly from the camera, possibly not) to the system photo library on the iPhone?</p>
<p>You can use this function:</p> <pre><code>UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo); </code></pre> <p>You only need <strong>completionTarget</strong>,...
<p>You can use this</p> <pre><code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ UIImageWriteToSavedPhotosAlbum(img.image, nil, nil, nil); }); </code></pre>
21,573
<p>It seems as if making the clipboard ring appear in the VS2008 toolbox is pretty elusive. Does anyone know how to turn this on ? <kbd>Ctrl</kbd>-<kbd>Shift</kbd>-<kbd>V</kbd> works fine, but I'd like to see what on the ring.</p>
<p>You should give <a href="http://ditto-cp.sourceforge.net/" rel="nofollow noreferrer">Ditto</a> a try. It saves everything you put in your clipboard into an sqlite database. A shortcut pops it up and shows the history of your clippings. </p> <p>The nice thing is that you can instantly search in this window through a...
<p>If you drag text to the toolbox doesn't it appear?</p>
10,023
<p>I've opened the <strong>cmd in windows</strong> and I've created a directory by using <code>md</code> command. After that I've opened a text file via <code>notepad &lt;name&gt;</code>, wrote my program and gave <code>.c</code> extention while saving the file.</p> <p>How can I compile and run my C program to get an ...
<p>Free (beer-free, not necessarily speech-free) C compilers for Windows include (from memory so there may be others):</p> <ul> <li>MinGW (Minimalist GNU for Windows)</li> <li>MSYS</li> <li>Cygwin</li> <li>Eclipse CDT (which uses GNU under the covers I think)</li> <li>Borland C++ (from their BDN museum site)</li> <li>...
<p>I would recommend if there is no reason to use MS windows, try linux.</p> <p><a href="http://www.ubuntu.com/testing/intrepid/beta" rel="nofollow noreferrer">http://www.ubuntu.com/testing/intrepid/beta</a></p> <p>The development environment is free.</p>
28,325
<p>I have a Google Web Toolkit (GWT) application and when I link to it, I want to pass some arguments/parameters that it can use to dynamically retrieve data. E.g. if it were a stock chart application, I would want my link to contain the symbol and then have the GWT app read that and make a request to some stock servi...
<p>If you want to read query string parameters from the request you can use the <strong>com.google.gwt.user.client.Window</strong> class:</p> <pre><code>// returns whole query string public static String getQueryString() { return Window.Location.getQueryString(); } // returns specific parameter public static St...
<p>It is also a nice option to 'parameterize' a GWT application using hash values. </p> <p>So, instead of</p> <pre><code> http://myapp/gwt/StockChart?symbol=GOOG </code></pre> <p>use</p> <pre><code> http://myapp/gwt/StockChart#symbol=GOOG </code></pre> <p>There is some nice tooling support for such 'parameters' th...
14,838
<p>I'm trying to print a calibration cube from PLA using a 70&nbsp;&deg;C heated build platform on a Prusa i3 Pro W. This results in:</p> <p><a href="https://i.stack.imgur.com/G00Um.jpg)" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G00Um.jpg)" alt="Calibration cube print failed"></a></p> <p>Please e...
<p>There are multiple issues that cause this result.</p> <p>First, your nozzle is to far from the bed. This can be seen by the curly deposited filament on the build plate (I guess that is the brim or the skirt). Please properly level the bed and position the nozzle at a distance of a plain A4 paper as best as possible...
<p>The layer shift can also be caused by the stepper motor "skipping" when it hits an obstruction. The obstruction can be a loop or ridge of filament sticking up higher than it should be.</p> <p>As Oscar suggests, the first step is always to make the first-layer-thickness be right. This is often called "bed leveling...
1,252
<p>Can the GT2 belts lengthen themselves if they are tentioned too much?</p> <p>I had them tensioned quite a bit until I saw the <a href="https://youtu.be/zoKmmT0a7jk" rel="nofollow noreferrer">video</a> from &quot;Lost in Tech&quot;. I then decided to reduce the tension, but the dimensional precision was all over the ...
<p>First of all there are two methods to achieve the belt be tensioned.</p> <p>First method is when both ends of the belt hard attached. In this case if there is a fluctuation in the mechanical system then it will be absorbed by the belt itself. And in this case with big tension it will result in stretching over time w...
<p>As I've seen in todays video from Makers Muse, he also says that these belts can lengthen over time: <div class="youtube-embed"><div> <iframe width="640px" height="395px" src="https://www.youtube.com/embed/-cm1vIER_bk?start=338"></iframe> </div></div> (Link with time code)</p>
2,141
<p>What is the best (cleanest, most efficient) way to write saturating addition in C?</p> <p>The function or macro should add two unsigned inputs (need both 16- and 32-bit versions) and return all-bits-one (0xFFFF or 0xFFFFFFFF) if the sum overflows.</p> <p>Target is x86 and ARM using gcc (4.1.2) and Visual Studio (f...
<p>You probably want portable C code here, which your compiler will turn into proper ARM assembly. ARM has conditional moves, and these can be conditional on overflow. The algorithm then becomes: add and conditionally set the destination to unsigned(-1), if overflow was detected.</p> <pre class="lang-c prettyprint-over...
<p>Using C++ you could write a more flexible variant of <em>Remo.D</em>'s solution:</p> <pre><code>template&lt;typename T&gt; T sadd(T first, T second) { static_assert(std::is_integral&lt;T&gt;::value, "sadd is not defined for non-integral types"); return first &gt; std::numeric_limits&lt;T&gt;::max() - second...
14,747
<p>One of the things mentioned recently maybe in the SO podcast or Joel was that the best way to succeed at business when you start out is to start specialised and concentrate on one thing only.</p> <p>If you say you're the jack of all trades; you're just another jack! If you say you're a specialist in - I think joels...
<p>I'd guess that most people choose a reason (interest, money) to head in a particular direction at the beginning of their careers, and the rest is largely serendipitous.</p> <p>I still try to keep a broad general knowledge across the technologies related to my current and imminent responsibilities (and those of my f...
<p>For people just starting out in the business it probably makes sense to specialize, cause they need something in order to compete. </p> <p>For more experienced developers I agree with what The Pragmatic Programmer book suggests, namely that as a professional developer, you should always try to add more useful tools...
48,952